Skip to content

Commit c03df19

Browse files
committed
✨ Enhance department group management and statistics
- Refactored department group statistics modal for improved performance and clarity - Implemented transaction handling in department updates to ensure data integrity - Added unique constraint for department group members to prevent duplicates - Introduced cleanup scripts for orphan department entries in the database - Updated changelog and database structure for version 4.71
1 parent 33066c4 commit c03df19

File tree

7 files changed

+120
-33
lines changed

7 files changed

+120
-33
lines changed

lhc_web/design/defaulttheme/tpl/lhstatistic/departmentstats.tpl.php

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -402,24 +402,9 @@
402402
'sort' => false
403403
));
404404

405-
$departmentGroups = array();
406-
if (!empty($departmentGroupMemberships)) {
407-
$groupIds = array();
408-
foreach ($departmentGroupMemberships as $membership) {
409-
$groupIds[] = $membership->dep_group_id;
410-
}
411-
412-
if (!empty($groupIds)) {
413-
$departmentGroups = erLhcoreClassModelDepartamentGroup::getList(array(
414-
'limit' => false,
415-
'filter' => array('id' => $groupIds),
416-
'sort' => 'name ASC'
417-
));
418-
}
419-
}
420405
?>
421406

422-
<?php if (empty($departmentGroups)) : ?>
407+
<?php if (empty($departmentGroupMemberships)) : ?>
423408
<div class="alert alert-info">
424409
<i class="material-icons">info</i>
425410
<strong><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('department/edit','Information');?></strong>
@@ -438,22 +423,22 @@
438423
</tr>
439424
</thead>
440425
<tbody>
441-
<?php foreach ($departmentGroups as $depGroup) : ?>
426+
<?php foreach ($departmentGroupMemberships as $depGroupmember) : $depGroup = erLhcoreClassModelDepartamentGroup::fetch($depGroupmember->dep_group_id);?>
442427
<tr>
443428
<td>
444-
<?php echo htmlspecialchars($depGroup->name)?><?php if (erLhcoreClassUser::instance()->hasAccessTo('lhdepartment', 'managegroups')) : ?><a class="ms-1" href="<?php echo erLhcoreClassDesign::baseurl('department/editgroup')?>/<?php echo $depGroup->id?>" title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('department/edit','Edit group')?>"><i class="material-icons">edit</i></a><?php endif; ?>
429+
<?php echo htmlspecialchars($depGroup?->name); ?><?php if (erLhcoreClassUser::instance()->hasAccessTo('lhdepartment', 'managegroups')) : ?><a class="ms-1" href="<?php echo erLhcoreClassDesign::baseurl('department/editgroup')?>/<?php echo $depGroup?->id?>" title="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('department/edit','Edit group')?>"><i class="material-icons">edit</i></a><?php endif; ?>
445430
</td>
446431
<td>
447-
<span class="badge bg-success"><?php echo (int)$depGroup->achats_cnt?></span>
432+
<span class="badge bg-success"><?php echo (int)$depGroup?->achats_cnt?></span>
448433
</td>
449434
<td>
450-
<span class="badge bg-warning"><?php echo (int)$depGroup->pchats_cnt?></span>
435+
<span class="badge bg-warning"><?php echo (int)$depGroup?->pchats_cnt?></span>
451436
</td>
452437
<td>
453-
<span class="badge bg-info"><?php echo (int)$depGroup->bchats_cnt?></span>
438+
<span class="badge bg-info"><?php echo (int)$depGroup?->bchats_cnt?></span>
454439
</td>
455440
<td>
456-
<span class="badge bg-secondary"><?php echo (int)$depGroup->inachats_cnt?></span>
441+
<span class="badge bg-secondary"><?php echo (int)$depGroup?->inachats_cnt?></span>
457442
</td>
458443
</tr>
459444
<?php endforeach; ?>

lhc_web/doc/CHANGELOG.txt

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,86 @@
1+
4.71v
2+
3+
1. Department Management and User Administration
4+
- Enhanced department group statistics modal for better oversight of group performance
5+
- Implemented read-only status toggle for department assignments with visual feedback
6+
- Added confirmation modal for assigned department edits to prevent accidental changes
7+
- Improved user department management with transaction handling for data integrity
8+
- Added utility to cleanup orphan departments and maintain database consistency
9+
- Enhanced department assignment UI with better UX and simultaneous request prevention
10+
- Added filtering for users by assigned departments for improved navigation
11+
- Implemented department limitation handling and cache version updates on changes
12+
- Added red/green color indicators for operator online status visibility
13+
14+
2. Bot System and Webhook Improvements
15+
- Enhanced bot conditions handling with condition identifiers for better query filtering
16+
- Updated trigger link display to show bot name alongside trigger name for clarity
17+
- Disabled cache for bot actions and conditions to ensure real-time updates
18+
- Added 'single_event' support to webhook functionality for better event handling
19+
- Implemented webhook search panel with filtering capabilities for easier management
20+
- Added event field to webhook search panel and configuration options
21+
- Enhanced bot trigger validation with improved button assignment verification
22+
- Added support for conditional text generation in bot responses
23+
- Implemented 'sub_source' parameter to sendBotResponse for better tracking
24+
- Added option to check chat status after REST API calls
25+
26+
3. File Management and Image Processing
27+
- Added HEIC image conversion support in verifyaccess.php for modern image formats
28+
- Implemented file download restrictions and settings to mail conversation module
29+
- Enhanced image verification process with re-verification features
30+
- Added modal display for attached image files with better user experience
31+
- Implemented resize support for form files to optimize storage and performance
32+
- Added option to download files inline with modal interface
33+
- Enhanced file extension detection and validation for security
34+
- Added fallback options when browser cannot render images
35+
- Implemented option to ignore specific image files during verification
36+
- Added resize functionality for large mail message screenshots
37+
38+
4. Chat System and Message Handling
39+
- Added system message indicating when chat was accepted by operator
40+
- Enhanced image handling and conditions in the chat system
41+
- Implemented separate events for messages added via incoming webhooks
42+
- Added loading spinner overlay to main widget for better user feedback
43+
- Enhanced form submission experience with spinner on submit button
44+
- Added option to inherit start chat form settings for consistency
45+
- Improved message handling with better error display and validation
46+
- Enhanced chat search capabilities with message ID search functionality
47+
- Added support for raw file embed syntax in chat messages
48+
- Implemented conditional text generation for dynamic responses
49+
50+
5. Security and Performance Improvements
51+
- Implemented strict locking mechanisms for critical operations
52+
- Added transaction handling for operator transfers and chat attribute updates
53+
- Enhanced permission checking in export functions for better security
54+
- Implemented proper transaction handling for icon operations
55+
- Added cache clearing mechanisms for improved performance
56+
- Enhanced error handling for failed file downloads and operations
57+
- Implemented audit log truncation option from back office
58+
- Added better logging for auto assignment operations and error tracking
59+
- Enhanced REST API with option to skip empty body requests
60+
61+
6. User Interface and Experience Enhancements
62+
- Enhanced department assignment functionality with improved UI feedback
63+
- Added 'user-select-none' class to labels for better user experience
64+
- Implemented lazy load option for widget theme optimization
65+
- Added argument titles to command execution for better clarity
66+
- Enhanced form styling with improved input field appearance
67+
- Added link to documentation for better user guidance
68+
- Updated React app version with enhanced network failure handling
69+
- Improved checkbox re-enabling logic after request completion
70+
- Added nowrap styling for department group lists for better display
71+
72+
7. System Maintenance and Bug Fixes
73+
- Fixed issue #2298, #2304, #2305, #2306 addressing various system bugs
74+
- Updated dependencies and php-imap reference for security and compatibility
75+
- Enhanced error handling for non-existing users in reports
76+
- Fixed replacement process and edge case scenarios
77+
- Improved file type validation and extension setting for known formats
78+
- Fixed undefined display issues in pending wait time calculations
79+
- Enhanced aggregation queries by removing duplicates for better performance
80+
- Updated default translations for better internationalization support
81+
82+
execute doc/update_db/update_339.sql for update
83+
184
4.70v
285

386
1. REST API and Bot Enhancements

lhc_web/doc/update_db/structure.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11865,6 +11865,12 @@
1186511865
},
1186611866
"old" : ["device_token_device_type"]
1186711867
},
11868+
"lh_departament_group_member" : {
11869+
"new" : {
11870+
"dep_group_id_dep_id" : "DELETE t1 FROM `lh_departament_group_member` t1 INNER JOIN `lh_departament_group_member` t2 ON t1.`dep_group_id` = t2.`dep_group_id` AND t1.`dep_id` = t2.`dep_id` WHERE t1.id > t2.id; ALTER TABLE `lh_departament_group_member` ADD UNIQUE `dep_group_id_dep_id` (`dep_group_id`, `dep_id`);"
11871+
},
11872+
"old" : ["dep_group_id"]
11873+
},
1186811874
"lh_chat_blocked_user" : {
1186911875
"new" : {
1187011876
"nick" : "ALTER TABLE `lh_chat_blocked_user` ADD INDEX `nick` (`nick`);",
@@ -12262,7 +12268,7 @@
1226212268
"lh_abstract_rest_api_key": "CREATE TABLE `lh_abstract_rest_api_key` ( `id` int(11) NOT NULL AUTO_INCREMENT, `api_key` varchar(50) NOT NULL, `user_id` int(11) NOT NULL, `active` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `user_id` (`user_id`), KEY `api_key_active` (`api_key`,`active`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
1226312269
"lh_abstract_rest_api_key_remote": "CREATE TABLE `lh_abstract_rest_api_key_remote` ( `id` int(11) NOT NULL AUTO_INCREMENT, `api_key` varchar(50) NOT NULL, `username` varchar(50) NOT NULL, `name` varchar(50) NOT NULL, `host` varchar(250) NOT NULL, `active` tinyint(1) NOT NULL DEFAULT '0', `position` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `active` (`active`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
1226412270
"lh_departament_group_user": "CREATE TABLE `lh_departament_group_user` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `dep_group_id` int(11) NOT NULL,\n `user_id` int(11) NOT NULL,\n `read_only` tinyint(1) unsigned NOT NULL DEFAULT 0,\n `exc_indv_autoasign` tinyint(1) unsigned NOT NULL DEFAULT 0,\n `assign_priority` int(11) unsigned NOT NULL DEFAULT 0,\n `chat_min_priority` int(11) unsigned NOT NULL DEFAULT 0,\n `chat_max_priority` int(11) unsigned NOT NULL DEFAULT 0,\n PRIMARY KEY (`id`),\n KEY `dep_group_id` (`dep_group_id`),\n KEY `user_id` (`user_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=382 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci\n",
12265-
"lh_departament_group_member": "CREATE TABLE `lh_departament_group_member` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dep_id` int(11) NOT NULL, `dep_group_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `dep_group_id` (`dep_group_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
12271+
"lh_departament_group_member": "CREATE TABLE `lh_departament_group_member` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dep_id` int(11) NOT NULL, `dep_group_id` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `dep_group_id_dep_id` (`dep_group_id`,`dep_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
1226612272
"lh_departament_limit_group_member": "CREATE TABLE `lh_departament_limit_group_member` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dep_id` int(11) NOT NULL, `dep_limit_group_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `dep_limit_group_id` (`dep_limit_group_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
1226712273
"lh_departament_group": "CREATE TABLE `lh_departament_group` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
1226812274
"lh_departament_limit_group": "CREATE TABLE `lh_departament_limit_group` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL,`pending_max` int(11) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DELETE t1 FROM `lh_departament_group_member` t1 INNER JOIN `lh_departament_group_member` t2 ON t1.`dep_group_id` = t2.`dep_group_id` AND t1.`dep_id` = t2.`dep_id` WHERE t1.id > t2.id;
2+
DELETE t1 FROM `lh_userdep` t1 INNER JOIN `lh_userdep` t2 ON t1.`user_id` = t2.`user_id` AND t1.`dep_id` = t2.`dep_id` AND t1.`dep_group_id` = t2.`dep_group_id` AND t1.`type` = t2.`type` WHERE t1.id > t2.id AND t1.type = 1;
3+
ALTER TABLE `lh_departament_group_member` ADD UNIQUE `dep_group_id_dep_id` (`dep_group_id`, `dep_id`);

lhc_web/lib/core/lhcore/lhupdate.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
class erLhcoreClassUpdate
44
{
5-
6-
const DB_VERSION = 338;
7-
const LHC_RELEASE = 470;
5+
const DB_VERSION = 339;
6+
const LHC_RELEASE = 471;
87

98
public static function doTablesUpdate($definition){
109
$updateInformation = self::getTablesStatus($definition);

lhc_web/modules/lhdepartment/editgroup.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,27 @@
5555
$Errors = erLhcoreClassDepartament::validateDepartmentGroup($Departament_group);
5656

5757
if (count($Errors) == 0)
58-
{
59-
$Departament_group->updateThis();
58+
{
59+
$db = ezcDbInstance::get();
60+
$db->beginTransaction();
6061

61-
erLhcoreClassDepartament::validateDepartmentGroupDepartments($Departament_group);
62+
try {
63+
$Departament_group->updateThis();
64+
$Departament_group->syncAndLock('`id`');
6265

63-
erLhcoreClassAdminChatValidatorHelper::clearUsersCache();
66+
erLhcoreClassDepartament::validateDepartmentGroupDepartments($Departament_group);
6467

65-
erLhcoreClassChatEventDispatcher::getInstance()->dispatch('department.edit_department_group',array('department_group' => & $Departament_group));
68+
erLhcoreClassAdminChatValidatorHelper::clearUsersCache();
6669

67-
erLhcoreClassChatStatsResque::updateDepartmentGroupStats($Departament_group);
70+
erLhcoreClassChatEventDispatcher::getInstance()->dispatch('department.edit_department_group',array('department_group' => & $Departament_group));
71+
72+
erLhcoreClassChatStatsResque::updateDepartmentGroupStats($Departament_group);
73+
74+
$db->commit();
75+
} catch (Exception $e) {
76+
$db->rollback();
77+
$tpl->set('errors',[$e->getMessage()]);
78+
}
6879

6980
if (isset($_POST['Save_departament'])) {
7081
erLhcoreClassModule::redirect('department/group');

lhc_web/modules/lhinstall/install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,7 @@
19091909
`dep_id` int(11) NOT NULL,
19101910
`dep_group_id` int(11) NOT NULL,
19111911
PRIMARY KEY (`id`),
1912-
KEY `dep_group_id` (`dep_group_id`)
1912+
UNIQUE KEY `dep_group_id_dep_id` (`dep_group_id`,`dep_id`)
19131913
) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
19141914

19151915
$db->query("CREATE TABLE `lh_generic_bot_rest_api` (`id` bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` varchar(50) NOT NULL, `description` varchar(250), `configuration` longtext NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");

0 commit comments

Comments
 (0)