Hello
sorry for my bad english. i really need help
i am creating a simple help desk and i have one question please answer me.
1: go to new ticket ( ex: localhost/helpdesk/index.php/ticket/show/10 ).
for number 1 i have a function ( public show ) and display all replies in id 10.
2: and show/10 has a form for reply your comment. ( screenshot :
http://s6.uplod.ir/i/00880/op3jnntpy1lu.jpg )
then i need validation form when users submit new reply. i wrote validation rules, but i can't pass message error from controller to view (ticket/show/id).
PHP Code:
public function show()
{
$show = array();
$id = $this->uri->segment('3');
$groups_id = $this->ticket_model->get_groups_id($id);
$show['show_ticket'] = $this->ticket_model->show($id, $groups_id);
foreach ($show['show_ticket'] as $show_value){
$show_gorup_id = $show_value['department_id'];
$create_by_id = $show_value['user_id'];
}
$show['show_ticket_comment'] = $this->ticket_model->get_reply($id);
foreach ($this->aauth->get_user_groups() as $user_groups) {
$user_groups_id = $user_groups->id;
}
if (($this->aauth->is_member('Admin')) ||($user_groups_id == $show_gorup_id) || ($create_by_id == $this->aauth->get_user_id())) {
$this->template->load('ticket/show_ticket', $show);
}else{
echo 'Access Denied';
}
}
PHP Code:
public function reply()
{
$this->form_validation->set_rules('comment','Comment','required|trim');
if($this->form_validation->run() == FALSE){
$ticket_id = $this->input->post('ticket_id');
//$show['show_ticket_comment'] = $this->ticket_model->get_reply($ticket_id);
// $this->template->load('ticket/show/'.$ticket_id,array('errors' => validation_errors('','<br />')));
// return;
// what code needs here ??????
}else{
if($_FILES['userfile']){
$this->load->library('upload', $config);
//$this->upload->initialize($config);
if($this->upload->do_upload('userfile')){
$config['upload_path'] = './file_ticket';
$config['allowed_types'] = 'gif|jpg|png|jpeg|pdf|doc|docx|txt';
$config['max_size'] = 4000;
$config['max_width'] = 11024;
$config['max_height'] = 7168;
$upload_data = $this->upload->data();
$file_name = $upload_data['file_name'];
$reply_ticket['ticket_comment_id'] = '';
$reply_ticket['ticket_id'] = $this->input->post('ticket_id');
$reply_ticket['user_id'] = $this->aauth->get_user_id();
$reply_ticket['comment'] = $this->input->post('comment');
$reply_ticket['create_date'] = now();
$reply_ticket['file'] = $file_name;
$insert_ticket_comment = $this->ticket_model->reply($reply_ticket);
if ($insert_ticket_comment){
$show = array();
$id = $this->input->post('ticket_id');
$groups_id = $this->ticket_model->get_groups_id($id);
$show['show_ticket'] = $this->ticket_model->show($id, $groups_id);
redirect('ticket/show/'.$id);
}
}else{
// $error = array('error' => $this->upload->display_errors());
echo '11';
// $this->load->view('show_ticket', $error);
}
}else{print_r($_POST);}
}
}