سلام
دوستان من مشکل خیلی جدی دارم
در حال ساخت سیستم مدیریت تیکتم. اول از طریق فانکشن show وارد صفجه یک تیکت خاص میشیم و یکسری اطلاعات از دیتابیس گرفته میشه.
از همون صفحه که بخوایم reply انجام بدیم ارد فانکشن reply میشم. اینجا میخوام اگر validation ناموفق بود برگرده به همون صفجه show که داشتیم پاسخ تیکت را میدادیم ( ticket/show_ticket/6 ) و خطا نمایش بده
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';
}
}
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;
}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);}
}
}