Newer
Older
$search = SavedSearch::create();
$tickets = TicketModel::objects();
$clear_button = false;
// Add "other" fields (via $_POST['other'][])
switch(strtolower($_REQUEST['status'])){ //Status is overloaded
case 'closed':
$status='closed';
$results_type=__('Closed Tickets');
$showassigned=true; //closed by.
break;
case 'overdue':
$status='open';
$results_type=__('Overdue Tickets');
$tickets->filter(array('isoverdue'=>1));
break;
case 'assigned':
$status='open';
$staffId=$thisstaff->getId();
$results_type=__('My Tickets');
$tickets->filter(array('staff_id'=>$thisstaff->getId()));
break;
case 'answered':
$status='open';
$showanswered=true;
$results_type=__('Answered Tickets');
$tickets->filter(array('isanswered'=>1));
break;
default:
if (isset($_GET['clear_filter']))
unset($_SESSION['advsearch']);
if (isset($_SESSION['advsearch'])) {
$form = $search->getForm();
$form->loadState($_SESSION['advsearch']);
$tickets = $search->mangleQuerySet($tickets, $form);
$results_type=__('Advanced Search')
. '<a class="action-button" href="?clear_filter"><i class="icon-ban-circle"></i> <em>' . __('clear') . '</em></a>';
Peter Rotich
committed
}
// Fall-through and show open tickets
case 'open':
$status='open';
$results_type=__('Open Tickets');
$tickets->filter(array('isanswered'=>0));
break;
Peter Rotich
committed
}
// Apply primary ticket status
if ($status)
$tickets->filter(array('status__state'=>$status));
// Impose visibility constraints
// ------------------------------------------------------------
// -- Open and assigned to me
$visibility = array(
new Q(array('status__state'=>'open', 'staff_id' => $thisstaff->getId()))
);
// -- Routed to a department of mine
if (!$thisstaff->showAssignedOnly() && ($depts=$thisstaff->getDepts()))
$visibility[] = new Q(array('dept_id__in' => $depts));
// -- Open and assigned to a team of mine
if (($teams = $thisstaff->getTeams()) && count(array_filter($teams)))
$visibility[] = new Q(array(
'team_id__in' => array_filter($teams), 'status__state'=>'open'
));
$tickets->filter(Q::any($visibility));
// Select pertinent columns
// ------------------------------------------------------------
$tickets->select_related('lock', 'dept', 'staff', 'user', 'user__default_email', 'topic', 'status', 'cdata', 'cdata__:priority');
// Apply requested quick filter
// Apply requested sorting
// Apply requested pagination
$pagelimit=($_GET['limit'] && is_numeric($_GET['limit']))?$_GET['limit']:PAGE_LIMIT;
$page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1;
$pageNav=new Pagenate($tickets->count(), $page,$pagelimit);
TicketForm::ensureDynamicDataView();
// Save the query to the session for exporting
$_SESSION[':Q:tickets'] = $tickets;
<input type="hidden" name="a" value="search">
<table>
<tr>
<td><input type="text" id="basic-ticket-search" name="query" size=30 value="<?php echo Format::htmlchars($_REQUEST['query']); ?>"
autocomplete="off" autocorrect="off" autocapitalize="off"></td>
<td><input type="submit" name="basic_search" class="button" value="<?php echo __('Search'); ?>"></td>
<td> <a href="#" onclick="javascript:
$.dialog('ajax.php/tickets/search', 201);"
>[<?php echo __('advanced'); ?>]</a> <i class="help-tip icon-question-sign" href="#advanced"></i></td>
</tr>
</table>
</form>
</div>
<!-- SEARCH FORM END -->
<div class="clear"></div>
<div style="margin-bottom:20px; padding-top:10px;">
<div>
<div class="pull-left flush-left">
<h2><a href="<?php echo Format::htmlchars($_SERVER['REQUEST_URI']); ?>"
title="<?php echo __('Refresh'); ?>"><i class="icon-refresh"></i> <?php echo
$results_type.$showing; ?></a></h2>
</div>
<div class="pull-right flush-right">
<?php
if ($thisstaff->canDeleteTickets()) { ?>
<a id="tickets-delete" class="action-button pull-right tickets-action"
href="#tickets/status/delete"><i
class="icon-trash"></i> <?php echo __('Delete'); ?></a>
} ?>
<?php
if ($thisstaff->canManageTickets()) {
echo TicketStatus::status_options();
</div>
</div>
<div class="clear" style="margin-bottom:10px;"></div>
<form action="tickets.php" method="POST" name='tickets' id="tickets">
<input type="hidden" name="a" value="mass_process" >
<input type="hidden" name="do" id="action" value="" >
<input type="hidden" name="status" value="<?php echo Format::htmlchars($_REQUEST['status']); ?>" >
<table class="list" border="0" cellspacing="1" cellpadding="2" width="940">
<thead>
<tr>
<?php if($thisstaff->canManageTickets()) { ?>
<th width="8px"> </th>
<?php } ?>
<th width="70">
<a <?php echo $id_sort; ?> href="tickets.php?sort=ID&order=<?php echo $negorder; ?><?php echo $qstr; ?>"
title="<?php echo sprintf(__('Sort by %s %s'), __('Ticket ID'), __($negorder)); ?>"><?php echo __('Ticket'); ?></a></th>
<a <?php echo $date_sort; ?> href="tickets.php?sort=date&order=<?php echo $negorder; ?><?php echo $qstr; ?>"
title="<?php echo sprintf(__('Sort by %s %s'), __('Date'), __($negorder)); ?>"><?php echo __('Date'); ?></a></th>
<a <?php echo $subj_sort; ?> href="tickets.php?sort=subj&order=<?php echo $negorder; ?><?php echo $qstr; ?>"
title="<?php echo sprintf(__('Sort by %s %s'), __('Subject'), __($negorder)); ?>"><?php echo __('Subject'); ?></a></th>
<th width="170">
<a <?php echo $name_sort; ?> href="tickets.php?sort=name&order=<?php echo $negorder; ?><?php echo $qstr; ?>"
title="<?php echo sprintf(__('Sort by %s %s'), __('Name'), __($negorder)); ?>"><?php echo __('From');?></a></th>
<?php
if($search && !$status) { ?>
<th width="60">
<a <?php echo $status_sort; ?> href="tickets.php?sort=status&order=<?php echo $negorder; ?><?php echo $qstr; ?>"
title="<?php echo sprintf(__('Sort by %s %s'), __('Status'), __($negorder)); ?>"><?php echo __('Status');?></a></th>
<a <?php echo $pri_sort; ?> href="tickets.php?sort=pri&order=<?php echo $negorder; ?><?php echo $qstr; ?>"
title="<?php echo sprintf(__('Sort by %s %s'), __('Priority'), __($negorder)); ?>"><?php echo __('Priority');?></a></th>
//Closed by
if(!strcasecmp($status,'closed')) { ?>
<th width="150">
<a <?php echo $staff_sort; ?> href="tickets.php?sort=staff&order=<?php echo $negorder; ?><?php echo $qstr; ?>"
title="<?php echo sprintf(__('Sort by %s %s'), __("Closing Agent's Name"), __($negorder)); ?>"><?php echo __('Closed By'); ?></a></th>
<?php
} else { //assigned to ?>
<th width="150">
<a <?php echo $assignee_sort; ?> href="tickets.php?sort=assignee&order=<?php echo $negorder; ?><?php echo $qstr; ?>"
title="<?php echo sprintf(__('Sort by %s %s'), __('Assignee'), __($negorder)); ?>"><?php echo __('Assigned To'); ?></a></th>
<?php
}
<th width="150">
<a <?php echo $dept_sort; ?> href="tickets.php?sort=dept&order=<?php echo $negorder;?><?php echo $qstr; ?>"
title="<?php echo sprintf(__('Sort by %s %s'), __('Department'), __($negorder)); ?>"><?php echo __('Department');?></a></th>
// Setup Subject field for display
$subject_field = TicketForm::objects()->one()->getField('subject');
$ids=($errors && $_POST['tids'] && is_array($_POST['tids']))?$_POST['tids']:null;
$subject_field = TicketForm::objects()->one()->getField('subject');
foreach ($tickets as $T) {
$total += 1;
$tag=$T->staff_id?'assigned':'openticket';
$dept = ($T->dept) ? $T->dept->getLocalName() : '';
if($showassigned) {
if($T->staff_id)
$lc=sprintf('<span class="Icon staffAssigned">%s</span>',Format::truncate($T->staff->getName(),40));
$lc=sprintf('<span class="Icon teamAssigned">%s</span>',Format::truncate($T->team->getName(),40));
$lc=Format::truncate($dept,40);
$tid=$T->number;
$subject = Format::truncate($subject_field->display($subject_field->to_php($T->cdata->subject)),40);
if(!strcasecmp($T->status->state,'open') && !$T->isanswered && !$T->lock) {
<tr id="<?php echo $T->ticket_id; ?>">
<?php if($thisstaff->canManageTickets()) {
if($ids && in_array($T->ticket_id, $ids))
value="<?php echo $T->ticket_id; ?>" <?php echo $sel?'checked="checked"':''; ?>>
<td title="<?php echo $T->user->getDefaultEmailAddress(); ?>" nowrap>
<a class="Icon <?php echo strtolower($T->source); ?>Ticket ticketPreview" title="Preview Ticket"
href="tickets.php?id=<?php echo $T->ticket_id; ?>"><?php echo $tid; ?></a></td>
<td align="center" nowrap><?php echo Format::datetime($T->getEffectiveDate()); ?></td>
<td><a <?php if ($flag) { ?> class="Icon <?php echo $flag; ?>Ticket" title="<?php echo ucfirst($flag); ?> Ticket" <?php } ?>
href="tickets.php?id=<?php echo $T->ticket_id; ?>"><?php echo $subject; ?></a>
<?php
if ($threadcount>1)
echo "<small>($threadcount)</small> ".'<i
class="icon-fixed-width icon-comments-alt"></i> ';
if ($row['collaborators'])
echo '<i class="icon-fixed-width icon-group faded"></i> ';
if ($row['attachments'])
echo '<i class="icon-fixed-width icon-paperclip"></i> ';
?>
<td nowrap> <?php echo Format::htmlchars(
Format::truncate($T->user->getName(), 22, strpos($T->user->getName(), '@'))); ?> </td>
$displaystatus=ucfirst($T->status);
if(!strcasecmp($T->status->state,'open'))
$displaystatus="<b>$displaystatus</b>";
echo "<td>$displaystatus</td>";
} else { ?>
<td class="nohover" align="center" style="background-color:<?php echo $T->cdata->{':priority'}->priority_color; ?>;">
<?php echo $T->cdata->{':priority'}->priority_desc; ?></td>
?>
<td nowrap> <?php echo $lc; ?></td>
</tr>
<?php
} //end of foreach
if (!$total)
$ferror=__('There are no tickets matching your criteria.');
</tbody>
<tfoot>
<tr>
<td colspan="7">
<?php if($total && $thisstaff->canManageTickets()){ ?>
<?php echo __('Select');?>:
<a id="selectAll" href="#ckb"><?php echo __('All');?></a>
<a id="selectNone" href="#ckb"><?php echo __('None');?></a>
<a id="selectToggle" href="#ckb"><?php echo __('Toggle');?></a>
echo $ferror?Format::htmlchars($ferror):__('Query returned 0 results.');
} ?>
</td>
</tr>
</tfoot>
</table>
<?php
if($total>0){ //if we actually had any tickets returned.
echo '<div> '.__('Page').':'.$pageNav->getPageLinks().' ';
echo '<a class="export-csv no-pjax" href="?a=export&h='
.$hash.'&status='.$_REQUEST['status'] .'">'.__('Export').'</a> <i class="help-tip icon-question-sign" href="#export"></i></div>';
<div style="display:none;" class="dialog" id="confirm-action">
<h3><?php echo __('Please Confirm');?></h3>
<a class="close" href=""><i class="icon-remove-circle"></i></a>
<hr/>
<p class="confirm-action" style="display:none;" id="mark_overdue-confirm">
<?php echo __('Are you sure want to flag the selected tickets as <font color="red"><b>overdue</b></font>?');?>
<div><?php echo __('Please confirm to continue.');?></div>
<hr style="margin-top:1em"/>
<p class="full-width">
<span class="buttons pull-left">
<input type="button" value="<?php echo __('No, Cancel');?>" class="close">
<span class="buttons pull-right">
<input type="button" value="<?php echo __('Yes, Do it!');?>" class="confirm">
</span>
</p>
<div class="clear"></div>
</div>
<script type="text/javascript">
$(function() {
$(document).off('.tickets');
$(document).on('click.tickets', 'a.tickets-action', function(e) {
e.preventDefault();
var count = checkbox_checker($('form#tickets'), 1);
if (count) {
var url = 'ajax.php/'
+$(this).attr('href').substr(1)
+'?count='+count
+'&_uid='+new Date().getTime();
$.dialog(url, [201], function (xhr) {
window.location.href = window.location.href;
});
}
return false;
});
});
</script>