28if (!defined(
'NOREQUIREMENU')) {
29 define(
'NOREQUIREMENU',
'1');
32if (!defined(
"NOLOGIN")) {
33 define(
"NOLOGIN",
'1');
35if (!defined(
'NOIPCHECK')) {
36 define(
'NOIPCHECK',
'1');
38if (!defined(
'NOBROWSERNOTIF')) {
39 define(
'NOBROWSERNOTIF',
'1');
46$entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
47if (is_numeric($entity)) {
48 define(
"DOLENTITY", $entity);
52require
'../../main.inc.php';
53require_once DOL_DOCUMENT_ROOT.
'/ticket/class/actions_ticket.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formticket.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/ticket.lib.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
71$langs->loadLangs(array(
"companies",
"other",
"ticket"));
74$action =
GETPOST(
'action',
'aZ09');
77$track_id =
GETPOST(
'track_id',
'alpha');
78$email =
GETPOST(
'email',
'email');
81if (
GETPOST(
'btn_view_ticket')) {
82 unset($_SESSION[
'email_customer']);
84if (isset($_SESSION[
'email_customer'])) {
85 $email = $_SESSION[
'email_customer'];
100 $backtopage =
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.
'/public/ticket/');
102 if (!empty($backtopage)) {
103 header(
"Location: ".$backtopage);
106 $action =
'view_ticket';
109$display_ticket =
false;
110if (in_array($action, array(
"view_ticket",
"presend",
"close",
"confirm_public_close",
"add_message",
"add_contact"))) {
112 if (!strlen($track_id)) {
114 array_push(
$object->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"TicketTrackId")));
117 if (!strlen($email)) {
119 array_push(
$object->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Email")));
124 array_push(
$object->errors, $langs->trans(
"ErrorEmailInvalid"));
130 $ret =
$object->fetch(0,
'', $track_id);
131 if ($ret &&
$object->dao->id > 0) {
134 if (strtolower($emailofticket) == strtolower($email)) {
135 $display_ticket =
true;
136 $_SESSION[
'email_customer'] = $email;
139 $contacts =
$object->dao->liste_contact(-1,
'external');
140 foreach ($contacts as $contact) {
141 if (strtolower($contact[
'email']) == strtolower($email)) {
142 $display_ticket =
true;
143 $_SESSION[
'email_customer'] = $email;
146 $display_ticket =
false;
152 $object->dao->fetch_thirdparty();
153 if ($email ==
$object->dao->thirdparty->email) {
154 $display_ticket =
true;
155 $_SESSION[
'email_customer'] = $email;
159 if (
$object->dao->fk_user_create > 0) {
160 $tmpuser =
new User($db);
161 $tmpuser->fetch(
$object->dao->fk_user_create);
162 if (strtolower($email) == strtolower($tmpuser->email)) {
163 $display_ticket =
true;
164 $_SESSION[
'email_customer'] = $email;
168 if (
$object->dao->fk_user_assign > 0 &&
$object->dao->fk_user_assign !=
$object->dao->fk_user_create) {
169 $tmpuser =
new User($db);
170 $tmpuser->fetch(
$object->dao->fk_user_assign);
171 if (strtolower($email) == strtolower($tmpuser->email)) {
172 $display_ticket =
true;
173 $_SESSION[
'email_customer'] = $email;
178 array_push(
$object->errors, $langs->trans(
"ErrorTicketNotFound", $track_id));
183 if (!$error && $action ==
'confirm_public_close' && $display_ticket) {
184 if (
$object->dao->close($user)) {
185 setEventMessages($langs->trans(
'TicketMarkedAsClosed'),
null,
'mesgs');
187 $url =
'view.php?action=view_ticket&track_id='.GETPOST(
'track_id',
'alpha').(!empty($entity) &&
isModEnabled(
'multicompany') ?
'&entity='.$entity :
'').
'&token='.
newToken();
188 header(
"Location: ".$url);
196 if (!$error && $action ==
"add_message" && $display_ticket &&
GETPOSTISSET(
'btn_add_message')) {
197 $ret =
$object->dao->newMessage($user, $action, 0, 1);
200 setEventMessages(
$object->dao->error,
$object->dao->errors,
'errors');
204 $action =
'view_ticket';
209 if (!$error && $action ==
"add_contact" && $display_ticket &&
GETPOSTISSET(
'btn_add_contact')) {
213 $action =
'view_ticket';
217 if ($error || !empty(
$object->errors)) {
219 if ($action ==
"add_message") {
229$triggersendname =
'TICKET_SENTBYMAIL';
231$autocopy =
'MAIN_MAIL_AUTOCOPY_TICKET_TO';
233 $trackid =
'tic'.$object->dao->id;
235include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
243$form =
new Form($db);
247$hookmanager->initHooks(array(
'ticketpublicview',
'globalcard'));
250 print
'<div class="error">'.$langs->trans(
'TicketPublicInterfaceForbidden').
'</div>';
256$arrayofcss = array(
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE',
'/public/ticket/').
'css/styles.css.php');
258llxHeaderTicket($langs->trans(
"Tickets"),
"", 0, 0, $arrayofjs, $arrayofcss);
261if ($action ==
"view_ticket" || $action ==
"presend" || $action ==
"close" || $action ==
"confirm_public_close") {
262 if ($display_ticket) {
263 print
'<!-- public view ticket if if -->';
264 print
'<div class="ticketpublicarea ticketlargemargin">';
267 if ($action ==
'close') {
268 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);
271 print
'<div id="form_view_ticket" class="margintoponly">';
273 print
'<table class="ticketpublictable centpercent tableforfield">';
276 print
'<tr><td class="titlefield">'.$langs->trans(
"Ref").
' / '.$langs->trans(
"TicketTrackId").
'</td><td>';
277 print img_picto(
'',
'ticket',
'class="pictofixedwidth"');
278 print dolPrintHTML(
$object->dao->ref);
279 print
'<span class="opacitylow"> / '.dolPrintHTML(
$object->dao->track_id).
'</span>';
283 print
'<tr><td>'.$langs->trans(
"Subject").
'</td><td>';
284 print
'<span class="bold large">';
290 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
291 print
$object->dao->getLibStatut(2);
295 print
'<tr><td>'.$langs->trans(
"Type").
'</td><td>';
300 print
'<tr><td>'.$langs->trans(
"Category").
'</td><td>';
301 if (
$object->dao->category_label) {
302 print img_picto(
'',
'category',
'class="pictofixedwidth"');
308 print
'<tr><td>'.$langs->trans(
"Severity").
'</td><td>';
313 print
'<tr><td>'.$langs->trans(
"DateCreation").
'</td><td>';
314 print img_picto(
'',
'calendar',
'class="pictofixedwidth"');
319 print
'<tr><td>'.$langs->trans(
"Author").
'</td><td>';
320 if (
$object->dao->fk_user_create > 0) {
321 $langs->load(
"users");
322 $fuser =
new User($db);
323 $fuser->fetch(
$object->dao->fk_user_create);
324 print img_picto(
'',
'user',
'class="pictofixedwidth"');
325 print $fuser->getFullName($langs);
327 print img_picto(
'',
'email',
'class="pictofixedwidth"');
334 if (!empty(
$object->dao->date_read)) {
335 print
'<tr><td>'.$langs->trans(
"TicketReadOn").
'</td><td>';
341 if (!empty(
$object->dao->date_close)) {
342 print
'<tr><td>'.$langs->trans(
"TicketCloseOn").
'</td><td>';
348 if (
$object->dao->fk_user_assign > 0) {
349 print
'<tr><td>'.$langs->trans(
"AssignedTo").
'aaaa</td><td>';
350 $fuser =
new User($db);
351 $fuser->fetch(
$object->dao->fk_user_assign);
352 print img_picto(
'',
'user',
'class="pictofixedwidth"');
353 print $fuser->getFullName($langs, 0);
359 print
'<tr><td>'.$langs->trans(
"ExternalContributors").
'</td><td>';
361 $contactlist =
$object->dao->liste_contact(-1,
'external');
362 foreach ($contactlist as $externalContributor) {
363 print img_picto(
'',
'contact',
'class="pictofixedwidth"');
364 print $externalContributor[
"lastname"].
" ".$externalContributor[
"firstname"].
"<br>";
372 print
'<form method="post" id="form_view_add_contact" name="form_view_add_contact" action="'.$_SERVER[
'PHP_SELF'].
'?track_id='.
$object->dao->track_id.
'">';
373 print
'<input type="hidden" name="token" value="'.newToken().
'">';
374 print
'<input type="hidden" name="action" value="add_contact">';
375 print
'<input type="hidden" name="email" value="'.$_SESSION[
'email_customer'].
'">';
376 print
'<tr><td>'.$langs->trans(
"AddContributor").
'</td><td>';
378 print $form->select_contact(
$object->dao->fk_soc,
'',
'contactid', 3,
'',
'', 1,
'minwidth100imp widthcentpercentminusxx maxwidth400',
true);
379 print
'<input type="submit" class="button smallpaddingimp reposition" name="btn_add_contact" value="'.$langs->trans(
'Add').
'" />';
380 print
'</td></tr></form>';
385 print
'<tr><td>'.$langs->trans(
"Progression").
'</td><td>';
391 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
397 print
'<div style="clear: both; margin-top: 1.5em;"></div>';
399 if ($action ==
'presend') {
401 print
load_fiche_titre($langs->trans(
'TicketAddMessage'),
'',
'conversation');
405 $formticket->action =
"add_message";
406 $formticket->track_id =
$object->dao->track_id;
407 $formticket->trackid =
'tic'.$object->dao->id;
409 $baseurl =
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.
'/public/ticket/');
411 $formticket->param = array(
'track_id' =>
$object->dao->track_id,
'fk_user_create' =>
'-1',
412 'returnurl' => $baseurl.
'view.php'.(!empty($entity) &&
isModEnabled(
'multicompany') ?
'?entity='.$entity :
''));
414 $formticket->withfile = 2;
415 $formticket->withcancel = 1;
416 $formticket->withtitletopic = 1;
418 $formticket->showMessageForm(
'100%', 1);
421 if ($action !=
'presend') {
422 $baseurl =
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.
'/public/ticket/');
424 print
'<form method="POST" id="form_view_ticket_list" name="form_view_ticket_list" action="'.$baseurl.
'list.php'.(!empty($entity) &&
isModEnabled(
'multicompany') ?
'?entity='.$entity :
'').
'">';
425 print
'<input type="hidden" name="token" value="'.newToken().
'">';
426 print
'<input type="hidden" name="action" value="view_ticketlist">';
427 print
'<input type="hidden" name="track_id" value="'.$object->dao->track_id.
'">';
428 print
'<input type="hidden" name="email" value="'.$_SESSION[
'email_customer'].
'">';
432 print
'<div class="tabsAction">';
435 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>';
437 if (
$object->dao->status < Ticket::STATUS_CLOSED) {
439 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>';
442 if (
$object->dao->status >= Ticket::STATUS_NOT_READ &&
$object->dao->status < Ticket::STATUS_CLOSED) {
443 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>';
453 print
'<div class="ticketpublicarea ticketlargemargin">';
455 print
load_fiche_titre($langs->trans(
'TicketMessagesList'),
'',
'conversation');
463 print
'<!-- public view ticket if else -->';
464 print
'<div class="ticketpublicarea ticketlargemargin">';
466 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(
"GoBack").
'</a></div>';
471 print
'<!-- public view ticket else -->';
472 print
'<div class="ticketpublicarea ticketlargemargin">';
474 print
'<div class="center opacitymedium margintoponly marginbottomonly ticketlargemargin">'.$langs->trans(
"TicketPublicMsgViewLogIn").
'</div>';
476 print
'<div id="form_view_ticket">';
477 print
'<form method="POST" class="maxwidth1000 center" name="form_view_ticket" action="'.$_SERVER[
'PHP_SELF'].(!empty($entity) &&
isModEnabled(
'multicompany') ?
'?entity='.$entity :
'').
'">';
479 print
'<input type="hidden" name="token" value="'.newToken().
'">';
480 print
'<input type="hidden" name="action" value="view_ticket">';
482 print
'<p><label for="track_id" style="display: inline-block;" class="titlefieldcreate left"><span class="fieldrequired">';
483 print img_picto($langs->trans(
"TicketTrackId"),
'generic',
'class="pictofixedwidth"');
484 print $langs->trans(
"TicketTrackId").
'</span></label>';
485 print
'<br class="showonsmartphone hidden">';
486 print
'<input class="minwidth100" id="track_id" name="track_id" value="'.(GETPOST(
'track_id',
'alpha') ?
GETPOST(
'track_id',
'alpha') :
'').
'" />';
489 print
'<p><label for="email" style="display: inline-block;" class="titlefieldcreate left"><span class="fieldrequired">';
490 print img_picto($langs->trans(
"Email"),
'email',
'class="pictofixedwidth"');
491 print $langs->trans(
'Email').
'</span></label>';
492 print
'<br class="showonsmartphone hidden">';
493 print
'<input class="minwidth100" id="email" name="email" value="'.(GETPOST(
'email',
'alpha') ?
GETPOST(
'email',
'alpha') : (!empty($_SESSION[
'customer_email']) ? $_SESSION[
'customer_email'] :
"")).
'" />';
496 print
'<p style="text-align: center; margin-top: 1.5em;">';
497 print
'<input type="submit" class="button" name="btn_view_ticket" value="'.$langs->trans(
'ViewTicket').
'" />';
499 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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 public pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
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.