diff --git a/main/inc/lib/TicketManager.php b/main/inc/lib/TicketManager.php index ef1af03892..1685f7cded 100644 --- a/main/inc/lib/TicketManager.php +++ b/main/inc/lib/TicketManager.php @@ -672,11 +672,6 @@ class TicketManager '; $content .= $form; - - $sql = "UPDATE $table_support_tickets - SET status_id = '".self::STATUS_UNCONFIRMED."' - WHERE id = '$ticket_id'"; - Database::query($sql); } $sql = "SELECT COUNT(*) as total_messages @@ -759,7 +754,7 @@ class TicketManager $user_id = api_get_user_id(); $ticket_id = intval($ticket_id); $new_file_name = add_ext_on_mime( - stripslashes($file_attach['name']), $file_attach['type'] + stripslashes($file_attach['name']), $file_attach['type'] ); $file_name = $file_attach['name']; $table_support_message_attachments = Database::get_main_table(TABLE_TICKET_MESSAGE_ATTACHMENTS); @@ -1014,8 +1009,14 @@ class TicketManager break; } - $row['col1'] = Display::tip(date_to_str_ago($row['col1']), api_get_local_time($row['col1'])); - $row['col2'] = Display::tip(date_to_str_ago($row['col2']), api_get_local_time($row['col2'])); + $row['col1'] = Display::tip( + date_to_str_ago($row['col1']), + api_get_local_time($row['col1']) + ); + $row['col2'] = Display::tip( + date_to_str_ago($row['col2']), + api_get_local_time($row['col2']) + ); if ($isAdmin) { if ($row['priority_id'] === self::PRIORITY_HIGH && $row['status_id'] != self::STATUS_CLOSE) { $actions .= ''; @@ -1890,6 +1891,23 @@ class TicketManager return $list; } + /** + * @param string $code + * @return int + */ + public static function getStatusIdFromCode($code) + { + $item = Database::getManager() + ->getRepository('ChamiloTicketBundle:Status') + ->findOneBy(['code' => $code]) + ; + if ($item) { + return $item->getId(); + } + + return 0; + } + /** * @return array */ diff --git a/main/ticket/ticket_details.php b/main/ticket/ticket_details.php index dbd5bed312..ee7c97909b 100644 --- a/main/ticket/ticket_details.php +++ b/main/ticket/ticket_details.php @@ -185,18 +185,23 @@ if (!isset($_GET['ticket_id'])) { header('Location: '.api_get_path(WEB_CODE_PATH).'ticket/tickets.php'); exit; } + if (isset($_POST['response'])) { - if ($user_id == $ticket['ticket']['assigned_last_user']) { - $response = $_POST['response'] == '1' ? true : $_POST['response'] == "0" ? false : null; - if ($response && $ticket['ticket']['status_id'] == TicketManager::STATUS_UNCONFIRMED) { - /*TicketManager::close_ticket($_GET['ticket_id'], $user_id); - $ticket['ticket']['status_id'] = TicketManager::STATUS_CLOSE; - $ticket['ticket']['status'] = get_lang('Closed');*/ - } else if (!is_null($response) && $ticket['ticket']['status_id'] == TicketManager::STATUS_UNCONFIRMED) { - TicketManager::update_ticket_status(TicketManager::STATUS_PENDING, $_GET['ticket_id'], $user_id); - $ticket['ticket']['status_id'] = TicketManager::STATUS_PENDING; - $ticket['ticket']['status'] = get_lang('StatusPending'); + if ($user_id == $ticket['ticket']['assigned_last_user'] || api_is_platform_admin()) { + $response = $_POST['response'] === '1' ? true : false; + $newStatus = TicketManager::STATUS_PENDING; + if ($response) { + $newStatus = TicketManager::STATUS_CLOSE; } + TicketManager::update_ticket_status( + TicketManager::getStatusIdFromCode($newStatus), + $ticket_id, + $user_id + ); + Display::addFlash(Display::return_message(get_lang('Updated'))); + header("Location:" . api_get_self() . "?ticket_id=" . $ticket_id); + exit; + } } if (isset($_REQUEST['action'])) { @@ -231,10 +236,7 @@ if (!isset($_POST['compose'])) { $ticket['ticket']['status_id'] = TicketManager::STATUS_CLOSE; $ticket['ticket']['status'] = get_lang('Closed'); } - /*$ticket['ticket']['request_user'] = intval($ticket['ticket']['request_user']); - if ($ticket['ticket']['request_user'] == $user_id || intval($ticket['ticket']['assigned_last_user']) == $user_id) { - TicketManager::update_message_status($ticket_id, $ticket['ticket']['request_user']); - }*/ + Display::display_header(); $form_close_ticket = ''; if ($ticket['ticket']['status_id'] != TicketManager::STATUS_FORWARDED && diff --git a/main/ticket/tickets.php b/main/ticket/tickets.php index 3ed02f0cc1..f374bce680 100644 --- a/main/ticket/tickets.php +++ b/main/ticket/tickets.php @@ -90,11 +90,11 @@ switch ($action) { array( '#', get_lang('Date'), - get_lang('DateLastEdition'), + get_lang('LastUpdate'), get_lang('Category'), get_lang('User'), get_lang('Program'), - get_lang('Responsible'), + get_lang('AssignedTo'), get_lang('Status'), get_lang('Description') )