//get messages
$sql='SELECT msg.msg_id,msg.created,msg.message,count(attach_id) as attachments FROM '.TICKET_MESSAGE_TABLE.' msg '.
' LEFT JOIN '.TICKET_ATTACHMENT_TABLE." attach ON msg.ticket_id=attach.ticket_id AND msg.msg_id=attach.ref_id AND ref_type='M' ".
' WHERE msg.ticket_id='.db_input($id).
' GROUP BY msg.msg_id ORDER BY created';
$msgres =db_query($sql);
while ($msg_row = db_fetch_array($msgres)) {
?>
=Format::db_daydatetime($msg_row['created'])?> |
if($msg_row['attachments']>0){ ?>
}?>
=Format::display($msg_row['message'])?> |
//get answers for messages
$sql='SELECT resp.*,count(attach_id) as attachments FROM '.TICKET_RESPONSE_TABLE.' resp '.
' LEFT JOIN '.TICKET_ATTACHMENT_TABLE." attach ON resp.ticket_id=attach.ticket_id AND resp.response_id=attach.ref_id AND ref_type='R' ".
' WHERE msg_id='.db_input($msg_row['msg_id']).' AND resp.ticket_id='.db_input($id).
' GROUP BY resp.response_id ORDER BY created';
$resp =db_query($sql);
while ($resp_row = db_fetch_array($resp)) {
$respID=$resp_row['response_id'];
if($respID != $response_id) {?>
=Format::db_daydatetime($resp_row['created'])?> - =$resp_row['staff_name']?> |
if($resp_row['attachments']>0){ ?>
}?>
=Format::display($resp_row['response'])?> |
}
else { ?>
=Format::db_daydatetime($resp_row['created'])?> - =$resp_row['staff_name']?> |
if($resp_row['attachments']>0){ ?>
}?>
|
}
}
$msgid =$msg_row['msg_id'];
}?>