create_ticket.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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 (getDolGlobalInt('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 = getDolGlobalString('TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.'/public/ticket/');
  99. header("Location: ".$backtopage);
  100. exit;
  101. }
  102. if (GETPOST('addfile', 'alpha') && !GETPOST('save', 'alpha')) {
  103. include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  104. // Set tmp directory
  105. // TODO Use a dedicated directory for temporary emails files
  106. $vardir = $conf->ticket->dir_output;
  107. $upload_dir_tmp = $vardir.'/temp/'.session_id();
  108. if (!dol_is_dir($upload_dir_tmp)) {
  109. dol_mkdir($upload_dir_tmp);
  110. }
  111. dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, '', 0);
  112. $action = 'create_ticket';
  113. }
  114. // Remove file
  115. if (GETPOST('removedfile', 'alpha') && !GETPOST('save', 'alpha')) {
  116. include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  117. // Set tmp directory
  118. // TODO Use a dedicated directory for temporary emails files
  119. $vardir = $conf->ticket->dir_output.'/';
  120. $upload_dir_tmp = $vardir.'/temp/'.session_id();
  121. // TODO Delete only files that was uploaded from form
  122. dol_remove_file_process(GETPOST('removedfile'), 0, 0);
  123. $action = 'create_ticket';
  124. }
  125. if ($action == 'create_ticket' && GETPOST('save', 'alpha')) {
  126. $error = 0;
  127. $origin_email = GETPOST('email', 'alpha');
  128. if (empty($origin_email)) {
  129. $error++;
  130. array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
  131. $action = '';
  132. } else {
  133. // Search company saved with email
  134. $searched_companies = $object->searchSocidByEmail($origin_email, '0');
  135. // Chercher un contact existant avec cette adresse email
  136. // Le premier contact trouvé est utilisé pour déterminer le contact suivi
  137. $contacts = $object->searchContactByEmail($origin_email);
  138. // Ensure that contact is active and select first active contact
  139. $cid = -1;
  140. foreach ($contacts as $key => $contact) {
  141. if ((int) $contact->statut == 1) {
  142. $cid = $key;
  143. break;
  144. }
  145. }
  146. // Option to require email exists to create ticket
  147. if (getDolGlobalInt('TICKET_EMAIL_MUST_EXISTS') && ($cid < 0 || empty($contacts[$cid]->socid))) {
  148. $error++;
  149. array_push($object->errors, $langs->trans("ErrorEmailMustExistToCreateTicket"));
  150. $action = '';
  151. }
  152. }
  153. $contact_lastname = '';
  154. $contact_firstname = '';
  155. $company_name = '';
  156. $contact_phone = '';
  157. if ($with_contact) {
  158. // set linked contact to add in form
  159. if (is_array($contacts) && count($contacts) == 1) {
  160. $with_contact = current($contacts);
  161. }
  162. // check mandatory fields on contact
  163. $contact_lastname = trim(GETPOST('contact_lastname', 'alphanohtml'));
  164. $contact_firstname = trim(GETPOST('contact_firstname', 'alphanohtml'));
  165. $company_name = trim(GETPOST('company_name', 'alphanohtml'));
  166. $contact_phone = trim(GETPOST('contact_phone', 'alphanohtml'));
  167. if (!($with_contact->id > 0)) {
  168. // check lastname
  169. if (empty($contact_lastname)) {
  170. $error++;
  171. array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Lastname')));
  172. $action = '';
  173. }
  174. // check firstname
  175. if (empty($contact_firstname)) {
  176. $error++;
  177. array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Firstname')));
  178. $action = '';
  179. }
  180. }
  181. }
  182. if (!GETPOST("subject", "restricthtml")) {
  183. $error++;
  184. array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")));
  185. $action = '';
  186. }
  187. if (!GETPOST("message", "restricthtml")) {
  188. $error++;
  189. array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")));
  190. $action = '';
  191. }
  192. // Check email address
  193. if (!empty($origin_email) && !isValidEmail($origin_email)) {
  194. $error++;
  195. array_push($object->errors, $langs->trans("ErrorBadEmailAddress", $langs->transnoentities("email")));
  196. $action = '';
  197. }
  198. // Check Captcha code if is enabled
  199. if (getDolGlobalInt('MAIN_SECURITY_ENABLECAPTCHA_TICKET')) {
  200. $sessionkey = 'dol_antispam_value';
  201. $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) === strtolower(GETPOST('code', 'restricthtml'))));
  202. if (!$ok) {
  203. $error++;
  204. array_push($object->errors, $langs->trans("ErrorBadValueForCode"));
  205. $action = '';
  206. }
  207. }
  208. if (!$error) {
  209. $object->type_code = GETPOST("type_code", 'aZ09');
  210. $object->category_code = GETPOST("category_code", 'aZ09');
  211. $object->severity_code = GETPOST("severity_code", 'aZ09');
  212. $object->ip = getUserRemoteIP();
  213. $nb_post_max = getDolGlobalInt("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
  214. $now = dol_now();
  215. $minmonthpost = dol_time_plus_duree($now, -1, "m");
  216. // Calculate nb of post for IP
  217. $nb_post_ip = 0;
  218. if ($nb_post_max > 0) { // Calculate only if there is a limit to check
  219. $sql = "SELECT COUNT(ref) as nb_tickets";
  220. $sql .= " FROM ".MAIN_DB_PREFIX."ticket";
  221. $sql .= " WHERE ip = '".$db->escape($object->ip)."'";
  222. $sql .= " AND datec > '".$db->idate($minmonthpost)."'";
  223. $resql = $db->query($sql);
  224. if ($resql) {
  225. $num = $db->num_rows($resql);
  226. $i = 0;
  227. while ($i < $num) {
  228. $i++;
  229. $obj = $db->fetch_object($resql);
  230. $nb_post_ip = $obj->nb_tickets;
  231. }
  232. }
  233. }
  234. $object->track_id = generate_random_id(16);
  235. $object->db->begin();
  236. $object->subject = GETPOST("subject", "restricthtml");
  237. $object->message = GETPOST("message", "restricthtml");
  238. $object->origin_email = $origin_email;
  239. $object->type_code = GETPOST("type_code", 'aZ09');
  240. $object->category_code = GETPOST("category_code", 'aZ09');
  241. $object->severity_code = GETPOST("severity_code", 'aZ09');
  242. if (!is_object($user)) {
  243. $user = new User($db);
  244. }
  245. // create third-party with contact
  246. $usertoassign = 0;
  247. if ($with_contact && !($with_contact->id > 0)) {
  248. $company = new Societe($db);
  249. if (!empty($company_name)) {
  250. $company->name = $company_name;
  251. } else {
  252. $company->particulier = 1;
  253. $company->name = dolGetFirstLastname($contact_firstname, $contact_lastname);
  254. }
  255. $result = $company->create($user);
  256. if ($result < 0) {
  257. $error++;
  258. $errors = ($company->error ? array($company->error) : $company->errors);
  259. array_push($object->errors, $errors);
  260. $action = 'create_ticket';
  261. }
  262. // create contact and link to this new company
  263. if (!$error) {
  264. $with_contact->email = $origin_email;
  265. $with_contact->lastname = $contact_lastname;
  266. $with_contact->firstname = $contact_firstname;
  267. $with_contact->socid = $company->id;
  268. $with_contact->phone_pro = $contact_phone;
  269. $result = $with_contact->create($user);
  270. if ($result < 0) {
  271. $error++;
  272. $errors = ($with_contact->error ? array($with_contact->error) : $with_contact->errors);
  273. array_push($object->errors, $errors);
  274. $action = 'create_ticket';
  275. } else {
  276. $contacts = array($with_contact);
  277. }
  278. }
  279. }
  280. if (!empty($searched_companies) && is_array($searched_companies)) {
  281. $object->fk_soc = $searched_companies[0]->id;
  282. }
  283. if (is_array($contacts) && count($contacts) > 0 && $cid >= 0) {
  284. $object->fk_soc = $contacts[$cid]->socid;
  285. $usertoassign = $contacts[$cid]->id;
  286. }
  287. $ret = $extrafields->setOptionalsFromPost(null, $object);
  288. // Generate new ref
  289. $object->ref = $object->getDefaultRef();
  290. $object->context['disableticketemail'] = 1; // Disable emails sent by ticket trigger when creation is done from this page, emails are already sent later
  291. if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
  292. $error++;
  293. array_push($object->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
  294. $action = 'create_ticket';
  295. }
  296. if (!$error) {
  297. // Creation of the ticket
  298. $id = $object->create($user);
  299. if ($id <= 0) {
  300. $error++;
  301. $errors = ($object->error ? array($object->error) : $object->errors);
  302. array_push($object->errors, $object->error ? array($object->error) : $object->errors);
  303. $action = 'create_ticket';
  304. }
  305. }
  306. if (!$error && $id > 0) {
  307. if ($usertoassign > 0) {
  308. $object->add_contact($usertoassign, "SUPPORTCLI", 'external', 0);
  309. }
  310. if (!$error) {
  311. $object->db->commit();
  312. $action = "infos_success";
  313. } else {
  314. $object->db->rollback();
  315. setEventMessages($object->error, $object->errors, 'errors');
  316. $action = 'create_ticket';
  317. }
  318. if (!$error) {
  319. $res = $object->fetch($id);
  320. if ($res) {
  321. // Create form object
  322. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
  323. include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  324. $formmail = new FormMail($db);
  325. // Init to avoid errors
  326. $filepath = array();
  327. $filename = array();
  328. $mimetype = array();
  329. $attachedfiles = $formmail->get_attached_files();
  330. $filepath = $attachedfiles['paths'];
  331. $filename = $attachedfiles['names'];
  332. $mimetype = $attachedfiles['mimes'];
  333. // Send email to customer
  334. $appli = $mysoc->name;
  335. $subject = '['.$appli.'] '.$langs->transnoentities('TicketNewEmailSubject', $object->ref, $object->track_id);
  336. $message = (getDolGlobalString('TICKET_MESSAGE_MAIL_NEW') !== '' ? getDolGlobalString('TICKET_MESSAGE_MAIL_NEW') : $langs->transnoentities('TicketNewEmailBody')).'<br><br>';
  337. $message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket').'<br>';
  338. $url_public_ticket = getDolGlobalString('TICKET_URL_PUBLIC_INTERFACE', dol_buildpath('/public/ticket/', 2)).'view.php?track_id='.$object->track_id;
  339. $infos_new_ticket = $langs->transnoentities('TicketNewEmailBodyInfosTrackId', '<a href="'.$url_public_ticket.'" rel="nofollow noopener">'.$object->track_id.'</a>').'<br>';
  340. $infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl').'<br><br>';
  341. $message .= $infos_new_ticket;
  342. $message .= getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE', $langs->transnoentities('TicketMessageMailSignatureText', $mysoc->name));
  343. $sendto = GETPOST('email', 'alpha');
  344. $from = getDolGlobalString('MAIN_INFO_SOCIETE_NOM') . ' <'.getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'>';
  345. $replyto = $from;
  346. $sendtocc = '';
  347. $deliveryreceipt = 0;
  348. if (getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO') !== '') {
  349. $old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO');
  350. $conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
  351. }
  352. include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
  353. $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket');
  354. if ($mailfile->error || !empty($mailfile->errors)) {
  355. setEventMessages($mailfile->error, $mailfile->errors, 'errors');
  356. } else {
  357. $result = $mailfile->sendfile();
  358. }
  359. if (getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO') !== '') {
  360. $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
  361. }
  362. // Send email to TICKET_NOTIFICATION_EMAIL_TO
  363. $sendto = getDolGlobalString('TICKET_NOTIFICATION_EMAIL_TO');
  364. if ($sendto) {
  365. $appli = $mysoc->name;
  366. $subject = '['.$appli.'] '.$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 = getDolGlobalString('MAIN_INFO_SOCIETE_NOM') . ' <' . getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM').'>';
  385. $replyto = $from;
  386. if (getDolGlobalString('TICKET_DISABLE_MAIL_AUTOCOPY_TO') !== '') {
  387. $old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('TICKET_DISABLE_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 ((getDolGlobalString('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. $object->copyFilesForTicket('');
  404. //setEventMessages($langs->trans('YourTicketSuccessfullySaved'), null, 'mesgs');
  405. // Make a redirect to avoid to have ticket submitted twice if we make back
  406. $messagetoshow = $langs->trans('MesgInfosPublicTicketCreatedWithTrackId', '{s1}', '{s2}');
  407. $messagetoshow = str_replace(array('{s1}', '{s2}'), array('<strong>'.$object->track_id.'</strong>', '<strong>'.$object->ref.'</strong>'), $messagetoshow);
  408. setEventMessages($messagetoshow, null, 'warnings');
  409. setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings');
  410. header("Location: index.php".(!empty($entity) && isModEnabled('multicompany') ? '?entity='.$entity : ''));
  411. exit;
  412. }
  413. } else {
  414. setEventMessages($object->error, $object->errors, 'errors');
  415. }
  416. }
  417. }
  418. }
  419. if (!empty($object->errors) || !empty($object->error)) {
  420. setEventMessages($object->error, $object->errors, 'errors');
  421. }
  422. /*
  423. * View
  424. */
  425. $form = new Form($db);
  426. $formticket = new FormTicket($db);
  427. if (!getDolGlobalInt('TICKET_ENABLE_PUBLIC_INTERFACE')) {
  428. print '<div class="error">'.$langs->trans('TicketPublicInterfaceForbidden').'</div>';
  429. $db->close();
  430. exit();
  431. }
  432. $arrayofjs = array();
  433. $arrayofcss = array('/opensurvey/css/style.css', getDolGlobalString('TICKET_URL_PUBLIC_INTERFACE', '/ticket/').'css/styles.css.php');
  434. llxHeaderTicket($langs->trans("CreateTicket"), "", 0, 0, $arrayofjs, $arrayofcss);
  435. print '<div class="ticketpublicarea ticketlargemargin centpercent">';
  436. if ($action != "infos_success") {
  437. $formticket->withfromsocid = isset($socid) ? $socid : $user->socid;
  438. $formticket->withtitletopic = 1;
  439. $formticket->withcompany = 0;
  440. $formticket->withusercreate = 1;
  441. $formticket->fk_user_create = 0;
  442. $formticket->withemail = 1;
  443. $formticket->ispublic = 1;
  444. $formticket->withfile = 2;
  445. $formticket->action = 'create_ticket';
  446. $formticket->withcancel = 1;
  447. $formticket->param = array('returnurl' => $_SERVER['PHP_SELF'].($conf->entity > 1 ? '?entity='.$conf->entity : ''));
  448. print load_fiche_titre($langs->trans('NewTicket'), '', '', 0, 0, 'marginleftonly');
  449. if (getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM')=='') {
  450. $langs->load("errors");
  451. print '<div class="error">';
  452. print $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketEmailNotificationFrom")).'<br>';
  453. print $langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentities("Ticket"));
  454. print '</div>';
  455. } else {
  456. //print '<div class="info marginleftonly marginrightonly">'.$langs->trans('TicketPublicInfoCreateTicket').'</div>';
  457. $formticket->showForm(0, 'edit', 1, $with_contact);
  458. }
  459. }
  460. print '</div>';
  461. if (getDolGlobalInt('TICKET_SHOW_COMPANY_FOOTER')) {
  462. // End of page
  463. htmlPrintOnlineFooter($mysoc, $langs, 0, $suffix, $object);
  464. }
  465. llxFooter('', 'public');
  466. $db->close();