public function openSessions() { $sessions = \Support\Models\ChatSessions::fetchForAdmin($this->id); return count($sessions); }
<div class="pull-left"> <div class="clearfix"> <a class="btn btn-default" href="./admin/support/live-chat"> Live Chat </a> <span id="unclaimed-sessions" class="poller" data-action="SupportGetUnclaimedSessions"> <?php echo $this->renderView('Support/Admin/Views::livechat/fragment_unclaimed_sessions.php'); ?> </div> </div> </div> <?php /* ?>foreach active admin session, display a tab, right-justified */ foreach ($chat_sessions = \Support\Models\ChatSessions::fetchForAdmin($this->auth->getIdentity()->id) as $chat_session) { ?> <?php $this->app->set('chat_session', $chat_session); $this->app->set('messages', $chat_session->messages); echo $this->renderView('Support/Admin/Views::livechatajax/tab.php'); } ?> <script> jQuery(document).ready(function(){ jQuery('.poller').poller(); }); SupportGetUnclaimedSessions = function(){ jQuery.get( "./admin/support/live-chat/unclaimed-sessions?ping=1", function( data ) { var current_count = jQuery('#unclaimed-sessions-alert').attr('data-count');