27 require_once DOL_DOCUMENT_ROOT.
"/core/class/html.form.class.php";
28 require_once DOL_DOCUMENT_ROOT.
"/core/class/html.formmail.class.php";
29 require_once DOL_DOCUMENT_ROOT.
"/core/class/html.formprojet.class.php";
31 if (!class_exists(
'FormCompany')) {
32 include DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
58 public $fk_user_create;
74 public $withfilereadonly;
80 public $withtitletopic;
81 public $withtopicreadonly;
83 public $withfromsocid;
84 public $withfromcontactid;
85 public $withnotifytiersatcreate;
86 public $withusercreate;
87 public $withcreatereadonly;
94 public $category_code;
95 public $severity_code;
102 public $substit = array();
103 public $param = array();
122 $this->action =
'add';
125 $this->withfromsocid = 0;
126 $this->withfromcontactid = 0;
129 $this->withnotifytiersatcreate = 0;
130 $this->withusercreate = 1;
131 $this->withcreatereadonly = 1;
132 $this->withemail = 0;
134 $this->withextrafields = 0;
148 public function showForm($withdolfichehead = 0, $mode =
'edit', $public = 0,
Contact $with_contact =
null, $action =
'')
150 global $conf, $langs, $user, $hookmanager;
153 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
157 $ticketstatic =
new Ticket($this->
db);
160 if (!empty($this->withfromsocid) && $this->withfromsocid > 0) {
161 $soc->fetch($this->withfromsocid);
164 $ticketstat =
new Ticket($this->
db);
167 $extrafields->fetch_name_optionals_label($ticketstat->table_element);
169 print
"\n<!-- Begin form TICKET -->\n";
171 if ($withdolfichehead) {
175 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"] :
"").
'">';
176 print
'<input type="hidden" name="token" value="'.newToken().
'">';
177 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
178 print
'<input type="hidden" name="trackid" value="'.$this->trackid.
'">';
179 foreach ($this->param as $key => $value) {
180 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
182 print
'<input type="hidden" name="fk_user_create" value="'.$this->fk_user_create.
'">';
184 print
'<table class="border centpercent">';
186 if ($this->withref) {
188 $defaultref = $ticketstat->getDefaultRef();
189 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Ref").
'</span></td><td>';
190 print
'<input type="text" name="ref" value="'.dol_escape_htmltag(
GETPOST(
"ref",
'alpha') ?
GETPOST(
"ref",
'alpha') : $defaultref).
'">';
196 if ($this->withemail) {
197 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"Email").
'</span></label></td><td>';
198 print
'<input class="text minwidth200" id="email" name="email" value="'.$email.
'" autofocus>';
203 $html_contact_search =
'';
204 $html_contact_search .=
'<tr id="contact_search_line">';
205 $html_contact_search .=
'<td class="titlefield">';
206 $html_contact_search .=
'<label for="contact"><span class="fieldrequired">' . $langs->trans(
'Contact') .
'</span></label>';
207 $html_contact_search .=
'<input type="hidden" id="contact_id" name="contact_id" value="" />';
208 $html_contact_search .=
'</td>';
209 $html_contact_search .=
'<td id="contact_search_result"></td>';
210 $html_contact_search .=
'</tr>';
211 print $html_contact_search;
213 $html_contact_lastname =
'';
214 $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>';
215 $html_contact_lastname .=
'<input type="text" id="contact_lastname" name="contact_lastname" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_lastname') ?
GETPOST(
'contact_lastname',
'alphanohtml') :
'') .
'" />';
216 $html_contact_lastname .=
'</td></tr>';
217 print $html_contact_lastname;
219 $html_contact_firstname =
'';
220 $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>';
221 $html_contact_firstname .=
'<input type="text" id="contact_firstname" name="contact_firstname" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_firstname') ?
GETPOST(
'contact_firstname',
'alphanohtml') :
'') .
'" />';
222 $html_contact_firstname .=
'</td></tr>';
223 print $html_contact_firstname;
225 $html_company_name =
'';
226 $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>';
227 $html_company_name .=
'<input type="text" id="company_name" name="company_name" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'company_name') ?
GETPOST(
'company_name',
'alphanohtml') :
'') .
'" />';
228 $html_company_name .=
'</td></tr>';
229 print $html_company_name;
231 $html_contact_phone =
'';
232 $html_contact_phone .=
'<tr id="contact_phone_line" class="contact_field"><td><label for="contact_phone"><span>' . $langs->trans(
'Phone') .
'</span></label></td><td>';
233 $html_contact_phone .=
'<input type="text" id="contact_phone" name="contact_phone" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_phone') ?
GETPOST(
'contact_phone',
'alphanohtml') :
'') .
'" />';
234 $html_contact_phone .=
'</td></tr>';
235 print $html_contact_phone;
238 $langs->load(
'errors');
239 print
'<script type="text/javascript">
240 jQuery(document).ready(function() {
241 var contact = jQuery.parseJSON("'.dol_escape_js(json_encode($with_contact), 2).
'");
242 jQuery("#contact_search_line").hide();
244 if (contact.id > 0) {
245 jQuery("#contact_search_line").show();
246 jQuery("#contact_id").val(contact.id);
247 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
248 jQuery(".contact_field").hide();
250 jQuery(".contact_field").show();
254 jQuery("#email").change(function() {
255 jQuery("#contact_search_line").show();
256 jQuery("#contact_search_result").html("'.
dol_escape_js($langs->trans(
'Select2SearchInProgress')).
'");
257 jQuery("#contact_id").val("");
258 jQuery("#contact_lastname").val("");
259 jQuery("#contact_firstname").val("");
260 jQuery("#company_name").val("");
261 jQuery("#contact_phone").val("");
266 action: "getContacts",
267 email: jQuery("#email").val()
270 if (response.error) {
271 jQuery("#contact_search_result").html("<span class=\"error\">"+response.error+"</span>");
273 var contact_list = response.contacts;
274 if (contact_list.length == 1) {
275 var contact = contact_list[0];
276 jQuery("#contact_id").val(contact.id);
277 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
278 jQuery(".contact_field").hide();
279 } else if (contact_list.length <= 0) {
280 jQuery("#contact_search_line").hide();
281 jQuery(".contact_field").show();
285 ).fail(function(jqxhr, textStatus, error) {
286 var error_msg = "'.
dol_escape_js($langs->trans(
'ErrorAjaxRequestFailed')).
'"+" ["+textStatus+"] : "+error;
287 jQuery("#contact_search_result").html("<span class=\"error\">"+error_msg+"</span>");
297 if (isset($this->param[
'origin']) && $this->param[
'originid'] > 0) {
299 $element = $subelement = $this->param[
'origin'];
301 if (preg_match(
'/^([^_]+)_([^_]+)/i', $this->param[
'origin'], $regs)) {
303 $subelement = $regs[2];
307 $classname = ucfirst($subelement);
308 $objectsrc =
new $classname($this->
db);
309 $objectsrc->fetch(
GETPOST(
'originid',
'int'));
311 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
312 $objectsrc->fetch_lines();
315 $objectsrc->fetch_thirdparty();
316 $newclassname = $classname;
317 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td colspan="2"><input name="'.$subelement.
'id" value="'.
GETPOST(
'originid').
'" type="hidden" />'.$objectsrc->getNomUrl(1).
'</td></tr>';
321 print
'<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans(
"TicketTypeRequest").
'</span></label></td><td>';
326 print
'<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans(
"TicketCategory").
'</span></label></td><td>';
329 $filter =
'public=1';
331 $this->
selectGroupTickets((
GETPOST(
'category_code') ?
GETPOST(
'category_code') : $this->category_code),
'category_code', $filter, 2, 0, 0, 0,
'minwidth200');
335 print
'<tr><td><span class=""><label for="selectseverity_code">'.$langs->trans(
"TicketSeverity").
'</span></label></td><td>';
340 if ($this->withtitletopic) {
341 print
'<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans(
"Subject").
'</span></label></td><td>';
344 if ($this->withtopicreadonly) {
345 print $langs->trans(
'SubjectAnswerToTicket').
' '.$this->topic_title;
348 if (isset($this->withreadid) && $this->withreadid > 0) {
349 $subject = $langs->trans(
'SubjectAnswerToTicket').
' '.$this->withreadid.
' : '.$this->topic_title.
'';
351 $subject =
GETPOST(
'subject',
'alpha');
353 print
'<input class="text minwidth500" id="subject" name="subject" value="'.$subject.
'" autofocus />';
358 if (!empty($conf->knowledgemanagement->enabled)) {
360 print
'<tr id="KWwithajax"></tr>';
361 print
'<!-- Script to manage change of ticket group -->
363 jQuery(document).ready(function() {
364 function groupticketchange(){
365 console.log("We called groupticketchange, so we try to load list KM linked to event");
366 $("#KWwithajax").html("");
367 idgroupticket = $("#selectcategory_code").val();
369 console.log("We have selected id="+idgroupticket);
371 if (idgroupticket != "") {
372 $.ajax({ url: \''.DOL_URL_ROOT.
'/core/ajax/fetchKnowledgeRecord.php\',
373 data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.
newToken().
'\', lang:\
''.$langs->defaultlang.
'\'},
375 success: function(response) {
377 console.log("We received response "+response);
378 response = JSON.parse(response)
379 for (key in response) {
380 answer = response[key].answer;
381 urllist += \'<li><a href="#" title="\'+response[key].title+\'" class="button_KMpopup" data-html="\'+answer+\'">\' +response[key].title+\'</a></li>\';
384 $("#KWwithajax").html(\'<td>'.$langs->trans(
"KMFoundForTicketGroup").
'</td><td><ul>\'+urllist+\'</ul></td>\');
385 $("#KWwithajax").show();
386 $(".button_KMpopup").on("click",function(){
387 console.log("Open popup with jQuery(...).dialog() with KM article")
388 var $dialog = $("<div></div>").html($(this).attr("data-html"))
392 height: (window.innerHeight - 150),
394 title: $(this).attr("title"),
396 $dialog.dialog("open");
397 console.log($dialog);
401 error : function(output) {
402 console.error("Error on Fetch of KM articles");
407 $("#selectcategory_code").on("change",function() { groupticketchange(); });
408 if ($("#selectcategory_code").val() != "") {
417 print
'<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span></label></td><td>';
420 $toolbarname =
'dolibarr_notes';
421 if ($this->ispublic) {
422 $toolbarname =
'dolibarr_details';
423 print
'<div class="warning">'.($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans(
'TicketPublicPleaseBeAccuratelyDescribe')).
'</div>';
425 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
426 $uselocalbrowser =
true;
427 $doleditor =
new DolEditor(
'message', $msg,
'100%', 230, $toolbarname,
'In',
true, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_TICKET'), ROWS_8,
'90%');
428 $doleditor->Create();
431 if ($public && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) {
432 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
433 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"SecurityCode").
'</span></label></td><td>';
434 print
'<span class="span-icon-security inline-block">';
435 print
'<input id="securitycode" placeholder="'.$langs->trans(
"SecurityCode").
'" class="flat input-icon-security width125" type="text" maxlength="5" name="code" tabindex="3" />';
437 print
'<span class="nowrap inline-block">';
438 print
'<img class="inline-block valignmiddle" src="'.DOL_URL_ROOT.
'/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />';
439 print
'<a class="inline-block valignmiddle" href="" tabindex="4" data-role="button">'.img_picto($langs->trans(
"Refresh"),
'refresh',
'id="captcha_refresh_img"').
'</a>';
446 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
447 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_TICKET,
'',
'parent', 64, 0, 1);
449 if (count($cate_arbo)) {
451 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
452 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
458 if (!empty($this->withfile)) {
460 $listofpaths = array();
461 $listofnames = array();
462 $listofmimes = array();
463 if (!empty($_SESSION[
"listofpaths"])) {
464 $listofpaths = explode(
';', $_SESSION[
"listofpaths"]);
467 if (!empty($_SESSION[
"listofnames"])) {
468 $listofnames = explode(
';', $_SESSION[
"listofnames"]);
471 if (!empty($_SESSION[
"listofmimes"])) {
472 $listofmimes = explode(
';', $_SESSION[
"listofmimes"]);
476 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
479 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
480 $out .=
'<script type="text/javascript">';
481 $out .=
'jQuery(document).ready(function () {';
482 $out .=
' jQuery(".removedfile").click(function() {';
483 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
486 $out .=
'</script>'.
"\n";
487 if (count($listofpaths)) {
488 foreach ($listofpaths as $key => $val) {
489 $out .=
'<div id="attachfile_'.$key.
'">';
490 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
491 if (!$this->withfilereadonly) {
492 $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.
'" />';
494 $out .=
'<br></div>';
497 $out .= $langs->trans(
"NoAttachedFiles").
'<br>';
499 if ($this->withfile == 2) {
501 $maxmin = $maxfilesizearray[
'maxmin'];
503 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
505 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
507 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="addfile" name="addfile" value="'.$langs->trans(
"MailingAddFile").
'" />';
509 $out .=
"</td></tr>\n";
515 if ($this->withusercreate > 0 && $this->fk_user_create) {
516 print
'<tr><td class="titlefield">'.$langs->trans(
"CreatedBy").
'</td><td>';
517 $langs->load(
"users");
518 $fuser =
new User($this->
db);
520 if ($this->withcreatereadonly) {
521 if ($res = $fuser->fetch($this->fk_user_create)) {
522 print $fuser->getNomUrl(1);
526 print
"</td></tr>\n";
530 if ($this->withcompany) {
532 if (empty($user->socid)) {
534 print
'<tr><td class="titlefield">'.$langs->trans(
"ThirdParty").
'</td><td>';
536 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
537 print
img_picto(
'',
'company',
'class="paddingright"');
538 print
$form->select_company($this->withfromsocid,
'socid',
'', 1, 1,
'', $events, 0,
'minwidth200');
540 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
542 print
'<script type="text/javascript">
543 $(document).ready(function () {
544 jQuery("#'.$htmlname.
'").change(function () {
545 var obj = '.json_encode($events).
';
546 $.each(obj, function(key,values) {
547 if (values.method.length) {
548 runJsCodeForEvent'.$htmlname.
'(values);
553 function runJsCodeForEvent'.$htmlname.
'(obj) {
554 console.log("Run runJsCodeForEvent'.$htmlname.
'");
555 var id = $("#'.$htmlname.
'").val();
556 var method = obj.method;
558 var htmlname = obj.htmlname;
559 var showempty = obj.showempty;
568 $.each(obj.params, function(key,action) {
570 var num = response.num;
572 $("#" + key).removeAttr(action);
574 $("#" + key).attr(action, action);
578 $("select#" + htmlname).html(response.value);
580 var selecthtml_str = response.value;
581 var selecthtml_dom=$.parseHTML(selecthtml_str);
582 if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
583 $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
586 $("#inputautocomplete"+htmlname).val("");
588 $("select#" + htmlname).change(); /* Trigger event change */
597 print
'<tr><td>'.$langs->trans(
"Contact").
'</td><td>';
599 $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
600 print
img_picto(
'',
'contact',
'class="paddingright"');
601 print
$form->selectcontacts($selectedCompany, $this->withfromcontactid,
'contactid', 3,
'',
'', 0,
'minwidth200');
603 $formcompany->selectTypeContact($ticketstatic,
'',
'type',
'external',
'', 0,
'maginleftonly');
606 print
'<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.
'"/></td>';
607 print
'<td><input type="hidden" name="contactid" value="'.$user->contact_id.
'"/></td>';
608 print
'<td><input type="hidden" name="type" value="Z"/></td></tr>';
612 if (empty($this->ispublic)) {
613 print
'<tr><td><label for="notify_tiers_at_create">'.$langs->trans(
"TicketNotifyTiersAtCreation").
'</label></td><td>';
614 print
'<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ?
' checked="checked"' :
'').
'>';
620 print $langs->trans(
"AssignedTo");
622 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
623 print
$form->select_dolusers(
GETPOST(
'fk_user_assign',
'int'),
'fk_user_assign', 1);
628 if ($subelement !=
'project') {
629 if (!empty($conf->project->enabled) && !$this->ispublic) {
631 print
'<tr><td><label for="project"><span class="">'.$langs->trans(
"Project").
'</span></label></td><td>';
632 print
img_picto(
'',
'project').$formproject->select_projects(-1,
GETPOST(
'projectid',
'int'),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
638 $parameters = array();
639 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $ticketstat, $action);
640 if (empty($reshook)) {
641 print $ticketstat->showOptionals($extrafields,
'create');
646 if ($withdolfichehead) {
652 print
$form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"CreateTicket"), ($this->withcancel ?
"Cancel" :
""));
664 print
'<input type="hidden" name="page_y">'.
"\n";
667 print
"<!-- End form TICKET -->\n";
683 public function selectTypesTickets($selected =
'', $htmlname =
'tickettype', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
685 global $langs, $user;
687 $ticketstat =
new Ticket($this->
db);
689 dol_syslog(get_class($this).
"::select_types_tickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
691 $filterarray = array();
693 if ($filtertype !=
'' && $filtertype !=
'-1') {
694 $filterarray = explode(
',', $filtertype);
697 $ticketstat->loadCacheTypesTickets();
699 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
701 print
'<option value=""> </option>';
704 if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
705 foreach ($ticketstat->cache_types_tickets as $id => $arraytypes) {
707 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
712 if ($empty && empty($arraytypes[
'code'])) {
717 print
'<option value="'.$id.
'"';
721 print
'<option value="'.$arraytypes[
'code'].
'"';
725 print
'<option value="'.$arraytypes[
'code'].
'"';
729 print
'<option value="'.$id.
'"';
733 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraytypes[
'code']) {
734 print
' selected="selected"';
735 } elseif ($selected == $id) {
736 print
' selected="selected"';
737 } elseif ($arraytypes[
'use_default'] ==
"1" && !$selected && !$empty) {
738 print
' selected="selected"';
744 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
745 } elseif ($format == 1) {
746 $value = $arraytypes[
'code'];
747 } elseif ($format == 2) {
748 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
749 } elseif ($format == 3) {
750 $value = $arraytypes[
'code'];
758 if ($user->admin && !$noadmininfo) {
759 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
780 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $use_multilevel = 0, $outputlangs =
null)
782 global $conf, $langs, $user;
784 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
786 if (is_null($outputlangs) || !is_object($outputlangs)) {
787 $outputlangs = $langs;
789 $outputlangs->load(
"ticket");
791 $ticketstat =
new Ticket($this->
db);
792 $ticketstat->loadCacheCategoriesTickets();
794 if ($use_multilevel <= 0) {
795 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
797 print
'<option value=""> </option>';
800 if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
801 foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
803 if ($filtertype ==
'public=1') {
804 if (empty($arraycategories[
'public'])) {
810 if ($empty && empty($arraycategories[
'code'])) {
814 $label = ($arraycategories[
'label'] !=
'-' ? $arraycategories[
'label'] :
'');
815 if ($outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']) != (
"TicketCategoryShort".$arraycategories[
'code'])) {
816 $label = $outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']);
817 } elseif ($outputlangs->trans($arraycategories[
'code']) != $arraycategories[
'code']) {
818 $label = $outputlangs->trans($arraycategories[
'code']);
822 print
'<option value="'.$id.
'"';
826 print
'<option value="'.$arraycategories[
'code'].
'"';
830 print
'<option value="'.$arraycategories[
'code'].
'"';
834 print
'<option value="'.$id.
'"';
838 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
839 print
' selected="selected"';
840 } elseif ($selected == $id) {
841 print
' selected="selected"';
842 } elseif ($arraycategories[
'use_default'] ==
"1" && !$selected && !$empty) {
843 print
' selected="selected"';
849 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
853 $value = $arraycategories[
'code'];
857 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
861 $value = $arraycategories[
'code'];
864 print $value ? $value :
' ';
869 if ($user->admin && !$noadmininfo) {
870 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
874 } elseif ($htmlname!=
'') {
875 $selectedgroups = array();
877 $groupticket=
GETPOST($htmlname,
'aZ09');
878 $child_id=
GETPOST($htmlname.
'_child_id',
'aZ09')?
GETPOST($htmlname.
'_child_id',
'aZ09'):0;
879 if (!empty($groupticket)) {
880 $tmpgroupticket = $groupticket;
881 $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).
"'";
884 $obj = $this->
db->fetch_object(
$resql);
885 $selectedgroups[] = $obj->code;
886 while ($obj->fk_parent > 0) {
887 $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).
"'";
890 $obj = $this->
db->fetch_object(
$resql);
891 $selectedgroups[] = $obj->code;
896 $arrayidused = array();
897 $arrayidusedconcat = array();
898 $arraycodenotparent = array();
899 $arraycodenotparent[] =
"";
901 $stringtoprint =
'<span class="supportemailfield bold">'.$langs->trans(
"GroupOfTicket").
'</span> ';
902 $stringtoprint .=
'<select id ="'.$htmlname.
'" class="minwidth500" child_id="0">';
903 $stringtoprint .=
'<option value=""> </option>';
905 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
906 $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";
907 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
908 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
909 if ($filtertype ==
'public=1') {
910 $sql .=
" AND ctc.public = 1";
912 $sql .=
" AND ctc.fk_parent = 0";
913 $sql .= $this->
db->order(
'ctc.pos',
'ASC');
917 $num_rows_level0 = $this->
db->num_rows(
$resql);
919 while ($i < $num_rows_level0) {
920 $obj = $this->
db->fetch_object(
$resql);
922 $label = ($obj->label !=
'-' ? $obj->label :
'');
923 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
924 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
925 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
926 $label = $outputlangs->trans($obj->code);
929 $grouprowid = $obj->rowid;
930 $groupvalue = $obj->code;
931 $grouplabel = $label;
933 $isparent = $obj->isparent;
934 if (is_array($selectedgroups)) {
935 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
937 $iselected = $groupticket == $obj->code ?
'selected':
'';
940 if ($isparent ==
'NOTPARENT') {
941 $arraycodenotparent[] = $groupvalue;
943 $arrayidused[] = $grouprowid;
944 $arrayidusedconcat[] = $grouprowid;
951 if (count($arrayidused) == 1) {
952 return '<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.
dol_escape_htmltag($groupvalue).
'">';
954 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'_select" class="maxwidth500 minwidth400">';
955 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'_child_id" id="'.$htmlname.
'_select_child_id" class="maxwidth500 minwidth400">';
957 $stringtoprint .=
'</select> ';
960 while ($levelid <= $use_multilevel) {
961 $tabscript = array();
962 $stringtoprint .=
'<select id ="'.$htmlname.
'_child_'.$levelid.
'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.
'">';
963 $stringtoprint .=
'<option value=""> </option>';
965 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
966 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
967 $sql .=
" JOIN ".$this->db->prefix().
"c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
968 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
969 $sql .=
" AND ctc.rowid NOT IN (".$this->db->sanitize(join(
',', $arrayidusedconcat)).
")";
971 if ($filtertype ==
'public=1') {
972 $sql .=
" AND ctc.public = 1";
975 if (!empty($arrayidused)) {
976 $sql .=
" AND ctc.fk_parent IN ( ";
977 foreach ($arrayidused as $idused) {
978 $sql .= $idused.
", ";
980 $sql = substr($sql, 0, -2);
984 $sql .= $this->
db->order(
'ctc.pos',
'ASC');
988 $num_rows = $this->
db->num_rows(
$resql);
990 $arrayidused=array();
991 while ($i < $num_rows) {
992 $obj = $this->
db->fetch_object(
$resql);
994 $label = ($obj->label !=
'-' ? $obj->label :
'');
995 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
996 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
997 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
998 $label = $outputlangs->trans($obj->code);
1001 $grouprowid = $obj->rowid;
1002 $groupvalue = $obj->code;
1003 $grouplabel = $label;
1004 $isparent = $obj->isparent;
1005 $fatherid = $obj->fk_parent;
1006 $arrayidused[] = $grouprowid;
1007 $arrayidusedconcat[] = $grouprowid;
1008 $groupcodefather = $obj->codefather;
1009 if ($isparent ==
'NOTPARENT') {
1010 $arraycodenotparent[] = $groupvalue;
1012 if (is_array($selectedgroups)) {
1013 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
1015 $iselected = $groupticket == $obj->code ?
'selected':
'';
1018 if (empty($tabscript[$groupcodefather])) {
1019 $tabscript[$groupcodefather] =
'if ($("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid-1:
'').
'").val() == "'.
dol_escape_js($groupcodefather).
'"){
1021 console.log("We show childs tickets of '.$groupcodefather.
' group ticket")
1024 console.log("We hide childs tickets of '.$groupcodefather.
' group ticket")
1033 $stringtoprint .=
'</select>';
1035 $stringtoprint .=
'<script>';
1036 $stringtoprint .=
'arraynotparents = '.json_encode($arraycodenotparent).
';';
1037 $stringtoprint .=
'if (arraynotparents.includes($("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid-1:
'').
'").val())){
1038 console.log("'.$htmlname.
'_child_'.$levelid.
'")
1039 if($("#'.$htmlname.
'_child_'.$levelid.
'").val() == "" && ($("#'.$htmlname.
'_child_'.$levelid.
'").attr("child_id")>'.$child_id.
')){
1040 $("#'.$htmlname.
'_child_'.$levelid.
'").hide();
1041 console.log("We hide '.$htmlname.
'_child_'.$levelid.
' input")
1043 if(arraynotparents.includes("'.$groupticket.
'") && '.$child_id.
' == 0){
1044 $("#ticketcategory_select_child_id").val($("#'.$htmlname.
'").attr("child_id"))
1045 $("#ticketcategory_select").val($("#'.$htmlname.
'").val()) ;
1046 console.log("We choose '.$htmlname.
' input and reload hidden input");
1049 $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid-1:
'').
'").change(function() {
1050 child_id = $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid:
'').
'").attr("child_id");
1052 /* Change of value to select this value*/
1053 if (arraynotparents.includes($(this).val()) || $(this).attr("child_id") == '.$use_multilevel.
') {
1054 $("#ticketcategory_select").val($(this).val());
1055 $("#ticketcategory_select_child_id").val($(this).attr("child_id")) ;
1056 console.log("We choose to select "+ $(this).val());
1058 if ($("#'.$htmlname.
'_child_'.$levelid.
' option").length <= 1) {
1059 $("#ticketcategory_select").val($(this).val());
1060 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1061 console.log("We choose to select "+ $(this).val() + " and next combo has no item, so we keep this selection");
1063 console.log("We choose to select "+ $(this).val() + " but next combo has some item, so we clean selected item");
1064 $("#ticketcategory_select").val("");
1065 $("#ticketcategory_select_child_id").val("");
1069 console.log("We select a new value into combo child_id="+child_id);
1071 /* Hide all selected box that are child of the one modified */
1072 $(".groupticketchild").each(function(){
1073 if ($(this).attr("child_id") > child_id) {
1074 console.log("hide child_id="+$(this).attr("child_id"));
1080 /* Now we enable the next combo */
1081 $("#'.$htmlname.
'_child_'.$levelid.
'").val("");
1082 if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.
'_child_'.$levelid.
' option").length > 1) {
1083 console.log($("#'.$htmlname.
'_child_'.$levelid.
' option").length);
1084 $("#'.$htmlname.
'_child_'.$levelid.
'").show()
1086 $("#'.$htmlname.
'_child_'.$levelid.
'").hide()
1090 foreach ($tabscript as $script) {
1091 $stringtoprint .= $script;
1093 $stringtoprint .=
'})';
1094 $stringtoprint .=
'</script>';
1096 $stringtoprint .=
'<script>';
1097 $stringtoprint .=
'$("#'.$htmlname.
'_child_'.$use_multilevel.
'").change(function() {
1098 $("#ticketcategory_select").val($(this).val());
1099 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1100 console.log($("#ticketcategory_select").val());
1102 $stringtoprint .=
'</script>';
1105 return $stringtoprint;
1122 public function selectSeveritiesTickets($selected =
'', $htmlname =
'ticketseverity', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
1124 global $langs, $user;
1126 $ticketstat =
new Ticket($this->
db);
1128 dol_syslog(get_class($this).
"::selectSeveritiesTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1130 $filterarray = array();
1132 if ($filtertype !=
'' && $filtertype !=
'-1') {
1133 $filterarray = explode(
',', $filtertype);
1136 $ticketstat->loadCacheSeveritiesTickets();
1138 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1140 print
'<option value=""> </option>';
1143 if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
1144 foreach ($ticketstat->cache_severity_tickets as $id => $arrayseverities) {
1146 if (count($filterarray) && !in_array($arrayseverities[
'type'], $filterarray)) {
1151 if ($empty && empty($arrayseverities[
'code'])) {
1156 print
'<option value="'.$id.
'"';
1160 print
'<option value="'.$arrayseverities[
'code'].
'"';
1164 print
'<option value="'.$arrayseverities[
'code'].
'"';
1168 print
'<option value="'.$id.
'"';
1172 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arrayseverities[
'code']) {
1173 print
' selected="selected"';
1174 } elseif ($selected == $id) {
1175 print
' selected="selected"';
1176 } elseif ($arrayseverities[
'use_default'] ==
"1" && !$selected && !$empty) {
1177 print
' selected="selected"';
1182 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1186 $value = $arrayseverities[
'code'];
1190 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1194 $value = $arrayseverities[
'code'];
1197 print $value ? $value :
' ';
1202 if ($user->admin && !$noadmininfo) {
1203 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1218 global $conf, $user;
1219 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1222 $vardir = $conf->user->dir_output.
"/".$user->id;
1223 $upload_dir = $vardir.
'/temp/';
1224 if (is_dir($upload_dir)) {
1228 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1229 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
1230 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
1231 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
1242 global $conf, $langs, $user, $hookmanager,
$form, $mysoc;
1245 $addfileaction =
'addfile';
1247 if (!is_object(
$form)) {
1252 $langs->loadLangs(array(
'other',
'mails'));
1255 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1256 $this->clear_attached_files();
1260 $outputlangs = $langs;
1262 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
1263 $newlang = $this->param[
'langsmodels'];
1265 if (!empty($newlang)) {
1266 $outputlangs =
new Translate(
"", $conf);
1267 $outputlangs->setDefaultLang($newlang);
1268 $outputlangs->load(
'other');
1272 $arraydefaultmessage = -1;
1273 if ($this->param[
'models'] !=
'none') {
1275 if (array_key_exists(
'models_id', $this->param)) {
1276 $model_id = $this->param[
"models_id"];
1279 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db, $this->param[
"models"], $user, $outputlangs, $model_id);
1283 $listofpaths = array();
1284 $listofnames = array();
1285 $listofmimes = array();
1286 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1288 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelselected') &&
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1289 if (!empty($arraydefaultmessage->joinfiles) && !empty($this->param[
'fileinit']) && is_array($this->param[
'fileinit'])) {
1290 foreach ($this->param[
'fileinit'] as $file) {
1291 $formmail->add_attached_files($file, basename($file),
dol_mimetype($file));
1296 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
1297 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
1299 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
1300 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
1302 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
1303 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
1307 $outputlangs = $langs;
1309 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
1310 $newlang = $this->param[
'langsmodels'];
1312 if (!empty($newlang)) {
1313 $outputlangs =
new Translate(
"", $conf);
1314 $outputlangs->setDefaultLang($newlang);
1315 $outputlangs->load(
'other');
1318 print
"\n<!-- Begin message_form TICKET -->\n";
1320 $send_email =
GETPOST(
'send_email',
'int') ?
GETPOST(
'send_email',
'int') : 0;
1323 print
'<script type="text/javascript">
1324 jQuery(document).ready(function() {
1325 send_email=' . $send_email.
';
1327 if (!jQuery("#send_msg_email").is(":checked")) {
1328 jQuery("#send_msg_email").prop("checked", true).trigger("change");
1330 jQuery(".email_line").show();
1332 if (!jQuery("#private_message").is(":checked")) {
1333 jQuery("#private_message").prop("checked", true).trigger("change");
1335 jQuery(".email_line").hide();
1338 jQuery("#send_msg_email").click(function() {
1339 if(jQuery(this).is(":checked")) {
1340 if (jQuery("#private_message").is(":checked")) {
1341 jQuery("#private_message").prop("checked", false).trigger("change");
1343 jQuery(".email_line").show();
1346 jQuery(".email_line").hide();
1350 jQuery("#private_message").click(function() {
1351 if (jQuery(this).is(":checked")) {
1352 if (jQuery("#send_msg_email").is(":checked")) {
1353 jQuery("#send_msg_email").prop("checked", false).trigger("change");
1355 jQuery(".email_line").hide();
1361 print
'<form method="post" name="ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
1362 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1363 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
1364 print
'<input type="hidden" name="actionbis" value="add_message">';
1365 print
'<input type="hidden" name="backtopage" value="'.$this->backtopage.
'">';
1366 foreach ($this->param as $key => $value) {
1367 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
1372 if (array_key_exists(
'models_id', $this->param)) {
1373 $model_id = $this->param[
"models_id"];
1374 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db, $this->param[
"models"], $user, $outputlangs, $model_id);
1377 $result = $formmail->fetchAllEMailTemplate($this->param[
"models"], $user, $outputlangs);
1381 $modelmail_array = array();
1382 foreach ($formmail->lines_model as $line) {
1383 $modelmail_array[$line->id] = $line->label;
1386 print
'<table class="border" width="'.$width.
'">';
1389 if ($user->rights->ticket->write && !$user->socid) {
1390 $ticketstat =
new Ticket($this->
db);
1391 $res = $ticketstat->fetch(
'',
'', $this->track_id);
1393 print
'<tr><td></td><td>';
1394 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' : ($conf->global->TICKETS_MESSAGE_FORCE_MAIL?
'checked':
''));
1395 print
'<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
1396 print
'<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
1400 if (count($modelmail_array) > 0) {
1401 print
'<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'.
"\n";
1402 print $langs->trans(
'SelectMailModel').
': '.$formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], 1, 0,
"",
"", 0, 0, 0,
'',
'minwidth200');
1404 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1407 print
'<input type="submit" class="button" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
1408 print
'</div></td>';
1412 if (!$user->socid) {
1413 print
'<tr><td></td><td>';
1414 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
1415 print
'<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
1416 print
'<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
1417 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1422 print
'<tr class="email_line"><td>'.$langs->trans(
'Subject').
'</td>';
1423 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').
'" />';
1427 print
'<tr class="email_line"><td>'.$langs->trans(
'MailRecipients').
'</td><td>';
1430 $contacts = $ticketstat->getInfosTicketInternalContact();
1431 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact());
1436 if (is_array($contacts) && count($contacts) > 0) {
1437 foreach ($contacts as $key => $info_sendto) {
1438 if ($info_sendto[
'email'] !=
'') {
1439 $sendto[] =
dol_escape_htmltag(trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">").
' <small class="opacitymedium">('.
dol_escape_htmltag($info_sendto[
'libelle']).
")</small>";
1444 if ($ticketstat->origin_email && !in_array($ticketstat->origin_email, $sendto)) {
1445 $sendto[] =
dol_escape_htmltag($ticketstat->origin_email).
' <small class="opacitymedium">('.$langs->trans(
"TicketEmailOriginIssuer").
")</small>";
1448 if ($ticketstat->fk_soc > 0) {
1449 $ticketstat->socid = $ticketstat->fk_soc;
1450 $ticketstat->fetch_thirdparty();
1452 if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
1453 $sendto[] = $ticketstat->thirdparty->email.
' <small class="opacitymedium">('.$langs->trans(
'Customer').
')</small>';
1457 if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) {
1458 $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO.
' <small class="opacitymedium">(generic email)</small>';
1462 if (is_array($sendto) && count($sendto) > 0) {
1463 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
1464 print implode(
', ', $sendto);
1466 print
'<div class="warning">'.$langs->trans(
'WarningNoEMailsAdded').
' '.$langs->trans(
'TicketGoIntoContactTab').
'</div>';
1472 $uselocalbrowser =
false;
1476 if ($user->rights->ticket->write && !$user->socid) {
1477 $mail_intro =
GETPOST(
'mail_intro') ?
GETPOST(
'mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO;
1478 print
'<tr class="email_line"><td><label for="mail_intro">';
1479 print
$form->textwithpicto($langs->trans(
"TicketMessageMailIntro"), $langs->trans(
"TicketMessageMailIntroHelp"), 1,
'help');
1483 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1485 $doleditor =
new DolEditor(
'mail_intro', $mail_intro,
'100%', 90,
'dolibarr_details',
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_2, 70);
1487 $doleditor->Create();
1493 $defaultmessage =
"";
1494 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1495 $defaultmessage = $arraydefaultmessage->content;
1497 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
1501 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1503 $defaultmessage =
dol_nl2br($defaultmessage);
1506 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1510 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1511 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1514 print
'<tr><td class="tdtop"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
1515 if ($user->rights->ticket->write && !$user->socid) {
1516 print
$form->textwithpicto(
'', $langs->trans(
"TicketMessageHelp"), 1,
'help');
1518 print
'</label></td><td>';
1520 $toolbarname =
'dolibarr_notes';
1521 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1522 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5, 70);
1523 $doleditor->Create();
1528 if ($user->rights->ticket->write && !$user->socid) {
1529 $mail_signature =
GETPOST(
'mail_signature') ?
GETPOST(
'mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE;
1530 print
'<tr class="email_line"><td><label for="mail_intro">'.$langs->trans(
"TicketMessageMailSignature").
'</label>';
1531 print
$form->textwithpicto(
'', $langs->trans(
"TicketMessageMailSignatureHelp"), 1,
'help');
1533 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1534 $doleditor =
new DolEditor(
'mail_signature', $mail_signature,
'100%', 150,
'dolibarr_details',
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_2, 70);
1535 $doleditor->Create();
1540 if (!empty($this->withfile)) {
1542 $out .=
'<td width="180">'.$langs->trans(
"MailFile").
'</td>';
1545 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1546 $out .=
'<script type="text/javascript">';
1547 $out .=
'jQuery(document).ready(function () {';
1548 $out .=
' jQuery(".removedfile").click(function() {';
1549 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1552 $out .=
'</script>'.
"\n";
1553 if (count($listofpaths)) {
1554 foreach ($listofpaths as $key => $val) {
1555 $out .=
'<div id="attachfile_'.$key.
'">';
1556 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
1557 if (!$this->withfilereadonly) {
1558 $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.
'" />';
1560 $out .=
'<br></div>';
1563 $out .= $langs->trans(
"NoAttachedFiles").
'<br>';
1565 if ($this->withfile == 2) {
1566 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1568 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1570 $out .=
"</td></tr>\n";
1577 print
'<center><br>';
1578 print
'<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans(
"AddMessage").
'" />';
1579 if ($this->withcancel) {
1580 print
" ";
1581 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1583 print
"</center>\n";
1585 print
'<input type="hidden" name="page_y">'.
"\n";
1588 print
"<!-- End form TICKET -->\n";