ticket.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <?php
  2. /* Copyright (C) 2013-2018 Jean-François FERRY <hello@librethic.io>
  3. * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file admin/ticket.php
  20. * \ingroup ticket
  21. * \brief Page to setup module ticket
  22. */
  23. require '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
  25. require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php";
  26. require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php";
  27. require_once DOL_DOCUMENT_ROOT."/core/class/html.formcategory.class.php";
  28. // Load translation files required by the page
  29. $langs->loadLangs(array("admin", "ticket"));
  30. // Access control
  31. if (!$user->admin) {
  32. accessforbidden();
  33. }
  34. // Parameters
  35. $value = GETPOST('value', 'alpha');
  36. $action = GETPOST('action', 'aZ09');
  37. $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
  38. $label = GETPOST('label', 'alpha');
  39. $scandir = GETPOST('scandir', 'alpha');
  40. $type = 'ticket';
  41. $error = 0;
  42. /*
  43. * Actions
  44. */
  45. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  46. if ($action == 'updateMask') {
  47. $maskconstticket = GETPOST('maskconstticket', 'alpha');
  48. $maskticket = GETPOST('maskticket', 'alpha');
  49. if ($maskconstticket) {
  50. $res = dolibarr_set_const($db, $maskconstticket, $maskticket, 'chaine', 0, '', $conf->entity);
  51. }
  52. if (!($res > 0)) {
  53. $error++;
  54. }
  55. if (!$error) {
  56. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  57. } else {
  58. setEventMessages($langs->trans("Error"), null, 'errors');
  59. }
  60. } elseif ($action == 'set') {
  61. // Activate a model
  62. $ret = addDocumentModel($value, $type, $label, $scandir);
  63. } elseif ($action == 'del') {
  64. $ret = delDocumentModel($value, $type);
  65. if ($ret > 0) {
  66. if ($conf->global->TICKET_ADDON_PDF == "$value") {
  67. dolibarr_del_const($db, 'TICKET_ADDON_PDF', $conf->entity);
  68. }
  69. }
  70. } elseif (preg_match('/set_(.*)/', $action, $reg)) {
  71. $code = $reg[1];
  72. $value = GETPOSTISSET($code) ? GETPOST($code, 'int') : 1;
  73. if ($code == 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS' && $conf->global->MAIN_FEATURES_LEVEL >= 2) {
  74. $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
  75. $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
  76. if (!($res > 0)) {
  77. $error++;
  78. }
  79. } else {
  80. $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity);
  81. if (!($res > 0)) {
  82. $error++;
  83. }
  84. }
  85. } elseif (preg_match('/del_(.*)/', $action, $reg)) {
  86. $code = $reg[1];
  87. $res = dolibarr_del_const($db, $code, $conf->entity);
  88. if (!($res > 0)) {
  89. $error++;
  90. }
  91. } elseif ($action == 'setdoc') {
  92. // Set default model
  93. if (dolibarr_set_const($db, "TICKET_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
  94. // The constant that was read before the new set
  95. // We therefore requires a variable to have a coherent view
  96. $conf->global->TICKET_ADDON_PDF = $value;
  97. }
  98. // On active le modele
  99. $ret = delDocumentModel($value, $type);
  100. if ($ret > 0) {
  101. $ret = addDocumentModel($value, $type, $label, $scandir);
  102. }
  103. } elseif ($action == 'setmod') {
  104. // TODO Verifier si module numerotation choisi peut etre active
  105. // par appel methode canBeActivated
  106. dolibarr_set_const($db, "TICKET_ADDON", $value, 'chaine', 0, '', $conf->entity);
  107. } elseif ($action == 'setvarworkflow') {
  108. // For compatibility when javascript is not enabled
  109. if (empty($conf->use_javascript_ajax)) {
  110. $param_auto_read = GETPOST('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', 'alpha');
  111. $res = dolibarr_set_const($db, 'TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND', $param_auto_read, 'chaine', 0, '', $conf->entity);
  112. if (!($res > 0)) {
  113. $error++;
  114. }
  115. $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha');
  116. $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
  117. if (!($res > 0)) {
  118. $error++;
  119. }
  120. $param_auto_notify_close = GETPOST('TICKET_NOTIFY_AT_CLOSING', 'alpha');
  121. $res = dolibarr_set_const($db, 'TICKET_NOTIFY_AT_CLOSING', $param_auto_notify_close, 'chaine', 0, '', $conf->entity);
  122. if (!($res > 0)) {
  123. $error++;
  124. }
  125. }
  126. $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha');
  127. $res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity);
  128. if (!($res > 0)) {
  129. $error++;
  130. }
  131. if (GETPOSTISSET('product_category_id')) {
  132. $param_ticket_product_category = GETPOST('product_category_id', 'int');
  133. $res = dolibarr_set_const($db, 'TICKET_PRODUCT_CATEGORY', $param_ticket_product_category, 'chaine', 0, '', $conf->entity);
  134. if (!($res > 0)) {
  135. $error++;
  136. }
  137. }
  138. $param_delay_first_response = GETPOST('delay_first_response', 'int');
  139. $res = dolibarr_set_const($db, 'TICKET_DELAY_BEFORE_FIRST_RESPONSE', $param_delay_first_response, 'chaine', 0, '', $conf->entity);
  140. if (!($res > 0)) {
  141. $error++;
  142. }
  143. $param_delay_between_responses = GETPOST('delay_between_responses', 'int');
  144. $res = dolibarr_set_const($db, 'TICKET_DELAY_SINCE_LAST_RESPONSE', $param_delay_between_responses, 'chaine', 0, '', $conf->entity);
  145. if (!($res > 0)) {
  146. $error++;
  147. }
  148. } elseif ($action == 'setvar') {
  149. include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
  150. $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha');
  151. $notification_email_description = "Sender of ticket replies sent from Dolibarr";
  152. if (!empty($notification_email)) {
  153. $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, $notification_email_description, $conf->entity);
  154. } else { // If an empty e-mail address is providen, use the global "FROM" since an empty field will cause other issues
  155. $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $conf->global->MAIN_MAIL_EMAIL_FROM, 'chaine', 0, $notification_email_description, $conf->entity);
  156. }
  157. if (!($res > 0)) {
  158. $error++;
  159. }
  160. // altairis : differentiate notification email FROM and TO
  161. $notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha');
  162. $notification_email_to_description = "Notified e-mail for ticket replies sent from Dolibarr";
  163. if (!empty($notification_email_to)) {
  164. $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, $notification_email_to_description, $conf->entity);
  165. } else {
  166. $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, $notification_email_to_description, $conf->entity);
  167. }
  168. if (!($res > 0)) {
  169. $error++;
  170. }
  171. $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'restricthtml');
  172. $mail_intro_description = "Introduction text of ticket replies sent from Dolibarr";
  173. if (!empty($mail_intro)) {
  174. $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, $mail_intro_description, $conf->entity);
  175. } else {
  176. $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', '', 'chaine', 0, $mail_intro_description, $conf->entity);
  177. }
  178. if (!($res > 0)) {
  179. $error++;
  180. }
  181. $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'restricthtml');
  182. $signature_description = "Signature of ticket replies sent from Dolibarr";
  183. if (!empty($mail_signature)) {
  184. $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, $signature_description, $conf->entity);
  185. } else {
  186. $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', '', 'chaine', 0, $signature_description, $conf->entity);
  187. }
  188. if (!($res > 0)) {
  189. $error++;
  190. }
  191. // For compatibility when javascript is not enabled
  192. if ($conf->global->MAIN_FEATURES_LEVEL >= 2 && empty($conf->use_javascript_ajax)) {
  193. $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
  194. $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
  195. if (!($res > 0)) {
  196. $error++;
  197. }
  198. }
  199. }
  200. /*
  201. * View
  202. */
  203. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  204. $formcategory = new FormCategory($db);
  205. $help_url = "FR:Module_Ticket";
  206. $page_name = "TicketSetup";
  207. llxHeader('', $langs->trans($page_name), $help_url);
  208. // Subheader
  209. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  210. print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
  211. // Configuration header
  212. $head = ticketAdminPrepareHead();
  213. print dol_get_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1, "ticket");
  214. print '<span class="opacitymedium">'.$langs->trans("TicketSetupDictionaries").'</span> : <a href="'.DOL_URL_ROOT.'/admin/dict.php">'.$langs->trans("ClickHereToGoTo", $langs->transnoentitiesnoconv("DictionarySetup")).'</a><br>';
  215. print dol_get_fiche_end();
  216. /*
  217. * Tickets numbering model
  218. */
  219. print load_fiche_titre($langs->trans("TicketNumberingModules"), '', '');
  220. print '<div class="div-table-responsive-no-min">';
  221. print '<table class="noborder centpercent">';
  222. print '<tr class="liste_titre">';
  223. print '<td width="100">'.$langs->trans("Name").'</td>';
  224. print '<td>'.$langs->trans("Description").'</td>';
  225. print '<td>'.$langs->trans("Example").'</td>';
  226. print '<td align="center" width="60">'.$langs->trans("Activated").'</td>';
  227. print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
  228. print "</tr>\n";
  229. clearstatcache();
  230. foreach ($dirmodels as $reldir) {
  231. $dir = dol_buildpath($reldir."core/modules/ticket");
  232. if (is_dir($dir)) {
  233. $handle = opendir($dir);
  234. if (is_resource($handle)) {
  235. while (($file = readdir($handle)) !== false) {
  236. if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) {
  237. $file = $reg[1];
  238. $classname = substr($file, 4);
  239. include_once $dir.'/'.$file.'.php';
  240. $module = new $file;
  241. // Show modules according to features level
  242. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  243. continue;
  244. }
  245. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  246. continue;
  247. }
  248. if ($module->isEnabled()) {
  249. print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
  250. print $module->info();
  251. print '</td>';
  252. // Show example of numbering model
  253. print '<td class="nowrap">';
  254. $tmp = $module->getExample();
  255. if (preg_match('/^Error/', $tmp)) {
  256. $langs->load("errors");
  257. print '<div class="error">'.$langs->trans($tmp).'</div>';
  258. } elseif ($tmp == 'NotConfigured') {
  259. print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
  260. } else {
  261. print $tmp;
  262. }
  263. print '</td>'."\n";
  264. print '<td class="center">';
  265. if ($conf->global->TICKET_ADDON == 'mod_'.$classname) {
  266. print img_picto($langs->trans("Activated"), 'switch_on');
  267. } else {
  268. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;token='.newToken().'&amp;value=mod_'.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
  269. }
  270. print '</td>';
  271. $ticket = new Ticket($db);
  272. $ticket->initAsSpecimen();
  273. // Info
  274. $htmltooltip = '';
  275. $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
  276. $nextval = $module->getNextValue($mysoc, $ticket);
  277. if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
  278. $htmltooltip .= ''.$langs->trans("NextValue").': ';
  279. if ($nextval) {
  280. $htmltooltip .= $nextval.'<br>';
  281. } else {
  282. $htmltooltip .= $langs->trans($module->error).'<br>';
  283. }
  284. }
  285. print '<td class="center">';
  286. print $formcategory->textwithpicto('', $htmltooltip, 1, 0);
  287. print '</td>';
  288. print '</tr>';
  289. }
  290. }
  291. }
  292. closedir($handle);
  293. }
  294. }
  295. }
  296. print '</table>';
  297. print '</div>';
  298. print '<br>';
  299. /*
  300. * Document templates generators
  301. */
  302. print load_fiche_titre($langs->trans("TicketsModelModule"), '', '');
  303. // Load array def with activated templates
  304. $def = array();
  305. $sql = "SELECT nom";
  306. $sql .= " FROM ".MAIN_DB_PREFIX."document_model";
  307. $sql .= " WHERE type = '".$db->escape($type)."'";
  308. $sql .= " AND entity = ".$conf->entity;
  309. $resql = $db->query($sql);
  310. if ($resql) {
  311. $i = 0;
  312. $num_rows = $db->num_rows($resql);
  313. while ($i < $num_rows) {
  314. $array = $db->fetch_array($resql);
  315. array_push($def, $array[0]);
  316. $i++;
  317. }
  318. } else {
  319. dol_print_error($db);
  320. }
  321. print '<div class="div-table-responsive-no-min">';
  322. print '<table class="noborder cenpercent">'."\n";
  323. print '<tr class="liste_titre">'."\n";
  324. print '<td>'.$langs->trans("Name").'</td>';
  325. print '<td>'.$langs->trans("Description").'</td>';
  326. print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
  327. print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
  328. print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
  329. print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
  330. print "</tr>\n";
  331. clearstatcache();
  332. foreach ($dirmodels as $reldir) {
  333. foreach (array('', '/doc') as $valdir) {
  334. $realpath = $reldir."core/modules/ticket".$valdir;
  335. $dir = dol_buildpath($realpath);
  336. if (is_dir($dir)) {
  337. $handle = opendir($dir);
  338. if (is_resource($handle)) {
  339. while (($file = readdir($handle)) !== false) {
  340. $filelist[] = $file;
  341. }
  342. closedir($handle);
  343. arsort($filelist);
  344. foreach ($filelist as $file) {
  345. if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
  346. if (file_exists($dir.'/'.$file)) {
  347. $name = substr($file, 4, dol_strlen($file) - 16);
  348. $classname = substr($file, 0, dol_strlen($file) - 12);
  349. require_once $dir.'/'.$file;
  350. $module = new $classname($db);
  351. $modulequalified = 1;
  352. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
  353. $modulequalified = 0;
  354. }
  355. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
  356. $modulequalified = 0;
  357. }
  358. if ($modulequalified) {
  359. print '<tr class="oddeven"><td width="100">';
  360. print (empty($module->name) ? $name : $module->name);
  361. print "</td><td>\n";
  362. if (method_exists($module, 'info')) {
  363. print $module->info($langs);
  364. } else {
  365. print $module->description;
  366. }
  367. print '</td>';
  368. // Active
  369. if (in_array($name, $def)) {
  370. print '<td class="center">'."\n";
  371. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
  372. print img_picto($langs->trans("Enabled"), 'switch_on');
  373. print '</a>';
  374. print '</td>';
  375. } else {
  376. print '<td class="center">'."\n";
  377. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
  378. print "</td>";
  379. }
  380. // Default
  381. print '<td class="center">';
  382. if ($conf->global->TICKET_ADDON_PDF == $name) {
  383. print img_picto($langs->trans("Default"), 'on');
  384. } else {
  385. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
  386. }
  387. print '</td>';
  388. // Info
  389. $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
  390. $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
  391. if ($module->type == 'pdf') {
  392. $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
  393. }
  394. $htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
  395. $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
  396. $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
  397. $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
  398. //$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
  399. //$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
  400. //$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
  401. print '<td class="center">';
  402. print $formcategory->textwithpicto('', $htmltooltip, 1, 0);
  403. print '</td>';
  404. // Preview
  405. print '<td class="center">';
  406. if ($module->type == 'pdf') {
  407. print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
  408. } else {
  409. print img_object($langs->trans("PreviewNotAvailable"), 'generic');
  410. }
  411. print '</td>';
  412. print "</tr>\n";
  413. }
  414. }
  415. }
  416. }
  417. }
  418. }
  419. }
  420. }
  421. print '</table>';
  422. print '</div><br>';
  423. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
  424. print '<input type="hidden" name="token" value="'.newToken().'">';
  425. print '<input type="hidden" name="action" value="setvarworkflow">';
  426. print '<input type="hidden" name="page_y" value="">';
  427. print load_fiche_titre($langs->trans("Other"), '', '');
  428. print '<div class="div-table-responsive-no-min">';
  429. print '<table class="noborder centpercent">';
  430. print '<tr class="liste_titre">';
  431. print '<td>'.$langs->trans("Parameter").'</td>';
  432. print '<td></td>';
  433. print '<td></td>';
  434. print "</tr>\n";
  435. // Auto mark ticket read when created from backoffice
  436. print '<tr class="oddeven"><td>'.$langs->trans("TicketsAutoReadTicket").'</td>';
  437. print '<td class="left">';
  438. if ($conf->use_javascript_ajax) {
  439. print ajax_constantonoff('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND');
  440. } else {
  441. $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
  442. print $formcategory->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND);
  443. }
  444. print '</td>';
  445. print '<td class="center">';
  446. print $formcategory->textwithpicto('', $langs->trans("TicketsAutoReadTicketHelp"), 1, 'help');
  447. print '</td>';
  448. print '</tr>';
  449. // Auto assign ticket at user who created it
  450. print '<tr class="oddeven">';
  451. print '<td>'.$langs->trans("TicketsAutoAssignTicket").'</td>';
  452. print '<td class="left">';
  453. if ($conf->use_javascript_ajax) {
  454. print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE');
  455. } else {
  456. $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
  457. print $formcategory->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE);
  458. }
  459. print '</td>';
  460. print '<td class="center">';
  461. print $formcategory->textwithpicto('', $langs->trans("TicketsAutoAssignTicketHelp"), 1, 'help');
  462. print '</td>';
  463. print '</tr>';
  464. // Auto notify contacts when closing the ticket
  465. print '<tr class="oddeven"><td>'.$langs->trans("TicketsAutoNotifyClose").'</td>';
  466. print '<td class="left">';
  467. if ($conf->use_javascript_ajax) {
  468. print ajax_constantonoff('TICKET_NOTIFY_AT_CLOSING');
  469. } else {
  470. $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
  471. print $formcategory->selectarray("TICKET_NOTIFY_AT_CLOSING", $arrval, $conf->global->TICKET_NOTIFY_AT_CLOSING);
  472. }
  473. print '</td>';
  474. print '<td class="center">';
  475. print $formcategory->textwithpicto('', $langs->trans("TicketsAutoNotifyCloseHelp"), 1, 'help');
  476. print '</td>';
  477. print '</tr>';
  478. if (! empty($conf->product->enabled)) {
  479. print '<tr class="oddeven"><td>'.$langs->trans("TicketChooseProductCategory").'</td>';
  480. print '<td class="left">';
  481. $formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, 'product_category_id');
  482. if ($conf->use_javascript_ajax) {
  483. print ajax_combobox('select_'.$htmlname);
  484. }
  485. print '</td>';
  486. print '<td class="center">';
  487. print $formcategory->textwithpicto('', $langs->trans("TicketChooseProductCategoryHelp"), 1, 'help');
  488. print '</td>';
  489. print '</tr>';
  490. }
  491. print '<tr class="oddeven">';
  492. print '<td>'.$langs->trans("TicketsDelayBeforeFirstAnswer")."</td>";
  493. print '<td class="left">
  494. <input type="number" value="'.$conf->global->TICKET_DELAY_BEFORE_FIRST_RESPONSE.'" name="delay_first_response" class="width50">
  495. </td>';
  496. print '<td class="center">';
  497. print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help');
  498. print '</td>';
  499. print '</tr>';
  500. print '<tr class="oddeven">';
  501. print '<td>'.$langs->trans("TicketsDelayBetweenAnswers")."</td>";
  502. print '<td class="left">
  503. <input type="number" value="'.$conf->global->TICKET_DELAY_SINCE_LAST_RESPONSE.'" name="delay_between_responses" class="width50">
  504. </td>';
  505. print '<td class="center">';
  506. print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help');
  507. print '</td>';
  508. print '</tr>';
  509. print '</table><br>';
  510. print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition');
  511. print '</form>';
  512. // Admin var of module
  513. print load_fiche_titre($langs->trans("Notification"), '', '');
  514. print '<table class="noborder centpercent">';
  515. print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
  516. print '<input type="hidden" name="token" value="'.newToken().'">';
  517. print '<input type="hidden" name="action" value="setvar">';
  518. print '<input type="hidden" name="page_y" value="">';
  519. print '<tr class="liste_titre">';
  520. print '<td colspan="3">'.$langs->trans("Email").'</td>';
  521. print "</tr>\n";
  522. if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
  523. print '<tr>';
  524. print '<td colspan="3"><div class="info">'.$langs->trans("TicketCkEditorEmailNotActivated").'</div></td>';
  525. print "</tr>\n";
  526. }
  527. // @todo Use module notification instead...
  528. // Email d'envoi des notifications
  529. print '<tr class="oddeven"><td>'.$langs->trans("TicketEmailNotificationFrom").'</td>';
  530. print '<td class="left">';
  531. print '<input type="text" class="minwidth200" name="TICKET_NOTIFICATION_EMAIL_FROM" value="'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'"></td>';
  532. print '<td class="center">';
  533. print $formcategory->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help');
  534. print '</td>';
  535. print '</tr>';
  536. // Email for notification of TICKET_CREATE
  537. print '<tr class="oddeven"><td>'.$langs->trans("TicketEmailNotificationTo").'</td>';
  538. print '<td class="left">';
  539. print '<input type="text" name="TICKET_NOTIFICATION_EMAIL_TO" value="'.(!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) ? $conf->global->TICKET_NOTIFICATION_EMAIL_TO : '').'"></td>';
  540. print '<td class="center">';
  541. print $formcategory->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help');
  542. print '</td>';
  543. print '</tr>';
  544. // Also send to TICKET_NOTIFICATION_EMAIL_TO for responses (not only creation)
  545. if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
  546. print '<tr class="oddeven"><td>'.$langs->trans("TicketsEmailAlsoSendToMainAddress").'</td>';
  547. print '<td class="left">';
  548. if ($conf->use_javascript_ajax) {
  549. print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS');
  550. } else {
  551. $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
  552. print $formcategory->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS);
  553. }
  554. print '</td>';
  555. print '<td class="center">';
  556. print $formcategory->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help');
  557. print '</td>';
  558. print '</tr>';
  559. }
  560. // Texte d'introduction
  561. $mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText');
  562. print '<tr class="oddeven"><td>'.$langs->trans("TicketMessageMailIntroLabelAdmin");
  563. print '</td><td>';
  564. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  565. $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAIL'), ROWS_2, 70);
  566. $doleditor->Create();
  567. print '</td>';
  568. print '<td class="center">';
  569. print $formcategory->textwithpicto('', $langs->trans("TicketMessageMailIntroHelpAdmin"), 1, 'help');
  570. print '</td></tr>';
  571. // Texte de signature
  572. $mail_signature = $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->trans('TicketMessageMailSignatureText');
  573. print '<tr class="oddeven"><td>'.$langs->trans("TicketMessageMailSignatureLabelAdmin").'</label>';
  574. print '</td><td>';
  575. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  576. $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAIL'), ROWS_2, 70);
  577. $doleditor->Create();
  578. print '</td>';
  579. print '<td class="center">';
  580. print $formcategory->textwithpicto('', $langs->trans("TicketMessageMailSignatureHelpAdmin"), 1, 'help');
  581. print '</td></tr>';
  582. print '</table>';
  583. print $formcategory->buttonsSaveCancel("Save", '', array(), 0, 'reposition');
  584. print '</form>';
  585. // End of page
  586. llxFooter();
  587. $db->close();