28 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
29 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
30 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
32 if (!class_exists(
'FormCompany')) {
33 include DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
64 public $fk_user_create;
80 public $withfilereadonly;
86 public $withtitletopic;
87 public $withtopicreadonly;
91 public $withfromsocid;
92 public $withfromcontactid;
93 public $withnotifytiersatcreate;
94 public $withusercreate;
95 public $withcreatereadonly;
100 public $withextrafields;
106 public $category_code;
107 public $severity_code;
114 public $substit = array();
115 public $param = array();
121 public $errors = array();
135 $this->action =
'add';
138 $this->withfromsocid = 0;
139 $this->withfromcontactid = 0;
142 $this->withnotifytiersatcreate = 0;
143 $this->withusercreate = 1;
144 $this->withcreatereadonly = 1;
145 $this->withemail = 0;
147 $this->withextrafields = 0;
161 public function showForm($withdolfichehead = 0, $mode =
'edit', $public = 0,
Contact $with_contact =
null, $action =
'')
163 global $conf, $langs, $user, $hookmanager;
166 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
170 $ticketstatic =
new Ticket($this->
db);
173 if (!empty($this->withfromsocid) && $this->withfromsocid > 0) {
174 $soc->fetch($this->withfromsocid);
177 $ticketstat =
new Ticket($this->
db);
180 $extrafields->fetch_name_optionals_label($ticketstat->table_element);
182 print
"\n<!-- Begin form TICKET -->\n";
184 if ($withdolfichehead) {
188 print
'<form method="POST" '.($withdolfichehead ?
'' :
'style="margin-bottom: 30px;" ').
'name="ticket" id="form_create_ticket" enctype="multipart/form-data" action="'.(!empty($this->param[
"returnurl"]) ? $this->param[
"returnurl"] : $_SERVER[
'PHP_SELF']).
'">';
189 print
'<input type="hidden" name="token" value="'.newToken().
'">';
190 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
191 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
192 foreach ($this->param as $key => $value) {
193 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
195 print
'<input type="hidden" name="fk_user_create" value="'.$this->fk_user_create.
'">';
197 print
'<table class="border centpercent">';
199 if ($this->withref) {
201 $defaultref = $ticketstat->getDefaultRef();
202 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Ref").
'</span></td><td>';
203 print
'<input type="text" name="ref" value="'.dol_escape_htmltag(
GETPOST(
"ref",
'alpha') ?
GETPOST(
"ref",
'alpha') : $defaultref).
'">';
209 if ($this->withemail) {
210 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"Email").
'</span></label></td><td>';
211 print
'<input class="text minwidth200" id="email" name="email" value="'.$email.
'" autofocus>';
216 $html_contact_search =
'';
217 $html_contact_search .=
'<tr id="contact_search_line">';
218 $html_contact_search .=
'<td class="titlefield">';
219 $html_contact_search .=
'<label for="contact"><span class="fieldrequired">' . $langs->trans(
'Contact') .
'</span></label>';
220 $html_contact_search .=
'<input type="hidden" id="contact_id" name="contact_id" value="" />';
221 $html_contact_search .=
'</td>';
222 $html_contact_search .=
'<td id="contact_search_result"></td>';
223 $html_contact_search .=
'</tr>';
224 print $html_contact_search;
226 $html_contact_lastname =
'';
227 $html_contact_lastname .=
'<tr id="contact_lastname_line" class="contact_field"><td class="titlefield"><label for="contact_lastname"><span class="fieldrequired">' . $langs->trans(
'Lastname') .
'</span></label></td><td>';
228 $html_contact_lastname .=
'<input type="text" id="contact_lastname" name="contact_lastname" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_lastname') ?
GETPOST(
'contact_lastname',
'alphanohtml') :
'') .
'" />';
229 $html_contact_lastname .=
'</td></tr>';
230 print $html_contact_lastname;
232 $html_contact_firstname =
'';
233 $html_contact_firstname .=
'<tr id="contact_firstname_line" class="contact_field"><td class="titlefield"><label for="contact_firstname"><span class="fieldrequired">' . $langs->trans(
'Firstname') .
'</span></label></td><td>';
234 $html_contact_firstname .=
'<input type="text" id="contact_firstname" name="contact_firstname" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_firstname') ?
GETPOST(
'contact_firstname',
'alphanohtml') :
'') .
'" />';
235 $html_contact_firstname .=
'</td></tr>';
236 print $html_contact_firstname;
238 $html_company_name =
'';
239 $html_company_name .=
'<tr id="contact_company_name_line" class="contact_field"><td><label for="company_name"><span>' . $langs->trans(
'Company') .
'</span></label></td><td>';
240 $html_company_name .=
'<input type="text" id="company_name" name="company_name" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'company_name') ?
GETPOST(
'company_name',
'alphanohtml') :
'') .
'" />';
241 $html_company_name .=
'</td></tr>';
242 print $html_company_name;
244 $html_contact_phone =
'';
245 $html_contact_phone .=
'<tr id="contact_phone_line" class="contact_field"><td><label for="contact_phone"><span>' . $langs->trans(
'Phone') .
'</span></label></td><td>';
246 $html_contact_phone .=
'<input type="text" id="contact_phone" name="contact_phone" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_phone') ?
GETPOST(
'contact_phone',
'alphanohtml') :
'') .
'" />';
247 $html_contact_phone .=
'</td></tr>';
248 print $html_contact_phone;
251 $langs->load(
'errors');
252 print
'<script nonce="'.getNonce().
'" type="text/javascript">
253 jQuery(document).ready(function() {
254 var contact = jQuery.parseJSON("'.
dol_escape_js(json_encode($with_contact), 2).
'");
255 jQuery("#contact_search_line").hide();
257 if (contact.id > 0) {
258 jQuery("#contact_search_line").show();
259 jQuery("#contact_id").val(contact.id);
260 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
261 jQuery(".contact_field").hide();
263 jQuery(".contact_field").show();
267 jQuery("#email").change(function() {
268 jQuery("#contact_search_line").show();
269 jQuery("#contact_search_result").html("'.
dol_escape_js($langs->trans(
'Select2SearchInProgress')).
'");
270 jQuery("#contact_id").val("");
271 jQuery("#contact_lastname").val("");
272 jQuery("#contact_firstname").val("");
273 jQuery("#company_name").val("");
274 jQuery("#contact_phone").val("");
279 action: "getContacts",
280 email: jQuery("#email").val()
283 if (response.error) {
284 jQuery("#contact_search_result").html("<span class=\"error\">"+response.error+"</span>");
286 var contact_list = response.contacts;
287 if (contact_list.length == 1) {
288 var contact = contact_list[0];
289 jQuery("#contact_id").val(contact.id);
290 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
291 jQuery(".contact_field").hide();
292 } else if (contact_list.length <= 0) {
293 jQuery("#contact_search_line").hide();
294 jQuery(".contact_field").show();
298 ).fail(function(jqxhr, textStatus, error) {
299 var error_msg = "'.
dol_escape_js($langs->trans(
'ErrorAjaxRequestFailed')).
'"+" ["+textStatus+"] : "+error;
300 jQuery("#contact_search_result").html("<span class=\"error\">"+error_msg+"</span>");
310 if (isset($this->param[
'origin']) && $this->param[
'originid'] > 0) {
312 $element = $subelement = $this->param[
'origin'];
314 if (preg_match(
'/^([^_]+)_([^_]+)/i', $this->param[
'origin'], $regs)) {
316 $subelement = $regs[2];
320 $classname = ucfirst($subelement);
321 $objectsrc =
new $classname($this->
db);
322 $objectsrc->fetch(
GETPOST(
'originid',
'int'));
324 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
325 $objectsrc->fetch_lines();
328 $objectsrc->fetch_thirdparty();
329 $newclassname = $classname;
330 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td colspan="2"><input name="'.$subelement.
'id" value="'.
GETPOST(
'originid').
'" type="hidden" />'.$objectsrc->getNomUrl(1).
'</td></tr>';
334 print
'<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans(
"TicketTypeRequest").
'</span></label></td><td>';
339 print
'<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans(
"TicketCategory").
'</span></label></td><td>';
342 $filter =
'public=1';
344 $this->
selectGroupTickets((
GETPOST(
'category_code') ?
GETPOST(
'category_code') : $this->category_code),
'category_code', $filter, 2, 1, 0, 0,
'minwidth200');
348 print
'<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans(
"TicketSeverity").
'</span></label></td><td>';
352 if (!empty($conf->knowledgemanagement->enabled)) {
354 print
'<tr id="KWwithajax" class="hidden"><td></td></tr>';
355 print
'<!-- Script to manage change of ticket group -->
356 <script nonce="'.getNonce().
'">
357 jQuery(document).ready(function() {
358 function groupticketchange() {
359 console.log("We called groupticketchange, so we try to load list KM linked to event");
360 $("#KWwithajax").html("");
361 idgroupticket = $("#selectcategory_code").val();
363 console.log("We have selected id="+idgroupticket);
365 if (idgroupticket != "") {
366 $.ajax({ url: \''.DOL_URL_ROOT.
'/core/ajax/fetchKnowledgeRecord.php\',
367 data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.
newToken().
'\', lang:\
''.$langs->defaultlang.
'\',
public:
'.($public).' },
369 success: function(response) {
371 console.log("We received response "+response);
372 if (typeof response == "object") {
373 console.log("response is already type object, no need to parse it");
375 console.log("response is type "+(typeof response));
376 response = JSON.parse(response);
378 for (key in response) {
379 answer = response[key].answer;
380 urllist += \'<li><a href="#" title="\'+response[key].title+\'" class="button_KMpopup" data-html="\'+answer+\'">\' +response[key].title+\'</a></li>\';
383 $("#KWwithajax").html(\'<td>'.$langs->trans(
"KMFoundForTicketGroup").
'</td><td><ul>\'+urllist+\'</ul></td>\');
384 $("#KWwithajax").show();
385 $(".button_KMpopup").on("click",function(){
386 console.log("Open popup with jQuery(...).dialog() with KM article")
387 var $dialog = $("<div></div>").html($(this).attr("data-html"))
391 height: (window.innerHeight - 150),
393 title: $(this).attr("title"),
395 $dialog.dialog("open");
396 console.log($dialog);
400 error : function(output) {
401 console.error("Error on Fetch of KM articles");
406 $("#selectcategory_code").on("change",function() { groupticketchange(); });
407 if ($("#selectcategory_code").val() != "") {
415 if ($this->withtitletopic) {
416 print
'<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans(
"Subject").
'</span></label></td><td>';
418 if ($this->withtopicreadonly) {
419 print $langs->trans(
'SubjectAnswerToTicket').
' '.$this->topic_title;
421 if (isset($this->withreadid) && $this->withreadid > 0) {
422 $subject = $langs->trans(
'SubjectAnswerToTicket').
' '.$this->withreadid.
' : '.$this->topic_title.
'';
424 $subject =
GETPOST(
'subject',
'alpha');
426 print
'<input class="text minwidth500" id="subject" name="subject" value="'.$subject.
'"'.(empty($this->withemail)?
' autofocus':
'').
' />';
433 print
'<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span></label></td><td>';
436 $toolbarname =
'dolibarr_notes';
437 if ($this->ispublic) {
438 $toolbarname =
'dolibarr_details';
439 print
'<div class="warning">'.(getDolGlobalString(
"TICKET_PUBLIC_TEXT_HELP_MESSAGE", $langs->trans(
'TicketPublicPleaseBeAccuratelyDescribe'))).
'</div>';
441 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
442 $uselocalbrowser =
true;
443 $doleditor =
new DolEditor(
'message', $msg,
'100%', 230, $toolbarname,
'In',
true, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_TICKET'), ROWS_8,
'90%');
444 $doleditor->Create();
447 if ($public && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) {
448 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
449 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"SecurityCode").
'</span></label></td><td>';
450 print
'<span class="span-icon-security inline-block">';
451 print
'<input id="securitycode" placeholder="'.$langs->trans(
"SecurityCode").
'" class="flat input-icon-security width125" type="text" maxlength="5" name="code" tabindex="3" />';
453 print
'<span class="nowrap inline-block">';
454 print
'<img class="inline-block valignmiddle" src="'.DOL_URL_ROOT.
'/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />';
455 print
'<a class="inline-block valignmiddle" href="" tabindex="4" data-role="button">'.img_picto($langs->trans(
"Refresh"),
'refresh',
'id="captcha_refresh_img"').
'</a>';
462 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
463 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_TICKET,
'',
'parent', 64, 0, 1);
465 if (count($cate_arbo)) {
467 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
468 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
474 if (!empty($this->withfile)) {
476 $listofpaths = array();
477 $listofnames = array();
478 $listofmimes = array();
479 if (!empty($_SESSION[
"listofpaths"])) {
480 $listofpaths = explode(
';', $_SESSION[
"listofpaths"]);
483 if (!empty($_SESSION[
"listofnames"])) {
484 $listofnames = explode(
';', $_SESSION[
"listofnames"]);
487 if (!empty($_SESSION[
"listofmimes"])) {
488 $listofmimes = explode(
';', $_SESSION[
"listofmimes"]);
492 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
495 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
496 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
497 $out .=
'jQuery(document).ready(function () {';
498 $out .=
' jQuery(".removedfile").click(function() {';
499 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
502 $out .=
'</script>'.
"\n";
503 if (count($listofpaths)) {
504 foreach ($listofpaths as $key => $val) {
505 $out .=
'<div id="attachfile_'.$key.
'">';
506 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
507 if (!$this->withfilereadonly) {
508 $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.
'" />';
510 $out .=
'<br></div>';
513 $out .= $langs->trans(
"NoAttachedFiles").
'<br>';
515 if ($this->withfile == 2) {
517 $maxmin = $maxfilesizearray[
'maxmin'];
519 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
521 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
523 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="addfile" name="addfile" value="'.$langs->trans(
"MailingAddFile").
'" />';
525 $out .=
"</td></tr>\n";
531 if ($this->withusercreate > 0 && $this->fk_user_create) {
532 print
'<tr><td class="titlefield">'.$langs->trans(
"CreatedBy").
'</td><td>';
533 $langs->load(
"users");
534 $fuser =
new User($this->
db);
536 if ($this->withcreatereadonly) {
537 if ($res = $fuser->fetch($this->fk_user_create)) {
538 print $fuser->getNomUrl(1);
542 print
"</td></tr>\n";
546 if ($this->withcompany) {
548 if (empty($user->socid)) {
550 print
'<tr><td class="titlefield">'.$langs->trans(
"ThirdParty").
'</td><td>';
552 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
553 print
img_picto(
'',
'company',
'class="paddingright"');
554 print
$form->select_company($this->withfromsocid,
'socid',
'', 1, 1,
'', $events, 0,
'minwidth200');
556 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
558 print
'<script nonce="'.getNonce().
'" type="text/javascript">
559 $(document).ready(function () {
560 jQuery("#'.$htmlname.
'").change(function () {
561 var obj = '.json_encode($events).
';
562 $.each(obj, function(key,values) {
563 if (values.method.length) {
564 runJsCodeForEvent'.$htmlname.
'(values);
569 function runJsCodeForEvent'.$htmlname.
'(obj) {
570 console.log("Run runJsCodeForEvent'.$htmlname.
'");
571 var id = $("#'.$htmlname.
'").val();
572 var method = obj.method;
574 var htmlname = obj.htmlname;
575 var showempty = obj.showempty;
584 $.each(obj.params, function(key,action) {
586 var num = response.num;
588 $("#" + key).removeAttr(action);
590 $("#" + key).attr(action, action);
594 $("select#" + htmlname).html(response.value);
596 var selecthtml_str = response.value;
597 var selecthtml_dom=$.parseHTML(selecthtml_str);
598 if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
599 $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
602 $("#inputautocomplete"+htmlname).val("");
604 $("select#" + htmlname).change(); /* Trigger event change */
613 print
'<tr><td>'.$langs->trans(
"Contact").
'</td><td>';
615 $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
616 print
img_picto(
'',
'contact',
'class="paddingright"');
617 print
$form->selectcontacts($selectedCompany, $this->withfromcontactid,
'contactid', 3,
'',
'', 0,
'minwidth200');
619 $formcompany->selectTypeContact($ticketstatic,
'',
'type',
'external',
'', 0,
'maginleftonly');
622 print
'<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.
'"/></td>';
623 print
'<td><input type="hidden" name="contactid" value="'.$user->contact_id.
'"/></td>';
624 print
'<td><input type="hidden" name="type" value="Z"/></td></tr>';
628 if (empty($this->ispublic)) {
629 print
'<tr><td><label for="notify_tiers_at_create">'.$langs->trans(
"TicketNotifyTiersAtCreation").
'</label></td><td>';
630 print
'<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ?
' checked="checked"' :
'').
'>';
636 print $langs->trans(
"AssignedTo");
638 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
639 print
$form->select_dolusers(
GETPOST(
'fk_user_assign',
'int'),
'fk_user_assign', 1);
644 if ($subelement !=
'project') {
647 print
'<tr><td><label for="project"><span class="">'.$langs->trans(
"Project").
'</span></label></td><td>';
648 print
img_picto(
'',
'project').$formproject->select_projects(-1,
GETPOST(
'projectid',
'int'),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
654 $parameters = array();
655 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $ticketstat, $action);
656 if (empty($reshook)) {
657 print $ticketstat->showOptionals($extrafields,
'create');
662 if ($withdolfichehead) {
668 print
$form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"CreateTicket"), ($this->withcancel ?
"Cancel" :
""));
680 print
'<input type="hidden" name="page_y">'.
"\n";
683 print
"<!-- End form TICKET -->\n";
700 public function selectTypesTickets($selected =
'', $htmlname =
'tickettype', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $multiselect = 0)
702 global $langs, $user;
704 $selected = is_array($selected) ? $selected : (!empty($selected) ? array($selected) : array());
705 $ticketstat =
new Ticket($this->
db);
707 dol_syslog(get_class($this) .
"::select_types_tickets " . implode(
';', $selected) .
", " . $htmlname .
", " . $filtertype .
", " . $format .
", " . $multiselect, LOG_DEBUG);
709 $filterarray = array();
711 if ($filtertype !=
'' && $filtertype !=
'-1') {
712 $filterarray = explode(
',', $filtertype);
715 $ticketstat->loadCacheTypesTickets();
717 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.($multiselect?
'[]':
'').
'"'.($multiselect?
' multiple':
'').
'>';
719 print
'<option value=""> </option>';
722 if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
723 foreach ($ticketstat->cache_types_tickets as $id => $arraytypes) {
725 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
730 if ($empty && empty($arraytypes[
'code'])) {
735 print
'<option value="'.$id.
'"';
739 print
'<option value="'.$arraytypes[
'code'].
'"';
743 print
'<option value="'.$arraytypes[
'code'].
'"';
747 print
'<option value="'.$id.
'"';
751 if (in_array($arraytypes[
'code'], $selected)) {
752 print
' selected="selected"';
753 } elseif (in_array($id, $selected)) {
754 print
' selected="selected"';
755 } elseif ($arraytypes[
'use_default'] ==
"1" && !$selected && !$empty) {
756 print
' selected="selected"';
763 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
764 } elseif ($format == 1) {
765 $value = $arraytypes[
'code'];
766 } elseif ($format == 2) {
767 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
768 } elseif ($format == 3) {
769 $value = $arraytypes[
'code'];
772 print $value ? $value :
' ';
777 if (isset($user->admin) && $user->admin && !$noadmininfo) {
778 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
799 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $use_multilevel = 0, $outputlangs =
null)
801 global $conf, $langs, $user;
803 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
805 if (is_null($outputlangs) || !is_object($outputlangs)) {
806 $outputlangs = $langs;
808 $outputlangs->load(
"ticket");
810 $ticketstat =
new Ticket($this->
db);
811 $ticketstat->loadCacheCategoriesTickets();
813 if ($use_multilevel <= 0) {
814 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
816 print
'<option value=""> </option>';
819 if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
820 foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
822 if ($filtertype ==
'public=1') {
823 if (empty($arraycategories[
'public'])) {
829 if ($empty && empty($arraycategories[
'code'])) {
833 $label = ($arraycategories[
'label'] !=
'-' ? $arraycategories[
'label'] :
'');
834 if ($outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']) != (
"TicketCategoryShort".$arraycategories[
'code'])) {
835 $label = $outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']);
836 } elseif ($outputlangs->trans($arraycategories[
'code']) != $arraycategories[
'code']) {
837 $label = $outputlangs->trans($arraycategories[
'code']);
841 print
'<option value="'.$id.
'"';
845 print
'<option value="'.$arraycategories[
'code'].
'"';
849 print
'<option value="'.$arraycategories[
'code'].
'"';
853 print
'<option value="'.$id.
'"';
857 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
858 print
' selected="selected"';
859 } elseif ($selected == $id) {
860 print
' selected="selected"';
861 } elseif ($arraycategories[
'use_default'] ==
"1" && !$selected && !$empty) {
862 print
' selected="selected"';
863 } elseif (count($ticketstat->cache_category_tickets) == 1) {
864 print
' selected="selected"';
871 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
875 $value = $arraycategories[
'code'];
879 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
883 $value = $arraycategories[
'code'];
886 print $value ? $value :
' ';
891 if (isset($user->admin) && $user->admin && !$noadmininfo) {
892 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
896 } elseif ($htmlname!=
'') {
897 $selectedgroups = array();
899 $groupticket=
GETPOST($htmlname,
'aZ09');
900 $child_id=
GETPOST($htmlname.
'_child_id',
'aZ09')?
GETPOST($htmlname.
'_child_id',
'aZ09'):0;
901 if (!empty($groupticket)) {
902 $tmpgroupticket = $groupticket;
903 $sql =
"SELECT ctc.rowid, ctc.fk_parent, ctc.code FROM ".$this->db->prefix().
"c_ticket_category as ctc WHERE ctc.code = '".$this->
db->escape($tmpgroupticket).
"'";
904 $resql = $this->
db->query(
$sql);
906 $obj = $this->
db->fetch_object($resql);
907 $selectedgroups[] = $obj->code;
908 while ($obj->fk_parent > 0) {
909 $sql =
"SELECT ctc.rowid, ctc.fk_parent, ctc.code FROM ".$this->db->prefix().
"c_ticket_category as ctc WHERE ctc.rowid ='".$this->
db->escape($obj->fk_parent).
"'";
910 $resql = $this->
db->query(
$sql);
912 $obj = $this->
db->fetch_object($resql);
913 $selectedgroups[] = $obj->code;
919 $arrayidused = array();
920 $arrayidusedconcat = array();
921 $arraycodenotparent = array();
922 $arraycodenotparent[] =
"";
924 $stringtoprint =
'<span class="supportemailfield bold">'.$langs->trans(
"GroupOfTicket").
'</span> ';
925 $stringtoprint .=
'<select id ="'.$htmlname.
'" class="minwidth500" child_id="0">';
926 $stringtoprint .=
'<option value=""> </option>';
928 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
929 $sql .= $this->
db->ifsql(
"ctc.rowid NOT IN (SELECT ctcfather.rowid FROM llx_c_ticket_category as ctcfather JOIN llx_c_ticket_category as ctcjoin ON ctcfather.rowid = ctcjoin.fk_parent)",
"'NOTPARENT'",
"'PARENT'").
" as isparent";
930 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
931 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
932 if ($filtertype ==
'public=1') {
933 $sql .=
" AND ctc.public = 1";
935 $sql .=
" AND ctc.fk_parent = 0";
936 $sql .= $this->
db->order(
'ctc.pos',
'ASC');
938 $resql = $this->
db->query(
$sql);
940 $num_rows_level0 = $this->
db->num_rows($resql);
942 while ($i < $num_rows_level0) {
943 $obj = $this->
db->fetch_object($resql);
945 $label = ($obj->label !=
'-' ? $obj->label :
'');
946 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
947 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
948 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
949 $label = $outputlangs->trans($obj->code);
952 $grouprowid = $obj->rowid;
953 $groupvalue = $obj->code;
954 $grouplabel = $label;
956 $isparent = $obj->isparent;
957 if (is_array($selectedgroups)) {
958 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
960 $iselected = $groupticket == $obj->code ?
'selected':
'';
963 if ($isparent ==
'NOTPARENT') {
964 $arraycodenotparent[] = $groupvalue;
966 $arrayidused[] = $grouprowid;
967 $arrayidusedconcat[] = $grouprowid;
974 if (count($arrayidused) == 1) {
975 return '<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.
dol_escape_htmltag($groupvalue).
'">';
977 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'_select" class="maxwidth500 minwidth400">';
978 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'_child_id" id="'.$htmlname.
'_select_child_id" class="maxwidth500 minwidth400">';
980 $stringtoprint .=
'</select> ';
983 while ($levelid <= $use_multilevel) {
984 $tabscript = array();
985 $stringtoprint .=
'<select id ="'.$htmlname.
'_child_'.$levelid.
'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.
'">';
986 $stringtoprint .=
'<option value=""> </option>';
988 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
989 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
990 $sql .=
" JOIN ".$this->db->prefix().
"c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
991 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
992 $sql .=
" AND ctc.rowid NOT IN (".$this->db->sanitize(join(
',', $arrayidusedconcat)).
")";
994 if ($filtertype ==
'public=1') {
995 $sql .=
" AND ctc.public = 1";
998 if (!empty($arrayidused)) {
999 $sql .=
" AND ctc.fk_parent IN ( ";
1000 foreach ($arrayidused as $idused) {
1001 $sql .= $idused.
", ";
1006 $sql .= $this->
db->order(
'ctc.pos',
'ASC');
1008 $resql = $this->
db->query(
$sql);
1010 $num_rows = $this->
db->num_rows($resql);
1012 $arrayidused=array();
1013 while ($i < $num_rows) {
1014 $obj = $this->
db->fetch_object($resql);
1016 $label = ($obj->label !=
'-' ? $obj->label :
'');
1017 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
1018 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
1019 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
1020 $label = $outputlangs->trans($obj->code);
1023 $grouprowid = $obj->rowid;
1024 $groupvalue = $obj->code;
1025 $grouplabel = $label;
1026 $isparent = $obj->isparent;
1027 $fatherid = $obj->fk_parent;
1028 $arrayidused[] = $grouprowid;
1029 $arrayidusedconcat[] = $grouprowid;
1030 $groupcodefather = $obj->codefather;
1031 if ($isparent ==
'NOTPARENT') {
1032 $arraycodenotparent[] = $groupvalue;
1034 if (is_array($selectedgroups)) {
1035 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
1037 $iselected = $groupticket == $obj->code ?
'selected':
'';
1040 if (empty($tabscript[$groupcodefather])) {
1041 $tabscript[$groupcodefather] =
'if ($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1):
'').
'").val() == "'.
dol_escape_js($groupcodefather).
'"){
1043 console.log("We show childs tickets of '.$groupcodefather.
' group ticket")
1046 console.log("We hide childs tickets of '.$groupcodefather.
' group ticket")
1055 $stringtoprint .=
'</select>';
1057 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1058 $stringtoprint .=
'arraynotparents = '.json_encode($arraycodenotparent).
';';
1059 $stringtoprint .=
'if (arraynotparents.includes($("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1):
'').
'").val())){
1060 console.log("'.$htmlname.
'_child_'.$levelid.
'")
1061 if($("#'.$htmlname.
'_child_'.$levelid.
'").val() == "" && ($("#'.$htmlname.
'_child_'.$levelid.
'").attr("child_id")>'.$child_id.
')){
1062 $("#'.$htmlname.
'_child_'.$levelid.
'").hide();
1063 console.log("We hide '.$htmlname.
'_child_'.$levelid.
' input")
1065 if(arraynotparents.includes("'.$groupticket.
'") && '.$child_id.
' == 0){
1066 $("#ticketcategory_select_child_id").val($("#'.$htmlname.
'").attr("child_id"))
1067 $("#ticketcategory_select").val($("#'.$htmlname.
'").val()) ;
1068 console.log("We choose '.$htmlname.
' input and reload hidden input");
1071 $("#'.$htmlname.($levelid > 1 ?
'_child_'.($levelid-1):
'').
'").change(function() {
1072 child_id = $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid:
'').
'").attr("child_id");
1074 /* Change of value to select this value*/
1075 if (arraynotparents.includes($(this).val()) || $(this).attr("child_id") == '.$use_multilevel.
') {
1076 $("#ticketcategory_select").val($(this).val());
1077 $("#ticketcategory_select_child_id").val($(this).attr("child_id")) ;
1078 console.log("We choose to select "+ $(this).val());
1080 if ($("#'.$htmlname.
'_child_'.$levelid.
' option").length <= 1) {
1081 $("#ticketcategory_select").val($(this).val());
1082 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1083 console.log("We choose to select "+ $(this).val() + " and next combo has no item, so we keep this selection");
1085 console.log("We choose to select "+ $(this).val() + " but next combo has some item, so we clean selected item");
1086 $("#ticketcategory_select").val("");
1087 $("#ticketcategory_select_child_id").val("");
1091 console.log("We select a new value into combo child_id="+child_id);
1093 // Hide all selected box that are child of the one modified
1094 $(".groupticketchild").each(function(){
1095 if ($(this).attr("child_id") > child_id) {
1096 console.log("hide child_id="+$(this).attr("child_id"));
1102 // Now we enable the next combo
1103 $("#'.$htmlname.
'_child_'.$levelid.
'").val("");
1104 if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.
'_child_'.$levelid.
' option").length > 1) {
1105 console.log($("#'.$htmlname.
'_child_'.$levelid.
' option").length);
1106 $("#'.$htmlname.
'_child_'.$levelid.
'").show()
1108 $("#'.$htmlname.
'_child_'.$levelid.
'").hide()
1112 foreach ($tabscript as $script) {
1113 $stringtoprint .= $script;
1115 $stringtoprint .=
'})';
1116 $stringtoprint .=
'</script>';
1118 $stringtoprint .=
'<script nonce="'.getNonce().
'">';
1119 $stringtoprint .=
'$("#'.$htmlname.
'_child_'.$use_multilevel.
'").change(function() {
1120 $("#ticketcategory_select").val($(this).val());
1121 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1122 console.log($("#ticketcategory_select").val());
1124 $stringtoprint .=
'</script>';
1127 return $stringtoprint;
1144 public function selectSeveritiesTickets($selected =
'', $htmlname =
'ticketseverity', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
1146 global $langs, $user;
1148 $ticketstat =
new Ticket($this->
db);
1150 dol_syslog(get_class($this).
"::selectSeveritiesTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1152 $filterarray = array();
1154 if ($filtertype !=
'' && $filtertype !=
'-1') {
1155 $filterarray = explode(
',', $filtertype);
1158 $ticketstat->loadCacheSeveritiesTickets();
1160 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1162 print
'<option value=""> </option>';
1165 if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
1166 foreach ($ticketstat->cache_severity_tickets as $id => $arrayseverities) {
1168 if (count($filterarray) && !in_array($arrayseverities[
'type'], $filterarray)) {
1173 if ($empty && empty($arrayseverities[
'code'])) {
1178 print
'<option value="'.$id.
'"';
1182 print
'<option value="'.$arrayseverities[
'code'].
'"';
1186 print
'<option value="'.$arrayseverities[
'code'].
'"';
1190 print
'<option value="'.$id.
'"';
1194 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arrayseverities[
'code']) {
1195 print
' selected="selected"';
1196 } elseif ($selected == $id) {
1197 print
' selected="selected"';
1198 } elseif ($arrayseverities[
'use_default'] ==
"1" && !$selected && !$empty) {
1199 print
' selected="selected"';
1206 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1210 $value = $arrayseverities[
'code'];
1214 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1218 $value = $arrayseverities[
'code'];
1221 print $value ? $value :
' ';
1226 if (isset($user->admin) && $user->admin && !$noadmininfo) {
1227 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1242 global $conf, $user;
1243 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1246 $vardir = $conf->user->dir_output.
"/".$user->id;
1247 $upload_dir = $vardir.
'/temp/';
1248 if (is_dir($upload_dir)) {
1252 if (!empty($this->trackid)) {
1253 $keytoavoidconflict =
'-'.$this->trackid;
1255 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1257 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
1258 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
1259 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
1270 global $conf, $langs, $user, $hookmanager,
$form, $mysoc;
1273 $addfileaction =
'addfile';
1275 if (!is_object(
$form)) {
1280 $langs->loadLangs(array(
'other',
'mails'));
1283 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1284 $this->clear_attached_files();
1288 $outputlangs = $langs;
1290 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1291 $newlang = $this->param[
'langsmodels'];
1293 if (!empty($newlang)) {
1294 $outputlangs =
new Translate(
"", $conf);
1295 $outputlangs->setDefaultLang($newlang);
1296 $outputlangs->load(
'other');
1300 $arraydefaultmessage = -1;
1301 if (isset($this->param[
'models']) && $this->param[
'models'] !=
'none') {
1303 if (array_key_exists(
'models_id', $this->param)) {
1304 $model_id = (int) $this->param[
"models_id"];
1307 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db, $this->param[
"models"], $user, $outputlangs, $model_id);
1311 $listofpaths = array();
1312 $listofnames = array();
1313 $listofmimes = array();
1315 if (!empty($this->trackid)) {
1316 $keytoavoidconflict =
'-'.$this->trackid;
1318 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1321 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1322 if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param[
'fileinit']) && is_array($this->param[
'fileinit'])) {
1323 foreach ($this->param[
'fileinit'] as $file) {
1324 $formmail->add_attached_files($file, basename($file),
dol_mimetype($file));
1330 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
1331 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
1333 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
1334 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
1336 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
1337 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
1341 $outputlangs = $langs;
1343 if (
getDolGlobalInt(
'MAIN_MULTILANGS') && empty($newlang) && isset($this->param[
'langsmodels'])) {
1344 $newlang = $this->param[
'langsmodels'];
1346 if (!empty($newlang)) {
1347 $outputlangs =
new Translate(
"", $conf);
1348 $outputlangs->setDefaultLang($newlang);
1349 $outputlangs->load(
'other');
1352 print
"\n<!-- Begin message_form TICKET -->\n";
1354 $send_email =
GETPOST(
'send_email',
'int') ?
GETPOST(
'send_email',
'int') : 0;
1357 print
'<script nonce="'.getNonce().
'" type="text/javascript">
1358 jQuery(document).ready(function() {
1359 send_email=' . $send_email.
';
1361 if (!jQuery("#send_msg_email").is(":checked")) {
1362 jQuery("#send_msg_email").prop("checked", true).trigger("change");
1364 jQuery(".email_line").show();
1366 if (!jQuery("#private_message").is(":checked")) {
1367 jQuery("#private_message").prop("checked", true).trigger("change");
1369 jQuery(".email_line").hide();
1372 jQuery("#send_msg_email").click(function() {
1373 if(jQuery(this).is(":checked")) {
1374 if (jQuery("#private_message").is(":checked")) {
1375 jQuery("#private_message").prop("checked", false).trigger("change");
1377 jQuery(".email_line").show();
1380 jQuery(".email_line").hide();
1384 jQuery("#private_message").click(function() {
1385 if (jQuery(this).is(":checked")) {
1386 if (jQuery("#send_msg_email").is(":checked")) {
1387 jQuery("#send_msg_email").prop("checked", false).trigger("change");
1389 jQuery(".email_line").hide();
1395 print
'<form method="post" name="ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
1396 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1397 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
1398 print
'<input type="hidden" name="actionbis" value="add_message">';
1399 print
'<input type="hidden" name="backtopage" value="'.$this->backtopage.
'">';
1400 if (!empty($this->trackid)) {
1401 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
1403 print
'<input type="hidden" name="trackid" value="'.(empty($this->track_id) ?
'' : $this->track_id).
'">';
1404 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1406 foreach ($this->param as $key => $value) {
1407 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
1412 if (array_key_exists(
'models_id', $this->param)) {
1413 $model_id = $this->param[
"models_id"];
1414 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db, $this->param[
"models"], $user, $outputlangs, $model_id);
1417 $result = $formmail->fetchAllEMailTemplate(!empty($this->param[
"models"]) ? $this->param[
"models"] :
"", $user, $outputlangs);
1421 $modelmail_array = array();
1422 foreach ($formmail->lines_model as $line) {
1423 $modelmail_array[$line->id] = $line->label;
1426 print
'<table class="border" width="'.$width.
'">';
1429 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1430 $ticketstat =
new Ticket($this->
db);
1431 $res = $ticketstat->fetch(
'',
'', $this->track_id);
1433 print
'<tr><td></td><td>';
1434 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' : ($conf->global->TICKETS_MESSAGE_FORCE_MAIL?
'checked':
''));
1435 print
'<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
1436 print
'<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
1437 $texttooltip = $langs->trans(
"TicketMessageSendEmailHelp",
'{s1}');
1438 $texttooltip = str_replace(
'{s1}', $langs->trans(
'MarkMessageAsPrivate'), $texttooltip);
1439 print
' '.$form->textwithpicto(
'', $texttooltip, 1,
'help');
1443 if (!$user->socid) {
1444 print
'<tr><td></td><td>';
1445 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
1446 print
'<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
1447 print
'<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
1448 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1453 if (count($modelmail_array) > 0) {
1454 print
'<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'.
"\n";
1455 print $langs->trans(
'SelectMailModel').
': '.$formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], 1, 0,
"",
"", 0, 0, 0,
'',
'minwidth200');
1457 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1460 print
'<input type="submit" class="button" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
1461 print
'</div></td>';
1465 print
'<tr class="email_line"><td>'.$langs->trans(
'Subject').
'</td>';
1466 print
'<td><input type="text" class="text minwidth500" name="subject" value="['.$conf->global->MAIN_INFO_SOCIETE_NOM.
' - '.$langs->trans(
"Ticket").
' '.$ticketstat->ref.
'] '.$langs->trans(
'TicketNewMessage').
'" />';
1470 print
'<tr class="email_line"><td>'.$langs->trans(
'MailRecipients').
'</td><td>';
1473 $contacts = $ticketstat->getInfosTicketInternalContact();
1474 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact());
1479 if (is_array($contacts) && count($contacts) > 0) {
1480 foreach ($contacts as $key => $info_sendto) {
1481 if ($info_sendto[
'email'] !=
'') {
1482 $sendto[] =
dol_escape_htmltag(trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">").
' <small class="opacitymedium">('.
dol_escape_htmltag($info_sendto[
'libelle']).
")</small>";
1487 if ($ticketstat->origin_email && !in_array($ticketstat->origin_email, $sendto)) {
1488 $sendto[] =
dol_escape_htmltag($ticketstat->origin_email).
' <small class="opacitymedium">('.$langs->trans(
"TicketEmailOriginIssuer").
")</small>";
1491 if ($ticketstat->fk_soc > 0) {
1492 $ticketstat->socid = $ticketstat->fk_soc;
1493 $ticketstat->fetch_thirdparty();
1495 if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
1496 $sendto[] = $ticketstat->thirdparty->email.
' <small class="opacitymedium">('.$langs->trans(
'Customer').
')</small>';
1500 if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) {
1501 $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO.
' <small class="opacitymedium">(generic email)</small>';
1505 if (is_array($sendto) && count($sendto) > 0) {
1506 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
1507 print implode(
', ', $sendto);
1509 print
'<div class="warning">'.$langs->trans(
'WarningNoEMailsAdded').
' '.$langs->trans(
'TicketGoIntoContactTab').
'</div>';
1515 $uselocalbrowser =
false;
1537 if (!empty($this->withfile)) {
1539 $out .=
'<td width="180">'.$langs->trans(
"MailFile").
'</td>';
1542 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1543 $out .=
'<script nonce="'.getNonce().
'" type="text/javascript">';
1544 $out .=
'jQuery(document).ready(function () {';
1545 $out .=
' jQuery(".removedfile").click(function() {';
1546 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1549 $out .=
'</script>'.
"\n";
1551 if (count($listofpaths)) {
1552 foreach ($listofpaths as $key => $val) {
1553 $out .=
'<div id="attachfile_'.$key.
'">';
1554 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
1555 if (!$this->withfilereadonly) {
1556 $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.
'" />';
1558 $out .=
'<br></div>';
1563 if ($this->withfile == 2) {
1564 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1566 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1568 $out .=
"</td></tr>\n";
1575 $defaultmessage =
"";
1576 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1577 $defaultmessage = $arraydefaultmessage->content;
1579 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
1583 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1584 } elseif (!
dol_textishtml($defaultmessage) && isset($this->substit[
'__USER_SIGNATURE__']) &&
dol_textishtml($this->substit[
'__USER_SIGNATURE__'])) {
1585 $defaultmessage =
dol_nl2br($defaultmessage);
1588 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1592 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1593 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1596 print
'<tr><td colspan="2"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
1597 if ($user->hasRight(
"ticket",
"write") && !$user->socid) {
1598 $texttooltip = $langs->trans(
"TicketMessageHelp");
1600 $texttooltip .=
'<br><br>'.$langs->trans(
"ForEmailMessageWillBeCompletedWith").
'...';
1603 $texttooltip .=
'<br><u>'.$langs->trans(
"TicketMessageMailIntro").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_INTRO');
1606 $texttooltip .=
'<br><br><u>'.$langs->trans(
"TicketMessageMailFooter").
'</u><br>'.
getDolGlobalString(
'TICKET_MESSAGE_MAIL_SIGNATURE');
1608 print
$form->textwithpicto(
'', $texttooltip, 1,
'help');
1610 print
'</label></td></tr>';
1613 print
'<tr><td colspan="2">';
1615 $toolbarname =
'dolibarr_notes';
1616 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1617 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5, 70);
1618 $doleditor->Create();
1637 print
'<center><br>';
1638 print
'<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans(
"Add").
'" />';
1639 if ($this->withcancel) {
1640 print
" ";
1641 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1643 print
"</center>\n";
1645 print
'<input type="hidden" name="page_y">'.
"\n";
1648 print
"<!-- End form TICKET -->\n";