Advertisement
jamboljack

List Detail Ticket SIMPEL

Jan 28th, 2019
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.70 KB | None | 0 0
  1. public function listdetailticket_post()
  2.     {
  3.         $username  = trim($this->post('username'));
  4.         $ticket_id = trim($this->post('ticket_id'));
  5.  
  6.         if ($username == '') {
  7.             $response = [
  8.                 'resp_error' => true,
  9.                 'resp_msg'   => 'Username kosong.',
  10.             ];
  11.         } elseif ($ticket_id == '') {
  12.             $response = [
  13.                 'resp_error' => true,
  14.                 'resp_msg'   => 'ID Ticket tidak ditemukan.',
  15.             ];
  16.         } else {
  17.             $detail = $this->db->get_where('v_ticket', array('ticket_id' => $ticket_id))->row();
  18.             // List Pendukung
  19.             $daftarHistory = array();
  20.             $this->db->select('*');
  21.             $this->db->from('v_detail_ticket');
  22.             $this->db->where('ticket_id', $ticket_id);
  23.             $this->db->order_by('detail_id', 'desc');
  24.  
  25.             $listHistory = $this->db->get()->result();
  26.             foreach ($listHistory as $x) {
  27.                 if ($x->detail_image != '') {
  28.                     $attachment = base_url('ticket/' . $x->detail_image);
  29.                 } else {
  30.                     $attachment = '';
  31.                 }
  32.  
  33.                 if ($x->user_avatar != '') {
  34.                     $avatar = base_url('img/icon/' . $x->user_avatar);
  35.                 } else {
  36.                     $avatar = '';
  37.                 }
  38.                 $daftarHistory[] = array(
  39.                     'detail_id'        => $x->detail_id,
  40.                     'detail_level'     => $x->detail_level,
  41.                     'detail_name'      => $x->user_name,
  42.                     'detail_level'     => $x->user_level,
  43.                     'detail_date_post' => date('d-m-Y', strtotime($x->detail_date_post)),
  44.                     'detail_message'   => trim($x->detail_message),
  45.                     'attachment'       => $attachment,
  46.                     'avatar'           => $avatar,
  47.                 );
  48.             }
  49.  
  50.             $response = [
  51.                 'resp_error'       => false,
  52.                 'ticket_id'        => $detail->ticket_id,
  53.                 'ticket_subject'   => trim($detail->ticket_subject),
  54.                 'ticket_status'    => trim($detail->ticket_status),
  55.                 'nama_pemohon'     => trim($detail->user_name),
  56.                 'email_pemohon'    => trim($detail->user_email),
  57.                 'ticket_date_post' => date('d-m-Y', strtotime($detail->ticket_date_post)),
  58.                 'ticket_update'    => date('d-m-Y', strtotime($detail->ticket_date_post)),
  59.                 'data'             => [
  60.                     "listhistory" => $daftarHistory,
  61.                 ],
  62.             ];
  63.         }
  64.  
  65.         $this->response($response, 200);
  66.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement