Ive managed to add check buttons and sections for a USER/CLIENT to get the emails along with the email template area but just need this block off code changing to add the extras for sending alert to user...
ive used these variables:
closed_alert_client
ticket_closed_client_subj
ticket_closed_client_body
can anyone just add the correct code to allow to send the optional closure alerts to the clients/user email
//Close the ticket
function close(){
global $cfg;
$sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('closed').',staff_id=0,isoverdue=0,duedate=NULL,updated=NOW(),closed=NOW() '.
' WHERE ticket_id='.db_input($this->getId());
//return (db_query($sql) && db_affected_rows())?true;
// Closed Ticket Alert for Department Members, modified by Masino Sinaga, February 27, 2010 NOT FINISHED YET
if(db_query($sql) && db_affected_rows()) {
//echo $sql;
$dept=$this->getDept();
if(!$dept || !($tplId=$dept->getTemplateId()))
$tplId=$cfg->getDefaultTemplateId();
//if requested && enabled fire nasty alerts.
if($cfg->alertONClosedTicket()){
$sql='SELECT ticket_closed_subj,ticket_closed_body FROM '.EMAIL_TEMPLATE_TABLE.
' WHERE cfg_id='.db_input($cfg->getId()).' AND tpl_id='.db_input($tplId);
if(($resp=db_query($sql)) && db_num_rows($resp) && list($subj,$body)=db_fetch_row($resp)){
$body=$this->replaceTemplateVars($body);
$subj=$this->replaceTemplateVars($subj);
if(!($email=$cfg->getAlertEmail()))
$email=$cfg->getDefaultEmail();
if($email && $email->getId()) {
//Fire and email to admin. No questions asked.
$alert = str_replace("%staff",'Admin',$body);
$email->send($cfg->getAdminEmail(),$subj,$alert);
/*** Build list of recipients and fire the alerts ***/
$recipients=array();
//Assigned staff... if any
if($this->isAssigned() && $cfg->alertAssignedONClosedTicket()){
$recipients=$this->getStaff();
}elseif($cfg->alertDeptMembersONClosedTicket()){ //Alert assigned or dept members not both
//All dept members.
$sql='SELECT staff_id FROM '.STAFF_TABLE.' WHERE dept_id='.db_input($dept->getId());
if(($users=db_query($sql)) && db_num_rows($users)) {
while(list($id)=db_fetch_row($users))
$recipients= new Staff($id); //possible mem issues with a large number of staff?
}
}
//Always blame the manager
if($cfg->alertDeptManagerONClosedTicket() && $dept) {
$recipients=$dept->getManager();
}
//Ok...we are ready to go....
$sentlist=array();
foreach( $recipients as $k=>$staff){
if(!$staff || !is_object($staff) || !$staff->isAvailable()) continue;
if(in_array($staff->getEmail(),$sentlist)) continue; //avoid duplicate emails.
$alert = str_replace("%staff",$staff->getFirstName(),$body);
$email->send($staff->getEmail(),$subj,$alert);
}
}
}else {
Sys:(LOG_WARNING,'Template Fetch Error',"Unable to fetch 'closed' alert template #$tplId");
}
}
return true;
}
return false;
// Closed Ticket Alert for Department Members, modified by Masino Sinaga, February 27, 2010 NOT FINISHED YET
Thanks
TAP