Skip to content

Commit

Permalink
Online operators show max chats
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Dec 7, 2021
1 parent 99d4647 commit 8824ac2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 79 deletions.
Expand Up @@ -33,7 +33,9 @@
<td class="align-middle">
<div class="abbr-list" title="{{operator.lastactivity_ago}}">{{operator.lastactivity_ago}}</div>
</td>
<td class="align-middle">{{operator.active_chats}}</td>
<td title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/syncadmininterface','Max');?> - {{operator.max_chats && operator.max_chats > 0 ? operator.max_chats : 'n/a'}} <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/syncadmininterface','chats');?>" ng-class="{'align-middle': true, 'text-danger' : (operator.max_chats && operator.max_chats > 0 && operator.max_chats - operator.active_chats <= 1),'text-success' : (operator.max_chats && operator.max_chats > 0 && operator.max_chats - operator.active_chats > 1)}">
{{operator.active_chats}} <abbr title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/syncadmininterface','Active chats')?>"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/syncadmininterface','a.c')?></abbr>, {{operator.max_chats && operator.max_chats > 0 ? (operator.max_chats - operator.active_chats) : ' n/a'}} <abbr title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/syncadmininterface','Free slots')?>"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/syncadmininterface','f.s')?></abbr>
</td>
<td class="align-middle"><div class="abbr-list" title="{{operator.departments_names.join(', ')}}">{{operator.departments_names.join(", ")}}</div></td>

</tr>
Expand Down
Expand Up @@ -31,6 +31,7 @@ public function getState()
'type' => $this->type,
'dep_group_id' => $this->dep_group_id,
'exclude_autoasign' => $this->exclude_autoasign,
'max_chats' => $this->max_chats,
);
}

Expand Down Expand Up @@ -150,6 +151,7 @@ public static function getOnlineOperators($currentUser, $canListOnlineUsersAll =
$filter['select_columns'] = '
max(`id`) as `id`,
max(`ro`) as `ro`,
max(`max_chats`) as `max_chats`,
max(`dep_id`) as `dep_id`,
max(`hide_online_ts`) as `hide_online_ts`,
max(`hide_online`) as `hide_online`,
Expand Down Expand Up @@ -180,6 +182,7 @@ public static function getOnlineOperators($currentUser, $canListOnlineUsersAll =
public $type = 0;
public $dep_group_id = 0;
public $exclude_autoasign = 0;
public $max_chats = 0;
}

?>
2 changes: 1 addition & 1 deletion lhc_web/modules/lhchat/syncadmininterface.php
Expand Up @@ -621,7 +621,7 @@

$onlineOperators = erLhcoreClassModelUserDep::getOnlineOperators($currentUser,$canListOnlineUsersAll,$filter,is_numeric($Params['user_parameters_unordered']['limito']) ? (int)$Params['user_parameters_unordered']['limito'] : 10,$onlineTimeout);

erLhcoreClassChat::prefillGetAttributes($onlineOperators,array('lastactivity_ago','offline_since','user_id','id','name_official','pending_chats','inactive_chats','active_chats','departments_names','hide_online','avatar'),array(),array('filter_function' => true, 'remove_all' => true));
erLhcoreClassChat::prefillGetAttributes($onlineOperators,array('lastactivity_ago','max_chats','offline_since','user_id','id','name_official','pending_chats','inactive_chats','active_chats','departments_names','hide_online','avatar'),array(),array('filter_function' => true, 'remove_all' => true));

$currentOp = isset($onlineOperators[$userData->id]) ? $onlineOperators[$userData->id] : null;

Expand Down
3 changes: 2 additions & 1 deletion lhc_web/modules/lhrestapi/onlineusers.php
Expand Up @@ -26,11 +26,12 @@
$filter['sort'] = 'active_chats DESC, hide_online ASC';
$filter['group'] = 'user_id';
$filter = array_merge_recursive($filter, $params);
$filter['ignore_fields'] = array('exclude_autoasign','dep_group_id','type','ro','id','dep_id','hide_online_ts','hide_online','last_activity','lastd_activity','always_on','last_accepted','active_chats','pending_chats','inactive_chats');
$filter['ignore_fields'] = array('exclude_autoasign','dep_group_id','type','max_chats','ro','id','dep_id','hide_online_ts','hide_online','last_activity','lastd_activity','always_on','last_accepted','active_chats','pending_chats','inactive_chats');
$filter['select_columns'] = '
max(`id`) as `id`,
max(`dep_id`) as `dep_id`,
max(`ro`) as `ro`,
max(`max_chats`) as `max_chats`,
max(`hide_online_ts`) as `hide_online_ts`,
max(`hide_online`) as `hide_online`,
max(`last_activity`) as `last_activity`,
Expand Down
83 changes: 7 additions & 76 deletions lhc_web/pos/lhdepartament/erlhcoreclassmodeluserdep.php
Expand Up @@ -9,82 +9,13 @@
$def->idProperty->propertyName = 'id';
$def->idProperty->generator = new ezcPersistentGeneratorDefinition( 'ezcPersistentNativeGenerator' );

$def->properties['user_id'] = new ezcPersistentObjectProperty();
$def->properties['user_id']->columnName = 'user_id';
$def->properties['user_id']->propertyName = 'user_id';
$def->properties['user_id']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def->properties['dep_id'] = new ezcPersistentObjectProperty();
$def->properties['dep_id']->columnName = 'dep_id';
$def->properties['dep_id']->propertyName = 'dep_id';
$def->properties['dep_id']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

// Last activity
$def->properties['last_activity'] = new ezcPersistentObjectProperty();
$def->properties['last_activity']->columnName = 'last_activity';
$def->properties['last_activity']->propertyName = 'last_activity';
$def->properties['last_activity']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

// Last dom activity
$def->properties['lastd_activity'] = new ezcPersistentObjectProperty();
$def->properties['lastd_activity']->columnName = 'lastd_activity';
$def->properties['lastd_activity']->propertyName = 'lastd_activity';
$def->properties['lastd_activity']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def->properties['hide_online_ts'] = new ezcPersistentObjectProperty();
$def->properties['hide_online_ts']->columnName = 'hide_online_ts';
$def->properties['hide_online_ts']->propertyName = 'hide_online_ts';
$def->properties['hide_online_ts']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def->properties['hide_online'] = new ezcPersistentObjectProperty();
$def->properties['hide_online']->columnName = 'hide_online';
$def->properties['hide_online']->propertyName = 'hide_online';
$def->properties['hide_online']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def->properties['last_accepted'] = new ezcPersistentObjectProperty();
$def->properties['last_accepted']->columnName = 'last_accepted';
$def->properties['last_accepted']->propertyName = 'last_accepted';
$def->properties['last_accepted']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def->properties['active_chats'] = new ezcPersistentObjectProperty();
$def->properties['active_chats']->columnName = 'active_chats';
$def->properties['active_chats']->propertyName = 'active_chats';
$def->properties['active_chats']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def->properties['pending_chats'] = new ezcPersistentObjectProperty();
$def->properties['pending_chats']->columnName = 'pending_chats';
$def->properties['pending_chats']->propertyName = 'pending_chats';
$def->properties['pending_chats']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def->properties['inactive_chats'] = new ezcPersistentObjectProperty();
$def->properties['inactive_chats']->columnName = 'inactive_chats';
$def->properties['inactive_chats']->propertyName = 'inactive_chats';
$def->properties['inactive_chats']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def->properties['always_on'] = new ezcPersistentObjectProperty();
$def->properties['always_on']->columnName = 'always_on';
$def->properties['always_on']->propertyName = 'always_on';
$def->properties['always_on']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def->properties['ro'] = new ezcPersistentObjectProperty();
$def->properties['ro']->columnName = 'ro';
$def->properties['ro']->propertyName = 'ro';
$def->properties['ro']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def->properties['type'] = new ezcPersistentObjectProperty();
$def->properties['type']->columnName = 'type';
$def->properties['type']->propertyName = 'type';
$def->properties['type']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def->properties['dep_group_id'] = new ezcPersistentObjectProperty();
$def->properties['dep_group_id']->columnName = 'dep_group_id';
$def->properties['dep_group_id']->propertyName = 'dep_group_id';
$def->properties['dep_group_id']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;

$def->properties['exclude_autoasign'] = new ezcPersistentObjectProperty();
$def->properties['exclude_autoasign']->columnName = 'exclude_autoasign';
$def->properties['exclude_autoasign']->propertyName = 'exclude_autoasign';
$def->properties['exclude_autoasign']->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;
foreach (['user_id','dep_id','last_activity','lastd_activity','hide_online_ts','hide_online','last_accepted',
'active_chats','pending_chats','inactive_chats','always_on','ro','max_chats','type','dep_group_id','exclude_autoasign'] as $posAttr) {
$def->properties[$posAttr] = new ezcPersistentObjectProperty();
$def->properties[$posAttr]->columnName = $posAttr;
$def->properties[$posAttr]->propertyName = $posAttr;
$def->properties[$posAttr]->propertyType = ezcPersistentObjectProperty::PHP_TYPE_INT;
}

return $def;

Expand Down

0 comments on commit 8824ac2

Please sign in to comment.