Newer
Older
<?php
// vim: expandtab sw=2 ts=2 sts=2:
if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
$info = $qs = array();
if (!$queue) {
$queue = CustomQueue::create(array(
'flags' => CustomQueue::FLAG_QUEUE,
));
$title=__('Add New Queue');
$action='create';
$submit_text=__('Create');
}
else {
$title=__('Manage Custom Queue');
$action='update';
$submit_text=__('Save Changes');
$info['id'] = $queue->getId();
$qs += array('id' => $queue->getId());
}
?>
<form action="queues.php?<?php echo Http::build_query($qs); ?>" method="post" id="save" autocomplete="off">
<?php csrf_token(); ?>
<input type="hidden" name="do" value="<?php echo $action; ?>">
<input type="hidden" name="a" value="<?php echo Format::htmlchars($_REQUEST['a']); ?>">
<input type="hidden" name="id" value="<?php echo $info['id']; ?>">
<input type="hidden" name="root" value="<?php echo Format::htmlchars($_REQUEST['t']); ?>">
<h2><a href="settings.php?t=tickets#queues"><?php echo __('Ticket Queues'); ?></a>
// <?php echo $title; ?>
<?php if (isset($queue->id)) { ?><small>
— <?php echo $queue->getFullName(); ?></small>
<?php } ?>
</h2>
<ul class="clean tabs">
<li class="active"><a href="#criteria"><i class="icon-filter"></i>
<?php echo __('Criteria'); ?></a></li>
<li><a href="#columns"><i class="icon-columns"></i>
<?php echo __('Columns'); ?></a></li>
<li><a href="#preview-tab"><i class="icon-eye-open"></i>
<?php echo __('Preview'); ?></a></li>
</ul>
<div class="tab_content" id="criteria">
<table class="table">
<td style="width:60%; vertical-align:top">
<div><strong><?php echo __('Queue Name'); ?>:</strong></div>
<input type="text" name="name" value="<?php
echo Format::htmlchars($queue->getName()); ?>"
style="width:100%" />
<br/>
<br/>
<div><strong><?php echo __("Queue Search Criteria"); ?></strong></div>
<label class="checkbox" style="line-height:1.3em">
<input type="checkbox" class="checkbox" name="inherit" <?php
if ($queue->inheritCriteria()) echo 'checked="checked"';
?>/>
<?php echo __('Include parent search criteria');
if ($queue->parent) { ?>
<span id="parent_q_crit" class="faded">
<i class="icon-caret-right"></i>
<br/><?php
echo $queue->parent->describeCriteria();
?></span>
<?php } ?>
</label>
<div class="error"><?php echo $errors['criteria']; ?></div>
<div class="advanced-search">
<?php
$form = $queue->getForm();
$matches = $queue->getSupportedMatches();
include STAFFINC_DIR . 'templates/advanced-search-criteria.tmpl.php';
?>
</div>
</td>
<td style="width:35%; padding-left:40px; vertical-align:top">
<div><strong><?php echo __("Parent Queue"); ?>:</strong></div>
<select name="parent_id" onchange="javascript:
$('#parent_q_crit').toggle($(this).find(':selected').val()
== <?php echo $queue->parent_id ?: 0; ?>);">
<option value="0">— <?php echo __('Top-Level Queue'); ?> —</option>
<?php foreach (CustomQueue::queues() as $cq) {
if ($cq->getId() == $queue->getId())
continue;
?>
<option value="<?php echo $cq->id; ?>"
<?php if ($cq->getId() == $queue->parent_id) echo 'selected="selected"'; ?>
><?php echo $cq->getFullName(); ?></option>
<?php } ?>
</select>
<br/>
<br/>
<div><strong><?php echo __("Quick Filter"); ?></strong></div>
<hr/>
<option value="" <?php if ($queue->filter == "")
echo 'selected="selected"'; ?>>— <?php echo __('None'); ?> —</option>
<option value="::" <?php if ($queue->filter == "::")
echo 'selected="selected"'; ?>>— <?php echo __('Inherit from parent');
if ($queue->parent
&& ($qf = $queue->parent->getQuickFilterField()))
echo sprintf(' (%s)', $qf->getLabel()); ?> —</option>
<?php foreach (SavedSearch::getSearchableFields('Ticket') as $path=>$f) {
list($label, $field) = $f;
if (!$field->supportsQuickFilter())
continue;
?>
<option value="<?php echo $path; ?>"
<?php if ($path == $queue->filter) echo 'selected="selected"'; ?>
><?php echo $label; ?></option>
<?php } ?>
</select>
<br/>
<br/>
<div><strong><?php echo __("Sort Options"); ?></strong></div>
<hr/>
</td>
</table>
</div>
<div class="hidden tab_content" id="columns">
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<table class="table two-column">
<tbody>
<tr class="header">
<th colspan="2">
<?php echo __("Manage columns in this queue"); ?>
<div><small><?php echo __(
"Add, remove, and customize the content of the columns in this queue using the options below. Click a column header to manage or resize it"); ?>
</small></div>
</th>
</tr>
<tr class="header">
<td><small><b><?php echo __('Column Name'); ?></b></small></td>
<td><small><b><?php echo __('Heading and Width'); ?></b></small></td>
</tr>
</tbody>
<tbody class="sortable-rows">
<tr id="column-template" class="hidden">
<td>
<i class="faded-more icon-sort"></i>
<input type="hidden" data-name="queue_id"
value="<?php echo $queue->getId(); ?>"/>
<input type="hidden" data-name="column_id" />
<span></span>
</td>
<td>
<input type="text" size="25" data-name="heading"
data-translate-tag="" />
<input type="text" size="5" data-name="width" />
<a class="action-button"
href="#" onclick="javascript:
var colid = $(this).closest('tr').find('[data-name=column_id]').val();
$.dialog('ajax.php/tickets/search/column/edit/' + colid, 201);
return false;
"><i class="icon-edit"></i> <?php echo __('Edit'); ?></a>
<a href="#" class="pull-right drop-column" title="<?php echo __('Delete');
?>"><i class="icon-trash"></i></a>
</td>
</tr>
</tbody>
<tbody>
<tr class="header">
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2" id="append-column">
<i class="icon-plus-sign"></i>
<select id="add-column" data-quick-add="queue-column">
<option value="">— <?php echo __('Add a column'); ?> —</option>
<?php foreach (QueueColumn::objects() as $C) { ?>
<option value="<?php echo $C->id; ?>"><?php echo
Format::htmlchars($C->name); ?></option>
<option value="0" data-quick-add>— <?php echo __('Add New');?> —</option>
</select>
<button type="button" class="green button">
<?php echo __('Add'); ?>
</button>
</td>
</tr>
</tbody>
</table>
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
</div>
<div class="hidden tab_content" id="preview-tab">
<div id="preview">
</div>
<script>
$(function() {
$('#preview-tab').on('afterShow', function() {
$.ajax({
url: 'ajax.php/queue/preview',
type: 'POST',
data: $('#save').serializeArray(),
success: function(html) {
$('#preview').html(html);
}
});
});
});
</script>
</div>
<p style="text-align:center;">
<input type="submit" name="submit" value="<?php echo $submit_text; ?>">
<input type="reset" name="reset" value="<?php echo __('Reset');?>">
<input type="button" name="cancel" value="<?php echo __('Cancel');?>" onclick="window.history.go(-1);">
</p>
</form>
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<script>
var addColumn = function(colid, info) {
if (!colid) return;
var copy = $('#column-template').clone(),
name_prefix = 'columns[' + colid + ']';
info['column_id'] = colid;
copy.find('input[data-name]').each(function() {
var $this = $(this),
name = $this.data('name');
if (info[name] !== undefined)
$this.val(info[name]);
$this.attr('name', name_prefix + '[' + name + ']');
});
copy.find('span').text(info['name']);
copy.attr('id', '').show().insertBefore($('#column-template'));
copy.removeClass('hidden');
if (info['trans'] !== undefined) {
var input = copy.find('input[data-translate-tag]')
.attr('data-translate-tag', info['trans']);
if ($.fn.translatable)
input.translatable();
// Else it will be made translatable when the JS library is loaded
}
copy.find('a.drop-column').click(function() {
$('<option>')
.attr('value', copy.find('input[data-name=column_id]').val())
.text(info.name)
.insertBefore($('#add-column')
.find('[data-quick-add]')
);
copy.fadeOut(function() { $(this).remove(); });
return false;
});
var selected = $('#add-column').find('option[value=' + colid + ']');
selected.remove();
};
$('#append-column').find('button').on('click', function() {
var selected = $('#add-column').find(':selected'),
id = parseInt(selected.val());
if (!id)
return;
addColumn(id, {name: selected.text(), heading: selected.text(), width: 100});
return false;
});
<?php foreach ($queue->columns as $C) {
echo sprintf('addColumn(%d, {name: %s, heading: %s, width: %d, trans: %s});',
$C->column_id, JsonDataEncoder::encode($C->name),
JsonDataEncoder::encode($C->heading), $C->width,
JsonDataEncoder::encode($C->getTranslateTag('heading')));
} ?>
</script>