dolibarr 23.0.3
create_ticket.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io>
3 * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
4 * Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
6 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28/* We need object $user->default_values
29if (!defined('NOREQUIREUSER')) {
30 define('NOREQUIREUSER', '1');
31}*/
32if (!defined('NOREQUIREMENU')) {
33 define('NOREQUIREMENU', '1');
34}
35if (!defined('NOREQUIREHTML')) {
36 define('NOREQUIREHTML', '1');
37}
38if (!defined('NOLOGIN')) {
39 define("NOLOGIN", 1); // This means this output page does not require to be logged.
40}
41if (!defined('NOIPCHECK')) {
42 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
43}
44if (!defined('NOBROWSERNOTIF')) {
45 define('NOBROWSERNOTIF', '1');
46}
47
48// For MultiCompany module.
49// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
50// Because 2 entities can have the same ref.
51$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
52if (is_numeric($entity)) {
53 define("DOLENTITY", $entity);
54}
55
56// Load Dolibarr environment
57require '../../main.inc.php';
58require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php';
59require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php';
60require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
61require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
62require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
63require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
64require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
65require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
66require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
67require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
68
78// Load translation files required by the page
79$langs->loadLangs(array('companies', 'other', 'mails', 'ticket'));
80
81// Get parameters
82$id = GETPOSTINT('id');
83$msg_id = GETPOSTINT('msg_id');
84$socid = GETPOSTINT('socid');
85$suffix = "";
86
87$action = GETPOST('action', 'aZ09');
88$cancel = GETPOST('cancel');
89
90
91$backtopage = '';
92
93// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
94$hookmanager->initHooks(array('publicnewticketcard', 'globalcard'));
95
96$object = new Ticket($db);
97$extrafields = new ExtraFields($db);
98$contacts = array();
99$with_contact = null;
100if (getDolGlobalInt('TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST')) {
101 $with_contact = new Contact($db);
102}
103
104$extrafields->fetch_name_optionals_label($object->table_element);
105
106if (!isModEnabled('ticket')) {
107 httponly_accessforbidden('Module Ticket not enabled');
108}
109
110if (!is_object($user)) {
111 $user = new User($db);
112}
113
114$captchaobj = null;
115if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_TICKET')) {
116 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
117 $captcha = getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_HANDLER', 'standard');
118 // List of directories where we can find captcha handlers
119 $dirModCaptcha = array_merge(
120 array(
121 'main' => '/core/modules/security/captcha/'
122 ),
123 is_array($conf->modules_parts['captcha']) ? $conf->modules_parts['captcha'] : array()
124 );
125 $fullpathclassfile = '';
126 foreach ($dirModCaptcha as $dir) {
127 $fullpathclassfile = dol_buildpath($dir."modCaptcha".ucfirst($captcha).'.class.php', 0, 2);
128 if ($fullpathclassfile) {
129 break;
130 }
131 }
132 if ($fullpathclassfile) {
133 include_once $fullpathclassfile;
134 // Charging the numbering class
135 $classname = "modCaptcha".ucfirst($captcha);
136 if (class_exists($classname)) {
137 $captchaobj = new $classname($db, $conf, $langs, $user);
138 '@phan-var-force ModeleCaptcha $captchaobj';
140 } else {
141 print 'Error, the captcha handler class '.$classname.' was not found after the include';
142 }
143 } else {
144 print 'Error, the captcha handler '.$captcha.' has no class file found modCaptcha'.ucfirst($captcha);
145 }
146}
147
148/*
149 * Actions
150 */
151
152$parameters = array(
153 'id' => $id,
154);
155// Note that $action and $object may have been modified by some hooks
156$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
157if ($reshook < 0) {
158 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
159}
160// Add file in email form
161if (empty($reshook)) {
162 if ($cancel) {
163 $backtopage = getDolGlobalString('TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.'/public/ticket/');
164
165 header("Location: ".$backtopage);
166 exit;
167 }
168
169 if (GETPOST('addfile', 'alpha') && !GETPOST('save', 'alpha')) {
170 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
171
172 // Set tmp directory
173 // TODO Use a dedicated directory for temporary emails files
174 $vardir = $conf->ticket->dir_output;
175 $upload_dir_tmp = $vardir.'/temp/'.session_id();
176 if (!dol_is_dir($upload_dir_tmp)) {
177 dol_mkdir($upload_dir_tmp);
178 }
179
180 dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, '', 0);
181 $action = 'create_ticket';
182 }
183
184 // Remove file
185 if (GETPOST('removedfile', 'alpha') && !GETPOST('save', 'alpha')) {
186 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
187
188 // Set tmp directory
189 // TODO Use a dedicated directory for temporary emails files
190 $vardir = $conf->ticket->dir_output.'/';
191 $upload_dir_tmp = $vardir.'/temp/'.session_id();
192
193 // TODO Delete only files that was uploaded from form
194 dol_remove_file_process(GETPOSTINT('removedfile'), 0, 0);
195 $action = 'create_ticket';
196 }
197
198 if ($action == 'create_ticket' && GETPOST('save', 'alpha')) { // Test on permission not required. This is a public form. Security is managed by mitigation.
199 $error = 0;
200 $cid = -1;
201 $origin_email = GETPOST('email', 'email');
202 if (empty($origin_email)) {
203 $error++;
204 array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
205 $action = '';
206 } else {
207 // Search company saved with email
208 $searched_companies = $object->searchSocidByEmail($origin_email, 0);
209
210 // Chercher un contact existent avec cette address email
211 // Le premier contact trouvé est utilisé pour déterminer le contact suivi
212 $contacts = $object->searchContactByEmail($origin_email);
213 if (!is_array($contacts)) {
214 $contacts = array();
215 }
216
217 // Ensure that contact is active and select first active contact
218 foreach ($contacts as $key => $contact) {
219 if ((int) $contact->statut == 1) {
220 $cid = $key;
221 break;
222 }
223 }
224
225 // Option to require email exists to create ticket
226 if (getDolGlobalInt('TICKET_EMAIL_MUST_EXISTS') && ($cid < 0 || empty($contacts[$cid]->socid))) {
227 $error++;
228 array_push($object->errors, $langs->trans("ErrorEmailMustExistToCreateTicket"));
229 $action = '';
230 }
231 }
232
233 $contact_lastname = '';
234 $contact_firstname = '';
235 $company_name = '';
236 $contact_phone = '';
237 if ($with_contact) {
238 // set linked contact to add in form
239 if (/* is_array($contacts) && */ count($contacts) == 1) {
240 $with_contact = current($contacts);
241 }
242
243 // check mandatory fields on contact
244 $contact_lastname = trim(GETPOST('contact_lastname', 'alphanohtml'));
245 $contact_firstname = trim(GETPOST('contact_firstname', 'alphanohtml'));
246 $company_name = trim(GETPOST('company_name', 'alphanohtml'));
247 $contact_phone = trim(GETPOST('contact_phone', 'alphanohtml'));
248 if (!($with_contact->id > 0)) {
249 // check lastname
250 if (empty($contact_lastname)) {
251 $error++;
252 array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Lastname')));
253 $action = '';
254 }
255 // check firstname
256 if (empty($contact_firstname)) {
257 $error++;
258 array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Firstname')));
259 $action = '';
260 }
261 }
262 }
263
264
265 $fieldsToCheck = [
266 'type_code' => ['check' => 'alpha', 'langs' => 'TicketTypeRequest'],
267 'category_code' => ['check' => 'alpha', 'langs' => 'TicketCategory'],
268 'severity_code' => ['check' => 'alpha', 'langs' => 'TicketSeverity'],
269 'subject' => ['check' => 'alphanohtml', 'langs' => 'Subject'],
270 'message' => ['check' => 'restricthtml', 'langs' => 'Message']
271 ];
272
273 FormTicket::checkRequiredFields($fieldsToCheck, $error);
274
275 // Check email address
276 if (!empty($origin_email) && !isValidEmail($origin_email)) {
277 $error++;
278 array_push($object->errors, $langs->trans("ErrorBadEmailAddress", $langs->transnoentities("Email")));
279 $action = '';
280 }
281
282 // Check Captcha code if is enabled
283 $ok = false;
284 if (getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_TICKET') && is_object($captchaobj)) {
285 if (method_exists($captchaobj, 'validateCodeAfterLoginSubmit')) {
286 $ok = $captchaobj->validateCodeAfterLoginSubmit(); // @phan-suppress-current-line PhanUndeclaredMethod
287 } else {
288 print 'Error, the captcha handler '.get_class($captchaobj).' does not have any method validateCodeAfterLoginSubmit()';
289 }
290 if (!$ok) {
291 $error++;
292 array_push($object->errors, $langs->trans("ErrorBadValueForCode"));
293 $action = '';
294 }
295 }
296
297 if (!$error) {
298 $object->type_code = GETPOST("type_code", 'aZ09');
299 $object->category_code = GETPOST("category_code", 'aZ09');
300 $object->severity_code = GETPOST("severity_code", 'aZ09');
301 $object->ip = getUserRemoteIP();
302
303 $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
304 $now = dol_now();
305 $minmonthpost = dol_time_plus_duree($now, -1, "m");
306
307 // Calculate nb of post for IP
308 $nb_post_ip = 0;
309 if ($nb_post_max > 0) { // Calculate only if there is a limit to check
310 $sql = "SELECT COUNT(ref) as nb_tickets";
311 $sql .= " FROM ".MAIN_DB_PREFIX."ticket";
312 $sql .= " WHERE ip = '".$db->escape($object->ip)."'";
313 $sql .= " AND datec > '".$db->idate($minmonthpost)."'";
314 $resql = $db->query($sql);
315 if ($resql) {
316 $num = $db->num_rows($resql);
317 $i = 0;
318 while ($i < $num) {
319 $i++;
320 $obj = $db->fetch_object($resql);
321 $nb_post_ip = $obj->nb_tickets;
322 }
323 }
324 }
325
326 $object->track_id = generate_random_id(16);
327
328 $object->db->begin();
329
330 $object->subject = GETPOST("subject", "alphanohtml");
331 $object->message = GETPOST("message", "restricthtml");
332 $object->origin_email = $origin_email;
333 $object->email_from = $origin_email;
334
335 $object->type_code = GETPOST("type_code", 'aZ09');
336 $object->category_code = GETPOST("category_code", 'aZ09');
337 $object->severity_code = GETPOST("severity_code", 'aZ09');
338
339 // create third-party with contact
340 $usertoassign = 0;
341 if ($with_contact && !($with_contact->id > 0)) {
342 $company = new Societe($db);
343 if (!empty($company_name)) {
344 $company->name = $company_name;
345 } else {
346 $company->particulier = 1;
347 $company->name = dolGetFirstLastname($contact_firstname, $contact_lastname);
348 }
349 $result = $company->create($user);
350 if ($result < 0) {
351 $error++;
352 $errors = ($company->error ? array($company->error) : $company->errors);
353 $object->errors = array_merge($object->errors, $errors);
354 $action = 'create_ticket';
355 }
356
357 // create contact and link to this new company
358 if (!$error) {
359 $with_contact->email = $origin_email;
360 $with_contact->lastname = $contact_lastname;
361 $with_contact->firstname = $contact_firstname;
362 $with_contact->socid = $company->id;
363 $with_contact->phone_pro = $contact_phone;
364 $result = $with_contact->create($user);
365 if ($result < 0) {
366 $error++;
367 $errors = ($with_contact->error ? array($with_contact->error) : $with_contact->errors);
368 $object->errors = array_merge($object->errors, $errors);
369 $action = 'create_ticket';
370 } else {
371 $contacts = array($with_contact);
372 }
373 }
374 }
375
376 if (!empty($searched_companies) && is_array($searched_companies)) {
377 $object->fk_soc = $searched_companies[0]->id;
378 }
379
380 if (/* is_array($contacts) && */ count($contacts) > 0 && $cid >= 0) {
381 $object->fk_soc = $contacts[$cid]->socid;
382 $usertoassign = $contacts[$cid]->id;
383 }
384
385 $ret = $extrafields->setOptionalsFromPost(null, $object);
386
387 // Generate new ref
388 $object->ref = $object->getDefaultRef();
389
390 $object->context['disableticketemail'] = 1; // Disable emails sent by ticket trigger when creation is done from this page, emails are already sent later
391 $object->context['contactid'] = GETPOSTINT('contactid'); // Disable emails sent by ticket trigger when creation is done from this page, emails are already sent later
392
393 $object->context['createdfrompublicinterface'] = 1; // To make a difference between a ticket created from the public interface and a ticket directly created from dolibarr
394
395 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
396 $error++;
397 array_push($object->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
398 $action = 'create_ticket';
399 }
400
401 if (!$error) {
402 // Creation of the ticket
403 $id = $object->create($user);
404 if ($id <= 0) {
405 $error++;
406 $errors = ($object->error ? array($object->error) : $object->errors);
407 if ($object->error) {
408 array_push($object->errors, $object->error);
409 }
410 $action = 'create_ticket';
411 }
412 }
413
414 if (!$error && $id > 0) {
415 if ($usertoassign > 0) {
416 $object->add_contact($usertoassign, "SUPPORTCLI", 'external', 0);
417 }
418
419 if (!$error) {
420 $object->db->commit();
421 $action = "infos_success";
422 } else {
423 $object->db->rollback();
424 setEventMessages($object->error, $object->errors, 'errors');
425 $action = 'create_ticket';
426 }
427
428 if (!$error) {
429 $res = $object->fetch($id);
430 if ($res) {
431 // Create form object
432 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
433 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
434 $formmail = new FormMail($db);
435
436 // Init to avoid errors
437 $filepath = array();
438 $filename = array();
439 $mimetype = array();
440
441 $attachedfiles = $formmail->get_attached_files();
442 $filepath = $attachedfiles['paths'];
443 $filename = $attachedfiles['names'];
444 $mimetype = $attachedfiles['mimes'];
445
446 // Send email to customer
447 $appli = $mysoc->name;
448
449 $subject = '['.$appli.'] '.$langs->transnoentities('TicketNewEmailSubject', $object->ref, $object->track_id);
450 $message = (getDolGlobalString('TICKET_MESSAGE_MAIL_NEW') !== '' ? getDolGlobalString('TICKET_MESSAGE_MAIL_NEW') : $langs->transnoentities('TicketNewEmailBody')).'<br><br>';
451 $message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket').'<br>';
452
453 $url_public_ticket = getDolGlobalString('TICKET_URL_PUBLIC_INTERFACE', dol_buildpath('/public/ticket/', 2)).'view.php?track_id='.$object->track_id;
454 $infos_new_ticket = $langs->transnoentities('TicketNewEmailBodyInfosTrackId', '<a href="'.$url_public_ticket.'" rel="nofollow noopener">'.$object->track_id.'</a>').'<br>';
455 $infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl').'<br><br>';
456
457 $message .= $infos_new_ticket;
458 $message .= getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE', $langs->transnoentities('TicketMessageMailSignatureText', $mysoc->name));
459
460 $sendto = GETPOST('email', 'alpha');
461
462 $from = getDolGlobalString('MAIN_INFO_SOCIETE_NOM') . ' <'.getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'>';
463 $replyto = $from;
464 $sendtocc = '';
465 $deliveryreceipt = 0;
466
467 $old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO');
468 if ($old_MAIN_MAIL_AUTOCOPY_TO !== '') {
469 $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
470 }
471 include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
472 $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket');
473 if ($mailfile->error || !empty($mailfile->errors)) {
474 setEventMessages($mailfile->error, $mailfile->errors, 'errors');
475 } else {
476 $result = $mailfile->sendfile();
477 }
478 if ($old_MAIN_MAIL_AUTOCOPY_TO !== '') {
479 $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
480 }
481
482 // Send email to TICKET_NOTIFICATION_EMAIL_TO
483 $sendto = getDolGlobalString('TICKET_NOTIFICATION_EMAIL_TO');
484 if ($sendto) {
485 $appli = $mysoc->name;
486
487 $subject = '['.$appli.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin', $object->ref, $object->track_id);
488 $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id).'<br><br>';
489 $message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
490 $message_admin .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
491 $message_admin .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
492 $message_admin .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
493 $message_admin .= '<li>'.$langs->trans('From').' : '.$object->origin_email.'</li>';
494 // Extrafields
495 $extrafields->fetch_name_optionals_label($object->table_element);
496 if (is_array($object->array_options) && count($object->array_options) > 0) {
497 foreach ($object->array_options as $key => $value) {
498 $key = substr($key, 8); // remove "options_"
499 $message_admin .= '<li>'.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' : '.$extrafields->showOutputField($key, $value, '', $object->table_element).'</li>';
500 }
501 }
502 $message_admin .= '</ul>';
503
504 $message_admin .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
505 $message_admin .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'" rel="nofollow noopener">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
506
507 $from = getDolGlobalString('MAIN_INFO_SOCIETE_NOM') . ' <' . getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'>';
508 $replyto = $from;
509
510 $old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO');
511 if ($old_MAIN_MAIL_AUTOCOPY_TO !== '') {
512 $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
513 }
514 include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
515 $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket');
516 if ($mailfile->error || !empty($mailfile->errors)) {
517 setEventMessages($mailfile->error, $mailfile->errors, 'errors');
518 } else {
519 $result = $mailfile->sendfile();
520 }
521 if ($old_MAIN_MAIL_AUTOCOPY_TO !== '') {
522 $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
523 }
524 }
525 }
526
527 // Copy files into ticket directory
528 $object->copyFilesForTicket('');
529
530 //setEventMessages($langs->trans('YourTicketSuccessfullySaved'), null, 'mesgs');
531
532 // Make a redirect to avoid to have ticket submitted twice if we make back
533 $messagetoshow = $langs->trans('MesgInfosPublicTicketCreatedWithTrackId', '{s1}', '{s2}');
534 $messagetoshow = str_replace(array('{s1}', '{s2}'), array('<strong>'.$object->track_id.'</strong>', '<strong>'.$object->ref.'</strong>'), $messagetoshow);
535 setEventMessages($messagetoshow, null, 'warnings');
536 setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings');
537
538 header("Location: index.php".(!empty($entity) && isModEnabled('multicompany') ? '?entity='.$entity : ''));
539 exit;
540 }
541 } else {
542 setEventMessages($object->error, $object->errors, 'errors');
543 }
544 }
545 }
546}
547if (!empty($object->errors) || !empty($object->error)) {
548 setEventMessages($object->error, $object->errors, 'errors');
549}
550
551
552/*
553 * View
554 */
555
556$form = new Form($db);
557$formticket = new FormTicket($db);
558
559if (!getDolGlobalInt('TICKET_ENABLE_PUBLIC_INTERFACE')) {
560 print '<div class="error">'.$langs->trans('TicketPublicInterfaceForbidden').'</div>';
561 $db->close();
562 exit();
563}
564
565$arrayofjs = array();
566
567$arrayofcss = array(getDolGlobalString('TICKET_URL_PUBLIC_INTERFACE', '/public/ticket/').'css/styles.css.php');
568
569llxHeaderTicket($langs->trans("CreateTicket"), "", 0, 0, $arrayofjs, $arrayofcss);
570
571
572print '<div class="ticketpublicarea ticketlargemargin">';
573
574if ($action != "infos_success") {
575 $formticket->withfromsocid = isset($socid) ? $socid : $user->socid;
576 $formticket->withtitletopic = 1;
577 $formticket->withcompany = 0;
578 $formticket->withusercreate = 1;
579 $formticket->fk_user_create = 0;
580 $formticket->withemail = 1;
581 $formticket->ispublic = 1;
582 $formticket->withfile = 2;
583 $formticket->action = 'create_ticket';
584 $formticket->withcancel = 1;
585
586 $formticket->param = array('returnurl' => $_SERVER['PHP_SELF'].($conf->entity > 1 ? '?entity='.$conf->entity : ''));
587
588 print load_fiche_titre($langs->trans('NewTicket'), '', '', 0, '', 'marginleftonly');
589
590 if (!getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM')) {
591 $langs->load("errors");
592 print '<div class="error">';
593 print $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketEmailNotificationFrom")).'<br>';
594 print $langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentities("Ticket"));
595 print '</div>';
596 } else {
597 //print '<div class="info marginleftonly marginrightonly">'.$langs->trans('TicketPublicInfoCreateTicket').'</div>';
598 $formticket->showForm(0, ($action ? $action : 'create'), 1, $with_contact, '', $object);
599 }
600}
601
602print '</div>';
603
604print '<br>';
605
606if (getDolGlobalInt('TICKET_SHOW_COMPANY_FOOTER')) {
607 // End of page
608 htmlPrintOnlineFooter($mysoc, $langs, 0, $suffix, $object);
609}
610
611llxFooter('', 'public');
612
613$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage contact/addresses.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation du formulaire html d'envoi de mail unitaire Usage: $formail = new Form...
static checkRequiredFields(array $fields, int &$errors)
Check required fields.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML public pages.
global $mysoc
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:125
dol_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $keyforsourcefile='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null, $forceFullTextIndexation='', $mode=0)
Get and save an upload file (for example after submitting a new file in a mail form).
dol_remove_file_process($filenb, $donotupdatesession=0, $donotdeletefile=1, $trackid='')
Remove an uploaded file (for example after submitting a new file a mail form).
dol_is_dir($folder)
Test if filename is a directory.
dol_now($mode='gmt')
Return date for now.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getUserRemoteIP($trusted=0)
Return the real IP of remote user.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Class to generate the form for creating a new ticket.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
generate_random_id($car=16)
Generate a random id.
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.