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;
147 public function showForm($withdolfichehead = 0, $mode =
'edit', $public = 0,
Contact $with_contact = null)
149 global $conf, $langs, $user, $hookmanager;
152 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
156 $ticketstatic =
new Ticket($this->
db);
159 if (!empty($this->withfromsocid) && $this->withfromsocid > 0) {
160 $soc->fetch($this->withfromsocid);
163 $ticketstat =
new Ticket($this->
db);
166 $extrafields->fetch_name_optionals_label($ticketstat->table_element);
168 print
"\n<!-- Begin form TICKET -->\n";
170 if ($withdolfichehead) {
174 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"] :
"").
'">';
175 print
'<input type="hidden" name="token" value="'.newToken().
'">';
176 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
177 foreach ($this->param as $key => $value) {
178 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
180 print
'<input type="hidden" name="fk_user_create" value="'.$this->fk_user_create.
'">';
182 print
'<table class="border centpercent">';
184 if ($this->withref) {
186 $defaultref = $ticketstat->getDefaultRef();
187 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Ref").
'</span></td><td>';
188 print
'<input type="text" name="ref" value="'.dol_escape_htmltag(
GETPOST(
"ref",
'alpha') ?
GETPOST(
"ref",
'alpha') : $defaultref).
'">';
194 if ($this->withemail) {
195 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"Email").
'</span></label></td><td>';
196 print
'<input class="text minwidth200" id="email" name="email" value="'.$email.
'" autofocus>';
201 $html_contact_search =
'';
202 $html_contact_search .=
'<tr id="contact_search_line">';
203 $html_contact_search .=
'<td class="titlefield">';
204 $html_contact_search .=
'<label for="contact"><span class="fieldrequired">' . $langs->trans(
'Contact') .
'</span></label>';
205 $html_contact_search .=
'<input type="hidden" id="contact_id" name="contact_id" value="" />';
206 $html_contact_search .=
'</td>';
207 $html_contact_search .=
'<td id="contact_search_result"></td>';
208 $html_contact_search .=
'</tr>';
209 print $html_contact_search;
211 $html_contact_lastname =
'';
212 $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>';
213 $html_contact_lastname .=
'<input type="text" id="contact_lastname" name="contact_lastname" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_lastname') ?
GETPOST(
'contact_lastname',
'alphanohtml') :
'') .
'" />';
214 $html_contact_lastname .=
'</td></tr>';
215 print $html_contact_lastname;
217 $html_contact_firstname =
'';
218 $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>';
219 $html_contact_firstname .=
'<input type="text" id="contact_firstname" name="contact_firstname" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_firstname') ?
GETPOST(
'contact_firstname',
'alphanohtml') :
'') .
'" />';
220 $html_contact_firstname .=
'</td></tr>';
221 print $html_contact_firstname;
223 $html_company_name =
'';
224 $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>';
225 $html_company_name .=
'<input type="text" id="company_name" name="company_name" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'company_name') ?
GETPOST(
'company_name',
'alphanohtml') :
'') .
'" />';
226 $html_company_name .=
'</td></tr>';
227 print $html_company_name;
229 $html_contact_phone =
'';
230 $html_contact_phone .=
'<tr id="contact_phone_line" class="contact_field"><td><label for="contact_phone"><span>' . $langs->trans(
'Phone') .
'</span></label></td><td>';
231 $html_contact_phone .=
'<input type="text" id="contact_phone" name="contact_phone" value="' .
dol_escape_htmltag(
GETPOSTISSET(
'contact_phone') ?
GETPOST(
'contact_phone',
'alphanohtml') :
'') .
'" />';
232 $html_contact_phone .=
'</td></tr>';
233 print $html_contact_phone;
236 $langs->load(
'errors');
237 print
'<script type="text/javascript">
238 jQuery(document).ready(function() {
239 var contact = jQuery.parseJSON("'.dol_escape_js(json_encode($with_contact), 2).
'");
240 jQuery("#contact_search_line").hide();
242 if (contact.id > 0) {
243 jQuery("#contact_search_line").show();
244 jQuery("#contact_id").val(contact.id);
245 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
246 jQuery(".contact_field").hide();
248 jQuery(".contact_field").show();
252 jQuery("#email").change(function() {
253 jQuery("#contact_search_line").show();
254 jQuery("#contact_search_result").html("'.
dol_escape_js($langs->trans(
'Select2SearchInProgress')).
'");
255 jQuery("#contact_id").val("");
256 jQuery("#contact_lastname").val("");
257 jQuery("#contact_firstname").val("");
258 jQuery("#company_name").val("");
259 jQuery("#contact_phone").val("");
264 action: "getContacts",
265 email: jQuery("#email").val()
268 if (response.error) {
269 jQuery("#contact_search_result").html("<span class=\"error\">"+response.error+"</span>");
271 var contact_list = response.contacts;
272 if (contact_list.length == 1) {
273 var contact = contact_list[0];
274 jQuery("#contact_id").val(contact.id);
275 jQuery("#contact_search_result").html(contact.firstname+" "+contact.lastname);
276 jQuery(".contact_field").hide();
277 } else if (contact_list.length <= 0) {
278 jQuery("#contact_search_line").hide();
279 jQuery(".contact_field").show();
283 ).fail(function(jqxhr, textStatus, error) {
284 var error_msg = "'.
dol_escape_js($langs->trans(
'ErrorAjaxRequestFailed')).
'"+" ["+textStatus+"] : "+error;
285 jQuery("#contact_search_result").html("<span class=\"error\">"+error_msg+"</span>");
295 if (isset($this->param[
'origin']) && $this->param[
'originid'] > 0) {
297 $element = $subelement = $this->param[
'origin'];
299 if (preg_match(
'/^([^_]+)_([^_]+)/i', $this->param[
'origin'], $regs)) {
301 $subelement = $regs[2];
305 $classname = ucfirst($subelement);
306 $objectsrc =
new $classname($this->
db);
307 $objectsrc->fetch(
GETPOST(
'originid',
'int'));
309 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
310 $objectsrc->fetch_lines();
313 $objectsrc->fetch_thirdparty();
314 $newclassname = $classname;
315 print
'<tr><td>'.$langs->trans($newclassname).
'</td><td colspan="2"><input name="'.$subelement.
'id" value="'.
GETPOST(
'originid').
'" type="hidden" />'.$objectsrc->getNomUrl(1).
'</td></tr>';
319 print
'<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans(
"TicketTypeRequest").
'</span></label></td><td>';
324 print
'<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans(
"TicketCategory").
'</span></label></td><td>';
327 $filter =
'public=1';
329 $this->
selectGroupTickets((
GETPOST(
'category_code') ?
GETPOST(
'category_code') : $this->category_code),
'category_code', $filter, 2, 0, 0, 0,
'minwidth200');
333 print
'<tr><td><span class=""><label for="selectseverity_code">'.$langs->trans(
"TicketSeverity").
'</span></label></td><td>';
338 if ($this->withtitletopic) {
339 print
'<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans(
"Subject").
'</span></label></td><td>';
342 if ($this->withtopicreadonly) {
343 print $langs->trans(
'SubjectAnswerToTicket').
' '.$this->topic_title;
346 if (isset($this->withreadid) && $this->withreadid > 0) {
347 $subject = $langs->trans(
'SubjectAnswerToTicket').
' '.$this->withreadid.
' : '.$this->topic_title.
'';
349 $subject =
GETPOST(
'subject',
'alpha');
351 print
'<input class="text minwidth500" id="subject" name="subject" value="'.$subject.
'" autofocus />';
356 if (!empty($conf->knowledgemanagement->enabled)) {
358 print
'<tr id="KWwithajax"></tr>';
359 print
'<!-- Script to manage change of ticket group -->
361 jQuery(document).ready(function() {
362 function groupticketchange(){
363 console.log("We called groupticketchange, so we try to load list KM linked to event");
364 $("#KWwithajax").html("");
365 idgroupticket = $("#selectcategory_code").val();
367 console.log("We have selected id="+idgroupticket);
369 if (idgroupticket != "") {
370 $.ajax({ url: \''.DOL_URL_ROOT.
'/core/ajax/fetchKnowledgeRecord.php\',
371 data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.
newToken().
'\', lang:\
''.$langs->defaultlang.
'\'},
373 success: function(response) {
375 console.log("We received response "+response);
376 response = JSON.parse(response)
377 for (key in response) {
378 answer = response[key].answer;
379 urllist += \'<li><a href="#" title="\'+response[key].title+\'" class="button_KMpopup" data-html="\'+answer+\'">\' +response[key].title+\'</a></li>\';
382 $("#KWwithajax").html(\'<td>'.$langs->trans(
"KMFoundForTicketGroup").
'</td><td><ul>\'+urllist+\'</ul></td>\');
383 $("#KWwithajax").show();
384 $(".button_KMpopup").on("click",function(){
385 console.log("Open popup with jQuery(...).dialog() with KM article")
386 var $dialog = $("<div></div>").html($(this).attr("data-html"))
390 height: (window.innerHeight - 150),
392 title: $(this).attr("title"),
394 $dialog.dialog("open");
395 console.log($dialog);
399 error : function(output) {
400 console.error("Error on Fetch of KM articles");
405 $("#selectcategory_code").on("change",function() { groupticketchange(); });
406 if ($("#selectcategory_code").val() != "") {
415 print
'<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span></label></td><td>';
418 $toolbarname =
'dolibarr_notes';
419 if ($this->ispublic) {
420 $toolbarname =
'dolibarr_details';
421 print
'<div class="warning">'.($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans(
'TicketPublicPleaseBeAccuratelyDescribe')).
'</div>';
423 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
424 $uselocalbrowser =
true;
425 $doleditor =
new DolEditor(
'message', $msg,
'100%', 230, $toolbarname,
'In',
true, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_TICKET'), ROWS_8,
'90%');
426 $doleditor->Create();
429 if ($public && !empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA_TICKET)) {
430 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
431 print
'<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"SecurityCode").
'</span></label></td><td>';
432 print
'<span class="span-icon-security inline-block">';
433 print
'<input id="securitycode" placeholder="'.$langs->trans(
"SecurityCode").
'" class="flat input-icon-security width125" type="text" maxlength="5" name="code" tabindex="3" />';
435 print
'<span class="nowrap inline-block">';
436 print
'<img class="inline-block valignmiddle" src="'.DOL_URL_ROOT.
'/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />';
437 print
'<a class="inline-block valignmiddle" href="" tabindex="4" data-role="button">'.img_picto($langs->trans(
"Refresh"),
'refresh',
'id="captcha_refresh_img"').
'</a>';
444 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
445 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_TICKET,
'',
'parent', 64, 0, 1);
447 if (count($cate_arbo)) {
449 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
450 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
456 if (!empty($this->withfile)) {
458 $listofpaths = array();
459 $listofnames = array();
460 $listofmimes = array();
461 if (!empty($_SESSION[
"listofpaths"])) {
462 $listofpaths = explode(
';', $_SESSION[
"listofpaths"]);
465 if (!empty($_SESSION[
"listofnames"])) {
466 $listofnames = explode(
';', $_SESSION[
"listofnames"]);
469 if (!empty($_SESSION[
"listofmimes"])) {
470 $listofmimes = explode(
';', $_SESSION[
"listofmimes"]);
474 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
477 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
478 $out .=
'<script type="text/javascript">';
479 $out .=
'jQuery(document).ready(function () {';
480 $out .=
' jQuery(".removedfile").click(function() {';
481 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
484 $out .=
'</script>'.
"\n";
485 if (count($listofpaths)) {
486 foreach ($listofpaths as $key => $val) {
487 $out .=
'<div id="attachfile_'.$key.
'">';
488 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
489 if (!$this->withfilereadonly) {
490 $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.
'" />';
492 $out .=
'<br></div>';
495 $out .= $langs->trans(
"NoAttachedFiles").
'<br>';
497 if ($this->withfile == 2) {
499 $maxmin = $maxfilesizearray[
'maxmin'];
501 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
503 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
505 $out .=
'<input type="submit" class="button smallpaddingimp reposition" id="addfile" name="addfile" value="'.$langs->trans(
"MailingAddFile").
'" />';
507 $out .=
"</td></tr>\n";
513 if ($this->withusercreate > 0 && $this->fk_user_create) {
514 print
'<tr><td class="titlefield">'.$langs->trans(
"CreatedBy").
'</td><td>';
515 $langs->load(
"users");
516 $fuser =
new User($this->
db);
518 if ($this->withcreatereadonly) {
519 if ($res = $fuser->fetch($this->fk_user_create)) {
520 print $fuser->getNomUrl(1);
524 print
"</td></tr>\n";
528 if ($this->withcompany) {
530 if (empty($user->socid)) {
532 print
'<tr><td class="titlefield">'.$langs->trans(
"ThirdParty").
'</td><td>';
534 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
535 print
img_picto(
'',
'company',
'class="paddingright"');
536 print
$form->select_company($this->withfromsocid,
'socid',
'', 1, 1,
'', $events, 0,
'minwidth200');
538 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
540 print
'<script type="text/javascript">
541 $(document).ready(function () {
542 jQuery("#'.$htmlname.
'").change(function () {
543 var obj = '.json_encode($events).
';
544 $.each(obj, function(key,values) {
545 if (values.method.length) {
546 runJsCodeForEvent'.$htmlname.
'(values);
551 function runJsCodeForEvent'.$htmlname.
'(obj) {
552 console.log("Run runJsCodeForEvent'.$htmlname.
'");
553 var id = $("#'.$htmlname.
'").val();
554 var method = obj.method;
556 var htmlname = obj.htmlname;
557 var showempty = obj.showempty;
566 $.each(obj.params, function(key,action) {
568 var num = response.num;
570 $("#" + key).removeAttr(action);
572 $("#" + key).attr(action, action);
576 $("select#" + htmlname).html(response.value);
578 var selecthtml_str = response.value;
579 var selecthtml_dom=$.parseHTML(selecthtml_str);
580 if (typeof(selecthtml_dom[0][0]) !== \'undefined\') {
581 $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
584 $("#inputautocomplete"+htmlname).val("");
586 $("select#" + htmlname).change(); /* Trigger event change */
595 print
'<tr><td>'.$langs->trans(
"Contact").
'</td><td>';
597 $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
598 print
img_picto(
'',
'contact',
'class="paddingright"');
599 print
$form->selectcontacts($selectedCompany, $this->withfromcontactid,
'contactid', 3,
'',
'', 0,
'minwidth200');
601 $formcompany->selectTypeContact($ticketstatic,
'',
'type',
'external',
'', 0,
'maginleftonly');
604 print
'<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.
'"/></td>';
605 print
'<td><input type="hidden" name="contactid" value="'.$user->contact_id.
'"/></td>';
606 print
'<td><input type="hidden" name="type" value="Z"/></td></tr>';
610 if (empty($this->ispublic)) {
611 print
'<tr><td><label for="notify_tiers_at_create">'.$langs->trans(
"TicketNotifyTiersAtCreation").
'</label></td><td>';
612 print
'<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ?
' checked="checked"' :
'').
'>';
618 print $langs->trans(
"AssignedTo");
620 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
621 print
$form->select_dolusers(
GETPOST(
'fk_user_assign',
'int'),
'fk_user_assign', 1);
626 if ($subelement !=
'project') {
627 if (!empty($conf->project->enabled) && !$this->ispublic) {
629 print
'<tr><td><label for="project"><span class="">'.$langs->trans(
"Project").
'</span></label></td><td>';
630 print
img_picto(
'',
'project').$formproject->select_projects(-1,
GETPOST(
'projectid',
'int'),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
636 $parameters = array();
637 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $ticketstat, $this->action);
638 if (empty($reshook)) {
639 print $ticketstat->showOptionals($extrafields,
'create');
644 if ($withdolfichehead) {
650 print
$form->buttonsSaveCancel(((isset($this->withreadid) && $this->withreadid > 0) ?
"SendResponse" :
"CreateTicket"), ($this->withcancel ?
"Cancel" :
""));
662 print
'<input type="hidden" name="page_y">'.
"\n";
665 print
"<!-- End form TICKET -->\n";
681 public function selectTypesTickets($selected =
'', $htmlname =
'tickettype', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
683 global $langs, $user;
685 $ticketstat =
new Ticket($this->
db);
687 dol_syslog(get_class($this).
"::select_types_tickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
689 $filterarray = array();
691 if ($filtertype !=
'' && $filtertype !=
'-1') {
692 $filterarray = explode(
',', $filtertype);
695 $ticketstat->loadCacheTypesTickets();
697 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
699 print
'<option value=""> </option>';
702 if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
703 foreach ($ticketstat->cache_types_tickets as $id => $arraytypes) {
705 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
710 if ($empty && empty($arraytypes[
'code'])) {
715 print
'<option value="'.$id.
'"';
719 print
'<option value="'.$arraytypes[
'code'].
'"';
723 print
'<option value="'.$arraytypes[
'code'].
'"';
727 print
'<option value="'.$id.
'"';
731 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraytypes[
'code']) {
732 print
' selected="selected"';
733 } elseif ($selected == $id) {
734 print
' selected="selected"';
735 } elseif ($arraytypes[
'use_default'] ==
"1" && !$selected && !$empty) {
736 print
' selected="selected"';
742 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
743 } elseif ($format == 1) {
744 $value = $arraytypes[
'code'];
745 } elseif ($format == 2) {
746 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
747 } elseif ($format == 3) {
748 $value = $arraytypes[
'code'];
756 if ($user->admin && !$noadmininfo) {
757 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
778 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'', $use_multilevel = 0, $outputlangs = null)
780 global $conf, $langs, $user;
782 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
784 if (is_null($outputlangs) || !is_object($outputlangs)) {
785 $outputlangs = $langs;
787 $outputlangs->load(
"ticket");
789 $ticketstat =
new Ticket($this->
db);
790 $ticketstat->loadCacheCategoriesTickets();
792 if ($use_multilevel <= 0) {
793 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
795 print
'<option value=""> </option>';
798 if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
799 foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
801 if ($filtertype ==
'public=1') {
802 if (empty($arraycategories[
'public'])) {
808 if ($empty && empty($arraycategories[
'code'])) {
812 $label = ($arraycategories[
'label'] !=
'-' ? $arraycategories[
'label'] :
'');
813 if ($outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']) != (
"TicketCategoryShort".$arraycategories[
'code'])) {
814 $label = $outputlangs->trans(
"TicketCategoryShort".$arraycategories[
'code']);
815 } elseif ($outputlangs->trans($arraycategories[
'code']) != $arraycategories[
'code']) {
816 $label = $outputlangs->trans($arraycategories[
'code']);
820 print
'<option value="'.$id.
'"';
824 print
'<option value="'.$arraycategories[
'code'].
'"';
828 print
'<option value="'.$arraycategories[
'code'].
'"';
832 print
'<option value="'.$id.
'"';
836 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
837 print
' selected="selected"';
838 } elseif ($selected == $id) {
839 print
' selected="selected"';
840 } elseif ($arraycategories[
'use_default'] ==
"1" && !$selected && !$empty) {
841 print
' selected="selected"';
847 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
851 $value = $arraycategories[
'code'];
855 $value = ($maxlength ?
dol_trunc($label, $maxlength) : $label);
859 $value = $arraycategories[
'code'];
862 print $value ? $value :
' ';
867 if ($user->admin && !$noadmininfo) {
868 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
872 } elseif ($htmlname!=
'') {
873 $selectedgroups = array();
875 $groupticket=
GETPOST($htmlname,
'aZ09');
876 $child_id=
GETPOST($htmlname.
'_child_id',
'aZ09')?
GETPOST($htmlname.
'_child_id',
'aZ09'):0;
877 if (!empty($groupticket)) {
878 $tmpgroupticket = $groupticket;
879 $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).
"'";
882 $obj = $this->
db->fetch_object(
$resql);
883 $selectedgroups[] = $obj->code;
884 while ($obj->fk_parent > 0) {
885 $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).
"'";
888 $obj = $this->
db->fetch_object(
$resql);
889 $selectedgroups[] = $obj->code;
894 $arrayidused = array();
895 $arrayidusedconcat = array();
896 $arraycodenotparent = array();
897 $arraycodenotparent[] =
"";
899 $stringtoprint =
'<span class="supportemailfield bold">'.$langs->trans(
"GroupOfTicket").
'</span> ';
900 $stringtoprint .=
'<select id ="'.$htmlname.
'" class="minwidth500" child_id="0">';
901 $stringtoprint .=
'<option value=""> </option>';
903 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ";
904 $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";
905 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
906 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
907 if ($filtertype ==
'public=1') {
908 $sql .=
" AND ctc.public = 1";
910 $sql .=
" AND ctc.fk_parent = 0";
911 $sql .= $this->
db->order(
'ctc.pos',
'ASC');
915 $num_rows_level0 = $this->
db->num_rows(
$resql);
917 while ($i < $num_rows_level0) {
918 $obj = $this->
db->fetch_object(
$resql);
920 $label = ($obj->label !=
'-' ? $obj->label :
'');
921 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
922 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
923 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
924 $label = $outputlangs->trans($obj->code);
927 $grouprowid = $obj->rowid;
928 $groupvalue = $obj->code;
929 $grouplabel = $label;
931 $isparent = $obj->isparent;
932 if (is_array($selectedgroups)) {
933 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
935 $iselected = $groupticket == $obj->code ?
'selected':
'';
938 if ($isparent ==
'NOTPARENT') {
939 $arraycodenotparent[] = $groupvalue;
941 $arrayidused[] = $grouprowid;
942 $arrayidusedconcat[] = $grouprowid;
949 if (count($arrayidused) == 1) {
950 return '<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'" value="'.
dol_escape_htmltag($groupvalue).
'">';
952 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'" id="'.$htmlname.
'_select" class="maxwidth500 minwidth400">';
953 $stringtoprint .=
'<input type="hidden" name="'.$htmlname.
'_child_id" id="'.$htmlname.
'_select_child_id" class="maxwidth500 minwidth400">';
955 $stringtoprint .=
'</select> ';
958 while ($levelid <= $use_multilevel) {
959 $tabscript = array();
960 $stringtoprint .=
'<select id ="'.$htmlname.
'_child_'.$levelid.
'" class="maxwidth500 minwidth400 groupticketchild" child_id="'.$levelid.
'">';
961 $stringtoprint .=
'<option value=""> </option>';
963 $sql =
"SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctc.public, ctcjoin.code as codefather";
964 $sql .=
" FROM ".$this->db->prefix().
"c_ticket_category as ctc";
965 $sql .=
" JOIN ".$this->db->prefix().
"c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
966 $sql .=
" WHERE ctc.active > 0 AND ctc.entity = ".((int) $conf->entity);
967 $sql .=
" AND ctc.rowid NOT IN (".$this->db->sanitize(join(
',', $arrayidusedconcat)).
")";
969 if ($filtertype ==
'public=1') {
970 $sql .=
" AND ctc.public = 1";
973 if (!empty($arrayidused)) {
974 $sql .=
" AND ctc.fk_parent IN ( ";
975 foreach ($arrayidused as $idused) {
976 $sql .= $idused.
", ";
978 $sql = substr($sql, 0, -2);
982 $sql .= $this->
db->order(
'ctc.pos',
'ASC');
986 $num_rows = $this->
db->num_rows(
$resql);
988 $arrayidused=array();
989 while ($i < $num_rows) {
990 $obj = $this->
db->fetch_object(
$resql);
992 $label = ($obj->label !=
'-' ? $obj->label :
'');
993 if ($outputlangs->trans(
"TicketCategoryShort".$obj->code) != (
"TicketCategoryShort".$obj->code)) {
994 $label = $outputlangs->trans(
"TicketCategoryShort".$obj->code);
995 } elseif ($outputlangs->trans($obj->code) != $obj->code) {
996 $label = $outputlangs->trans($obj->code);
999 $grouprowid = $obj->rowid;
1000 $groupvalue = $obj->code;
1001 $grouplabel = $label;
1002 $isparent = $obj->isparent;
1003 $fatherid = $obj->fk_parent;
1004 $arrayidused[] = $grouprowid;
1005 $arrayidusedconcat[] = $grouprowid;
1006 $groupcodefather = $obj->codefather;
1007 if ($isparent ==
'NOTPARENT') {
1008 $arraycodenotparent[] = $groupvalue;
1010 if (is_array($selectedgroups)) {
1011 $iselected = in_array($obj->code, $selectedgroups) ?
'selected':
'';
1013 $iselected = $groupticket == $obj->code ?
'selected':
'';
1016 if (empty($tabscript[$groupcodefather])) {
1017 $tabscript[$groupcodefather] =
'if ($("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid-1:
'').
'").val() == "'.
dol_escape_js($groupcodefather).
'"){
1019 console.log("We show childs tickets of '.$groupcodefather.
' group ticket")
1022 console.log("We hide childs tickets of '.$groupcodefather.
' group ticket")
1031 $stringtoprint .=
'</select>';
1033 $stringtoprint .=
'<script>';
1034 $stringtoprint .=
'arraynotparents = '.json_encode($arraycodenotparent).
';';
1035 $stringtoprint .=
'if (arraynotparents.includes($("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid-1:
'').
'").val())){
1036 console.log("'.$htmlname.
'_child_'.$levelid.
'")
1037 if($("#'.$htmlname.
'_child_'.$levelid.
'").val() == "" && ($("#'.$htmlname.
'_child_'.$levelid.
'").attr("child_id")>'.$child_id.
')){
1038 $("#'.$htmlname.
'_child_'.$levelid.
'").hide();
1039 console.log("We hide '.$htmlname.
'_child_'.$levelid.
' input")
1041 if(arraynotparents.includes("'.$groupticket.
'") && '.$child_id.
' == 0){
1042 $("#ticketcategory_select_child_id").val($("#'.$htmlname.
'").attr("child_id"))
1043 $("#ticketcategory_select").val($("#'.$htmlname.
'").val()) ;
1044 console.log("We choose '.$htmlname.
' input and reload hidden input");
1047 $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid-1:
'').
'").change(function() {
1048 child_id = $("#'.$htmlname.($levelid > 1 ?
'_child_'.$levelid:
'').
'").attr("child_id");
1050 /* Change of value to select this value*/
1051 if (arraynotparents.includes($(this).val()) || $(this).attr("child_id") == '.$use_multilevel.
') {
1052 $("#ticketcategory_select").val($(this).val());
1053 $("#ticketcategory_select_child_id").val($(this).attr("child_id")) ;
1054 console.log("We choose to select "+ $(this).val());
1056 if ($("#'.$htmlname.
'_child_'.$levelid.
' option").length <= 1) {
1057 $("#ticketcategory_select").val($(this).val());
1058 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1059 console.log("We choose to select "+ $(this).val() + " and next combo has no item, so we keep this selection");
1061 console.log("We choose to select "+ $(this).val() + " but next combo has some item, so we clean selected item");
1062 $("#ticketcategory_select").val("");
1063 $("#ticketcategory_select_child_id").val("");
1067 console.log("We select a new value into combo child_id="+child_id);
1069 /* Hide all selected box that are child of the one modified */
1070 $(".groupticketchild").each(function(){
1071 if ($(this).attr("child_id") > child_id) {
1072 console.log("hide child_id="+$(this).attr("child_id"));
1078 /* Now we enable the next combo */
1079 $("#'.$htmlname.
'_child_'.$levelid.
'").val("");
1080 if (!arraynotparents.includes($(this).val()) && $("#'.$htmlname.
'_child_'.$levelid.
' option").length > 1) {
1081 console.log($("#'.$htmlname.
'_child_'.$levelid.
' option").length);
1082 $("#'.$htmlname.
'_child_'.$levelid.
'").show()
1084 $("#'.$htmlname.
'_child_'.$levelid.
'").hide()
1088 foreach ($tabscript as $script) {
1089 $stringtoprint .= $script;
1091 $stringtoprint .=
'})';
1092 $stringtoprint .=
'</script>';
1094 $stringtoprint .=
'<script>';
1095 $stringtoprint .=
'$("#'.$htmlname.
'_child_'.$use_multilevel.
'").change(function() {
1096 $("#ticketcategory_select").val($(this).val());
1097 $("#ticketcategory_select_child_id").val($(this).attr("child_id"));
1098 console.log($("#ticketcategory_select").val());
1100 $stringtoprint .=
'</script>';
1103 return $stringtoprint;
1120 public function selectSeveritiesTickets($selected =
'', $htmlname =
'ticketseverity', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
1122 global $langs, $user;
1124 $ticketstat =
new Ticket($this->
db);
1126 dol_syslog(get_class($this).
"::selectSeveritiesTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
1128 $filterarray = array();
1130 if ($filtertype !=
'' && $filtertype !=
'-1') {
1131 $filterarray = explode(
',', $filtertype);
1134 $ticketstat->loadCacheSeveritiesTickets();
1136 print
'<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1138 print
'<option value=""> </option>';
1141 if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
1142 foreach ($ticketstat->cache_severity_tickets as $id => $arrayseverities) {
1144 if (count($filterarray) && !in_array($arrayseverities[
'type'], $filterarray)) {
1149 if ($empty && empty($arrayseverities[
'code'])) {
1154 print
'<option value="'.$id.
'"';
1158 print
'<option value="'.$arrayseverities[
'code'].
'"';
1162 print
'<option value="'.$arrayseverities[
'code'].
'"';
1166 print
'<option value="'.$id.
'"';
1170 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arrayseverities[
'code']) {
1171 print
' selected="selected"';
1172 } elseif ($selected == $id) {
1173 print
' selected="selected"';
1174 } elseif ($arrayseverities[
'use_default'] ==
"1" && !$selected && !$empty) {
1175 print
' selected="selected"';
1180 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1184 $value = $arrayseverities[
'code'];
1188 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
1192 $value = $arrayseverities[
'code'];
1195 print $value ? $value :
' ';
1200 if ($user->admin && !$noadmininfo) {
1201 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1216 global $conf, $user;
1217 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1220 $vardir = $conf->user->dir_output.
"/".$user->id;
1221 $upload_dir = $vardir.
'/temp/';
1222 if (is_dir($upload_dir)) {
1226 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1227 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
1228 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
1229 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
1240 global $conf, $langs, $user, $hookmanager,
$form, $mysoc;
1243 $addfileaction =
'addfile';
1245 if (!is_object($form)) {
1246 $form =
new Form($this->
db);
1250 $langs->loadLangs(array(
'other',
'mails'));
1253 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1254 $this->clear_attached_files();
1258 $outputlangs = $langs;
1260 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
1261 $newlang = $this->param[
'langsmodels'];
1263 if (!empty($newlang)) {
1264 $outputlangs =
new Translate(
"", $conf);
1265 $outputlangs->setDefaultLang($newlang);
1266 $outputlangs->load(
'other');
1270 $arraydefaultmessage = -1;
1271 if ($this->param[
'models'] !=
'none') {
1273 if (array_key_exists(
'models_id', $this->param)) {
1274 $model_id = $this->param[
"models_id"];
1277 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db, $this->param[
"models"], $user, $outputlangs, $model_id);
1281 $listofpaths = array();
1282 $listofnames = array();
1283 $listofmimes = array();
1284 $keytoavoidconflict = empty($this->track_id) ?
'' :
'-'.$this->track_id;
1286 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1')) {
1287 if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param[
'fileinit'])) {
1288 foreach ($this->param[
'fileinit'] as $file) {
1289 $formmail->add_attached_files($file, basename($file),
dol_mimetype($file));
1294 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) {
1295 $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
1297 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) {
1298 $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
1300 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) {
1301 $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
1305 $outputlangs = $langs;
1307 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
1308 $newlang = $this->param[
'langsmodels'];
1310 if (!empty($newlang)) {
1311 $outputlangs =
new Translate(
"", $conf);
1312 $outputlangs->setDefaultLang($newlang);
1313 $outputlangs->load(
'other');
1316 print
"\n<!-- Begin message_form TICKET -->\n";
1318 $send_email =
GETPOST(
'send_email',
'int') ?
GETPOST(
'send_email',
'int') : 0;
1321 print
'<script type="text/javascript">
1322 jQuery(document).ready(function() {
1323 send_email=' . $send_email.
';
1325 if (!jQuery("#send_msg_email").is(":checked")) {
1326 jQuery("#send_msg_email").prop("checked", true).trigger("change");
1328 jQuery(".email_line").show();
1330 if (!jQuery("#private_message").is(":checked")) {
1331 jQuery("#private_message").prop("checked", true).trigger("change");
1333 jQuery(".email_line").hide();
1336 jQuery("#send_msg_email").click(function() {
1337 if(jQuery(this).is(":checked")) {
1338 if (jQuery("#private_message").is(":checked")) {
1339 jQuery("#private_message").prop("checked", false).trigger("change");
1341 jQuery(".email_line").show();
1344 jQuery(".email_line").hide();
1348 jQuery("#private_message").click(function() {
1349 if (jQuery(this).is(":checked")) {
1350 if (jQuery("#send_msg_email").is(":checked")) {
1351 jQuery("#send_msg_email").prop("checked", false).trigger("change");
1353 jQuery(".email_line").hide();
1359 print
'<form method="post" name="ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
1360 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1361 print
'<input type="hidden" name="action" value="'.$this->action.
'">';
1362 print
'<input type="hidden" name="actionbis" value="add_message">';
1363 print
'<input type="hidden" name="backtopage" value="'.$this->backtopage.
'">';
1364 foreach ($this->param as $key => $value) {
1365 print
'<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
1370 if (array_key_exists(
'models_id', $this->param)) {
1371 $model_id = $this->param[
"models_id"];
1372 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db, $this->param[
"models"], $user, $outputlangs, $model_id);
1375 $result = $formmail->fetchAllEMailTemplate($this->param[
"models"], $user, $outputlangs);
1379 $modelmail_array = array();
1380 foreach ($formmail->lines_model as $line) {
1381 $modelmail_array[$line->id] = $line->label;
1384 print
'<table class="border" width="'.$width.
'">';
1387 if ($user->rights->ticket->write && !$user->socid) {
1388 $ticketstat =
new Ticket($this->
db);
1389 $res = $ticketstat->fetch(
'',
'', $this->track_id);
1391 print
'<tr><td></td><td>';
1392 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' : ($conf->global->TICKETS_MESSAGE_FORCE_MAIL?
'checked':
''));
1393 print
'<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
1394 print
'<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
1398 if (count($modelmail_array) > 0) {
1399 print
'<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'.
"\n";
1400 print $langs->trans(
'SelectMailModel').
': '.$formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], 1, 0,
"",
"", 0, 0, 0,
'',
'minwidth200');
1402 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1405 print
'<input type="submit" class="button" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
1406 print
'</div></td>';
1410 if (!$user->socid) {
1411 print
'<tr><td></td><td>';
1412 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
1413 print
'<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
1414 print
'<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
1415 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1420 print
'<tr class="email_line"><td>'.$langs->trans(
'Subject').
'</td>';
1421 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').
'" />';
1425 print
'<tr class="email_line"><td>'.$langs->trans(
'MailRecipients').
'</td><td>';
1428 $contacts = $ticketstat->getInfosTicketInternalContact();
1429 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact());
1434 if (is_array($contacts) && count($contacts) > 0) {
1435 foreach ($contacts as $key => $info_sendto) {
1436 if ($info_sendto[
'email'] !=
'') {
1437 $sendto[] =
dol_escape_htmltag(trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">").
' <small class="opacitymedium">('.
dol_escape_htmltag($info_sendto[
'libelle']).
")</small>";
1442 if ($ticketstat->origin_email && !in_array($ticketstat->origin_email, $sendto)) {
1443 $sendto[] =
dol_escape_htmltag($ticketstat->origin_email).
' <small class="opacitymedium">('.$langs->trans(
"TicketEmailOriginIssuer").
")</small>";
1446 if ($ticketstat->fk_soc > 0) {
1447 $ticketstat->socid = $ticketstat->fk_soc;
1448 $ticketstat->fetch_thirdparty();
1450 if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
1451 $sendto[] = $ticketstat->thirdparty->email.
' <small class="opacitymedium">('.$langs->trans(
'Customer').
')</small>';
1455 if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) {
1456 $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO.
' <small class="opacitymedium">(generic email)</small>';
1460 if (is_array($sendto) && count($sendto) > 0) {
1461 print
img_picto(
'',
'email',
'class="pictofixedwidth"');
1462 print implode(
', ', $sendto);
1464 print
'<div class="warning">'.$langs->trans(
'WarningNoEMailsAdded').
' '.$langs->trans(
'TicketGoIntoContactTab').
'</div>';
1470 $uselocalbrowser =
false;
1474 if ($user->rights->ticket->write && !$user->socid) {
1475 $mail_intro =
GETPOST(
'mail_intro') ?
GETPOST(
'mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO;
1476 print
'<tr class="email_line"><td><label for="mail_intro">';
1477 print $form->textwithpicto($langs->trans(
"TicketMessageMailIntro"), $langs->trans(
"TicketMessageMailIntroHelp"), 1,
'help');
1481 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1483 $doleditor =
new DolEditor(
'mail_intro', $mail_intro,
'100%', 90,
'dolibarr_details',
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_2, 70);
1485 $doleditor->Create();
1491 $defaultmessage =
"";
1492 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
1493 $defaultmessage = $arraydefaultmessage->content;
1495 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
1499 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1501 $defaultmessage =
dol_nl2br($defaultmessage);
1504 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1508 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1509 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1512 print
'<tr><td class="tdtop"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
1513 if ($user->rights->ticket->write && !$user->socid) {
1514 print $form->textwithpicto(
'', $langs->trans(
"TicketMessageHelp"), 1,
'help');
1516 print
'</label></td><td>';
1518 $toolbarname =
'dolibarr_notes';
1519 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1520 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5, 70);
1521 $doleditor->Create();
1526 if ($user->rights->ticket->write && !$user->socid) {
1527 $mail_signature =
GETPOST(
'mail_signature') ?
GETPOST(
'mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE;
1528 print
'<tr class="email_line"><td><label for="mail_intro">'.$langs->trans(
"TicketMessageMailSignature").
'</label>';
1529 print $form->textwithpicto(
'', $langs->trans(
"TicketMessageMailSignatureHelp"), 1,
'help');
1531 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1532 $doleditor =
new DolEditor(
'mail_signature', $mail_signature,
'100%', 150,
'dolibarr_details',
'',
false, $uselocalbrowser,
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_2, 70);
1533 $doleditor->Create();
1538 if (!empty($this->withfile)) {
1540 $out .=
'<td width="180">'.$langs->trans(
"MailFile").
'</td>';
1543 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1544 $out .=
'<script type="text/javascript">';
1545 $out .=
'jQuery(document).ready(function () {';
1546 $out .=
' jQuery(".removedfile").click(function() {';
1547 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1550 $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>';
1561 $out .= $langs->trans(
"NoAttachedFiles").
'<br>';
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 print
'<center><br>';
1576 print
'<input type="submit" class="button" name="btn_add_message" value="'.$langs->trans(
"AddMessage").
'" />';
1577 if ($this->withcancel) {
1578 print
" ";
1579 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1581 print
"</center>\n";
1583 print
'<input type="hidden" name="page_y">'.
"\n";
1586 print
"<!-- End form TICKET -->\n";
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
getMaxFileSizeArray()
Return the max allowed for file upload.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
$conf db
API class for accounts.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
Class to manage Dolibarr users.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
img_mime($file, $titlealt= '', $morecss= '')
Show MIME img of a file.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage third parties objects (customers, suppliers, prospects...)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= 'hideonsmartphone', $textfordropdown= '')
Show information for admin users or standard users.
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories) ...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage translations.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve', $idforemptyvalue= '-1')
Convert a html select field into an ajax combobox.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
isModEnabled($module)
Is Dolibarr module enabled.
Class to manage a WYSIWYG editor.
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length. ...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dol_textishtml($msg, $option=0)
Return if a text is a html content.