jamboljack

List Unread Petugas

Sep 9th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. public function listunreadpetugas_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.             $this->db->where('notifikasi_level', $level);
  18.             $this->db->where('notifikasi_status', 1);
  19.             $this->db->from('bpmppt_notifikasi');
  20.             $total = $this->db->count_all_results();
  21.  
  22.             if ($total > 0) {
  23.                 $response = [
  24.                     'resp_error' => false,
  25.                     'jumlah'     => $total,
  26.                 ];
  27.             } else {
  28.                 $response = [
  29.                     'resp_error' => false,
  30.                     'resp_msg'   => 'Tidak Ada Data Notifikasi.',
  31.                 ];
  32.             }
  33.         }
  34.  
  35.         $this->response($response, 200);
  36.     }
Add Comment
Please, Sign In to add comment