ticket.php 26 KB

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