diff --git a/include/class.filter.php b/include/class.filter.php index 7178aece5eba1d0540020b9898f2602bdcdd55df..e76b5175a3d8b5c6ac4a866bdd091fe6ec045a04 100644 --- a/include/class.filter.php +++ b/include/class.filter.php @@ -473,18 +473,22 @@ class Filter { function save($id,$vars,&$errors) { if ($this) { foreach ($this->getActions() as $A) { - if ($A->type == 'dept') - $dept = Dept::lookup($A->parseConfiguration($vars)['dept_id']); - - if ($A->type == 'topic') - $topic = Topic::lookup($A->parseConfiguration($vars)['topic_id']); + if ($A->type == 'dept') { + $dept = Dept::lookup($A->parseConfiguration($vars)['dept_id']); + $dept_action = $A->getId(); + } + + if ($A->type == 'topic') { + $topic = Topic::lookup($A->parseConfiguration($vars)['topic_id']); + $topic_action = $A->getId(); + } } } - if($dept && !$dept->isActive()) + if($dept && !$dept->isActive() && !in_array('D' . $dept_action,$vars['actions'])) $errors['err'] = sprintf(__('%s selected for %s must be active'), __('Department'), __('Filter Action')); - if($topic && !$topic->isActive()) + if($topic && !$topic->isActive() && !in_array('D' . $topic_action,$vars['actions'])) $errors['err'] = sprintf(__('%s selected for %s must be active'), __('Help Topic'), __('Filter Action')); if(!$vars['execorder']) @@ -522,7 +526,7 @@ class Filter { .',execorder='.db_input($vars['execorder']) .',email_id='.db_input($emailId) .',match_all_rules='.db_input($vars['match_all_rules']) - .',stop_onmatch='.db_input(isset($vars['stop_onmatch'])?1:0) + .',stop_onmatch='.db_input($vars['stop_onmatch']) .',notes='.db_input(Format::sanitize($vars['notes'])); if($id) { diff --git a/include/class.filter_action.php b/include/class.filter_action.php index c963e355c1ab0905f49d10dcf6926718851a8c71..59bafbf57ebfe40205adbfe2dbecd60b33525083 100644 --- a/include/class.filter_action.php +++ b/include/class.filter_action.php @@ -41,8 +41,7 @@ class FilterAction extends VerySimpleModel { return $this->_config; } - function parseConfiguration($source, &$errors=array()) - { + function parseConfiguration($source, &$errors=array()) { if (!$source) return $this->getConfiguration(); diff --git a/include/class.forms.php b/include/class.forms.php index 161e06fdb24ec34f700b025b55adff01f80f4c78..cc6572a3efdac509067b256d34f5a5df7a35de8f 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -2690,15 +2690,12 @@ class DepartmentField extends ChoiceField { else { $current_id = $selected->value; $current_name = Dept::getNameById($current_id); - $addNew = true; } } - $active_depts = array(); - if($current_id) - $active_depts = Dept::objects() - ->filter(array('flags__hasbit' => Dept::FLAG_ACTIVE)) - ->values('id', 'name'); + $active_depts = Dept::objects() + ->filter(array('flags__hasbit' => Dept::FLAG_ACTIVE)) + ->values('id', 'name'); $choices = array(); if ($depts = Dept::getDepartments(null, true, Dept::DISPLAY_DISABLED)) { @@ -2708,18 +2705,17 @@ class DepartmentField extends ChoiceField { $active[$dept['id']] = $dept['name']; //add selected dept to list - $active[$current_id] = $current_name; - + if($current_id) + $active[$current_id] = $current_name; + else + return $active; foreach ($depts as $id => $name) { $choices[$id] = $name; if(!array_key_exists($id, $active) && $current_id) - unset($choices[$id]); + unset($choices[$id]); } - } - if($addNew) - $choices[':new:'] = '— '.__('Add New').' —'; return $choices; } @@ -3933,6 +3929,8 @@ class ChoicesWidget extends Widget { $values[$v] = $choices[$v]; elseif (($i=$this->field->lookupChoice($v))) $values += $i; + elseif (!$k && $v) + return $v; } } } @@ -4916,7 +4914,7 @@ class ReferralForm extends Form { ), ) ), - 'dept' => new ChoiceField(array( + 'dept' => new DepartmentField(array( 'id'=>4, 'label' => '', 'flags' => hexdec(0X450F3), diff --git a/include/class.report.php b/include/class.report.php index 999ae22fe0ac6c6e12a70edbb1bf6fc340f2611c..5e1ac94b97f52c3c8b5f5efb50ffa06e841c3737 100644 --- a/include/class.report.php +++ b/include/class.report.php @@ -211,9 +211,10 @@ class OverviewReport { $headers = array(__('Help Topic')); $header = function($row) { return Topic::getLocalNameById($row['topic_id'], $row['topic__topic']); }; $pk = 'topic_id'; + $topics = Topic::getHelpTopics(); $stats = $stats ->values('topic_id', 'topic__topic', 'topic__flags') - ->filter(array('dept_id__in' => $thisstaff->getDepts(), 'topic_id__gt' => 0)); + ->filter(array('dept_id__in' => $thisstaff->getDepts(), 'topic_id__gt' => 0, 'topic_id__in' => array_keys($topics))); $times = $times ->values('topic_id') ->filter(array('topic_id__gt' => 0)); @@ -223,7 +224,10 @@ class OverviewReport { $header = function($row) { return new AgentsName(array( 'first' => $row['staff__firstname'], 'last' => $row['staff__lastname'])); }; $pk = 'staff_id'; - $stats = $stats->values('staff_id', 'staff__firstname', 'staff__lastname'); + $staff = Staff::getStaffMembers(); + $stats = $stats + ->values('staff_id', 'staff__firstname', 'staff__lastname') + ->filter(array('staff_id__in' => array_keys($staff))); $times = $times->values('staff_id'); $depts = $thisstaff->getManagedDepartments(); if ($thisstaff->hasPerm(ReportModel::PERM_AGENTS)) diff --git a/include/class.topic.php b/include/class.topic.php index 84a1c9d47d85892d62ef4c44976ade79c33afcee..245b3c39f88535ab0afe34a24e8d189d126ca01e 100644 --- a/include/class.topic.php +++ b/include/class.topic.php @@ -191,8 +191,7 @@ implements TemplateVariable, Searchable { return $this->isActive(); } - function isActive() - { + function isActive() { return !!($this->flags & self::FLAG_ACTIVE); } diff --git a/include/staff/filter.inc.php b/include/staff/filter.inc.php index ba0c06ce58ccdd35b8dadcdc9001362477da7b83..100e1273cb9def31eef2bc386705526e5fddb117 100644 --- a/include/staff/filter.inc.php +++ b/include/staff/filter.inc.php @@ -242,7 +242,6 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); $existing[] = $A->type; if($A->type == 'dept') { $errors['topic_id'] = ''; - // $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); $dept_config = $A->parseConfiguration($_POST); $dept = Dept::lookup($dept_config['dept_id']); if($dept && !$dept->isActive()) diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 0767f5ebcd6f5624742965fd34babb0ac1603966..b17f8a846c172c293b24a1f1c2324a55c25d03af 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -616,7 +616,14 @@ foreach (DynamicFormEntry::forTicket($ticket->getId()) as $form) { <a class="ticket-action" id="inline-update" data-placement="bottom" data-toggle="tooltip" title="<?php echo __('Update'); ?>" data-redirect="tickets.php?id=<?php echo $ticket->getId(); ?>" href="#tickets/<?php echo $ticket->getId(); ?>/field/<?php echo $id; ?>/edit"> - <?php echo $v; ?> + <?php + if (strlen($v) > 200) { + echo Format::truncate($v, 200); + echo "<br><i class=\"icon-edit\"></i>"; + } + else + echo $v; + ?> </a> <?php } else { echo $v;