public function reply()
{
$this->form_validation->set_rules('comment','Comment','required|trim');
$ticket_id = $this->input->post('ticket_id');
if($this->form_validation->run() == FALSE){
$error_msg_reply = 'پر کردن شرح درخواست الزامی می باشد';
$error_msg_reply = $this->session->set_flashdata('key',$error_msg_reply);
//$show['show_ticket_comment'] = $this->ticket_model->get_reply($ticket_id);
redirect('ticket/show/'.$ticket_id);
}else{
$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;
$this->load->library('upload', $config);
if(empty($_FILES['userfile'])) {
$reply_ticket['file'] = 'Null';
}else{
$uploaded = $this->upload->do_upload('userfile');
if (!$uploaded) {
$error_msg_reply .= $this->upload->display_errors();
$this->session->set_flashdata('key',$error_msg_reply);
redirect('ticket/show/'.$ticket_id);
} else {
$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);
}
}
}