diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index 01a537117382bb66c50d580ca7de5bfcdc80fed8..3d93e9a9cf3585d38189e8c705dafe54246fa2aa 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -135,8 +135,8 @@ class TicketsAjaxAPI extends AjaxController { // Status if ($req['statusId'] && ($status=TicketStatus::lookup($req['statusId']))) { - $where .= sprintf(' AND status.state="%s" ', - $status->getState()); + $where .= sprintf(' AND status.id="%d" ', + $status->getId()); $criteria['status_id'] = $status->getId(); } @@ -701,7 +701,7 @@ class TicketsAjaxAPI extends AjaxController { return $canned->getFormattedResponse($format, $varReplacer); } - function changeTicketStatus($tid, $status) { + function changeTicketStatus($tid, $status, $id=0) { global $thisstaff; if (!$thisstaff) @@ -748,7 +748,7 @@ class TicketsAjaxAPI extends AjaxController { $info['title'] = sprintf('%s %s #%s', $verb ?: $status, __('Ticket'), $ticket->getNumber()); - $info['status_id'] = $_REQUEST['status_id'] ?: $ticket->getStatusId(); + $info['status_id'] = $_REQUEST['status_id'] ?: $id ?: $ticket->getStatusId(); return self::_setStatus($state, $info); } @@ -901,9 +901,9 @@ class TicketsAjaxAPI extends AjaxController { } } + $count = count($_REQUEST['tids']); if (!$errors) { $i = 0; - $count = count($_REQUEST['tids']); $comments = $_REQUEST['comments']; foreach ($_REQUEST['tids'] as $tid) { if (($ticket=Ticket::lookup($tid)) @@ -914,8 +914,8 @@ class TicketsAjaxAPI extends AjaxController { } if (!$i) - $errors['err'] = sprintf(__('Unable to set status for %s'), - _N('selected ticket', 'selected tickets', $count)); + $errors['err'] = sprintf(__('Unable to change status for %s'), + _N('the selected ticket', 'any of the selected tickets', $count)); else { // Assume success if ($i==$count) { @@ -936,6 +936,17 @@ class TicketsAjaxAPI extends AjaxController { } } + $info['title'] = sprintf('%s %s', + TicketStateField::getVerb($state), + __('Tickets')); + + if ($count) + $info['title'] .= sprintf(' — %d %s', + $count, __('selected')); + + + $info['status_id'] = $_REQUEST['status_id']; + $info['comments'] = Format::htmlchars($_REQUEST['comments']); $info['errors'] = $errors; return self::_setStatus($state, $info); } diff --git a/include/class.list.php b/include/class.list.php index 3decd37f97c2efe00d63100963496d184d30265b..b4423c3aab51662afb6cb316582607ed81f3b50b 100644 --- a/include/class.list.php +++ b/include/class.list.php @@ -1036,7 +1036,7 @@ class TicketStatus extends VerySimpleModel implements CustomListItem { return $status; } - static function options() { + static function status_options() { include(STAFFINC_DIR . 'templates/status-options.tmpl.php'); } } diff --git a/include/staff/templates/status-options.tmpl.php b/include/staff/templates/status-options.tmpl.php index ebc5db6cb1fe6692ee0e07835cf5936da24691de..19235f19b9d07aa79d5b8e4d6910605d3318cf0e 100644 --- a/include/staff/templates/status-options.tmpl.php +++ b/include/staff/templates/status-options.tmpl.php @@ -1,60 +1,60 @@ <?php +global $thisstaff, $ticket; +// Map states to actions $actions= array( - 'close' => array( + 'closed' => array( 'icon' => 'icon-repeat', - 'state' => 'closed' + 'action' => 'close' ), - 'resolve' => array( + 'resolved' => array( 'icon' => 'icon-ok-circle', - 'state' => 'resolved' + 'action' => 'resolve' ), - 'reopen' => array( + 'open' => array( 'icon' => 'icon-undo', - 'state' => 'open' + 'action' => 'reopen' ), ); +?> -foreach($actions as $k => $v) { - $criteria = array('states' => array($v['state'])); - if (!($statuses = TicketStatusList::getStatuses($criteria)->all())) - continue; - - if ($statuses && count($statuses) > 1) { - ?> - <span - class="action-button" - data-dropdown="#action-dropdown-<?php echo $k; ?>"> - <a id="tickets-<?php echo $k; ?>" - class="tickets-action" - href="#tickets/status/<?php echo $k; ?>"><i - class="<?php echo $v['icon']; ?>"></i> <?php - echo TicketStateField::getVerb($v['state']); ?></a> - <i class="icon-caret-down"></i> - </span> - <div id="action-dropdown-<?php echo $k; ?>" - class="action-dropdown anchor-right"> - <ul> - <?php - foreach ($statuses as $s) { - ?> +<span + class="action-button" + data-dropdown="#action-dropdown-statuses"> + <a class="tickets-action" + href="#statuses"><i + class="icon-flag"></i> <?php + echo __('Change Status'); ?></a> + <i class="icon-caret-down"></i> +</span> +<div id="action-dropdown-statuses" + class="action-dropdown anchor-right"> + <ul> + <?php + $states = array('open'); + if ($thisstaff->canCloseTickets()) + $states = array_merge($states, + array('resolved', 'closed')); - <li> - <a class="no-pjax tickets-action" - href="#tickets/status/<?php echo $k; ?>/<?php - echo $s->getId(); ?>"> <i - class="icon-tag"></i> <?php echo __($s->getName()); ?></a> </li> - <?php - } ?> - </ul> - </div> + $statusId = $ticket ? $ticket->getStatusId() : 0; + foreach (TicketStatusList::getStatuses( + array('states' => $states))->all() as $status) { + if (!isset($actions[$status->getState()]) + || $statusId == $status->getId()) + continue; + ?> + <li> + <a class="no-pjax <?php + echo $ticket? 'ticket-action' : 'tickets-action'; ?>" + href="<?php + echo sprintf('#%s/status/%s/%d', + $ticket ? ('tickets/'.$ticket->getId()) : 'tickets', + $actions[$status->getState()]['action'], + $status->getId()); ?>"><i class=" aaa <?php + echo $actions[$status->getState()]['icon'] ?: 'icon-tag'; + ?>"></i> <?php + echo __($status->getName()); ?></a> + </li> <?php - } else { - ?> - <a id="tickets-<?php echo $k; ?>" class="action-button tickets-action" - href="#tickets/status/<?php echo $k; ?>"><i - class="<?php echo $v['icon']; ?>"></i> <?php - echo TicketStateField::getVerb($v['state']); ?></a> -<?php - } -} -?> + } ?> + </ul> +</div> diff --git a/include/staff/templates/ticket-status.tmpl.php b/include/staff/templates/ticket-status.tmpl.php index 8646a05cf439b1f550b6b992fdeef8d72d4df1ee..7f7dc7d647edec0ff78f9217f3c111392c0e4ce2 100644 --- a/include/staff/templates/ticket-status.tmpl.php +++ b/include/staff/templates/ticket-status.tmpl.php @@ -86,7 +86,7 @@ $action = $info['action'] ?: ('#tickets/status/'. $state); cols="50" rows="3" wrap="soft" style="width:100%" class="richtext ifhtml no-bar" placeholder="<?php echo $placeholder; ?>"><?php - echo $info['notes']; ?></textarea> + echo $info['comments']; ?></textarea> </td> </tr> </tbody> diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index addb9aa3bbe019388755a78388fb548708687338..6d02950177062c676b704805e778fe2a092f2379 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -56,29 +56,15 @@ if($ticket->isOverdue()) </span> <?php } - if($thisstaff->canCloseTickets()) { - if($ticket->isOpen()) {?> - <a class="action-button ticket-action" - href="#tickets/<?php echo $ticket->getId() - ?>/status/close"><i class="icon-repeat"></i> <?php echo __('Close');?></a> - <a class="action-button ticket-action" - href="#tickets/<?php echo $ticket->getId() - ?>/status/resolve"><i class="icon-ok-circle"></i> <?php echo __('Resolve');?></a> - <?php - } else { ?> - <a class="action-button ticket-action" - href="#tickets/<?php echo $ticket->getId() - ?>/status/reopen"><i class="icon-undo"></i> <?php echo - __('Reopen');?></a> - <?php - } - } - if($thisstaff->canEditTickets()) { ?> + // Status change options + echo TicketStatus::status_options(); + + if ($thisstaff->canEditTickets()) { ?> <a class="action-button" href="tickets.php?id=<?php echo $ticket->getId(); ?>&a=edit"><i class="icon-edit"></i> <?php echo __('Edit'); ?></a> <?php } - if($ticket->isOpen() && !$ticket->isAssigned() && $thisstaff->canAssignTickets()) {?> + if ($ticket->isOpen() && !$ticket->isAssigned() && $thisstaff->canAssignTickets()) {?> <a id="ticket-claim" class="action-button confirm-action" href="#claim"><i class="icon-user"></i> <?php echo __('Claim'); ?></a> diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php index 8c3f4c5ed6bc58338cd739219d21374be9abf465..3f828d210662a13a70264c9405069e991b7fe252 100644 --- a/include/staff/tickets.inc.php +++ b/include/staff/tickets.inc.php @@ -55,9 +55,10 @@ switch(strtolower($_REQUEST['status'])){ //Status is overloaded $results_type=__('Answered Tickets'); break; default: - if(!$search && !isset($_REQUEST['advsid'])) + if (!$search && !isset($_REQUEST['advsid'])) { $_REQUEST['status']=$status='open'; - $results_type=__('Open Tickets'); + $results_type=__('Open Tickets'); + } } $qwhere =''; @@ -335,12 +336,17 @@ if ($results) { $results_type.$showing; ?></a></h2> </div> <div class="pull-right flush-right"> + + <?php + if ($thisstaff->canDeleteTickets()) { ?> <a id="tickets-delete" class="action-button tickets-action" href="#tickets/status/delete"><i class="icon-trash"></i> <?php echo __('Delete'); ?></a> <?php - if ($res && $results && $thisstaff->canManageTickets()) { - echo TicketStatus::options(); + } ?> + <?php + if ($thisstaff->canManageTickets()) { + echo TicketStatus::status_options(); } ?> </div> diff --git a/scp/ajax.php b/scp/ajax.php index 7cfe289d568964f6fd8fb22e5b4f349460d793ab..7ce76dc97a96ad86dd9903631d30b6210b9ba1dd 100644 --- a/scp/ajax.php +++ b/scp/ajax.php @@ -140,7 +140,7 @@ $dispatcher = patterns('', url_get('^(?P<tid>\d+)/forms/manage$', 'manageForms'), url_post('^(?P<tid>\d+)/forms/manage$', 'updateForms'), url_get('^(?P<tid>\d+)/canned-resp/(?P<cid>\w+).(?P<format>json|txt)', 'cannedResponse'), - url_get('^(?P<tid>\d+)/status/(?P<status>\w+)$', 'changeTicketStatus'), + url_get('^(?P<tid>\d+)/status/(?P<status>\w+)(?:/(?P<sid>\d+))?$', 'changeTicketStatus'), url_post('^(?P<tid>\d+)/status/(?P<status>\w+)$', 'setTicketStatus'), url_get('^status/(?P<status>\w+)(?:/(?P<sid>\d+))?$', 'changeTicketsStatus'), url_post('^status/(?P<state>\w+)$', 'setTicketsStatus'),