* Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/public/ticket/index.php * \ingroup ticket * \brief Public file to add and manage ticket */ if (!defined('NOCSRFCHECK')) { define('NOCSRFCHECK', '1'); } // Do not check anti CSRF attack test if (!defined('NOREQUIREMENU')) { define('NOREQUIREMENU', '1'); } // If there is no need to load and show top and left menu if (!defined("NOLOGIN")) { define("NOLOGIN", '1'); } // If this page is public (can be called outside logged session) require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php'; // Load translation files required by the page $langs->loadLangs(array("companies","other","ticket")); // Get parameters $track_id = GETPOST('track_id', 'alpha'); $action = GETPOST('action', 'aZ09'); $email = GETPOST('email', 'alpha'); if (GETPOST('btn_view_ticket')) { unset($_SESSION['email_customer']); } if (isset($_SESSION['email_customer'])) { $email = $_SESSION['email_customer']; } $object = new ActionsTicket($db); /* * Actions */ if ($action == "view_ticket" || $action == "add_message" || $action == "close" || $action == "confirm_public_close" || $action == "new_public_message") { $error = 0; $display_ticket = false; if (!strlen($track_id)) { $error++; array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketTrackId"))); $action = ''; } if (!strlen($email)) { $error++; array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email"))); $action = ''; } else { if (!isValidEmail($email)) { $error++; array_push($object->errors, $langs->trans("ErrorEmailInvalid")); $action = ''; } } if (!$error) { $ret = $object->fetch('', '', $track_id); if ($ret && $object->dao->id > 0) { // vérifie si l'adresse email est bien dans les contacts du ticket $contacts = $object->dao->liste_contact(-1, 'external'); foreach ($contacts as $contact) { if ($contact['email'] == $email) { $display_ticket = true; $_SESSION['email_customer'] = $email; break; } else { $display_ticket = false; } } if ($object->dao->fk_soc > 0) { $object->dao->fetch_thirdparty(); } if ($email == $object->dao->origin_email || $email == $object->dao->thirdparty->email) { $display_ticket = true; $_SESSION['email_customer'] = $email; } } else { $error++; array_push($object->errors, $langs->trans("ErrorTicketNotFound", $track_id)); $action = ''; } } if ($error || $errors) { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } $object->doActions($action); /* * View */ $form = new Form($db); $formticket = new FormTicket($db); $arrayofjs = array(); $arrayofcss = array('/ticket/css/styles.css.php'); llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss); if (!$conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) { print '
' . $langs->trans('TicketPublicInterfaceForbidden') . '
'; $db->close(); exit(); } print '
'; if ($action == "view_ticket" || $action == "add_message" || $action == "close" || $action == "confirm_public_close") { if ($display_ticket) { // Confirmation close if ($action == 'close') { print $form->form_confirm($_SERVER["PHP_SELF"] . "?track_id=" . $track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_public_close", '', '', 1); } print '
'; print ''; // Ref print ''; // Tracking ID print ''; // Subject print ''; // Statut print ''; // Type print ''; // Category print ''; // Severity print ''; // Creation date print ''; // Author print ''; // Read date if (!empty($object->dao->date_read)) { print ''; } // Close date if (!empty($object->dao->date_close)) { print ''; } // User assigned print ''; // Progression print ''; print '
' . $langs->trans("Ref") . ''; print $object->dao->ref; print '
' . $langs->trans("TicketTrackId") . ''; print $object->dao->track_id; print '
' . $langs->trans("Subject") . ''; print $object->dao->subject; print '
' . $langs->trans("Status") . ''; print $object->dao->getLibStatut(2); print '
' . $langs->trans("Type") . ''; print $object->dao->type_label; print '
' . $langs->trans("Category") . ''; print $object->dao->category_label; print '
' . $langs->trans("Severity") . ''; print $object->dao->severity_label; print '
' . $langs->trans("DateCreation") . ''; print dol_print_date($object->dao->datec, 'dayhour'); print '
' . $langs->trans("Author") . ''; if ($object->dao->fk_user_create > 0) { $langs->load("users"); $fuser = new User($db); $fuser->fetch($object->dao->fk_user_create); print $fuser->getFullName($langs); } else { print $object->dao->origin_email; } print '
' . $langs->trans("TicketReadOn") . ''; print dol_print_date($object->dao->date_read, 'dayhour'); print '
' . $langs->trans("TicketCloseOn") . ''; print dol_print_date($object->dao->date_close, 'dayhour'); print '
' . $langs->trans("AssignedTo") . ''; if ($object->dao->fk_user_assign > 0) { $fuser = new User($db); $fuser->fetch($object->dao->fk_user_assign); print $fuser->getFullName($langs, 1); } else { print $langs->trans('None'); } print '
' . $langs->trans("Progression") . ''; print ($object->dao->progress > 0 ? $object->dao->progress : '0') . '%'; print '
'; print '
'; print '
'; if ($action == 'add_message') { print load_fiche_titre($langs->trans('TicketAddMessage'), '', 'messages@ticket'); $formticket = new FormTicket($db); $formticket->action = "new_public_message"; $formticket->track_id = $object->dao->track_id; $formticket->id = $object->dao->id; $formticket->param = array('fk_user_create' => '-1'); $formticket->withfile = 2; $formticket->showMessageForm('100%'); } else { print '
'; print ''; print ''; print ''; print ''; print ''; print "
\n"; print '
'; // List ticket print ''; if ($object->dao->fk_statut < 8) { // New message print ''; // Close ticket if ($object->dao->fk_statut > 0 && $object->dao->fk_statut < 8) { print ''; } } print '
'; } // Message list print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticket'); $object->viewTicketMessages(false); print '
'; // Logs list print load_fiche_titre($langs->trans('TicketHistory'), '', 'history@ticket'); $object->viewTicketLogs(false); } else { print ''; } } else { print '

' . $langs->trans("TicketPublicMsgViewLogIn") . '

'; print '
'; print '
'; print ''; print ''; print '

'; print ''; print '

'; print '

'; print ''; print '

'; print '

'; print ''; print "

\n"; print "
\n"; print "
\n"; } // End of page llxFooter(); $db->close();