|
|
|
@ -716,17 +716,14 @@ class TicketManager |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
$obj = Database::fetch_object($result); |
|
|
|
|
|
|
|
|
|
$message_attch_id = $obj->total_attach + 1; |
|
|
|
|
if (is_array($file_attachments)) { |
|
|
|
|
foreach ($file_attachments as $file_attach) { |
|
|
|
|
if ($file_attach['error'] == 0) { |
|
|
|
|
$data_files[] = self::save_message_attachment_file( |
|
|
|
|
$file_attach, |
|
|
|
|
$ticket_id, |
|
|
|
|
$message_id, |
|
|
|
|
$message_attch_id |
|
|
|
|
$message_id |
|
|
|
|
); |
|
|
|
|
$message_attch_id++; |
|
|
|
|
} else { |
|
|
|
|
if ($file_attach['error'] != UPLOAD_ERR_NO_FILE) { |
|
|
|
|
return false; |
|
|
|
@ -743,14 +740,12 @@ class TicketManager |
|
|
|
|
* @param $file_attach |
|
|
|
|
* @param $ticket_id |
|
|
|
|
* @param $message_id |
|
|
|
|
* @param $message_attch_id |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public static function save_message_attachment_file( |
|
|
|
|
$file_attach, |
|
|
|
|
$ticket_id, |
|
|
|
|
$message_id, |
|
|
|
|
$message_attch_id |
|
|
|
|
$message_id |
|
|
|
|
) { |
|
|
|
|
$now = api_get_utc_datetime(); |
|
|
|
|
$user_id = api_get_user_id(); |
|
|
|
@ -782,7 +777,6 @@ class TicketManager |
|
|
|
|
path, |
|
|
|
|
ticket_id, |
|
|
|
|
message_id, |
|
|
|
|
message_attch_id, |
|
|
|
|
size, |
|
|
|
|
sys_insert_user_id, |
|
|
|
|
sys_insert_datetime, |
|
|
|
@ -793,7 +787,6 @@ class TicketManager |
|
|
|
|
'$safe_new_file_name', |
|
|
|
|
'$ticket_id', |
|
|
|
|
'$message_id', |
|
|
|
|
'$message_attch_id', |
|
|
|
|
'" . $file_attach['size'] . "', |
|
|
|
|
'$user_id', |
|
|
|
|
'$now', |
|
|
|
@ -1272,15 +1265,15 @@ class TicketManager |
|
|
|
|
cat.name, |
|
|
|
|
status.name as status, |
|
|
|
|
priority.name priority |
|
|
|
|
FROM $table_support_tickets ticket, |
|
|
|
|
$table_support_category cat, |
|
|
|
|
$table_support_priority priority, |
|
|
|
|
$table_support_status status |
|
|
|
|
FROM $table_support_tickets ticket |
|
|
|
|
INNER JOIN $table_support_category cat |
|
|
|
|
ON (cat.id = ticket.category_id) |
|
|
|
|
INNER JOIN $table_support_priority priority |
|
|
|
|
ON (priority.id = ticket.priority_id) |
|
|
|
|
INNER JOIN $table_support_status status |
|
|
|
|
ON (status.id = ticket.status_id) |
|
|
|
|
WHERE |
|
|
|
|
ticket.id = $ticket_id |
|
|
|
|
AND cat.id = ticket.category_id |
|
|
|
|
AND priority.id = ticket.priority_id |
|
|
|
|
AND status.id = ticket.status_id "; |
|
|
|
|
ticket.id = $ticket_id "; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
$ticket = array(); |
|
|
|
|
if (Database::num_rows($result) > 0) { |
|
|
|
@ -1316,16 +1309,17 @@ class TicketManager |
|
|
|
|
$ticket['usuario'] = $userInfo; |
|
|
|
|
$ticket['ticket'] = $row; |
|
|
|
|
} |
|
|
|
|
$sql = "SELECT * FROM $table_support_messages message, |
|
|
|
|
$table_main_user user |
|
|
|
|
$sql = "SELECT *, message.id as message_id |
|
|
|
|
FROM $table_support_messages message |
|
|
|
|
INNER JOIN $table_main_user user |
|
|
|
|
ON (message.sys_insert_user_id = user.user_id) |
|
|
|
|
WHERE |
|
|
|
|
message.ticket_id = '$ticket_id' AND |
|
|
|
|
message.sys_insert_user_id = user.user_id "; |
|
|
|
|
message.ticket_id = '$ticket_id' "; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
$ticket['messages'] = array(); |
|
|
|
|
$attach_icon = Display::return_icon('attachment.gif', ''); |
|
|
|
|
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN); |
|
|
|
|
$webPath = api_get_path(WEB_PATH); |
|
|
|
|
$webPath = api_get_path(WEB_CODE_PATH); |
|
|
|
|
while ($row = Database::fetch_assoc($result)) { |
|
|
|
|
$message = $row; |
|
|
|
|
$completeName = api_get_person_name($row['firstname'], $row['lastname']); |
|
|
|
@ -1344,11 +1338,12 @@ class TicketManager |
|
|
|
|
$sql = "SELECT * |
|
|
|
|
FROM $table_support_message_attachments |
|
|
|
|
WHERE |
|
|
|
|
message_id = " . $row['id'] . " AND |
|
|
|
|
ticket_id = '$ticket_id' "; |
|
|
|
|
message_id = " . $row['message_id'] . " AND |
|
|
|
|
ticket_id = $ticket_id"; |
|
|
|
|
|
|
|
|
|
$result_attach = Database::query($sql); |
|
|
|
|
while ($row2 = Database::fetch_assoc($result_attach)) { |
|
|
|
|
$archiveURL = $archiveURL = $webPath . "plugin/" . PLUGIN_NAME . '/src/download.php?ticket_id=' . $ticket_id . '&file='; |
|
|
|
|
$archiveURL = $archiveURL = $webPath . 'ticket/download.php?ticket_id=' . $ticket_id . '&file='; |
|
|
|
|
$row2['attachment_link'] = $attach_icon . ' <a href="' . $archiveURL . $row2['path'] . '&title=' . $row2['filename'] . '">' . $row2['filename'] . '</a> (' . $row2['size'] . ')'; |
|
|
|
|
$message['attachments'][] = $row2; |
|
|
|
|
} |
|
|
|
|