26if (!defined(
'NOREQUIREMENU')) {
27 define(
'NOREQUIREMENU',
'1');
30if (!defined(
"NOLOGIN")) {
31 define(
"NOLOGIN",
'1');
33if (!defined(
'NOIPCHECK')) {
34 define(
'NOIPCHECK',
'1');
36if (!defined(
'NOBROWSERNOTIF')) {
37 define(
'NOBROWSERNOTIF',
'1');
44$entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
45if (is_numeric($entity)) {
46 define(
"DOLENTITY", $entity);
50require
'../../main.inc.php';
51require_once DOL_DOCUMENT_ROOT.
'/ticket/class/actions_ticket.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formticket.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/lib/ticket.lib.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
60$langs->loadLangs(array(
"companies",
"other",
"ticket"));
63$action =
GETPOST(
'action',
'aZ09');
64$cancel =
GETPOST(
'cancel',
'aZ09');
66$track_id =
GETPOST(
'track_id',
'alpha');
67$email =
GETPOST(
'email',
'email');
70if (
GETPOST(
'btn_view_ticket')) {
71 unset($_SESSION[
'email_customer']);
73if (isset($_SESSION[
'email_customer'])) {
74 $email = $_SESSION[
'email_customer'];
79if (!isModEnabled(
'ticket')) {
89 $backtopage =
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.
'/public/ticket/');
91 if (!empty($backtopage)) {
92 header(
"Location: ".$backtopage);
95 $action =
'view_ticket';
98if (in_array($action, array(
"view_ticket",
"presend",
"close",
"confirm_public_close",
"add_message",
"add_contact"))) {
100 $display_ticket =
false;
101 if (!strlen($track_id)) {
103 array_push(
$object->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"TicketTrackId")));
106 if (!strlen($email)) {
108 array_push(
$object->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Email")));
113 array_push(
$object->errors, $langs->trans(
"ErrorEmailInvalid"));
119 $ret =
$object->fetch(
'',
'', $track_id);
120 if ($ret &&
$object->dao->id > 0) {
123 if (strtolower($emailofticket) == strtolower($email)) {
124 $display_ticket =
true;
125 $_SESSION[
'email_customer'] = $email;
128 $contacts =
$object->dao->liste_contact(-1,
'external');
129 foreach ($contacts as $contact) {
130 if (strtolower($contact[
'email']) == strtolower($email)) {
131 $display_ticket =
true;
132 $_SESSION[
'email_customer'] = $email;
135 $display_ticket =
false;
141 $object->dao->fetch_thirdparty();
142 if ($email ==
$object->dao->thirdparty->email) {
143 $display_ticket =
true;
144 $_SESSION[
'email_customer'] = $email;
148 if (
$object->dao->fk_user_create > 0) {
149 $tmpuser =
new User($db);
150 $tmpuser->fetch(
$object->dao->fk_user_create);
151 if (strtolower($email) == strtolower($tmpuser->email)) {
152 $display_ticket =
true;
153 $_SESSION[
'email_customer'] = $email;
157 if (
$object->dao->fk_user_assign > 0 &&
$object->dao->fk_user_assign !=
$object->dao->fk_user_create) {
158 $tmpuser =
new User($db);
159 $tmpuser->fetch(
$object->dao->fk_user_assign);
160 if (strtolower($email) == strtolower($tmpuser->email)) {
161 $display_ticket =
true;
162 $_SESSION[
'email_customer'] = $email;
167 array_push(
$object->errors, $langs->trans(
"ErrorTicketNotFound", $track_id));
172 if (!$error && $action ==
'confirm_public_close' && $display_ticket) {
173 if (
$object->dao->close($user)) {
176 $url =
'view.php?action=view_ticket&track_id='.GETPOST(
'track_id',
'alpha').(!empty($entity) && isModEnabled(
'multicompany') ?
'&entity='.$entity :
'').
'&token='.
newToken();
177 header(
"Location: ".$url);
185 if (!$error && $action ==
"add_message" && $display_ticket && GETPOSTISSET(
'btn_add_message')) {
186 $ret =
$object->dao->newMessage($user, $action, 0, 1);
189 $action =
'view_ticket';
194 if (!$error && $action ==
"add_contact" && $display_ticket && GETPOSTISSET(
'btn_add_contact')) {
198 $action =
'view_ticket';
202 if ($error || !empty(
$object->errors)) {
204 if ($action ==
"add_message") {
213$triggersendname =
'TICKET_SENTBYMAIL';
215$autocopy =
'MAIN_MAIL_AUTOCOPY_TICKET_TO';
217 $trackid =
'tic'.$object->dao->id;
219include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
227$form =
new Form($db);
231$hookmanager->initHooks(array(
'ticketpublicview',
'globalcard'));
234 print
'<div class="error">'.$langs->trans(
'TicketPublicInterfaceForbidden').
'</div>';
240$arrayofcss = array(
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE',
'/public/ticket/').
'css/styles.css.php');
242llxHeaderTicket($langs->trans(
"Tickets"),
"", 0, 0, $arrayofjs, $arrayofcss);
245if ($action ==
"view_ticket" || $action ==
"presend" || $action ==
"close" || $action ==
"confirm_public_close") {
246 if ($display_ticket) {
247 print
'<!-- public view ticket -->';
248 print
'<div class="ticketpublicarea ticketlargemargin centpercent">';
251 if ($action ==
'close') {
252 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);
255 print
'<div id="form_view_ticket" class="margintoponly">';
257 print
'<table class="ticketpublictable centpercent tableforfield">';
260 print
'<tr><td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
261 print
img_picto(
'',
'ticket',
'class="pictofixedwidth"');
266 print
'<tr><td>'.$langs->trans(
"TicketTrackId").
'</td><td>';
271 print
'<tr><td>'.$langs->trans(
"Subject").
'</td><td>';
272 print
'<span class="bold">';
278 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
279 print
$object->dao->getLibStatut(2);
283 print
'<tr><td>'.$langs->trans(
"Type").
'</td><td>';
288 print
'<tr><td>'.$langs->trans(
"Category").
'</td><td>';
289 if (
$object->dao->category_label) {
290 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
296 print
'<tr><td>'.$langs->trans(
"Severity").
'</td><td>';
301 print
'<tr><td>'.$langs->trans(
"DateCreation").
'</td><td>';
306 print
'<tr><td>'.$langs->trans(
"Author").
'</td><td>';
307 if (
$object->dao->fk_user_create > 0) {
308 $langs->load(
"users");
309 $fuser =
new User($db);
310 $fuser->fetch(
$object->dao->fk_user_create);
311 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
312 print $fuser->getFullName($langs);
314 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
321 if (!empty(
$object->dao->date_read)) {
322 print
'<tr><td>'.$langs->trans(
"TicketReadOn").
'</td><td>';
328 if (!empty(
$object->dao->date_close)) {
329 print
'<tr><td>'.$langs->trans(
"TicketCloseOn").
'</td><td>';
335 print
'<tr><td>'.$langs->trans(
"AssignedTo").
'</td><td>';
336 if (
$object->dao->fk_user_assign > 0) {
337 $fuser =
new User($db);
338 $fuser->fetch(
$object->dao->fk_user_assign);
339 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
340 print $fuser->getFullName($langs, 0);
346 print
'<tr><td>'.$langs->trans(
"ExternalContributors").
'</td><td>';
348 $contactlist =
$object->dao->liste_contact(-1,
'external');
349 foreach ($contactlist as $externalContributor) {
350 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
351 print $externalContributor[
"lastname"].
" ".$externalContributor[
"firstname"].
"<br>";
359 print
'<form method="post" id="form_view_add_contact" name="form_view_add_contact" action="'.$_SERVER[
'PHP_SELF'].
'?track_id='.
$object->dao->track_id.
'">';
360 print
'<input type="hidden" name="token" value="'.newToken().
'">';
361 print
'<input type="hidden" name="action" value="add_contact">';
362 print
'<input type="hidden" name="email" value="'.$_SESSION[
'email_customer'].
'">';
363 print
'<tr><td>'.$langs->trans(
"AddContributor").
'</td><td>';
365 print $form->select_contact(
$object->dao->fk_soc,
'',
'contactid', 3,
'',
'', 1,
'minwidth100imp widthcentpercentminusxx maxwidth400',
true);
366 print
'<input type="submit" class="button smallpaddingimp reposition" name="btn_add_contact" value="'.$langs->trans(
'Add').
'" />';
367 print
'</td></tr></form>';
372 print
'<tr><td>'.$langs->trans(
"Progression").
'</td><td>';
378 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
384 print
'<div style="clear: both; margin-top: 1.5em;"></div>';
386 if ($action ==
'presend') {
388 print
load_fiche_titre($langs->trans(
'TicketAddMessage'),
'',
'conversation');
392 $formticket->action =
"add_message";
393 $formticket->track_id =
$object->dao->track_id;
394 $formticket->trackid =
'tic'.$object->dao->id;
396 $baseurl =
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.
'/public/ticket/');
398 $formticket->param = array(
'track_id' =>
$object->dao->track_id,
'fk_user_create' =>
'-1',
399 'returnurl' => $baseurl.
'view.php'.(!empty($entity) && isModEnabled(
'multicompany')?
'?entity='.$entity:
''));
401 $formticket->withfile = 2;
402 $formticket->withcancel = 1;
404 $formticket->showMessageForm(
'100%');
407 if ($action !=
'presend') {
408 $baseurl =
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.
'/public/ticket/');
410 print
'<form method="POST" id="form_view_ticket_list" name="form_view_ticket_list" action="'.$baseurl.
'list.php'.(!empty($entity) && isModEnabled(
'multicompany')?
'?entity='.$entity:
'').
'">';
411 print
'<input type="hidden" name="token" value="'.newToken().
'">';
412 print
'<input type="hidden" name="action" value="view_ticketlist">';
413 print
'<input type="hidden" name="track_id" value="'.$object->dao->track_id.
'">';
414 print
'<input type="hidden" name="email" value="'.$_SESSION[
'email_customer'].
'">';
418 print
'<div class="tabsAction">';
421 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>';
423 if (
$object->dao->fk_statut < Ticket::STATUS_CLOSED) {
425 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>';
428 if (
$object->dao->fk_statut >= Ticket::STATUS_NOT_READ &&
$object->dao->fk_statut < Ticket::STATUS_CLOSED) {
429 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>';
439 print
'<div class="ticketpublicarea ticketlargemargin centpercent">';
440 print
load_fiche_titre($langs->trans(
'TicketMessagesList'),
'',
'conversation');
445 print
'<!-- public view ticket -->';
446 print
'<div class="ticketpublicarea ticketlargemargin centpercent">';
448 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>';
453 print
'<!-- public view ticket -->';
454 print
'<div class="ticketpublicarea ticketlargemargin centpercent">';
456 print
'<div class="center opacitymedium margintoponly marginbottomonly ticketlargemargin">'.$langs->trans(
"TicketPublicMsgViewLogIn").
'</div>';
458 print
'<div id="form_view_ticket">';
459 print
'<form method="POST" class="maxwidth1000 center" name="form_view_ticket" action="'.$_SERVER[
'PHP_SELF'].(!empty($entity) && isModEnabled(
'multicompany') ?
'?entity='.$entity :
'').
'">';
461 print
'<input type="hidden" name="token" value="'.newToken().
'">';
462 print
'<input type="hidden" name="action" value="view_ticket">';
464 print
'<p><label for="track_id" style="display: inline-block;" class="titlefieldcreate left"><span class="fieldrequired">';
465 print
img_picto($langs->trans(
"TicketTrackId"),
'generic',
'class="pictofixedwidth"');
466 print $langs->trans(
"TicketTrackId").
'</span></label>';
467 print
'<br class="showonsmartphone hidden">';
468 print
'<input class="minwidth100" id="track_id" name="track_id" value="'.(GETPOST(
'track_id',
'alpha') ?
GETPOST(
'track_id',
'alpha') :
'').
'" />';
471 print
'<p><label for="email" style="display: inline-block;" class="titlefieldcreate left"><span class="fieldrequired">';
472 print
img_picto($langs->trans(
"Email"),
'email',
'class="pictofixedwidth"');
473 print $langs->trans(
'Email').
'</span></label>';
474 print
'<br class="showonsmartphone hidden">';
475 print
'<input class="minwidth100" id="email" name="email" value="'.(GETPOST(
'email',
'alpha') ?
GETPOST(
'email',
'alpha') : (!empty($_SESSION[
'customer_email']) ? $_SESSION[
'customer_email'] :
"")).
'" />';
478 print
'<p style="text-align: center; margin-top: 1.5em;">';
479 print
'<input type="submit" class="button" name="btn_view_ticket" value="'.$langs->trans(
'ViewTicket').
'" />';
481 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class Actions of the module ticket.
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
Class to manage Dolibarr users.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
llxHeaderTicket($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[])
Show http header, open body tag and show HTML header banner for public pages for tickets.