From cf94e16f003d87ee79571f4605252a41f9038ea1 Mon Sep 17 00:00:00 2001 From: Julio Date: Fri, 9 Oct 2015 15:59:01 +0200 Subject: [PATCH] Add notifications + update lang vars --- plugin/ticket/lang/english.php | 3 +- plugin/ticket/lang/french.php | 3 +- plugin/ticket/lang/spanish.php | 18 ++++---- plugin/ticket/src/ticket.class.php | 74 ++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 11 deletions(-) diff --git a/plugin/ticket/lang/english.php b/plugin/ticket/lang/english.php index 907906cba5..ab817e4d14 100755 --- a/plugin/ticket/lang/english.php +++ b/plugin/ticket/lang/english.php @@ -83,4 +83,5 @@ $strings['AreYouSure'] = "Are you sure?"; $strings['allow_student_add'] = "Allow students to generate tickets"; $strings['PleaseBeforeRegisterATicketSelectOneUser'] = "Please select a user before you register a ticket."; $strings['RequestConfirmation'] = "Request confirmation"; - +$strings['TicketUpdated'] = "Ticket updated"; +$strings['TicketClosed'] = "Ticket closed"; diff --git a/plugin/ticket/lang/french.php b/plugin/ticket/lang/french.php index e22a32bff4..0b32b1e7bb 100755 --- a/plugin/ticket/lang/french.php +++ b/plugin/ticket/lang/french.php @@ -83,4 +83,5 @@ $strings['AreYouSure'] = "Êtes-vous certain?"; $strings['allow_student_add'] = "Permettre à l'étudiant de générer des tickets"; $strings['PleaseBeforeRegisterATicketSelectOneUser'] = "Veuillez sélectionner un utilisateur avant d'enregistrer un ticket."; $strings['RequestConfirmation'] = "Demander confirmation"; - +$strings['TicketUpdated'] = "Ticket modifié"; +$strings['TicketClosed'] = "Ticket fermé"; diff --git a/plugin/ticket/lang/spanish.php b/plugin/ticket/lang/spanish.php index c810bb306b..826900472c 100755 --- a/plugin/ticket/lang/spanish.php +++ b/plugin/ticket/lang/spanish.php @@ -13,10 +13,10 @@ $strings['Program'] = "Programa"; $strings['Responsible'] = "Responsable"; $strings['Status'] = "Estado"; $strings['Message'] = "Mensajes"; -$strings['Description'] = "Descripcion"; +$strings['Description'] = "Descripción"; $strings['Tickets'] = "Tickets"; $strings['MyTickets'] = "Mis Tickets"; -$strings['MsgWelcome'] = "Bienvenido a su sección MIS TICKETS. Esta sección le permite revisar sus Tickets de Soporte generados en SOPORTE TECNICO"; +$strings['MsgWelcome'] = "Bienvenido a su sección MIS TICKETS. Esta sección le permite revisar sus Tickets de Soporte generados en SOPORTE TÉCNICO"; $strings['TckSuccessSave'] = "Se registró con éxito su ticket"; $strings['TckClose'] = "Cerrar Tickets"; $strings['TckNew'] = "Nuevo Ticket"; @@ -24,14 +24,14 @@ $strings['TcksNew'] = "Tickets Nuevos"; $strings['Unassigned'] = "No asignados"; $strings['Unassign'] = "Desasignado"; $strings['Read'] = "Leídos"; -$strings['Unread'] = "No Leídos"; +$strings['Unread'] = "No leídos"; $strings['RegisterDate'] = "Fecha de Registro"; $strings['AssignedTo'] = "Asignado a"; $strings['ValidUser'] = "Debe seleccionar a un usuario"; $strings['ValidType'] = "Debe seleccionar un tipo"; $strings['ValidSubject'] = "Debe escribir un asunto"; $strings['ValidCourse'] = "Debe elegir un curso"; -$strings['ValidEmail'] = "Debe digitar un email valido"; +$strings['ValidEmail'] = "Debe escribir un email válido"; $strings['ValidMessage'] = "Debe escribir un mensaje"; $strings['PersonalEmail'] = "Email Personal"; $strings['Optional'] = "Opcional"; @@ -65,7 +65,7 @@ $strings['IfYouAreSureTheTicketWillBeClosed'] = "Si está seguro el Ticket será $strings['YourQuestionWasSentToTheResponableAreaX'] = "

Su consulta fue reenviada al área responsable: %s

"; $strings['YourAnswerToTheQuestionWillBeSentToX'] = "

La respuesta a su consulta será enviada al correo:%s

"; $strings['VirtualSupport'] = "Soporte Virtual"; -$strings['IncidentResentToVirtualSupport'] = "El incidente ha sido reenviado al Soporte Virtual"; +$strings['IncidentResentToVirtualSupport'] = "El incidente ha sido reenviado al Soporte Técnico"; $strings['DateLastEdition'] = "Fecha Última Edición"; $strings['GeneralInformation'] = "Información General"; $strings['TicketsAboutGeneralInformation'] = "Tickets acerca de Infomación General."; @@ -81,11 +81,11 @@ $strings['OnlineEvaluation'] = "Evaluación en línea"; $strings['TicketsAboutOnlineEvaluation'] = "Tickets relacionados a las evaluaciones en línea"; $strings['ToBeAssigned'] = "Por Asignar"; $strings['Untill'] = "Hasta"; -$strings['TicketWasThisAnswerSatisfying'] = "¿Fué la respuesta al Ticket satisfactoria?"; +$strings['TicketWasThisAnswerSatisfying'] = "¿Fue la respuesta al Ticket satisfactoria?"; $strings['TicketDetail'] = "Detalle del Ticket"; $strings['AreYouSure'] = "¿Está seguro?"; - -$strings['allow_student_add'] = "Permitir al studiante generar Tickets"; +$strings['allow_student_add'] = "Permitir al estudiante generar Tickets"; $strings['PleaseBeforeRegisterATicketSelectOneUser'] = "Por favor, antes de registrar un Ticket seleccione un usuario."; $strings['RequestConfirmation'] = "Solicitar confirmación"; - +$strings['TicketUpdated'] = "Ticket actualizado"; +$strings['TicketClosed'] = "Ticket cerrado"; diff --git a/plugin/ticket/src/ticket.class.php b/plugin/ticket/src/ticket.class.php index ab48e7c2e8..08845ac318 100755 --- a/plugin/ticket/src/ticket.class.php +++ b/plugin/ticket/src/ticket.class.php @@ -1113,6 +1113,65 @@ class TicketManager } } + /** + * @param int $ticketId + * @param int $userId + * @param string $title + * @param string $message + */ + public static function sendNotification($ticketId, $userId, $title, $message) + { + global $plugin; + $userInfo = api_get_user_info($userId); + $ticketInfo = self::get_ticket_detail_by_id($ticketId, $userId); + $requestUserInfo = $ticketInfo['usuario']; + $ticketCode = $ticketInfo['ticket']['ticket_code']; + $status = $ticketInfo['ticket']['status']; + $priority = $ticketInfo['ticket']['priority']; + + $titleEmail = "[$ticketCode] $title"; + $messageEmail = $plugin->get_lang('TicketNum').": $ticketCode
"; + $messageEmail .= $plugin->get_lang('Status').": $status
"; + $messageEmail .= $plugin->get_lang('Priority').": $priority
"; + $messageEmail .= '

'; + $messageEmail .= $message; + + /*MessageManager::send_message_simple( + $requestUserInfo['user_id'], + $titleEmail, + $messageEmail + ); + + MessageManager::send_message_simple( + $userInfo['user_id'], + $titleEmail, + $messageEmail + );*/ + + api_mail_html( + $requestUserInfo['complete_name'], + $requestUserInfo['email'], + $titleEmail, + $messageEmail, + null, + null, + array(), + null + ); + + // Admin + api_mail_html( + $userInfo['complete_name'], + $userInfo['email'], + $titleEmail, + $messageEmail, + null, + null, + array(), + null + ); + } + /** * @param $status_id * @param $ticket_id @@ -1124,6 +1183,7 @@ class TicketManager $ticket_id, $user_id ) { + global $plugin; $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); $ticket_id = intval($ticket_id); @@ -1139,6 +1199,12 @@ class TicketManager $result = Database::query($sql); if (Database::affected_rows($result) > 0) { + self::sendNotification( + $ticket_id, + $user_id, + $plugin->get_lang('TicketUpdated'), + $plugin->get_lang('TicketUpdated') + ); return true; } else { return false; @@ -1204,6 +1270,7 @@ class TicketManager */ public static function close_ticket($ticket_id, $user_id) { + global $plugin; $ticket_id = intval($ticket_id); $user_id = intval($user_id); @@ -1216,6 +1283,13 @@ class TicketManager end_date ='$now' WHERE ticket_id ='$ticket_id'"; Database::query($sql); + + self::sendNotification( + $ticket_id, + $user_id, + $plugin->get_lang('TicketClosed'), + $plugin->get_lang('TicketClosed') + ); } /**