Hi!
Most tickets we handle are created via incoming email.
A ticket is then beeing assigned to staff.
Staff works with blackberry and would like to get an email with all ticket information.
So I added a new variable for use in the email templates: %history
OPEN include/class.ticket.php
FIND (~558)
if(($resp=db_query($sql)) && db_num_rows($resp) && list($subj,$body)=db_fetch_row($resp)){
ADD after:
//############ START MOD: mail ticket history on assignment
//Adds a new template variable %history containing ticket thread
//added: 30.03.2010, Bernie78
//get whole ticket thread
//Code taken from viewticket.inc / little modified
$myhist="";
$sql='SELECT msg.msg_id,msg.created,msg.message FROM '.TICKET_MESSAGE_TABLE.' msg '.
' WHERE msg.ticket_id='.$this->id.
' GROUP BY msg.msg_id ORDER BY created';
$msgres =db_query($sql);
//echo $sql;
while ($msg_row = db_fetch_array($msgres)) {
$myhist.=Format:($resp_row)."\n";
$myhist.=Format:($msg_row)."\n\n";
//get answers for messages
$sql2='SELECT resp.* FROM '.TICKET_RESPONSE_TABLE.' resp '.
' WHERE msg_id='.db_input($msg_row).' AND resp.ticket_id='.$this->id.
' GROUP BY resp.response_id ORDER BY created';
$resp =db_query($sql2);
while ($resp_row = db_fetch_array($resp)) {
$myhist.=Format:($resp_row)." - ".$resp_row."\n";
$myhist.=Format:($resp_row)."\n\n";
}
}
//############ END MOD
FIND (~3 lines down):
$body = str_replace('%note',$message,$body);
ADD after:
//############ START MOD: Add line to replace %history variable by ticket thread
$body = str_replace("%history", $myhist,$body); //replace tag with history
//############ END MOD
Greets