Hi guys
Im struggling like mad to do email the User on Close of a ticket
Ive gotcode below in Class.ticket which ive narrowed it down to: my variables are DB entries are:
ticket_closed_client_subj
ticket_closed_client_body
alertClientsONClosedTicket
Done the amendments needed in the following files below:
Amendments in DataBase: Done
Amendments in preference.inc.php Done
Amendments in Class.ticket ----------------------- Stuggling with!!!
Amendments in Class.config DONE
Amendments in template.inc DONE
Amendments in class.msgtpl DONE
This is what ive been playing with below, i just want a email to be fired to the user when staff closes the ticket just like the staff member it is assigned to gets one. Any Pointers on code I need would be ace :) at the moment this code is stopping the actual tickets from closing, i only know bits of PHP so i just need this code making right. Thanks
This code is in after the following close section of class.ticket
//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());
This bit in just underneath, there is an issue with it.....
if($cfg->alertClientsONClosedTicket()){
$sql='SELECT ticket_closed_client_subj,ticket_closed_client_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);
$body = str_replace('%signature',($dept && $dept->isPublic())?$dept->getSignature():'',$body);
//Reply separator tag.
if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator()))
$body ="\n$tag\n\n".$body;
if(!$dept || !($email=$dept->getAutoRespEmail()))
$email=$cfg->getDefaultEmail();
if($email) {
$email->send($this->getEMail(),$subj,$body);
}
}else {
Sys:(LOG_WARNING,'Template Fetch Error',"Unable to fetch 'new message' auto response template #$tplId");
}
}