Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isi() {
- // $data_chat = [
- // "status_buka" => 1
- // ];
- // $update_chat = $this->db->where('dari_dinas_ID', Request('kepada_user_ID'))
- // ->where('kepada_dinas_ID', Session("user_ID"))
- // ->where('judul', 'chat')
- // ->update('notifikasi', $data_chat);
- $query_header = $this->db
- ->select("u.ID as user_ID, u.dinas_ID, u.nama,IF(DATE_SUB(NOW(),INTERVAL 1 HOUR) < u.modified_at,1,0) AS online,
- CONCAT(
- FLOOR((SUBSTRING_INDEX(TIMEDIFF(NOW(), u.modified_at), ':', 1))/24), ' days ',
- MOD(SUBSTRING_INDEX(TIMEDIFF(NOW(), u.modified_at), ':', 1), 24) , ' hours ',
- 0+SUBSTRING_INDEX(SUBSTRING_INDEX(TIMEDIFF(NOW(), u.modified_at), ':', 2), ':', -1), ' minutes '
- ) AS last_seen,
- IF(
- (SELECT file_path FROM ".DB_PREFIX."foto where table_name = 'user' and table_ID=u.ID) is null,
- '".BASE_ASSETS."/images/gallery/user.png',
- REPLACE(
- (SELECT file_path FROM ".DB_PREFIX."foto where table_name = 'user' and table_ID=u.ID),'./assets','".BASE_ASSETS."')
- ) as foto,
- FLOOR((SUBSTRING_INDEX(TIMEDIFF(NOW(), u.modified_at), ':', 1))/24) as days ,
- MOD(SUBSTRING_INDEX(TIMEDIFF(NOW(), u.modified_at), ':', 1), 24) as hours,
- 0+SUBSTRING_INDEX(SUBSTRING_INDEX(TIMEDIFF(NOW(), u.modified_at), ':', 2), ':', -1) as minutes")
- // ->where("u.dinas_ID", Request('kepada_user_ID'))
- ->where("u.ID", Request('kepada_user_ID'))
- ->where("u.dinas_ID","d.ID",false)
- ->get("user u, dinas d")->row();
- $query_chat = $this->db->query("SELECT * FROM akt_bpkad_chat WHERE dari_user_ID = '".Session('user_ID')."' AND kepada_user_ID = '".request('kepada_user_ID')."' OR dari_user_ID = '".request('kepada_user_ID')."' AND kepada_user_ID = '".Session('user_ID')."' ")->result();
- $isi_chat = '<li class="center-align pt-2 pb-2 sidenav-close chat-head">
- <a href="#!"><i class="material-icons mr-0">chevron_left</i>'.$query_header->nama.'</a>
- </li>
- <li class="chat-body">
- <ul class="collection">';
- foreach($query_chat as $row_chat) {
- $date = date('H:i A', strtotime($row_chat->created_at));
- if($row_chat->dari_user_ID == Session('user_ID')) {
- $isi_chat .= '<li class="collection-item display-flex avatar justify-content-end pl-5 pb-0" data-target="slide-out-chat">
- <div class="user-content speech-bubble-right">
- <p class="medium-small">'.$row_chat->isi.'</p>
- <p style="font-size:9px; color:#E6E6E6; float:right">'.$date.'</p>
- </div>
- </li>';
- } else {
- $isi_chat .= '<li class="collection-item display-flex avatar pl-5 pb-0" data-target="slide-out-chat">
- <span class="avatar-status avatar-online avatar-50">
- <img src="'.$query_header->foto.'" alt="avatar" />
- </span>
- <div class="user-content speech-bubble">
- <p class="medium-small">'.$row_chat->isi.'</p>
- <p style="font-size:9px; color:#3e51b5; float:right">'.$date.'</p>
- </div>
- </li>';
- }
- }
- $isi_chat .= '</ul>';
- echo $isi_chat;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement