Part 2:
Next, in class.ticket.php you need to replace your current
function postReply()
with the following code
//Sturg2013 - Modified 'function postReply()' April 10 2013
//contains new dept members alerts and closed ticket alerts.
/* public */
function postReply($vars, &$errors, $alert = true) {
global $thisstaff, $cfg;
if(!$vars && $thisstaff)
$vars = $thisstaff->getName();
if(!$vars && $thisstaff)
$vars = $thisstaff->getId();
if(!($response = $this->getThread()->addResponse($vars, $errors)))
return null;
//Set status - if checked.
if(isset($vars) && $vars)
$this->setStatus($vars);
if(!$alert) return $response;
$this->reload(); //fix status updates first before sending mail.
//alert the user
if(!$alert) return $response;
$dept = $this->getDept();
if(!($tpl = $dept->getTemplate()))
$tpl= $cfg->getDefaultTemplate();
if(!$dept || !($email=$dept->getEmail()))
$email = $cfg->getDefaultEmail();
if($tpl && ($msg=$tpl->getReplyMsgTemplate()) && $email) {
if($thisstaff && $vars=='mine')
$signature=$thisstaff->getSignature();
elseif($vars=='dept' && $dept && $dept->isPublic())
$signature=$dept->getSignature();
else
$signature='';
$msg = $this->replaceVars($msg,
array('response' => $response, 'signature' => $signature, 'staff' => $thisstaff));
if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator()))
$msg ="\n$tag\n\n".$msg;
//Set attachments if emailing.
$attachments = $cfg->emailAttachments()?$response->getAttachments()();
//TODO: setup 5 param (options... e.g mid trackable on replies)
$email->send($this->getEmail(), $msg, $msg, $attachments);
}
$this->onResponse(); //do house cleaning..
$this->reload();
// If alerts are not enabled then return a success.
//Sturg2013 Reply Alerts now includes Dept Members -YAY!
if($alert || $cfg->alertONNewMessage()) {
$dept = $this->getDept();
if($tpl && ($msg=$tpl->getUpdateDeptMembersMsgTemplate()) && $email) {
$msg = $this->replaceVars($msg,
array('response' => $vars, 'staff' => $thisstaff));
// Alert recipients
$recipients=array();
//Someone else replies - get response back to Assignee
if($thisstaff->getId() != $this->getStaffId()) {
if($this->isAssigned() && $this->getStaffId() && !$this->isClosed())
$recipients=$this->getStaff();
}
//Sturg2013 - Alerts dept members if the ticket is NOT assigned.
if($cfg->alertDeptMembersONNewMessage() && !$this->isAssigned() && !$this->isClosed()) {
if(($members=$dept->getMembers()))
$recipients=array_merge($recipients, $members);
}
}
}
//Sturg2013 - MUST RELOAD!
$this->reload();
//Sturg2013 If Ticket is Closed:
//Closed Alerts
if($alert && $cfg->alertONClosedTicket() && $this->isClosed() ) {
$dept = $this->getDept();
if($tpl && ($msg=$tpl->getClosedAlertMsgTemplate()) && $email) {
$msg = $this->replaceVars($msg,
array('response' => $vars, 'staff' => $thisstaff));
// Alert recipients
$recipients=array();
//Assigned staff if any...could be the last respondent
//-- Sturg2013 -> not going to use this - redundant messages if in DEPT checked below
/* if($cfg->alertAssignedONClosedTicket() && $this->isAssigned() && $this->getStaffId())
$recipients=$this->getStaff(); */
//Dept manager
if($cfg->alertDeptManagerONClosedTicket() && $dept && $dept->getManagerId())
$recipients=$dept->getManager();
//Sturg2013 - Only alerts dept members if the ticket is NOT assigned.
if($cfg->alertDeptMembersONClosedTicket()) {
if(($members=$dept->getMembers()))
$recipients=array_merge($recipients, $members);
}
}
}
$attachments = $cfg->emailAttachments()?$response->getAttachments()();
$sentlist=array();
foreach( $recipients as $k=>$staff) {
if(!$staff || !is_object($staff) || !$staff->getEmail() || !$staff->isAvailable()) continue;
if(in_array($staff->getEmail(),$sentlist) || ($staffId && $staffId==$staff->getId())) continue;
$alert = str_replace('%{recipient}',$staff->getFirstName(), $msg);
$email->sendAlert($staff->getEmail(), $msg, $alert, $attachments);
$sentlist = $staff->getEmail();
}
return $response;
}
Then go to include\class.template.php
find the following code
case 'overdue_alert':
$sql.=',ticket_overdue_subj='.db_input($vars).',ticket_overdue_body='.db_input($vars);
break;
And after it add the following:
//sturg2013
case 'closed_alert':
$sql.=',ticket_closed_subj='.db_input($vars).',ticket_closed_body='.db_input($vars);
break;
case 'ticket_upd_mbers_alert':
$sql.=',ticket_upd_mbers_subj='.db_input($vars).',ticket_upd_mbers_body='.db_input($vars);
break;
find the following code
function getOverdueAlertMsgTemplate() {
return $this->getMsgTemplate('overdue_alert');
}
and add below it
function getClosedAlertMsgTemplate() {
return $this->getMsgTemplate('closed_alert');
}
function getUpdateDeptMembersMsgTemplate() {
return $this->getMsgTemplate('ticket_upd_mbers_alert');
}
and in the same file - find the following code further down and modify it with a -->>COMMA !!!
'overdue_alert'=>array('name'=>'Overdue Ticket Alert',
'desc'=>'Alert sent to staff on stale or overdue tickets.'),
and after it add the following code
'closed_alert'=>array('name'=>'Closed Ticket Alert',
'desc'=>'Alert sent to staff on Closed tickets.'),
'ticket_upd_mbers_alert'=>array('name'=>'Update Dept Members Ticket Alert',
'desc'=>'Alert sent to staff for updates on unassigned tickets.')
Then further down - find the following code:
.' ,ticket_overdue_subj='.db_input($info)
.' ,ticket_overdue_body='.db_input($info)
And add after it:
// Closed Ticket Alert for Department Members,Added By Sturg2013 February 27, 2013 -- originally modified by Masino Sinaga, February 27, 2010 -- wow 3 years on the nose! Great Karma!
.',ticket_closed_subj='.db_input($info)
.',ticket_closed_body='.db_input($info)
//Sturg2013 -- Update the team with message when unassigned - db entries
.',ticket_upd_mbers_subj='.db_input($info)
.',ticket_upd_mbers_body='.db_input($info)