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

Mass claim/assignment

parent 6a7bcfa9
No related branches found
No related tags found
No related merge requests found
......@@ -496,7 +496,8 @@ class TicketsAjaxAPI extends AjaxController {
__('This ticket'),
$assigned);
} else {
$info['warn'] = __('Are you sure you want to claim this ticket?');
$info['warn'] = sprintf(__('Are you sure you want to claim %s?'),
__('this ticket'));
}
if ($_POST && $form->isValid()) {
......@@ -521,7 +522,7 @@ class TicketsAjaxAPI extends AjaxController {
}
function massProcess($action) {
function massProcess($action, $w=null) {
global $thisstaff;
$actions = array(
......@@ -531,6 +532,9 @@ class TicketsAjaxAPI extends AjaxController {
'assign' => array(
'verbed' => __('assigned'),
),
'claim' => array(
'verbed' => __('assigned'),
),
'delete' => array(
'verbed' => __('deleted'),
),
......@@ -558,12 +562,56 @@ class TicketsAjaxAPI extends AjaxController {
$count = $_REQUEST['count'];
}
switch ($action) {
case 'claim':
$w = 'me';
case 'assign':
$inc = 'assign.tmpl.php';
$info[':action'] = '#tickets/mass/assign';
$info[':title'] = sprintf('Assign %s',
_N('selected ticket', 'selected tickets', $count));
$form = AssignmentForm::instantiate($_POST);
$assignCB = function($t, $f, $e) {
return $t->assign($f, $e);
};
$assignees = array();
switch ($w) {
case 'agents':
$prompt = __('Select an Agent');
foreach (Staff::getAvailableStaffMembers() as $id => $name)
$assignees['s'.$id] = $name;
break;
case 'teams':
$prompt = __('Select a Team');
foreach (Team::getActiveTeams() as $id => $name)
$assignees['t'.$id] = $name;
break;
case 'me':
$info[':action'] = '#tickets/mass/claim';
$info[':title'] = sprintf('Claim %s',
_N('selected ticket', 'selected tickets', $count));
$info['warn'] = sprintf(__('Are you sure you want to claim %s?'),
_N('selected ticket', 'selected tickets', $count));
$verb = sprintf('%s, %s', __('Yes'), __('Claim'));
$id = sprintf('s%s', $thisstaff->getId());
$assignees = array($id => $thisstaff->getName());
$vars = $_POST ?: array('assignee' => array($id));
$form = ClaimForm::instantiate($vars);
$assignCB = function($t, $f, $e) {
return $t->claim($f, $e);
};
break;
}
if ($assignees)
$form->setAssignees($assignees);
if ($prompt && ($f=$form->getField('assignee')))
$f->configure('prompt', $prompt);
if ($_POST && $form->isValid()) {
foreach ($_POST['tids'] as $tid) {
if (($t=Ticket::lookup($tid))
......@@ -571,7 +619,7 @@ class TicketsAjaxAPI extends AjaxController {
// access and assign the task.
&& $t->checkStaffPerm($thisstaff, Ticket::PERM_ASSIGN)
// Do the assignment
&& $t->assign($form, $e)
&& $assignCB($t, $form, $e)
)
$i++;
}
......
......@@ -19,7 +19,7 @@ if ($agent->hasPerm(Ticket::PERM_ASSIGN, false)) {?>
<div id="action-dropdown-assign" class="action-dropdown anchor-right">
<ul>
<li><a class="no-pjax tickets-action"
href="#tickets/mass/assign/<?php echo $agent->getId(); ?>"><i
href="#tickets/mass/claim"><i
class="icon-chevron-sign-down"></i> <?php echo __('Claim'); ?></a>
<li><a class="no-pjax tickets-action"
href="#tickets/mass/assign/agents"><i
......
......@@ -161,8 +161,7 @@ $dispatcher = patterns('',
url_get('^(?P<tid>\d+)/tasks/(?P<id>\d+)/view$', 'task'),
url_post('^(?P<tid>\d+)/tasks/(?P<id>\d+)$', 'task'),
url_get('^lookup', 'lookup'),
url_get('^mass/(?P<action>[\w.]+)', 'massProcess'),
url_post('^mass/(?P<action>[\w.]+)', 'massProcess'),
url('^mass/(?P<action>\w+)(?:/(?P<what>\w+))?', 'massProcess'),
url('^(?P<tid>\d+)/transfer$', 'transfer'),
url('^(?P<tid>\d+)/assign(?:/(?P<to>\w+))?$', 'assign'),
url('^(?P<tid>\d+)/claim$', 'claim'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment