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

closed-by: Credit the agent opening a ticket

This PR addresses a bug where an agent-opened ticket doesn't set closed by
or mistakenly set it to auto-assigned agent when a status of closed state is
selected.

* Always credit the agent opening the ticket with close credit on closure
* Only do ticket auto-assignment IF the resulting status is in open state
parent 5acdf568
No related branches found
No related tags found
No related merge requests found
......@@ -3245,7 +3245,9 @@ implements RestrictedAccess, Threadable {
}
}
// Any error above is fatal.
// Any errors above are fatal.
if ($errors)
return 0;
......@@ -3427,38 +3429,39 @@ implements RestrictedAccess, Threadable {
// Configure service-level-agreement for this ticket
$ticket->selectSLAId($vars['slaId']);
// Assign ticket to staff or team (new ticket by staff)
if ($vars['assignId']) {
$asnform = $ticket->getAssignmentForm(array(
'assignee' => $vars['assignId'],
'comments' => $vars['note'])
);
$e = array();
$ticket->assign($asnform, $e);
}
else {
// Auto assign staff or team - auto assignment based on filter
// rules. Both team and staff can be assigned
if ($vars['staffId'])
$ticket->assignToStaff($vars['staffId'], false);
if ($vars['teamId'])
// No team alert if also assigned to an individual agent
$ticket->assignToTeam($vars['teamId'], false, !$vars['staffId']);
// Set status
$status = TicketStatus::lookup($statusId);
if (!$status || !$ticket->setStatus($status, false, $errors,
!strcasecmp($origin, 'staff'))) {
// Tickets _must_ have a status. Forceably set one here
$ticket->setStatusId($cfg->getDefaultTicketStatusId());
}
// Only do assignment if the ticket is in an open state
if ($ticket->isOpen()) {
// Assign ticket to staff or team (new ticket by staff)
if ($vars['assignId']) {
$asnform = $ticket->getAssignmentForm(array(
'assignee' => $vars['assignId'],
'comments' => $vars['note'])
);
$e = array();
$ticket->assign($asnform, $e);
}
else {
// Auto assign staff or team - auto assignment based on filter
// rules. Both team and staff can be assigned
if ($vars['staffId'])
$ticket->assignToStaff($vars['staffId'], false);
if ($vars['teamId'])
// No team alert if also assigned to an individual agent
$ticket->assignToTeam($vars['teamId'], false, !$vars['staffId']);
}
}
// Update the estimated due date in the database
$ticket->updateEstDueDate();
// Apply requested status — this should be done AFTER assignment,
// because if it is requested to be closed, it should not cause the
// ticket to be reopened for assignment.
if ($statusId) {
if (!$ticket->setStatus($statusId, false, $errors, false)) {
// Tickets _must_ have a status. Forceably set one here
$ticket->setStatusId($cfg->getDefaultTicketStatusId());
}
}
/********** double check auto-response ************/
//Override auto responder if the FROM email is one of the internal emails...loop control.
if($autorespond && (Email::getIdByEmail($ticket->getEmail())))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment