From cf8f7578f76e2b739336e6a1c72c5ca09e064c6a Mon Sep 17 00:00:00 2001 From: aydreeihn <adriane@enhancesoft.com> Date: Wed, 2 May 2018 08:58:35 -0500 Subject: [PATCH] Quick Fixes: - On ticket edit, only display inactive help topic warning if the ticket has a help topic - Inline edit file save fix - Remove future search/filter criteria for datetime fields that can't be in the future - Fix calculations for 'next 7 days' and 'next 30 days'. They were selecting dates between now and n days AGO instead of between now and n days in the future --- include/ajax.tickets.php | 3 +-- include/class.forms.php | 9 +++++++-- include/class.queue.php | 5 +++++ include/staff/templates/queue-quickfilter.tmpl.php | 4 ++++ include/staff/ticket-edit.inc.php | 3 +-- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index 6825556a9..91f12f895 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -524,8 +524,7 @@ function refer($tid, $target=null) { ) ); - $impl = $field->getImpl(); - if ($impl instanceof FileUploadField) + if ($field instanceof FileUploadField) $field->save(); Http::response(201, $field->getClean()); } diff --git a/include/class.forms.php b/include/class.forms.php index db227a922..c4d6ea44e 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -2003,6 +2003,11 @@ class DatetimeField extends FormField { return $this->max; } + function getPastPresentLabels() { + return array(__('Create Date'), __('Reopen Date'), + __('Close Date'), __('Last Update')); + } + function to_database($value) { // Store time in format given by Date Picker (DateTime::W3C) return $value; @@ -2401,11 +2406,11 @@ class DatetimeField extends FormField { ]); case 'n7': return $query->filter([ - "{$name}__range" => array($now, $now->minus(SqlInterval::DAY(7))), + "{$name}__range" => array($now, $now->plus(SqlInterval::DAY(7))), ]); case 'n30': return $query->filter([ - "{$name}__range" => array($now, $now->minus(SqlInterval::DAY(30))), + "{$name}__range" => array($now, $now->plus(SqlInterval::DAY(30))), ]); case 'g': $midnight -= 86400; diff --git a/include/class.queue.php b/include/class.queue.php index 189a7a846..0458fd7a0 100644 --- a/include/class.queue.php +++ b/include/class.queue.php @@ -441,6 +441,11 @@ class CustomQueue extends VerySimpleModel { ), )); $methods = $field->getSearchMethods(); + + //remove future options for datetime fields that can't be in the future + if (in_array($field->getLabel(), DateTimeField::getPastPresentLabels())) + unset($methods['ndays'], $methods['future'], $methods['distfut']); + $pieces["{$name}+method"] = new ChoiceField(array( 'choices' => $methods, 'default' => key($methods), diff --git a/include/staff/templates/queue-quickfilter.tmpl.php b/include/staff/templates/queue-quickfilter.tmpl.php index 6b288f494..9e4d64850 100644 --- a/include/staff/templates/queue-quickfilter.tmpl.php +++ b/include/staff/templates/queue-quickfilter.tmpl.php @@ -15,6 +15,10 @@ if (!($qf_field = $queue->getQuickFilterField($quick_filter))) return; $choices = $qf_field->getQuickFilterChoices(); + +//remove future options for datetime fields that can't be in the future +if (in_array($qf_field->getLabel(), DatetimeField::getPastPresentLabels())) + unset($choices['m'], $choices['n7'], $choices['n30']); ?> <span class="action-button muted" data-dropdown="#quickfilter-dropdown"> <i class="icon-caret-down pull-right"></i> diff --git a/include/staff/ticket-edit.inc.php b/include/staff/ticket-edit.inc.php index f77e02b87..71d8871e6 100644 --- a/include/staff/ticket-edit.inc.php +++ b/include/staff/ticket-edit.inc.php @@ -94,8 +94,7 @@ if ($_POST) <option value="" selected >— <?php echo __('Select Help Topic');?> —</option> <?php if($topics=Topic::getHelpTopics()) { - if(!array_key_exists($ticket->topic_id, $topics)) - { + if($ticket->topic_id && !array_key_exists($ticket->topic_id, $topics)) { $topics[$ticket->topic_id] = $ticket->topic; $warn = sprintf(__('%s selected must be active'), __('Help Topic')); } -- GitLab