|
|
|
@ -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; |
|
|
|
|
} |
|
|
|
@ -1374,8 +1369,8 @@ class TicketManager |
|
|
|
|
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); |
|
|
|
|
$now = api_get_utc_datetime(); |
|
|
|
|
$sql = "UPDATE $table_support_messages |
|
|
|
|
SET |
|
|
|
|
status = 'LEI', |
|
|
|
|
SET |
|
|
|
|
status = 'LEI', |
|
|
|
|
sys_lastedit_user_id ='" . api_get_user_id() . "', |
|
|
|
|
sys_lastedit_datetime ='" . $now . "' |
|
|
|
|
WHERE ticket_id ='$ticket_id' "; |
|
|
|
@ -1389,7 +1384,7 @@ class TicketManager |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
if (Database::affected_rows($result) > 0) { |
|
|
|
|
Database::query( |
|
|
|
|
"UPDATE $table_support_tickets SET |
|
|
|
|
"UPDATE $table_support_tickets SET |
|
|
|
|
status_id = '".self::STATUS_PENDING."' |
|
|
|
|
WHERE id ='$ticket_id' AND status_id = '".self::STATUS_NEW."'" |
|
|
|
|
); |
|
|
|
@ -1534,9 +1529,9 @@ class TicketManager |
|
|
|
|
FROM $table_support_tickets ticket, |
|
|
|
|
$table_support_messages message , |
|
|
|
|
$table_main_user user |
|
|
|
|
WHERE |
|
|
|
|
ticket.id = message.ticket_id AND |
|
|
|
|
message.status = 'NOL' AND |
|
|
|
|
WHERE |
|
|
|
|
ticket.id = message.ticket_id AND |
|
|
|
|
message.status = 'NOL' AND |
|
|
|
|
user.user_id = message.sys_insert_user_id "; |
|
|
|
|
if (!api_is_platform_admin()) { |
|
|
|
|
$sql .= " AND ticket.request_user = '$user_id' |
|
|
|
@ -1613,10 +1608,10 @@ class TicketManager |
|
|
|
|
sys_lastedit_user_id ='$userId', |
|
|
|
|
sys_lastedit_datetime ='$now', |
|
|
|
|
end_date = '$now' |
|
|
|
|
WHERE |
|
|
|
|
WHERE |
|
|
|
|
DATEDIFF('$now', sys_lastedit_datetime) > 7 AND |
|
|
|
|
status_id != '".self::STATUS_CLOSE."' AND |
|
|
|
|
status_id != '".self::STATUS_NEW."' AND |
|
|
|
|
status_id != '".self::STATUS_CLOSE."' AND |
|
|
|
|
status_id != '".self::STATUS_NEW."' AND |
|
|
|
|
status_id != '".self::STATUS_FORWARDED."'"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
} |
|
|
|
@ -1630,7 +1625,7 @@ class TicketManager |
|
|
|
|
$table_support_assigned_log = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG); |
|
|
|
|
$ticket_id = intval($ticket_id); |
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM $table_support_assigned_log |
|
|
|
|
$sql = "SELECT * FROM $table_support_assigned_log |
|
|
|
|
WHERE ticket_id = '$ticket_id' |
|
|
|
|
ORDER BY assigned_date DESC"; |
|
|
|
|
$result = Database::query($sql); |
|
|
|
@ -1692,13 +1687,13 @@ class TicketManager |
|
|
|
|
$user_id = api_get_user_id(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sql = "SELECT |
|
|
|
|
ticket.code, |
|
|
|
|
$sql = "SELECT |
|
|
|
|
ticket.code, |
|
|
|
|
ticket.sys_insert_datetime, |
|
|
|
|
ticket.sys_lastedit_datetime, |
|
|
|
|
ticket.sys_lastedit_datetime, |
|
|
|
|
cat.name as category, |
|
|
|
|
CONCAT(user.lastname,' ', user.firstname) AS fullname, |
|
|
|
|
status.name as status, |
|
|
|
|
status.name as status, |
|
|
|
|
ticket.total_messages as messages, |
|
|
|
|
ticket.assigned_last_user as responsable |
|
|
|
|
FROM $table_support_tickets ticket, |
|
|
|
|