Skip to content

Commit f9130bc

Browse files
committed
New setting use_default_status_id
1 parent 9eee493 commit f9130bc

4 files changed

Lines changed: 43 additions & 26 deletions

File tree

src/Controllers/ConfigurationsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function index()
3030
'email.color_button_bg', 'email.account.name', 'email.account.mailbox' ];
3131
$tickets_section = ['default_priority_id', 'default_status_id', 'default_close_status_id', 'default_reopen_status_id',
3232
'subject_content_column', 'paginate_items', 'attachments_ticket_max_size', 'attachments_ticket_max_files_num', 'attachments_mimes',
33-
'attachments_path', 'thumbnails_path', 'oldest_year', 'user_route', 'html_replacements', 'list_text_max_length'];
33+
'attachments_path', 'thumbnails_path', 'oldest_year', 'user_route', 'html_replacements', 'list_text_max_length', 'use_default_status_id'];
3434
$perms_section = ['agent_restrict', 'close_ticket_perm', 'reopen_ticket_perm'];
3535
$editor_section = ['editor_enabled', 'editor_html_highlighter', 'codemirror_theme',
3636
'summernote_locale', 'summernote_options_json_file', 'summernote_options_user', 'purifier_config', ];

src/Controllers/TicketsController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,10 @@ protected function getCacheList($list)
617617
break;
618618
case 'statuses':
619619
$instance = Cache::remember('panichd::statuses', 60, function () {
620-
return Models\Status::all();
620+
if (Setting::grab('use_default_status_id')){
621+
return Models\Status::all();
622+
}else
623+
return Models\Status::all()->where('id', '!=', Setting::grab('default_status_id'));
621624
});
622625
break;
623626
default:
@@ -822,6 +825,8 @@ protected function validation_common($request, $new_ticket = true)
822825
}
823826

824827
$fields['status_id'] = 'required|exists:panichd_statuses,id';
828+
if (!Setting::grab('use_default_status_id')) $fields['status_id'].= '|not_in:' . Setting::grab('default_status_id');
829+
825830
$fields['priority_id'] = 'required|exists:panichd_priorities,id';
826831

827832
if ($request->has('start_date')){

src/Seeds/SettingsTableSeeder.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,21 @@ public function getDefaults()
188188
*/
189189
'default_status_id' => 1,
190190
/*
191-
* The default closing status
191+
* The default closing status for tickets
192192
* Default: false
193193
*/
194194
'default_close_status_id' => false,
195195
/*
196-
* The default reopening status
196+
* The default reopening status for tickets
197197
* Default: false
198198
*/
199199
'default_reopen_status_id' => false,
200200

201+
/*
202+
* Define the behavior related to default_status_id. If enabled, it allows to edit a ticket using "Newest" list or the status == default_status_id
203+
*/
204+
'use_default_status_id' => 'yes',
205+
201206
/*
202207
* [Deprecated] User ids who are members of admin role
203208
* Default: 1

src/Views/tickets/createedit.blade.php

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,30 @@
8989
]) !!}
9090
<div class="col-lg-9">
9191
<?php
92-
$a_lists = [
93-
'newest' => [
94-
'complete' => 'no',
95-
'default_status_id' => $setting->grab('default_status_id')
96-
],
97-
'active' => [
98-
'complete' => 'no',
99-
'default_status_id' => $setting->grab('default_reopen_status_id')
100-
],
101-
'complete' => [
102-
'complete' => 'yes',
103-
'default_status_id' => $setting->grab('default_close_status_id')
104-
]
92+
if ($setting->grab('use_default_status_id')){
93+
$a_lists['newest'] = [
94+
'complete' => 'no',
95+
'default_status_id' => $setting->grab('default_status_id')
96+
];
97+
}
98+
99+
$a_lists['active'] = [
100+
'complete' => 'no',
101+
'default_status_id' => $setting->grab('default_reopen_status_id')
102+
];
103+
$a_lists['complete'] = [
104+
'complete' => 'yes',
105+
'default_status_id' => $setting->grab('default_close_status_id')
105106
];
106107
107108
if ($a_current['complete'] == "yes"){
108109
$checked_list = 'complete';
109110
}elseif($a_current['status_id'] == $setting->grab('default_status_id')){
110-
$checked_list = 'newest';
111+
if ($setting->grab('use_default_status_id')){
112+
$checked_list = 'newest';
113+
}else{
114+
$checked_list = 'active';
115+
}
111116
}else{
112117
$checked_list = 'active';
113118
}
@@ -321,14 +326,16 @@
321326
}
322327
});
323328
324-
// Change in status affects the List only changing from or to default_status_id
325-
$('#select_status').change(function(){
326-
if ($(this).val() == '{{ $setting->grab('default_status_id') }}'){
327-
if (!$('#radio_newest_list').is(':checked')) $('#radio_newest_list').prop('checked', true).parent().effect('highlight');
328-
}else{
329-
if ($('#radio_newest_list').is(':checked')) $('#radio_active_list').prop('checked', true).parent().effect('highlight');
330-
}
331-
});
329+
@if($setting->grab('use_default_status_id'))
330+
// Change in status affects the List only changing from or to default_status_id
331+
$('#select_status').change(function(){
332+
if ($(this).val() == '{{ $setting->grab('default_status_id') }}'){
333+
if (!$('#radio_newest_list').is(':checked')) $('#radio_newest_list').prop('checked', true).parent().effect('highlight');
334+
}else{
335+
if ($('#radio_newest_list').is(':checked')) $('#radio_active_list').prop('checked', true).parent().effect('highlight');
336+
}
337+
});
338+
@endif
332339
333340
// Category select with $u->maxLevel() > 1 only
334341
$('#category_change').change(function(){

0 commit comments

Comments
 (0)