create_ticket.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/public/ticket/create_ticket.php
  21. * \ingroup ticket
  22. * \brief Display public form to add new ticket
  23. */
  24. /* We need object $user->default_values
  25. if (!defined('NOREQUIREUSER')) {
  26. define('NOREQUIREUSER', '1');
  27. }*/
  28. if (!defined('NOREQUIREMENU')) {
  29. define('NOREQUIREMENU', '1');
  30. }
  31. if (!defined('NOREQUIREHTML')) {
  32. define('NOREQUIREHTML', '1');
  33. }
  34. if (!defined('NOLOGIN')) {
  35. define("NOLOGIN", 1); // This means this output page does not require to be logged.
  36. }
  37. if (!defined('NOIPCHECK')) {
  38. define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
  39. }
  40. if (!defined('NOBROWSERNOTIF')) {
  41. define('NOBROWSERNOTIF', '1');
  42. }
  43. // For MultiCompany module.
  44. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
  45. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
  46. if (is_numeric($entity)) {
  47. define("DOLENTITY", $entity);
  48. }
  49. // Load Dolibarr environment
  50. require '../../main.inc.php';
  51. require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php';
  52. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php';
  53. require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
  54. require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
  55. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  56. require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
  57. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  58. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  59. require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
  60. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  61. // Load translation files required by the page
  62. $langs->loadLangs(array('companies', 'other', 'mails', 'ticket'));
  63. // Get parameters
  64. $id = GETPOST('id', 'int');
  65. $msg_id = GETPOST('msg_id', 'int');
  66. $socid = GETPOST('socid', 'int');
  67. $suffix = "";
  68. $action = GETPOST('action', 'aZ09');
  69. $cancel = GETPOST('cancel', 'aZ09');
  70. $backtopage = '';
  71. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  72. $hookmanager->initHooks(array('publicnewticketcard', 'globalcard'));
  73. $object = new Ticket($db);
  74. $extrafields = new ExtraFields($db);
  75. $contacts = array();
  76. $with_contact = null;
  77. if (!empty($conf->global->TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST)) {
  78. $with_contact = new Contact($db);
  79. }
  80. $extrafields->fetch_name_optionals_label($object->table_element);
  81. if (!isModEnabled('ticket')) {
  82. httponly_accessforbidden('Module Ticket not enabled');
  83. }
  84. /*
  85. * Actions
  86. */
  87. $parameters = array(
  88. 'id' => $id,
  89. );
  90. // Note that $action and $object may have been modified by some hooks
  91. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
  92. if ($reshook < 0) {
  93. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  94. }
  95. // Add file in email form
  96. if (empty($reshook)) {
  97. if ($cancel) {
  98. $backtopage = DOL_URL_ROOT.'/public/ticket/index.php';
  99. header("Location: ".$backtopage);
  100. exit;
  101. }
  102. if (GETPOST('addfile', 'alpha') && !GETPOST('save', 'alpha')) {
  103. ////$res = $object->fetch('','',GETPOST('track_id'));
  104. ////if($res > 0)
  105. ////{
  106. include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  107. // Set tmp directory TODO Use a dedicated directory for temp mails files
  108. $vardir = $conf->ticket->dir_output;
  109. $upload_dir_tmp = $vardir.'/temp/'.session_id();
  110. if (!dol_is_dir($upload_dir_tmp)) {
  111. dol_mkdir($upload_dir_tmp);
  112. }
  113. dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, '', 0);
  114. $action = 'create_ticket';
  115. ////}
  116. }
  117. // Remove file
  118. if (GETPOST('removedfile', 'alpha') && !GETPOST('save', 'alpha')) {
  119. include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  120. // Set tmp directory
  121. $vardir = $conf->ticket->dir_output.'/';
  122. $upload_dir_tmp = $vardir.'/temp/'.session_id();
  123. // TODO Delete only files that was uploaded from email form
  124. dol_remove_file_process(GETPOST('removedfile'), 0, 0);
  125. $action = 'create_ticket';
  126. }
  127. if ($action == 'create_ticket' && GETPOST('save', 'alpha')) {
  128. $error = 0;
  129. $origin_email = GETPOST('email', 'alpha');
  130. if (empty($origin_email)) {
  131. $error++;
  132. array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
  133. $action = '';
  134. } else {
  135. // Search company saved with email
  136. $searched_companies = $object->searchSocidByEmail($origin_email, '0');
  137. // Chercher un contact existant avec cette adresse email
  138. // Le premier contact trouvé est utilisé pour déterminer le contact suivi
  139. $contacts = $object->searchContactByEmail($origin_email);
  140. // Ensure that contact is active and select first active contact
  141. $cid = -1;
  142. foreach ($contacts as $key => $contact) {
  143. if ((int) $contact->statut == 1) {
  144. $cid = $key;
  145. break;
  146. }
  147. }
  148. // Option to require email exists to create ticket
  149. if (!empty($conf->global->TICKET_EMAIL_MUST_EXISTS) && ($cid < 0 || empty($contacts[$cid]->socid))) {
  150. $error++;
  151. array_push($object->errors, $langs->trans("ErrorEmailMustExistToCreateTicket"));
  152. $action = '';
  153. }
  154. }
  155. $contact_lastname = '';
  156. $contact_firstname = '';
  157. $company_name = '';
  158. $contact_phone = '';
  159. if ($with_contact) {
  160. // set linked contact to add in form
  161. if (is_array($contacts) && count($contacts) == 1) {
  162. $with_contact = current($contacts);
  163. }
  164. // check mandatory fields on contact
  165. $contact_lastname = trim(GETPOST('contact_lastname', 'alphanohtml'));
  166. $contact_firstname = trim(GETPOST('contact_firstname', 'alphanohtml'));
  167. $company_name = trim(GETPOST('company_name', 'alphanohtml'));
  168. $contact_phone = trim(GETPOST('contact_phone', 'alphanohtml'));
  169. if (!($with_contact->id > 0)) {
  170. // check lastname
  171. if (empty($contact_lastname)) {
  172. $error++;
  173. array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Lastname')));
  174. $action = '';
  175. }
  176. // check firstname
  177. if (empty($contact_firstname)) {
  178. $error++;
  179. array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Firstname')));
  180. $action = '';
  181. }
  182. }
  183. }
  184. if (!GETPOST("subject", "restricthtml")) {
  185. $error++;
  186. array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")));
  187. $action = '';
  188. }
  189. if (!GETPOST("message", "restricthtml")) {
  190. $error++;
  191. array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")));
  192. $action = '';
  193. }
  194. // Check email address
  195. if (!empty($origin_email) && !isValidEmail($origin_email)) {
  196. $error++;
  197. array_push($object->errors, $langs->trans("ErrorBadEmailAddress", $langs->transnoentities("email")));
  198. $action = '';
  199. }
  200. // Check Captcha code if is enabled
  201. if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) {
  202. $sessionkey = 'dol_antispam_value';
  203. $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) === strtolower(GETPOST('code', 'restricthtml'))));
  204. if (!$ok) {
  205. $error++;
  206. array_push($object->errors, $langs->trans("ErrorBadValueForCode"));
  207. $action = '';
  208. }
  209. }
  210. if (!$error) {
  211. $object->type_code = GETPOST("type_code", 'aZ09');
  212. $object->category_code = GETPOST("category_code", 'aZ09');
  213. $object->severity_code = GETPOST("severity_code", 'aZ09');
  214. $object->ip = getUserRemoteIP();
  215. $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
  216. $now = dol_now();
  217. $minmonthpost = dol_time_plus_duree($now, -1, "m");
  218. // Calculate nb of post for IP
  219. $nb_post_ip = 0;
  220. if ($nb_post_max > 0) { // Calculate only if there is a limit to check
  221. $sql = "SELECT COUNT(ref) as nb_tickets";
  222. $sql .= " FROM ".MAIN_DB_PREFIX."ticket";
  223. $sql .= " WHERE ip = '".$db->escape($object->ip)."'";
  224. $sql .= " AND datec > '".$db->idate($minmonthpost)."'";
  225. $resql = $db->query($sql);
  226. if ($resql) {
  227. $num = $db->num_rows($resql);
  228. $i = 0;
  229. while ($i < $num) {
  230. $i++;
  231. $obj = $db->fetch_object($resql);
  232. $nb_post_ip = $obj->nb_tickets;
  233. }
  234. }
  235. }
  236. $object->track_id = generate_random_id(16);
  237. $object->db->begin();
  238. $object->subject = GETPOST("subject", "restricthtml");
  239. $object->message = GETPOST("message", "restricthtml");
  240. $object->origin_email = $origin_email;
  241. $object->type_code = GETPOST("type_code", 'aZ09');
  242. $object->category_code = GETPOST("category_code", 'aZ09');
  243. $object->severity_code = GETPOST("severity_code", 'aZ09');
  244. if (!is_object($user)) {
  245. $user = new User($db);
  246. }
  247. // create third-party with contact
  248. $usertoassign = 0;
  249. if ($with_contact && !($with_contact->id > 0)) {
  250. $company = new Societe($db);
  251. if (!empty($company_name)) {
  252. $company->name = $company_name;
  253. } else {
  254. $company->particulier = 1;
  255. $company->name = dolGetFirstLastname($contact_firstname, $contact_lastname);
  256. }
  257. $result = $company->create($user);
  258. if ($result < 0) {
  259. $error++;
  260. $errors = ($company->error ? array($company->error) : $company->errors);
  261. array_push($object->errors, $errors);
  262. $action = 'create_ticket';
  263. }
  264. // create contact and link to this new company
  265. if (!$error) {
  266. $with_contact->email = $origin_email;
  267. $with_contact->lastname = $contact_lastname;
  268. $with_contact->firstname = $contact_firstname;
  269. $with_contact->socid = $company->id;
  270. $with_contact->phone_pro = $contact_phone;
  271. $result = $with_contact->create($user);
  272. if ($result < 0) {
  273. $error++;
  274. $errors = ($with_contact->error ? array($with_contact->error) : $with_contact->errors);
  275. array_push($object->errors, $errors);
  276. $action = 'create_ticket';
  277. } else {
  278. $contacts = array($with_contact);
  279. }
  280. }
  281. }
  282. if (!empty($searched_companies) && is_array($searched_companies)) {
  283. $object->fk_soc = $searched_companies[0]->id;
  284. }
  285. if (is_array($contacts) && count($contacts) > 0 && $cid >= 0) {
  286. $object->fk_soc = $contacts[$cid]->socid;
  287. $usertoassign = $contacts[$cid]->id;
  288. }
  289. $ret = $extrafields->setOptionalsFromPost(null, $object);
  290. // Generate new ref
  291. $object->ref = $object->getDefaultRef();
  292. $object->context['disableticketemail'] = 1; // Disable emails sent by ticket trigger when creation is done from this page, emails are already sent later
  293. if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
  294. $error++;
  295. $errors = array($langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
  296. array_push($object->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
  297. $action = 'create_ticket';
  298. }
  299. if (!$error) {
  300. $id = $object->create($user);
  301. if ($id <= 0) {
  302. $error++;
  303. $errors = ($object->error ? array($object->error) : $object->errors);
  304. array_push($object->errors, $object->error ? array($object->error) : $object->errors);
  305. $action = 'create_ticket';
  306. }
  307. }
  308. if (!$error && $id > 0) {
  309. if ($usertoassign > 0) {
  310. $object->add_contact($usertoassign, "SUPPORTCLI", 'external', 0);
  311. }
  312. if (!$error) {
  313. $object->db->commit();
  314. $action = "infos_success";
  315. } else {
  316. $object->db->rollback();
  317. setEventMessages($object->error, $object->errors, 'errors');
  318. $action = 'create_ticket';
  319. }
  320. if (!$error) {
  321. $res = $object->fetch($id);
  322. if ($res) {
  323. // Create form object
  324. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
  325. include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  326. $formmail = new FormMail($db);
  327. // Init to avoid errors
  328. $filepath = array();
  329. $filename = array();
  330. $mimetype = array();
  331. $attachedfiles = $formmail->get_attached_files();
  332. $filepath = $attachedfiles['paths'];
  333. $filename = $attachedfiles['names'];
  334. $mimetype = $attachedfiles['mimes'];
  335. // Send email to customer
  336. $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubject', $object->ref, $object->track_id);
  337. $message = ($conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody')).'<br><br>';
  338. $message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket').'<br>';
  339. $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/view.php' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id;
  340. $infos_new_ticket = $langs->transnoentities('TicketNewEmailBodyInfosTrackId', '<a href="'.$url_public_ticket.'" rel="nofollow noopener">'.$object->track_id.'</a>').'<br>';
  341. $infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl').'<br><br>';
  342. $message .= $infos_new_ticket;
  343. $message .= getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE', $langs->transnoentities('TicketMessageMailSignatureText', $mysoc->name));
  344. $sendto = GETPOST('email', 'alpha');
  345. $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'>';
  346. $replyto = $from;
  347. $sendtocc = '';
  348. $deliveryreceipt = 0;
  349. if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
  350. $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
  351. $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
  352. }
  353. include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
  354. $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket');
  355. if ($mailfile->error || !empty($mailfile->errors)) {
  356. setEventMessages($mailfile->error, $mailfile->errors, 'errors');
  357. } else {
  358. $result = $mailfile->sendfile();
  359. }
  360. if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
  361. $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
  362. }
  363. // Send email to TICKET_NOTIFICATION_EMAIL_TO
  364. $sendto = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
  365. if ($sendto) {
  366. $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin', $object->ref, $object->track_id);
  367. $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id).'<br><br>';
  368. $message_admin .= '<ul><li>'.$langs->trans('Title').' : '.$object->subject.'</li>';
  369. $message_admin .= '<li>'.$langs->trans('Type').' : '.$object->type_label.'</li>';
  370. $message_admin .= '<li>'.$langs->trans('Category').' : '.$object->category_label.'</li>';
  371. $message_admin .= '<li>'.$langs->trans('Severity').' : '.$object->severity_label.'</li>';
  372. $message_admin .= '<li>'.$langs->trans('From').' : '.$object->origin_email.'</li>';
  373. // Extrafields
  374. $extrafields->fetch_name_optionals_label($object->table_element);
  375. if (is_array($object->array_options) && count($object->array_options) > 0) {
  376. foreach ($object->array_options as $key => $value) {
  377. $key = substr($key, 8); // remove "options_"
  378. $message_admin .= '<li>'.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' : '.$extrafields->showOutputField($key, $value, '', $object->table_element).'</li>';
  379. }
  380. }
  381. $message_admin .= '</ul>';
  382. $message_admin .= '<p>'.$langs->trans('Message').' : <br>'.$object->message.'</p>';
  383. $message_admin .= '<p><a href="'.dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id.'" rel="nofollow noopener">'.$langs->trans('SeeThisTicketIntomanagementInterface').'</a></p>';
  384. $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
  385. $replyto = $from;
  386. if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
  387. $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
  388. $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
  389. }
  390. include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
  391. $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket');
  392. if ($mailfile->error || !empty($mailfile->errors)) {
  393. setEventMessages($mailfile->error, $mailfile->errors, 'errors');
  394. } else {
  395. $result = $mailfile->sendfile();
  396. }
  397. if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
  398. $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
  399. }
  400. }
  401. }
  402. // Copy files into ticket directory
  403. $destdir = $conf->ticket->dir_output.'/'.$object->ref;
  404. if (!dol_is_dir($destdir)) {
  405. dol_mkdir($destdir);
  406. }
  407. foreach ($filename as $i => $val) {
  408. dol_move($filepath[$i], $destdir.'/'.$filename[$i], 0, 1);
  409. $formmail->remove_attached_files($i);
  410. }
  411. //setEventMessages($langs->trans('YourTicketSuccessfullySaved'), null, 'mesgs');
  412. // Make a redirect to avoid to have ticket submitted twice if we make back
  413. $messagetoshow = $langs->trans('MesgInfosPublicTicketCreatedWithTrackId', '{s1}', '{s2}');
  414. $messagetoshow = str_replace(array('{s1}', '{s2}'), array('<strong>'.$object->track_id.'</strong>', '<strong>'.$object->ref.'</strong>'), $messagetoshow);
  415. setEventMessages($messagetoshow, null, 'warnings');
  416. setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings');
  417. header("Location: index.php".(!empty($entity) && isModEnabled('multicompany')?'?entity='.$entity:''));
  418. exit;
  419. }
  420. } else {
  421. setEventMessages($object->error, $object->errors, 'errors');
  422. }
  423. }
  424. }
  425. }
  426. /*
  427. * View
  428. */
  429. $form = new Form($db);
  430. $formticket = new FormTicket($db);
  431. if (!$conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) {
  432. print '<div class="error">'.$langs->trans('TicketPublicInterfaceForbidden').'</div>';
  433. $db->close();
  434. exit();
  435. }
  436. $arrayofjs = array();
  437. $arrayofcss = array('/opensurvey/css/style.css', '/ticket/css/styles.css.php');
  438. llxHeaderTicket($langs->trans("CreateTicket"), "", 0, 0, $arrayofjs, $arrayofcss);
  439. print '<div class="ticketpublicarea ticketlargemargin centpercent">';
  440. if ($action != "infos_success") {
  441. $formticket->withfromsocid = isset($socid) ? $socid : $user->socid;
  442. $formticket->withtitletopic = 1;
  443. $formticket->withcompany = 0;
  444. $formticket->withusercreate = 1;
  445. $formticket->fk_user_create = 0;
  446. $formticket->withemail = 1;
  447. $formticket->ispublic = 1;
  448. $formticket->withfile = 2;
  449. $formticket->action = 'create_ticket';
  450. $formticket->withcancel = 1;
  451. $formticket->param = array('returnurl' => $_SERVER['PHP_SELF'].($conf->entity > 1 ? '?entity='.$conf->entity : ''));
  452. print load_fiche_titre($langs->trans('NewTicket'), '', '', 0, 0, 'marginleftonly');
  453. if (empty($conf->global->TICKET_NOTIFICATION_EMAIL_FROM)) {
  454. $langs->load("errors");
  455. print '<div class="error">';
  456. print $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketEmailNotificationFrom")).'<br>';
  457. print $langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentities("Ticket"));
  458. print '</div>';
  459. } else {
  460. //print '<div class="info marginleftonly marginrightonly">'.$langs->trans('TicketPublicInfoCreateTicket').'</div>';
  461. $formticket->showForm(0, 'edit', 1, $with_contact);
  462. }
  463. }
  464. print '</div>';
  465. // End of page
  466. htmlPrintOnlineFooter($mysoc, $langs, 1, $suffix, $object);
  467. llxFooter('', 'public');
  468. $db->close();