Done!
Hi Beeman,
I have successfully modified my post on my blog regarding your request.
Simply change the mergeTicket in \include\class.ticket.php file become this following code below. This is the latest version in order to insert response message about merging ticket in the destination ticket (besides in the origin ticket):
//merge this ticket to another ticket
function mergeTicket($keepticket,$notifycustomer,$email,$status) {
global $cfg;
global $thisuser;
// update these tables...:
// ost_ticket_attachment
$sql1= 'UPDATE '.TICKET_ATTACHMENT_TABLE.' SET '.
' ticket_id='.db_input(Format:($keepticket)).
' WHERE '.
'ticket_id='.db_input($this->getId());
// ost_ticket_message
$sql2= 'UPDATE '.TICKET_MESSAGE_TABLE.' SET '.
' ticket_id='.db_input(Format:($keepticket)).
' WHERE '.
'ticket_id='.db_input($this->getId());
// ost_ticket_note
$sql3= 'UPDATE '.TICKET_NOTE_TABLE.' SET '.
' ticket_id='.db_input(Format:($keepticket)).
' WHERE '.
'ticket_id='.db_input($this->getId());
// ost_ticket_response
$sql4= 'UPDATE '.TICKET_RESPONSE_TABLE.' SET '.
' ticket_id='.db_input(Format:($keepticket)).
' WHERE '.
'ticket_id='.db_input($this->getId());
// create message on this ticket about merge (ost_ticket_message)
$sql5= 'INSERT INTO '.TICKET_MESSAGE_TABLE.' SET '.
' ticket_id='.db_input($this->getId()).
', source="Web"'.
', created=NOW()'.
', message=CONCAT("Merged with ticket ",'.
' ( SELECT ticketID FROM '.TICKET_TABLE.' WHERE ticket_id='.db_input(Format:($keepticket)).' ))'.
';';
// close and unassign this ticket (ost_ticket)
$sql6 = 'UPDATE '.TICKET_TABLE.' SET '.
' staff_id = 0'.
', status = "closed"'.
', updated=NOW()'.
', closed=NOW()'.
' WHERE '.
'ticket_id='.db_input($this->getId());
if((db_query($sql1)) && (db_query($sql2)) &&
(db_query($sql3)) && (db_query($sql4)) &&
(db_query($sql6)) ){
if ( db_query($sql5) && $msgid=db_insert_id() ); { // && $msgid=db_insert_id($res5)
$sql7= 'INSERT INTO '.TICKET_RESPONSE_TABLE.' SET '.
' msg_id='.db_input($msgid).
', ticket_id='.db_input($this->getId()).
', staff_id='.db_input($thisuser->getId()).
', staff_name='.db_input($thisuser->getName()).
', ip_address=""'.
', created=NOW()'.
', response=CONCAT("Ticket closed for merging reason ",'.
' ( SELECT ticketID FROM '.TICKET_TABLE.' WHERE ticket_id='.db_input(Format:($keepticket)).' ))'.
';';
db_query($sql7);
$sqlt = 'SELECT ticketID FROM '.TICKET_TABLE.' WHERE ticket_id='.db_input(Format:($keepticket));
$rest=db_query($sqlt);
if($rest && db_num_rows($rest))
list($ticketID)=db_fetch_row($rest);
$sqlm = 'SELECT m.msgid FROM '.TICKET_MESSAGE_TABLE.' m, '.TICKET_TABLE.' t
WHERE t.ticketID='.$ticketID.' AND m.ticket_id=t.ticket_id ORDER BY msgid ASC LIMIT 1';
$resm=db_query($sqlm);
if($resm && db_num_rows($resm))
list($msgid)=db_fetch_row($resm);
$sql8= 'INSERT INTO '.TICKET_RESPONSE_TABLE.' SET '.
' msg_id='.db_input($msgid).
', ticket_id='.db_input(Format:($keepticket)).
', staff_id='.db_input($thisuser->getId()).
', staff_name='.db_input($thisuser->getName()).
', ip_address=""'.
', created=NOW()'.
', response=CONCAT("Ticket merged from ticket ",'.$this->getExtId().')';
db_query($sql8);
}
if ($notifycustomer && ($status!='closed')) {
$helpdesk_email=$cfg->getDefaultEmail();
$helpdesk_email->send($email,
'Merging Ticket #'.$this->getExtId().' to Ticket #'.$ticketID,
'Your ticket #'.$this->getExtId().' has been merged to ticket #'.$ticketID.'.');
}
return true;
} else {
return false;
}
}
Sincerely,
Masino Sinaga