html.formticket.class.php 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. <?php
  2. /* Copyright (C) 2013-2015 Jean-François FERRY <hello@librethic.io>
  3. * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
  4. * Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/core/class/html.formticket.class.php
  21. * \ingroup ticket
  22. * \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire
  23. */
  24. require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php";
  25. require_once DOL_DOCUMENT_ROOT."/core/class/html.formmail.class.php";
  26. require_once DOL_DOCUMENT_ROOT."/core/class/html.formprojet.class.php";
  27. if (!class_exists('FormCompany')) {
  28. include DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  29. }
  30. /**
  31. * Classe permettant la generation du formulaire d'un nouveau ticket.
  32. *
  33. * @package Ticket
  34. * \remarks Utilisation: $formticket = new FormTicket($db)
  35. * \remarks $formticket->proprietes=1 ou chaine ou tableau de valeurs
  36. * \remarks $formticket->show_form() affiche le formulaire
  37. */
  38. class FormTicket
  39. {
  40. /**
  41. * @var DoliDB Database handler.
  42. */
  43. public $db;
  44. public $track_id;
  45. /**
  46. * @var int ID
  47. */
  48. public $fk_user_create;
  49. public $message;
  50. public $topic_title;
  51. public $action;
  52. public $withtopic;
  53. public $withemail;
  54. /**
  55. *
  56. * @var int $withsubstit Show substitution array
  57. */
  58. public $withsubstit;
  59. public $withfile;
  60. public $withfilereadonly;
  61. public $ispublic; // To show information or not into public form
  62. public $withtitletopic;
  63. public $withcompany; // affiche liste déroulante company
  64. public $withfromsocid;
  65. public $withfromcontactid;
  66. public $withnotifytiersatcreate;
  67. public $withusercreate; // Show name of creating user in form
  68. public $withcreatereadonly;
  69. public $withref; // Show ref field
  70. public $withcancel;
  71. /**
  72. *
  73. * @var array $substit Substitutions
  74. */
  75. public $substit = array();
  76. public $param = array();
  77. /**
  78. * @var string Error code (or message)
  79. */
  80. public $error;
  81. /**
  82. * Constructor
  83. *
  84. * @param DoliDB $db Database handler
  85. */
  86. public function __construct($db)
  87. {
  88. $this->db = $db;
  89. $this->action = 'add';
  90. $this->withcompany = 1;
  91. $this->withfromsocid = 0;
  92. $this->withfromcontactid = 0;
  93. //$this->withthreadid=0;
  94. //$this->withtitletopic='';
  95. $this->withnotifytiersatcreate = 0;
  96. $this->withusercreate = 1;
  97. $this->withcreatereadonly = 1;
  98. $this->withemail = 0;
  99. $this->withref = 0;
  100. $this->withextrafields = 0; // Show extrafields or not
  101. //$this->withtopicreadonly=0;
  102. }
  103. /**
  104. * Show the form to input ticket
  105. *
  106. * @param int $withdolfichehead With dol_fiche_head
  107. * @param string $mode Mode ('create' or 'edit')
  108. * @return void
  109. */
  110. public function showForm($withdolfichehead = 0, $mode = 'edit')
  111. {
  112. global $conf, $langs, $user, $hookmanager;
  113. // Load translation files required by the page
  114. $langs->loadLangs(array('other', 'mails', 'ticket'));
  115. $form = new Form($this->db);
  116. $formcompany = new FormCompany($this->db);
  117. $ticketstatic = new Ticket($this->db);
  118. $soc = new Societe($this->db);
  119. if (!empty($this->withfromsocid) && $this->withfromsocid > 0) {
  120. $soc->fetch($this->withfromsocid);
  121. }
  122. $ticketstat = new Ticket($this->db);
  123. $extrafields = new ExtraFields($this->db);
  124. $extrafields->fetch_name_optionals_label($ticketstat->table_element);
  125. print "\n<!-- Begin form TICKET -->\n";
  126. if ($withdolfichehead) dol_fiche_head(null, 'card', '', 0, '');
  127. print '<form method="POST" '.($withdolfichehead ? '' : 'style="margin-bottom: 30px;" ').'name="ticket" id="form_create_ticket" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">';
  128. print '<input type="hidden" name="token" value="'.newToken().'">';
  129. print '<input type="hidden" name="action" value="'.$this->action.'">';
  130. foreach ($this->param as $key => $value) {
  131. print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
  132. }
  133. print '<input type="hidden" name="fk_user_create" value="'.$this->fk_user_create.'">';
  134. print '<table class="border centpercent">';
  135. if ($this->withref) {
  136. // Ref
  137. $defaultref = $ticketstat->getDefaultRef();
  138. print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td><input size="18" type="text" name="ref" value="'.(GETPOST("ref", 'alpha') ? GETPOST("ref", 'alpha') : $defaultref).'"></td></tr>';
  139. }
  140. // TITLE
  141. if ($this->withemail) {
  142. print '<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans("Email").'</span></label></td><td>';
  143. print '<input class="text minwidth200" id="email" name="email" value="'.(GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : $subject).'" />';
  144. print '</td></tr>';
  145. }
  146. // If ticket created from another object
  147. if (isset($this->param['origin']) && $this->param['originid'] > 0) {
  148. // Parse element/subelement (ex: project_task)
  149. $element = $subelement = $this->param['origin'];
  150. if (preg_match('/^([^_]+)_([^_]+)/i', $this->param['origin'], $regs)) {
  151. $element = $regs[1];
  152. $subelement = $regs[2];
  153. }
  154. dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
  155. $classname = ucfirst($subelement);
  156. $objectsrc = new $classname($this->db);
  157. $objectsrc->fetch(GETPOST('originid', 'int'));
  158. if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) {
  159. $objectsrc->fetch_lines();
  160. }
  161. $objectsrc->fetch_thirdparty();
  162. $newclassname = $classname;
  163. print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2"><input name="'.$subelement.'id" value="'.GETPOST('originid').'" type="hidden" />'.$objectsrc->getNomUrl(1).'</td></tr>';
  164. }
  165. // Type
  166. print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans("TicketTypeRequest").'</span></label></td><td>';
  167. $this->selectTypesTickets((GETPOST('type_code', 'alpha') ? GETPOST('type_code', 'alpha') : $this->type_code), 'type_code', '', '2', 0, 0, 0, 'minwidth150');
  168. print '</td></tr>';
  169. // Severity
  170. print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans("TicketSeverity").'</span></label></td><td>';
  171. $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', '2');
  172. print '</td></tr>';
  173. // Group
  174. print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans("TicketCategory").'</span></label></td><td>';
  175. $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', '2');
  176. print '</td></tr>';
  177. // Subject
  178. if ($this->withtitletopic) {
  179. print '<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans("Subject").'</span></label></td><td>';
  180. // Réponse à un ticket : affichage du titre du thread en readonly
  181. if ($this->withtopicreadonly) {
  182. print $langs->trans('SubjectAnswerToTicket').' '.$this->topic_title;
  183. print '</td></tr>';
  184. } else {
  185. if ($this->withthreadid > 0) {
  186. $subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withthreadid.' : '.$this->topic_title.'';
  187. }
  188. print '<input class="text minwidth500" id="subject" name="subject" value="'.(GETPOST('subject', 'alpha') ? GETPOST('subject', 'alpha') : $subject).'" autofocus />';
  189. print '</td></tr>';
  190. }
  191. }
  192. // MESSAGE
  193. $msg = GETPOSTISSET('message') ? GETPOST('message', 'none') : '';
  194. print '<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans("Message").'</span></label></td><td>';
  195. // If public form, display more information
  196. $toolbarname = 'dolibarr_notes';
  197. if ($this->ispublic)
  198. {
  199. $toolbarname = 'dolibarr_details';
  200. print '<div class="warning">'.($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe')).'</div>';
  201. }
  202. include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  203. $uselocalbrowser = true;
  204. $doleditor = new DolEditor('message', $msg, '100%', 230, $toolbarname, 'In', true, $uselocalbrowser, $conf->global->FCKEDITOR_ENABLE_TICKET, ROWS_8, '90%');
  205. $doleditor->Create();
  206. print '</td></tr>';
  207. // User of creation
  208. if ($this->withusercreate > 0 && $this->fk_user_create) {
  209. print '<tr><td class="titlefield">'.$langs->trans("CreatedBy").'</td><td>';
  210. $langs->load("users");
  211. $fuser = new User($this->db);
  212. if ($this->withcreatereadonly) {
  213. if ($res = $fuser->fetch($this->fk_user_create)) {
  214. print $fuser->getNomUrl(1);
  215. }
  216. }
  217. print ' &nbsp; ';
  218. print "</td></tr>\n";
  219. }
  220. // Customer or supplier
  221. if ($this->withcompany) {
  222. // altairis: force company and contact id for external user
  223. if (empty($user->socid)) {
  224. // Company
  225. print '<tr><td class="titlefield">'.$langs->trans("ThirdParty").'</td><td>';
  226. $events = array();
  227. $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
  228. print img_picto('', 'company', 'class="paddingright"');
  229. print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, '', $events, 0, 'minwidth200');
  230. print '</td></tr>';
  231. if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
  232. $htmlname = 'socid';
  233. print '<script type="text/javascript">
  234. $(document).ready(function () {
  235. jQuery("#'.$htmlname.'").change(function () {
  236. var obj = '.json_encode($events).';
  237. $.each(obj, function(key,values) {
  238. if (values.method.length) {
  239. runJsCodeForEvent'.$htmlname.'(values);
  240. }
  241. });
  242. });
  243. function runJsCodeForEvent'.$htmlname.'(obj) {
  244. console.log("Run runJsCodeForEvent'.$htmlname.'");
  245. var id = $("#'.$htmlname.'").val();
  246. var method = obj.method;
  247. var url = obj.url;
  248. var htmlname = obj.htmlname;
  249. var showempty = obj.showempty;
  250. $.getJSON(url,
  251. {
  252. action: method,
  253. id: id,
  254. htmlname: htmlname,
  255. showempty: showempty
  256. },
  257. function(response) {
  258. $.each(obj.params, function(key,action) {
  259. if (key.length) {
  260. var num = response.num;
  261. if (num > 0) {
  262. $("#" + key).removeAttr(action);
  263. } else {
  264. $("#" + key).attr(action, action);
  265. }
  266. }
  267. });
  268. $("select#" + htmlname).html(response.value);
  269. if (response.num) {
  270. var selecthtml_str = response.value;
  271. var selecthtml_dom=$.parseHTML(selecthtml_str);
  272. $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
  273. } else {
  274. $("#inputautocomplete"+htmlname).val("");
  275. }
  276. $("select#" + htmlname).change(); /* Trigger event change */
  277. }
  278. );
  279. }
  280. });
  281. </script>';
  282. }
  283. // Contact and type
  284. print '<tr><td>'.$langs->trans("Contact").'</td><td>';
  285. // If no socid, set to -1 to avoid full contacts list
  286. $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
  287. print img_picto('', 'contact', 'class="paddingright"');
  288. $nbofcontacts = $form->select_contacts($selectedCompany, $this->withfromcontactid, 'contactid', 3, '', '', 0, 'minwidth200');
  289. print ' ';
  290. $formcompany->selectTypeContact($ticketstatic, '', 'type', 'external', '', 0, 'maginleftonly');
  291. print '</td></tr>';
  292. } else {
  293. print '<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.'"/></td>';
  294. print '<td><input type="hidden" name="contactid" value="'.$user->contact_id.'"/></td>';
  295. print '<td><input type="hidden" name="type" value="Z"/></td></tr>';
  296. }
  297. // Notify thirdparty at creation
  298. if (empty($this->ispublic))
  299. {
  300. print '<tr><td><label for="notify_tiers_at_create">'.$langs->trans("TicketNotifyTiersAtCreation").'</label></td><td>';
  301. print '<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ? ' checked="checked"' : '').'>';
  302. print '</td></tr>';
  303. }
  304. }
  305. if (!empty($conf->projet->enabled) && !$this->ispublic)
  306. {
  307. $formproject = new FormProjets($this->db);
  308. print '<tr><td><label for="project"><span class="">'.$langs->trans("Project").'</span></label></td><td>';
  309. print $formproject->select_projects(-1, GETPOST('projectid', 'int'), 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
  310. print '</td></tr>';
  311. }
  312. // Attached files
  313. if (!empty($this->withfile)) {
  314. // Define list of attached files
  315. $listofpaths = array();
  316. $listofnames = array();
  317. $listofmimes = array();
  318. if (!empty($_SESSION["listofpaths"])) {
  319. $listofpaths = explode(';', $_SESSION["listofpaths"]);
  320. }
  321. if (!empty($_SESSION["listofnames"])) {
  322. $listofnames = explode(';', $_SESSION["listofnames"]);
  323. }
  324. if (!empty($_SESSION["listofmimes"])) {
  325. $listofmimes = explode(';', $_SESSION["listofmimes"]);
  326. }
  327. $out = '<tr>';
  328. $out .= '<td>'.$langs->trans("MailFile").'</td>';
  329. $out .= '<td>';
  330. // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
  331. $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
  332. $out .= '<script type="text/javascript" language="javascript">';
  333. $out .= 'jQuery(document).ready(function () {';
  334. $out .= ' jQuery(".removedfile").click(function() {';
  335. $out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
  336. $out .= ' });';
  337. $out .= '})';
  338. $out .= '</script>'."\n";
  339. if (count($listofpaths)) {
  340. foreach ($listofpaths as $key => $val) {
  341. $out .= '<div id="attachfile_'.$key.'">';
  342. $out .= img_mime($listofnames[$key]).' '.$listofnames[$key];
  343. if (!$this->withfilereadonly) {
  344. $out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
  345. }
  346. $out .= '<br></div>';
  347. }
  348. } else {
  349. $out .= $langs->trans("NoAttachedFiles").'<br>';
  350. }
  351. if ($this->withfile == 2) { // Can add other files
  352. $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
  353. $out .= ' ';
  354. $out .= '<input type="submit" class="button" id="addfile" name="addfile" value="'.$langs->trans("MailingAddFile").'" />';
  355. }
  356. $out .= "</td></tr>\n";
  357. print $out;
  358. }
  359. // Other attributes
  360. $parameters = array();
  361. $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $this->action); // Note that $action and $object may have been modified by hook
  362. if (empty($reshook))
  363. {
  364. print $ticketstat->showOptionals($extrafields, 'create');
  365. }
  366. print '</table>';
  367. if ($withdolfichehead) dol_fiche_end();
  368. print '<div class="center">';
  369. print '<input class="button" type="submit" name="add" value="'.$langs->trans(($this->withthreadid > 0 ? "SendResponse" : "NewTicket")).'" />';
  370. if ($this->withcancel) {
  371. print " &nbsp; &nbsp; &nbsp;";
  372. print "<input class=\"button\" type=\"submit\" name=\"cancel\" value=\"".$langs->trans("Cancel")."\">";
  373. }
  374. print '</div>';
  375. print "</form>\n";
  376. print "<!-- End form TICKET -->\n";
  377. }
  378. /**
  379. * Return html list of tickets type
  380. *
  381. * @param string $selected Id du type pre-selectionne
  382. * @param string $htmlname Nom de la zone select
  383. * @param string $filtertype To filter on field type in llx_c_ticket_type (array('code'=>xx,'label'=>zz))
  384. * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code
  385. * @param int $empty 1=peut etre vide, 0 sinon
  386. * @param int $noadmininfo 0=Add admin info, 1=Disable admin info
  387. * @param int $maxlength Max length of label
  388. * @param string $morecss More CSS
  389. * @return void
  390. */
  391. public function selectTypesTickets($selected = '', $htmlname = 'tickettype', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '')
  392. {
  393. global $langs, $user;
  394. $ticketstat = new Ticket($this->db);
  395. dol_syslog(get_class($this)."::select_types_tickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
  396. $filterarray = array();
  397. if ($filtertype != '' && $filtertype != '-1') {
  398. $filterarray = explode(',', $filtertype);
  399. }
  400. $ticketstat->loadCacheTypesTickets();
  401. print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
  402. if ($empty) {
  403. print '<option value="">&nbsp;</option>';
  404. }
  405. if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
  406. foreach ($ticketstat->cache_types_tickets as $id => $arraytypes) {
  407. // On passe si on a demande de filtrer sur des modes de paiments particuliers
  408. if (count($filterarray) && !in_array($arraytypes['type'], $filterarray)) {
  409. continue;
  410. }
  411. // We discard empty line if showempty is on because an empty line has already been output.
  412. if ($empty && empty($arraytypes['code'])) {
  413. continue;
  414. }
  415. if ($format == 0) {
  416. print '<option value="'.$id.'"';
  417. }
  418. if ($format == 1) {
  419. print '<option value="'.$arraytypes['code'].'"';
  420. }
  421. if ($format == 2) {
  422. print '<option value="'.$arraytypes['code'].'"';
  423. }
  424. if ($format == 3) {
  425. print '<option value="'.$id.'"';
  426. }
  427. // Si selected est text, on compare avec code, sinon avec id
  428. if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code']) {
  429. print ' selected="selected"';
  430. } elseif ($selected == $id) {
  431. print ' selected="selected"';
  432. } elseif ($arraytypes['use_default'] == "1" && !$empty) {
  433. print ' selected="selected"';
  434. }
  435. print '>';
  436. $value = '&nbsp;';
  437. if ($format == 0) {
  438. $value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
  439. } elseif ($format == 1) {
  440. $value = $arraytypes['code'];
  441. } elseif ($format == 2) {
  442. $value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
  443. } elseif ($format == 3) {
  444. $value = $arraytypes['code'];
  445. }
  446. print $value;
  447. print '</option>';
  448. }
  449. }
  450. print '</select>';
  451. if ($user->admin && !$noadmininfo) {
  452. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
  453. }
  454. print ajax_combobox('select'.$htmlname);
  455. }
  456. /**
  457. * Return html list of ticket anaytic codes
  458. *
  459. * @param string $selected Id categorie pre-selectionnée
  460. * @param string $htmlname Nom de la zone select
  461. * @param string $filtertype To filter on field type in llx_c_ticket_category (array('code'=>xx,'label'=>zz))
  462. * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code
  463. * @param int $empty 1=peut etre vide, 0 sinon
  464. * @param int $noadmininfo 0=Add admin info, 1=Disable admin info
  465. * @param int $maxlength Max length of label
  466. * @param string $morecss More CSS
  467. * @return void
  468. */
  469. public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '')
  470. {
  471. global $langs, $user;
  472. $ticketstat = new Ticket($this->db);
  473. dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
  474. $filterarray = array();
  475. if ($filtertype != '' && $filtertype != '-1') {
  476. $filterarray = explode(',', $filtertype);
  477. }
  478. $ticketstat->loadCacheCategoriesTickets();
  479. print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
  480. if ($empty) {
  481. print '<option value="">&nbsp;</option>';
  482. }
  483. if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
  484. foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
  485. // On passe si on a demande de filtrer sur des modes de paiments particuliers
  486. if (count($filterarray) && !in_array($arraycategories['type'], $filterarray)) {
  487. continue;
  488. }
  489. // We discard empty line if showempty is on because an empty line has already been output.
  490. if ($empty && empty($arraycategories['code'])) {
  491. continue;
  492. }
  493. if ($format == 0) {
  494. print '<option value="'.$id.'"';
  495. }
  496. if ($format == 1) {
  497. print '<option value="'.$arraycategories['code'].'"';
  498. }
  499. if ($format == 2) {
  500. print '<option value="'.$arraycategories['code'].'"';
  501. }
  502. if ($format == 3) {
  503. print '<option value="'.$id.'"';
  504. }
  505. // Si selected est text, on compare avec code, sinon avec id
  506. if (preg_match('/[a-z]/i', $selected) && $selected == $arraycategories['code']) {
  507. print ' selected="selected"';
  508. } elseif ($selected == $id) {
  509. print ' selected="selected"';
  510. } elseif ($arraycategories['use_default'] == "1" && !$empty) {
  511. print ' selected="selected"';
  512. }
  513. print '>';
  514. if ($format == 0) {
  515. $value = ($maxlength ? dol_trunc($arraycategories['label'], $maxlength) : $arraycategories['label']);
  516. }
  517. if ($format == 1) {
  518. $value = $arraycategories['code'];
  519. }
  520. if ($format == 2) {
  521. $value = ($maxlength ? dol_trunc($arraycategories['label'], $maxlength) : $arraycategories['label']);
  522. }
  523. if ($format == 3) {
  524. $value = $arraycategories['code'];
  525. }
  526. print $value ? $value : '&nbsp;';
  527. print '</option>';
  528. }
  529. }
  530. print '</select>';
  531. if ($user->admin && !$noadmininfo) {
  532. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
  533. }
  534. print ajax_combobox('select'.$htmlname);
  535. }
  536. /**
  537. * Return html list of ticket severitys
  538. *
  539. * @param string $selected Id severity pre-selectionnée
  540. * @param string $htmlname Nom de la zone select
  541. * @param string $filtertype To filter on field type in llx_c_ticket_severity (array('code'=>xx,'label'=>zz))
  542. * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code
  543. * @param int $empty 1=peut etre vide, 0 sinon
  544. * @param int $noadmininfo 0=Add admin info, 1=Disable admin info
  545. * @param int $maxlength Max length of label
  546. * @param string $morecss More CSS
  547. * @return void
  548. */
  549. public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketseverity', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '')
  550. {
  551. global $langs, $user;
  552. $ticketstat = new Ticket($this->db);
  553. dol_syslog(get_class($this)."::selectSeveritiesTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
  554. $filterarray = array();
  555. if ($filtertype != '' && $filtertype != '-1') {
  556. $filterarray = explode(',', $filtertype);
  557. }
  558. $ticketstat->loadCacheSeveritiesTickets();
  559. print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
  560. if ($empty) {
  561. print '<option value="">&nbsp;</option>';
  562. }
  563. if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
  564. foreach ($ticketstat->cache_severity_tickets as $id => $arrayseverities) {
  565. // On passe si on a demande de filtrer sur des modes de paiments particuliers
  566. if (count($filterarray) && !in_array($arrayseverities['type'], $filterarray)) {
  567. continue;
  568. }
  569. // We discard empty line if showempty is on because an empty line has already been output.
  570. if ($empty && empty($arrayseverities['code'])) {
  571. continue;
  572. }
  573. if ($format == 0) {
  574. print '<option value="'.$id.'"';
  575. }
  576. if ($format == 1) {
  577. print '<option value="'.$arrayseverities['code'].'"';
  578. }
  579. if ($format == 2) {
  580. print '<option value="'.$arrayseverities['code'].'"';
  581. }
  582. if ($format == 3) {
  583. print '<option value="'.$id.'"';
  584. }
  585. // Si selected est text, on compare avec code, sinon avec id
  586. if (preg_match('/[a-z]/i', $selected) && $selected == $arrayseverities['code']) {
  587. print ' selected="selected"';
  588. } elseif ($selected == $id) {
  589. print ' selected="selected"';
  590. } elseif ($arrayseverities['use_default'] == "1" && !$empty) {
  591. print ' selected="selected"';
  592. }
  593. print '>';
  594. if ($format == 0) {
  595. $value = ($maxlength ? dol_trunc($arrayseverities['label'], $maxlength) : $arrayseverities['label']);
  596. }
  597. if ($format == 1) {
  598. $value = $arrayseverities['code'];
  599. }
  600. if ($format == 2) {
  601. $value = ($maxlength ? dol_trunc($arrayseverities['label'], $maxlength) : $arrayseverities['label']);
  602. }
  603. if ($format == 3) {
  604. $value = $arrayseverities['code'];
  605. }
  606. print $value ? $value : '&nbsp;';
  607. print '</option>';
  608. }
  609. }
  610. print '</select>';
  611. if ($user->admin && !$noadmininfo) {
  612. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
  613. }
  614. print ajax_combobox('select'.$htmlname);
  615. }
  616. // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
  617. /**
  618. * Clear list of attached files in send mail form (also stored in session)
  619. *
  620. * @return void
  621. */
  622. public function clear_attached_files()
  623. {
  624. // phpcs:enable
  625. global $conf, $user;
  626. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  627. // Set tmp user directory
  628. $vardir = $conf->user->dir_output."/".$user->id;
  629. $upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path
  630. if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir);
  631. $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
  632. unset($_SESSION["listofpaths".$keytoavoidconflict]);
  633. unset($_SESSION["listofnames".$keytoavoidconflict]);
  634. unset($_SESSION["listofmimes".$keytoavoidconflict]);
  635. }
  636. /**
  637. * Show the form to add message on ticket
  638. *
  639. * @param string $width Width of form
  640. * @return void
  641. */
  642. public function showMessageForm($width = '40%')
  643. {
  644. global $conf, $langs, $user, $hookmanager, $form, $mysoc;
  645. $formmail = new FormMail($this->db);
  646. $addfileaction = 'addfile';
  647. if (!is_object($form)) $form = new Form($this->db);
  648. // Load translation files required by the page
  649. $langs->loadLangs(array('other', 'mails'));
  650. // Clear temp files. Must be done at beginning, before call of triggers
  651. if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
  652. {
  653. $this->clear_attached_files();
  654. }
  655. // Define output language
  656. $outputlangs = $langs;
  657. $newlang = '';
  658. if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param['langsmodels'];
  659. if (!empty($newlang))
  660. {
  661. $outputlangs = new Translate("", $conf);
  662. $outputlangs->setDefaultLang($newlang);
  663. $outputlangs->load('other');
  664. }
  665. // Get message template for $this->param["models"] into c_email_templates
  666. $arraydefaultmessage = -1;
  667. if ($this->param['models'] != 'none')
  668. {
  669. $model_id = 0;
  670. if (array_key_exists('models_id', $this->param))
  671. {
  672. $model_id = $this->param["models_id"];
  673. }
  674. $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); // If $model_id is empty, preselect the first one
  675. }
  676. // Define list of attached files
  677. $listofpaths = array();
  678. $listofnames = array();
  679. $listofmimes = array();
  680. $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
  681. if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
  682. {
  683. if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit']))
  684. {
  685. foreach ($this->param['fileinit'] as $file)
  686. {
  687. $this->add_attached_files($file, basename($file), dol_mimetype($file));
  688. }
  689. }
  690. }
  691. if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
  692. if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
  693. if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
  694. // Define output language
  695. $outputlangs = $langs;
  696. $newlang = '';
  697. if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
  698. $newlang = $this->param['langsmodels'];
  699. }
  700. if (!empty($newlang)) {
  701. $outputlangs = new Translate("", $conf);
  702. $outputlangs->setDefaultLang($newlang);
  703. $outputlangs->load('other');
  704. }
  705. print "\n<!-- Begin message_form TICKET -->\n";
  706. $send_email = GETPOST('send_email', 'int') ? GETPOST('send_email', 'int') : 0;
  707. // Example 1 : Adding jquery code
  708. print '<script type="text/javascript" language="javascript">
  709. jQuery(document).ready(function() {
  710. send_email=' . $send_email.';
  711. if (send_email) {
  712. jQuery(".email_line").show();
  713. } else {
  714. jQuery(".email_line").hide();
  715. }
  716. jQuery("#send_msg_email").click(function() {
  717. if(jQuery(this).is(":checked")) {
  718. jQuery(".email_line").show();
  719. }
  720. else {
  721. jQuery(".email_line").hide();
  722. }
  723. });';
  724. print '});
  725. </script>';
  726. print '<form method="post" name="ticket" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">';
  727. print '<input type="hidden" name="token" value="'.newToken().'">';
  728. print '<input type="hidden" name="action" value="'.$this->action.'">';
  729. print '<input type="hidden" name="actionbis" value="add_message">';
  730. foreach ($this->param as $key => $value) {
  731. print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
  732. }
  733. // Get message template
  734. $model_id = 0;
  735. if (array_key_exists('models_id', $this->param)) {
  736. $model_id = $this->param["models_id"];
  737. $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
  738. }
  739. $result = $formmail->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs);
  740. if ($result < 0) {
  741. setEventMessages($this->error, $this->errors, 'errors');
  742. }
  743. $modelmail_array = array();
  744. foreach ($formmail->lines_model as $line) {
  745. $modelmail_array[$line->id] = $line->label;
  746. }
  747. print '<table class="border" width="'.$width.'">';
  748. // External users can't send message email
  749. if ($user->rights->ticket->write && !$user->socid)
  750. {
  751. print '<tr><td></td><td>';
  752. $checkbox_selected = (GETPOST('send_email') == "1" ? ' checked' : '');
  753. print '<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.'/> ';
  754. print '<label for="send_msg_email">'.$langs->trans('SendMessageByEmail').'</label>';
  755. print '</td></tr>';
  756. // Zone to select its email template
  757. if (count($modelmail_array) > 0) {
  758. print '<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'."\n";
  759. print $langs->trans('SelectMailModel').': '.$formmail->selectarray('modelmailselected', $modelmail_array, $this->param['models_id'], 1);
  760. if ($user->admin) {
  761. print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
  762. }
  763. print ' &nbsp; ';
  764. print '<input class="button" type="submit" value="'.$langs->trans('Apply').'" name="modelselected" id="modelselected">';
  765. print '</div></td>';
  766. }
  767. // Private message (not visible by customer/external user)
  768. if (!$user->socid) {
  769. print '<tr><td></td><td>';
  770. $checkbox_selected = (GETPOST('private_message', 'alpha') == "1" ? ' checked' : '');
  771. print '<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.'/> ';
  772. print '<label for="private_message">'.$langs->trans('MarkMessageAsPrivate').'</label>';
  773. print ' '.$form->textwithpicto('', $langs->trans("TicketMessagePrivateHelp"), 1, 'help');
  774. print '</td></tr>';
  775. }
  776. // Subject
  777. print '<tr class="email_line"><td class="titlefieldcreate">'.$langs->trans('Subject').'</td>';
  778. print '<td><input type="text" class="text minwidth500" name="subject" value="[' . $conf->global->MAIN_INFO_SOCIETE_NOM . ' - ' . $langs->trans("Ticket") . ' ' . $this->ref . '] '.$langs->trans('TicketNewMessage').'" />';
  779. print '</td></tr>';
  780. // Destinataires
  781. print '<tr class="email_line"><td>'.$langs->trans('MailRecipients').'</td><td>';
  782. $ticketstat = new Ticket($this->db);
  783. $res = $ticketstat->fetch('', '', $this->track_id);
  784. if ($res) {
  785. // Retrieve email of all contacts (internal and external)
  786. $contacts = $ticketstat->getInfosTicketInternalContact();
  787. $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact());
  788. // Build array to display recipient list
  789. if (is_array($contacts) && count($contacts) > 0) {
  790. foreach ($contacts as $key => $info_sendto) {
  791. if ($info_sendto['email'] != '') {
  792. $sendto[] = dol_escape_htmltag(trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">").' <small class="opacitymedium">('.dol_escape_htmltag($info_sendto['libelle']).")</small>";
  793. }
  794. }
  795. }
  796. if ($ticketstat->origin_email && !in_array($this->dao->origin_email, $sendto)) {
  797. $sendto[] = dol_escape_htmltag($ticketstat->origin_email).' <small class="opacitymedium">('.$langs->trans("TicketEmailOriginIssuer").")</small>";
  798. }
  799. if ($ticketstat->fk_soc > 0) {
  800. $ticketstat->socid = $ticketstat->fk_soc;
  801. $ticketstat->fetch_thirdparty();
  802. if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
  803. $sendto[] = $ticketstat->thirdparty->email.' <small class="opacitymedium">('.$langs->trans('Customer').')</small>';
  804. }
  805. }
  806. if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) {
  807. $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO.' <small class="opacitymedium">(generic email)</small>';
  808. }
  809. // Print recipient list
  810. if (is_array($sendto) && count($sendto) > 0) {
  811. print implode(', ', $sendto);
  812. } else {
  813. print '<div class="warning">'.$langs->trans('WarningNoEMailsAdded').' '.$langs->trans('TicketGoIntoContactTab').'</div>';
  814. }
  815. }
  816. print '</td></tr>';
  817. }
  818. // Intro
  819. // External users can't send message email
  820. if ($user->rights->ticket->write && !$user->socid) {
  821. $mail_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO;
  822. print '<tr class="email_line"><td><label for="mail_intro">';
  823. print $form->textwithpicto($langs->trans("TicketMessageMailIntro"), $langs->trans("TicketMessageMailIntroHelp"), 1, 'help');
  824. print '</label>';
  825. print '</td><td>';
  826. include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  827. $uselocalbrowser = true;
  828. $doleditor = new DolEditor('mail_intro', $mail_intro, '100%', 90, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
  829. $doleditor->Create();
  830. print '</td></tr>';
  831. }
  832. // MESSAGE
  833. $defaultmessage="";
  834. if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
  835. $defaultmessage = $arraydefaultmessage->content;
  836. }
  837. $defaultmessage = str_replace('\n', "\n", $defaultmessage);
  838. // Deal with format differences between message and signature (text / HTML)
  839. if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
  840. $this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']);
  841. } elseif (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
  842. $defaultmessage = dol_nl2br($defaultmessage);
  843. }
  844. if (isset($_POST["message"]) && !$_POST['modelselected']) {
  845. $defaultmessage = GETPOST('message');
  846. } else {
  847. $defaultmessage = make_substitutions($defaultmessage, $this->substit);
  848. // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty)
  849. $defaultmessage = preg_replace("/^(<br>)+/", "", $defaultmessage);
  850. $defaultmessage = preg_replace("/^\n+/", "", $defaultmessage);
  851. }
  852. print '<tr><td class="tdtop"><label for="message"><span class="fieldrequired">'.$langs->trans("Message").'</span>';
  853. if ($user->rights->ticket->write && !$user->socid) {
  854. print $form->textwithpicto('', $langs->trans("TicketMessageHelp"), 1, 'help');
  855. }
  856. print '</label></td><td>';
  857. //$toolbarname = 'dolibarr_details';
  858. $toolbarname = 'dolibarr_notes';
  859. include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  860. $doleditor = new DolEditor('message', $defaultmessage, '100%', 200, $toolbarname, '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, 70);
  861. $doleditor->Create();
  862. print '</td></tr>';
  863. // Signature
  864. // External users can't send message email
  865. if ($user->rights->ticket->write && !$user->socid) {
  866. $mail_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE;
  867. print '<tr class="email_line"><td><label for="mail_intro">'.$langs->trans("TicketMessageMailSignature").'</label>';
  868. print $form->textwithpicto('', $langs->trans("TicketMessageMailSignatureHelp"), 1, 'help');
  869. print '</td><td>';
  870. include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
  871. $doleditor = new DolEditor('mail_signature', $mail_signature, '100%', 150, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
  872. $doleditor->Create();
  873. print '</td></tr>';
  874. }
  875. // Attached files
  876. if (!empty($this->withfile)) {
  877. $out = '<tr>';
  878. $out .= '<td width="180">'.$langs->trans("MailFile").'</td>';
  879. $out .= '<td>';
  880. // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript
  881. $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">'."\n";
  882. $out .= '<script type="text/javascript" language="javascript">';
  883. $out .= 'jQuery(document).ready(function () {';
  884. $out .= ' jQuery(".removedfile").click(function() {';
  885. $out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());';
  886. $out .= ' });';
  887. $out .= '})';
  888. $out .= '</script>'."\n";
  889. if (count($listofpaths)) {
  890. foreach ($listofpaths as $key => $val) {
  891. $out .= '<div id="attachfile_'.$key.'">';
  892. $out .= img_mime($listofnames[$key]).' '.$listofnames[$key];
  893. if (!$this->withfilereadonly) {
  894. $out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile reposition" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
  895. }
  896. $out .= '<br></div>';
  897. }
  898. } else {
  899. $out .= $langs->trans("NoAttachedFiles").'<br>';
  900. }
  901. if ($this->withfile == 2) { // Can add other files
  902. $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
  903. $out .= ' ';
  904. $out .= '<input type="submit" class="button" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />';
  905. }
  906. $out .= "</td></tr>\n";
  907. print $out;
  908. }
  909. print '</table>';
  910. print '<center><br>';
  911. print '<input class="button" type="submit" name="btn_add_message" value="'.$langs->trans("AddMessage").'" />';
  912. if ($this->withcancel) {
  913. print " &nbsp; &nbsp; ";
  914. print "<input class=\"button\" type=\"submit\" name=\"cancel\" value=\"".$langs->trans("Cancel")."\">";
  915. }
  916. print "</center>\n";
  917. print "</form>\n";
  918. print "<!-- End form TICKET -->\n";
  919. }
  920. }