public function user_with() { $to_id = $this->uri->segment(3); $uid = $this->session->userdata('uid'); $url_chat_both = base_api_url() . "chat/both_chat/fid/" . $uid . "/tid/" . $to_id . base_api_key(); $data['chat_both'] = self::getapi($url_chat_both); $array_both = $data['chat_both']; asort($array_both); //echo "<pre>"; //print_r($array_both); //echo "</pre>"; //exit(); ?> <div class="box box-success direct-chat direct-chat-success"> <div class="box-header with-border"> <h3 class="box-title">Chat</h3> <div class="box-tools pull-right"> <a onclick="javascript:chatWith('<?php echo $to_id; ?> ')" data-toggle="tooltip" title="Chat With User" class='badge bg-green'>Chat</a> <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button> <button class="btn btn-box-tool" data-toggle="tooltip" title="Chat" data-widget="chat-pane-toggle" onclick="javascript:chatWith('<?php echo $to_id; ?> ')"><i class="fa fa-comments"></i></button> <button class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button> </div> </div><!-- /.box-header --> <div class="box-body"> <!-- Conversations are loaded here --> <div class="direct-chat-messages"> <?php $count = count($array_both) - 1; foreach ($array_both as $k => $v) { if ($v['from'] == $uid) { echo "<div class='direct-chat-msg right'>"; echo "<div class='direct-chat-info clearfix'>"; echo "<span class='direct-chat-name pull-right'>" . $v['from_fn'] . "</span>"; echo "<span class='direct-chat-timestamp pull-left'>" . time_dmtmi($v['sent']) . "</span>"; echo "</div>"; echo "<img class='direct-chat-img' src=" . base_url() . 'images/profile/' . $v['from_pimg'] . " alt='message user image' />"; } else { echo "<div class='direct-chat-msg'>"; echo "<div class='direct-chat-info clearfix'>"; echo "<span class='direct-chat-name pull-left'>" . $v['from_fn'] . "</span>"; echo "<span class='direct-chat-timestamp pull-right'>" . time_dmtmi($v['sent']) . "</span>"; echo "</div>"; echo "<img class='direct-chat-img' src=" . base_url() . 'images/profile/' . $v['from_pimg'] . " alt='message user image' />"; } //ELSE COND END echo "<div class='direct-chat-text'>" . $v['message'] . "</div>"; echo "</div>"; } //FOREACH LOOP END ?> </div><!--/.direct-chat-messages--> </div><!-- /.box-body --> </div><!--/.direct-chat --> <?php }
?> <?php //echo $this->session->userdata('uid'); //sort($chat_all); for ($i = 0; $i <= count($chat_all) - 1; $i++) { if ($chat_all[$i]['from'] != $this->session->userdata('uid')) { echo "<tr>"; echo "<td>"; echo $chat_all[$i]['id']; echo "</td>"; echo "<td>"; echo $chat_all[$i]['from']; echo "</td>"; echo "<td>"; echo time_dmtmi($chat_all[$i]['sent']); //echo $chat_all[$i]['to']; echo "</td>"; echo "<td>"; //echo $chat_all[$i]['online']; if ($chat_all[$i]["from_online"] == "1") { echo "<a href='#' onclick='funenter(" . $this->session->set_userdata('from', $chat_all[$i]['from']) . ")'>"; echo '<small class="label label-success"><i class="fa fa-clock-o"></i> Online</small>'; echo "</a>"; } else { echo "<a href='#' onclick='funoffline()'>"; echo '<small class="label label-danger"><i class="fa fa-clock-o"></i> Offline</small>'; echo "</a>"; } echo "</td>"; echo "<td>";