Skip to content

Commit f5d26b0

Browse files
committed
✨ Add proactive chat invitation filter and department selection functionality 🎉
- Implemented a new filter for proactive chat invitations, allowing users to filter by department in the search panel. 🏢 - Created a dedicated template for the proactive chat invitation filter to enhance UI and user experience. 🎨 - Updated the model to support department filtering logic, ensuring accurate results based on selected departments. 🔍 - Introduced new attributes for department handling in the proactive chat invitation model. 📊
1 parent 713fc80 commit f5d26b0

5 files changed

Lines changed: 100 additions & 3 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<form action="<?php echo erLhcoreClassDesign::baseurl('abstract/list')?>/ProactiveChatInvitation" method="get">
2+
<div class="row">
3+
<div class="col-md-4">
4+
<div class="form-group">
5+
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Department');?></label>
6+
<?php echo erLhcoreClassRenderHelper::renderMultiDropdown(array(
7+
'input_name' => 'dep_id[]',
8+
'optional_field' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Choose department'),
9+
'selected_id' => $input_form->dep_id,
10+
'css_class' => 'form-control',
11+
'display_name' => 'name',
12+
'ajax' => 'deps',
13+
'list_function_params' => array_merge(['sort' => '`name` ASC', 'limit' => 20], erLhcoreClassUserDep::conditionalDepartmentFilter()),
14+
'list_function' => 'erLhcoreClassModelDepartament::getList'
15+
)); ?>
16+
</div>
17+
</div>
18+
<div class="col-md-12">
19+
<div class="form-group">
20+
<input type="submit" class="btn btn-secondary" value="<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('system/buttons','Search');?>" name="doSearch">
21+
</div>
22+
</div>
23+
</div>
24+
</form>
25+
26+
<script>
27+
$(function() {
28+
$('.btn-block-department').makeDropdown();
29+
});
30+
</script>

‎lhc_web/design/defaulttheme/tpl/lhabstract/list.tpl.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
<?php ;
1717
break;
1818

19+
case 'proactivechatinvitation': ?>
20+
<?php include(erLhcoreClassDesign::designtpl('lhabstract/filter/proactivechatinvitation.tpl.php')); ?>
21+
<?php ;
22+
break;
23+
1924
case 'subject': ?>
2025
<?php include(erLhcoreClassDesign::designtpl('lhabstract/filter/subject.tpl.php')); ?>
2126
<?php ;

‎lhc_web/lib/core/lhabstract/fields/erlhabstractmodeleproactivechatinvitation.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
'required' => true,
2626
'validation_definition' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw')
2727
),
28+
'list_department' => array(
29+
'type' => 'none',
30+
'hide_edit' => true,
31+
'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/widgettheme', 'Departments'),
32+
'required' => false
33+
),
2834
'operator_name' => array(
2935
'type' => 'text',
3036
'translatable' => true,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
$fieldsSearch = array();
4+
5+
$fieldsSearch['dep_id'] = array(
6+
'type' => 'text',
7+
'trans' => 'Department',
8+
'required' => false,
9+
'valid_if_filled' => false,
10+
'filter_type' => false,
11+
'filter_table_field' => '`lh_abstract_proactive_chat_invitation`.`dep_id`',
12+
'validation_definition' => new ezcInputFormDefinitionElement(
13+
ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1), FILTER_REQUIRE_ARRAY
14+
)
15+
);
16+
17+
$fieldSortAttr = array(
18+
'field' => false,
19+
'default' => false,
20+
'serialised' => true,
21+
'disabled' => true,
22+
'options' => array()
23+
);
24+
25+
return array(
26+
'filterAttributes' => $fieldsSearch,
27+
'sortAttributes' => $fieldSortAttr
28+
);

‎lhc_web/lib/models/lhabstract/erlhabstractmodeleproactivechatinvitation.php‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,21 @@ public function customAction($action) {
9595
}
9696
}
9797

98-
public static function getFilter(){
99-
// Global filters
100-
return erLhcoreClassUserDep::conditionalDepartmentFilter(false,'dep_id');
98+
public static function getFilter($inputData = null){
99+
$filter = erLhcoreClassUserDep::conditionalDepartmentFilter(false,'dep_id');
100+
101+
if (is_object($inputData) && isset($inputData->dep_id) && is_array($inputData->dep_id)) {
102+
$departmentIds = array_filter(array_map('intval', $inputData->dep_id), function ($id) {
103+
return $id > 0;
104+
});
105+
106+
if (!empty($departmentIds)) {
107+
$ids = implode(',', $departmentIds);
108+
$filter['filter_custom'][] = '(`lh_abstract_proactive_chat_invitation`.`dep_id` IN (' . $ids . ') OR `lh_abstract_proactive_chat_invitation`.`id` IN (SELECT `invitation_id` FROM `lh_abstract_proactive_chat_invitation_dep` WHERE `dep_id` IN (' . $ids . ')))';
109+
}
110+
}
111+
112+
return $filter;
101113
}
102114

103115
public function getFields()
@@ -234,6 +246,20 @@ public function __get($var)
234246
}
235247
return $this->dep_ids_front;
236248

249+
case 'list_department':
250+
if ($this->dep_id == 0) {
251+
$this->list_department = '∞';
252+
} else {
253+
$departmentIds = $this->dep_ids_front;
254+
if ($this->dep_id > 0) {
255+
$departmentIds[] = $this->dep_id;
256+
}
257+
$this->list_department = !empty($departmentIds)
258+
? implode(', ', erLhcoreClassModelDepartament::getList(['filterin' => ['id' => array_unique($departmentIds)], 'sort' => '`name` ASC', 'limit' => false]))
259+
: '-';
260+
}
261+
return $this->list_department;
262+
237263
default:
238264
break;
239265
}
@@ -1304,6 +1330,8 @@ public function afterSave($params)
13041330
public $next_reschedule = 0;
13051331
public $hide_add = false;
13061332
public $hide_delete = false;
1333+
public $has_filter = true;
1334+
public $filter_name = 'proactivechatinvitation';
13071335

13081336
public $created_at = 0;
13091337
public $updated_at = 0;

0 commit comments

Comments
 (0)