Example #1
0
 public function init()
 {
     $settings = \Support\Models\Settings::fetch();
     if (!$settings->live_chat_enabled) {
         return null;
     }
     if ($this->session->get('support_close_tab') == 1) {
         return null;
     }
     // are there no operators online?
     $operators = \Support\Models\Operators::fetchActive();
     if (empty($operators)) {
         return $this->outputJson($this->getJsonResponse(array('result' => $this->theme->renderView('Support/Site/Views::livechatajax/no_operators.php'))));
     }
     // is a chat session already started/requested?
     $this->app->set('chat_session', null);
     $chat_session = (new \Support\Models\ChatSessions())->setState('filter.user_session', $this->session->id())->getItem();
     if (!empty($chat_session->id)) {
         $this->session->set('support_session_id', (string) $chat_session->id);
         $this->app->set('chat_session', $chat_session);
         $this->app->set('messages', $chat_session->messages);
     }
     // Display the tab
     return $this->outputJson($this->getJsonResponse(array('result' => $this->theme->renderView('Support/Site/Views::livechatajax/init.php'))));
 }
<?php

foreach ($operators = \Support\Models\Operators::fetchActive() as $operator) {
    ?>
<div class="list-group-item">
    <b><?php 
    echo $operator->fullName();
    ?>
</b>
    <p class="help-block"><small><?php 
    echo (int) $operator->openSessions();
    ?>
 open sessions</small></p>
    
    <div class="help-block">
        <div><small>Last active: <?php 
    echo \Dsc\Mongo\Collections\Sessions::ago($operator->last_activity);
    ?>
</small></div>               
    </div>    
</div>
<?php 
}
?>

<?php 
if (empty($operators)) {
    ?>
<div class="list-group-item">
    <p>No online operators</p>
</div>