26 require_once DOL_DOCUMENT_ROOT.
"/core/class/html.form.class.php";
27 require_once DOL_DOCUMENT_ROOT.
"/core/class/html.formmail.class.php";
28 require_once DOL_DOCUMENT_ROOT.
"/core/class/html.formprojet.class.php";
30 if (!class_exists(
'FormCompany')) {
31 include DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
54 public $fk_user_create;
70 public $withfilereadonly;
74 public $withtitletopic;
76 public $withfromsocid;
77 public $withfromcontactid;
78 public $withnotifytiersatcreate;
79 public $withusercreate;
80 public $withcreatereadonly;
90 public $substit = array();
91 public $param = array();
108 $this->action =
'add';
110 $this->withcompany = 1;
111 $this->withfromsocid = 0;
112 $this->withfromcontactid = 0;
115 $this->withnotifytiersatcreate = 0;
116 $this->withusercreate = 1;
117 $this->withcreatereadonly = 1;
118 $this->withemail = 0;
120 $this->withextrafields = 0;
131 public function showForm($withdolfichehead = 0, $mode =
'edit')
133 global $conf, $langs, $user, $hookmanager;
136 $langs->loadLangs(array(
'other',
'mails',
'ticket'));
138 $form =
new Form($this->
db);
140 $ticketstatic =
new Ticket($this->
db);
143 if (!empty($this->withfromsocid) && $this->withfromsocid > 0) {
144 $soc->fetch($this->withfromsocid);
147 $ticketstat =
new Ticket($this->
db);
150 $extrafields->fetch_name_optionals_label($ticketstat->table_element);
152 print "\n<!-- Begin form TICKET -->\n";
156 print '<form method="POST" '.($withdolfichehead ?
'' :
'style="margin-bottom: 30px;" ').
'name="ticket" id="form_create_ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
157 print '<input type="hidden" name="token" value="'.newToken().
'">';
158 print '<input type="hidden" name="action" value="'.$this->action.
'">';
159 foreach ($this->param as $key => $value) {
160 print '<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
162 print '<input type="hidden" name="fk_user_create" value="'.$this->fk_user_create.
'">';
164 print '<table class="border centpercent">';
166 if ($this->withref) {
168 $defaultref = $ticketstat->getDefaultRef();
169 print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Ref").
'</span></td><td><input size="18" type="text" name="ref" value="'.(
GETPOST(
"ref",
'alpha') ?
GETPOST(
"ref",
'alpha') : $defaultref).
'"></td></tr>';
173 if ($this->withemail) {
174 print '<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans(
"Email").
'</span></label></td><td>';
175 print '<input class="text minwidth200" id="email" name="email" value="'.(GETPOST(
'email',
'alpha') ?
GETPOST(
'email',
'alpha') : $subject).
'" />';
180 if (isset($this->param[
'origin']) && $this->param[
'originid'] > 0) {
182 $element = $subelement = $this->param[
'origin'];
183 if (preg_match(
'/^([^_]+)_([^_]+)/i', $this->param[
'origin'], $regs)) {
185 $subelement = $regs[2];
189 $classname = ucfirst($subelement);
190 $objectsrc =
new $classname($this->
db);
191 $objectsrc->fetch(
GETPOST(
'originid',
'int'));
193 if (empty($objectsrc->lines) && method_exists($objectsrc,
'fetch_lines')) {
194 $objectsrc->fetch_lines();
197 $objectsrc->fetch_thirdparty();
198 $newclassname = $classname;
199 print '<tr><td>'.$langs->trans($newclassname).
'</td><td colspan="2"><input name="'.$subelement.
'id" value="'.
GETPOST(
'originid').
'" type="hidden" />'.$objectsrc->getNomUrl(1).
'</td></tr>';
203 print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans(
"TicketTypeRequest").
'</span></label></td><td>';
208 print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans(
"TicketCategory").
'</span></label></td><td>';
213 print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans(
"TicketSeverity").
'</span></label></td><td>';
218 if ($this->withtitletopic) {
219 print '<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans(
"Subject").
'</span></label></td><td>';
222 if ($this->withtopicreadonly) {
223 print $langs->trans(
'SubjectAnswerToTicket').
' '.$this->topic_title;
226 if ($this->withthreadid > 0) {
227 $subject = $langs->trans(
'SubjectAnswerToTicket').
' '.$this->withthreadid.
' : '.$this->topic_title.
'';
229 print '<input class="text minwidth500" id="subject" name="subject" value="'.(GETPOST(
'subject',
'alpha') ?
GETPOST(
'subject',
'alpha') : $subject).
'" autofocus />';
236 print '<tr><td><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span></label></td><td>';
239 $toolbarname =
'dolibarr_notes';
242 $toolbarname =
'dolibarr_details';
243 print '<div class="warning">'.($conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans(
'TicketPublicPleaseBeAccuratelyDescribe')).
'</div>';
245 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
246 $uselocalbrowser =
true;
247 $doleditor =
new DolEditor(
'message', $msg,
'100%', 230, $toolbarname,
'In',
true, $uselocalbrowser, $conf->global->FCKEDITOR_ENABLE_TICKET, ROWS_8,
'90%');
248 $doleditor->Create();
253 if (!empty($this->withfile)) {
255 $listofpaths = array();
256 $listofnames = array();
257 $listofmimes = array();
258 if (!empty($_SESSION[
"listofpaths"])) {
259 $listofpaths = explode(
';', $_SESSION[
"listofpaths"]);
262 if (!empty($_SESSION[
"listofnames"])) {
263 $listofnames = explode(
';', $_SESSION[
"listofnames"]);
266 if (!empty($_SESSION[
"listofmimes"])) {
267 $listofmimes = explode(
';', $_SESSION[
"listofmimes"]);
271 $out .=
'<td>'.$langs->trans(
"MailFile").
'</td>';
274 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
275 $out .=
'<script type="text/javascript" language="javascript">';
276 $out .=
'jQuery(document).ready(function () {';
277 $out .=
' jQuery(".removedfile").click(function() {';
278 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
281 $out .=
'</script>'.
"\n";
282 if (count($listofpaths)) {
283 foreach ($listofpaths as $key => $val) {
284 $out .=
'<div id="attachfile_'.$key.
'">';
285 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
286 if (!$this->withfilereadonly) {
287 $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.
'" />';
289 $out .=
'<br></div>';
292 $out .= $langs->trans(
"NoAttachedFiles").
'<br>';
294 if ($this->withfile == 2) {
295 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
297 $out .=
'<input type="submit" class="button" id="addfile" name="addfile" value="'.$langs->trans(
"MailingAddFile").
'" />';
299 $out .=
"</td></tr>\n";
305 if ($this->withusercreate > 0 && $this->fk_user_create) {
306 print '<tr><td class="titlefield">'.$langs->trans(
"CreatedBy").
'</td><td>';
307 $langs->load(
"users");
308 $fuser =
new User($this->
db);
310 if ($this->withcreatereadonly) {
311 if ($res = $fuser->fetch($this->fk_user_create)) {
312 print $fuser->getNomUrl(1);
316 print "</td></tr>\n";
320 if ($this->withcompany) {
322 if (empty($user->socid)) {
324 print '<tr><td class="titlefield">'.$langs->trans(
"ThirdParty").
'</td><td>';
326 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
328 print $form->select_company($this->withfromsocid,
'socid',
'', 1, 1,
'', $events, 0,
'minwidth200');
330 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
332 print '<script type="text/javascript">
333 $(document).ready(function () {
334 jQuery("#'.$htmlname.
'").change(function () {
335 var obj = '.json_encode($events).
';
336 $.each(obj, function(key,values) {
337 if (values.method.length) {
338 runJsCodeForEvent'.$htmlname.
'(values);
343 function runJsCodeForEvent'.$htmlname.
'(obj) {
344 console.log("Run runJsCodeForEvent'.$htmlname.
'");
345 var id = $("#'.$htmlname.
'").val();
346 var method = obj.method;
348 var htmlname = obj.htmlname;
349 var showempty = obj.showempty;
358 $.each(obj.params, function(key,action) {
360 var num = response.num;
362 $("#" + key).removeAttr(action);
364 $("#" + key).attr(action, action);
368 $("select#" + htmlname).html(response.value);
370 var selecthtml_str = response.value;
371 var selecthtml_dom=$.parseHTML(selecthtml_str);
372 $("#inputautocomplete"+htmlname).val(selecthtml_dom[0][0].innerHTML);
374 $("#inputautocomplete"+htmlname).val("");
376 $("select#" + htmlname).change(); /* Trigger event change */
385 print '<tr><td>'.$langs->trans(
"Contact").
'</td><td>';
387 $selectedCompany = ($this->withfromsocid > 0) ? $this->withfromsocid : -1;
389 print $form->selectcontacts($selectedCompany, $this->withfromcontactid,
'contactid', 3,
'',
'', 0,
'minwidth200');
391 $formcompany->selectTypeContact($ticketstatic,
'',
'type',
'external',
'', 0,
'maginleftonly');
394 print '<tr><td class="titlefield"><input type="hidden" name="socid" value="'.$user->socid.
'"/></td>';
395 print '<td><input type="hidden" name="contactid" value="'.$user->contact_id.
'"/></td>';
396 print '<td><input type="hidden" name="type" value="Z"/></td></tr>';
400 if (empty($this->ispublic))
402 print '<tr><td><label for="notify_tiers_at_create">'.$langs->trans(
"TicketNotifyTiersAtCreation").
'</label></td><td>';
403 print '<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate ?
' checked="checked"' :
'').
'>';
408 if (!empty($conf->projet->enabled) && !$this->ispublic)
411 print '<tr><td><label for="project"><span class="">'.$langs->trans(
"Project").
'</span></label></td><td>';
412 print img_picto(
'',
'project').$formproject->select_projects(-1,
GETPOST(
'projectid',
'int'),
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500');
417 $parameters = array();
418 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $ticketstat, $this->action);
421 print $ticketstat->showOptionals($extrafields,
'create');
428 print '<div class="center">';
429 print '<input class="button" type="submit" name="add" value="'.$langs->trans(($this->withthreadid > 0 ?
"SendResponse" :
"NewTicket")).
'" />';
430 if ($this->withcancel) {
431 print " ";
432 print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
437 print "<!-- End form TICKET -->\n";
453 public function selectTypesTickets($selected =
'', $htmlname =
'tickettype', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
455 global $langs, $user;
457 $ticketstat =
new Ticket($this->
db);
459 dol_syslog(get_class($this).
"::select_types_tickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
461 $filterarray = array();
463 if ($filtertype !=
'' && $filtertype !=
'-1') {
464 $filterarray = explode(
',', $filtertype);
467 $ticketstat->loadCacheTypesTickets();
469 print '<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
471 print '<option value=""> </option>';
474 if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
475 foreach ($ticketstat->cache_types_tickets as $id => $arraytypes) {
477 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
482 if ($empty && empty($arraytypes[
'code'])) {
487 print '<option value="'.$id.
'"';
491 print '<option value="'.$arraytypes[
'code'].
'"';
495 print '<option value="'.$arraytypes[
'code'].
'"';
499 print '<option value="'.$id.
'"';
503 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraytypes[
'code']) {
504 print ' selected="selected"';
505 } elseif ($selected == $id) {
506 print ' selected="selected"';
507 } elseif ($arraytypes[
'use_default'] ==
"1" && !$selected && !$empty) {
508 print ' selected="selected"';
514 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
515 } elseif ($format == 1) {
516 $value = $arraytypes[
'code'];
517 } elseif ($format == 2) {
518 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
519 } elseif ($format == 3) {
520 $value = $arraytypes[
'code'];
528 if ($user->admin && !$noadmininfo) {
529 print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
548 public function selectGroupTickets($selected =
'', $htmlname =
'ticketcategory', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
550 global $langs, $user;
552 $ticketstat =
new Ticket($this->
db);
554 dol_syslog(get_class($this).
"::selectCategoryTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
556 $filterarray = array();
558 if ($filtertype !=
'' && $filtertype !=
'-1') {
559 $filterarray = explode(
',', $filtertype);
562 $ticketstat->loadCacheCategoriesTickets();
564 print '<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
566 print '<option value=""> </option>';
569 if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
570 foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
572 if (count($filterarray) && !in_array($arraycategories[
'type'], $filterarray)) {
577 if ($empty && empty($arraycategories[
'code'])) {
582 print '<option value="'.$id.
'"';
586 print '<option value="'.$arraycategories[
'code'].
'"';
590 print '<option value="'.$arraycategories[
'code'].
'"';
594 print '<option value="'.$id.
'"';
598 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraycategories[
'code']) {
599 print ' selected="selected"';
600 } elseif ($selected == $id) {
601 print ' selected="selected"';
602 } elseif ($arraycategories[
'use_default'] ==
"1" && !$selected && !$empty) {
603 print ' selected="selected"';
609 $value = ($maxlength ?
dol_trunc($arraycategories[
'label'], $maxlength) : $arraycategories[
'label']);
613 $value = $arraycategories[
'code'];
617 $value = ($maxlength ?
dol_trunc($arraycategories[
'label'], $maxlength) : $arraycategories[
'label']);
621 $value = $arraycategories[
'code'];
624 print $value ? $value :
' ';
629 if ($user->admin && !$noadmininfo) {
630 print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
649 public function selectSeveritiesTickets($selected =
'', $htmlname =
'ticketseverity', $filtertype =
'', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss =
'')
651 global $langs, $user;
653 $ticketstat =
new Ticket($this->
db);
655 dol_syslog(get_class($this).
"::selectSeveritiesTickets ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
657 $filterarray = array();
659 if ($filtertype !=
'' && $filtertype !=
'-1') {
660 $filterarray = explode(
',', $filtertype);
663 $ticketstat->loadCacheSeveritiesTickets();
665 print '<select id="select'.$htmlname.
'" class="flat minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
667 print '<option value=""> </option>';
670 if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
671 foreach ($ticketstat->cache_severity_tickets as $id => $arrayseverities) {
673 if (count($filterarray) && !in_array($arrayseverities[
'type'], $filterarray)) {
678 if ($empty && empty($arrayseverities[
'code'])) {
683 print '<option value="'.$id.
'"';
687 print '<option value="'.$arrayseverities[
'code'].
'"';
691 print '<option value="'.$arrayseverities[
'code'].
'"';
695 print '<option value="'.$id.
'"';
699 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arrayseverities[
'code']) {
700 print ' selected="selected"';
701 } elseif ($selected == $id) {
702 print ' selected="selected"';
703 } elseif ($arrayseverities[
'use_default'] ==
"1" && !$selected && !$empty) {
704 print ' selected="selected"';
709 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
713 $value = $arrayseverities[
'code'];
717 $value = ($maxlength ?
dol_trunc($arrayseverities[
'label'], $maxlength) : $arrayseverities[
'label']);
721 $value = $arrayseverities[
'code'];
724 print $value ? $value :
' ';
729 if ($user->admin && !$noadmininfo) {
730 print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
746 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
749 $vardir = $conf->user->dir_output.
"/".$user->id;
750 $upload_dir = $vardir.
'/temp/';
753 $keytoavoidconflict = empty($this->trackid) ?
'' :
'-'.$this->trackid;
754 unset($_SESSION[
"listofpaths".$keytoavoidconflict]);
755 unset($_SESSION[
"listofnames".$keytoavoidconflict]);
756 unset($_SESSION[
"listofmimes".$keytoavoidconflict]);
767 global $conf, $langs, $user, $hookmanager, $form, $mysoc;
770 $addfileaction =
'addfile';
772 if (!is_object($form)) $form =
new Form($this->
db);
775 $langs->loadLangs(array(
'other',
'mails'));
778 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1'))
784 $outputlangs = $langs;
786 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param[
'langsmodels'];
787 if (!empty($newlang))
790 $outputlangs->setDefaultLang($newlang);
791 $outputlangs->load(
'other');
795 $arraydefaultmessage = -1;
796 if ($this->param[
'models'] !=
'none')
799 if (array_key_exists(
'models_id', $this->param))
801 $model_id = $this->param[
"models_id"];
804 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db, $this->param[
"models"], $user, $outputlangs, $model_id);
808 $listofpaths = array();
809 $listofnames = array();
810 $listofmimes = array();
811 $keytoavoidconflict = empty($this->trackid) ?
'' :
'-'.$this->trackid;
813 if (
GETPOST(
'mode',
'alpha') ==
'init' || (
GETPOST(
'modelmailselected',
'alpha') &&
GETPOST(
'modelmailselected',
'alpha') !=
'-1'))
815 if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param[
'fileinit']))
817 foreach ($this->param[
'fileinit'] as $file)
819 $this->add_attached_files($file, basename($file),
dol_mimetype($file));
824 if (!empty($_SESSION[
"listofpaths".$keytoavoidconflict])) $listofpaths = explode(
';', $_SESSION[
"listofpaths".$keytoavoidconflict]);
825 if (!empty($_SESSION[
"listofnames".$keytoavoidconflict])) $listofnames = explode(
';', $_SESSION[
"listofnames".$keytoavoidconflict]);
826 if (!empty($_SESSION[
"listofmimes".$keytoavoidconflict])) $listofmimes = explode(
';', $_SESSION[
"listofmimes".$keytoavoidconflict]);
829 $outputlangs = $langs;
831 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
832 $newlang = $this->param[
'langsmodels'];
834 if (!empty($newlang)) {
836 $outputlangs->setDefaultLang($newlang);
837 $outputlangs->load(
'other');
840 print "\n<!-- Begin message_form TICKET -->\n";
842 $send_email =
GETPOST(
'send_email',
'int') ?
GETPOST(
'send_email',
'int') : 0;
845 print '<script type="text/javascript" language="javascript">
846 jQuery(document).ready(function() {
847 send_email=' . $send_email.
';
849 jQuery(".email_line").show();
851 jQuery(".email_line").hide();
854 jQuery("#send_msg_email").click(function() {
855 if(jQuery(this).is(":checked")) {
856 jQuery(".email_line").show();
859 jQuery(".email_line").hide();
865 print '<form method="post" name="ticket" enctype="multipart/form-data" action="'.$this->param[
"returnurl"].
'">';
866 print '<input type="hidden" name="token" value="'.newToken().
'">';
867 print '<input type="hidden" name="action" value="'.$this->action.
'">';
868 print '<input type="hidden" name="actionbis" value="add_message">';
869 foreach ($this->param as $key => $value) {
870 print '<input type="hidden" name="'.$key.
'" value="'.$value.
'">';
875 if (array_key_exists(
'models_id', $this->param)) {
876 $model_id = $this->param[
"models_id"];
877 $arraydefaultmessage = $formmail->getEMailTemplate($this->
db, $this->param[
"models"], $user, $outputlangs, $model_id);
880 $result = $formmail->fetchAllEMailTemplate($this->param[
"models"], $user, $outputlangs);
884 $modelmail_array = array();
885 foreach ($formmail->lines_model as $line) {
886 $modelmail_array[$line->id] = $line->label;
889 print '<table class="border" width="'.$width.
'">';
892 if ($user->rights->ticket->write && !$user->socid)
894 print '<tr><td></td><td>';
895 $checkbox_selected = (
GETPOST(
'send_email') ==
"1" ?
' checked' :
'');
896 print '<input type="checkbox" name="send_email" value="1" id="send_msg_email" '.$checkbox_selected.
'/> ';
897 print '<label for="send_msg_email">'.$langs->trans(
'SendMessageByEmail').
'</label>';
901 if (count($modelmail_array) > 0) {
902 print '<tr class="email_line"><td></td><td colspan="2"><div style="padding: 3px 0 3px 0">'.
"\n";
903 print $langs->trans(
'SelectMailModel').
': '.$formmail->selectarray(
'modelmailselected', $modelmail_array, $this->param[
'models_id'], 1);
905 print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
908 print '<input class="button" type="submit" value="'.$langs->trans(
'Apply').
'" name="modelselected" id="modelselected">';
914 print '<tr><td></td><td>';
915 $checkbox_selected = (
GETPOST(
'private_message',
'alpha') ==
"1" ?
' checked' :
'');
916 print '<input type="checkbox" name="private_message" value="1" id="private_message" '.$checkbox_selected.
'/> ';
917 print '<label for="private_message">'.$langs->trans(
'MarkMessageAsPrivate').
'</label>';
918 print ' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
923 print '<tr class="email_line"><td class="titlefieldcreate">'.$langs->trans(
'Subject').
'</td>';
924 print '<td><input type="text" class="text minwidth500" name="subject" value="['.$conf->global->MAIN_INFO_SOCIETE_NOM.
' - '.$langs->trans(
"Ticket").
' '.$this->ref.
'] '.$langs->trans(
'TicketNewMessage').
'" />';
928 print '<tr class="email_line"><td>'.$langs->trans(
'MailRecipients').
'</td><td>';
929 $ticketstat =
new Ticket($this->
db);
930 $res = $ticketstat->fetch(
'',
'', $this->track_id);
933 $contacts = $ticketstat->getInfosTicketInternalContact();
934 $contacts = array_merge($contacts, $ticketstat->getInfosTicketExternalContact());
937 if (is_array($contacts) && count($contacts) > 0) {
938 foreach ($contacts as $key => $info_sendto) {
939 if ($info_sendto[
'email'] !=
'') {
940 $sendto[] =
dol_escape_htmltag(trim($info_sendto[
'firstname'].
" ".$info_sendto[
'lastname']).
" <".$info_sendto[
'email'].
">").
' <small class="opacitymedium">('.
dol_escape_htmltag($info_sendto[
'libelle']).
")</small>";
945 if ($ticketstat->origin_email && !in_array($this->dao->origin_email, $sendto)) {
946 $sendto[] =
dol_escape_htmltag($ticketstat->origin_email).
' <small class="opacitymedium">('.$langs->trans(
"TicketEmailOriginIssuer").
")</small>";
949 if ($ticketstat->fk_soc > 0) {
950 $ticketstat->socid = $ticketstat->fk_soc;
951 $ticketstat->fetch_thirdparty();
953 if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
954 $sendto[] = $ticketstat->thirdparty->email.
' <small class="opacitymedium">('.$langs->trans(
'Customer').
')</small>';
958 if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) {
959 $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO.
' <small class="opacitymedium">(generic email)</small>';
963 if (is_array($sendto) && count($sendto) > 0) {
964 print implode(
', ', $sendto);
966 print '<div class="warning">'.$langs->trans(
'WarningNoEMailsAdded').
' '.$langs->trans(
'TicketGoIntoContactTab').
'</div>';
974 if ($user->rights->ticket->write && !$user->socid) {
975 $mail_intro =
GETPOST(
'mail_intro') ?
GETPOST(
'mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO;
976 print '<tr class="email_line"><td><label for="mail_intro">';
977 print $form->textwithpicto($langs->trans(
"TicketMessageMailIntro"), $langs->trans(
"TicketMessageMailIntroHelp"), 1,
'help');
981 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
982 $uselocalbrowser =
true;
984 $doleditor =
new DolEditor(
'mail_intro', $mail_intro,
'100%', 90,
'dolibarr_details',
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
986 $doleditor->Create();
991 $defaultmessage =
"";
992 if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) {
993 $defaultmessage = $arraydefaultmessage->content;
995 $defaultmessage = str_replace(
'\n',
"\n", $defaultmessage);
999 $this->substit[
'__USER_SIGNATURE__'] =
dol_nl2br($this->substit[
'__USER_SIGNATURE__']);
1001 $defaultmessage =
dol_nl2br($defaultmessage);
1003 if (
GETPOSTISSET(
"message") && !$_POST[
'modelselected']) {
1004 $defaultmessage =
GETPOST(
'message',
'restricthtml');
1008 $defaultmessage = preg_replace(
"/^(<br>)+/",
"", $defaultmessage);
1009 $defaultmessage = preg_replace(
"/^\n+/",
"", $defaultmessage);
1012 print '<tr><td class="tdtop"><label for="message"><span class="fieldrequired">'.$langs->trans(
"Message").
'</span>';
1013 if ($user->rights->ticket->write && !$user->socid) {
1014 print $form->textwithpicto(
'', $langs->trans(
"TicketMessageHelp"), 1,
'help');
1016 print '</label></td><td>';
1018 $toolbarname =
'dolibarr_notes';
1019 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1020 $doleditor =
new DolEditor(
'message', $defaultmessage,
'100%', 200, $toolbarname,
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, 70);
1021 $doleditor->Create();
1026 if ($user->rights->ticket->write && !$user->socid) {
1027 $mail_signature =
GETPOST(
'mail_signature') ?
GETPOST(
'mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE;
1028 print '<tr class="email_line"><td><label for="mail_intro">'.$langs->trans(
"TicketMessageMailSignature").
'</label>';
1029 print $form->textwithpicto(
'', $langs->trans(
"TicketMessageMailSignatureHelp"), 1,
'help');
1031 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1032 $doleditor =
new DolEditor(
'mail_signature', $mail_signature,
'100%', 150,
'dolibarr_details',
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
1033 $doleditor->Create();
1038 if (!empty($this->withfile)) {
1040 $out .=
'<td width="180">'.$langs->trans(
"MailFile").
'</td>';
1043 $out .=
'<input type="hidden" class="removedfilehidden" name="removedfile" value="">'.
"\n";
1044 $out .=
'<script type="text/javascript" language="javascript">';
1045 $out .=
'jQuery(document).ready(function () {';
1046 $out .=
' jQuery(".removedfile").click(function() {';
1047 $out .=
' jQuery(".removedfilehidden").val(jQuery(this).val());';
1050 $out .=
'</script>'.
"\n";
1051 if (count($listofpaths)) {
1052 foreach ($listofpaths as $key => $val) {
1053 $out .=
'<div id="attachfile_'.$key.
'">';
1054 $out .=
img_mime($listofnames[$key]).
' '.$listofnames[$key];
1055 if (!$this->withfilereadonly) {
1056 $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.
'" />';
1058 $out .=
'<br></div>';
1061 $out .= $langs->trans(
"NoAttachedFiles").
'<br>';
1063 if ($this->withfile == 2) {
1064 $out .=
'<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans(
"Upload").
'" />';
1066 $out .=
'<input type="submit" class="button" id="'.$addfileaction.
'" name="'.$addfileaction.
'" value="'.$langs->trans(
"MailingAddFile").
'" />';
1068 $out .=
"</td></tr>\n";
1075 print '<center><br>';
1076 print '<input class="button" type="submit" name="btn_add_message" value="'.$langs->trans(
"AddMessage").
'" />';
1077 if ($this->withcancel) {
1078 print " ";
1079 print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1081 print "</center>\n";
1084 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.
Class to manage Dolibarr users.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
img_mime($file, $titlealt= '', $morecss= '')
Show MIME img of a file.
$conf db
API class for accounts.
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.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return mime type of a file.
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.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories) ...
Class to manage translations.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
dol_textishtml($msg, $option=0)
Return if a text is a html content.