Skip to content

Commit 48d3d8f

Browse files
committed
👥 Add team lead assignment for operators with filtering and statistics support
- 🗄️ Add `team_lead_user_id` column and index to `lh_users` table (migration `update_359.sql`), update installer, db.dbml and structure.json - 🧩 Extend `erLhcoreClassModelUser` with `team_lead_user_id` field, related `team_lead_user` lazy getter and POS mapping so the lead can be resolved and displayed - 📝 Validate team lead input in `lhuservalidator` and support filtering by `team_lead_user_id` in user list search attributes and `lhuser` module - 🎛️ Add team lead multiselect radio dropdown to new/edit user forms under user groups section - 👀 Show read-only team lead info above username on operator account page and add team lead column to user list - 🔎 Add team lead filter to user list search panel and adjust column widths for the new field - 📊 Support team lead filter in agent statistics: extend search attributes, chat statistic filter propagation and `lhstatistic` module routing - 🛠️ Allow customizable optional dropdown label in `erLhcoreClassRenderHelper` via `optional_value_text` - 📝 Bump DB version to 359 and LHC release to 493 and update CHANGELOG with 4.93v notes
1 parent 103ab1b commit 48d3d8f

22 files changed

Lines changed: 196 additions & 26 deletions

File tree

‎lhc_web/cli/lib/install.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,6 +2079,7 @@ function step3() {
20792079
`llogin` bigint(20) unsigned NOT NULL DEFAULT '0',
20802080
`always_on` tinyint(1) NOT NULL DEFAULT '0',
20812081
`offline_reason_id` int(11) unsigned NOT NULL DEFAULT 0,
2082+
`team_lead_user_id` int(11) unsigned NOT NULL DEFAULT 0,
20822083
`exclude_autoasign_mails` tinyint(1) NOT NULL DEFAULT '0',
20832084
`max_active_mails` int(11) NOT NULL DEFAULT '0',
20842085
PRIMARY KEY (`id`),
@@ -2087,6 +2088,7 @@ function step3() {
20872088
KEY `disabled` (`disabled`),
20882089
KEY `email` (`email`),
20892090
KEY `username` (`username`),
2091+
KEY `team_lead_user_id` (`team_lead_user_id`),
20902092
KEY `xmpp_username` (`xmpp_username`(191))
20912093
) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
20922094

‎lhc_web/design/defaulttheme/tpl/lhstatistic/tabs/agentstatistic.tpl.php‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,22 @@
119119
</div>
120120
</div>
121121

122+
<div class="col-md-2">
123+
<div class="form-group">
124+
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Team lead');?></label>
125+
<?php echo erLhcoreClassRenderHelper::renderMultiDropdown( array (
126+
'input_name' => 'team_lead_user_id[]',
127+
'optional_field' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Choose team lead'),
128+
'selected_id' => $input->team_lead_user_id,
129+
'css_class' => 'form-control form-control-sm',
130+
'display_name' => 'name_official',
131+
'ajax' => 'users',
132+
'list_function_params' => array_merge(erLhcoreClassGroupUser::getConditionalUserFilter(),array('sort' => '`name` ASC','limit' => 50)),
133+
'list_function' => 'erLhcoreClassModelUser::getUserList',
134+
)); ?>
135+
</div>
136+
</div>
137+
122138
<div class="col-md-2">
123139
<div class="form-group">
124140
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Department');?></label>
@@ -165,13 +181,13 @@
165181
</div>
166182
</div>
167183

168-
<div class="col-md-2">
184+
<div class="col-md-3">
169185
<div class="form-group">
170186
<label><input type="checkbox" <?php if ($input->has_online_hours == 1) : ?>checked="checked"<?php endif;?> name="has_online_hours" value="1"> <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Only operators who were online during selected period')?></label>
171187
</div>
172188
</div>
173189

174-
<div class="col-md-2">
190+
<div class="col-md-3">
175191
<div class="form-group">
176192
<label><input type="checkbox" <?php if ($input->exclude_deactivated == 1) : ?>checked="checked"<?php endif;?> name="exclude_deactivated" value="1"> <?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Exclude deactivated operators')?></label>
177193
</div>

‎lhc_web/design/defaulttheme/tpl/lhuser/account.tpl.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@
6464

6565
<?php include(erLhcoreClassDesign::designtpl('lhkernel/csfr_token.tpl.php'));?>
6666

67+
<?php $teamLead = $user->team_lead_user; ?>
68+
<?php if ($teamLead instanceof erLhcoreClassModelUser) : ?>
69+
<div class="alert alert-info" role="alert">
70+
<strong><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/account','Your team lead');?>:</strong>
71+
<?php echo htmlspecialchars($teamLead->name_official)?>
72+
</div>
73+
<?php endif; ?>
74+
6775
<div class="form-group">
6876
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/account','Username');?>*</label> <input <?php if (!erLhcoreClassUser::instance()->hasAccessTo('lhuser','change_core_attributes')) : ?>disabled<?php endif?> type="text" ng-non-bindable class="form-control" placeholder="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/account','Your username');?>" name="Username" value="<?php echo htmlspecialchars($user->username);?>" />
6977
</div>

‎lhc_web/design/defaulttheme/tpl/lhuser/edit.tpl.php‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,28 @@
230230
</div>
231231
<?php endif; ?>
232232

233+
<hr>
234+
<div class="form-group">
235+
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/new','Team lead');?></label>
236+
<?php $teamLeadParams = array('limit' => 10, 'sort' => '`name` ASC'); ?>
237+
<?php echo erLhcoreClassRenderHelper::renderMultiDropdown( array (
238+
'input_name' => 'team_lead_user_id',
239+
'optional_field' => erTranslationClassLhTranslation::getInstance()->getTranslation('user/new','Choose team lead'),
240+
'optional_value_text' => erTranslationClassLhTranslation::getInstance()->getTranslation('user/new','None'),
241+
'selected_id' => [(int)$user->team_lead_user_id],
242+
'type' => 'radio',
243+
'data_prop' => 'data-limit="1"',
244+
'css_class' => 'form-control',
245+
'display_name' => 'name_official',
246+
'show_optional' => true,
247+
'no_selector' => true,
248+
'ajax' => 'users',
249+
'wrapper_class' => 'team-lead-dropdown',
250+
'list_function_params' => $teamLeadParams,
251+
'list_function' => 'erLhcoreClassModelUser::getList',
252+
)); ?>
253+
</div>
254+
233255
<hr>
234256
<label><input type="checkbox" value="on" name="UserDisabled" <?php echo $user->disabled == 1 ? 'checked="checked"' : '' ?> />&nbsp;<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/new','Disabled')?></label><br>
235257
<?php endif; ?>
@@ -459,3 +481,9 @@
459481
<?php include(erLhcoreClassDesign::designtpl('lhuser/menu_tabs_content/custom_multiinclude_tab.tpl.php'));?>
460482

461483
</div>
484+
485+
<script>
486+
$(function() {
487+
$('.team-lead-dropdown').makeDropdown();
488+
});
489+
</script>

‎lhc_web/design/defaulttheme/tpl/lhuser/new.tpl.php‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,29 @@
148148
)); ?>
149149
</div>
150150
<?php endif; ?>
151+
152+
<hr>
153+
<div class="form-group">
154+
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/new','Team lead');?></label>
155+
<?php $teamLeadParams = array('limit' => 10, 'sort' => '`name` ASC'); ?>
156+
<?php echo erLhcoreClassRenderHelper::renderMultiDropdown( array (
157+
'input_name' => 'team_lead_user_id',
158+
'optional_field' => erTranslationClassLhTranslation::getInstance()->getTranslation('user/new','Choose team lead'),
159+
'optional_value_text' => erTranslationClassLhTranslation::getInstance()->getTranslation('user/new','None'),
160+
'selected_id' => [(int)$user->team_lead_user_id],
161+
'type' => 'radio',
162+
'data_prop' => 'data-limit="1"',
163+
'css_class' => 'form-control',
164+
'display_name' => 'name_official',
165+
'show_optional' => true,
166+
'no_selector' => true,
167+
'ajax' => 'users',
168+
'wrapper_class' => 'team-lead-dropdown',
169+
'list_function_params' => $teamLeadParams,
170+
'list_function' => 'erLhcoreClassModelUser::getList',
171+
)); ?>
172+
</div>
173+
151174
<hr>
152175
<label>&nbsp;<input type="checkbox" value="on" name="UserDisabled" <?php echo $user->disabled == 1 ? 'checked="checked"' : '' ?> />&nbsp;<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/new','Disabled')?></label><br>
153176

@@ -311,3 +334,8 @@
311334
</div>
312335
</form>
313336

337+
<script>
338+
$(function() {
339+
$('.team-lead-dropdown').makeDropdown();
340+
});
341+
</script>

‎lhc_web/design/defaulttheme/tpl/lhuser/userlist.tpl.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<th width="1%">ID</th>
1515
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Username (Nickname)');?></th>
1616
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','E-mail');?></th>
17+
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Team lead');?></th>
1718
<th title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Maximum number of chats operator can have.');?>"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Number of chats');?></th>
1819
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Last activity');?></th>
1920
<th><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Last login');?></th>
@@ -44,6 +45,10 @@
4445
<?php if ($canEdit) : ?><a href="<?php echo erLhcoreClassDesign::baseurl('user/edit')?>/<?php echo $user->id?>"><?php endif; ?><?php echo htmlspecialchars($user->username)?><?php echo htmlspecialchars($user->chat_nickname !== '' ? ' ('. $user->chat_nickname .')' : '')?><?php if ($canEdit) : ?></a><?php endif; ?>
4546
</td>
4647
<td><?php echo htmlspecialchars($user->email)?></td>
48+
<td>
49+
<?php $teamLead = $user->team_lead_user; ?>
50+
<?php if ($teamLead instanceof erLhcoreClassModelUser) : ?><?php if ($canEdit) : ?><a href="<?php echo erLhcoreClassDesign::baseurl('user/edit')?>/<?php echo $teamLead->id?>"><?php endif; ?><?php echo htmlspecialchars($teamLead->name_official)?><?php if ($canEdit) : ?></a><?php endif; ?><?php endif; ?>
51+
</td>
4752
<td>
4853
<?php if ($user->exclude_autoasign == 1) : ?>
4954
<span title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('user/userlist','Excluded from auto assign workflow');?>" class="material-icons chat-closed me-1">block</span>

‎lhc_web/design/defaulttheme/tpl/lhuser/userlist/search_panel.tpl.php‎

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@
33
<input type="hidden" name="doSearch" value="1">
44

55
<div class="row">
6-
<div class="col-md-3">
6+
<div class="col-md-2">
77
<div class="form-group">
88
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Username');?></label>
99
<input type="text" class="form-control form-control-sm" name="username" value="<?php echo htmlspecialchars($input->username)?>" />
1010
</div>
1111
</div>
12-
<div class="col-md-3">
12+
<div class="col-md-2">
1313
<div class="form-group">
1414
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Nickname');?></label>
1515
<input type="text" class="form-control form-control-sm" name="chat_nickname" value="<?php echo htmlspecialchars((string)$input->chat_nickname)?>" />
1616
</div>
1717
</div>
18-
<div class="col-md-3">
18+
<div class="col-md-2">
1919
<div class="form-group">
2020
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','E-mail');?></label>
2121
<input type="text" class="form-control form-control-sm" name="email" value="<?php echo htmlspecialchars($input->email)?>" />
2222
</div>
2323
</div>
24-
<div class="col-md-3">
24+
<div class="col-md-2">
2525
<div class="form-group">
2626
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Name');?></label>
2727
<input type="text" class="form-control form-control-sm" name="name" value="<?php echo htmlspecialchars($input->name)?>" />
2828
</div>
2929
</div>
30-
<div class="col-md-3">
30+
<div class="col-md-2">
3131
<div class="form-group">
3232
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Surname');?></label>
3333
<input type="text" class="form-control form-control-sm" name="surname" value="<?php echo htmlspecialchars($input->surname)?>" />
3434
</div>
3535
</div>
36-
<div class="col-md-3">
36+
<div class="col-md-2">
3737
<div class="form-group">
3838
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','User group');?></label>
3939
<?php echo erLhcoreClassRenderHelper::renderMultiDropdown( array (
@@ -47,7 +47,22 @@
4747
)); ?>
4848
</div>
4949
</div>
50-
<div class="col-md-3">
50+
<div class="col-md-2">
51+
<div class="form-group">
52+
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Team lead');?></label>
53+
<?php echo erLhcoreClassRenderHelper::renderMultiDropdown( array (
54+
'input_name' => 'team_lead_user_id[]',
55+
'optional_field' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Choose team lead'),
56+
'selected_id' => $input->team_lead_user_id,
57+
'css_class' => 'form-control form-control-sm',
58+
'display_name' => 'name_official',
59+
'ajax' => 'users',
60+
'list_function_params' => array('limit' => 50, 'sort' => '`name` ASC'),
61+
'list_function' => 'erLhcoreClassModelUser::getUserList',
62+
)); ?>
63+
</div>
64+
</div>
65+
<div class="col-md-2">
5166
<div class="form-group">
5267
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Account status');?></label>
5368
<select name="disabled" class="form-control form-control-sm">
@@ -57,7 +72,7 @@
5772
</select>
5873
</div>
5974
</div>
60-
<div class="col-md-3">
75+
<div class="col-md-2">
6176
<div class="form-group">
6277
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','User language');?></label>
6378
<?php echo erLhcoreClassRenderHelper::renderMultiDropdown( array (
@@ -143,8 +158,7 @@
143158
</div>
144159
</div>
145160
</div>
146-
147-
<div class="col-md-3">
161+
<div class="col-md-2">
148162
<div class="form-group">
149163
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Department');?></label>
150164
<?php echo erLhcoreClassRenderHelper::renderMultiDropdown( array (
@@ -159,7 +173,7 @@
159173
)); ?>
160174
</div>
161175
</div>
162-
<div class="col-md-3">
176+
<div class="col-md-2">
163177
<div class="form-group">
164178
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Department group');?></label>
165179
<?php echo erLhcoreClassRenderHelper::renderMultiDropdown( array (
@@ -173,8 +187,6 @@
173187
)); ?>
174188
</div>
175189
</div>
176-
177-
178190
</div>
179191

180192
<div class="btn-group" role="group" aria-label="...">

‎lhc_web/doc/CHANGELOG.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
4.93v
2+
3+
1. Added `team_lead_user_id` attribute for operators. Team lead can be assigned in the new/edit user window under the user groups section. The team lead is shown read-only above the username in the operator account page. User list now has a team lead column and a multi-select team lead filter.
4+
5+
execute doc/update_db/update_359.sql for update
6+
7+
18
4.92v
29

310
1. Notable changes since 4.91v

‎lhc_web/doc/update_db/db.dbml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,6 +2681,7 @@ Table "lh_users" {
26812681
"always_on" tinyint(1) [not null, default: 0]
26822682
"exclude_autoasign_mails" tinyint(1) [not null, default: 0]
26832683
"max_active_mails" int(11) [not null, default: 0]
2684+
"team_lead_user_id" int(11) [not null, default: 0, note: 'Team lead user ID']
26842685

26852686
Indexes {
26862687
hide_online [name: "hide_online"]
@@ -2689,6 +2690,7 @@ Table "lh_users" {
26892690
email [name: "email"]
26902691
xmpp_username [name: "xmpp_username"]
26912692
username [name: "username"]
2693+
team_lead_user_id [name: "team_lead_user_id"]
26922694
}
26932695
}
26942696

‎lhc_web/doc/update_db/structure.json‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9605,6 +9605,14 @@
96059605
"default": "0",
96069606
"extra": ""
96079607
},
9608+
{
9609+
"field": "team_lead_user_id",
9610+
"type": "int(11) unsigned",
9611+
"null": "NO",
9612+
"key": "",
9613+
"default": "0",
9614+
"extra": ""
9615+
},
96089616
{
96099617
"field": "llogin",
96109618
"type": "bigint(20) unsigned",
@@ -12305,7 +12313,8 @@
1230512313
"new" : {
1230612314
"rec_per_req" : "ALTER TABLE `lh_users` ADD INDEX `rec_per_req` (`rec_per_req`);",
1230712315
"disabled" : "ALTER TABLE `lh_users` ADD INDEX `disabled` (`disabled`);",
12308-
"username" : "ALTER TABLE `lh_users` ADD INDEX `username` (`username`);"
12316+
"username" : "ALTER TABLE `lh_users` ADD INDEX `username` (`username`);",
12317+
"team_lead_user_id" : "ALTER TABLE `lh_users` ADD INDEX `team_lead_user_id` (`team_lead_user_id`);"
1230912318
},
1231012319
"old" : []
1231112320
},

0 commit comments

Comments
 (0)