diff --git a/include/class.task.php b/include/class.task.php index edf0a0e87e3fef8df2048e4ce24b22b976c9549a..55671d1af58b9ac43cb9939bd94ecaf5b95f8df7 100644 --- a/include/class.task.php +++ b/include/class.task.php @@ -170,8 +170,7 @@ class TaskModel extends VerySimpleModel { } function getCloseDate() { - // TODO: have true close date - return $this->isClosed() ? $this->updated : ''; + return $this->isClosed() ? $this->closed : ''; } function isOpen() { @@ -805,8 +804,8 @@ class Task extends TaskModel implements RestrictedAccess, Threadable { $assignee = $this->getStaff(); - if (isset($vars['task_status'])) - $this->setStatus($vars['task_status']); + if (isset($vars['task:status'])) + $this->setStatus($vars['task:status']); $this->onActivity(array( 'activity' => $note->getActivity(), @@ -835,12 +834,9 @@ class Task extends TaskModel implements RestrictedAccess, Threadable { return null; $assignee = $this->getStaff(); - // Set status - if checked. - if ($vars['reply_status_id'] - && $vars['reply_status_id'] != $this->getStatusId() - ) { - $this->setStatus($vars['reply_status_id']); - } + + if (isset($vars['task:status'])) + $this->setStatus($vars['task:status']); /* // TODO: add auto claim setting for tasks. diff --git a/include/class.thread.php b/include/class.thread.php index 0636df348a0d3a990a5778f1793ef80f165e762b..7e94e08d794274e2d49bbeb63f3213626743c44b 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -1818,7 +1818,10 @@ class CloseEvent extends ThreadEvent { static $state = 'closed'; function getDescription($mode=self::MODE_STAFF) { - return $this->template(__('Closed by <b>{somebody}</b> with status of {<TicketStatus>data.status} {timestamp}')); + if ($this->getData('status')) + return $this->template(__('Closed by <b>{somebody}</b> with status of {<TicketStatus>data.status} {timestamp}')); + else + return $this->template(__('Closed by <b>{somebody}</b> {timestamp}')); } } diff --git a/include/class.ticket.php b/include/class.ticket.php index fa4024056d6eb33dc160063773ff4843e6ff8ae2..9c0181fcd5be2c894a27643800a319c6421807e7 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1931,8 +1931,9 @@ implements RestrictedAccess, Threadable { $this->logEvent('transferred'); // Post internal note if any - $note = $form->getField('comments')->getClean(); - if ($note) { + $note = null; + $comments = $form->getField('comments')->getClean(); + if ($comments) { $title = sprintf(__('%1$s transferred from %2$s to %3$s'), __('Ticket'), $cdept->getName(), @@ -1940,7 +1941,7 @@ implements RestrictedAccess, Threadable { $_errors = array(); $note = $this->postNote( - array('note' => $note, 'title' => $title), + array('note' => $comments, 'title' => $title), $_errors, $thisstaff, false); } @@ -1980,7 +1981,7 @@ implements RestrictedAccess, Threadable { ) { $recipients[] = $manager; } - $sentlist = array(); + $sentlist = $options = array(); if ($note) { $options += array( 'inreplyto'=>$note->getEmailMessageId(), diff --git a/include/staff/tasks.inc.php b/include/staff/tasks.inc.php index 9dbd1c3c4fbc3bccd1db790375e7ecdeb131ab07..4b0b333c9d8cd332402e5f7498bab479a9279632 100644 --- a/include/staff/tasks.inc.php +++ b/include/staff/tasks.inc.php @@ -24,11 +24,14 @@ $sort_options = array( 'relevance' => __('Relevance'), ); -$queue_name = strtolower($_GET['status'] ?: $_GET['a']); //Status is overloaded +// Queue we're viewing +$queue_key = sprintf('::Q:%s', ObjectModel::OBJECT_TYPE_TASK); +$queue_name = $_SESSION[$queue_key] ?: ''; + switch ($queue_name) { case 'closed': $status='closed'; - $results_type=__('Closed Tasks'); + $results_type=__('Completed Tasks'); $showassigned=true; //closed by. $queue_sort_options = array('closed', 'updated', 'created', 'number', 'hot'); @@ -56,6 +59,7 @@ case 'search': 'number__startswith' => $_REQUEST['query'], 'cdata__title__contains' => $_REQUEST['query'], ))); + unset($_SESSION[$queue_key]); break; } elseif (isset($_SESSION['advsearch:tasks'])) { // XXX: De-duplicate and simplify this code @@ -418,8 +422,12 @@ $(function() { +$(this).attr('href').substr(1) +'?count='+count +'&_uid='+new Date().getTime(); + var $redirect = $(this).data('redirect'); $.dialog(url, [201], function (xhr) { - $.pjax.reload('#pjax-container'); + if (!!$redirect) + $.pjax({url: $redirect, container:'#pjax-container'}); + else + $.pjax.reload('#pjax-container'); }); } return false; @@ -433,7 +441,7 @@ $(function() { var $options = $(this).data('dialogConfig'); var $redirect = $(this).data('redirect'); $.dialog(url, [201], function (xhr) { - if ($redirect) + if (!!$redirect) window.location.href = $redirect; else $.pjax.reload('#pjax-container'); diff --git a/include/staff/templates/status-options.tmpl.php b/include/staff/templates/status-options.tmpl.php index 71e05981f349a83830ab8c980f5f5daaa7e8beab..1f9918f26ca44c70df7cd72e2af925d598cc84fe 100644 --- a/include/staff/templates/status-options.tmpl.php +++ b/include/staff/templates/status-options.tmpl.php @@ -55,7 +55,7 @@ if (!$nextStatuses) $status->getId()); ?>" <?php if (isset($actions[$status->getState()]['href'])) - echo sprintf('data-href="%s"', + echo sprintf('data-redirect="%s"', $actions[$status->getState()]['href']); ?> diff --git a/include/staff/templates/task-preview.tmpl.php b/include/staff/templates/task-preview.tmpl.php index e4488321071b78103592d951978a53fe4212745d..e1f32892c94ce791f7d90979920a2e885e1a6286 100644 --- a/include/staff/templates/task-preview.tmpl.php +++ b/include/staff/templates/task-preview.tmpl.php @@ -48,7 +48,16 @@ echo sprintf(' </tr>',$status, Format::datetime($task->getCreateDate())); -if ($task->isOpen() && $task->duedate) { +if ($task->isClosed()) { + + echo sprintf(' + <tr> + <th>'.__('Completed').':</th> + <td>%s</td> + </tr>', + Format::datetime($task->getCloseDate())); + +} elseif ($task->isOpen() && $task->duedate) { echo sprintf(' <tr> <th>'.__('Due Date').':</th> diff --git a/include/staff/templates/task-view.tmpl.php b/include/staff/templates/task-view.tmpl.php index eae5ad98d491033300ef5f757da19dda2ca8d0a7..b69be9dfbb1f19742eb8094a8346845ee12923ee 100644 --- a/include/staff/templates/task-view.tmpl.php +++ b/include/staff/templates/task-view.tmpl.php @@ -32,7 +32,8 @@ if ($role->hasPerm(Task::PERM_ASSIGN)) { 'assign' => array( 'href' => sprintf('#tasks/%d/assign', $task->getId()), 'icon' => 'icon-user', - 'label' => $task->isAssigned() ? __('Reassign') : __('Assign') + 'label' => $task->isAssigned() ? __('Reassign') : __('Assign'), + 'redirect' => 'tasks.php' )); } @@ -41,7 +42,8 @@ if ($role->hasPerm(Task::PERM_TRANSFER)) { 'transfer' => array( 'href' => sprintf('#tasks/%d/transfer', $task->getId()), 'icon' => 'icon-share', - 'label' => __('Transfer') + 'label' => __('Transfer'), + 'redirect' => 'tasks.php' )); } @@ -52,7 +54,8 @@ if ($role->hasPerm(Task::PERM_DELETE)) { 'href' => sprintf('#tasks/%d/delete', $task->getId()), 'icon' => 'icon-trash', 'class' => 'red button task-action', - 'label' => __('Delete') + 'label' => __('Delete'), + 'redirect' => 'tasks.php' )); } @@ -157,6 +160,8 @@ if ($task->isOverdue()) <?php if ($action['dialog']) echo sprintf("data-dialog-config='%s'", $action['dialog']); + if ($action['redirect']) + echo sprintf("data-redirect='%s'", $action['redirect']); ?> href="<?php echo $action['href']; ?>"><i class="<?php @@ -183,7 +188,7 @@ if (!$ticket) { ?> </tr> <tr> - <th><?php echo __('Create Date');?>:</th> + <th><?php echo __('Created');?>:</th> <td><?php echo Format::datetime($task->getCreateDate()); ?></td> </tr> <?php @@ -197,7 +202,7 @@ if (!$ticket) { ?> <?php }else { ?> <tr> - <th><?php echo __('Close Date');?>:</th> + <th><?php echo __('Completed');?>:</th> <td><?php echo Format::datetime($task->getCloseDate()); ?></td> </tr> <?php @@ -399,7 +404,7 @@ else <td> <div><?php echo __('Status');?> <span class="faded"> - </span> - <select name="task_status"> + <select name="task:status"> <option value="open" <?php echo $task->isOpen() ? 'selected="selected"': ''; ?>> <?php @@ -415,7 +420,7 @@ else } ?> </select> <span class='error'><?php echo - $errors['task_status']; ?></span> + $errors['task:status']; ?></span> </div> </td> </tr> @@ -459,7 +464,7 @@ else <td> <div><?php echo __('Status');?> <span class="faded"> - </span> - <select name="task_status"> + <select name="task:status"> <option value="open" <?php echo $task->isOpen() ? 'selected="selected"': ''; ?>> <?php @@ -475,7 +480,7 @@ else } ?> </select> <span class='error'><?php echo - $errors['task_status']; ?></span> + $errors['task:status']; ?></span> </div> </td> </tr> @@ -509,7 +514,7 @@ $(function() { var $options = $(this).data('dialogConfig'); var $redirect = $(this).data('redirect'); $.dialog(url, [201], function (xhr) { - if ($redirect) + if (!!$redirect) window.location.href = $redirect; else $.pjax.reload('#pjax-container'); diff --git a/include/staff/templates/tasks-actions.tmpl.php b/include/staff/templates/tasks-actions.tmpl.php index fcf6192a42b6289ca7b45ff529292f93ff14a694..04696a7714499e87b20aa35f0e3140d79921d17e 100644 --- a/include/staff/templates/tasks-actions.tmpl.php +++ b/include/staff/templates/tasks-actions.tmpl.php @@ -71,6 +71,7 @@ if ($agent->hasPerm(Task::PERM_TRANSFER, false)) { $actions += array( 'transfer' => array( 'icon' => 'icon-share', + 'redirect' => 'tickets.php', 'action' => __('Transfer') )); } diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index ea79bc6c1ecfa7dbda2356ee5d4c6a7d70843282..5bf1a6e5c988d9b94a3549eeb474508cab34669c 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -76,6 +76,7 @@ if($ticket->isOverdue()) // Transfer if ($role->hasPerm(TicketModel::PERM_TRANSFER)) {?> <a class="ticket-action action-button pull-right" id="ticket-transfer" + data-redirect="tickets.php" href="#tickets/<?php echo $ticket->getId(); ?>/transfer"><i class="icon-share"></i> <?php echo __('Transfer'); ?></a> <?php @@ -86,16 +87,24 @@ if($ticket->isOverdue()) if ($role->hasPerm(TicketModel::PERM_ASSIGN)) {?> <span class="action-button pull-right" data-dropdown="#action-dropdown-assign"> <i class="icon-caret-down pull-right"></i> - <a class="ticket-action" id="ticket-assign" href="#tickets/<?php echo $ticket->getId(); ?>/assign"><i class="icon-user"></i> <?php + <a class="ticket-action" id="ticket-assign" + data-redirect="tickets.php" + href="#tickets/<?php echo $ticket->getId(); ?>/assign"><i class="icon-user"></i> <?php echo $ticket->isAssigned() ? __('Assign') : __('Reassign'); ?></a> </span> <div id="action-dropdown-assign" class="action-dropdown anchor-right"> <ul> - <li><a class="no-pjax ticket-action" href="#tickets/<?php echo $ticket->getId(); ?>/assign/<?php echo $thisstaff->getId(); ?>"><i + <li><a class="no-pjax ticket-action" + data-redirect="tickets.php" + href="#tickets/<?php echo $ticket->getId(); ?>/assign/<?php echo $thisstaff->getId(); ?>"><i class="icon-chevron-sign-down"></i> <?php echo __('Claim'); ?></a> - <li><a class="no-pjax ticket-action" href="#tickets/<?php echo $ticket->getId(); ?>/assign/agents"><i + <li><a class="no-pjax ticket-action" + data-redirect="tickets.php" + href="#tickets/<?php echo $ticket->getId(); ?>/assign/agents"><i class="icon-user"></i> <?php echo __('Agent'); ?></a> - <li><a class="no-pjax ticket-action" href="#tickets/<?php echo $ticket->getId(); ?>/assign/teams"><i + <li><a class="no-pjax ticket-action" + data-redirect="tickets.php" + href="#tickets/<?php echo $ticket->getId(); ?>/assign/teams"><i class="icon-group"></i> <?php echo __('Team'); ?></a> </ul> </div> @@ -173,7 +182,7 @@ if($ticket->isOverdue()) ?> <li class="danger"><a class="ticket-action" href="#tickets/<?php echo $ticket->getId(); ?>/status/delete" - data-href="tickets.php"><i class="icon-trash"></i> <?php + data-redirect="tickets.php"><i class="icon-trash"></i> <?php echo __('Delete Ticket'); ?></a></li> <?php } diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php index a47ba72662cbabfed2f2e48a2dfa165483541adb..34dee7b1d1666819d0a8b6114c0eeb8e25740d1d 100644 --- a/include/staff/tickets.inc.php +++ b/include/staff/tickets.inc.php @@ -33,10 +33,9 @@ $sort_options = array( ); $use_subquery = true; -$queue_name = strtolower($_GET['a'] ?: $_GET['status']); //Status is overloaded - -// Stash current queue view -$_SESSION['::Q'] = $queue_name; +// Figure out the queue we're viewing +$queue_key = sprintf('::Q:%s', ObjectModel::OBJECT_TYPE_TICKET); +$queue_name = $_SESSION[$queue_key] ?: ''; switch ($queue_name) { case 'closed': @@ -106,6 +105,8 @@ case 'search': } $tickets->filter($basic_search); } + // Clear sticky search queue + unset($_SESSION[$queue_key]); break; } elseif (isset($_SESSION['advsearch'])) { $form = $search->getFormFromSession('advsearch'); diff --git a/scp/js/ticket.js b/scp/js/ticket.js index 21ed2f415ba93a720603cab01cb17b2f1f222211..61ba8c7b84f9364b1863042dd32a4986dacbf598 100644 --- a/scp/js/ticket.js +++ b/scp/js/ticket.js @@ -328,10 +328,13 @@ var ticket_onload = function($) { var url = 'ajax.php/' +$(this).attr('href').substr(1) +'?_uid='+new Date().getTime(); - var $redirect = $(this).data('href'); + var $redirect = $(this).data('redirect'); var $options = $(this).data('dialog'); $.dialog(url, [201], function (xhr) { - window.location.href = $redirect ? $redirect : window.location.href; + if (!!$redirect) + window.location.href = $redirect; + else + $.pjax.reload('#pjax-container'); }, $options); return false; diff --git a/scp/tasks.php b/scp/tasks.php index ced34f872ad4bd73cd9e75af307393f5c31b84ef..f33018f3252569cd9ace6f0de58115d1e7ee7a26 100644 --- a/scp/tasks.php +++ b/scp/tasks.php @@ -118,6 +118,24 @@ $stats= $thisstaff->getTasksStats(); if (isset($_GET['clear_filter'])) unset($_SESSION['advsearch:tasks']); + +if (!$task) { + $queue_key = sprintf('::Q:%s', ObjectModel::OBJECT_TYPE_TASK); + $queue_name = strtolower($_GET['status'] ?: $_GET['a']); + if (!$queue_name && isset($_SESSION[$queue_key])) + $queue_name = $_SESSION[$queue_key]; + + // Stash current queue view + $_SESSION[$queue_key] = $queue_name; + + // Set queue as status + if (@!isset($_REQUEST['advanced']) + && @$_REQUEST['a'] != 'search' + && !isset($_GET['status']) + && $queue_name) + $_GET['status'] = $_REQUEST['status'] = $queue_name; +} + //Navigation $nav->setTabActive('tasks'); $open_name = _P('queue-name', diff --git a/scp/tickets.php b/scp/tickets.php index fadaf9730c037c6a04dbfe1c717f1f118e55981e..e5e03aa2ea37dbe603e5e53f916bc9c4b35db038 100644 --- a/scp/tickets.php +++ b/scp/tickets.php @@ -35,13 +35,25 @@ if($_REQUEST['id']) { } } -//Lookup user if id is available. if ($_REQUEST['uid']) { $user = User::lookup($_REQUEST['uid']); +} elseif (!$ticket) { + $queue_key = sprintf('::Q:%s', ObjectModel::OBJECT_TYPE_TICKET); + $queue_name = strtolower($_GET['status'] ?: $_GET['a']); //Status is overloaded + if (!$queue_name && isset($_SESSION[$queue_key])) + $queue_name = $_SESSION[$queue_key]; + + // Stash current queue view + $_SESSION[$queue_key] = $queue_name; + + // Set queue as status + if (@!isset($_REQUEST['advanced']) + && @$_REQUEST['a'] != 'search' + && !isset($_GET['status']) + && $queue_name) + $_GET['status'] = $_REQUEST['status'] = $queue_name; } -elseif (@!isset($_REQUEST['advanced']) && @$_REQUEST['a'] != 'search' && !isset($_GET['status']) && isset($_SESSION['::Q'])) { - $_GET['status'] = $_REQUEST['status'] = $_SESSION['::Q']; -} + // Configure form for file uploads $response_form = new SimpleForm(array( 'attachments' => new FileUploadField(array('id'=>'attach',