2018-03-10 04:23:59 +01:00
< ? php
2018-10-22 22:40:18 +02:00
/* Copyright ( C ) 2013 - 2016 Jean - François FERRY < hello @ librethic . io >
2024-09-05 16:05:37 +02:00
* Copyright ( C ) 2018 - 2024 Frédéric France < frederic . france @ free . fr >
2023-07-28 14:29:23 +02:00
* Copyright ( C ) 2023 Benjamin Falière < benjamin . faliere @ altairis . fr >
2025-02-12 00:52:24 +01:00
* Copyright ( C ) 2025 MDW < mdeweerd @ users . noreply . github . com >
2023-08-12 01:10:13 +02:00
*
2018-03-10 04:23:59 +01:00
* 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2018-03-10 04:23:59 +01:00
*/
/**
2019-07-19 20:06:02 +02:00
* \file htdocs / public / ticket / view . php
2018-06-04 21:49:29 +02:00
* \ingroup ticket
2020-07-26 22:02:49 +02:00
* \brief Public file to show one ticket
2018-03-10 04:23:59 +01:00
*/
if ( ! defined ( 'NOREQUIREMENU' )) {
2020-04-16 00:42:57 +02:00
define ( 'NOREQUIREMENU' , '1' );
2018-03-10 04:23:59 +01:00
}
// If there is no need to load and show top and left menu
if ( ! defined ( " NOLOGIN " )) {
2020-04-16 00:42:57 +02:00
define ( " NOLOGIN " , '1' );
2018-03-10 04:23:59 +01:00
}
2021-02-26 18:58:34 +01:00
if ( ! defined ( 'NOIPCHECK' )) {
define ( 'NOIPCHECK' , '1' ); // Do not check IP defined into conf $dolibarr_main_restrict_ip
}
if ( ! defined ( 'NOBROWSERNOTIF' )) {
define ( 'NOBROWSERNOTIF' , '1' );
}
2018-03-10 04:23:59 +01:00
// If this page is public (can be called outside logged session)
2021-12-17 11:10:08 +01:00
// For MultiCompany module.
// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
2024-03-28 20:19:28 +01:00
// Because 2 entities can have the same ref.
2021-12-17 11:10:08 +01:00
$entity = ( ! empty ( $_GET [ 'entity' ]) ? ( int ) $_GET [ 'entity' ] : ( ! empty ( $_POST [ 'entity' ]) ? ( int ) $_POST [ 'entity' ] : 1 ));
if ( is_numeric ( $entity )) {
define ( " DOLENTITY " , $entity );
}
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
2018-03-11 23:07:57 +01:00
require '../../main.inc.php' ;
2018-06-04 21:49:29 +02:00
require_once DOL_DOCUMENT_ROOT . '/ticket/class/actions_ticket.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formticket.class.php' ;
2019-10-05 11:52:02 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php' ;
2018-06-04 21:49:29 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php' ;
2019-05-03 17:11:13 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/security.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/payments.lib.php' ;
2018-03-10 04:23:59 +01:00
2024-11-04 23:53:20 +01:00
/**
* @ var Conf $conf
* @ var DoliDB $db
* @ var HookManager $hookmanager
* @ var Societe $mysoc
* @ var Translate $langs
*/
2018-05-26 23:52:52 +02:00
// Load translation files required by the page
2019-11-13 19:35:39 +01:00
$langs -> loadLangs ( array ( " companies " , " other " , " ticket " ));
2018-03-10 04:23:59 +01:00
// Get parameters
2019-07-19 23:11:00 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2022-09-01 10:54:20 +02:00
$cancel = GETPOST ( 'cancel' , 'aZ09' );
$track_id = GETPOST ( 'track_id' , 'alpha' );
2021-04-09 14:17:41 +02:00
$email = GETPOST ( 'email' , 'email' );
2022-11-08 16:27:04 +01:00
$suffix = " " ;
2018-03-10 04:23:59 +01:00
if ( GETPOST ( 'btn_view_ticket' )) {
2020-04-16 00:42:57 +02:00
unset ( $_SESSION [ 'email_customer' ]);
2018-03-10 04:23:59 +01:00
}
if ( isset ( $_SESSION [ 'email_customer' ])) {
2020-04-16 00:42:57 +02:00
$email = $_SESSION [ 'email_customer' ];
2018-03-10 04:23:59 +01:00
}
2018-06-04 21:49:29 +02:00
$object = new ActionsTicket ( $db );
2018-03-10 04:23:59 +01:00
2022-09-25 06:16:11 +02:00
if ( ! isModEnabled ( 'ticket' )) {
2022-09-09 13:58:54 +02:00
httponly_accessforbidden ( 'Module Ticket not enabled' );
2021-08-31 18:03:37 +02:00
}
2018-04-19 16:04:08 +02:00
/*
* Actions
*/
2021-02-26 18:58:34 +01:00
if ( $cancel ) {
2024-02-27 00:24:22 +01:00
$backtopage = getDolGlobalString ( 'TICKET_URL_PUBLIC_INTERFACE' , DOL_URL_ROOT . '/public/ticket/' );
2022-09-01 10:54:20 +02:00
2021-02-26 18:58:34 +01:00
if ( ! empty ( $backtopage )) {
2019-07-19 23:11:00 +02:00
header ( " Location: " . $backtopage );
exit ;
}
2019-11-13 19:35:39 +01:00
$action = 'view_ticket' ;
2019-07-19 23:11:00 +02:00
}
2025-02-12 00:52:24 +01:00
$display_ticket = false ;
2024-09-06 16:40:06 +02:00
if ( in_array ( $action , array ( " view_ticket " , " presend " , " close " , " confirm_public_close " , " add_message " , " add_contact " ))) { // Test on permission not required here. Done later by using the $track_id + check email in session
2020-04-16 00:42:57 +02:00
$error = 0 ;
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 ) {
2025-02-12 00:52:24 +01:00
$ret = $object -> fetch ( 0 , '' , $track_id );
2020-04-16 00:42:57 +02:00
if ( $ret && $object -> dao -> id > 0 ) {
// Check if emails provided is the one of author
$emailofticket = CMailFile :: getValidAddress ( $object -> dao -> origin_email , 2 );
2021-04-09 14:17:41 +02:00
if ( strtolower ( $emailofticket ) == strtolower ( $email )) {
2020-04-16 00:42:57 +02:00
$display_ticket = true ;
$_SESSION [ 'email_customer' ] = $email ;
2021-02-26 18:58:34 +01:00
} else {
// Check if emails provided is inside list of contacts
2020-04-16 00:42:57 +02:00
$contacts = $object -> dao -> liste_contact ( - 1 , 'external' );
foreach ( $contacts as $contact ) {
2021-04-09 14:17:41 +02:00
if ( strtolower ( $contact [ 'email' ]) == strtolower ( $email )) {
2020-04-16 00:42:57 +02:00
$display_ticket = true ;
$_SESSION [ 'email_customer' ] = $email ;
break ;
} else {
$display_ticket = false ;
}
}
}
// Check email of thirdparty of ticket
if ( $object -> dao -> fk_soc > 0 || $object -> dao -> socid > 0 ) {
$object -> dao -> fetch_thirdparty ();
if ( $email == $object -> dao -> thirdparty -> email ) {
$display_ticket = true ;
$_SESSION [ 'email_customer' ] = $email ;
}
}
// Check if email is email of creator
2021-02-26 18:58:34 +01:00
if ( $object -> dao -> fk_user_create > 0 ) {
2020-04-16 00:42:57 +02:00
$tmpuser = new User ( $db );
$tmpuser -> fetch ( $object -> dao -> fk_user_create );
2021-04-09 14:17:41 +02:00
if ( strtolower ( $email ) == strtolower ( $tmpuser -> email )) {
2020-04-16 00:42:57 +02:00
$display_ticket = true ;
$_SESSION [ 'email_customer' ] = $email ;
}
}
// Check if email is email of creator
2021-02-26 18:58:34 +01:00
if ( $object -> dao -> fk_user_assign > 0 && $object -> dao -> fk_user_assign != $object -> dao -> fk_user_create ) {
2020-04-16 00:42:57 +02:00
$tmpuser = new User ( $db );
$tmpuser -> fetch ( $object -> dao -> fk_user_assign );
2021-04-09 14:17:41 +02:00
if ( strtolower ( $email ) == strtolower ( $tmpuser -> email )) {
2020-04-16 00:42:57 +02:00
$display_ticket = true ;
$_SESSION [ 'email_customer' ] = $email ;
}
}
} else {
$error ++ ;
array_push ( $object -> errors , $langs -> trans ( " ErrorTicketNotFound " , $track_id ));
$action = '' ;
}
}
2024-09-06 16:40:06 +02:00
if ( ! $error && $action == 'confirm_public_close' && $display_ticket ) { // Test on permission already done
2020-04-16 00:42:57 +02:00
if ( $object -> dao -> close ( $user )) {
setEventMessages ( $langs -> trans ( 'TicketMarkedAsClosed' ), null , 'mesgs' );
2023-12-04 13:49:31 +01:00
$url = 'view.php?action=view_ticket&track_id=' . GETPOST ( 'track_id' , 'alpha' ) . ( ! empty ( $entity ) && isModEnabled ( 'multicompany' ) ? '&entity=' . $entity : '' ) . '&token=' . newToken ();
2020-04-16 00:42:57 +02:00
header ( " Location: " . $url );
2020-09-26 12:19:08 +02:00
exit ;
2020-04-16 00:42:57 +02:00
} else {
$action = '' ;
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
}
2024-09-06 16:40:06 +02:00
if ( ! $error && $action == " add_message " && $display_ticket && GETPOSTISSET ( 'btn_add_message' )) { // Test on permission already done
2020-05-27 11:39:06 +02:00
$ret = $object -> dao -> newMessage ( $user , $action , 0 , 1 );
2020-04-16 00:42:57 +02:00
2021-02-26 18:58:34 +01:00
if ( ! $error ) {
2020-04-16 00:42:57 +02:00
$action = 'view_ticket' ;
}
}
2023-07-28 14:29:23 +02:00
// Add a new external contributor to a ticket
2024-09-06 16:40:06 +02:00
if ( ! $error && $action == " add_contact " && $display_ticket && GETPOSTISSET ( 'btn_add_contact' )) { // Test on permission already done
2023-07-28 14:29:23 +02:00
$ret = $object -> dao -> add_contact ( GETPOSTINT ( 'contactid' ), 'CONTRIBUTOR' );
2023-08-12 01:10:13 +02:00
2023-07-28 14:29:23 +02:00
if ( ! $error ) {
$action = 'view_ticket' ;
}
}
2023-11-17 11:39:16 +01:00
if ( $error || ! empty ( $object -> errors )) {
2020-04-16 00:42:57 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2024-09-06 16:40:06 +02:00
if ( $action == " add_message " ) { // Test on permission not required here
2020-04-16 00:42:57 +02:00
$action = 'presend' ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-16 00:42:57 +02:00
$action = '' ;
}
}
2018-03-10 04:23:59 +01:00
}
2019-07-19 23:57:35 +02:00
// Actions to send emails (for ticket, we need to manage the addfile and removefile only)
2019-12-02 09:38:16 +01:00
$triggersendname = 'TICKET_SENTBYMAIL' ;
2019-11-13 19:35:39 +01:00
$paramname = 'id' ;
$autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO' ; // used to know the automatic BCC to add
2023-12-04 13:49:31 +01:00
if ( ! empty ( $object -> dao -> id )) {
$trackid = 'tic' . $object -> dao -> id ;
}
2019-07-19 23:57:35 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php' ;
2018-04-19 16:04:08 +02:00
/*
* View
*/
2018-03-10 04:23:59 +01:00
$form = new Form ( $db );
2018-06-04 21:49:29 +02:00
$formticket = new FormTicket ( $db );
2018-03-10 04:23:59 +01:00
2024-06-30 21:02:50 +02:00
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
2023-03-06 15:41:58 +01:00
$hookmanager -> initHooks ( array ( 'ticketpublicview' , 'globalcard' ));
2024-03-16 15:37:38 +01:00
if ( ! getDolGlobalString ( 'TICKET_ENABLE_PUBLIC_INTERFACE' )) {
2019-11-13 19:35:39 +01:00
print '<div class="error">' . $langs -> trans ( 'TicketPublicInterfaceForbidden' ) . '</div>' ;
2019-07-05 11:21:04 +02:00
$db -> close ();
exit ();
}
2018-03-10 04:23:59 +01:00
$arrayofjs = array ();
2024-07-27 22:25:13 +02:00
$arrayofcss = array ( getDolGlobalString ( 'TICKET_URL_PUBLIC_INTERFACE' , '/public/ticket/' ) . 'css/styles.css.php' );
2018-04-19 16:04:08 +02:00
2018-03-10 04:23:59 +01:00
llxHeaderTicket ( $langs -> trans ( " Tickets " ), " " , 0 , 0 , $arrayofjs , $arrayofcss );
2019-07-19 23:11:00 +02:00
if ( $action == " view_ticket " || $action == " presend " || $action == " close " || $action == " confirm_public_close " ) {
2021-02-26 18:58:34 +01:00
if ( $display_ticket ) {
2023-11-09 11:31:16 +01:00
print '<!-- public view ticket -->' ;
print '<div class="ticketpublicarea ticketlargemargin centpercent">' ;
2020-04-16 00:42:57 +02:00
// Confirmation close
if ( $action == 'close' ) {
2023-12-04 13:49:31 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?track_id= " . $track_id . ( ! empty ( $entity ) && isModEnabled ( 'multicompany' ) ? '&entity=' . $entity : '' ), $langs -> trans ( " CloseATicket " ), $langs -> trans ( " ConfirmCloseAticket " ), " confirm_public_close " , '' , '' , 1 );
2020-04-16 00:42:57 +02:00
}
print '<div id="form_view_ticket" class="margintoponly">' ;
print '<table class="ticketpublictable centpercent tableforfield">' ;
// Ref
print '<tr><td class="titlefield">' . $langs -> trans ( " Ref " ) . '</td><td>' ;
2021-06-07 01:43:24 +02:00
print img_picto ( '' , 'ticket' , 'class="pictofixedwidth"' );
2020-09-26 12:19:08 +02:00
print dol_escape_htmltag ( $object -> dao -> ref );
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
// Tracking ID
print '<tr><td>' . $langs -> trans ( " TicketTrackId " ) . '</td><td>' ;
2020-09-26 12:19:08 +02:00
print dol_escape_htmltag ( $object -> dao -> track_id );
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
// Subject
print '<tr><td>' . $langs -> trans ( " Subject " ) . '</td><td>' ;
2021-06-07 01:43:24 +02:00
print '<span class="bold">' ;
2020-09-26 12:19:08 +02:00
print dol_escape_htmltag ( $object -> dao -> subject );
2021-06-07 01:43:24 +02:00
print '</span>' ;
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
// Statut
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td><td>' ;
print $object -> dao -> getLibStatut ( 2 );
print '</td></tr>' ;
// Type
print '<tr><td>' . $langs -> trans ( " Type " ) . '</td><td>' ;
2020-09-26 12:19:08 +02:00
print dol_escape_htmltag ( $object -> dao -> type_label );
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
// Category
print '<tr><td>' . $langs -> trans ( " Category " ) . '</td><td>' ;
2021-07-30 01:42:52 +02:00
if ( $object -> dao -> category_label ) {
print img_picto ( '' , 'category' , 'class="pictofixedwidth"' );
print dol_escape_htmltag ( $object -> dao -> category_label );
}
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
// Severity
print '<tr><td>' . $langs -> trans ( " Severity " ) . '</td><td>' ;
2020-09-26 12:19:08 +02:00
print dol_escape_htmltag ( $object -> dao -> severity_label );
2020-04-16 00:42:57 +02:00
print '</td></tr>' ;
// Creation date
print '<tr><td>' . $langs -> trans ( " DateCreation " ) . '</td><td>' ;
print dol_print_date ( $object -> dao -> datec , 'dayhour' );
print '</td></tr>' ;
// Author
print '<tr><td>' . $langs -> trans ( " Author " ) . '</td><td>' ;
if ( $object -> dao -> fk_user_create > 0 ) {
$langs -> load ( " users " );
$fuser = new User ( $db );
$fuser -> fetch ( $object -> dao -> fk_user_create );
2021-06-07 01:43:24 +02:00
print img_picto ( '' , 'user' , 'class="pictofixedwidth"' );
2020-04-16 00:42:57 +02:00
print $fuser -> getFullName ( $langs );
} else {
2021-06-07 01:43:24 +02:00
print img_picto ( '' , 'email' , 'class="pictofixedwidth"' );
2020-04-16 00:42:57 +02:00
print dol_escape_htmltag ( $object -> dao -> origin_email );
}
print '</td></tr>' ;
// Read date
if ( ! empty ( $object -> dao -> date_read )) {
print '<tr><td>' . $langs -> trans ( " TicketReadOn " ) . '</td><td>' ;
print dol_print_date ( $object -> dao -> date_read , 'dayhour' );
print '</td></tr>' ;
}
// Close date
if ( ! empty ( $object -> dao -> date_close )) {
print '<tr><td>' . $langs -> trans ( " TicketCloseOn " ) . '</td><td>' ;
print dol_print_date ( $object -> dao -> date_close , 'dayhour' );
print '</td></tr>' ;
}
// User assigned
print '<tr><td>' . $langs -> trans ( " AssignedTo " ) . '</td><td>' ;
if ( $object -> dao -> fk_user_assign > 0 ) {
$fuser = new User ( $db );
$fuser -> fetch ( $object -> dao -> fk_user_assign );
2021-06-07 01:43:24 +02:00
print img_picto ( '' , 'user' , 'class="pictofixedwidth"' );
2023-11-09 10:56:13 +01:00
print $fuser -> getFullName ( $langs , 0 );
2020-04-16 00:42:57 +02:00
}
print '</td></tr>' ;
2023-07-28 14:29:23 +02:00
// External contributors
2023-08-12 01:10:13 +02:00
if ( getDolGlobalInt ( 'TICKET_PUBLIC_DISPLAY_EXTERNAL_CONTRIBUTORS' )) {
2023-07-28 14:29:23 +02:00
print '<tr><td>' . $langs -> trans ( " ExternalContributors " ) . '</td><td>' ;
if ( $object -> dao -> id > 0 ) {
$contactlist = $object -> dao -> liste_contact ( - 1 , 'external' );
2023-08-12 01:10:13 +02:00
foreach ( $contactlist as $externalContributor ) {
2023-07-28 14:29:23 +02:00
print img_picto ( '' , 'contact' , 'class="pictofixedwidth"' );
print $externalContributor [ " lastname " ] . " " . $externalContributor [ " firstname " ] . " <br> " ;
}
}
print '</td></tr>' ;
}
// Add new external contributor
2023-08-12 01:10:13 +02:00
if ( getDolGlobalInt ( 'TICKET_PUBLIC_SELECT_EXTERNAL_CONTRIBUTORS' ) && ! empty ( $object -> dao -> fk_soc )) {
2023-07-28 14:29:23 +02:00
print '<form method="post" id="form_view_add_contact" name="form_view_add_contact" action="' . $_SERVER [ 'PHP_SELF' ] . '?track_id=' . $object -> dao -> track_id . '">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="add_contact">' ;
print '<input type="hidden" name="email" value="' . $_SESSION [ 'email_customer' ] . '">' ;
print '<tr><td>' . $langs -> trans ( " AddContributor " ) . '</td><td>' ;
2024-05-08 15:41:13 +02:00
//print $form->selectcontacts($object->dao->fk_soc, '', 'contactid', 3, '', '', 1, 'minwidth100imp widthcentpercentminusxx maxwidth400');
print $form -> select_contact ( $object -> dao -> fk_soc , '' , 'contactid' , 3 , '' , '' , 1 , 'minwidth100imp widthcentpercentminusxx maxwidth400' , true );
2023-07-28 14:29:23 +02:00
print '<input type="submit" class="button smallpaddingimp reposition" name="btn_add_contact" value="' . $langs -> trans ( 'Add' ) . '" />' ;
print '</td></tr></form>' ;
}
2020-04-16 00:42:57 +02:00
// Progression
2023-11-27 11:56:32 +01:00
if ( getDolGlobalString ( 'TICKET_SHOW_PROGRESSION' )) {
2023-03-06 11:43:01 +01:00
print '<tr><td>' . $langs -> trans ( " Progression " ) . '</td><td>' ;
2024-09-05 16:05:37 +02:00
print ( $object -> dao -> progress > 0 ? dol_escape_htmltag (( string ) $object -> dao -> progress ) : '0' ) . '%' ;
2023-03-06 11:43:01 +01:00
print '</td></tr>' ;
}
2020-04-16 00:42:57 +02:00
2023-03-06 15:41:58 +01:00
// Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2020-04-16 00:42:57 +02:00
print '</table>' ;
print '</div>' ;
print '<div style="clear: both; margin-top: 1.5em;"></div>' ;
if ( $action == 'presend' ) {
2023-11-09 11:31:16 +01:00
print '<br>' ;
2021-06-07 01:43:24 +02:00
print load_fiche_titre ( $langs -> trans ( 'TicketAddMessage' ), '' , 'conversation' );
2020-04-16 00:42:57 +02:00
$formticket = new FormTicket ( $db );
$formticket -> action = " add_message " ;
$formticket -> track_id = $object -> dao -> track_id ;
2023-02-16 09:43:03 +01:00
$formticket -> trackid = 'tic' . $object -> dao -> id ;
2020-04-16 00:42:57 +02:00
2024-02-27 00:24:22 +01:00
$baseurl = getDolGlobalString ( 'TICKET_URL_PUBLIC_INTERFACE' , DOL_URL_ROOT . '/public/ticket/' );
2021-12-17 11:10:08 +01:00
$formticket -> param = array ( 'track_id' => $object -> dao -> track_id , 'fk_user_create' => '-1' ,
2025-02-12 00:52:24 +01:00
'returnurl' => $baseurl . 'view.php' . ( ! empty ( $entity ) && isModEnabled ( 'multicompany' ) ? '?entity=' . $entity : '' ));
2020-04-16 00:42:57 +02:00
$formticket -> withfile = 2 ;
$formticket -> withcancel = 1 ;
$formticket -> showMessageForm ( '100%' );
}
if ( $action != 'presend' ) {
2024-02-27 00:24:22 +01:00
$baseurl = getDolGlobalString ( 'TICKET_URL_PUBLIC_INTERFACE' , DOL_URL_ROOT . '/public/ticket/' );
2025-02-12 00:52:24 +01:00
print '<form method="POST" id="form_view_ticket_list" name="form_view_ticket_list" action="' . $baseurl . 'list.php' . ( ! empty ( $entity ) && isModEnabled ( 'multicompany' ) ? '?entity=' . $entity : '' ) . '">' ;
2020-04-16 00:42:57 +02:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="view_ticketlist">' ;
print '<input type="hidden" name="track_id" value="' . $object -> dao -> track_id . '">' ;
print '<input type="hidden" name="email" value="' . $_SESSION [ 'email_customer' ] . '">' ;
//print '<input type="hidden" name="search_fk_status" value="non_closed">';
print " </form> \n " ;
print '<div class="tabsAction">' ;
// List ticket
print '<div class="inline-block divButAction"><a class="left" style="padding-right: 50px" href="javascript:$(\'#form_view_ticket_list\').submit();">' . $langs -> trans ( 'ViewMyTicketList' ) . '</a></div>' ;
if ( $object -> dao -> fk_statut < Ticket :: STATUS_CLOSED ) {
// New message
2024-04-20 14:28:59 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=presend&mode=init&track_id=' . $object -> dao -> track_id . ( ! empty ( $entity ) && isModEnabled ( 'multicompany' ) ? '&entity=' . $entity : '' ) . '&token=' . newToken () . '">' . $langs -> trans ( 'TicketAddMessage' ) . '</a></div>' ;
2020-04-16 00:42:57 +02:00
// Close ticket
if ( $object -> dao -> fk_statut >= Ticket :: STATUS_NOT_READ && $object -> dao -> fk_statut < Ticket :: STATUS_CLOSED ) {
2024-04-20 14:28:59 +02:00
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=close&track_id=' . $object -> dao -> track_id . ( ! empty ( $entity ) && isModEnabled ( 'multicompany' ) ? '&entity=' . $entity : '' ) . '&token=' . newToken () . '">' . $langs -> trans ( 'CloseTicket' ) . '</a></div>' ;
2020-04-16 00:42:57 +02:00
}
}
print '</div>' ;
}
2023-11-09 11:31:16 +01:00
print '</div>' ;
2020-04-16 00:42:57 +02:00
// Message list
2023-11-09 11:31:16 +01:00
print '<div class="ticketpublicarea ticketlargemargin centpercent">' ;
2021-06-07 01:43:24 +02:00
print load_fiche_titre ( $langs -> trans ( 'TicketMessagesList' ), '' , 'conversation' );
2023-11-09 11:31:16 +01:00
print '</div>' ;
2020-04-16 00:42:57 +02:00
$object -> viewTicketMessages ( false , true , $object -> dao );
2024-10-03 15:28:51 +02:00
print '<br>' ;
2020-05-21 15:05:19 +02:00
} else {
2023-11-09 11:31:16 +01:00
print '<!-- public view ticket -->' ;
print '<div class="ticketpublicarea ticketlargemargin centpercent">' ;
2023-12-04 13:49:31 +01:00
print '<div class="error">Not Allowed<br><a href="' . $_SERVER [ 'PHP_SELF' ] . '?track_id=' . $object -> dao -> track_id . ( ! empty ( $entity ) && isModEnabled ( 'multicompany' ) ? '?entity=' . $entity : '' ) . '" rel="nofollow noopener">' . $langs -> trans ( 'Back' ) . '</a></div>' ;
2023-11-09 11:31:16 +01:00
print '</div>' ;
2020-04-16 00:42:57 +02:00
}
2018-03-10 04:23:59 +01:00
} else {
2023-11-09 11:31:16 +01:00
print '<!-- public view ticket -->' ;
print '<div class="ticketpublicarea ticketlargemargin centpercent">' ;
2023-03-12 21:31:33 +01:00
print '<div class="center opacitymedium margintoponly marginbottomonly ticketlargemargin">' . $langs -> trans ( " TicketPublicMsgViewLogIn " ) . '</div>' ;
2018-03-10 04:23:59 +01:00
2020-04-16 00:42:57 +02:00
print '<div id="form_view_ticket">' ;
2024-04-20 18:49:24 +02:00
print '<form method="POST" class="maxwidth1000 center" name="form_view_ticket" action="' . $_SERVER [ 'PHP_SELF' ] . ( ! empty ( $entity ) && isModEnabled ( 'multicompany' ) ? '?entity=' . $entity : '' ) . '">' ;
2023-03-12 21:31:33 +01:00
2020-04-16 00:42:57 +02:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="view_ticket">' ;
2018-03-10 04:23:59 +01:00
2024-04-20 18:49:24 +02:00
print '<p><label for="track_id" style="display: inline-block;" class="titlefieldcreate left"><span class="fieldrequired">' ;
2024-04-20 14:28:59 +02:00
print img_picto ( $langs -> trans ( " TicketTrackId " ), 'generic' , 'class="pictofixedwidth"' );
print $langs -> trans ( " TicketTrackId " ) . '</span></label>' ;
2024-04-20 14:49:40 +02:00
print '<br class="showonsmartphone hidden">' ;
2024-04-20 14:28:59 +02:00
print '<input class="minwidth100" id="track_id" name="track_id" value="' . ( GETPOST ( 'track_id' , 'alpha' ) ? GETPOST ( 'track_id' , 'alpha' ) : '' ) . '" />' ;
2020-04-16 00:42:57 +02:00
print '</p>' ;
2018-03-10 04:23:59 +01:00
2024-04-20 18:49:24 +02:00
print '<p><label for="email" style="display: inline-block;" class="titlefieldcreate left"><span class="fieldrequired">' ;
2024-04-20 14:28:59 +02:00
print img_picto ( $langs -> trans ( " Email " ), 'email' , 'class="pictofixedwidth"' );
print $langs -> trans ( 'Email' ) . '</span></label>' ;
2024-04-20 14:49:40 +02:00
print '<br class="showonsmartphone hidden">' ;
2024-04-20 14:28:59 +02:00
print '<input class="minwidth100" id="email" name="email" value="' . ( GETPOST ( 'email' , 'alpha' ) ? GETPOST ( 'email' , 'alpha' ) : ( ! empty ( $_SESSION [ 'customer_email' ]) ? $_SESSION [ 'customer_email' ] : " " )) . '" />' ;
2020-04-16 00:42:57 +02:00
print '</p>' ;
2018-03-10 04:23:59 +01:00
2020-04-16 00:42:57 +02:00
print '<p style="text-align: center; margin-top: 1.5em;">' ;
2021-08-24 17:04:17 +02:00
print '<input type="submit" class="button" name="btn_view_ticket" value="' . $langs -> trans ( 'ViewTicket' ) . '" />' ;
2022-09-01 10:54:20 +02:00
print ' ' ;
print '<input type="submit" class="button button-cancel" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2020-04-16 00:42:57 +02:00
print " </p> \n " ;
2018-03-10 04:23:59 +01:00
2020-04-16 00:42:57 +02:00
print " </form> \n " ;
print " </div> \n " ;
2018-03-10 04:23:59 +01:00
2023-11-09 11:31:16 +01:00
print '</div>' ;
}
2019-05-03 17:11:13 +02:00
2023-07-31 04:14:18 +02:00
if ( getDolGlobalInt ( 'TICKET_SHOW_COMPANY_FOOTER' )) {
// End of page
htmlPrintOnlineFooter ( $mysoc , $langs , 0 , $suffix , $object );
}
2019-05-03 17:11:13 +02:00
llxFooter ( '' , 'public' );
2018-03-10 04:23:59 +01:00
$db -> close ();