Advertisement
abdurahman_argoebie

function notifikasi

Oct 5th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.50 KB | None | 0 0
  1. function notifikasi(){
  2.                   $this->db->select("judul, keterangan, link, icon, CONCAT(
  3.                         FLOOR((SUBSTRING_INDEX(TIMEDIFF(NOW(), created_at), ':', 1))/24), ' days ',
  4.                         MOD(SUBSTRING_INDEX(TIMEDIFF(NOW(), created_at), ':', 1), 24) , ' hours ',
  5.                         0+SUBSTRING_INDEX(SUBSTRING_INDEX(TIMEDIFF(NOW(), created_at), ':', 2), ':', -1), ' minutes '      
  6.                     ) AS created_at");
  7.                    
  8.         // $query              = $this->db->get_where("notifikasi",["status_buka"=>"0","kepada_dinas_ID" => Session("dinas_ID")]);
  9.         $query       = $this->db->where("status_buka", 0)
  10.                        ->where("kepada_dinas_ID", Session("dinas_ID"))
  11.                        ->where("judul !=", "chat")
  12.                        ->get('notifikasi');
  13.         $query_chat  = $this->db->get_where("notifikasi",["status_buka"=>"0","kepada_dinas_ID" => Session("user_ID"), "judul" => "chat"]);
  14.        
  15.         // $query_name_sender = $this->db->get_where("notifikasi",["status_buka"=>"0","kepada_dinas_ID" => Session("user_ID"), "judul" => "chat"])->row_array();
  16.         // $test = $query_name_sender['dari_dinas_ID'];
  17.         // $get_name_sender   = $this->db->get_where("user", ["ID" => $test])->row_array();
  18.        
  19.         $total_nofitikasi_baru = $query->num_rows();
  20.         $total_nofitikasi_chat_baru = $query_chat->num_rows();
  21.  
  22.         $data['notification_badge'] = $total_nofitikasi_baru;
  23.         $data['chat_badge']         = $total_nofitikasi_chat_baru;
  24.  
  25.         $data['item'] = '<li><h6>NOTIFICATIONS<span class="new badge">'.$total_nofitikasi_baru.'</span></h6></li><li class="divider"></li>';
  26.        
  27.        
  28.         foreach ($query->result() as $row){
  29.             // if($row->judul == "chat") {
  30.             //  $data['item'].= "<li><a class='grey-text text-darken-2 menu' href='".$row->link."'><span class='material-icons icon-bg-circle green small'>".$row->icon."</span> ".substr($row->judul,"0",20)." : dari ".$get_name_sender['nama']."</a><time class='media-meta' datetime='".$row->created_at."'>".$row->created_at."</time></li>";
  31.             //  // $data['item'].= "<li><a class='grey-text text-darken-2 menu' href='".$row->link."'><span class='material-icons icon-bg-circle green small'>".$row->icon."</span> ".substr($row->judul,"0",20)." : Dari</a><time class='media-meta' datetime='".$row->created_at."'>".$row->created_at."</time></li>";
  32.             // } else {
  33.                 $data['item'].= "<li><a class='grey-text text-darken-2 menu' href='".$row->link."'><span class='material-icons icon-bg-circle green small'>".$row->icon."</span> ".substr($row->judul,"0",20)."...</a><time class='media-meta' datetime='".$row->created_at."'>".$row->created_at."</time></li>";
  34.             // }
  35.            
  36.         }
  37.  
  38.         return $data;
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement