Skip to content

Commit 738b1ca

Browse files
committed
✨ Introduce online mode offline reasons with auto-assign and transfer restrictions
🆕 Offline reasons gain a `mode` field ("Offline Mode" default, "Online mode"), letting operators pick a reason such as "Training" and stay online instead of going offline: - 🟢 Online mode reasons keep `hide_online = 0`, store the reason on the operator, and start a new online session record (reason stored in the new `online_reason_id` column so `offline_reason_id` is not overwritten). - ⏱️ Switching reason while online starts a new record but closes the previous one exactly at the new record start, so online hours shows no bogus "sync timeout" gap (zero length gaps are no longer rendered). - 🔁 Re-selecting the same online mode reason does not create another session record; switching back to plain online clears the reason. - 📊 Online hours statistics now show both the offline and the online reason. 🔒 Reason enforced restrictions: - 🚫 `disable_auto_assign`: while online with such a reason the operator's `exclude_autoasign` / `exclude_autoasign_mails` department flags are set so chat/mail auto assignment skips him; the operator's own preference is restored when he switches away. - 🔀 `disable_transfer`: blocks manual chat/mail transfer and owner change to that operator while this mode is active. - 👥 `syncAutoAssignStatus` / `isTransferDisabled` helpers applied in setoffline, setopstatus, transferuser modules. 🛠️ Supporting changes: - 🗄️ Added `update_361.sql`, `structure.json`, `db.dbml`, install scripts and POS definitions for the three new `lh_abstract_offline_reason` columns and `lh_users_online_session.online_reason_id`. - ⬆️ Bumped `DB_VERSION` to 361 and `LHC_RELEASE` to 496, updated `CHANGELOG.txt`. - 🖥️ Status control and "Set online status" modal list reasons with their mode, colorize based on active reason, and show online/offline mode groupings in the dropdown. - 📈 `userstats` modal widened to `xxxl` and gained a "Can be auto assigned" column explaining which flags block auto assignment. - 📡 `loadinitialdata` / `setopstatus` expose reason `mode` in the API; `syncadmininterface` reports reason even when the operator is online. 🐛 Misc fixes: - 🔒 Private group chats accept messages/history only from their members (addmessage, loadpreviousmessages).
1 parent 9568b2f commit 738b1ca

31 files changed

Lines changed: 442 additions & 58 deletions

File tree

‎lhc_web/cli/lib/install.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ function step3() {
273273
`lactivity` int(11) NOT NULL,
274274
`type` tinyint(1) NOT NULL DEFAULT '0',
275275
`offline_reason_id` int(11) unsigned NOT NULL DEFAULT 0,
276+
`online_reason_id` int(11) unsigned NOT NULL DEFAULT 0,
276277
`updated_by_user_id` int(11) unsigned NOT NULL DEFAULT 0,
277278
`online_by_user_id` int(11) unsigned NOT NULL DEFAULT 0,
278279
PRIMARY KEY (`id`),
@@ -554,7 +555,7 @@ function step3() {
554555

555556
$db->query("CREATE TABLE `lh_abstract_content_chunk` (`id` bigint(20) NOT NULL AUTO_INCREMENT, `name` varchar(250) NOT NULL, `in_active` tinyint(1) NOT NULL DEFAULT 0, `identifier` varchar(50) NOT NULL, `content` longtext NOT NULL, PRIMARY KEY (`id`), KEY `identifier` (`identifier`, `in_active`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
556557
$db->query("CREATE TABLE `lh_abstract_content_chunk_dep` (`id` bigint(20) NOT NULL AUTO_INCREMENT, `chunk_id` bigint(20) NOT NULL, `dep_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `chunk_id` (`chunk_id`), KEY `dep_id` (`dep_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
557-
$db->query("CREATE TABLE `lh_abstract_offline_reason` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(250) NOT NULL, `description` text NOT NULL, `icon` varchar(250) NOT NULL, `pos` int(11) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
558+
$db->query("CREATE TABLE `lh_abstract_offline_reason` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(250) NOT NULL, `description` text NOT NULL, `icon` varchar(250) NOT NULL, `pos` int(11) unsigned NOT NULL DEFAULT 0, `mode` tinyint(1) NOT NULL DEFAULT 0, `disable_auto_assign` tinyint(1) NOT NULL DEFAULT 0, `disable_transfer` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
558559

559560
$db->query("CREATE TABLE IF NOT EXISTS `lh_cobrowse` (
560561
`id` int(11) NOT NULL AUTO_INCREMENT,

‎lhc_web/design/defaulttheme/css/app.css‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,18 @@ a:not([href]){
19551955
cursor: -webkit-grabbing;
19561956
}
19571957

1958+
/* Wider modal size variations.
1959+
Bootstrap bundle only ships up to .modal-xl (1140px), so define
1960+
reusable bigger sizes here. Use via `$modalSize = 'xxl'` / `'xxxl'`
1961+
in templates that include lhkernel/modal_header.tpl.php. */
1962+
.modal-xxl {
1963+
--bs-modal-width: 1320px;
1964+
}
1965+
1966+
.modal-xxxl {
1967+
--bs-modal-width: 1600px;
1968+
}
1969+
19581970
/* new dashboard options */
19591971
.chats-column {
19601972
flex: 0 0 30%;

‎lhc_web/design/defaulttheme/css/css_static/30dc84470e88171e4fca9847c8266705.css‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lhc_web/design/defaulttheme/css/css_static/520698f54a44f8d39fb59228eb9aa54c.css‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lhc_web/design/defaulttheme/css/css_static/df02810f25cccd650d034c5d99fa1fb5.css‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lhc_web/design/defaulttheme/js/svelte/public/build/main.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lhc_web/design/defaulttheme/js/svelte/public/build/main.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lhc_web/design/defaulttheme/js/svelte/src/LinkActions/ChangeOnlineStatus.svelte‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
}
1616
}
1717
18-
function goOnline(e) {
18+
function goOnline(e, reasonId) {
1919
if (e) {
2020
e.stopPropagation();
2121
e.preventDefault();
2222
}
23-
updateSettings({store: lhcList, attr: 'hideOnline', setVal: false, url: 'user/setoffline/false', setAttrs: {offlineReasonId: 0}});
23+
reasonId = reasonId || 0;
24+
updateSettings({store: lhcList, attr: 'hideOnline', setVal: false, url: 'user/setoffline/false' + (reasonId > 0 ? '/(reason)/' + reasonId : ''), setAttrs: {offlineReasonId: reasonId}});
2425
}
2526
2627
function goOffline(e, reasonId) {
@@ -48,7 +49,9 @@
4849
export let show_text = false;
4950
export let css_class = "nav-link";
5051
51-
$: offlineReasonName = $lhcList.hideOnline && $lhcList.offlineReasonId ? ($lhcList.offlineReasons.find(r => r.id === $lhcList.offlineReasonId) || {}).name || '' : '';
52+
$: activeReason = $lhcList.offlineReasonId ? ($lhcList.offlineReasons.find(r => r.id === $lhcList.offlineReasonId) || null) : null;
53+
$: onlineModeReasons = $lhcList.offlineReasons.filter(r => r.mode === 1);
54+
$: offlineModeReasons = $lhcList.offlineReasons.filter(r => r.mode !== 1);
5255
5356
const handleKeydown = (event) => {
5457
if (enable_shortcut) {
@@ -62,11 +65,11 @@
6265
{#if $lhcList.offlineReasons.length > 0}
6366
<div class="dropdown">
6467
<a href={'#'} class={css_class + ' dropdown-toggle'} data-bs-toggle="dropdown" aria-expanded="false">
65-
<i id="online-offline-user" class={"material-icons " + ($lhcList.hideOnline === true ? 'text-danger' : 'text-success')} title={$t("homepage.change_online_status")}>
68+
<i id="online-offline-user" class={"material-icons " + ($lhcList.hideOnline === true ? 'text-danger' : (activeReason ? 'text-warning' : 'text-success'))} title={$t("homepage.change_online_status")}>
6669
{$lhcList.hideOnline == true ? 'flash_off' : 'flash_on'}
6770
</i>
68-
{#if $lhcList.hideOnline && offlineReasonName}
69-
<span class="ms-1 small">{offlineReasonName}</span>
71+
{#if activeReason}
72+
<span class="ms-1 small">{activeReason.name}</span>
7073
{/if}
7174
{#if show_text}
7275
{#if $lhcList.hideOnline == true}
@@ -77,15 +80,22 @@
7780
{/if}
7881
</a>
7982
<ul class="dropdown-menu">
80-
{#if $lhcList.hideOnline}
83+
{#if $lhcList.hideOnline || activeReason}
8184
<li><a href={'#'} class="dropdown-item" on:click={goOnline}>
8285
<i class="material-icons text-success">flash_on</i> {$t("homepage.status_online")}
8386
</a></li>
87+
{/if}
88+
{#each onlineModeReasons as reason}
89+
<li><a href={'#'} class={"dropdown-item" + (!$lhcList.hideOnline && reason.id === $lhcList.offlineReasonId ? ' fw-bold' : '')} title={reason.desc || ''} on:click={(e) => goOnline(e, reason.id)}>
90+
<i class="material-icons text-success">{reason.icon || 'flash_on'}</i>{reason.name}
91+
</a></li>
92+
{/each}
93+
{#if onlineModeReasons.length > 0 && offlineModeReasons.length > 0}
8494
<li><hr class="dropdown-divider"></li>
8595
{/if}
86-
{#each $lhcList.offlineReasons as reason}
96+
{#each offlineModeReasons as reason}
8797
<li><a href={'#'} class={"dropdown-item" + ($lhcList.hideOnline && reason.id === $lhcList.offlineReasonId ? ' fw-bold' : '')} title={reason.desc || ''} on:click={(e) => goOffline(e, reason.id)}>
88-
<i class="material-icons">{reason.icon || 'flash_off'}</i>{reason.name}
98+
<i class="material-icons text-danger">{reason.icon || 'flash_off'}</i>{reason.name}
8999
</a></li>
90100
{/each}
91101
</ul>

‎lhc_web/design/defaulttheme/tpl/lhstatistic/onlinehours.tpl.php‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
<th width="1%">ID</th>
99
<th><span class="material-icons">person</span><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Username');?></th>
1010
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Start activity');?></th>
11+
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Online reason');?></th>
1112
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Last activity');?></th>
12-
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Duration');?></th>
1313
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Offline reason');?></th>
14+
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Duration');?></th>
1415
<th><span class="material-icons text-danger">supervisor_account</span><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Set offline by');?></th>
1516
<th><span class="material-icons text-success">supervisor_account</span><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Set online by');?></th>
1617
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Chats served');?></th>
@@ -19,14 +20,15 @@
1920
<?php $parentItem = null;?>
2021

2122
<?php foreach ($items as $item) : ?>
22-
<?php if (isset($input->user_id) && is_array($input->user_id) && !empty($input->user_id) && is_object($parentItem)) : ?>
23+
<?php $gapSeconds = is_object($parentItem) ? $parentItem->time - $item->lactivity : 0; ?>
24+
<?php if (isset($input->user_id) && is_array($input->user_id) && !empty($input->user_id) && is_object($parentItem) && $gapSeconds > 0) : ?>
2325
<tr>
2426
<td colspan="4">
2527
</td>
2628
<td colspan="1">
2729
<div class="text-danger" title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Was offline for');?>"><b><?php echo erLhcoreClassChat::formatSeconds($parentItem->time - $item->lactivity)?></b>&nbsp;<?php if ($item->type == erLhcoreClassModelUserOnlineSession::OFFLINE) :?><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Went offline');?><?php else : ?><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Sync timeout');?><?php endif; ?></div>
2830
</td>
29-
<td colspan="4">
31+
<td colspan="5">
3032
<?php if ( $item->chatsOffline > 0) : ?>
3133
<a class="text-danger" href="<?php echo erLhcoreClassDesign::baseurl('chat/list')?>/(user_ids)/<?php echo $item->user_id?>/(timeto_seconds)/<?php echo date('s',$parentItem->time)?>/(timeto_minutes)/<?php echo date('i',$parentItem->time)?>/(timeto_hours)/<?php echo date('H',$parentItem->time)?>/(timeto)/<?php echo date('Y-m-d',$parentItem->time)?>/(timefrom)/<?php echo date('Y-m-d',$item->lactivity)?>/(timefrom_hours)/<?php echo date('H',$item->lactivity)?>/(timefrom_minutes)/<?php echo date('i',$item->lactivity)?>/(timefrom_seconds)/<?php echo date('s',$item->lactivity)?>" target="_blank"><span class="material-icons">open_in_new</span> <?php echo $item->chatsOffline?></a>
3234
<?php endif; ?>
@@ -37,9 +39,10 @@
3739
<td><?php echo $item->id?></td>
3840
<td title="<?php echo htmlspecialchars($item->user_id)?>"><?php echo htmlspecialchars($item->user_name)?></td>
3941
<td><?php echo htmlspecialchars($item->time_front)?>&nbsp;<?php if ($item->type == erLhcoreClassModelUserOnlineSession::ONLINE) : ?><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Went online');?><?php endif; ?></td>
42+
<td><?php echo htmlspecialchars($item->online_reason_name)?></td>
4043
<td><?php echo htmlspecialchars($item->lactivity_front)?>&nbsp;<?php if ($item->type == erLhcoreClassModelUserOnlineSession::OFFLINE) :?><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Went offline');?><?php endif; ?></td>
41-
<td><?php echo $item->duration_front?></td>
4244
<td><?php echo htmlspecialchars($item->offline_reason_name)?></td>
45+
<td><?php echo $item->duration_front?></td>
4346
<td title="<?php echo htmlspecialchars($item->updated_by_user_id)?>"><?php echo htmlspecialchars($item->updated_by_user_name)?></td>
4447
<td title="<?php echo htmlspecialchars($item->online_by_user_id)?>"><?php echo htmlspecialchars($item->online_by_user_name)?></td>
4548
<td>

‎lhc_web/design/defaulttheme/tpl/lhstatistic/userstats.tpl.php‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$modalHeaderClass = 'pt-1 pb-1 ps-2 pe-2 ';
33
$modalHeaderTitle = erTranslationClassLhTranslation::getInstance()->getTranslation('statistic/departmentstats','Statistic');
44
$modalBodyClass = 'p-1';
5-
$modalSize = 'xl';
5+
$modalSize = 'xxxl';
66
?>
77
<?php include(erLhcoreClassDesign::designtpl('lhkernel/modal_header.tpl.php'));?>
88
<div class="modal-body" ng-non-bindable>
@@ -83,6 +83,7 @@
8383
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('statistic/departmentstats','Department group');?></th>
8484
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('statistic/departmentstats','Assignment type');?></th>
8585
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('statistic/departmentstats','Read only');?></th>
86+
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('statistic/departmentstats','Can be auto assigned');?></th>
8687
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('statistic/departmentstats','Exclude from auto assign workflow');?></th>
8788
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('statistic/departmentstats','Chat priority queue');?></th>
8889
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('statistic/departmentstats','Standard queue priority');?></th>
@@ -135,6 +136,29 @@
135136
<span class="text-success"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('statistic/departmentstats','No');?></span>
136137
<?php endif; ?>
137138
</td>
139+
<td nowrap="nowrap">
140+
<?php
141+
// Flags which prevent this department record from receiving an auto assigned chat
142+
$autoAssignBlockedBy = array();
143+
if ((int)$operator['hide_online'] === 1) {
144+
$autoAssignBlockedBy[] = 'hide_online';
145+
}
146+
if ((int)$operator['exclude_autoasign'] === 1) {
147+
$autoAssignBlockedBy[] = 'exclude_autoasign';
148+
}
149+
if ((int)$operator['exc_indv_autoasign'] === 1) {
150+
$autoAssignBlockedBy[] = 'exc_indv_autoasign';
151+
}
152+
if ((int)$operator['ro'] === 1) {
153+
$autoAssignBlockedBy[] = 'ro';
154+
}
155+
?>
156+
<?php if (empty($autoAssignBlockedBy)) : ?>
157+
<span class="material-icons text-success" title="<?php echo htmlspecialchars(erTranslationClassLhTranslation::getInstance()->getTranslation('statistic/departmentstats','Can be auto assigned'))?>">done</span>
158+
<?php else : ?>
159+
<span class="material-icons text-danger" title="<?php echo htmlspecialchars(erTranslationClassLhTranslation::getInstance()->getTranslation('statistic/departmentstats','Can not be auto assigned') . ': ' . implode(', ', $autoAssignBlockedBy))?>">block</span>
160+
<?php endif; ?>
161+
</td>
138162
<td>
139163
<?php if ($operator['exclude_autoasign'] == 1 || $operator['exc_indv_autoasign'] == 1) : ?>
140164
<span class="text-danger">

0 commit comments

Comments
 (0)