Skip to content
Snippets Groups Projects
Commit f83bf420 authored by Peter Rotich's avatar Peter Rotich
Browse files

Queue Export - Exportable fields

* Export all exportable fields by default - for all queues + adhoc searches
* Export Due Date as well as SLA Due Date
parent a88e3fc1
Branches
Tags
No related merge requests found
...@@ -538,7 +538,8 @@ class CustomQueue extends VerySimpleModel { ...@@ -538,7 +538,8 @@ class CustomQueue extends VerySimpleModel {
'source' => __('Source'), 'source' => __('Source'),
'status::getName' =>__('Current Status'), 'status::getName' =>__('Current Status'),
'lastupdate' => __('Last Updated'), 'lastupdate' => __('Last Updated'),
'est_duedate' => __('Due Date'), 'est_duedate' => __('SLA Due Date'),
'duedate' => __('Due Date'),
'isoverdue' => __('Overdue'), 'isoverdue' => __('Overdue'),
'isanswered' => __('Answered'), 'isanswered' => __('Answered'),
'staff::getName' => __('Agent Assigned'), 'staff::getName' => __('Agent Assigned'),
...@@ -547,30 +548,30 @@ class CustomQueue extends VerySimpleModel { ...@@ -547,30 +548,30 @@ class CustomQueue extends VerySimpleModel {
'attachment_count' => __('Attachment Count'), 'attachment_count' => __('Attachment Count'),
) + $cdata; ) + $cdata;
return $fields; return $fields;
} }
function getExportFields() { function getExportFields($inherit=true) {
$fields = array(); $fields = array();
if ($this->parent_id if ($inherit
&& $this->parent_id
&& $this->hasFlag(self::FLAG_INHERIT_EXPORT) && $this->hasFlag(self::FLAG_INHERIT_EXPORT)
&& $this->parent && $this->parent
) { ) {
$fields = $this->parent->getExportFields(); $fields = $this->parent->getExportFields();
} }
elseif (count($this->exports)) { elseif (count($this->exports)) {
$fields = $this->exports; foreach ($this->exports as $f)
$fields[$f->path] = $f->getHeading();
} }
elseif ($this->isAQueue()) elseif ($this->isAQueue())
return $this->getExportableFields(); $fields = $this->getExportableFields();
$_fields = array(); if (!count($fields))
foreach ($fields as $f) $fields = $this->getExportableFields();
$_fields[$f->path] = $f->getHeading();
return $_fields; return $fields;
} }
function getColumns($use_template=false) { function getColumns($use_template=false) {
...@@ -713,7 +714,7 @@ class CustomQueue extends VerySimpleModel { ...@@ -713,7 +714,7 @@ class CustomQueue extends VerySimpleModel {
if (!($query=$this->getBasicQuery())) if (!($query=$this->getBasicQuery()))
return false; return false;
if (!($fields=$this->getFields())) if (!($fields=$this->getExportFields()))
return false; return false;
return Export::saveTickets($query, $fields, $filename, $format); return Export::saveTickets($query, $fields, $filename, $format);
...@@ -953,7 +954,7 @@ class CustomQueue extends VerySimpleModel { ...@@ -953,7 +954,7 @@ class CustomQueue extends VerySimpleModel {
$this->setFlag(self::FLAG_INHERIT_COLUMNS, $this->setFlag(self::FLAG_INHERIT_COLUMNS,
$this->parent_id > 0 && isset($vars['inherit-columns'])); $this->parent_id > 0 && isset($vars['inherit-columns']));
$this->setFlag(self::FLAG_INHERIT_EXPORT, $this->setFlag(self::FLAG_INHERIT_EXPORT,
$this->parent_id > 0 && isset($vars['inherit-fields'])); $this->parent_id > 0 && isset($vars['inherit-exports']));
$this->setFlag(self::FLAG_INHERIT_SORTING, $this->setFlag(self::FLAG_INHERIT_SORTING,
$this->parent_id > 0 && isset($vars['inherit-sorting'])); $this->parent_id > 0 && isset($vars['inherit-sorting']));
...@@ -1023,6 +1024,9 @@ class CustomQueue extends VerySimpleModel { ...@@ -1023,6 +1024,9 @@ class CustomQueue extends VerySimpleModel {
$this->exports->sort(function($f) { return $f->sort; }); $this->exports->sort(function($f) { return $f->sort; });
} }
if (!count($this->exports) && $this->parent)
$this->hasFlag(self::FLAG_INHERIT_EXPORT);
// Update advanced sorting options for the queue // Update advanced sorting options for the queue
if (isset($vars['sorts']) && !$this->hasFlag(self::FLAG_INHERIT_SORTING)) { if (isset($vars['sorts']) && !$this->hasFlag(self::FLAG_INHERIT_SORTING)) {
$new = $order = $vars['sorts']; $new = $order = $vars['sorts'];
......
...@@ -4,7 +4,7 @@ if ($queue->parent) { ?> ...@@ -4,7 +4,7 @@ if ($queue->parent) { ?>
<tbody> <tbody>
<tr> <tr>
<td colspan="3"> <td colspan="3">
<input type="checkbox" name="inherit-fields" <?php <input type="checkbox" name="inherit-exports" <?php
if ($queue->inheritExport()) echo 'checked="checked"'; ?> if ($queue->inheritExport()) echo 'checked="checked"'; ?>
onchange="javascript:$(this).closest('table').find('.if-not-inherited').toggle(!$(this).prop('checked'));" /> onchange="javascript:$(this).closest('table').find('.if-not-inherited').toggle(!$(this).prop('checked'));" />
<?php echo __('Inherit export fields from the parent queue'); ?> <?php echo __('Inherit export fields from the parent queue'); ?>
...@@ -19,7 +19,7 @@ if ($queue->parent) { ?> ...@@ -19,7 +19,7 @@ if ($queue->parent) { ?>
<tbody> <tbody>
<tr> <tr>
<td colspan="3"> <td colspan="3">
<input type="checkbox" name="inherit-fields" <?php <input type="checkbox" name="inherit-exports" <?php
if (count($queue->exports) == 0) echo 'checked="checked"'; if (count($queue->exports) == 0) echo 'checked="checked"';
if ($queue instanceof SavedSearch) echo 'disabled="disabled"'; ?> if ($queue instanceof SavedSearch) echo 'disabled="disabled"'; ?>
onchange="javascript:$(this).closest('table').find('.if-not-inherited').toggle(!$(this).prop('checked'));" /> onchange="javascript:$(this).closest('table').find('.if-not-inherited').toggle(!$(this).prop('checked'));" />
...@@ -86,7 +86,6 @@ var Q = setInterval(function() { ...@@ -86,7 +86,6 @@ var Q = setInterval(function() {
clearInterval(Q); clearInterval(Q);
var addField = function(field, info) { var addField = function(field, info) {
console.log(field, info);
if (!field) return; if (!field) return;
var i = $('#fields tr.field-entry').length; var i = $('#fields tr.field-entry').length;
...@@ -137,7 +136,7 @@ var Q = setInterval(function() { ...@@ -137,7 +136,7 @@ var Q = setInterval(function() {
return false; return false;
}); });
<?php <?php
foreach ($queue->getExportFields() as $k => $v) { foreach ($queue->getExportFields(false) as $k => $v) {
echo sprintf('addField(%s, {name: %s, heading: %s});', echo sprintf('addField(%s, {name: %s, heading: %s});',
JsonDataEncoder::encode($k), JsonDataEncoder::encode($k),
JsonDataEncoder::encode($v), JsonDataEncoder::encode($v),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment