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" 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>';
206 public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata =
'string', $editvalue =
'', $extObject = null, $custommsg = null, $moreparam =
'', $notabletag = 0, $formatfunc =
'', $paramid =
'id', $gm =
'auto')
208 global $conf, $langs;
213 if (empty($typeofdata)) {
214 return 'ErrorBadParameter';
218 if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match(
'/^select;|day|datepicker|dayhour|datehourpicker/', $typeofdata)) {
219 $ret .= $this->
editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg);
221 $editmode = (
GETPOST(
'action',
'aZ09') ==
'edit'.$htmlname);
224 $ret .=
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].($moreparam ?
'?'.$moreparam :
'').
'">';
225 $ret .=
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
226 $ret .=
'<input type="hidden" name="token" value="'.newToken().
'">';
227 $ret .=
'<input type="hidden" name="'.$paramid.
'" value="'.$object->id.
'">';
228 if (empty($notabletag)) {
229 $ret .=
'<table class="nobordernopadding centpercent">';
231 if (empty($notabletag)) {
234 if (preg_match(
'/^(string|safehtmlstring|email)/', $typeofdata)) {
235 $tmp = explode(
':', $typeofdata);
236 $ret .=
'<input type="text" id="'.$htmlname.
'" name="'.$htmlname.
'" value="'.($editvalue ? $editvalue : $value).
'"'.(empty($tmp[1]) ?
'' :
' size="'.$tmp[1].
'"').
' autofocus>';
237 } elseif (preg_match(
'/^(integer)/', $typeofdata)) {
238 $tmp = explode(
':', $typeofdata);
239 $valuetoshow =
price2num($editvalue ? $editvalue : $value, 0);
240 $ret .=
'<input type="text" id="'.$htmlname.
'" name="'.$htmlname.
'" value="'.$valuetoshow.
'"'.(empty($tmp[1]) ?
'' :
' size="'.$tmp[1].
'"').
' autofocus>';
241 } elseif (preg_match(
'/^(numeric|amount)/', $typeofdata)) {
242 $tmp = explode(
':', $typeofdata);
243 $valuetoshow =
price2num($editvalue ? $editvalue : $value);
244 $ret .=
'<input type="text" id="'.$htmlname.
'" name="'.$htmlname.
'" value="'.($valuetoshow !=
'' ?
price($valuetoshow) :
'').
'"'.(empty($tmp[1]) ?
'' :
' size="'.$tmp[1].
'"').
' autofocus>';
245 } elseif (preg_match(
'/^(checkbox)/', $typeofdata)) {
246 $tmp = explode(
':', $typeofdata);
247 $ret .=
'<input type="checkbox" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $value .
'"' . (empty($tmp[1]) ?
'' : $tmp[1]) .
'/>';
248 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) {
249 $tmp = explode(
':', $typeofdata);
250 $cols = (empty($tmp[2]) ?
'' : $tmp[2]);
252 if (preg_match(
'/%/', $cols)) {
253 $morealt =
' style="width: '.$cols.
'"';
257 $valuetoshow = ($editvalue ? $editvalue : $value);
258 $ret .=
'<textarea id="'.$htmlname.
'" name="'.$htmlname.
'" wrap="soft" rows="'.(empty($tmp[1]) ?
'20' : $tmp[1]).
'"'.($cols ?
' cols="'.$cols.
'"' :
'class="quatrevingtpercent"').$morealt.
'" autofocus>';
261 $valuetoshow = str_replace(
'&',
'&', $valuetoshow);
263 $ret .=
'</textarea>';
264 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') {
265 $ret .= $this->
selectDate($value, $htmlname, 0, 0, 1,
'form'.$htmlname, 1, 0, 0,
'',
'',
'',
'', 1,
'',
'', $gm);
266 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') {
267 $ret .= $this->
selectDate($value, $htmlname, 1, 1, 1,
'form'.$htmlname, 1, 0, 0,
'',
'',
'',
'', 1,
'',
'', $gm);
268 } elseif (preg_match(
'/^select;/', $typeofdata)) {
269 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
270 $arraylist = array();
271 foreach ($arraydata as $val) {
272 $tmp = explode(
':', $val);
273 $tmpkey = str_replace(
'|',
':', $tmp[0]);
274 $arraylist[$tmpkey] = $tmp[1];
276 $ret .= $this->
selectarray($htmlname, $arraylist, $value);
277 } elseif (preg_match(
'/^ckeditor/', $typeofdata)) {
278 $tmp = explode(
':', $typeofdata);
279 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
280 $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]));
281 $ret .= $doleditor->Create(1);
283 if (empty($notabletag)) {
288 if (empty($notabletag)) {
289 $ret .=
'<td class="left">';
292 $ret .=
'<input type="submit" class="smallpaddingimp button'.(empty($notabletag) ?
'' :
' ').
'" name="modify" value="'.$langs->trans(
"Modify").
'">';
293 if (preg_match(
'/ckeditor|textarea/', $typeofdata) && empty($notabletag)) {
296 $ret .=
'<input type="submit" class="smallpaddingimp button button-cancel'.(empty($notabletag) ?
'' :
' ').
'" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
297 if (empty($notabletag)) {
301 if (empty($notabletag)) {
302 $ret .=
'</tr></table>'.
"\n";
304 $ret .=
'</form>'.
"\n";
306 if (preg_match(
'/^(email)/', $typeofdata)) {
308 } elseif (preg_match(
'/^(amount|numeric)/', $typeofdata)) {
309 $ret .= ($value !=
'' ?
price($value,
'', $langs, 0, -1, -1, $conf->currency) :
'');
310 } elseif (preg_match(
'/^(checkbox)/', $typeofdata)) {
311 $tmp = explode(
':', $typeofdata);
312 $ret .=
'<input type="checkbox" disabled id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $value .
'"' . ($tmp[1] ? $tmp[1] :
'') .
'/>';
313 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) {
315 } elseif (preg_match(
'/^safehtmlstring/', $typeofdata)) {
317 } elseif (preg_match(
'/^restricthtml/', $typeofdata)) {
319 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') {
320 $ret .=
'<span class="valuedate">'.dol_print_date($value,
'day', $gm).
'</span>';
321 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') {
322 $ret .=
'<span class="valuedate">'.dol_print_date($value,
'dayhour', $gm).
'</span>';
323 } elseif (preg_match(
'/^select;/', $typeofdata)) {
324 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
325 $arraylist = array();
326 foreach ($arraydata as $val) {
327 $tmp = explode(
':', $val);
328 $arraylist[$tmp[0]] = $tmp[1];
330 $ret .= $arraylist[$value];
331 if ($htmlname ==
'fk_product_type') {
333 $ret =
img_picto($langs->trans(
"Product"),
'product',
'class="paddingleftonly paddingrightonly colorgrey"').$ret;
335 $ret =
img_picto($langs->trans(
"Service"),
'service',
'class="paddingleftonly paddingrightonly colorgrey"').$ret;
338 } elseif (preg_match(
'/^ckeditor/', $typeofdata)) {
340 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
341 $firstline = preg_replace(
'/<br>.*/',
'', $tmpcontent);
342 $firstline = preg_replace(
'/[\n\r].*/',
'', $firstline);
343 $tmpcontent = $firstline.((strlen($firstline) != strlen($tmpcontent)) ?
'...' :
'');
352 if ($formatfunc && method_exists($object, $formatfunc)) {
353 $ret = $object->$formatfunc($ret);
371 public function widgetForTranslation($fieldname, $object, $perm, $typeofdata =
'string', $check =
'', $morecss =
'')
373 global $conf, $langs, $extralanguages;
378 $arrayoflangcode = array();
379 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) {
380 $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
383 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
384 if (!is_object($extralanguages)) {
385 include_once DOL_DOCUMENT_ROOT.
'/core/class/extralanguages.class.php';
388 $extralanguages->fetch_name_extralanguages(
'societe');
390 if (!is_array($extralanguages->attributes[$object->element]) || empty($extralanguages->attributes[$object->element][$fieldname])) {
394 $result .=
'<!-- Widget for translation -->'.
"\n";
395 $result .=
'<div class="inline-block paddingleft image-'.$object->element.
'-'.$fieldname.
'">';
396 $s =
img_picto($langs->trans(
"ShowOtherLanguages"),
'language',
'',
false, 0, 0,
'',
'fa-15 editfieldlang');
400 $result .=
'<div class="inline-block hidden field-'.$object->element.
'-'.$fieldname.
'">';
402 $resultforextrlang =
'';
403 foreach ($arrayoflangcode as $langcode) {
404 $valuetoshow =
GETPOSTISSET(
'field-'.$object->element.
"-".$fieldname.
"-".$langcode) ?
GETPOST(
'field-'.$object->element.
'-'.$fieldname.
"-".$langcode, $check) :
'';
405 if (empty($valuetoshow)) {
406 $object->fetchValuesForExtraLanguages();
408 $valuetoshow = $object->array_languages[$fieldname][$langcode];
412 $resultforextrlang .= $s;
415 if ($typeofdata ==
'textarea') {
416 $resultforextrlang .=
'<textarea name="field-'.$object->element.
"-".$fieldname.
"-".$langcode.
'" id="'.$fieldname.
"-".$langcode.
'" class="'.$morecss.
'" rows="'.ROWS_2.
'" wrap="soft">';
417 $resultforextrlang .= $valuetoshow;
418 $resultforextrlang .=
'</textarea>';
420 $resultforextrlang .=
'<input type="text" class="inputfieldforlang '.($morecss ?
' '.$morecss :
'').
'" name="field-'.$object->element.
'-'.$fieldname.
'-'.$langcode.
'" value="'.$valuetoshow.
'">';
423 $result .= $resultforextrlang;
426 $result .=
'<script>$(".image-'.$object->element.
'-'.$fieldname.
'").click(function() { console.log("Toggle lang widget"); jQuery(".field-'.$object->element.
'-'.$fieldname.
'").toggle(); });</script>';
445 protected function editInPlace($object, $value, $htmlname, $condition, $inputType =
'textarea', $editvalue = null, $extObject = null, $custommsg = null)
452 if (preg_match(
'/^text/', $inputType)) {
454 } elseif (preg_match(
'/^numeric/', $inputType)) {
455 $value =
price($value);
456 } elseif ($inputType ==
'day' || $inputType ==
'datepicker') {
462 $table_element =
false;
466 $ext_element =
false;
467 $button_only =
false;
472 if (is_object($object)) {
473 $element = $object->element;
474 $table_element = $object->table_element;
475 $fk_element = $object->id;
478 if (is_object($extObject)) {
479 $ext_element = $extObject->element;
482 if (preg_match(
'/^(string|email|numeric)/', $inputType)) {
483 $tmp = explode(
':', $inputType);
484 $inputType = $tmp[0];
485 if (!empty($tmp[1])) {
486 $inputOption = $tmp[1];
488 if (!empty($tmp[2])) {
489 $savemethod = $tmp[2];
491 $out .=
'<input id="width_'.$htmlname.
'" value="'.$inputOption.
'" type="hidden"/>'.
"\n";
492 } elseif ((preg_match(
'/^day$/', $inputType)) || (preg_match(
'/^datepicker/', $inputType)) || (preg_match(
'/^datehourpicker/', $inputType))) {
493 $tmp = explode(
':', $inputType);
494 $inputType = $tmp[0];
495 if (!empty($tmp[1])) {
496 $inputOption = $tmp[1];
498 if (!empty($tmp[2])) {
499 $savemethod = $tmp[2];
502 $out .=
'<input id="timestamp" type="hidden"/>'.
"\n";
503 } elseif (preg_match(
'/^(select|autocomplete)/', $inputType)) {
504 $tmp = explode(
':', $inputType);
505 $inputType = $tmp[0];
506 $loadmethod = $tmp[1];
507 if (!empty($tmp[2])) {
508 $savemethod = $tmp[2];
510 if (!empty($tmp[3])) {
513 } elseif (preg_match(
'/^textarea/', $inputType)) {
514 $tmp = explode(
':', $inputType);
515 $inputType = $tmp[0];
516 $rows = (empty($tmp[1]) ?
'8' : $tmp[1]);
517 $cols = (empty($tmp[2]) ?
'80' : $tmp[2]);
518 } elseif (preg_match(
'/^ckeditor/', $inputType)) {
519 $tmp = explode(
':', $inputType);
520 $inputType = $tmp[0];
522 if (!empty($tmp[2])) {
525 if (!empty($tmp[3])) {
528 if (!empty($tmp[4])) {
529 $savemethod = $tmp[4];
532 if (!empty($conf->fckeditor->enabled)) {
533 $out .=
'<input id="ckeditor_toolbar" value="'.$toolbar.
'" type="hidden"/>'.
"\n";
535 $inputType =
'textarea';
539 $out .=
'<input id="element_'.$htmlname.
'" value="'.$element.
'" type="hidden"/>'.
"\n";
540 $out .=
'<input id="table_element_'.$htmlname.
'" value="'.$table_element.
'" type="hidden"/>'.
"\n";
541 $out .=
'<input id="fk_element_'.$htmlname.
'" value="'.$fk_element.
'" type="hidden"/>'.
"\n";
542 $out .=
'<input id="loadmethod_'.$htmlname.
'" value="'.$loadmethod.
'" type="hidden"/>'.
"\n";
543 if (!empty($savemethod)) {
544 $out .=
'<input id="savemethod_'.$htmlname.
'" value="'.$savemethod.
'" type="hidden"/>'.
"\n";
546 if (!empty($ext_element)) {
547 $out .=
'<input id="ext_element_'.$htmlname.
'" value="'.$ext_element.
'" type="hidden"/>'.
"\n";
549 if (!empty($custommsg)) {
550 if (is_array($custommsg)) {
551 if (!empty($custommsg[
'success'])) {
552 $out .=
'<input id="successmsg_'.$htmlname.
'" value="'.$custommsg[
'success'].
'" type="hidden"/>'.
"\n";
554 if (!empty($custommsg[
'error'])) {
555 $out .=
'<input id="errormsg_'.$htmlname.
'" value="'.$custommsg[
'error'].
'" type="hidden"/>'.
"\n";
558 $out .=
'<input id="successmsg_'.$htmlname.
'" value="'.$custommsg.
'" type="hidden"/>'.
"\n";
561 if ($inputType ==
'textarea') {
562 $out .=
'<input id="textarea_'.$htmlname.
'_rows" value="'.$rows.
'" type="hidden"/>'.
"\n";
563 $out .=
'<input id="textarea_'.$htmlname.
'_cols" value="'.$cols.
'" type="hidden"/>'.
"\n";
565 $out .=
'<span id="viewval_'.$htmlname.
'" class="viewval_'.$inputType.($button_only ?
' inactive' :
' active').
'">'.$value.
'</span>'.
"\n";
566 $out .=
'<span id="editval_'.$htmlname.
'" class="editval_'.$inputType.($button_only ?
' inactive' :
' active').
' hideobject">'.(!empty($editvalue) ? $editvalue : $value).
'</span>'.
"\n";
592 public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img =
'', $extracss =
'', $notabs = 3, $incbefore =
'', $noencodehtmltext = 0, $tooltiptrigger =
'', $forcenowrap = 0)
595 $text = $incbefore.$text;
600 $direction = (int) $direction;
610 $htmltext = str_replace(array(
"\r",
"\n"),
'', $htmltext);
613 if ($direction < 0) {
614 $extracss = ($extracss ? $extracss.
' ' :
'').($notabs != 3 ?
'inline-block' :
'');
615 $extrastyle =
'padding: 0px; padding-left: 3px !important;';
617 if ($direction > 0) {
618 $extracss = ($extracss ? $extracss.
' ' :
'').($notabs != 3 ?
'inline-block' :
'');
619 $extrastyle =
'padding: 0px; padding-right: 3px !important;';
622 $classfortooltip =
'classfortooltip';
627 if ($tooltiptrigger ==
'') {
628 $htmltext = str_replace(
'"',
'"', $htmltext);
630 $classfortooltip =
'classfortooltiponclick';
631 $textfordialog .=
'<div style="display: none;" id="idfortooltiponclick_'.$tooltiptrigger.
'" class="classfortooltiponclicktext">'.$htmltext.
'</div>';
633 if ($tooltipon == 2 || $tooltipon == 3) {
634 $paramfortooltipimg =
' class="'.$classfortooltip.($notabs != 3 ?
' inline-block' :
'').($extracss ?
' '.$extracss :
'').
'" style="padding: 0px;'.($extrastyle ?
' '.$extrastyle :
'').
'"';
635 if ($tooltiptrigger ==
'') {
636 $paramfortooltipimg .=
' title="'.($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1)).
'"';
638 $paramfortooltipimg .=
' dolid="'.$tooltiptrigger.
'"';
641 $paramfortooltipimg = ($extracss ?
' class="'.$extracss.
'"' :
'').($extrastyle ?
' style="'.$extrastyle.
'"' :
'');
643 if ($tooltipon == 1 || $tooltipon == 3) {
644 $paramfortooltiptd =
' class="'.($tooltipon == 3 ?
'cursorpointer ' :
'').$classfortooltip.
' inline-block'.($extracss ?
' '.$extracss :
'').
'" style="padding: 0px;'.($extrastyle ?
' '.$extrastyle :
'').
'" ';
645 if ($tooltiptrigger ==
'') {
646 $paramfortooltiptd .=
' title="'.($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1)).
'"';
648 $paramfortooltiptd .=
' dolid="'.$tooltiptrigger.
'"';
651 $paramfortooltiptd = ($extracss ?
' class="'.$extracss.
'"' :
'').($extrastyle ?
' style="'.$extrastyle.
'"' :
'');
653 if (empty($notabs)) {
654 $s .=
'<table class="nobordernopadding"><tr style="height: auto;">';
655 } elseif ($notabs == 2) {
656 $s .=
'<div class="inline-block'.($forcenowrap ?
' nowrap' :
'').
'">';
659 if ($direction < 0) {
660 $s .=
'<'.$tag.$paramfortooltipimg;
662 $s .=
' class=valigntop" width="14"';
664 $s .=
'>'.$textfordialog.$img.
'</'.$tag.
'>';
668 if ((
string) $text !=
'') {
669 $s .=
'<'.$tag.$paramfortooltiptd.
'>'.$text.
'</'.$tag.
'>';
672 if ($direction > 0) {
673 $s .=
'<'.$tag.$paramfortooltipimg;
675 $s .=
' class="valignmiddle" width="14"';
677 $s .=
'>'.$textfordialog.$img.
'</'.$tag.
'>';
679 if (empty($notabs)) {
680 $s .=
'</tr></table>';
681 } elseif ($notabs == 2) {
702 public function textwithpicto($text, $htmltext, $direction = 1, $type =
'help', $extracss =
'', $noencodehtmltext = 0, $notabs = 3, $tooltiptrigger =
'', $forcenowrap = 0)
704 global $conf, $langs;
707 if ($tooltiptrigger) {
708 $alt = $langs->transnoentitiesnoconv(
"ClickToShowHelp");
714 } elseif ($type ==
'1') {
719 if (empty($conf->use_javascript_ajax)) {
720 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable') {
729 if (!empty($conf->dol_no_mouse_hover) && empty($tooltiptrigger)) {
730 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable') {
741 if ($type ==
'info') {
743 } elseif ($type ==
'help') {
744 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
745 } elseif ($type ==
'helpclickable') {
746 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
747 } elseif ($type ==
'superadmin') {
749 } elseif ($type ==
'admin') {
751 } elseif ($type ==
'warning') {
753 } elseif ($type !=
'none') {
757 return $this->
textwithtooltip($text, $htmltext, ((($tooltiptrigger && !$img) || strpos($type,
'clickable')) ? 3 : 2), $direction, $img, $extracss, $notabs,
'', $noencodehtmltext, $tooltiptrigger, $forcenowrap);
770 public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0, $name =
'massaction', $cssclass =
'checkforselect')
772 global $conf, $langs, $hookmanager;
776 $ret =
'<div class="centpercent center">';
777 $ret .=
'<select class="flat'.(empty($conf->use_javascript_ajax) ?
'' :
' hideobject').
' '.$name.
' '.$name.
'select valignmiddle alignstart" id="'.$name.
'" name="'.$name.
'"'.($disabled ?
' disabled="disabled"' :
'').
'>';
780 $parameters = array();
781 $reshook = $hookmanager->executeHooks(
'addMoreMassActions', $parameters);
783 if (count($arrayofaction) == 0 && empty($hookmanager->resPrint)) {
786 if (empty($reshook)) {
787 $ret .=
'<option value="0"'.($disabled ?
' disabled="disabled"' :
'').
'>-- '.$langs->trans(
"SelectAction").
' --</option>';
788 foreach ($arrayofaction as $code => $label) {
789 $ret .=
'<option value="'.$code.
'"'.($disabled ?
' disabled="disabled"' :
'').
' data-html="'.
dol_escape_htmltag($label).
'">'.$label.
'</option>';
792 $ret .= $hookmanager->resPrint;
796 if (empty($conf->dol_optimize_smallscreen)) {
801 $ret .=
'<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">';
802 $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")).
'">';
805 if (!empty($conf->use_javascript_ajax)) {
806 $ret .=
'<!-- JS CODE TO ENABLE mass action select -->
808 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 */
810 atleastoneselected=0;
811 jQuery("."+cssclass).each(function( index ) {
812 /* console.log( index + ": " + $( this ).text() ); */
813 if ($(this).is(\':checked\')) atleastoneselected++;
816 console.log("initCheckForSelect mode="+mode+" name="+name+" cssclass="+cssclass+" atleastoneselected="+atleastoneselected);
818 if (atleastoneselected || '.$alwaysvisible.
')
820 jQuery("."+name).show();
821 '.($selected ?
'if (atleastoneselected) { jQuery("."+name+"select").val("'.$selected.
'").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', false); }' :
'').
'
822 '.($selected ?
'if (! atleastoneselected) { jQuery("."+name+"select").val("0").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', true); } ' :
'').
'
826 jQuery("."+name).hide();
827 jQuery("."+name+"other").hide();
831 jQuery(document).ready(function () {
832 initCheckForSelect(0, "' . $name.
'", "'.$cssclass.
'");
833 jQuery(".' . $cssclass.
'").click(function() {
834 initCheckForSelect(1, "'.$name.
'", "'.$cssclass.
'");
836 jQuery(".' . $name.
'select").change(function() {
837 var massaction = $( this ).val();
838 var urlform = $( this ).closest("form").attr("action").replace("#show_files","");
839 if (massaction == "builddoc")
841 urlform = urlform + "#show_files";
843 $( this ).closest("form").attr("action", urlform);
844 console.log("we select a mass action name='.$name.
' massaction="+massaction+" - "+urlform);
845 /* Warning: if you set submit button to disabled, post using Enter will no more work if there is no other button */
846 if ($(this).val() != \'0\')
848 jQuery(".' . $name.
'confirmed").prop(\'disabled\', false);
849 jQuery(".' . $name.
'other").hide(); /* To disable if another div was open */
850 jQuery(".' . $name.
'"+massaction).show();
854 jQuery(".' . $name.
'confirmed").prop(\'disabled\', true);
855 jQuery(".' . $name.
'other").hide(); /* To disable any div open */
883 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)
886 global $conf, $langs, $mysoc;
888 $langs->load(
"dict");
891 $countryArray = array();
894 $atleastonefavorite = 0;
896 $sql =
"SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite, eec";
897 $sql .=
" FROM ".$this->db->prefix().
"c_country";
898 $sql .=
" WHERE active > 0";
901 dol_syslog(get_class($this).
"::select_country", LOG_DEBUG);
904 $out .=
'<select id="select'.$htmlname.
'" class="flat maxwidth200onsmartphone selectcountry'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" '.$htmloption.
'>';
905 $num = $this->db->num_rows(
$resql);
909 $obj = $this->
db->fetch_object(
$resql);
911 $countryArray[$i][
'rowid'] = $obj->rowid;
912 $countryArray[$i][
'code_iso'] = $obj->code_iso;
913 $countryArray[$i][
'code_iso3'] = $obj->code_iso3;
914 $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 :
''));
915 $countryArray[$i][
'favorite'] = $obj->favorite;
916 $countryArray[$i][
'eec'] = $obj->eec;
917 $favorite[$i] = $obj->favorite;
922 if (empty($disablefavorites)) {
923 $array1_sort_order = SORT_DESC;
924 $array2_sort_order = SORT_ASC;
925 array_multisort($favorite, $array1_sort_order, $label, $array2_sort_order, $countryArray);
931 if (is_numeric($showempty)) {
932 $out .=
'<option value=""> </option>'.
"\n";
934 $out .=
'<option value="">'.$langs->trans($showempty).
'</option>'.
"\n";
938 if ($addspecialentries) {
940 $out .=
'<option value="special_allnotme"'.($selected ==
'special_allnotme' ?
' selected' :
'').
'>'.$langs->trans(
"CountriesExceptMe", $langs->transnoentitiesnoconv(
"Country".$mysoc->country_code)).
'</option>';
941 $out .=
'<option value="special_eec"'.($selected ==
'special_eec' ?
' selected' :
'').
'>'.$langs->trans(
"CountriesInEEC").
'</option>';
942 if ($mysoc->isInEEC()) {
943 $out .=
'<option value="special_eecnotme"'.($selected ==
'special_eecnotme' ?
' selected' :
'').
'>'.$langs->trans(
"CountriesInEECExceptMe", $langs->transnoentitiesnoconv(
"Country".$mysoc->country_code)).
'</option>';
945 $out .=
'<option value="special_noteec"'.($selected ==
'special_noteec' ?
' selected' :
'').
'>'.$langs->trans(
"CountriesNotInEEC").
'</option>';
946 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
949 foreach ($countryArray as $row) {
951 if (empty($row[
'rowid'])) {
954 if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row[
'code_iso'], $exclude_country_code)) {
958 if (empty($disablefavorites) && $row[
'favorite'] && $row[
'code_iso']) {
959 $atleastonefavorite++;
961 if (empty($row[
'favorite']) && $atleastonefavorite) {
962 $atleastonefavorite = 0;
963 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
968 $labeltoshow .=
dol_trunc($row[
'label'], $maxlength,
'middle');
970 $labeltoshow .=
' ';
972 if ($row[
'code_iso']) {
973 $labeltoshow .=
' <span class="opacitymedium">('.$row[
'code_iso'].
')</span>';
974 if (empty($hideflags)) {
975 $tmpflag =
picto_from_langcode($row[
'code_iso'],
'class="saturatemedium paddingrightonly"', 1);
976 $labeltoshow = $tmpflag.
' '.$labeltoshow;
980 if ($selected && $selected !=
'-1' && ($selected == $row[
'rowid'] || $selected == $row[
'code_iso'] || $selected == $row[
'code_iso3'] || $selected == $row[
'label'])) {
981 $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']).
'">';
983 $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']).
'">';
985 $out .= $labeltoshow;
986 $out .=
'</option>'.
"\n";
995 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
996 $out .=
ajax_combobox(
'select'.$htmlname, array(), 0, 0,
'resolve');
1015 public function select_incoterms($selected =
'', $location_incoterms =
'', $page =
'', $htmlname =
'incoterm_id', $htmloption =
'', $forcecombo = 1, $events = array(), $disableautocomplete = 0)
1018 global $conf, $langs;
1020 $langs->load(
"dict");
1024 $incotermArray = array();
1026 $sql =
"SELECT rowid, code";
1027 $sql .=
" FROM ".$this->db->prefix().
"c_incoterms";
1028 $sql .=
" WHERE active > 0";
1029 $sql .=
" ORDER BY code ASC";
1031 dol_syslog(get_class($this).
"::select_incoterm", LOG_DEBUG);
1034 if ($conf->use_javascript_ajax && !$forcecombo) {
1035 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1039 if (!empty($page)) {
1040 $out .=
'<form method="post" action="'.$page.
'">';
1041 $out .=
'<input type="hidden" name="action" value="set_incoterms">';
1042 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1045 $out .=
'<select id="'.$htmlname.
'" class="flat selectincoterm width75" name="'.$htmlname.
'" '.$htmloption.
'>';
1046 $out .=
'<option value="0"> </option>';
1047 $num = $this->
db->num_rows(
$resql);
1051 $obj = $this->
db->fetch_object(
$resql);
1052 $incotermArray[$i][
'rowid'] = $obj->rowid;
1053 $incotermArray[$i][
'code'] = $obj->code;
1057 foreach ($incotermArray as $row) {
1058 if ($selected && ($selected == $row[
'rowid'] || $selected == $row[
'code'])) {
1059 $out .=
'<option value="'.$row[
'rowid'].
'" selected>';
1061 $out .=
'<option value="'.$row[
'rowid'].
'">';
1065 $out .= $row[
'code'];
1068 $out .=
'</option>';
1071 $out .=
'</select>';
1073 if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
1074 $out .=
ajax_multiautocompleter(
'location_incoterms',
'', DOL_URL_ROOT.
'/core/ajax/locationincoterms.php').
"\n";
1075 $moreattrib .=
' autocomplete="off"';
1077 $out .=
'<input id="location_incoterms" class="maxwidthonsmartphone type="text" name="location_incoterms" value="'.$location_incoterms.
'">'.
"\n";
1079 if (!empty($page)) {
1080 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp nomargintop nomarginbottom" value="'.$langs->trans(
"Modify").
'"></form>';
1101 public function select_type_of_lines($selected =
'', $htmlname =
'type', $showempty = 0, $hidetext = 0, $forceall = 0)
1104 global $langs, $conf;
1107 if ($forceall == 1 || (empty($forceall) && !empty($conf->product->enabled) && !empty($conf->service->enabled))
1108 || (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled))) {
1109 if (empty($hidetext)) {
1110 print $langs->trans(
"Type").
': ';
1112 print
'<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
1114 print
'<option value="-1"';
1115 if ($selected == -1) {
1118 print
'> </option>';
1121 print
'<option value="0"';
1122 if (0 == $selected || ($selected == -1 &&
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') ==
'product')) {
1125 print
'>'.$langs->trans(
"Product");
1127 print
'<option value="1"';
1128 if (1 == $selected || ($selected == -1 &&
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') ==
'service')) {
1131 print
'>'.$langs->trans(
"Service");
1137 if ((empty($forceall) && empty($conf->product->enabled) && !empty($conf->service->enabled)) || $forceall == 3) {
1138 print $langs->trans(
"Service");
1139 print
'<input type="hidden" name="'.$htmlname.
'" value="1">';
1141 if ((empty($forceall) && !empty($conf->product->enabled) && empty($conf->service->enabled)) || $forceall == 2) {
1142 print $langs->trans(
"Product");
1143 print
'<input type="hidden" name="'.$htmlname.
'" value="0">';
1145 if ($forceall < 0) {
1146 print
'<input type="hidden" name="'.$htmlname.
'" value="1">';
1161 $num = count($this->cache_types_fees);
1168 $langs->load(
"trips");
1170 $sql =
"SELECT c.code, c.label";
1171 $sql .=
" FROM ".$this->db->prefix().
"c_type_fees as c";
1172 $sql .=
" WHERE active > 0";
1176 $num = $this->
db->num_rows(
$resql);
1180 $obj = $this->
db->fetch_object(
$resql);
1183 $label = ($obj->code != $langs->trans($obj->code) ? $langs->trans($obj->code) : $langs->trans($obj->label));
1184 $this->cache_types_fees[$obj->code] = $label;
1188 asort($this->cache_types_fees);
1209 global $user, $langs;
1211 dol_syslog(__METHOD__.
" selected=".$selected.
", htmlname=".$htmlname, LOG_DEBUG);
1215 print
'<select id="select_'.$htmlname.
'" class="flat" name="'.$htmlname.
'">';
1217 print
'<option value="-1"';
1218 if ($selected == -1) {
1221 print
'> </option>';
1224 foreach ($this->cache_types_fees as $key => $value) {
1225 print
'<option value="'.$key.
'"';
1226 if ($key == $selected) {
1236 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1263 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)
1266 global $conf, $user, $langs;
1270 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && !$forcecombo) {
1271 if (is_null($ajaxoptions)) {
1272 $ajaxoptions = array();
1275 require_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1279 if ($selected && empty($selected_input_value)) {
1280 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1282 $societetmp->fetch($selected);
1283 $selected_input_value = $societetmp->name;
1288 $urloption =
'htmlname='.urlencode(str_replace(
'.',
'_', $htmlname)).
'&outjson=1&filter='.urlencode($filter).(empty($excludeids) ?
'' :
'&excludeids='.join(
',', $excludeids)).($showtype ?
'&showtype='.urlencode($showtype) :
'').($showcode ?
'&showcode='.urlencode($showcode) :
'');
1290 $out .=
'<style type="text/css">.ui-autocomplete { z-index: 1003; }</style>';
1291 if (empty($hidelabel)) {
1292 print $langs->trans(
"RefOrLabel").
' : ';
1293 } elseif ($hidelabel > 1) {
1294 $placeholder = $langs->trans(
"RefOrLabel");
1295 if ($hidelabel == 2) {
1296 $out .=
img_picto($langs->trans(
"Search"),
'search');
1299 $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' :
'').
' />';
1300 if ($hidelabel == 3) {
1301 $out .=
img_picto($langs->trans(
"Search"),
'search');
1304 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
1307 $out .= $this->
select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events,
'', 0, $limit, $morecss, $moreparam, $multiple, $excludeids, $showcode);
1335 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)
1338 global $conf, $user, $langs;
1339 global $hookmanager;
1343 $outarray = array();
1345 if ($selected ===
'') {
1346 $selected = array();
1347 } elseif (!is_array($selected)) {
1348 $selected = array($selected);
1352 if (function_exists(
'testSqlAndScriptInject')) {
1359 $sql =
"SELECT s.rowid, s.nom as name, s.name_alias, s.tva_intra, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
1360 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1361 $sql .=
", s.address, s.zip, s.town";
1362 $sql .=
", dictp.code as country_code";
1364 $sql .=
" FROM ".$this->db->prefix().
"societe as s";
1365 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1366 $sql .=
" LEFT JOIN ".$this->db->prefix().
"c_country as dictp ON dictp.rowid = s.fk_pays";
1368 if (empty($user->rights->societe->client->voir) && !$user->socid) {
1369 $sql .=
", ".$this->db->prefix().
"societe_commerciaux as sc";
1371 $sql .=
" WHERE s.entity IN (".getEntity(
'societe').
")";
1372 if (!empty($user->socid)) {
1373 $sql .=
" AND s.rowid = ".((int) $user->socid);
1376 $sql .=
" AND (".$filter.
")";
1378 if (empty($user->rights->societe->client->voir) && !$user->socid) {
1379 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
1381 if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) {
1382 $sql .=
" AND s.status <> 0";
1384 if (!empty($excludeids)) {
1385 $sql .=
" AND s.rowid NOT IN (".$this->db->sanitize(join(
',', $excludeids)).
")";
1388 $parameters = array();
1389 $reshook = $hookmanager->executeHooks(
'selectThirdpartyListWhere', $parameters);
1390 $sql .= $hookmanager->resPrint;
1392 if ($filterkey && $filterkey !=
'') {
1394 $prefix = empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE) ?
'%' :
'';
1396 $scrit = explode(
' ', $filterkey);
1398 if (count($scrit) > 1) {
1401 foreach ($scrit as $crit) {
1405 $sql .=
"(s.nom LIKE '".$this->db->escape($prefix.$crit).
"%')";
1408 if (count($scrit) > 1) {
1411 if (!empty($conf->barcode->enabled)) {
1412 $sql .=
" OR s.barcode LIKE '".$this->db->escape($prefix.$filterkey).
"%'";
1414 $sql .=
" OR s.code_client LIKE '".$this->db->escape($prefix.$filterkey).
"%' OR s.code_fournisseur LIKE '".$this->
db->escape($prefix.$filterkey).
"%'";
1415 $sql .=
" OR s.name_alias LIKE '".$this->db->escape($prefix.$filterkey).
"%' OR s.tva_intra LIKE '".$this->
db->escape($prefix.$filterkey).
"%'";
1418 $sql .= $this->
db->order(
"nom",
"ASC");
1419 $sql .= $this->
db->plimit($limit, 0);
1422 dol_syslog(get_class($this).
"::select_thirdparty_list", LOG_DEBUG);
1426 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1431 $out .=
'<select id="'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'"'.($moreparam ?
' '.$moreparam :
'').
' name="'.$htmlname.($multiple ?
'[]' :
'').
'" '.($multiple ?
'multiple' :
'').
'>'.
"\n";
1433 $textifempty = (($showempty && !is_numeric($showempty)) ? $langs->trans($showempty) :
'');
1434 if (!empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
1437 if ($showempty && !is_numeric($showempty)) {
1438 $textifempty = $langs->trans($showempty);
1440 $textifempty .= $langs->trans(
"All");
1444 $out .=
'<option value="-1" data-html="'.dol_escape_htmltag(
'<span class="opacitymedium">'.($textifempty ? $textifempty :
' ').
'</span>').
'">'.$textifempty.
'</option>'.
"\n";
1449 $num = $this->
db->num_rows(
$resql);
1453 $obj = $this->
db->fetch_object(
$resql);
1455 if ($showcode || !empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
1456 if (($obj->client) && (!empty($obj->code_client))) {
1457 $label = $obj->code_client.
' - ';
1459 if (($obj->fournisseur) && (!empty($obj->code_fournisseur))) {
1460 $label .= $obj->code_fournisseur.
' - ';
1462 $label .=
' '.$obj->name;
1464 $label = $obj->name;
1467 if (!empty($obj->name_alias)) {
1468 $label .=
' ('.$obj->name_alias.
')';
1471 if (!empty($conf->global->SOCIETE_SHOW_VAT_IN_LIST) && !empty($obj->tva_intra)) {
1472 $label .=
' - '.$obj->tva_intra.
'';
1475 $labelhtml = $label;
1478 $companytemp->id = $obj->rowid;
1479 $companytemp->client = $obj->client;
1480 $companytemp->fournisseur = $obj->fournisseur;
1481 $tmptype = $companytemp->getTypeUrl(1,
'', 0,
'span');
1483 $labelhtml .=
' '.$tmptype;
1486 if ($obj->client || $obj->fournisseur) {
1489 if ($obj->client == 1 || $obj->client == 3) {
1490 $label .= $langs->trans(
"Customer");
1492 if ($obj->client == 2 || $obj->client == 3) {
1493 $label .= ($obj->client == 3 ?
', ' :
'').$langs->trans(
"Prospect");
1495 if ($obj->fournisseur) {
1496 $label .= ($obj->client ?
', ' :
'').$langs->trans(
"Supplier");
1498 if ($obj->client || $obj->fournisseur) {
1503 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1504 $s = ($obj->address ?
' - '.$obj->address :
'').($obj->zip ?
' - '.$obj->zip :
'').($obj->town ?
' '.$obj->town :
'');
1505 if (!empty($obj->country_code)) {
1506 $s .=
', '.$langs->trans(
'Country'.$obj->country_code);
1512 if (empty($outputmode)) {
1513 if (in_array($obj->rowid, $selected)) {
1514 $out .=
'<option value="'.$obj->rowid.
'" selected data-html="'.
dol_escape_htmltag($labelhtml).
'">'.$label.
'</option>';
1516 $out .=
'<option value="'.$obj->rowid.
'" data-html="'.
dol_escape_htmltag($labelhtml).
'">'.$label.
'</option>';
1519 array_push($outarray, array(
'key'=>$obj->rowid,
'value'=>$label,
'label'=>$label,
'labelhtml'=>$labelhtml));
1523 if (($i % 10) == 0) {
1528 $out .=
'</select>'.
"\n";
1533 $this->result = array(
'nbofthirdparties'=>$num);
1556 global $langs, $conf;
1559 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
1560 $sql .=
" re.description, re.fk_facture_source";
1561 $sql .=
" FROM ".$this->db->prefix().
"societe_remise_except as re";
1562 $sql .=
" WHERE re.fk_soc = ".(int) $socid;
1563 $sql .=
" AND re.entity = ".$conf->entity;
1565 $sql .=
" AND ".$filter;
1567 $sql .=
" ORDER BY re.description ASC";
1569 dol_syslog(get_class($this).
"::select_remises", LOG_DEBUG);
1572 print
'<select id="select_'.$htmlname.
'" class="flat maxwidthonsmartphone" name="'.$htmlname.
'">';
1573 $num = $this->
db->num_rows(
$resql);
1575 $qualifiedlines = $num;
1579 print
'<option value="0"> </option>';
1581 $obj = $this->
db->fetch_object(
$resql);
1582 $desc =
dol_trunc($obj->description, 40);
1583 if (preg_match(
'/\(CREDIT_NOTE\)/', $desc)) {
1584 $desc = preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $desc);
1586 if (preg_match(
'/\(DEPOSIT\)/', $desc)) {
1587 $desc = preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"Deposit"), $desc);
1589 if (preg_match(
'/\(EXCESS RECEIVED\)/', $desc)) {
1590 $desc = preg_replace(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"ExcessReceived"), $desc);
1592 if (preg_match(
'/\(EXCESS PAID\)/', $desc)) {
1593 $desc = preg_replace(
'/\(EXCESS PAID\)/', $langs->trans(
"ExcessPaid"), $desc);
1597 if ($selected > 0 && $selected == $obj->rowid) {
1598 $selectstring =
' selected';
1602 if ($maxvalue > 0 && $obj->amount_ttc > $maxvalue) {
1604 $disabled =
' disabled';
1607 if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->fk_facture_source)) {
1609 if ($tmpfac->fetch($obj->fk_facture_source) > 0) {
1610 $desc = $desc.
' - '.$tmpfac->ref;
1614 print
'<option value="'.$obj->rowid.
'"'.$selectstring.$disabled.
'>'.$desc.
' ('.
price($obj->amount_ht).
' '.$langs->trans(
"HT").
' - '.
price($obj->amount_ttc).
' '.$langs->trans(
"TTC").
')</option>';
1621 return $qualifiedlines;
1649 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 =
'')
1652 print $this->
selectcontacts($socid, $selected, $htmlname, $showempty, $exclude, $limitto, $showfunction, $morecss, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid);
1680 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)
1682 global $conf, $langs, $hookmanager, $action;
1684 $langs->load(
'companies');
1686 if (empty($htmlid)) {
1687 $htmlid = $htmlname;
1691 if ($selected ===
'') {
1692 $selected = array();
1693 } elseif (!is_array($selected)) {
1694 $selected = array($selected);
1698 if (!is_object($hookmanager)) {
1699 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1704 $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";
1705 if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1706 $sql .=
", s.nom as company, s.town AS company_town";
1708 $sql .=
" FROM ".$this->db->prefix().
"socpeople as sp";
1709 if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1710 $sql .=
" LEFT OUTER JOIN ".$this->db->prefix().
"societe as s ON s.rowid=sp.fk_soc";
1712 $sql .=
" WHERE sp.entity IN (".getEntity(
'contact').
")";
1713 if ($socid > 0 || $socid == -1) {
1714 $sql .=
" AND sp.fk_soc = ".((int) $socid);
1716 if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) {
1717 $sql .=
" AND sp.statut <> 0";
1720 $parameters = array();
1721 $reshook = $hookmanager->executeHooks(
'selectContactListWhere', $parameters);
1722 $sql .= $hookmanager->resPrint;
1723 $sql .=
" ORDER BY sp.lastname ASC";
1725 dol_syslog(get_class($this).
"::selectcontacts", LOG_DEBUG);
1728 $num = $this->
db->num_rows(
$resql);
1730 if ($htmlname !=
'none' && !$options_only) {
1731 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlid.
'" name="'.$htmlname.(($num || empty($disableifempty)) ?
'' :
' disabled').($multiple ?
'[]' :
'').
'" '.($multiple ?
'multiple' :
'').
' '.(!empty($moreparam) ? $moreparam :
'').
'>';
1734 if ($showempty && ! is_numeric($showempty)) {
1735 $textforempty = $showempty;
1736 $out .=
'<option class="optiongrey" value="-1"'.(in_array(-1, $selected) ?
' selected' :
'').
'>'.$textforempty.
'</option>';
1738 if (($showempty == 1 || ($showempty == 3 && $num > 1)) && ! $multiple) {
1739 $out .=
'<option value="0"'.(in_array(0, $selected) ?
' selected' :
'').
'> </option>';
1741 if ($showempty == 2) {
1742 $out .=
'<option value="0"'.(in_array(0, $selected) ?
' selected' :
'').
'>-- '.$langs->trans(
"Internal").
' --</option>';
1748 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
1749 $contactstatic =
new Contact($this->
db);
1752 $obj = $this->
db->fetch_object(
$resql);
1755 $extendedInfos =
'';
1756 if (!empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1757 $extendedInfos = array();
1758 $email = trim($obj->email);
1759 if (!empty($email)) {
1760 $extendedInfos[] = $email;
1762 $phone = trim($obj->phone);
1763 $phone_perso = trim($obj->phone_perso);
1764 $phone_mobile = trim($obj->phone_mobile);
1765 if (!empty($phone)) {
1766 $extendedInfos[] = $phone;
1768 if (!empty($phone_perso)) {
1769 $extendedInfos[] = $phone_perso;
1771 if (!empty($phone_mobile)) {
1772 $extendedInfos[] = $phone_mobile;
1775 $contact_town = trim($obj->contact_town);
1776 $company_town = trim($obj->company_town);
1777 if (!empty($contact_town)) {
1778 $extendedInfos[] = $contact_town;
1779 } elseif (!empty($company_town)) {
1780 $extendedInfos[] = $company_town;
1782 $extendedInfos = implode(
' - ', $extendedInfos);
1783 if (!empty($extendedInfos)) {
1784 $extendedInfos =
' - '.$extendedInfos;
1788 $contactstatic->id = $obj->rowid;
1789 $contactstatic->lastname = $obj->lastname;
1790 $contactstatic->firstname = $obj->firstname;
1791 if ($obj->statut == 1) {
1792 if ($htmlname !=
'none') {
1794 if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) {
1797 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
1800 if (!empty($selected) && in_array($obj->rowid, $selected)) {
1801 $out .=
'<option value="'.$obj->rowid.
'"';
1803 $out .=
' disabled';
1805 $out .=
' selected>';
1806 $out .= $contactstatic->getFullName($langs).$extendedInfos;
1807 if ($showfunction && $obj->poste) {
1808 $out .=
' ('.$obj->poste.
')';
1810 if (($showsoc > 0) && $obj->company) {
1811 $out .=
' - ('.$obj->company.
')';
1813 $out .=
'</option>';
1815 $out .=
'<option value="'.$obj->rowid.
'"';
1817 $out .=
' disabled';
1820 $out .= $contactstatic->getFullName($langs).$extendedInfos;
1821 if ($showfunction && $obj->poste) {
1822 $out .=
' ('.$obj->poste.
')';
1824 if (($showsoc > 0) && $obj->company) {
1825 $out .=
' - ('.$obj->company.
')';
1827 $out .=
'</option>';
1830 if (in_array($obj->rowid, $selected)) {
1831 $out .= $contactstatic->getFullName($langs).$extendedInfos;
1832 if ($showfunction && $obj->poste) {
1833 $out .=
' ('.$obj->poste.
')';
1835 if (($showsoc > 0) && $obj->company) {
1836 $out .=
' - ('.$obj->company.
')';
1844 $labeltoshow = ($socid != -1) ? ($langs->trans($socid ?
"NoContactDefinedForThirdParty" :
"NoContactDefined")) : $langs->trans(
'SelectAThirdPartyFirst');
1845 $out .=
'<option class="disabled" value="-1"'.(($showempty == 2 || $multiple) ?
'' :
' selected').
' disabled="disabled">';
1846 $out .= $labeltoshow;
1847 $out .=
'</option>';
1850 $parameters = array(
1852 'htmlname'=>$htmlname,
1855 'showfunction'=>$showfunction,
1856 'showsoc'=>$showsoc,
1859 $reshook = $hookmanager->executeHooks(
'afterSelectContactOptions', $parameters, $this, $action);
1861 if ($htmlname !=
'none' && !$options_only) {
1862 $out .=
'</select>';
1865 if ($conf->use_javascript_ajax && !$forcecombo && !$options_only) {
1866 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1894 public function select_users($selected =
'', $htmlname =
'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0')
1897 print $this->
select_dolusers($selected, $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity);
1925 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 =
'', $noactive = 0, $outputmode = 0, $multiple =
false, $forcecombo = 0)
1928 global $conf, $user, $langs, $hookmanager;
1932 if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) {
1933 $selected = $user->id;
1936 if ($selected ===
'') {
1937 $selected = array();
1938 } elseif (!is_array($selected)) {
1939 $selected = array($selected);
1942 $excludeUsers = null;
1943 $includeUsers = null;
1946 if (is_array($exclude)) {
1947 $excludeUsers = implode(
",", $exclude);
1950 if (is_array($include)) {
1951 $includeUsers = implode(
",", $include);
1952 } elseif ($include ==
'hierarchy') {
1954 $includeUsers = implode(
",", $user->getAllChildIds(0));
1955 } elseif ($include ==
'hierarchyme') {
1957 $includeUsers = implode(
",", $user->getAllChildIds(1));
1961 $outarray = array();
1964 $sql =
"SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut as status, u.login, u.admin, u.entity, u.photo";
1965 if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
1966 $sql .=
", e.label";
1968 $sql .=
" FROM ".$this->db->prefix().
"user as u";
1969 if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
1970 $sql .=
" LEFT JOIN ".$this->db->prefix().
"entity as e ON e.rowid = u.entity";
1971 if ($force_entity) {
1972 $sql .=
" WHERE u.entity IN (0, ".$this->db->sanitize($force_entity).
")";
1974 $sql .=
" WHERE u.entity IS NOT NULL";
1977 if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1978 $sql .=
" LEFT JOIN ".$this->db->prefix().
"usergroup_user as ug";
1979 $sql .=
" ON ug.fk_user = u.rowid";
1980 $sql .=
" WHERE ug.entity = ".$conf->entity;
1982 $sql .=
" WHERE u.entity IN (0, ".$conf->entity.
")";
1985 if (!empty($user->socid)) {
1986 $sql .=
" AND u.fk_soc = ".((int) $user->socid);
1988 if (is_array($exclude) && $excludeUsers) {
1989 $sql .=
" AND u.rowid NOT IN (".$this->db->sanitize($excludeUsers).
")";
1991 if ($includeUsers) {
1992 $sql .=
" AND u.rowid IN (".$this->db->sanitize($includeUsers).
")";
1994 if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) {
1995 $sql .=
" AND u.statut <> 0";
1997 if (!empty($morefilter)) {
1998 $sql .=
" ".$morefilter;
2002 $reshook = $hookmanager->executeHooks(
'addSQLWhereFilterOnSelectUsers', array(), $this, $action);
2003 if (!empty($reshook)) {
2004 $sql .= $hookmanager->resPrint;
2007 if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) {
2008 $sql .=
" ORDER BY u.statut DESC, u.firstname ASC, u.lastname ASC";
2010 $sql .=
" ORDER BY u.statut DESC, u.lastname ASC, u.firstname ASC";
2013 dol_syslog(get_class($this).
"::select_dolusers", LOG_DEBUG);
2017 $num = $this->
db->num_rows(
$resql);
2021 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
' minwidth200').
'" id="'.$htmlname.
'" name="'.$htmlname.($multiple ?
'[]' :
'').
'" '.($multiple ?
'multiple' :
'').
' '.($disabled ?
' disabled' :
'').
'>';
2022 if ($show_empty && !$multiple) {
2023 $textforempty =
' ';
2024 if (!empty($conf->use_javascript_ajax)) {
2025 $textforempty =
' ';
2027 if (!is_numeric($show_empty)) {
2028 $textforempty = $show_empty;
2030 $out .=
'<option class="optiongrey" value="'.($show_empty < 0 ? $show_empty : -1).
'"'.((empty($selected) || in_array(-1, $selected)) ?
' selected' :
'').
'>'.$textforempty.
'</option>'.
"\n";
2033 $out .=
'<option value="-2"'.((in_array(-2, $selected)) ?
' selected' :
'').
'>-- '.$langs->trans(
"Everybody").
' --</option>'.
"\n";
2036 $userstatic =
new User($this->
db);
2039 $obj = $this->
db->fetch_object(
$resql);
2041 $userstatic->id = $obj->rowid;
2042 $userstatic->lastname = $obj->lastname;
2043 $userstatic->firstname = $obj->firstname;
2044 $userstatic->photo = $obj->photo;
2045 $userstatic->statut = $obj->status;
2046 $userstatic->entity = $obj->entity;
2047 $userstatic->admin = $obj->admin;
2050 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
2051 $disableline = ($enableonlytext ? $enableonlytext :
'1');
2058 if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) {
2061 $labeltoshow .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
2062 if (empty($obj->firstname) && empty($obj->lastname)) {
2063 $labeltoshow .= $obj->login;
2068 if (!empty($conf->global->MAIN_SHOW_LOGIN)) {
2069 $moreinfo .= ($moreinfo ?
' - ' :
' (').$obj->login;
2071 if ($showstatus >= 0) {
2072 if ($obj->status == 1 && $showstatus == 1) {
2073 $moreinfo .= ($moreinfo ?
' - ' :
' (').$langs->trans(
'Enabled');
2075 if ($obj->status == 0 && $showstatus == 1) {
2076 $moreinfo .= ($moreinfo ?
' - ' :
' (').$langs->trans(
'Disabled');
2079 if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
2080 if (!$obj->entity) {
2081 $moreinfo .= ($moreinfo ?
' - ' :
' (').$langs->trans(
"AllEntities");
2083 if ($obj->entity != $conf->entity) {
2084 $moreinfo .= ($moreinfo ?
' - ' :
' (').($obj->label ? $obj->label : $langs->trans(
"EntityNameNotDefined"));
2088 $moreinfo .= ($moreinfo ?
')' :
'');
2089 if ($disableline && $disableline !=
'1') {
2090 $moreinfo .=
' - '.$disableline;
2092 $labeltoshow .= $moreinfo;
2094 $out .=
'<option value="'.$obj->rowid.
'"';
2096 $out .=
' disabled';
2098 if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected))) {
2099 $out .=
' selected';
2101 $out .=
' data-html="';
2104 $outhtml .= $userstatic->getNomUrl(-3,
'', 0, 1, 24, 1,
'login',
'', 1).
' ';
2106 if ($showstatus >= 0 && $obj->status == 0) {
2107 $outhtml .=
'<strike class="opacitymediumxxx">';
2109 $outhtml .= $labeltoshow;
2110 if ($showstatus >= 0 && $obj->status == 0) {
2111 $outhtml .=
'</strike>';
2115 $out .= $labeltoshow;
2116 $out .=
'</option>';
2118 $outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength).$moreinfo;
2123 $out .=
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'" disabled>';
2124 $out .=
'<option value="">'.$langs->trans(
"None").
'</option>';
2126 $out .=
'</select>';
2128 if ($num && !$forcecombo) {
2130 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
2168 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())
2171 global $conf, $user, $langs;
2173 $userstatic =
new User($this->
db);
2177 $assignedtouser = array();
2178 if (!empty($_SESSION[
'assignedtouser'])) {
2179 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
2181 $nbassignetouser = count($assignedtouser);
2184 if ($nbassignetouser) {
2185 $out .=
'<ul class="attendees">';
2189 foreach ($assignedtouser as $key => $value) {
2190 if ($value[
'id'] == $ownerid) {
2195 $userstatic->fetch($value[
'id']);
2196 $out .= $userstatic->getNomUrl(-1);
2198 $ownerid = $value[
'id'];
2199 $out .=
' ('.$langs->trans(
"Owner").
')';
2201 if ($nbassignetouser > 1 && $action !=
'view') {
2202 $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.
'">';
2205 if ($showproperties) {
2206 if ($ownerid == $value[
'id'] && is_array($listofuserid) && count($listofuserid) && in_array($ownerid, array_keys($listofuserid))) {
2207 $out .=
'<div class="myavailability inline-block">';
2208 $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>';
2218 if ($nbassignetouser) {
2223 if ($action !=
'view') {
2224 $out .=
'<input type="hidden" class="removedassignedhidden" name="removedassigned" value="">';
2225 $out .=
'<script type="text/javascript">jQuery(document).ready(function () {';
2226 $out .=
'jQuery(".removedassigned").click(function() { jQuery(".removedassignedhidden").val(jQuery(this).val()); });';
2227 $out .=
'jQuery(".assignedtouser").change(function() { console.log(jQuery(".assignedtouser option:selected").val());';
2228 $out .=
' if (jQuery(".assignedtouser option:selected").val() > 0) { jQuery("#'.$action.
'assignedtouser").attr("disabled", false); }';
2229 $out .=
' else { jQuery("#'.$action.
'assignedtouser").attr("disabled", true); }';
2231 $out .=
'})</script>';
2232 $out .= $this->
select_dolusers(
'', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter);
2233 $out .=
' <input type="submit" disabled class="button valignmiddle smallpaddingimp reposition" id="'.$action.
'assignedtouser" name="'.$action.
'assignedtouser" value="'.
dol_escape_htmltag($langs->trans(
"Add")).
'">';
2269 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)
2272 global $langs, $conf;
2277 $price_level = (!empty($price_level) ? $price_level : 0);
2278 if (is_null($ajaxoptions)) {
2279 $ajaxoptions = array();
2282 if (strval($filtertype) ===
'' && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
2283 if (!empty($conf->product->enabled) && empty($conf->service->enabled)) {
2285 } elseif (empty($conf->product->enabled) && !empty($conf->service->enabled)) {
2290 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
2293 if ($selected && empty($selected_input_value)) {
2294 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
2295 $producttmpselect =
new Product($this->
db);
2296 $producttmpselect->fetch($selected);
2297 $selected_input_value = $producttmpselect->ref;
2298 unset($producttmpselect);
2301 if ($filtertype ==
'') {
2302 if (empty($conf->product->enabled)) {
2304 } elseif (empty($conf->service->enabled)) {
2309 $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;
2311 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
2312 $urloption .=
'&socid='.$socid;
2314 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
2316 if (!empty($conf->variants->enabled) && is_array($selected_combinations)) {
2320 <!-- script to auto show attributes select tags if a variant was selected -->
2322 // auto show attributes fields
2323 selected = '.json_encode($selected_combinations).
';
2326 jQuery(document).ready(function () {
2328 jQuery("input[name=\'prod_entry_mode\']").change(function () {
2329 if (jQuery(this).val() == \'free\') {
2330 jQuery(\'div#attributes_box\').empty();
2334 jQuery("input#'.$htmlname.
'").change(function () {
2336 if (!jQuery(this).val()) {
2337 jQuery(\'div#attributes_box\').empty();
2341 console.log("A change has started. We get variants fields to inject html select");
2343 jQuery.getJSON("'.DOL_URL_ROOT.
'/variants/ajax/getCombinations.php", {
2344 id: jQuery(this).val()
2345 }, function (data) {
2346 jQuery(\'div#attributes_box\').empty();
2348 jQuery.each(data, function (key, val) {
2350 combvalues[val.id] = val.values;
2352 var span = jQuery(document.createElement(\'div\')).css({
2353 \'display\': \'table-row\'
2357 jQuery(document.createElement(\'div\')).text(val.label).css({
2358 \'font-weight\': \'bold\',
2359 \'display\': \'table-cell\'
2363 var html = jQuery(document.createElement(\'select\')).attr(\'name\', \'combinations[\' + val.id + \']\').css({
2364 \'margin-left\': \'15px\',
2365 \'white-space\': \'pre\'
2367 jQuery(document.createElement(\'option\')).val(\'\')
2370 jQuery.each(combvalues[val.id], function (key, val) {
2371 var tag = jQuery(document.createElement(\'option\')).val(val.id).html(val.value);
2373 if (selected[val.fk_product_attribute] == val.id) {
2374 tag.attr(\'selected\', \'selected\');
2381 jQuery(\'div#attributes_box\').append(span);
2386 '.($selected ?
'jQuery("input#'.$htmlname.
'").change();' :
'').
'
2392 if (empty($hidelabel)) {
2393 $out .= $langs->trans(
"RefOrLabel").
' : ';
2394 } elseif ($hidelabel > 1) {
2395 $placeholder =
' placeholder="'.$langs->trans(
"RefOrLabel").
'"';
2396 if ($hidelabel == 2) {
2397 $out .=
img_picto($langs->trans(
"Search"),
'search');
2400 $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' :
'').
' />';
2401 if ($hidelabel == 3) {
2402 $out .=
img_picto($langs->trans(
"Search"),
'search');
2405 $out .= $this->
select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level,
'', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus, $status_purchase);
2408 if (empty($nooutput)) {
2431 public function select_bom($selected =
'', $htmlname =
'bom_id', $limit = 0, $status = 1, $type = 1, $showempty =
'1', $morecss =
'', $nooutput =
'', $forcecombo = 0)
2434 global $conf, $user, $langs, $db;
2436 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
2442 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
2447 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
2449 $sql =
'SELECT b.rowid, b.ref, b.label, b.fk_product';
2450 $sql.=
' FROM '.MAIN_DB_PREFIX.
'bom_bom as b';
2451 $sql.=
' WHERE b.entity IN ('.getEntity(
'bom').
')';
2452 if (!empty($status)) $sql.=
' AND status = '. (int) $status;
2453 if (!empty($type)) $sql.=
' AND status = '. (
int) $type;
2454 if (!empty($limit)) $sql.=
'LIMIT '. (
int) $limit;
2455 $resql = $db->query($sql);
2458 $out .=
'<option value="-1"';
2459 if (empty($selected)) $out .=
' selected';
2460 $out .=
'> </option>';
2462 while ($obj = $db->fetch_object(
$resql)) {
2464 $res = $product->fetch($obj->fk_product);
2465 if ($obj->rowid == $selected) $out .=
'<option value="'.$obj->rowid.
'" selected>'.$obj->ref.
' - '. $product->label .
' - '.$obj->label.
'</option>';
2466 $out .=
'<option value="'.$obj->rowid.
'">'.$obj->ref.
' - '.$product->label .
' - '. $obj->label.
'</option>';
2472 if (empty($nooutput)) {
2505 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)
2508 global $langs, $conf;
2509 global $hookmanager;
2512 $outarray = array();
2515 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2516 $langs->load(
'other');
2519 $warehouseStatusArray = array();
2520 if (!empty($warehouseStatus)) {
2521 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
2522 if (preg_match(
'/warehouseclosed/', $warehouseStatus)) {
2525 if (preg_match(
'/warehouseopen/', $warehouseStatus)) {
2528 if (preg_match(
'/warehouseinternal/', $warehouseStatus)) {
2533 $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";
2534 if (count($warehouseStatusArray)) {
2535 $selectFieldsGrouped =
", sum(".$this->db->ifsql(
"e.statut IS NULL",
"0",
"ps.reel").
") as stock";
2537 $selectFieldsGrouped =
", ".$this->db->ifsql(
"p.stock IS NULL", 0,
"p.stock").
" AS stock";
2541 $sql .= $selectFields.$selectFieldsGrouped;
2543 if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) {
2545 $sql .=
", (SELECT ".$this->db->prefix().
"categorie_product.fk_categorie
2546 FROM ".$this->
db->prefix().
"categorie_product
2547 WHERE ".$this->
db->prefix().
"categorie_product.fk_product=p.rowid
2549 ) AS categorie_product_id ";
2553 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
2554 $sql .=
', pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,';
2555 $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';
2556 $selectFields .=
", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx, custdefault_vat_code, custref";
2559 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2560 $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";
2561 $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';
2565 if (!empty($conf->global->MAIN_MULTILANGS)) {
2566 $sql .=
", pl.label as label_translated";
2567 $sql .=
", pl.description as description_translated";
2568 $selectFields .=
", label_translated";
2569 $selectFields .=
", description_translated";
2572 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
2573 $sql .=
", (SELECT pp.rowid FROM ".$this->db->prefix().
"product_price as pp WHERE pp.fk_product = p.rowid";
2574 if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
2575 $sql .=
" AND price_level = ".((int) $price_level);
2577 $sql .=
" ORDER BY date_price";
2578 $sql .=
" DESC LIMIT 1) as price_rowid";
2579 $sql .=
", (SELECT pp.price_by_qty FROM ".$this->db->prefix().
"product_price as pp WHERE pp.fk_product = p.rowid";
2580 if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
2581 $sql .=
" AND price_level = ".((int) $price_level);
2583 $sql .=
" ORDER BY date_price";
2584 $sql .=
" DESC LIMIT 1) as price_by_qty";
2585 $selectFields .=
", price_rowid, price_by_qty";
2587 $sql .=
" FROM ".$this->db->prefix().
"product as p";
2588 if (count($warehouseStatusArray)) {
2589 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_stock as ps on ps.fk_product = p.rowid";
2590 $sql .=
" LEFT JOIN ".$this->db->prefix().
"entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (".
getEntity(
'stock').
")";
2591 $sql .=
' AND e.statut IN ('.$this->db->sanitize($this->
db->escape(implode(
',', $warehouseStatusArray))).
')';
2595 if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) {
2596 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
2600 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
2601 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_customer_price as pcp ON pcp.fk_soc=".((int) $socid).
" AND pcp.fk_product=p.rowid";
2604 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2605 $sql .=
" LEFT JOIN ".$this->db->prefix().
"c_units u ON u.rowid = p.fk_unit";
2608 if (!empty($conf->global->MAIN_MULTILANGS)) {
2609 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_lang as pl ON pl.fk_product = p.rowid ";
2610 if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && !empty($socid)) {
2611 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
2613 $result = $soc->fetch($socid);
2614 if ($result > 0 && !empty($soc->default_lang)) {
2615 $sql .=
" AND pl.lang = '".$this->db->escape($soc->default_lang).
"'";
2617 $sql .=
" AND pl.lang = '".$this->db->escape($langs->getDefaultLang()).
"'";
2620 $sql .=
" AND pl.lang = '".$this->db->escape($langs->getDefaultLang()).
"'";
2624 if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
2625 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_attribute_combination pac ON pac.fk_product_child = p.rowid";
2628 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
2630 if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
2631 $sql .=
" AND pac.rowid IS NULL";
2634 if ($finished == 0) {
2635 $sql .=
" AND p.finished = ".((int) $finished);
2636 } elseif ($finished == 1) {
2637 $sql .=
" AND p.finished = ".((int) $finished);
2639 $sql .=
" AND p.tosell = ".((int) $status);
2641 } elseif ($status >= 0) {
2642 $sql .=
" AND p.tosell = ".((int) $status);
2644 if ($status_purchase >= 0) {
2645 $sql .=
" AND p.tobuy = ".((int) $status_purchase);
2648 if (strval($filtertype) !=
'') {
2649 $sql .=
" AND p.fk_product_type = ".((int) $filtertype);
2650 } elseif (empty($conf->product->enabled)) {
2651 $sql .=
" AND p.fk_product_type = 1";
2652 } elseif (empty($conf->service->enabled)) {
2653 $sql .=
" AND p.fk_product_type = 0";
2656 $parameters = array();
2657 $reshook = $hookmanager->executeHooks(
'selectProductsListWhere', $parameters);
2658 $sql .= $hookmanager->resPrint;
2660 if ($filterkey !=
'') {
2662 $prefix = empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE) ?
'%' :
'';
2664 $scrit = explode(
' ', $filterkey);
2666 if (count($scrit) > 1) {
2669 foreach ($scrit as $crit) {
2673 $sql .=
"(p.ref LIKE '".$this->db->escape($prefix.$crit).
"%' OR p.label LIKE '".$this->
db->escape($prefix.$crit).
"%'";
2674 if (!empty($conf->global->MAIN_MULTILANGS)) {
2675 $sql .=
" OR pl.label LIKE '".$this->db->escape($prefix.$crit).
"%'";
2677 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && ! empty($socid)) {
2678 $sql .=
" OR pcp.ref_customer LIKE '".$this->db->escape($prefix.$crit).
"%'";
2680 if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION)) {
2681 $sql .=
" OR p.description LIKE '".$this->db->escape($prefix.$crit).
"%'";
2682 if (!empty($conf->global->MAIN_MULTILANGS)) {
2683 $sql .=
" OR pl.description LIKE '".$this->db->escape($prefix.$crit).
"%'";
2686 if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) {
2687 $sql .=
" OR pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit).
"%'";
2692 if (count($scrit) > 1) {
2695 if (!empty($conf->barcode->enabled)) {
2696 $sql .=
" OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey).
"%'";
2700 if (count($warehouseStatusArray)) {
2701 $sql .=
" GROUP BY ".$selectFields;
2705 if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) {
2706 $sql .=
" ORDER BY categorie_product_id ";
2708 ($conf->global->PRODUCT_SORT_BY_CATEGORY == 1) ? $sql .=
"ASC" : $sql .=
"DESC";
2710 $sql .= $this->
db->order(
"p.ref");
2713 $sql .= $this->
db->plimit($limit, 0);
2716 dol_syslog(get_class($this).
"::select_produits_list search products", LOG_DEBUG);
2717 $result = $this->
db->query($sql);
2719 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
2720 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
2721 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
2723 $num = $this->
db->num_rows($result);
2728 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
2732 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
2737 if (!empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
2738 if ($showempty && !is_numeric($showempty)) {
2739 $textifempty = $langs->trans($showempty);
2741 $textifempty .= $langs->trans(
"All");
2744 if ($showempty && !is_numeric($showempty)) {
2745 $textifempty = $langs->trans($showempty);
2749 $out .=
'<option value="-1" selected>'.($textifempty ? $textifempty :
' ').
'</option>';
2753 while ($num && $i < $num) {
2756 $objp = $this->
db->fetch_object($result);
2758 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) {
2759 $sql =
"SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type";
2760 $sql .=
" FROM ".$this->db->prefix().
"product_price_by_qty";
2761 $sql .=
" WHERE fk_product_price = ".((int) $objp->price_rowid);
2762 $sql .=
" ORDER BY quantity ASC";
2764 dol_syslog(get_class($this).
"::select_produits_list search prices by qty", LOG_DEBUG);
2765 $result2 = $this->
db->query($sql);
2767 $nb_prices = $this->
db->num_rows($result2);
2769 while ($nb_prices && $j < $nb_prices) {
2770 $objp2 = $this->
db->fetch_object($result2);
2772 $objp->price_by_qty_rowid = $objp2->rowid;
2773 $objp->price_by_qty_price_base_type = $objp2->price_base_type;
2774 $objp->price_by_qty_quantity = $objp2->quantity;
2775 $objp->price_by_qty_unitprice = $objp2->unitprice;
2776 $objp->price_by_qty_remise_percent = $objp2->remise_percent;
2778 $objp->quantity = $objp2->quantity;
2779 $objp->price = $objp2->price;
2780 $objp->unitprice = $objp2->unitprice;
2781 $objp->remise_percent = $objp2->remise_percent;
2794 array_push($outarray, $optJson);
2798 if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression)) {
2799 $price_product =
new Product($this->
db);
2800 $price_product->fetch($objp->rowid,
'',
'', 1);
2802 $price_result = $priceparser->parseProduct($price_product);
2803 if ($price_result >= 0) {
2804 $objp->price = $price_result;
2805 $objp->unitprice = $price_result;
2807 $objp->price_ttc =
price2num($objp->price) * (1 + ($objp->tva_tx / 100));
2808 $objp->price_ttc =
price2num($objp->price_ttc,
'MU');
2817 array_push($outarray, $optJson);
2823 $out .=
'</select>';
2825 $this->
db->free($result);
2827 if (empty($outputmode)) {
2851 protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey =
'', $novirtualstock = 0)
2853 global $langs, $conf, $user;
2859 $outlabel_translated =
'';
2861 $outdesc_translated =
'';
2867 $outpricebasetype =
'';
2869 $outdefault_vat_code =
'';
2873 $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
2875 $label = $objp->label;
2876 if (!empty($objp->label_translated)) {
2877 $label = $objp->label_translated;
2879 if (!empty($filterkey) && $filterkey !=
'') {
2880 $label = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $label, 1);
2883 $outkey = $objp->rowid;
2884 $outref = $objp->ref;
2885 $outrefcust = empty($objp->custref) ?
'' : $objp->custref;
2886 $outlabel = $objp->label;
2887 $outdesc = $objp->description;
2888 if (!empty($conf->global->MAIN_MULTILANGS)) {
2889 $outlabel_translated = $objp->label_translated;
2890 $outdesc_translated = $objp->description_translated;
2892 $outbarcode = $objp->barcode;
2893 $outorigin = $objp->fk_country;
2894 $outpbq = empty($objp->price_by_qty_rowid) ?
'' : $objp->price_by_qty_rowid;
2896 $outtype = $objp->fk_product_type;
2900 if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) {
2901 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
2906 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2907 if (!empty($objp->unit_short)) {
2908 $outvalUnits .=
' - '.$objp->unit_short;
2911 if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) {
2912 if (!empty($objp->weight) && $objp->weight_units !== null) {
2914 $outvalUnits .=
' - '.$unitToShow;
2916 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) {
2917 $unitToShow = $objp->length.
' x '.$objp->width.
' x '.$objp->height.
' '.
measuringUnitString(0,
'size', $objp->length_units);
2918 $outvalUnits .=
' - '.$unitToShow;
2920 if (!empty($objp->surface) && $objp->surface_units !== null) {
2922 $outvalUnits .=
' - '.$unitToShow;
2924 if (!empty($objp->volume) && $objp->volume_units !== null) {
2926 $outvalUnits .=
' - '.$unitToShow;
2929 if ($outdurationvalue && $outdurationunit) {
2931 'h' => $langs->trans(
'Hour'),
2932 'd' => $langs->trans(
'Day'),
2933 'w' => $langs->trans(
'Week'),
2934 'm' => $langs->trans(
'Month'),
2935 'y' => $langs->trans(
'Year')
2937 if (isset($da[$outdurationunit])) {
2938 $outvalUnits .=
' - '.$outdurationvalue.
' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ?
's' :
''));
2942 $opt =
'<option value="'.$objp->rowid.
'"';
2943 $opt .= ($objp->rowid == $selected) ?
' selected' :
'';
2944 if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) {
2945 $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.
'"';
2947 if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
2948 if (!empty($user->rights->stock->lire)) {
2949 if ($objp->stock > 0) {
2950 $opt .=
' class="product_line_stock_ok"';
2951 } elseif ($objp->stock <= 0) {
2952 $opt .=
' class="product_line_stock_too_low"';
2956 if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
2957 $opt .=
' data-labeltrans="'.$outlabel_translated.
'"';
2958 $opt .=
' data-desctrans="'.dol_escape_htmltag($outdesc_translated).
'"';
2962 if (! empty($objp->custref)) {
2963 $opt.=
' (' . $objp->custref .
')';
2966 $opt .=
' ('.$outbarcode.
')';
2968 $opt .=
' - '.dol_trunc($label, $maxlengtharticle);
2969 if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) {
2970 $opt .=
' ('.getCountry($outorigin, 1).
')';
2973 $objRef = $objp->ref;
2974 if (! empty($objp->custref)) {
2975 $objRef .=
' (' . $objp->custref .
')';
2977 if (!empty($filterkey) && $filterkey !=
'') {
2978 $objRef = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $objRef, 1);
2982 $outval .=
' ('.$outbarcode.
')';
2984 $outval .=
' - '.dol_trunc($label, $maxlengtharticle);
2985 if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) {
2986 $outval .=
' ('.getCountry($outorigin, 1).
')';
2990 $opt .= $outvalUnits;
2991 $outval .= $outvalUnits;
2997 if (empty($hidepriceinlabel) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
2998 $sql =
"SELECT price, price_ttc, price_base_type, tva_tx, default_vat_code";
2999 $sql .=
" FROM ".$this->db->prefix().
"product_price";
3000 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
3001 $sql .=
" AND entity IN (".getEntity(
'productprice').
")";
3002 $sql .=
" AND price_level = ".((int) $price_level);
3003 $sql .=
" ORDER BY date_price DESC, rowid DESC";
3006 dol_syslog(get_class($this).
'::constructProductListOption search price for product '.$objp->rowid.
' AND level '.$price_level.
'', LOG_DEBUG);
3007 $result2 = $this->
db->query($sql);
3009 $objp2 = $this->
db->fetch_object($result2);
3012 if ($objp2->price_base_type ==
'HT') {
3013 $opt .=
' - '.price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"HT");
3014 $outval .=
' - '.price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"HT");
3016 $opt .=
' - '.price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"TTC");
3017 $outval .=
' - '.price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"TTC");
3019 $outprice_ht =
price($objp2->price);
3020 $outprice_ttc =
price($objp2->price_ttc);
3021 $outpricebasetype = $objp2->price_base_type;
3022 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
3023 $outtva_tx = $objp2->tva_tx;
3024 $outdefault_vat_code = $objp2->default_vat_code;
3026 $outtva_tx = $objp->tva_tx;
3027 $outdefault_vat_code = $objp->default_vat_code;
3036 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))) {
3038 $outqty = $objp->quantity;
3039 $outdiscount = $objp->remise_percent;
3040 if ($objp->quantity == 1) {
3041 $opt .=
' - '.price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency).
"/";
3042 $outval .=
' - '.price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency).
"/";
3043 $opt .= $langs->trans(
"Unit");
3044 $outval .= $langs->transnoentities(
"Unit");
3046 $opt .=
' - '.price($objp->price, 1, $langs, 0, 0, -1, $conf->currency).
"/".$objp->quantity;
3047 $outval .=
' - '.price($objp->price, 0, $langs, 0, 0, -1, $conf->currency).
"/".$objp->quantity;
3048 $opt .= $langs->trans(
"Units");
3049 $outval .= $langs->transnoentities(
"Units");
3052 $outprice_ht =
price($objp->unitprice);
3053 $outprice_ttc =
price($objp->unitprice * (1 + ($objp->tva_tx / 100)));
3054 $outpricebasetype = $objp->price_base_type;
3055 $outtva_tx = $objp->tva_tx;
3056 $outdefault_vat_code = $objp->default_vat_code;
3058 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1) {
3059 $opt .=
" (".price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency).
"/".$langs->trans(
"Unit").
")";
3060 $outval .=
" (".price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency).
"/".$langs->transnoentities(
"Unit").
")";
3062 if (empty($hidepriceinlabel) && !empty($objp->remise_percent) && $objp->remise_percent >= 1) {
3063 $opt .=
" - ".$langs->trans(
"Discount").
" : ".
vatrate($objp->remise_percent).
' %';
3064 $outval .=
" - ".$langs->transnoentities(
"Discount").
" : ".
vatrate($objp->remise_percent).
' %';
3068 if (empty($hidepriceinlabel) && !empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
3069 if (!empty($objp->idprodcustprice)) {
3072 if ($objp->custprice_base_type ==
'HT') {
3073 $opt .=
' - '.price($objp->custprice, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"HT");
3074 $outval .=
' - '.price($objp->custprice, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"HT");
3076 $opt .=
' - '.price($objp->custprice_ttc, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"TTC");
3077 $outval .=
' - '.price($objp->custprice_ttc, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"TTC");
3080 $outprice_ht =
price($objp->custprice);
3081 $outprice_ttc =
price($objp->custprice_ttc);
3082 $outpricebasetype = $objp->custprice_base_type;
3083 $outtva_tx = $objp->custtva_tx;
3084 $outdefault_vat_code = $objp->custdefault_vat_code;
3089 if (empty($hidepriceinlabel) && !$found) {
3090 if ($objp->price_base_type ==
'HT') {
3091 $opt .=
' - '.price($objp->price, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"HT");
3092 $outval .=
' - '.price($objp->price, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"HT");
3094 $opt .=
' - '.price($objp->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"TTC");
3095 $outval .=
' - '.price($objp->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"TTC");
3097 $outprice_ht =
price($objp->price);
3098 $outprice_ttc =
price($objp->price_ttc);
3099 $outpricebasetype = $objp->price_base_type;
3100 $outtva_tx = $objp->tva_tx;
3101 $outdefault_vat_code = $objp->default_vat_code;
3104 if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
3105 if (!empty($user->rights->stock->lire)) {
3106 $opt .=
' - '.$langs->trans(
"Stock").
': '.
price(
price2num($objp->stock,
'MS'));
3108 if ($objp->stock > 0) {
3109 $outval .=
' - <span class="product_line_stock_ok">';
3110 } elseif ($objp->stock <= 0) {
3111 $outval .=
' - <span class="product_line_stock_too_low">';
3113 $outval .= $langs->transnoentities(
"Stock").
': '.
price(
price2num($objp->stock,
'MS'));
3114 $outval .=
'</span>';
3115 if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) {
3116 $langs->load(
"stocks");
3119 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3120 $tmpproduct->load_virtual_stock();
3121 $virtualstock = $tmpproduct->stock_theorique;
3123 $opt .=
' - '.$langs->trans(
"VirtualStock").
':'.$virtualstock;
3125 $outval .=
' - '.$langs->transnoentities(
"VirtualStock").
':';
3126 if ($virtualstock > 0) {
3127 $outval .=
'<span class="product_line_stock_ok">';
3128 } elseif ($virtualstock <= 0) {
3129 $outval .=
'<span class="product_line_stock_too_low">';
3131 $outval .= $virtualstock;
3132 $outval .=
'</span>';
3139 $opt .=
"</option>\n";
3144 'label2'=>$outlabel,
3149 'pricebasetype'=>$outpricebasetype,
3150 'tva_tx'=>$outtva_tx,
3151 'default_vat_code'=>$outdefault_vat_code,
3153 'discount'=>$outdiscount,
3154 'duration_value'=>$outdurationvalue,
3155 'duration_unit'=>$outdurationunit,
3157 'labeltrans'=>$outlabel_translated,
3158 'desctrans'=>$outdesc_translated,
3159 'ref_customer'=>$outrefcust
3179 public function select_produits_fournisseurs($socid, $selected =
'', $htmlname =
'productid', $filtertype =
'', $filtre =
'', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss =
'', $placeholder =
'')
3182 global $langs, $conf;
3183 global $price_level, $status, $finished;
3185 if (!isset($status)) {
3189 $selected_input_value =
'';
3190 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
3191 if ($selected > 0) {
3192 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
3193 $producttmpselect =
new Product($this->
db);
3194 $producttmpselect->fetch($selected);
3195 $selected_input_value = $producttmpselect->ref;
3196 unset($producttmpselect);
3200 $urloption = ($socid > 0 ?
'socid='.$socid.
'&' :
'').
'htmlname='.$htmlname.
'&outjson=1&price_level='.$price_level.
'&type='.$filtertype.
'&mode=2&status='.$status.
'&finished='.$finished.
'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice;
3201 print
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
3202 print ($hidelabel ?
'' : $langs->trans(
"RefOrLabel").
' : ').
'<input type="text" class="minwidth300" name="search_'.$htmlname.
'" id="search_'.$htmlname.
'" value="'.$selected_input_value.
'"'.($placeholder ?
' placeholder="'.$placeholder.
'"' :
'').
'>';
3204 print $this->
select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre,
'', $status, 0, 0, $alsoproductwithnosupplierprice, $morecss, 0, $placeholder);
3227 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 =
'')
3230 global $langs, $conf, $user;
3231 global $hookmanager;
3234 $outarray = array();
3236 $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
3238 $langs->load(
'stocks');
3240 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
3241 $langs->load(
'other');
3244 $sql =
"SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type, p.stock,";
3245 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
3246 $sql .=
" pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.default_vat_code, pfp.fk_soc, s.nom as name,";
3247 $sql .=
" pfp.supplier_reputation";
3249 if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) {
3250 $sql .=
" ,pfp.desc_fourn as description";
3252 $sql .=
" ,p.description";
3255 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
3256 $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";
3258 if (!empty($conf->barcode->enabled)) {
3259 $sql .=
", pfp.barcode";
3261 $sql .=
" FROM ".$this->db->prefix().
"product as p";
3262 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (".
getEntity(
'product').
") )";
3264 $sql .=
" AND pfp.fk_soc = ".((int) $socid);
3266 $sql .=
" LEFT JOIN ".$this->db->prefix().
"societe as s ON pfp.fk_soc = s.rowid";
3268 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
3269 $sql .=
" LEFT JOIN ".$this->db->prefix().
"c_units u ON u.rowid = p.fk_unit";
3271 $sql .=
" WHERE p.entity IN (".getEntity(
'product').
")";
3272 if ($statut != -1) {
3273 $sql .=
" AND p.tobuy = ".((int) $statut);
3275 if (strval($filtertype) !=
'') {
3276 $sql .=
" AND p.fk_product_type = ".((int) $filtertype);
3278 if (!empty($filtre)) {
3279 $sql .=
" ".$filtre;
3282 $parameters = array();
3283 $reshook = $hookmanager->executeHooks(
'selectSuppliersProductsListWhere', $parameters);
3284 $sql .= $hookmanager->resPrint;
3286 if ($filterkey !=
'') {
3288 $prefix = empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE) ?
'%' :
'';
3290 $scrit = explode(
' ', $filterkey);
3292 if (count($scrit) > 1) {
3295 foreach ($scrit as $crit) {
3299 $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).
"%'";
3300 if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) {
3301 $sql .=
" OR pfp.desc_fourn LIKE '".$this->db->escape($prefix.$crit).
"%'";
3306 if (count($scrit) > 1) {
3309 if (!empty($conf->barcode->enabled)) {
3310 $sql .=
" OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey).
"%'";
3311 $sql .=
" OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey).
"%'";
3315 $sql .=
" ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
3316 $sql .= $this->
db->plimit($limit, 0);
3320 dol_syslog(get_class($this).
"::select_produits_fournisseurs_list", LOG_DEBUG);
3321 $result = $this->
db->query($sql);
3323 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
3324 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
3326 $num = $this->
db->num_rows($result);
3329 $out .=
'<select class="flat '.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.
'">';
3331 $out .=
'<option value="-1" selected>'.($placeholder ? $placeholder :
' ').
'</option>';
3333 $out .=
'<option value="-1">'.($placeholder ? $placeholder :
' ').
'</option>';
3338 $objp = $this->
db->fetch_object($result);
3340 $outkey = $objp->idprodfournprice;
3341 if (!$outkey && $alsoproductwithnosupplierprice) {
3342 $outkey =
'idprod_'.$objp->rowid;
3345 $outref = $objp->ref;
3347 $outbarcode = $objp->barcode;
3350 $outtype = $objp->fk_product_type;
3356 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
3357 if (!empty($objp->unit_short)) {
3358 $outvalUnits .=
' - '.$objp->unit_short;
3360 if (!empty($objp->weight) && $objp->weight_units !== null) {
3362 $outvalUnits .=
' - '.$unitToShow;
3364 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) {
3365 $unitToShow = $objp->length.
' x '.$objp->width.
' x '.$objp->height.
' '.
measuringUnitString(0,
'size', $objp->length_units);
3366 $outvalUnits .=
' - '.$unitToShow;
3368 if (!empty($objp->surface) && $objp->surface_units !== null) {
3370 $outvalUnits .=
' - '.$unitToShow;
3372 if (!empty($objp->volume) && $objp->volume_units !== null) {
3374 $outvalUnits .=
' - '.$unitToShow;
3376 if ($outdurationvalue && $outdurationunit) {
3378 'h' => $langs->trans(
'Hour'),
3379 'd' => $langs->trans(
'Day'),
3380 'w' => $langs->trans(
'Week'),
3381 'm' => $langs->trans(
'Month'),
3382 'y' => $langs->trans(
'Year')
3384 if (isset($da[$outdurationunit])) {
3385 $outvalUnits .=
' - '.$outdurationvalue.
' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ?
's' :
''));
3390 $objRef = $objp->ref;
3391 if ($filterkey && $filterkey !=
'') {
3392 $objRef = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $objRef, 1);
3394 $objRefFourn = $objp->ref_fourn;
3395 if ($filterkey && $filterkey !=
'') {
3396 $objRefFourn = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $objRefFourn, 1);
3398 $label = $objp->label;
3399 if ($filterkey && $filterkey !=
'') {
3400 $label = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $label, 1);
3403 $optlabel = $objp->ref;
3404 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
3405 $optlabel .=
' <span class="opacitymedium">('.$objp->ref_fourn.
')</span>';
3407 if (!empty($conf->barcode->enabled) && !empty($objp->barcode)) {
3408 $optlabel .=
' ('.$outbarcode.
')';
3410 $optlabel .=
' - '.dol_trunc($label, $maxlengtharticle);
3412 $outvallabel = $objRef;
3413 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
3414 $outvallabel .=
' ('.$objRefFourn.
')';
3416 if (!empty($conf->barcode->enabled) && !empty($objp->barcode)) {
3417 $outvallabel .=
' ('.$outbarcode.
')';
3419 $outvallabel .=
' - '.dol_trunc($label, $maxlengtharticle);
3422 $optlabel .= $outvalUnits;
3423 $outvallabel .= $outvalUnits;
3425 if (!empty($objp->idprodfournprice)) {
3426 $outqty = $objp->quantity;
3427 $outdiscount = $objp->remise_percent;
3428 if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_supplier_price_expression)) {
3430 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
3431 $prod_supplier->id = $objp->fk_product;
3432 $prod_supplier->fourn_qty = $objp->quantity;
3433 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
3434 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
3436 $price_result = $priceparser->parseProductSupplier($prod_supplier);
3437 if ($price_result >= 0) {
3438 $objp->fprice = $price_result;
3439 if ($objp->quantity >= 1) {
3440 $objp->unitprice = $objp->fprice / $objp->quantity;
3444 if ($objp->quantity == 1) {
3445 $optlabel .=
' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency).
"/";
3446 $outvallabel .=
' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency).
"/";
3447 $optlabel .= $langs->trans(
"Unit");
3448 $outvallabel .= $langs->transnoentities(
"Unit");
3450 $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;
3451 $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;
3452 $optlabel .=
' '.$langs->trans(
"Units");
3453 $outvallabel .=
' '.$langs->transnoentities(
"Units");
3456 if ($objp->quantity > 1) {
3457 $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").
")";
3458 $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").
")";
3460 if ($objp->remise_percent >= 1) {
3461 $optlabel .=
" - ".$langs->trans(
"Discount").
" : ".
vatrate($objp->remise_percent).
' %';
3462 $outvallabel .=
" - ".$langs->transnoentities(
"Discount").
" : ".
vatrate($objp->remise_percent).
' %';
3464 if ($objp->duration) {
3465 $optlabel .=
" - ".$objp->duration;
3466 $outvallabel .=
" - ".$objp->duration;
3469 $optlabel .=
" - ".dol_trunc($objp->name, 8);
3470 $outvallabel .=
" - ".dol_trunc($objp->name, 8);
3472 if ($objp->supplier_reputation) {
3474 $reputations = array(
''=>$langs->trans(
'Standard'),
'FAVORITE'=>$langs->trans(
'Favorite'),
'NOTTHGOOD'=>$langs->trans(
'NotTheGoodQualitySupplier'),
'DONOTORDER'=>$langs->trans(
'DoNotOrderThisProductToThisSupplier'));
3476 $optlabel .=
" - ".$reputations[$objp->supplier_reputation];
3477 $outvallabel .=
" - ".$reputations[$objp->supplier_reputation];
3480 if (empty($alsoproductwithnosupplierprice)) {
3481 $optlabel .=
" - <span class='opacitymedium'>".$langs->trans(
"NoPriceDefinedForThisSupplier").
'</span>';
3482 $outvallabel .=
' - '.$langs->transnoentities(
"NoPriceDefinedForThisSupplier");
3485 $optlabel .=
" - <span class='opacitymedium'>".$langs->trans(
"NoPriceDefinedForThisSupplier").
'</span>';
3486 $outvallabel .=
' - '.$langs->transnoentities(
"NoPriceDefinedForThisSupplier");
3490 if (!empty($conf->stock->enabled) && $showstockinlist && isset($objp->stock) && ($objp->fk_product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
3491 $novirtualstock = ($showstockinlist == 2);
3493 if (!empty($user->rights->stock->lire)) {
3494 $outvallabel .=
' - '.$langs->trans(
"Stock").
': '.
price(
price2num($objp->stock,
'MS'));
3496 if ($objp->stock > 0) {
3497 $optlabel .=
' - <span class="product_line_stock_ok">';
3498 } elseif ($objp->stock <= 0) {
3499 $optlabel .=
' - <span class="product_line_stock_too_low">';
3501 $optlabel .= $langs->transnoentities(
"Stock").
':'.
price(
price2num($objp->stock,
'MS'));
3502 $optlabel .=
'</span>';
3503 if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) {
3504 $langs->load(
"stocks");
3507 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3508 $tmpproduct->load_virtual_stock();
3509 $virtualstock = $tmpproduct->stock_theorique;
3511 $outvallabel .=
' - '.$langs->trans(
"VirtualStock").
':'.$virtualstock;
3513 $optlabel .=
' - '.$langs->transnoentities(
"VirtualStock").
':';
3514 if ($virtualstock > 0) {
3515 $optlabel .=
'<span class="product_line_stock_ok">';
3516 } elseif ($virtualstock <= 0) {
3517 $optlabel .=
'<span class="product_line_stock_too_low">';
3519 $optlabel .= $virtualstock;
3520 $optlabel .=
'</span>';
3527 $opt =
'<option value="'.$outkey.
'"';
3528 if ($selected && $selected == $objp->idprodfournprice) {
3529 $opt .=
' selected';
3531 if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) {
3532 $opt .=
' disabled';
3534 if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
3535 $opt .=
' data-product-id="'.$objp->rowid.
'" data-price-id="'.$objp->idprodfournprice.
'" data-qty="'.$objp->quantity.
'" data-up="'.$objp->unitprice.
'" data-discount="'.$outdiscount.
'" data-tvatx="'.$objp->tva_tx.
'"';
3537 $opt .=
' data-description="'.dol_escape_htmltag($objp->description, 0, 1).
'"';
3538 $opt .=
' data-html="'.dol_escape_htmltag($optlabel).
'"';
3542 $outval .= $outvallabel;
3544 $opt .=
"</option>\n";
3552 array(
'key'=>$outkey,
3556 'price_qty_ht'=>
price2num($objp->fprice,
'MU'),
3557 'price_unit_ht'=>
price2num($objp->unitprice,
'MU'),
3558 'price_ht'=>
price2num($objp->unitprice,
'MU'),
3559 'tva_tx'=>$objp->tva_tx,
3560 'default_vat_code'=>$objp->default_vat_code,
3561 'discount'=>$outdiscount,
3563 'duration_value'=>$outdurationvalue,
3564 'duration_unit'=>$outdurationunit,
3565 'disabled'=>(empty($objp->idprodfournprice) ?
true :
false),
3566 'description'=>$objp->description
3580 $out .=
'</select>';
3582 $this->
db->free($result);
3584 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
3587 if (empty($outputmode)) {
3608 global $langs, $conf;
3610 $langs->load(
'stocks');
3612 $sql =
"SELECT p.rowid, p.ref, p.label, p.price, p.duration, pfp.fk_soc,";
3613 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,";
3614 $sql .=
" pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name";
3615 $sql .=
" FROM ".$this->db->prefix().
"product as p";
3616 $sql .=
" LEFT JOIN ".$this->db->prefix().
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
3617 $sql .=
" LEFT JOIN ".$this->db->prefix().
"societe as s ON pfp.fk_soc = s.rowid";
3618 $sql .=
" WHERE pfp.entity IN (".getEntity(
'productsupplierprice').
")";
3619 $sql .=
" AND p.tobuy = 1";
3620 $sql .=
" AND s.fournisseur = 1";
3621 $sql .=
" AND p.rowid = ".((int) $productid);
3622 $sql .=
" ORDER BY s.nom, pfp.ref_fourn DESC";
3624 dol_syslog(get_class($this).
"::select_product_fourn_price", LOG_DEBUG);
3625 $result = $this->
db->query($sql);
3628 $num = $this->
db->num_rows($result);
3630 $form =
'<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
3633 $form .=
'<option value="0">-- '.$langs->trans(
"NoSupplierPriceDefinedForThisProduct").
' --</option>';
3635 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
3636 $form .=
'<option value="0"> </option>';
3640 $objp = $this->
db->fetch_object($result);
3642 $opt =
'<option value="'.$objp->idprodfournprice.
'"';
3644 if ($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier)) {
3645 $opt .=
' selected';
3647 $opt .=
'>'.$objp->name.
' - '.$objp->ref_fourn.
' - ';
3649 if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_supplier_price_expression)) {
3651 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
3652 $prod_supplier->id = $productid;
3653 $prod_supplier->fourn_qty = $objp->quantity;
3654 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
3655 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
3657 $price_result = $priceparser->parseProductSupplier($prod_supplier);
3658 if ($price_result >= 0) {
3659 $objp->fprice = $price_result;
3660 if ($objp->quantity >= 1) {
3661 $objp->unitprice = $objp->fprice / $objp->quantity;
3665 if ($objp->quantity == 1) {
3666 $opt .=
price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency).
"/";
3669 $opt .= $objp->quantity.
' ';
3671 if ($objp->quantity == 1) {
3672 $opt .= $langs->trans(
"Unit");
3674 $opt .= $langs->trans(
"Units");
3676 if ($objp->quantity > 1) {
3678 $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");
3680 if ($objp->duration) {
3681 $opt .=
" - ".$objp->duration;
3683 $opt .=
"</option>\n";
3690 $form .=
'</select>';
3691 $this->
db->free($result);
3708 public function select_address($selected, $socid, $htmlname =
'address_id', $showempty = 0)
3712 $sql =
"SELECT a.rowid, a.label";
3713 $sql .=
" FROM ".$this->db->prefix().
"societe_address as a";
3714 $sql .=
" WHERE a.fk_soc = ".((int) $socid);
3715 $sql .=
" ORDER BY a.label ASC";
3717 dol_syslog(get_class($this).
"::select_address", LOG_DEBUG);
3720 print
'<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
3722 print
'<option value="0"> </option>';
3724 $num = $this->
db->num_rows(
$resql);
3728 $obj = $this->
db->fetch_object(
$resql);
3730 if ($selected && $selected == $obj->rowid) {
3731 print
'<option value="'.$obj->rowid.
'" selected>'.$obj->label.
'</option>';
3733 print
'<option value="'.$obj->rowid.
'">'.$obj->label.
'</option>';
3756 $num = count($this->cache_conditions_paiements);
3763 $sql =
"SELECT rowid, code, libelle as label, deposit_percent";
3764 $sql .=
" FROM ".$this->db->prefix().
'c_payment_term';
3765 $sql .=
" WHERE entity IN (".getEntity(
'c_payment_term').
")";
3766 $sql .=
" AND active > 0";
3767 $sql .=
" ORDER BY sortorder";
3771 $num = $this->
db->num_rows(
$resql);
3774 $obj = $this->
db->fetch_object(
$resql);
3777 $label = ($langs->trans(
"PaymentConditionShort".$obj->code) != (
"PaymentConditionShort".$obj->code) ? $langs->trans(
"PaymentConditionShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
3778 $this->cache_conditions_paiements[$obj->rowid][
'code'] = $obj->code;
3779 $this->cache_conditions_paiements[$obj->rowid][
'label'] = $label;
3780 $this->cache_conditions_paiements[$obj->rowid][
'deposit_percent'] = $obj->deposit_percent;
3804 $num = count($this->cache_availability);
3811 $langs->load(
'propal');
3813 $sql =
"SELECT rowid, code, label, position";
3814 $sql .=
" FROM ".$this->db->prefix().
'c_availability';
3815 $sql .=
" WHERE active > 0";
3819 $num = $this->
db->num_rows(
$resql);
3822 $obj = $this->
db->fetch_object(
$resql);
3825 $label = ($langs->trans(
"AvailabilityType".$obj->code) != (
"AvailabilityType".$obj->code) ? $langs->trans(
"AvailabilityType".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
3826 $this->cache_availability[$obj->rowid][
'code'] = $obj->code;
3827 $this->cache_availability[$obj->rowid][
'label'] = $label;
3828 $this->cache_availability[$obj->rowid][
'position'] = $obj->position;
3832 $this->cache_availability =
dol_sort_array($this->cache_availability,
'position',
'asc', 0, 0, 1);
3853 global $langs, $user;
3857 dol_syslog(__METHOD__.
" selected=".$selected.
", htmlname=".$htmlname, LOG_DEBUG);
3859 print
'<select id="'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
3861 print
'<option value="0"> </option>';
3863 foreach ($this->cache_availability as $id => $arrayavailability) {
3864 if ($selected == $id) {
3865 print
'<option value="'.$id.
'" selected>';
3867 print
'<option value="'.$id.
'">';
3874 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3888 $num = count($this->cache_demand_reason);
3893 $sql =
"SELECT rowid, code, label";
3894 $sql .=
" FROM ".$this->db->prefix().
'c_input_reason';
3895 $sql .=
" WHERE active > 0";
3899 $num = $this->
db->num_rows(
$resql);
3901 $tmparray = array();
3903 $obj = $this->
db->fetch_object(
$resql);
3906 $label = ($obj->label !=
'-' ? $obj->label :
'');
3907 if ($langs->trans(
"DemandReasonType".$obj->code) != (
"DemandReasonType".$obj->code)) {
3908 $label = $langs->trans(
"DemandReasonType".$obj->code);
3910 if ($langs->trans($obj->code) != $obj->code) {
3911 $label = $langs->trans($obj->code);
3914 $tmparray[$obj->rowid][
'id'] = $obj->rowid;
3915 $tmparray[$obj->rowid][
'code'] = $obj->code;
3916 $tmparray[$obj->rowid][
'label'] = $label;
3920 $this->cache_demand_reason =
dol_sort_array($tmparray,
'label',
'asc', 0, 0, 1);
3942 public function selectInputReason($selected =
'', $htmlname =
'demandreasonid', $exclude =
'', $addempty = 0, $morecss =
'', $notooltip = 0)
3944 global $langs, $user;
3948 print
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
3950 print
'<option value="0"'.(empty($selected) ?
' selected' :
'').
'> </option>';
3952 foreach ($this->cache_demand_reason as $id => $arraydemandreason) {
3953 if ($arraydemandreason[
'code'] == $exclude) {
3957 if ($selected && ($selected == $arraydemandreason[
'id'] || $selected == $arraydemandreason[
'code'])) {
3958 print
'<option value="'.$arraydemandreason[
'id'].
'" selected>';
3960 print
'<option value="'.$arraydemandreason[
'id'].
'">';
3962 $label = $arraydemandreason[
'label'];
3963 print $langs->trans($label);
3967 if ($user->admin && empty($notooltip)) {
3968 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3984 $num = count($this->cache_types_paiements);
3991 $this->cache_types_paiements = array();
3993 $sql =
"SELECT id, code, libelle as label, type, active";
3994 $sql .=
" FROM ".$this->db->prefix().
"c_paiement";
3995 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
3999 $num = $this->
db->num_rows(
$resql);
4002 $obj = $this->
db->fetch_object(
$resql);
4005 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort".$obj->code) != (
"PaymentTypeShort".$obj->code) ? $langs->transnoentitiesnoconv(
"PaymentTypeShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4006 $this->cache_types_paiements[$obj->id][
'id'] = $obj->id;
4007 $this->cache_types_paiements[$obj->id][
'code'] = $obj->code;
4008 $this->cache_types_paiements[$obj->id][
'label'] = $label;
4009 $this->cache_types_paiements[$obj->id][
'type'] = $obj->type;
4010 $this->cache_types_paiements[$obj->id][
'active'] = $obj->active;
4014 $this->cache_types_paiements =
dol_sort_array($this->cache_types_paiements,
'label',
'asc', 0, 0, 1);
4041 public function select_conditions_paiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1)
4044 print $this->
getSelectConditionsPaiements($selected, $htmlname, $filtertype, $addempty, $noinfoadmin, $morecss, $deposit_percent = -1);
4064 public function getSelectConditionsPaiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1)
4066 global $langs, $user, $conf;
4069 dol_syslog(__METHOD__.
" selected=".$selected.
", htmlname=".$htmlname, LOG_DEBUG);
4074 if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) {
4075 $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID;
4078 $out.=
'<select id="'.$htmlname.
'" class="flat selectpaymentterms'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
4080 $out.=
'<option value="0"> </option>';
4083 $selectedDepositPercent = null;
4085 foreach ($this->cache_conditions_paiements as $id => $arrayconditions) {
4086 if ($filtertype <= 0 && ! empty($arrayconditions[
'deposit_percent'])) {
4090 if ($selected == $id) {
4091 $selectedDepositPercent = $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'];
4092 $out .=
'<option value="'.$id.
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'" selected>';
4094 $out .=
'<option value="'.$id.
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'">';
4096 $label = $arrayconditions[
'label'];
4098 if (! empty($arrayconditions[
'deposit_percent'])) {
4099 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'], $label);
4106 if ($user->admin && empty($noinfoadmin)) {
4107 $out.=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4111 if ($deposit_percent >= 0) {
4112 $out .=
' <span id="'.$htmlname.
'_deposit_percent_container"' . (empty($selectedDepositPercent) ?
' style="display: none"' :
'') .
'>';
4113 $out .= $langs->trans(
'DepositPercent') .
' : ';
4114 $out .=
'<input id="'.$htmlname.
'_deposit_percent" name="'.$htmlname.
'_deposit_percent" class="maxwidth50" value="' . strval($deposit_percent) .
'" />';
4118 $(document).ready(function () {
4119 $("#' . $htmlname .
'").change(function () {
4120 let $selected = $(this).find("option:selected");
4121 let depositPercent = $selected.attr("data-deposit_percent");
4123 if (depositPercent.length > 0) {
4124 $("#'.$htmlname.
'_deposit_percent_container").show().find("#'.$htmlname.
'_deposit_percent").val(depositPercent);
4126 $("#'.$htmlname.
'_deposit_percent_container").hide();
4156 public function select_types_paiements($selected =
'', $htmlname =
'paiementtype', $filtertype =
'', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'', $nooutput = 0)
4159 global $langs, $user, $conf;
4163 dol_syslog(__METHOD__.
" ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
4165 $filterarray = array();
4166 if ($filtertype ==
'CRDT') {
4167 $filterarray = array(0, 2, 3);
4168 } elseif ($filtertype ==
'DBIT') {
4169 $filterarray = array(1, 2, 3);
4170 } elseif ($filtertype !=
'' && $filtertype !=
'-1') {
4171 $filterarray = explode(
',', $filtertype);
4177 if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID)) {
4178 $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID;
4181 $out .=
'<select id="select'.$htmlname.
'" class="flat selectpaymenttypes'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
4183 $out .=
'<option value=""> </option>';
4185 foreach ($this->cache_types_paiements as $id => $arraytypes) {
4187 if ($active >= 0 && $arraytypes[
'active'] != $active) {
4192 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
4197 if ($empty && empty($arraytypes[
'code'])) {
4202 $out .=
'<option value="'.$id.
'"';
4203 } elseif ($format == 1) {
4204 $out .=
'<option value="'.$arraytypes[
'code'].
'"';
4205 } elseif ($format == 2) {
4206 $out .=
'<option value="'.$arraytypes[
'code'].
'"';
4207 } elseif ($format == 3) {
4208 $out .=
'<option value="'.$id.
'"';
4211 if ($format == 1 || $format == 2) {
4212 if ($selected == $arraytypes[
'code']) {
4213 $out .=
' selected';
4216 if ($selected == $id) {
4217 $out .=
' selected';
4223 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4224 } elseif ($format == 1) {
4225 $value = $arraytypes[
'code'];
4226 } elseif ($format == 2) {
4227 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4228 } elseif ($format == 3) {
4229 $value = $arraytypes[
'code'];
4231 $out .= $value ? $value :
' ';
4232 $out .=
'</option>';
4234 $out .=
'</select>';
4235 if ($user->admin && !$noadmininfo) {
4236 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4240 if (empty($nooutput)) {
4260 $return =
'<select class="flat maxwidth100" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
4262 'HT'=>$langs->trans(
"HT"),
4263 'TTC'=>$langs->trans(
"TTC")
4265 foreach ($options as $id => $value) {
4266 if ($selected == $id) {
4267 $return .=
'<option value="'.$id.
'" selected>'.$value;
4269 $return .=
'<option value="'.$id.
'">'.$value;
4271 $return .=
'</option>';
4273 $return .=
'</select>';
4292 $num = count($this->cache_transport_mode);
4299 $this->cache_transport_mode = array();
4301 $sql =
"SELECT rowid, code, label, active";
4302 $sql .=
" FROM ".$this->db->prefix().
"c_transport_mode";
4303 $sql .=
" WHERE entity IN (".getEntity(
'c_transport_mode').
")";
4307 $num = $this->
db->num_rows(
$resql);
4310 $obj = $this->
db->fetch_object(
$resql);
4313 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort".$obj->code) != (
"PaymentTypeShort".$obj->code) ? $langs->transnoentitiesnoconv(
"PaymentTypeShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4314 $this->cache_transport_mode[$obj->rowid][
'rowid'] = $obj->rowid;
4315 $this->cache_transport_mode[$obj->rowid][
'code'] = $obj->code;
4316 $this->cache_transport_mode[$obj->rowid][
'label'] = $label;
4317 $this->cache_transport_mode[$obj->rowid][
'active'] = $obj->active;
4321 $this->cache_transport_mode =
dol_sort_array($this->cache_transport_mode,
'label',
'asc', 0, 0, 1);
4343 public function selectTransportMode($selected =
'', $htmlname =
'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'')
4345 global $langs, $user;
4347 dol_syslog(__METHOD__.
" ".$selected.
", ".$htmlname.
", ".$format, LOG_DEBUG);
4351 print
'<select id="select'.$htmlname.
'" class="flat selectmodetransport'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
4353 print
'<option value=""> </option>';
4355 foreach ($this->cache_transport_mode as $id => $arraytypes) {
4357 if ($active >= 0 && $arraytypes[
'active'] != $active) {
4362 if ($empty && empty($arraytypes[
'code'])) {
4367 print
'<option value="'.$id.
'"';
4368 } elseif ($format == 1) {
4369 print
'<option value="'.$arraytypes[
'code'].
'"';
4370 } elseif ($format == 2) {
4371 print
'<option value="'.$arraytypes[
'code'].
'"';
4372 } elseif ($format == 3) {
4373 print
'<option value="'.$id.
'"';
4376 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraytypes[
'code']) {
4378 } elseif ($selected == $id) {
4384 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4385 } elseif ($format == 1) {
4386 $value = $arraytypes[
'code'];
4387 } elseif ($format == 2) {
4388 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4389 } elseif ($format == 3) {
4390 $value = $arraytypes[
'code'];
4392 print $value ? $value :
' ';
4396 if ($user->admin && !$noadmininfo) {
4397 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4413 public function selectShippingMethod($selected =
'', $htmlname =
'shipping_method_id', $filtre =
'', $useempty = 0, $moreattrib =
'', $noinfoadmin = 0, $morecss =
'')
4415 global $langs, $conf, $user;
4417 $langs->load(
"admin");
4418 $langs->load(
"deliveries");
4420 $sql =
"SELECT rowid, code, libelle as label";
4421 $sql .=
" FROM ".$this->db->prefix().
"c_shipment_mode";
4422 $sql .=
" WHERE active > 0";
4424 $sql .=
" AND ".$filtre;
4426 $sql .=
" ORDER BY libelle ASC";
4428 dol_syslog(get_class($this).
"::selectShippingMode", LOG_DEBUG);
4429 $result = $this->
db->query($sql);
4431 $num = $this->
db->num_rows($result);
4434 print
'<select id="select'.$htmlname.
'" class="flat selectshippingmethod'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
4435 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
4436 print
'<option value="-1"> </option>';
4439 $obj = $this->
db->fetch_object($result);
4440 if ($selected == $obj->rowid) {
4441 print
'<option value="'.$obj->rowid.
'" selected>';
4443 print
'<option value="'.$obj->rowid.
'">';
4445 print ($langs->trans(
"SendingMethod".strtoupper($obj->code)) !=
"SendingMethod".strtoupper($obj->code)) ? $langs->trans(
"SendingMethod".strtoupper($obj->code)) : $obj->label;
4450 if ($user->admin && empty($noinfoadmin)) {
4451 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4456 print $langs->trans(
"NoShippingMethodDefined");
4476 $langs->load(
"deliveries");
4478 if ($htmlname !=
"none") {
4479 print
'<form method="POST" action="'.$page.
'">';
4480 print
'<input type="hidden" name="action" value="setshippingmethod">';
4481 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4483 print
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
4487 $code = $langs->getLabelFromKey($this->
db, $selected,
'c_shipment_mode',
'rowid',
'code');
4488 print $langs->trans(
"SendingMethod".strtoupper($code));
4507 $langs->load(
'bills');
4509 $opt =
'<option value="" selected></option>';
4510 $sql =
"SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc";
4511 $sql .=
' FROM '.$this->db->prefix().
'facture';
4512 $sql .=
' WHERE entity IN ('.getEntity(
'invoice').
')';
4513 $sql .=
' AND situation_counter >= 1';
4514 $sql .=
' AND fk_soc = '.(int) $socid;
4515 $sql .=
' AND type <> 2';
4516 $sql .=
' ORDER by situation_cycle_ref, situation_counter desc';
4522 while ($obj = $this->
db->fetch_object(
$resql)) {
4524 if ($obj->situation_cycle_ref != $ref) {
4526 $ref = $obj->situation_cycle_ref;
4528 if ($obj->situation_final != 1) {
4530 if (substr($obj->ref, 1, 4) !=
'PROV') {
4531 if ($selected == $obj->rowid) {
4532 $opt .=
'<option value="'.$obj->rowid.
'" selected>'.$obj->ref.
'</option>';
4534 $opt .=
'<option value="'.$obj->rowid.
'">'.$obj->ref.
'</option>';
4541 dol_syslog(
"Error sql=".$sql.
", error=".$this->error, LOG_ERR);
4543 if ($opt ==
'<option value ="" selected></option>') {
4544 $opt =
'<option value ="0" selected>'.$langs->trans(
'NoSituations').
'</option>';
4558 public function selectUnits($selected =
'', $htmlname =
'units', $showempty = 0, $unit_type =
'')
4562 $langs->load(
'products');
4564 $return =
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
4566 $sql =
"SELECT rowid, label, code FROM ".$this->db->prefix().
"c_units";
4567 $sql .=
' WHERE active > 0';
4568 if (!empty($unit_type)) {
4569 $sql .=
" AND unit_type = '".$this->db->escape($unit_type).
"'";
4571 $sql .=
" ORDER BY sortorder";
4576 $return .=
'<option value="none"></option>';
4579 while ($res = $this->
db->fetch_object(
$resql)) {
4580 $unitLabel = $res->label;
4581 if (!empty($langs->tab_translate[
'unit'.$res->code])) {
4582 $unitLabel = $langs->trans(
'unit'.$res->code) != $res->label ? $langs->trans(
'unit'.$res->code) : $res->label;
4585 if ($selected == $res->rowid) {
4586 $return .=
'<option value="'.$res->rowid.
'" selected>'.$unitLabel.
'</option>';
4588 $return .=
'<option value="'.$res->rowid.
'">'.$unitLabel.
'</option>';
4591 $return .=
'</select>';
4611 public function select_comptes($selected =
'', $htmlname =
'accountid', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'', $showcurrency = 0, $morecss =
'', $nooutput = 0)
4614 global $langs, $conf;
4618 $langs->load(
"admin");
4621 $sql =
"SELECT rowid, label, bank, clos as status, currency_code";
4622 $sql .=
" FROM ".$this->db->prefix().
"bank_account";
4623 $sql .=
" WHERE entity IN (".getEntity(
'bank_account').
")";
4625 $sql .=
" AND clos = ".(int) $status;
4628 $sql .=
" AND ".$filtre;
4630 $sql .=
" ORDER BY label";
4632 dol_syslog(get_class($this).
"::select_comptes", LOG_DEBUG);
4633 $result = $this->
db->query($sql);
4635 $num = $this->
db->num_rows($result);
4638 $out .=
'<select id="select'.$htmlname.
'" class="flat selectbankaccount'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
4639 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
4640 $out .=
'<option value="-1"> </option>';
4644 $obj = $this->
db->fetch_object($result);
4645 if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected))) {
4646 $out .=
'<option value="'.$obj->rowid.
'" data-currency-code="'.$obj->currency_code.
'" selected>';
4648 $out .=
'<option value="'.$obj->rowid.
'" data-currency-code="'.$obj->currency_code.
'">';
4650 $out .= trim($obj->label);
4651 if ($showcurrency) {
4652 $out .=
' ('.$obj->currency_code.
')';
4654 if ($status == 2 && $obj->status == 1) {
4655 $out .=
' ('.$langs->trans(
"Closed").
')';
4657 $out .=
'</option>';
4660 $out .=
"</select>";
4664 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoActiveBankAccountDefined").
'</span>';
4666 $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoBankAccountFound").
'</span>';
4674 if (empty($nooutput)) {
4694 public function selectEstablishments($selected =
'', $htmlname =
'entity', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'')
4696 global $langs, $conf;
4698 $langs->load(
"admin");
4701 $sql =
"SELECT rowid, name, fk_country, status, entity";
4702 $sql .=
" FROM ".$this->db->prefix().
"establishment";
4703 $sql .=
" WHERE 1=1";
4705 $sql .=
" AND status = ".(int) $status;
4708 $sql .=
" AND ".$filtre;
4710 $sql .=
" ORDER BY name";
4712 dol_syslog(get_class($this).
"::select_establishment", LOG_DEBUG);
4713 $result = $this->
db->query($sql);
4715 $num = $this->
db->num_rows($result);
4718 print
'<select id="select'.$htmlname.
'" class="flat selectestablishment" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
4719 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
4720 print
'<option value="-1"> </option>';
4724 $obj = $this->
db->fetch_object($result);
4725 if ($selected == $obj->rowid) {
4726 print
'<option value="'.$obj->rowid.
'" selected>';
4728 print
'<option value="'.$obj->rowid.
'">';
4730 print trim($obj->name);
4731 if ($status == 2 && $obj->status == 1) {
4732 print
' ('.$langs->trans(
"Closed").
')';
4740 print
'<span class="opacitymedium">'.$langs->trans(
"NoActiveEstablishmentDefined").
'</span>';
4742 print
'<span class="opacitymedium">'.$langs->trans(
"NoEstablishmentFound").
'</span>';
4762 if ($htmlname !=
"none") {
4763 print
'<form method="POST" action="'.$page.
'">';
4764 print
'<input type="hidden" name="action" value="setbankaccount">';
4765 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4766 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
4767 $nbaccountfound = $this->
select_comptes($selected, $htmlname, 0,
'', $addempty);
4768 if ($nbaccountfound > 0) {
4769 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
4773 $langs->load(
'banks');
4776 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
4778 $result = $bankstatic->fetch($selected);
4780 print $bankstatic->getNomUrl(1);
4807 public function select_all_categories($type, $selected =
'', $htmlname =
"parent", $maxlength = 64, $markafterid = 0, $outputmode = 0, $include = 0, $morecss =
'')
4810 global $conf, $langs;
4811 $langs->load(
"categories");
4813 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
4816 if (is_numeric($type)) {
4817 dol_syslog(__METHOD__.
': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
4820 if ($type === Categorie::TYPE_BANK_LINE) {
4822 $cate_arbo = array();
4823 $sql =
"SELECT c.label, c.rowid";
4824 $sql .=
" FROM ".$this->db->prefix().
"bank_categ as c";
4825 $sql .=
" WHERE entity = ".$conf->entity;
4826 $sql .=
" ORDER BY c.label";
4827 $result = $this->
db->query($sql);
4829 $num = $this->
db->num_rows($result);
4832 $objp = $this->
db->fetch_object($result);
4834 $cate_arbo[$objp->rowid] = array(
'id'=>$objp->rowid,
'fulllabel'=>$objp->label);
4838 $this->
db->free($result);
4844 $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include);
4847 $output =
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
4848 $outarray = array();
4849 if (is_array($cate_arbo)) {
4850 if (!count($cate_arbo)) {
4851 $output .=
'<option value="-1" disabled>'.$langs->trans(
"NoCategoriesDefined").
'</option>';
4853 $output .=
'<option value="-1"> </option>';
4854 foreach ($cate_arbo as $key => $value) {
4855 if ($cate_arbo[$key][
'id'] == $selected || ($selected ===
'auto' && count($cate_arbo) == 1)) {
4860 $output .=
'<option '.$add.
'value="'.$cate_arbo[$key][
'id'].
'">'.
dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle').
'</option>';
4862 $outarray[$cate_arbo[$key][
'id']] = $cate_arbo[$key][
'fulllabel'];
4866 $output .=
'</select>';
4892 public function form_confirm($page, $title, $question, $action, $formquestion =
'', $selectedchoice =
"", $useajax = 0, $height = 170, $width = 500)
4895 dol_syslog(__METHOD__.
': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING);
4896 print $this->
formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width);
4925 public function formconfirm($page, $title, $question, $action, $formquestion =
'', $selectedchoice =
'', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0, $labelbuttonyes =
'Yes', $labelbuttonno =
'No')
4927 global $langs, $conf;
4929 $more =
'<!-- formconfirm before calling page='.dol_escape_htmltag($page).
' -->';
4935 $newselectedchoice = empty($selectedchoice) ?
"no" : $selectedchoice;
4936 if ($conf->browser->layout ==
'phone') {
4941 if (empty($height)) {
4943 if (is_array($formquestion) && count($formquestion) > 2) {
4944 $height += ((count($formquestion) - 2) * 24);
4948 if (is_array($formquestion) && !empty($formquestion)) {
4950 foreach ($formquestion as $key => $input) {
4951 if (is_array($input) && !empty($input)) {
4952 if ($input[
'type'] ==
'hidden') {
4953 $moreattr = (!empty($input[
'moreattr']) ?
' '.$input[
'moreattr'] :
'');
4954 $morecss = (!empty($input[
'morecss']) ?
' '.$input[
'morecss'] :
'');
4956 $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";
4962 $moreonecolumn =
'';
4963 $more .=
'<div class="tagtable paddingtopbottomonly centpercent noborderspacing">'.
"\n";
4964 foreach ($formquestion as $key => $input) {
4965 if (is_array($input) && !empty($input)) {
4966 $size = (!empty($input[
'size']) ?
' size="'.$input[
'size'].
'"' :
'');
4967 $moreattr = (!empty($input[
'moreattr']) ?
' '.$input[
'moreattr'] :
'');
4968 $morecss = (!empty($input[
'morecss']) ?
' '.$input[
'morecss'] :
'');
4970 if ($input[
'type'] ==
'text') {
4971 $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="'.$input[
'value'].
'"'.$moreattr.
' /></div></div>'.
"\n";
4972 } elseif ($input[
'type'] ==
'password') {
4973 $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="'.$input[
'value'].
'"'.$moreattr.
' /></div></div>'.
"\n";
4974 } elseif ($input[
'type'] ==
'textarea') {
4980 $moreonecolumn .=
'<div class="margintoponly">';
4981 $moreonecolumn .= $input[
'label'].
'<br>';
4982 $moreonecolumn .=
'<textarea name="'.dol_escape_htmltag($input[
'name']).
'" id="'.
dol_escape_htmltag($input[
'name']).
'" class="'.$morecss.
'"'.$moreattr.
'>';
4983 $moreonecolumn .= $input[
'value'];
4984 $moreonecolumn .=
'</textarea>';
4985 $moreonecolumn .=
'</div>';
4986 } elseif ($input[
'type'] ==
'select') {
4987 if (empty($morecss)) {
4988 $morecss =
'minwidth100';
4991 $show_empty = isset($input[
'select_show_empty']) ? $input[
'select_show_empty'] : 1;
4992 $key_in_label = isset($input[
'select_key_in_label']) ? $input[
'select_key_in_label'] : 0;
4993 $value_as_key = isset($input[
'select_value_as_key']) ? $input[
'select_value_as_key'] : 0;
4994 $translate = isset($input[
'select_translate']) ? $input[
'select_translate'] : 0;
4995 $maxlen = isset($input[
'select_maxlen']) ? $input[
'select_maxlen'] : 0;
4996 $disabled = isset($input[
'select_disabled']) ? $input[
'select_disabled'] : 0;
4997 $sort = isset($input[
'select_sort']) ? $input[
'select_sort'] :
'';
4999 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">';
5000 if (!empty($input[
'label'])) {
5001 $more .= $input[
'label'].
'</div><div class="tagtd left">';
5003 $more .= $this->
selectarray($input[
'name'], $input[
'values'], isset($input[
'default'])?$input[
'default']:
'', $show_empty, $key_in_label, $value_as_key, $moreattr, $translate, $maxlen, $disabled, $sort, $morecss);
5004 $more .=
'</div></div>'.
"\n";
5005 } elseif ($input[
'type'] ==
'checkbox') {
5006 $more .=
'<div class="tagtr">';
5007 $more .=
'<div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">'.$input[
'label'].
' </div><div class="tagtd">';
5009 if (!is_bool($input[
'value']) && $input[
'value'] !=
'false' && $input[
'value'] !=
'0' && $input[
'value'] !=
'') {
5010 $more .=
' checked';
5012 if (is_bool($input[
'value']) && $input[
'value']) {
5013 $more .=
' checked';
5015 if (isset($input[
'disabled'])) {
5016 $more .=
' disabled';
5018 $more .=
' /></div>';
5019 $more .=
'</div>'.
"\n";
5020 } elseif ($input[
'type'] ==
'radio') {
5022 foreach ($input[
'values'] as $selkey => $selval) {
5023 $more .=
'<div class="tagtr">';
5025 $more .=
'<div class="tagtd'.(empty($input[
'tdclass']) ?
' tdtop' : (
' tdtop '.$input[
'tdclass'])).
'">'.$input[
'label'].
'</div>';
5027 $more .=
'<div clas="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' "'.$input[
'tdclass'])).
'"> </div>';
5029 $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;
5030 if (!empty($input[
'disabled'])) {
5031 $more .=
' disabled';
5033 if (isset($input[
'default']) && $input[
'default'] === $selkey) {
5034 $more .=
' checked="checked"';
5037 $more .=
'<label for="'.dol_escape_htmltag($input[
'name'].$selkey).
'" class="valignmiddle">'.$selval.
'</label>';
5038 $more .=
'</div></div>'.
"\n";
5041 } elseif ($input[
'type'] ==
'date') {
5042 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">'.$input[
'label'].
'</div>';
5043 $more .=
'<div class="tagtd">';
5044 $addnowlink = (empty($input[
'datenow']) ? 0 : 1);
5045 $more .= $this->
selectDate($input[
'value'], $input[
'name'], 0, 0, 0,
'', 1, $addnowlink);
5046 $more .=
'</div></div>'.
"\n";
5047 $formquestion[] = array(
'name'=>$input[
'name'].
'day');
5048 $formquestion[] = array(
'name'=>$input[
'name'].
'month');
5049 $formquestion[] = array(
'name'=>$input[
'name'].
'year');
5050 $formquestion[] = array(
'name'=>$input[
'name'].
'hour');
5051 $formquestion[] = array(
'name'=>$input[
'name'].
'min');
5052 } elseif ($input[
'type'] ==
'other') {
5053 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">';
5054 if (!empty($input[
'label'])) {
5055 $more .= $input[
'label'].
'</div><div class="tagtd">';
5057 $more .= $input[
'value'];
5058 $more .=
'</div></div>'.
"\n";
5059 } elseif ($input[
'type'] ==
'onecolumn') {
5060 $moreonecolumn .=
'<div class="margintoponly">';
5061 $moreonecolumn .= $input[
'value'];
5062 $moreonecolumn .=
'</div>'.
"\n";
5063 } elseif ($input[
'type'] ==
'hidden') {
5065 } elseif ($input[
'type'] ==
'separator') {
5068 $more .=
'Error type '.$input[
'type'].
' for the confirm box is not a supported type';
5072 $more .=
'</div>'.
"\n";
5073 $more .= $moreonecolumn;
5079 if (!empty($conf->dol_use_jmobile)) {
5082 if (empty($conf->use_javascript_ajax)) {
5088 $dialogconfirm =
'dialog-confirm';
5090 if (!is_numeric($useajax)) {
5094 $dialogconfirm .=
'-'.$button;
5096 $pageyes = $page.(preg_match(
'/\?/', $page) ?
'&' :
'?').
'action='.urlencode($action).
'&confirm=yes';
5097 $pageno = ($useajax == 2 ? $page.(preg_match(
'/\?/', $page) ?
'&' :
'?').
'action='.urlencode($action).
'&confirm=no' :
'');
5100 if (is_array($formquestion)) {
5101 foreach ($formquestion as $key => $input) {
5104 if (is_array($input) && isset($input[
'name'])) {
5105 if (strpos($input[
'name'],
',') > 0) {
5106 $inputok = array_merge($inputok, explode(
',', $input[
'name']));
5108 array_push($inputok, $input[
'name']);
5112 if (isset($input[
'inputko']) && $input[
'inputko'] == 1) {
5113 array_push($inputko, $input[
'name']);
5120 if (is_array($formquestion) && !empty($formquestion[
'text'])) {
5121 $formconfirm .=
'<div class="confirmtext">'.$formquestion[
'text'].
'</div>'.
"\n";
5123 if (!empty($more)) {
5124 $formconfirm .=
'<div class="confirmquestions">'.$more.
'</div>'.
"\n";
5126 $formconfirm .= ($question ?
'<div class="confirmmessage">'.img_help(
'',
'').
' '.$question.
'</div>' :
'');
5129 $formconfirm .=
"\n<!-- begin code of popup for formconfirm page=".$page.
" -->\n";
5130 $formconfirm .=
'<script type="text/javascript">'.
"\n";
5131 $formconfirm .=
"/* Code for the jQuery('#dialogforpopup').dialog() */\n";
5134 $( "#'.$dialogconfirm.
'" ).dialog(
5136 autoOpen: '.($autoOpen ?
"true" :
"false").
',';
5137 if ($newselectedchoice ==
'no') {
5140 $(this).parent().find("button.ui-button:eq(2)").focus();
5145 if (empty($useajax)) {
5146 $jsforcursor =
'// The call to urljump can be slow, so we set the wait cursor'.
"\n";
5147 $jsforcursor .=
'jQuery("html,body,#id-container").addClass("cursorwait");'.
"\n";
5152 height: "'.$height.
'",
5153 width: "'.$width.
'",
5155 closeOnEscape: false,
5157 "'.
dol_escape_js($langs->transnoentities($labelbuttonyes)).
'": function() {
5158 var options = "&token='.urlencode(
newToken()).
'";
5159 var inputok = '.json_encode($inputok).
'; /* List of fields into form */
5160 var pageyes = "'.
dol_escape_js(!empty($pageyes) ? $pageyes :
'').
'";
5162 if (inputok.length > 0) {
5163 $.each(inputok, function(i, inputname) {
5166 if ($("input[name=\'" + inputname + "\']").attr("type") == "radio") {
5167 inputvalue = $("input[name=\'" + inputname + "\']:checked").val();
5169 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
5170 inputvalue = $("#" + inputname + more).val();
5172 if (typeof inputvalue == "undefined") { inputvalue=""; }
5173 console.log("formconfirm check inputname="+inputname+" inputvalue="+inputvalue);
5174 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
5177 var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "") + options;
5178 if (pageyes.length > 0) {
5180 location.href = urljump;
5181 console.log("after location.href");
5183 $(this).dialog("close");
5185 "'.
dol_escape_js($langs->transnoentities($labelbuttonno)).
'": function() {
5186 var options = "&token='.urlencode(
newToken()).
'";
5187 var inputko = '.json_encode($inputko).
'; /* List of fields into form */
5188 var pageno="'.
dol_escape_js(!empty($pageno) ? $pageno :
'').
'";
5189 if (inputko.length > 0) {
5190 $.each(inputko, function(i, inputname) {
5192 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
5193 var inputvalue = $("#" + inputname + more).val();
5194 if (typeof inputvalue == "undefined") { inputvalue=""; }
5195 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
5198 var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "") + options;
5200 if (pageno.length > 0) {
5202 location.href = urljump;
5203 console.log("after location.href");
5205 $(this).dialog("close");
5211 var button = "'.$button.
'";
5212 if (button.length > 0) {
5213 $( "#" + button ).click(function() {
5214 $("#'.$dialogconfirm.
'").dialog("open");
5222 $formconfirm .=
"\n<!-- begin formconfirm page=".dol_escape_htmltag($page).
" -->\n";
5224 if (empty($disableformtag)) {
5225 $formconfirm .=
'<form method="POST" action="'.$page.
'" class="notoptoleftroright">'.
"\n";
5228 $formconfirm .=
'<input type="hidden" name="action" value="'.$action.
'">'.
"\n";
5229 $formconfirm .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
5231 $formconfirm .=
'<table class="valid centpercent">'.
"\n";
5234 $formconfirm .=
'<tr class="validtitre"><td class="validtitre" colspan="2">';
5239 if (is_array($formquestion) && !empty($formquestion[
'text'])) {
5240 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="2">'.$formquestion[
'text'].
'</td></tr>'.
"\n";
5245 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="2">'.
"\n";
5252 $formconfirm .=
'<td class="valid">'.$question.
'</td>';
5254 $formconfirm .= $this->
selectyesno(
"confirm", $newselectedchoice, 0,
false, 0, 0,
'marginleftonly marginrightonly', $labelbuttonyes, $labelbuttonno);
5255 $formconfirm .=
'<input class="button valignmiddle confirmvalidatebutton small" type="submit" value="'.$langs->trans(
"Validate").
'">';
5261 if (empty($disableformtag)) {
5266 if (!empty($conf->use_javascript_ajax)) {
5267 $formconfirm .=
'<!-- code to disable button to avoid double clic -->';
5268 $formconfirm .=
'<script type="text/javascript">'.
"\n";
5270 $(document).ready(function () {
5271 $(".confirmvalidatebutton").on("click", function() {
5272 console.log("We click on button");
5273 $(this).attr("disabled", "disabled");
5274 setTimeout(\'$(".confirmvalidatebutton").removeAttr("disabled")\', 3000);
5275 //console.log($(this).closest("form"));
5276 $(this).closest("form").submit();
5304 public function form_project($page, $socid, $selected =
'', $htmlname =
'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0)
5309 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
5310 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
5316 $langs->load(
"project");
5317 if ($htmlname !=
"none") {
5319 $out .=
'<form method="post" action="'.$page.
'">';
5320 $out .=
'<input type="hidden" name="action" value="classin">';
5321 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
5322 $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0,
'', 1);
5323 $out .=
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
5326 $out .=
'<span class="project_head_block">';
5329 $projet->fetch($selected);
5330 $out .= $projet->getNomUrl(1,
'', 1);
5337 if (empty($nooutput)) {
5359 public function form_conditions_reglement($page, $selected =
'', $htmlname =
'cond_reglement_id', $addempty = 0, $type =
'', $filtertype = -1, $deposit_percent = -1)
5363 if ($htmlname !=
"none") {
5364 print
'<form method="POST" action="'.$page.
'">';
5365 print
'<input type="hidden" name="action" value="setconditions">';
5366 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5368 print
'<input type="hidden" name="type" value="'.dol_escape_htmltag($type).
'">';
5371 print
'<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
5376 if (isset($this->cache_conditions_paiements[$selected])) {
5377 $label = $this->cache_conditions_paiements[$selected][
'label'];
5379 if (! empty($this->cache_conditions_paiements[$selected][
'deposit_percent'])) {
5380 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $this->cache_conditions_paiements[$selected][
'deposit_percent'], $label);
5385 $langs->load(
'errors');
5386 print $langs->trans(
'ErrorNotInDictionaryPaymentConditions');
5408 if ($htmlname !=
"none") {
5409 print
'<form method="post" action="'.$page.
'">';
5410 print
'<input type="hidden" name="action" value="setavailability">';
5411 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5413 print
'<input type="submit" name="modify" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
5414 print
'<input type="submit" name="cancel" class="button smallpaddingimp" value="'.$langs->trans(
"Cancel").
'">';
5419 print $this->cache_availability[$selected][
'label'];
5436 public function formInputReason($page, $selected =
'', $htmlname =
'demandreason', $addempty = 0)
5439 if ($htmlname !=
"none") {
5440 print
'<form method="post" action="'.$page.
'">';
5441 print
'<input type="hidden" name="action" value="setdemandreason">';
5442 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5444 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
5449 foreach ($this->cache_demand_reason as $key => $val) {
5450 if ($val[
'id'] == $selected) {
5451 print $val[
'label'];
5475 public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0, $type =
'')
5482 if ($htmlname !=
"none") {
5483 $ret .=
'<form method="POST" action="'.$page.
'" name="form'.$htmlname.
'">';
5484 $ret .=
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
5485 $ret .=
'<input type="hidden" name="token" value="'.newToken().
'">';
5487 $ret .=
'<input type="hidden" name="type" value="'.dol_escape_htmltag($type).
'">';
5489 $ret .=
'<table class="nobordernopadding">';
5491 $ret .= $this->
selectDate($selected, $htmlname, $displayhour, $displaymin, 1,
'form'.$htmlname, 1, 0);
5493 $ret .=
'<td class="left"><input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'"></td>';
5494 $ret .=
'</tr></table></form>';
5503 if (empty($nooutput)) {
5521 public function form_users($page, $selected =
'', $htmlname =
'userid', $exclude =
'', $include =
'')
5526 if ($htmlname !=
"none") {
5527 print
'<form method="POST" action="'.$page.
'" name="form'.$htmlname.
'">';
5528 print
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
5529 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5530 print $this->
select_dolusers($selected, $htmlname, 1, $exclude, 0, $include);
5531 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5535 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
5536 $theuser =
new User($this->
db);
5537 $theuser->fetch($selected);
5538 print $theuser->getNomUrl(1);
5559 public function form_modes_reglement($page, $selected =
'', $htmlname =
'mode_reglement_id', $filtertype =
'', $active = 1, $addempty = 0, $type =
'')
5563 if ($htmlname !=
"none") {
5564 print
'<form method="POST" action="'.$page.
'">';
5565 print
'<input type="hidden" name="action" value="setmode">';
5566 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5568 print
'<input type="hidden" name="type" value="'.dol_escape_htmltag($type).
'">';
5570 print $this->
select_types_paiements($selected, $htmlname, $filtertype, 0, $addempty, 0, 0, $active,
'', 1);
5571 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5576 print $this->cache_types_paiements[$selected][
'label'];
5596 if ($htmlname !=
"none") {
5597 print
'<form method="POST" action="'.$page.
'">';
5598 print
'<input type="hidden" name="action" value="settransportmode">';
5599 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5601 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5606 print $this->cache_transport_mode[$selected][
'label'];
5626 if ($htmlname !=
"none") {
5627 print
'<form method="POST" action="'.$page.
'">';
5628 print
'<input type="hidden" name="action" value="setmulticurrencycode">';
5629 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5631 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5635 print !empty($selected) ?
currency_name($selected, 1) :
' ';
5652 global $langs, $mysoc, $conf;
5654 if ($htmlname !=
"none") {
5655 print
'<form method="POST" action="'.$page.
'">';
5656 print
'<input type="hidden" name="action" value="setmulticurrencyrate">';
5657 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5658 print
'<input type="text" class="maxwidth100" name="'.$htmlname.
'" value="'.(!empty($rate) ?
price(
price2num($rate,
'CU')) : 1).
'" /> ';
5659 print
'<select name="calculation_mode">';
5660 print
'<option value="1">Change '.$langs->trans(
"PriceUHT").
' of lines</option>';
5661 print
'<option value="2">Change '.$langs->trans(
"PriceUHTCurrency").
' of lines</option>';
5663 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5666 if (!empty($rate)) {
5667 print
price($rate, 1, $langs, 1, 0);
5668 if ($currency && $rate != 1) {
5669 print
' ('.price($rate, 1, $langs, 1, 0).
' '.$currency.
' = 1 '.$conf->currency.
')';
5694 public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter =
'', $maxvalue = 0, $more =
'', $hidelist = 0, $discount_type = 0)
5697 global $conf, $langs;
5698 if ($htmlname !=
"none") {
5699 print
'<form method="post" action="'.$page.
'">';
5700 print
'<input type="hidden" name="action" value="setabsolutediscount">';
5701 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5702 print
'<div class="inline-block">';
5703 if (!empty($discount_type)) {
5704 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
5705 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL") {
5706 $translationKey =
'HasAbsoluteDiscountFromSupplier';
5708 $translationKey =
'HasCreditNoteFromSupplier';
5711 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
5712 $translationKey =
'HasAbsoluteDiscountFromSupplier';
5714 $translationKey =
'HasCreditNoteFromSupplier';
5718 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
5719 if (!$filter || $filter ==
"fk_facture_source IS NULL") {
5720 $translationKey =
'CompanyHasAbsoluteDiscount';
5722 $translationKey =
'CompanyHasCreditNote';
5725 if (!$filter || $filter ==
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
5726 $translationKey =
'CompanyHasAbsoluteDiscount';
5728 $translationKey =
'CompanyHasCreditNote';
5732 print $langs->trans($translationKey,
price($amount, 0, $langs, 0, 0, -1, $conf->currency));
5733 if (empty($hidelist)) {
5737 if (empty($hidelist)) {
5738 print
'<div class="inline-block" style="padding-right: 10px">';
5739 $newfilter =
'discount_type='.intval($discount_type);
5740 if (!empty($discount_type)) {
5741 $newfilter .=
' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL';
5743 $newfilter .=
' AND fk_facture IS NULL AND fk_facture_line IS NULL';
5746 $newfilter .=
' AND ('.$filter.
')';
5749 $nbqualifiedlines = $this->
select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue);
5750 if ($nbqualifiedlines > 0) {
5751 print
' <input type="submit" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"UseLine")).
'"';
5752 if (!empty($discount_type) && $filter && $filter !=
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
5753 print
' title="'.$langs->trans(
"UseCreditNoteInInvoicePayment").
'"';
5755 if (empty($discount_type) && $filter && $filter !=
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
5756 print
' title="'.$langs->trans(
"UseCreditNoteInInvoicePayment").
'"';
5764 print
'<div class="inline-block">';
5789 public function form_contacts($page, $societe, $selected =
'', $htmlname =
'contactid')
5792 global $langs, $conf;
5794 if ($htmlname !=
"none") {
5795 print
'<form method="post" action="'.$page.
'">';
5796 print
'<input type="hidden" name="action" value="set_contact">';
5797 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5798 print
'<table class="nobordernopadding">';
5803 $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
5804 print
'<a href="'.DOL_URL_ROOT.
'/contact/card.php?socid='.$societe->id.
'&action=create&backtoreferer=1">'.$addcontact.
'</a>';
5807 print
'<td class="left"><input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'"></td>';
5808 print
'</tr></table></form>';
5811 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
5813 $contact->fetch($selected);
5814 print $contact->getFullName($langs);
5837 public function form_thirdparty($page, $selected =
'', $htmlname =
'socid', $filter =
'', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0, $excludeids = array())
5843 if ($htmlname !=
"none") {
5844 $out .=
'<form method="post" action="'.$page.
'">';
5845 $out .=
'<input type="hidden" name="action" value="set_thirdparty">';
5846 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
5847 $out .= $this->
select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, 0,
'minwidth100',
'',
'', 1, array(),
false, $excludeids);
5848 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5852 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
5854 $soc->fetch($selected);
5855 $out .= $soc->getNomUrl($langs);
5892 public function selectCurrency($selected =
'', $htmlname =
'currency_id', $mode = 0, $useempty =
'')
5894 global $conf, $langs, $user;
5896 $langs->loadCacheCurrencies(
'');
5900 if ($selected ==
'euro' || $selected ==
'euros') {
5904 $out .=
'<select class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.
'" id="'.$htmlname.
'">';
5906 $out .=
'<option value="-1" selected></option>';
5908 foreach ($langs->cache_currencies as $code_iso => $currency) {
5909 $labeltoshow = $currency[
'label'];
5911 $labeltoshow .=
' <span class="opacitymedium">('.$code_iso.
')</span>';
5913 $labeltoshow .=
' <span class="opacitymedium">('.$langs->getCurrencySymbol($code_iso).
')</span>';
5916 if ($selected && $selected == $code_iso) {
5917 $out .=
'<option value="'.$code_iso.
'" selected data-html="'.
dol_escape_htmltag($labeltoshow).
'">';
5919 $out .=
'<option value="'.$code_iso.
'" data-html="'.
dol_escape_htmltag($labeltoshow).
'">';
5921 $out .= $labeltoshow;
5922 $out .=
'</option>';
5924 $out .=
'</select>';
5926 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
5930 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5948 public function selectMultiCurrency($selected =
'', $htmlname =
'multicurrency_code', $useempty = 0, $filter =
'', $excludeConfCurrency =
false, $morecss =
'')
5950 global $conf, $langs;
5952 $langs->loadCacheCurrencies(
'');
5954 $TCurrency = array();
5956 $sql =
"SELECT code FROM ".$this->db->prefix().
"multicurrency";
5957 $sql .=
" WHERE entity IN ('".getEntity(
'mutlicurrency').
"')";
5959 $sql .=
" AND ".$filter;
5963 while ($obj = $this->
db->fetch_object(
$resql)) {
5964 $TCurrency[$obj->code] = $obj->code;
5969 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
5971 $out .=
'<option value=""> </option>';
5974 if (!in_array($conf->currency, $TCurrency) && !$excludeConfCurrency) {
5975 $TCurrency[$conf->currency] = $conf->currency;
5977 if (count($TCurrency) > 0) {
5978 foreach ($langs->cache_currencies as $code_iso => $currency) {
5979 if (isset($TCurrency[$code_iso])) {
5980 if (!empty($selected) && $selected == $code_iso) {
5981 $out .=
'<option value="'.$code_iso.
'" selected="selected">';
5983 $out .=
'<option value="'.$code_iso.
'">';
5986 $out .= $currency[
'label'];
5987 $out .=
' ('.$langs->getCurrencySymbol($code_iso).
')';
5988 $out .=
'</option>';
5993 $out .=
'</select>';
5996 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
6014 $num = count($this->cache_vatrates);
6021 $sql =
"SELECT DISTINCT t.rowid, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly";
6022 $sql .=
" FROM ".$this->db->prefix().
"c_tva as t, ".$this->
db->prefix().
"c_country as c";
6023 $sql .=
" WHERE t.fk_pays = c.rowid";
6024 $sql .=
" AND t.active > 0";
6025 $sql .=
" AND c.code IN (".$this->db->sanitize($country_code, 1).
")";
6026 $sql .=
" ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC";
6030 $num = $this->
db->num_rows(
$resql);
6032 for ($i = 0; $i < $num; $i++) {
6033 $obj = $this->
db->fetch_object(
$resql);
6034 $this->cache_vatrates[$i][
'rowid'] = $obj->rowid;
6035 $this->cache_vatrates[$i][
'code'] = $obj->code;
6036 $this->cache_vatrates[$i][
'txtva'] = $obj->taux;
6037 $this->cache_vatrates[$i][
'nprtva'] = $obj->recuperableonly;
6038 $this->cache_vatrates[$i][
'localtax1'] = $obj->localtax1;
6039 $this->cache_vatrates[$i][
'localtax1_type'] = $obj->localtax1_type;
6040 $this->cache_vatrates[$i][
'localtax2'] = $obj->localtax2;
6041 $this->cache_vatrates[$i][
'localtax2_type'] = $obj->localtax1_type;
6043 $this->cache_vatrates[$i][
'label'] = $obj->taux.
'%'.($obj->code ?
' ('.$obj->code.
')' :
'');
6044 $this->cache_vatrates[$i][
'labelallrates'] = $obj->taux.
'/'.($obj->localtax1 ? $obj->localtax1 :
'0').
'/'.($obj->localtax2 ? $obj->localtax2 :
'0').($obj->code ?
' ('.$obj->code.
')' :
'');
6045 $positiverates =
'';
6047 $positiverates .= ($positiverates ?
'/' :
'').$obj->taux;
6049 if ($obj->localtax1) {
6050 $positiverates .= ($positiverates ?
'/' :
'').$obj->localtax1;
6052 if ($obj->localtax2) {
6053 $positiverates .= ($positiverates ?
'/' :
'').$obj->localtax2;
6055 if (empty($positiverates)) {
6056 $positiverates =
'0';
6058 $this->cache_vatrates[$i][
'labelpositiverates'] = $positiverates.($obj->code ?
' ('.$obj->code.
')' :
'');
6063 $this->error =
'<span class="error">'.$langs->trans(
"ErrorNoVATRateDefinedForSellerCountry", $country_code).
'</span>';
6067 $this->error =
'<span class="error">'.$this->db->error().
'</span>';
6094 public function load_tva($htmlname =
'tauxtva', $selectedrate =
'', $societe_vendeuse =
'', $societe_acheteuse =
'', $idprod = 0, $info_bits = 0, $type =
'', $options_only =
false, $mode = 0)
6097 global $langs, $conf, $mysoc;
6099 $langs->load(
'errors');
6104 $defaultnpr = ($info_bits & 0x01);
6105 $defaultnpr = (preg_match(
'/\*/', $selectedrate) ? 1 : $defaultnpr);
6106 $defaulttx = str_replace(
'*',
'', $selectedrate);
6109 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6110 $defaultcode = $reg[1];
6111 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6116 if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
6117 if ($societe_vendeuse->id == $mysoc->id) {
6118 $return .=
'<span class="error">'.$langs->trans(
"ErrorYourCountryIsNotDefined").
'</span>';
6120 $return .=
'<span class="error">'.$langs->trans(
"ErrorSupplierCountryIsNotDefined").
'</span>';
6131 if (is_object($societe_vendeuse)) {
6132 $code_country =
"'".$societe_vendeuse->country_code.
"'";
6134 $code_country =
"'".$mysoc->country_code.
"'";
6136 if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
6137 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
6138 if (!
isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (
isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()))) {
6140 if (is_numeric($type)) {
6142 $code_country .=
",'".$societe_acheteuse->country_code.
"'";
6144 } elseif (!$idprod) {
6145 $code_country .=
",'".$societe_acheteuse->country_code.
"'";
6148 $prodstatic->fetch($idprod);
6150 $code_country .=
",'".$societe_acheteuse->country_code.
"'";
6161 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
6162 $tmpthirdparty =
new Societe($this->
db);
6163 $defaulttx =
get_default_tva($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
6164 $defaultnpr =
get_default_npr($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
6165 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6166 $defaultcode = $reg[1];
6167 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6169 if (empty($defaulttx)) {
6176 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
6177 if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
6178 $defaulttx = $this->cache_vatrates[$num - 1][
'txtva'];
6180 $defaulttx = ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS ==
'none' ?
'' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS);
6187 if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj ==
"0") {
6190 if (empty($conf->global->EXPENSEREPORT_OVERRIDE_VAT)) {
6191 $title =
' title="'.$langs->trans(
'VATIsNotUsed').
'"';
6196 if (!$options_only) {
6197 $return .=
'<select class="flat minwidth75imp" id="'.$htmlname.
'" name="'.$htmlname.
'"'.($disabled ?
' disabled' :
'').$title.
'>';
6200 $selectedfound =
false;
6201 foreach ($this->cache_vatrates as $rate) {
6203 if ($disabled && $rate[
'txtva'] != 0) {
6208 $key = $rate[
'txtva'];
6209 $key .= $rate[
'nprtva'] ?
'*' :
'';
6210 if ($mode > 0 && $rate[
'code']) {
6211 $key .=
' ('.$rate[
'code'].
')';
6214 $key = $rate[
'rowid'];
6217 $return .=
'<option value="'.$key.
'"';
6218 if (!$selectedfound) {
6220 if ($defaultcode == $rate[
'code']) {
6221 $return .=
' selected';
6222 $selectedfound =
true;
6224 } elseif ($rate[
'txtva'] == $defaulttx && $rate[
'nprtva'] == $defaultnpr) {
6225 $return .=
' selected';
6226 $selectedfound =
true;
6231 if ($mysoc->country_code ==
'IN' || !empty($conf->global->MAIN_VAT_LABEL_IS_POSITIVE_RATES)) {
6232 $return .= $rate[
'labelpositiverates'];
6234 $return .=
vatrate($rate[
'label']);
6237 $return .= (empty($rate[
'code']) && $rate[
'nprtva']) ?
' *' :
'';
6239 $return .=
'</option>';
6242 if (!$options_only) {
6243 $return .=
'</select>';
6246 $return .= $this->error;
6279 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 =
'')
6282 $retstring = $this->
selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof);
6283 if (!empty($nooutput)) {
6305 public function selectDateToDate($set_time =
'', $set_time_end =
'', $prefix =
're', $empty = 0, $forcenewline = 0)
6309 $ret = $this->
selectDate($set_time, $prefix.
'_start', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"),
'tzuserrel');
6310 if ($forcenewline) {
6313 $ret .= $this->
selectDate($set_time_end, $prefix.
'_end', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
6344 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')
6346 global $conf, $langs;
6348 if ($gm ===
'auto') {
6349 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
6354 if ($prefix ==
'') {
6365 if ($stepminutes <= 0 || $stepminutes > 30) {
6376 $orig_set_time = $set_time;
6378 if ($set_time ===
'' && $emptydate == 0) {
6379 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
6380 if ($gm ==
'tzuser' || $gm ==
'tzuserrel') {
6392 if (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg)) {
6394 $syear = (!empty($reg[1]) ? $reg[1] :
'');
6395 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
6396 $sday = (!empty($reg[3]) ? $reg[3] :
'');
6397 $shour = (!empty($reg[4]) ? $reg[4] :
'');
6398 $smin = (!empty($reg[5]) ? $reg[5] :
'');
6399 } elseif (strval($set_time) !=
'' && $set_time != -1) {
6404 if ($orig_set_time !=
'') {
6414 $shour = !isset($conf->global->MAIN_DEFAULT_DATE_HOUR) ? ($h == -1 ?
'23' :
'') : $conf->global->MAIN_DEFAULT_DATE_HOUR;
6415 $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? ($h == -1 ?
'59' :
'') : $conf->global->MAIN_DEFAULT_DATE_MIN;
6416 $ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? ($h == -1 ?
'59' :
'') : $conf->global->MAIN_DEFAULT_DATE_SEC;
6429 $usecalendar =
'combo';
6430 if (!empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR !=
"none")) {
6431 $usecalendar = ((empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR ==
'eldy') ?
'jquery' : $conf->global->MAIN_POPUP_CALENDAR);
6436 if ($usecalendar !=
'combo') {
6437 $formated_date =
'';
6439 if (strval($set_time) !=
'' && $set_time != -1) {
6441 $formated_date =
dol_print_date($set_time, $langs->trans(
"FormatDateShortInput"), $gm);
6445 if ($usecalendar ==
"eldy") {
6447 $retstring .=
'<input id="'.$prefix.
'" name="'.$prefix.
'" type="text" class="maxwidthdate" maxlength="11" value="'.$formated_date.
'"';
6448 $retstring .= ($disabled ?
' disabled' :
'');
6449 $retstring .=
' onChange="dpChangeDay(\''.$prefix.
'\',\
''.$langs->trans(
"FormatDateShortJavaInput").
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
6453 $retstringbuttom = '';
6455 $retstringbuttom = '<button id="'.$prefix.'Button
" type="button
" class="dpInvisibleButtons
"';
6456 $base = DOL_URL_ROOT.'/core/';
6457 $retstringbuttom .= ' onClick="showDP(\
''.$base.
'\',\
''.$prefix.
'\',\
''.$langs->trans(
"FormatDateShortJavaInput").
'\',\
''.$langs->defaultlang.
'\');
"';
6458 $retstringbuttom .= '>'.img_object($langs->trans("SelectDate
"), 'calendarday', 'class="datecallink
"').'</button>';
6460 $retstringbuttom = '<button id="'.$prefix.'Button
" type="button
" class="dpInvisibleButtons
">'.img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"').'</button>';
6462 $retstring = $retstringbuttom.$retstring;
6464 $retstring .= '<input type="hidden
" id="'.$prefix.'day
" name="'.$prefix.'day
" value="'.$sday.'">'."\n
";
6465 $retstring .= '<input type="hidden
" id="'.$prefix.'month
" name="'.$prefix.'month
" value="'.$smonth.'">'."\n
";
6466 $retstring .= '<input type="hidden
" id="'.$prefix.'year
" name="'.$prefix.'year
" value="'.$syear.'">'."\n
";
6467 } elseif ($usecalendar == 'jquery') {
6469 // Output javascript for datepicker
6470 $minYear = getDolGlobalString('MIN_YEAR_SELECT_DATE', date('Y') - 100);
6471 $maxYear = getDolGlobalString('MAX_YEAR_SELECT_DATE', date('Y') + 100);
6473 $retstring .= "<script
type=
'text/javascript'>
";
6474 $retstring .= "$(
function(){ $(
'#".$prefix."').datepicker({
6475 dateFormat:
'".$langs->trans("FormatDateShortJQueryInput")."',
6477 todayHighlight:
true,
6478 yearRange:
'".$minYear.":".$maxYear."',
";
6479 if (!empty($conf->dol_use_jmobile)) {
6481 beforeShow:
function (input, datePicker) {
6482 input.disabled =
true;
6484 onClose:
function (dateText, datePicker) {
6485 this.disabled =
false;
6489 // Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php
6490 if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS)) {
6493 buttonImage:
'".DOL_URL_ROOT."/theme/".dol_escape_js($conf->theme)."/img/object_calendarday.png',
6494 buttonImageOnly:
true";
6498 $retstring .= "</script>
";
6501 // Zone de saisie manuelle de la date
6502 $retstring .= '<div class="nowrap
inline-block divfordateinput
">';
6503 $retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text
" class="maxwidthdate
" maxlength="11
" value="'.$formated_date.'"';
6504 $retstring .= ($disabled ? ' disabled' : '');
6505 $retstring .= ($placeholder ? ' placeholder="'.dol_escape_htmltag($placeholder).'"' : '');
6506 $retstring .= ' onChange="dpChangeDay(\
''.
dol_escape_js($prefix).
'\',\
''.
dol_escape_js($langs->trans(
"FormatDateShortJavaInput")).
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
6511 /* Not required. Managed by option buttonImage of jquery
6512 $retstring.=img_object($langs->trans("SelectDate
"),'calendarday','id="'.$prefix.'id" class="datecallink
"');
6513 $retstring.="<script type=
'text/javascript'>
";
6514 $retstring.="jQuery(document).ready(
function() {
";
6515 $retstring.=' jQuery("#
'.$prefix.'id").click(function() {';
6516 $retstring.=" jQuery(
'#".$prefix."').focus();
";
6519 $retstring.="</script>
";*/
6521 $retstringbutton = '<button id="'.$prefix.'Button
" type="button
" class="dpInvisibleButtons
">'.img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"').'</button>';
6522 $retsring = $retstringbutton.$retstring;
6525 $retstring .= '</div>';
6526 $retstring .= '<input type="hidden
" id="'.$prefix.'day
" name="'.$prefix.'day
" value="'.$sday.'">'."\n
";
6527 $retstring .= '<input type="hidden
" id="'.$prefix.'month
" name="'.$prefix.'month
" value="'.$smonth.'">'."\n
";
6528 $retstring .= '<input type="hidden
" id="'.$prefix.'year
" name="'.$prefix.'year
" value="'.$syear.'">'."\n
";
6530 $retstring .= "Bad value of MAIN_POPUP_CALENDAR
";
6533 // Show date with combo selects
6535 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50imp
" id="'.$prefix.'day
" name="'.$prefix.'day
">';
6537 if ($emptydate || $set_time == -1) {
6538 $retstring .= '<option value="0
" selected> </option>';
6541 for ($day = 1; $day <= 31; $day++) {
6542 $retstring .= '<option value="'.$day.'"'.($day == $sday ? ' selected' : '').'>'.$day.'</option>';
6545 $retstring .= "</select>
";
6547 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth75imp
" id="'.$prefix.'month
" name="'.$prefix.'month
">';
6548 if ($emptydate || $set_time == -1) {
6549 $retstring .= '<option value="0
" selected> </option>';
6553 for ($month = 1; $month <= 12; $month++) {
6554 $retstring .= '<option value="'.$month.'"'.($month == $smonth ? ' selected' : '').'>';
6555 $retstring .= dol_print_date(mktime(12, 0, 0, $month, 1, 2000), "%b
");
6556 $retstring .= "</option>
";
6558 $retstring .= "</select>
";
6561 if ($emptydate || $set_time == -1) {
6562 $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.'">';
6564 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth75imp
" id="'.$prefix.'year
" name="'.$prefix.'year
">';
6566 for ($year = $syear - 10; $year < $syear + 10; $year++) {
6567 $retstring .= '<option value="'.$year.'"'.($year == $syear ? ' selected' : '').'>'.$year.'</option>';
6569 $retstring .= "</select>\n
";
6575 $retstring .= ($h == 2 ? '<br>' : ' ');
6576 $retstring .= '<span class="nowraponall
">';
6582 if ($openinghours != '') {
6583 $openinghours = explode(',', $openinghours);
6584 $hourstart = $openinghours[0];
6585 $hourend = $openinghours[1];
6586 if ($hourend < $hourstart) {
6587 $hourend = $hourstart;
6591 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50
'.($fullday ? $fullday.'hour
' : '').'" id="'.$prefix.'hour
" name="'.$prefix.'hour
">';
6593 $retstring .= '<option value="-1
"> </option>';
6595 for ($hour = $hourstart; $hour < $hourend; $hour++) {
6596 if (strlen($hour) < 2) {
6599 $retstring .= '<option value="'.$hour.'"'.(($hour == $shour) ? ' selected' : '').'>'.$hour;
6600 //$retstring .= (empty($conf->dol_optimize_smallscreen) ? '' : 'H');
6601 $retstring .= '</option>';
6603 $retstring .= '</select>';
6604 //if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":
";
6612 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50
'.($fullday ? $fullday.'min
' : '').'" id="'.$prefix.'min
" name="'.$prefix.'min
">';
6614 $retstring .= '<option value="-1
"> </option>';
6616 for ($min = 0; $min < 60; $min += $stepminutes) {
6617 if (strlen($min) < 2) {
6620 $retstring .= '<option value="'.$min.'"'.(($min == $smin) ? ' selected' : '').'>'.$min.(empty($conf->dol_optimize_smallscreen) ? '' : '').'</option>';
6622 $retstring .= '</select>';
6624 $retstring .= '<input type="hidden
" name="'.$prefix.'sec
" value="'.$ssec.'">';
6628 $retstring .= '</span>';
6632 if ($conf->use_javascript_ajax && $addnowlink) {
6633 // Script which will be inserted in the onClick of the "Now
" link
6634 $reset_scripts = "";
6635 if ($addnowlink == 2) { // local computer time
6636 // pad add leading 0 on numbers
6637 $reset_scripts .= "Number.prototype.pad =
function(size) {
6638 var s = String(
this);
6639 while (s.length < (size || 2)) {s =
'0' + s;}
6642 var d =
new Date();
";
6645 // Generate the date part, depending on the use or not of the javascript calendar
6646 if ($addnowlink == 1) { // server time expressed in user time setup
6647 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'day', 'tzuserrel').'\');';
6648 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');';
6649 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');';
6650 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');';
6651 } elseif ($addnowlink == 2) {
6652 /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix.
6653 * This break application for foreign languages.
6654 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));';
6655 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());';
6656 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);';
6657 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());';
6659 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'day', 'tzuserrel').'\');';
6660 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');';
6661 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');';
6662 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');';
6664 /*if ($usecalendar == "eldy
")
6666 $base=DOL_URL_ROOT.'/core/';
6667 $reset_scripts .= 'resetDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput
").'\',\''.$langs->defaultlang.'\');';
6671 $reset_scripts .= 'this.form.elements[\''.$prefix.'day\'].value=formatDate(new Date(), \'d\'); ';
6672 $reset_scripts .= 'this.form.elements[\''.$prefix.'month\'].value=formatDate(new Date(), \'M\'); ';
6673 $reset_scripts .= 'this.form.elements[\''.$prefix.'year\'].value=formatDate(new Date(), \'yyyy\'); ';
6675 // Update the hour part
6678 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() == null) {
";
6680 //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); ';
6681 if ($addnowlink == 1) {
6682 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');';
6683 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();';
6684 } elseif ($addnowlink == 2) {
6685 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());';
6686 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();';
6690 $reset_scripts .= ' } ';
6693 // Update the minute part
6696 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() == null) {
";
6698 //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); ';
6699 if ($addnowlink == 1) {
6700 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');';
6701 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();';
6702 } elseif ($addnowlink == 2) {
6703 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());';
6704 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();';
6707 $reset_scripts .= ' } ';
6710 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
6711 if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
6712 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="'.$prefix.'ButtonNow
" type="button
" name="_useless
" value="now
" onClick="'.$reset_scripts.'">';
6713 $retstring .= $langs->trans("Now
");
6714 $retstring .= '</button> ';
6718 // Add a "Plus one hour
" link
6719 if ($conf->use_javascript_ajax && $addplusone) {
6720 // Script which will be inserted in the onClick of the "Add plusone
" link
6721 $reset_scripts = "";
6723 // Generate the date part, depending on the use or not of the javascript calendar
6724 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'dayinputnoreduce', 'tzuserrel').'\');';
6725 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');';
6726 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');';
6727 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');';
6728 // Update the hour part
6731 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() == null) {
";
6733 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');';
6735 $reset_scripts .= ' } ';
6738 // Update the minute part
6741 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() == null) {
";
6743 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');';
6745 $reset_scripts .= ' } ';
6748 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
6749 if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
6750 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="'.$prefix.'ButtonPlusOne
" type="button
" name="_useless2
" value="plusone
" onClick="'.$reset_scripts.'">';
6751 $retstring .= $langs->trans("DateStartPlusOne
");
6752 $retstring .= '</button> ';
6756 // Add a link to set data
6757 if ($conf->use_javascript_ajax && $adddateof) {
6758 $tmparray = dol_getdate($adddateof);
6759 if (empty($labeladddateof)) {
6760 $labeladddateof = $langs->trans("DateInvoice
");
6762 $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>';
6776 public function selectTypeDuration($prefix, $selected = 'i', $excludetypes = array())
6780 $TDurationTypes = array(
6781 'y'=>$langs->trans('Years'),
6782 'm'=>$langs->trans('Month'),
6783 'w'=>$langs->trans('Weeks'),
6784 'd'=>$langs->trans('Days'),
6785 'h'=>$langs->trans('Hours'),
6786 'i'=>$langs->trans('Minutes')
6789 // Removed undesired duration types
6790 foreach ($excludetypes as $value) {
6791 unset($TDurationTypes[$value]);
6794 $retstring = '<select class="flat minwidth75 maxwidth100
" id="select_
'.$prefix.'type_duration
" name="'.$prefix.'type_duration
">';
6795 foreach ($TDurationTypes as $key => $typeduration) {
6796 $retstring .= '<option value="'.$key.'"';
6797 if ($key == $selected) {
6798 $retstring .= " selected
";
6800 $retstring .= ">
".$typeduration."</option>
";
6802 $retstring .= "</select>
";
6804 $retstring .= ajax_combobox('select_'.$prefix.'type_duration');
6809 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
6823 public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0)
6828 $retstring = '<span class="nowraponall
">';
6834 if ($iSecond != '') {
6835 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
6837 $hourSelected = convertSecondToTime($iSecond, 'allhour');
6838 $minSelected = convertSecondToTime($iSecond, 'min');
6841 if ($typehour == 'select') {
6842 $retstring .= '<select class="flat
" id="select_
'.$prefix.'hour
" name="'.$prefix.'hour
"'.($disabled ? ' disabled' : '').'>';
6843 for ($hour = 0; $hour < 25; $hour++) { // For a duration, we allow 24 hours
6844 $retstring .= '<option value="'.$hour.'"';
6845 if ($hourSelected == $hour) {
6846 $retstring .= " selected
";
6848 $retstring .= ">
".$hour."</option>
";
6850 $retstring .= "</select>
";
6851 } elseif ($typehour == 'text' || $typehour == 'textselect') {
6852 $retstring .= '<input placeholder="'.$langs->trans('HourShort
').'" type="number
" min="0
" name="'.$prefix.'hour
"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputhour
" value="'.(($hourSelected != '') ? ((int) $hourSelected) : '').'">';
6854 return 'BadValueForParameterTypeHour';
6857 if ($typehour != 'text') {
6858 $retstring .= ' '.$langs->trans('HourShort');
6860 $retstring .= '<span class="">:</span>';
6864 if ($minunderhours) {
6865 $retstring .= '<br>';
6867 $retstring .= '<span class="hideonsmartphone
"> </span>';
6870 if ($typehour == 'select' || $typehour == 'textselect') {
6871 $retstring .= '<select class="flat
" id="select_
'.$prefix.'min
" name="'.$prefix.'min
"'.($disabled ? ' disabled' : '').'>';
6872 for ($min = 0; $min <= 55; $min = $min + 5) {
6873 $retstring .= '<option value="'.$min.'"';
6874 if ($minSelected == $min) {
6875 $retstring .= ' selected';
6877 $retstring .= '>'.$min.'</option>';
6879 $retstring .= "</select>
";
6880 } elseif ($typehour == 'text') {
6881 $retstring .= '<input placeholder="'.$langs->trans('MinuteShort
').'" type="number
" min="0
" name="'.$prefix.'min
"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputminute
" value="'.(($minSelected != '') ? ((int) $minSelected) : '').'">';
6884 if ($typehour != 'text') {
6885 $retstring .= ' '.$langs->trans('MinuteShort');
6888 $retstring.="</span>
";
6890 if (!empty($nooutput)) {
6917 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)
6919 global $langs, $conf;
6924 if (is_null($ajaxoptions)) $ajaxoptions = array();
6926 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
6929 if ($selected && empty($selected_input_value)) {
6930 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
6931 $tickettmpselect = new Ticket($this->db);
6932 $tickettmpselect->fetch($selected);
6933 $selected_input_value = $tickettmpselect->ref;
6934 unset($tickettmpselect);
6938 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/ticket/ajax/tickets.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
6940 if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel
").' : ';
6941 elseif ($hidelabel > 1) {
6942 $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
6943 if ($hidelabel == 2) {
6944 $out .= img_picto($langs->trans("Search
"), 'search');
6947 $out .= '<input type="text
" class="minwidth100
" name="search_
'.$htmlname.'" id="search_
'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
6948 if ($hidelabel == 3) {
6949 $out .= img_picto($langs->trans("Search
"), 'search');
6952 $out .= $this->selectTicketsList($selected, $htmlname, $filtertype, $limit, $status, 0, $socid, $showempty, $forcecombo, $morecss);
6955 if (empty($nooutput)) print $out;
6976 public function selectTicketsList($selected = '', $htmlname = 'ticketid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
6978 global $langs, $conf;
6981 $outarray = array();
6983 $selectFields = " p.rowid, p.ref, p.message
";
6986 $sql .= $selectFields;
6987 $sql .= " FROM
".$this->db->prefix()."ticket as p
";
6988 $sql .= ' WHERE p.entity IN ('.getEntity('ticket').')';
6990 // Add criteria on ref/label
6991 if ($filterkey != '') {
6993 $prefix = empty($conf->global->TICKET_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
6994 // For natural search
6995 $scrit = explode(' ', $filterkey);
6997 if (count($scrit) > 1) $sql .= "(
";
6998 foreach ($scrit as $crit) {
6999 if ($i > 0) $sql .= " AND
";
7000 $sql .= "(p.ref LIKE
'".$this->db->escape($prefix.$crit)."%' OR p.subject LIKE
'".$this->db->escape($prefix.$crit)."%'";
7004 if (count($scrit) > 1) $sql .= ")
";
7008 $sql .= $this->db->plimit($limit, 0);
7010 // Build output string
7012 $result = $this->db->query($sql);
7014 require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
7015 require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
7017 $num = $this->db->num_rows($result);
7022 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
7023 $out .= ajax_combobox($htmlname, $events, $conf->global->TICKET_USE_SEARCH_TO_SELECT);
7026 $out .= '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
7029 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7030 //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7031 if (!empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
7032 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7033 else $textifempty .= $langs->trans("All
");
7035 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7037 if ($showempty) $out .= '<option value="0
" selected>'.$textifempty.'</option>';
7040 while ($num && $i < $num) {
7043 $objp = $this->db->fetch_object($result);
7045 $this->constructTicketListOption($objp, $opt, $optJson, $selected, $filterkey);
7047 // "key
" value of json key array is used by jQuery automatically as selected value
7048 // "label
" value of json key array is used by jQuery automatically as text for combo box
7050 array_push($outarray, $optJson);
7055 $out .= '</select>';
7057 $this->db->free($result);
7059 if (empty($outputmode)) return $out;
7062 dol_print_error($this->db);
7077 protected function constructTicketListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7083 $outkey = $objp->rowid;
7084 $outref = $objp->ref;
7085 $outtype = $objp->fk_product_type;
7087 $opt = '<option value="'.$objp->rowid.'"';
7088 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7091 $objRef = $objp->ref;
7092 if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
7094 $opt .= "</option>\n
";
7095 $optJson = array('key'=>$outkey, 'value'=>$outref, 'type'=>$outtype);
7117 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)
7119 global $langs, $conf;
7124 if (is_null($ajaxoptions)) $ajaxoptions = array();
7126 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
7129 if ($selected && empty($selected_input_value)) {
7130 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
7131 $projecttmpselect = new Project($this->db);
7132 $projecttmpselect->fetch($selected);
7133 $selected_input_value = $projecttmpselect->ref;
7134 unset($projecttmpselect);
7137 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7139 if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel
").' : ';
7140 elseif ($hidelabel > 1) {
7141 $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
7142 if ($hidelabel == 2) {
7143 $out .= img_picto($langs->trans("Search
"), 'search');
7146 $out .= '<input type="text
" class="minwidth100
" name="search_
'.$htmlname.'" id="search_
'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
7147 if ($hidelabel == 3) {
7148 $out .= img_picto($langs->trans("Search
"), 'search');
7151 $out .= $this->selectProjectsList($selected, $htmlname, $filtertype, $limit, $status, 0, $socid, $showempty, $forcecombo, $morecss);
7154 if (empty($nooutput)) print $out;
7174 public function selectProjectsList($selected = '', $htmlname = 'projectid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7176 global $langs, $conf;
7179 $outarray = array();
7181 $selectFields = " p.rowid, p.ref
";
7184 $sql .= $selectFields;
7185 $sql .= " FROM
".$this->db->prefix()."projet as p
";
7186 $sql .= ' WHERE p.entity IN ('.getEntity('project').')';
7188 // Add criteria on ref/label
7189 if ($filterkey != '') {
7191 $prefix = empty($conf->global->TICKET_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7192 // For natural search
7193 $scrit = explode(' ', $filterkey);
7195 if (count($scrit) > 1) $sql .= "(
";
7196 foreach ($scrit as $crit) {
7197 if ($i > 0) $sql .= " AND
";
7198 $sql .= "p.ref LIKE
'".$this->db->escape($prefix.$crit)."%'";
7202 if (count($scrit) > 1) $sql .= ")
";
7206 $sql .= $this->db->plimit($limit, 0);
7208 // Build output string
7210 $result = $this->db->query($sql);
7212 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
7213 require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
7215 $num = $this->db->num_rows($result);
7220 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
7221 $out .= ajax_combobox($htmlname, $events, $conf->global->PROJECT_USE_SEARCH_TO_SELECT);
7224 $out .= '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
7227 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7228 //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7229 if (!empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) {
7230 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7231 else $textifempty .= $langs->trans("All
");
7233 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7235 if ($showempty) $out .= '<option value="0
" selected>'.$textifempty.'</option>';
7238 while ($num && $i < $num) {
7241 $objp = $this->db->fetch_object($result);
7243 $this->constructProjectListOption($objp, $opt, $optJson, $selected, $filterkey);
7245 // "key
" value of json key array is used by jQuery automatically as selected value
7246 // "label
" value of json key array is used by jQuery automatically as text for combo box
7248 array_push($outarray, $optJson);
7253 $out .= '</select>';
7255 $this->db->free($result);
7257 if (empty($outputmode)) return $out;
7260 dol_print_error($this->db);
7275 protected function constructProjectListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7283 $label = $objp->label;
7285 $outkey = $objp->rowid;
7286 $outref = $objp->ref;
7287 $outlabel = $objp->label;
7288 $outtype = $objp->fk_product_type;
7290 $opt = '<option value="'.$objp->rowid.'"';
7291 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7294 $objRef = $objp->ref;
7295 if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
7298 $opt .= "</option>\n
";
7299 $optJson = array('key'=>$outkey, 'value'=>$outref, 'type'=>$outtype);
7322 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)
7324 global $langs, $conf;
7329 if (is_null($ajaxoptions)) $ajaxoptions = array();
7331 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
7335 if ($selected && empty($selected_input_value)) {
7336 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
7337 $adherenttmpselect = new Adherent($this->db);
7338 $adherenttmpselect->fetch($selected);
7339 $selected_input_value = $adherenttmpselect->ref;
7340 unset($adherenttmpselect);
7345 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/adherents/ajax/adherents.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7347 if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel
").' : ';
7348 elseif ($hidelabel > 1) {
7349 $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
7350 if ($hidelabel == 2) {
7351 $out .= img_picto($langs->trans("Search
"), 'search');
7354 $out .= '<input type="text
" class="minwidth100
" name="search_
'.$htmlname.'" id="search_
'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
7355 if ($hidelabel == 3) {
7356 $out .= img_picto($langs->trans("Search
"), 'search');
7361 $out .= $this->selectMembersList($selected, $htmlname, $filtertype, $limit, $filterkey, $status, 0, $showempty, $forcecombo, $morecss);
7364 if (empty($nooutput)) print $out;
7384 public function selectMembersList($selected = '', $htmlname = 'adherentid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7386 global $langs, $conf;
7389 $outarray = array();
7391 $selectFields = " p.rowid, p.ref, p.firstname, p.lastname
";
7394 $sql .= $selectFields;
7395 $sql .= " FROM
".$this->db->prefix()."adherent as p
";
7396 $sql .= ' WHERE p.entity IN ('.getEntity('adherent').')';
7398 // Add criteria on ref/label
7399 if ($filterkey != '') {
7401 $prefix = empty($conf->global->MEMBER_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7402 // For natural search
7403 $scrit = explode(' ', $filterkey);
7405 if (count($scrit) > 1) $sql .= "(
";
7406 foreach ($scrit as $crit) {
7407 if ($i > 0) $sql .= " AND
";
7408 $sql .= "(p.firstname LIKE
'".$this->db->escape($prefix.$crit)."%'";
7409 $sql .= " OR p.lastname LIKE
'".$this->db->escape($prefix.$crit)."%')
";
7412 if (count($scrit) > 1) $sql .= ")
";
7415 if ($status != -1) {
7416 $sql .= ' AND statut = '.((int) $status);
7418 $sql .= $this->db->plimit($limit, 0);
7420 // Build output string
7422 $result = $this->db->query($sql);
7424 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
7425 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
7427 $num = $this->db->num_rows($result);
7432 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
7433 $out .= ajax_combobox($htmlname, $events, $conf->global->PROJECT_USE_SEARCH_TO_SELECT);
7436 $out .= '<select class="flat
'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
7439 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7440 //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7441 if (!empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) {
7442 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7443 else $textifempty .= $langs->trans("All
");
7445 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7448 $out .= '<option value="-1
" selected>'.$textifempty.'</option>';
7452 while ($num && $i < $num) {
7455 $objp = $this->db->fetch_object($result);
7457 $this->constructMemberListOption($objp, $opt, $optJson, $selected, $filterkey);
7460 // "key
" value of json key array is used by jQuery automatically as selected value
7461 // "label
" value of json key array is used by jQuery automatically as text for combo box
7463 array_push($outarray, $optJson);
7468 $out .= '</select>';
7470 $this->db->free($result);
7472 if (empty($outputmode)) return $out;
7475 dol_print_error($this->db);
7490 protected function constructMemberListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7496 $outkey = $objp->rowid;
7497 $outlabel = dolGetFirstLastname($objp->firstname, $objp->lastname);
7498 $outtype = $objp->fk_adherent_type;
7500 $opt = '<option value="'.$objp->rowid.'"';
7501 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7503 if (!empty($filterkey) && $filterkey != '') {
7504 $outlabel = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $outlabel, 1);
7507 $opt .= "</option>\n
";
7509 $optJson = array('key'=>$outkey, 'value'=>$outlabel, 'type'=>$outtype);
7531 public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '')
7533 global $conf, $user;
7537 // Example of value for $objectdec:
7538 // Bom:bom/class/bom.class.php:0:t.status=1
7539 // Bom:bom/class/bom.class.php:0:t.status=1:ref
7540 // Bom:bom/class/bom.class.php:0:(t.status:=:1):ref
7541 $InfoFieldList = explode(":
", $objectdesc, 4);
7542 $vartmp = (empty($InfoFieldList[3]) ? '' : $InfoFieldList[3]);
7544 if (preg_match('/^.*:(\w*)$/', $vartmp, $reg)) {
7545 $InfoFieldList[4] = $reg[1]; // take the sort field
7547 $InfoFieldList[3] = preg_replace('/:\w*$/', '', $vartmp); // take the filter field
7549 $classname = $InfoFieldList[0];
7550 $classpath = $InfoFieldList[1];
7551 $addcreatebuttonornot = empty($InfoFieldList[2]) ? 0 : $InfoFieldList[2];
7552 $filter = empty($InfoFieldList[3]) ? '' : $InfoFieldList[3];
7553 $sortfield = empty($InfoFieldList[4]) ? '' : $InfoFieldList[4];
7555 if (!empty($classpath)) {
7556 dol_include_once($classpath);
7558 if ($classname && class_exists($classname)) {
7559 $objecttmp = new $classname($this->db);
7560 // Make some replacement
7561 $sharedentities = getEntity(strtolower($classname));
7562 $objecttmp->filter = str_replace(
7563 array('__ENTITY__', '__SHARED_ENTITIES__', '__USER_ID__'),
7564 array($conf->entity, $sharedentities, $user->id),
7569 if (!is_object($objecttmp)) {
7570 dol_syslog('Error bad setup of type for field '.$InfoFieldList, LOG_WARNING);
7571 return 'Error bad setup of type for field '.join(',', $InfoFieldList);
7574 //var_dump($objecttmp->filter);
7575 $prefixforautocompletemode = $objecttmp->element;
7576 if ($prefixforautocompletemode == 'societe') {
7577 $prefixforautocompletemode = 'company';
7579 if ($prefixforautocompletemode == 'product') {
7580 $prefixforautocompletemode = 'produit';
7582 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
7584 dol_syslog(get_class($this)."::
selectForForms object->filter=
".$objecttmp->filter, LOG_DEBUG);
7586 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->$confkeyforautocompletemode) && !$forcecombo) {
7587 // No immediate load of all database
7589 if ($preselectedvalue && empty($selected_input_value)) {
7590 $objecttmp->fetch($preselectedvalue);
7591 $selected_input_value = ($prefixforautocompletemode == 'company' ? $objecttmp->name : $objecttmp->ref);
7592 //unset($objecttmp);
7595 $objectdesc = $classname.':'.$classpath.':'.$addcreatebuttonornot.':'.$filter;
7596 $urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php';
7598 // No immediate load of all database
7599 $urloption = 'htmlname='.urlencode($htmlname).'&outjson=1&objectdesc='.urlencode($objectdesc).'&filter='.urlencode($objecttmp->filter).($sortfield ? '&sortfield='.urlencode($sortfield) : '');
7600 // Activate the auto complete using ajax call.
7601 $out .= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array());
7602 $out .= '<style type="text/css
">.ui-autocomplete { z-index: 1003; }</style>';
7603 $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).'"' : '') .' />';
7605 // Immediate load of table record. Note: filter is inside $objecttmp->filter
7606 $out .= $this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled, $sortfield);
7618 protected static function forgeCriteriaCallback($matches)
7622 //dol_syslog("Convert matches
".$matches[1]);
7623 if (empty($matches[1])) {
7626 $tmp = explode(':', $matches[1]);
7627 if (count($tmp) < 3) {
7631 $tmpescaped = $tmp[2];
7633 if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis)) {
7634 $tmpescaped = "'".$db->escape($regbis[1])."'";
7636 $tmpescaped = $db->escape($tmpescaped);
7638 return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped;
7660 public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0, $sortfield = '')
7662 global $conf, $langs, $user, $hookmanager;
7664 //print "$objecttmp->filter, $htmlname, $preselectedvalue, $showempty =
'', $searchkey =
'', $placeholder =
'', $morecss =
'', $moreparams =
'', $forcecombo = 0, $outputmode = 0, $disabled
";
7666 $prefixforautocompletemode = $objecttmp->element;
7667 if ($prefixforautocompletemode == 'societe') {
7668 $prefixforautocompletemode = 'company';
7670 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
7672 if (!empty($objecttmp->fields)) { // For object that declare it, it is better to use declared fields (like societe, contact, ...)
7673 $tmpfieldstoshow = '';
7674 foreach ($objecttmp->fields as $key => $val) {
7675 if (!dol_eval($val['enabled'], 1, 1, '1')) {
7678 if (!empty($val['showoncombobox'])) {
7679 $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '').'t.'.$key;
7682 if ($tmpfieldstoshow) {
7683 $fieldstoshow = $tmpfieldstoshow;
7686 // For backward compatibility
7687 $objecttmp->fields['ref'] = array('type'=>'varchar(30)', 'label'=>'Ref', 'showoncombobox'=>1);
7690 if (empty($fieldstoshow)) {
7691 if (isset($objecttmp->fields['ref'])) {
7692 $fieldstoshow = 't.ref';
7694 $langs->load("errors
");
7695 $this->error = $langs->trans("ErrorNoFieldWithAttributeShowoncombobox
");
7696 return $langs->trans('ErrorNoFieldWithAttributeShowoncombobox');
7701 $outarray = array();
7702 $tmparray = array();
7707 $sql = "SELECT t.rowid,
".$fieldstoshow." FROM
".$this->db->prefix().$objecttmp->table_element." as t
";
7708 if (isset($objecttmp->ismultientitymanaged)) {
7709 if (!is_numeric($objecttmp->ismultientitymanaged)) {
7710 $tmparray = explode('@', $objecttmp->ismultientitymanaged);
7711 $sql .= " INNER JOIN
".$this->db->prefix().$tmparray[1]." as parenttable ON parenttable.rowid = t.
".$tmparray[0];
7713 if ($objecttmp->ismultientitymanaged === 'fk_soc@societe') {
7714 if (empty($user->rights->societe->client->voir) && !$user->socid) {
7715 $sql .= ",
".$this->db->prefix()."societe_commerciaux as sc
";
7720 // Add where from hooks
7721 $parameters = array();
7722 $reshook = $hookmanager->executeHooks('selectForFormsListWhere', $parameters); // Note that $action and $object may have been modified by hook
7723 if (!empty($hookmanager->resPrint)) {
7724 $sql .= $hookmanager->resPrint;
7726 $sql .= " WHERE 1=1
";
7727 if (isset($objecttmp->ismultientitymanaged)) {
7728 if ($objecttmp->ismultientitymanaged == 1) {
7729 $sql .= " AND t.entity IN (
".getEntity($objecttmp->table_element).")
";
7731 if (!is_numeric($objecttmp->ismultientitymanaged)) {
7732 $sql .= " AND parenttable.entity = t.
".$tmparray[0];
7734 if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
7735 if ($objecttmp->element == 'societe') {
7736 $sql .= " AND t.rowid =
".((int) $user->socid);
7738 $sql .= " AND t.fk_soc =
".((int) $user->socid);
7741 if ($objecttmp->ismultientitymanaged === 'fk_soc@societe') {
7742 if (empty($user->rights->societe->client->voir) && !$user->socid) {
7743 $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user =
".((int) $user->id);
7747 if ($searchkey != '') {
7748 $sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
7750 if ($objecttmp->filter) { // Syntax example "(t.ref:like:
'SO-%') and (t.date_creation:<:
'20160101')
"
7751 /*if (! DolibarrApi::_checkFilters($objecttmp->filter))
7753 throw new RestException(503, 'Error when validating parameter sqlfilters '.$objecttmp->filter);
7755 $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
7756 $sql .= " AND (
".preg_replace_callback('/'.$regexstring.'/', 'Form::forgeCriteriaCallback', $objecttmp->filter).")
";
7759 $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow, "ASC
");
7760 //$sql.=$this->db->plimit($limit, 0);
7763 // Build output string
7764 $resql = $this->db->query($sql);
7766 // Construct $out and $outarray
7767 $out .= '<select id="'.$htmlname.'" class="flat
'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled
"' : '').($moreparams ? ' '.$moreparams : '').' name="'.$htmlname.'">'."\n
";
7769 // Warning: Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. Seems it is no more true with selec2 v4
7770 $textifempty = ' ';
7772 //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7773 if (!empty($conf->global->$confkeyforautocompletemode)) {
7774 if ($showempty && !is_numeric($showempty)) {
7775 $textifempty = $langs->trans($showempty);
7777 $textifempty .= $langs->trans("All
");
7781 $out .= '<option value="-1
">'.$textifempty.'</option>'."\n
";
7784 $num = $this->db->num_rows($resql);
7788 $obj = $this->db->fetch_object($resql);
7790 $tmparray = explode(',', $fieldstoshow);
7791 $oldvalueforshowoncombobox = 0;
7792 foreach ($tmparray as $key => $val) {
7793 $val = preg_replace('/t\./', '', $val);
7794 $label .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val]['showoncombobox'] ? ' - ' : ' ') : '');
7795 $label .= $obj->$val;
7796 $oldvalueforshowoncombobox = !empty($objecttmp->fields[$val]['showoncombobox']) ? $objecttmp->fields[$val]['showoncombobox'] : 0;
7798 if (empty($outputmode)) {
7799 if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
7800 $out .= '<option value="'.$obj->rowid.'" selected>'.$label.'</option>';
7802 $out .= '<option value="'.$obj->rowid.'">'.$label.'</option>';
7805 array_push($outarray, array('key'=>$obj->rowid, 'value'=>$label, 'label'=>$label));
7809 if (($i % 10) == 0) {
7815 $out .= '</select>'."\n
";
7818 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
7819 $out .= ajax_combobox($htmlname, null, (!empty($conf->global->$confkeyforautocompletemode) ? $conf->global->$confkeyforautocompletemode : 0));
7822 dol_print_error($this->db);
7825 $this->result = array('nbofelement'=>$num);
7857 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 = '', $addjscombo = 1, $moreparamonempty = '', $disablebademail = 0, $nohtmlescape = 0)
7859 global $conf, $langs;
7861 // Do we want a multiselect ?
7863 //if (preg_match('/^multi/',$htmlname)) $jsbeautify = 1;
7866 if ($value_as_key) {
7867 $array = array_combine($array, $array);
7872 if ($addjscombo < 0) {
7873 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
7880 $out .= '<select id="'.preg_replace('/^\./
', '', $htmlname).'" '.($disabled ? 'disabled="disabled
" ' : '').'class="flat
'.(preg_replace('/^\./
', '', $htmlname)).($morecss ? ' '.$morecss : '').'"';
7881 $out .= ' name="'.preg_replace('/^\./
', '', $htmlname).'" '.($moreparam ? $moreparam : '');
7885 $textforempty = ' ';
7886 if (!empty($conf->use_javascript_ajax)) {
7887 $textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
7889 if (!is_numeric($show_empty)) {
7890 $textforempty = $show_empty;
7892 $out .= '<option class="optiongrey
" '.($moreparamonempty ? $moreparamonempty.' ' : '').'value="'.($show_empty < 0 ? $show_empty : -1).'"'.($id == $show_empty ? ' selected' : '').'>'.$textforempty.'</option>'."\n
";
7895 if (is_array($array)) {
7898 foreach ($array as $key => $value) {
7899 if (!is_array($value)) {
7900 $array[$key] = $langs->trans($value);
7902 $array[$key]['label'] = $langs->trans($value['label']);
7908 if ($sort == 'ASC') {
7910 } elseif ($sort == 'DESC') {
7914 foreach ($array as $key => $tmpvalue) {
7915 if (is_array($tmpvalue)) {
7916 $value = $tmpvalue['label'];
7917 $disabled = empty($tmpvalue['disabled']) ? '' : ' disabled';
7918 $style = empty($tmpvalue['css']) ? '' : ' class="'.$tmpvalue['css
'].'"';
7924 if (!empty($disablebademail)) {
7925 if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value))
7926 || ($disablebademail == 2 && preg_match('/---/', $value))) {
7927 $disabled = ' disabled';
7928 $style = ' class="warning
"';
7932 if ($key_in_label) {
7933 if (empty($nohtmlescape)) {
7934 $selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value));
7936 $selectOptionValue = $key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value);
7939 if (empty($nohtmlescape)) {
7940 $selectOptionValue = dol_escape_htmltag($maxlen ?dol_trunc($value, $maxlen) : $value);
7942 $selectOptionValue = $maxlen ?dol_trunc($value, $maxlen) : $value;
7944 if ($value == '' || $value == '-') {
7945 $selectOptionValue = ' ';
7949 $out .= '<option value="'.$key.'"';
7950 $out .= $style.$disabled;
7951 if (is_array($id)) {
7952 if (in_array($key, $id) && !$disabled) {
7953 $out .= ' selected'; // To preselect a value
7956 $id = (string) $id; // if $id = 0, then $id = '0'
7957 if ($id != '' && ($id == $key || ($id == 'ifone' && count($array) == 1)) && !$disabled) {
7958 $out .= ' selected'; // To preselect a value
7961 if ($nohtmlescape) {
7962 $out .= ' data-html="'.dol_escape_htmltag($selectOptionValue).'"';
7964 if (is_array($tmpvalue)) {
7965 foreach ($tmpvalue as $keyforvalue => $valueforvalue) {
7966 if (preg_match('/^data-/', $keyforvalue)) {
7967 $out .= ' '.$keyforvalue.'="'.$valueforvalue.'"';
7972 //var_dump($selectOptionValue);
7973 $out .= $selectOptionValue;
7974 $out .= "</option>\n
";
7978 $out .= "</select>
";
7980 // Add code for jquery to use multiselect
7981 if ($addjscombo && $jsbeautify) {
7982 // Enhance with select2
7983 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
7984 $out .= ajax_combobox($htmlname, array(), 0, 0, 'resolve', $show_empty < 0 ? (string) $show_empty : '-1');
8009 public static function selectArrayAjax($htmlname, $url, $id = '', $moreparam = '', $moreparamtourl = '', $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0)
8011 global $conf, $langs;
8012 global $delayedhtmlcontent; // Will be used later outside of this function
8014 // TODO Use an internal dolibarr component instead of select2
8015 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) {
8019 $out = '<select type="text
" class="'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name="'.$htmlname.'"></select>';
8022 if (!empty($conf->use_javascript_ajax)) {
8023 $tmpplugin = 'select2';
8024 $outdelayed = "\n
".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
8026 $(document).ready(function () {
8028 '.($callurlonselect ? 'var saveRemoteData = [];' : '').'
8030 $(".
'.$htmlname.'").select2({
8036 data: function (params) {
8038 q: params.term, // search term
8042 processResults: function (data) {
8043 // parse the results into the format expected by Select2.
8044 // since we are using custom formatting functions we do not need to alter the remote JSON data
8045 //console.log(data);
8046 saveRemoteData = data;
8047 /* format json result for select2 */
8049 $.each( data, function( key, value ) {
8050 result.push({id: key, text: value.text});
8052 //return {results:[{id:\'none\', text:\'aa\'}, {id:\'rrr\', text:\'Red\'},{id:\'bbb\', text:\'Search a into projects\'}], more:false}
8053 //console.log(result);
8054 return {results: result, more: false}
8058 language: select2arrayoflanguage,
8059 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
8060 placeholder:
"'.dol_escape_js($placeholder).'",
8061 escapeMarkup:
function (markup) {
return markup; },
8062 minimumInputLength:
'.$minimumInputLength.',
8063 formatResult:
function(result, container, query, escapeMarkup) {
8064 return escapeMarkup(result.text);
8068 '.($callurlonselect ? '
8070 $(
".'.$htmlname.'").change(
function() {
8071 var selected = $(
".'.$htmlname.'").val();
8072 console.log(
"We select in selectArrayAjax the entry "+selected)
8073 $(
".'.$htmlname.'").val(
"");
8074 $.each( saveRemoteData,
function( key, value ) {
8075 if (key == selected)
8077 console.log(
"selectArrayAjax - Do a redirect to "+value.url)
8078 location.assign(value.url);
8087 if ($acceptdelayedhtml) {
8088 $delayedhtmlcontent .= $outdelayed;
8090 $out .= $outdelayed;
8113 public static function selectArrayFilter($htmlname, $array, $id = '', $moreparam = '', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0)
8115 global $conf, $langs;
8116 global $delayedhtmlcontent; // Will be used later outside of this function
8118 // TODO Use an internal dolibarr component instead of select2
8119 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT
')) {
8123 $out = '<select type=
"text" class=
"'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name=
"'.$htmlname.'"><option></option></select>
';
8125 $formattedarrayresult = array();
8127 foreach ($array as $key => $value) {
8128 $o = new stdClass();
8130 $o->text = $value['text
'];
8131 $o->url = $value['url
'];
8132 $formattedarrayresult[] = $o;
8136 if (!empty($conf->use_javascript_ajax)) {
8137 $tmpplugin = 'select2
';
8138 $outdelayed = "\n".'<!-- JS CODE TO ENABLE
'.$tmpplugin.' for id '.$htmlname.' -->
8140 $(document).ready(
function () {
8141 var data =
'.json_encode($formattedarrayresult).';
8143 '.($callurlonselect ? 'var saveRemoteData =
'.json_encode($array).';
' : '').'
8145 $(
".'.$htmlname.'").select2({
8147 language: select2arrayoflanguage,
8148 containerCssClass: \
':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
8149 placeholder: "'.dol_escape_js($placeholder).
'",
8150 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
8151 minimumInputLength: '.$minimumInputLength.
',
8152 formatResult: function(result, container, query, escapeMarkup) {
8153 return escapeMarkup(result.text);
8155 matcher: function (params, data) {
8157 if(! data.id) return null;';
8159 if ($callurlonselect) {
8162 var urlBase = data.url;
8163 var separ = urlBase.indexOf("?") >= 0 ? "&" : "?";
8164 /* console.log("params.term="+params.term); */
8165 /* console.log("params.term encoded="+encodeURIComponent(params.term)); */
8166 saveRemoteData[data.id].url = urlBase + separ + "sall=" + encodeURIComponent(params.term.replace(/\"/g, ""));';
8169 if (!$disableFiltering) {
8172 if(data.text.match(new RegExp(params.term))) {
8187 '.($callurlonselect ?
'
8188 /* Code to execute a GET when we select a value */
8189 $(".'.$htmlname.
'").change(function() {
8190 var selected = $(".'.$htmlname.
'").val();
8191 console.log("We select "+selected)
8193 $(".'.$htmlname.
'").val(""); /* reset visible combo value */
8194 $.each( saveRemoteData, function( key, value ) {
8195 if (key == selected)
8197 console.log("selectArrayFilter - Do a redirect to "+value.url)
8198 location.assign(value.url);
8207 if ($acceptdelayedhtml) {
8208 $delayedhtmlcontent .= $outdelayed;
8210 $out .= $outdelayed;
8233 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)
8235 global $conf, $langs;
8239 if ($addjscombo < 0) {
8240 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
8248 $out .=
'<select id="'.$htmlname.
'" class="multiselect'.($morecss ?
' '.$morecss :
'').
'" multiple name="'.$htmlname.
'[]"'.($moreattrib ?
' '.$moreattrib :
'').($width ?
' style="width: '.(preg_match(
'/%/', $width) ? $width : $width.
'px').
'"' :
'').
'>'.
"\n";
8249 if (is_array($array) && !empty($array)) {
8250 if ($value_as_key) {
8251 $array = array_combine($array, $array);
8254 if (!empty($array)) {
8255 foreach ($array as $key => $value) {
8256 $newval = ($translate ? $langs->trans($value) : $value);
8257 $newval = ($key_in_label ? $key.
' - '.$newval : $newval);
8259 $out .=
'<option value="'.$key.
'"';
8260 if (is_array($selected) && !empty($selected) && in_array((
string) $key, $selected) && ((string) $key !=
'')) {
8261 $out .=
' selected';
8263 $out .=
' data-html="'.dol_escape_htmltag($newval).
'"';
8266 $out .=
'</option>'.
"\n";
8270 $out .=
'</select>'.
"\n";
8273 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined(
'REQUIRE_JQUERY_MULTISELECT')) {
8274 $out .=
"\n".
'<!-- JS CODE TO ENABLE select for id '.$htmlname.
', addjscombo='.$addjscombo.
' -->';
8275 $out .=
"\n".
'<script>'.
"\n";
8276 if ($addjscombo == 1) {
8277 $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant(
'REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
8278 $out .=
'function formatResult(record, container) {'.
"\n";
8279 $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";
8280 $out .=
' return record.text;';
8282 $out .=
'function formatSelection(record) {'.
"\n";
8283 if ($elemtype ==
'category') {
8284 $out .=
'return \'<span><img src="'.DOL_URL_ROOT.
'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
8286 $out .=
'return record.text;';
8289 $out .=
'$(document).ready(function () {
8290 $(\'#'.$htmlname.
'\').
'.$tmpplugin.'({
';
8295 text: \''.dol_escape_js($placeholder).
'\'
8298 $out .= ' dir: \
'ltr\',
8299 // Specify format function for dropdown item
8300 formatResult: formatResult,
8301 templateResult: formatResult, /* For 4.0 */
8302 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
8303 // Specify format function for selected item
8304 formatSelection: formatSelection,
8305 templateSelection: formatSelection /* For 4.0 */
8308 /* Add also morecss to the css .select2 that is after the #htmlname, for component that are show dynamically after load, because select2 set
8309 the size only if component is not hidden by default on load */
8310 $(\'#'.$htmlname.
' + .select2\').addClass(\''.$morecss.
'\');
8312 } elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT
')) {
8314 // TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
8316 $out .= 'console.log(\
'addjscombo=2 for htmlname='.$htmlname.
'\');
';
8317 $out .= '$(document).ready(
function () {
8318 $(\
'#'.$htmlname.
'\').multiSelect({
8319 containerHTML: \
'<div class="multi-select-container">\',
8320 menuHTML: \'<div class="multi-select-menu">\',
8321 buttonHTML: \'<span class="multi-select-button '.$morecss.
'">\',
8322 menuItemHTML: \'<label class="multi-select-menuitem">\',
8323 activeClass: \'multi-select-container--open\',
8324 noneText: \''.$placeholder.
'\'
8328 $out .= '</script>
';
8345 public static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage, $pos = '')
8347 global $conf, $langs, $user, $extrafields;
8349 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
8353 $tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; // To get list of saved selected fields to show
8355 if (!empty($user->conf->$tmpvar)) { // A list of fields was already customized for user
8356 $tmparray = explode(',
', $user->conf->$tmpvar);
8357 foreach ($array as $key => $val) {
8359 //var_dump($tmparray);
8360 if (in_array($key, $tmparray)) {
8361 $array[$key]['checked
'] = 1;
8363 $array[$key]['checked
'] = 0;
8366 } else { // There is no list of fields already customized for user
8367 foreach ($array as $key => $val) {
8368 if (!empty($array[$key]['checked
']) && $array[$key]['checked
'] < 0) {
8369 $array[$key]['checked
'] = 0;
8374 $listoffieldsforselection = '';
8375 $listcheckedstring = '';
8377 foreach ($array as $key => $val) {
8379 // var_dump(array_key_exists('enabled
', $val));
8380 // var_dump(!$val['enabled
']);
8381 if (array_key_exists('enabled
', $val) && isset($val['enabled
']) && !$val['enabled
']) {
8382 unset($array[$key]); // We don't want
this field
8385 if (!empty($val[
'type']) && $val[
'type'] ==
'separate') {
8390 if ($val[
'label']) {
8391 if (!empty($val[
'langfile']) && is_object($langs)) {
8392 $langs->load($val[
'langfile']);
8396 $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>';
8397 $listcheckedstring .= (empty($val[
'checked']) ?
'' : $key.
',');
8401 $out =
'<!-- Component multiSelectArrayWithCheckbox '.$htmlname.
' -->
8403 <dl class="dropdown">
8405 <a href="#'.$htmlname.
'">
8408 <input type="hidden" class="'.$htmlname.
'" name="'.$htmlname.
'" value="'.$listcheckedstring.
'">
8410 <dd class="dropdowndd">
8411 <div class="multiselectcheckbox'.$htmlname.
'">
8412 <ul class="ul'.$htmlname.
' '.$htmlname.$pos.
'">
8413 '.$listoffieldsforselection.
'
8419 <script type="text/javascript">
8420 jQuery(document).ready(function () {
8421 $(\'.multiselectcheckbox'.$htmlname.
' input[type="checkbox"]\').on(\'click\', function () {
8422 console.log("A new field was added/removed, we edit field input[name=formfilteraction]");
8424 $("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\'); // Update field so we know we changed something on selected fields after POST
8426 var title = $(this).val() + ",";
8427 if ($(this).is(\':checked\')) {
8428 $(\'.'.$htmlname.
'\').val(title + $(\
'.'.$htmlname.
'\').val());
8431 $(\
'.'.$htmlname.
'\').val( $(\
'.'.$htmlname.
'\').val().replace(title, \
'\') )
8454 public function showCategories($id, $type, $rendermode = 0, $nolink = 0)
8456 include_once DOL_DOCUMENT_ROOT.'/categories/
class/categorie.class.php
';
8458 $cat = new Categorie($this->db);
8459 $categories = $cat->containing($id, $type);
8461 if ($rendermode == 1) {
8463 foreach ($categories as $c) {
8464 $ways = $c->print_all_ways(' >>
', ($nolink ? 'none
' : ''), 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
8465 foreach ($ways as $way) {
8466 $toprint[] = '<li
class=
"select2-search-choice-dolibarr noborderoncategories"'.($c->color ? ' style=
"background: #'.$c->color.';"' : ' style=
"background: #bbb"').'>
'.$way.'</li>
';
8469 return '<div
class=
"select2-container-multi-dolibarr"><ul
class=
"select2-choices-dolibarr">
'.implode(' ', $toprint).'</ul></div>
';
8472 if ($rendermode == 0) {
8473 $arrayselected = array();
8474 $cate_arbo = $this->select_all_categories($type, '', 'parent
', 64, 0, 1);
8475 foreach ($categories as $c) {
8476 $arrayselected[] = $c->id;
8479 return $this->multiselectarray('categories
', $cate_arbo, $arrayselected, '', 0, '', 0, '100%
', 'disabled
', 'category
');
8482 return 'ErrorBadValueForParameterRenderMode
'; // Should not happened
8494 public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = false, $title = 'RelatedObjects
')
8496 global $conf, $langs, $hookmanager;
8497 global $bc, $action;
8499 $object->fetchObjectLinked();
8501 // Bypass the default method
8502 $hookmanager->initHooks(array('commonobject
'));
8503 $parameters = array(
8504 'morehtmlright
' => $morehtmlright,
8505 'compatibleImportElementsList
' => &$compatibleImportElementsList,
8507 $reshook = $hookmanager->executeHooks('showLinkedObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
8509 if (empty($reshook)) {
8510 $nbofdifferenttypes = count($object->linkedObjects);
8513 print load_fiche_titre($langs->trans($title), $morehtmlright, '', 0, 0, 'showlinkedobjectblock
');
8516 print '<div
class=
"div-table-responsive-no-min">
';
8517 print '<table
class=
"noborder allwidth" data-block=
"showLinkedObject" data-element=
"'.$object->element.'" data-elementid=
"'.$object->id.'" >
';
8519 print '<tr
class=
"liste_titre">
';
8520 print '<td>
'.$langs->trans("Type").'</td>
';
8521 print '<td>
'.$langs->trans("Ref").'</td>
';
8522 print '<td
class=
"center"></td>
';
8523 print '<td
class=
"center">
'.$langs->trans("Date").'</td>
';
8524 print '<td
class=
"right">
'.$langs->trans("AmountHTShort").'</td>
';
8525 print '<td
class=
"right">
'.$langs->trans("Status").'</td>
';
8529 $nboftypesoutput = 0;
8531 foreach ($object->linkedObjects as $objecttype => $objects) {
8532 $tplpath = $element = $subelement = $objecttype;
8534 // to display inport button on tpl
8535 $showImportButton = false;
8536 if (!empty($compatibleImportElementsList) && in_array($element, $compatibleImportElementsList)) {
8537 $showImportButton = true;
8541 if ($objecttype != 'supplier_proposal
' && preg_match('/^([^_]+)_([^_]+)/i
', $objecttype, $regs)) {
8542 $element = $regs[1];
8543 $subelement = $regs[2];
8544 $tplpath = $element.'/
'.$subelement;
8546 $tplname = 'linkedobjectblock
';
8548 // To work with non standard path
8549 if ($objecttype == 'facture
') {
8550 $tplpath = 'compta/
'.$element;
8551 if (!isModEnabled('facture
')) {
8552 continue; // Do not show if module disabled
8554 } elseif ($objecttype == 'facturerec
') {
8555 $tplpath = 'compta/facture
';
8556 $tplname = 'linkedobjectblockForRec
';
8557 if (!isModEnabled('facture
')) {
8558 continue; // Do not show if module disabled
8560 } elseif ($objecttype == 'propal
') {
8561 $tplpath = 'comm/
'.$element;
8562 if (empty($conf->propal->enabled)) {
8563 continue; // Do not show if module disabled
8565 } elseif ($objecttype == 'supplier_proposal
') {
8566 if (empty($conf->supplier_proposal->enabled)) {
8567 continue; // Do not show if module disabled
8569 } elseif ($objecttype == 'shipping
' || $objecttype == 'shipment
') {
8570 $tplpath = 'expedition
';
8571 if (empty($conf->expedition->enabled)) {
8572 continue; // Do not show if module disabled
8574 } elseif ($objecttype == 'reception
') {
8575 $tplpath = 'reception
';
8576 if (empty($conf->reception->enabled)) {
8577 continue; // Do not show if module disabled
8579 } elseif ($objecttype == 'delivery
') {
8580 $tplpath = 'delivery
';
8581 if (empty($conf->expedition->enabled)) {
8582 continue; // Do not show if module disabled
8584 } elseif ($objecttype == 'ficheinter
') {
8585 $tplpath = 'fichinter
';
8586 if (empty($conf->ficheinter->enabled)) {
8587 continue; // Do not show if module disabled
8589 } elseif ($objecttype == 'invoice_supplier
') {
8590 $tplpath = 'fourn/facture
';
8591 } elseif ($objecttype == 'order_supplier
') {
8592 $tplpath = 'fourn/commande
';
8593 } elseif ($objecttype == 'expensereport
') {
8594 $tplpath = 'expensereport
';
8595 } elseif ($objecttype == 'subscription
') {
8596 $tplpath = 'adherents
';
8597 } elseif ($objecttype == 'conferenceorbooth
') {
8598 $tplpath = 'eventorganization
';
8599 } elseif ($objecttype == 'conferenceorboothattendee
') {
8600 $tplpath = 'eventorganization
';
8601 } elseif ($objecttype == 'mo
') {
8603 if (empty($conf->mrp->enabled)) {
8604 continue; // Do not show if module disabled
8608 global $linkedObjectBlock;
8609 $linkedObjectBlock = $objects;
8611 // Output template part (modules that overwrite templates must declare this into descriptor)
8612 $dirtpls = array_merge($conf->modules_parts['tpl
'], array('/
'.$tplpath.'/tpl
'));
8613 foreach ($dirtpls as $reldir) {
8614 if ($nboftypesoutput == ($nbofdifferenttypes - 1)) { // No more type to show after
8615 global $noMoreLinkedObjectBlockAfter;
8616 $noMoreLinkedObjectBlockAfter = 1;
8619 $res = @include dol_buildpath($reldir.'/
'.$tplname.'.tpl.php
');
8627 if (!$nboftypesoutput) {
8628 print '<tr><td
class=
"impair" colspan=
"7"><span
class=
"opacitymedium">
'.$langs->trans("None").'</span></td></tr>
';
8633 if (!empty($compatibleImportElementsList)) {
8634 $res = @include dol_buildpath('core/tpl/ajax/objectlinked_lineimport.tpl.php
');
8640 return $nbofdifferenttypes;
8652 public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array())
8654 global $conf, $langs, $hookmanager;
8658 $linktoelemlist = '';
8659 $listofidcompanytoscan = '';
8661 if (!is_object($object->thirdparty)) {
8662 $object->fetch_thirdparty();
8665 $possiblelinks = array();
8666 if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
8667 $listofidcompanytoscan = $object->thirdparty->id;
8668 if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) {
8669 $listofidcompanytoscan .= ',
'.$object->thirdparty->parent;
8671 if (($object->fk_project > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) {
8672 include_once DOL_DOCUMENT_ROOT.'/projet/
class/project.class.php
';
8673 $tmpproject = new Project($this->db);
8674 $tmpproject->fetch($object->fk_project);
8675 if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) {
8676 $listofidcompanytoscan .= ',
'.$tmpproject->socid;
8681 $possiblelinks = array(
8683 'enabled
'=>(!empty($conf->propal->enabled) ? $conf->propal->enabled : 0),
8685 'label
'=>'LinkToProposal
',
8686 '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
').')
'),
8688 'enabled
'=>(!empty($conf->commande->enabled) ? $conf->commande->enabled : 0),
8690 'label
'=>'LinkToOrder
',
8691 '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
').')
'),
8693 'enabled
'=>isModEnabled('facture
'),
8695 'label
'=>'LinkToInvoice
',
8696 '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
').')
'),
8697 'invoice_template
'=>array(
8698 'enabled
'=>isModEnabled('facture
'),
8700 'label
'=>'LinkToTemplateInvoice
',
8701 '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
').')
'),
8703 'enabled
'=>(!empty($conf->contrat->enabled) ? $conf->contrat->enabled : 0),
8705 'label
'=>'LinkToContract
',
8706 '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
8707 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
'
8710 'enabled
'=>(!empty($conf->ficheinter->enabled) ? $conf->ficheinter->enabled : 0),
8712 'label
'=>'LinkToIntervention
',
8713 '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
').')
'),
8714 'supplier_proposal
'=>array(
8715 'enabled
'=>(!empty($conf->supplier_proposal->enabled) ? $conf->supplier_proposal->enabled : 0),
8717 'label
'=>'LinkToSupplierProposal
',
8718 '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
').')
'),
8719 'order_supplier
'=>array(
8720 'enabled
'=>(!empty($conf->supplier_order->enabled) ? $conf->supplier_order->enabled : 0),
8722 'label
'=>'LinkToSupplierOrder
',
8723 '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
').')
'),
8724 'invoice_supplier
'=>array(
8725 'enabled
'=>(!empty($conf->supplier_invoice->enabled) ? $conf->supplier_invoice->enabled : 0),
8726 'perms
'=>1, 'label
'=>'LinkToSupplierInvoice
',
8727 '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
').')
'),
8729 'enabled
'=>(!empty($conf->ticket->enabled) ? $conf->ticket->enabled : 0),
8731 'label
'=>'LinkToTicket
',
8732 '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
').')
'),
8734 'enabled
'=>(!empty($conf->mrp->enabled) ? $conf->mrp->enabled : 0),
8736 'label
'=>'LinkToMo
',
8737 '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
').')
')
8741 if (!empty($listofidcompanytoscan)) { // If empty, we don't have criteria to scan the
object we can link to
8743 $hookmanager->initHooks(array(
'commonobject'));
8744 $parameters = array(
'listofidcompanytoscan' => $listofidcompanytoscan,
'possiblelinks' => $possiblelinks);
8745 $reshook = $hookmanager->executeHooks(
'showLinkToObjectBlock', $parameters, $object, $action);
8748 if (empty($reshook)) {
8749 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
8750 $possiblelinks = array_merge($possiblelinks, $hookmanager->resArray);
8752 } elseif ($reshook > 0) {
8753 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
8754 $possiblelinks = $hookmanager->resArray;
8758 foreach ($possiblelinks as $key => $possiblelink) {
8761 if (empty($possiblelink[
'enabled'])) {
8765 if (!empty($possiblelink[
'perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) {
8766 print
'<div id="'.$key.
'list"'.(empty($conf->use_javascript_ajax) ?
'' :
' style="display:none"').
'>';
8768 if (!empty($conf->global->MAIN_LINK_BY_REF_IN_LINKTO)) {
8769 print
'<br><form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="formlinkedbyref' . $key .
'">';
8770 print
'<input type="hidden" name="id" value="' . $object->id .
'">';
8771 print
'<input type="hidden" name="action" value="addlinkbyref">';
8772 print
'<input type="hidden" name="token" value="'.newToken().
'">';
8773 print
'<input type="hidden" name="addlink" value="' . $key .
'">';
8774 print
'<table class="noborder">';
8776 print
'<td>' . $langs->trans(
"Ref") .
'</td>';
8777 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>';
8783 $sql = $possiblelink[
'sql'];
8785 $resqllist = $this->
db->query($sql);
8787 $num = $this->
db->num_rows($resqllist);
8791 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formlinked'.$key.
'">';
8792 print
'<input type="hidden" name="action" value="addlink">';
8793 print
'<input type="hidden" name="token" value="'.newToken().
'">';
8794 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
8795 print
'<input type="hidden" name="addlink" value="'.$key.
'">';
8796 print
'<table class="noborder">';
8797 print
'<tr class="liste_titre">';
8798 print
'<td class="nowrap"></td>';
8799 print
'<td class="center">'.$langs->trans(
"Ref").
'</td>';
8800 print
'<td class="left">'.$langs->trans(
"RefCustomer").
'</td>';
8801 print
'<td class="right">'.$langs->trans(
"AmountHTShort").
'</td>';
8802 print
'<td class="left">'.$langs->trans(
"Company").
'</td>';
8805 $objp = $this->
db->fetch_object($resqllist);
8807 print
'<tr class="oddeven">';
8808 print
'<td class="left">';
8809 print
'<input type="radio" name="idtolinkto" id="'.$key.
'_'.$objp->rowid.
'" value="'.$objp->rowid.
'">';
8811 print
'<td class="center"><label for="'.$key.
'_'.$objp->rowid.
'">'.$objp->ref.
'</label></td>';
8812 print
'<td>'.(!empty($objp->ref_client) ? $objp->ref_client : (!empty($objp->ref_supplier) ? $objp->ref_supplier :
'')).
'</td>';
8813 print
'<td class="right">';
8814 if ($possiblelink[
'label'] ==
'LinkToContract') {
8816 print
$form->textwithpicto(
'', $langs->trans(
"InformationOnLinkToContract")).
' ';
8818 print
'<span class="amount">'.price($objp->total_ht).
'</span>';
8820 print
'<td>'.$objp->name.
'</td>';
8825 print
'<div class="center">';
8826 print
'<input type="submit" class="button valignmiddle marginleftonly marginrightonly" value="'.$langs->trans(
'ToLink').
'">';
8827 if (empty($conf->use_javascript_ajax)) {
8828 print
'<input type="submit" class="button button-cancel marginleftonly marginrightonly" name="cancel" value="'.$langs->trans(
"Cancel").
'"></div>';
8830 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>';
8833 $this->
db->free($resqllist);
8840 if ($num > 0 || !empty($conf->global->MAIN_LINK_BY_REF_IN_LINKTO)) {
8841 $linktoelemlist .=
'<li><a href="#linkto'.$key.
'" class="linkto dropdowncloseonclick" rel="'.$key.
'">'.$langs->trans($possiblelink[
'label']).
' ('.$num.
')</a></li>';
8844 $linktoelemlist .=
'<li><span class="linktodisabled">'.$langs->trans($possiblelink[
'label']).
' (0)</span></li>';
8849 if ($linktoelemlist) {
8851 <dl class="dropdown" id="linktoobjectname">
8853 if (!empty($conf->use_javascript_ajax)) {
8854 $linktoelem .=
'<dt><a href="#linktoobjectname"><span class="fas fa-link paddingrightonly"></span>'.$langs->trans(
"LinkTo").
'...</a></dt>';
8856 $linktoelem .=
'<dd>
8857 <div class="multiselectlinkto">
8858 <ul class="ulselectedfields">'.$linktoelemlist.
'
8867 if (!empty($conf->use_javascript_ajax)) {
8868 print
'<!-- Add js to show linkto box -->
8870 jQuery(document).ready(function() {
8871 jQuery(".linkto").click(function() {
8872 console.log("We choose to show/hide links for rel="+jQuery(this).attr(\'rel\')+" so #"+jQuery(this).attr(\'rel\')+"list");
8873 jQuery("#"+jQuery(this).attr(\'rel\')+"list").toggle();
8897 public function selectyesno($htmlname, $value =
'', $option = 0, $disabled =
false, $useempty = 0, $addjscombo = 0, $morecss =
'', $labelyes =
'Yes', $labelno =
'No')
8909 $disabled = ($disabled ?
' disabled' :
'');
8911 $resultyesno =
'<select class="flat width75'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.
'"'.$disabled.
'>'.
"\n";
8913 $resultyesno .=
'<option value="-1"'.(($value < 0) ?
' selected' :
'').
'> </option>'.
"\n";
8915 if ((
"$value" ==
'yes') || ($value == 1)) {
8916 $resultyesno .=
'<option value="'.$yes.
'" selected>'.$langs->trans($labelyes).
'</option>'.
"\n";
8917 $resultyesno .=
'<option value="'.$no.
'">'.$langs->trans($labelno).
'</option>'.
"\n";
8919 $selected = (($useempty && $value !=
'0' && $value !=
'no') ?
'' :
' selected');
8920 $resultyesno .=
'<option value="'.$yes.
'">'.$langs->trans($labelyes).
'</option>'.
"\n";
8921 $resultyesno .=
'<option value="'.$no.
'"'.$selected.
'>'.$langs->trans($labelno).
'</option>'.
"\n";
8923 $resultyesno .=
'</select>'.
"\n";
8929 return $resultyesno;
8945 $sql =
"SELECT rowid, label";
8946 $sql .=
" FROM ".$this->db->prefix().
"export_model";
8947 $sql .=
" WHERE type = '".$this->db->escape($type).
"'";
8948 $sql .=
" ORDER BY rowid";
8949 $result = $this->
db->query($sql);
8951 print
'<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
8953 print
'<option value="-1"> </option>';
8956 $num = $this->
db->num_rows($result);
8959 $obj = $this->
db->fetch_object($result);
8960 if ($selected == $obj->rowid) {
8961 print
'<option value="'.$obj->rowid.
'" selected>';
8963 print
'<option value="'.$obj->rowid.
'">';
8993 public function showrefnav($object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $morehtmlright =
'')
8995 global $conf, $langs, $hookmanager, $extralanguages;
8998 if (empty($fieldid)) {
9001 if (empty($fieldref)) {
9007 if (property_exists($object,
'gender') && !empty($object->gender)) {
9008 $addgendertxt =
' ';
9009 switch ($object->gender) {
9011 $addgendertxt .=
'<i class="fas fa-mars"></i>';
9014 $addgendertxt .=
'<i class="fas fa-venus"></i>';
9017 $addgendertxt .=
'<i class="fas fa-transgender"></i>';
9033 if (is_object($hookmanager)) {
9034 $parameters = array(
'showrefnav' =>
true);
9035 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
9036 $object->next_prev_filter .= $hookmanager->resPrint;
9038 $previous_ref = $next_ref =
'';
9041 $object->load_previous_next_ref((isset($object->next_prev_filter) ? $object->next_prev_filter :
''), $fieldid, $nodbprefix);
9043 $navurl = $_SERVER[
"PHP_SELF"];
9045 if ($paramid ==
'project_ref') {
9046 if (preg_match(
'/\/tasks\/(task|contact|note|document)\.php/', $navurl)) {
9047 $navurl = preg_replace(
'/\/tasks\/(task|contact|time|note|document)\.php/',
'/tasks.php', $navurl);
9054 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
9055 if ($conf->browser->name ==
'chrome') {
9056 $stringforfirstkey .=
' ALT +';
9057 } elseif ($conf->browser->name ==
'firefox') {
9058 $stringforfirstkey .=
' ALT + SHIFT +';
9060 $stringforfirstkey .=
' CTL +';
9063 $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>';
9064 $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>';
9068 $ret .=
'<!-- Start banner content --><div style="vertical-align: middle">';
9071 if ($morehtmlright) {
9072 $ret .=
'<div class="inline-block floatleft">'.$morehtmlright.
'</div>';
9075 if ($previous_ref || $next_ref || $morehtml) {
9076 $ret .=
'<div class="pagination paginationref"><ul class="right">';
9079 $ret .=
'<li class="noborder litext'.(($shownav && $previous_ref && $next_ref) ?
' clearbothonsmartphone' :
'').
'">'.$morehtml.
'</li>';
9081 if ($shownav && ($previous_ref || $next_ref)) {
9082 $ret .=
'<li class="pagination">'.$previous_ref.
'</li>';
9083 $ret .=
'<li class="pagination">'.$next_ref.
'</li>';
9085 if ($previous_ref || $next_ref || $morehtml) {
9086 $ret .=
'</ul></div>';
9089 $parameters = array();
9090 $reshook = $hookmanager->executeHooks(
'moreHtmlStatus', $parameters, $object);
9091 if (empty($reshook)) {
9092 $morehtmlstatus .= $hookmanager->resPrint;
9094 $morehtmlstatus = $hookmanager->resPrint;
9096 if ($morehtmlstatus) {
9097 $ret .=
'<div class="statusref">'.$morehtmlstatus.
'</div>';
9100 $parameters = array();
9101 $reshook = $hookmanager->executeHooks(
'moreHtmlRef', $parameters, $object);
9102 if (empty($reshook)) {
9103 $morehtmlref .= $hookmanager->resPrint;
9104 } elseif ($reshook > 0) {
9105 $morehtmlref = $hookmanager->resPrint;
9109 if ($morehtmlleft) {
9110 if ($conf->browser->layout ==
'phone') {
9111 $ret .=
'<!-- morehtmlleft --><div class="floatleft">'.$morehtmlleft.
'</div>';
9113 $ret .=
'<!-- morehtmlleft --><div class="inline-block floatleft">'.$morehtmlleft.
'</div>';
9118 $ret .=
'<div class="inline-block floatleft valignmiddle maxwidth750 marginbottomonly refid'.(($shownav && ($previous_ref || $next_ref)) ?
' refidpadding' :
'').
'">';
9121 if ($object->element ==
'societe') {
9125 $arrayoflangcode = array();
9126 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) {
9127 $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
9130 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
9131 if (!is_object($extralanguages)) {
9132 include_once DOL_DOCUMENT_ROOT.
'/core/class/extralanguages.class.php';
9135 $extralanguages->fetch_name_extralanguages(
'societe');
9137 if (!empty($extralanguages->attributes[
'societe'][
'name'])) {
9138 $object->fetchValuesForExtraLanguages();
9142 foreach ($arrayoflangcode as $extralangcode) {
9144 if ($object->array_languages[
'name'][$extralangcode]) {
9145 $htmltext .= $object->array_languages[
'name'][$extralangcode];
9147 $htmltext .=
'<span class="opacitymedium">'.$langs->trans(
"SwitchInEditModeToAddTranslation").
'</span>';
9150 $ret .=
'<!-- Show translations of name -->'.
"\n";
9151 $ret .= $this->
textwithpicto(
'', $htmltext, -1,
'language',
'opacitymedium paddingleft');
9154 } elseif ($object->element ==
'member') {
9155 $ret .= $object->ref.
'<br>';
9156 $fullname = $object->getFullName($langs);
9157 if ($object->morphy ==
'mor' && $object->societe) {
9158 $ret .=
dol_htmlentities($object->societe).((!empty($fullname) && $object->societe != $fullname) ?
' ('.
dol_htmlentities($fullname).$addgendertxt.
')' :
'');
9160 $ret .=
dol_htmlentities($fullname).$addgendertxt.((!empty($object->societe) && $object->societe != $fullname) ?
' ('.
dol_htmlentities($object->societe).
')' :
'');
9162 } elseif (in_array($object->element, array(
'contact',
'user',
'usergroup'))) {
9164 } elseif (in_array($object->element, array(
'action',
'agenda'))) {
9165 $ret .= $object->ref.
'<br>'.$object->label;
9166 } elseif (in_array($object->element, array(
'adherent_type'))) {
9167 $ret .= $object->label;
9168 } elseif ($object->element ==
'ecm_directories') {
9170 } elseif ($fieldref !=
'none') {
9176 if (substr($morehtmlref, 0, 4) !=
'<div') {
9180 $ret .= $morehtmlref;
9185 $ret .=
'</div><!-- End banner content -->';
9204 if (empty($object->barcode)) {
9209 if (empty($object->barcode_type_code) || empty($object->barcode_type_coder)) {
9210 $result = $object->fetch_barcode();
9213 return '<!-- ErrorFetchBarcode -->';
9218 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=barcode&generator='.urlencode($object->barcode_type_coder).
'&code='.urlencode($object->barcode).
'&encoding='.urlencode($object->barcode_type_code);
9219 $out =
'<!-- url barcode = '.$url.
' -->';
9220 $out .=
'<img src="'.$url.
'"'.($morecss ?
' class="'.$morecss.
'"' :
'').
'>';
9240 public static function showphoto($modulepart, $object, $width = 100, $height = 0, $caneditfield = 0, $cssclass =
'photowithmargin', $imagesize =
'', $addlinktofullsize = 1, $cache = 0, $forcecapture =
'', $noexternsourceoverwrite = 0)
9242 global $conf, $langs;
9244 $entity = (!empty($object->entity) ? $object->entity : $conf->entity);
9245 $id = (!empty($object->id) ? $object->id : $object->rowid);
9254 if ($modulepart ==
'societe') {
9255 $dir = $conf->societe->multidir_output[$entity];
9256 if (!empty($object->logo)) {
9258 if ((
string) $imagesize ==
'mini') {
9260 } elseif ((
string) $imagesize ==
'small') {
9263 $file =
get_exdir(0, 0, 0, 0, $object,
'thirdparty').
'logos/'.$object->logo;
9265 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'thirdparty').
'logos/'.$object->logo;
9268 $email = $object->email;
9269 } elseif ($modulepart ==
'contact') {
9270 $dir = $conf->societe->multidir_output[$entity].
'/contact';
9271 if (!empty($object->photo)) {
9273 if ((
string) $imagesize ==
'mini') {
9275 } elseif ((
string) $imagesize ==
'small') {
9278 $file =
get_exdir(0, 0, 0, 0, $object,
'contact').
'photos/'.$object->photo;
9280 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'contact').
'photos/'.$object->photo;
9283 $email = $object->email;
9285 } elseif ($modulepart ==
'userphoto') {
9286 $dir = $conf->user->dir_output;
9287 if (!empty($object->photo)) {
9289 if ((
string) $imagesize ==
'mini') {
9291 } elseif ((
string) $imagesize ==
'small') {
9294 $file =
get_exdir(0, 0, 0, 0, $object,
'user').
'photos/'.$object->photo;
9296 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'user').
'photos/'.$object->photo;
9299 if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
9300 $altfile = $object->id.
".jpg";
9302 $email = $object->email;
9304 } elseif ($modulepart ==
'memberphoto') {
9305 $dir = $conf->adherent->dir_output;
9306 if (!empty($object->photo)) {
9308 if ((
string) $imagesize ==
'mini') {
9310 } elseif ((
string) $imagesize ==
'small') {
9313 $file =
get_exdir(0, 0, 0, 0, $object,
'member').
'photos/'.$object->photo;
9315 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'member').
'photos/'.$object->photo;
9318 if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
9319 $altfile = $object->id.
".jpg";
9321 $email = $object->email;
9325 $dir = $conf->$modulepart->dir_output;
9326 if (!empty($object->photo)) {
9328 if ((
string) $imagesize ==
'mini') {
9330 } elseif ((
string) $imagesize ==
'small') {
9333 $file =
get_exdir($id, 2, 0, 0, $object, $modulepart).
'photos/'.$object->photo;
9335 $originalfile =
get_exdir($id, 2, 0, 0, $object, $modulepart).
'photos/'.$object->photo;
9338 if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
9339 $altfile = $object->id.
".jpg";
9341 $email = $object->email;
9344 if ($forcecapture) {
9345 $capture = $forcecapture;
9349 if ($file && file_exists($dir.
"/".$file)) {
9350 if ($addlinktofullsize) {
9353 $ret .=
'<a href="'.$urladvanced.
'">';
9355 $ret .=
'<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($originalfile).
'&cache='.$cache.
'">';
9358 $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.
'">';
9359 if ($addlinktofullsize) {
9362 } elseif ($altfile && file_exists($dir.
"/".$altfile)) {
9363 if ($addlinktofullsize) {
9366 $ret .=
'<a href="'.$urladvanced.
'">';
9368 $ret .=
'<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($originalfile).
'&cache='.$cache.
'">';
9371 $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.
'">';
9372 if ($addlinktofullsize) {
9376 $nophoto =
'/public/theme/common/nophoto.png';
9377 $defaultimg =
'identicon';
9378 if (in_array($modulepart, array(
'societe',
'userphoto',
'contact',
'memberphoto'))) {
9379 if ($modulepart ==
'societe' || ($modulepart ==
'memberphoto' && strpos($object->morphy,
'mor')) !==
false) {
9380 $nophoto =
'company';
9382 $nophoto =
'/public/theme/common/user_anonymous.png';
9383 if (!empty($object->gender) && $object->gender ==
'man') {
9384 $nophoto =
'/public/theme/common/user_man.png';
9386 if (!empty($object->gender) && $object->gender ==
'woman') {
9387 $nophoto =
'/public/theme/common/user_woman.png';
9392 if (!empty($conf->gravatar->enabled) && $email && empty($noexternsourceoverwrite)) {
9394 $ret .=
'<!-- Put link to gravatar -->';
9395 $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.
'">';
9397 if ($nophoto ==
'company') {
9398 $ret .=
'<div class="divforspanimg photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" alt="" '.($width ?
' width="'.$width.
'"' :
'').($height ?
' height="'.$height.
'"' :
'').
'>'.
img_picto(
'',
'company').
'</div>';
9399 $ret .=
'<div class="difforspanimgright"></div>';
9401 $ret .=
'<img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" alt="" '.($width ?
' width="'.$width.
'"' :
'').($height ?
' height="'.$height.
'"' :
'').
' src="'.DOL_URL_ROOT.$nophoto.
'">';
9406 if ($caneditfield) {
9407 if ($object->photo) {
9410 $ret .=
'<table class="nobordernopadding centpercent">';
9411 if ($object->photo) {
9412 $ret .=
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">'.$langs->trans(
"Delete").
'</label><br><br></td></tr>';
9414 $ret .=
'<tr><td class="tdoverflow">';
9416 $maxmin = $maxfilesizearray[
'maxmin'];
9418 $ret .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
9420 $ret .=
'<input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"'.($capture ?
' capture="'.$capture.
'"' :
'').
'>';
9421 $ret .=
'</td></tr>';
9425 dol_print_error(
'',
'Call of showphoto with wrong parameters modulepart='.$modulepart);
9448 public function select_dolgroups($selected =
'', $htmlname =
'groupid', $show_empty = 0, $exclude =
'', $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0', $multiple =
false, $morecss =
'')
9451 global $conf, $user, $langs;
9454 $excludeGroups = null;
9455 if (is_array($exclude)) {
9456 $excludeGroups = implode(
",", $exclude);
9459 $includeGroups = null;
9460 if (is_array($include)) {
9461 $includeGroups = implode(
",", $include);
9464 if (!is_array($selected)) {
9465 $selected = array($selected);
9471 $sql =
"SELECT ug.rowid, ug.nom as name";
9472 if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
9473 $sql .=
", e.label";
9475 $sql .=
" FROM ".$this->db->prefix().
"usergroup as ug ";
9476 if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
9477 $sql .=
" LEFT JOIN ".$this->db->prefix().
"entity as e ON e.rowid=ug.entity";
9478 if ($force_entity) {
9479 $sql .=
" WHERE ug.entity IN (0, ".$force_entity.
")";
9481 $sql .=
" WHERE ug.entity IS NOT NULL";
9484 $sql .=
" WHERE ug.entity IN (0, ".$conf->entity.
")";
9486 if (is_array($exclude) && $excludeGroups) {
9487 $sql .=
" AND ug.rowid NOT IN (".$this->db->sanitize($excludeGroups).
")";
9489 if (is_array($include) && $includeGroups) {
9490 $sql .=
" AND ug.rowid IN (".$this->db->sanitize($includeGroups).
")";
9492 $sql .=
" ORDER BY ug.nom ASC";
9494 dol_syslog(get_class($this).
"::select_dolgroups", LOG_DEBUG);
9498 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
9500 $out .=
'<select class="flat minwidth200'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.($multiple ?
'[]' :
'').
'" '.($multiple ?
'multiple' :
'').
' '.($disabled ?
' disabled' :
'').
'>';
9502 $num = $this->
db->num_rows(
$resql);
9505 if ($show_empty && !$multiple) {
9506 $out .=
'<option value="-1"'.(in_array(-1, $selected) ?
' selected' :
'').
'> </option>'.
"\n";
9510 $obj = $this->
db->fetch_object(
$resql);
9512 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
9516 $out .=
'<option value="'.$obj->rowid.
'"';
9518 $out .=
' disabled';
9520 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))) {
9521 $out .=
' selected';
9526 if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) {
9527 $out .=
" (".$obj->label.
")";
9530 $out .=
'</option>';
9535 $out .=
'<option value="-1"'.(in_array(-1, $selected) ?
' selected' :
'').
'></option>'.
"\n";
9537 $out .=
'<option value="" disabled>'.$langs->trans(
"NoUserGroupDefined").
'</option>';
9539 $out .=
'</select>';
9558 $out =
'<div class="nowraponall">';
9559 if ($pos ==
'left') {
9560 $out .=
'<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fa fa-remove"></span></button>';
9561 $out .=
'<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
9563 $out .=
'<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
9564 $out .=
'<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fa fa-remove"></span></button>';
9579 public function showCheckAddButtons($cssclass =
'checkforaction', $calljsfunction = 0, $massactionname =
"massaction")
9581 global $conf, $langs;
9585 if (!empty($conf->use_javascript_ajax)) {
9586 $out .=
'<div class="inline-block checkallactions"><input type="checkbox" id="'.$cssclass.
's" name="'.$cssclass.
's" class="checkallactions"></div>';
9589 $(document).ready(function() {
9590 $("#' . $cssclass.
's").click(function() {
9591 if($(this).is(\':checked\')){
9592 console.log("We check all '.$cssclass.
' and trigger the change method");
9593 $(".'.$cssclass.
'").prop(\'checked\', true).trigger(\'change\');
9597 console.log("We uncheck all");
9598 $(".'.$cssclass.
'").prop(\'checked\', false).trigger(\'change\');
9600 if ($calljsfunction) {
9601 $out .=
'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "'.$massactionname.
'", "'.$cssclass.
'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
9604 $(".' . $cssclass.
'").change(function() {
9605 $(this).closest("tr").toggleClass("highlight", this.checked);
9625 if ($addcheckuncheckall) {
9644 public function selectExpenseCategories($selected =
'', $htmlname =
'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target =
'', $default_selected = 0, $params = array(), $info_admin = 1)
9646 global $langs, $user;
9649 $sql =
"SELECT rowid, label FROM ".$this->db->prefix().
"c_exp_tax_cat WHERE active = 1";
9650 $sql .=
" AND entity IN (0,".getEntity(
'exp_tax_cat').
")";
9651 if (!empty($excludeid)) {
9652 $sql .=
" AND rowid NOT IN (".$this->db->sanitize(implode(
',', $excludeid)).
")";
9654 $sql .=
" ORDER BY label";
9658 $out =
'<select id="select_'.$htmlname.
'" name="'.$htmlname.
'" class="'.$htmlname.
' flat minwidth75imp maxwidth200">';
9660 $out .=
'<option value="0"> </option>';
9663 while ($obj = $this->
db->fetch_object(
$resql)) {
9664 $out .=
'<option '.($selected == $obj->rowid ?
'selected="selected"' :
'').
' value="'.$obj->rowid.
'">'.$langs->trans($obj->label).
'</option>';
9666 $out .=
'</select>';
9669 if (!empty($htmlname) && $user->admin && $info_admin) {
9670 $out .=
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
9673 if (!empty($target)) {
9674 $sql =
"SELECT c.id FROM ".$this->db->prefix().
"c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1";
9677 if ($this->
db->num_rows(
$resql) > 0) {
9678 $obj = $this->
db->fetch_object(
$resql);
9681 $("select[name='.$target.
']").on("change", function() {
9682 var current_val = $(this).val();
9683 if (current_val == '.$obj->id.
') {';
9684 if (!empty($default_selected) || !empty($selected)) {
9685 $out .=
'$("select[name='.$htmlname.
']").val("'.($default_selected > 0 ? $default_selected : $selected).
'");';
9689 $("select[name='.$htmlname.
']").change();
9693 $("select[name='.$htmlname.
']").change(function() {
9695 if ($("select[name='.$target.
']").val() == '.$obj->id.
') {
9696 // get price of kilometer to fill the unit price
9700 data: { fk_c_exp_tax_cat: $(this).val(), token: \''.
currentToken().
'\' },
9701 url:
"'.(DOL_URL_ROOT.'/expensereport/ajax/ajaxik.php?'.$params).'",
9702 }).done(
function( data, textStatus, jqXHR ) {
9704 if (typeof data.up !=
"undefined") {
9705 $(
"input[name=value_unit]").val(data.up);
9706 $(
"select[name='.$htmlname.']").attr(
"title", data.title);
9708 $(
"input[name=value_unit]").val(
"");
9709 $(
"select[name='.$htmlname.']").attr(
"title",
"");
9720 dol_print_error($this->db);
9734 public function selectExpenseRanges($selected = '', $htmlname = 'fk_range
', $useempty = 0)
9736 global $conf, $langs;
9739 $sql = "SELECT rowid, range_ik FROM ".$this->db->prefix()."c_exp_tax_range";
9740 $sql .= " WHERE entity = ".$conf->entity." AND active = 1";
9742 $resql = $this->db->query($sql);
9744 $out = '<select
id=
"select_'.$htmlname.'" name=
"'.$htmlname.'" class=
"'.$htmlname.' flat minwidth75imp">
';
9746 $out .= '<option value=
"0"></option>
';
9749 while ($obj = $this->db->fetch_object($resql)) {
9750 $out .= '<option
'.($selected == $obj->rowid ? 'selected=
"selected"' : '').' value=
"'.$obj->rowid.'">
'.price($obj->range_ik, 0, $langs, 1, 0).'</option>
';
9752 $out .= '</select>
';
9754 dol_print_error($this->db);
9770 public function selectExpense($selected = '', $htmlname = 'fk_c_type_fees
', $useempty = 0, $allchoice = 1, $useid = 0)
9775 $sql = "SELECT id, code, label FROM ".$this->db->prefix()."c_type_fees";
9776 $sql .= " WHERE active = 1";
9778 $resql = $this->db->query($sql);
9780 $out = '<select
id=
"select_'.$htmlname.'" name=
"'.$htmlname.'" class=
"'.$htmlname.' flat minwidth75imp">
';
9782 $out .= '<option value=
"0"></option>
';
9785 $out .= '<option value=
"-1">
'.$langs->trans('AllExpenseReport
').'</option>
';
9793 while ($obj = $this->db->fetch_object($resql)) {
9794 $key = $langs->trans($obj->code);
9795 $out .= '<option
'.($selected == $obj->{$field} ? 'selected=
"selected"' : '').' value=
"'.$obj->{$field}.'">
'.($key != $obj->code ? $key : $obj->label).'</option>
';
9797 $out .= '</select>
';
9799 dol_print_error($this->db);
9823 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)
9825 global $user, $conf, $langs;
9827 require_once DOL_DOCUMENT_ROOT.'/projet/
class/project.class.php
';
9829 if (is_null($usertofilter)) {
9830 $usertofilter = $user;
9835 $hideunselectables = false;
9836 if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) {
9837 $hideunselectables = true;
9840 if (empty($projectsListId)) {
9841 if (empty($usertofilter->rights->projet->all->lire)) {
9842 $projectstatic = new Project($this->db);
9843 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
9847 // Search all projects
9848 $sql = "SELECT f.rowid, f.ref as fref, 'nolabel
' as flabel, p.rowid as pid, f.ref,
9849 p.title, p.fk_soc, p.fk_statut, p.public,";
9850 $sql .= ' s.nom as
name';
9851 $sql .= ' FROM
'.$this->db->prefix().'projet as p
';
9852 $sql .= ' LEFT JOIN
'.$this->db->prefix().'societe as s ON s.rowid = p.fk_soc,
';
9853 $sql .= ' '.$this->db->prefix().'facture as f
';
9854 $sql .= " WHERE p.entity IN (".getEntity('project
').")";
9855 $sql .= " AND f.fk_projet = p.rowid AND f.fk_statut=0"; //Brouillons seulement
9856 //if ($projectsListId) $sql.= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")";
9857 //if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
9858 //if ($socid > 0) $sql.= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)";
9859 $sql .= " ORDER BY p.ref, f.ref ASC";
9861 $resql = $this->db->query($sql);
9863 // Use select2 selector
9864 if (!empty($conf->use_javascript_ajax)) {
9865 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php
';
9866 $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
9867 $out .= $comboenhancement;
9868 $morecss = 'minwidth200imp maxwidth500
';
9871 if (empty($option_only)) {
9872 $out .= '<select
class=
"valignmiddle flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled=
"disabled"' : '').' id=
"'.$htmlname.'" name=
"'.$htmlname.'">
';
9874 if (!empty($show_empty)) {
9875 $out .= '<option value=
"0" class=
"optiongrey">
';
9876 if (!is_numeric($show_empty)) {
9877 $out .= $show_empty;
9881 $out .= '</option>
';
9883 $num = $this->db->num_rows($resql);
9887 $obj = $this->db->fetch_object($resql);
9888 // 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.
9889 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($usertofilter->rights->societe->lire)) {
9892 if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED) {
9899 if ($showproject == 'all
') {
9900 $labeltoshow .= dol_trunc($obj->ref, 18); // Invoice ref
9902 $labeltoshow .= ' -
'.$obj->name; // Soc name
9906 if ($obj->fk_statut == Project::STATUS_DRAFT) {
9908 $labeltoshow .= ' -
'.$langs->trans("Draft");
9909 } elseif ($obj->fk_statut == Project::STATUS_CLOSED) {
9910 if ($discard_closed == 2) {
9913 $labeltoshow .= ' -
'.$langs->trans("Closed");
9914 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
9916 $labeltoshow .= ' -
'.$langs->trans("LinkedToAnotherCompany");
9920 if (!empty($selected) && $selected == $obj->rowid) {
9921 $out .= '<option value=
"'.$obj->rowid.'" selected
';
9922 //if ($disabled) $out.=' disabled
'; // with select2, field can't be preselected
if disabled
9923 $out .=
'>'.$labeltoshow.
'</option>';
9925 if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
9928 $resultat =
'<option value="'.$obj->rowid.
'"';
9930 $resultat .=
' disabled';
9935 $resultat .= $labeltoshow;
9936 $resultat .=
'</option>';
9944 if (empty($option_only)) {
9945 $out .=
'</select>';
9971 public function selectInvoiceRec($selected =
'', $htmlname =
'facrecid', $maxlength = 24, $option_only = 0, $show_empty =
'1', $forcefocus = 0, $disabled = 0, $morecss =
'maxwidth500')
9973 global $user, $conf, $langs;
9979 $sql =
'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc';
9981 $sql .=
' FROM ' . MAIN_DB_PREFIX .
'facture_rec as f';
9982 $sql .=
" WHERE f.entity IN (" .
getEntity(
'invoice') .
")";
9983 $sql .=
" ORDER BY f.titre ASC";
9988 if (!empty($conf->use_javascript_ajax)) {
9989 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
9990 $comboenhancement =
ajax_combobox($htmlname,
'', 0, $forcefocus);
9991 $out .= $comboenhancement;
9992 $morecss =
'minwidth200imp maxwidth500';
9995 if (empty($option_only)) {
9996 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' id="' . $htmlname .
'" name="' . $htmlname .
'">';
9998 if (!empty($show_empty)) {
9999 $out .=
'<option value="0" class="optiongrey">';
10000 if (!is_numeric($show_empty)) {
10001 $out .= $show_empty;
10005 $out .=
'</option>';
10007 $num = $this->
db->num_rows(
$resql);
10009 while ($obj = $this->
db->fetch_object(
$resql)) {
10010 $labeltoshow =
dol_trunc($obj->title, 18);
10013 if (!empty($obj->suspended)) {
10015 $labeltoshow .=
' - ' . $langs->trans(
"Closed");
10019 if (!empty($selected) && $selected == $obj->rowid) {
10020 $out .=
'<option value="' . $obj->rowid .
'" selected';
10022 $out .=
'>' . $labeltoshow .
'</option>';
10024 if ($disabled && ($selected != $obj->rowid)) {
10027 $resultat =
'<option value="' . $obj->rowid .
'"';
10029 $resultat .=
' disabled';
10032 $resultat .= $labeltoshow;
10033 $resultat .=
'</option>';
10039 if (empty($option_only)) {
10040 $out .=
'</select>';
10048 $this->errors[]=$this->
db->lasterror;
10062 public function searchComponent($arrayofcriterias, $search_component_params, $arrayofinputfieldsalreadyoutput = array(), $search_component_params_hidden =
'')
10068 $ret .=
'<div class="divadvancedsearchfieldcomp inline-block">';
10070 $ret .=
'<a href="#" class="dropdownsearch-toggle unsetcolor">';
10071 $ret .=
'<span class="fas fa-filter linkobject boxfilter pictofixedwidth" title="'.dol_escape_htmltag($langs->trans(
"Filters")).
'" id="idsubimgproductdistribution"></span>';
10075 $ret .=
'<div class="divadvancedsearchfieldcompinput inline-block minwidth500 maxwidth300onsmartphone">';
10078 $ret .=
'<div name="divsearch_component_params" class="noborderbottom search_component_params inline-block valignmiddle">';
10080 if ($search_component_params_hidden) {
10081 if (!preg_match(
'/^\(.*\)$/', $search_component_params_hidden)) {
10082 $search_component_params_hidden .=
'('.$search_component_params_hidden.
')';
10084 $errormessage =
'';
10085 if (!
dolCheckFilters($search_component_params_hidden, $errormessage)) {
10086 print
'ERROR in parsing search string';
10088 $regexstring =
'\(([^:\'\(\)]+:[^:\'\(\)]+:[^\(\)]+)\)';
10090 $htmltags = preg_replace_callback(
'/'.$regexstring.
'/',
'dolForgeCriteriaCallback', $search_component_params_hidden);
10092 $ret .=
'<span class="marginleftonlyshort valignmiddle tagsearch"><span class="tagsearchdelete select2-selection__choice__remove">x</span> '.$htmltags.
'</span>';
10101 $show_search_component_params_hidden = 1;
10102 if ($show_search_component_params_hidden) {
10103 $ret .=
'<input type="hidden" name="show_search_component_params_hidden" value="1">';
10105 $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%')) -->";
10106 $ret .=
'<input type="hidden" name="search_component_params_hidden" value="'.dol_escape_htmltag($search_component_params_hidden).
'">';
10108 foreach ($arrayofcriterias as $criterias) {
10109 foreach ($criterias as $criteriafamilykey => $criteriafamilyval) {
10110 if (in_array(
'search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput)) {
10113 if (in_array($criteriafamilykey, array(
'rowid',
'ref_ext',
'entity',
'extraparams'))) {
10116 if (in_array($criteriafamilyval[
'type'], array(
'date',
'datetime',
'timestamp'))) {
10117 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_start">';
10118 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_startyear">';
10119 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_startmonth">';
10120 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_startday">';
10121 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_end">';
10122 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_endyear">';
10123 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_endmonth">';
10124 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_endday">';
10126 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'">';
10133 $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";
10134 $ret .=
'<input type="text" placeholder="'.$langs->trans(
"Search").
'" name="search_component_params_input" class="noborderbottom search_component_input" value="">';
10153 global $langs, $user;
10157 $TModels = array();
10159 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
10161 $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs);
10164 $TModels[0] = $langs->trans(
'DefaultMailModel');
10167 foreach ($formmail->lines_model as $model) {
10168 $TModels[$model->id] = $model->label;
10172 $retstring .=
'<select class="flat" id="select_'.$prefix.
'model_mail" name="'.$prefix.
'model_mail">';
10174 foreach ($TModels as $id_model => $label_model) {
10175 $retstring .=
'<option value="'.$id_model.
'"';
10176 $retstring .=
">".$label_model.
"</option>";
10179 $retstring .=
"</select>";
10182 $retstring .=
ajax_combobox(
'select_'.$prefix.
'model_mail');
10199 public function buttonsSaveCancel($save_label =
'Save', $cancel_label =
'Cancel', $morebuttons = array(), $withoutdiv = 0, $morecss =
'', $dol_openinpopup =
'')
10203 $buttons = array();
10207 'label_key' => $save_label,
10210 if ($save_label ==
'Create' || $save_label ==
'Add' ) {
10211 $save[
'name'] =
'add';
10212 } elseif ($save_label ==
'Modify') {
10213 $save[
'name'] =
'edit';
10217 'name' =>
'cancel',
10218 'label_key' =>
'Cancel',
10221 !empty($save_label) ? $buttons[] = $save :
'';
10223 if (!empty($morebuttons)) {
10224 $buttons[] = $morebuttons;
10227 !empty($cancel_label) ? $buttons[] = $cancel :
'';
10229 $retstring = $withoutdiv ?
'':
'<div class="center">';
10231 foreach ($buttons as $button) {
10232 $addclass = empty($button[
'addclass']) ?
'' : $button[
'addclass'];
10233 $retstring .=
'<input type="submit" class="button button-'.$button[
'name'].($morecss ?
' '.$morecss :
'').
' '.$addclass.
'" name="'.$button[
'name'].
'" value="'.
dol_escape_htmltag($langs->trans($button[
'label_key'])).
'">';
10235 $retstring .= $withoutdiv ?
'':
'</div>';
10237 if ($dol_openinpopup) {
10238 $retstring .=
'<!-- buttons are shown into a $dol_openinpopup='.$dol_openinpopup.
' context, so we enable the close of dialog on cancel -->'.
"\n";
10239 $retstring .=
'<script>';
10240 $retstring .=
'jQuery(".button-cancel").click(function(e) {
10241 e.preventDefault(); console.log(\'We click on cancel in iframe popup '.$dol_openinpopup.
'\');
10242 window.parent.jQuery(\
'#idfordialog'.$dol_openinpopup.
'\').dialog(\
'close\');
10244 $retstring .=
'</script>';
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolIsAllowedForPreview($file)
Return if a file is qualified for preview.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
getMaxFileSizeArray()
Return the max allowed for file upload.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
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...
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
const STATUS_CLOSED
Warehouse closed, inactive.
Class to parse product price expressions.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
const STATUS_OPEN_ALL
Warehouse open and operations for customer shipping, supplier dispatch, internal stock transfers/corr...
$conf db
API class for accounts.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0)
Clean a string to keep only desirable HTML tags.
Class to manage products or services.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
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...
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...
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
const TYPE_SERVICE
Service.
const TYPE_PRODUCT
Regular product.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
$conf db name
Only used if Module[ID]Name translation string is not found.
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...
Class to manage bank accounts.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
currency_name($code_iso, $withcode= '', $outputlangs=null)
Return label of currency or code+label.
getImageFileNameForSize($file, $extName, $extImgTarget= '')
Return the filename of file to get the thumbs.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput= 'no', $use_short_label=0)
Output a dimension with best unit.
const STATUS_OPEN_INTERNAL
Warehouse open and operations for stock transfers/corrections allowed (not for customer shipping and ...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage third parties objects (customers, suppliers, prospects...)
dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea'), $cleanalsosomestyles=0)
Clean a string from some undesirable HTML tags.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to manage categories.
getServerTimeZoneInt($refgmtdate= 'now')
Return server timezone int.
print *****$script_file(".$version.") pid code
! Closing after partial payment: discount_vat, badcustomer or badsupplier, bankcharge, other ! Closing when no payment: replaced, abandoned
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= 'hideonsmartphone', $textfordropdown= '')
Show information for admin users or standard users.
Class to manage projects.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dolCheckFilters($sqlfilters, &$error= '')
Return if a $sqlfilters parameter is valid and will pass the preg_replace_callback() to replace Gener...
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve', $idforemptyvalue= '-1')
Convert a html select field into an ajax combobox.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_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...
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
testSqlAndScriptInject($val, $type)
Security: WAF layer for SQL Injection and XSS Injection (scripts) protection (Filters on GET...
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Class to manage a WYSIWYG editor.
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length. ...
Class to manage invoices.
picto_from_langcode($codelang, $moreatt= '', $notitlealt=0)
Return img flag of country for a language code or country code.
currentToken()
Return the value of token currently saved into session with name 'token'.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param= '')
Return URL we can use for advanced preview links.
$formconfirm
if ($action == 'delbookkeepingyear') {
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
Class to manage predefined suppliers products.
measuringUnitString($unit, $measuring_style= '', $scale= '', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
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...