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';
68$langs->loadLangs(array(
"companies",
"other",
"ticket"));
71$action =
GETPOST(
'action',
'aZ09');
72$cancel =
GETPOST(
'cancel',
'aZ09');
74$track_id =
GETPOST(
'track_id',
'alpha');
75$email =
GETPOST(
'email',
'email');
78if (
GETPOST(
'btn_view_ticket')) {
79 unset($_SESSION[
'email_customer']);
81if (isset($_SESSION[
'email_customer'])) {
82 $email = $_SESSION[
'email_customer'];
87if (!isModEnabled(
'ticket')) {
97 $backtopage =
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.
'/public/ticket/');
99 if (!empty($backtopage)) {
100 header(
"Location: ".$backtopage);
103 $action =
'view_ticket';
106if (in_array($action, array(
"view_ticket",
"presend",
"close",
"confirm_public_close",
"add_message",
"add_contact"))) {
108 $display_ticket =
false;
109 if (!strlen($track_id)) {
111 array_push(
$object->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"TicketTrackId")));
114 if (!strlen($email)) {
116 array_push(
$object->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Email")));
121 array_push(
$object->errors, $langs->trans(
"ErrorEmailInvalid"));
127 $ret =
$object->fetch(
'',
'', $track_id);
128 if ($ret &&
$object->dao->id > 0) {
131 if (strtolower($emailofticket) == strtolower($email)) {
132 $display_ticket =
true;
133 $_SESSION[
'email_customer'] = $email;
136 $contacts =
$object->dao->liste_contact(-1,
'external');
137 foreach ($contacts as $contact) {
138 if (strtolower($contact[
'email']) == strtolower($email)) {
139 $display_ticket =
true;
140 $_SESSION[
'email_customer'] = $email;
143 $display_ticket =
false;
149 $object->dao->fetch_thirdparty();
150 if ($email ==
$object->dao->thirdparty->email) {
151 $display_ticket =
true;
152 $_SESSION[
'email_customer'] = $email;
156 if (
$object->dao->fk_user_create > 0) {
157 $tmpuser =
new User($db);
158 $tmpuser->fetch(
$object->dao->fk_user_create);
159 if (strtolower($email) == strtolower($tmpuser->email)) {
160 $display_ticket =
true;
161 $_SESSION[
'email_customer'] = $email;
165 if (
$object->dao->fk_user_assign > 0 &&
$object->dao->fk_user_assign !=
$object->dao->fk_user_create) {
166 $tmpuser =
new User($db);
167 $tmpuser->fetch(
$object->dao->fk_user_assign);
168 if (strtolower($email) == strtolower($tmpuser->email)) {
169 $display_ticket =
true;
170 $_SESSION[
'email_customer'] = $email;
175 array_push(
$object->errors, $langs->trans(
"ErrorTicketNotFound", $track_id));
180 if (!$error && $action ==
'confirm_public_close' && $display_ticket) {
181 if (
$object->dao->close($user)) {
184 $url =
'view.php?action=view_ticket&track_id='.GETPOST(
'track_id',
'alpha').(!empty($entity) && isModEnabled(
'multicompany') ?
'&entity='.$entity :
'').
'&token='.
newToken();
185 header(
"Location: ".$url);
193 if (!$error && $action ==
"add_message" && $display_ticket && GETPOSTISSET(
'btn_add_message')) {
194 $ret =
$object->dao->newMessage($user, $action, 0, 1);
197 $action =
'view_ticket';
202 if (!$error && $action ==
"add_contact" && $display_ticket && GETPOSTISSET(
'btn_add_contact')) {
206 $action =
'view_ticket';
210 if ($error || !empty(
$object->errors)) {
212 if ($action ==
"add_message") {
221$triggersendname =
'TICKET_SENTBYMAIL';
223$autocopy =
'MAIN_MAIL_AUTOCOPY_TICKET_TO';
225 $trackid =
'tic'.$object->dao->id;
227include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
235$form =
new Form($db);
239$hookmanager->initHooks(array(
'ticketpublicview',
'globalcard'));
242 print
'<div class="error">'.$langs->trans(
'TicketPublicInterfaceForbidden').
'</div>';
248$arrayofcss = array(
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE',
'/public/ticket/').
'css/styles.css.php');
250llxHeaderTicket($langs->trans(
"Tickets"),
"", 0, 0, $arrayofjs, $arrayofcss);
253if ($action ==
"view_ticket" || $action ==
"presend" || $action ==
"close" || $action ==
"confirm_public_close") {
254 if ($display_ticket) {
255 print
'<!-- public view ticket -->';
256 print
'<div class="ticketpublicarea ticketlargemargin centpercent">';
259 if ($action ==
'close') {
260 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);
263 print
'<div id="form_view_ticket" class="margintoponly">';
265 print
'<table class="ticketpublictable centpercent tableforfield">';
268 print
'<tr><td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
269 print
img_picto(
'',
'ticket',
'class="pictofixedwidth"');
274 print
'<tr><td>'.$langs->trans(
"TicketTrackId").
'</td><td>';
279 print
'<tr><td>'.$langs->trans(
"Subject").
'</td><td>';
280 print
'<span class="bold">';
286 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
287 print
$object->dao->getLibStatut(2);
291 print
'<tr><td>'.$langs->trans(
"Type").
'</td><td>';
296 print
'<tr><td>'.$langs->trans(
"Category").
'</td><td>';
297 if (
$object->dao->category_label) {
298 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
304 print
'<tr><td>'.$langs->trans(
"Severity").
'</td><td>';
309 print
'<tr><td>'.$langs->trans(
"DateCreation").
'</td><td>';
314 print
'<tr><td>'.$langs->trans(
"Author").
'</td><td>';
315 if (
$object->dao->fk_user_create > 0) {
316 $langs->load(
"users");
317 $fuser =
new User($db);
318 $fuser->fetch(
$object->dao->fk_user_create);
319 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
320 print $fuser->getFullName($langs);
322 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
329 if (!empty(
$object->dao->date_read)) {
330 print
'<tr><td>'.$langs->trans(
"TicketReadOn").
'</td><td>';
336 if (!empty(
$object->dao->date_close)) {
337 print
'<tr><td>'.$langs->trans(
"TicketCloseOn").
'</td><td>';
343 print
'<tr><td>'.$langs->trans(
"AssignedTo").
'</td><td>';
344 if (
$object->dao->fk_user_assign > 0) {
345 $fuser =
new User($db);
346 $fuser->fetch(
$object->dao->fk_user_assign);
347 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
348 print $fuser->getFullName($langs, 0);
354 print
'<tr><td>'.$langs->trans(
"ExternalContributors").
'</td><td>';
356 $contactlist =
$object->dao->liste_contact(-1,
'external');
357 foreach ($contactlist as $externalContributor) {
358 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
359 print $externalContributor[
"lastname"].
" ".$externalContributor[
"firstname"].
"<br>";
367 print
'<form method="post" id="form_view_add_contact" name="form_view_add_contact" action="'.$_SERVER[
'PHP_SELF'].
'?track_id='.
$object->dao->track_id.
'">';
368 print
'<input type="hidden" name="token" value="'.newToken().
'">';
369 print
'<input type="hidden" name="action" value="add_contact">';
370 print
'<input type="hidden" name="email" value="'.$_SESSION[
'email_customer'].
'">';
371 print
'<tr><td>'.$langs->trans(
"AddContributor").
'</td><td>';
373 print $form->select_contact(
$object->dao->fk_soc,
'',
'contactid', 3,
'',
'', 1,
'minwidth100imp widthcentpercentminusxx maxwidth400',
true);
374 print
'<input type="submit" class="button smallpaddingimp reposition" name="btn_add_contact" value="'.$langs->trans(
'Add').
'" />';
375 print
'</td></tr></form>';
380 print
'<tr><td>'.$langs->trans(
"Progression").
'</td><td>';
386 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
392 print
'<div style="clear: both; margin-top: 1.5em;"></div>';
394 if ($action ==
'presend') {
396 print
load_fiche_titre($langs->trans(
'TicketAddMessage'),
'',
'conversation');
400 $formticket->action =
"add_message";
401 $formticket->track_id =
$object->dao->track_id;
402 $formticket->trackid =
'tic'.$object->dao->id;
404 $baseurl =
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.
'/public/ticket/');
406 $formticket->param = array(
'track_id' =>
$object->dao->track_id,
'fk_user_create' =>
'-1',
407 'returnurl' => $baseurl.
'view.php'.(!empty($entity) && isModEnabled(
'multicompany')?
'?entity='.$entity:
''));
409 $formticket->withfile = 2;
410 $formticket->withcancel = 1;
412 $formticket->showMessageForm(
'100%');
415 if ($action !=
'presend') {
416 $baseurl =
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.
'/public/ticket/');
418 print
'<form method="POST" id="form_view_ticket_list" name="form_view_ticket_list" action="'.$baseurl.
'list.php'.(!empty($entity) && isModEnabled(
'multicompany')?
'?entity='.$entity:
'').
'">';
419 print
'<input type="hidden" name="token" value="'.newToken().
'">';
420 print
'<input type="hidden" name="action" value="view_ticketlist">';
421 print
'<input type="hidden" name="track_id" value="'.$object->dao->track_id.
'">';
422 print
'<input type="hidden" name="email" value="'.$_SESSION[
'email_customer'].
'">';
426 print
'<div class="tabsAction">';
429 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>';
431 if (
$object->dao->fk_statut < Ticket::STATUS_CLOSED) {
433 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>';
436 if (
$object->dao->fk_statut >= Ticket::STATUS_NOT_READ &&
$object->dao->fk_statut < Ticket::STATUS_CLOSED) {
437 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>';
447 print
'<div class="ticketpublicarea ticketlargemargin centpercent">';
448 print
load_fiche_titre($langs->trans(
'TicketMessagesList'),
'',
'conversation');
455 print
'<!-- public view ticket -->';
456 print
'<div class="ticketpublicarea ticketlargemargin centpercent">';
458 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>';
463 print
'<!-- public view ticket -->';
464 print
'<div class="ticketpublicarea ticketlargemargin centpercent">';
466 print
'<div class="center opacitymedium margintoponly marginbottomonly ticketlargemargin">'.$langs->trans(
"TicketPublicMsgViewLogIn").
'</div>';
468 print
'<div id="form_view_ticket">';
469 print
'<form method="POST" class="maxwidth1000 center" name="form_view_ticket" action="'.$_SERVER[
'PHP_SELF'].(!empty($entity) && isModEnabled(
'multicompany') ?
'?entity='.$entity :
'').
'">';
471 print
'<input type="hidden" name="token" value="'.newToken().
'">';
472 print
'<input type="hidden" name="action" value="view_ticket">';
474 print
'<p><label for="track_id" style="display: inline-block;" class="titlefieldcreate left"><span class="fieldrequired">';
475 print
img_picto($langs->trans(
"TicketTrackId"),
'generic',
'class="pictofixedwidth"');
476 print $langs->trans(
"TicketTrackId").
'</span></label>';
477 print
'<br class="showonsmartphone hidden">';
478 print
'<input class="minwidth100" id="track_id" name="track_id" value="'.(GETPOST(
'track_id',
'alpha') ?
GETPOST(
'track_id',
'alpha') :
'').
'" />';
481 print
'<p><label for="email" style="display: inline-block;" class="titlefieldcreate left"><span class="fieldrequired">';
482 print
img_picto($langs->trans(
"Email"),
'email',
'class="pictofixedwidth"');
483 print $langs->trans(
'Email').
'</span></label>';
484 print
'<br class="showonsmartphone hidden">';
485 print
'<input class="minwidth100" id="email" name="email" value="'.(GETPOST(
'email',
'alpha') ?
GETPOST(
'email',
'alpha') : (!empty($_SESSION[
'customer_email']) ? $_SESSION[
'customer_email'] :
"")).
'" />';
488 print
'<p style="text-align: center; margin-top: 1.5em;">';
489 print
'<input type="submit" class="button" name="btn_view_ticket" value="'.$langs->trans(
'ViewTicket').
'" />';
491 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.