Returns departments with atleast one logged
public static getLoggedDepartmentsIds ( $departmentsIds, $exclipic = false ) |
header('Content-Type: application/json'); $departmentParams = array(); $userDepartments = erLhcoreClassUserDep::parseUserDepartmetnsForFilter($currentUser->getUserID()); if ($userDepartments !== true) { $departmentParams['filterin']['id'] = $userDepartments; if (!$currentUser->hasAccessTo('lhchat', 'sees_all_online_visitors')) { $filter['filterin']['dep_id'] = $userDepartments; } } $departmentParams['sort'] = 'sort_priority ASC, name ASC'; $departmentNames = array(); $departmentList = array(); $departments = erLhcoreClassModelDepartament::getList($departmentParams); $loggedDepartments = erLhcoreClassChat::getLoggedDepartmentsIds(array_keys($departments), false); $loggedDepartmentsExplicit = erLhcoreClassChat::getLoggedDepartmentsIds(array_keys($departments), true); // Filter products $filterProducts = array(); foreach ($departments as $department) { $departmentNames[$department->id] = $department->name; $departmentList[] = array('id' => $department->id, 'name' => $department->name, 'hidden' => $department->hidden, 'disabled' => $department->disabled == 1, 'ogen' => in_array($department->id, $loggedDepartments), 'oexp' => in_array($department->id, $loggedDepartmentsExplicit)); $filterProducts[] = $department->id; } $productsFilter = array(); // Add products if (!empty($departments)) { $productsFilter['filterin']['departament_id'] = array_keys($departments); } $productsNames = array(); $products = erLhAbstractModelProduct::getList($productsFilter); foreach ($products as $product) {
<h4><span class="label label-success"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/transferchat', 'Online'); ?> </span></h4> <?php $departments = erLhcoreClassModelDepartament::getList(array_merge($departments_filter['filter'], array('sort' => 'sort_priority ASC, name ASC'))); $onlineDepartments = erLhcoreClassChat::getLoggedDepartmentsIds(array_keys($departments), $departments_filter['explicit']); foreach ($departments as $departament) { if ($departament->id !== $departments_filter['dep_id'] && in_array($departament->id, $onlineDepartments)) { ?> <div class="checkbox"><label><input type="radio" name="DepartamentID<?php echo $departments_filter['chat_id']; ?> " value="<?php echo $departament->id; ?> "/> <?php echo htmlspecialchars($departament->name); ?> </label></div> <?php } } ?> <h4><span class="label label-default"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/transferchat', 'Offline'); ?> </span></h4> <?php foreach ($departments as $departament) {