Advertisement
jamboljack

Jumlah Notifikasi Informasi

Jan 27th, 2019
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. public function jumlahnotifikasi_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.         } elseif ($level == '') {
  12.             $response = [
  13.                 'resp_error' => true,
  14.                 'resp_msg'   => 'Level tidak diketahui.',
  15.             ];
  16.         } else {
  17.             if ($level == 'Member') {
  18.                 $this->db->select('count(notifikasi_id) as jumlah');
  19.                 $this->db->from('lemlit_notifikasi');
  20.                 $this->db->where('notifikasi_status', 1);
  21.                 $this->db->where('user_username', $username);
  22.                 $this->db->where('notifikasi_level', 'Member');
  23.             } else {
  24.                 $this->db->select('count(notifikasi_id) as jumlah');
  25.                 $this->db->from('lemlit_notifikasi');
  26.                 $this->db->where('notifikasi_status', 1);
  27.                 $this->db->where('notifikasi_level', 'Admin');
  28.             }
  29.  
  30.             $total = $this->db->get()->row();
  31.  
  32.             $response = [
  33.                 'resp_error' => false,
  34.                 'resp_msg'   => 'success',
  35.                 'total'      => number_format($total->jumlah, 0, '', ','),
  36.             ];
  37.         }
  38.  
  39.         $this->response($response, 200);
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement