Advertisement
jamboljack

List Notifikasi Petugas

Sep 9th, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. public function listnotifikasipetugas_post()
  2.     {
  3.         $username = trim($this->post('username'));
  4.         $level    = trim($this->post('level'));
  5.  
  6.         if ($username == '') {
  7.             $response = [
  8.                 'resp_error' => true,
  9.                 'resp_msg'   => 'Username Kosong.',
  10.             ];
  11.         } else if ($level == '') {
  12.             $response = [
  13.                 'resp_error' => true,
  14.                 'resp_msg'   => 'Level Kosong.',
  15.             ];
  16.         } else {
  17.             $listNotifikasi = $this->db->get_where('bpmppt_notifikasi', array('notifikasi_level' => $level))->result();
  18.             if (count($listNotifikasi) > 0) {
  19.                 foreach ($listNotifikasi as $r) {
  20.                     $response['items'][] = [
  21.                         'resp_error'             => false,
  22.                         'notifikasi_id'          => $r->notifikasi_id,
  23.                         'notifikasi_no_register' => trim($r->notifikasi_no_register),
  24.                         'notifikasi_date'        => date('d-m-Y', strtotime($r->notifikasi_date)),
  25.                         'notifikasi_level'       => trim($r->notifikasi_level),
  26.                         'notifikasi_desc'        => trim($r->notifikasi_desc),
  27.                         'notifikasi_status'      => ($r->notifikasi_status == 1 ? 'Unread' : 'Read'),
  28.                     ];
  29.                 }
  30.             } else {
  31.                 $response = [
  32.                     'resp_error' => false,
  33.                     'resp_msg'   => 'Tidak Ada Notifikasi.',
  34.                 ];
  35.             }
  36.         }
  37.         $this->response($response, 200);
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement