25 if (!defined(
'NOREQUIREMENU')) {
26 define(
'NOREQUIREMENU',
'1');
29 if (!defined(
"NOLOGIN")) {
30 define(
"NOLOGIN",
'1');
32 if (!defined(
'NOIPCHECK')) {
33 define(
'NOIPCHECK',
'1');
35 if (!defined(
'NOBROWSERNOTIF')) {
36 define(
'NOBROWSERNOTIF',
'1');
42 $entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
43 if (is_numeric($entity)) {
44 define(
"DOLENTITY", $entity);
48 require
'../../main.inc.php';
49 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/actions_ticket.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formticket.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ticket.lib.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
55 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
58 $langs->loadLangs(array(
"companies",
"other",
"ticket"));
61 $action =
GETPOST(
'action',
'aZ09');
62 $cancel =
GETPOST(
'cancel',
'aZ09');
64 $track_id =
GETPOST(
'track_id',
'alpha');
65 $email =
GETPOST(
'email',
'email');
68 if (
GETPOST(
'btn_view_ticket')) {
69 unset($_SESSION[
'email_customer']);
71 if (isset($_SESSION[
'email_customer'])) {
72 $email = $_SESSION[
'email_customer'];
87 $backtopage = DOL_URL_ROOT.
'/public/ticket/index.php';
89 if (!empty($backtopage)) {
90 header(
"Location: ".$backtopage);
93 $action =
'view_ticket';
96 if ($action ==
"view_ticket" || $action ==
"presend" || $action ==
"close" || $action ==
"confirm_public_close" || $action ==
"add_message") {
98 $display_ticket =
false;
99 if (!strlen($track_id)) {
101 array_push($object->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"TicketTrackId")));
104 if (!strlen($email)) {
106 array_push($object->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Email")));
111 array_push($object->errors, $langs->trans(
"ErrorEmailInvalid"));
117 $ret = $object->fetch(
'',
'', $track_id);
118 if ($ret && $object->dao->id > 0) {
121 if (strtolower($emailofticket) == strtolower($email)) {
122 $display_ticket =
true;
123 $_SESSION[
'email_customer'] = $email;
126 $contacts = $object->dao->liste_contact(-1,
'external');
127 foreach ($contacts as $contact) {
128 if (strtolower($contact[
'email']) == strtolower($email)) {
129 $display_ticket =
true;
130 $_SESSION[
'email_customer'] = $email;
133 $display_ticket =
false;
138 if ($object->dao->fk_soc > 0 || $object->dao->socid > 0) {
139 $object->dao->fetch_thirdparty();
140 if ($email == $object->dao->thirdparty->email) {
141 $display_ticket =
true;
142 $_SESSION[
'email_customer'] = $email;
146 if ($object->dao->fk_user_create > 0) {
147 $tmpuser =
new User($db);
148 $tmpuser->fetch($object->dao->fk_user_create);
149 if (strtolower($email) == strtolower($tmpuser->email)) {
150 $display_ticket =
true;
151 $_SESSION[
'email_customer'] = $email;
155 if ($object->dao->fk_user_assign > 0 && $object->dao->fk_user_assign != $object->dao->fk_user_create) {
156 $tmpuser =
new User($db);
157 $tmpuser->fetch($object->dao->fk_user_assign);
158 if (strtolower($email) == strtolower($tmpuser->email)) {
159 $display_ticket =
true;
160 $_SESSION[
'email_customer'] = $email;
165 array_push($object->errors, $langs->trans(
"ErrorTicketNotFound", $track_id));
170 if (!$error && $action ==
'confirm_public_close' && $display_ticket) {
171 if ($object->dao->close($user)) {
174 $url =
'view.php?action=view_ticket&track_id='.GETPOST(
'track_id',
'alpha').(!empty($entity) &&
isModEnabled(
'multicompany')?
'&entity='.$entity:
'');
175 header(
"Location: ".$url);
183 if (!$error && $action ==
"add_message" && $display_ticket &&
GETPOSTISSET(
'btn_add_message')) {
185 $ret = $object->dao->newMessage($user, $action, 0, 1);
189 $action =
'view_ticket';
193 if ($error || $errors) {
195 if ($action ==
"add_message") {
206 $triggersendname =
'TICKET_SENTBYMAIL';
208 $autocopy =
'MAIN_MAIL_AUTOCOPY_TICKET_TO';
209 if (!empty($object->id)) $trackid =
'tic'.$object->id;
210 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
221 if (!$conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) {
222 print
'<div class="error">'.$langs->trans(
'TicketPublicInterfaceForbidden').
'</div>';
227 $arrayofjs = array();
228 $arrayofcss = array(
'/ticket/css/styles.css.php');
230 llxHeaderTicket($langs->trans(
"Tickets"),
"", 0, 0, $arrayofjs, $arrayofcss);
232 print
'<div class="ticketpublicarea">';
234 if ($action ==
"view_ticket" || $action ==
"presend" || $action ==
"close" || $action ==
"confirm_public_close") {
235 if ($display_ticket) {
237 if ($action ==
'close') {
238 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);
241 print
'<div id="form_view_ticket" class="margintoponly">';
243 print
'<table class="ticketpublictable centpercent tableforfield">';
246 print
'<tr><td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
247 print
img_picto(
'',
'ticket',
'class="pictofixedwidth"');
252 print
'<tr><td>'.$langs->trans(
"TicketTrackId").
'</td><td>';
257 print
'<tr><td>'.$langs->trans(
"Subject").
'</td><td>';
258 print
'<span class="bold">';
264 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
265 print $object->dao->getLibStatut(2);
269 print
'<tr><td>'.$langs->trans(
"Type").
'</td><td>';
274 print
'<tr><td>'.$langs->trans(
"Category").
'</td><td>';
275 if ($object->dao->category_label) {
276 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
282 print
'<tr><td>'.$langs->trans(
"Severity").
'</td><td>';
287 print
'<tr><td>'.$langs->trans(
"DateCreation").
'</td><td>';
292 print
'<tr><td>'.$langs->trans(
"Author").
'</td><td>';
293 if ($object->dao->fk_user_create > 0) {
294 $langs->load(
"users");
295 $fuser =
new User($db);
296 $fuser->fetch($object->dao->fk_user_create);
297 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
298 print $fuser->getFullName($langs);
300 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
307 if (!empty($object->dao->date_read)) {
308 print
'<tr><td>'.$langs->trans(
"TicketReadOn").
'</td><td>';
314 if (!empty($object->dao->date_close)) {
315 print
'<tr><td>'.$langs->trans(
"TicketCloseOn").
'</td><td>';
321 print
'<tr><td>'.$langs->trans(
"AssignedTo").
'</td><td>';
322 if ($object->dao->fk_user_assign > 0) {
323 $fuser =
new User($db);
324 $fuser->fetch($object->dao->fk_user_assign);
325 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
326 print $fuser->getFullName($langs, 1);
331 print
'<tr><td>'.$langs->trans(
"Progression").
'</td><td>';
332 print ($object->dao->progress > 0 ?
dol_escape_htmltag($object->dao->progress) :
'0').
'%';
339 print
'<div style="clear: both; margin-top: 1.5em;"></div>';
341 if ($action ==
'presend') {
342 print
load_fiche_titre($langs->trans(
'TicketAddMessage'),
'',
'conversation');
346 $formticket->action =
"add_message";
347 $formticket->track_id = $object->dao->track_id;
348 $formticket->id = $object->dao->id;
350 $formticket->param = array(
'track_id' => $object->dao->track_id,
'fk_user_create' =>
'-1',
351 'returnurl' => DOL_URL_ROOT.
'/public/ticket/view.php'.(!empty($entity) &&
isModEnabled(
'multicompany')?
'?entity='.$entity:
''));
353 $formticket->withfile = 2;
354 $formticket->withcancel = 1;
356 $formticket->showMessageForm(
'100%');
359 if ($action !=
'presend') {
360 print
'<form method="post" id="form_view_ticket_list" name="form_view_ticket_list" action="'.DOL_URL_ROOT.
'/public/ticket/list.php'.(!empty($entity) &&
isModEnabled(
'multicompany')?
'?entity='.$entity:
'').
'">';
361 print
'<input type="hidden" name="token" value="'.newToken().
'">';
362 print
'<input type="hidden" name="action" value="view_ticketlist">';
363 print
'<input type="hidden" name="track_id" value="'.$object->dao->track_id.
'">';
364 print
'<input type="hidden" name="email" value="'.$_SESSION[
'email_customer'].
'">';
368 print
'<div class="tabsAction">';
371 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>';
373 if ($object->dao->fk_statut < Ticket::STATUS_CLOSED) {
375 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:
'').
'">'.$langs->trans(
'TicketAddMessage').
'</a></div>';
379 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:
'').
'">'.$langs->trans(
'CloseTicket').
'</a></div>';
387 print
load_fiche_titre($langs->trans(
'TicketMessagesList'),
'',
'conversation');
388 $object->viewTicketMessages(
false,
true, $object->dao);
390 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>';
393 print
'<div class="center opacitymedium margintoponly marginbottomonly">'.$langs->trans(
"TicketPublicMsgViewLogIn").
'</div>';
395 print
'<div id="form_view_ticket">';
396 print
'<form method="post" name="form_view_ticket" action="'.$_SERVER[
'PHP_SELF'].(!empty($entity) &&
isModEnabled(
'multicompany')?
'?entity='.$entity:
'').
'">';
397 print
'<input type="hidden" name="token" value="'.newToken().
'">';
398 print
'<input type="hidden" name="action" value="view_ticket">';
400 print
'<p><label for="track_id" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans(
"TicketTrackId").
'</span></label>';
401 print
'<input size="30" id="track_id" name="track_id" value="'.(GETPOST(
'track_id',
'alpha') ?
GETPOST(
'track_id',
'alpha') :
'').
'" />';
404 print
'<p><label for="email" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans(
'Email').
'</span></label>';
405 print
'<input size="30" id="email" name="email" value="'.(GETPOST(
'email',
'alpha') ?
GETPOST(
'email',
'alpha') : (!empty($_SESSION[
'customer_email']) ? $_SESSION[
'customer_email'] :
"")).
'" />';
408 print
'<p style="text-align: center; margin-top: 1.5em;">';
409 print
'<input type="submit" class="button" name="btn_view_ticket" value="'.$langs->trans(
'ViewTicket').
'" />';
411 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
421 htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix, $object);
Class Actions of the module ticket.
static getValidAddress($address, $format, $encode=0, $maxnumberofemail=0)
Return a formatted address string for SMTP protocol.
const STATUS_NOT_READ
Status.
Class to manage Dolibarr users.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
isModEnabled($module)
Is Dolibarr module enabled.
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 header for public pages.