67 public $errors = array();
72 public $cache_types_paiements = array();
73 public $cache_conditions_paiements = array();
74 public $cache_transport_mode = array();
75 public $cache_availability = array();
76 public $cache_demand_reason = array();
77 public $cache_types_fees = array();
78 public $cache_vatrates = array();
107 public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata =
'string', $moreparam =
'', $fieldrequired = 0, $notabletag = 0, $paramid =
'id', $help =
'')
109 global $conf, $langs;
114 if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match(
'/^select;/', $typeofdata)) {
116 $tmp = explode(
':', $typeofdata);
117 $ret .=
'<div class="editkey_'.$tmp[0].(!empty($tmp[1]) ?
' '.$tmp[1] :
'').
'" id="'.$htmlname.
'">';
118 if ($fieldrequired) {
119 $ret .=
'<span class="fieldrequired">';
124 $ret .= $langs->trans($text);
126 if ($fieldrequired) {
129 $ret .=
'</div>'.
"\n";
131 if ($fieldrequired) {
132 $ret .=
'<span class="fieldrequired">';
137 $ret .= $langs->trans($text);
139 if ($fieldrequired) {
144 if (empty($notabletag) && $perm) {
145 $ret .=
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
147 if ($fieldrequired) {
148 $ret .=
'<span class="fieldrequired">';
153 $ret .= $langs->trans($text);
155 if ($fieldrequired) {
158 if (!empty($notabletag)) {
161 if (empty($notabletag) && $perm) {
164 if (empty($notabletag) && $perm) {
165 $ret .=
'<td class="right">';
167 if ($htmlname &&
GETPOST(
'action',
'aZ09') !=
'edit'.$htmlname && $perm) {
168 $ret .=
'<a class="editfielda reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit'.$htmlname.
'&token='.
newToken().
'&'.$paramid.
'='.$object->id.$moreparam.
'">'.
img_edit($langs->trans(
'Edit'), ($notabletag ? 0 : 1)).
'</a>';
170 if (!empty($notabletag) && $notabletag == 1) {
173 if (!empty($notabletag) && $notabletag == 3) {
176 if (empty($notabletag) && $perm) {
179 if (empty($notabletag) && $perm) {
180 $ret .=
'</tr></table>';
207 public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata =
'string', $editvalue =
'', $extObject =
null, $custommsg =
null, $moreparam =
'', $notabletag = 0, $formatfunc =
'', $paramid =
'id', $gm =
'auto', $moreoptions = array())
209 global $conf, $langs;
214 if (empty($typeofdata)) {
215 return 'ErrorBadParameter typeofdata is empty';
218 if ($typeofdata ==
'datetime') {
219 $typeofdata =
'dayhour';
222 if (preg_match(
'/^(\w+)\((\d+)\)$/', $typeofdata, $reg)) {
223 if ($reg[1] ==
'varchar') {
224 $typeofdata =
'string';
225 } elseif ($reg[1] ==
'int') {
226 $typeofdata =
'numeric';
228 return 'ErrorBadParameter '.$typeofdata;
233 if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match(
'/^select;|day|datepicker|dayhour|datehourpicker/', $typeofdata)) {
234 $ret .= $this->
editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg);
236 $editmode = (
GETPOST(
'action',
'aZ09') ==
'edit'.$htmlname);
239 $ret .=
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].($moreparam ?
'?'.$moreparam :
'').
'">';
240 $ret .=
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
241 $ret .=
'<input type="hidden" name="token" value="'.newToken().
'">';
242 $ret .=
'<input type="hidden" name="'.$paramid.
'" value="'.$object->id.
'">';
243 if (empty($notabletag)) {
244 $ret .=
'<table class="nobordernopadding centpercent">';
246 if (empty($notabletag)) {
249 if (preg_match(
'/^(string|safehtmlstring|email)/', $typeofdata)) {
250 $tmp = explode(
':', $typeofdata);
251 $ret .=
'<input type="text" id="'.$htmlname.
'" name="'.$htmlname.
'" value="'.($editvalue ? $editvalue : $value).
'"'.(empty($tmp[1]) ?
'' :
' size="'.$tmp[1].
'"').
' autofocus>';
252 } elseif (preg_match(
'/^(integer)/', $typeofdata)) {
253 $tmp = explode(
':', $typeofdata);
254 $valuetoshow =
price2num($editvalue ? $editvalue : $value, 0);
255 $ret .=
'<input type="text" id="'.$htmlname.
'" name="'.$htmlname.
'" value="'.$valuetoshow.
'"'.(empty($tmp[1]) ?
'' :
' size="'.$tmp[1].
'"').
' autofocus>';
256 } elseif (preg_match(
'/^(numeric|amount)/', $typeofdata)) {
257 $tmp = explode(
':', $typeofdata);
258 $valuetoshow =
price2num($editvalue ? $editvalue : $value);
259 $ret .=
'<input type="text" id="'.$htmlname.
'" name="'.$htmlname.
'" value="'.($valuetoshow !=
'' ?
price($valuetoshow) :
'').
'"'.(empty($tmp[1]) ?
'' :
' size="'.$tmp[1].
'"').
' autofocus>';
260 } elseif (preg_match(
'/^(checkbox)/', $typeofdata)) {
261 $tmp = explode(
':', $typeofdata);
262 $ret .=
'<input type="checkbox" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $value .
'"' . (empty($tmp[1]) ?
'' : $tmp[1]) .
'/>';
263 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) {
264 $tmp = explode(
':', $typeofdata);
265 $cols = (empty($tmp[2]) ?
'' : $tmp[2]);
267 if (preg_match(
'/%/', $cols)) {
268 $morealt =
' style="width: '.$cols.
'"';
272 $valuetoshow = ($editvalue ? $editvalue : $value);
273 $ret .=
'<textarea id="'.$htmlname.
'" name="'.$htmlname.
'" wrap="soft" rows="'.(empty($tmp[1]) ?
'20' : $tmp[1]).
'"'.($cols ?
' cols="'.$cols.
'"' :
'class="quatrevingtpercent"').$morealt.
'" autofocus>';
276 $valuetoshow = str_replace(
'&',
'&', $valuetoshow);
278 $ret .=
'</textarea>';
279 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') {
280 $addnowlink = empty($moreoptions[
'addnowlink']) ? 0 : $moreoptions[
'addnowlink'];
281 $ret .= $this->
selectDate($value, $htmlname, 0, 0, 1,
'form'.$htmlname, 1, $addnowlink, 0,
'',
'',
'',
'', 1,
'',
'', $gm);
282 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') {
283 $addnowlink = empty($moreoptions[
'addnowlink']) ? 0 : $moreoptions[
'addnowlink'];
284 $ret .= $this->
selectDate($value, $htmlname, 1, 1, 1,
'form'.$htmlname, 1, $addnowlink, 0,
'',
'',
'',
'', 1,
'',
'', $gm);
285 } elseif (preg_match(
'/^select;/', $typeofdata)) {
286 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
287 $arraylist = array();
288 foreach ($arraydata as $val) {
289 $tmp = explode(
':', $val);
290 $tmpkey = str_replace(
'|',
':', $tmp[0]);
291 $arraylist[$tmpkey] = $tmp[1];
293 $ret .= $this->
selectarray($htmlname, $arraylist, $value);
294 } elseif (preg_match(
'/^ckeditor/', $typeofdata)) {
295 $tmp = explode(
':', $typeofdata);
296 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
297 $doleditor =
new DolEditor($htmlname, ($editvalue ? $editvalue : $value), (empty($tmp[2]) ?
'' : $tmp[2]), (empty($tmp[3]) ?
'100' : $tmp[3]), (empty($tmp[1]) ?
'dolibarr_notes' : $tmp[1]),
'In', (empty($tmp[5]) ? 0 : $tmp[5]), (isset($tmp[8]) ? ($tmp[8] ?
true :
false) :
true),
true, (empty($tmp[6]) ?
'20' : $tmp[6]), (empty($tmp[7]) ?
'100' : $tmp[7]));
298 $ret .= $doleditor->Create(1);
300 if (empty($notabletag)) {
305 if (empty($notabletag)) {
306 $ret .=
'<td class="left">';
309 $ret .=
'<input type="submit" class="smallpaddingimp button'.(empty($notabletag) ?
'' :
' ').
'" name="modify" value="'.$langs->trans(
"Modify").
'">';
310 if (preg_match(
'/ckeditor|textarea/', $typeofdata) && empty($notabletag)) {
313 $ret .=
'<input type="submit" class="smallpaddingimp button button-cancel'.(empty($notabletag) ?
'' :
' ').
'" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
314 if (empty($notabletag)) {
318 if (empty($notabletag)) {
319 $ret .=
'</tr></table>'.
"\n";
321 $ret .=
'</form>'.
"\n";
323 if (preg_match(
'/^(email)/', $typeofdata)) {
325 } elseif (preg_match(
'/^(amount|numeric)/', $typeofdata)) {
326 $ret .= ($value !=
'' ?
price($value,
'', $langs, 0, -1, -1, $conf->currency) :
'');
327 } elseif (preg_match(
'/^(checkbox)/', $typeofdata)) {
328 $tmp = explode(
':', $typeofdata);
329 $ret .=
'<input type="checkbox" disabled id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $value .
'"' . ($tmp[1] ? $tmp[1] :
'') .
'/>';
330 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) {
332 } elseif (preg_match(
'/^safehtmlstring/', $typeofdata)) {
334 } elseif (preg_match(
'/^restricthtml/', $typeofdata)) {
336 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') {
337 $ret .=
'<span class="valuedate">'.dol_print_date($value,
'day', $gm).
'</span>';
338 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') {
339 $ret .=
'<span class="valuedate">'.dol_print_date($value,
'dayhour', $gm).
'</span>';
340 } elseif (preg_match(
'/^select;/', $typeofdata)) {
341 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
342 $arraylist = array();
343 foreach ($arraydata as $val) {
344 $tmp = explode(
':', $val);
345 $arraylist[$tmp[0]] = $tmp[1];
347 $ret .= $arraylist[$value];
348 if ($htmlname ==
'fk_product_type') {
350 $ret =
img_picto($langs->trans(
"Product"),
'product',
'class="paddingleftonly paddingrightonly colorgrey"').$ret;
352 $ret =
img_picto($langs->trans(
"Service"),
'service',
'class="paddingleftonly paddingrightonly colorgrey"').$ret;
355 } elseif (preg_match(
'/^ckeditor/', $typeofdata)) {
357 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
358 $firstline = preg_replace(
'/<br>.*/',
'', $tmpcontent);
359 $firstline = preg_replace(
'/[\n\r].*/',
'', $firstline);
360 $tmpcontent = $firstline.((strlen($firstline) != strlen($tmpcontent)) ?
'...' :
'');
369 if ($formatfunc && method_exists($object, $formatfunc)) {
370 $ret = $object->$formatfunc($ret);
388 public function widgetForTranslation($fieldname, $object, $perm, $typeofdata =
'string', $check =
'', $morecss =
'')
390 global $conf, $langs, $extralanguages;
395 $arrayoflangcode = array();
396 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) {
397 $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
400 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
401 if (!is_object($extralanguages)) {
402 include_once DOL_DOCUMENT_ROOT.
'/core/class/extralanguages.class.php';
405 $extralanguages->fetch_name_extralanguages(
'societe');
407 if (!is_array($extralanguages->attributes[$object->element]) || empty($extralanguages->attributes[$object->element][$fieldname])) {
411 $result .=
'<!-- Widget for translation -->'.
"\n";
412 $result .=
'<div class="inline-block paddingleft image-'.$object->element.
'-'.$fieldname.
'">';
413 $s =
img_picto($langs->trans(
"ShowOtherLanguages"),
'language',
'',
false, 0, 0,
'',
'fa-15 editfieldlang');
417 $result .=
'<div class="inline-block hidden field-'.$object->element.
'-'.$fieldname.
'">';
419 $resultforextrlang =
'';
420 foreach ($arrayoflangcode as $langcode) {
421 $valuetoshow =
GETPOSTISSET(
'field-'.$object->element.
"-".$fieldname.
"-".$langcode) ?
GETPOST(
'field-'.$object->element.
'-'.$fieldname.
"-".$langcode, $check) :
'';
422 if (empty($valuetoshow)) {
423 $object->fetchValuesForExtraLanguages();
425 $valuetoshow = $object->array_languages[$fieldname][$langcode];
429 $resultforextrlang .= $s;
432 if ($typeofdata ==
'textarea') {
433 $resultforextrlang .=
'<textarea name="field-'.$object->element.
"-".$fieldname.
"-".$langcode.
'" id="'.$fieldname.
"-".$langcode.
'" class="'.$morecss.
'" rows="'.ROWS_2.
'" wrap="soft">';
434 $resultforextrlang .= $valuetoshow;
435 $resultforextrlang .=
'</textarea>';
437 $resultforextrlang .=
'<input type="text" class="inputfieldforlang '.($morecss ?
' '.$morecss :
'').
'" name="field-'.$object->element.
'-'.$fieldname.
'-'.$langcode.
'" value="'.$valuetoshow.
'">';
440 $result .= $resultforextrlang;
443 $result .=
'<script>$(".image-'.$object->element.
'-'.$fieldname.
'").click(function() { console.log("Toggle lang widget"); jQuery(".field-'.$object->element.
'-'.$fieldname.
'").toggle(); });</script>';
462 protected function editInPlace($object, $value, $htmlname, $condition, $inputType =
'textarea', $editvalue =
null, $extObject =
null, $custommsg =
null)
469 if (preg_match(
'/^text/', $inputType)) {
471 } elseif (preg_match(
'/^numeric/', $inputType)) {
472 $value =
price($value);
473 } elseif ($inputType ==
'day' || $inputType ==
'datepicker') {
479 $table_element =
false;
483 $ext_element =
false;
484 $button_only =
false;
489 if (is_object($object)) {
490 $element = $object->element;
491 $table_element = $object->table_element;
492 $fk_element = $object->id;
495 if (is_object($extObject)) {
496 $ext_element = $extObject->element;
499 if (preg_match(
'/^(string|email|numeric)/', $inputType)) {
500 $tmp = explode(
':', $inputType);
501 $inputType = $tmp[0];
502 if (!empty($tmp[1])) {
503 $inputOption = $tmp[1];
505 if (!empty($tmp[2])) {
506 $savemethod = $tmp[2];
508 $out .=
'<input id="width_'.$htmlname.
'" value="'.$inputOption.
'" type="hidden"/>'.
"\n";
509 } elseif ((preg_match(
'/^day$/', $inputType)) || (preg_match(
'/^datepicker/', $inputType)) || (preg_match(
'/^datehourpicker/', $inputType))) {
510 $tmp = explode(
':', $inputType);
511 $inputType = $tmp[0];
512 if (!empty($tmp[1])) {
513 $inputOption = $tmp[1];
515 if (!empty($tmp[2])) {
516 $savemethod = $tmp[2];
519 $out .=
'<input id="timestamp" type="hidden"/>'.
"\n";
520 } elseif (preg_match(
'/^(select|autocomplete)/', $inputType)) {
521 $tmp = explode(
':', $inputType);
522 $inputType = $tmp[0];
523 $loadmethod = $tmp[1];
524 if (!empty($tmp[2])) {
525 $savemethod = $tmp[2];
527 if (!empty($tmp[3])) {
530 } elseif (preg_match(
'/^textarea/', $inputType)) {
531 $tmp = explode(
':', $inputType);
532 $inputType = $tmp[0];
533 $rows = (empty($tmp[1]) ?
'8' : $tmp[1]);
534 $cols = (empty($tmp[2]) ?
'80' : $tmp[2]);
535 } elseif (preg_match(
'/^ckeditor/', $inputType)) {
536 $tmp = explode(
':', $inputType);
537 $inputType = $tmp[0];
539 if (!empty($tmp[2])) {
542 if (!empty($tmp[3])) {
545 if (!empty($tmp[4])) {
546 $savemethod = $tmp[4];
550 $out .=
'<input id="ckeditor_toolbar" value="'.$toolbar.
'" type="hidden"/>'.
"\n";
552 $inputType =
'textarea';
556 $out .=
'<input id="element_'.$htmlname.
'" value="'.$element.
'" type="hidden"/>'.
"\n";
557 $out .=
'<input id="table_element_'.$htmlname.
'" value="'.$table_element.
'" type="hidden"/>'.
"\n";
558 $out .=
'<input id="fk_element_'.$htmlname.
'" value="'.$fk_element.
'" type="hidden"/>'.
"\n";
559 $out .=
'<input id="loadmethod_'.$htmlname.
'" value="'.$loadmethod.
'" type="hidden"/>'.
"\n";
560 if (!empty($savemethod)) {
561 $out .=
'<input id="savemethod_'.$htmlname.
'" value="'.$savemethod.
'" type="hidden"/>'.
"\n";
563 if (!empty($ext_element)) {
564 $out .=
'<input id="ext_element_'.$htmlname.
'" value="'.$ext_element.
'" type="hidden"/>'.
"\n";
566 if (!empty($custommsg)) {
567 if (is_array($custommsg)) {
568 if (!empty($custommsg[
'success'])) {
569 $out .=
'<input id="successmsg_'.$htmlname.
'" value="'.$custommsg[
'success'].
'" type="hidden"/>'.
"\n";
571 if (!empty($custommsg[
'error'])) {
572 $out .=
'<input id="errormsg_'.$htmlname.
'" value="'.$custommsg[
'error'].
'" type="hidden"/>'.
"\n";
575 $out .=
'<input id="successmsg_'.$htmlname.
'" value="'.$custommsg.
'" type="hidden"/>'.
"\n";
578 if ($inputType ==
'textarea') {
579 $out .=
'<input id="textarea_'.$htmlname.
'_rows" value="'.$rows.
'" type="hidden"/>'.
"\n";
580 $out .=
'<input id="textarea_'.$htmlname.
'_cols" value="'.$cols.
'" type="hidden"/>'.
"\n";
582 $out .=
'<span id="viewval_'.$htmlname.
'" class="viewval_'.$inputType.($button_only ?
' inactive' :
' active').
'">'.$value.
'</span>'.
"\n";
583 $out .=
'<span id="editval_'.$htmlname.
'" class="editval_'.$inputType.($button_only ?
' inactive' :
' active').
' hideobject">'.(!empty($editvalue) ? $editvalue : $value).
'</span>'.
"\n";
609 public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img =
'', $extracss =
'', $notabs = 3, $incbefore =
'', $noencodehtmltext = 0, $tooltiptrigger =
'', $forcenowrap = 0)
612 $text = $incbefore.$text;
617 $direction = (int) $direction;
627 $htmltext = str_replace(array(
"\r",
"\n"),
'', $htmltext);
630 if ($direction < 0) {
631 $extracss = ($extracss ? $extracss.
' ' :
'').($notabs != 3 ?
'inline-block' :
'');
632 $extrastyle =
'padding: 0px; padding-left: 3px;';
634 if ($direction > 0) {
635 $extracss = ($extracss ? $extracss.
' ' :
'').($notabs != 3 ?
'inline-block' :
'');
636 $extrastyle =
'padding: 0px; padding-right: 3px;';
639 $classfortooltip =
'classfortooltip';
644 if ($tooltiptrigger ==
'') {
645 $htmltext = str_replace(
'"',
'"', $htmltext);
647 $classfortooltip =
'classfortooltiponclick';
648 $textfordialog .=
'<div style="display: none;" id="idfortooltiponclick_'.$tooltiptrigger.
'" class="classfortooltiponclicktext">'.$htmltext.
'</div>';
650 if ($tooltipon == 2 || $tooltipon == 3) {
651 $paramfortooltipimg =
' class="'.$classfortooltip.($notabs != 3 ?
' inline-block' :
'').($extracss ?
' '.$extracss :
'').
'" style="padding: 0px;'.($extrastyle ?
' '.$extrastyle :
'').
'"';
652 if ($tooltiptrigger ==
'') {
653 $paramfortooltipimg .=
' title="'.($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1)).
'"';
655 $paramfortooltipimg .=
' dolid="'.$tooltiptrigger.
'"';
658 $paramfortooltipimg = ($extracss ?
' class="'.$extracss.
'"' :
'').($extrastyle ?
' style="'.$extrastyle.
'"' :
'');
660 if ($tooltipon == 1 || $tooltipon == 3) {
661 $paramfortooltiptd =
' class="'.($tooltipon == 3 ?
'cursorpointer ' :
'').$classfortooltip.
' inline-block'.($extracss ?
' '.$extracss :
'').
'" style="padding: 0px;'.($extrastyle ?
' '.$extrastyle :
'').
'" ';
662 if ($tooltiptrigger ==
'') {
663 $paramfortooltiptd .=
' title="'.($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1)).
'"';
665 $paramfortooltiptd .=
' dolid="'.$tooltiptrigger.
'"';
668 $paramfortooltiptd = ($extracss ?
' class="'.$extracss.
'"' :
'').($extrastyle ?
' style="'.$extrastyle.
'"' :
'');
670 if (empty($notabs)) {
671 $s .=
'<table class="nobordernopadding"><tr style="height: auto;">';
672 } elseif ($notabs == 2) {
673 $s .=
'<div class="inline-block'.($forcenowrap ?
' nowrap' :
'').
'">';
676 if ($direction < 0) {
677 $s .=
'<'.$tag.$paramfortooltipimg;
679 $s .=
' class="valigntop" width="14"';
681 $s .=
'>'.$textfordialog.$img.
'</'.$tag.
'>';
685 if ((
string) $text !=
'') {
686 $s .=
'<'.$tag.$paramfortooltiptd.
'>'.$text.
'</'.$tag.
'>';
689 if ($direction > 0) {
690 $s .=
'<'.$tag.$paramfortooltipimg;
692 $s .=
' class="valignmiddle" width="14"';
694 $s .=
'>'.$textfordialog.$img.
'</'.$tag.
'>';
696 if (empty($notabs)) {
697 $s .=
'</tr></table>';
698 } elseif ($notabs == 2) {
719 public function textwithpicto($text, $htmltext, $direction = 1, $type =
'help', $extracss =
'', $noencodehtmltext = 0, $notabs = 3, $tooltiptrigger =
'', $forcenowrap = 0)
721 global $conf, $langs;
724 if ($tooltiptrigger) {
725 $alt = $langs->transnoentitiesnoconv(
"ClickToShowHelp");
731 } elseif ($type ==
'1') {
736 if (empty($conf->use_javascript_ajax)) {
737 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable') {
746 if (!empty($conf->dol_no_mouse_hover) && empty($tooltiptrigger)) {
747 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable') {
758 if ($type ==
'info') {
760 } elseif ($type ==
'help') {
761 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
762 } elseif ($type ==
'helpclickable') {
763 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
764 } elseif ($type ==
'superadmin') {
766 } elseif ($type ==
'admin') {
768 } elseif ($type ==
'warning') {
770 } elseif ($type !=
'none') {
774 return $this->
textwithtooltip($text, $htmltext, ((($tooltiptrigger && !$img) || strpos($type,
'clickable')) ? 3 : 2), $direction, $img, $extracss, $notabs,
'', $noencodehtmltext, $tooltiptrigger, $forcenowrap);
787 public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0, $name =
'massaction', $cssclass =
'checkforselect')
789 global $conf, $langs, $hookmanager;
793 $ret =
'<div class="centpercent center">';
794 $ret .=
'<select class="flat'.(empty($conf->use_javascript_ajax) ?
'' :
' hideobject').
' '.$name.
' '.$name.
'select valignmiddle alignstart" id="'.$name.
'" name="'.$name.
'"'.($disabled ?
' disabled="disabled"' :
'').
'>';
797 $parameters = array();
798 $reshook = $hookmanager->executeHooks(
'addMoreMassActions', $parameters);
800 if (count($arrayofaction) == 0 && empty($hookmanager->resPrint)) {
803 if (empty($reshook)) {
804 $ret .=
'<option value="0"'.($disabled ?
' disabled="disabled"' :
'').
'>-- '.$langs->trans(
"SelectAction").
' --</option>';
805 foreach ($arrayofaction as $code => $label) {
806 $ret .=
'<option value="'.$code.
'"'.($disabled ?
' disabled="disabled"' :
'').
' data-html="'.
dol_escape_htmltag($label).
'">'.$label.
'</option>';
809 $ret .= $hookmanager->resPrint;
813 if (empty($conf->dol_optimize_smallscreen)) {
818 $ret .=
'<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">';
819 $ret .=
'<input type="submit" disabled name="confirmmassaction"'.(empty($conf->use_javascript_ajax) ?
'' :
' style="display: none"').
' class="button smallpaddingimp'.(empty($conf->use_javascript_ajax) ?
'' :
' hideobject').
' '.$name.
' '.$name.
'confirmed" value="'.
dol_escape_htmltag($langs->trans(
"Confirm")).
'">';
822 if (!empty($conf->use_javascript_ajax)) {
823 $ret .=
'<!-- JS CODE TO ENABLE mass action select -->
825 function initCheckForSelect(mode, name, cssclass) /* mode is 0 during init of page or click all, 1 when we click on 1 checkboxi, "name" refers to the class of the massaction button, "cssclass" to the class of the checkfor select boxes */
827 atleastoneselected=0;
828 jQuery("."+cssclass).each(function( index ) {
829 /* console.log( index + ": " + $( this ).text() ); */
830 if ($(this).is(\':checked\')) atleastoneselected++;
833 console.log("initCheckForSelect mode="+mode+" name="+name+" cssclass="+cssclass+" atleastoneselected="+atleastoneselected);
835 if (atleastoneselected || '.$alwaysvisible.
')
837 jQuery("."+name).show();
838 '.($selected ?
'if (atleastoneselected) { jQuery("."+name+"select").val("'.$selected.
'").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', false); }' :
'').
'
839 '.($selected ?
'if (! atleastoneselected) { jQuery("."+name+"select").val("0").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', true); } ' :
'').
'
843 jQuery("."+name).hide();
844 jQuery("."+name+"other").hide();
848 jQuery(document).ready(function () {
849 initCheckForSelect(0, "' . $name.
'", "'.$cssclass.
'");
850 jQuery(".' . $cssclass.
'").click(function() {
851 initCheckForSelect(1, "'.$name.
'", "'.$cssclass.
'");
853 jQuery(".' . $name.
'select").change(function() {
854 var massaction = $( this ).val();
855 var urlform = $( this ).closest("form").attr("action").replace("#show_files","");
856 if (massaction == "builddoc")
858 urlform = urlform + "#show_files";
860 $( this ).closest("form").attr("action", urlform);
861 console.log("we select a mass action name='.$name.
' massaction="+massaction+" - "+urlform);
862 /* Warning: if you set submit button to disabled, post using Enter will no more work if there is no other button */
863 if ($(this).val() != \'0\')
865 jQuery(".' . $name.
'confirmed").prop(\'disabled\', false);
866 jQuery(".' . $name.
'other").hide(); /* To disable if another div was open */
867 jQuery(".' . $name.
'"+massaction).show();
871 jQuery(".' . $name.
'confirmed").prop(\'disabled\', true);
872 jQuery(".' . $name.
'other").hide(); /* To disable any div open */
900 public function select_country($selected =
'', $htmlname =
'country_id', $htmloption =
'', $maxlength = 0, $morecss =
'minwidth300', $usecodeaskey =
'', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0, $exclude_country_code = array(), $hideflags = 0)
903 global $conf, $langs, $mysoc;
905 $langs->load(
"dict");
908 $countryArray = array();
911 $atleastonefavorite = 0;
913 $sql =
"SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite, eec";
914 $sql .=
" FROM ".$this->db->prefix().
"c_country";
915 $sql .=
" WHERE active > 0";
918 dol_syslog(get_class($this).
"::select_country", LOG_DEBUG);
921 $out .=
'<select id="select'.$htmlname.
'" class="flat maxwidth200onsmartphone selectcountry'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" '.$htmloption.
'>';
922 $num = $this->db->num_rows(
$resql);
926 $obj = $this->
db->fetch_object(
$resql);
928 $countryArray[$i][
'rowid'] = $obj->rowid;
929 $countryArray[$i][
'code_iso'] = $obj->code_iso;
930 $countryArray[$i][
'code_iso3'] = $obj->code_iso3;
931 $countryArray[$i][
'label'] = ($obj->code_iso && $langs->transnoentitiesnoconv(
"Country".$obj->code_iso) !=
"Country".$obj->code_iso ? $langs->transnoentitiesnoconv(
"Country".$obj->code_iso) : ($obj->label !=
'-' ? $obj->label :
''));
932 $countryArray[$i][
'favorite'] = $obj->favorite;
933 $countryArray[$i][
'eec'] = $obj->eec;
934 $favorite[$i] = $obj->favorite;
939 if (empty($disablefavorites)) {
940 $array1_sort_order = SORT_DESC;
941 $array2_sort_order = SORT_ASC;
942 array_multisort($favorite, $array1_sort_order, $label, $array2_sort_order, $countryArray);
948 if (is_numeric($showempty)) {
949 $out .=
'<option value=""> </option>'.
"\n";
951 $out .=
'<option value="">'.$langs->trans($showempty).
'</option>'.
"\n";
955 if ($addspecialentries) {
957 $out .=
'<option value="special_allnotme"'.($selected ==
'special_allnotme' ?
' selected' :
'').
'>'.$langs->trans(
"CountriesExceptMe", $langs->transnoentitiesnoconv(
"Country".$mysoc->country_code)).
'</option>';
958 $out .=
'<option value="special_eec"'.($selected ==
'special_eec' ?
' selected' :
'').
'>'.$langs->trans(
"CountriesInEEC").
'</option>';
959 if ($mysoc->isInEEC()) {
960 $out .=
'<option value="special_eecnotme"'.($selected ==
'special_eecnotme' ?
' selected' :
'').
'>'.$langs->trans(
"CountriesInEECExceptMe", $langs->transnoentitiesnoconv(
"Country".$mysoc->country_code)).
'</option>';
962 $out .=
'<option value="special_noteec"'.($selected ==
'special_noteec' ?
' selected' :
'').
'>'.$langs->trans(
"CountriesNotInEEC").
'</option>';
963 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
966 foreach ($countryArray as $row) {
968 if (empty($row[
'rowid'])) {
971 if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row[
'code_iso'], $exclude_country_code)) {
975 if (empty($disablefavorites) && $row[
'favorite'] && $row[
'code_iso']) {
976 $atleastonefavorite++;
978 if (empty($row[
'favorite']) && $atleastonefavorite) {
979 $atleastonefavorite = 0;
980 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
985 $labeltoshow .=
dol_trunc($row[
'label'], $maxlength,
'middle');
987 $labeltoshow .=
' ';
989 if ($row[
'code_iso']) {
990 $labeltoshow .=
' <span class="opacitymedium">('.$row[
'code_iso'].
')</span>';
991 if (empty($hideflags)) {
992 $tmpflag =
picto_from_langcode($row[
'code_iso'],
'class="saturatemedium paddingrightonly"', 1);
993 $labeltoshow = $tmpflag.
' '.$labeltoshow;
997 if ($selected && $selected !=
'-1' && ($selected == $row[
'rowid'] || $selected == $row[
'code_iso'] || $selected == $row[
'code_iso3'] || $selected == $row[
'label'])) {
998 $out .=
'<option value="'.($usecodeaskey ? ($usecodeaskey ==
'code2' ? $row[
'code_iso'] : $row[
'code_iso3']) : $row[
'rowid']).
'" selected data-html="'.
dol_escape_htmltag($labeltoshow).
'" data-eec="'.((int) $row[
'eec']).
'">';
1000 $out .=
'<option value="'.($usecodeaskey ? ($usecodeaskey ==
'code2' ? $row[
'code_iso'] : $row[
'code_iso3']) : $row[
'rowid']).
'" data-html="'.
dol_escape_htmltag($labeltoshow).
'" data-eec="'.((int) $row[
'eec']).
'">';
1002 $out .= $labeltoshow;
1003 $out .=
'</option>'.
"\n";
1006 $out .=
'</select>';
1012 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1013 $out .=
ajax_combobox(
'select'.$htmlname, array(), 0, 0,
'resolve');
1032 public function select_incoterms($selected =
'', $location_incoterms =
'', $page =
'', $htmlname =
'incoterm_id', $htmloption =
'', $forcecombo = 1, $events = array(), $disableautocomplete = 0)
1035 global $conf, $langs;
1037 $langs->load(
"dict");
1041 $incotermArray = array();
1043 $sql =
"SELECT rowid, code";
1044 $sql .=
" FROM ".$this->db->prefix().
"c_incoterms";
1045 $sql .=
" WHERE active > 0";
1046 $sql .=
" ORDER BY code ASC";
1048 dol_syslog(get_class($this).
"::select_incoterm", LOG_DEBUG);
1051 if ($conf->use_javascript_ajax && !$forcecombo) {
1052 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1056 if (!empty($page)) {
1057 $out .=
'<form method="post" action="'.$page.
'">';
1058 $out .=
'<input type="hidden" name="action" value="set_incoterms">';
1059 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1062 $out .=
'<select id="'.$htmlname.
'" class="flat selectincoterm width75" name="'.$htmlname.
'" '.$htmloption.
'>';
1063 $out .=
'<option value="0"> </option>';
1064 $num = $this->
db->num_rows(
$resql);
1068 $obj = $this->
db->fetch_object(
$resql);
1069 $incotermArray[$i][
'rowid'] = $obj->rowid;
1070 $incotermArray[$i][
'code'] = $obj->code;
1074 foreach ($incotermArray as $row) {
1075 if ($selected && ($selected == $row[
'rowid'] || $selected == $row[
'code'])) {
1076 $out .=
'<option value="'.$row[
'rowid'].
'" selected>';
1078 $out .=
'<option value="'.$row[
'rowid'].
'">';
1082 $out .= $row[
'code'];
1085 $out .=
'</option>';
1088 $out .=
'</select>';
1090 if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
1091 $out .=
ajax_multiautocompleter(
'location_incoterms',
'', DOL_URL_ROOT.
'/core/ajax/locationincoterms.php').
"\n";
1092 $moreattrib .=
' autocomplete="off"';
1094 $out .=
'<input id="location_incoterms" class="maxwidthonsmartphone type="text" name="location_incoterms" value="'.$location_incoterms.
'">'.
"\n";
1096 if (!empty($page)) {
1097 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp nomargintop nomarginbottom" value="'.$langs->trans(
"Modify").
'"></form>';
1118 public function select_type_of_lines($selected =
'', $htmlname =
'type', $showempty = 0, $hidetext = 0, $forceall = 0)
1121 global $langs, $conf;
1126 if (empty($hidetext)) {
1127 print $langs->trans(
"Type").
': ';
1129 print
'<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
1131 print
'<option value="-1"';
1132 if ($selected == -1) {
1135 print
'> </option>';
1138 print
'<option value="0"';
1139 if (0 == $selected || ($selected == -1 &&
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') ==
'product')) {
1142 print
'>'.$langs->trans(
"Product");
1144 print
'<option value="1"';
1145 if (1 == $selected || ($selected == -1 &&
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') ==
'service')) {
1148 print
'>'.$langs->trans(
"Service");
1155 print $langs->trans(
"Service");
1156 print
'<input type="hidden" name="'.$htmlname.
'" value="1">';
1159 print $langs->trans(
"Product");
1160 print
'<input type="hidden" name="'.$htmlname.
'" value="0">';
1162 if ($forceall < 0) {
1163 print
'<input type="hidden" name="'.$htmlname.
'" value="1">';
1178 $num = count($this->cache_types_fees);
1185 $langs->load(
"trips");
1187 $sql =
"SELECT c.code, c.label";
1188 $sql .=
" FROM ".$this->db->prefix().
"c_type_fees as c";
1189 $sql .=
" WHERE active > 0";
1193 $num = $this->
db->num_rows(
$resql);
1197 $obj = $this->
db->fetch_object(
$resql);
1200 $label = ($obj->code != $langs->trans($obj->code) ? $langs->trans($obj->code) : $langs->trans($obj->label));
1201 $this->cache_types_fees[$obj->code] = $label;
1205 asort($this->cache_types_fees);
1226 global $user, $langs;
1228 dol_syslog(__METHOD__.
" selected=".$selected.
", htmlname=".$htmlname, LOG_DEBUG);
1232 print
'<select id="select_'.$htmlname.
'" class="flat" name="'.$htmlname.
'">';
1234 print
'<option value="-1"';
1235 if ($selected == -1) {
1238 print
'> </option>';
1241 foreach ($this->cache_types_fees as $key => $value) {
1242 print
'<option value="'.$key.
'"';
1243 if ($key == $selected) {
1253 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1280 public function select_company($selected =
'', $htmlname =
'socid', $filter =
'', $showempty =
'', $showtype = 0, $forcecombo = 0, $events = array(), $limit = 0, $morecss =
'minwidth100', $moreparam =
'', $selected_input_value =
'', $hidelabel = 1, $ajaxoptions = array(), $multiple =
false, $excludeids = array(), $showcode = 0)
1283 global $conf, $user, $langs;
1287 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && !$forcecombo) {
1288 if (is_null($ajaxoptions)) {
1289 $ajaxoptions = array();
1292 require_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1296 if ($selected && empty($selected_input_value)) {
1297 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1299 $societetmp->fetch($selected);
1300 $selected_input_value = $societetmp->name;
1305 $urloption =
'htmlname='.urlencode(str_replace(
'.',
'_', $htmlname)).
'&outjson=1&filter='.urlencode($filter).(empty($excludeids) ?
'' :
'&excludeids='.join(
',', $excludeids)).($showtype ?
'&showtype='.urlencode($showtype) :
'').($showcode ?
'&showcode='.urlencode($showcode) :
'');
1307 $out .=
'<style type="text/css">.ui-autocomplete { z-index: 1003; }</style>';
1308 if (empty($hidelabel)) {
1309 print $langs->trans(
"RefOrLabel").
' : ';
1310 } elseif ($hidelabel > 1) {
1311 $placeholder = $langs->trans(
"RefOrLabel");
1312 if ($hidelabel == 2) {
1313 $out .=
img_picto($langs->trans(
"Search"),
'search');
1316 $out .=
'<input type="text" class="'.$morecss.
'" name="search_'.$htmlname.
'" id="search_'.$htmlname.
'" value="'.$selected_input_value.
'"'.($placeholder ?
' placeholder="'.dol_escape_htmltag($placeholder).
'"' :
'').
' '.(!empty($conf->global->THIRDPARTY_SEARCH_AUTOFOCUS) ?
'autofocus' :
'').
' />';
1317 if ($hidelabel == 3) {
1318 $out .=
img_picto($langs->trans(
"Search"),
'search');
1321 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
1324 $out .= $this->
select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events,
'', 0, $limit, $morecss, $moreparam, $multiple, $excludeids, $showcode);
1352 public function select_thirdparty_list($selected =
'', $htmlname =
'socid', $filter =
'', $showempty =
'', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey =
'', $outputmode = 0, $limit = 0, $morecss =
'minwidth100', $moreparam =
'', $multiple =
false, $excludeids = array(), $showcode = 0)
1355 global $conf, $user, $langs;
1356 global $hookmanager;
1360 $outarray = array();
1362 if ($selected ===
'') {
1363 $selected = array();
1364 } elseif (!is_array($selected)) {
1365 $selected = array($selected);
1369 if (function_exists(
'testSqlAndScriptInject')) {
1376 $sql =
"SELECT s.rowid, s.nom as name, s.name_alias, s.tva_intra, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
1377 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1378 $sql .=
", s.address, s.zip, s.town";
1379 $sql .=
", dictp.code as country_code";
1381 $sql .=
" FROM ".$this->db->prefix().
"societe as s";
1382 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1383 $sql .=
" LEFT JOIN ".$this->db->prefix().
"c_country as dictp ON dictp.rowid = s.fk_pays";
1385 if (empty($user->rights->societe->client->voir) && !$user->socid) {
1386 $sql .=
", ".$this->db->prefix().
"societe_commerciaux as sc";
1388 $sql .=
" WHERE s.entity IN (".getEntity(
'societe').
")";
1389 if (!empty($user->socid)) {
1390 $sql .=
" AND s.rowid = ".((int) $user->socid);
1393 $sql .=
" AND (".$filter.
")";
1395 if (empty($user->rights->societe->client->voir) && !$user->socid) {
1396 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1398 if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) {
1399 $sql .=
" AND s.status <> 0";
1401 if (!empty($excludeids)) {
1402 $sql .=
" AND s.rowid NOT IN (".$this->db->sanitize(join(
',', $excludeids)).
")";
1405 $parameters = array();
1406 $reshook = $hookmanager->executeHooks(
'selectThirdpartyListWhere', $parameters);
1407 $sql .= $hookmanager->resPrint;
1409 if ($filterkey && $filterkey !=
'') {
1411 $prefix = empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE) ?
'%' :
'';
1413 $scrit = explode(
' ', $filterkey);
1415 if (count($scrit) > 1) {
1418 foreach ($scrit as $crit) {
1422 $sql .=
"(s.nom LIKE '".$this->db->escape($prefix.$crit).
"%')";
1425 if (count($scrit) > 1) {
1429 $sql .=
" OR s.barcode LIKE '".$this->db->escape($prefix.$filterkey).
"%'";
1431 $sql .=
" OR s.code_client LIKE '".$this->db->escape($prefix.$filterkey).
"%' OR s.code_fournisseur LIKE '".$this->
db->escape($prefix.$filterkey).
"%'";
1432 $sql .=
" OR s.name_alias LIKE '".$this->db->escape($prefix.$filterkey).
"%' OR s.tva_intra LIKE '".$this->
db->escape($prefix.$filterkey).
"%'";
1435 $sql .= $this->
db->order(
"nom",
"ASC");
1436 $sql .= $this->
db->plimit($limit, 0);
1439 dol_syslog(get_class($this).
"::select_thirdparty_list", LOG_DEBUG);
1443 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1448 $out .=
'<select id="'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'"'.($moreparam ?
' '.$moreparam :
'').
' name="'.$htmlname.($multiple ?
'[]' :
'').
'" '.($multiple ?
'multiple' :
'').
'>'.
"\n";
1450 $textifempty = (($showempty && !is_numeric($showempty)) ? $langs->trans($showempty) :
'');
1451 if (!empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
1454 if ($showempty && !is_numeric($showempty)) {
1455 $textifempty = $langs->trans($showempty);
1457 $textifempty .= $langs->trans(
"All");
1461 $out .=
'<option value="-1" data-html="'.dol_escape_htmltag(
'<span class="opacitymedium">'.($textifempty ? $textifempty :
' ').
'</span>').
'">'.$textifempty.
'</option>'.
"\n";
1466 $num = $this->
db->num_rows(
$resql);
1470 $obj = $this->
db->fetch_object(
$resql);
1472 if ($showcode || !empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
1473 if (($obj->client) && (!empty($obj->code_client))) {
1474 $label = $obj->code_client.
' - ';
1476 if (($obj->fournisseur) && (!empty($obj->code_fournisseur))) {
1477 $label .= $obj->code_fournisseur.
' - ';
1479 $label .=
' '.$obj->name;
1481 $label = $obj->name;
1484 if (!empty($obj->name_alias)) {
1485 $label .=
' ('.$obj->name_alias.
')';
1488 if (!empty($conf->global->SOCIETE_SHOW_VAT_IN_LIST) && !empty($obj->tva_intra)) {
1489 $label .=
' - '.$obj->tva_intra;
1492 $labelhtml = $label;
1495 $companytemp->id = $obj->rowid;
1496 $companytemp->client = $obj->client;
1497 $companytemp->fournisseur = $obj->fournisseur;
1498 $tmptype = $companytemp->getTypeUrl(1,
'', 0,
'span');
1500 $labelhtml .=
' '.$tmptype;
1503 if ($obj->client || $obj->fournisseur) {
1506 if ($obj->client == 1 || $obj->client == 3) {
1507 $label .= $langs->trans(
"Customer");
1509 if ($obj->client == 2 || $obj->client == 3) {
1510 $label .= ($obj->client == 3 ?
', ' :
'').$langs->trans(
"Prospect");
1512 if ($obj->fournisseur) {
1513 $label .= ($obj->client ?
', ' :
'').$langs->trans(
"Supplier");
1515 if ($obj->client || $obj->fournisseur) {
1520 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1521 $s = ($obj->address ?
' - '.$obj->address :
'').($obj->zip ?
' - '.$obj->zip :
'').($obj->town ?
' '.$obj->town :
'');
1522 if (!empty($obj->country_code)) {
1523 $s .=
', '.$langs->trans(
'Country'.$obj->country_code);
1529 if (empty($outputmode)) {
1530 if (in_array($obj->rowid, $selected)) {
1531 $out .=
'<option value="'.$obj->rowid.
'" selected data-html="'.
dol_escape_htmltag($labelhtml).
'">'.$label.
'</option>';
1533 $out .=
'<option value="'.$obj->rowid.
'" data-html="'.
dol_escape_htmltag($labelhtml).
'">'.$label.
'</option>';
1536 array_push($outarray, array(
'key'=>$obj->rowid,
'value'=>$label,
'label'=>$label,
'labelhtml'=>$labelhtml));
1540 if (($i % 10) == 0) {
1545 $out .=
'</select>'.
"\n";
1550 $this->result = array(
'nbofthirdparties'=>$num);
1573 global $langs, $conf;
1576 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
1577 $sql .=
" re.description, re.fk_facture_source";
1578 $sql .=
" FROM ".$this->db->prefix().
"societe_remise_except as re";
1579 $sql .=
" WHERE re.fk_soc = ".(int) $socid;
1580 $sql .=
" AND re.entity = ".$conf->entity;
1582 $sql .=
" AND ".$filter;
1584 $sql .=
" ORDER BY re.description ASC";
1586 dol_syslog(get_class($this).
"::select_remises", LOG_DEBUG);
1589 print
'<select id="select_'.$htmlname.
'" class="flat maxwidthonsmartphone" name="'.$htmlname.
'">';
1590 $num = $this->
db->num_rows(
$resql);
1592 $qualifiedlines = $num;
1596 print
'<option value="0"> </option>';
1598 $obj = $this->
db->fetch_object(
$resql);
1599 $desc =
dol_trunc($obj->description, 40);
1600 if (preg_match(
'/\(CREDIT_NOTE\)/', $desc)) {
1601 $desc = preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $desc);
1603 if (preg_match(
'/\(DEPOSIT\)/', $desc)) {
1604 $desc = preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"Deposit"), $desc);
1606 if (preg_match(
'/\(EXCESS RECEIVED\)/', $desc)) {
1607 $desc = preg_replace(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"ExcessReceived"), $desc);
1609 if (preg_match(
'/\(EXCESS PAID\)/', $desc)) {
1610 $desc = preg_replace(
'/\(EXCESS PAID\)/', $langs->trans(
"ExcessPaid"), $desc);
1614 if ($selected > 0 && $selected == $obj->rowid) {
1615 $selectstring =
' selected';
1619 if ($maxvalue > 0 && $obj->amount_ttc > $maxvalue) {
1621 $disabled =
' disabled';
1624 if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->fk_facture_source)) {
1626 if ($tmpfac->fetch($obj->fk_facture_source) > 0) {
1627 $desc = $desc.
' - '.$tmpfac->ref;
1631 print
'<option value="'.$obj->rowid.
'"'.$selectstring.$disabled.
'>'.$desc.
' ('.
price($obj->amount_ht).
' '.$langs->trans(
"HT").
' - '.
price($obj->amount_ttc).
' '.$langs->trans(
"TTC").
')</option>';
1638 return $qualifiedlines;
1666 public function select_contacts($socid, $selected =
'', $htmlname =
'contactid', $showempty = 0, $exclude =
'', $limitto =
'', $showfunction = 0, $morecss =
'', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only =
false, $moreparam =
'', $htmlid =
'')
1669 print $this->
selectcontacts($socid, $selected, $htmlname, $showempty, $exclude, $limitto, $showfunction, $morecss, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid);
1697 public function selectcontacts($socid, $selected =
'', $htmlname =
'contactid', $showempty = 0, $exclude =
'', $limitto =
'', $showfunction = 0, $morecss =
'', $options_only =
false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam =
'', $htmlid =
'', $multiple =
false, $disableifempty = 0)
1699 global $conf, $langs, $hookmanager, $action;
1701 $langs->load(
'companies');
1703 if (empty($htmlid)) {
1704 $htmlid = $htmlname;
1708 if ($selected ===
'') {
1709 $selected = array();
1710 } elseif (!is_array($selected)) {
1711 $selected = array($selected);
1715 if (!is_object($hookmanager)) {
1716 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1721 $sql =
"SELECT sp.rowid, sp.lastname, sp.statut, sp.firstname, sp.poste, sp.email, sp.phone, sp.phone_perso, sp.phone_mobile, sp.town AS contact_town";
1722 if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1723 $sql .=
", s.nom as company, s.town AS company_town";
1725 $sql .=
" FROM ".$this->db->prefix().
"socpeople as sp";
1726 if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1727 $sql .=
" LEFT OUTER JOIN ".$this->db->prefix().
"societe as s ON s.rowid=sp.fk_soc";
1729 $sql .=
" WHERE sp.entity IN (".getEntity(
'contact').
")";
1730 if ($socid > 0 || $socid == -1) {
1731 $sql .=
" AND sp.fk_soc = ".((int) $socid);
1733 if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) {
1734 $sql .=
" AND sp.statut <> 0";
1737 $parameters = array();
1738 $reshook = $hookmanager->executeHooks(
'selectContactListWhere', $parameters);
1739 $sql .= $hookmanager->resPrint;
1740 $sql .=
" ORDER BY sp.lastname ASC";
1742 dol_syslog(get_class($this).
"::selectcontacts", LOG_DEBUG);
1745 $num = $this->
db->num_rows(
$resql);
1747 if ($htmlname !=
'none' && !$options_only) {
1748 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlid.
'" name="'.$htmlname.(($num || empty($disableifempty)) ?
'' :
' disabled').($multiple ?
'[]' :
'').
'" '.($multiple ?
'multiple' :
'').
' '.(!empty($moreparam) ? $moreparam :
'').
'>';
1751 if ($showempty && ! is_numeric($showempty)) {
1752 $textforempty = $showempty;
1753 $out .=
'<option class="optiongrey" value="-1"'.(in_array(-1, $selected) ?
' selected' :
'').
'>'.$textforempty.
'</option>';
1755 if (($showempty == 1 || ($showempty == 3 && $num > 1)) && ! $multiple) {
1756 $out .=
'<option value="0"'.(in_array(0, $selected) ?
' selected' :
'').
'> </option>';
1758 if ($showempty == 2) {
1759 $out .=
'<option value="0"'.(in_array(0, $selected) ?
' selected' :
'').
'>-- '.$langs->trans(
"Internal").
' --</option>';
1765 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
1766 $contactstatic =
new Contact($this->
db);
1769 $obj = $this->
db->fetch_object(
$resql);
1772 $extendedInfos =
'';
1773 if (!empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1774 $extendedInfos = array();
1775 $email = trim($obj->email);
1776 if (!empty($email)) {
1777 $extendedInfos[] = $email;
1779 $phone = trim($obj->phone);
1780 $phone_perso = trim($obj->phone_perso);
1781 $phone_mobile = trim($obj->phone_mobile);
1782 if (!empty($phone)) {
1783 $extendedInfos[] = $phone;
1785 if (!empty($phone_perso)) {
1786 $extendedInfos[] = $phone_perso;
1788 if (!empty($phone_mobile)) {
1789 $extendedInfos[] = $phone_mobile;
1792 $contact_town = trim($obj->contact_town);
1793 $company_town = trim($obj->company_town);
1794 if (!empty($contact_town)) {
1795 $extendedInfos[] = $contact_town;
1796 } elseif (!empty($company_town)) {
1797 $extendedInfos[] = $company_town;
1799 $extendedInfos = implode(
' - ', $extendedInfos);
1800 if (!empty($extendedInfos)) {
1801 $extendedInfos =
' - '.$extendedInfos;
1805 $contactstatic->id = $obj->rowid;
1806 $contactstatic->lastname = $obj->lastname;
1807 $contactstatic->firstname = $obj->firstname;
1808 if ($obj->statut == 1) {
1809 if ($htmlname !=
'none') {
1811 if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) {
1814 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
1817 if (!empty($selected) && in_array($obj->rowid, $selected)) {
1818 $out .=
'<option value="'.$obj->rowid.
'"';
1820 $out .=
' disabled';
1822 $out .=
' selected>';
1823 $out .= $contactstatic->getFullName($langs).$extendedInfos;
1824 if ($showfunction && $obj->poste) {
1825 $out .=
' ('.$obj->poste.
')';
1827 if (($showsoc > 0) && $obj->company) {
1828 $out .=
' - ('.$obj->company.
')';
1830 $out .=
'</option>';
1832 $out .=
'<option value="'.$obj->rowid.
'"';
1834 $out .=
' disabled';
1837 $out .= $contactstatic->getFullName($langs).$extendedInfos;
1838 if ($showfunction && $obj->poste) {
1839 $out .=
' ('.$obj->poste.
')';
1841 if (($showsoc > 0) && $obj->company) {
1842 $out .=
' - ('.$obj->company.
')';
1844 $out .=
'</option>';
1847 if (in_array($obj->rowid, $selected)) {
1848 $out .= $contactstatic->getFullName($langs).$extendedInfos;
1849 if ($showfunction && $obj->poste) {
1850 $out .=
' ('.$obj->poste.
')';
1852 if (($showsoc > 0) && $obj->company) {
1853 $out .=
' - ('.$obj->company.
')';
1861 $labeltoshow = ($socid != -1) ? ($langs->trans($socid ?
"NoContactDefinedForThirdParty" :
"NoContactDefined")) : $langs->trans(
'SelectAThirdPartyFirst');
1862 $out .=
'<option class="disabled" value="-1"'.(($showempty == 2 || $multiple) ?
'' :
' selected').
' disabled="disabled">';
1863 $out .= $labeltoshow;
1864 $out .=
'</option>';
1867 $parameters = array(
1869 'htmlname'=>$htmlname,
1872 'showfunction'=>$showfunction,
1873 'showsoc'=>$showsoc,
1876 $reshook = $hookmanager->executeHooks(
'afterSelectContactOptions', $parameters, $this, $action);
1878 if ($htmlname !=
'none' && !$options_only) {
1879 $out .=
'</select>';
1882 if ($conf->use_javascript_ajax && !$forcecombo && !$options_only) {
1883 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1911 public function select_users($selected =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0')
1914 print $this->
select_dolusers($selected, $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity);
1942 public function select_dolusers($selected =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0', $maxlength = 0, $showstatus = 0, $morefilter =
'', $show_every = 0, $enableonlytext =
'', $morecss =
'', $notdisabled = 0, $outputmode = 0, $multiple =
false, $forcecombo = 0)
1945 global $conf, $user, $langs, $hookmanager;
1949 if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) {
1950 $selected = $user->id;
1953 if ($selected ===
'') {
1954 $selected = array();
1955 } elseif (!is_array($selected)) {
1956 $selected = array($selected);
1959 $excludeUsers =
null;
1960 $includeUsers =
null;
1963 if (is_array($exclude)) {
1964 $excludeUsers = implode(
",", $exclude);
1967 if (is_array($include)) {
1968 $includeUsers = implode(
",", $include);
1969 } elseif ($include ==
'hierarchy') {
1971 $includeUsers = implode(
",", $user->getAllChildIds(0));
1972 } elseif ($include ==
'hierarchyme') {
1974 $includeUsers = implode(
",", $user->getAllChildIds(1));
1978 $outarray = array();
1981 $sql =
"SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut as status, u.login, u.admin, u.entity, u.photo";
1982 if (
isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
1983 $sql .=
", e.label";
1985 $sql .=
" FROM ".$this->db->prefix().
"user as u";
1986 if (
isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
1987 $sql .=
" LEFT JOIN ".$this->db->prefix().
"entity as e ON e.rowid = u.entity";
1988 if ($force_entity) {
1989 $sql .=
" WHERE u.entity IN (0, ".$this->db->sanitize($force_entity).
")";
1991 $sql .=
" WHERE u.entity IS NOT NULL";
1994 if (
isModEnabled(
'multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1995 $sql .=
" LEFT JOIN ".$this->db->prefix().
"usergroup_user as ug";
1996 $sql .=
" ON ug.fk_user = u.rowid";
1997 $sql .=
" WHERE ug.entity = ".$conf->entity;
1999 $sql .=
" WHERE u.entity IN (0, ".$conf->entity.
")";
2002 if (!empty($user->socid)) {
2003 $sql .=
" AND u.fk_soc = ".((int) $user->socid);
2005 if (is_array($exclude) && $excludeUsers) {
2006 $sql .=
" AND u.rowid NOT IN (".$this->db->sanitize($excludeUsers).
")";
2008 if ($includeUsers) {
2009 $sql .=
" AND u.rowid IN (".$this->db->sanitize($includeUsers).
")";
2011 if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $notdisabled) {
2012 $sql .=
" AND u.statut <> 0";
2014 if (!empty($morefilter)) {
2015 $sql .=
" ".$morefilter;
2019 $reshook = $hookmanager->executeHooks(
'addSQLWhereFilterOnSelectUsers', array(), $this, $action);
2020 if (!empty($reshook)) {
2021 $sql .= $hookmanager->resPrint;
2024 if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) {
2025 $sql .=
" ORDER BY u.statut DESC, u.firstname ASC, u.lastname ASC";
2027 $sql .=
" ORDER BY u.statut DESC, u.lastname ASC, u.firstname ASC";
2030 dol_syslog(get_class($this).
"::select_dolusers", LOG_DEBUG);
2034 $num = $this->
db->num_rows(
$resql);
2038 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
' minwidth200').
'" id="'.$htmlname.
'" name="'.$htmlname.($multiple ?
'[]' :
'').
'" '.($multiple ?
'multiple' :
'').
' '.($disabled ?
' disabled' :
'').
'>';
2039 if ($show_empty && !$multiple) {
2040 $textforempty =
' ';
2041 if (!empty($conf->use_javascript_ajax)) {
2042 $textforempty =
' ';
2044 if (!is_numeric($show_empty)) {
2045 $textforempty = $show_empty;
2047 $out .=
'<option class="optiongrey" value="'.($show_empty < 0 ? $show_empty : -1).
'"'.((empty($selected) || in_array(-1, $selected)) ?
' selected' :
'').
'>'.$textforempty.
'</option>'.
"\n";
2050 $out .=
'<option value="-2"'.((in_array(-2, $selected)) ?
' selected' :
'').
'>-- '.$langs->trans(
"Everybody").
' --</option>'.
"\n";
2053 $userstatic =
new User($this->
db);
2056 $obj = $this->
db->fetch_object(
$resql);
2058 $userstatic->id = $obj->rowid;
2059 $userstatic->lastname = $obj->lastname;
2060 $userstatic->firstname = $obj->firstname;
2061 $userstatic->photo = $obj->photo;
2062 $userstatic->statut = $obj->status;
2063 $userstatic->entity = $obj->entity;
2064 $userstatic->admin = $obj->admin;
2067 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
2068 $disableline = ($enableonlytext ? $enableonlytext :
'1');
2071 $labeltoshow =
''; $labeltoshowhtml =
'';
2075 if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) {
2078 $labeltoshow .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
2079 $labeltoshowhtml .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
2080 if (empty($obj->firstname) && empty($obj->lastname)) {
2081 $labeltoshow .= $obj->login;
2082 $labeltoshowhtml .= $obj->login;
2086 $moreinfo =
''; $moreinfohtml =
'';
2087 if (!empty($conf->global->MAIN_SHOW_LOGIN)) {
2088 $moreinfo .= ($moreinfo ?
' - ' :
' (');
2089 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(');
2090 $moreinfo .= $obj->login;
2091 $moreinfohtml .= $obj->login;
2093 if ($showstatus >= 0) {
2094 if ($obj->status == 1 && $showstatus == 1) {
2095 $moreinfo .= ($moreinfo ?
' - ' :
' (').$langs->trans(
'Enabled');
2096 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(').$langs->trans(
'Enabled');
2098 if ($obj->status == 0 && $showstatus == 1) {
2099 $moreinfo .= ($moreinfo ?
' - ' :
' (').$langs->trans(
'Disabled');
2100 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(').$langs->trans(
'Disabled');
2103 if (
isModEnabled(
'multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
2104 if (!$obj->entity) {
2105 $moreinfo .= ($moreinfo ?
' - ' :
' (').$langs->trans(
"AllEntities");
2106 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(').$langs->trans(
"AllEntities");
2108 if ($obj->entity != $conf->entity) {
2109 $moreinfo .= ($moreinfo ?
' - ' :
' (').($obj->label ? $obj->label : $langs->trans(
"EntityNameNotDefined"));
2110 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(').($obj->label ? $obj->label : $langs->trans(
"EntityNameNotDefined"));
2114 $moreinfo .= ($moreinfo ?
')' :
'');
2115 $moreinfohtml .= ($moreinfohtml ?
')' :
'');
2116 if ($disableline && $disableline !=
'1') {
2118 $moreinfo .=
' - '.$disableline;
2119 $moreinfohtml .=
' - '.$disableline;
2121 $labeltoshow .= $moreinfo;
2122 $labeltoshowhtml .= $moreinfohtml;
2124 $out .=
'<option value="'.$obj->rowid.
'"';
2126 $out .=
' disabled';
2128 if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected))) {
2129 $out .=
' selected';
2131 $out .=
' data-html="';
2134 $outhtml .= $userstatic->getNomUrl(-3,
'', 0, 1, 24, 1,
'login',
'', 1).
' ';
2136 if ($showstatus >= 0 && $obj->status == 0) {
2137 $outhtml .=
'<strike class="opacitymediumxxx">';
2139 $outhtml .= $labeltoshowhtml;
2140 if ($showstatus >= 0 && $obj->status == 0) {
2141 $outhtml .=
'</strike>';
2145 $out .= $labeltoshow;
2146 $out .=
'</option>';
2148 $outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength).$moreinfo;
2153 $out .=
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'" disabled>';
2154 $out .=
'<option value="">'.$langs->trans(
"None").
'</option>';
2156 $out .=
'</select>';
2158 if ($num && !$forcecombo) {
2160 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
2198 public function select_dolusers_forevent($action =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0', $maxlength = 0, $showstatus = 0, $morefilter =
'', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array())
2201 global $conf, $user, $langs;
2203 $userstatic =
new User($this->
db);
2207 $assignedtouser = array();
2208 if (!empty($_SESSION[
'assignedtouser'])) {
2209 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
2211 $nbassignetouser = count($assignedtouser);
2214 if ($nbassignetouser) {
2215 $out .=
'<ul class="attendees">';
2219 foreach ($assignedtouser as $key => $value) {
2220 if ($value[
'id'] == $ownerid) {
2225 $userstatic->fetch($value[
'id']);
2226 $out .= $userstatic->getNomUrl(-1);
2228 $ownerid = $value[
'id'];
2229 $out .=
' ('.$langs->trans(
"Owner").
')';
2231 if ($nbassignetouser > 1 && $action !=
'view') {
2232 $out .=
' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans(
"Remove"),
'delete',
'', 0, 1).
'" value="'.$userstatic->id.
'" class="removedassigned reposition" id="removedassigned_'.$userstatic->id.
'" name="removedassigned_'.$userstatic->id.
'">';
2235 if ($showproperties) {
2236 if ($ownerid == $value[
'id'] && is_array($listofuserid) && count($listofuserid) && in_array($ownerid, array_keys($listofuserid))) {
2237 $out .=
'<div class="myavailability inline-block">';
2238 $out .=
'<span class="hideonsmartphone"> - <span class="opacitymedium">'.$langs->trans(
"Availability").
':</span> </span><input id="transparency" class="paddingrightonly" '.($action ==
'view' ?
'disabled' :
'').
' type="checkbox" name="transparency"'.($listofuserid[$ownerid][
'transparency'] ?
' checked' :
'').
'><label for="transparency">'.$langs->trans(
"Busy").
'</label>';
2248 if ($nbassignetouser) {
2253 if ($action !=
'view') {
2254 $out .=
'<input type="hidden" class="removedassignedhidden" name="removedassigned" value="">';
2255 $out .=
'<script type="text/javascript">jQuery(document).ready(function () {';
2256 $out .=
'jQuery(".removedassigned").click(function() { jQuery(".removedassignedhidden").val(jQuery(this).val()); });';
2257 $out .=
'jQuery(".assignedtouser").change(function() { console.log(jQuery(".assignedtouser option:selected").val());';
2258 $out .=
' if (jQuery(".assignedtouser option:selected").val() > 0) { jQuery("#'.$action.
'assignedtouser").attr("disabled", false); }';
2259 $out .=
' else { jQuery("#'.$action.
'assignedtouser").attr("disabled", true); }';
2261 $out .=
'})</script>';
2262 $out .= $this->
select_dolusers(
'', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter);
2263 $out .=
' <input type="submit" disabled class="button valignmiddle smallpaddingimp reposition" id="'.$action.
'assignedtouser" name="'.$action.
'assignedtouser" value="'.
dol_escape_htmltag($langs->trans(
"Add")).
'">';
2299 public function select_produits($selected =
'', $htmlname =
'productid', $filtertype =
'', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value =
'', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty =
'1', $forcecombo = 0, $morecss =
'', $hidepriceinlabel = 0, $warehouseStatus =
'', $selected_combinations =
null, $nooutput = 0, $status_purchase = -1)
2302 global $langs, $conf;
2307 $price_level = (!empty($price_level) ? $price_level : 0);
2308 if (is_null($ajaxoptions)) {
2309 $ajaxoptions = array();
2320 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
2323 if ($selected && empty($selected_input_value)) {
2324 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
2325 $producttmpselect =
new Product($this->
db);
2326 $producttmpselect->fetch($selected);
2327 $selected_input_value = $producttmpselect->ref;
2328 unset($producttmpselect);
2331 if ($filtertype ==
'') {
2339 $urloption =
'htmlname='.$htmlname.
'&outjson=1&price_level='.$price_level.
'&type='.$filtertype.
'&mode=1&status='.$status.
'&status_purchase='.$status_purchase.
'&finished='.$finished.
'&hidepriceinlabel='.$hidepriceinlabel.
'&warehousestatus='.$warehouseStatus;
2341 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
2342 $urloption .=
'&socid='.$socid;
2344 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
2346 if (
isModEnabled(
'variants') && is_array($selected_combinations)) {
2350 <!-- script to auto show attributes select tags if a variant was selected -->
2352 // auto show attributes fields
2353 selected = '.json_encode($selected_combinations).
';
2356 jQuery(document).ready(function () {
2358 jQuery("input[name=\'prod_entry_mode\']").change(function () {
2359 if (jQuery(this).val() == \'free\') {
2360 jQuery(\'div#attributes_box\').empty();
2364 jQuery("input#'.$htmlname.
'").change(function () {
2366 if (!jQuery(this).val()) {
2367 jQuery(\'div#attributes_box\').empty();
2371 console.log("A change has started. We get variants fields to inject html select");
2373 jQuery.getJSON("'.DOL_URL_ROOT.
'/variants/ajax/getCombinations.php", {
2374 id: jQuery(this).val()
2375 }, function (data) {
2376 jQuery(\'div#attributes_box\').empty();
2378 jQuery.each(data, function (key, val) {
2380 combvalues[val.id] = val.values;
2382 var span = jQuery(document.createElement(\'div\')).css({
2383 \'display\': \'table-row\'
2387 jQuery(document.createElement(\'div\')).text(val.label).css({
2388 \'font-weight\': \'bold\',
2389 \'display\': \'table-cell\'
2393 var html = jQuery(document.createElement(\'select\')).attr(\'name\', \'combinations[\' + val.id + \']\').css({
2394 \'margin-left\': \'15px\',
2395 \'white-space\': \'pre\'
2397 jQuery(document.createElement(\'option\')).val(\'\')
2400 jQuery.each(combvalues[val.id], function (key, val) {
2401 var tag = jQuery(document.createElement(\'option\')).val(val.id).html(val.value);
2403 if (selected[val.fk_product_attribute] == val.id) {
2404 tag.attr(\'selected\', \'selected\');
2411 jQuery(\'div#attributes_box\').append(span);
2416 '.($selected ?
'jQuery("input#'.$htmlname.
'").change();' :
'').
'
2422 if (empty($hidelabel)) {
2423 $out .= $langs->trans(
"RefOrLabel").
' : ';
2424 } elseif ($hidelabel > 1) {
2425 $placeholder =
' placeholder="'.$langs->trans(
"RefOrLabel").
'"';
2426 if ($hidelabel == 2) {
2427 $out .=
img_picto($langs->trans(
"Search"),
'search');
2430 $out .=
'<input type="text" class="minwidth100'.($morecss ?
' '.$morecss :
'').
'" name="search_'.$htmlname.
'" id="search_'.$htmlname.
'" value="'.$selected_input_value.
'"'.$placeholder.
' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ?
'autofocus' :
'').
' />';
2431 if ($hidelabel == 3) {
2432 $out .=
img_picto($langs->trans(
"Search"),
'search');
2435 $out .= $this->
select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level,
'', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus, $status_purchase);
2438 if (empty($nooutput)) {
2462 public function select_bom($selected =
'', $htmlname =
'bom_id', $limit = 0, $status = 1, $type = 0, $showempty =
'1', $morecss =
'', $nooutput =
'', $forcecombo = 0, $TProducts = [])
2465 global $conf, $user, $langs, $db;
2467 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
2473 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
2478 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
2480 $sql =
'SELECT b.rowid, b.ref, b.label, b.fk_product';
2481 $sql.=
' FROM '.MAIN_DB_PREFIX.
'bom_bom as b';
2482 $sql.=
' WHERE b.entity IN ('.getEntity(
'bom').
')';
2483 if (!empty($status)) $sql.=
' AND status = '. (
int) $status;
2484 if (!empty($type)) $sql.=
' AND bomtype = '. (
int) $type;
2485 if (!empty($TProducts)) $sql .=
' AND fk_product IN ('.$this->
db->sanitize(implode(
',', $TProducts)).
')';
2486 if (!empty($limit)) $sql.=
' LIMIT '. (
int) $limit;
2487 $resql = $db->query($sql);
2490 $out .=
'<option value="-1"';
2491 if (empty($selected)) $out .=
' selected';
2492 $out .=
'> </option>';
2494 while ($obj = $db->fetch_object(
$resql)) {
2496 $res = $product->fetch($obj->fk_product);
2497 $out .=
'<option value="'.$obj->rowid.
'"';
2498 if ($obj->rowid == $selected) $out .=
'selected';
2499 $out .=
'>'.$obj->ref.
' - '.$product->label .
' - '. $obj->label.
'</option>';
2505 if (empty($nooutput)) {
2538 public function select_produits_list($selected =
'', $htmlname =
'productid', $filtertype =
'', $limit = 20, $price_level = 0, $filterkey =
'', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty =
'1', $forcecombo = 0, $morecss =
'', $hidepriceinlabel = 0, $warehouseStatus =
'', $status_purchase = -1)
2541 global $langs, $conf;
2542 global $hookmanager;
2545 $outarray = array();
2549 $langs->load(
'other');
2552 $warehouseStatusArray = array();
2553 if (!empty($warehouseStatus)) {
2554 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
2555 if (preg_match(
'/warehouseclosed/', $warehouseStatus)) {
2558 if (preg_match(
'/warehouseopen/', $warehouseStatus)) {
2561 if (preg_match(
'/warehouseinternal/', $warehouseStatus)) {
2566 $selectFields =
" p.rowid, p.ref, p.label, p.description, p.barcode, p.fk_country, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.default_vat_code, p.duration, p.fk_price_expression";
2567 if (count($warehouseStatusArray)) {
2568 $selectFieldsGrouped =
", sum(".$this->db->ifsql(
"e.statut IS NULL",
"0",
"ps.reel").
") as stock";
2570 $selectFieldsGrouped =
", ".$this->db->ifsql(
"p.stock IS NULL", 0,
"p.stock").
" AS stock";
2574 $sql .= $selectFields.$selectFieldsGrouped;
2576 if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) {
2578 $sql .=
", (SELECT ".$this->db->prefix().
"categorie_product.fk_categorie
2579 FROM ".$this->
db->prefix().
"categorie_product
2580 WHERE ".$this->
db->prefix().
"categorie_product.fk_product=p.rowid
2582 ) AS categorie_product_id ";
2586 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
2587 $sql .=
', pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,';
2588 $sql .=
' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx, pcp.default_vat_code as custdefault_vat_code, pcp.ref_customer as custref';
2589 $selectFields .=
", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx, custdefault_vat_code, custref";
2593 $sql .=
", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units";
2594 $selectFields .=
', unit_long, unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units';
2599 $sql .=
", pl.label as label_translated";
2600 $sql .=
", pl.description as description_translated";
2601 $selectFields .=
", label_translated";
2602 $selectFields .=
", description_translated";
2605 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
2606 $sql .=
", (SELECT pp.rowid FROM ".$this->db->prefix().
"product_price as pp WHERE pp.fk_product = p.rowid";
2607 if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
2608 $sql .=
" AND price_level = ".((int) $price_level);
2610 $sql .=
" ORDER BY date_price";
2611 $sql .=
" DESC LIMIT 1) as price_rowid";
2612 $sql .=
", (SELECT pp.price_by_qty FROM ".$this->db->prefix().
"product_price as pp WHERE pp.fk_product = p.rowid";
2613 if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
2614 $sql .=
" AND price_level = ".((int) $price_level);
2616 $sql .=
" ORDER BY date_price";
2617 $sql .=
" DESC LIMIT 1) as price_by_qty";
2618 $selectFields .=
", price_rowid, price_by_qty";
2620 $sql .=
" FROM ".$this->db->prefix().
"product as p";
2621 if (count($warehouseStatusArray)) {
2622 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_stock as ps on ps.fk_product = p.rowid";
2623 $sql .=
" LEFT JOIN ".$this->db->prefix().
"entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (".
getEntity(
'stock').
")";
2624 $sql .=
' AND e.statut IN ('.$this->db->sanitize($this->
db->escape(implode(
',', $warehouseStatusArray))).
')';
2628 if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) {
2629 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
2633 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
2634 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_customer_price as pcp ON pcp.fk_soc=".((int) $socid).
" AND pcp.fk_product=p.rowid";
2638 $sql .=
" LEFT JOIN ".$this->db->prefix().
"c_units u ON u.rowid = p.fk_unit";
2642 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_lang as pl ON pl.fk_product = p.rowid ";
2643 if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && !empty($socid)) {
2644 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
2646 $result = $soc->fetch($socid);
2647 if ($result > 0 && !empty($soc->default_lang)) {
2648 $sql .=
" AND pl.lang = '".$this->db->escape($soc->default_lang).
"'";
2650 $sql .=
" AND pl.lang = '".$this->db->escape($langs->getDefaultLang()).
"'";
2653 $sql .=
" AND pl.lang = '".$this->db->escape($langs->getDefaultLang()).
"'";
2657 if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
2658 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_attribute_combination pac ON pac.fk_product_child = p.rowid";
2661 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
2663 if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
2664 $sql .=
" AND pac.rowid IS NULL";
2667 if ($finished == 0) {
2668 $sql .=
" AND p.finished = ".((int) $finished);
2669 } elseif ($finished == 1) {
2670 $sql .=
" AND p.finished = ".((int) $finished);
2672 $sql .=
" AND p.tosell = ".((int) $status);
2674 } elseif ($status >= 0) {
2675 $sql .=
" AND p.tosell = ".((int) $status);
2677 if ($status_purchase >= 0) {
2678 $sql .=
" AND p.tobuy = ".((int) $status_purchase);
2681 if (strval($filtertype) !=
'') {
2682 $sql .=
" AND p.fk_product_type = ".((int) $filtertype);
2684 $sql .=
" AND p.fk_product_type = 1";
2686 $sql .=
" AND p.fk_product_type = 0";
2689 $parameters = array();
2690 $reshook = $hookmanager->executeHooks(
'selectProductsListWhere', $parameters);
2691 $sql .= $hookmanager->resPrint;
2693 if ($filterkey !=
'') {
2695 $prefix = empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE) ?
'%' :
'';
2697 $scrit = explode(
' ', $filterkey);
2699 if (count($scrit) > 1) {
2702 foreach ($scrit as $crit) {
2706 $sql .=
"(p.ref LIKE '".$this->db->escape($prefix.$crit).
"%' OR p.label LIKE '".$this->
db->escape($prefix.$crit).
"%'";
2708 $sql .=
" OR pl.label LIKE '".$this->db->escape($prefix.$crit).
"%'";
2710 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
2711 $sql .=
" OR pcp.ref_customer LIKE '".$this->db->escape($prefix.$crit).
"%'";
2713 if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION)) {
2714 $sql .=
" OR p.description LIKE '".$this->db->escape($prefix.$crit).
"%'";
2716 $sql .=
" OR pl.description LIKE '".$this->db->escape($prefix.$crit).
"%'";
2719 if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) {
2720 $sql .=
" OR pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit).
"%'";
2725 if (count($scrit) > 1) {
2729 $sql .=
" OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey).
"%'";
2733 if (count($warehouseStatusArray)) {
2734 $sql .=
" GROUP BY ".$selectFields;
2738 if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) {
2739 $sql .=
" ORDER BY categorie_product_id ";
2741 ($conf->global->PRODUCT_SORT_BY_CATEGORY == 1) ? $sql .=
"ASC" : $sql .=
"DESC";
2743 $sql .= $this->
db->order(
"p.ref");
2746 $sql .= $this->
db->plimit($limit, 0);
2749 dol_syslog(get_class($this).
"::select_produits_list search products", LOG_DEBUG);
2750 $result = $this->
db->query($sql);
2752 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
2753 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
2754 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
2756 $num = $this->
db->num_rows($result);
2761 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
2765 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
2770 if (!empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
2771 if ($showempty && !is_numeric($showempty)) {
2772 $textifempty = $langs->trans($showempty);
2774 $textifempty .= $langs->trans(
"All");
2777 if ($showempty && !is_numeric($showempty)) {
2778 $textifempty = $langs->trans($showempty);
2782 $out .=
'<option value="-1" selected>'.($textifempty ? $textifempty :
' ').
'</option>';
2786 while ($num && $i < $num) {
2789 $objp = $this->
db->fetch_object($result);
2791 if ((!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1) {
2792 $sql =
"SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type";
2793 $sql .=
" FROM ".$this->db->prefix().
"product_price_by_qty";
2794 $sql .=
" WHERE fk_product_price = ".((int) $objp->price_rowid);
2795 $sql .=
" ORDER BY quantity ASC";
2797 dol_syslog(get_class($this).
"::select_produits_list search prices by qty", LOG_DEBUG);
2798 $result2 = $this->
db->query($sql);
2800 $nb_prices = $this->
db->num_rows($result2);
2802 while ($nb_prices && $j < $nb_prices) {
2803 $objp2 = $this->
db->fetch_object($result2);
2805 $objp->price_by_qty_rowid = $objp2->rowid;
2806 $objp->price_by_qty_price_base_type = $objp2->price_base_type;
2807 $objp->price_by_qty_quantity = $objp2->quantity;
2808 $objp->price_by_qty_unitprice = $objp2->unitprice;
2809 $objp->price_by_qty_remise_percent = $objp2->remise_percent;
2811 $objp->quantity = $objp2->quantity;
2812 $objp->price = $objp2->price;
2813 $objp->unitprice = $objp2->unitprice;
2814 $objp->remise_percent = $objp2->remise_percent;
2827 array_push($outarray, $optJson);
2831 if (
isModEnabled(
'dynamicprices') && !empty($objp->fk_price_expression)) {
2832 $price_product =
new Product($this->
db);
2833 $price_product->fetch($objp->rowid,
'',
'', 1);
2835 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
2837 $price_result = $priceparser->parseProduct($price_product);
2838 if ($price_result >= 0) {
2839 $objp->price = $price_result;
2840 $objp->unitprice = $price_result;
2842 $objp->price_ttc =
price2num($objp->price) * (1 + ($objp->tva_tx / 100));
2843 $objp->price_ttc =
price2num($objp->price_ttc,
'MU');
2852 array_push($outarray, $optJson);
2858 $out .=
'</select>';
2860 $this->
db->free($result);
2862 if (empty($outputmode)) {
2889 protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey =
'', $novirtualstock = 0)
2891 global $langs, $conf, $user;
2897 $outlabel_translated =
'';
2899 $outdesc_translated =
'';
2905 $outpricebasetype =
'';
2907 $outdefault_vat_code =
'';
2911 $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
2913 $label = $objp->label;
2914 if (!empty($objp->label_translated)) {
2915 $label = $objp->label_translated;
2917 if (!empty($filterkey) && $filterkey !=
'') {
2918 $label = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $label, 1);
2921 $outkey = $objp->rowid;
2922 $outref = $objp->ref;
2923 $outrefcust = empty($objp->custref) ?
'' : $objp->custref;
2924 $outlabel = $objp->label;
2925 $outdesc = $objp->description;
2927 $outlabel_translated = $objp->label_translated;
2928 $outdesc_translated = $objp->description_translated;
2930 $outbarcode = $objp->barcode;
2931 $outorigin = $objp->fk_country;
2932 $outpbq = empty($objp->price_by_qty_rowid) ?
'' : $objp->price_by_qty_rowid;
2934 $outtype = $objp->fk_product_type;
2938 if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) {
2939 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
2945 if (!empty($objp->unit_short)) {
2946 $outvalUnits .=
' - '.$objp->unit_short;
2949 if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) {
2950 if (!empty($objp->weight) && $objp->weight_units !==
null) {
2952 $outvalUnits .=
' - '.$unitToShow;
2954 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !==
null) {
2955 $unitToShow = $objp->length.
' x '.$objp->width.
' x '.$objp->height.
' '.
measuringUnitString(0,
'size', $objp->length_units);
2956 $outvalUnits .=
' - '.$unitToShow;
2958 if (!empty($objp->surface) && $objp->surface_units !==
null) {
2960 $outvalUnits .=
' - '.$unitToShow;
2962 if (!empty($objp->volume) && $objp->volume_units !==
null) {
2964 $outvalUnits .=
' - '.$unitToShow;
2967 if ($outdurationvalue && $outdurationunit) {
2969 'h' => $langs->trans(
'Hour'),
2970 'd' => $langs->trans(
'Day'),
2971 'w' => $langs->trans(
'Week'),
2972 'm' => $langs->trans(
'Month'),
2973 'y' => $langs->trans(
'Year')
2975 if (isset($da[$outdurationunit])) {
2976 $outvalUnits .=
' - '.$outdurationvalue.
' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ?
's' :
''));
2980 $opt =
'<option value="'.$objp->rowid.
'"';
2981 $opt .= ($objp->rowid == $selected) ?
' selected' :
'';
2982 if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) {
2983 $opt .=
' pbq="'.$objp->price_by_qty_rowid.
'" data-pbq="'.$objp->price_by_qty_rowid.
'" data-pbqup="'.$objp->price_by_qty_unitprice.
'" data-pbqbase="'.$objp->price_by_qty_price_base_type.
'" data-pbqqty="'.$objp->price_by_qty_quantity.
'" data-pbqpercent="'.$objp->price_by_qty_remise_percent.
'"';
2986 if (!empty($user->rights->stock->lire)) {
2987 if ($objp->stock > 0) {
2988 $opt .=
' class="product_line_stock_ok"';
2989 } elseif ($objp->stock <= 0) {
2990 $opt .=
' class="product_line_stock_too_low"';
2994 if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
2995 $opt .=
' data-labeltrans="'.$outlabel_translated.
'"';
2996 $opt .=
' data-desctrans="'.dol_escape_htmltag($outdesc_translated).
'"';
3000 if (!empty($objp->custref)) {
3001 $opt.=
' (' . $objp->custref .
')';
3004 $opt .=
' ('.$outbarcode.
')';
3006 $opt .=
' - '.dol_trunc($label, $maxlengtharticle);
3007 if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) {
3008 $opt .=
' ('.getCountry($outorigin, 1).
')';
3011 $objRef = $objp->ref;
3012 if (!empty($objp->custref)) {
3013 $objRef .=
' (' . $objp->custref .
')';
3015 if (!empty($filterkey) && $filterkey !=
'') {
3016 $objRef = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $objRef, 1);
3020 $outval .=
' ('.$outbarcode.
')';
3022 $outval .=
' - '.dol_trunc($label, $maxlengtharticle);
3023 if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) {
3024 $outval .=
' ('.getCountry($outorigin, 1).
')';
3028 $opt .= $outvalUnits;
3029 $outval .= $outvalUnits;
3035 if (empty($hidepriceinlabel) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
3036 $sql =
"SELECT price, price_ttc, price_base_type, tva_tx, default_vat_code";
3037 $sql .=
" FROM ".$this->db->prefix().
"product_price";
3038 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
3039 $sql .=
" AND entity IN (".getEntity(
'productprice').
")";
3040 $sql .=
" AND price_level = ".((int) $price_level);
3041 $sql .=
" ORDER BY date_price DESC, rowid DESC";
3044 dol_syslog(get_class($this).
'::constructProductListOption search price for product '.$objp->rowid.
' AND level '.$price_level, LOG_DEBUG);
3045 $result2 = $this->
db->query($sql);
3047 $objp2 = $this->
db->fetch_object($result2);
3050 if ($objp2->price_base_type ==
'HT') {
3051 $opt .=
' - '.price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"HT");
3052 $outval .=
' - '.price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"HT");
3054 $opt .=
' - '.price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"TTC");
3055 $outval .=
' - '.price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"TTC");
3057 $outprice_ht =
price($objp2->price);
3058 $outprice_ttc =
price($objp2->price_ttc);
3059 $outpricebasetype = $objp2->price_base_type;
3060 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
3061 $outtva_tx = $objp2->tva_tx;
3062 $outdefault_vat_code = $objp2->default_vat_code;
3064 $outtva_tx = $objp->tva_tx;
3065 $outdefault_vat_code = $objp->default_vat_code;
3074 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1 && (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
3076 $outqty = $objp->quantity;
3077 $outdiscount = $objp->remise_percent;
3078 if ($objp->quantity == 1) {
3079 $opt .=
' - '.price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency).
"/";
3080 $outval .=
' - '.price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency).
"/";
3081 $opt .= $langs->trans(
"Unit");
3082 $outval .= $langs->transnoentities(
"Unit");
3084 $opt .=
' - '.price($objp->price, 1, $langs, 0, 0, -1, $conf->currency).
"/".$objp->quantity;
3085 $outval .=
' - '.price($objp->price, 0, $langs, 0, 0, -1, $conf->currency).
"/".$objp->quantity;
3086 $opt .= $langs->trans(
"Units");
3087 $outval .= $langs->transnoentities(
"Units");
3090 $outprice_ht =
price($objp->unitprice);
3091 $outprice_ttc =
price($objp->unitprice * (1 + ($objp->tva_tx / 100)));
3092 $outpricebasetype = $objp->price_base_type;
3093 $outtva_tx = $objp->tva_tx;
3094 $outdefault_vat_code = $objp->default_vat_code;
3096 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1) {
3097 $opt .=
" (".price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency).
"/".$langs->trans(
"Unit").
")";
3098 $outval .=
" (".price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency).
"/".$langs->transnoentities(
"Unit").
")";
3100 if (empty($hidepriceinlabel) && !empty($objp->remise_percent) && $objp->remise_percent >= 1) {
3101 $opt .=
" - ".$langs->trans(
"Discount").
" : ".
vatrate($objp->remise_percent).
' %';
3102 $outval .=
" - ".$langs->transnoentities(
"Discount").
" : ".
vatrate($objp->remise_percent).
' %';
3106 if (empty($hidepriceinlabel) && !empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
3107 if (!empty($objp->idprodcustprice)) {
3110 if ($objp->custprice_base_type ==
'HT') {
3111 $opt .=
' - '.price($objp->custprice, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"HT");
3112 $outval .=
' - '.price($objp->custprice, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"HT");
3114 $opt .=
' - '.price($objp->custprice_ttc, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"TTC");
3115 $outval .=
' - '.price($objp->custprice_ttc, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"TTC");
3118 $outprice_ht =
price($objp->custprice);
3119 $outprice_ttc =
price($objp->custprice_ttc);
3120 $outpricebasetype = $objp->custprice_base_type;
3121 $outtva_tx = $objp->custtva_tx;
3122 $outdefault_vat_code = $objp->custdefault_vat_code;
3127 if (empty($hidepriceinlabel) && !$found) {
3128 if ($objp->price_base_type ==
'HT') {
3129 $opt .=
' - '.price($objp->price, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"HT");
3130 $outval .=
' - '.price($objp->price, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"HT");
3132 $opt .=
' - '.price($objp->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"TTC");
3133 $outval .=
' - '.price($objp->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"TTC");
3135 $outprice_ht =
price($objp->price);
3136 $outprice_ttc =
price($objp->price_ttc);
3137 $outpricebasetype = $objp->price_base_type;
3138 $outtva_tx = $objp->tva_tx;
3139 $outdefault_vat_code = $objp->default_vat_code;
3143 if (!empty($user->rights->stock->lire)) {
3144 $opt .=
' - '.$langs->trans(
"Stock").
': '.
price(
price2num($objp->stock,
'MS'));
3146 if ($objp->stock > 0) {
3147 $outval .=
' - <span class="product_line_stock_ok">';
3148 } elseif ($objp->stock <= 0) {
3149 $outval .=
' - <span class="product_line_stock_too_low">';
3151 $outval .= $langs->transnoentities(
"Stock").
': '.
price(
price2num($objp->stock,
'MS'));
3152 $outval .=
'</span>';
3153 if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) {
3154 $langs->load(
"stocks");
3157 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3158 $tmpproduct->load_virtual_stock();
3159 $virtualstock = $tmpproduct->stock_theorique;
3161 $opt .=
' - '.$langs->trans(
"VirtualStock").
':'.$virtualstock;
3163 $outval .=
' - '.$langs->transnoentities(
"VirtualStock").
':';
3164 if ($virtualstock > 0) {
3165 $outval .=
'<span class="product_line_stock_ok">';
3166 } elseif ($virtualstock <= 0) {
3167 $outval .=
'<span class="product_line_stock_too_low">';
3169 $outval .= $virtualstock;
3170 $outval .=
'</span>';
3177 $opt .=
"</option>\n";
3182 'label2'=>$outlabel,
3189 'pricebasetype'=>$outpricebasetype,
3190 'tva_tx'=>$outtva_tx,
3191 'default_vat_code'=>$outdefault_vat_code,
3193 'discount'=>$outdiscount,
3194 'duration_value'=>$outdurationvalue,
3195 'duration_unit'=>$outdurationunit,
3197 'labeltrans'=>$outlabel_translated,
3198 'desctrans'=>$outdesc_translated,
3199 'ref_customer'=>$outrefcust
3219 public function select_produits_fournisseurs($socid, $selected =
'', $htmlname =
'productid', $filtertype =
'', $filtre =
'', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss =
'', $placeholder =
'')
3222 global $langs, $conf;
3223 global $price_level, $status, $finished;
3225 if (!isset($status)) {
3229 $selected_input_value =
'';
3230 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
3231 if ($selected > 0) {
3232 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
3233 $producttmpselect =
new Product($this->
db);
3234 $producttmpselect->fetch($selected);
3235 $selected_input_value = $producttmpselect->ref;
3236 unset($producttmpselect);
3240 $urloption = ($socid > 0 ?
'socid='.$socid.
'&' :
'').
'htmlname='.$htmlname.
'&outjson=1&price_level='.$price_level.
'&type='.$filtertype.
'&mode=2&status='.$status.
'&finished='.$finished.
'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice;
3241 print
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
3242 print ($hidelabel ?
'' : $langs->trans(
"RefOrLabel").
' : ').
'<input type="text" class="minwidth300" name="search_'.$htmlname.
'" id="search_'.$htmlname.
'" value="'.$selected_input_value.
'"'.($placeholder ?
' placeholder="'.$placeholder.
'"' :
'').
'>';
3244 print $this->
select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre,
'', $status, 0, 0, $alsoproductwithnosupplierprice, $morecss, 0, $placeholder);
3267 public function select_produits_fournisseurs_list($socid, $selected =
'', $htmlname =
'productid', $filtertype =
'', $filtre =
'', $filterkey =
'', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss =
'', $showstockinlist = 0, $placeholder =
'')
3270 global $langs, $conf, $user;
3271 global $hookmanager;
3274 $outarray = array();
3276 $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
3278 $langs->load(
'stocks');
3281 $langs->load(
'other');
3284 $sql =
"SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type, p.stock, p.tva_tx as tva_tx_sale, p.default_vat_code as default_vat_code_sale,";
3285 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
3286 $sql .=
" pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.default_vat_code, pfp.fk_soc, s.nom as name,";
3287 $sql .=
" pfp.supplier_reputation";
3289 if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) {
3290 $sql .=
", pfp.desc_fourn as description";
3292 $sql .=
", p.description";
3296 $sql .=
", u.label as unit_long, u.short_label as unit_short, p.weight, p.weight_units, p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.surface, p.surface_units, p.volume, p.volume_units";
3299 $sql .=
", pfp.barcode";
3301 $sql .=
" FROM ".$this->db->prefix().
"product as p";
3302 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (".
getEntity(
'product').
") )";
3304 $sql .=
" AND pfp.fk_soc = ".((int) $socid);
3306 $sql .=
" LEFT JOIN ".$this->db->prefix().
"societe as s ON pfp.fk_soc = s.rowid";
3309 $sql .=
" LEFT JOIN ".$this->db->prefix().
"c_units u ON u.rowid = p.fk_unit";
3311 $sql .=
" WHERE p.entity IN (".getEntity(
'product').
")";
3312 if ($statut != -1) {
3313 $sql .=
" AND p.tobuy = ".((int) $statut);
3315 if (strval($filtertype) !=
'') {
3316 $sql .=
" AND p.fk_product_type = ".((int) $filtertype);
3318 if (!empty($filtre)) {
3319 $sql .=
" ".$filtre;
3322 $parameters = array();
3323 $reshook = $hookmanager->executeHooks(
'selectSuppliersProductsListWhere', $parameters);
3324 $sql .= $hookmanager->resPrint;
3326 if ($filterkey !=
'') {
3328 $prefix = empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE) ?
'%' :
'';
3330 $scrit = explode(
' ', $filterkey);
3332 if (count($scrit) > 1) {
3335 foreach ($scrit as $crit) {
3339 $sql .=
"(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit).
"%' OR p.ref LIKE '".$this->
db->escape($prefix.$crit).
"%' OR p.label LIKE '".$this->
db->escape($prefix.$crit).
"%'";
3340 if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) {
3341 $sql .=
" OR pfp.desc_fourn LIKE '".$this->db->escape($prefix.$crit).
"%'";
3346 if (count($scrit) > 1) {
3350 $sql .=
" OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey).
"%'";
3351 $sql .=
" OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey).
"%'";
3355 $sql .=
" ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
3356 $sql .= $this->
db->plimit($limit, 0);
3360 dol_syslog(get_class($this).
"::select_produits_fournisseurs_list", LOG_DEBUG);
3361 $result = $this->
db->query($sql);
3363 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
3364 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
3366 $num = $this->
db->num_rows($result);
3369 $out .=
'<select class="flat '.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.
'">';
3371 $out .=
'<option value="-1" selected>'.($placeholder ? $placeholder :
' ').
'</option>';
3373 $out .=
'<option value="-1">'.($placeholder ? $placeholder :
' ').
'</option>';
3378 $objp = $this->
db->fetch_object($result);
3380 if (is_null($objp->idprodfournprice)) {
3382 $objp->tva_tx = $objp->tva_tx_sale;
3383 $objp->default_vat_code = $objp->default_vat_code_sale;
3386 $outkey = $objp->idprodfournprice;
3387 if (!$outkey && $alsoproductwithnosupplierprice) {
3388 $outkey =
'idprod_'.$objp->rowid;
3391 $outref = $objp->ref;
3392 $outbarcode = $objp->barcode;
3395 $outtype = $objp->fk_product_type;
3402 if (!empty($objp->unit_short)) {
3403 $outvalUnits .=
' - '.$objp->unit_short;
3405 if (!empty($objp->weight) && $objp->weight_units !==
null) {
3407 $outvalUnits .=
' - '.$unitToShow;
3409 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !==
null) {
3410 $unitToShow = $objp->length.
' x '.$objp->width.
' x '.$objp->height.
' '.
measuringUnitString(0,
'size', $objp->length_units);
3411 $outvalUnits .=
' - '.$unitToShow;
3413 if (!empty($objp->surface) && $objp->surface_units !==
null) {
3415 $outvalUnits .=
' - '.$unitToShow;
3417 if (!empty($objp->volume) && $objp->volume_units !==
null) {
3419 $outvalUnits .=
' - '.$unitToShow;
3421 if ($outdurationvalue && $outdurationunit) {
3423 'h' => $langs->trans(
'Hour'),
3424 'd' => $langs->trans(
'Day'),
3425 'w' => $langs->trans(
'Week'),
3426 'm' => $langs->trans(
'Month'),
3427 'y' => $langs->trans(
'Year')
3429 if (isset($da[$outdurationunit])) {
3430 $outvalUnits .=
' - '.$outdurationvalue.
' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ?
's' :
''));
3435 $objRef = $objp->ref;
3436 if ($filterkey && $filterkey !=
'') {
3437 $objRef = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $objRef, 1);
3439 $objRefFourn = $objp->ref_fourn;
3440 if ($filterkey && $filterkey !=
'') {
3441 $objRefFourn = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $objRefFourn, 1);
3443 $label = $objp->label;
3444 if ($filterkey && $filterkey !=
'') {
3445 $label = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $label, 1);
3448 $optlabel = $objp->ref;
3449 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
3450 $optlabel .=
' <span class="opacitymedium">('.$objp->ref_fourn.
')</span>';
3452 if (
isModEnabled(
'barcode') && !empty($objp->barcode)) {
3453 $optlabel .=
' ('.$outbarcode.
')';
3455 $optlabel .=
' - '.dol_trunc($label, $maxlengtharticle);
3457 $outvallabel = $objRef;
3458 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
3459 $outvallabel .=
' ('.$objRefFourn.
')';
3461 if (
isModEnabled(
'barcode') && !empty($objp->barcode)) {
3462 $outvallabel .=
' ('.$outbarcode.
')';
3464 $outvallabel .=
' - '.dol_trunc($label, $maxlengtharticle);
3467 $optlabel .= $outvalUnits;
3468 $outvallabel .= $outvalUnits;
3470 if (!empty($objp->idprodfournprice)) {
3471 $outqty = $objp->quantity;
3472 $outdiscount = $objp->remise_percent;
3473 if (
isModEnabled(
'dynamicprices') && !empty($objp->fk_supplier_price_expression)) {
3475 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
3476 $prod_supplier->id = $objp->fk_product;
3477 $prod_supplier->fourn_qty = $objp->quantity;
3478 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
3479 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
3481 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
3483 $price_result = $priceparser->parseProductSupplier($prod_supplier);
3484 if ($price_result >= 0) {
3485 $objp->fprice = $price_result;
3486 if ($objp->quantity >= 1) {
3487 $objp->unitprice = $objp->fprice / $objp->quantity;
3491 if ($objp->quantity == 1) {
3492 $optlabel .=
' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency).
"/";
3493 $outvallabel .=
' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency).
"/";
3494 $optlabel .= $langs->trans(
"Unit");
3495 $outvallabel .= $langs->transnoentities(
"Unit");
3497 $optlabel .=
' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency).
"/".$objp->quantity;
3498 $outvallabel .=
' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency).
"/".$objp->quantity;
3499 $optlabel .=
' '.$langs->trans(
"Units");
3500 $outvallabel .=
' '.$langs->transnoentities(
"Units");
3503 if ($objp->quantity > 1) {
3504 $optlabel .=
" (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency).
"/".$langs->trans(
"Unit").
")";
3505 $outvallabel .=
" (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency).
"/".$langs->transnoentities(
"Unit").
")";
3507 if ($objp->remise_percent >= 1) {
3508 $optlabel .=
" - ".$langs->trans(
"Discount").
" : ".
vatrate($objp->remise_percent).
' %';
3509 $outvallabel .=
" - ".$langs->transnoentities(
"Discount").
" : ".
vatrate($objp->remise_percent).
' %';
3511 if ($objp->duration) {
3512 $optlabel .=
" - ".$objp->duration;
3513 $outvallabel .=
" - ".$objp->duration;
3516 $optlabel .=
" - ".dol_trunc($objp->name, 8);
3517 $outvallabel .=
" - ".dol_trunc($objp->name, 8);
3519 if ($objp->supplier_reputation) {
3521 $reputations = array(
''=>$langs->trans(
'Standard'),
'FAVORITE'=>$langs->trans(
'Favorite'),
'NOTTHGOOD'=>$langs->trans(
'NotTheGoodQualitySupplier'),
'DONOTORDER'=>$langs->trans(
'DoNotOrderThisProductToThisSupplier'));
3523 $optlabel .=
" - ".$reputations[$objp->supplier_reputation];
3524 $outvallabel .=
" - ".$reputations[$objp->supplier_reputation];
3527 if (empty($alsoproductwithnosupplierprice)) {
3528 $optlabel .=
" - <span class='opacitymedium'>".$langs->trans(
"NoPriceDefinedForThisSupplier").
'</span>';
3529 $outvallabel .=
' - '.$langs->transnoentities(
"NoPriceDefinedForThisSupplier");
3532 $optlabel .=
" - <span class='opacitymedium'>".$langs->trans(
"NoPriceDefinedForThisSupplier").
'</span>';
3533 $outvallabel .=
' - '.$langs->transnoentities(
"NoPriceDefinedForThisSupplier");
3537 if (
isModEnabled(
'stock') && $showstockinlist && isset($objp->stock) && ($objp->fk_product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
3538 $novirtualstock = ($showstockinlist == 2);
3540 if (!empty($user->rights->stock->lire)) {
3541 $outvallabel .=
' - '.$langs->trans(
"Stock").
': '.
price(
price2num($objp->stock,
'MS'));
3543 if ($objp->stock > 0) {
3544 $optlabel .=
' - <span class="product_line_stock_ok">';
3545 } elseif ($objp->stock <= 0) {
3546 $optlabel .=
' - <span class="product_line_stock_too_low">';
3548 $optlabel .= $langs->transnoentities(
"Stock").
':'.
price(
price2num($objp->stock,
'MS'));
3549 $optlabel .=
'</span>';
3550 if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) {
3551 $langs->load(
"stocks");
3554 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3555 $tmpproduct->load_virtual_stock();
3556 $virtualstock = $tmpproduct->stock_theorique;
3558 $outvallabel .=
' - '.$langs->trans(
"VirtualStock").
':'.$virtualstock;
3560 $optlabel .=
' - '.$langs->transnoentities(
"VirtualStock").
':';
3561 if ($virtualstock > 0) {
3562 $optlabel .=
'<span class="product_line_stock_ok">';
3563 } elseif ($virtualstock <= 0) {
3564 $optlabel .=
'<span class="product_line_stock_too_low">';
3566 $optlabel .= $virtualstock;
3567 $optlabel .=
'</span>';
3574 $optstart =
'<option value="'.$outkey.
'"';
3575 if ($selected && $selected == $objp->idprodfournprice) {
3576 $optstart .=
' selected';
3578 if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) {
3579 $optstart .=
' disabled';
3582 if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
3583 $optstart .=
' data-product-id="'.dol_escape_htmltag($objp->rowid).
'"';
3584 $optstart .=
' data-price-id="'.dol_escape_htmltag($objp->idprodfournprice).
'"';
3585 $optstart .=
' data-qty="'.dol_escape_htmltag($objp->quantity).
'"';
3586 $optstart .=
' data-up="'.dol_escape_htmltag(
price2num($objp->unitprice)).
'"';
3587 $optstart .=
' data-up-locale="'.dol_escape_htmltag(
price($objp->unitprice)).
'"';
3588 $optstart .=
' data-discount="'.dol_escape_htmltag($outdiscount).
'"';
3589 $optstart .=
' data-tvatx="'.dol_escape_htmltag(
price2num($objp->tva_tx)).
'"';
3590 $optstart .=
' data-tvatx-formated="'.dol_escape_htmltag(
price($objp->tva_tx, 0, $langs, 1, -1, 2)).
'"';
3591 $optstart .=
' data-default-vat-code="'.dol_escape_htmltag($objp->default_vat_code).
'"';
3593 $optstart .=
' data-description="'.dol_escape_htmltag($objp->description, 0, 1).
'"';
3595 $outarrayentry = array(
3598 'label' => $outvallabel,
3600 'price_qty_ht' =>
price2num($objp->fprice,
'MU'),
3601 'price_unit_ht' =>
price2num($objp->unitprice,
'MU'),
3602 'price_ht' =>
price2num($objp->unitprice,
'MU'),
3603 'tva_tx_formated' =>
price($objp->tva_tx, 0, $langs, 1, -1, 2),
3605 'default_vat_code' => $objp->default_vat_code,
3606 'discount' => $outdiscount,
3608 'duration_value' => $outdurationvalue,
3609 'duration_unit' => $outdurationunit,
3610 'disabled' => (empty($objp->idprodfournprice) ?
true :
false),
3611 'description' => $objp->description
3614 $parameters = array(
3616 'optstart' => &$optstart,
3617 'optlabel' => &$optlabel,
3618 'outvallabel' => &$outvallabel,
3619 'outarrayentry' => &$outarrayentry
3621 $reshook = $hookmanager->executeHooks(
'selectProduitsFournisseurListOption', $parameters, $this);
3627 $out .= $optstart .
' data-html="'.dol_escape_htmltag($optlabel).
'">' . $optlabel .
"</option>\n";
3630 array(
'key'=>$outkey,
3632 'label'=>$outvallabel,
3634 'price_qty_ht'=>
price2num($objp->fprice,
'MU'),
3635 'price_qty_ht_locale'=>
price($objp->fprice),
3636 'price_unit_ht'=>
price2num($objp->unitprice,
'MU'),
3637 'price_unit_ht_locale'=>
price($objp->unitprice),
3638 'price_ht'=>
price2num($objp->unitprice,
'MU'),
3639 'tva_tx_formated' =>
price($objp->tva_tx),
3641 'default_vat_code'=>$objp->default_vat_code,
3642 'discount'=>$outdiscount,
3644 'duration_value'=>$outdurationvalue,
3645 'duration_unit'=>$outdurationunit,
3646 'disabled'=>(empty($objp->idprodfournprice) ?
true :
false),
3647 'description'=>$objp->description
3661 $out .=
'</select>';
3663 $this->
db->free($result);
3665 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
3671 if (empty($outputmode)) {
3689 global $langs, $conf;
3691 $langs->load(
'stocks');
3693 $sql =
"SELECT p.rowid, p.ref, p.label, p.price, p.duration, pfp.fk_soc,";
3694 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,";
3695 $sql .=
" pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name";
3696 $sql .=
" FROM ".$this->db->prefix().
"product as p";
3697 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
3698 $sql .=
" LEFT JOIN ".$this->db->prefix().
"societe as s ON pfp.fk_soc = s.rowid";
3699 $sql .=
" WHERE pfp.entity IN (".getEntity(
'productsupplierprice').
")";
3700 $sql .=
" AND p.tobuy = 1";
3701 $sql .=
" AND s.fournisseur = 1";
3702 $sql .=
" AND p.rowid = ".((int) $productid);
3703 if (empty($conf->global->PRODUCT_BEST_SUPPLIER_PRICE_PRESELECTED)) {
3704 $sql .=
" ORDER BY s.nom, pfp.ref_fourn DESC";
3706 $sql .=
" ORDER BY pfp.unitprice ASC";
3709 dol_syslog(get_class($this).
"::select_product_fourn_price", LOG_DEBUG);
3710 $result = $this->
db->query($sql);
3713 $num = $this->
db->num_rows($result);
3715 $form =
'<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
3718 $form .=
'<option value="0">-- '.$langs->trans(
"NoSupplierPriceDefinedForThisProduct").
' --</option>';
3720 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
3721 $form .=
'<option value="0"> </option>';
3725 $objp = $this->
db->fetch_object($result);
3727 $opt =
'<option value="'.$objp->idprodfournprice.
'"';
3729 if ($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier) || ($i == 0 && !empty($conf->global->PRODUCT_BEST_SUPPLIER_PRICE_PRESELECTED))) {
3730 $opt .=
' selected';
3732 $opt .=
'>'.$objp->name.
' - '.$objp->ref_fourn.
' - ';
3734 if (
isModEnabled(
'dynamicprices') && !empty($objp->fk_supplier_price_expression)) {
3736 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
3737 $prod_supplier->id = $productid;
3738 $prod_supplier->fourn_qty = $objp->quantity;
3739 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
3740 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
3742 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
3744 $price_result = $priceparser->parseProductSupplier($prod_supplier);
3745 if ($price_result >= 0) {
3746 $objp->fprice = $price_result;
3747 if ($objp->quantity >= 1) {
3748 $objp->unitprice = $objp->fprice / $objp->quantity;
3752 if ($objp->quantity == 1) {
3753 $opt .=
price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency).
"/";
3756 $opt .= $objp->quantity.
' ';
3758 if ($objp->quantity == 1) {
3759 $opt .= $langs->trans(
"Unit");
3761 $opt .= $langs->trans(
"Units");
3763 if ($objp->quantity > 1) {
3765 $opt .=
price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency).
"/".$langs->trans(
"Unit");
3767 if ($objp->duration) {
3768 $opt .=
" - ".$objp->duration;
3770 $opt .=
"</option>\n";
3777 $form .=
'</select>';
3778 $this->
db->free($result);
3796 public function select_address($selected, $socid, $htmlname =
'address_id', $showempty = 0)
3800 $sql =
"SELECT a.rowid, a.label";
3801 $sql .=
" FROM ".$this->db->prefix().
"societe_address as a";
3802 $sql .=
" WHERE a.fk_soc = ".((int) $socid);
3803 $sql .=
" ORDER BY a.label ASC";
3805 dol_syslog(get_class($this).
"::select_address", LOG_DEBUG);
3808 print
'<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
3810 print
'<option value="0"> </option>';
3812 $num = $this->
db->num_rows(
$resql);
3816 $obj = $this->
db->fetch_object(
$resql);
3818 if ($selected && $selected == $obj->rowid) {
3819 print
'<option value="'.$obj->rowid.
'" selected>'.$obj->label.
'</option>';
3821 print
'<option value="'.$obj->rowid.
'">'.$obj->label.
'</option>';
3845 $num = count($this->cache_conditions_paiements);
3852 $sql =
"SELECT rowid, code, libelle as label, deposit_percent";
3853 $sql .=
" FROM ".$this->db->prefix().
'c_payment_term';
3854 $sql .=
" WHERE entity IN (".getEntity(
'c_payment_term').
")";
3855 $sql .=
" AND active > 0";
3856 $sql .=
" ORDER BY sortorder";
3860 $num = $this->
db->num_rows(
$resql);
3863 $obj = $this->
db->fetch_object(
$resql);
3866 $label = ($langs->trans(
"PaymentConditionShort".$obj->code) != (
"PaymentConditionShort".$obj->code) ? $langs->trans(
"PaymentConditionShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
3867 $this->cache_conditions_paiements[$obj->rowid][
'code'] = $obj->code;
3868 $this->cache_conditions_paiements[$obj->rowid][
'label'] = $label;
3869 $this->cache_conditions_paiements[$obj->rowid][
'deposit_percent'] = $obj->deposit_percent;
3893 $num = count($this->cache_availability);
3900 $langs->load(
'propal');
3902 $sql =
"SELECT rowid, code, label, position";
3903 $sql .=
" FROM ".$this->db->prefix().
'c_availability';
3904 $sql .=
" WHERE active > 0";
3908 $num = $this->
db->num_rows(
$resql);
3911 $obj = $this->
db->fetch_object(
$resql);
3914 $label = ($langs->trans(
"AvailabilityType".$obj->code) != (
"AvailabilityType".$obj->code) ? $langs->trans(
"AvailabilityType".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
3915 $this->cache_availability[$obj->rowid][
'code'] = $obj->code;
3916 $this->cache_availability[$obj->rowid][
'label'] = $label;
3917 $this->cache_availability[$obj->rowid][
'position'] = $obj->position;
3921 $this->cache_availability =
dol_sort_array($this->cache_availability,
'position',
'asc', 0, 0, 1);
3942 global $langs, $user;
3946 dol_syslog(__METHOD__.
" selected=".$selected.
", htmlname=".$htmlname, LOG_DEBUG);
3948 print
'<select id="'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
3950 print
'<option value="0"> </option>';
3952 foreach ($this->cache_availability as $id => $arrayavailability) {
3953 if ($selected == $id) {
3954 print
'<option value="'.$id.
'" selected>';
3956 print
'<option value="'.$id.
'">';
3963 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3977 $num = count($this->cache_demand_reason);
3982 $sql =
"SELECT rowid, code, label";
3983 $sql .=
" FROM ".$this->db->prefix().
'c_input_reason';
3984 $sql .=
" WHERE active > 0";
3988 $num = $this->
db->num_rows(
$resql);
3990 $tmparray = array();
3992 $obj = $this->
db->fetch_object(
$resql);
3995 $label = ($obj->label !=
'-' ? $obj->label :
'');
3996 if ($langs->trans(
"DemandReasonType".$obj->code) != (
"DemandReasonType".$obj->code)) {
3997 $label = $langs->trans(
"DemandReasonType".$obj->code);
3999 if ($langs->trans($obj->code) != $obj->code) {
4000 $label = $langs->trans($obj->code);
4003 $tmparray[$obj->rowid][
'id'] = $obj->rowid;
4004 $tmparray[$obj->rowid][
'code'] = $obj->code;
4005 $tmparray[$obj->rowid][
'label'] = $label;
4009 $this->cache_demand_reason =
dol_sort_array($tmparray,
'label',
'asc', 0, 0, 1);
4031 public function selectInputReason($selected =
'', $htmlname =
'demandreasonid', $exclude =
'', $addempty = 0, $morecss =
'', $notooltip = 0)
4033 global $langs, $user;
4037 print
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
4039 print
'<option value="0"'.(empty($selected) ?
' selected' :
'').
'> </option>';
4041 foreach ($this->cache_demand_reason as $id => $arraydemandreason) {
4042 if ($arraydemandreason[
'code'] == $exclude) {
4046 if ($selected && ($selected == $arraydemandreason[
'id'] || $selected == $arraydemandreason[
'code'])) {
4047 print
'<option value="'.$arraydemandreason[
'id'].
'" selected>';
4049 print
'<option value="'.$arraydemandreason[
'id'].
'">';
4051 $label = $arraydemandreason[
'label'];
4052 print $langs->trans($label);
4056 if ($user->admin && empty($notooltip)) {
4057 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4073 $num = count($this->cache_types_paiements);
4080 $this->cache_types_paiements = array();
4082 $sql =
"SELECT id, code, libelle as label, type, active";
4083 $sql .=
" FROM ".$this->db->prefix().
"c_paiement";
4084 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
4088 $num = $this->
db->num_rows(
$resql);
4091 $obj = $this->
db->fetch_object(
$resql);
4094 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort".$obj->code) != (
"PaymentTypeShort".$obj->code) ? $langs->transnoentitiesnoconv(
"PaymentTypeShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4095 $this->cache_types_paiements[$obj->id][
'id'] = $obj->id;
4096 $this->cache_types_paiements[$obj->id][
'code'] = $obj->code;
4097 $this->cache_types_paiements[$obj->id][
'label'] = $label;
4098 $this->cache_types_paiements[$obj->id][
'type'] = $obj->type;
4099 $this->cache_types_paiements[$obj->id][
'active'] = $obj->active;
4103 $this->cache_types_paiements =
dol_sort_array($this->cache_types_paiements,
'label',
'asc', 0, 0, 1);
4131 public function select_conditions_paiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1)
4134 print $this->
getSelectConditionsPaiements($selected, $htmlname, $filtertype, $addempty, $noinfoadmin, $morecss, $deposit_percent = -1);
4154 public function getSelectConditionsPaiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1)
4156 global $langs, $user, $conf;
4159 dol_syslog(__METHOD__.
" selected=".$selected.
", htmlname=".$htmlname, LOG_DEBUG);
4164 if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) {
4165 $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID;
4168 $out.=
'<select id="'.$htmlname.
'" class="flat selectpaymentterms'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
4170 $out.=
'<option value="0"> </option>';
4173 $selectedDepositPercent =
null;
4175 foreach ($this->cache_conditions_paiements as $id => $arrayconditions) {
4176 if ($filtertype <= 0 && !empty($arrayconditions[
'deposit_percent'])) {
4180 if ($selected == $id) {
4181 $selectedDepositPercent = $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'];
4182 $out .=
'<option value="'.$id.
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'" selected>';
4184 $out .=
'<option value="'.$id.
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'">';
4186 $label = $arrayconditions[
'label'];
4188 if (!empty($arrayconditions[
'deposit_percent'])) {
4189 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'], $label);
4196 if ($user->admin && empty($noinfoadmin)) {
4197 $out.=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4201 if ($deposit_percent >= 0) {
4202 $out .=
' <span id="'.$htmlname.
'_deposit_percent_container"' . (empty($selectedDepositPercent) ?
' style="display: none"' :
'') .
'>';
4203 $out .= $langs->trans(
'DepositPercent') .
' : ';
4204 $out .=
'<input id="'.$htmlname.
'_deposit_percent" name="'.$htmlname.
'_deposit_percent" class="maxwidth50" value="' . $deposit_percent .
'" />';
4208 $(document).ready(function () {
4209 $("#' . $htmlname .
'").change(function () {
4210 let $selected = $(this).find("option:selected");
4211 let depositPercent = $selected.attr("data-deposit_percent");
4213 if (depositPercent.length > 0) {
4214 $("#'.$htmlname.
'_deposit_percent_container").show().find("#'.$htmlname.
'_deposit_percent").val(depositPercent);
4216 $("#'.$htmlname.
'_deposit_percent_container").hide();
4246 public function select_types_paiements($selected =
'', $htmlname =
'paiementtype', $filtertype =
'', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'', $nooutput = 0)
4249 global $langs, $user, $conf;
4253 dol_syslog(__METHOD__.
" ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
4255 $filterarray = array();
4256 if ($filtertype ==
'CRDT') {
4257 $filterarray = array(0, 2, 3);
4258 } elseif ($filtertype ==
'DBIT') {
4259 $filterarray = array(1, 2, 3);
4260 } elseif ($filtertype !=
'' && $filtertype !=
'-1') {
4261 $filterarray = explode(
',', $filtertype);
4267 if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID)) {
4268 $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID;
4271 $out .=
'<select id="select'.$htmlname.
'" class="flat selectpaymenttypes'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
4273 $out .=
'<option value=""> </option>';
4275 foreach ($this->cache_types_paiements as $id => $arraytypes) {
4277 if ($active >= 0 && $arraytypes[
'active'] != $active) {
4282 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
4287 if ($empty && empty($arraytypes[
'code'])) {
4292 $out .=
'<option value="'.$id.
'"';
4293 } elseif ($format == 1) {
4294 $out .=
'<option value="'.$arraytypes[
'code'].
'"';
4295 } elseif ($format == 2) {
4296 $out .=
'<option value="'.$arraytypes[
'code'].
'"';
4297 } elseif ($format == 3) {
4298 $out .=
'<option value="'.$id.
'"';
4301 if ($format == 1 || $format == 2) {
4302 if ($selected == $arraytypes[
'code']) {
4303 $out .=
' selected';
4306 if ($selected == $id) {
4307 $out .=
' selected';
4313 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4314 } elseif ($format == 1) {
4315 $value = $arraytypes[
'code'];
4316 } elseif ($format == 2) {
4317 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4318 } elseif ($format == 3) {
4319 $value = $arraytypes[
'code'];
4321 $out .= $value ? $value :
' ';
4322 $out .=
'</option>';
4324 $out .=
'</select>';
4325 if ($user->admin && !$noadmininfo) {
4326 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4330 if (empty($nooutput)) {
4350 $return =
'<select class="flat maxwidth100" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
4352 'HT'=>$langs->trans(
"HT"),
4353 'TTC'=>$langs->trans(
"TTC")
4355 foreach ($options as $id => $value) {
4356 if ($selected == $id) {
4357 $return .=
'<option value="'.$id.
'" selected>'.$value;
4359 $return .=
'<option value="'.$id.
'">'.$value;
4361 $return .=
'</option>';
4363 $return .=
'</select>';
4382 $num = count($this->cache_transport_mode);
4389 $this->cache_transport_mode = array();
4391 $sql =
"SELECT rowid, code, label, active";
4392 $sql .=
" FROM ".$this->db->prefix().
"c_transport_mode";
4393 $sql .=
" WHERE entity IN (".getEntity(
'c_transport_mode').
")";
4397 $num = $this->
db->num_rows(
$resql);
4400 $obj = $this->
db->fetch_object(
$resql);
4403 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort".$obj->code) != (
"PaymentTypeShort".$obj->code) ? $langs->transnoentitiesnoconv(
"PaymentTypeShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4404 $this->cache_transport_mode[$obj->rowid][
'rowid'] = $obj->rowid;
4405 $this->cache_transport_mode[$obj->rowid][
'code'] = $obj->code;
4406 $this->cache_transport_mode[$obj->rowid][
'label'] = $label;
4407 $this->cache_transport_mode[$obj->rowid][
'active'] = $obj->active;
4411 $this->cache_transport_mode =
dol_sort_array($this->cache_transport_mode,
'label',
'asc', 0, 0, 1);
4433 public function selectTransportMode($selected =
'', $htmlname =
'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'')
4435 global $langs, $user;
4437 dol_syslog(__METHOD__.
" ".$selected.
", ".$htmlname.
", ".$format, LOG_DEBUG);
4441 print
'<select id="select'.$htmlname.
'" class="flat selectmodetransport'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
4443 print
'<option value=""> </option>';
4445 foreach ($this->cache_transport_mode as $id => $arraytypes) {
4447 if ($active >= 0 && $arraytypes[
'active'] != $active) {
4452 if ($empty && empty($arraytypes[
'code'])) {
4457 print
'<option value="'.$id.
'"';
4458 } elseif ($format == 1) {
4459 print
'<option value="'.$arraytypes[
'code'].
'"';
4460 } elseif ($format == 2) {
4461 print
'<option value="'.$arraytypes[
'code'].
'"';
4462 } elseif ($format == 3) {
4463 print
'<option value="'.$id.
'"';
4466 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraytypes[
'code']) {
4468 } elseif ($selected == $id) {
4474 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4475 } elseif ($format == 1) {
4476 $value = $arraytypes[
'code'];
4477 } elseif ($format == 2) {
4478 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4479 } elseif ($format == 3) {
4480 $value = $arraytypes[
'code'];
4482 print $value ? $value :
' ';
4486 if ($user->admin && !$noadmininfo) {
4487 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4503 public function selectShippingMethod($selected =
'', $htmlname =
'shipping_method_id', $filtre =
'', $useempty = 0, $moreattrib =
'', $noinfoadmin = 0, $morecss =
'')
4505 global $langs, $conf, $user;
4507 $langs->load(
"admin");
4508 $langs->load(
"deliveries");
4510 $sql =
"SELECT rowid, code, libelle as label";
4511 $sql .=
" FROM ".$this->db->prefix().
"c_shipment_mode";
4512 $sql .=
" WHERE active > 0";
4514 $sql .=
" AND ".$filtre;
4516 $sql .=
" ORDER BY libelle ASC";
4518 dol_syslog(get_class($this).
"::selectShippingMode", LOG_DEBUG);
4519 $result = $this->
db->query($sql);
4521 $num = $this->
db->num_rows($result);
4524 print
'<select id="select'.$htmlname.
'" class="flat selectshippingmethod'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
4525 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
4526 print
'<option value="-1"> </option>';
4529 $obj = $this->
db->fetch_object($result);
4530 if ($selected == $obj->rowid) {
4531 print
'<option value="'.$obj->rowid.
'" selected>';
4533 print
'<option value="'.$obj->rowid.
'">';
4535 print ($langs->trans(
"SendingMethod".strtoupper($obj->code)) !=
"SendingMethod".strtoupper($obj->code)) ? $langs->trans(
"SendingMethod".strtoupper($obj->code)) : $obj->label;
4540 if ($user->admin && empty($noinfoadmin)) {
4541 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4546 print $langs->trans(
"NoShippingMethodDefined");
4566 $langs->load(
"deliveries");
4568 if ($htmlname !=
"none") {
4569 print
'<form method="POST" action="'.$page.
'">';
4570 print
'<input type="hidden" name="action" value="setshippingmethod">';
4571 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4573 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
4577 $code = $langs->getLabelFromKey($this->
db, $selected,
'c_shipment_mode',
'rowid',
'code');
4578 print $langs->trans(
"SendingMethod".strtoupper($code));
4597 $langs->load(
'bills');
4599 $opt =
'<option value="" selected></option>';
4600 $sql =
"SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc";
4601 $sql .=
' FROM '.$this->db->prefix().
'facture';
4602 $sql .=
' WHERE entity IN ('.getEntity(
'invoice').
')';
4603 $sql .=
' AND situation_counter >= 1';
4604 $sql .=
' AND fk_soc = '.(int) $socid;
4605 $sql .=
' AND type <> 2';
4606 $sql .=
' ORDER by situation_cycle_ref, situation_counter desc';
4612 while ($obj = $this->
db->fetch_object(
$resql)) {
4614 if ($obj->situation_cycle_ref != $ref) {
4616 $ref = $obj->situation_cycle_ref;
4618 if ($obj->situation_final != 1) {
4620 if (substr($obj->ref, 1, 4) !=
'PROV') {
4621 if ($selected == $obj->rowid) {
4622 $opt .=
'<option value="'.$obj->rowid.
'" selected>'.$obj->ref.
'</option>';
4624 $opt .=
'<option value="'.$obj->rowid.
'">'.$obj->ref.
'</option>';
4631 dol_syslog(
"Error sql=".$sql.
", error=".$this->error, LOG_ERR);
4633 if ($opt ==
'<option value ="" selected></option>') {
4634 $opt =
'<option value ="0" selected>'.$langs->trans(
'NoSituations').
'</option>';
4648 public function selectUnits($selected =
'', $htmlname =
'units', $showempty = 0, $unit_type =
'')
4652 $langs->load(
'products');
4654 $return =
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
4656 $sql =
"SELECT rowid, label, code FROM ".$this->db->prefix().
"c_units";
4657 $sql .=
' WHERE active > 0';
4658 if (!empty($unit_type)) {
4659 $sql .=
" AND unit_type = '".$this->db->escape($unit_type).
"'";
4661 $sql .=
" ORDER BY sortorder";
4666 $return .=
'<option value="none"></option>';
4669 while ($res = $this->
db->fetch_object(
$resql)) {
4670 $unitLabel = $res->label;
4671 if (!empty($langs->tab_translate[
'unit'.$res->code])) {
4672 $unitLabel = $langs->trans(
'unit'.$res->code) != $res->label ? $langs->trans(
'unit'.$res->code) : $res->label;
4675 if ($selected == $res->rowid) {
4676 $return .=
'<option value="'.$res->rowid.
'" selected>'.$unitLabel.
'</option>';
4678 $return .=
'<option value="'.$res->rowid.
'">'.$unitLabel.
'</option>';
4681 $return .=
'</select>';
4701 public function select_comptes($selected =
'', $htmlname =
'accountid', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'', $showcurrency = 0, $morecss =
'', $nooutput = 0)
4704 global $langs, $conf;
4708 $langs->load(
"admin");
4711 $sql =
"SELECT rowid, label, bank, clos as status, currency_code";
4712 $sql .=
" FROM ".$this->db->prefix().
"bank_account";
4713 $sql .=
" WHERE entity IN (".getEntity(
'bank_account').
")";
4715 $sql .=
" AND clos = ".(int) $status;
4718 $sql .=
" AND ".$filtre;
4720 $sql .=
" ORDER BY label";
4722 dol_syslog(get_class($this).
"::select_comptes", LOG_DEBUG);
4723 $result = $this->
db->query($sql);
4725 $num = $this->
db->num_rows($result);
4728 $out .=
'<select id="select'.$htmlname.
'" class="flat selectbankaccount'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
4729 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
4730 $out .=
'<option value="-1"> </option>';
4734 $obj = $this->
db->fetch_object($result);
4735 if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected))) {
4736 $out .=
'<option value="'.$obj->rowid.
'" data-currency-code="'.$obj->currency_code.
'" selected>';
4738 $out .=
'<option value="'.$obj->rowid.
'" data-currency-code="'.$obj->currency_code.
'">';
4740 $out .= trim($obj->label);
4741 if ($showcurrency) {
4742 $out .=
' ('.$obj->currency_code.
')';
4744 if ($status == 2 && $obj->status == 1) {
4745 $out .=
' ('.$langs->trans(
"Closed").
')';
4747 $out .=
'</option>';
4750 $out .=
"</select>";
4754 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoActiveBankAccountDefined").
'</span>';
4756 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoBankAccountFound").
'</span>';
4764 if (empty($nooutput)) {
4784 public function selectEstablishments($selected =
'', $htmlname =
'entity', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'')
4786 global $langs, $conf;
4788 $langs->load(
"admin");
4791 $sql =
"SELECT rowid, name, fk_country, status, entity";
4792 $sql .=
" FROM ".$this->db->prefix().
"establishment";
4793 $sql .=
" WHERE 1=1";
4795 $sql .=
" AND status = ".(int) $status;
4798 $sql .=
" AND ".$filtre;
4800 $sql .=
" ORDER BY name";
4802 dol_syslog(get_class($this).
"::select_establishment", LOG_DEBUG);
4803 $result = $this->
db->query($sql);
4805 $num = $this->
db->num_rows($result);
4808 print
'<select id="select'.$htmlname.
'" class="flat selectestablishment" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
4809 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
4810 print
'<option value="-1"> </option>';
4814 $obj = $this->
db->fetch_object($result);
4815 if ($selected == $obj->rowid) {
4816 print
'<option value="'.$obj->rowid.
'" selected>';
4818 print
'<option value="'.$obj->rowid.
'">';
4820 print trim($obj->name);
4821 if ($status == 2 && $obj->status == 1) {
4822 print
' ('.$langs->trans(
"Closed").
')';
4830 print
'<span class="opacitymedium">'.$langs->trans(
"NoActiveEstablishmentDefined").
'</span>';
4832 print
'<span class="opacitymedium">'.$langs->trans(
"NoEstablishmentFound").
'</span>';
4853 if ($htmlname !=
"none") {
4854 print
'<form method="POST" action="'.$page.
'">';
4855 print
'<input type="hidden" name="action" value="setbankaccount">';
4856 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4857 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
4858 $nbaccountfound = $this->
select_comptes($selected, $htmlname, 0,
'', $addempty);
4859 if ($nbaccountfound > 0) {
4860 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
4864 $langs->load(
'banks');
4867 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
4869 $result = $bankstatic->fetch($selected);
4871 print $bankstatic->getNomUrl(1);
4898 public function select_all_categories($type, $selected =
'', $htmlname =
"parent", $maxlength = 64, $markafterid = 0, $outputmode = 0, $include = 0, $morecss =
'')
4901 global $conf, $langs;
4902 $langs->load(
"categories");
4904 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
4907 if (is_numeric($type)) {
4908 dol_syslog(__METHOD__.
': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
4911 if ($type === Categorie::TYPE_BANK_LINE) {
4913 $cate_arbo = array();
4914 $sql =
"SELECT c.label, c.rowid";
4915 $sql .=
" FROM ".$this->db->prefix().
"bank_categ as c";
4916 $sql .=
" WHERE entity = ".$conf->entity;
4917 $sql .=
" ORDER BY c.label";
4918 $result = $this->
db->query($sql);
4920 $num = $this->
db->num_rows($result);
4923 $objp = $this->
db->fetch_object($result);
4925 $cate_arbo[$objp->rowid] = array(
'id'=>$objp->rowid,
'fulllabel'=>$objp->label,
'color'=>
'',
'picto'=>
'category');
4929 $this->
db->free($result);
4935 $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include);
4938 $outarray = array();
4940 $output =
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
4941 if (is_array($cate_arbo)) {
4942 if (!count($cate_arbo)) {
4943 $output .=
'<option value="-1" disabled>'.$langs->trans(
"NoCategoriesDefined").
'</option>';
4945 $output .=
'<option value="-1"> </option>';
4946 foreach ($cate_arbo as $key => $value) {
4947 if ($cate_arbo[$key][
'id'] == $selected || ($selected ===
'auto' && count($cate_arbo) == 1)) {
4952 $output .=
'<option '.$add.
'value="'.$cate_arbo[$key][
'id'].
'"';
4953 $output .=
' data-html="'.dol_escape_htmltag(
img_picto(
'',
'category',
'class="pictofixedwidth" style="color: #'.$cate_arbo[$key][
'color'].
'"').dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle')).
'"';
4955 $output .=
dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle');
4956 $output .=
'</option>';
4958 $outarray[$cate_arbo[$key][
'id']] = $cate_arbo[$key][
'fulllabel'];
4962 $output .=
'</select>';
4965 if ($outputmode == 2) {
4967 } elseif ($outputmode) {
4990 public function form_confirm($page, $title, $question, $action, $formquestion =
'', $selectedchoice =
"", $useajax = 0, $height = 170, $width = 500)
4993 dol_syslog(__METHOD__.
': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING);
4994 print $this->
formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width);
5024 public function formconfirm($page, $title, $question, $action, $formquestion =
'', $selectedchoice =
'', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0, $labelbuttonyes =
'Yes', $labelbuttonno =
'No')
5026 global $langs, $conf;
5028 $more =
'<!-- formconfirm - before call, page='.dol_escape_htmltag($page).
' -->';
5034 $newselectedchoice = empty($selectedchoice) ?
"no" : $selectedchoice;
5035 if ($conf->browser->layout ==
'phone') {
5040 if (empty($height)) {
5042 if (is_array($formquestion) && count($formquestion) > 2) {
5043 $height += ((count($formquestion) - 2) * 24);
5047 if (is_array($formquestion) && !empty($formquestion)) {
5049 foreach ($formquestion as $key => $input) {
5050 if (is_array($input) && !empty($input)) {
5051 if ($input[
'type'] ==
'hidden') {
5052 $moreattr = (!empty($input[
'moreattr']) ?
' '.$input[
'moreattr'] :
'');
5053 $morecss = (!empty($input[
'morecss']) ?
' '.$input[
'morecss'] :
'');
5055 $more .=
'<input type="hidden" id="'.dol_escape_htmltag($input[
'name']).
'" name="'.
dol_escape_htmltag($input[
'name']).
'" value="'.
dol_escape_htmltag($input[
'value']).
'" class="'.$morecss.
'"'.$moreattr.
'>'.
"\n";
5061 $moreonecolumn =
'';
5062 $more .=
'<div class="tagtable paddingtopbottomonly centpercent noborderspacing">'.
"\n";
5063 foreach ($formquestion as $key => $input) {
5064 if (is_array($input) && !empty($input)) {
5065 $size = (!empty($input[
'size']) ?
' size="'.$input[
'size'].
'"' :
'');
5066 $moreattr = (!empty($input[
'moreattr']) ?
' '.$input[
'moreattr'] :
'');
5067 $morecss = (!empty($input[
'morecss']) ?
' '.$input[
'morecss'] :
'');
5069 if ($input[
'type'] ==
'text') {
5070 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">'.$input[
'label'].
'</div><div class="tagtd"><input type="text" class="flat'.$morecss.
'" id="'.
dol_escape_htmltag($input[
'name']).
'" name="'.
dol_escape_htmltag($input[
'name']).
'"'.$size.
' value="'.(empty($input[
'value']) ?
'' : $input[
'value']).
'"'.$moreattr.
' /></div></div>'.
"\n";
5071 } elseif ($input[
'type'] ==
'password') {
5072 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">'.$input[
'label'].
'</div><div class="tagtd"><input type="password" class="flat'.$morecss.
'" id="'.
dol_escape_htmltag($input[
'name']).
'" name="'.
dol_escape_htmltag($input[
'name']).
'"'.$size.
' value="'.(empty($input[
'value']) ?
'' : $input[
'value']).
'"'.$moreattr.
' /></div></div>'.
"\n";
5073 } elseif ($input[
'type'] ==
'textarea') {
5079 $moreonecolumn .=
'<div class="margintoponly">';
5080 $moreonecolumn .= $input[
'label'].
'<br>';
5081 $moreonecolumn .=
'<textarea name="'.dol_escape_htmltag($input[
'name']).
'" id="'.
dol_escape_htmltag($input[
'name']).
'" class="'.$morecss.
'"'.$moreattr.
'>';
5082 $moreonecolumn .= $input[
'value'];
5083 $moreonecolumn .=
'</textarea>';
5084 $moreonecolumn .=
'</div>';
5085 } elseif (in_array($input[
'type'], [
'select',
'multiselect'])) {
5086 if (empty($morecss)) {
5087 $morecss =
'minwidth100';
5090 $show_empty = isset($input[
'select_show_empty']) ? $input[
'select_show_empty'] : 1;
5091 $key_in_label = isset($input[
'select_key_in_label']) ? $input[
'select_key_in_label'] : 0;
5092 $value_as_key = isset($input[
'select_value_as_key']) ? $input[
'select_value_as_key'] : 0;
5093 $translate = isset($input[
'select_translate']) ? $input[
'select_translate'] : 0;
5094 $maxlen = isset($input[
'select_maxlen']) ? $input[
'select_maxlen'] : 0;
5095 $disabled = isset($input[
'select_disabled']) ? $input[
'select_disabled'] : 0;
5096 $sort = isset($input[
'select_sort']) ? $input[
'select_sort'] :
'';
5098 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">';
5099 if (!empty($input[
'label'])) {
5100 $more .= $input[
'label'].
'</div><div class="tagtd left">';
5102 if ($input[
'type'] ==
'select') {
5103 $more .= $this->
selectarray($input[
'name'], $input[
'values'], !empty($input[
'default']) ? $input[
'default'] :
'-1', $show_empty, $key_in_label, $value_as_key, $moreattr, $translate, $maxlen, $disabled, $sort, $morecss);
5105 $more .= $this->
multiselectarray($input[
'name'], $input[
'values'], is_array($input[
'default']) ? $input[
'default'] : [$input[
'default']], $key_in_label, $value_as_key, $morecss, $translate, $maxlen, $moreattr);
5107 $more .=
'</div></div>'.
"\n";
5108 } elseif ($input[
'type'] ==
'checkbox') {
5109 $more .=
'<div class="tagtr">';
5110 $more .=
'<div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">'.$input[
'label'].
' </div><div class="tagtd">';
5111 $more .=
'<input type="checkbox" class="flat'.($morecss ?
' '.$morecss :
'').
'" id="'.
dol_escape_htmltag($input[
'name']).
'" name="'.
dol_escape_htmltag($input[
'name']).
'"'.$moreattr;
5112 if (!is_bool($input[
'value']) && $input[
'value'] !=
'false' && $input[
'value'] !=
'0' && $input[
'value'] !=
'') {
5113 $more .=
' checked';
5115 if (is_bool($input[
'value']) && $input[
'value']) {
5116 $more .=
' checked';
5118 if (isset($input[
'disabled'])) {
5119 $more .=
' disabled';
5121 $more .=
' /></div>';
5122 $more .=
'</div>'.
"\n";
5123 } elseif ($input[
'type'] ==
'radio') {
5125 foreach ($input[
'values'] as $selkey => $selval) {
5126 $more .=
'<div class="tagtr">';
5128 $more .=
'<div class="tagtd'.(empty($input[
'tdclass']) ?
' tdtop' : (
' tdtop '.$input[
'tdclass'])).
'">'.$input[
'label'].
'</div>';
5130 $more .=
'<div clas="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' "'.$input[
'tdclass'])).
'"> </div>';
5132 $more .=
'<div class="tagtd'.($i == 0 ?
' tdtop' :
'').
'"><input type="radio" class="flat'.$morecss.
'" id="'.
dol_escape_htmltag($input[
'name'].$selkey).
'" name="'.
dol_escape_htmltag($input[
'name']).
'" value="'.$selkey.
'"'.$moreattr;
5133 if (!empty($input[
'disabled'])) {
5134 $more .=
' disabled';
5136 if (isset($input[
'default']) && $input[
'default'] === $selkey) {
5137 $more .=
' checked="checked"';
5140 $more .=
'<label for="'.dol_escape_htmltag($input[
'name'].$selkey).
'" class="valignmiddle">'.$selval.
'</label>';
5141 $more .=
'</div></div>'.
"\n";
5144 } elseif ($input[
'type'] ==
'date' || $input[
'type'] ==
'datetime') {
5145 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">'.$input[
'label'].
'</div>';
5146 $more .=
'<div class="tagtd">';
5147 $addnowlink = (empty($input[
'datenow']) ? 0 : 1);
5148 $more .= $this->
selectDate($input[
'value'], $input[
'name'], ($input[
'type'] ==
'datetime' ? 1 : 0), ($input[
'type'] ==
'datetime' ? 1 : 0), 0,
'', 1, $addnowlink);
5149 $more .=
'</div></div>'.
"\n";
5150 $formquestion[] = array(
'name'=>$input[
'name'].
'day');
5151 $formquestion[] = array(
'name'=>$input[
'name'].
'month');
5152 $formquestion[] = array(
'name'=>$input[
'name'].
'year');
5153 $formquestion[] = array(
'name'=>$input[
'name'].
'hour');
5154 $formquestion[] = array(
'name'=>$input[
'name'].
'min');
5155 } elseif ($input[
'type'] ==
'other') {
5156 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">';
5157 if (!empty($input[
'label'])) {
5158 $more .= $input[
'label'].
'</div><div class="tagtd">';
5160 $more .= $input[
'value'];
5161 $more .=
'</div></div>'.
"\n";
5162 } elseif ($input[
'type'] ==
'onecolumn') {
5163 $moreonecolumn .=
'<div class="margintoponly">';
5164 $moreonecolumn .= $input[
'value'];
5165 $moreonecolumn .=
'</div>'.
"\n";
5166 } elseif ($input[
'type'] ==
'hidden') {
5168 } elseif ($input[
'type'] ==
'separator') {
5171 $more .=
'Error type '.$input[
'type'].
' for the confirm box is not a supported type';
5175 $more .=
'</div>'.
"\n";
5176 $more .= $moreonecolumn;
5182 if (!empty($conf->dol_use_jmobile)) {
5185 if (empty($conf->use_javascript_ajax)) {
5191 $dialogconfirm =
'dialog-confirm';
5193 if (!is_numeric($useajax)) {
5197 $dialogconfirm .=
'-'.$button;
5199 $pageyes = $page.(preg_match(
'/\?/', $page) ?
'&' :
'?').
'action='.urlencode($action).
'&confirm=yes';
5200 $pageno = ($useajax == 2 ? $page.(preg_match(
'/\?/', $page) ?
'&' :
'?').
'action='.urlencode($action).
'&confirm=no' :
'');
5203 if (is_array($formquestion)) {
5204 foreach ($formquestion as $key => $input) {
5207 if (is_array($input) && isset($input[
'name'])) {
5208 if (strpos($input[
'name'],
',') > 0) {
5209 $inputok = array_merge($inputok, explode(
',', $input[
'name']));
5211 array_push($inputok, $input[
'name']);
5215 if (isset($input[
'inputko']) && $input[
'inputko'] == 1) {
5216 array_push($inputko, $input[
'name']);
5223 if (is_array($formquestion) && !empty($formquestion[
'text'])) {
5224 $formconfirm .=
'<div class="confirmtext">'.$formquestion[
'text'].
'</div>'.
"\n";
5226 if (!empty($more)) {
5227 $formconfirm .=
'<div class="confirmquestions">'.$more.
'</div>'.
"\n";
5229 $formconfirm .= ($question ?
'<div class="confirmmessage">'.img_help(
'',
'').
' '.$question.
'</div>' :
'');
5232 $formconfirm .=
"\n<!-- begin code of popup for formconfirm page=".$page.
" -->\n";
5233 $formconfirm .=
'<script type="text/javascript">'.
"\n";
5234 $formconfirm .=
"/* Code for the jQuery('#dialogforpopup').dialog() */\n";
5237 $( "#'.$dialogconfirm.
'" ).dialog(
5239 autoOpen: '.($autoOpen ?
"true" :
"false").
',';
5240 if ($newselectedchoice ==
'no') {
5243 $(this).parent().find("button.ui-button:eq(2)").focus();
5248 if ($useajax == 1) {
5249 $jsforcursor =
'// The call to urljump can be slow, so we set the wait cursor'.
"\n";
5250 $jsforcursor .=
'jQuery("html,body,#id-container").addClass("cursorwait");'.
"\n";
5253 $postconfirmas =
'GET';
5257 height: "'.$height.
'",
5258 width: "'.$width.
'",
5260 closeOnEscape: false,
5262 "'.
dol_escape_js($langs->transnoentities($labelbuttonyes)).
'": function() {
5263 var options = "token='.urlencode(
newToken()).
'";
5264 var inputok = '.json_encode($inputok).
'; /* List of fields into form */
5266 var pageyes = "'.
dol_escape_js(!empty($pageyes) ? $pageyes :
'').
'";
5268 if (inputok.length > 0) {
5269 $.each(inputok, function(i, inputname) {
5272 if ($("input[name=\'" + inputname + "\']").attr("type") == "radio") {
5273 inputvalue = $("input[name=\'" + inputname + "\']:checked").val();
5275 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
5276 inputvalue = $("#" + inputname + more).val();
5278 if (typeof inputvalue == "undefined") { inputvalue=""; }
5279 console.log("formconfirm check inputname="+inputname+" inputvalue="+inputvalue);
5280 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
5283 var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "&") + options;
5284 if (pageyes.length > 0) {';
5285 if ($postconfirmas ==
'GET') {
5292 function(data) { $("body").html(data); jQuery("html,body,#id-container").removeClass("cursorwait"); }
5296 console.log("after post ok");
5298 $(this).dialog("close");
5300 "'.dol_escape_js($langs->transnoentities($labelbuttonno)).
'": function() {
5301 var options = "token='.urlencode(
newToken()).
'";
5302 var inputko = '.json_encode($inputko).
'; /* List of fields into form */
5304 var pageno="'.
dol_escape_js(!empty($pageno) ? $pageno :
'').
'";
5305 if (inputko.length > 0) {
5306 $.each(inputko, function(i, inputname) {
5308 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
5309 var inputvalue = $("#" + inputname + more).val();
5310 if (typeof inputvalue == "undefined") { inputvalue=""; }
5311 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
5314 var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "&") + options;
5316 if (pageno.length > 0) {';
5317 if ($postconfirmas ==
'GET') {
5324 function(data) { $("body").html(data); jQuery("html,body,#id-container").removeClass("cursorwait"); }
5328 console.log("after post ko");
5330 $(this).dialog("close");
5336 var button = "'.$button.
'";
5337 if (button.length > 0) {
5338 $( "#" + button ).click(function() {
5339 $("#'.$dialogconfirm.
'").dialog("open");
5347 $formconfirm .=
"\n<!-- begin formconfirm page=".dol_escape_htmltag($page).
" -->\n";
5349 if (empty($disableformtag)) {
5350 $formconfirm .=
'<form method="POST" action="'.$page.
'" class="notoptoleftroright">'.
"\n";
5353 $formconfirm .=
'<input type="hidden" name="action" value="'.$action.
'">'.
"\n";
5354 $formconfirm .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
5356 $formconfirm .=
'<table class="valid centpercent">'.
"\n";
5359 $formconfirm .=
'<tr class="validtitre"><td class="validtitre" colspan="2">';
5364 if (is_array($formquestion) && !empty($formquestion[
'text'])) {
5365 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="2">'.$formquestion[
'text'].
'</td></tr>'.
"\n";
5370 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="2">'.
"\n";
5377 $formconfirm .=
'<td class="valid">'.$question.
'</td>';
5379 $formconfirm .= $this->
selectyesno(
"confirm", $newselectedchoice, 0,
false, 0, 0,
'marginleftonly marginrightonly', $labelbuttonyes, $labelbuttonno);
5380 $formconfirm .=
'<input class="button valignmiddle confirmvalidatebutton small" type="submit" value="'.$langs->trans(
"Validate").
'">';
5386 if (empty($disableformtag)) {
5391 if (!empty($conf->use_javascript_ajax)) {
5392 $formconfirm .=
'<!-- code to disable button to avoid double clic -->';
5393 $formconfirm .=
'<script type="text/javascript">'.
"\n";
5395 $(document).ready(function () {
5396 $(".confirmvalidatebutton").on("click", function() {
5397 console.log("We click on button");
5398 $(this).attr("disabled", "disabled");
5399 setTimeout(\'$(".confirmvalidatebutton").removeAttr("disabled")\', 3000);
5400 //console.log($(this).closest("form"));
5401 $(this).closest("form").submit();
5430 public function form_project($page, $socid, $selected =
'', $htmlname =
'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0, $textifnoproject =
'')
5435 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
5436 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
5442 $langs->load(
"project");
5443 if ($htmlname !=
"none") {
5444 $out .=
'<form method="post" action="'.$page.
'">';
5445 $out .=
'<input type="hidden" name="action" value="classin">';
5446 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
5447 $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0,
'', 1);
5448 $out .=
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
5451 $out .=
'<span class="project_head_block">';
5454 $projet->fetch($selected);
5455 $out .= $projet->getNomUrl(0,
'', 1);
5457 $out .=
'<span class="opacitymedium">'.$textifnoproject.
'</span>';
5462 if (empty($nooutput)) {
5485 public function form_conditions_reglement($page, $selected =
'', $htmlname =
'cond_reglement_id', $addempty = 0, $type =
'', $filtertype = -1, $deposit_percent = -1, $nooutput = 0)
5492 if ($htmlname !=
"none") {
5493 $out .=
'<form method="POST" action="'.$page.
'">';
5494 $out .=
'<input type="hidden" name="action" value="setconditions">';
5495 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
5497 $out .=
'<input type="hidden" name="type" value="'.dol_escape_htmltag($type).
'">';
5500 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
5505 if (isset($this->cache_conditions_paiements[$selected])) {
5506 $label = $this->cache_conditions_paiements[$selected][
'label'];
5508 if (!empty($this->cache_conditions_paiements[$selected][
'deposit_percent'])) {
5509 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $this->cache_conditions_paiements[$selected][
'deposit_percent'], $label);
5514 $langs->load(
'errors');
5515 $out .= $langs->trans(
'ErrorNotInDictionaryPaymentConditions');
5522 if (empty($nooutput)) {
5543 if ($htmlname !=
"none") {
5544 print
'<form method="post" action="'.$page.
'">';
5545 print
'<input type="hidden" name="action" value="setavailability">';
5546 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5548 print
'<input type="submit" name="modify" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
5549 print
'<input type="submit" name="cancel" class="button smallpaddingimp" value="'.$langs->trans(
"Cancel").
'">';
5554 print $this->cache_availability[$selected][
'label'];
5571 public function formInputReason($page, $selected =
'', $htmlname =
'demandreason', $addempty = 0)
5574 if ($htmlname !=
"none") {
5575 print
'<form method="post" action="'.$page.
'">';
5576 print
'<input type="hidden" name="action" value="setdemandreason">';
5577 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5579 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
5584 foreach ($this->cache_demand_reason as $key => $val) {
5585 if ($val[
'id'] == $selected) {
5586 print $val[
'label'];
5610 public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0, $type =
'')
5617 if ($htmlname !=
"none") {
5618 $ret .=
'<form method="POST" action="'.$page.
'" name="form'.$htmlname.
'">';
5619 $ret .=
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
5620 $ret .=
'<input type="hidden" name="token" value="'.newToken().
'">';
5622 $ret .=
'<input type="hidden" name="type" value="'.dol_escape_htmltag($type).
'">';
5624 $ret .=
'<table class="nobordernopadding">';
5626 $ret .= $this->
selectDate($selected, $htmlname, $displayhour, $displaymin, 1,
'form'.$htmlname, 1, 0);
5628 $ret .=
'<td class="left"><input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'"></td>';
5629 $ret .=
'</tr></table></form>';
5638 if (empty($nooutput)) {
5656 public function form_users($page, $selected =
'', $htmlname =
'userid', $exclude =
'', $include =
'')
5661 if ($htmlname !=
"none") {
5662 print
'<form method="POST" action="'.$page.
'" name="form'.$htmlname.
'">';
5663 print
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
5664 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5665 print $this->
select_dolusers($selected, $htmlname, 1, $exclude, 0, $include);
5666 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5670 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
5671 $theuser =
new User($this->
db);
5672 $theuser->fetch($selected);
5673 print $theuser->getNomUrl(1);
5695 public function form_modes_reglement($page, $selected =
'', $htmlname =
'mode_reglement_id', $filtertype =
'', $active = 1, $addempty = 0, $type =
'', $nooutput = 0)
5701 if ($htmlname !=
"none") {
5702 $out .=
'<form method="POST" action="'.$page.
'">';
5703 $out .=
'<input type="hidden" name="action" value="setmode">';
5704 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
5706 $out .=
'<input type="hidden" name="type" value="'.dol_escape_htmltag($type).
'">';
5708 $out .= $this->
select_types_paiements($selected, $htmlname, $filtertype, 0, $addempty, 0, 0, $active,
'', 1);
5709 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5714 $out .= $this->cache_types_paiements[$selected][
'label'];
5741 if ($htmlname !=
"none") {
5742 print
'<form method="POST" action="'.$page.
'">';
5743 print
'<input type="hidden" name="action" value="settransportmode">';
5744 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5746 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5751 print $this->cache_transport_mode[$selected][
'label'];
5771 if ($htmlname !=
"none") {
5772 print
'<form method="POST" action="'.$page.
'">';
5773 print
'<input type="hidden" name="action" value="setmulticurrencycode">';
5774 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5776 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5780 print !empty($selected) ?
currency_name($selected, 1) :
' ';
5797 global $langs, $mysoc, $conf;
5799 if ($htmlname !=
"none") {
5800 print
'<form method="POST" action="'.$page.
'">';
5801 print
'<input type="hidden" name="action" value="setmulticurrencyrate">';
5802 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5803 print
'<input type="text" class="maxwidth100" name="'.$htmlname.
'" value="'.(!empty($rate) ?
price(
price2num($rate,
'CU')) : 1).
'" /> ';
5804 print
'<select name="calculation_mode">';
5805 print
'<option value="1">Change '.$langs->trans(
"PriceUHT").
' of lines</option>';
5806 print
'<option value="2">Change '.$langs->trans(
"PriceUHTCurrency").
' of lines</option>';
5808 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5811 if (!empty($rate)) {
5812 print
price($rate, 1, $langs, 1, 0);
5813 if ($currency && $rate != 1) {
5814 print
' ('.price($rate, 1, $langs, 1, 0).
' '.$currency.
' = 1 '.$conf->currency.
')';
5839 public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter =
'', $maxvalue = 0, $more =
'', $hidelist = 0, $discount_type = 0)
5842 global $conf, $langs;
5843 if ($htmlname !=
"none") {
5844 print
'<form method="post" action="'.$page.
'">';
5845 print
'<input type="hidden" name="action" value="setabsolutediscount">';
5846 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5847 print
'<div class="inline-block">';
5848 if (!empty($discount_type)) {
5849 if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
5850 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL") {
5851 $translationKey =
'HasAbsoluteDiscountFromSupplier';
5853 $translationKey =
'HasCreditNoteFromSupplier';
5856 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
5857 $translationKey =
'HasAbsoluteDiscountFromSupplier';
5859 $translationKey =
'HasCreditNoteFromSupplier';
5863 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
5864 if (!$filter || $filter ==
"fk_facture_source IS NULL") {
5865 $translationKey =
'CompanyHasAbsoluteDiscount';
5867 $translationKey =
'CompanyHasCreditNote';
5870 if (!$filter || $filter ==
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
5871 $translationKey =
'CompanyHasAbsoluteDiscount';
5873 $translationKey =
'CompanyHasCreditNote';
5877 print $langs->trans($translationKey,
price($amount, 0, $langs, 0, 0, -1, $conf->currency));
5878 if (empty($hidelist)) {
5882 if (empty($hidelist)) {
5883 print
'<div class="inline-block" style="padding-right: 10px">';
5884 $newfilter =
'discount_type='.intval($discount_type);
5885 if (!empty($discount_type)) {
5886 $newfilter .=
' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL';
5888 $newfilter .=
' AND fk_facture IS NULL AND fk_facture_line IS NULL';
5891 $newfilter .=
' AND ('.$filter.
')';
5894 $nbqualifiedlines = $this->
select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue);
5895 if ($nbqualifiedlines > 0) {
5896 print
' <input type="submit" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"UseLine")).
'"';
5897 if (!empty($discount_type) && $filter && $filter !=
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
5898 print
' title="'.$langs->trans(
"UseCreditNoteInInvoicePayment").
'"';
5900 if (empty($discount_type) && $filter && $filter !=
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
5901 print
' title="'.$langs->trans(
"UseCreditNoteInInvoicePayment").
'"';
5909 print
'<div class="inline-block">';
5934 public function form_contacts($page, $societe, $selected =
'', $htmlname =
'contactid')
5937 global $langs, $conf;
5939 if ($htmlname !=
"none") {
5940 print
'<form method="post" action="'.$page.
'">';
5941 print
'<input type="hidden" name="action" value="set_contact">';
5942 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5943 print
'<table class="nobordernopadding">';
5948 $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
5949 print
'<a href="'.DOL_URL_ROOT.
'/contact/card.php?socid='.$societe->id.
'&action=create&backtoreferer=1">'.$addcontact.
'</a>';
5952 print
'<td class="left"><input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'"></td>';
5953 print
'</tr></table></form>';
5956 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
5958 $contact->fetch($selected);
5959 print $contact->getFullName($langs);
5983 public function form_thirdparty($page, $selected =
'', $htmlname =
'socid', $filter =
'', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0, $excludeids = array(), $textifnothirdparty =
'')
5989 if ($htmlname !=
"none") {
5990 $out .=
'<form method="post" action="'.$page.
'">';
5991 $out .=
'<input type="hidden" name="action" value="set_thirdparty">';
5992 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
5993 $out .= $this->
select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, 0,
'minwidth100',
'',
'', 1, array(),
false, $excludeids);
5994 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5998 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
6000 $soc->fetch($selected);
6001 $out .= $soc->getNomUrl(0,
'');
6003 $out .=
'<span class="opacitymedium">'.$textifnothirdparty.
'</span>';
6040 public function selectCurrency($selected =
'', $htmlname =
'currency_id', $mode = 0, $useempty =
'')
6042 global $conf, $langs, $user;
6044 $langs->loadCacheCurrencies(
'');
6048 if ($selected ==
'euro' || $selected ==
'euros') {
6052 $out .=
'<select class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.
'" id="'.$htmlname.
'">';
6054 $out .=
'<option value="-1" selected></option>';
6056 foreach ($langs->cache_currencies as $code_iso => $currency) {
6057 $labeltoshow = $currency[
'label'];
6059 $labeltoshow .=
' <span class="opacitymedium">('.$code_iso.
')</span>';
6061 $labeltoshow .=
' <span class="opacitymedium">('.$langs->getCurrencySymbol($code_iso).
')</span>';
6064 if ($selected && $selected == $code_iso) {
6065 $out .=
'<option value="'.$code_iso.
'" selected data-html="'.
dol_escape_htmltag($labeltoshow).
'">';
6067 $out .=
'<option value="'.$code_iso.
'" data-html="'.
dol_escape_htmltag($labeltoshow).
'">';
6069 $out .= $labeltoshow;
6070 $out .=
'</option>';
6072 $out .=
'</select>';
6074 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
6078 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
6096 public function selectMultiCurrency($selected =
'', $htmlname =
'multicurrency_code', $useempty = 0, $filter =
'', $excludeConfCurrency =
false, $morecss =
'')
6098 global $conf, $langs;
6100 $langs->loadCacheCurrencies(
'');
6102 $TCurrency = array();
6104 $sql =
"SELECT code FROM ".$this->db->prefix().
"multicurrency";
6105 $sql .=
" WHERE entity IN ('".getEntity(
'mutlicurrency').
"')";
6107 $sql .=
" AND ".$filter;
6111 while ($obj = $this->
db->fetch_object(
$resql)) {
6112 $TCurrency[$obj->code] = $obj->code;
6117 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
6119 $out .=
'<option value=""> </option>';
6122 if (!in_array($conf->currency, $TCurrency) && !$excludeConfCurrency) {
6123 $TCurrency[$conf->currency] = $conf->currency;
6125 if (count($TCurrency) > 0) {
6126 foreach ($langs->cache_currencies as $code_iso => $currency) {
6127 if (isset($TCurrency[$code_iso])) {
6128 if (!empty($selected) && $selected == $code_iso) {
6129 $out .=
'<option value="'.$code_iso.
'" selected="selected">';
6131 $out .=
'<option value="'.$code_iso.
'">';
6134 $out .= $currency[
'label'];
6135 $out .=
' ('.$langs->getCurrencySymbol($code_iso).
')';
6136 $out .=
'</option>';
6141 $out .=
'</select>';
6144 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
6162 $num = count($this->cache_vatrates);
6169 $sql =
"SELECT DISTINCT t.rowid, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly";
6170 $sql .=
" FROM ".$this->db->prefix().
"c_tva as t, ".$this->
db->prefix().
"c_country as c";
6171 $sql .=
" WHERE t.fk_pays = c.rowid";
6172 $sql .=
" AND t.active > 0";
6173 $sql .=
" AND c.code IN (".$this->db->sanitize($country_code, 1).
")";
6174 $sql .=
" ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC";
6178 $num = $this->
db->num_rows(
$resql);
6180 for ($i = 0; $i < $num; $i++) {
6181 $obj = $this->
db->fetch_object(
$resql);
6182 $this->cache_vatrates[$i][
'rowid'] = $obj->rowid;
6183 $this->cache_vatrates[$i][
'code'] = $obj->code;
6184 $this->cache_vatrates[$i][
'txtva'] = $obj->taux;
6185 $this->cache_vatrates[$i][
'nprtva'] = $obj->recuperableonly;
6186 $this->cache_vatrates[$i][
'localtax1'] = $obj->localtax1;
6187 $this->cache_vatrates[$i][
'localtax1_type'] = $obj->localtax1_type;
6188 $this->cache_vatrates[$i][
'localtax2'] = $obj->localtax2;
6189 $this->cache_vatrates[$i][
'localtax2_type'] = $obj->localtax1_type;
6191 $this->cache_vatrates[$i][
'label'] = $obj->taux.
'%'.($obj->code ?
' ('.$obj->code.
')' :
'');
6192 $this->cache_vatrates[$i][
'labelallrates'] = $obj->taux.
'/'.($obj->localtax1 ? $obj->localtax1 :
'0').
'/'.($obj->localtax2 ? $obj->localtax2 :
'0').($obj->code ?
' ('.$obj->code.
')' :
'');
6193 $positiverates =
'';
6195 $positiverates .= ($positiverates ?
'/' :
'').$obj->taux;
6197 if ($obj->localtax1) {
6198 $positiverates .= ($positiverates ?
'/' :
'').$obj->localtax1;
6200 if ($obj->localtax2) {
6201 $positiverates .= ($positiverates ?
'/' :
'').$obj->localtax2;
6203 if (empty($positiverates)) {
6204 $positiverates =
'0';
6206 $this->cache_vatrates[$i][
'labelpositiverates'] = $positiverates.($obj->code ?
' ('.$obj->code.
')' :
'');
6211 $this->error =
'<span class="error">'.$langs->trans(
"ErrorNoVATRateDefinedForSellerCountry", $country_code).
'</span>';
6215 $this->error =
'<span class="error">'.$this->db->error().
'</span>';
6242 public function load_tva($htmlname =
'tauxtva', $selectedrate =
'', $societe_vendeuse =
'', $societe_acheteuse =
'', $idprod = 0, $info_bits = 0, $type =
'', $options_only =
false, $mode = 0)
6245 global $langs, $conf, $mysoc;
6247 $langs->load(
'errors');
6252 $defaultnpr = ($info_bits & 0x01);
6253 $defaultnpr = (preg_match(
'/\*/', $selectedrate) ? 1 : $defaultnpr);
6254 $defaulttx = str_replace(
'*',
'', $selectedrate);
6257 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6258 $defaultcode = $reg[1];
6259 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6264 if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
6265 if ($societe_vendeuse->id == $mysoc->id) {
6266 $return .=
'<span class="error">'.$langs->trans(
"ErrorYourCountryIsNotDefined").
'</span>';
6268 $return .=
'<span class="error">'.$langs->trans(
"ErrorSupplierCountryIsNotDefined").
'</span>';
6279 if (is_object($societe_vendeuse)) {
6280 $code_country =
"'".$societe_vendeuse->country_code.
"'";
6282 $code_country =
"'".$mysoc->country_code.
"'";
6284 if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
6285 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
6286 if (!
isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (
isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()))) {
6288 if (is_numeric($type)) {
6290 $code_country .=
",'".$societe_acheteuse->country_code.
"'";
6292 } elseif (!$idprod) {
6293 $code_country .=
",'".$societe_acheteuse->country_code.
"'";
6296 $prodstatic->fetch($idprod);
6298 $code_country .=
",'".$societe_acheteuse->country_code.
"'";
6309 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
6310 $tmpthirdparty =
new Societe($this->
db);
6312 $defaulttx =
get_default_tva($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
6313 $defaultnpr =
get_default_npr($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
6315 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6316 $defaultcode = $reg[1];
6317 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6319 if (empty($defaulttx)) {
6326 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
6327 if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
6329 $defaulttx = $this->cache_vatrates[$num - 1][
'txtva'];
6333 if ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS !=
'none') {
6334 $defaulttx = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
6336 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6337 $defaultcode = $reg[1];
6338 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6346 if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj ==
"0") {
6349 if (empty($conf->global->EXPENSEREPORT_OVERRIDE_VAT)) {
6350 $title =
' title="'.dol_escape_htmltag($langs->trans(
'VATIsNotUsed')).
'"';
6355 if (!$options_only) {
6356 $return .=
'<select class="flat minwidth50imp maxwidth100" id="'.$htmlname.
'" name="'.$htmlname.
'"'.($disabled ?
' disabled' :
'').$title.
'>';
6359 $selectedfound =
false;
6360 foreach ($this->cache_vatrates as $rate) {
6362 if ($disabled && $rate[
'txtva'] != 0) {
6367 $key = $rate[
'txtva'];
6368 $key .= $rate[
'nprtva'] ?
'*' :
'';
6369 if ($mode > 0 && $rate[
'code']) {
6370 $key .=
' ('.$rate[
'code'].
')';
6373 $key = $rate[
'rowid'];
6376 $return .=
'<option value="'.$key.
'"';
6377 if (!$selectedfound) {
6379 if ($defaultcode == $rate[
'code']) {
6380 $return .=
' selected';
6381 $selectedfound =
true;
6383 } elseif ($rate[
'txtva'] == $defaulttx && $rate[
'nprtva'] == $defaultnpr) {
6384 $return .=
' selected';
6385 $selectedfound =
true;
6391 if ($mysoc->country_code ==
'IN' || !empty($conf->global->MAIN_VAT_LABEL_IS_POSITIVE_RATES)) {
6393 $return .= $rate[
'labelpositiverates'];
6396 $return .=
vatrate($rate[
'label']);
6400 $return .= (empty($rate[
'code']) && $rate[
'nprtva']) ?
' *' :
'';
6402 $return .=
'</option>';
6405 if (!$options_only) {
6406 $return .=
'</select>';
6410 $return .= $this->error;
6443 public function select_date($set_time =
'', $prefix =
're', $h = 0, $m = 0, $empty = 0, $form_name =
"", $d = 1, $addnowlink = 0, $nooutput = 0, $disabled = 0, $fullday =
'', $addplusone =
'', $adddateof =
'')
6446 $retstring = $this->
selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof);
6447 if (!empty($nooutput)) {
6469 public function selectDateToDate($set_time =
'', $set_time_end =
'', $prefix =
're', $empty = 0, $forcenewline = 0)
6473 $ret = $this->
selectDate($set_time, $prefix.
'_start', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"),
'tzuserrel');
6474 if ($forcenewline) {
6477 $ret .= $this->
selectDate($set_time_end, $prefix.
'_end', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
6508 public function selectDate($set_time =
'', $prefix =
're', $h = 0, $m = 0, $empty = 0, $form_name =
"", $d = 1, $addnowlink = 0, $disabled = 0, $fullday =
'', $addplusone =
'', $adddateof =
'', $openinghours =
'', $stepminutes = 1, $labeladddateof =
'', $placeholder =
'', $gm =
'auto')
6510 global $conf, $langs;
6512 if ($gm ===
'auto') {
6513 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
6518 if ($prefix ==
'') {
6529 if ($stepminutes <= 0 || $stepminutes > 30) {
6540 $orig_set_time = $set_time;
6542 if ($set_time ===
'' && $emptydate == 0) {
6543 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
6544 if ($gm ==
'tzuser' || $gm ==
'tzuserrel') {
6556 if (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg)) {
6558 $syear = (!empty($reg[1]) ? $reg[1] :
'');
6559 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
6560 $sday = (!empty($reg[3]) ? $reg[3] :
'');
6561 $shour = (!empty($reg[4]) ? $reg[4] :
'');
6562 $smin = (!empty($reg[5]) ? $reg[5] :
'');
6563 } elseif (strval($set_time) !=
'' && $set_time != -1) {
6568 if ($orig_set_time !=
'') {
6578 $shour = !isset($conf->global->MAIN_DEFAULT_DATE_HOUR) ? ($h == -1 ?
'23' :
'') : $conf->global->MAIN_DEFAULT_DATE_HOUR;
6579 $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? ($h == -1 ?
'59' :
'') : $conf->global->MAIN_DEFAULT_DATE_MIN;
6580 $ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? ($h == -1 ?
'59' :
'') : $conf->global->MAIN_DEFAULT_DATE_SEC;
6593 $usecalendar =
'combo';
6594 if (!empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR !=
"none")) {
6595 $usecalendar = ((empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR ==
'eldy') ?
'jquery' : $conf->global->MAIN_POPUP_CALENDAR);
6600 if ($usecalendar !=
'combo') {
6601 $formated_date =
'';
6603 if (strval($set_time) !=
'' && $set_time != -1) {
6605 $formated_date =
dol_print_date($set_time, $langs->trans(
"FormatDateShortInput"), $gm);
6609 if ($usecalendar ==
"eldy") {
6611 $retstring .=
'<input id="'.$prefix.
'" name="'.$prefix.
'" type="text" class="maxwidthdate" maxlength="11" value="'.$formated_date.
'"';
6612 $retstring .= ($disabled ?
' disabled' :
'');
6613 $retstring .=
' onChange="dpChangeDay(\''.$prefix.
'\',\
''.$langs->trans(
"FormatDateShortJavaInput").
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
6617 $retstringbuttom = '';
6619 $retstringbuttom = '<button id="'.$prefix.'Button
" type="button" class="dpInvisibleButtons
"';
6620 $base = DOL_URL_ROOT.'/core/';
6621 $retstringbuttom .= ' onClick="showDP(\
''.$base.
'\',\
''.$prefix.
'\',\
''.$langs->trans(
"FormatDateShortJavaInput").
'\',\
''.$langs->defaultlang.
'\');
"';
6622 $retstringbuttom .= '>'.img_object($langs->trans("SelectDate
"), 'calendarday', 'class="datecallink
"').'</button>';
6624 $retstringbuttom = '<button id="'.$prefix.'Button
" type="button" class="dpInvisibleButtons
">'.img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"').'</button>';
6626 $retstring = $retstringbuttom.$retstring;
6628 $retstring .= '<input type="hidden
" id="'.$prefix.'day
" name="'.$prefix.'day
" value="'.$sday.'">'."\n
";
6629 $retstring .= '<input type="hidden
" id="'.$prefix.'month
" name="'.$prefix.'month
" value="'.$smonth.'">'."\n
";
6630 $retstring .= '<input type="hidden
" id="'.$prefix.'year
" name="'.$prefix.'year
" value="'.$syear.'">'."\n
";
6631 } elseif ($usecalendar == 'jquery') {
6633 // Output javascript for datepicker
6634 $minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (date('Y') - 100));
6635 $maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (date('Y') + 100));
6637 $retstring .= "<script
type=
'text/javascript'>
";
6638 $retstring .= "$(
function(){ $(
'#".$prefix."').datepicker({
6639 dateFormat:
'".$langs->trans("FormatDateShortJQueryInput")."',
6641 todayHighlight:
true,
6642 yearRange:
'".$minYear.":".$maxYear."',
";
6643 if (!empty($conf->dol_use_jmobile)) {
6645 beforeShow:
function (input, datePicker) {
6646 input.disabled =
true;
6648 onClose:
function (dateText, datePicker) {
6649 this.disabled =
false;
6653 // Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php
6654 if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS)) {
6657 buttonImage:
'".DOL_URL_ROOT."/theme/".dol_escape_js($conf->theme)."/img/object_calendarday.png',
6658 buttonImageOnly:
true";
6662 $retstring .= "</script>
";
6665 // Zone de saisie manuelle de la date
6666 $retstring .= '<div class="nowrap
inline-block divfordateinput
">';
6667 $retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text
" class="maxwidthdate
" maxlength="11
" value="'.$formated_date.'"';
6668 $retstring .= ($disabled ? ' disabled' : '');
6669 $retstring .= ($placeholder ? ' placeholder="'.dol_escape_htmltag($placeholder).'"' : '');
6670 $retstring .= ' onChange="dpChangeDay(\
''.
dol_escape_js($prefix).
'\',\
''.
dol_escape_js($langs->trans(
"FormatDateShortJavaInput")).
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
6675 /* Not required. Managed by option buttonImage of jquery
6676 $retstring.=img_object($langs->trans("SelectDate
"),'calendarday','id="'.$prefix.'id" class="datecallink
"');
6677 $retstring.="<script
type=
'text/javascript'>
";
6678 $retstring.="jQuery(document).ready(
function() {
";
6679 $retstring.=' jQuery("#
'.$prefix.'id").click(function() {';
6680 $retstring.=" jQuery(
'#".$prefix."').focus();
";
6683 $retstring.="</script>
";*/
6685 $retstringbutton = '<button id="'.$prefix.'Button
" type="button" class="dpInvisibleButtons
">'.img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"').'</button>';
6686 $retsring = $retstringbutton.$retstring;
6689 $retstring .= '</div>';
6690 $retstring .= '<input type="hidden
" id="'.$prefix.'day
" name="'.$prefix.'day
" value="'.$sday.'">'."\n
";
6691 $retstring .= '<input type="hidden
" id="'.$prefix.'month
" name="'.$prefix.'month
" value="'.$smonth.'">'."\n
";
6692 $retstring .= '<input type="hidden
" id="'.$prefix.'year
" name="'.$prefix.'year
" value="'.$syear.'">'."\n
";
6694 $retstring .= "Bad value of MAIN_POPUP_CALENDAR
";
6697 // Show date with combo selects
6699 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50imp
" id="'.$prefix.'day
" name="'.$prefix.'day
">';
6701 if ($emptydate || $set_time == -1) {
6702 $retstring .= '<option value="0
" selected> </option>';
6705 for ($day = 1; $day <= 31; $day++) {
6706 $retstring .= '<option value="'.$day.'"'.($day == $sday ? ' selected' : '').'>'.$day.'</option>';
6709 $retstring .= "</select>
";
6711 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth75imp
" id="'.$prefix.'month
" name="'.$prefix.'month
">';
6712 if ($emptydate || $set_time == -1) {
6713 $retstring .= '<option value="0
" selected> </option>';
6717 for ($month = 1; $month <= 12; $month++) {
6718 $retstring .= '<option value="'.$month.'"'.($month == $smonth ? ' selected' : '').'>';
6719 $retstring .= dol_print_date(mktime(12, 0, 0, $month, 1, 2000), "%b
");
6720 $retstring .= "</option>
";
6722 $retstring .= "</select>
";
6725 if ($emptydate || $set_time == -1) {
6726 $retstring .= '<input'.($disabled ? ' disabled' : '').' placeholder="'.dol_escape_htmltag($langs->trans("Year")).'" class="flat maxwidth50imp valignmiddle
" type="number
" min="0
" max="3000
" maxlength="4
" id="'.$prefix.'year
" name="'.$prefix.'year
" value="'.$syear.'">';
6728 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth75imp
" id="'.$prefix.'year
" name="'.$prefix.'year
">';
6730 for ($year = $syear - 10; $year < $syear + 10; $year++) {
6731 $retstring .= '<option value="'.$year.'"'.($year == $syear ? ' selected' : '').'>'.$year.'</option>';
6733 $retstring .= "</select>\n
";
6739 $retstring .= ($h == 2 ? '<br>' : ' ');
6740 $retstring .= '<span class="nowraponall
">';
6746 if ($openinghours != '') {
6747 $openinghours = explode(',', $openinghours);
6748 $hourstart = $openinghours[0];
6749 $hourend = $openinghours[1];
6750 if ($hourend < $hourstart) {
6751 $hourend = $hourstart;
6755 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50
'.($fullday ? $fullday.'hour
' : '').'" id="'.$prefix.'hour
" name="'.$prefix.'hour
">';
6757 $retstring .= '<option value="-1
"> </option>';
6759 for ($hour = $hourstart; $hour < $hourend; $hour++) {
6760 if (strlen($hour) < 2) {
6763 $retstring .= '<option value="'.$hour.'"'.(($hour == $shour) ? ' selected' : '').'>'.$hour;
6764 //$retstring .= (empty($conf->dol_optimize_smallscreen) ? '' : 'H');
6765 $retstring .= '</option>';
6767 $retstring .= '</select>';
6768 //if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":
";
6776 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50
'.($fullday ? $fullday.'min
' : '').'" id="'.$prefix.'min
" name="'.$prefix.'min
">';
6778 $retstring .= '<option value="-1
"> </option>';
6780 for ($min = 0; $min < 60; $min += $stepminutes) {
6781 if (strlen($min) < 2) {
6784 $retstring .= '<option value="'.$min.'"'.(($min == $smin) ? ' selected' : '').'>'.$min.(empty($conf->dol_optimize_smallscreen) ? '' : '').'</option>';
6786 $retstring .= '</select>';
6788 $retstring .= '<input type="hidden
" name="'.$prefix.'sec
" value="'.$ssec.'">';
6792 $retstring .= '</span>';
6796 if (!empty($conf->use_javascript_ajax) && $addnowlink) {
6797 // Script which will be inserted in the onClick of the "Now
" link
6798 $reset_scripts = "";
6799 if ($addnowlink == 2) { // local computer time
6800 // pad add leading 0 on numbers
6801 $reset_scripts .= "Number.prototype.pad =
function(size) {
6802 var s = String(
this);
6803 while (s.length < (size || 2)) {s =
'0' + s;}
6806 var d =
new Date();
";
6809 // Generate the date part, depending on the use or not of the javascript calendar
6810 if ($addnowlink == 1) { // server time expressed in user time setup
6811 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'day', 'tzuserrel').'\');';
6812 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');';
6813 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');';
6814 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');';
6815 } elseif ($addnowlink == 2) {
6816 /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix.
6817 * This break application for foreign languages.
6818 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));';
6819 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());';
6820 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);';
6821 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());';
6823 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'day', 'tzuserrel').'\');';
6824 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');';
6825 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');';
6826 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');';
6828 /*if ($usecalendar == "eldy
")
6830 $base=DOL_URL_ROOT.'/core/';
6831 $reset_scripts .= 'resetDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput
").'\',\''.$langs->defaultlang.'\');';
6835 $reset_scripts .= 'this.form.elements[\''.$prefix.'day\'].value=formatDate(new Date(), \'d\'); ';
6836 $reset_scripts .= 'this.form.elements[\''.$prefix.'month\'].value=formatDate(new Date(), \'M\'); ';
6837 $reset_scripts .= 'this.form.elements[\''.$prefix.'year\'].value=formatDate(new Date(), \'yyyy\'); ';
6839 // Update the hour part
6842 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
6844 //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); ';
6845 if ($addnowlink == 1) {
6846 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');';
6847 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();';
6848 } elseif ($addnowlink == 2) {
6849 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());';
6850 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();';
6854 $reset_scripts .= ' } ';
6857 // Update the minute part
6860 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
6862 //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); ';
6863 if ($addnowlink == 1) {
6864 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');';
6865 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();';
6866 } elseif ($addnowlink == 2) {
6867 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());';
6868 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();';
6871 $reset_scripts .= ' } ';
6874 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
6875 if ($reset_scripts && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
6876 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="'.$prefix.'ButtonNow
" type="button" name="_useless
" value="now
" onClick="'.$reset_scripts.'">';
6877 $retstring .= $langs->trans("Now
");
6878 $retstring .= '</button> ';
6882 // Add a "Plus one hour
" link
6883 if ($conf->use_javascript_ajax && $addplusone) {
6884 // Script which will be inserted in the onClick of the "Add plusone
" link
6885 $reset_scripts = "";
6887 // Generate the date part, depending on the use or not of the javascript calendar
6888 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'dayinputnoreduce', 'tzuserrel').'\');';
6889 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');';
6890 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');';
6891 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');';
6892 // Update the hour part
6895 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
6897 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');';
6899 $reset_scripts .= ' } ';
6902 // Update the minute part
6905 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
6907 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');';
6909 $reset_scripts .= ' } ';
6912 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
6913 if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
6914 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="'.$prefix.'ButtonPlusOne
" type="button" name="_useless2
" value="plusone
" onClick="'.$reset_scripts.'">';
6915 $retstring .= $langs->trans("DateStartPlusOne
");
6916 $retstring .= '</button> ';
6920 // Add a link to set data
6921 if ($conf->use_javascript_ajax && $adddateof) {
6922 $tmparray = dol_getdate($adddateof);
6923 if (empty($labeladddateof)) {
6924 $labeladddateof = $langs->trans("DateInvoice
");
6926 $retstring .= ' - <button class="dpInvisibleButtons datenowlink
" id="dateofinvoice
" type="button" name="_dateofinvoice
" value="now
" onclick="console.log(\
'Click on now link\'); jQuery(\'#re\').val(\''.
dol_print_date($adddateof,
'dayinputnoreduce').
'\');jQuery(\
'#reday\').val(\''.$tmparray[
'mday'].
'\');jQuery(\
'#remonth\').val(\''.$tmparray[
'mon'].
'\');jQuery(\
'#reyear\').val(\''.$tmparray[
'year'].
'\');
">'.$labeladddateof.'</a>';
6940 public function selectTypeDuration($prefix, $selected = 'i', $excludetypes = array())
6944 $TDurationTypes = array(
6945 'y'=>$langs->trans('Years'),
6946 'm'=>$langs->trans('Month'),
6947 'w'=>$langs->trans('Weeks'),
6948 'd'=>$langs->trans('Days'),
6949 'h'=>$langs->trans('Hours'),
6950 'i'=>$langs->trans('Minutes')
6953 // Removed undesired duration types
6954 foreach ($excludetypes as $value) {
6955 unset($TDurationTypes[$value]);
6958 $retstring = '<select class="flat minwidth75 maxwidth100
" id="select_
'.$prefix.'type_duration
" name="'.$prefix.'type_duration
">';
6959 foreach ($TDurationTypes as $key => $typeduration) {
6960 $retstring .= '<option value="'.$key.'"';
6961 if ($key == $selected) {
6962 $retstring .= " selected
";
6964 $retstring .= ">
".$typeduration."</option>
";
6966 $retstring .= "</select>
";
6968 $retstring .= ajax_combobox('select_'.$prefix.'type_duration');
6973 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
6987 public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0)
6992 $retstring = '<span class="nowraponall
">';
6998 if ($iSecond != '') {
6999 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
7001 $hourSelected = convertSecondToTime($iSecond, 'allhour');
7002 $minSelected = convertSecondToTime($iSecond, 'min');
7005 if ($typehour == 'select') {
7006 $retstring .= '<select class="flat
" id="select_
'.$prefix.'hour
" name="'.$prefix.'hour
"'.($disabled ? ' disabled' : '').'>';
7007 for ($hour = 0; $hour < 25; $hour++) { // For a duration, we allow 24 hours
7008 $retstring .= '<option value="'.$hour.'"';
7009 if ($hourSelected == $hour) {
7010 $retstring .= " selected
";
7012 $retstring .= ">
".$hour."</option>
";
7014 $retstring .= "</select>
";
7015 } elseif ($typehour == 'text' || $typehour == 'textselect') {
7016 $retstring .= '<input placeholder="'.$langs->trans('HourShort
').'" type="number
" min="0
" name="'.$prefix.'hour
"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputhour
" value="'.(($hourSelected != '') ? ((int) $hourSelected) : '').'">';
7018 return 'BadValueForParameterTypeHour';
7021 if ($typehour != 'text') {
7022 $retstring .= ' '.$langs->trans('HourShort');
7024 $retstring .= '<span class="">:</span>';
7028 if ($minunderhours) {
7029 $retstring .= '<br>';
7031 $retstring .= '<span class="hideonsmartphone
"> </span>';
7034 if ($typehour == 'select' || $typehour == 'textselect') {
7035 $retstring .= '<select class="flat
" id="select_
'.$prefix.'min
" name="'.$prefix.'min
"'.($disabled ? ' disabled' : '').'>';
7036 for ($min = 0; $min <= 55; $min = $min + 5) {
7037 $retstring .= '<option value="'.$min.'"';
7038 if ($minSelected == $min) {
7039 $retstring .= ' selected';
7041 $retstring .= '>'.$min.'</option>';
7043 $retstring .= "</select>
";
7044 } elseif ($typehour == 'text') {
7045 $retstring .= '<input placeholder="'.$langs->trans('MinuteShort
').'" type="number
" min="0
" name="'.$prefix.'min
"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputminute
" value="'.(($minSelected != '') ? ((int) $minSelected) : '').'">';
7048 if ($typehour != 'text') {
7049 $retstring .= ' '.$langs->trans('MinuteShort');
7052 $retstring.="</span>
";
7054 if (!empty($nooutput)) {
7081 public function selectTickets($selected = '', $htmlname = 'ticketid', $filtertype = '', $limit = 0, $status = 1, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $selected_combinations = null, $nooutput = 0)
7083 global $langs, $conf;
7088 if (is_null($ajaxoptions)) $ajaxoptions = array();
7090 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
7093 if ($selected && empty($selected_input_value)) {
7094 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
7095 $tickettmpselect = new Ticket($this->db);
7096 $tickettmpselect->fetch($selected);
7097 $selected_input_value = $tickettmpselect->ref;
7098 unset($tickettmpselect);
7102 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/ticket/ajax/tickets.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7104 if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel
").' : ';
7105 elseif ($hidelabel > 1) {
7106 $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
7107 if ($hidelabel == 2) {
7108 $out .= img_picto($langs->trans("Search
"), 'search');
7111 $out .= '<input type="text
" class="minwidth100
" name="search_
'.$htmlname.'" id="search_
'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
7112 if ($hidelabel == 3) {
7113 $out .= img_picto($langs->trans("Search
"), 'search');
7116 $out .= $this->selectTicketsList($selected, $htmlname, $filtertype, $limit, $status, 0, $socid, $showempty, $forcecombo, $morecss);
7119 if (empty($nooutput)) {
7144 public function selectTicketsList($selected = '', $htmlname = 'ticketid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7146 global $langs, $conf;
7149 $outarray = array();
7151 $selectFields = " p.rowid, p.ref, p.message
";
7154 $sql .= $selectFields;
7155 $sql .= " FROM
".$this->db->prefix()."ticket as p
";
7156 $sql .= ' WHERE p.entity IN ('.getEntity('ticket').')';
7158 // Add criteria on ref/label
7159 if ($filterkey != '') {
7161 $prefix = empty($conf->global->TICKET_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7162 // For natural search
7163 $scrit = explode(' ', $filterkey);
7165 if (count($scrit) > 1) $sql .= "(
";
7166 foreach ($scrit as $crit) {
7167 if ($i > 0) $sql .= " AND
";
7168 $sql .= "(p.ref LIKE
'".$this->db->escape($prefix.$crit)."%' OR p.subject LIKE
'".$this->db->escape($prefix.$crit)."%'";
7172 if (count($scrit) > 1) $sql .= ")
";
7176 $sql .= $this->db->plimit($limit, 0);
7178 // Build output string
7180 $result = $this->db->query($sql);
7182 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
7183 require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
7185 $num = $this->db->num_rows($result);
7190 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
7191 $out .= ajax_combobox($htmlname, $events, $conf->global->TICKET_USE_SEARCH_TO_SELECT);
7194 $out .= '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
7197 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7198 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7199 if (!empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
7200 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7201 else $textifempty .= $langs->trans("All
");
7203 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7205 if ($showempty) $out .= '<option value="0
" selected>'.$textifempty.'</option>';
7208 while ($num && $i < $num) {
7211 $objp = $this->db->fetch_object($result);
7213 $this->constructTicketListOption($objp, $opt, $optJson, $selected, $filterkey);
7215 // "key
" value of json key array is used by jQuery automatically as selected value
7216 // "label
" value of json key array is used by jQuery automatically as text for combo box
7218 array_push($outarray, $optJson);
7223 $out .= '</select>';
7225 $this->db->free($result);
7227 if (empty($outputmode)) {
7232 dol_print_error($this->db);
7249 protected function constructTicketListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7255 $outkey = $objp->rowid;
7256 $outref = $objp->ref;
7257 $outtype = $objp->fk_product_type;
7259 $opt = '<option value="'.$objp->rowid.'"';
7260 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7263 $objRef = $objp->ref;
7264 if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
7266 $opt .= "</option>\n
";
7267 $optJson = array('key'=>$outkey, 'value'=>$outref, 'type'=>$outtype);
7289 public function selectProjects($selected = '', $htmlname = 'projectid', $filtertype = '', $limit = 0, $status = 1, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $selected_combinations = null, $nooutput = 0)
7291 global $langs, $conf;
7296 if (is_null($ajaxoptions)) $ajaxoptions = array();
7298 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
7301 if ($selected && empty($selected_input_value)) {
7302 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
7303 $projecttmpselect = new Project($this->db);
7304 $projecttmpselect->fetch($selected);
7305 $selected_input_value = $projecttmpselect->ref;
7306 unset($projecttmpselect);
7309 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7311 if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel
").' : ';
7312 elseif ($hidelabel > 1) {
7313 $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
7314 if ($hidelabel == 2) {
7315 $out .= img_picto($langs->trans("Search
"), 'search');
7318 $out .= '<input type="text
" class="minwidth100
" name="search_
'.$htmlname.'" id="search_
'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
7319 if ($hidelabel == 3) {
7320 $out .= img_picto($langs->trans("Search
"), 'search');
7323 $out .= $this->selectProjectsList($selected, $htmlname, $filtertype, $limit, $status, 0, $socid, $showempty, $forcecombo, $morecss);
7326 if (empty($nooutput)) {
7350 public function selectProjectsList($selected = '', $htmlname = 'projectid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7352 global $langs, $conf;
7355 $outarray = array();
7357 $selectFields = " p.rowid, p.ref
";
7360 $sql .= $selectFields;
7361 $sql .= " FROM
".$this->db->prefix()."projet as p
";
7362 $sql .= ' WHERE p.entity IN ('.getEntity('project').')';
7364 // Add criteria on ref/label
7365 if ($filterkey != '') {
7367 $prefix = empty($conf->global->TICKET_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7368 // For natural search
7369 $scrit = explode(' ', $filterkey);
7371 if (count($scrit) > 1) $sql .= "(
";
7372 foreach ($scrit as $crit) {
7373 if ($i > 0) $sql .= " AND
";
7374 $sql .= "p.ref LIKE
'".$this->db->escape($prefix.$crit)."%'";
7378 if (count($scrit) > 1) $sql .= ")
";
7382 $sql .= $this->db->plimit($limit, 0);
7384 // Build output string
7386 $result = $this->db->query($sql);
7388 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
7389 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
7391 $num = $this->db->num_rows($result);
7396 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
7397 $out .= ajax_combobox($htmlname, $events, $conf->global->PROJECT_USE_SEARCH_TO_SELECT);
7400 $out .= '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
7403 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7404 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7405 if (!empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) {
7406 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7407 else $textifempty .= $langs->trans("All
");
7409 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7411 if ($showempty) $out .= '<option value="0
" selected>'.$textifempty.'</option>';
7414 while ($num && $i < $num) {
7417 $objp = $this->db->fetch_object($result);
7419 $this->constructProjectListOption($objp, $opt, $optJson, $selected, $filterkey);
7421 // "key
" value of json key array is used by jQuery automatically as selected value
7422 // "label
" value of json key array is used by jQuery automatically as text for combo box
7424 array_push($outarray, $optJson);
7429 $out .= '</select>';
7431 $this->db->free($result);
7433 if (empty($outputmode)) {
7438 dol_print_error($this->db);
7455 protected function constructProjectListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7461 $label = $objp->label;
7463 $outkey = $objp->rowid;
7464 $outref = $objp->ref;
7465 $outlabel = $objp->label;
7466 $outtype = $objp->fk_product_type;
7468 $opt = '<option value="'.$objp->rowid.'"';
7469 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7472 $objRef = $objp->ref;
7473 if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
7475 $opt .= "</option>\n
";
7476 $optJson = array('key'=>$outkey, 'value'=>$outref, 'type'=>$outtype);
7499 public function selectMembers($selected = '', $htmlname = 'adherentid', $filtertype = '', $limit = 0, $status = 1, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $selected_combinations = null, $nooutput = 0)
7501 global $langs, $conf;
7506 if (is_null($ajaxoptions)) $ajaxoptions = array();
7508 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
7512 if ($selected && empty($selected_input_value)) {
7513 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
7514 $adherenttmpselect = new Adherent($this->db);
7515 $adherenttmpselect->fetch($selected);
7516 $selected_input_value = $adherenttmpselect->ref;
7517 unset($adherenttmpselect);
7522 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/adherents/ajax/adherents.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7524 if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel
").' : ';
7525 elseif ($hidelabel > 1) {
7526 $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
7527 if ($hidelabel == 2) {
7528 $out .= img_picto($langs->trans("Search
"), 'search');
7531 $out .= '<input type="text
" class="minwidth100
" name="search_
'.$htmlname.'" id="search_
'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
7532 if ($hidelabel == 3) {
7533 $out .= img_picto($langs->trans("Search
"), 'search');
7538 $out .= $this->selectMembersList($selected, $htmlname, $filtertype, $limit, $filterkey, $status, 0, $showempty, $forcecombo, $morecss);
7541 if (empty($nooutput)) {
7565 public function selectMembersList($selected = '', $htmlname = 'adherentid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7567 global $langs, $conf;
7570 $outarray = array();
7572 $selectFields = " p.rowid, p.ref, p.firstname, p.lastname
";
7575 $sql .= $selectFields;
7576 $sql .= " FROM
".$this->db->prefix()."adherent as p
";
7577 $sql .= ' WHERE p.entity IN ('.getEntity('adherent').')';
7579 // Add criteria on ref/label
7580 if ($filterkey != '') {
7582 $prefix = empty($conf->global->MEMBER_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7583 // For natural search
7584 $scrit = explode(' ', $filterkey);
7586 if (count($scrit) > 1) $sql .= "(
";
7587 foreach ($scrit as $crit) {
7588 if ($i > 0) $sql .= " AND
";
7589 $sql .= "(p.firstname LIKE
'".$this->db->escape($prefix.$crit)."%'";
7590 $sql .= " OR p.lastname LIKE
'".$this->db->escape($prefix.$crit)."%')
";
7593 if (count($scrit) > 1) $sql .= ")
";
7596 if ($status != -1) {
7597 $sql .= ' AND statut = '.((int) $status);
7599 $sql .= $this->db->plimit($limit, 0);
7601 // Build output string
7603 $result = $this->db->query($sql);
7605 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
7606 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
7608 $num = $this->db->num_rows($result);
7613 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
7614 $out .= ajax_combobox($htmlname, $events, $conf->global->PROJECT_USE_SEARCH_TO_SELECT);
7617 $out .= '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
7620 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7621 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7622 if (!empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) {
7623 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7624 else $textifempty .= $langs->trans("All
");
7626 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7629 $out .= '<option value="-1
" selected>'.$textifempty.'</option>';
7633 while ($num && $i < $num) {
7636 $objp = $this->db->fetch_object($result);
7638 $this->constructMemberListOption($objp, $opt, $optJson, $selected, $filterkey);
7641 // "key
" value of json key array is used by jQuery automatically as selected value
7642 // "label
" value of json key array is used by jQuery automatically as text for combo box
7644 array_push($outarray, $optJson);
7649 $out .= '</select>';
7651 $this->db->free($result);
7653 if (empty($outputmode)) {
7658 dol_print_error($this->db);
7675 protected function constructMemberListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7681 $outkey = $objp->rowid;
7682 $outlabel = dolGetFirstLastname($objp->firstname, $objp->lastname);
7683 $outtype = $objp->fk_adherent_type;
7685 $opt = '<option value="'.$objp->rowid.'"';
7686 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7688 if (!empty($filterkey) && $filterkey != '') {
7689 $outlabel = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $outlabel, 1);
7692 $opt .= "</option>\n
";
7694 $optJson = array('key'=>$outkey, 'value'=>$outlabel, 'type'=>$outtype);
7716 public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '')
7718 global $conf, $user;
7722 // Example of value for $objectdec:
7723 // Bom:bom/class/bom.class.php:0:t.status=1
7724 // Bom:bom/class/bom.class.php:0:t.status=1:ref
7725 // Bom:bom/class/bom.class.php:0:(t.status:=:1):ref
7726 $InfoFieldList = explode(":
", $objectdesc, 4);
7727 $vartmp = (empty($InfoFieldList[3]) ? '' : $InfoFieldList[3]);
7729 if (preg_match('/^.*:(\w*)$/', $vartmp, $reg)) {
7730 $InfoFieldList[4] = $reg[1]; // take the sort field
7732 $InfoFieldList[3] = preg_replace('/:\w*$/', '', $vartmp); // take the filter field
7734 $classname = $InfoFieldList[0];
7735 $classpath = $InfoFieldList[1];
7736 $addcreatebuttonornot = empty($InfoFieldList[2]) ? 0 : $InfoFieldList[2];
7737 $filter = empty($InfoFieldList[3]) ? '' : $InfoFieldList[3];
7738 $sortfield = empty($InfoFieldList[4]) ? '' : $InfoFieldList[4];
7740 if (!empty($classpath)) {
7741 dol_include_once($classpath);
7743 if ($classname && class_exists($classname)) {
7744 $objecttmp = new $classname($this->db);
7746 // Make some replacement
7747 $sharedentities = getEntity(strtolower($classname));
7748 $filter = str_replace(
7749 array('__ENTITY__', '__SHARED_ENTITIES__', '__USER_ID__'),
7750 array($conf->entity, $sharedentities, $user->id),
7755 if (!is_object($objecttmp)) {
7756 dol_syslog('Error bad setup of type for field '.join(',', $InfoFieldList), LOG_WARNING);
7757 return 'Error bad setup of type for field '.join(',', $InfoFieldList);
7760 //var_dump($filter);
7761 $prefixforautocompletemode = $objecttmp->element;
7762 if ($prefixforautocompletemode == 'societe') {
7763 $prefixforautocompletemode = 'company';
7765 if ($prefixforautocompletemode == 'product') {
7766 $prefixforautocompletemode = 'produit';
7768 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
7770 dol_syslog(get_class($this)."::
selectForForms filter=
".$filter, LOG_DEBUG);
7772 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->$confkeyforautocompletemode) && !$forcecombo) {
7773 // No immediate load of all database
7775 if ($preselectedvalue && empty($selected_input_value)) {
7776 $objecttmp->fetch($preselectedvalue);
7777 $selected_input_value = ($prefixforautocompletemode == 'company' ? $objecttmp->name : $objecttmp->ref);
7778 //unset($objecttmp);
7781 $objectdesc = $classname.':'.$classpath.':'.$addcreatebuttonornot.':'.$filter;
7782 $urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php';
7784 // No immediate load of all database
7785 $urloption = 'htmlname='.urlencode($htmlname).'&outjson=1&objectdesc='.urlencode($objectdesc).'&filter='.urlencode($filter).($sortfield ? '&sortfield='.urlencode($sortfield) : '');
7786 // Activate the auto complete using ajax call.
7787 $out .= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array());
7788 $out .= '<style type="text/css
">.ui-autocomplete { z-index: 1003; }</style>';
7789 $out .= '<input type="text
" class="'.$morecss.'"'.($disabled ? ' disabled="disabled
"' : '').' name="search_
'.$htmlname.'" id="search_
'.$htmlname.'" value="'.$selected_input_value.'"'.($placeholder ? ' placeholder="'.dol_escape_htmltag($placeholder).'"' : '') .' />';
7791 // Immediate load of table record.
7792 $out .= $this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled, $sortfield, $filter);
7804 protected static function forgeCriteriaCallback($matches)
7808 //dol_syslog("Convert matches
".$matches[1]);
7809 if (empty($matches[1])) {
7812 $tmp = explode(':', $matches[1]);
7813 if (count($tmp) < 3) {
7817 $tmpescaped = $tmp[2];
7819 if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) {
7820 $tmpescaped = "'".$db->escape($regbis[1])."'";
7822 $tmpescaped = $db->escape($tmpescaped);
7824 return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped;
7847 public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0, $sortfield = '', $filter = '')
7849 global $conf, $langs, $user, $hookmanager;
7851 //print "$htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, $outputmode, $disabled
";
7853 $prefixforautocompletemode = $objecttmp->element;
7854 if ($prefixforautocompletemode == 'societe') {
7855 $prefixforautocompletemode = 'company';
7857 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
7859 if (!empty($objecttmp->fields)) { // For object that declare it, it is better to use declared fields (like societe, contact, ...)
7860 $tmpfieldstoshow = '';
7861 foreach ($objecttmp->fields as $key => $val) {
7862 if (!dol_eval($val['enabled'], 1, 1, '1')) {
7865 if (!empty($val['showoncombobox'])) {
7866 $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '').'t.'.$key;
7869 if ($tmpfieldstoshow) {
7870 $fieldstoshow = $tmpfieldstoshow;
7873 // For backward compatibility
7874 $objecttmp->fields['ref'] = array('type'=>'varchar(30)', 'label'=>'Ref', 'showoncombobox'=>1);
7877 if (empty($fieldstoshow)) {
7878 if (isset($objecttmp->fields['ref'])) {
7879 $fieldstoshow = 't.ref';
7881 $langs->load("errors
");
7882 $this->error = $langs->trans("ErrorNoFieldWithAttributeShowoncombobox
");
7883 return $langs->trans('ErrorNoFieldWithAttributeShowoncombobox');
7888 $outarray = array();
7889 $tmparray = array();
7894 $sql = "SELECT t.rowid,
".$fieldstoshow." FROM
".$this->db->prefix().$objecttmp->table_element." as t
";
7895 if (isset($objecttmp->ismultientitymanaged)) {
7896 if (!is_numeric($objecttmp->ismultientitymanaged)) {
7897 $tmparray = explode('@', $objecttmp->ismultientitymanaged);
7898 $sql .= " INNER JOIN
".$this->db->prefix().$tmparray[1]." as parenttable ON parenttable.rowid = t.
".$tmparray[0];
7900 if ($objecttmp->ismultientitymanaged === 'fk_soc@societe') {
7901 if (empty($user->rights->societe->client->voir) && !$user->socid) {
7902 $sql .= ",
".$this->db->prefix()."societe_commerciaux as sc
";
7907 // Add where from hooks
7908 $parameters = array();
7909 $reshook = $hookmanager->executeHooks('selectForFormsListWhere', $parameters); // Note that $action and $object may have been modified by hook
7910 if (!empty($hookmanager->resPrint)) {
7911 $sql .= $hookmanager->resPrint;
7913 $sql .= " WHERE 1=1
";
7914 if (isset($objecttmp->ismultientitymanaged)) {
7915 if ($objecttmp->ismultientitymanaged == 1) {
7916 $sql .= " AND t.entity IN (
".getEntity($objecttmp->table_element).")
";
7918 if (!is_numeric($objecttmp->ismultientitymanaged)) {
7919 $sql .= " AND parenttable.entity = t.
".$tmparray[0];
7921 if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
7922 if ($objecttmp->element == 'societe') {
7923 $sql .= " AND t.rowid =
".((int) $user->socid);
7925 $sql .= " AND t.fk_soc =
".((int) $user->socid);
7928 if ($objecttmp->ismultientitymanaged === 'fk_soc@societe') {
7929 if (empty($user->rights->societe->client->voir) && !$user->socid) {
7930 $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user =
".((int) $user->id);
7934 if ($searchkey != '') {
7935 $sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
7938 if ($filter) { // Syntax example "(t.ref:like:
'SO-%') and (t.date_creation:<:
'20160101')
"
7939 /*if (! DolibarrApi::_checkFilters($filter))
7941 throw new RestException(503, 'Error when validating parameter sqlfilters '.$filter);
7943 $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
7944 $sql .= " AND (
".preg_replace_callback('/'.$regexstring.'/', 'Form::forgeCriteriaCallback', $filter).")
";
7947 $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow, "ASC
");
7948 //$sql.=$this->db->plimit($limit, 0);
7951 // Build output string
7952 $resql = $this->db->query($sql);
7954 // Construct $out and $outarray
7955 $out .= '<select id="'.$htmlname.'" class="flat
'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled
"' : '').($moreparams ? ' '.$moreparams : '').' name="'.$htmlname.'">'."\n
";
7957 // Warning: Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. Seems it is no more true with selec2 v4
7958 $textifempty = ' ';
7960 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7961 if (!empty($conf->global->$confkeyforautocompletemode)) {
7962 if ($showempty && !is_numeric($showempty)) {
7963 $textifempty = $langs->trans($showempty);
7965 $textifempty .= $langs->trans("All
");
7969 $out .= '<option value="-1
">'.$textifempty.'</option>'."\n
";
7972 $num = $this->db->num_rows($resql);
7976 $obj = $this->db->fetch_object($resql);
7978 $tmparray = explode(',', $fieldstoshow);
7979 $oldvalueforshowoncombobox = 0;
7980 foreach ($tmparray as $key => $val) {
7981 $val = preg_replace('/t\./', '', $val);
7982 $label .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val]['showoncombobox'] ? ' - ' : ' ') : '');
7983 $label .= $obj->$val;
7984 $oldvalueforshowoncombobox = !empty($objecttmp->fields[$val]['showoncombobox']) ? $objecttmp->fields[$val]['showoncombobox'] : 0;
7986 if (empty($outputmode)) {
7987 if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
7988 $out .= '<option value="'.$obj->rowid.'" selected>'.$label.'</option>';
7990 $out .= '<option value="'.$obj->rowid.'">'.$label.'</option>';
7993 array_push($outarray, array('key'=>$obj->rowid, 'value'=>$label, 'label'=>$label));
7997 if (($i % 10) == 0) {
8003 $out .= '</select>'."\n
";
8006 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
8007 $out .= ajax_combobox($htmlname, null, (!empty($conf->global->$confkeyforautocompletemode) ? $conf->global->$confkeyforautocompletemode : 0));
8010 dol_print_error($this->db);
8013 $this->result = array('nbofelement'=>$num);
8045 public static function selectarray($htmlname, $array, $id = '', $show_empty = 0, $key_in_label = 0, $value_as_key = 0, $moreparam = '', $translate = 0, $maxlen = 0, $disabled = 0, $sort = '', $morecss = 'minwidth75', $addjscombo = 1, $moreparamonempty = '', $disablebademail = 0, $nohtmlescape = 0)
8047 global $conf, $langs;
8049 // Do we want a multiselect ?
8051 //if (preg_match('/^multi/',$htmlname)) $jsbeautify = 1;
8054 if ($value_as_key) {
8055 $array = array_combine($array, $array);
8060 if ($addjscombo < 0) {
8061 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
8068 $idname = str_replace(array('[', ']'), array('', ''), $htmlname);
8069 $out .= '<select id="'.preg_replace('/^\./
', '', $idname).'" '.($disabled ? 'disabled="disabled
" ' : '').'class="flat
'.(preg_replace('/^\./
', '', $htmlname)).($morecss ? ' '.$morecss : '').'"';
8070 $out .= ' name="'.preg_replace('/^\./
', '', $htmlname).'" '.($moreparam ? $moreparam : '');
8074 $textforempty = ' ';
8075 if (!empty($conf->use_javascript_ajax)) {
8076 $textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
8078 if (!is_numeric($show_empty)) {
8079 $textforempty = $show_empty;
8081 $out .= '<option class="optiongrey
" '.($moreparamonempty ? $moreparamonempty.' ' : '').'value="'.($show_empty < 0 ? $show_empty : -1).'"'.($id == $show_empty ? ' selected' : '').'>'.$textforempty.'</option>'."\n
";
8084 if (is_array($array)) {
8087 foreach ($array as $key => $value) {
8088 if (!is_array($value)) {
8089 $array[$key] = $langs->trans($value);
8091 $array[$key]['label'] = $langs->trans($value['label']);
8097 if ($sort == 'ASC') {
8099 } elseif ($sort == 'DESC') {
8103 foreach ($array as $key => $tmpvalue) {
8104 if (is_array($tmpvalue)) {
8105 $value = $tmpvalue['label'];
8106 $disabled = empty($tmpvalue['disabled']) ? '' : ' disabled';
8107 $style = empty($tmpvalue['css']) ? '' : ' class="'.$tmpvalue['css
'].'"';
8113 if (!empty($disablebademail)) {
8114 if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value))
8115 || ($disablebademail == 2 && preg_match('/---/', $value))) {
8116 $disabled = ' disabled';
8117 $style = ' class="warning
"';
8121 if ($key_in_label) {
8122 if (empty($nohtmlescape)) {
8123 $selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value));
8125 $selectOptionValue = $key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value);
8128 if (empty($nohtmlescape)) {
8129 $selectOptionValue = dol_escape_htmltag($maxlen ?dol_trunc($value, $maxlen) : $value);
8131 $selectOptionValue = $maxlen ? dol_trunc($value, $maxlen) : $value;
8133 if ($value == '' || $value == '-') {
8134 $selectOptionValue = ' ';
8138 $out .= '<option value="'.$key.'"';
8139 $out .= $style.$disabled;
8140 if (is_array($id)) {
8141 if (in_array($key, $id) && !$disabled) {
8142 $out .= ' selected'; // To preselect a value
8145 $id = (string) $id; // if $id = 0, then $id = '0'
8146 if ($id != '' && ($id == $key || ($id == 'ifone' && count($array) == 1)) && !$disabled) {
8147 $out .= ' selected'; // To preselect a value
8150 if ($nohtmlescape) {
8151 $out .= ' data-html="'.dol_escape_htmltag($selectOptionValue).'"';
8153 if (is_array($tmpvalue)) {
8154 foreach ($tmpvalue as $keyforvalue => $valueforvalue) {
8155 if (preg_match('/^data-/', $keyforvalue)) {
8156 $out .= ' '.$keyforvalue.'="'.$valueforvalue.'"';
8161 //var_dump($selectOptionValue);
8162 $out .= $selectOptionValue;
8163 $out .= "</option>\n
";
8167 $out .= "</select>
";
8169 // Add code for jquery to use multiselect
8170 if ($addjscombo && $jsbeautify) {
8171 // Enhance with select2
8172 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
8173 $out .= ajax_combobox($idname, array(), 0, 0, 'resolve', ($show_empty < 0 ? (string) $show_empty : '-1'), $morecss);
8198 public static function selectArrayAjax($htmlname, $url, $id = '', $moreparam = '', $moreparamtourl = '', $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0)
8200 global $conf, $langs;
8201 global $delayedhtmlcontent; // Will be used later outside of this function
8203 // TODO Use an internal dolibarr component instead of select2
8204 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) {
8208 $out = '<select type="text
" class="'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name="'.$htmlname.'"></select>';
8211 if (!empty($conf->use_javascript_ajax)) {
8212 $tmpplugin = 'select2';
8213 $outdelayed = "\n
".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
8215 $(document).ready(function () {
8217 '.($callurlonselect ? 'var saveRemoteData = [];' : '').'
8219 $(".
'.$htmlname.'").select2({
8225 data: function (params) {
8227 q: params.term, // search term
8231 processResults: function (data) {
8232 // parse the results into the format expected by Select2.
8233 // since we are using custom formatting functions we do not need to alter the remote JSON data
8234 //console.log(data);
8235 saveRemoteData = data;
8236 /* format json result for select2 */
8238 $.each( data, function( key, value ) {
8239 result.push({id: key, text: value.text});
8241 //return {results:[{id:\'none\', text:\'aa\'}, {id:\'rrr\', text:\'Red\'},{id:\'bbb\', text:\'Search a into projects\'}], more:false}
8242 //console.log(result);
8243 return {results: result, more: false}
8247 language: select2arrayoflanguage,
8248 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
8249 placeholder:
"'.dol_escape_js($placeholder).'",
8250 escapeMarkup:
function (markup) {
return markup; },
8251 minimumInputLength:
'.$minimumInputLength.',
8252 formatResult:
function(result, container, query, escapeMarkup) {
8253 return escapeMarkup(result.text);
8257 '.($callurlonselect ? '
8259 $(
".'.$htmlname.'").change(
function() {
8260 var selected = $(
".'.$htmlname.'").val();
8261 console.log(
"We select in selectArrayAjax the entry "+selected)
8262 $(
".'.$htmlname.'").val(
"");
8263 $.each( saveRemoteData,
function( key, value ) {
8264 if (key == selected)
8266 console.log(
"selectArrayAjax - Do a redirect to "+value.url)
8267 location.assign(value.url);
8276 if ($acceptdelayedhtml) {
8277 $delayedhtmlcontent .= $outdelayed;
8279 $out .= $outdelayed;
8302 public static function selectArrayFilter($htmlname, $array, $id = '', $moreparam = '', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0)
8304 global $conf, $langs;
8305 global $delayedhtmlcontent; // Will be used later outside of this function
8307 // TODO Use an internal dolibarr component instead of select2
8308 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT
')) {
8312 $out = '<select
type=
"text" class=
"'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name=
"'.$htmlname.'"><option></option></select>
';
8314 $formattedarrayresult = array();
8316 foreach ($array as $key => $value) {
8317 $o = new stdClass();
8319 $o->text = $value['text
'];
8320 $o->url = $value['url
'];
8321 $formattedarrayresult[] = $o;
8325 if (!empty($conf->use_javascript_ajax)) {
8326 $tmpplugin = 'select2
';
8327 $outdelayed = "\n".'<!-- JS CODE TO ENABLE
'.$tmpplugin.' for id '.$htmlname.' -->
8329 $(document).ready(
function () {
8330 var data =
'.json_encode($formattedarrayresult).';
8332 '.($callurlonselect ? 'var saveRemoteData =
'.json_encode($array).';
' : '').'
8334 $(
".'.$htmlname.'").select2({
8336 language: select2arrayoflanguage,
8337 containerCssClass: \
':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
8338 placeholder: "'.dol_escape_js($placeholder).
'",
8339 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
8340 minimumInputLength: '.$minimumInputLength.
',
8341 formatResult: function(result, container, query, escapeMarkup) {
8342 return escapeMarkup(result.text);
8344 matcher: function (params, data) {
8346 if(! data.id) return null;';
8348 if ($callurlonselect) {
8352 var urlBase = data.url;
8353 var separ = urlBase.indexOf("?") >= 0 ? "&" : "?";
8354 /* console.log("params.term="+params.term); */
8355 /* console.log("params.term encoded="+encodeURIComponent(params.term)); */
8356 saveRemoteData[data.id].url = urlBase + separ + "search_all=" + encodeURIComponent(params.term.replace(/\"/g, ""));';
8359 if (!$disableFiltering) {
8362 if(data.text.match(new RegExp(params.term))) {
8377 '.($callurlonselect ?
'
8378 /* Code to execute a GET when we select a value */
8379 $(".'.$htmlname.
'").change(function() {
8380 var selected = $(".'.$htmlname.
'").val();
8381 console.log("We select "+selected)
8383 $(".'.$htmlname.
'").val(""); /* reset visible combo value */
8384 $.each( saveRemoteData, function( key, value ) {
8385 if (key == selected)
8387 console.log("selectArrayFilter - Do a redirect to "+value.url)
8388 location.assign(value.url);
8397 if ($acceptdelayedhtml) {
8398 $delayedhtmlcontent .= $outdelayed;
8400 $out .= $outdelayed;
8423 public static function multiselectarray($htmlname, $array, $selected = array(), $key_in_label = 0, $value_as_key = 0, $morecss =
'', $translate = 0, $width = 0, $moreattrib =
'', $elemtype =
'', $placeholder =
'', $addjscombo = -1)
8425 global $conf, $langs;
8429 if ($addjscombo < 0) {
8430 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
8438 $out .=
'<select id="'.$htmlname.
'" class="multiselect'.($morecss ?
' '.$morecss :
'').
'" multiple name="'.$htmlname.
'[]"'.($moreattrib ?
' '.$moreattrib :
'').($width ?
' style="width: '.(preg_match(
'/%/', $width) ? $width : $width.
'px').
'"' :
'').
'>'.
"\n";
8439 if (is_array($array) && !empty($array)) {
8440 if ($value_as_key) {
8441 $array = array_combine($array, $array);
8444 if (!empty($array)) {
8445 foreach ($array as $key => $value) {
8450 if (is_array($value) && array_key_exists(
'id', $value) && array_key_exists(
'label', $value)) {
8451 $tmpkey = $value[
'id'];
8452 $tmpvalue = $value[
'label'];
8453 $tmpcolor = $value[
'color'];
8454 $tmppicto = $value[
'picto'];
8456 $newval = ($translate ? $langs->trans($tmpvalue) : $tmpvalue);
8457 $newval = ($key_in_label ? $tmpkey.
' - '.$newval : $newval);
8459 $out .=
'<option value="'.$tmpkey.
'"';
8460 if (is_array($selected) && !empty($selected) && in_array((
string) $tmpkey, $selected) && ((string) $tmpkey !=
'')) {
8461 $out .=
' selected';
8463 $out .=
' data-html="'.dol_escape_htmltag(($tmppicto ?
img_picto(
'', $tmppicto,
'class="pictofixedwidth" style="color: #'.$tmpcolor.
'"') :
'').$newval).
'"';
8466 $out .=
'</option>'.
"\n";
8470 $out .=
'</select>'.
"\n";
8473 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined(
'REQUIRE_JQUERY_MULTISELECT')) {
8474 $out .=
"\n".
'<!-- JS CODE TO ENABLE select for id '.$htmlname.
', addjscombo='.$addjscombo.
' -->';
8475 $out .=
"\n".
'<script>'.
"\n";
8476 if ($addjscombo == 1) {
8477 $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant(
'REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
8478 $out .=
'function formatResult(record, container) {'.
"\n";
8479 $out .=
' if ($(record.element).attr("data-html") != undefined) return htmlEntityDecodeJs($(record.element).attr("data-html")); // If property html set, we decode html entities and use this'.
"\n";
8480 $out .=
' return record.text;';
8482 $out .=
'function formatSelection(record) {'.
"\n";
8483 if ($elemtype ==
'category') {
8484 $out .=
'return \'<span><img src="'.DOL_URL_ROOT.
'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
8486 $out .=
'return record.text;';
8489 $out .=
'$(document).ready(function () {
8490 $(\'#'.$htmlname.
'\').
'.$tmpplugin.'({
';
8495 text: \''.dol_escape_js($placeholder).
'\'
8498 $out .= ' dir: \
'ltr\',
8499 // Specify format function for dropdown item
8500 formatResult: formatResult,
8501 templateResult: formatResult, /* For 4.0 */
8502 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
8503 // Specify format function for selected item
8504 formatSelection: formatSelection,
8505 templateSelection: formatSelection /* For 4.0 */
8508 /* Add also morecss to the css .select2 that is after the #htmlname, for component that are show dynamically after load, because select2 set
8509 the size only if component is not hidden by default on load */
8510 $(\'#'.$htmlname.
' + .select2\').addClass(\''.$morecss.
'\');
8512 } elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT
')) {
8514 // TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
8516 $out .= 'console.log(\
'addjscombo=2 for htmlname='.$htmlname.
'\');
';
8517 $out .= '$(document).ready(
function () {
8518 $(\
'#'.$htmlname.
'\').multiSelect({
8519 containerHTML: \
'<div class="multi-select-container">\',
8520 menuHTML: \'<div class="multi-select-menu">\',
8521 buttonHTML: \'<span class="multi-select-button '.$morecss.
'">\',
8522 menuItemHTML: \'<label class="multi-select-menuitem">\',
8523 activeClass: \'multi-select-container--open\',
8524 noneText: \''.$placeholder.
'\'
8528 $out .= '</script>
';
8545 public static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage, $pos = '')
8547 global $conf, $langs, $user, $extrafields;
8549 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
8553 $tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; // To get list of saved selected fields to show
8555 if (!empty($user->conf->$tmpvar)) { // A list of fields was already customized for user
8556 $tmparray = explode(',
', $user->conf->$tmpvar);
8557 foreach ($array as $key => $val) {
8559 //var_dump($tmparray);
8560 if (in_array($key, $tmparray)) {
8561 $array[$key]['checked
'] = 1;
8563 $array[$key]['checked
'] = 0;
8566 } else { // There is no list of fields already customized for user
8567 foreach ($array as $key => $val) {
8568 if (!empty($array[$key]['checked
']) && $array[$key]['checked
'] < 0) {
8569 $array[$key]['checked
'] = 0;
8574 $listoffieldsforselection = '';
8575 $listcheckedstring = '';
8577 foreach ($array as $key => $val) {
8579 // var_dump(array_key_exists('enabled
', $val));
8580 // var_dump(!$val['enabled
']);
8581 if (array_key_exists('enabled
', $val) && isset($val['enabled
']) && !$val['enabled
']) {
8582 unset($array[$key]); // We don't want
this field
8585 if (!empty($val[
'type']) && $val[
'type'] ==
'separate') {
8590 if ($val[
'label']) {
8591 if (!empty($val[
'langfile']) && is_object($langs)) {
8592 $langs->load($val[
'langfile']);
8596 $listoffieldsforselection .=
'<li><input type="checkbox" id="checkbox'.$key.
'" value="'.$key.
'"'.((empty($val[
'checked']) || $val[
'checked'] ==
'-1') ?
'' :
' checked="checked"').
'/><label for="checkbox'.$key.
'">'.
dol_escape_htmltag($langs->trans($val[
'label'])).
'</label></li>';
8597 $listcheckedstring .= (empty($val[
'checked']) ?
'' : $key.
',');
8601 $out =
'<!-- Component multiSelectArrayWithCheckbox '.$htmlname.
' -->
8603 <dl class="dropdown">
8605 <a href="#'.$htmlname.
'">
8608 <input type="hidden" class="'.$htmlname.
'" name="'.$htmlname.
'" value="'.$listcheckedstring.
'">
8610 <dd class="dropdowndd">
8611 <div class="multiselectcheckbox'.$htmlname.
'">
8612 <ul class="'.$htmlname.($pos ==
'1' ?
'left' :
'').
'">
8613 '.$listoffieldsforselection.
'
8619 <script type="text/javascript">
8620 jQuery(document).ready(function () {
8621 $(\'.multiselectcheckbox'.$htmlname.
' input[type="checkbox"]\').on(\'click\', function () {
8622 console.log("A new field was added/removed, we edit field input[name=formfilteraction]");
8624 $("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\'); // Update field so we know we changed something on selected fields after POST
8626 var title = $(this).val() + ",";
8627 if ($(this).is(\':checked\')) {
8628 $(\'.'.$htmlname.
'\').val(title + $(\
'.'.$htmlname.
'\').val());
8631 $(\
'.'.$htmlname.
'\').val( $(\
'.'.$htmlname.
'\').val().replace(title, \
'\') )
8654 public function showCategories($id, $type, $rendermode = 0, $nolink = 0)
8656 include_once DOL_DOCUMENT_ROOT.'/categories/
class/categorie.class.php
';
8658 $cat = new Categorie($this->db);
8659 $categories = $cat->containing($id, $type);
8661 if ($rendermode == 1) {
8663 foreach ($categories as $c) {
8664 $ways = $c->print_all_ways(' >>
', ($nolink ? 'none
' : ''), 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
8665 foreach ($ways as $way) {
8666 $toprint[] = '<li
class=
"select2-search-choice-dolibarr noborderoncategories"'.($c->color ? ' style=
"background: #'.$c->color.';"' : ' style=
"background: #bbb"').'>
'.$way.'</li>
';
8669 return '<div
class=
"select2-container-multi-dolibarr"><ul
class=
"select2-choices-dolibarr">
'.implode(' ', $toprint).'</ul></div>
';
8672 if ($rendermode == 0) {
8673 $arrayselected = array();
8674 $cate_arbo = $this->select_all_categories($type, '', 'parent
', 64, 0, 1);
8675 foreach ($categories as $c) {
8676 $arrayselected[] = $c->id;
8679 return $this->multiselectarray('categories
', $cate_arbo, $arrayselected, '', 0, '', 0, '100%
', 'disabled
', 'category
');
8682 return 'ErrorBadValueForParameterRenderMode
'; // Should not happened
8694 public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = false, $title = 'RelatedObjects
')
8696 global $conf, $langs, $hookmanager;
8697 global $bc, $action;
8699 $object->fetchObjectLinked();
8701 // Bypass the default method
8702 $hookmanager->initHooks(array('commonobject
'));
8703 $parameters = array(
8704 'morehtmlright
' => $morehtmlright,
8705 'compatibleImportElementsList
' => &$compatibleImportElementsList,
8707 $reshook = $hookmanager->executeHooks('showLinkedObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
8709 if (empty($reshook)) {
8710 $nbofdifferenttypes = count($object->linkedObjects);
8713 print load_fiche_titre($langs->trans($title), $morehtmlright, '', 0, 0, 'showlinkedobjectblock
');
8716 print '<div
class=
"div-table-responsive-no-min">
';
8717 print '<table
class=
"noborder allwidth" data-block=
"showLinkedObject" data-element=
"'.$object->element.'" data-elementid=
"'.$object->id.'" >
';
8719 print '<tr
class=
"liste_titre">
';
8720 print '<td>
'.$langs->trans("Type").'</td>
';
8721 print '<td>
'.$langs->trans("Ref").'</td>
';
8722 print '<td
class=
"center"></td>
';
8723 print '<td
class=
"center">
'.$langs->trans("Date").'</td>
';
8724 print '<td
class=
"right">
'.$langs->trans("AmountHTShort").'</td>
';
8725 print '<td
class=
"right">
'.$langs->trans("Status").'</td>
';
8729 $nboftypesoutput = 0;
8731 foreach ($object->linkedObjects as $objecttype => $objects) {
8732 $tplpath = $element = $subelement = $objecttype;
8734 // to display inport button on tpl
8735 $showImportButton = false;
8736 if (!empty($compatibleImportElementsList) && in_array($element, $compatibleImportElementsList)) {
8737 $showImportButton = true;
8741 if ($objecttype != 'supplier_proposal
' && preg_match('/^([^_]+)_([^_]+)/i
', $objecttype, $regs)) {
8742 $element = $regs[1];
8743 $subelement = $regs[2];
8744 $tplpath = $element.'/
'.$subelement;
8746 $tplname = 'linkedobjectblock
';
8748 // To work with non standard path
8749 if ($objecttype == 'facture
') {
8750 $tplpath = 'compta/
'.$element;
8751 if (!isModEnabled('facture
')) {
8752 continue; // Do not show if module disabled
8754 } elseif ($objecttype == 'facturerec
') {
8755 $tplpath = 'compta/facture
';
8756 $tplname = 'linkedobjectblockForRec
';
8757 if (!isModEnabled('facture
')) {
8758 continue; // Do not show if module disabled
8760 } elseif ($objecttype == 'propal
') {
8761 $tplpath = 'comm/
'.$element;
8762 if (!isModEnabled('propal
')) {
8763 continue; // Do not show if module disabled
8765 } elseif ($objecttype == 'supplier_proposal
') {
8766 if (!isModEnabled('supplier_proposal
')) {
8767 continue; // Do not show if module disabled
8769 } elseif ($objecttype == 'shipping
' || $objecttype == 'shipment
' || $objecttype == 'expedition
') {
8770 $tplpath = 'expedition
';
8771 if (!isModEnabled('expedition
')) {
8772 continue; // Do not show if module disabled
8774 } elseif ($objecttype == 'reception
') {
8775 $tplpath = 'reception
';
8776 if (!isModEnabled('reception
')) {
8777 continue; // Do not show if module disabled
8779 } elseif ($objecttype == 'delivery
') {
8780 $tplpath = 'delivery
';
8781 if (!isModEnabled('expedition
')) {
8782 continue; // Do not show if module disabled
8784 } elseif ($objecttype == 'ficheinter
') {
8785 $tplpath = 'fichinter
';
8786 if (!isModEnabled('ficheinter
')) {
8787 continue; // Do not show if module disabled
8789 } elseif ($objecttype == 'invoice_supplier
') {
8790 $tplpath = 'fourn/facture
';
8791 } elseif ($objecttype == 'order_supplier
') {
8792 $tplpath = 'fourn/commande
';
8793 } elseif ($objecttype == 'expensereport
') {
8794 $tplpath = 'expensereport
';
8795 } elseif ($objecttype == 'subscription
') {
8796 $tplpath = 'adherents
';
8797 } elseif ($objecttype == 'conferenceorbooth
') {
8798 $tplpath = 'eventorganization
';
8799 } elseif ($objecttype == 'conferenceorboothattendee
') {
8800 $tplpath = 'eventorganization
';
8801 } elseif ($objecttype == 'mo
') {
8803 if (!isModEnabled('mrp
')) {
8804 continue; // Do not show if module disabled
8808 global $linkedObjectBlock;
8809 $linkedObjectBlock = $objects;
8811 // Output template part (modules that overwrite templates must declare this into descriptor)
8812 $dirtpls = array_merge($conf->modules_parts['tpl
'], array('/
'.$tplpath.'/tpl
'));
8813 foreach ($dirtpls as $reldir) {
8814 if ($nboftypesoutput == ($nbofdifferenttypes - 1)) { // No more type to show after
8815 global $noMoreLinkedObjectBlockAfter;
8816 $noMoreLinkedObjectBlockAfter = 1;
8819 $res = @include dol_buildpath($reldir.'/
'.$tplname.'.tpl.php
');
8827 if (!$nboftypesoutput) {
8828 print '<tr><td
class=
"impair" colspan=
"7"><span
class=
"opacitymedium">
'.$langs->trans("None").'</span></td></tr>
';
8833 if (!empty($compatibleImportElementsList)) {
8834 $res = @include dol_buildpath('core/tpl/objectlinked_lineimport.tpl.php
');
8840 return $nbofdifferenttypes;
8852 public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array())
8854 global $conf, $langs, $hookmanager;
8858 $linktoelemlist = '';
8859 $listofidcompanytoscan = '';
8861 if (!is_object($object->thirdparty)) {
8862 $object->fetch_thirdparty();
8865 $possiblelinks = array();
8866 if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
8867 $listofidcompanytoscan = $object->thirdparty->id;
8868 if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) {
8869 $listofidcompanytoscan .= ',
'.$object->thirdparty->parent;
8871 if (($object->fk_project > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) {
8872 include_once DOL_DOCUMENT_ROOT.'/projet/
class/project.class.php
';
8873 $tmpproject = new Project($this->db);
8874 $tmpproject->fetch($object->fk_project);
8875 if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) {
8876 $listofidcompanytoscan .= ',
'.$tmpproject->socid;
8881 $possiblelinks = array(
8883 'enabled
'=>isModEnabled('propal
'),
8885 'label
'=>'LinkToProposal
',
8886 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN (
'.getEntity('propal
').')
'),
8888 'enabled
'=>isModEnabled('expedition
'),
8890 'label
'=>'LinkToExpedition
',
8891 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."expedition as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN (
'.getEntity('shipping
').')
'),
8893 'enabled
'=>isModEnabled('commande
'),
8895 'label
'=>'LinkToOrder
',
8896 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN (
'.getEntity('commande
').')
'),
8898 'enabled
'=>isModEnabled('facture
'),
8900 'label
'=>'LinkToInvoice
',
8901 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN (
'.getEntity('invoice
').')
'),
8902 'invoice_template
'=>array(
8903 'enabled
'=>isModEnabled('facture
'),
8905 'label
'=>'LinkToTemplateInvoice
',
8906 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN (
'.getEntity('invoice
').')
'),
8908 'enabled
'=>isModEnabled('contrat
'),
8910 'label
'=>'LinkToContract
',
8911 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht
8912 FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."contrat as t, ".$this->db->prefix()."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN (
'.getEntity('contract
').') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier
'
8915 'enabled
'=>isModEnabled('ficheinter
'),
8917 'label
'=>'LinkToIntervention
',
8918 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN (
'.getEntity('intervention
').')
'),
8919 'supplier_proposal
'=>array(
8920 'enabled
'=>(isModEnabled('supplier_proposal
') ? $conf->supplier_proposal->enabled : 0),
8922 'label
'=>'LinkToSupplierProposal
',
8923 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN (
'.getEntity('supplier_proposal
').')
'),
8924 'order_supplier
'=>array(
8925 'enabled
'=>(isModEnabled("supplier_order") ? $conf->supplier_order->enabled : 0),
8927 'label
'=>'LinkToSupplierOrder
',
8928 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN (
'.getEntity('commande_fournisseur
').')
'),
8929 'invoice_supplier
'=>array(
8930 'enabled
'=>(isModEnabled("supplier_invoice") ? $conf->supplier_invoice->enabled : 0),
8931 'perms
'=>1, 'label
'=>'LinkToSupplierInvoice
',
8932 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN (
'.getEntity('facture_fourn
').')
'),
8934 'enabled
'=>isModEnabled('ticket
'),
8936 'label
'=>'LinkToTicket
',
8937 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0
' as total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN (
'.getEntity('ticket
').')
'),
8939 'enabled
'=>isModEnabled('mrp
'),
8941 'label
'=>'LinkToMo
',
8942 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.rowid, '0
' as total_ht FROM ".$this->db->prefix()."societe as s INNER JOIN ".$this->db->prefix()."mrp_mo as t ON t.fk_soc = s.rowid WHERE t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN (
'.getEntity('mo
').')
')
8946 if (!empty($listofidcompanytoscan)) { // If empty, we don't have criteria to scan the
object we can link to
8948 $hookmanager->initHooks(array(
'commonobject'));
8949 $parameters = array(
'listofidcompanytoscan' => $listofidcompanytoscan,
'possiblelinks' => $possiblelinks);
8950 $reshook = $hookmanager->executeHooks(
'showLinkToObjectBlock', $parameters, $object, $action);
8953 if (empty($reshook)) {
8954 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
8955 $possiblelinks = array_merge($possiblelinks, $hookmanager->resArray);
8957 } elseif ($reshook > 0) {
8958 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
8959 $possiblelinks = $hookmanager->resArray;
8963 foreach ($possiblelinks as $key => $possiblelink) {
8966 if (empty($possiblelink[
'enabled'])) {
8970 if (!empty($possiblelink[
'perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) {
8971 print
'<div id="'.$key.
'list"'.(empty($conf->use_javascript_ajax) ?
'' :
' style="display:none"').
'>';
8973 if (!empty($conf->global->MAIN_LINK_BY_REF_IN_LINKTO)) {
8974 print
'<br><form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="formlinkedbyref' . $key .
'">';
8975 print
'<input type="hidden" name="id" value="' . $object->id .
'">';
8976 print
'<input type="hidden" name="action" value="addlinkbyref">';
8977 print
'<input type="hidden" name="token" value="'.newToken().
'">';
8978 print
'<input type="hidden" name="addlink" value="' . $key .
'">';
8979 print
'<table class="noborder">';
8981 print
'<td>' . $langs->trans(
"Ref") .
'</td>';
8982 print
'<td><input type="text" name="reftolinkto" value="' .
dol_escape_htmltag(
GETPOST(
'reftolinkto',
'alpha')) .
'"> <input type="submit" class="button valignmiddle" value="' . $langs->trans(
'ToLink') .
'"> <input type="submit" class="button" name="cancel" value="' . $langs->trans(
'Cancel') .
'"></td>';
8988 $sql = $possiblelink[
'sql'];
8990 $resqllist = $this->
db->query($sql);
8992 $num = $this->
db->num_rows($resqllist);
8996 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formlinked'.$key.
'">';
8997 print
'<input type="hidden" name="action" value="addlink">';
8998 print
'<input type="hidden" name="token" value="'.newToken().
'">';
8999 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
9000 print
'<input type="hidden" name="addlink" value="'.$key.
'">';
9001 print
'<table class="noborder">';
9002 print
'<tr class="liste_titre">';
9003 print
'<td class="nowrap"></td>';
9004 print
'<td class="center">'.$langs->trans(
"Ref").
'</td>';
9005 print
'<td class="left">'.$langs->trans(
"RefCustomer").
'</td>';
9006 print
'<td class="right">'.$langs->trans(
"AmountHTShort").
'</td>';
9007 print
'<td class="left">'.$langs->trans(
"Company").
'</td>';
9010 $objp = $this->
db->fetch_object($resqllist);
9012 print
'<tr class="oddeven">';
9013 print
'<td class="left">';
9014 print
'<input type="radio" name="idtolinkto" id="'.$key.
'_'.$objp->rowid.
'" value="'.$objp->rowid.
'">';
9016 print
'<td class="center"><label for="'.$key.
'_'.$objp->rowid.
'">'.$objp->ref.
'</label></td>';
9017 print
'<td>'.(!empty($objp->ref_client) ? $objp->ref_client : (!empty($objp->ref_supplier) ? $objp->ref_supplier :
'')).
'</td>';
9018 print
'<td class="right">';
9019 if ($possiblelink[
'label'] ==
'LinkToContract') {
9021 print
$form->textwithpicto(
'', $langs->trans(
"InformationOnLinkToContract")).
' ';
9023 print
'<span class="amount">'.(isset($objp->total_ht) ?
price($objp->total_ht) :
'').
'</span>';
9025 print
'<td>'.$objp->name.
'</td>';
9030 print
'<div class="center">';
9031 print
'<input type="submit" class="button valignmiddle marginleftonly marginrightonly" value="'.$langs->trans(
'ToLink').
'">';
9032 if (empty($conf->use_javascript_ajax)) {
9033 print
'<input type="submit" class="button button-cancel marginleftonly marginrightonly" name="cancel" value="'.$langs->trans(
"Cancel").
'"></div>';
9035 print
'<input type="submit"; onclick="javascript:jQuery(\'#'.$key.
'list\').toggle(); return false;" class="button button-cancel marginleftonly marginrightonly" name="cancel" value="'.$langs->trans(
"Cancel").
'"></div>';
9038 $this->
db->free($resqllist);
9045 if ($num > 0 || !empty($conf->global->MAIN_LINK_BY_REF_IN_LINKTO)) {
9046 $linktoelemlist .=
'<li><a href="#linkto'.$key.
'" class="linkto dropdowncloseonclick" rel="'.$key.
'">'.$langs->trans($possiblelink[
'label']).
' ('.$num.
')</a></li>';
9049 $linktoelemlist .=
'<li><span class="linktodisabled">'.$langs->trans($possiblelink[
'label']).
' (0)</span></li>';
9054 if ($linktoelemlist) {
9056 <dl class="dropdown" id="linktoobjectname">
9058 if (!empty($conf->use_javascript_ajax)) {
9059 $linktoelem .=
'<dt><a href="#linktoobjectname"><span class="fas fa-link paddingrightonly"></span>'.$langs->trans(
"LinkTo").
'...</a></dt>';
9061 $linktoelem .=
'<dd>
9062 <div class="multiselectlinkto">
9063 <ul class="ulselectedfields">'.$linktoelemlist.
'
9072 if (!empty($conf->use_javascript_ajax)) {
9073 print
'<!-- Add js to show linkto box -->
9075 jQuery(document).ready(function() {
9076 jQuery(".linkto").click(function() {
9077 console.log("We choose to show/hide links for rel="+jQuery(this).attr(\'rel\')+" so #"+jQuery(this).attr(\'rel\')+"list");
9078 jQuery("#"+jQuery(this).attr(\'rel\')+"list").toggle();
9102 public function selectyesno($htmlname, $value =
'', $option = 0, $disabled =
false, $useempty = 0, $addjscombo = 0, $morecss =
'', $labelyes =
'Yes', $labelno =
'No')
9113 $disabled = ($disabled ?
' disabled' :
'');
9115 $resultyesno =
'<select class="flat width75'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.
'"'.$disabled.
'>'.
"\n";
9117 $resultyesno .=
'<option value="-1"'.(($value < 0) ?
' selected' :
'').
'> </option>'.
"\n";
9119 if ((
"$value" ==
'yes') || ($value == 1)) {
9120 $resultyesno .=
'<option value="'.$yes.
'" selected>'.$langs->trans($labelyes).
'</option>'.
"\n";
9121 $resultyesno .=
'<option value="'.$no.
'">'.$langs->trans($labelno).
'</option>'.
"\n";
9123 $selected = (($useempty && $value !=
'0' && $value !=
'no') ?
'' :
' selected');
9124 $resultyesno .=
'<option value="'.$yes.
'">'.$langs->trans($labelyes).
'</option>'.
"\n";
9125 $resultyesno .=
'<option value="'.$no.
'"'.$selected.
'>'.$langs->trans($labelno).
'</option>'.
"\n";
9127 $resultyesno .=
'</select>'.
"\n";
9130 $resultyesno .=
ajax_combobox($htmlname, array(), 0, 0,
'resolve', ($useempty < 0 ? (
string) $useempty :
'-1'), $morecss);
9133 return $resultyesno;
9149 $sql =
"SELECT rowid, label";
9150 $sql .=
" FROM ".$this->db->prefix().
"export_model";
9151 $sql .=
" WHERE type = '".$this->db->escape($type).
"'";
9152 $sql .=
" ORDER BY rowid";
9153 $result = $this->
db->query($sql);
9155 print
'<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
9157 print
'<option value="-1"> </option>';
9160 $num = $this->
db->num_rows($result);
9163 $obj = $this->
db->fetch_object($result);
9164 if ($selected == $obj->rowid) {
9165 print
'<option value="'.$obj->rowid.
'" selected>';
9167 print
'<option value="'.$obj->rowid.
'">';
9197 public function showrefnav($object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $morehtmlright =
'')
9199 global $conf, $langs, $hookmanager, $extralanguages;
9202 if (empty($fieldid)) {
9205 if (empty($fieldref)) {
9211 if (property_exists($object,
'gender') && !empty($object->gender)) {
9212 $addgendertxt =
' ';
9213 switch ($object->gender) {
9215 $addgendertxt .=
'<i class="fas fa-mars"></i>';
9218 $addgendertxt .=
'<i class="fas fa-venus"></i>';
9221 $addgendertxt .=
'<i class="fas fa-transgender"></i>';
9237 if (is_object($hookmanager)) {
9238 $parameters = array(
'showrefnav' =>
true);
9239 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
9240 $object->next_prev_filter .= $hookmanager->resPrint;
9242 $previous_ref = $next_ref =
'';
9245 $object->load_previous_next_ref((isset($object->next_prev_filter) ? $object->next_prev_filter :
''), $fieldid, $nodbprefix);
9247 $navurl = $_SERVER[
"PHP_SELF"];
9249 if ($paramid ==
'project_ref') {
9250 if (preg_match(
'/\/tasks\/(task|contact|note|document)\.php/', $navurl)) {
9251 $navurl = preg_replace(
'/\/tasks\/(task|contact|time|note|document)\.php/',
'/tasks.php', $navurl);
9258 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
9259 if ($conf->browser->name ==
'chrome') {
9260 $stringforfirstkey .=
' ALT +';
9261 } elseif ($conf->browser->name ==
'firefox') {
9262 $stringforfirstkey .=
' ALT + SHIFT +';
9264 $stringforfirstkey .=
' CTL +';
9267 $previous_ref = $object->ref_previous ?
'<a accesskey="p" title="'.$stringforfirstkey.
' p" class="classfortooltip" href="'.$navurl.
'?'.$paramid.
'='.urlencode($object->ref_previous).$moreparam.
'"><i class="fa fa-chevron-left"></i></a>' :
'<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>';
9268 $next_ref = $object->ref_next ?
'<a accesskey="n" title="'.$stringforfirstkey.
' n" class="classfortooltip" href="'.$navurl.
'?'.$paramid.
'='.urlencode($object->ref_next).$moreparam.
'"><i class="fa fa-chevron-right"></i></a>' :
'<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>';
9272 $ret .=
'<!-- Start banner content --><div style="vertical-align: middle">';
9275 if ($morehtmlright) {
9276 $ret .=
'<div class="inline-block floatleft">'.$morehtmlright.
'</div>';
9279 if ($previous_ref || $next_ref || $morehtml) {
9280 $ret .=
'<div class="pagination paginationref"><ul class="right">';
9283 $ret .=
'<li class="noborder litext'.(($shownav && $previous_ref && $next_ref) ?
' clearbothonsmartphone' :
'').
'">'.$morehtml.
'</li>';
9285 if ($shownav && ($previous_ref || $next_ref)) {
9286 $ret .=
'<li class="pagination">'.$previous_ref.
'</li>';
9287 $ret .=
'<li class="pagination">'.$next_ref.
'</li>';
9289 if ($previous_ref || $next_ref || $morehtml) {
9290 $ret .=
'</ul></div>';
9293 $parameters = array();
9294 $reshook = $hookmanager->executeHooks(
'moreHtmlStatus', $parameters, $object);
9295 if (empty($reshook)) {
9296 $morehtmlstatus .= $hookmanager->resPrint;
9298 $morehtmlstatus = $hookmanager->resPrint;
9300 if ($morehtmlstatus) {
9301 $ret .=
'<div class="statusref">'.$morehtmlstatus.
'</div>';
9304 $parameters = array();
9305 $reshook = $hookmanager->executeHooks(
'moreHtmlRef', $parameters, $object);
9306 if (empty($reshook)) {
9307 $morehtmlref .= $hookmanager->resPrint;
9308 } elseif ($reshook > 0) {
9309 $morehtmlref = $hookmanager->resPrint;
9313 if ($morehtmlleft) {
9314 if ($conf->browser->layout ==
'phone') {
9315 $ret .=
'<!-- morehtmlleft --><div class="floatleft">'.$morehtmlleft.
'</div>';
9317 $ret .=
'<!-- morehtmlleft --><div class="inline-block floatleft">'.$morehtmlleft.
'</div>';
9322 $ret .=
'<div class="inline-block floatleft valignmiddle maxwidth750 marginbottomonly refid'.(($shownav && ($previous_ref || $next_ref)) ?
' refidpadding' :
'').
'">';
9325 if ($object->element ==
'societe') {
9329 $arrayoflangcode = array();
9330 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) {
9331 $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
9334 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
9335 if (!is_object($extralanguages)) {
9336 include_once DOL_DOCUMENT_ROOT.
'/core/class/extralanguages.class.php';
9339 $extralanguages->fetch_name_extralanguages(
'societe');
9341 if (!empty($extralanguages->attributes[
'societe'][
'name'])) {
9342 $object->fetchValuesForExtraLanguages();
9346 foreach ($arrayoflangcode as $extralangcode) {
9348 if ($object->array_languages[
'name'][$extralangcode]) {
9349 $htmltext .= $object->array_languages[
'name'][$extralangcode];
9351 $htmltext .=
'<span class="opacitymedium">'.$langs->trans(
"SwitchInEditModeToAddTranslation").
'</span>';
9354 $ret .=
'<!-- Show translations of name -->'.
"\n";
9355 $ret .= $this->
textwithpicto(
'', $htmltext, -1,
'language',
'opacitymedium paddingleft');
9358 } elseif ($object->element ==
'member') {
9359 $ret .= $object->ref.
'<br>';
9360 $fullname = $object->getFullName($langs);
9361 if ($object->morphy ==
'mor' && $object->societe) {
9362 $ret .=
dol_htmlentities($object->societe).((!empty($fullname) && $object->societe != $fullname) ?
' ('.
dol_htmlentities($fullname).$addgendertxt.
')' :
'');
9364 $ret .=
dol_htmlentities($fullname).$addgendertxt.((!empty($object->societe) && $object->societe != $fullname) ?
' ('.
dol_htmlentities($object->societe).
')' :
'');
9366 } elseif (in_array($object->element, array(
'contact',
'user',
'usergroup'))) {
9368 } elseif (in_array($object->element, array(
'action',
'agenda'))) {
9369 $ret .= $object->ref.
'<br>'.$object->label;
9370 } elseif (in_array($object->element, array(
'adherent_type'))) {
9371 $ret .= $object->label;
9372 } elseif ($object->element ==
'ecm_directories') {
9374 } elseif ($fieldref !=
'none') {
9375 $ret .=
dol_htmlentities(!empty($object->$fieldref) ? $object->$fieldref :
"");
9380 if (substr($morehtmlref, 0, 4) !=
'<div') {
9384 $ret .= $morehtmlref;
9389 $ret .=
'</div><!-- End banner content -->';
9408 if (empty($object->barcode)) {
9413 if (empty($object->barcode_type_code) || empty($object->barcode_type_coder)) {
9414 $result = $object->fetch_barcode();
9417 return '<!-- ErrorFetchBarcode -->';
9422 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=barcode&generator='.urlencode($object->barcode_type_coder).
'&code='.urlencode($object->barcode).
'&encoding='.urlencode($object->barcode_type_code);
9423 $out =
'<!-- url barcode = '.$url.
' -->';
9424 $out .=
'<img src="'.$url.
'"'.($morecss ?
' class="'.$morecss.
'"' :
'').
'>';
9445 public static function showphoto($modulepart, $object, $width = 100, $height = 0, $caneditfield = 0, $cssclass =
'photowithmargin', $imagesize =
'', $addlinktofullsize = 1, $cache = 0, $forcecapture =
'', $noexternsourceoverwrite = 0)
9447 global $conf, $langs;
9449 $entity = (!empty($object->entity) ? $object->entity : $conf->entity);
9450 $id = (!empty($object->id) ? $object->id : $object->rowid);
9459 if ($modulepart ==
'societe') {
9460 $dir = $conf->societe->multidir_output[$entity];
9461 if (!empty($object->logo)) {
9463 if ((
string) $imagesize ==
'mini') {
9465 } elseif ((
string) $imagesize ==
'small') {
9468 $file =
get_exdir(0, 0, 0, 0, $object,
'thirdparty').
'logos/'.$object->logo;
9470 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'thirdparty').
'logos/'.$object->logo;
9473 $email = $object->email;
9474 } elseif ($modulepart ==
'contact') {
9475 $dir = $conf->societe->multidir_output[$entity].
'/contact';
9476 if (!empty($object->photo)) {
9478 if ((
string) $imagesize ==
'mini') {
9480 } elseif ((
string) $imagesize ==
'small') {
9483 $file =
get_exdir(0, 0, 0, 0, $object,
'contact').
'photos/'.$object->photo;
9485 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'contact').
'photos/'.$object->photo;
9488 $email = $object->email;
9490 } elseif ($modulepart ==
'userphoto') {
9491 $dir = $conf->user->dir_output;
9492 if (!empty($object->photo)) {
9494 if ((
string) $imagesize ==
'mini') {
9496 } elseif ((
string) $imagesize ==
'small') {
9499 $file =
get_exdir(0, 0, 0, 0, $object,
'user').
'photos/'.$object->photo;
9501 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'user').
'photos/'.$object->photo;
9504 if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
9505 $altfile = $object->id.
".jpg";
9507 $email = $object->email;
9509 } elseif ($modulepart ==
'memberphoto') {
9510 $dir = $conf->adherent->dir_output;
9511 if (!empty($object->photo)) {
9513 if ((
string) $imagesize ==
'mini') {
9515 } elseif ((
string) $imagesize ==
'small') {
9518 $file =
get_exdir(0, 0, 0, 0, $object,
'member').
'photos/'.$object->photo;
9520 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'member').
'photos/'.$object->photo;
9523 if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
9524 $altfile = $object->id.
".jpg";
9526 $email = $object->email;
9530 $dir = $conf->$modulepart->dir_output;
9531 if (!empty($object->photo)) {
9533 if ((
string) $imagesize ==
'mini') {
9535 } elseif ((
string) $imagesize ==
'small') {
9538 $file =
get_exdir($id, 2, 0, 0, $object, $modulepart).
'photos/'.$object->photo;
9540 $originalfile =
get_exdir($id, 2, 0, 0, $object, $modulepart).
'photos/'.$object->photo;
9543 if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
9544 $altfile = $object->id.
".jpg";
9546 $email = $object->email;
9549 if ($forcecapture) {
9550 $capture = $forcecapture;
9554 if ($file && file_exists($dir.
"/".$file)) {
9555 if ($addlinktofullsize) {
9558 $ret .=
'<a href="'.$urladvanced.
'">';
9560 $ret .=
'<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($originalfile).
'&cache='.$cache.
'">';
9563 $ret .=
'<img alt="Photo" class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
' photologo'.(preg_replace(
'/[^a-z]/i',
'_', $file)).
'" '.($width ?
' width="'.$width.
'"' :
'').($height ?
' height="'.$height.
'"' :
'').
' src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($file).
'&cache='.$cache.
'">';
9564 if ($addlinktofullsize) {
9567 } elseif ($altfile && file_exists($dir.
"/".$altfile)) {
9568 if ($addlinktofullsize) {
9571 $ret .=
'<a href="'.$urladvanced.
'">';
9573 $ret .=
'<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($originalfile).
'&cache='.$cache.
'">';
9576 $ret .=
'<img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" alt="Photo alt" id="photologo'.(preg_replace(
'/[^a-z]/i',
'_', $file)).
'" class="'.$cssclass.
'" '.($width ?
' width="'.$width.
'"' :
'').($height ?
' height="'.$height.
'"' :
'').
' src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($altfile).
'&cache='.$cache.
'">';
9577 if ($addlinktofullsize) {
9581 $nophoto =
'/public/theme/common/nophoto.png';
9582 $defaultimg =
'identicon';
9583 if (in_array($modulepart, array(
'societe',
'userphoto',
'contact',
'memberphoto'))) {
9584 if ($modulepart ==
'societe' || ($modulepart ==
'memberphoto' && strpos($object->morphy,
'mor')) !==
false) {
9585 $nophoto =
'company';
9587 $nophoto =
'/public/theme/common/user_anonymous.png';
9588 if (!empty($object->gender) && $object->gender ==
'man') {
9589 $nophoto =
'/public/theme/common/user_man.png';
9591 if (!empty($object->gender) && $object->gender ==
'woman') {
9592 $nophoto =
'/public/theme/common/user_woman.png';
9597 if (
isModEnabled(
'gravatar') && $email && empty($noexternsourceoverwrite)) {
9599 $ret .=
'<!-- Put link to gravatar -->';
9600 $ret .=
'<img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" alt="" title="'.$email.
' Gravatar avatar" '.($width ?
' width="'.$width.
'"' :
'').($height ?
' height="'.$height.
'"' :
'').
' src="https://www.gravatar.com/avatar/'.md5(strtolower(trim($email))).
'?s='.$width.
'&d='.$defaultimg.
'">';
9602 if ($nophoto ==
'company') {
9603 $ret .=
'<div class="divforspanimg photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" alt="" '.($width ?
' width="'.$width.
'"' :
'').($height ?
' height="'.$height.
'"' :
'').
'>'.
img_picto(
'',
'company').
'</div>';
9604 $ret .=
'<div class="difforspanimgright"></div>';
9606 $ret .=
'<img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" alt="" '.($width ?
' width="'.$width.
'"' :
'').($height ?
' height="'.$height.
'"' :
'').
' src="'.DOL_URL_ROOT.$nophoto.
'">';
9611 if ($caneditfield) {
9612 if ($object->photo) {
9615 $ret .=
'<table class="nobordernopadding centpercent">';
9616 if ($object->photo) {
9617 $ret .=
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">'.$langs->trans(
"Delete").
'</label><br><br></td></tr>';
9619 $ret .=
'<tr><td class="tdoverflow">';
9621 $maxmin = $maxfilesizearray[
'maxmin'];
9623 $ret .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
9625 $ret .=
'<input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"'.($capture ?
' capture="'.$capture.
'"' :
'').
'>';
9626 $ret .=
'</td></tr>';
9630 dol_print_error(
'',
'Call of showphoto with wrong parameters modulepart='.$modulepart);
9653 public function select_dolgroups($selected =
'', $htmlname =
'groupid', $show_empty = 0, $exclude =
'', $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0', $multiple =
false, $morecss =
'')
9656 global $conf, $user, $langs;
9659 $excludeGroups =
null;
9660 if (is_array($exclude)) {
9661 $excludeGroups = implode(
",", $exclude);
9664 $includeGroups =
null;
9665 if (is_array($include)) {
9666 $includeGroups = implode(
",", $include);
9669 if (!is_array($selected)) {
9670 $selected = array($selected);
9676 $sql =
"SELECT ug.rowid, ug.nom as name";
9677 if (
isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
9678 $sql .=
", e.label";
9680 $sql .=
" FROM ".$this->db->prefix().
"usergroup as ug ";
9681 if (
isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
9682 $sql .=
" LEFT JOIN ".$this->db->prefix().
"entity as e ON e.rowid=ug.entity";
9683 if ($force_entity) {
9684 $sql .=
" WHERE ug.entity IN (0, ".$force_entity.
")";
9686 $sql .=
" WHERE ug.entity IS NOT NULL";
9689 $sql .=
" WHERE ug.entity IN (0, ".$conf->entity.
")";
9691 if (is_array($exclude) && $excludeGroups) {
9692 $sql .=
" AND ug.rowid NOT IN (".$this->db->sanitize($excludeGroups).
")";
9694 if (is_array($include) && $includeGroups) {
9695 $sql .=
" AND ug.rowid IN (".$this->db->sanitize($includeGroups).
")";
9697 $sql .=
" ORDER BY ug.nom ASC";
9699 dol_syslog(get_class($this).
"::select_dolgroups", LOG_DEBUG);
9703 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
9705 $out .=
'<select class="flat minwidth200'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.($multiple ?
'[]' :
'').
'" '.($multiple ?
'multiple' :
'').
' '.($disabled ?
' disabled' :
'').
'>';
9707 $num = $this->
db->num_rows(
$resql);
9710 if ($show_empty && !$multiple) {
9711 $out .=
'<option value="-1"'.(in_array(-1, $selected) ?
' selected' :
'').
'> </option>'.
"\n";
9715 $obj = $this->
db->fetch_object(
$resql);
9717 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
9721 $out .=
'<option value="'.$obj->rowid.
'"';
9723 $out .=
' disabled';
9725 if ((isset($selected[0]) && is_object($selected[0]) && $selected[0]->
id == $obj->rowid) || ((!isset($selected[0]) || !is_object($selected[0])) && !empty($selected) && in_array($obj->rowid, $selected))) {
9726 $out .=
' selected';
9731 if (
isModEnabled(
'multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) {
9732 $out .=
" (".$obj->label.
")";
9735 $out .=
'</option>';
9740 $out .=
'<option value="-1"'.(in_array(-1, $selected) ?
' selected' :
'').
'></option>'.
"\n";
9742 $out .=
'<option value="" disabled>'.$langs->trans(
"NoUserGroupDefined").
'</option>';
9744 $out .=
'</select>';
9763 $out =
'<div class="nowraponall">';
9764 if ($pos ==
'left') {
9765 $out .=
'<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fa fa-remove"></span></button>';
9766 $out .=
'<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
9768 $out .=
'<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
9769 $out .=
'<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fa fa-remove"></span></button>';
9784 public function showCheckAddButtons($cssclass =
'checkforaction', $calljsfunction = 0, $massactionname =
"massaction")
9786 global $conf, $langs;
9790 if (!empty($conf->use_javascript_ajax)) {
9791 $out .=
'<div class="inline-block checkallactions"><input type="checkbox" id="'.$cssclass.
's" name="'.$cssclass.
's" class="checkallactions"></div>';
9794 $(document).ready(function() {
9795 $("#' . $cssclass.
's").click(function() {
9796 if($(this).is(\':checked\')){
9797 console.log("We check all '.$cssclass.
' and trigger the change method");
9798 $(".'.$cssclass.
'").prop(\'checked\', true).trigger(\'change\');
9802 console.log("We uncheck all");
9803 $(".'.$cssclass.
'").prop(\'checked\', false).trigger(\'change\');
9805 if ($calljsfunction) {
9806 $out .=
'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "'.$massactionname.
'", "'.$cssclass.
'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
9809 $(".' . $cssclass.
'").change(function() {
9810 $(this).closest("tr").toggleClass("highlight", this.checked);
9830 if ($addcheckuncheckall) {
9849 public function selectExpenseCategories($selected =
'', $htmlname =
'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target =
'', $default_selected = 0, $params = array(), $info_admin = 1)
9851 global $langs, $user;
9854 $sql =
"SELECT rowid, label FROM ".$this->db->prefix().
"c_exp_tax_cat WHERE active = 1";
9855 $sql .=
" AND entity IN (0,".getEntity(
'exp_tax_cat').
")";
9856 if (!empty($excludeid)) {
9857 $sql .=
" AND rowid NOT IN (".$this->db->sanitize(implode(
',', $excludeid)).
")";
9859 $sql .=
" ORDER BY label";
9863 $out =
'<select id="select_'.$htmlname.
'" name="'.$htmlname.
'" class="'.$htmlname.
' flat minwidth75imp maxwidth200">';
9865 $out .=
'<option value="0"> </option>';
9868 while ($obj = $this->
db->fetch_object(
$resql)) {
9869 $out .=
'<option '.($selected == $obj->rowid ?
'selected="selected"' :
'').
' value="'.$obj->rowid.
'">'.$langs->trans($obj->label).
'</option>';
9871 $out .=
'</select>';
9874 if (!empty($htmlname) && $user->admin && $info_admin) {
9875 $out .=
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
9878 if (!empty($target)) {
9879 $sql =
"SELECT c.id FROM ".$this->db->prefix().
"c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1";
9882 if ($this->
db->num_rows(
$resql) > 0) {
9883 $obj = $this->
db->fetch_object(
$resql);
9886 $("select[name='.$target.
']").on("change", function() {
9887 var current_val = $(this).val();
9888 if (current_val == '.$obj->id.
') {';
9889 if (!empty($default_selected) || !empty($selected)) {
9890 $out .=
'$("select[name='.$htmlname.
']").val("'.($default_selected > 0 ? $default_selected : $selected).
'");';
9894 $("select[name='.$htmlname.
']").change();
9898 $("select[name='.$htmlname.
']").change(function() {
9900 if ($("select[name='.$target.
']").val() == '.$obj->id.
') {
9901 // get price of kilometer to fill the unit price
9905 data: { fk_c_exp_tax_cat: $(this).val(), token: \''.
currentToken().
'\' },
9906 url:
"'.(DOL_URL_ROOT.'/expensereport/ajax/ajaxik.php?'.join('&', $params)).'",
9907 }).done(
function( data, textStatus, jqXHR ) {
9909 if (typeof data.up !=
"undefined") {
9910 $(
"input[name=value_unit]").val(data.up);
9911 $(
"select[name='.$htmlname.']").attr(
"title", data.title);
9913 $(
"input[name=value_unit]").val(
"");
9914 $(
"select[name='.$htmlname.']").attr(
"title",
"");
9925 dol_print_error($this->db);
9939 public function selectExpenseRanges($selected = '', $htmlname = 'fk_range
', $useempty = 0)
9941 global $conf, $langs;
9944 $sql = "SELECT rowid, range_ik FROM ".$this->db->prefix()."c_exp_tax_range";
9945 $sql .= " WHERE entity = ".$conf->entity." AND active = 1";
9947 $resql = $this->db->query($sql);
9949 $out = '<select
id=
"select_'.$htmlname.'" name=
"'.$htmlname.'" class=
"'.$htmlname.' flat minwidth75imp">
';
9951 $out .= '<option value=
"0"></option>
';
9954 while ($obj = $this->db->fetch_object($resql)) {
9955 $out .= '<option
'.($selected == $obj->rowid ? 'selected=
"selected"' : '').' value=
"'.$obj->rowid.'">
'.price($obj->range_ik, 0, $langs, 1, 0).'</option>
';
9957 $out .= '</select>
';
9959 dol_print_error($this->db);
9975 public function selectExpense($selected = '', $htmlname = 'fk_c_type_fees
', $useempty = 0, $allchoice = 1, $useid = 0)
9980 $sql = "SELECT id, code, label FROM ".$this->db->prefix()."c_type_fees";
9981 $sql .= " WHERE active = 1";
9983 $resql = $this->db->query($sql);
9985 $out = '<select
id=
"select_'.$htmlname.'" name=
"'.$htmlname.'" class=
"'.$htmlname.' flat minwidth75imp">
';
9987 $out .= '<option value=
"0"></option>
';
9990 $out .= '<option value=
"-1">
'.$langs->trans('AllExpenseReport
').'</option>
';
9998 while ($obj = $this->db->fetch_object($resql)) {
9999 $key = $langs->trans($obj->code);
10000 $out .= '<option
'.($selected == $obj->{$field} ? 'selected=
"selected"' : '').' value=
"'.$obj->{$field}.'">
'.($key != $obj->code ? $key : $obj->label).'</option>
';
10002 $out .= '</select>
';
10004 dol_print_error($this->db);
10028 public function selectInvoice($socid = -1, $selected = '', $htmlname = 'invoiceid
', $maxlength = 24, $option_only = 0, $show_empty = '1
', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500
', $projectsListId = '', $showproject = 'all
', $usertofilter = null)
10030 global $user, $conf, $langs;
10032 require_once DOL_DOCUMENT_ROOT.'/projet/
class/project.class.php
';
10034 if (is_null($usertofilter)) {
10035 $usertofilter = $user;
10040 $hideunselectables = false;
10041 if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) {
10042 $hideunselectables = true;
10045 if (empty($projectsListId)) {
10046 if (empty($usertofilter->rights->projet->all->lire)) {
10047 $projectstatic = new Project($this->db);
10048 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
10052 // Search all projects
10053 $sql = "SELECT f.rowid, f.ref as fref, 'nolabel
' as flabel, p.rowid as pid, f.ref,
10054 p.title, p.fk_soc, p.fk_statut, p.public,";
10055 $sql .= ' s.nom as
name';
10056 $sql .= ' FROM
'.$this->db->prefix().'projet as p
';
10057 $sql .= ' LEFT JOIN
'.$this->db->prefix().'societe as s ON s.rowid = p.fk_soc,
';
10058 $sql .= ' '.$this->db->prefix().'facture as f
';
10059 $sql .= " WHERE p.entity IN (".getEntity('project
').")";
10060 $sql .= " AND f.fk_projet = p.rowid AND f.fk_statut=0"; //Brouillons seulement
10061 //if ($projectsListId) $sql.= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")";
10062 //if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
10063 //if ($socid > 0) $sql.= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)";
10064 $sql .= " ORDER BY p.ref, f.ref ASC";
10066 $resql = $this->db->query($sql);
10068 // Use select2 selector
10069 if (!empty($conf->use_javascript_ajax)) {
10070 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php
';
10071 $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
10072 $out .= $comboenhancement;
10073 $morecss = 'minwidth200imp maxwidth500
';
10076 if (empty($option_only)) {
10077 $out .= '<select
class=
"valignmiddle flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled=
"disabled"' : '').' id=
"'.$htmlname.'" name=
"'.$htmlname.'">
';
10079 if (!empty($show_empty)) {
10080 $out .= '<option value=
"0" class=
"optiongrey">
';
10081 if (!is_numeric($show_empty)) {
10082 $out .= $show_empty;
10086 $out .= '</option>
';
10088 $num = $this->db->num_rows($resql);
10091 while ($i < $num) {
10092 $obj = $this->db->fetch_object($resql);
10093 // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
10094 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($usertofilter->rights->societe->lire)) {
10097 if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED) {
10104 if ($showproject == 'all
') {
10105 $labeltoshow .= dol_trunc($obj->ref, 18); // Invoice ref
10107 $labeltoshow .= ' -
'.$obj->name; // Soc name
10111 if ($obj->fk_statut == Project::STATUS_DRAFT) {
10113 $labeltoshow .= ' -
'.$langs->trans("Draft");
10114 } elseif ($obj->fk_statut == Project::STATUS_CLOSED) {
10115 if ($discard_closed == 2) {
10118 $labeltoshow .= ' -
'.$langs->trans("Closed");
10119 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
10121 $labeltoshow .= ' -
'.$langs->trans("LinkedToAnotherCompany");
10125 if (!empty($selected) && $selected == $obj->rowid) {
10126 $out .= '<option value=
"'.$obj->rowid.'" selected
';
10127 //if ($disabled) $out.=' disabled
'; // with select2, field can't be preselected
if disabled
10128 $out .=
'>'.$labeltoshow.
'</option>';
10130 if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
10133 $resultat =
'<option value="'.$obj->rowid.
'"';
10135 $resultat .=
' disabled';
10140 $resultat .= $labeltoshow;
10141 $resultat .=
'</option>';
10149 if (empty($option_only)) {
10150 $out .=
'</select>';
10176 public function selectInvoiceRec($selected =
'', $htmlname =
'facrecid', $maxlength = 24, $option_only = 0, $show_empty =
'1', $forcefocus = 0, $disabled = 0, $morecss =
'maxwidth500')
10178 global $user, $conf, $langs;
10184 $sql =
'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc';
10186 $sql .=
' FROM ' . MAIN_DB_PREFIX .
'facture_rec as f';
10187 $sql .=
" WHERE f.entity IN (" .
getEntity(
'invoice') .
")";
10188 $sql .=
" ORDER BY f.titre ASC";
10193 if (!empty($conf->use_javascript_ajax)) {
10194 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
10195 $comboenhancement =
ajax_combobox($htmlname,
'', 0, $forcefocus);
10196 $out .= $comboenhancement;
10197 $morecss =
'minwidth200imp maxwidth500';
10200 if (empty($option_only)) {
10201 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' id="' . $htmlname .
'" name="' . $htmlname .
'">';
10203 if (!empty($show_empty)) {
10204 $out .=
'<option value="0" class="optiongrey">';
10205 if (!is_numeric($show_empty)) {
10206 $out .= $show_empty;
10210 $out .=
'</option>';
10212 $num = $this->
db->num_rows(
$resql);
10214 while ($obj = $this->
db->fetch_object(
$resql)) {
10215 $labeltoshow =
dol_trunc($obj->title, 18);
10218 if (!empty($obj->suspended)) {
10220 $labeltoshow .=
' - ' . $langs->trans(
"Closed");
10224 if (!empty($selected) && $selected == $obj->rowid) {
10225 $out .=
'<option value="' . $obj->rowid .
'" selected';
10227 $out .=
'>' . $labeltoshow .
'</option>';
10229 if ($disabled && ($selected != $obj->rowid)) {
10232 $resultat =
'<option value="' . $obj->rowid .
'"';
10234 $resultat .=
' disabled';
10237 $resultat .= $labeltoshow;
10238 $resultat .=
'</option>';
10244 if (empty($option_only)) {
10245 $out .=
'</select>';
10253 $this->errors[]=$this->
db->lasterror;
10267 public function searchComponent($arrayofcriterias, $search_component_params, $arrayofinputfieldsalreadyoutput = array(), $search_component_params_hidden =
'')
10273 $ret .=
'<div class="divadvancedsearchfieldcomp inline-block">';
10275 $ret .=
'<a href="#" class="dropdownsearch-toggle unsetcolor">';
10276 $ret .=
'<span class="fas fa-filter linkobject boxfilter paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans(
"Filters")).
'" id="idsubimgproductdistribution"></span>';
10280 $ret .=
'<div class="divadvancedsearchfieldcompinput inline-block minwidth500 maxwidth300onsmartphone">';
10283 $ret .=
'<div name="divsearch_component_params" class="noborderbottom search_component_params inline-block valignmiddle">';
10285 if ($search_component_params_hidden) {
10286 if (!preg_match(
'/^\(.*\)$/', $search_component_params_hidden)) {
10287 $search_component_params_hidden .=
'('.$search_component_params_hidden.
')';
10289 $errormessage =
'';
10290 if (!
dolCheckFilters($search_component_params_hidden, $errormessage)) {
10291 print
'ERROR in parsing search string';
10293 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
10295 $htmltags = preg_replace_callback(
'/'.$regexstring.
'/',
'dolForgeCriteriaCallback', $search_component_params_hidden);
10297 $ret .=
'<span class="marginleftonlyshort valignmiddle tagsearch"><span class="tagsearchdelete select2-selection__choice__remove">x</span> '.$htmltags.
'</span>';
10306 $show_search_component_params_hidden = 1;
10307 if ($show_search_component_params_hidden) {
10308 $ret .=
'<input type="hidden" name="show_search_component_params_hidden" value="1">';
10310 $ret .=
"<!-- We store the full search string into this field. For example: (t.ref:like:'SO-%') and ((t.ref:like:'CO-%') or (t.ref:like:'AA%')) -->";
10311 $ret .=
'<input type="hidden" name="search_component_params_hidden" value="'.dol_escape_htmltag($search_component_params_hidden).
'">';
10313 foreach ($arrayofcriterias as $criterias) {
10314 foreach ($criterias as $criteriafamilykey => $criteriafamilyval) {
10315 if (in_array(
'search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput)) {
10318 if (in_array($criteriafamilykey, array(
'rowid',
'ref_ext',
'entity',
'extraparams'))) {
10321 if (in_array($criteriafamilyval[
'type'], array(
'date',
'datetime',
'timestamp'))) {
10322 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_start">';
10323 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_startyear">';
10324 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_startmonth">';
10325 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_startday">';
10326 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_end">';
10327 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_endyear">';
10328 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_endmonth">';
10329 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_endday">';
10331 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'">';
10338 $ret .=
"<!-- Syntax of Generic filter string: t.ref:like:'SO-%', t.date_creation:<:'20160101', t.date_creation:<:'2016-01-01 12:30:00', t.nature:is:NULL, t.field2:isnot:NULL -->\n";
10339 $ret .=
'<input type="text" placeholder="'.$langs->trans(
"Search").
'" name="search_component_params_input" class="noborderbottom search_component_input" value="">';
10358 global $langs, $user;
10362 $TModels = array();
10364 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
10366 $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs);
10369 $TModels[0] = $langs->trans(
'DefaultMailModel');
10372 foreach ($formmail->lines_model as $model) {
10373 $TModels[$model->id] = $model->label;
10377 $retstring .=
'<select class="flat" id="select_'.$prefix.
'model_mail" name="'.$prefix.
'model_mail">';
10379 foreach ($TModels as $id_model => $label_model) {
10380 $retstring .=
'<option value="'.$id_model.
'"';
10381 $retstring .=
">".$label_model.
"</option>";
10384 $retstring .=
"</select>";
10387 $retstring .=
ajax_combobox(
'select_'.$prefix.
'model_mail');
10404 public function buttonsSaveCancel($save_label =
'Save', $cancel_label =
'Cancel', $morebuttons = array(), $withoutdiv = 0, $morecss =
'', $dol_openinpopup =
'')
10408 $buttons = array();
10412 'label_key' => $save_label,
10415 if ($save_label ==
'Create' || $save_label ==
'Add' ) {
10416 $save[
'name'] =
'add';
10417 } elseif ($save_label ==
'Modify') {
10418 $save[
'name'] =
'edit';
10422 'name' =>
'cancel',
10423 'label_key' =>
'Cancel',
10426 !empty($save_label) ? $buttons[] = $save :
'';
10428 if (!empty($morebuttons)) {
10429 $buttons[] = $morebuttons;
10432 !empty($cancel_label) ? $buttons[] = $cancel :
'';
10434 $retstring = $withoutdiv ?
'':
'<div class="center">';
10436 foreach ($buttons as $button) {
10437 $addclass = empty($button[
'addclass']) ?
'' : $button[
'addclass'];
10438 $retstring .=
'<input type="submit" class="button button-'.$button[
'name'].($morecss ?
' '.$morecss :
'').
' '.$addclass.
'" name="'.$button[
'name'].
'" value="'.
dol_escape_htmltag($langs->trans($button[
'label_key'])).
'">';
10440 $retstring .= $withoutdiv ?
'':
'</div>';
10442 if ($dol_openinpopup) {
10443 $retstring .=
'<!-- buttons are shown into a $dol_openinpopup='.$dol_openinpopup.
' context, so we enable the close of dialog on cancel -->'.
"\n";
10444 $retstring .=
'<script>';
10445 $retstring .=
'jQuery(".button-cancel").click(function(e) {
10446 e.preventDefault(); console.log(\'We click on cancel in iframe popup '.$dol_openinpopup.
'\');
10447 window.parent.jQuery(\
'#idfordialog'.$dol_openinpopup.
'\').dialog(\
'close\');
10449 $retstring .=
'</script>';
ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array(), $moreparams='')
Generic function that return javascript to add to a page to transform a common input field into an au...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
ajax_multiautocompleter($htmlname, $fields, $url, $option='', $minLength=2, $autoselect=0)
Generic function that return javascript to add to a page to transform a common input field into an au...
Class to manage bank accounts.
Class to manage categories.
Class to manage a WYSIWYG editor.
const STATUS_OPEN_INTERNAL
Warehouse open and operations for stock transfers/corrections allowed (not for customer shipping and ...
const STATUS_OPEN_ALL
Warehouse open and operations for customer shipping, supplier dispatch, internal stock transfers/corr...
const STATUS_CLOSED
Warehouse closed, inactive.
Class to manage invoices.
Class to parse product price expressions.
Class to manage predefined suppliers products.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
currency_name($code_iso, $withcode='', $outputlangs=null)
Return label of currency or code+label.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
getServerTimeZoneInt($refgmtdate='now')
Return server timezone int.
dolCheckFilters($sqlfilters, &$error='')
Return if a $sqlfilters parameter is valid and will pass the preg_replace_callback() to replace Gener...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array())
Clean a string to keep only desirable HTML tags.
dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea'), $cleanalsosomestyles=0)
Clean a string from some undesirable HTML tags.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='')
Return URL we can use for advanced preview links.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolIsAllowedForPreview($file)
Return if a file is qualified for preview.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
$formconfirm
if ($action == 'delbookkeepingyear') {
testSqlAndScriptInject($val, $type)
Security: WAF layer for SQL Injection and XSS Injection (scripts) protection (Filters on GET,...
table tableforfield button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
getMaxFileSizeArray()
Return the max allowed for file upload.
$conf db
API class for accounts.
print *****$script_file(".$version.") pid code
! Closing after partial payment: discount_vat, badcustomer or badsupplier, bankcharge,...