Advertisement
jamboljack

List Detail Ticket

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