diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index 6825556a98ad07028029130e195d7eaa3d7447d5..91f12f895d7945e804bbc05ac72e3837bb6f9e64 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 db227a922e162abd06931d2aff6c0b6971fcc600..c4d6ea44e58da9266fce504a21b0f08f319d3615 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 189a7a84654a2bda283c60e0a49eae443ab142e8..0458fd7a0e96e78a68674748b97262bd31564016 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 6b288f49484f3887ef7a2b23e67e76666c5250e3..9e4d64850a5ec3ea3e7afac9d17e179c62edd7de 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 f77e02b8715cf9ce690b56777163b743c39551f7..71d8871e65af1f9ff1b73959b0c0bb043a464c0b 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')); }