ticket.php 27 KB

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