ticket_public.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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_public.php
  20. * \ingroup ticket
  21. * \brief Page to public interface of 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. // Load translation files required by the page
  28. $langs->loadLangs(array("admin", "ticket"));
  29. // Access control
  30. if (!$user->admin) {
  31. accessforbidden();
  32. }
  33. // Parameters
  34. $value = GETPOST('value', 'alpha');
  35. $action = GETPOST('action', 'aZ09');
  36. $label = GETPOST('label', 'alpha');
  37. $scandir = GETPOST('scandir', 'alpha');
  38. $type = 'ticket';
  39. $error = 0;
  40. /*
  41. * Actions
  42. */
  43. if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') {
  44. if (GETPOST('value')) {
  45. dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity);
  46. } else {
  47. dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity);
  48. }
  49. }
  50. if ($action == 'setvar') {
  51. include_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php";
  52. if (GETPOSTISSET('TICKET_ENABLE_PUBLIC_INTERFACE')) { // only for no js case
  53. $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha');
  54. $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity);
  55. if (!($res > 0)) {
  56. $error++;
  57. }
  58. }
  59. if (GETPOSTISSET('TICKET_EMAIL_MUST_EXISTS')) { // only for no js case
  60. $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha');
  61. $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity);
  62. if (!($res > 0)) {
  63. $error++;
  64. }
  65. }
  66. if (GETPOSTISSET('TICKET_DISABLE_CUSTOMER_MAILS')) { // only for no js case
  67. $param_disable_email = GETPOST('TICKET_DISABLE_CUSTOMER_MAILS', 'alpha');
  68. $res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity);
  69. if (!($res > 0)) {
  70. $error++;
  71. }
  72. }
  73. if (GETPOSTISSET('TICKET_SHOW_COMPANY_LOGO')) { // only for no js case
  74. $param_show_module_logo = GETPOST('TICKET_SHOW_COMPANY_LOGO', 'alpha');
  75. $res = dolibarr_set_const($db, 'TICKET_SHOW_COMPANY_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity);
  76. if (!($res > 0)) {
  77. $error++;
  78. }
  79. }
  80. $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml');
  81. if (!empty($topic_interface)) {
  82. $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity);
  83. } else {
  84. $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity);
  85. }
  86. if (!($res > 0)) {
  87. $error++;
  88. }
  89. $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'restricthtml');
  90. if (!empty($text_home)) {
  91. $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity);
  92. } else {
  93. $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity);
  94. }
  95. if (!($res > 0)) {
  96. $error++;
  97. }
  98. $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'restricthtml');
  99. if (!empty($text_help)) {
  100. $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity);
  101. } else {
  102. $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity);
  103. }
  104. if (!($res > 0)) {
  105. $error++;
  106. }
  107. $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'restricthtml');
  108. if (!empty($mail_new_ticket)) {
  109. $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity);
  110. } else {
  111. $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity);
  112. }
  113. if (!($res > 0)) {
  114. $error++;
  115. }
  116. $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha');
  117. if (!empty($url_interface)) {
  118. $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity);
  119. } else {
  120. $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity);
  121. }
  122. if (!($res > 0)) {
  123. $error++;
  124. }
  125. $param_public_notification_new_message_default_email = GETPOST('TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL', 'alpha');
  126. $res = dolibarr_set_const($db, 'TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL', $param_public_notification_new_message_default_email, 'chaine', 0, '', $conf->entity);
  127. if (!($res > 0)) {
  128. $error++;
  129. }
  130. if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
  131. $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
  132. $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
  133. if (!($res > 0)) {
  134. $error++;
  135. }
  136. }
  137. }
  138. /*
  139. * View
  140. */
  141. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  142. $form = new Form($db);
  143. $help_url = "FR:Module_Ticket";
  144. $page_name = "TicketSetup";
  145. llxHeader('', $langs->trans($page_name), $help_url);
  146. // Subheader
  147. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  148. print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
  149. // Configuration header
  150. $head = ticketAdminPrepareHead();
  151. print dol_get_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, "ticket");
  152. print '<span class="opacitymedium">'.$langs->trans("TicketPublicAccess").'</span> : <a class="wordbreak" href="'.dol_buildpath('/public/ticket/index.php', 1).'" target="_blank" >'.dol_buildpath('/public/ticket/index.php', 2).'</a>';
  153. print dol_get_fiche_end();
  154. $enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' ';
  155. if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) {
  156. // Button off, click to enable
  157. $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setTICKET_ENABLE_PUBLIC_INTERFACE&token='.newToken().'&value=1'.$param.'">';
  158. $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
  159. $enabledisablehtml .= '</a>';
  160. } else {
  161. // Button on, click to disable
  162. $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setTICKET_ENABLE_PUBLIC_INTERFACE&token='.newToken().'&value=0'.$param.'">';
  163. $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
  164. $enabledisablehtml .= '</a>';
  165. }
  166. print $enabledisablehtml;
  167. print '<input type="hidden" id="TICKET_ENABLE_PUBLIC_INTERFACE" name="TICKET_ENABLE_PUBLIC_INTERFACE" value="'.(empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ? 0 : 1).'">';
  168. print '<br><br>';
  169. if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) {
  170. print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" >';
  171. print '<input type="hidden" name="token" value="'.newToken().'">';
  172. print '<input type="hidden" name="action" value="setvar">';
  173. print '<div class="div-table-responsive-no-min">';
  174. print '<table class="noborder centpercent">';
  175. print '<tr class="liste_titre"><td>'.$langs->trans("Parameters").'</td>';
  176. print '<td class="left">';
  177. print '</td>';
  178. print '<td class="center width75">';
  179. print '</td>';
  180. print '</tr>';
  181. // Check if email exists
  182. print '<tr class="oddeven"><td>'.$langs->trans("TicketsEmailMustExist").'</td>';
  183. print '<td class="left">';
  184. if ($conf->use_javascript_ajax) {
  185. print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS');
  186. } else {
  187. $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
  188. print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS);
  189. }
  190. print '</td>';
  191. print '<td class="center width75">';
  192. print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help');
  193. print '</td>';
  194. print '</tr>';
  195. /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
  196. {
  197. // Show logo for module
  198. print '<tr class="oddeven"><td>' . $langs->trans("TicketsShowModuleLogo") . '</td>';
  199. print '<td class="left">';
  200. if ($conf->use_javascript_ajax) {
  201. print ajax_constantonoff('TICKET_SHOW_MODULE_LOGO');
  202. } else {
  203. $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
  204. print $form->selectarray("TICKET_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKET_SHOW_MODULE_LOGO);
  205. }
  206. print '</td>';
  207. print '<td class="center">';
  208. print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help');
  209. print '</td>';
  210. print '</tr>';
  211. }*/
  212. // Show logo for company
  213. print '<tr class="oddeven"><td>'.$langs->trans("TicketsShowCompanyLogo").'</td>';
  214. print '<td class="left">';
  215. if ($conf->use_javascript_ajax) {
  216. print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO');
  217. } else {
  218. $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
  219. print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO);
  220. }
  221. print '</td>';
  222. print '<td class="center width75">';
  223. print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help');
  224. print '</td>';
  225. print '</tr>';
  226. // Also send to main email address
  227. if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
  228. print '<tr class="oddeven"><td>'.$langs->trans("TicketsEmailAlsoSendToMainAddress").'</td>';
  229. print '<td class="left">';
  230. if ($conf->use_javascript_ajax) {
  231. print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS');
  232. } else {
  233. $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
  234. print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS);
  235. }
  236. print '</td>';
  237. print '<td class="center width75">';
  238. print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp", $langs->transnoentitiesnoconv("TicketEmailNotificationTo").' ('.$langs->transnoentitiesnoconv("Creation").')', $langs->trans("Settings")), 1, 'help');
  239. print '</td>';
  240. print '</tr>';
  241. }
  242. if (!$conf->use_javascript_ajax) {
  243. print '<tr class="impair"><td colspan="3" align="center"><input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></td>';
  244. print '</tr>';
  245. }
  246. if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
  247. print '<tr>';
  248. print '<td colspan="3"><div class="info">'.$langs->trans("TicketCkEditorEmailNotActivated").'</div></td>';
  249. print "</tr>\n";
  250. }
  251. // Interface topic
  252. $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC;
  253. print '<tr><td>'.$langs->trans("TicketPublicInterfaceTopicLabelAdmin").'</label>';
  254. print '</td><td>';
  255. print '<input type="text" name="TICKET_PUBLIC_INTERFACE_TOPIC" value="'.$conf->global->TICKET_PUBLIC_INTERFACE_TOPIC.'" size="40" ></td>';
  256. print '</td>';
  257. print '<td class="center width75">';
  258. print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help');
  259. print '</td></tr>';
  260. // Texte d'accueil homepage
  261. $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome');
  262. print '<tr><td>'.$langs->trans("TicketPublicInterfaceTextHomeLabelAdmin").'</label>';
  263. print '</td><td>';
  264. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  265. $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
  266. $doleditor->Create();
  267. print '</td>';
  268. print '<td class="center">';
  269. print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help');
  270. print '</td></tr>';
  271. // Texte d'aide à la saisie du message
  272. $public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe');
  273. print '<tr><td>'.$langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin").'</label>';
  274. print '</td><td>';
  275. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  276. $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
  277. $doleditor->Create();
  278. print '</td>';
  279. print '<td class="center">';
  280. print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help');
  281. print '</td></tr>';
  282. // Activate email creation to user
  283. print '<tr class="pair"><td>'.$langs->trans("TicketsDisableCustomerEmail").'</td>';
  284. print '<td class="left">';
  285. if ($conf->use_javascript_ajax) {
  286. print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS');
  287. } else {
  288. $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
  289. print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, $conf->global->TICKET_DISABLE_CUSTOMER_MAILS);
  290. }
  291. print '</td>';
  292. print '<td class="center">';
  293. print $form->textwithpicto('', $langs->trans("TicketsDisableEmailHelp"), 1, 'help');
  294. print '</td>';
  295. print '</tr>';
  296. // Texte de création d'un ticket
  297. $mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody');
  298. print '<tr><td>'.$langs->trans("TicketNewEmailBodyLabel").'</label>';
  299. print '</td><td>';
  300. require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  301. $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
  302. $doleditor->Create();
  303. print '</td>';
  304. print '<td class="center">';
  305. print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help');
  306. print '</td></tr>';
  307. // Url public interface
  308. $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE;
  309. print '<tr><td>'.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").'</label>';
  310. print '</td><td>';
  311. print '<input type="text" class="minwidth500" name="TICKET_URL_PUBLIC_INTERFACE" value="'.$conf->global->TICKET_URL_PUBLIC_INTERFACE.'"></td>';
  312. print '</td>';
  313. print '<td class="center">';
  314. print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help');
  315. print '</td></tr>';
  316. // Activate email notification when a new message is added
  317. print '<tr class="pair"><td>'.$langs->trans("TicketsPublicNotificationNewMessage").'</td>';
  318. print '<td class="left">';
  319. if ($conf->use_javascript_ajax) {
  320. print ajax_constantonoff('TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED');
  321. } else {
  322. $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
  323. print $form->selectarray("TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED", $arrval, $conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED);
  324. }
  325. print '</td>';
  326. print '<td align="center">';
  327. print $form->textwithpicto('', $langs->trans("TicketsPublicNotificationNewMessageHelp"), 1, 'help');
  328. print '</td>';
  329. print '</tr>';
  330. // Send notification when a new message is added to a email if a user is not assigned to the ticket
  331. print '<tr><td>'.$langs->trans("TicketPublicNotificationNewMessageDefaultEmail").'</label>';
  332. print '</td><td>';
  333. print '<input type="text" name="TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL" value="'.$conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL.'" size="40" ></td>';
  334. print '</td>';
  335. print '<td align="center">';
  336. print $form->textwithpicto('', $langs->trans("TicketPublicNotificationNewMessageDefaultEmailHelp"), 1, 'help');
  337. print '</td></tr>';
  338. print '</table>';
  339. print '</div>';
  340. print '<div class="center"><input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></div>';
  341. print '</form>';
  342. }
  343. // End of page
  344. llxFooter();
  345. $db->close();