First let me say this is just a work around and just a combination of post put together. I someone who has some php experience (more than the 1 week I have ;) ) It would be nice to have this as a email template
Please back up everything before try this I have only 1 week experience with php
Find in class.ticket.php
function getName(){
return $this->fullname;
}
Below that add (from (http://www.osticket.com/forums/showthread.php?t=4128&highlight=getMessageHistory) )
//MOD own function added for the added %history template substitution
function getMessageHistory(){
// build an array of both messages and responses (conversion history = $c)
//$c = array;
$i = 0; // start from the beginning...
// first we get the messages
$sql ='SELECT created, message FROM '.TICKET_MESSAGE_TABLE.' WHERE ticket_id='.db_input($this->id);
if(($res=db_query($sql)) && db_num_rows($res))
{
while($row=db_fetch_array($res))
{
$c=$row;
$c="Message: ".$row;
}
}
// then we get the response history
$sql ='SELECT created, response FROM '.TICKET_RESPONSE_TABLE.' WHERE ticket_id='.db_input($this->id);
if(($res=db_query($sql)) && db_num_rows($res))
{
while($row=db_fetch_array($res))
{
$c=$row;
$c="Response: ".$row;
}
}
// sort the array on the date field
// first we need to alter the arrays from rows to columns to make array_multisort work properly...
foreach($c as $k => $r)
{
$create = $r;
$text = $r;
}
// reorder the arrays in tandem...
array_multisort($create, SORT_ASC, $text);
// turn everything into a string and return it.. (we counted $i upwards the last time and it should contain the nr of elements...)
$output='';
for($x=0; $x <= $i; $x++)
{
$output .= $create.' - '.$text."\n";
$output .= "-----------------------------------------------------------------\n";
}
return($output);
}
// end modification
Find
Close the ticket
function close(){
$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;
}
Replace with (from (http://www.osticket.com/forums/showpost.php?p=9443&postcount=8) )
// ALL CHANGES IN class.ticket.php
function close(){
$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());
// NEW MOD CODE STARTS HERE
// get dept object
$dept = new Dept($this->getDeptId());
// get email object for current
$email = new Email($this->getEmail());
// see if the department ticket is configured for is setup for auto response on
// new tickets. I have some departments I don't want notification on close
// A new attribute could be used, but I piggy backed on an existing as it suited my needs fine for now.
if ($dept->autoRespONNewTicket()) {
// small debug message that prints at the top of ticket screen so I know an email was sent
print "<b>Email Sent</b>";
// subject for email -- totally configurable.
$subj= "Helpdesk Request # has been closed.";
// I added a link in the body to the ticket for the user if they wanted to view it just after I closed it.
$body= "This is a notification that Request#" .$this->getExtId(). " has been closed." .$this->getMessageHistory(). " You can see request information here: http://" . $_SERVER . "/job/view.php?e=" . $this->getEmail() . "&t=" . $this->getExtId() . ".";
// this sends out the email ensuring the "From" address is whatever is configured for the department
$dept->getEmail()->send($this->getEmail(),$subj,$body);
}
// NEW MOD CODE ENDS HERE
return (db_query($sql) && db_affected_rows())?true;
}
add %history and $this->getMessageHistory()); to $search & $replace like below
$search = array('/%id/','/%ticket/','/%email/','/%name/','/%subject/','/%location/','/%machine/','/%topic/','/%phone/','/%status/','/%priority/',
'/%dept/','/%assigned_staff/','/%createdate/','/%duedate/','/%closedate/','/%url/','/%history/');
$replace = array($this->getId(),
$this->getExtId(),
$this->getEmail(),
$this->getName(),
$this->getSubject(),
$this->getHelpTopic(),
$this->getPhoneNumber(),
$this->getStatus(),
$this->getPriority(),
($dept?$dept->getName():''),
($staff?$staff->getName():''),
Format:($this->getCreateDate()),
Format:($this->getDueDate()),
Format:($this->getCloseDate()),
$cfg->getBaseUrl(),
$this->getMessageHistory()); // added for %history
return preg_replace($search,$replace,$text);
}
I think I have removed all my other mods so it should be standard but no guaranties
Hope this help and some one can use it make this into a template! But it works for now good luck