68 public $errors = array();
75 public $cache_types_paiements = array();
76 public $cache_conditions_paiements = array();
77 public $cache_transport_mode = array();
78 public $cache_availability = array();
79 public $cache_demand_reason = array();
80 public $cache_types_fees = array();
81 public $cache_vatrates = array();
110 public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata =
'string', $moreparam =
'', $fieldrequired = 0, $notabletag = 0, $paramid =
'id', $help =
'')
112 global $conf, $langs;
117 if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match(
'/^select;/', $typeofdata)) {
119 $tmp = explode(
':', $typeofdata);
120 $ret .=
'<div class="editkey_' . $tmp[0] . (!empty($tmp[1]) ?
' ' . $tmp[1] :
'') .
'" id="' . $htmlname .
'">';
121 if ($fieldrequired) {
122 $ret .=
'<span class="fieldrequired">';
127 $ret .= $langs->trans($text);
129 if ($fieldrequired) {
132 $ret .=
'</div>' .
"\n";
134 if ($fieldrequired) {
135 $ret .=
'<span class="fieldrequired">';
140 $ret .= $langs->trans($text);
142 if ($fieldrequired) {
147 if (empty($notabletag) && $perm) {
148 $ret .=
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
150 if ($fieldrequired) {
151 $ret .=
'<span class="fieldrequired">';
156 $ret .= $langs->trans($text);
158 if ($fieldrequired) {
161 if (!empty($notabletag)) {
164 if (empty($notabletag) && $perm) {
167 if (empty($notabletag) && $perm) {
168 $ret .=
'<td class="right">';
170 if ($htmlname &&
GETPOST(
'action',
'aZ09') !=
'edit' . $htmlname && $perm) {
171 $ret .=
'<a class="editfielda reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?action=edit' . $htmlname .
'&token=' . newToken() .
'&' . $paramid .
'=' . $object->id . $moreparam .
'">' .
img_edit($langs->trans(
'Edit'), ($notabletag ? 0 : 1)) .
'</a>';
173 if (!empty($notabletag) && $notabletag == 1) {
180 if (!empty($notabletag) && $notabletag == 3) {
183 if (empty($notabletag) && $perm) {
186 if (empty($notabletag) && $perm) {
187 $ret .=
'</tr></table>';
217 public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata =
'string', $editvalue =
'', $extObject =
null, $custommsg =
null, $moreparam =
'', $notabletag = 1, $formatfunc =
'', $paramid =
'id', $gm =
'auto', $moreoptions = array(), $editaction =
'')
219 global $conf, $langs;
224 if (empty($typeofdata)) {
225 return 'ErrorBadParameter typeofdata is empty';
228 if ($typeofdata ==
'datetime') {
229 $typeofdata =
'dayhour';
232 if (preg_match(
'/^(\w+)\((\d+)\)$/', $typeofdata, $reg)) {
233 if ($reg[1] ==
'varchar') {
234 $typeofdata =
'string';
235 } elseif ($reg[1] ==
'int') {
236 $typeofdata =
'numeric';
238 return 'ErrorBadParameter ' . $typeofdata;
243 if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match(
'/^select;|day|datepicker|dayhour|datehourpicker/', $typeofdata)) {
244 $ret .= $this->
editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg);
246 if ($editaction ==
'') {
247 $editaction =
GETPOST(
'action',
'aZ09');
249 $editmode = ($editaction ==
'edit' . $htmlname);
252 $ret .=
'<form method="post" action="' . $_SERVER[
"PHP_SELF"] . ($moreparam ?
'?' . $moreparam :
'') .
'">';
253 $ret .=
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
254 $ret .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
255 $ret .=
'<input type="hidden" name="' . $paramid .
'" value="' . $object->id .
'">';
256 if (empty($notabletag)) {
257 $ret .=
'<table class="nobordernopadding centpercent">';
259 if (empty($notabletag)) {
262 if (preg_match(
'/^(string|safehtmlstring|email|phone|url)/', $typeofdata)) {
263 $tmp = explode(
':', $typeofdata);
264 $ret .=
'<input type="text" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . ($editvalue ? $editvalue : $value) .
'"' . (empty($tmp[1]) ?
'' :
' size="' . $tmp[1] .
'"') .
' autofocus>';
265 } elseif (preg_match(
'/^(integer)/', $typeofdata)) {
266 $tmp = explode(
':', $typeofdata);
267 $valuetoshow =
price2num($editvalue ? $editvalue : $value, 0);
268 $ret .=
'<input type="text" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $valuetoshow .
'"' . (empty($tmp[1]) ?
'' :
' size="' . $tmp[1] .
'"') .
' autofocus>';
269 } elseif (preg_match(
'/^(numeric|amount)/', $typeofdata)) {
270 $tmp = explode(
':', $typeofdata);
271 $valuetoshow =
price2num($editvalue ? $editvalue : $value);
272 $ret .=
'<input type="text" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . ($valuetoshow !=
'' ?
price($valuetoshow) :
'') .
'"' . (empty($tmp[1]) ?
'' :
' size="' . $tmp[1] .
'"') .
' autofocus>';
273 } elseif (preg_match(
'/^(checkbox)/', $typeofdata)) {
274 $tmp = explode(
':', $typeofdata);
275 $ret .=
'<input type="checkbox" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . ($value ? $value :
'on') .
'"' . ($value ?
' checked' :
'') . (empty($tmp[1]) ?
'' : $tmp[1]) .
'/>';
276 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) {
277 $tmp = explode(
':', $typeofdata);
278 $cols = (empty($tmp[2]) ?
'' : $tmp[2]);
280 if (preg_match(
'/%/', $cols)) {
281 $morealt =
' style="width: ' . $cols .
'"';
284 $valuetoshow = ($editvalue ? $editvalue : $value);
285 $ret .=
'<textarea id="' . $htmlname .
'" name="' . $htmlname .
'" wrap="soft" rows="' . (empty($tmp[1]) ?
'20' : $tmp[1]) .
'"' . ($cols ?
' cols="' . $cols .
'"' :
'class="quatrevingtpercent"') . $morealt .
'" autofocus>';
288 $valuetoshow = str_replace(
'&',
'&', $valuetoshow);
290 $ret .=
'</textarea>';
291 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') {
292 $addnowlink = empty($moreoptions[
'addnowlink']) ? 0 : $moreoptions[
'addnowlink'];
293 $adddateof = empty($moreoptions[
'adddateof']) ?
'' : $moreoptions[
'adddateof'];
294 $labeladddateof = empty($moreoptions[
'labeladddateof']) ?
'' : $moreoptions[
'labeladddateof'];
295 $ret .= $this->
selectDate($value, $htmlname, 0, 0, 1,
'form' . $htmlname, 1, $addnowlink, 0,
'',
'', $adddateof,
'', 1, $labeladddateof,
'', $gm);
296 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') {
297 $addnowlink = empty($moreoptions[
'addnowlink']) ? 0 : $moreoptions[
'addnowlink'];
298 $adddateof = empty($moreoptions[
'adddateof']) ?
'' : $moreoptions[
'adddateof'];
299 $labeladddateof = empty($moreoptions[
'labeladddateof']) ?
'' : $moreoptions[
'labeladddateof'];
300 $ret .= $this->
selectDate($value, $htmlname, 1, 1, 1,
'form' . $htmlname, 1, $addnowlink, 0,
'',
'', $adddateof,
'', 1, $labeladddateof,
'', $gm);
301 } elseif (preg_match(
'/^select;/', $typeofdata)) {
302 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
303 $arraylist = array();
304 foreach ($arraydata as $val) {
305 $tmp = explode(
':', $val);
306 $tmpkey = str_replace(
'|',
':', $tmp[0]);
307 $arraylist[$tmpkey] = $tmp[1];
309 $ret .= $this->
selectarray($htmlname, $arraylist, $value);
310 } elseif (preg_match(
'/^link/', $typeofdata)) {
312 } elseif (preg_match(
'/^ckeditor/', $typeofdata)) {
313 $tmp = explode(
':', $typeofdata);
314 require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
315 $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]));
316 $ret .= $doleditor->Create(1);
317 } elseif ($typeofdata ==
'asis') {
318 $ret .= ($editvalue ? $editvalue : $value);
320 if (empty($notabletag)) {
325 if (empty($notabletag)) {
329 $ret .=
'<input type="submit" class="smallpaddingimp button' . (empty($notabletag) ?
'' :
' ') .
'" name="modify" value="' . $langs->trans(
"Modify") .
'">';
330 if (preg_match(
'/ckeditor|textarea/', $typeofdata) && empty($notabletag)) {
331 $ret .=
'<br>' .
"\n";
333 $ret .=
'<input type="submit" class="smallpaddingimp button button-cancel' . (empty($notabletag) ?
'' :
' ') .
'" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
334 if (empty($notabletag)) {
338 if (empty($notabletag)) {
339 $ret .=
'</tr></table>' .
"\n";
341 $ret .=
'</form>' .
"\n";
343 if (preg_match(
'/^email/', $typeofdata)) {
345 } elseif (preg_match(
'/^phone/', $typeofdata)) {
347 } elseif (preg_match(
'/^url/', $typeofdata)) {
349 } elseif (preg_match(
'/^(amount|numeric)/', $typeofdata)) {
350 $ret .= ($value !=
'' ?
price($value,
'', $langs, 0, -1, -1, $conf->currency) :
'');
351 } elseif (preg_match(
'/^checkbox/', $typeofdata)) {
352 $tmp = explode(
':', $typeofdata);
353 $ret .=
'<input type="checkbox" disabled id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $value .
'"' . ($value ?
' checked' :
'') . ($tmp[1] ? $tmp[1] :
'') .
'/>';
354 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) {
356 } elseif (preg_match(
'/^(safehtmlstring|restricthtml)/', $typeofdata)) {
358 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') {
359 $ret .=
'<span class="valuedate">' .
dol_print_date($value,
'day', $gm) .
'</span>';
360 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') {
361 $ret .=
'<span class="valuedate">' .
dol_print_date($value,
'dayhour', $gm) .
'</span>';
362 } elseif (preg_match(
'/^select;/', $typeofdata)) {
363 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
364 $arraylist = array();
365 foreach ($arraydata as $val) {
366 $tmp = explode(
':', $val);
367 $arraylist[$tmp[0]] = $tmp[1];
369 $ret .= $arraylist[$value];
370 if ($htmlname ==
'fk_product_type') {
372 $ret =
img_picto($langs->trans(
"Product"),
'product',
'class="paddingleftonly paddingrightonly colorgrey"') . $ret;
374 $ret =
img_picto($langs->trans(
"Service"),
'service',
'class="paddingleftonly paddingrightonly colorgrey"') . $ret;
377 } elseif (preg_match(
'/^ckeditor/', $typeofdata)) {
379 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
380 $firstline = preg_replace(
'/<br>.*/',
'', $tmpcontent);
381 $firstline = preg_replace(
'/[\n\r].*/',
'', $firstline);
382 $tmpcontent = $firstline . ((strlen($firstline) != strlen($tmpcontent)) ?
'...' :
'');
388 if (empty($moreoptions[
'valuealreadyhtmlescaped'])) {
396 if ($formatfunc && method_exists($object, $formatfunc)) {
397 $ret = $object->$formatfunc($ret);
415 public function widgetForTranslation($fieldname, $object, $perm, $typeofdata =
'string', $check =
'', $morecss =
'')
417 global $conf, $langs, $extralanguages;
422 $arrayoflangcode = array();
423 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) {
424 $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
427 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
428 if (!is_object($extralanguages)) {
429 include_once DOL_DOCUMENT_ROOT .
'/core/class/extralanguages.class.php';
432 $extralanguages->fetch_name_extralanguages(
'societe');
434 if (!is_array($extralanguages->attributes[$object->element]) || empty($extralanguages->attributes[$object->element][$fieldname])) {
438 $result .=
'<!-- Widget for translation -->' .
"\n";
439 $result .=
'<div class="inline-block paddingleft image-' . $object->element .
'-' . $fieldname .
'">';
440 $s =
img_picto($langs->trans(
"ShowOtherLanguages"),
'language',
'',
false, 0, 0,
'',
'fa-15 editfieldlang');
444 $result .=
'<div class="inline-block hidden field-' . $object->element .
'-' . $fieldname .
'">';
446 $resultforextrlang =
'';
447 foreach ($arrayoflangcode as $langcode) {
448 $valuetoshow = GETPOSTISSET(
'field-' . $object->element .
"-" . $fieldname .
"-" . $langcode) ?
GETPOST(
'field-' . $object->element .
'-' . $fieldname .
"-" . $langcode, $check) :
'';
449 if (empty($valuetoshow)) {
450 $object->fetchValuesForExtraLanguages();
452 $valuetoshow = $object->array_languages[$fieldname][$langcode];
456 $resultforextrlang .= $s;
459 if ($typeofdata ==
'textarea') {
460 $resultforextrlang .=
'<textarea name="field-' . $object->element .
"-" . $fieldname .
"-" . $langcode .
'" id="' . $fieldname .
"-" . $langcode .
'" class="' . $morecss .
'" rows="' . ROWS_2 .
'" wrap="soft">';
461 $resultforextrlang .= $valuetoshow;
462 $resultforextrlang .=
'</textarea>';
464 $resultforextrlang .=
'<input type="text" class="inputfieldforlang ' . ($morecss ?
' ' . $morecss :
'') .
'" name="field-' . $object->element .
'-' . $fieldname .
'-' . $langcode .
'" value="' . $valuetoshow .
'">';
467 $result .= $resultforextrlang;
470 $result .=
'<script nonce="' .
getNonce() .
'">$(".image-' . $object->element .
'-' . $fieldname .
'").click(function() { console.log("Toggle lang widget"); jQuery(".field-' . $object->element .
'-' . $fieldname .
'").toggle(); });</script>';
489 protected function editInPlace($object, $value, $htmlname, $condition, $inputType =
'textarea', $editvalue =
null, $extObject =
null, $custommsg =
null)
496 if (preg_match(
'/^text/', $inputType)) {
498 } elseif (preg_match(
'/^numeric/', $inputType)) {
499 $value =
price($value);
500 } elseif ($inputType ==
'day' || $inputType ==
'datepicker') {
506 $table_element =
false;
510 $ext_element =
false;
511 $button_only =
false;
516 if (is_object($object)) {
517 $element = $object->element;
518 $table_element = $object->table_element;
519 $fk_element = $object->id;
522 if (is_object($extObject)) {
523 $ext_element = $extObject->element;
526 if (preg_match(
'/^(string|email|numeric)/', $inputType)) {
527 $tmp = explode(
':', $inputType);
528 $inputType = $tmp[0];
529 if (!empty($tmp[1])) {
530 $inputOption = $tmp[1];
532 if (!empty($tmp[2])) {
533 $savemethod = $tmp[2];
535 $out .=
'<input id="width_' . $htmlname .
'" value="' . $inputOption .
'" type="hidden"/>' .
"\n";
536 } elseif ((preg_match(
'/^day$/', $inputType)) || (preg_match(
'/^datepicker/', $inputType)) || (preg_match(
'/^datehourpicker/', $inputType))) {
537 $tmp = explode(
':', $inputType);
538 $inputType = $tmp[0];
539 if (!empty($tmp[1])) {
540 $inputOption = $tmp[1];
542 if (!empty($tmp[2])) {
543 $savemethod = $tmp[2];
546 $out .=
'<input id="timestamp" type="hidden"/>' .
"\n";
547 } elseif (preg_match(
'/^(select|autocomplete)/', $inputType)) {
548 $tmp = explode(
':', $inputType);
549 $inputType = $tmp[0];
550 $loadmethod = $tmp[1];
551 if (!empty($tmp[2])) {
552 $savemethod = $tmp[2];
554 if (!empty($tmp[3])) {
557 } elseif (preg_match(
'/^textarea/', $inputType)) {
558 $tmp = explode(
':', $inputType);
559 $inputType = $tmp[0];
560 $rows = (empty($tmp[1]) ?
'8' : $tmp[1]);
561 $cols = (empty($tmp[2]) ?
'80' : $tmp[2]);
562 } elseif (preg_match(
'/^ckeditor/', $inputType)) {
563 $tmp = explode(
':', $inputType);
564 $inputType = $tmp[0];
566 if (!empty($tmp[2])) {
569 if (!empty($tmp[3])) {
572 if (!empty($tmp[4])) {
573 $savemethod = $tmp[4];
576 if (isModEnabled(
'fckeditor')) {
577 $out .=
'<input id="ckeditor_toolbar" value="' . $toolbar .
'" type="hidden"/>' .
"\n";
579 $inputType =
'textarea';
583 $out .=
'<input id="element_' . $htmlname .
'" value="' . $element .
'" type="hidden"/>' .
"\n";
584 $out .=
'<input id="table_element_' . $htmlname .
'" value="' . $table_element .
'" type="hidden"/>' .
"\n";
585 $out .=
'<input id="fk_element_' . $htmlname .
'" value="' . $fk_element .
'" type="hidden"/>' .
"\n";
586 $out .=
'<input id="loadmethod_' . $htmlname .
'" value="' . $loadmethod .
'" type="hidden"/>' .
"\n";
587 if (!empty($savemethod)) {
588 $out .=
'<input id="savemethod_' . $htmlname .
'" value="' . $savemethod .
'" type="hidden"/>' .
"\n";
590 if (!empty($ext_element)) {
591 $out .=
'<input id="ext_element_' . $htmlname .
'" value="' . $ext_element .
'" type="hidden"/>' .
"\n";
593 if (!empty($custommsg)) {
594 if (is_array($custommsg)) {
595 if (!empty($custommsg[
'success'])) {
596 $out .=
'<input id="successmsg_' . $htmlname .
'" value="' . $custommsg[
'success'] .
'" type="hidden"/>' .
"\n";
598 if (!empty($custommsg[
'error'])) {
599 $out .=
'<input id="errormsg_' . $htmlname .
'" value="' . $custommsg[
'error'] .
'" type="hidden"/>' .
"\n";
602 $out .=
'<input id="successmsg_' . $htmlname .
'" value="' . $custommsg .
'" type="hidden"/>' .
"\n";
605 if ($inputType ==
'textarea') {
606 $out .=
'<input id="textarea_' . $htmlname .
'_rows" value="' . $rows .
'" type="hidden"/>' .
"\n";
607 $out .=
'<input id="textarea_' . $htmlname .
'_cols" value="' . $cols .
'" type="hidden"/>' .
"\n";
609 $out .=
'<span id="viewval_' . $htmlname .
'" class="viewval_' . $inputType . ($button_only ?
' inactive' :
' active') .
'">' . $value .
'</span>' .
"\n";
610 $out .=
'<span id="editval_' . $htmlname .
'" class="editval_' . $inputType . ($button_only ?
' inactive' :
' active') .
' hideobject">' . (!empty($editvalue) ? $editvalue : $value) .
'</span>' .
"\n";
636 public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img =
'', $extracss =
'', $notabs = 3, $incbefore =
'', $noencodehtmltext = 0, $tooltiptrigger =
'', $forcenowrap = 0)
639 $text = $incbefore . $text;
644 $direction = (int) $direction;
654 $htmltext = str_replace(array(
"\r",
"\n"),
'', $htmltext);
657 if ($direction < 0) {
658 $extracss = ($extracss ? $extracss .
' ' :
'') . ($notabs != 3 ?
'inline-block' :
'');
659 $extrastyle =
'padding: 0px; padding-left: 3px;';
661 if ($direction > 0) {
662 $extracss = ($extracss ? $extracss .
' ' :
'') . ($notabs != 3 ?
'inline-block' :
'');
663 $extrastyle =
'padding: 0px; padding-right: 3px;';
666 $classfortooltip =
'classfortooltip';
671 if ($tooltiptrigger ==
'') {
672 $htmltext = str_replace(
'"',
'"', $htmltext);
674 $classfortooltip =
'classfortooltiponclick';
675 $textfordialog .=
'<div style="display: none;" id="idfortooltiponclick_' . $tooltiptrigger .
'" class="classfortooltiponclicktext">' . $htmltext .
'</div>';
677 if ($tooltipon == 2 || $tooltipon == 3) {
678 $paramfortooltipimg =
' class="' . $classfortooltip . ($notabs != 3 ?
' inline-block' :
'') . ($extracss ?
' ' . $extracss :
'') .
'" style="padding: 0px;' . ($extrastyle ?
' ' . $extrastyle :
'') .
'"';
679 if ($tooltiptrigger ==
'') {
680 $paramfortooltipimg .=
' title="' . ($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1)) .
'"';
682 $paramfortooltipimg .=
' dolid="' . $tooltiptrigger .
'"';
685 $paramfortooltipimg = ($extracss ?
' class="' . $extracss .
'"' :
'') . ($extrastyle ?
' style="' . $extrastyle .
'"' :
'');
687 if ($tooltipon == 1 || $tooltipon == 3) {
688 $paramfortooltiptd =
' class="' . ($tooltipon == 3 ?
'cursorpointer ' :
'') . $classfortooltip .
' inline-block' . ($extracss ?
' ' . $extracss :
'') .
'" style="padding: 0px;' . ($extrastyle ?
' ' . $extrastyle :
'') .
'" ';
689 if ($tooltiptrigger ==
'') {
690 $paramfortooltiptd .=
' title="' . ($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1)) .
'"';
692 $paramfortooltiptd .=
' dolid="' . $tooltiptrigger .
'"';
695 $paramfortooltiptd = ($extracss ?
' class="' . $extracss .
'"' :
'') . ($extrastyle ?
' style="' . $extrastyle .
'"' :
'');
697 if (empty($notabs)) {
698 $s .=
'<table class="nobordernopadding"><tr style="height: auto;">';
699 } elseif ($notabs == 2) {
700 $s .=
'<div class="inline-block' . ($forcenowrap ?
' nowrap' :
'') .
'">';
703 if ($direction < 0) {
704 $s .=
'<' . $tag . $paramfortooltipimg;
706 $s .=
' class="valigntop" width="14"';
708 $s .=
'>' . $textfordialog . $img .
'</' . $tag .
'>';
712 if ((
string) $text !=
'') {
713 $s .=
'<' . $tag . $paramfortooltiptd .
'>' . $text .
'</' . $tag .
'>';
716 if ($direction > 0) {
717 $s .=
'<' . $tag . $paramfortooltipimg;
719 $s .=
' class="valignmiddle" width="14"';
721 $s .=
'>' . $textfordialog . $img .
'</' . $tag .
'>';
723 if (empty($notabs)) {
724 $s .=
'</tr></table>';
725 } elseif ($notabs == 2) {
746 public function textwithpicto($text, $htmltext, $direction = 1, $type =
'help', $extracss =
'', $noencodehtmltext = 0, $notabs = 3, $tooltiptrigger =
'', $forcenowrap = 0)
748 global $conf, $langs;
753 } elseif ($type ==
'1') {
757 if (preg_match(
'/onsmartphone$/', $tooltiptrigger) && empty($conf->dol_no_mouse_hover)) {
758 $tooltiptrigger = preg_replace(
'/^.*onsmartphone$/',
'', $tooltiptrigger);
762 if ($tooltiptrigger) {
763 $alt = $langs->transnoentitiesnoconv(
"ClickToShowHelp");
767 if (empty($conf->use_javascript_ajax)) {
768 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable') {
777 if (!empty($conf->dol_no_mouse_hover) && empty($tooltiptrigger)) {
778 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable') {
789 if ($type ==
'info') {
791 } elseif ($type ==
'help') {
792 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
793 } elseif ($type ==
'helpclickable') {
794 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
795 } elseif ($type ==
'superadmin') {
797 } elseif ($type ==
'admin') {
799 } elseif ($type ==
'warning') {
801 } elseif ($type !=
'none') {
805 return $this->
textwithtooltip($text, $htmltext, ((($tooltiptrigger && !$img) || strpos($type,
'clickable')) ? 3 : 2), $direction, $img, $extracss, $notabs,
'', $noencodehtmltext, $tooltiptrigger, $forcenowrap);
818 public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0, $name =
'massaction', $cssclass =
'checkforselect')
820 global $conf, $langs, $hookmanager;
823 $ret =
'<div class="centpercent center">';
824 $ret .=
'<select class="flat' . (empty($conf->use_javascript_ajax) ?
'' :
' hideobject') .
' ' . $name .
' ' . $name .
'select valignmiddle alignstart" id="' . $name .
'" name="' . $name .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
'>';
827 $parameters = array();
828 $reshook = $hookmanager->executeHooks(
'addMoreMassActions', $parameters);
830 if (count($arrayofaction) == 0 && empty($hookmanager->resPrint)) {
833 if (empty($reshook)) {
834 $ret .=
'<option value="0"' . ($disabled ?
' disabled="disabled"' :
'') .
'>-- ' . $langs->trans(
"SelectAction") .
' --</option>';
835 foreach ($arrayofaction as $code => $label) {
836 $ret .=
'<option value="' . $code .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' data-html="' .
dol_escape_htmltag($label) .
'">' . $label .
'</option>';
839 $ret .= $hookmanager->resPrint;
843 if (empty($conf->dol_optimize_smallscreen)) {
848 $ret .=
'<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">';
849 $ret .=
'<input type="submit" disabled name="confirmmassaction"' . (empty($conf->use_javascript_ajax) ?
'' :
' style="display: none"') .
' class="reposition button smallpaddingimp' . (empty($conf->use_javascript_ajax) ?
'' :
' hideobject') .
' ' . $name .
' ' . $name .
'confirmed" value="' .
dol_escape_htmltag($langs->trans(
"Confirm")) .
'">';
852 if (!empty($conf->use_javascript_ajax)) {
853 $ret .=
'<!-- JS CODE TO ENABLE mass action select -->
855 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 */
857 atleastoneselected=0;
858 jQuery("."+cssclass).each(function( index ) {
859 /* console.log( index + ": " + $( this ).text() ); */
860 if ($(this).is(\':checked\')) atleastoneselected++;
863 console.log("initCheckForSelect mode="+mode+" name="+name+" cssclass="+cssclass+" atleastoneselected="+atleastoneselected);
865 if (atleastoneselected || ' . $alwaysvisible .
')
867 jQuery("."+name).show();
868 ' . ($selected ?
'if (atleastoneselected) { jQuery("."+name+"select").val("' . $selected .
'").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', false); }' :
'') .
'
869 ' . ($selected ?
'if (! atleastoneselected) { jQuery("."+name+"select").val("0").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', true); } ' :
'') .
'
873 jQuery("."+name).hide();
874 jQuery("."+name+"other").hide();
878 jQuery(document).ready(function () {
879 initCheckForSelect(0, "' . $name .
'", "' . $cssclass .
'");
880 jQuery(".' . $cssclass .
'").click(function() {
881 initCheckForSelect(1, "' . $name .
'", "' . $cssclass .
'");
883 jQuery(".' . $name .
'select").change(function() {
884 var massaction = $( this ).val();
885 var urlform = $( this ).closest("form").attr("action").replace("#show_files","");
886 if (massaction == "builddoc")
888 urlform = urlform + "#show_files";
890 $( this ).closest("form").attr("action", urlform);
891 console.log("we select a mass action name=' . $name .
' massaction="+massaction+" - "+urlform);
892 /* Warning: if you set submit button to disabled, post using Enter will no more work if there is no other button */
893 if ($(this).val() != \'0\')
895 jQuery(".' . $name .
'confirmed").prop(\'disabled\', false);
896 jQuery(".' . $name .
'other").hide(); /* To disable if another div was open */
897 jQuery(".' . $name .
'"+massaction).show();
901 jQuery(".' . $name .
'confirmed").prop(\'disabled\', true);
902 jQuery(".' . $name .
'other").hide(); /* To disable any div open */
931 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)
934 global $conf, $langs, $mysoc;
936 $langs->load(
"dict");
939 $countryArray = array();
942 $atleastonefavorite = 0;
944 $sql =
"SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite, eec";
945 $sql .=
" FROM " . $this->db->prefix() .
"c_country";
946 $sql .=
" WHERE active > 0";
949 dol_syslog(get_class($this) .
"::select_country", LOG_DEBUG);
950 $resql = $this->db->query($sql);
952 $out .=
'<select id="select' . $htmlname .
'" class="flat maxwidth200onsmartphone selectcountry' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" ' . $htmloption .
'>';
953 $num = $this->db->num_rows($resql);
957 $obj = $this->db->fetch_object($resql);
959 $countryArray[$i][
'rowid'] = $obj->rowid;
960 $countryArray[$i][
'code_iso'] = $obj->code_iso;
961 $countryArray[$i][
'code_iso3'] = $obj->code_iso3;
962 $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 :
''));
963 $countryArray[$i][
'favorite'] = $obj->favorite;
964 $countryArray[$i][
'eec'] = $obj->eec;
965 $favorite[$i] = $obj->favorite;
970 if (empty($disablefavorites)) {
971 $array1_sort_order = SORT_DESC;
972 $array2_sort_order = SORT_ASC;
973 array_multisort($favorite, $array1_sort_order, $label, $array2_sort_order, $countryArray);
979 if (is_numeric($showempty)) {
980 $out .=
'<option value=""> </option>' .
"\n";
982 $out .=
'<option value="-1">' . $langs->trans($showempty) .
'</option>' .
"\n";
986 if ($addspecialentries) {
988 $out .=
'<option value="special_allnotme"' . ($selected ==
'special_allnotme' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesExceptMe", $langs->transnoentitiesnoconv(
"Country" . $mysoc->country_code)) .
'</option>';
989 $out .=
'<option value="special_eec"' . ($selected ==
'special_eec' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesInEEC") .
'</option>';
990 if ($mysoc->isInEEC()) {
991 $out .=
'<option value="special_eecnotme"' . ($selected ==
'special_eecnotme' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesInEECExceptMe", $langs->transnoentitiesnoconv(
"Country" . $mysoc->country_code)) .
'</option>';
993 $out .=
'<option value="special_noteec"' . ($selected ==
'special_noteec' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesNotInEEC") .
'</option>';
994 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
997 foreach ($countryArray as $row) {
999 if (empty($row[
'rowid'])) {
1002 if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row[
'code_iso'], $exclude_country_code)) {
1006 if (empty($disablefavorites) && $row[
'favorite'] && $row[
'code_iso']) {
1007 $atleastonefavorite++;
1009 if (empty($row[
'favorite']) && $atleastonefavorite) {
1010 $atleastonefavorite = 0;
1011 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
1015 if ($row[
'label']) {
1016 $labeltoshow .=
dol_trunc($row[
'label'], $maxlength,
'middle');
1018 $labeltoshow .=
' ';
1020 if ($row[
'code_iso']) {
1021 $labeltoshow .=
' <span class="opacitymedium">(' . $row[
'code_iso'] .
')</span>';
1022 if (empty($hideflags)) {
1023 $tmpflag =
picto_from_langcode($row[
'code_iso'],
'class="saturatemedium paddingrightonly"', 1);
1024 $labeltoshow = $tmpflag .
' ' . $labeltoshow;
1028 if ($selected && $selected !=
'-1' && ($selected == $row[
'rowid'] || $selected == $row[
'code_iso'] || $selected == $row[
'code_iso3'] || $selected == $row[
'label'])) {
1029 $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']) .
'">';
1031 $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']) .
'">';
1033 $out .= $labeltoshow;
1034 $out .=
'</option>' .
"\n";
1037 $out .=
'</select>';
1043 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1044 $out .=
ajax_combobox(
'select' . $htmlname, array(), 0, 0,
'resolve');
1064 public function select_incoterms($selected =
'', $location_incoterms =
'', $page =
'', $htmlname =
'incoterm_id', $htmloption =
'', $forcecombo = 1, $events = array(), $disableautocomplete = 0)
1067 global $conf, $langs;
1069 $langs->load(
"dict");
1073 $incotermArray = array();
1075 $sql =
"SELECT rowid, code";
1076 $sql .=
" FROM " . $this->db->prefix() .
"c_incoterms";
1077 $sql .=
" WHERE active > 0";
1078 $sql .=
" ORDER BY code ASC";
1080 dol_syslog(get_class($this) .
"::select_incoterm", LOG_DEBUG);
1081 $resql = $this->db->query($sql);
1083 if ($conf->use_javascript_ajax && !$forcecombo) {
1084 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1088 if (!empty($page)) {
1089 $out .=
'<form method="post" action="' . $page .
'">';
1090 $out .=
'<input type="hidden" name="action" value="set_incoterms">';
1091 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
1094 $out .=
'<select id="' . $htmlname .
'" class="flat selectincoterm width75" name="' . $htmlname .
'" ' . $htmloption .
'>';
1095 $out .=
'<option value="0"> </option>';
1096 $num = $this->db->num_rows($resql);
1100 $obj = $this->db->fetch_object($resql);
1101 $incotermArray[$i][
'rowid'] = $obj->rowid;
1102 $incotermArray[$i][
'code'] = $obj->code;
1106 foreach ($incotermArray as $row) {
1107 if ($selected && ($selected == $row[
'rowid'] || $selected == $row[
'code'])) {
1108 $out .=
'<option value="' . $row[
'rowid'] .
'" selected>';
1110 $out .=
'<option value="' . $row[
'rowid'] .
'">';
1114 $out .= $row[
'code'];
1117 $out .=
'</option>';
1120 $out .=
'</select>';
1122 if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
1123 $out .=
ajax_multiautocompleter(
'location_incoterms', array(), DOL_URL_ROOT .
'/core/ajax/locationincoterms.php') .
"\n";
1124 $moreattrib .=
' autocomplete="off"';
1126 $out .=
'<input id="location_incoterms" class="maxwidthonsmartphone type="text" name="location_incoterms" value="' . $location_incoterms .
'">' .
"\n";
1128 if (!empty($page)) {
1129 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp nomargintop nomarginbottom" value="' . $langs->trans(
"Modify") .
'"></form>';
1151 public function select_type_of_lines($selected =
'', $htmlname =
'type', $showempty = 0, $hidetext = 0, $forceall = 0)
1154 global $langs, $conf;
1157 if ($forceall == 1 || (empty($forceall) && isModEnabled(
"product") && isModEnabled(
"service"))
1158 || (empty($forceall) && !isModEnabled(
'product') && !isModEnabled(
'service'))) {
1159 if (empty($hidetext)) {
1160 print $langs->trans(
"Type") .
': ';
1162 print
'<select class="flat" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
1164 print
'<option value="-1"';
1165 if ($selected == -1) {
1168 print
'> </option>';
1171 print
'<option value="0"';
1172 if (0 == $selected || ($selected == -1 &&
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') ==
'product')) {
1175 print
'>' . $langs->trans(
"Product");
1177 print
'<option value="1"';
1178 if (1 == $selected || ($selected == -1 &&
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') ==
'service')) {
1181 print
'>' . $langs->trans(
"Service");
1187 if ((empty($forceall) && !isModEnabled(
'product') && isModEnabled(
"service")) || $forceall == 3) {
1188 print $langs->trans(
"Service");
1189 print
'<input type="hidden" name="' . $htmlname .
'" value="1">';
1191 if ((empty($forceall) && isModEnabled(
"product") && !isModEnabled(
'service')) || $forceall == 2) {
1192 print $langs->trans(
"Product");
1193 print
'<input type="hidden" name="' . $htmlname .
'" value="0">';
1195 if ($forceall < 0) {
1196 print
'<input type="hidden" name="' . $htmlname .
'" value="1">';
1212 $num = count($this->cache_types_fees);
1219 $langs->load(
"trips");
1221 $sql =
"SELECT c.code, c.label";
1222 $sql .=
" FROM " . $this->db->prefix() .
"c_type_fees as c";
1223 $sql .=
" WHERE active > 0";
1225 $resql = $this->db->query($sql);
1227 $num = $this->db->num_rows($resql);
1231 $obj = $this->db->fetch_object($resql);
1234 $label = ($obj->code != $langs->trans($obj->code) ? $langs->trans($obj->code) : $langs->trans($obj->label));
1235 $this->cache_types_fees[$obj->code] = $label;
1239 asort($this->cache_types_fees);
1261 global $user, $langs;
1263 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
1267 print
'<select id="select_' . $htmlname .
'" class="flat" name="' . $htmlname .
'">';
1269 print
'<option value="-1"';
1270 if ($selected == -1) {
1273 print
'> </option>';
1276 foreach ($this->cache_types_fees as $key => $value) {
1277 print
'<option value="' . $key .
'"';
1278 if ($key == $selected) {
1288 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1316 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)
1319 global $conf, $user, $langs;
1323 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && !$forcecombo) {
1324 if (is_null($ajaxoptions)) {
1325 $ajaxoptions = array();
1328 require_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1332 if ($selected && empty($selected_input_value)) {
1333 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
1334 $societetmp =
new Societe($this->db);
1335 $societetmp->fetch($selected);
1336 $selected_input_value = $societetmp->name;
1341 $urloption =
'htmlname=' . urlencode(str_replace(
'.',
'_', $htmlname)) .
'&outjson=1&filter=' . urlencode($filter) . (empty($excludeids) ?
'' :
'&excludeids=' . join(
',', $excludeids)) . ($showtype ?
'&showtype=' . urlencode($showtype) :
'') . ($showcode ?
'&showcode=' . urlencode($showcode) :
'');
1343 $out .=
'<!-- force css to be higher than dialog popup --><style type="text/css">.ui-autocomplete { z-index: 1010; }</style>';
1344 if (empty($hidelabel)) {
1345 print $langs->trans(
"RefOrLabel") .
' : ';
1346 } elseif ($hidelabel > 1) {
1347 $placeholder = $langs->trans(
"RefOrLabel");
1348 if ($hidelabel == 2) {
1349 $out .=
img_picto($langs->trans(
"Search"),
'search');
1352 $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' :
'') .
' />';
1353 if ($hidelabel == 3) {
1354 $out .=
img_picto($langs->trans(
"Search"),
'search');
1359 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT .
'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
1362 $out .= $this->
select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events,
'', 0, $limit, $morecss, $moreparam, $multiple, $excludeids, $showcode);
1393 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)
1396 global $conf, $user, $langs;
1397 global $hookmanager;
1401 $outarray = array();
1403 if ($selected ===
'') {
1404 $selected = array();
1405 } elseif (!is_array($selected)) {
1406 $selected = array($selected);
1410 if (function_exists(
'testSqlAndScriptInject')) {
1413 return 'SQLInjectionTryDetected';
1417 if (preg_match(
'/[\(\)]/', $filter)) {
1423 if (function_exists(
'testSqlAndScriptInject')) {
1426 return 'SQLInjectionTryDetected';
1432 dol_syslog(
"Warning, select_thirdparty_list was called with a filter criteria not using the Universal Search Syntax.", LOG_WARNING);
1436 $sql =
"SELECT s.rowid, s.nom as name, s.name_alias, s.tva_intra, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
1437 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1438 $sql .=
", s.address, s.zip, s.town";
1439 $sql .=
", dictp.code as country_code";
1441 $sql .=
" FROM " . $this->db->prefix() .
"societe as s";
1442 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1443 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_country as dictp ON dictp.rowid = s.fk_pays";
1445 if (empty($user->rights->societe->client->voir) && !$user->socid) {
1446 $sql .=
", " . $this->db->prefix() .
"societe_commerciaux as sc";
1448 $sql .=
" WHERE s.entity IN (" .
getEntity(
'societe') .
")";
1449 if (!empty($user->socid)) {
1450 $sql .=
" AND s.rowid = " . ((int) $user->socid);
1455 $sql .=
" AND (" . $filter .
")";
1457 if (empty($user->rights->societe->client->voir) && !$user->socid) {
1458 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = " . ((int) $user->id);
1460 if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) {
1461 $sql .=
" AND s.status <> 0";
1463 if (!empty($excludeids)) {
1464 $sql .=
" AND s.rowid NOT IN (" . $this->db->sanitize(join(
',', $excludeids)) .
")";
1467 $parameters = array();
1468 $reshook = $hookmanager->executeHooks(
'selectThirdpartyListWhere', $parameters);
1469 $sql .= $hookmanager->resPrint;
1471 if ($filterkey && $filterkey !=
'') {
1473 $prefix = empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE) ?
'%' :
'';
1475 $scrit = explode(
' ', $filterkey);
1477 if (count($scrit) > 1) {
1480 foreach ($scrit as $crit) {
1484 $sql .=
"(s.nom LIKE '" . $this->db->escape($prefix . $crit) .
"%')";
1487 if (count($scrit) > 1) {
1490 if (isModEnabled(
'barcode')) {
1491 $sql .=
" OR s.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
1493 $sql .=
" OR s.code_client LIKE '" . $this->db->escape($prefix . $filterkey) .
"%' OR s.code_fournisseur LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
1494 $sql .=
" OR s.name_alias LIKE '" . $this->db->escape($prefix . $filterkey) .
"%' OR s.tva_intra LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
1497 $sql .= $this->db->order(
"nom",
"ASC");
1498 $sql .= $this->db->plimit($limit, 0);
1501 dol_syslog(get_class($this).
"::select_thirdparty_list", LOG_DEBUG);
1502 $resql = $this->db->query($sql);
1505 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1510 $out .=
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($moreparam ?
' ' . $moreparam :
'') .
' name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
'>' .
"\n";
1512 $textifempty = (($showempty && !is_numeric($showempty)) ? $langs->trans($showempty) :
'');
1513 if (!empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
1516 if ($showempty && !is_numeric($showempty)) {
1517 $textifempty = $langs->trans($showempty);
1519 $textifempty .= $langs->trans(
"All");
1523 $out .=
'<option value="-1" data-html="' .
dol_escape_htmltag(
'<span class="opacitymedium">' . ($textifempty ? $textifempty :
' ') .
'</span>') .
'">' . $textifempty .
'</option>' .
"\n";
1526 $companytemp =
new Societe($this->db);
1528 $num = $this->db->num_rows($resql);
1532 $obj = $this->db->fetch_object($resql);
1534 if ($showcode || !empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) {
1535 if (($obj->client) && (!empty($obj->code_client))) {
1536 $label = $obj->code_client .
' - ';
1538 if (($obj->fournisseur) && (!empty($obj->code_fournisseur))) {
1539 $label .= $obj->code_fournisseur .
' - ';
1541 $label .=
' ' . $obj->name;
1543 $label = $obj->name;
1546 if (!empty($obj->name_alias)) {
1547 $label .=
' (' . $obj->name_alias .
')';
1550 if (!empty($conf->global->SOCIETE_SHOW_VAT_IN_LIST) && !empty($obj->tva_intra)) {
1551 $label .=
' - '.$obj->tva_intra;
1554 $labelhtml = $label;
1557 $companytemp->id = $obj->rowid;
1558 $companytemp->client = $obj->client;
1559 $companytemp->fournisseur = $obj->fournisseur;
1560 $tmptype = $companytemp->getTypeUrl(1,
'', 0,
'span');
1562 $labelhtml .=
' ' . $tmptype;
1565 if ($obj->client || $obj->fournisseur) {
1568 if ($obj->client == 1 || $obj->client == 3) {
1569 $label .= $langs->trans(
"Customer");
1571 if ($obj->client == 2 || $obj->client == 3) {
1572 $label .= ($obj->client == 3 ?
', ' :
'') . $langs->trans(
"Prospect");
1574 if ($obj->fournisseur) {
1575 $label .= ($obj->client ?
', ' :
'') . $langs->trans(
"Supplier");
1577 if ($obj->client || $obj->fournisseur) {
1582 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1583 $s = ($obj->address ?
' - ' . $obj->address :
'') . ($obj->zip ?
' - ' . $obj->zip :
'') . ($obj->town ?
' ' . $obj->town :
'');
1584 if (!empty($obj->country_code)) {
1585 $s .=
', ' . $langs->trans(
'Country' . $obj->country_code);
1591 if (empty($outputmode)) {
1592 if (in_array($obj->rowid, $selected)) {
1593 $out .=
'<option value="' . $obj->rowid .
'" selected data-html="' .
dol_escape_htmltag($labelhtml, 0, 0,
'', 0, 1) .
'">' .
dol_escape_htmltag($label, 0, 0,
'', 0, 1) .
'</option>';
1595 $out .=
'<option value="' . $obj->rowid .
'" data-html="' .
dol_escape_htmltag($labelhtml, 0, 0,
'', 0, 1) .
'">' .
dol_escape_htmltag($label, 0, 0,
'', 0, 1) .
'</option>';
1598 array_push($outarray, array(
'key' => $obj->rowid,
'value' => $label,
'label' => $label,
'labelhtml' => $labelhtml));
1602 if (($i % 10) == 0) {
1607 $out .=
'</select>' .
"\n";
1612 $this->result = array(
'nbofthirdparties' => $num);
1636 global $langs, $conf;
1639 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
1640 $sql .=
" re.description, re.fk_facture_source";
1641 $sql .=
" FROM " . $this->db->prefix() .
"societe_remise_except as re";
1642 $sql .=
" WHERE re.fk_soc = " . (int) $socid;
1643 $sql .=
" AND re.entity = " . $conf->entity;
1645 $sql .=
" AND " . $filter;
1647 $sql .=
" ORDER BY re.description ASC";
1649 dol_syslog(get_class($this) .
"::select_remises", LOG_DEBUG);
1650 $resql = $this->db->query($sql);
1652 print
'<select id="select_' . $htmlname .
'" class="flat maxwidthonsmartphone" name="' . $htmlname .
'">';
1653 $num = $this->db->num_rows($resql);
1655 $qualifiedlines = $num;
1659 print
'<option value="0"> </option>';
1661 $obj = $this->db->fetch_object($resql);
1662 $desc =
dol_trunc($obj->description, 40);
1663 if (preg_match(
'/\(CREDIT_NOTE\)/', $desc)) {
1664 $desc = preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $desc);
1666 if (preg_match(
'/\(DEPOSIT\)/', $desc)) {
1667 $desc = preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"Deposit"), $desc);
1669 if (preg_match(
'/\(EXCESS RECEIVED\)/', $desc)) {
1670 $desc = preg_replace(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"ExcessReceived"), $desc);
1672 if (preg_match(
'/\(EXCESS PAID\)/', $desc)) {
1673 $desc = preg_replace(
'/\(EXCESS PAID\)/', $langs->trans(
"ExcessPaid"), $desc);
1677 if ($selected > 0 && $selected == $obj->rowid) {
1678 $selectstring =
' selected';
1682 if ($maxvalue > 0 && $obj->amount_ttc > $maxvalue) {
1684 $disabled =
' disabled';
1687 if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->fk_facture_source)) {
1688 $tmpfac =
new Facture($this->db);
1689 if ($tmpfac->fetch($obj->fk_facture_source) > 0) {
1690 $desc = $desc .
' - ' . $tmpfac->ref;
1694 print
'<option value="' . $obj->rowid .
'"' . $selectstring . $disabled .
'>' . $desc .
' (' .
price($obj->amount_ht) .
' ' . $langs->trans(
"HT") .
' - ' .
price($obj->amount_ttc) .
' ' . $langs->trans(
"TTC") .
')</option>';
1701 return $qualifiedlines;
1730 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 =
'')
1733 print $this->
selectcontacts($socid, $selected, $htmlname, $showempty, $exclude, $limitto, $showfunction, $morecss, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid);
1761 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)
1763 global $conf, $langs, $hookmanager, $action;
1765 $langs->load(
'companies');
1767 if (empty($htmlid)) {
1768 $htmlid = $htmlname;
1772 if ($selected ===
'') {
1773 $selected = array();
1774 } elseif (!is_array($selected)) {
1775 $selected = array($selected);
1779 if (!is_object($hookmanager)) {
1780 include_once DOL_DOCUMENT_ROOT .
'/core/class/hookmanager.class.php';
1785 $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";
1786 if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1787 $sql .=
", s.nom as company, s.town AS company_town";
1789 $sql .=
" FROM " . $this->db->prefix() .
"socpeople as sp";
1790 if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1791 $sql .=
" LEFT OUTER JOIN " . $this->db->prefix() .
"societe as s ON s.rowid=sp.fk_soc";
1793 $sql .=
" WHERE sp.entity IN (" .
getEntity(
'contact') .
")";
1794 if ($socid > 0 || $socid == -1) {
1795 $sql .=
" AND sp.fk_soc = " . ((int) $socid);
1797 if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) {
1798 $sql .=
" AND sp.statut <> 0";
1801 $parameters = array();
1802 $reshook = $hookmanager->executeHooks(
'selectContactListWhere', $parameters);
1803 $sql .= $hookmanager->resPrint;
1804 $sql .=
" ORDER BY sp.lastname ASC";
1806 dol_syslog(get_class($this) .
"::selectcontacts", LOG_DEBUG);
1807 $resql = $this->db->query($sql);
1809 $num = $this->db->num_rows($resql);
1811 if ($htmlname !=
'none' && !$options_only) {
1812 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlid .
'" name="' . $htmlname . (($num || empty($disableifempty)) ?
'' :
' disabled') . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
' ' . (!empty($moreparam) ? $moreparam :
'') .
'>';
1815 if ($showempty && !is_numeric($showempty)) {
1816 $textforempty = $showempty;
1817 $out .=
'<option class="optiongrey" value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'>' . $textforempty .
'</option>';
1819 if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) {
1820 $out .=
'<option value="0"' . (in_array(0, $selected) ?
' selected' :
'') .
'> </option>';
1822 if ($showempty == 2) {
1823 $out .=
'<option value="0"' . (in_array(0, $selected) ?
' selected' :
'') .
'>-- ' . $langs->trans(
"Internal") .
' --</option>';
1829 include_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
1830 $contactstatic =
new Contact($this->db);
1833 $obj = $this->db->fetch_object($resql);
1836 $extendedInfos =
'';
1837 if (!empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1838 $extendedInfos = array();
1839 $email = trim($obj->email);
1840 if (!empty($email)) {
1841 $extendedInfos[] = $email;
1843 $phone = trim($obj->phone);
1844 $phone_perso = trim($obj->phone_perso);
1845 $phone_mobile = trim($obj->phone_mobile);
1846 if (!empty($phone)) {
1847 $extendedInfos[] = $phone;
1849 if (!empty($phone_perso)) {
1850 $extendedInfos[] = $phone_perso;
1852 if (!empty($phone_mobile)) {
1853 $extendedInfos[] = $phone_mobile;
1856 $contact_town = trim($obj->contact_town);
1857 $company_town = trim($obj->company_town);
1858 if (!empty($contact_town)) {
1859 $extendedInfos[] = $contact_town;
1860 } elseif (!empty($company_town)) {
1861 $extendedInfos[] = $company_town;
1863 $extendedInfos = implode(
' - ', $extendedInfos);
1864 if (!empty($extendedInfos)) {
1865 $extendedInfos =
' - ' . $extendedInfos;
1869 $contactstatic->id = $obj->rowid;
1870 $contactstatic->lastname = $obj->lastname;
1871 $contactstatic->firstname = $obj->firstname;
1872 if ($obj->statut == 1) {
1873 if ($htmlname !=
'none') {
1875 if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) {
1878 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
1881 if (!empty($selected) && in_array($obj->rowid, $selected)) {
1882 $out .=
'<option value="' . $obj->rowid .
'"';
1884 $out .=
' disabled';
1886 $out .=
' selected>';
1887 $out .= $contactstatic->getFullName($langs) . $extendedInfos;
1888 if ($showfunction && $obj->poste) {
1889 $out .=
' (' . $obj->poste .
')';
1891 if (($showsoc > 0) && $obj->company) {
1892 $out .=
' - (' . $obj->company .
')';
1894 $out .=
'</option>';
1896 $out .=
'<option value="' . $obj->rowid .
'"';
1898 $out .=
' disabled';
1901 $out .= $contactstatic->getFullName($langs) . $extendedInfos;
1902 if ($showfunction && $obj->poste) {
1903 $out .=
' (' . $obj->poste .
')';
1905 if (($showsoc > 0) && $obj->company) {
1906 $out .=
' - (' . $obj->company .
')';
1908 $out .=
'</option>';
1911 if (in_array($obj->rowid, $selected)) {
1912 $out .= $contactstatic->getFullName($langs) . $extendedInfos;
1913 if ($showfunction && $obj->poste) {
1914 $out .=
' (' . $obj->poste .
')';
1916 if (($showsoc > 0) && $obj->company) {
1917 $out .=
' - (' . $obj->company .
')';
1925 $labeltoshow = ($socid != -1) ? ($langs->trans($socid ?
"NoContactDefinedForThirdParty" :
"NoContactDefined")) : $langs->trans(
'SelectAThirdPartyFirst');
1926 $out .=
'<option class="disabled" value="-1"' . (($showempty == 2 || $multiple) ?
'' :
' selected') .
' disabled="disabled">';
1927 $out .= $labeltoshow;
1928 $out .=
'</option>';
1931 $parameters = array(
1933 'htmlname' => $htmlname,
1936 'showfunction' => $showfunction,
1937 'showsoc' => $showsoc,
1940 $reshook = $hookmanager->executeHooks(
'afterSelectContactOptions', $parameters, $this, $action);
1942 if ($htmlname !=
'none' && !$options_only) {
1943 $out .=
'</select>';
1946 if ($conf->use_javascript_ajax && !$forcecombo && !$options_only) {
1947 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1976 public function select_users($selected =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0')
1979 print $this->
select_dolusers($selected, $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity);
2008 public function select_dolusers($selected =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0', $maxlength = 0, $showstatus = 0, $morefilter =
'', $show_every = 0, $enableonlytext =
'', $morecss =
'', $notdisabled = 0, $outputmode = 0, $multiple =
false, $forcecombo = 0)
2011 global $conf, $user, $langs, $hookmanager;
2015 if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) {
2016 $selected = $user->id;
2019 if ($selected ===
'') {
2020 $selected = array();
2021 } elseif (!is_array($selected)) {
2022 $selected = array($selected);
2025 $excludeUsers =
null;
2026 $includeUsers =
null;
2029 if (is_array($exclude)) {
2030 $excludeUsers = implode(
",", $exclude);
2033 if (is_array($include)) {
2034 $includeUsers = implode(
",", $include);
2035 } elseif ($include ==
'hierarchy') {
2037 $includeUsers = implode(
",", $user->getAllChildIds(0));
2038 } elseif ($include ==
'hierarchyme') {
2040 $includeUsers = implode(
",", $user->getAllChildIds(1));
2044 $outarray = array();
2045 $outarray2 = array();
2048 $sql =
"SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut as status, u.login, u.admin, u.entity, u.photo";
2049 if (isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
2050 $sql .=
", e.label";
2052 $sql .=
" FROM " . $this->db->prefix() .
"user as u";
2053 if (isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
2054 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entity as e ON e.rowid = u.entity";
2055 if ($force_entity) {
2056 $sql .=
" WHERE u.entity IN (0, " . $this->db->sanitize($force_entity) .
")";
2058 $sql .=
" WHERE u.entity IS NOT NULL";
2061 if (isModEnabled(
'multicompany') && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
2062 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"usergroup_user as ug";
2063 $sql .=
" ON ug.fk_user = u.rowid";
2064 $sql .=
" WHERE ug.entity = " . (int) $conf->entity;
2066 $sql .=
" WHERE u.entity IN (0, " . ((int) $conf->entity) .
")";
2069 if (!empty($user->socid)) {
2070 $sql .=
" AND u.fk_soc = " . ((int) $user->socid);
2072 if (is_array($exclude) && $excludeUsers) {
2073 $sql .=
" AND u.rowid NOT IN (" . $this->db->sanitize($excludeUsers) .
")";
2075 if ($includeUsers) {
2076 $sql .=
" AND u.rowid IN (" . $this->db->sanitize($includeUsers) .
")";
2078 if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $notdisabled) {
2079 $sql .=
" AND u.statut <> 0";
2081 if (!empty($morefilter)) {
2082 $sql .=
" " . $morefilter;
2086 $reshook = $hookmanager->executeHooks(
'addSQLWhereFilterOnSelectUsers', array(), $this, $action);
2087 if (!empty($reshook)) {
2088 $sql .= $hookmanager->resPrint;
2091 if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) {
2092 $sql .=
" ORDER BY u.statut DESC, u.firstname ASC, u.lastname ASC";
2094 $sql .=
" ORDER BY u.statut DESC, u.lastname ASC, u.firstname ASC";
2097 dol_syslog(get_class($this) .
"::select_dolusers", LOG_DEBUG);
2099 $resql = $this->db->query($sql);
2101 $num = $this->db->num_rows($resql);
2105 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
' minwidth200') .
'" id="' . $htmlname .
'" name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
' ' . ($disabled ?
' disabled' :
'') .
'>';
2106 if ($show_empty && !$multiple) {
2107 $textforempty =
' ';
2108 if (!empty($conf->use_javascript_ajax)) {
2109 $textforempty =
' ';
2111 if (!is_numeric($show_empty)) {
2112 $textforempty = $show_empty;
2114 $out .=
'<option class="optiongrey" value="' . ($show_empty < 0 ? $show_empty : -1) .
'"' . ((empty($selected) || in_array(-1, $selected)) ?
' selected' :
'') .
'>' . $textforempty .
'</option>' .
"\n";
2117 $out .=
'<option value="-2"' . ((in_array(-2, $selected)) ?
' selected' :
'') .
'>-- ' . $langs->trans(
"Everybody") .
' --</option>' .
"\n";
2120 $userstatic =
new User($this->db);
2123 $obj = $this->db->fetch_object($resql);
2125 $userstatic->id = $obj->rowid;
2126 $userstatic->lastname = $obj->lastname;
2127 $userstatic->firstname = $obj->firstname;
2128 $userstatic->photo = $obj->photo;
2129 $userstatic->statut = $obj->status;
2130 $userstatic->entity = $obj->entity;
2131 $userstatic->admin = $obj->admin;
2134 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
2135 $disableline = ($enableonlytext ? $enableonlytext :
'1');
2139 $labeltoshowhtml =
'';
2143 if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) {
2146 $labeltoshow .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
2147 $labeltoshowhtml .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
2148 if (empty($obj->firstname) && empty($obj->lastname)) {
2149 $labeltoshow .= $obj->login;
2150 $labeltoshowhtml .= $obj->login;
2156 if (!empty($conf->global->MAIN_SHOW_LOGIN)) {
2157 $moreinfo .= ($moreinfo ?
' - ' :
' (');
2158 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(');
2159 $moreinfo .= $obj->login;
2160 $moreinfohtml .= $obj->login;
2162 if ($showstatus >= 0) {
2163 if ($obj->status == 1 && $showstatus == 1) {
2164 $moreinfo .= ($moreinfo ?
' - ' :
' (') . $langs->trans(
'Enabled');
2165 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . $langs->trans(
'Enabled');
2167 if ($obj->status == 0 && $showstatus == 1) {
2168 $moreinfo .= ($moreinfo ?
' - ' :
' (') . $langs->trans(
'Disabled');
2169 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . $langs->trans(
'Disabled');
2172 if (isModEnabled(
'multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
2173 if (!$obj->entity) {
2174 $moreinfo .= ($moreinfo ?
' - ' :
' (') . $langs->trans(
"AllEntities");
2175 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . $langs->trans(
"AllEntities");
2177 if ($obj->entity != $conf->entity) {
2178 $moreinfo .= ($moreinfo ?
' - ' :
' (') . ($obj->label ? $obj->label : $langs->trans(
"EntityNameNotDefined"));
2179 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . ($obj->label ? $obj->label : $langs->trans(
"EntityNameNotDefined"));
2183 $moreinfo .= ($moreinfo ?
')' :
'');
2184 $moreinfohtml .= ($moreinfohtml ?
')</span>' :
'');
2185 if ($disableline && $disableline !=
'1') {
2187 $moreinfo .=
' - ' . $disableline;
2188 $moreinfohtml .=
' - ' . $disableline;
2190 $labeltoshow .= $moreinfo;
2191 $labeltoshowhtml .= $moreinfohtml;
2193 $out .=
'<option value="' . $obj->rowid .
'"';
2195 $out .=
' disabled';
2197 if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected))) {
2198 $out .=
' selected';
2200 $out .=
' data-html="';
2201 $outhtml = $userstatic->getNomUrl(-3,
'', 0, 1, 24, 1,
'login',
'', 1) .
' ';
2202 if ($showstatus >= 0 && $obj->status == 0) {
2203 $outhtml .=
'<strike class="opacitymediumxxx">';
2205 $outhtml .= $labeltoshowhtml;
2206 if ($showstatus >= 0 && $obj->status == 0) {
2207 $outhtml .=
'</strike>';
2211 $out .= $labeltoshow;
2212 $out .=
'</option>';
2214 $outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength) . $moreinfo;
2215 $outarray2[$userstatic->id] = array(
2216 'id'=>$userstatic->id,
2217 'label'=>$labeltoshow,
2218 'labelhtml'=>$labeltoshowhtml,
2226 $out .=
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'" disabled>';
2227 $out .=
'<option value="">' . $langs->trans(
"None") .
'</option>';
2229 $out .=
'</select>';
2231 if ($num && !$forcecombo) {
2233 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
2240 if ($outputmode == 2) {
2242 } elseif ($outputmode) {
2274 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())
2277 global $conf, $user, $langs;
2279 $userstatic =
new User($this->db);
2283 $assignedtouser = array();
2284 if (!empty($_SESSION[
'assignedtouser'])) {
2285 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
2287 $nbassignetouser = count($assignedtouser);
2290 if ($nbassignetouser) {
2291 $out .=
'<ul class="attendees">';
2295 foreach ($assignedtouser as $key => $value) {
2296 if ($value[
'id'] == $ownerid) {
2301 $userstatic->fetch($value[
'id']);
2302 $out .= $userstatic->getNomUrl(-1);
2304 $ownerid = $value[
'id'];
2305 $out .=
' (' . $langs->trans(
"Owner") .
')';
2307 if ($nbassignetouser > 1 && $action !=
'view') {
2308 $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 .
'">';
2311 if ($showproperties) {
2312 if ($ownerid == $value[
'id'] && is_array($listofuserid) && count($listofuserid) && in_array($ownerid, array_keys($listofuserid))) {
2313 $out .=
'<div class="myavailability inline-block">';
2314 $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>';
2324 if ($nbassignetouser) {
2329 if ($action !=
'view') {
2330 $out .=
'<input type="hidden" class="removedassignedhidden" name="removedassigned" value="">';
2331 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">jQuery(document).ready(function () {';
2332 $out .=
'jQuery(".removedassigned").click(function() { jQuery(".removedassignedhidden").val(jQuery(this).val()); });';
2333 $out .=
'jQuery(".assignedtouser").change(function() { console.log(jQuery(".assignedtouser option:selected").val());';
2334 $out .=
' if (jQuery(".assignedtouser option:selected").val() > 0) { jQuery("#' . $action .
'assignedtouser").attr("disabled", false); }';
2335 $out .=
' else { jQuery("#' . $action .
'assignedtouser").attr("disabled", true); }';
2337 $out .=
'})</script>';
2338 $out .= $this->
select_dolusers(
'', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter);
2339 $out .=
' <input type="submit" disabled class="button valignmiddle smallpaddingimp reposition" id="' . $action .
'assignedtouser" name="' . $action .
'assignedtouser" value="' .
dol_escape_htmltag($langs->trans(
"Add")) .
'">';
2376 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)
2379 global $langs, $conf;
2384 $price_level = (!empty($price_level) ? $price_level : 0);
2385 if (is_null($ajaxoptions)) {
2386 $ajaxoptions = array();
2389 if (strval($filtertype) ===
'' && (isModEnabled(
"product") || isModEnabled(
"service"))) {
2390 if (isModEnabled(
"product") && !isModEnabled(
'service')) {
2392 } elseif (!isModEnabled(
'product') && isModEnabled(
"service")) {
2397 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
2400 if ($selected && empty($selected_input_value)) {
2401 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
2402 $producttmpselect =
new Product($this->db);
2403 $producttmpselect->fetch($selected);
2404 $selected_input_value = $producttmpselect->ref;
2405 unset($producttmpselect);
2408 if ($filtertype ==
'') {
2409 if (!isModEnabled(
'product')) {
2411 } elseif (!isModEnabled(
'service')) {
2416 $urloption = ($socid > 0 ?
'socid=' . $socid .
'&' :
'') .
'htmlname=' . $htmlname .
'&outjson=1&price_level=' . $price_level .
'&type=' . $filtertype .
'&mode=1&status=' . $status .
'&status_purchase=' . $status_purchase .
'&finished=' . $finished .
'&hidepriceinlabel=' . $hidepriceinlabel .
'&warehousestatus=' . $warehouseStatus;
2417 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT .
'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
2419 if (isModEnabled(
'variants') && is_array($selected_combinations)) {
2423 <!-- script to auto show attributes select tags if a variant was selected -->
2424 <script nonce="' .
getNonce() .
'">
2425 // auto show attributes fields
2426 selected = ' . json_encode($selected_combinations) .
';
2429 jQuery(document).ready(function () {
2431 jQuery("input[name=\'prod_entry_mode\']").change(function () {
2432 if (jQuery(this).val() == \'free\') {
2433 jQuery(\'div#attributes_box\').empty();
2437 jQuery("input#' . $htmlname .
'").change(function () {
2439 if (!jQuery(this).val()) {
2440 jQuery(\'div#attributes_box\').empty();
2444 console.log("A change has started. We get variants fields to inject html select");
2446 jQuery.getJSON("' . DOL_URL_ROOT .
'/variants/ajax/getCombinations.php", {
2447 id: jQuery(this).val()
2448 }, function (data) {
2449 jQuery(\'div#attributes_box\').empty();
2451 jQuery.each(data, function (key, val) {
2453 combvalues[val.id] = val.values;
2455 var span = jQuery(document.createElement(\'div\')).css({
2456 \'display\': \'table-row\'
2460 jQuery(document.createElement(\'div\')).text(val.label).css({
2461 \'font-weight\': \'bold\',
2462 \'display\': \'table-cell\'
2466 var html = jQuery(document.createElement(\'select\')).attr(\'name\', \'combinations[\' + val.id + \']\').css({
2467 \'margin-left\': \'15px\',
2468 \'white-space\': \'pre\'
2470 jQuery(document.createElement(\'option\')).val(\'\')
2473 jQuery.each(combvalues[val.id], function (key, val) {
2474 var tag = jQuery(document.createElement(\'option\')).val(val.id).html(val.value);
2476 if (selected[val.fk_product_attribute] == val.id) {
2477 tag.attr(\'selected\', \'selected\');
2484 jQuery(\'div#attributes_box\').append(span);
2489 ' . ($selected ?
'jQuery("input#' . $htmlname .
'").change();' :
'') .
'
2495 if (empty($hidelabel)) {
2496 $out .= $langs->trans(
"RefOrLabel") .
' : ';
2497 } elseif ($hidelabel > 1) {
2498 $placeholder =
' placeholder="' . $langs->trans(
"RefOrLabel") .
'"';
2499 if ($hidelabel == 2) {
2500 $out .=
img_picto($langs->trans(
"Search"),
'search');
2503 $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' :
'') .
' />';
2504 if ($hidelabel == 3) {
2505 $out .=
img_picto($langs->trans(
"Search"),
'search');
2508 $out .= $this->
select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level,
'', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus, $status_purchase);
2511 if (empty($nooutput)) {
2535 public function select_bom($selected =
'', $htmlname =
'bom_id', $limit = 0, $status = 1, $type = 0, $showempty =
'1', $morecss =
'', $nooutput =
'', $forcecombo = 0, $TProducts = [])
2538 global $conf, $user, $langs, $db;
2540 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
2546 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
2551 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
2553 $sql =
'SELECT b.rowid, b.ref, b.label, b.fk_product';
2554 $sql .=
' FROM ' . MAIN_DB_PREFIX .
'bom_bom as b';
2555 $sql .=
' WHERE b.entity IN (' .
getEntity(
'bom') .
')';
2556 if (!empty($status)) $sql .=
' AND status = ' . (int) $status;
2557 if (!empty($type)) $sql .=
' AND bomtype = ' . (
int) $type;
2558 if (!empty($TProducts)) $sql .=
' AND fk_product IN (' . $this->db->sanitize(implode(
',', $TProducts)) .
')';
2559 if (!empty($limit)) $sql .=
' LIMIT ' . (
int) $limit;
2560 $resql = $db->query($sql);
2563 $out .=
'<option value="-1"';
2564 if (empty($selected)) $out .=
' selected';
2565 $out .=
'> </option>';
2567 while ($obj = $db->fetch_object($resql)) {
2569 $res = $product->fetch($obj->fk_product);
2570 $out .=
'<option value="' . $obj->rowid .
'"';
2571 if ($obj->rowid == $selected) $out .=
'selected';
2572 $out .=
'>' . $obj->ref .
' - ' . $product->label .
' - ' . $obj->label .
'</option>';
2578 $out .=
'</select>';
2579 if (empty($nooutput)) {
2613 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)
2616 global $langs, $conf;
2617 global $hookmanager;
2620 $outarray = array();
2624 $langs->load(
'other');
2627 $warehouseStatusArray = array();
2628 if (!empty($warehouseStatus)) {
2629 require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/entrepot.class.php';
2630 if (preg_match(
'/warehouseclosed/', $warehouseStatus)) {
2633 if (preg_match(
'/warehouseopen/', $warehouseStatus)) {
2636 if (preg_match(
'/warehouseinternal/', $warehouseStatus)) {
2641 $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";
2642 if (count($warehouseStatusArray)) {
2643 $selectFieldsGrouped =
", sum(" . $this->db->ifsql(
"e.statut IS NULL",
"0",
"ps.reel") .
") as stock";
2645 $selectFieldsGrouped =
", " . $this->db->ifsql(
"p.stock IS NULL", 0,
"p.stock") .
" AS stock";
2651 $parameters = array();
2652 $reshook = $hookmanager->executeHooks(
'selectProductsListSelect', $parameters);
2653 if (empty($reshook)) {
2654 $sql .= $selectFields.$selectFieldsGrouped.$hookmanager->resPrint;
2656 $sql .= $hookmanager->resPrint;
2659 if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) {
2661 $sql .=
", (SELECT " . $this->db->prefix() .
"categorie_product.fk_categorie
2662 FROM " . $this->db->prefix() .
"categorie_product
2663 WHERE " . $this->db->prefix() .
"categorie_product.fk_product=p.rowid
2665 ) AS categorie_product_id ";
2669 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
2670 $sql .=
', pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,';
2671 $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';
2672 $selectFields .=
", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx, custdefault_vat_code, custref";
2676 $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";
2677 $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';
2682 $sql .=
", pl.label as label_translated";
2683 $sql .=
", pl.description as description_translated";
2684 $selectFields .=
", label_translated";
2685 $selectFields .=
", description_translated";
2688 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
2689 $sql .=
", (SELECT pp.rowid FROM " . $this->db->prefix() .
"product_price as pp WHERE pp.fk_product = p.rowid";
2690 if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
2691 $sql .=
" AND price_level = " . ((int) $price_level);
2693 $sql .=
" ORDER BY date_price";
2694 $sql .=
" DESC LIMIT 1) as price_rowid";
2695 $sql .=
", (SELECT pp.price_by_qty FROM " . $this->db->prefix() .
"product_price as pp WHERE pp.fk_product = p.rowid";
2696 if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
2697 $sql .=
" AND price_level = " . ((int) $price_level);
2699 $sql .=
" ORDER BY date_price";
2700 $sql .=
" DESC LIMIT 1) as price_by_qty";
2701 $selectFields .=
", price_rowid, price_by_qty";
2704 $sql .=
" FROM ".$this->db->prefix().
"product as p";
2706 $parameters = array();
2707 $reshook = $hookmanager->executeHooks(
'selectProductsListFrom', $parameters);
2708 $sql .= $hookmanager->resPrint;
2710 if (count($warehouseStatusArray)) {
2711 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_stock as ps on ps.fk_product = p.rowid";
2712 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (" .
getEntity(
'stock') .
")";
2713 $sql .=
' AND e.statut IN (' . $this->db->sanitize($this->db->escape(implode(
',', $warehouseStatusArray))) .
')';
2717 if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) {
2718 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
2722 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
2723 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_customer_price as pcp ON pcp.fk_soc=" . ((int) $socid) .
" AND pcp.fk_product=p.rowid";
2727 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_units u ON u.rowid = p.fk_unit";
2731 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_lang as pl ON pl.fk_product = p.rowid ";
2732 if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && !empty($socid)) {
2733 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
2734 $soc =
new Societe($this->db);
2735 $result = $soc->fetch($socid);
2736 if ($result > 0 && !empty($soc->default_lang)) {
2737 $sql .=
" AND pl.lang = '" . $this->db->escape($soc->default_lang) .
"'";
2739 $sql .=
" AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) .
"'";
2742 $sql .=
" AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) .
"'";
2746 if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
2747 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_attribute_combination pac ON pac.fk_product_child = p.rowid";
2750 $sql .=
' WHERE p.entity IN (' .
getEntity(
'product') .
')';
2752 if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
2753 $sql .=
" AND pac.rowid IS NULL";
2756 if ($finished == 0) {
2757 $sql .=
" AND p.finished = " . ((int) $finished);
2758 } elseif ($finished == 1) {
2759 $sql .=
" AND p.finished = ".((int) $finished);
2762 $sql .=
" AND p.tosell = ".((int) $status);
2764 if ($status_purchase >= 0) {
2765 $sql .=
" AND p.tobuy = " . ((int) $status_purchase);
2768 if (strval($filtertype) !=
'') {
2769 $sql .=
" AND p.fk_product_type = " . ((int) $filtertype);
2770 } elseif (!isModEnabled(
'product')) {
2771 $sql .=
" AND p.fk_product_type = 1";
2772 } elseif (!isModEnabled(
'service')) {
2773 $sql .=
" AND p.fk_product_type = 0";
2776 $parameters = array();
2777 $reshook = $hookmanager->executeHooks(
'selectProductsListWhere', $parameters);
2778 $sql .= $hookmanager->resPrint;
2780 if ($filterkey !=
'') {
2782 $prefix = empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE) ?
'%' :
'';
2784 $scrit = explode(
' ', $filterkey);
2786 if (count($scrit) > 1) {
2789 foreach ($scrit as $crit) {
2793 $sql .=
"(p.ref LIKE '" . $this->db->escape($prefix . $crit) .
"%' OR p.label LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
2795 $sql .=
" OR pl.label LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
2797 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
2798 $sql .=
" OR pcp.ref_customer LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
2800 if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION)) {
2801 $sql .=
" OR p.description LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
2803 $sql .=
" OR pl.description LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
2806 if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) {
2807 $sql .=
" OR pfp.ref_fourn LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
2812 if (count($scrit) > 1) {
2815 if (isModEnabled(
'barcode')) {
2816 $sql .=
" OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
2820 if (count($warehouseStatusArray)) {
2821 $sql .=
" GROUP BY " . $selectFields;
2825 if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) {
2826 $sql .=
" ORDER BY categorie_product_id ";
2828 ($conf->global->PRODUCT_SORT_BY_CATEGORY == 1) ? $sql .=
"ASC" : $sql .=
"DESC";
2830 $sql .= $this->db->order(
"p.ref");
2833 $sql .= $this->db->plimit($limit, 0);
2836 dol_syslog(get_class($this) .
"::select_produits_list search products", LOG_DEBUG);
2837 $result = $this->db->query($sql);
2839 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
2840 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
2841 require_once DOL_DOCUMENT_ROOT .
'/core/lib/product.lib.php';
2843 $num = $this->db->num_rows($result);
2848 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
2852 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
2857 if (!empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
2858 if ($showempty && !is_numeric($showempty)) {
2859 $textifempty = $langs->trans($showempty);
2861 $textifempty .= $langs->trans(
"All");
2864 if ($showempty && !is_numeric($showempty)) {
2865 $textifempty = $langs->trans($showempty);
2869 $out .=
'<option value="-1" selected>' . ($textifempty ? $textifempty :
' ') .
'</option>';
2873 while ($num && $i < $num) {
2876 $objp = $this->db->fetch_object($result);
2878 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) {
2879 $sql =
"SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type";
2880 $sql .=
" FROM " . $this->db->prefix() .
"product_price_by_qty";
2881 $sql .=
" WHERE fk_product_price = " . ((int) $objp->price_rowid);
2882 $sql .=
" ORDER BY quantity ASC";
2884 dol_syslog(get_class($this) .
"::select_produits_list search prices by qty", LOG_DEBUG);
2885 $result2 = $this->db->query($sql);
2887 $nb_prices = $this->db->num_rows($result2);
2889 while ($nb_prices && $j < $nb_prices) {
2890 $objp2 = $this->db->fetch_object($result2);
2892 $objp->price_by_qty_rowid = $objp2->rowid;
2893 $objp->price_by_qty_price_base_type = $objp2->price_base_type;
2894 $objp->price_by_qty_quantity = $objp2->quantity;
2895 $objp->price_by_qty_unitprice = $objp2->unitprice;
2896 $objp->price_by_qty_remise_percent = $objp2->remise_percent;
2898 $objp->quantity = $objp2->quantity;
2899 $objp->price = $objp2->price;
2900 $objp->unitprice = $objp2->unitprice;
2901 $objp->remise_percent = $objp2->remise_percent;
2914 array_push($outarray, $optJson);
2918 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_price_expression)) {
2919 $price_product =
new Product($this->db);
2920 $price_product->fetch($objp->rowid,
'',
'', 1);
2922 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
2924 $price_result = $priceparser->parseProduct($price_product);
2925 if ($price_result >= 0) {
2926 $objp->price = $price_result;
2927 $objp->unitprice = $price_result;
2929 $objp->price_ttc =
price2num($objp->price) * (1 + ($objp->tva_tx / 100));
2930 $objp->price_ttc =
price2num($objp->price_ttc,
'MU');
2939 array_push($outarray, $optJson);
2945 $out .=
'</select>';
2947 $this->db->free($result);
2949 if (empty($outputmode)) {
2976 protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey =
'', $novirtualstock = 0)
2978 global $langs, $conf, $user;
2979 global $hookmanager;
2985 $outlabel_translated =
'';
2987 $outdesc_translated =
'';
2993 $outpricebasetype =
'';
2995 $outdefault_vat_code =
'';
2999 $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
3001 $label = $objp->label;
3002 if (!empty($objp->label_translated)) {
3003 $label = $objp->label_translated;
3005 if (!empty($filterkey) && $filterkey !=
'') {
3006 $label = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $label, 1);
3009 $outkey = $objp->rowid;
3010 $outref = $objp->ref;
3011 $outrefcust = empty($objp->custref) ?
'' : $objp->custref;
3012 $outlabel = $objp->label;
3013 $outdesc = $objp->description;
3015 $outlabel_translated = $objp->label_translated;
3016 $outdesc_translated = $objp->description_translated;
3018 $outbarcode = $objp->barcode;
3019 $outorigin = $objp->fk_country;
3020 $outpbq = empty($objp->price_by_qty_rowid) ?
'' : $objp->price_by_qty_rowid;
3022 $outtype = $objp->fk_product_type;
3026 if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) {
3027 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
3033 if (!empty($objp->unit_short)) {
3034 $outvalUnits .=
' - ' . $objp->unit_short;
3037 if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) {
3038 if (!empty($objp->weight) && $objp->weight_units !==
null) {
3040 $outvalUnits .=
' - ' . $unitToShow;
3042 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !==
null) {
3043 $unitToShow = $objp->length .
' x ' . $objp->width .
' x ' . $objp->height .
' ' .
measuringUnitString(0,
'size', $objp->length_units);
3044 $outvalUnits .=
' - ' . $unitToShow;
3046 if (!empty($objp->surface) && $objp->surface_units !==
null) {
3048 $outvalUnits .=
' - ' . $unitToShow;
3050 if (!empty($objp->volume) && $objp->volume_units !==
null) {
3052 $outvalUnits .=
' - ' . $unitToShow;
3055 if ($outdurationvalue && $outdurationunit) {
3057 'h' => $langs->trans(
'Hour'),
3058 'd' => $langs->trans(
'Day'),
3059 'w' => $langs->trans(
'Week'),
3060 'm' => $langs->trans(
'Month'),
3061 'y' => $langs->trans(
'Year')
3063 if (isset($da[$outdurationunit])) {
3064 $outvalUnits .=
' - ' . $outdurationvalue .
' ' . $langs->transnoentities($da[$outdurationunit] . ($outdurationvalue > 1 ?
's' :
''));
3068 $opt =
'<option value="' . $objp->rowid .
'"';
3069 $opt .= ($objp->rowid == $selected) ?
' selected' :
'';
3070 if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) {
3071 $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 .
'"';
3073 if (isModEnabled(
'stock') && isset($objp->stock) && ($objp->fk_product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
3074 if (!empty($user->rights->stock->lire)) {
3075 if ($objp->stock > 0) {
3076 $opt .=
' class="product_line_stock_ok"';
3077 } elseif ($objp->stock <= 0) {
3078 $opt .=
' class="product_line_stock_too_low"';
3082 if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
3083 $opt .=
' data-labeltrans="' . $outlabel_translated .
'"';
3088 if (!empty($objp->custref)) {
3089 $opt .=
' (' . $objp->custref .
')';
3092 $opt .=
' (' . $outbarcode .
')';
3094 $opt .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3095 if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) {
3096 $opt .=
' (' .
getCountry($outorigin, 1) .
')';
3099 $objRef = $objp->ref;
3100 if (!empty($objp->custref)) {
3101 $objRef .=
' (' . $objp->custref .
')';
3103 if (!empty($filterkey) && $filterkey !=
'') {
3104 $objRef = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRef, 1);
3108 $outval .=
' (' . $outbarcode .
')';
3110 $outval .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3111 if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) {
3112 $outval .=
' (' .
getCountry($outorigin, 1) .
')';
3116 $opt .= $outvalUnits;
3117 $outval .= $outvalUnits;
3123 if (empty($hidepriceinlabel) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
3124 $sql =
"SELECT price, price_ttc, price_base_type, tva_tx, default_vat_code";
3125 $sql .=
" FROM " . $this->db->prefix() .
"product_price";
3126 $sql .=
" WHERE fk_product = " . ((int) $objp->rowid);
3127 $sql .=
" AND entity IN (" .
getEntity(
'productprice') .
")";
3128 $sql .=
" AND price_level = " . ((int) $price_level);
3129 $sql .=
" ORDER BY date_price DESC, rowid DESC";
3132 dol_syslog(get_class($this) .
'::constructProductListOption search price for product ' . $objp->rowid .
' AND level ' . $price_level, LOG_DEBUG);
3133 $result2 = $this->db->query($sql);
3135 $objp2 = $this->db->fetch_object($result2);
3138 if ($objp2->price_base_type ==
'HT') {
3139 $opt .=
' - ' .
price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"HT");
3140 $outval .=
' - ' .
price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"HT");
3142 $opt .=
' - ' .
price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"TTC");
3143 $outval .=
' - ' .
price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"TTC");
3145 $outprice_ht =
price($objp2->price);
3146 $outprice_ttc =
price($objp2->price_ttc);
3147 $outpricebasetype = $objp2->price_base_type;
3148 if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {
3149 $outtva_tx = $objp2->tva_tx;
3150 $outdefault_vat_code = $objp2->default_vat_code;
3152 $outtva_tx = $objp->tva_tx;
3153 $outdefault_vat_code = $objp->default_vat_code;
3162 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))) {
3164 $outqty = $objp->quantity;
3165 $outdiscount = $objp->remise_percent;
3166 if ($objp->quantity == 1) {
3167 $opt .=
' - ' .
price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) .
"/";
3168 $outval .=
' - ' .
price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) .
"/";
3169 $opt .= $langs->trans(
"Unit");
3170 $outval .= $langs->transnoentities(
"Unit");
3172 $opt .=
' - ' .
price($objp->price, 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3173 $outval .=
' - ' .
price($objp->price, 0, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3174 $opt .= $langs->trans(
"Units");
3175 $outval .= $langs->transnoentities(
"Units");
3178 $outprice_ht =
price($objp->unitprice);
3179 $outprice_ttc =
price($objp->unitprice * (1 + ($objp->tva_tx / 100)));
3180 $outpricebasetype = $objp->price_base_type;
3181 $outtva_tx = $objp->tva_tx;
3182 $outdefault_vat_code = $objp->default_vat_code;
3184 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1) {
3185 $opt .=
" (" .
price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $langs->trans(
"Unit") .
")";
3186 $outval .=
" (" .
price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) .
"/" . $langs->transnoentities(
"Unit") .
")";
3188 if (empty($hidepriceinlabel) && !empty($objp->remise_percent) && $objp->remise_percent >= 1) {
3189 $opt .=
" - " . $langs->trans(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3190 $outval .=
" - " . $langs->transnoentities(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3194 if (empty($hidepriceinlabel) && !empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
3195 if (!empty($objp->idprodcustprice)) {
3198 if ($objp->custprice_base_type ==
'HT') {
3199 $opt .=
' - ' .
price($objp->custprice, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"HT");
3200 $outval .=
' - ' .
price($objp->custprice, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"HT");
3202 $opt .=
' - ' .
price($objp->custprice_ttc, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"TTC");
3203 $outval .=
' - ' .
price($objp->custprice_ttc, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"TTC");
3206 $outprice_ht =
price($objp->custprice);
3207 $outprice_ttc =
price($objp->custprice_ttc);
3208 $outpricebasetype = $objp->custprice_base_type;
3209 $outtva_tx = $objp->custtva_tx;
3210 $outdefault_vat_code = $objp->custdefault_vat_code;
3215 if (empty($hidepriceinlabel) && !$found) {
3216 if ($objp->price_base_type ==
'HT') {
3217 $opt .=
' - ' .
price($objp->price, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"HT");
3218 $outval .=
' - ' .
price($objp->price, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"HT");
3220 $opt .=
' - ' .
price($objp->price_ttc, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"TTC");
3221 $outval .=
' - ' .
price($objp->price_ttc, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"TTC");
3223 $outprice_ht =
price($objp->price);
3224 $outprice_ttc =
price($objp->price_ttc);
3225 $outpricebasetype = $objp->price_base_type;
3226 $outtva_tx = $objp->tva_tx;
3227 $outdefault_vat_code = $objp->default_vat_code;
3230 if (isModEnabled(
'stock') && isset($objp->stock) && ($objp->fk_product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
3231 if (!empty($user->rights->stock->lire)) {
3232 $opt .=
' - ' . $langs->trans(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'));
3234 if ($objp->stock > 0) {
3235 $outval .=
' - <span class="product_line_stock_ok">';
3236 } elseif ($objp->stock <= 0) {
3237 $outval .=
' - <span class="product_line_stock_too_low">';
3239 $outval .= $langs->transnoentities(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'));
3240 $outval .=
'</span>';
3241 if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) {
3242 $langs->load(
"stocks");
3244 $tmpproduct =
new Product($this->db);
3245 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3246 $tmpproduct->load_virtual_stock();
3247 $virtualstock = $tmpproduct->stock_theorique;
3249 $opt .=
' - ' . $langs->trans(
"VirtualStock") .
':' . $virtualstock;
3251 $outval .=
' - ' . $langs->transnoentities(
"VirtualStock") .
':';
3252 if ($virtualstock > 0) {
3253 $outval .=
'<span class="product_line_stock_ok">';
3254 } elseif ($virtualstock <= 0) {
3255 $outval .=
'<span class="product_line_stock_too_low">';
3257 $outval .= $virtualstock;
3258 $outval .=
'</span>';
3265 $parameters = array(
'objp'=>$objp);
3266 $reshook = $hookmanager->executeHooks(
'constructProductListOption', $parameters);
3267 if (empty($reshook)) {
3268 $opt .= $hookmanager->resPrint;
3270 $opt = $hookmanager->resPrint;
3273 $opt .=
"</option>\n";
3278 'label2' => $outlabel,
3282 'price_ttc' =>
price2num($outprice_ttc),
3285 'pricebasetype' => $outpricebasetype,
3286 'tva_tx' => $outtva_tx,
3287 'default_vat_code' => $outdefault_vat_code,
3289 'discount' => $outdiscount,
3290 'duration_value' => $outdurationvalue,
3291 'duration_unit' => $outdurationunit,
3293 'labeltrans' => $outlabel_translated,
3294 'desctrans' => $outdesc_translated,
3295 'ref_customer' => $outrefcust
3316 public function select_produits_fournisseurs($socid, $selected =
'', $htmlname =
'productid', $filtertype =
'', $filtre =
'', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss =
'', $placeholder =
'')
3319 global $langs, $conf;
3320 global $price_level, $status, $finished;
3322 if (!isset($status)) {
3326 $selected_input_value =
'';
3327 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
3328 if ($selected > 0) {
3329 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
3330 $producttmpselect =
new Product($this->db);
3331 $producttmpselect->fetch($selected);
3332 $selected_input_value = $producttmpselect->ref;
3333 unset($producttmpselect);
3337 $urloption = ($socid > 0 ?
'socid=' . $socid .
'&' :
'') .
'htmlname=' . $htmlname .
'&outjson=1&price_level=' . $price_level .
'&type=' . $filtertype .
'&mode=2&status=' . $status .
'&finished=' . $finished .
'&alsoproductwithnosupplierprice=' . $alsoproductwithnosupplierprice;
3338 print
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT .
'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
3340 print ($hidelabel ?
'' : $langs->trans(
"RefOrLabel") .
' : ') .
'<input type="text" class="minwidth300" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . ($placeholder ?
' placeholder="' . $placeholder .
'"' :
'') .
'>';
3342 print $this->
select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre,
'', $status, 0, 0, $alsoproductwithnosupplierprice, $morecss, 0, $placeholder);
3366 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 =
'')
3369 global $langs, $conf, $user;
3370 global $hookmanager;
3373 $outarray = array();
3375 $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
3377 $langs->load(
'stocks');
3380 $langs->load(
'other');
3383 $sql =
"SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type, p.stock, p.tva_tx as tva_tx_sale, p.default_vat_code as default_vat_code_sale,";
3384 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice";
3385 $sql .=
", pfp.multicurrency_code, pfp.multicurrency_unitprice";
3386 $sql .=
", pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.default_vat_code, pfp.fk_soc, s.nom as name";
3387 $sql .=
", pfp.supplier_reputation";
3389 if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) {
3390 $sql .=
", pfp.desc_fourn as description";
3392 $sql .=
", p.description";
3396 $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";
3398 if (isModEnabled(
'barcode')) {
3399 $sql .=
", pfp.barcode";
3401 $sql .=
" FROM " . $this->db->prefix() .
"product as p";
3402 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (" .
getEntity(
'product') .
") )";
3404 $sql .=
" AND pfp.fk_soc = " . ((int) $socid);
3406 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON pfp.fk_soc = s.rowid";
3409 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_units u ON u.rowid = p.fk_unit";
3411 $sql .=
" WHERE p.entity IN (" .
getEntity(
'product') .
")";
3412 if ($statut != -1) {
3413 $sql .=
" AND p.tobuy = " . ((int) $statut);
3415 if (strval($filtertype) !=
'') {
3416 $sql .=
" AND p.fk_product_type = " . ((int) $filtertype);
3418 if (!empty($filtre)) {
3419 $sql .=
" " . $filtre;
3422 $parameters = array();
3423 $reshook = $hookmanager->executeHooks(
'selectSuppliersProductsListWhere', $parameters);
3424 $sql .= $hookmanager->resPrint;
3426 if ($filterkey !=
'') {
3428 $prefix = empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE) ?
'%' :
'';
3430 $scrit = explode(
' ', $filterkey);
3432 if (count($scrit) > 1) {
3435 foreach ($scrit as $crit) {
3439 $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) .
"%'";
3440 if (!empty($conf->global->PRODUIT_FOURN_TEXTS)) {
3441 $sql .=
" OR pfp.desc_fourn LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3446 if (count($scrit) > 1) {
3449 if (isModEnabled(
'barcode')) {
3450 $sql .=
" OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
3451 $sql .=
" OR pfp.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
3455 $sql .=
" ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
3456 $sql .= $this->db->plimit($limit, 0);
3460 dol_syslog(get_class($this) .
"::select_produits_fournisseurs_list", LOG_DEBUG);
3461 $result = $this->db->query($sql);
3463 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3464 require_once DOL_DOCUMENT_ROOT .
'/core/lib/product.lib.php';
3466 $num = $this->db->num_rows($result);
3469 $out .=
'<select class="flat ' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'">';
3471 $out .=
'<option value="-1" selected>' . ($placeholder ? $placeholder :
' ') .
'</option>';
3473 $out .=
'<option value="-1">' . ($placeholder ? $placeholder :
' ') .
'</option>';
3478 $objp = $this->db->fetch_object($result);
3480 if (is_null($objp->idprodfournprice)) {
3482 $objp->tva_tx = $objp->tva_tx_sale;
3483 $objp->default_vat_code = $objp->default_vat_code_sale;
3486 $outkey = $objp->idprodfournprice;
3487 if (!$outkey && $alsoproductwithnosupplierprice) {
3488 $outkey =
'idprod_' . $objp->rowid;
3491 $outref = $objp->ref;
3492 $outbarcode = $objp->barcode;
3495 $outtype = $objp->fk_product_type;
3502 if (!empty($objp->unit_short)) {
3503 $outvalUnits .=
' - ' . $objp->unit_short;
3505 if (!empty($objp->weight) && $objp->weight_units !==
null) {
3507 $outvalUnits .=
' - ' . $unitToShow;
3509 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !==
null) {
3510 $unitToShow = $objp->length .
' x ' . $objp->width .
' x ' . $objp->height .
' ' .
measuringUnitString(0,
'size', $objp->length_units);
3511 $outvalUnits .=
' - ' . $unitToShow;
3513 if (!empty($objp->surface) && $objp->surface_units !==
null) {
3515 $outvalUnits .=
' - ' . $unitToShow;
3517 if (!empty($objp->volume) && $objp->volume_units !==
null) {
3519 $outvalUnits .=
' - ' . $unitToShow;
3521 if ($outdurationvalue && $outdurationunit) {
3523 'h' => $langs->trans(
'Hour'),
3524 'd' => $langs->trans(
'Day'),
3525 'w' => $langs->trans(
'Week'),
3526 'm' => $langs->trans(
'Month'),
3527 'y' => $langs->trans(
'Year')
3529 if (isset($da[$outdurationunit])) {
3530 $outvalUnits .=
' - ' . $outdurationvalue .
' ' . $langs->transnoentities($da[$outdurationunit] . ($outdurationvalue > 1 ?
's' :
''));
3535 $objRef = $objp->ref;
3536 if ($filterkey && $filterkey !=
'') {
3537 $objRef = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRef, 1);
3539 $objRefFourn = $objp->ref_fourn;
3540 if ($filterkey && $filterkey !=
'') {
3541 $objRefFourn = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRefFourn, 1);
3543 $label = $objp->label;
3544 if ($filterkey && $filterkey !=
'') {
3545 $label = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $label, 1);
3548 $optlabel = $objp->ref;
3549 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
3550 $optlabel .=
' <span class="opacitymedium">(' . $objp->ref_fourn .
')</span>';
3552 if (isModEnabled(
'barcode') && !empty($objp->barcode)) {
3553 $optlabel .=
' (' . $outbarcode .
')';
3555 $optlabel .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3557 $outvallabel = $objRef;
3558 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
3559 $outvallabel .=
' (' . $objRefFourn .
')';
3561 if (isModEnabled(
'barcode') && !empty($objp->barcode)) {
3562 $outvallabel .=
' (' . $outbarcode .
')';
3564 $outvallabel .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3567 $optlabel .= $outvalUnits;
3568 $outvallabel .= $outvalUnits;
3570 if (!empty($objp->idprodfournprice)) {
3571 $outqty = $objp->quantity;
3572 $outdiscount = $objp->remise_percent;
3573 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_supplier_price_expression)) {
3575 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
3576 $prod_supplier->id = $objp->fk_product;
3577 $prod_supplier->fourn_qty = $objp->quantity;
3578 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
3579 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
3581 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3583 $price_result = $priceparser->parseProductSupplier($prod_supplier);
3584 if ($price_result >= 0) {
3585 $objp->fprice = $price_result;
3586 if ($objp->quantity >= 1) {
3587 $objp->unitprice = $objp->fprice / $objp->quantity;
3591 if ($objp->quantity == 1) {
3592 $optlabel .=
' - ' .
price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/";
3593 $outvallabel .=
' - ' .
price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency) .
"/";
3594 $optlabel .= $langs->trans(
"Unit");
3595 $outvallabel .= $langs->transnoentities(
"Unit");
3597 $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;
3598 $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;
3599 $optlabel .=
' ' . $langs->trans(
"Units");
3600 $outvallabel .=
' ' . $langs->transnoentities(
"Units");
3603 if ($objp->quantity > 1) {
3604 $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") .
")";
3605 $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") .
")";
3607 if ($objp->remise_percent >= 1) {
3608 $optlabel .=
" - " . $langs->trans(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3609 $outvallabel .=
" - " . $langs->transnoentities(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3611 if ($objp->duration) {
3612 $optlabel .=
" - " . $objp->duration;
3613 $outvallabel .=
" - " . $objp->duration;
3616 $optlabel .=
" - " .
dol_trunc($objp->name, 8);
3617 $outvallabel .=
" - " .
dol_trunc($objp->name, 8);
3619 if ($objp->supplier_reputation) {
3621 $reputations = array(
'' => $langs->trans(
'Standard'),
'FAVORITE' => $langs->trans(
'Favorite'),
'NOTTHGOOD' => $langs->trans(
'NotTheGoodQualitySupplier'),
'DONOTORDER' => $langs->trans(
'DoNotOrderThisProductToThisSupplier'));
3623 $optlabel .=
" - " . $reputations[$objp->supplier_reputation];
3624 $outvallabel .=
" - " . $reputations[$objp->supplier_reputation];
3627 if (empty($alsoproductwithnosupplierprice)) {
3628 $optlabel .=
" - <span class='opacitymedium'>" . $langs->trans(
"NoPriceDefinedForThisSupplier") .
'</span>';
3629 $outvallabel .=
' - ' . $langs->transnoentities(
"NoPriceDefinedForThisSupplier");
3632 $optlabel .=
" - <span class='opacitymedium'>" . $langs->trans(
"NoPriceDefinedForThisSupplier") .
'</span>';
3633 $outvallabel .=
' - ' . $langs->transnoentities(
"NoPriceDefinedForThisSupplier");
3637 if (isModEnabled(
'stock') && $showstockinlist && isset($objp->stock) && ($objp->fk_product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) {
3638 $novirtualstock = ($showstockinlist == 2);
3640 if (!empty($user->rights->stock->lire)) {
3641 $outvallabel .=
' - ' . $langs->trans(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'));
3643 if ($objp->stock > 0) {
3644 $optlabel .=
' - <span class="product_line_stock_ok">';
3645 } elseif ($objp->stock <= 0) {
3646 $optlabel .=
' - <span class="product_line_stock_too_low">';
3648 $optlabel .= $langs->transnoentities(
"Stock") .
':' .
price(
price2num($objp->stock,
'MS'));
3649 $optlabel .=
'</span>';
3650 if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) {
3651 $langs->load(
"stocks");
3653 $tmpproduct =
new Product($this->db);
3654 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3655 $tmpproduct->load_virtual_stock();
3656 $virtualstock = $tmpproduct->stock_theorique;
3658 $outvallabel .=
' - ' . $langs->trans(
"VirtualStock") .
':' . $virtualstock;
3660 $optlabel .=
' - ' . $langs->transnoentities(
"VirtualStock") .
':';
3661 if ($virtualstock > 0) {
3662 $optlabel .=
'<span class="product_line_stock_ok">';
3663 } elseif ($virtualstock <= 0) {
3664 $optlabel .=
'<span class="product_line_stock_too_low">';
3666 $optlabel .= $virtualstock;
3667 $optlabel .=
'</span>';
3674 $optstart =
'<option value="' . $outkey .
'"';
3675 if ($selected && $selected == $objp->idprodfournprice) {
3676 $optstart .=
' selected';
3678 if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) {
3679 $optstart .=
' disabled';
3682 if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
3691 $optstart .=
' data-default-vat-code="' .
dol_escape_htmltag($objp->default_vat_code) .
'"';
3693 if (isModEnabled(
'multicurrency')) {
3694 $optstart .=
' data-multicurrency-code="' .
dol_escape_htmltag($objp->multicurrency_code) .
'"';
3695 $optstart .=
' data-multicurrency-up="' .
dol_escape_htmltag($objp->multicurrency_unitprice) .
'"';
3698 $optstart .=
' data-description="' .
dol_escape_htmltag($objp->description, 0, 1) .
'"';
3700 $outarrayentry = array(
3703 'label' => $outvallabel,
3705 'price_qty_ht' =>
price2num($objp->fprice,
'MU'),
3706 'price_unit_ht' =>
price2num($objp->unitprice,
'MU'),
3707 'price_ht' =>
price2num($objp->unitprice,
'MU'),
3708 'tva_tx_formated' =>
price($objp->tva_tx, 0, $langs, 1, -1, 2),
3710 'default_vat_code' => $objp->default_vat_code,
3711 'discount' => $outdiscount,
3713 'duration_value' => $outdurationvalue,
3714 'duration_unit' => $outdurationunit,
3715 'disabled' => (empty($objp->idprodfournprice) ?
true :
false),
3716 'description' => $objp->description
3718 if (isModEnabled(
'multicurrency')) {
3719 $outarrayentry[
'multicurrency_code'] = $objp->multicurrency_code;
3720 $outarrayentry[
'multicurrency_unitprice'] =
price2num($objp->multicurrency_unitprice,
'MU');
3723 $parameters = array(
3725 'optstart' => &$optstart,
3726 'optlabel' => &$optlabel,
3727 'outvallabel' => &$outvallabel,
3728 'outarrayentry' => &$outarrayentry
3730 $reshook = $hookmanager->executeHooks(
'selectProduitsFournisseurListOption', $parameters, $this);
3736 $out .= $optstart .
' data-html="' .
dol_escape_htmltag($optlabel) .
'">' . $optlabel .
"</option>\n";
3737 $outarraypush = array(
3740 'label' => $outvallabel,
3742 'price_qty_ht' =>
price2num($objp->fprice,
'MU'),
3743 'price_qty_ht_locale' =>
price($objp->fprice),
3744 'price_unit_ht' =>
price2num($objp->unitprice,
'MU'),
3745 'price_unit_ht_locale' =>
price($objp->unitprice),
3746 'price_ht' =>
price2num($objp->unitprice,
'MU'),
3747 'tva_tx_formated' =>
price($objp->tva_tx),
3749 'default_vat_code' => $objp->default_vat_code,
3750 'discount' => $outdiscount,
3752 'duration_value' => $outdurationvalue,
3753 'duration_unit' => $outdurationunit,
3754 'disabled' => (empty($objp->idprodfournprice) ?
true :
false),
3755 'description' => $objp->description
3757 if (isModEnabled(
'multicurrency')) {
3758 $outarraypush[
'multicurrency_code'] = $objp->multicurrency_code;
3759 $outarraypush[
'multicurrency_unitprice'] =
price2num($objp->multicurrency_unitprice,
'MU');
3761 array_push($outarray, $outarraypush);
3774 $out .=
'</select>';
3776 $this->db->free($result);
3778 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
3784 if (empty($outputmode)) {
3803 global $langs, $conf;
3805 $langs->load(
'stocks');
3807 $sql =
"SELECT p.rowid, p.ref, p.label, p.price, p.duration, pfp.fk_soc,";
3808 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,";
3809 $sql .=
" pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name";
3810 $sql .=
" FROM " . $this->db->prefix() .
"product as p";
3811 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
3812 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON pfp.fk_soc = s.rowid";
3813 $sql .=
" WHERE pfp.entity IN (" .
getEntity(
'productsupplierprice') .
")";
3814 $sql .=
" AND p.tobuy = 1";
3815 $sql .=
" AND s.fournisseur = 1";
3816 $sql .=
" AND p.rowid = " . ((int) $productid);
3817 if (empty($conf->global->PRODUCT_BEST_SUPPLIER_PRICE_PRESELECTED)) {
3818 $sql .=
" ORDER BY s.nom, pfp.ref_fourn DESC";
3820 $sql .=
" ORDER BY pfp.unitprice ASC";
3823 dol_syslog(get_class($this) .
"::select_product_fourn_price", LOG_DEBUG);
3824 $result = $this->db->query($sql);
3827 $num = $this->db->num_rows($result);
3829 $form =
'<select class="flat" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
3832 $form .=
'<option value="0">-- ' . $langs->trans(
"NoSupplierPriceDefinedForThisProduct") .
' --</option>';
3834 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3835 $form .=
'<option value="0"> </option>';
3839 $objp = $this->db->fetch_object($result);
3841 $opt =
'<option value="' . $objp->idprodfournprice .
'"';
3843 if ($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier) || ($i == 0 && !empty($conf->global->PRODUCT_BEST_SUPPLIER_PRICE_PRESELECTED))) {
3844 $opt .=
' selected';
3846 $opt .=
'>' . $objp->name .
' - ' . $objp->ref_fourn .
' - ';
3848 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_supplier_price_expression)) {
3850 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
3851 $prod_supplier->id = $productid;
3852 $prod_supplier->fourn_qty = $objp->quantity;
3853 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
3854 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
3856 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3858 $price_result = $priceparser->parseProductSupplier($prod_supplier);
3859 if ($price_result >= 0) {
3860 $objp->fprice = $price_result;
3861 if ($objp->quantity >= 1) {
3862 $objp->unitprice = $objp->fprice / $objp->quantity;
3866 if ($objp->quantity == 1) {
3867 $opt .=
price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/";
3870 $opt .= $objp->quantity .
' ';
3872 if ($objp->quantity == 1) {
3873 $opt .= $langs->trans(
"Unit");
3875 $opt .= $langs->trans(
"Units");
3877 if ($objp->quantity > 1) {
3879 $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");
3881 if ($objp->duration) {
3882 $opt .=
" - " . $objp->duration;
3884 $opt .=
"</option>\n";
3891 $form .=
'</select>';
3892 $this->db->free($result);
3911 public function select_address($selected, $socid, $htmlname =
'address_id', $showempty = 0)
3915 $sql =
"SELECT a.rowid, a.label";
3916 $sql .=
" FROM " . $this->db->prefix() .
"societe_address as a";
3917 $sql .=
" WHERE a.fk_soc = " . ((int) $socid);
3918 $sql .=
" ORDER BY a.label ASC";
3920 dol_syslog(get_class($this) .
"::select_address", LOG_DEBUG);
3921 $resql = $this->db->query($sql);
3923 print
'<select class="flat" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
3925 print
'<option value="0"> </option>';
3927 $num = $this->db->num_rows($resql);
3931 $obj = $this->db->fetch_object($resql);
3933 if ($selected && $selected == $obj->rowid) {
3934 print
'<option value="' . $obj->rowid .
'" selected>' . $obj->label .
'</option>';
3936 print
'<option value="' . $obj->rowid .
'">' . $obj->label .
'</option>';
3961 $num = count($this->cache_conditions_paiements);
3968 $sql =
"SELECT rowid, code, libelle as label, deposit_percent";
3969 $sql .=
" FROM " . $this->db->prefix() .
'c_payment_term';
3970 $sql .=
" WHERE entity IN (" .
getEntity(
'c_payment_term') .
")";
3971 $sql .=
" AND active > 0";
3972 $sql .=
" ORDER BY sortorder";
3974 $resql = $this->db->query($sql);
3976 $num = $this->db->num_rows($resql);
3979 $obj = $this->db->fetch_object($resql);
3982 $label = ($langs->trans(
"PaymentConditionShort" . $obj->code) != (
"PaymentConditionShort" . $obj->code) ? $langs->trans(
"PaymentConditionShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
3983 $this->cache_conditions_paiements[$obj->rowid][
'code'] = $obj->code;
3984 $this->cache_conditions_paiements[$obj->rowid][
'label'] = $label;
3985 $this->cache_conditions_paiements[$obj->rowid][
'deposit_percent'] = $obj->deposit_percent;
4010 $num = count($this->cache_availability);
4017 $langs->load(
'propal');
4019 $sql =
"SELECT rowid, code, label, position";
4020 $sql .=
" FROM " . $this->db->prefix() .
'c_availability';
4021 $sql .=
" WHERE active > 0";
4023 $resql = $this->db->query($sql);
4025 $num = $this->db->num_rows($resql);
4028 $obj = $this->db->fetch_object($resql);
4031 $label = ($langs->trans(
"AvailabilityType" . $obj->code) != (
"AvailabilityType" . $obj->code) ? $langs->trans(
"AvailabilityType" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4032 $this->cache_availability[$obj->rowid][
'code'] = $obj->code;
4033 $this->cache_availability[$obj->rowid][
'label'] = $label;
4034 $this->cache_availability[$obj->rowid][
'position'] = $obj->position;
4038 $this->cache_availability =
dol_sort_array($this->cache_availability,
'position',
'asc', 0, 0, 1);
4059 global $langs, $user;
4063 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
4065 print
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4067 print
'<option value="0"> </option>';
4069 foreach ($this->cache_availability as $id => $arrayavailability) {
4070 if ($selected == $id) {
4071 print
'<option value="' . $id .
'" selected>';
4073 print
'<option value="' . $id .
'">';
4080 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4094 $num = count($this->cache_demand_reason);
4099 $sql =
"SELECT rowid, code, label";
4100 $sql .=
" FROM " . $this->db->prefix() .
'c_input_reason';
4101 $sql .=
" WHERE active > 0";
4103 $resql = $this->db->query($sql);
4105 $num = $this->db->num_rows($resql);
4107 $tmparray = array();
4109 $obj = $this->db->fetch_object($resql);
4112 $label = ($obj->label !=
'-' ? $obj->label :
'');
4113 if ($langs->trans(
"DemandReasonType" . $obj->code) != (
"DemandReasonType" . $obj->code)) {
4114 $label = $langs->trans(
"DemandReasonType" . $obj->code);
4116 if ($langs->trans($obj->code) != $obj->code) {
4117 $label = $langs->trans($obj->code);
4120 $tmparray[$obj->rowid][
'id'] = $obj->rowid;
4121 $tmparray[$obj->rowid][
'code'] = $obj->code;
4122 $tmparray[$obj->rowid][
'label'] = $label;
4126 $this->cache_demand_reason =
dol_sort_array($tmparray,
'label',
'asc', 0, 0, 1);
4148 public function selectInputReason($selected =
'', $htmlname =
'demandreasonid', $exclude =
'', $addempty = 0, $morecss =
'', $notooltip = 0)
4150 global $langs, $user;
4154 print
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
4156 print
'<option value="0"' . (empty($selected) ?
' selected' :
'') .
'> </option>';
4158 foreach ($this->cache_demand_reason as $id => $arraydemandreason) {
4159 if ($arraydemandreason[
'code'] == $exclude) {
4163 if ($selected && ($selected == $arraydemandreason[
'id'] || $selected == $arraydemandreason[
'code'])) {
4164 print
'<option value="' . $arraydemandreason[
'id'] .
'" selected>';
4166 print
'<option value="' . $arraydemandreason[
'id'] .
'">';
4168 $label = $arraydemandreason[
'label'];
4169 print $langs->trans($label);
4173 if ($user->admin && empty($notooltip)) {
4174 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4191 $num = count($this->cache_types_paiements);
4198 $this->cache_types_paiements = array();
4200 $sql =
"SELECT id, code, libelle as label, type, active";
4201 $sql .=
" FROM " . $this->db->prefix() .
"c_paiement";
4202 $sql .=
" WHERE entity IN (" .
getEntity(
'c_paiement') .
")";
4204 $resql = $this->db->query($sql);
4206 $num = $this->db->num_rows($resql);
4209 $obj = $this->db->fetch_object($resql);
4212 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) != (
"PaymentTypeShort" . $obj->code) ? $langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4213 $this->cache_types_paiements[$obj->id][
'id'] = $obj->id;
4214 $this->cache_types_paiements[$obj->id][
'code'] = $obj->code;
4215 $this->cache_types_paiements[$obj->id][
'label'] = $label;
4216 $this->cache_types_paiements[$obj->id][
'type'] = $obj->type;
4217 $this->cache_types_paiements[$obj->id][
'active'] = $obj->active;
4221 $this->cache_types_paiements =
dol_sort_array($this->cache_types_paiements,
'label',
'asc', 0, 0, 1);
4250 public function select_conditions_paiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1)
4273 public function getSelectConditionsPaiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1)
4275 global $langs, $user, $conf;
4278 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
4283 if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) {
4284 $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID;
4287 $out .=
'<select id="' . $htmlname .
'" class="flat selectpaymentterms' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4289 $out .=
'<option value="0"> </option>';
4292 $selectedDepositPercent =
null;
4294 foreach ($this->cache_conditions_paiements as $id => $arrayconditions) {
4295 if ($filtertype <= 0 && !empty($arrayconditions[
'deposit_percent'])) {
4299 if ($selected == $id) {
4300 $selectedDepositPercent = $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'];
4301 $out .=
'<option value="' . $id .
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'" selected>';
4303 $out .=
'<option value="' . $id .
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'">';
4305 $label = $arrayconditions[
'label'];
4307 if (!empty($arrayconditions[
'deposit_percent'])) {
4308 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'], $label);
4312 $out .=
'</option>';
4314 $out .=
'</select>';
4315 if ($user->admin && empty($noinfoadmin)) {
4316 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4320 if ($deposit_percent >= 0) {
4321 $out .=
' <span id="' . $htmlname .
'_deposit_percent_container"' . (empty($selectedDepositPercent) ?
' style="display: none"' :
'') .
'>';
4322 $out .= $langs->trans(
'DepositPercent') .
' : ';
4323 $out .=
'<input id="' . $htmlname .
'_deposit_percent" name="' . $htmlname .
'_deposit_percent" class="maxwidth50" value="' . $deposit_percent .
'" />';
4326 <script nonce="' .
getNonce() .
'">
4327 $(document).ready(function () {
4328 $("#' . $htmlname .
'").change(function () {
4329 let $selected = $(this).find("option:selected");
4330 let depositPercent = $selected.attr("data-deposit_percent");
4332 if (depositPercent.length > 0) {
4333 $("#' . $htmlname .
'_deposit_percent_container").show().find("#' . $htmlname .
'_deposit_percent").val(depositPercent);
4335 $("#' . $htmlname .
'_deposit_percent_container").hide();
4366 public function select_types_paiements($selected =
'', $htmlname =
'paiementtype', $filtertype =
'', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'', $nooutput = 0)
4369 global $langs, $user, $conf;
4373 dol_syslog(__METHOD__ .
" " . $selected .
", " . $htmlname .
", " . $filtertype .
", " . $format, LOG_DEBUG);
4375 $filterarray = array();
4376 if ($filtertype ==
'CRDT') {
4377 $filterarray = array(0, 2, 3);
4378 } elseif ($filtertype ==
'DBIT') {
4379 $filterarray = array(1, 2, 3);
4380 } elseif ($filtertype !=
'' && $filtertype !=
'-1') {
4381 $filterarray = explode(
',', $filtertype);
4387 if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID)) {
4388 $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID;
4391 $out .=
'<select id="select' . $htmlname .
'" class="flat selectpaymenttypes' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4393 $out .=
'<option value=""> </option>';
4395 foreach ($this->cache_types_paiements as $id => $arraytypes) {
4397 if ($active >= 0 && $arraytypes[
'active'] != $active) {
4402 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
4407 if ($empty && empty($arraytypes[
'code'])) {
4412 $out .=
'<option value="' . $id .
'"';
4413 } elseif ($format == 1) {
4414 $out .=
'<option value="' . $arraytypes[
'code'] .
'"';
4415 } elseif ($format == 2) {
4416 $out .=
'<option value="' . $arraytypes[
'code'] .
'"';
4417 } elseif ($format == 3) {
4418 $out .=
'<option value="' . $id .
'"';
4421 if ($format == 1 || $format == 2) {
4422 if ($selected == $arraytypes[
'code']) {
4423 $out .=
' selected';
4426 if ($selected == $id) {
4427 $out .=
' selected';
4433 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4434 } elseif ($format == 1) {
4435 $value = $arraytypes[
'code'];
4436 } elseif ($format == 2) {
4437 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4438 } elseif ($format == 3) {
4439 $value = $arraytypes[
'code'];
4441 $out .= $value ? $value :
' ';
4442 $out .=
'</option>';
4444 $out .=
'</select>';
4445 if ($user->admin && !$noadmininfo) {
4446 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4450 if (empty($nooutput)) {
4470 $return =
'<select class="flat maxwidth100" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
4472 'HT' => $langs->trans(
"HT"),
4473 'TTC' => $langs->trans(
"TTC")
4475 foreach ($options as $id => $value) {
4476 if ($selected == $id) {
4477 $return .=
'<option value="' . $id .
'" selected>' . $value;
4479 $return .=
'<option value="' . $id .
'">' . $value;
4481 $return .=
'</option>';
4483 $return .=
'</select>';
4503 $num = count($this->cache_transport_mode);
4510 $this->cache_transport_mode = array();
4512 $sql =
"SELECT rowid, code, label, active";
4513 $sql .=
" FROM " . $this->db->prefix() .
"c_transport_mode";
4514 $sql .=
" WHERE entity IN (" .
getEntity(
'c_transport_mode') .
")";
4516 $resql = $this->db->query($sql);
4518 $num = $this->db->num_rows($resql);
4521 $obj = $this->db->fetch_object($resql);
4524 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) != (
"PaymentTypeShort" . $obj->code) ? $langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4525 $this->cache_transport_mode[$obj->rowid][
'rowid'] = $obj->rowid;
4526 $this->cache_transport_mode[$obj->rowid][
'code'] = $obj->code;
4527 $this->cache_transport_mode[$obj->rowid][
'label'] = $label;
4528 $this->cache_transport_mode[$obj->rowid][
'active'] = $obj->active;
4532 $this->cache_transport_mode =
dol_sort_array($this->cache_transport_mode,
'label',
'asc', 0, 0, 1);
4554 public function selectTransportMode($selected =
'', $htmlname =
'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'')
4556 global $langs, $user;
4558 dol_syslog(__METHOD__ .
" " . $selected .
", " . $htmlname .
", " . $format, LOG_DEBUG);
4562 print
'<select id="select' . $htmlname .
'" class="flat selectmodetransport' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4564 print
'<option value=""> </option>';
4566 foreach ($this->cache_transport_mode as $id => $arraytypes) {
4568 if ($active >= 0 && $arraytypes[
'active'] != $active) {
4573 if ($empty && empty($arraytypes[
'code'])) {
4578 print
'<option value="' . $id .
'"';
4579 } elseif ($format == 1) {
4580 print
'<option value="' . $arraytypes[
'code'] .
'"';
4581 } elseif ($format == 2) {
4582 print
'<option value="' . $arraytypes[
'code'] .
'"';
4583 } elseif ($format == 3) {
4584 print
'<option value="' . $id .
'"';
4587 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraytypes[
'code']) {
4589 } elseif ($selected == $id) {
4595 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4596 } elseif ($format == 1) {
4597 $value = $arraytypes[
'code'];
4598 } elseif ($format == 2) {
4599 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4600 } elseif ($format == 3) {
4601 $value = $arraytypes[
'code'];
4603 print $value ? $value :
' ';
4607 if ($user->admin && !$noadmininfo) {
4608 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4624 public function selectShippingMethod($selected =
'', $htmlname =
'shipping_method_id', $filtre =
'', $useempty = 0, $moreattrib =
'', $noinfoadmin = 0, $morecss =
'')
4626 global $langs, $conf, $user;
4628 $langs->load(
"admin");
4629 $langs->load(
"deliveries");
4631 $sql =
"SELECT rowid, code, libelle as label";
4632 $sql .=
" FROM " . $this->db->prefix() .
"c_shipment_mode";
4633 $sql .=
" WHERE active > 0";
4635 $sql .=
" AND " . $filtre;
4637 $sql .=
" ORDER BY libelle ASC";
4639 dol_syslog(get_class($this) .
"::selectShippingMode", LOG_DEBUG);
4640 $result = $this->db->query($sql);
4642 $num = $this->db->num_rows($result);
4645 print
'<select id="select' . $htmlname .
'" class="flat selectshippingmethod' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
4646 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
4647 print
'<option value="-1"> </option>';
4650 $obj = $this->db->fetch_object($result);
4651 if ($selected == $obj->rowid) {
4652 print
'<option value="' . $obj->rowid .
'" selected>';
4654 print
'<option value="' . $obj->rowid .
'">';
4656 print ($langs->trans(
"SendingMethod" . strtoupper($obj->code)) !=
"SendingMethod" . strtoupper($obj->code)) ? $langs->trans(
"SendingMethod" . strtoupper($obj->code)) : $obj->label;
4661 if ($user->admin && empty($noinfoadmin)) {
4662 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4667 print $langs->trans(
"NoShippingMethodDefined");
4687 $langs->load(
"deliveries");
4689 if ($htmlname !=
"none") {
4690 print
'<form method="POST" action="' . $page .
'">';
4691 print
'<input type="hidden" name="action" value="setshippingmethod">';
4692 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
4694 print
'<input type="submit" class="button valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
4698 $code = $langs->getLabelFromKey($this->db, $selected,
'c_shipment_mode',
'rowid',
'code');
4699 print $langs->trans(
"SendingMethod" . strtoupper($code));
4718 $langs->load(
'bills');
4720 $opt =
'<option value="" selected></option>';
4721 $sql =
"SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc";
4722 $sql .=
' FROM ' . $this->db->prefix() .
'facture';
4723 $sql .=
' WHERE entity IN (' .
getEntity(
'invoice') .
')';
4724 $sql .=
' AND situation_counter >= 1';
4725 $sql .=
' AND fk_soc = ' . (int) $socid;
4726 $sql .=
' AND type <> 2';
4727 $sql .=
' ORDER by situation_cycle_ref, situation_counter desc';
4728 $resql = $this->db->query($sql);
4730 if ($resql && $this->db->num_rows($resql) > 0) {
4733 while ($obj = $this->db->fetch_object($resql)) {
4735 if ($obj->situation_cycle_ref != $ref) {
4737 $ref = $obj->situation_cycle_ref;
4739 if ($obj->situation_final != 1) {
4741 if (substr($obj->ref, 1, 4) !=
'PROV') {
4742 if ($selected == $obj->rowid) {
4743 $opt .=
'<option value="' . $obj->rowid .
'" selected>' . $obj->ref .
'</option>';
4745 $opt .=
'<option value="' . $obj->rowid .
'">' . $obj->ref .
'</option>';
4752 dol_syslog(
"Error sql=" . $sql .
", error=" . $this->error, LOG_ERR);
4754 if ($opt ==
'<option value ="" selected></option>') {
4755 $opt =
'<option value ="0" selected>' . $langs->trans(
'NoSituations') .
'</option>';
4769 public function selectUnits($selected =
'', $htmlname =
'units', $showempty = 0, $unit_type =
'')
4773 $langs->load(
'products');
4775 $return =
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'">';
4777 $sql =
"SELECT rowid, label, code FROM " . $this->db->prefix() .
"c_units";
4778 $sql .=
' WHERE active > 0';
4779 if (!empty($unit_type)) {
4780 $sql .=
" AND unit_type = '" . $this->db->escape($unit_type) .
"'";
4782 $sql .=
" ORDER BY sortorder";
4784 $resql = $this->db->query($sql);
4785 if ($resql && $this->db->num_rows($resql) > 0) {
4787 $return .=
'<option value="none"></option>';
4790 while ($res = $this->db->fetch_object($resql)) {
4791 $unitLabel = $res->label;
4792 if (!empty($langs->tab_translate[
'unit' . $res->code])) {
4793 $unitLabel = $langs->trans(
'unit' . $res->code) != $res->label ? $langs->trans(
'unit' . $res->code) : $res->label;
4796 if ($selected == $res->rowid) {
4797 $return .=
'<option value="' . $res->rowid .
'" selected>' . $unitLabel .
'</option>';
4799 $return .=
'<option value="' . $res->rowid .
'">' . $unitLabel .
'</option>';
4802 $return .=
'</select>';
4823 public function select_comptes($selected =
'', $htmlname =
'accountid', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'', $showcurrency = 0, $morecss =
'', $nooutput = 0)
4826 global $langs, $conf;
4830 $langs->load(
"admin");
4833 $sql =
"SELECT rowid, label, bank, clos as status, currency_code";
4834 $sql .=
" FROM " . $this->db->prefix() .
"bank_account";
4835 $sql .=
" WHERE entity IN (" .
getEntity(
'bank_account') .
")";
4837 $sql .=
" AND clos = " . (int) $status;
4840 $sql .=
" AND " . $filtre;
4842 $sql .=
" ORDER BY label";
4844 dol_syslog(get_class($this) .
"::select_comptes", LOG_DEBUG);
4845 $result = $this->db->query($sql);
4847 $num = $this->db->num_rows($result);
4850 $out .=
'<select id="select' . $htmlname .
'" class="flat selectbankaccount' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
4851 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
4852 $out .=
'<option value="-1"> </option>';
4856 $obj = $this->db->fetch_object($result);
4857 if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected))) {
4858 $out .=
'<option value="' . $obj->rowid .
'" data-currency-code="' . $obj->currency_code .
'" selected>';
4860 $out .=
'<option value="' . $obj->rowid .
'" data-currency-code="' . $obj->currency_code .
'">';
4862 $out .= trim($obj->label);
4863 if ($showcurrency) {
4864 $out .=
' (' . $obj->currency_code .
')';
4866 if ($status == 2 && $obj->status == 1) {
4867 $out .=
' (' . $langs->trans(
"Closed") .
')';
4869 $out .=
'</option>';
4872 $out .=
"</select>";
4876 $out .=
'<span class="opacitymedium">' . $langs->trans(
"NoActiveBankAccountDefined") .
'</span>';
4878 $out .=
'<span class="opacitymedium">' . $langs->trans(
"NoBankAccountFound") .
'</span>';
4886 if (empty($nooutput)) {
4906 public function selectEstablishments($selected =
'', $htmlname =
'entity', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'')
4908 global $langs, $conf;
4910 $langs->load(
"admin");
4913 $sql =
"SELECT rowid, name, fk_country, status, entity";
4914 $sql .=
" FROM " . $this->db->prefix() .
"establishment";
4915 $sql .=
" WHERE 1=1";
4917 $sql .=
" AND status = " . (int) $status;
4920 $sql .=
" AND " . $filtre;
4922 $sql .=
" ORDER BY name";
4924 dol_syslog(get_class($this) .
"::select_establishment", LOG_DEBUG);
4925 $result = $this->db->query($sql);
4927 $num = $this->db->num_rows($result);
4930 print
'<select id="select' . $htmlname .
'" class="flat selectestablishment" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
4931 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
4932 print
'<option value="-1"> </option>';
4936 $obj = $this->db->fetch_object($result);
4937 if ($selected == $obj->rowid) {
4938 print
'<option value="' . $obj->rowid .
'" selected>';
4940 print
'<option value="' . $obj->rowid .
'">';
4942 print trim($obj->name);
4943 if ($status == 2 && $obj->status == 1) {
4944 print
' (' . $langs->trans(
"Closed") .
')';
4952 print
'<span class="opacitymedium">' . $langs->trans(
"NoActiveEstablishmentDefined") .
'</span>';
4954 print
'<span class="opacitymedium">' . $langs->trans(
"NoEstablishmentFound") .
'</span>';
4977 if ($htmlname !=
"none") {
4978 print
'<form method="POST" action="' . $page .
'">';
4979 print
'<input type="hidden" name="action" value="setbankaccount">';
4980 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
4981 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
4982 $nbaccountfound = $this->
select_comptes($selected, $htmlname, 0,
'', $addempty);
4983 if ($nbaccountfound > 0) {
4984 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
4988 $langs->load(
'banks');
4991 require_once DOL_DOCUMENT_ROOT .
'/compta/bank/class/account.class.php';
4992 $bankstatic =
new Account($this->db);
4993 $result = $bankstatic->fetch($selected);
4995 print $bankstatic->getNomUrl(1);
5023 public function select_all_categories($type, $selected =
'', $htmlname =
"parent", $maxlength = 64, $markafterid = 0, $outputmode = 0, $include = 0, $morecss =
'')
5026 global $conf, $langs;
5027 $langs->load(
"categories");
5029 include_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
5032 if (is_numeric($type)) {
5033 dol_syslog(__METHOD__ .
': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
5036 if ($type === Categorie::TYPE_BANK_LINE) {
5038 $cate_arbo = array();
5039 $sql =
"SELECT c.label, c.rowid";
5040 $sql .=
" FROM " . $this->db->prefix() .
"bank_categ as c";
5041 $sql .=
" WHERE entity = " . $conf->entity;
5042 $sql .=
" ORDER BY c.label";
5043 $result = $this->db->query($sql);
5045 $num = $this->db->num_rows($result);
5048 $objp = $this->db->fetch_object($result);
5050 $cate_arbo[$objp->rowid] = array(
'id' => $objp->rowid,
'fulllabel' => $objp->label,
'color' =>
'',
'picto' =>
'category');
5054 $this->db->free($result);
5060 $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include);
5063 $outarray = array();
5065 $output =
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
5066 if (is_array($cate_arbo)) {
5067 if (!count($cate_arbo)) {
5068 $output .=
'<option value="-1" disabled>' . $langs->trans(
"NoCategoriesDefined") .
'</option>';
5070 $output .=
'<option value="-1"> </option>';
5071 foreach ($cate_arbo as $key => $value) {
5072 if ($cate_arbo[$key][
'id'] == $selected || ($selected ===
'auto' && count($cate_arbo) == 1)) {
5077 $output .=
'<option ' . $add .
'value="' . $cate_arbo[$key][
'id'] .
'"';
5078 $output .=
' data-html="' .
dol_escape_htmltag(
img_picto(
'',
'category',
'class="pictofixedwidth" style="color: #' . $cate_arbo[$key][
'color'] .
'"') .
dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle')) .
'"';
5080 $output .=
dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle');
5081 $output .=
'</option>';
5083 $outarray[$cate_arbo[$key][
'id']] = $cate_arbo[$key][
'fulllabel'];
5087 $output .=
'</select>';
5090 if ($outputmode == 2) {
5092 } elseif ($outputmode) {
5116 public function form_confirm($page, $title, $question, $action, $formquestion =
'', $selectedchoice =
"", $useajax = 0, $height = 170, $width = 500)
5119 dol_syslog(__METHOD__ .
': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING);
5120 print $this->
formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width);
5150 public function formconfirm($page, $title, $question, $action, $formquestion =
'', $selectedchoice =
'', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0, $labelbuttonyes =
'Yes', $labelbuttonno =
'No')
5152 global $langs, $conf;
5154 $more =
'<!-- formconfirm - before call, page=' .
dol_escape_htmltag($page) .
' -->';
5160 $newselectedchoice = empty($selectedchoice) ?
"no" : $selectedchoice;
5161 if ($conf->browser->layout ==
'phone') {
5166 if (empty($height)) {
5168 if (is_array($formquestion) && count($formquestion) > 2) {
5169 $height += ((count($formquestion) - 2) * 24);
5173 if (is_array($formquestion) && !empty($formquestion)) {
5175 foreach ($formquestion as $key => $input) {
5176 if (is_array($input) && !empty($input)) {
5177 if ($input[
'type'] ==
'hidden') {
5178 $moreattr = (!empty($input[
'moreattr']) ?
' ' . $input[
'moreattr'] :
'');
5179 $morecss = (!empty($input[
'morecss']) ?
' ' . $input[
'morecss'] :
'');
5187 $moreonecolumn =
'';
5188 $more .=
'<div class="tagtable paddingtopbottomonly centpercent noborderspacing">' .
"\n";
5189 foreach ($formquestion as $key => $input) {
5190 if (is_array($input) && !empty($input)) {
5191 $size = (!empty($input[
'size']) ?
' size="' . $input[
'size'] .
'"' :
'');
5192 $moreattr = (!empty($input[
'moreattr']) ?
' ' . $input[
'moreattr'] :
'');
5193 $morecss = (!empty($input[
'morecss']) ?
' ' . $input[
'morecss'] :
'');
5195 if ($input[
'type'] ==
'text') {
5196 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div><div class="tagtd"><input type="text" class="flat' . $morecss .
'" id="' .
dol_escape_htmltag($input[
'name']) .
'" name="' .
dol_escape_htmltag($input[
'name']) .
'"' . $size .
' value="' . (empty($input[
'value']) ?
'' : $input[
'value']) .
'"' . $moreattr .
' /></div></div>' .
"\n";
5197 } elseif ($input[
'type'] ==
'password') {
5198 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div><div class="tagtd"><input type="password" class="flat' . $morecss .
'" id="' .
dol_escape_htmltag($input[
'name']) .
'" name="' .
dol_escape_htmltag($input[
'name']) .
'"' . $size .
' value="' . (empty($input[
'value']) ?
'' : $input[
'value']) .
'"' . $moreattr .
' /></div></div>' .
"\n";
5199 } elseif ($input[
'type'] ==
'textarea') {
5205 $moreonecolumn .=
'<div class="margintoponly">';
5206 $moreonecolumn .= $input[
'label'] .
'<br>';
5208 $moreonecolumn .= $input[
'value'];
5209 $moreonecolumn .=
'</textarea>';
5210 $moreonecolumn .=
'</div>';
5211 } elseif (in_array($input[
'type'], [
'select',
'multiselect'])) {
5212 if (empty($morecss)) {
5213 $morecss =
'minwidth100';
5216 $show_empty = isset($input[
'select_show_empty']) ? $input[
'select_show_empty'] : 1;
5217 $key_in_label = isset($input[
'select_key_in_label']) ? $input[
'select_key_in_label'] : 0;
5218 $value_as_key = isset($input[
'select_value_as_key']) ? $input[
'select_value_as_key'] : 0;
5219 $translate = isset($input[
'select_translate']) ? $input[
'select_translate'] : 0;
5220 $maxlen = isset($input[
'select_maxlen']) ? $input[
'select_maxlen'] : 0;
5221 $disabled = isset($input[
'select_disabled']) ? $input[
'select_disabled'] : 0;
5222 $sort = isset($input[
'select_sort']) ? $input[
'select_sort'] :
'';
5224 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">';
5225 if (!empty($input[
'label'])) {
5226 $more .= $input[
'label'] .
'</div><div class="tagtd left">';
5228 if ($input[
'type'] ==
'select') {
5229 $more .= $this->
selectarray($input[
'name'], $input[
'values'], isset($input[
'default']) ? $input[
'default'] :
'-1', $show_empty, $key_in_label, $value_as_key, $moreattr, $translate, $maxlen, $disabled, $sort, $morecss);
5231 $more .= $this->
multiselectarray($input[
'name'], $input[
'values'], is_array($input[
'default']) ? $input[
'default'] : [$input[
'default']], $key_in_label, $value_as_key, $morecss, $translate, $maxlen, $moreattr);
5233 $more .=
'</div></div>' .
"\n";
5234 } elseif ($input[
'type'] ==
'checkbox') {
5235 $more .=
'<div class="tagtr">';
5236 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'"><label for="' .
dol_escape_htmltag($input[
'name']) .
'">' . $input[
'label'] .
'</label></div><div class="tagtd">';
5237 $more .=
'<input type="checkbox" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' .
dol_escape_htmltag($input[
'name']) .
'" name="' .
dol_escape_htmltag($input[
'name']) .
'"' . $moreattr;
5238 if (!is_bool($input[
'value']) && $input[
'value'] !=
'false' && $input[
'value'] !=
'0' && $input[
'value'] !=
'') {
5239 $more .=
' checked';
5241 if (is_bool($input[
'value']) && $input[
'value']) {
5242 $more .=
' checked';
5244 if (isset($input[
'disabled'])) {
5245 $more .=
' disabled';
5247 $more .=
' /></div>';
5248 $more .=
'</div>' .
"\n";
5249 } elseif ($input[
'type'] ==
'radio') {
5251 foreach ($input[
'values'] as $selkey => $selval) {
5252 $more .=
'<div class="tagtr">';
5253 if (isset($input[
'label'])) {
5255 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
' tdtop' : (
' tdtop ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div>';
5257 $more .=
'<div clas="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' "' . $input[
'tdclass'])) .
'"> </div>';
5260 $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;
5261 if (!empty($input[
'disabled'])) {
5262 $more .=
' disabled';
5264 if (isset($input[
'default']) && $input[
'default'] === $selkey) {
5265 $more .=
' checked="checked"';
5268 $more .=
'<label for="' .
dol_escape_htmltag($input[
'name'] . $selkey) .
'" class="valignmiddle">' . $selval .
'</label>';
5269 $more .=
'</div></div>' .
"\n";
5272 } elseif ($input[
'type'] ==
'date' || $input[
'type'] ==
'datetime') {
5273 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div>';
5274 $more .=
'<div class="tagtd">';
5275 $addnowlink = (empty($input[
'datenow']) ? 0 : 1);
5277 if ($input[
'type'] ==
'datetime') {
5278 $h = isset($input[
'hours']) ? $input[
'hours'] : 1;
5279 $m = isset($input[
'minutes']) ? $input[
'minutes'] : 1;
5281 $more .= $this->
selectDate($input[
'value'], $input[
'name'], $h, $m, 0,
'', 1, $addnowlink);
5282 $more .=
'</div></div>'.
"\n";
5283 $formquestion[] = array(
'name'=>$input[
'name'].
'day');
5284 $formquestion[] = array(
'name'=>$input[
'name'].
'month');
5285 $formquestion[] = array(
'name'=>$input[
'name'].
'year');
5286 $formquestion[] = array(
'name'=>$input[
'name'].
'hour');
5287 $formquestion[] = array(
'name'=>$input[
'name'].
'min');
5288 } elseif ($input[
'type'] ==
'other') {
5289 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">';
5290 if (!empty($input[
'label'])) {
5291 $more .= $input[
'label'] .
'</div><div class="tagtd">';
5293 $more .= $input[
'value'];
5294 $more .=
'</div></div>' .
"\n";
5295 } elseif ($input[
'type'] ==
'onecolumn') {
5296 $moreonecolumn .=
'<div class="margintoponly">';
5297 $moreonecolumn .= $input[
'value'];
5298 $moreonecolumn .=
'</div>' .
"\n";
5299 } elseif ($input[
'type'] ==
'hidden') {
5301 } elseif ($input[
'type'] ==
'separator') {
5304 $more .=
'Error type ' . $input[
'type'] .
' for the confirm box is not a supported type';
5308 $more .=
'</div>' .
"\n";
5309 $more .= $moreonecolumn;
5315 if (!empty($conf->dol_use_jmobile)) {
5318 if (empty($conf->use_javascript_ajax)) {
5324 $dialogconfirm =
'dialog-confirm';
5326 if (!is_numeric($useajax)) {
5330 $dialogconfirm .=
'-' . $button;
5332 $pageyes = $page . (preg_match(
'/\?/', $page) ?
'&' :
'?') .
'action=' . urlencode($action) .
'&confirm=yes';
5333 $pageno = ($useajax == 2 ? $page . (preg_match(
'/\?/', $page) ?
'&' :
'?') .
'action=' . urlencode($action) .
'&confirm=no' :
'');
5336 if (is_array($formquestion)) {
5337 foreach ($formquestion as $key => $input) {
5340 if (is_array($input) && isset($input[
'name'])) {
5341 if (strpos($input[
'name'],
',') > 0) {
5342 $inputok = array_merge($inputok, explode(
',', $input[
'name']));
5344 array_push($inputok, $input[
'name']);
5348 if (isset($input[
'inputko']) && $input[
'inputko'] == 1) {
5349 array_push($inputko, $input[
'name']);
5355 $formconfirm .=
'<div id="' . $dialogconfirm .
'" title="' .
dol_escape_htmltag($title) .
'" style="display: none;">';
5356 if (is_array($formquestion) && !empty($formquestion[
'text'])) {
5357 $formconfirm .=
'<div class="confirmtext">' . $formquestion[
'text'] .
'</div>' .
"\n";
5359 if (!empty($more)) {
5360 $formconfirm .=
'<div class="confirmquestions">' . $more .
'</div>' .
"\n";
5362 $formconfirm .= ($question ?
'<div class="confirmmessage">' .
img_help(
'',
'') .
' ' . $question .
'</div>' :
'');
5363 $formconfirm .=
'</div>' .
"\n";
5365 $formconfirm .=
"\n<!-- begin code of popup for formconfirm page=" . $page .
" -->\n";
5366 $formconfirm .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">' .
"\n";
5367 $formconfirm .=
"/* Code for the jQuery('#dialogforpopup').dialog() */\n";
5368 $formconfirm .=
'jQuery(document).ready(function() {
5370 $( "#' . $dialogconfirm .
'" ).dialog(
5372 autoOpen: ' . ($autoOpen ?
"true" :
"false") .
',';
5373 if ($newselectedchoice ==
'no') {
5376 $(this).parent().find("button.ui-button:eq(2)").focus();
5381 if ($useajax == 1) {
5382 $jsforcursor =
'// The call to urljump can be slow, so we set the wait cursor' .
"\n";
5383 $jsforcursor .=
'jQuery("html,body,#id-container").addClass("cursorwait");' .
"\n";
5386 $postconfirmas =
'GET';
5390 height: "' . $height .
'",
5391 width: "' . $width .
'",
5393 closeOnEscape: false,
5395 "' .
dol_escape_js($langs->transnoentities($labelbuttonyes)) .
'": function() {
5396 var options = "token=' . urlencode(newToken()) .
'";
5397 var inputok = ' . json_encode($inputok) .
'; /* List of fields into form */
5398 var page = "' .
dol_escape_js(!empty($page) ? $page :
'') .
'";
5399 var pageyes = "' .
dol_escape_js(!empty($pageyes) ? $pageyes :
'') .
'";
5401 if (inputok.length > 0) {
5402 $.each(inputok, function(i, inputname) {
5405 if ($("input[name=\'" + inputname + "\']").attr("type") == "radio") {
5406 inputvalue = $("input[name=\'" + inputname + "\']:checked").val();
5408 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
5409 inputvalue = $("#" + inputname + more).val();
5411 if (typeof inputvalue == "undefined") { inputvalue=""; }
5412 console.log("formconfirm check inputname="+inputname+" inputvalue="+inputvalue);
5413 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
5416 var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "&") + options;
5417 if (pageyes.length > 0) {';
5418 if ($postconfirmas ==
'GET') {
5419 $formconfirm .=
'location.href = urljump;';
5421 $formconfirm .= $jsforcursor;
5422 $formconfirm .=
'var post = $.post(
5425 function(data) { $("body").html(data); jQuery("html,body,#id-container").removeClass("cursorwait"); }
5429 console.log("after post ok");
5431 $(this).dialog("close");
5433 "' .
dol_escape_js($langs->transnoentities($labelbuttonno)) .
'": function() {
5434 var options = "token=' . urlencode(newToken()) .
'";
5435 var inputko = ' . json_encode($inputko) .
'; /* List of fields into form */
5436 var page = "' .
dol_escape_js(!empty($page) ? $page :
'') .
'";
5437 var pageno="' .
dol_escape_js(!empty($pageno) ? $pageno :
'') .
'";
5438 if (inputko.length > 0) {
5439 $.each(inputko, function(i, inputname) {
5441 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
5442 var inputvalue = $("#" + inputname + more).val();
5443 if (typeof inputvalue == "undefined") { inputvalue=""; }
5444 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
5447 var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "&") + options;
5449 if (pageno.length > 0) {';
5450 if ($postconfirmas ==
'GET') {
5451 $formconfirm .=
'location.href = urljump;';
5453 $formconfirm .= $jsforcursor;
5454 $formconfirm .=
'var post = $.post(
5457 function(data) { $("body").html(data); jQuery("html,body,#id-container").removeClass("cursorwait"); }
5461 console.log("after post ko");
5463 $(this).dialog("close");
5469 var button = "' . $button .
'";
5470 if (button.length > 0) {
5471 $( "#" + button ).click(function() {
5472 $("#' . $dialogconfirm .
'").dialog("open");
5478 $formconfirm .=
"<!-- end ajax formconfirm -->\n";
5480 $formconfirm .=
"\n<!-- begin formconfirm page=" .
dol_escape_htmltag($page) .
" -->\n";
5482 if (empty($disableformtag)) {
5483 $formconfirm .=
'<form method="POST" action="' . $page .
'" class="notoptoleftroright">' .
"\n";
5486 $formconfirm .=
'<input type="hidden" name="action" value="' . $action .
'">' .
"\n";
5487 $formconfirm .=
'<input type="hidden" name="token" value="' . newToken() .
'">' .
"\n";
5489 $formconfirm .=
'<table class="valid centpercent">' .
"\n";
5492 $formconfirm .=
'<tr class="validtitre"><td class="validtitre" colspan="2">';
5493 $formconfirm .=
img_picto(
'',
'pictoconfirm') .
' ' . $title;
5494 $formconfirm .=
'</td></tr>' .
"\n";
5497 if (is_array($formquestion) && !empty($formquestion[
'text'])) {
5498 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="2">' . $formquestion[
'text'] .
'</td></tr>' .
"\n";
5503 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="2">' .
"\n";
5504 $formconfirm .= $more;
5505 $formconfirm .=
'</td></tr>' .
"\n";
5509 $formconfirm .=
'<tr class="valid">';
5510 $formconfirm .=
'<td class="valid">' . $question .
'</td>';
5511 $formconfirm .=
'<td class="valid center">';
5512 $formconfirm .= $this->
selectyesno(
"confirm", $newselectedchoice, 0,
false, 0, 0,
'marginleftonly marginrightonly', $labelbuttonyes, $labelbuttonno);
5513 $formconfirm .=
'<input class="button valignmiddle confirmvalidatebutton small" type="submit" value="' . $langs->trans(
"Validate") .
'">';
5514 $formconfirm .=
'</td>';
5515 $formconfirm .=
'</tr>' .
"\n";
5517 $formconfirm .=
'</table>' .
"\n";
5519 if (empty($disableformtag)) {
5520 $formconfirm .=
"</form>\n";
5522 $formconfirm .=
'<br>';
5524 if (!empty($conf->use_javascript_ajax)) {
5525 $formconfirm .=
'<!-- code to disable button to avoid double clic -->';
5526 $formconfirm .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">' .
"\n";
5528 $(document).ready(function () {
5529 $(".confirmvalidatebutton").on("click", function() {
5530 console.log("We click on button");
5531 $(this).attr("disabled", "disabled");
5532 setTimeout(\'$(".confirmvalidatebutton").removeAttr("disabled")\', 3000);
5533 //console.log($(this).closest("form"));
5534 $(this).closest("form").submit();
5538 $formconfirm .=
'</script>' .
"\n";
5541 $formconfirm .=
"<!-- end formconfirm -->\n";
5544 return $formconfirm;
5565 public function form_project($page, $socid, $selected =
'', $htmlname =
'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0, $textifnoproject =
'', $morecss =
'')
5570 require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
5571 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
5577 $langs->load(
"project");
5578 if ($htmlname !=
"none") {
5579 $out .=
'<form method="post" action="' . $page .
'">';
5580 $out .=
'<input type="hidden" name="action" value="classin">';
5581 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
5582 $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0,
'', 1, 0, $morecss);
5583 $out .=
'<input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
5586 $out .=
'<span class="project_head_block">';
5588 $projet =
new Project($this->db);
5589 $projet->fetch($selected);
5590 $out .= $projet->getNomUrl(0,
'', 1);
5592 $out .=
'<span class="opacitymedium">' . $textifnoproject .
'</span>';
5597 if (empty($nooutput)) {
5621 public function form_conditions_reglement($page, $selected =
'', $htmlname =
'cond_reglement_id', $addempty = 0, $type =
'', $filtertype = -1, $deposit_percent = -1, $nooutput = 0)
5628 if ($htmlname !=
"none") {
5629 $out .=
'<form method="POST" action="' . $page .
'">';
5630 $out .=
'<input type="hidden" name="action" value="setconditions">';
5631 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
5633 $out .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
5636 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
5641 if (isset($this->cache_conditions_paiements[$selected])) {
5642 $label = $this->cache_conditions_paiements[$selected][
'label'];
5644 if (!empty($this->cache_conditions_paiements[$selected][
'deposit_percent'])) {
5645 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $this->cache_conditions_paiements[$selected][
'deposit_percent'], $label);
5650 $langs->load(
'errors');
5651 $out .= $langs->trans(
'ErrorNotInDictionaryPaymentConditions');
5658 if (empty($nooutput)) {
5680 if ($htmlname !=
"none") {
5681 print
'<form method="post" action="' . $page .
'">';
5682 print
'<input type="hidden" name="action" value="setavailability">';
5683 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
5685 print
'<input type="submit" name="modify" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
5686 print
'<input type="submit" name="cancel" class="button smallpaddingimp" value="' . $langs->trans(
"Cancel") .
'">';
5691 print $this->cache_availability[$selected][
'label'];
5708 public function formInputReason($page, $selected =
'', $htmlname =
'demandreason', $addempty = 0)
5711 if ($htmlname !=
"none") {
5712 print
'<form method="post" action="' . $page .
'">';
5713 print
'<input type="hidden" name="action" value="setdemandreason">';
5714 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
5716 print
'<input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
5721 foreach ($this->cache_demand_reason as $key => $val) {
5722 if ($val[
'id'] == $selected) {
5723 print $val[
'label'];
5748 public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0, $type =
'')
5755 if ($htmlname !=
"none") {
5756 $ret .=
'<form method="POST" action="' . $page .
'" name="form' . $htmlname .
'">';
5757 $ret .=
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
5758 $ret .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
5760 $ret .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
5762 $ret .=
'<table class="nobordernopadding">';
5764 $ret .= $this->
selectDate($selected, $htmlname, $displayhour, $displaymin, 1,
'form' . $htmlname, 1, 0);
5766 $ret .=
'<td class="left"><input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'"></td>';
5767 $ret .=
'</tr></table></form>';
5776 if (empty($nooutput)) {
5795 public function form_users($page, $selected =
'', $htmlname =
'userid', $exclude =
'', $include =
'')
5800 if ($htmlname !=
"none") {
5801 print
'<form method="POST" action="' . $page .
'" name="form' . $htmlname .
'">';
5802 print
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
5803 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
5804 print $this->
select_dolusers($selected, $htmlname, 1, $exclude, 0, $include);
5805 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
5809 require_once DOL_DOCUMENT_ROOT .
'/user/class/user.class.php';
5810 $theuser =
new User($this->db);
5811 $theuser->fetch($selected);
5812 print $theuser->getNomUrl(1);
5835 public function form_modes_reglement($page, $selected =
'', $htmlname =
'mode_reglement_id', $filtertype =
'', $active = 1, $addempty = 0, $type =
'', $nooutput = 0)
5841 if ($htmlname !=
"none") {
5842 $out .=
'<form method="POST" action="' . $page .
'">';
5843 $out .=
'<input type="hidden" name="action" value="setmode">';
5844 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
5846 $out .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
5848 $out .= $this->
select_types_paiements($selected, $htmlname, $filtertype, 0, $addempty, 0, 0, $active,
'', 1);
5849 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
5854 $out .= $this->cache_types_paiements[$selected][
'label'];
5881 if ($htmlname !=
"none") {
5882 print
'<form method="POST" action="' . $page .
'">';
5883 print
'<input type="hidden" name="action" value="settransportmode">';
5884 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
5886 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
5891 print $this->cache_transport_mode[$selected][
'label'];
5912 if ($htmlname !=
"none") {
5913 print
'<form method="POST" action="' . $page .
'">';
5914 print
'<input type="hidden" name="action" value="setmulticurrencycode">';
5915 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
5917 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
5921 print !empty($selected) ?
currency_name($selected, 1) :
' ';
5939 global $langs, $mysoc, $conf;
5941 if ($htmlname !=
"none") {
5942 print
'<form method="POST" action="' . $page .
'">';
5943 print
'<input type="hidden" name="action" value="setmulticurrencyrate">';
5944 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
5945 print
'<input type="text" class="maxwidth100" name="' . $htmlname .
'" value="' . (!empty($rate) ?
price(
price2num($rate,
'CU')) : 1) .
'" /> ';
5946 print
'<select name="calculation_mode">';
5947 print
'<option value="1">Change ' . $langs->trans(
"PriceUHT") .
' of lines</option>';
5948 print
'<option value="2">Change ' . $langs->trans(
"PriceUHTCurrency") .
' of lines</option>';
5950 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
5953 if (!empty($rate)) {
5954 print
price($rate, 1, $langs, 0, 0);
5955 if ($currency && $rate != 1) {
5956 print
' (' .
price($rate, 1, $langs, 0, 0) .
' ' . $currency .
' = 1 ' . $conf->currency .
')';
5982 public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter =
'', $maxvalue = 0, $more =
'', $hidelist = 0, $discount_type = 0)
5985 global $conf, $langs;
5986 if ($htmlname !=
"none") {
5987 print
'<form method="post" action="' . $page .
'">';
5988 print
'<input type="hidden" name="action" value="setabsolutediscount">';
5989 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
5990 print
'<div class="inline-block">';
5991 if (!empty($discount_type)) {
5992 if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
5993 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL") {
5994 $translationKey =
'HasAbsoluteDiscountFromSupplier';
5996 $translationKey =
'HasCreditNoteFromSupplier';
5999 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
6000 $translationKey =
'HasAbsoluteDiscountFromSupplier';
6002 $translationKey =
'HasCreditNoteFromSupplier';
6006 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
6007 if (!$filter || $filter ==
"fk_facture_source IS NULL") {
6008 $translationKey =
'CompanyHasAbsoluteDiscount';
6010 $translationKey =
'CompanyHasCreditNote';
6013 if (!$filter || $filter ==
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
6014 $translationKey =
'CompanyHasAbsoluteDiscount';
6016 $translationKey =
'CompanyHasCreditNote';
6020 print $langs->trans($translationKey,
price($amount, 0, $langs, 0, 0, -1, $conf->currency));
6021 if (empty($hidelist)) {
6025 if (empty($hidelist)) {
6026 print
'<div class="inline-block" style="padding-right: 10px">';
6027 $newfilter =
'discount_type=' . intval($discount_type);
6028 if (!empty($discount_type)) {
6029 $newfilter .=
' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL';
6031 $newfilter .=
' AND fk_facture IS NULL AND fk_facture_line IS NULL';
6034 $newfilter .=
' AND (' . $filter .
')';
6037 $nbqualifiedlines = $this->
select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue);
6038 if ($nbqualifiedlines > 0) {
6039 print
' <input type="submit" class="button smallpaddingimp" value="' .
dol_escape_htmltag($langs->trans(
"UseLine")) .
'"';
6040 if (!empty($discount_type) && $filter && $filter !=
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
6041 print
' title="' . $langs->trans(
"UseCreditNoteInInvoicePayment") .
'"';
6043 if (empty($discount_type) && $filter && $filter !=
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
6044 print
' title="' . $langs->trans(
"UseCreditNoteInInvoicePayment") .
'"';
6052 print
'<div class="inline-block">';
6078 public function form_contacts($page, $societe, $selected =
'', $htmlname =
'contactid')
6081 global $langs, $conf;
6083 if ($htmlname !=
"none") {
6084 print
'<form method="post" action="' . $page .
'">';
6085 print
'<input type="hidden" name="action" value="set_contact">';
6086 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
6087 print
'<table class="nobordernopadding">';
6092 $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
6093 print
'<a href="' . DOL_URL_ROOT .
'/contact/card.php?socid=' . $societe->id .
'&action=create&backtoreferer=1">' . $addcontact .
'</a>';
6096 print
'<td class="left"><input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'"></td>';
6097 print
'</tr></table></form>';
6100 require_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
6101 $contact =
new Contact($this->db);
6102 $contact->fetch($selected);
6103 print $contact->getFullName($langs);
6128 public function form_thirdparty($page, $selected =
'', $htmlname =
'socid', $filter =
'', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0, $excludeids = array(), $textifnothirdparty =
'')
6134 if ($htmlname !=
"none") {
6135 $out .=
'<form method="post" action="' . $page .
'">';
6136 $out .=
'<input type="hidden" name="action" value="set_thirdparty">';
6137 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
6138 $out .= $this->
select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, 0,
'minwidth100',
'',
'', 1, array(),
false, $excludeids);
6139 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6143 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
6144 $soc =
new Societe($this->db);
6145 $soc->fetch($selected);
6146 $out .= $soc->getNomUrl(0,
'');
6148 $out .=
'<span class="opacitymedium">' . $textifnothirdparty .
'</span>';
6186 public function selectCurrency($selected =
'', $htmlname =
'currency_id', $mode = 0, $useempty =
'')
6188 global $conf, $langs, $user;
6190 $langs->loadCacheCurrencies(
'');
6194 if ($selected ==
'euro' || $selected ==
'euros') {
6198 $out .=
'<select class="flat maxwidth200onsmartphone minwidth300" name="' . $htmlname .
'" id="' . $htmlname .
'">';
6200 $out .=
'<option value="-1" selected></option>';
6202 foreach ($langs->cache_currencies as $code_iso => $currency) {
6203 $labeltoshow = $currency[
'label'];
6205 $labeltoshow .=
' <span class="opacitymedium">(' . $code_iso .
')</span>';
6207 $labeltoshow .=
' <span class="opacitymedium">(' . $langs->getCurrencySymbol($code_iso) .
')</span>';
6210 if ($selected && $selected == $code_iso) {
6211 $out .=
'<option value="' . $code_iso .
'" selected data-html="' .
dol_escape_htmltag($labeltoshow) .
'">';
6213 $out .=
'<option value="' . $code_iso .
'" data-html="' .
dol_escape_htmltag($labeltoshow) .
'">';
6215 $out .= $labeltoshow;
6216 $out .=
'</option>';
6218 $out .=
'</select>';
6220 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
6224 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
6242 public function selectMultiCurrency($selected =
'', $htmlname =
'multicurrency_code', $useempty = 0, $filter =
'', $excludeConfCurrency =
false, $morecss =
'')
6244 global $conf, $langs;
6246 $langs->loadCacheCurrencies(
'');
6248 $TCurrency = array();
6250 $sql =
"SELECT code FROM " . $this->db->prefix() .
"multicurrency";
6251 $sql .=
" WHERE entity IN ('" .
getEntity(
'mutlicurrency') .
"')";
6253 $sql .=
" AND " . $filter;
6255 $resql = $this->db->query($sql);
6257 while ($obj = $this->db->fetch_object($resql)) {
6258 $TCurrency[$obj->code] = $obj->code;
6263 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
6265 $out .=
'<option value=""> </option>';
6268 if (!in_array($conf->currency, $TCurrency) && !$excludeConfCurrency) {
6269 $TCurrency[$conf->currency] = $conf->currency;
6271 if (count($TCurrency) > 0) {
6272 foreach ($langs->cache_currencies as $code_iso => $currency) {
6273 if (isset($TCurrency[$code_iso])) {
6274 if (!empty($selected) && $selected == $code_iso) {
6275 $out .=
'<option value="' . $code_iso .
'" selected="selected">';
6277 $out .=
'<option value="' . $code_iso .
'">';
6280 $out .= $currency[
'label'];
6281 $out .=
' (' . $langs->getCurrencySymbol($code_iso) .
')';
6282 $out .=
'</option>';
6287 $out .=
'</select>';
6290 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
6307 global $langs, $user;
6309 $num = count($this->cache_vatrates);
6316 $sql =
"SELECT DISTINCT t.rowid, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly";
6317 $sql .=
" FROM " . $this->db->prefix() .
"c_tva as t, " . $this->db->prefix() .
"c_country as c";
6318 $sql .=
" WHERE t.fk_pays = c.rowid";
6319 $sql .=
" AND t.active > 0";
6320 $sql .=
" AND c.code IN (" . $this->db->sanitize($country_code, 1) .
")";
6321 $sql .=
" ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC";
6323 $resql = $this->db->query($sql);
6325 $num = $this->db->num_rows($resql);
6327 for ($i = 0; $i < $num; $i++) {
6328 $obj = $this->db->fetch_object($resql);
6329 $this->cache_vatrates[$i][
'rowid'] = $obj->rowid;
6330 $this->cache_vatrates[$i][
'code'] = $obj->code;
6331 $this->cache_vatrates[$i][
'txtva'] = $obj->taux;
6332 $this->cache_vatrates[$i][
'nprtva'] = $obj->recuperableonly;
6333 $this->cache_vatrates[$i][
'localtax1'] = $obj->localtax1;
6334 $this->cache_vatrates[$i][
'localtax1_type'] = $obj->localtax1_type;
6335 $this->cache_vatrates[$i][
'localtax2'] = $obj->localtax2;
6336 $this->cache_vatrates[$i][
'localtax2_type'] = $obj->localtax1_type;
6338 $this->cache_vatrates[$i][
'label'] = $obj->taux .
'%' . ($obj->code ?
' (' . $obj->code .
')' :
'');
6339 $this->cache_vatrates[$i][
'labelallrates'] = $obj->taux .
'/' . ($obj->localtax1 ? $obj->localtax1 :
'0') .
'/' . ($obj->localtax2 ? $obj->localtax2 :
'0') . ($obj->code ?
' (' . $obj->code .
')' :
'');
6340 $positiverates =
'';
6342 $positiverates .= ($positiverates ?
'/' :
'') . $obj->taux;
6344 if ($obj->localtax1) {
6345 $positiverates .= ($positiverates ?
'/' :
'') . $obj->localtax1;
6347 if ($obj->localtax2) {
6348 $positiverates .= ($positiverates ?
'/' :
'') . $obj->localtax2;
6350 if (empty($positiverates)) {
6351 $positiverates =
'0';
6353 $this->cache_vatrates[$i][
'labelpositiverates'] = $positiverates . ($obj->code ?
' (' . $obj->code .
')' :
'');
6358 $this->error =
'<span class="error">';
6359 $this->error .= $langs->trans(
"ErrorNoVATRateDefinedForSellerCountry", $country_code);
6361 if (!empty($user) && $user->admin && preg_match(
'/\'(..)\'/', $country_code, $reg)) {
6362 $langs->load(
"errors");
6363 $new_country_code = $reg[1];
6364 $country_id =
dol_getIdFromCode($this->db, $new_country_code,
'c_country',
'code',
'rowid');
6365 $this->error .=
'<br>'.$langs->trans(
"ErrorFixThisHere", DOL_URL_ROOT.
'/admin/dict.php?id=10'.($country_id > 0 ?
'&countryidforinsert='.$country_id :
''));
6367 $this->error .=
'</span>';
6371 $this->error =
'<span class="error">' . $this->db->error() .
'</span>';
6399 public function load_tva($htmlname =
'tauxtva', $selectedrate =
'', $societe_vendeuse =
'', $societe_acheteuse =
'', $idprod = 0, $info_bits = 0, $type =
'', $options_only =
false, $mode = 0)
6402 global $langs, $conf, $mysoc;
6404 $langs->load(
'errors');
6409 $defaultnpr = ($info_bits & 0x01);
6410 $defaultnpr = (preg_match(
'/\*/', $selectedrate) ? 1 : $defaultnpr);
6411 $defaulttx = str_replace(
'*',
'', $selectedrate);
6414 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6415 $defaultcode = $reg[1];
6416 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6421 if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
6422 if ($societe_vendeuse->id == $mysoc->id) {
6423 $return .=
'<span class="error">' . $langs->trans(
"ErrorYourCountryIsNotDefined") .
'</span>';
6425 $return .=
'<span class="error">' . $langs->trans(
"ErrorSupplierCountryIsNotDefined") .
'</span>';
6436 if (is_object($societe_vendeuse)) {
6437 $code_country =
"'" . $societe_vendeuse->country_code .
"'";
6439 $code_country =
"'" . $mysoc->country_code .
"'";
6441 if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {
6442 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
6443 if (!
isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (
isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()))) {
6445 if (is_numeric($type)) {
6447 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
6449 } elseif (!$idprod) {
6450 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
6452 $prodstatic =
new Product($this->db);
6453 $prodstatic->fetch($idprod);
6455 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
6466 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
6467 $tmpthirdparty =
new Societe($this->db);
6469 $defaulttx =
get_default_tva($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
6470 $defaultnpr =
get_default_npr($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
6472 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6473 $defaultcode = $reg[1];
6474 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6476 if (empty($defaulttx)) {
6483 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
6484 if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
6486 $defaulttx = $this->cache_vatrates[$num - 1][
'txtva'];
6490 if ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS !=
'none') {
6491 $defaulttx = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
6493 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6494 $defaultcode = $reg[1];
6495 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6503 if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj ==
"0") {
6506 if (empty($conf->global->EXPENSEREPORT_OVERRIDE_VAT)) {
6512 if (!$options_only) {
6513 $return .=
'<select class="flat minwidth50imp maxwidth100" id="' . $htmlname .
'" name="' . $htmlname .
'"' . ($disabled ?
' disabled' :
'') . $title .
'>';
6516 $selectedfound =
false;
6517 foreach ($this->cache_vatrates as $rate) {
6519 if ($disabled && $rate[
'txtva'] != 0) {
6524 $key = $rate[
'txtva'];
6525 $key .= $rate[
'nprtva'] ?
'*' :
'';
6526 if ($mode > 0 && $rate[
'code']) {
6527 $key .=
' (' . $rate[
'code'] .
')';
6530 $key = $rate[
'rowid'];
6533 $return .=
'<option value="' . $key .
'"';
6534 if (!$selectedfound) {
6536 if ($defaultcode == $rate[
'code']) {
6537 $return .=
' selected';
6538 $selectedfound =
true;
6540 } elseif ($rate[
'txtva'] == $defaulttx && $rate[
'nprtva'] == $defaultnpr) {
6541 $return .=
' selected';
6542 $selectedfound =
true;
6548 if ($mysoc->country_code ==
'IN' || !empty($conf->global->MAIN_VAT_LABEL_IS_POSITIVE_RATES)) {
6550 $return .= $rate[
'labelpositiverates'];
6553 $return .=
vatrate($rate[
'label']);
6557 $return .= (empty($rate[
'code']) && $rate[
'nprtva']) ?
' *' :
'';
6559 $return .=
'</option>';
6562 if (!$options_only) {
6563 $return .=
'</select>';
6567 $return .= $this->error;
6601 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 =
'')
6604 $retstring = $this->
selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof);
6605 if (!empty($nooutput)) {
6628 public function selectDateToDate($set_time =
'', $set_time_end =
'', $prefix =
're', $empty = 0, $forcenewline = 0)
6632 $ret = $this->
selectDate($set_time, $prefix .
'_start', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"),
'tzuserrel');
6633 if ($forcenewline) {
6636 $ret .= $this->
selectDate($set_time_end, $prefix .
'_end', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
6667 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')
6669 global $conf, $langs;
6671 if ($gm ===
'auto') {
6672 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
6677 if ($prefix ==
'') {
6688 if ($stepminutes <= 0 || $stepminutes > 30) {
6699 $orig_set_time = $set_time;
6701 if ($set_time ===
'' && $emptydate == 0) {
6702 include_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
6703 if ($gm ==
'tzuser' || $gm ==
'tzuserrel') {
6715 if (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg)) {
6717 $syear = (!empty($reg[1]) ? $reg[1] :
'');
6718 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
6719 $sday = (!empty($reg[3]) ? $reg[3] :
'');
6720 $shour = (!empty($reg[4]) ? $reg[4] :
'');
6721 $smin = (!empty($reg[5]) ? $reg[5] :
'');
6722 } elseif (strval($set_time) !=
'' && $set_time != -1) {
6727 if ($orig_set_time !=
'') {
6737 $shour = !isset($conf->global->MAIN_DEFAULT_DATE_HOUR) ? ($h == -1 ?
'23' :
'') : $conf->global->MAIN_DEFAULT_DATE_HOUR;
6738 $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? ($h == -1 ?
'59' :
'') : $conf->global->MAIN_DEFAULT_DATE_MIN;
6739 $ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? ($h == -1 ?
'59' :
'') : $conf->global->MAIN_DEFAULT_DATE_SEC;
6752 $usecalendar =
'combo';
6753 if (!empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR !=
"none")) {
6754 $usecalendar = ((empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR ==
'eldy') ?
'jquery' : $conf->global->MAIN_POPUP_CALENDAR);
6759 if ($usecalendar !=
'combo') {
6760 $formated_date =
'';
6762 if (strval($set_time) !=
'' && $set_time != -1) {
6764 $formated_date =
dol_print_date($set_time, $langs->trans(
"FormatDateShortInput"), $gm);
6768 if ($usecalendar ==
"eldy") {
6770 $retstring .=
'<input id="' . $prefix .
'" name="' . $prefix .
'" type="text" class="maxwidthdate" maxlength="11" value="' . $formated_date .
'"';
6771 $retstring .= ($disabled ?
' disabled' :
'');
6772 $retstring .=
' onChange="dpChangeDay(\'' . $prefix .
'\',\
'' . $langs->trans(
"FormatDateShortJavaInput") .
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
6776 $retstringbuttom = '';
6778 $retstringbuttom = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
"';
6779 $base = DOL_URL_ROOT . '/core/';
6780 $retstringbuttom .= ' onClick="showDP(\
'' . $base .
'\',\
'' . $prefix .
'\',\
'' . $langs->trans(
"FormatDateShortJavaInput") .
'\',\
'' . $langs->defaultlang .
'\');
"';
6781 $retstringbuttom .= '>' . img_object($langs->trans("SelectDate
"), 'calendarday', 'class="datecallink
"') . '</button>';
6783 $retstringbuttom = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
">' . img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"') . '</button>';
6785 $retstring = $retstringbuttom . $retstring;
6787 $retstring .= '<input type="hidden
" id="' . $prefix . 'day
" name="' . $prefix . 'day
" value="' . $sday . '">' . "\n
";
6788 $retstring .= '<input type="hidden
" id="' . $prefix . 'month
" name="' . $prefix . 'month
" value="' . $smonth . '">' . "\n
";
6789 $retstring .= '<input type="hidden
" id="' . $prefix . 'year
" name="' . $prefix . 'year
" value="' . $syear . '">' . "\n
";
6790 } elseif ($usecalendar == 'jquery') {
6792 // Output javascript for datepicker
6793 $minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (date('Y') - 100));
6794 $maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (date('Y') + 100));
6796 $retstring .= '<script nonce="' . getNonce() . '" type="text/javascript
">';
6797 $retstring .= "$(
function(){ $(
'#" . $prefix . "').datepicker({
6798 dateFormat:
'" . $langs->trans("FormatDateShortJQueryInput") . "',
6800 todayHighlight:
true,
6801 yearRange:
'" . $minYear . ":" . $maxYear . "',
";
6802 if (!empty($conf->dol_use_jmobile)) {
6804 beforeShow:
function (input, datePicker) {
6805 input.disabled =
true;
6807 onClose:
function (dateText, datePicker) {
6808 this.disabled =
false;
6812 // Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php
6813 if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS)) {
6816 buttonImage:
'" . DOL_URL_ROOT . "/theme/" . dol_escape_js($conf->theme) . "/img/object_calendarday.png',
6817 buttonImageOnly:
true";
6821 $retstring .= "</script>
";
6824 // Zone de saisie manuelle de la date
6825 $retstring .= '<div class="nowraponall
inline-block divfordateinput
">';
6826 $retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text
" class="maxwidthdate
" maxlength="11
" value="'.$formated_date.'"';
6827 $retstring .= ($disabled ? ' disabled' : '');
6828 $retstring .= ($placeholder ? ' placeholder="' . dol_escape_htmltag($placeholder) . '"' : '');
6829 $retstring .= ' onChange="dpChangeDay(\
'' .
dol_escape_js($prefix) .
'\',\
'' .
dol_escape_js($langs->trans(
"FormatDateShortJavaInput")) .
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
6834 /* Not required. Managed by option buttonImage of jquery
6835 $retstring.=img_object($langs->trans("SelectDate
"),'calendarday','id="'.$prefix.'id" class="datecallink
"');
6836 $retstring.='<script nonce="'.getNonce().'" type="text/javascript
">';
6837 $retstring.="jQuery(document).ready(
function() {
";
6838 $retstring.=' jQuery("#
'.$prefix.'id").click(function() {';
6839 $retstring.=" jQuery(
'#".$prefix."').focus();
";
6842 $retstring.="</script>
";*/
6844 $retstringbutton = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
">' . img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"') . '</button>';
6845 $retsring = $retstringbutton . $retstring;
6848 $retstring .= '</div>';
6849 $retstring .= '<input type="hidden
" id="' . $prefix . 'day
" name="' . $prefix . 'day
" value="' . $sday . '">' . "\n
";
6850 $retstring .= '<input type="hidden
" id="' . $prefix . 'month
" name="' . $prefix . 'month
" value="' . $smonth . '">' . "\n
";
6851 $retstring .= '<input type="hidden
" id="' . $prefix . 'year
" name="' . $prefix . 'year
" value="' . $syear . '">' . "\n
";
6853 $retstring .= "Bad value of MAIN_POPUP_CALENDAR
";
6856 // Show date with combo selects
6858 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50imp
" id="' . $prefix . 'day
" name="' . $prefix . 'day
">';
6860 if ($emptydate || $set_time == -1) {
6861 $retstring .= '<option value="0
" selected> </option>';
6864 for ($day = 1; $day <= 31; $day++) {
6865 $retstring .= '<option value="' . $day . '"' . ($day == $sday ? ' selected' : '') . '>' . $day . '</option>';
6868 $retstring .= "</select>
";
6870 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp
" id="' . $prefix . 'month
" name="' . $prefix . 'month
">';
6871 if ($emptydate || $set_time == -1) {
6872 $retstring .= '<option value="0
" selected> </option>';
6876 for ($month = 1; $month <= 12; $month++) {
6877 $retstring .= '<option value="' . $month . '"' . ($month == $smonth ? ' selected' : '') . '>';
6878 $retstring .= dol_print_date(mktime(12, 0, 0, $month, 1, 2000), "%b
");
6879 $retstring .= "</option>
";
6881 $retstring .= "</select>
";
6884 if ($emptydate || $set_time == -1) {
6885 $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 . '">';
6887 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp
" id="' . $prefix . 'year
" name="' . $prefix . 'year
">';
6889 for ($year = $syear - 10; $year < $syear + 10; $year++) {
6890 $retstring .= '<option value="' . $year . '"' . ($year == $syear ? ' selected' : '') . '>' . $year . '</option>';
6892 $retstring .= "</select>\n
";
6898 $retstring .= ($h == 2 ? '<br>' : ' ');
6899 $retstring .= '<span class="nowraponall
">';
6905 if ($openinghours != '') {
6906 $openinghours = explode(',', $openinghours);
6907 $hourstart = $openinghours[0];
6908 $hourend = $openinghours[1];
6909 if ($hourend < $hourstart) {
6910 $hourend = $hourstart;
6914 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50
' . ($fullday ? $fullday . 'hour
' : '') . '" id="' . $prefix . 'hour
" name="' . $prefix . 'hour
">';
6916 $retstring .= '<option value="-1
"> </option>';
6918 for ($hour = $hourstart; $hour < $hourend; $hour++) {
6919 if (strlen($hour) < 2) {
6920 $hour = "0
" . $hour;
6922 $retstring .= '<option value="' . $hour . '"' . (($hour == $shour) ? ' selected' : '') . '>' . $hour;
6923 //$retstring .= (empty($conf->dol_optimize_smallscreen) ? '' : 'H');
6924 $retstring .= '</option>';
6926 $retstring .= '</select>';
6927 //if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":
";
6935 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50
' . ($fullday ? $fullday . 'min
' : '') . '" id="' . $prefix . 'min
" name="' . $prefix . 'min
">';
6937 $retstring .= '<option value="-1
"> </option>';
6939 for ($min = 0; $min < 60; $min += $stepminutes) {
6940 if (strlen($min) < 2) {
6943 $retstring .= '<option value="' . $min . '"' . (($min == $smin) ? ' selected' : '') . '>' . $min . (empty($conf->dol_optimize_smallscreen) ? '' : '') . '</option>';
6945 $retstring .= '</select>';
6947 $retstring .= '<input type="hidden
" name="' . $prefix . 'sec
" value="' . $ssec . '">';
6951 $retstring .= '</span>';
6955 if (!empty($conf->use_javascript_ajax) && $addnowlink) {
6956 // Script which will be inserted in the onClick of the "Now
" link
6957 $reset_scripts = "";
6958 if ($addnowlink == 2) { // local computer time
6959 // pad add leading 0 on numbers
6960 $reset_scripts .= "Number.prototype.pad =
function(size) {
6961 var s = String(
this);
6962 while (s.length < (size || 2)) {s =
'0' + s;}
6965 var d =
new Date();
";
6968 // Generate the date part, depending on the use or not of the javascript calendar
6969 if ($addnowlink == 1) { // server time expressed in user time setup
6970 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'day', 'tzuserrel') . '\');';
6971 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
6972 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
6973 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
6974 } elseif ($addnowlink == 2) {
6975 /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix.
6976 * This break application for foreign languages.
6977 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));';
6978 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());';
6979 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);';
6980 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());';
6982 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'day', 'tzuserrel') . '\');';
6983 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
6984 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
6985 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
6987 /*if ($usecalendar == "eldy
")
6989 $base=DOL_URL_ROOT.'/core/';
6990 $reset_scripts .= 'resetDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput
").'\',\''.$langs->defaultlang.'\');';
6994 $reset_scripts .= 'this.form.elements[\''.$prefix.'day\'].value=formatDate(new Date(), \'d\'); ';
6995 $reset_scripts .= 'this.form.elements[\''.$prefix.'month\'].value=formatDate(new Date(), \'M\'); ';
6996 $reset_scripts .= 'this.form.elements[\''.$prefix.'year\'].value=formatDate(new Date(), \'yyyy\'); ';
6998 // Update the hour part
7001 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7003 //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); ';
7004 if ($addnowlink == 1) {
7005 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date($nowgmt, '%H', 'tzuserrel') . '\');';
7006 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').change();';
7007 } elseif ($addnowlink == 2) {
7008 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(d.getHours().pad());';
7009 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').change();';
7013 $reset_scripts .= ' } ';
7016 // Update the minute part
7019 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7021 //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); ';
7022 if ($addnowlink == 1) {
7023 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date($nowgmt, '%M', 'tzuserrel') . '\');';
7024 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').change();';
7025 } elseif ($addnowlink == 2) {
7026 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(d.getMinutes().pad());';
7027 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').change();';
7030 $reset_scripts .= ' } ';
7033 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
7034 if ($reset_scripts && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
7035 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="' . $prefix . 'ButtonNow
" type="button" name="_useless
" value="now
" onClick="' . $reset_scripts . '">';
7036 $retstring .= $langs->trans("Now
");
7037 $retstring .= '</button> ';
7041 // Add a "Plus one hour
" link
7042 if ($conf->use_javascript_ajax && $addplusone) {
7043 // Script which will be inserted in the onClick of the "Add plusone
" link
7044 $reset_scripts = "";
7046 // Generate the date part, depending on the use or not of the javascript calendar
7047 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'dayinputnoreduce', 'tzuserrel') . '\');';
7048 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
7049 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
7050 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
7051 // Update the hour part
7054 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7056 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date($nowgmt, '%H', 'tzuserrel') . '\');';
7058 $reset_scripts .= ' } ';
7061 // Update the minute part
7064 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7066 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date($nowgmt, '%M', 'tzuserrel') . '\');';
7068 $reset_scripts .= ' } ';
7071 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
7072 if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
7073 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="' . $prefix . 'ButtonPlusOne
" type="button" name="_useless2
" value="plusone
" onClick="' . $reset_scripts . '">';
7074 $retstring .= $langs->trans("DateStartPlusOne
");
7075 $retstring .= '</button> ';
7079 // Add a link to set data
7080 if ($conf->use_javascript_ajax && !empty($adddateof)) {
7081 if (!is_array($adddateof)) {
7082 $arrayofdateof = array(array('adddateof'=>$adddateof, 'labeladddateof'=>$labeladddateof));
7084 $arrayofdateof = $adddateof;
7086 foreach ($arrayofdateof as $valuedateof) {
7087 $tmpadddateof = $valuedateof['adddateof'] != '' ? $valuedateof['adddateof'] : 0;
7088 $tmplabeladddateof = $valuedateof['labeladddateof'];
7089 $tmparray = dol_getdate($tmpadddateof);
7090 if (empty($tmplabeladddateof)) {
7091 $tmplabeladddateof = $langs->trans("DateInvoice
");
7093 $reset_scripts = 'console.log(\'Click on now link\'); ';
7094 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($tmpadddateof, 'dayinputnoreduce').'\');';
7095 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.$tmparray['mday'].'\');';
7096 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.$tmparray['mon'].'\');';
7097 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.$tmparray['year'].'\');';
7098 $retstring .= ' - <button class="dpInvisibleButtons datenowlink
" id="dateofinvoice
" type="button" name="_dateofinvoice
" value="now
" onclick="'.$reset_scripts.'">'.$tmplabeladddateof.'</button>';
7113 public function selectTypeDuration($prefix, $selected = 'i', $excludetypes = array())
7117 $TDurationTypes = array(
7118 'y' => $langs->trans('Years'),
7119 'm' => $langs->trans('Month'),
7120 'w' => $langs->trans('Weeks'),
7121 'd' => $langs->trans('Days'),
7122 'h' => $langs->trans('Hours'),
7123 'i' => $langs->trans('Minutes')
7126 // Removed undesired duration types
7127 foreach ($excludetypes as $value) {
7128 unset($TDurationTypes[$value]);
7131 $retstring = '<select class="flat minwidth75 maxwidth100
" id="select_
' . $prefix . 'type_duration
" name="' . $prefix . 'type_duration
">';
7132 foreach ($TDurationTypes as $key => $typeduration) {
7133 $retstring .= '<option value="' . $key . '"';
7134 if ($key == $selected) {
7135 $retstring .= " selected
";
7137 $retstring .= ">
" . $typeduration . "</option>
";
7139 $retstring .= "</select>
";
7141 $retstring .= ajax_combobox('select_' . $prefix . 'type_duration');
7146 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
7161 public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0)
7166 $retstring = '<span class="nowraponall
">';
7172 if ($iSecond != '') {
7173 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
7175 $hourSelected = convertSecondToTime($iSecond, 'allhour');
7176 $minSelected = convertSecondToTime($iSecond, 'min');
7179 if ($typehour == 'select') {
7180 $retstring .= '<select class="flat
" id="select_
' . $prefix . 'hour
" name="' . $prefix . 'hour
"' . ($disabled ? ' disabled' : '') . '>';
7181 for ($hour = 0; $hour < 25; $hour++) { // For a duration, we allow 24 hours
7182 $retstring .= '<option value="' . $hour . '"';
7183 if (is_numeric($hourSelected) && $hourSelected == $hour) {
7184 $retstring .= " selected
";
7186 $retstring .= ">
" . $hour . "</option>
";
7188 $retstring .= "</select>
";
7189 } elseif ($typehour == 'text' || $typehour == 'textselect') {
7190 $retstring .= '<input placeholder="' . $langs->trans('HourShort
') . '" type="number
" min="0
" name="' . $prefix . 'hour
"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputhour right
" value="' . (($hourSelected != '') ? ((int) $hourSelected) : '') . '">';
7192 return 'BadValueForParameterTypeHour';
7195 if ($typehour != 'text') {
7196 $retstring .= ' ' . $langs->trans('HourShort');
7198 $retstring .= '<span class="">:</span>';
7202 if ($minunderhours) {
7203 $retstring .= '<br>';
7205 if ($typehour != 'text') {
7206 $retstring .= '<span class="hideonsmartphone
"> </span>';
7210 if ($typehour == 'select' || $typehour == 'textselect') {
7211 $retstring .= '<select class="flat
" id="select_
' . $prefix . 'min
" name="' . $prefix . 'min
"' . ($disabled ? ' disabled' : '') . '>';
7212 for ($min = 0; $min <= 55; $min = $min + 5) {
7213 $retstring .= '<option value="' . $min . '"';
7214 if (is_numeric($minSelected) && $minSelected == $min) {
7215 $retstring .= ' selected';
7217 $retstring .= '>' . $min . '</option>';
7219 $retstring .= "</select>
";
7220 } elseif ($typehour == 'text') {
7221 $retstring .= '<input placeholder="' . $langs->trans('MinuteShort
') . '" type="number
" min="0
" name="' . $prefix . 'min
"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputminute right
" value="' . (($minSelected != '') ? ((int) $minSelected) : '') . '">';
7224 if ($typehour != 'text') {
7225 $retstring .= ' ' . $langs->trans('MinuteShort');
7228 $retstring .= "</span>
";
7230 if (!empty($nooutput)) {
7258 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)
7260 global $langs, $conf;
7265 if (is_null($ajaxoptions)) $ajaxoptions = array();
7267 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
7270 if ($selected && empty($selected_input_value)) {
7271 require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
7272 $tickettmpselect = new Ticket($this->db);
7273 $tickettmpselect->fetch($selected);
7274 $selected_input_value = $tickettmpselect->ref;
7275 unset($tickettmpselect);
7279 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/ticket/ajax/tickets.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7281 if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel
") . ' : ';
7282 elseif ($hidelabel > 1) {
7283 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
7284 if ($hidelabel == 2) {
7285 $out .= img_picto($langs->trans("Search
"), 'search');
7288 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '') . ' />';
7289 if ($hidelabel == 3) {
7290 $out .= img_picto($langs->trans("Search
"), 'search');
7293 $out .= $this->selectTicketsList($selected, $htmlname, $filtertype, $limit, $status, 0, $socid, $showempty, $forcecombo, $morecss);
7296 if (empty($nooutput)) {
7321 public function selectTicketsList($selected = '', $htmlname = 'ticketid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7323 global $langs, $conf;
7326 $outarray = array();
7328 $selectFields = " p.rowid, p.ref, p.message
";
7331 $sql .= $selectFields;
7332 $sql .= " FROM
" . $this->db->prefix() . "ticket as p
";
7333 $sql .= ' WHERE p.entity IN (' . getEntity('ticket') . ')';
7335 // Add criteria on ref/label
7336 if ($filterkey != '') {
7338 $prefix = empty($conf->global->TICKET_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7339 // For natural search
7340 $scrit = explode(' ', $filterkey);
7342 if (count($scrit) > 1) $sql .= "(
";
7343 foreach ($scrit as $crit) {
7344 if ($i > 0) $sql .= " AND
";
7345 $sql .= "(p.ref LIKE
'" . $this->db->escape($prefix . $crit) . "%' OR p.subject LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
7349 if (count($scrit) > 1) $sql .= ")
";
7353 $sql .= $this->db->plimit($limit, 0);
7355 // Build output string
7357 $result = $this->db->query($sql);
7359 require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
7360 require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php';
7362 $num = $this->db->num_rows($result);
7367 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
7368 $out .= ajax_combobox($htmlname, $events, $conf->global->TICKET_USE_SEARCH_TO_SELECT);
7371 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
7374 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7375 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7376 if (!empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
7377 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7378 else $textifempty .= $langs->trans("All
");
7380 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7382 if ($showempty) $out .= '<option value="0
" selected>' . $textifempty . '</option>';
7385 while ($num && $i < $num) {
7388 $objp = $this->db->fetch_object($result);
7390 $this->constructTicketListOption($objp, $opt, $optJson, $selected, $filterkey);
7392 // "key
" value of json key array is used by jQuery automatically as selected value
7393 // "label
" value of json key array is used by jQuery automatically as text for combo box
7395 array_push($outarray, $optJson);
7400 $out .= '</select>';
7402 $this->db->free($result);
7404 if (empty($outputmode)) {
7409 dol_print_error($this->db);
7426 protected function constructTicketListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7432 $outkey = $objp->rowid;
7433 $outref = $objp->ref;
7434 $outtype = $objp->fk_product_type;
7436 $opt = '<option value="
' . $objp->rowid . '"';
7437 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7440 $objRef = $objp->ref;
7441 if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $objRef, 1);
7443 $opt .= "</option>\n
";
7444 $optJson = array('key' => $outkey, 'value' => $outref, 'type' => $outtype);
7466 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)
7468 global $langs, $conf;
7473 if (is_null($ajaxoptions)) $ajaxoptions = array();
7475 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
7478 if ($selected && empty($selected_input_value)) {
7479 require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
7480 $projecttmpselect = new Project($this->db);
7481 $projecttmpselect->fetch($selected);
7482 $selected_input_value = $projecttmpselect->ref;
7483 unset($projecttmpselect);
7486 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/projet/ajax/projects.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7488 if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel
") . ' : ';
7489 elseif ($hidelabel > 1) {
7490 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
7491 if ($hidelabel == 2) {
7492 $out .= img_picto($langs->trans("Search
"), 'search');
7495 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '') . ' />';
7496 if ($hidelabel == 3) {
7497 $out .= img_picto($langs->trans("Search
"), 'search');
7500 $out .= $this->selectProjectsList($selected, $htmlname, $filtertype, $limit, $status, 0, $socid, $showempty, $forcecombo, $morecss);
7503 if (empty($nooutput)) {
7527 public function selectProjectsList($selected = '', $htmlname = 'projectid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7529 global $langs, $conf;
7532 $outarray = array();
7534 $selectFields = " p.rowid, p.ref
";
7537 $sql .= $selectFields;
7538 $sql .= " FROM
" . $this->db->prefix() . "projet as p
";
7539 $sql .= ' WHERE p.entity IN (' . getEntity('project') . ')';
7541 // Add criteria on ref/label
7542 if ($filterkey != '') {
7544 $prefix = empty($conf->global->TICKET_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7545 // For natural search
7546 $scrit = explode(' ', $filterkey);
7548 if (count($scrit) > 1) $sql .= "(
";
7549 foreach ($scrit as $crit) {
7550 if ($i > 0) $sql .= " AND
";
7551 $sql .= "p.ref LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
7555 if (count($scrit) > 1) $sql .= ")
";
7559 $sql .= $this->db->plimit($limit, 0);
7561 // Build output string
7563 $result = $this->db->query($sql);
7565 require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
7566 require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php';
7568 $num = $this->db->num_rows($result);
7573 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
7574 $out .= ajax_combobox($htmlname, $events, $conf->global->PROJECT_USE_SEARCH_TO_SELECT);
7577 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
7580 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7581 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7582 if (!empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) {
7583 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7584 else $textifempty .= $langs->trans("All
");
7586 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7588 if ($showempty) $out .= '<option value="0
" selected>' . $textifempty . '</option>';
7591 while ($num && $i < $num) {
7594 $objp = $this->db->fetch_object($result);
7596 $this->constructProjectListOption($objp, $opt, $optJson, $selected, $filterkey);
7598 // "key
" value of json key array is used by jQuery automatically as selected value
7599 // "label
" value of json key array is used by jQuery automatically as text for combo box
7601 array_push($outarray, $optJson);
7606 $out .= '</select>';
7608 $this->db->free($result);
7610 if (empty($outputmode)) {
7615 dol_print_error($this->db);
7632 protected function constructProjectListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7638 $label = $objp->label;
7640 $outkey = $objp->rowid;
7641 $outref = $objp->ref;
7642 $outlabel = $objp->label;
7643 $outtype = $objp->fk_product_type;
7645 $opt = '<option value="
' . $objp->rowid . '"';
7646 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7649 $objRef = $objp->ref;
7650 if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $objRef, 1);
7652 $opt .= "</option>\n
";
7653 $optJson = array('key' => $outkey, 'value' => $outref, 'type' => $outtype);
7676 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)
7678 global $langs, $conf;
7683 if (is_null($ajaxoptions)) $ajaxoptions = array();
7685 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->TICKET_USE_SEARCH_TO_SELECT)) {
7689 if ($selected && empty($selected_input_value)) {
7690 require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
7691 $adherenttmpselect = new Adherent($this->db);
7692 $adherenttmpselect->fetch($selected);
7693 $selected_input_value = $adherenttmpselect->ref;
7694 unset($adherenttmpselect);
7699 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/adherents/ajax/adherents.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7701 if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel
") . ' : ';
7702 elseif ($hidelabel > 1) {
7703 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
7704 if ($hidelabel == 2) {
7705 $out .= img_picto($langs->trans("Search
"), 'search');
7708 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '') . ' />';
7709 if ($hidelabel == 3) {
7710 $out .= img_picto($langs->trans("Search
"), 'search');
7715 $out .= $this->selectMembersList($selected, $htmlname, $filtertype, $limit, $filterkey, $status, 0, $showempty, $forcecombo, $morecss);
7718 if (empty($nooutput)) {
7742 public function selectMembersList($selected = '', $htmlname = 'adherentid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7744 global $langs, $conf;
7747 $outarray = array();
7749 $selectFields = " p.rowid, p.ref, p.firstname, p.lastname, p.fk_adherent_type
";
7752 $sql .= $selectFields;
7753 $sql .= " FROM
" . $this->db->prefix() . "adherent as p
";
7754 $sql .= ' WHERE p.entity IN (' . getEntity('adherent') . ')';
7756 // Add criteria on ref/label
7757 if ($filterkey != '') {
7759 $prefix = empty($conf->global->MEMBER_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7760 // For natural search
7761 $scrit = explode(' ', $filterkey);
7763 if (count($scrit) > 1) $sql .= "(
";
7764 foreach ($scrit as $crit) {
7765 if ($i > 0) $sql .= " AND
";
7766 $sql .= "(p.firstname LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
7767 $sql .= " OR p.lastname LIKE
'" . $this->db->escape($prefix . $crit) . "%')
";
7770 if (count($scrit) > 1) $sql .= ")
";
7773 if ($status != -1) {
7774 $sql .= ' AND statut = ' . ((int) $status);
7776 $sql .= $this->db->plimit($limit, 0);
7778 // Build output string
7780 $result = $this->db->query($sql);
7782 require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
7783 require_once DOL_DOCUMENT_ROOT . '/core/lib/member.lib.php';
7785 $num = $this->db->num_rows($result);
7790 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
7791 $out .= ajax_combobox($htmlname, $events, !empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT) ? $conf->global->PROJECT_USE_SEARCH_TO_SELECT : '');
7794 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
7797 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7798 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7799 if (!empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) {
7800 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7801 else $textifempty .= $langs->trans("All
");
7803 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
7806 $out .= '<option value="-1
" selected>' . $textifempty . '</option>';
7810 while ($num && $i < $num) {
7813 $objp = $this->db->fetch_object($result);
7815 $this->constructMemberListOption($objp, $opt, $optJson, $selected, $filterkey);
7818 // "key
" value of json key array is used by jQuery automatically as selected value
7819 // "label
" value of json key array is used by jQuery automatically as text for combo box
7821 array_push($outarray, $optJson);
7826 $out .= '</select>';
7828 $this->db->free($result);
7830 if (empty($outputmode)) {
7835 dol_print_error($this->db);
7852 protected function constructMemberListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7858 $outkey = $objp->rowid;
7859 $outlabel = dolGetFirstLastname($objp->firstname, $objp->lastname);
7860 $outtype = $objp->fk_adherent_type;
7862 $opt = '<option value="
' . $objp->rowid . '"';
7863 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7865 if (!empty($filterkey) && $filterkey != '') {
7866 $outlabel = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $outlabel, 1);
7869 $opt .= "</option>\n
";
7871 $optJson = array('key' => $outkey, 'value' => $outlabel, 'type' => $outtype);
7893 public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '')
7895 global $conf, $user;
7899 // Example of value for $objectdec:
7900 // Bom:bom/class/bom.class.php:0:t.status=1
7901 // Bom:bom/class/bom.class.php:0:t.status=1:ref
7902 // Bom:bom/class/bom.class.php:0:(t.status:=:1):ref
7903 $InfoFieldList = explode(":
", $objectdesc, 4);
7904 $vartmp = (empty($InfoFieldList[3]) ? '' : $InfoFieldList[3]);
7906 if (preg_match('/^.*:(\w*)$/', $vartmp, $reg)) {
7907 $InfoFieldList[4] = $reg[1]; // take the sort field
7909 $InfoFieldList[3] = preg_replace('/:\w*$/', '', $vartmp); // take the filter field
7911 $classname = $InfoFieldList[0];
7912 $classpath = $InfoFieldList[1];
7913 $addcreatebuttonornot = empty($InfoFieldList[2]) ? 0 : $InfoFieldList[2];
7914 $filter = empty($InfoFieldList[3]) ? '' : $InfoFieldList[3];
7915 $sortfield = empty($InfoFieldList[4]) ? '' : $InfoFieldList[4];
7917 if (!empty($classpath)) {
7918 dol_include_once($classpath);
7920 if ($classname && class_exists($classname)) {
7921 $objecttmp = new $classname($this->db);
7923 // Make some replacement
7924 $sharedentities = getEntity(strtolower($classname));
7925 $filter = str_replace(
7926 array('__ENTITY__', '__SHARED_ENTITIES__', '__USER_ID__'),
7927 array($conf->entity, $sharedentities, $user->id),
7932 if (!is_object($objecttmp)) {
7933 dol_syslog('Error bad setup of type for field ' . join(',', $InfoFieldList), LOG_WARNING);
7934 return 'Error bad setup of type for field ' . join(',', $InfoFieldList);
7937 //var_dump($filter);
7938 $prefixforautocompletemode = $objecttmp->element;
7939 if ($prefixforautocompletemode == 'societe') {
7940 $prefixforautocompletemode = 'company';
7942 if ($prefixforautocompletemode == 'product') {
7943 $prefixforautocompletemode = 'produit';
7945 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
7947 dol_syslog(get_class($this) . "::
selectForForms filter=
" . $filter, LOG_DEBUG);
7949 if (!empty($conf->use_javascript_ajax) && getDolGlobalString($confkeyforautocompletemode) && !$forcecombo) {
7950 // No immediate load of all database
7952 if ($preselectedvalue && empty($selected_input_value)) {
7953 $objecttmp->fetch($preselectedvalue);
7954 $selected_input_value = ($prefixforautocompletemode == 'company' ? $objecttmp->name : $objecttmp->ref);
7955 //unset($objecttmp);
7958 $objectdesc = $classname . ':' . $classpath . ':' . $addcreatebuttonornot . ':' . $filter;
7959 $urlforajaxcall = DOL_URL_ROOT . '/core/ajax/selectobject.php';
7961 // No immediate load of all database
7962 $urloption = 'htmlname=' . urlencode($htmlname) . '&outjson=1&objectdesc=' . urlencode($objectdesc) . '&filter=' . urlencode($filter) . ($sortfield ? '&sortfield=' . urlencode($sortfield) : '');
7963 // Activate the auto complete using ajax call.
7964 $out .= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array());
7965 $out .= '<!-- force css to be higher than dialog popup --><style type="text/css
">.ui-autocomplete { z-index: 1010; }</style>';
7966 $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) . '"' : '') . ' />';
7968 // Immediate load of table record.
7969 $out .= $this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled, $sortfield, $filter);
7996 public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0, $sortfield = '', $filter = '')
7998 global $conf, $langs, $user, $hookmanager;
8000 //print "$htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, $outputmode, $disabled
";
8002 $prefixforautocompletemode = $objecttmp->element;
8003 if ($prefixforautocompletemode == 'societe') {
8004 $prefixforautocompletemode = 'company';
8006 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
8008 if (!empty($objecttmp->fields)) { // For object that declare it, it is better to use declared fields (like societe, contact, ...)
8009 $tmpfieldstoshow = '';
8010 foreach ($objecttmp->fields as $key => $val) {
8011 if (!dol_eval($val['enabled'], 1, 1, '1')) {
8014 if (!empty($val['showoncombobox'])) {
8015 $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '') . 't.' . $key;
8018 if ($tmpfieldstoshow) {
8019 $fieldstoshow = $tmpfieldstoshow;
8022 // For backward compatibility
8023 $objecttmp->fields['ref'] = array('type' => 'varchar(30)', 'label' => 'Ref', 'showoncombobox' => 1);
8026 if (empty($fieldstoshow)) {
8027 if (isset($objecttmp->fields['ref'])) {
8028 $fieldstoshow = 't.ref';
8030 $langs->load("errors
");
8031 $this->error = $langs->trans("ErrorNoFieldWithAttributeShowoncombobox
");
8032 return $langs->trans('ErrorNoFieldWithAttributeShowoncombobox');
8037 $outarray = array();
8038 $tmparray = array();
8043 $sql = "SELECT t.
rowid,
" . $fieldstoshow . " FROM
" . $this->db->prefix() . $objecttmp->table_element . " as t
";
8044 if (isset($objecttmp->ismultientitymanaged)) {
8045 if (!is_numeric($objecttmp->ismultientitymanaged)) {
8046 $tmparray = explode('@', $objecttmp->ismultientitymanaged);
8047 $sql .= " INNER JOIN
" . $this->db->prefix() . $tmparray[1] . " as parenttable ON parenttable.
rowid = t.
" . $tmparray[0];
8049 if ($objecttmp->ismultientitymanaged === 'fk_soc@societe') {
8050 if (empty($user->rights->societe->client->voir) && !$user->socid) {
8051 $sql .= ",
" . $this->db->prefix() . "societe_commerciaux as sc
";
8056 // Add where from hooks
8057 $parameters = array(
8058 'object' => $objecttmp,
8059 'htmlname' => $htmlname,
8060 'filter' => $filter,
8061 'searchkey' => $searchkey
8064 $reshook = $hookmanager->executeHooks('selectForFormsListWhere', $parameters); // Note that $action and $object may have been modified by hook
8065 if (!empty($hookmanager->resPrint)) {
8066 $sql .= $hookmanager->resPrint;
8068 $sql .= " WHERE 1=1
";
8069 if (isset($objecttmp->ismultientitymanaged)) {
8070 if ($objecttmp->ismultientitymanaged == 1) {
8071 $sql .= " AND t.entity IN (
" . getEntity($objecttmp->table_element) . ")
";
8073 if (!is_numeric($objecttmp->ismultientitymanaged)) {
8074 $sql .= " AND parenttable.entity = t.
" . $tmparray[0];
8076 if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
8077 if ($objecttmp->element == 'societe') {
8078 $sql .= " AND t.
rowid =
" . ((int) $user->socid);
8080 $sql .= " AND t.fk_soc =
" . ((int) $user->socid);
8083 if ($objecttmp->ismultientitymanaged === 'fk_soc@societe') {
8084 if (empty($user->rights->societe->client->voir) && !$user->socid) {
8085 $sql .= " AND t.
rowid = sc.fk_soc AND sc.fk_user =
" . ((int) $user->id);
8089 if ($searchkey != '') {
8090 $sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
8093 if ($filter) { // Syntax example "(t.
ref:like:
'SO-%') and (t.date_creation:<:
'20160101')
"
8095 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
8096 if ($errormessage) {
8097 return 'Error forging a SQL request from an universal criteria: ' . $errormessage;
8101 $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow, "ASC
");
8102 //$sql.=$this->db->plimit($limit, 0);
8105 // Build output string
8106 $resql = $this->db->query($sql);
8108 // Construct $out and $outarray
8109 $out .= '<select id="' . $htmlname . '" class="flat
' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled="disabled
"' : '') . ($moreparams ? ' ' . $moreparams : '') . ' name="' . $htmlname . '">' . "\n
";
8111 // Warning: Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. Seems it is no more true with selec2 v4
8112 $textifempty = ' ';
8114 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
8115 if (!empty($conf->global->$confkeyforautocompletemode)) {
8116 if ($showempty && !is_numeric($showempty)) {
8117 $textifempty = $langs->trans($showempty);
8119 $textifempty .= $langs->trans("All
");
8123 $out .= '<option value="-1
">' . $textifempty . '</option>' . "\n
";
8126 $num = $this->db->num_rows($resql);
8130 $obj = $this->db->fetch_object($resql);
8133 $tmparray = explode(',', $fieldstoshow);
8134 $oldvalueforshowoncombobox = 0;
8135 foreach ($tmparray as $key => $val) {
8136 $val = preg_replace('/t\./', '', $val);
8137 $label .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val]['showoncombobox'] ? ' - ' : ' ') : '');
8138 $labelhtml .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val]['showoncombobox'] ? ' - ' : ' ') : '');
8139 $label .= $obj->$val;
8140 $labelhtml .= $obj->$val;
8142 $oldvalueforshowoncombobox = empty($objecttmp->fields[$val]['showoncombobox']) ? 0 : $objecttmp->fields[$val]['showoncombobox'];
8144 if (empty($outputmode)) {
8145 if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
8146 $out .= '<option value="' . $obj->rowid . '" selected data-html="' . dol_escape_htmltag($labelhtml, 0, 0, '', 0, 1) . '">' . dol_escape_htmltag($label, 0, 0, '', 0, 1) . '</option>';
8148 $out .= '<option value="' . $obj->rowid . '" data-html="' . dol_escape_htmltag($labelhtml, 0, 0, '', 0, 1) . '">' . dol_escape_htmltag($label, 0, 0, '', 0, 1) . '</option>';
8151 array_push($outarray, array('key' => $obj->rowid, 'value' => $label, 'label' => $label));
8155 if (($i % 10) == 0) {
8161 $out .= '</select>' . "\n
";
8164 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
8165 $out .= ajax_combobox($htmlname, null, (!empty($conf->global->$confkeyforautocompletemode) ? $conf->global->$confkeyforautocompletemode : 0));
8168 dol_print_error($this->db);
8171 $this->result = array('nbofelement' => $num);
8203 public static function selectarray($htmlname, $array, $id = '', $show_empty = 0, $key_in_label = 0, $value_as_key = 0, $moreparam = '', $translate = 0, $maxlen = 0, $disabled = 0, $sort = '', $morecss = 'minwidth75', $addjscombo = 1, $moreparamonempty = '', $disablebademail = 0, $nohtmlescape = 0)
8205 global $conf, $langs;
8207 // Do we want a multiselect ?
8209 //if (preg_match('/^multi/',$htmlname)) $jsbeautify = 1;
8212 if ($value_as_key) {
8213 $array = array_combine($array, $array);
8218 if ($addjscombo < 0) {
8219 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
8226 $idname = str_replace(array('[', ']'), array('', ''), $htmlname);
8227 $out .= '<select id="
' . preg_replace('/^\./
', '', $idname) . '" ' . ($disabled ? 'disabled="disabled
" ' : '') . 'class="flat
' . (preg_replace('/^\./
', '', $htmlname)) . ($morecss ? ' ' . $morecss : '') . ' selectformat
"';
8228 $out .= ' name="' . preg_replace('/^\./
', '', $htmlname) . '" ' . ($moreparam ? $moreparam : '');
8232 $textforempty = ' ';
8233 if (!empty($conf->use_javascript_ajax)) {
8234 $textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
8236 if (!is_numeric($show_empty)) {
8237 $textforempty = $show_empty;
8239 $out .= '<option class="optiongrey
" ' . ($moreparamonempty ? $moreparamonempty . ' ' : '') . 'value="' . (((int) $show_empty) < 0 ? $show_empty : -1) . '"' . ($id == $show_empty ? ' selected' : '') . '>' . $textforempty . '</option>' . "\n
";
8242 if (is_array($array)) {
8245 foreach ($array as $key => $value) {
8246 if (!is_array($value)) {
8247 $array[$key] = $langs->trans($value);
8249 $array[$key]['label'] = $langs->trans($value['label']);
8255 if ($sort == 'ASC') {
8257 } elseif ($sort == 'DESC') {
8261 foreach ($array as $key => $tmpvalue) {
8262 if (is_array($tmpvalue)) {
8263 $value = $tmpvalue['label'];
8264 $disabled = empty($tmpvalue['disabled']) ? '' : ' disabled';
8265 $style = empty($tmpvalue['css']) ? '' : ' class="' . $tmpvalue['css
'] . '"';
8271 if (!empty($disablebademail)) {
8272 if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value))
8273 || ($disablebademail == 2 && preg_match('/---/', $value))) {
8274 $disabled = ' disabled';
8275 $style = ' class="warning
"';
8279 if ($key_in_label) {
8280 if (empty($nohtmlescape)) {
8281 $selectOptionValue = dol_escape_htmltag($key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value));
8283 $selectOptionValue = $key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value);
8286 if (empty($nohtmlescape)) {
8287 $selectOptionValue = dol_escape_htmltag($maxlen ? dol_trunc($value, $maxlen) : $value);
8289 $selectOptionValue = $maxlen ? dol_trunc($value, $maxlen) : $value;
8291 if ($value == '' || $value == '-') {
8292 $selectOptionValue = ' ';
8296 $out .= '<option value="' . $key . '"';
8297 $out .= $style . $disabled;
8298 if (is_array($id)) {
8299 if (in_array($key, $id) && !$disabled) {
8300 $out .= ' selected'; // To preselect a value
8303 $id = (string) $id; // if $id = 0, then $id = '0'
8304 if ($id != '' && ($id == $key || ($id == 'ifone' && count($array) == 1)) && !$disabled) {
8305 $out .= ' selected'; // To preselect a value
8308 if ($nohtmlescape) {
8309 $out .= ' data-html="' . dol_escape_htmltag($selectOptionValue) . '"';
8311 if (is_array($tmpvalue)) {
8312 foreach ($tmpvalue as $keyforvalue => $valueforvalue) {
8313 if (preg_match('/^data-/', $keyforvalue)) {
8314 $out .= ' '.$keyforvalue.'="'.dol_escape_htmltag($valueforvalue).'"';
8319 //var_dump($selectOptionValue);
8320 $out .= $selectOptionValue;
8321 $out .= "</option>\n
";
8325 $out .= "</select>
";
8327 // Add code for jquery to use multiselect
8328 if ($addjscombo && $jsbeautify) {
8329 // Enhance with select2
8330 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
8331 $out .= ajax_combobox($idname, array(), 0, 0, 'resolve', (((int) $show_empty) < 0 ? (string) $show_empty : '-1'), $morecss);
8356 public static function selectArrayAjax($htmlname, $url, $id = '', $moreparam = '', $moreparamtourl = '', $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0)
8358 global $conf, $langs;
8359 global $delayedhtmlcontent; // Will be used later outside of this function
8361 // TODO Use an internal dolibarr component instead of select2
8362 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) {
8366 $out = '<select type="text
" class="' . $htmlname . ($morecss ? ' ' . $morecss : '') . '" ' . ($moreparam ? $moreparam . ' ' : '') . 'name="' . $htmlname . '"></select>';
8369 if (!empty($conf->use_javascript_ajax)) {
8370 $tmpplugin = 'select2';
8371 $outdelayed = "\n
" . '<!-- JS CODE TO ENABLE ' . $tmpplugin . ' for id ' . $htmlname . ' -->
8372 <script nonce="' . getNonce() . '">
8373 $(document).ready(function () {
8375 ' . ($callurlonselect ? 'var saveRemoteData = [];' : '') . '
8377 $(".
' . $htmlname . '").select2({
8380 url: "' . $url . '",
8383 data: function (params) {
8385 q: params.term, // search term
8389 processResults: function (data) {
8390 // parse the results into the format expected by Select2.
8391 // since we are using custom formatting functions we do not need to alter the remote JSON data
8392 //console.log(data);
8393 saveRemoteData = data;
8394 /* format json result for select2 */
8396 $.each( data, function( key, value ) {
8397 result.push({id: key, text: value.text});
8399 //return {results:[{id:\'none\', text:\'aa\'}, {id:\'rrr\', text:\'Red\'},{id:\'bbb\', text:\'Search a into projects\'}], more:false}
8400 //console.log(result);
8401 return {results: result, more: false}
8405 language: select2arrayoflanguage,
8406 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
8407 placeholder:
"' . dol_escape_js($placeholder) . '",
8408 escapeMarkup: function (markup) {
return markup; },
8409 minimumInputLength:
' . ((int) $minimumInputLength) . ',
8410 formatResult:
function (result, container, query, escapeMarkup) {
8411 return escapeMarkup(result.text);
8415 ' . ($callurlonselect ? '
8417 $(
".' . $htmlname . '").change(
function() {
8418 var selected = $(
".' . $htmlname . '").val();
8419 console.log(
"We select in selectArrayAjax the entry "+selected)
8420 $(
".' . $htmlname . '").val(
"");
8421 $.each( saveRemoteData,
function( key, value ) {
8422 if (key == selected)
8424 console.log(
"selectArrayAjax - Do a redirect to "+value.url)
8425 location.assign(value.url);
8434 if ($acceptdelayedhtml) {
8435 $delayedhtmlcontent .= $outdelayed;
8437 $out .= $outdelayed;
8461 public static function selectArrayFilter($htmlname, $array, $id = '
', $moreparam = '', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0, $textfortitle = '')
8463 global $conf, $langs;
8464 global $delayedhtmlcontent; // Will be used later outside of this function
8466 // TODO Use an internal dolibarr component instead of select2
8467 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT
')) {
8471 $out = '<select
type=
"text"'.($textfortitle? ' title=
"'.dol_escape_htmltag($textfortitle).'"' : '').' id=
"'.$htmlname.'" class=
"'.$htmlname.($morecss ? ' ' . $morecss : '').'"'.($moreparam ? ' '.$moreparam : '').' name=
"'.$htmlname.'"><option></option></select>
';
8473 $formattedarrayresult = array();
8475 foreach ($array as $key => $value) {
8476 $o = new stdClass();
8478 $o->text = $value['text
'];
8479 $o->url = $value['url
'];
8480 $formattedarrayresult[] = $o;
8484 if (!empty($conf->use_javascript_ajax)) {
8485 $tmpplugin = 'select2
';
8486 $outdelayed = "\n" . '<!-- JS CODE TO ENABLE
' . $tmpplugin . ' for id ' . $htmlname . ' -->
8487 <script nonce=
"' . getNonce() . '">
8488 $(document).ready(
function () {
8489 var data =
' . json_encode($formattedarrayresult) . ';
8491 ' . ($callurlonselect ? 'var saveRemoteData =
' . json_encode($array) . ';
' : '') . '
8493 $(
".' . $htmlname . '").select2({
8495 language: select2arrayoflanguage,
8496 containerCssClass: \
':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
8498 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
8499 minimumInputLength: ' . $minimumInputLength .
',
8500 formatResult: function (result, container, query, escapeMarkup) {
8501 return escapeMarkup(result.text);
8503 matcher: function (params, data) {
8505 if(! data.id) return null;';
8507 if ($callurlonselect) {
8511 var urlBase = data.url;
8512 var separ = urlBase.indexOf("?") >= 0 ? "&" : "?";
8513 /* console.log("params.term="+params.term); */
8514 /* console.log("params.term encoded="+encodeURIComponent(params.term)); */
8515 saveRemoteData[data.id].url = urlBase + separ + "search_all=" + encodeURIComponent(params.term.replace(/\"/g, ""));';
8518 if (!$disableFiltering) {
8521 if(data.text.match(new RegExp(params.term))) {
8536 ' . ($callurlonselect ?
'
8537 /* Code to execute a GET when we select a value */
8538 $(".' . $htmlname .
'").change(function() {
8539 var selected = $(".' . $htmlname .
'").val();
8540 console.log("We select "+selected)
8542 $(".' . $htmlname .
'").val(""); /* reset visible combo value */
8543 $.each( saveRemoteData, function( key, value ) {
8544 if (key == selected)
8546 console.log("selectArrayFilter - Do a redirect to "+value.url)
8547 location.assign(value.url);
8556 if ($acceptdelayedhtml) {
8557 $delayedhtmlcontent .= $outdelayed;
8559 $out .= $outdelayed;
8582 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)
8584 global $conf, $langs;
8588 if ($addjscombo < 0) {
8589 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
8596 $useenhancedmultiselect = 0;
8597 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined(
'REQUIRE_JQUERY_MULTISELECT')) {
8598 $useenhancedmultiselect = 1;
8602 $out .=
'<select id="' . $htmlname .
'" class="multiselect' . ($useenhancedmultiselect ?
' multiselectononeline' :
'') . ($morecss ?
' ' . $morecss :
'') .
'" multiple name="' . $htmlname .
'[]"' . ($moreattrib ?
' ' . $moreattrib :
'') . ($width ?
' style="width: ' . (preg_match(
'/%/', $width) ? $width : $width .
'px') .
'"' :
'') .
'>' .
"\n";
8603 if (is_array($array) && !empty($array)) {
8604 if ($value_as_key) {
8605 $array = array_combine($array, $array);
8608 if (!empty($array)) {
8609 foreach ($array as $key => $value) {
8615 if (is_array($value) && array_key_exists(
'id', $value) && array_key_exists(
'label', $value)) {
8616 $tmpkey = $value[
'id'];
8617 $tmpvalue = $value[
'label'];
8618 $tmpcolor = $value[
'color'];
8619 $tmppicto = $value[
'picto'];
8620 $tmplabelhtml = !empty($value[
'labelhtml']) ? $value[
'labelhtml'] :
'';
8622 $newval = ($translate ? $langs->trans($tmpvalue) : $tmpvalue);
8623 $newval = ($key_in_label ? $tmpkey .
' - ' . $newval : $newval);
8625 $out .=
'<option value="' . $tmpkey .
'"';
8626 if (is_array($selected) && !empty($selected) && in_array((
string) $tmpkey, $selected) && ((string) $tmpkey !=
'')) {
8627 $out .=
' selected';
8629 if (!empty($tmplabelhtml)) {
8632 $tmplabelhtml = ($tmppicto ?
img_picto(
'', $tmppicto,
'class="pictofixedwidth" style="color: #' . $tmpcolor .
'"') :
'') . $newval;
8637 $out .=
'</option>' .
"\n";
8641 $out .=
'</select>' .
"\n";
8644 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined(
'REQUIRE_JQUERY_MULTISELECT')) {
8645 $out .=
"\n" .
'<!-- JS CODE TO ENABLE select for id ' . $htmlname .
', addjscombo=' . $addjscombo .
' -->';
8646 $out .=
"\n" .
'<script nonce="' .
getNonce() .
'">' .
"\n";
8647 if ($addjscombo == 1) {
8648 $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ? constant(
'REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
8649 $out .=
'function formatResult(record, container) {' .
"\n";
8652 $out .=
' if ($(record.element).attr("data-html") != undefined) { return htmlEntityDecodeJs($(record.element).attr("data-html")); }'.
"\n";
8653 $out .=
' return record.text;';
8655 $out .=
'function formatSelection(record) {' .
"\n";
8656 if ($elemtype ==
'category') {
8657 $out .=
'return \'<span><img src="' . DOL_URL_ROOT .
'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
8659 $out .=
'return record.text;';
8662 $out .=
'$(document).ready(function () {
8663 $(\'#' . $htmlname .
'\').
' . $tmpplugin . '({
';
8671 $out .= ' dir: \
'ltr\',
8672 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag (ko with multiselect) */
8673 dropdownCssClass: \'' . $morecss .
'\',
8675 formatResult: formatResult,
8676 templateResult: formatResult,
8677 escapeMarkup:
function (markup) {
return markup; },
8679 formatSelection: formatSelection,
8680 templateSelection: formatSelection
8685 $(\
'#' . $htmlname .
' + .select2\').addClass(\'' . $morecss .
'\');
8687 } elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT
')) {
8689 // TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
8691 $out .= 'console.log(\
'addjscombo=2 for htmlname=' . $htmlname .
'\');
';
8692 $out .= '$(document).ready(
function () {
8693 $(\
'#' . $htmlname .
'\').multiSelect({
8694 containerHTML: \
'<div class="multi-select-container">\',
8695 menuHTML: \'<div class="multi-select-menu">\',
8696 buttonHTML: \'<span class="multi-select-button ' . $morecss .
'">\',
8697 menuItemHTML: \'<label class="multi-select-menuitem">\',
8698 activeClass: \'multi-select-container--open\',
8699 noneText: \'' . $placeholder .
'\'
8703 $out .= '</script>
';
8720 public static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage, $pos = '
')
8722 global $conf, $langs, $user, $extrafields;
8724 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
8727 if (empty($array)) {
8731 $tmpvar = "MAIN_SELECTEDFIELDS_" . $varpage; // To get list of saved selected fields to show
8733 if (!empty($user->conf->$tmpvar)) { // A list of fields was already customized for user
8734 $tmparray = explode(',
', $user->conf->$tmpvar);
8735 foreach ($array as $key => $val) {
8737 //var_dump($tmparray);
8738 if (in_array($key, $tmparray)) {
8739 $array[$key]['checked
'] = 1;
8741 $array[$key]['checked
'] = 0;
8744 } else { // There is no list of fields already customized for user
8745 foreach ($array as $key => $val) {
8746 if (!empty($array[$key]['checked
']) && $array[$key]['checked
'] < 0) {
8747 $array[$key]['checked
'] = 0;
8752 $listoffieldsforselection = '';
8753 $listcheckedstring = '';
8755 foreach ($array as $key => $val) {
8757 // var_dump(array_key_exists('enabled
', $val));
8758 // var_dump(!$val['enabled
']);
8759 if (array_key_exists('enabled
', $val) && isset($val['enabled
']) && !$val['enabled
']) {
8760 unset($array[$key]); // We don't want
this field
8763 if (!empty($val[
'type']) && $val[
'type'] ==
'separate') {
8768 if ($val[
'label']) {
8769 if (!empty($val[
'langfile']) && is_object($langs)) {
8770 $langs->load($val[
'langfile']);
8774 $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>';
8775 $listcheckedstring .= (empty($val[
'checked']) ?
'' : $key .
',');
8779 $out =
'<!-- Component multiSelectArrayWithCheckbox ' . $htmlname .
' -->
8781 <dl class="dropdown">
8783 <a href="#' . $htmlname .
'">
8786 <input type="hidden" class="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $listcheckedstring .
'">
8788 <dd class="dropdowndd">
8789 <div class="multiselectcheckbox'.$htmlname.
'">
8790 <ul class="'.$htmlname.($pos ==
'1' ?
'left' :
'').
'">
8791 <li><input class="inputsearch_dropdownselectedfields width90p minwidth200imp" style="width:90%;" type="text" placeholder="'.$langs->trans(
'Search').
'"></li>
8792 '.$listoffieldsforselection.
'
8798 <script nonce="' .
getNonce() .
'" type="text/javascript">
8799 jQuery(document).ready(function () {
8800 $(\'.multiselectcheckbox' . $htmlname .
' input[type="checkbox"]\').on(\'click\', function () {
8801 console.log("A new field was added/removed, we edit field input[name=formfilteraction]");
8803 $("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\'); // Update field so we know we changed something on selected fields after POST
8805 var title = $(this).val() + ",";
8806 if ($(this).is(\':checked\')) {
8807 $(\'.' . $htmlname .
'\').val(title + $(\
'.' . $htmlname .
'\').val());
8810 $(\
'.' . $htmlname .
'\').val( $(\
'.' . $htmlname .
'\').val().replace(title, \
'\') )
8815 $(
"input.inputsearch_dropdownselectedfields").on(
"keyup",
function() {
8816 var value = $(
this).val().toLowerCase();
8817 $(\
'.multiselectcheckbox'.$htmlname.
' li > label\').filter(function() {
8818 $(this).parent().toggle($(this).text().toLowerCase().indexOf(value) > -1)
8841 include_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
8844 $categories = $cat->containing($id, $type);
8846 if ($rendermode == 1) {
8848 foreach ($categories as $c) {
8849 $ways = $c->print_all_ways(
' >> ', ($nolink ?
'none' :
''), 0, 1);
8850 foreach ($ways as $way) {
8851 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' . $way .
'</li>';
8854 return '<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
8857 if ($rendermode == 0) {
8858 $arrayselected = array();
8860 foreach ($categories as $c) {
8861 $arrayselected[] = $c->id;
8864 return $this->
multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'', 0,
'100%',
'disabled',
'category');
8867 return 'ErrorBadValueForParameterRenderMode';
8879 public function showLinkedObjectBlock($object, $morehtmlright =
'', $compatibleImportElementsList =
false, $title =
'RelatedObjects')
8881 global $conf, $langs, $hookmanager;
8882 global $bc, $action;
8884 $object->fetchObjectLinked();
8887 $hookmanager->initHooks(array(
'commonobject'));
8888 $parameters = array(
8889 'morehtmlright' => $morehtmlright,
8890 'compatibleImportElementsList' => &$compatibleImportElementsList,
8892 $reshook = $hookmanager->executeHooks(
'showLinkedObjectBlock', $parameters, $object, $action);
8894 $nbofdifferenttypes = count($object->linkedObjects);
8896 if (empty($reshook)) {
8897 print
'<!-- showLinkedObjectBlock -->';
8898 print
load_fiche_titre($langs->trans($title), $morehtmlright,
'', 0, 0,
'showlinkedobjectblock');
8901 print
'<div class="div-table-responsive-no-min">';
8902 print
'<table class="noborder allwidth" data-block="showLinkedObject" data-element="' . $object->element .
'" data-elementid="' . $object->id .
'" >';
8904 print
'<tr class="liste_titre">';
8905 print
'<td>' . $langs->trans(
"Type") .
'</td>';
8906 print
'<td>' . $langs->trans(
"Ref") .
'</td>';
8907 print
'<td class="center"></td>';
8908 print
'<td class="center">' . $langs->trans(
"Date") .
'</td>';
8909 print
'<td class="right">' . $langs->trans(
"AmountHTShort") .
'</td>';
8910 print
'<td class="right">' . $langs->trans(
"Status") .
'</td>';
8914 $nboftypesoutput = 0;
8916 foreach ($object->linkedObjects as $objecttype => $objects) {
8917 $tplpath = $element = $subelement = $objecttype;
8920 $showImportButton =
false;
8921 if (!empty($compatibleImportElementsList) && in_array($element, $compatibleImportElementsList)) {
8922 $showImportButton =
true;
8926 if ($objecttype !=
'supplier_proposal' && preg_match(
'/^([^_]+)_([^_]+)/i', $objecttype, $regs)) {
8927 $element = $regs[1];
8928 $subelement = $regs[2];
8929 $tplpath = $element .
'/' . $subelement;
8931 $tplname =
'linkedobjectblock';
8934 if ($objecttype ==
'facture') {
8935 $tplpath =
'compta/' . $element;
8936 if (!isModEnabled(
'facture')) {
8939 } elseif ($objecttype ==
'facturerec') {
8940 $tplpath =
'compta/facture';
8941 $tplname =
'linkedobjectblockForRec';
8942 if (!isModEnabled(
'facture')) {
8945 } elseif ($objecttype ==
'propal') {
8946 $tplpath =
'comm/' . $element;
8947 if (!isModEnabled(
'propal')) {
8950 } elseif ($objecttype ==
'supplier_proposal') {
8951 if (!isModEnabled(
'supplier_proposal')) {
8954 } elseif ($objecttype ==
'shipping' || $objecttype ==
'shipment' || $objecttype ==
'expedition') {
8955 $tplpath =
'expedition';
8956 if (!isModEnabled(
'expedition')) {
8959 } elseif ($objecttype ==
'reception') {
8960 $tplpath =
'reception';
8961 if (!isModEnabled(
'reception')) {
8964 } elseif ($objecttype ==
'delivery') {
8965 $tplpath =
'delivery';
8966 if (!isModEnabled(
'expedition')) {
8969 } elseif ($objecttype ==
'ficheinter') {
8970 $tplpath =
'fichinter';
8971 if (!isModEnabled(
'ficheinter')) {
8974 } elseif ($objecttype ==
'invoice_supplier') {
8975 $tplpath =
'fourn/facture';
8976 } elseif ($objecttype ==
'order_supplier') {
8977 $tplpath =
'fourn/commande';
8978 } elseif ($objecttype ==
'expensereport') {
8979 $tplpath =
'expensereport';
8980 } elseif ($objecttype ==
'subscription') {
8981 $tplpath =
'adherents';
8982 } elseif ($objecttype ==
'conferenceorbooth') {
8983 $tplpath =
'eventorganization';
8984 } elseif ($objecttype ==
'conferenceorboothattendee') {
8985 $tplpath =
'eventorganization';
8986 } elseif ($objecttype ==
'mo') {
8988 if (!isModEnabled(
'mrp')) {
8993 global $linkedObjectBlock;
8994 $linkedObjectBlock = $objects;
8997 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/' . $tplpath .
'/tpl'));
8998 foreach ($dirtpls as $reldir) {
8999 if ($nboftypesoutput == ($nbofdifferenttypes - 1)) {
9000 global $noMoreLinkedObjectBlockAfter;
9001 $noMoreLinkedObjectBlockAfter = 1;
9004 $res = @include
dol_buildpath($reldir .
'/' . $tplname .
'.tpl.php');
9012 if (!$nboftypesoutput) {
9013 print
'<tr><td class="impair" colspan="7"><span class="opacitymedium">' . $langs->trans(
"None") .
'</span></td></tr>';
9018 if (!empty($compatibleImportElementsList)) {
9019 $res = @include
dol_buildpath(
'core/tpl/objectlinked_lineimport.tpl.php');
9025 return $nbofdifferenttypes;
9038 global $conf, $langs, $hookmanager;
9042 $linktoelemlist =
'';
9043 $listofidcompanytoscan =
'';
9045 if (!is_object($object->thirdparty)) {
9046 $object->fetch_thirdparty();
9049 $possiblelinks = array();
9050 if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
9051 $listofidcompanytoscan = $object->thirdparty->id;
9052 if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) {
9053 $listofidcompanytoscan .=
',' . $object->thirdparty->parent;
9055 if (($object->fk_project > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) {
9056 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
9057 $tmpproject =
new Project($this->db);
9058 $tmpproject->fetch($object->fk_project);
9059 if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) {
9060 $listofidcompanytoscan .=
',' . $tmpproject->socid;
9065 $possiblelinks = array(
9067 'enabled' => isModEnabled(
'propal'),
9069 'label' =>
'LinkToProposal',
9070 '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') .
')'),
9071 'shipping' => array(
9072 'enabled' => isModEnabled(
'expedition'),
9074 'label' =>
'LinkToExpedition',
9075 'sql' =>
"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM " . $this->db->prefix() .
"societe as s, " . $this->db->prefix() .
"expedition as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) .
') AND t.entity IN (' .
getEntity(
'shipping') .
')'),
9077 'enabled' => isModEnabled(
'commande'),
9079 'label' =>
'LinkToOrder',
9080 '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') .
')'),
9082 'enabled' => isModEnabled(
'facture'),
9084 'label' =>
'LinkToInvoice',
9085 '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') .
')'),
9086 'invoice_template' => array(
9087 'enabled' => isModEnabled(
'facture'),
9089 'label' =>
'LinkToTemplateInvoice',
9090 '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') .
')'),
9092 'enabled' => isModEnabled(
'contrat'),
9094 'label' =>
'LinkToContract',
9095 '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
9096 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'
9098 'fichinter' => array(
9099 'enabled' => isModEnabled(
'ficheinter'),
9101 'label' =>
'LinkToIntervention',
9102 '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') .
')'),
9103 'supplier_proposal' => array(
9104 'enabled' => (isModEnabled(
'supplier_proposal') ? $conf->supplier_proposal->enabled : 0),
9106 'label' =>
'LinkToSupplierProposal',
9107 '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') .
')'),
9108 'order_supplier' => array(
9109 'enabled' => (isModEnabled(
"supplier_order") ? $conf->supplier_order->enabled : 0),
9111 'label' =>
'LinkToSupplierOrder',
9112 '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') .
')'),
9113 'invoice_supplier' => array(
9114 'enabled' => (isModEnabled(
"supplier_invoice") ? $conf->supplier_invoice->enabled : 0),
9115 'perms' => 1,
'label' =>
'LinkToSupplierInvoice',
9116 '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') .
')'),
9118 'enabled' => isModEnabled(
'ticket'),
9120 'label' =>
'LinkToTicket',
9121 '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') .
')'),
9123 'enabled' => isModEnabled(
'mrp'),
9125 'label' =>
'LinkToMo',
9126 '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') .
')')
9130 if ($object->table_element ==
'commande_fournisseur') {
9131 $possiblelinks[
'mo'][
'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.entity IN ('.
getEntity(
'mo').
')';
9132 } elseif ($object->table_element ==
'mrp_mo') {
9133 $possiblelinks[
'order_supplier'][
'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.entity IN ('.
getEntity(
'commande_fournisseur').
')';
9136 if (!empty($listofidcompanytoscan)) {
9138 $hookmanager->initHooks(array(
'commonobject'));
9139 $parameters = array(
'listofidcompanytoscan' => $listofidcompanytoscan,
'possiblelinks' => $possiblelinks);
9140 $reshook = $hookmanager->executeHooks(
'showLinkToObjectBlock', $parameters, $object, $action);
9143 if (empty($reshook)) {
9144 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
9145 $possiblelinks = array_merge($possiblelinks, $hookmanager->resArray);
9147 } elseif ($reshook > 0) {
9148 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
9149 $possiblelinks = $hookmanager->resArray;
9153 foreach ($possiblelinks as $key => $possiblelink) {
9156 if (empty($possiblelink[
'enabled'])) {
9160 if (!empty($possiblelink[
'perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) {
9161 print
'<div id="' . $key .
'list"' . (empty($conf->use_javascript_ajax) ?
'' :
' style="display:none"') .
'>';
9163 if (!empty($conf->global->MAIN_LINK_BY_REF_IN_LINKTO)) {
9165 print
'<!-- form to add a link from anywhere -->'.
"\n";
9166 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="formlinkedbyref' . $key .
'">';
9167 print
'<input type="hidden" name="id" value="' . $object->id .
'">';
9168 print
'<input type="hidden" name="action" value="addlinkbyref">';
9169 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
9170 print
'<input type="hidden" name="addlink" value="' . $key .
'">';
9171 print
'<table class="noborder">';
9174 print
'<td class="center"><input type="text" placeholder="'.dol_escape_htmltag($langs->trans(
"Ref")).
'" name="reftolinkto" value="' .
dol_escape_htmltag(
GETPOST(
'reftolinkto',
'alpha')) .
'"> ';
9175 print
'<input type="submit" class="button small valignmiddle" value="' . $langs->trans(
'ToLink') .
'"> ';
9176 print
'<input type="submit" class="button small" name="cancel" value="' . $langs->trans(
'Cancel') .
'"></td>';
9182 $sql = $possiblelink[
'sql'];
9184 $resqllist = $this->db->query($sql);
9186 $num = $this->db->num_rows($resqllist);
9190 print
'<!-- form to add a link from object to same thirdparty -->'.
"\n";
9191 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="formlinked' . $key .
'">';
9192 print
'<input type="hidden" name="action" value="addlink">';
9193 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
9194 print
'<input type="hidden" name="id" value="' . $object->id .
'">';
9195 print
'<input type="hidden" name="addlink" value="' . $key .
'">';
9196 print
'<table class="noborder">';
9197 print
'<tr class="liste_titre">';
9198 print
'<td class="nowrap"></td>';
9199 print
'<td class="center">' . $langs->trans(
"Ref") .
'</td>';
9200 print
'<td class="left">' . $langs->trans(
"RefCustomer") .
'</td>';
9201 print
'<td class="right">' . $langs->trans(
"AmountHTShort") .
'</td>';
9202 print
'<td class="left">' . $langs->trans(
"Company") .
'</td>';
9205 $objp = $this->db->fetch_object($resqllist);
9207 print
'<tr class="oddeven">';
9208 print
'<td class="left">';
9209 print
'<input type="radio" name="idtolinkto" id="' . $key .
'_' . $objp->rowid .
'" value="' . $objp->rowid .
'">';
9211 print
'<td class="center"><label for="' . $key .
'_' . $objp->rowid .
'">' . $objp->ref .
'</label></td>';
9212 print
'<td>' . (!empty($objp->ref_client) ? $objp->ref_client : (!empty($objp->ref_supplier) ? $objp->ref_supplier :
'')) .
'</td>';
9213 print
'<td class="right">';
9214 if ($possiblelink[
'label'] ==
'LinkToContract') {
9215 $form =
new Form($this->db);
9216 print $form->textwithpicto(
'', $langs->trans(
"InformationOnLinkToContract")) .
' ';
9218 print
'<span class="amount">' . (isset($objp->total_ht) ?
price($objp->total_ht) :
'') .
'</span>';
9220 print
'<td>' . $objp->name .
'</td>';
9225 print
'<div class="center">';
9227 print
'<input type="submit" class="button valignmiddle marginleftonly marginrightonly small" value="' . $langs->trans(
'ToLink') .
'">';
9229 if (empty($conf->use_javascript_ajax)) {
9230 print
'<input type="submit" class="button button-cancel marginleftonly marginrightonly small" name="cancel" value="' . $langs->trans(
"Cancel") .
'"></div>';
9232 print
'<input type="submit" onclick="jQuery(\'#' . $key .
'list\').toggle(); return false;" class="button button-cancel marginleftonly marginrightonly small" name="cancel" value="' . $langs->trans(
"Cancel") .
'"></div>';
9235 $this->db->free($resqllist);
9242 if ($num > 0 || !empty($conf->global->MAIN_LINK_BY_REF_IN_LINKTO)) {
9243 $linktoelemlist .=
'<li><a href="#linkto' . $key .
'" class="linkto dropdowncloseonclick" rel="' . $key .
'">' . $langs->trans($possiblelink[
'label']) .
' (' . $num .
')</a></li>';
9246 $linktoelemlist .=
'<li><span class="linktodisabled">' . $langs->trans($possiblelink[
'label']) .
' (0)</span></li>';
9251 if ($linktoelemlist) {
9253 <dl class="dropdown" id="linktoobjectname">
9255 if (!empty($conf->use_javascript_ajax)) {
9256 $linktoelem .=
'<dt><a href="#linktoobjectname"><span class="fas fa-link paddingrightonly"></span>' . $langs->trans(
"LinkTo") .
'...</a></dt>';
9258 $linktoelem .=
'<dd>
9259 <div class="multiselectlinkto">
9260 <ul class="ulselectedfields">' . $linktoelemlist .
'
9269 if (!empty($conf->use_javascript_ajax)) {
9270 print
'<!-- Add js to show linkto box -->
9271 <script nonce="' .
getNonce() .
'">
9272 jQuery(document).ready(function() {
9273 jQuery(".linkto").click(function() {
9274 console.log("We choose to show/hide links for rel="+jQuery(this).attr(\'rel\')+" so #"+jQuery(this).attr(\'rel\')+"list");
9275 jQuery("#"+jQuery(this).attr(\'rel\')+"list").toggle();
9299 public function selectyesno($htmlname, $value =
'', $option = 0, $disabled =
false, $useempty = 0, $addjscombo = 0, $morecss =
'', $labelyes =
'Yes', $labelno =
'No')
9310 $disabled = ($disabled ?
' disabled' :
'');
9312 $resultyesno =
'<select class="flat width75' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'"' . $disabled .
'>' .
"\n";
9314 $resultyesno .=
'<option value="-1"' . (($value < 0) ?
' selected' :
'') .
'> </option>' .
"\n";
9316 if ((
"$value" ==
'yes') || ($value == 1)) {
9317 $resultyesno .=
'<option value="' . $yes .
'" selected>' . $langs->trans($labelyes) .
'</option>' .
"\n";
9318 $resultyesno .=
'<option value="' . $no .
'">' . $langs->trans($labelno) .
'</option>' .
"\n";
9320 $selected = (($useempty && $value !=
'0' && $value !=
'no') ?
'' :
' selected');
9321 $resultyesno .=
'<option value="' . $yes .
'">' . $langs->trans($labelyes) .
'</option>' .
"\n";
9322 $resultyesno .=
'<option value="' . $no .
'"' . $selected .
'>' . $langs->trans($labelno) .
'</option>' .
"\n";
9324 $resultyesno .=
'</select>' .
"\n";
9327 $resultyesno .=
ajax_combobox($htmlname, array(), 0, 0,
'resolve', ($useempty < 0 ? (
string) $useempty :
'-1'), $morecss);
9330 return $resultyesno;
9347 $sql =
"SELECT rowid, label";
9348 $sql .=
" FROM " . $this->db->prefix() .
"export_model";
9349 $sql .=
" WHERE type = '" . $this->db->escape($type) .
"'";
9350 $sql .=
" ORDER BY rowid";
9351 $result = $this->db->query($sql);
9353 print
'<select class="flat" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
9355 print
'<option value="-1"> </option>';
9358 $num = $this->db->num_rows($result);
9361 $obj = $this->db->fetch_object($result);
9362 if ($selected == $obj->rowid) {
9363 print
'<option value="' . $obj->rowid .
'" selected>';
9365 print
'<option value="' . $obj->rowid .
'">';
9395 public function showrefnav($object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $morehtmlright =
'')
9397 global $conf, $langs, $hookmanager, $extralanguages;
9400 if (empty($fieldid)) {
9403 if (empty($fieldref)) {
9409 if (property_exists($object,
'gender') && !empty($object->gender)) {
9410 $addgendertxt =
' ';
9411 switch ($object->gender) {
9413 $addgendertxt .=
'<i class="fas fa-mars"></i>';
9416 $addgendertxt .=
'<i class="fas fa-venus"></i>';
9419 $addgendertxt .=
'<i class="fas fa-transgender"></i>';
9425 if (is_object($hookmanager)) {
9426 $parameters = array(
'showrefnav' =>
true);
9427 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
9428 $object->next_prev_filter .= $hookmanager->resPrint;
9430 $previous_ref = $next_ref =
'';
9433 $object->load_previous_next_ref((isset($object->next_prev_filter) ? $object->next_prev_filter :
''), $fieldid, $nodbprefix);
9435 $navurl = $_SERVER[
"PHP_SELF"];
9437 if ($paramid ==
'project_ref') {
9438 if (preg_match(
'/\/tasks\/(task|contact|note|document)\.php/', $navurl)) {
9439 $navurl = preg_replace(
'/\/tasks\/(task|contact|time|note|document)\.php/',
'/tasks.php', $navurl);
9446 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
9447 if ($conf->browser->name ==
'chrome') {
9448 $stringforfirstkey .=
' ALT +';
9449 } elseif ($conf->browser->name ==
'firefox') {
9450 $stringforfirstkey .=
' ALT + SHIFT +';
9452 $stringforfirstkey .=
' CTL +';
9455 $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>';
9456 $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>';
9460 $ret .=
'<!-- Start banner content --><div style="vertical-align: middle">';
9463 if ($morehtmlright) {
9464 $ret .=
'<div class="inline-block floatleft">' . $morehtmlright .
'</div>';
9467 if ($previous_ref || $next_ref || $morehtml) {
9468 $ret .=
'<div class="pagination paginationref"><ul class="right">';
9471 $ret .=
'<li class="noborder litext' . (($shownav && $previous_ref && $next_ref) ?
' clearbothonsmartphone' :
'') .
'">' . $morehtml .
'</li>';
9473 if ($shownav && ($previous_ref || $next_ref)) {
9474 $ret .=
'<li class="pagination">' . $previous_ref .
'</li>';
9475 $ret .=
'<li class="pagination">' . $next_ref .
'</li>';
9477 if ($previous_ref || $next_ref || $morehtml) {
9478 $ret .=
'</ul></div>';
9482 $parameters = array();
9483 $reshook = $hookmanager->executeHooks(
'moreHtmlStatus', $parameters, $object);
9484 if (empty($reshook)) {
9485 $morehtmlstatus .= $hookmanager->resPrint;
9487 $morehtmlstatus = $hookmanager->resPrint;
9489 if ($morehtmlstatus) {
9490 $ret .=
'<div class="statusref">' . $morehtmlstatus .
'</div>';
9493 $parameters = array();
9494 $reshook = $hookmanager->executeHooks(
'moreHtmlRef', $parameters, $object);
9495 if (empty($reshook)) {
9496 $morehtmlref .= $hookmanager->resPrint;
9497 } elseif ($reshook > 0) {
9498 $morehtmlref = $hookmanager->resPrint;
9502 if ($morehtmlleft) {
9503 if ($conf->browser->layout ==
'phone') {
9504 $ret .=
'<!-- morehtmlleft --><div class="floatleft">' . $morehtmlleft .
'</div>';
9506 $ret .=
'<!-- morehtmlleft --><div class="inline-block floatleft">' . $morehtmlleft .
'</div>';
9511 $ret .=
'<div class="inline-block floatleft valignmiddle maxwidth750 marginbottomonly refid' . (($shownav && ($previous_ref || $next_ref)) ?
' refidpadding' :
'') .
'">';
9514 if ($object->element ==
'societe') {
9518 $arrayoflangcode = array();
9519 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) {
9520 $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
9523 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
9524 if (!is_object($extralanguages)) {
9525 include_once DOL_DOCUMENT_ROOT .
'/core/class/extralanguages.class.php';
9528 $extralanguages->fetch_name_extralanguages(
'societe');
9530 if (!empty($extralanguages->attributes[
'societe'][
'name'])) {
9531 $object->fetchValuesForExtraLanguages();
9535 foreach ($arrayoflangcode as $extralangcode) {
9537 if ($object->array_languages[
'name'][$extralangcode]) {
9538 $htmltext .= $object->array_languages[
'name'][$extralangcode];
9540 $htmltext .=
'<span class="opacitymedium">' . $langs->trans(
"SwitchInEditModeToAddTranslation") .
'</span>';
9543 $ret .=
'<!-- Show translations of name -->' .
"\n";
9544 $ret .= $this->
textwithpicto(
'', $htmltext, -1,
'language',
'opacitymedium paddingleft');
9547 } elseif ($object->element ==
'member') {
9548 $ret .= $object->ref .
'<br>';
9549 $fullname = $object->getFullName($langs);
9550 if ($object->morphy ==
'mor' && $object->societe) {
9551 $ret .=
dol_htmlentities($object->societe) . ((!empty($fullname) && $object->societe != $fullname) ?
' (' .
dol_htmlentities($fullname) . $addgendertxt .
')' :
'');
9553 $ret .=
dol_htmlentities($fullname) . $addgendertxt . ((!empty($object->societe) && $object->societe != $fullname) ?
' (' .
dol_htmlentities($object->societe) .
')' :
'');
9555 } elseif (in_array($object->element, array(
'contact',
'user'))) {
9557 } elseif ($object->element ==
'usergroup') {
9559 } elseif (in_array($object->element, array(
'action',
'agenda'))) {
9560 $ret .= $object->ref .
'<br>' . $object->label;
9561 } elseif (in_array($object->element, array(
'adherent_type'))) {
9562 $ret .= $object->label;
9563 } elseif ($object->element ==
'ecm_directories') {
9565 } elseif ($fieldref !=
'none') {
9566 $ret .=
dol_htmlentities(!empty($object->$fieldref) ? $object->$fieldref :
"");
9570 if (substr($morehtmlref, 0, 4) !=
'<div') {
9574 $ret .= $morehtmlref;
9579 $ret .=
'</div><!-- End banner content -->';
9598 if (empty($object->barcode)) {
9603 if (empty($object->barcode_type_code) || empty($object->barcode_type_coder)) {
9604 $result = $object->fetch_barcode();
9607 return '<!-- ErrorFetchBarcode -->';
9612 $url = DOL_URL_ROOT .
'/viewimage.php?modulepart=barcode&generator=' . urlencode($object->barcode_type_coder) .
'&code=' . urlencode($object->barcode) .
'&encoding=' . urlencode($object->barcode_type_code);
9613 $out =
'<!-- url barcode = ' . $url .
' -->';
9614 $out .=
'<img src="' . $url .
'"' . ($morecss ?
' class="' . $morecss .
'"' :
'') .
'>';
9635 public static function showphoto($modulepart, $object, $width = 100, $height = 0, $caneditfield = 0, $cssclass =
'photowithmargin', $imagesize =
'', $addlinktofullsize = 1, $cache = 0, $forcecapture =
'', $noexternsourceoverwrite = 0)
9637 global $conf, $langs;
9639 $entity = (!empty($object->entity) ? $object->entity : $conf->entity);
9640 $id = (!empty($object->id) ? $object->id : $object->rowid);
9649 if ($modulepart ==
'societe') {
9650 $dir = $conf->societe->multidir_output[$entity];
9651 if (!empty($object->logo)) {
9653 if ((
string) $imagesize ==
'mini') {
9655 } elseif ((
string) $imagesize ==
'small') {
9658 $file =
get_exdir(0, 0, 0, 0, $object,
'thirdparty') .
'logos/' . $object->logo;
9660 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'thirdparty') .
'logos/' . $object->logo;
9663 $email = $object->email;
9664 } elseif ($modulepart ==
'contact') {
9665 $dir = $conf->societe->multidir_output[$entity] .
'/contact';
9666 if (!empty($object->photo)) {
9668 if ((
string) $imagesize ==
'mini') {
9670 } elseif ((
string) $imagesize ==
'small') {
9673 $file =
get_exdir(0, 0, 0, 0, $object,
'contact') .
'photos/' . $object->photo;
9675 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'contact') .
'photos/' . $object->photo;
9678 $email = $object->email;
9680 } elseif ($modulepart ==
'userphoto') {
9681 $dir = $conf->user->dir_output;
9682 if (!empty($object->photo)) {
9684 if ((
string) $imagesize ==
'mini') {
9686 } elseif ((
string) $imagesize ==
'small') {
9689 $file =
get_exdir(0, 0, 0, 0, $object,
'user') .
'photos/' . $object->photo;
9691 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'user') .
'photos/' . $object->photo;
9694 if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
9695 $altfile = $object->id .
".jpg";
9697 $email = $object->email;
9699 } elseif ($modulepart ==
'memberphoto') {
9700 $dir = $conf->adherent->dir_output;
9701 if (!empty($object->photo)) {
9703 if ((
string) $imagesize ==
'mini') {
9705 } elseif ((
string) $imagesize ==
'small') {
9708 $file =
get_exdir(0, 0, 0, 0, $object,
'member') .
'photos/' . $object->photo;
9710 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'member') .
'photos/' . $object->photo;
9713 if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
9714 $altfile = $object->id .
".jpg";
9716 $email = $object->email;
9720 $dir = $conf->$modulepart->dir_output;
9721 if (!empty($object->photo)) {
9723 if ((
string) $imagesize ==
'mini') {
9725 } elseif ((
string) $imagesize ==
'small') {
9728 $file =
get_exdir($id, 2, 0, 0, $object, $modulepart) .
'photos/' . $object->photo;
9730 $originalfile =
get_exdir($id, 2, 0, 0, $object, $modulepart) .
'photos/' . $object->photo;
9733 if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) {
9734 $altfile = $object->id .
".jpg";
9736 $email = $object->email;
9739 if ($forcecapture) {
9740 $capture = $forcecapture;
9744 if ($file && file_exists($dir .
"/" . $file)) {
9745 if ($addlinktofullsize) {
9748 $ret .=
'<a href="' . $urladvanced .
'">';
9750 $ret .=
'<a href="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($originalfile) .
'&cache=' . $cache .
'">';
9753 $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 .
'">';
9754 if ($addlinktofullsize) {
9757 } elseif ($altfile && file_exists($dir .
"/" . $altfile)) {
9758 if ($addlinktofullsize) {
9761 $ret .=
'<a href="' . $urladvanced .
'">';
9763 $ret .=
'<a href="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($originalfile) .
'&cache=' . $cache .
'">';
9766 $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 .
'">';
9767 if ($addlinktofullsize) {
9771 $nophoto =
'/public/theme/common/nophoto.png';
9772 $defaultimg =
'identicon';
9773 if (in_array($modulepart, array(
'societe',
'userphoto',
'contact',
'memberphoto'))) {
9774 if ($modulepart ==
'societe' || ($modulepart ==
'memberphoto' && !empty($object->morphy) && strpos($object->morphy,
'mor')) !==
false) {
9775 $nophoto =
'company';
9777 $nophoto =
'/public/theme/common/user_anonymous.png';
9778 if (!empty($object->gender) && $object->gender ==
'man') {
9779 $nophoto =
'/public/theme/common/user_man.png';
9781 if (!empty($object->gender) && $object->gender ==
'woman') {
9782 $nophoto =
'/public/theme/common/user_woman.png';
9787 if (isModEnabled(
'gravatar') && $email && empty($noexternsourceoverwrite)) {
9789 $ret .=
'<!-- Put link to gravatar -->';
9790 $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 .
'">';
9792 if ($nophoto ==
'company') {
9793 $ret .=
'<div class="divforspanimg photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
'>' .
img_picto(
'',
'company') .
'</div>';
9794 $ret .=
'<div class="difforspanimgright"></div>';
9796 $ret .=
'<img class="photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
' src="' . DOL_URL_ROOT . $nophoto .
'">';
9801 if ($caneditfield) {
9802 if ($object->photo) {
9805 $ret .=
'<table class="nobordernopadding centpercent">';
9806 if ($object->photo) {
9807 $ret .=
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">' . $langs->trans(
"Delete") .
'</label><br><br></td></tr>';
9809 $ret .=
'<tr><td class="tdoverflow">';
9811 $maxmin = $maxfilesizearray[
'maxmin'];
9813 $ret .=
'<input type="hidden" name="MAX_FILE_SIZE" value="' . ($maxmin * 1024) .
'">';
9815 $ret .=
'<input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"' . ($capture ?
' capture="' . $capture .
'"' :
'') .
'>';
9816 $ret .=
'</td></tr>';
9842 public function select_dolgroups($selected =
'', $htmlname =
'groupid', $show_empty = 0, $exclude =
'', $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0', $multiple =
false, $morecss =
'')
9845 global $conf, $user, $langs;
9848 $excludeGroups =
null;
9849 if (is_array($exclude)) {
9850 $excludeGroups = implode(
",", $exclude);
9853 $includeGroups =
null;
9854 if (is_array($include)) {
9855 $includeGroups = implode(
",", $include);
9858 if (!is_array($selected)) {
9859 $selected = array($selected);
9865 $sql =
"SELECT ug.rowid, ug.nom as name";
9866 if (isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
9867 $sql .=
", e.label";
9869 $sql .=
" FROM " . $this->db->prefix() .
"usergroup as ug ";
9870 if (isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
9871 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entity as e ON e.rowid=ug.entity";
9872 if ($force_entity) {
9873 $sql .=
" WHERE ug.entity IN (0, " . $force_entity .
")";
9875 $sql .=
" WHERE ug.entity IS NOT NULL";
9878 $sql .=
" WHERE ug.entity IN (0, " . $conf->entity .
")";
9880 if (is_array($exclude) && $excludeGroups) {
9881 $sql .=
" AND ug.rowid NOT IN (" . $this->db->sanitize($excludeGroups) .
")";
9883 if (is_array($include) && $includeGroups) {
9884 $sql .=
" AND ug.rowid IN (" . $this->db->sanitize($includeGroups) .
")";
9886 $sql .=
" ORDER BY ug.nom ASC";
9888 dol_syslog(get_class($this) .
"::select_dolgroups", LOG_DEBUG);
9889 $resql = $this->db->query($sql);
9892 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
9894 $out .=
'<select class="flat minwidth200' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
' ' . ($disabled ?
' disabled' :
'') .
'>';
9896 $num = $this->db->num_rows($resql);
9899 if ($show_empty && !$multiple) {
9900 $out .=
'<option value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'> </option>' .
"\n";
9904 $obj = $this->db->fetch_object($resql);
9906 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
9910 $label = $obj->name;
9911 $labelhtml = $obj->name;
9912 if (isModEnabled(
'multicompany') && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) {
9913 $label .=
" (" . $obj->label .
")";
9914 $labelhtml .=
' <span class="opacitymedium">(' . $obj->label .
')</span>';
9917 $out .=
'<option value="' . $obj->rowid .
'"';
9919 $out .=
' disabled';
9921 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))) {
9922 $out .=
' selected';
9924 $out .=
' data-html="'.dol_escape_htmltag($labelhtml).
'"';
9929 $out .=
'</option>';
9934 $out .=
'<option value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'></option>' .
"\n";
9936 $out .=
'<option value="" disabled>' . $langs->trans(
"NoUserGroupDefined") .
'</option>';
9938 $out .=
'</select>';
9957 $out =
'<div class="nowraponall">';
9958 if ($pos ==
'left') {
9959 $out .=
'<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
9960 $out .=
'<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fa fa-remove"></span></button>';
9962 $out .=
'<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
9963 $out .=
'<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fa fa-remove"></span></button>';
9978 public function showCheckAddButtons($cssclass =
'checkforaction', $calljsfunction = 0, $massactionname =
"massaction")
9980 global $conf, $langs;
9984 if (!empty($conf->use_javascript_ajax)) {
9985 $out .=
'<div class="inline-block checkallactions"><input type="checkbox" id="' . $cssclass .
's" name="' . $cssclass .
's" class="checkallactions"></div>';
9987 $out .=
'<script nonce="' .
getNonce() .
'">
9988 $(document).ready(function() {
9989 $("#' . $cssclass .
's").click(function() {
9990 if($(this).is(\':checked\')){
9991 console.log("We check all ' . $cssclass .
' and trigger the change method");
9992 $(".' . $cssclass .
'").prop(\'checked\', true).trigger(\'change\');
9996 console.log("We uncheck all");
9997 $(".' . $cssclass .
'").prop(\'checked\', false).trigger(\'change\');
9999 if ($calljsfunction) {
10000 $out .=
'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "' . $massactionname .
'", "' . $cssclass .
'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
10003 $(".' . $cssclass .
'").change(function() {
10004 $(this).closest("tr").toggleClass("highlight", this.checked);
10024 if ($addcheckuncheckall) {
10043 public function selectExpenseCategories($selected =
'', $htmlname =
'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target =
'', $default_selected = 0, $params = array(), $info_admin = 1)
10045 global $langs, $user;
10048 $sql =
"SELECT rowid, label FROM " . $this->db->prefix() .
"c_exp_tax_cat WHERE active = 1";
10049 $sql .=
" AND entity IN (0," .
getEntity(
'exp_tax_cat') .
")";
10050 if (!empty($excludeid)) {
10051 $sql .=
" AND rowid NOT IN (" . $this->db->sanitize(implode(
',', $excludeid)) .
")";
10053 $sql .=
" ORDER BY label";
10055 $resql = $this->db->query($sql);
10057 $out =
'<select id="select_' . $htmlname .
'" name="' . $htmlname .
'" class="' . $htmlname .
' flat minwidth75imp maxwidth200">';
10059 $out .=
'<option value="0"> </option>';
10062 while ($obj = $this->db->fetch_object($resql)) {
10063 $out .=
'<option ' . ($selected == $obj->rowid ?
'selected="selected"' :
'') .
' value="' . $obj->rowid .
'">' . $langs->trans($obj->label) .
'</option>';
10065 $out .=
'</select>';
10068 if (!empty($htmlname) && $user->admin && $info_admin) {
10069 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
10072 if (!empty($target)) {
10073 $sql =
"SELECT c.id FROM " . $this->db->prefix() .
"c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1";
10074 $resql = $this->db->query($sql);
10076 if ($this->db->num_rows($resql) > 0) {
10077 $obj = $this->db->fetch_object($resql);
10078 $out .=
'<script nonce="' .
getNonce() .
'">
10080 $("select[name=' . $target .
']").on("change", function() {
10081 var current_val = $(this).val();
10082 if (current_val == ' . $obj->id .
') {';
10083 if (!empty($default_selected) || !empty($selected)) {
10084 $out .=
'$("select[name=' . $htmlname .
']").val("' . ($default_selected > 0 ? $default_selected : $selected) .
'");';
10088 $("select[name=' . $htmlname .
']").change();
10092 $("select[name=' . $htmlname .
']").change(function() {
10094 if ($("select[name=' . $target .
']").val() == ' . $obj->id .
') {
10095 // get price of kilometer to fill the unit price
10099 data: { fk_c_exp_tax_cat: $(this).val(), token: \'' .
currentToken() .
'\' },
10100 url:
"' . (DOL_URL_ROOT . '/expensereport/ajax/ajaxik.php?' . join('&', $params)) . '",
10101 }).done(
function( data, textStatus, jqXHR ) {
10103 if (typeof data.up !=
"undefined") {
10104 $(
"input[name=value_unit]").val(data.up);
10105 $(
"select[name=' . $htmlname . ']").attr(
"title", data.title);
10107 $(
"input[name=value_unit]").val(
"");
10108 $(
"select[name=' . $htmlname . ']").attr(
"title",
"");
10119 dol_print_error($this->db);
10133 public function selectExpenseRanges($selected = '
', $htmlname = 'fk_range
', $useempty = 0)
10135 global $conf, $langs;
10138 $sql = "SELECT rowid, range_ik FROM " . $this->db->prefix() . "c_exp_tax_range";
10139 $sql .= " WHERE entity = " . $conf->entity . " AND active = 1";
10141 $resql = $this->db->query($sql);
10143 $out = '<select
id=
"select_' . $htmlname . '" name=
"' . $htmlname . '" class=
"' . $htmlname . ' flat minwidth75imp">
';
10145 $out .= '<option value=
"0"></option>
';
10148 while ($obj = $this->db->fetch_object($resql)) {
10149 $out .= '<option
' . ($selected == $obj->rowid ? 'selected=
"selected"' : '') . ' value=
"' . $obj->rowid . '">
' . price($obj->range_ik, 0, $langs, 1, 0) . '</option>
';
10151 $out .= '</select>
';
10153 dol_print_error($this->db);
10169 public function selectExpense($selected = '
', $htmlname = 'fk_c_type_fees
', $useempty = 0, $allchoice = 1, $useid = 0)
10174 $sql = "SELECT id, code, label FROM " . $this->db->prefix() . "c_type_fees";
10175 $sql .= " WHERE active = 1";
10177 $resql = $this->db->query($sql);
10179 $out = '<select
id=
"select_' . $htmlname . '" name=
"' . $htmlname . '" class=
"' . $htmlname . ' flat minwidth75imp">
';
10181 $out .= '<option value=
"0"></option>
';
10184 $out .= '<option value=
"-1">
' . $langs->trans('AllExpenseReport
') . '</option>
';
10192 while ($obj = $this->db->fetch_object($resql)) {
10193 $key = $langs->trans($obj->code);
10194 $out .= '<option
' . ($selected == $obj->{$field} ? 'selected=
"selected"' : '') . ' value=
"' . $obj->{$field} . '">
' . ($key != $obj->code ? $key : $obj->label) . '</option>
';
10196 $out .= '</select>
';
10198 dol_print_error($this->db);
10222 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)
10224 global $user, $conf, $langs;
10226 require_once DOL_DOCUMENT_ROOT . '/projet/
class/project.class.php
';
10228 if (is_null($usertofilter)) {
10229 $usertofilter = $user;
10234 $hideunselectables = false;
10235 if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) {
10236 $hideunselectables = true;
10239 if (empty($projectsListId)) {
10240 if (empty($usertofilter->rights->projet->all->lire)) {
10241 $projectstatic = new Project($this->db);
10242 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
10246 // Search all projects
10247 $sql = "SELECT f.rowid, f.ref as fref, 'nolabel
' as flabel, p.rowid as pid, f.ref,
10248 p.title, p.fk_soc, p.fk_statut, p.public,";
10249 $sql .= ' s.nom as
name';
10250 $sql .= ' FROM
' . $this->db->prefix() . 'projet as p
';
10251 $sql .= ' LEFT JOIN
' . $this->db->prefix() . 'societe as s ON s.rowid = p.fk_soc,
';
10252 $sql .= ' ' . $this->db->prefix() . 'facture as f
';
10253 $sql .= " WHERE p.entity IN (" . getEntity('project
') . ")";
10254 $sql .= " AND f.fk_projet = p.rowid AND f.fk_statut=0"; //Brouillons seulement
10255 //if ($projectsListId) $sql.= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")";
10256 //if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
10257 //if ($socid > 0) $sql.= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)";
10258 $sql .= " ORDER BY p.ref, f.ref ASC";
10260 $resql = $this->db->query($sql);
10262 // Use select2 selector
10263 if (!empty($conf->use_javascript_ajax)) {
10264 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php
';
10265 $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
10266 $out .= $comboenhancement;
10267 $morecss = 'minwidth200imp maxwidth500
';
10270 if (empty($option_only)) {
10271 $out .= '<select
class=
"valignmiddle flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled=
"disabled"' : '') . ' id=
"' . $htmlname . '" name=
"' . $htmlname . '">
';
10273 if (!empty($show_empty)) {
10274 $out .= '<option value=
"0" class=
"optiongrey">
';
10275 if (!is_numeric($show_empty)) {
10276 $out .= $show_empty;
10280 $out .= '</option>
';
10282 $num = $this->db->num_rows($resql);
10285 while ($i < $num) {
10286 $obj = $this->db->fetch_object($resql);
10287 // 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.
10288 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($usertofilter->rights->societe->lire)) {
10291 if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED) {
10298 if ($showproject == 'all
') {
10299 $labeltoshow .= dol_trunc($obj->ref, 18); // Invoice ref
10301 $labeltoshow .= ' -
' . $obj->name; // Soc name
10305 if ($obj->fk_statut == Project::STATUS_DRAFT) {
10307 $labeltoshow .= ' -
' . $langs->trans("Draft");
10308 } elseif ($obj->fk_statut == Project::STATUS_CLOSED) {
10309 if ($discard_closed == 2) {
10312 $labeltoshow .= ' -
' . $langs->trans("Closed");
10313 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
10315 $labeltoshow .= ' -
' . $langs->trans("LinkedToAnotherCompany");
10319 if (!empty($selected) && $selected == $obj->rowid) {
10320 $out .= '<option value=
"' . $obj->rowid . '" selected
';
10321 //if ($disabled) $out.=' disabled
'; // with select2, field can't be preselected
if disabled
10322 $out .=
'>' . $labeltoshow .
'</option>';
10324 if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
10327 $resultat =
'<option value="' . $obj->rowid .
'"';
10329 $resultat .=
' disabled';
10334 $resultat .= $labeltoshow;
10335 $resultat .=
'</option>';
10343 if (empty($option_only)) {
10344 $out .=
'</select>';
10347 $this->db->free($resql);
10369 public function selectInvoiceRec($selected =
'', $htmlname =
'facrecid', $maxlength = 24, $option_only = 0, $show_empty =
'1', $forcefocus = 0, $disabled = 0, $morecss =
'maxwidth500')
10371 global $user, $conf, $langs;
10377 $sql =
'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc';
10379 $sql .=
' FROM ' . MAIN_DB_PREFIX .
'facture_rec as f';
10380 $sql .=
" WHERE f.entity IN (" .
getEntity(
'invoice') .
")";
10381 $sql .=
" ORDER BY f.titre ASC";
10383 $resql = $this->db->query($sql);
10386 if (!empty($conf->use_javascript_ajax)) {
10387 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
10388 $comboenhancement =
ajax_combobox($htmlname,
'', 0, $forcefocus);
10389 $out .= $comboenhancement;
10390 $morecss =
'minwidth200imp maxwidth500';
10393 if (empty($option_only)) {
10394 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' id="' . $htmlname .
'" name="' . $htmlname .
'">';
10396 if (!empty($show_empty)) {
10397 $out .=
'<option value="0" class="optiongrey">';
10398 if (!is_numeric($show_empty)) {
10399 $out .= $show_empty;
10403 $out .=
'</option>';
10405 $num = $this->db->num_rows($resql);
10407 while ($obj = $this->db->fetch_object($resql)) {
10408 $labeltoshow =
dol_trunc($obj->title, 18);
10411 if (!empty($obj->suspended)) {
10413 $labeltoshow .=
' - ' . $langs->trans(
"Closed");
10417 if (!empty($selected) && $selected == $obj->rowid) {
10418 $out .=
'<option value="' . $obj->rowid .
'" selected';
10420 $out .=
'>' . $labeltoshow .
'</option>';
10422 if ($disabled && ($selected != $obj->rowid)) {
10425 $resultat =
'<option value="' . $obj->rowid .
'"';
10427 $resultat .=
' disabled';
10430 $resultat .= $labeltoshow;
10431 $resultat .=
'</option>';
10437 if (empty($option_only)) {
10438 $out .=
'</select>';
10443 $this->db->free($resql);
10446 $this->errors[] = $this->db->lasterror;
10460 public function searchComponent($arrayofcriterias, $search_component_params, $arrayofinputfieldsalreadyoutput = array(), $search_component_params_hidden =
'')
10464 if ($search_component_params_hidden !=
'' && !preg_match(
'/^\(.*\)$/', $search_component_params_hidden)) {
10465 $search_component_params_hidden =
'(' . $search_component_params_hidden .
')';
10470 $ret .=
'<div class="divadvancedsearchfieldcomp inline-block">';
10471 $ret .=
'<a href="#" class="dropdownsearch-toggle unsetcolor">';
10472 $ret .=
'<span class="fas fa-filter linkobject boxfilter paddingright pictofixedwidth" title="' .
dol_escape_htmltag($langs->trans(
"Filters")) .
'" id="idsubimgproductdistribution"></span>';
10475 $ret .=
'<div class="divadvancedsearchfieldcompinput inline-block minwidth500 maxwidth300onsmartphone">';
10478 $ret .=
'<div name="divsearch_component_params" class="noborderbottom search_component_params inline-block valignmiddle">';
10480 if ($search_component_params_hidden) {
10484 $nbofchars =
dol_strlen($search_component_params_hidden);
10485 $arrayofandtags = array();
10487 $countparenthesis = 0;
10488 while ($i < $nbofchars) {
10489 $char =
dol_substr($search_component_params_hidden, $i, 1);
10491 if ($char ==
'(') {
10492 $countparenthesis++;
10493 } elseif ($char ==
')') {
10494 $countparenthesis--;
10497 if ($countparenthesis == 0) {
10498 $char2 =
dol_substr($search_component_params_hidden, $i+1, 1);
10499 $char3 =
dol_substr($search_component_params_hidden, $i+2, 1);
10500 if ($char ==
'A' && $char2 ==
'N' && $char3 ==
'D') {
10502 $arrayofandtags[] = trim($s);
10514 $arrayofandtags[] = trim($s);
10518 foreach ($arrayofandtags as $tmpkey => $tmpval) {
10519 $errormessage =
'';
10521 if ($errormessage) {
10522 $this->error =
'ERROR in parsing search string: '.$errormessage;
10525 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
10528 $ret .=
'<span class="marginleftonlyshort valignmiddle tagsearch" data-ufilterid="'.($tmpkey+1).
'" data-ufilter="'.
dol_escape_htmltag($tmpval).
'">';
10529 $ret .=
'<span class="tagsearchdelete select2-selection__choice__remove" data-ufilterid="'.($tmpkey+1).
'">x</span> ';
10541 $show_search_component_params_hidden = 1;
10542 if ($show_search_component_params_hidden) {
10543 $ret .=
'<input type="hidden" name="show_search_component_params_hidden" value="1">';
10545 $ret .=
"<!-- We store the full Universal Search String into this field. For example: (t.ref:like:'SO-%') AND ((t.ref:like:'CO-%') OR (t.ref:like:'AA%')) -->";
10546 $ret .=
'<input type="hidden" name="search_component_params_hidden" value="' .
dol_escape_htmltag($search_component_params_hidden) .
'">';
10550 foreach ($arrayofcriterias as $criterias) {
10551 foreach ($criterias as $criteriafamilykey => $criteriafamilyval) {
10552 if (in_array(
'search_' . $criteriafamilykey, $arrayofinputfieldsalreadyoutput)) {
10555 if (in_array($criteriafamilykey, array(
'rowid',
'ref_ext',
'entity',
'extraparams'))) {
10558 if (in_array($criteriafamilyval[
'type'], array(
'date',
'datetime',
'timestamp'))) {
10559 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_start">';
10560 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startyear">';
10561 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startmonth">';
10562 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startday">';
10563 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_end">';
10564 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endyear">';
10565 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endmonth">';
10566 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endday">';
10568 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'">';
10575 $ret .=
"<!-- Field to enter a 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";
10576 $ret .=
'<input type="text" placeholder="' . $langs->trans(
"Search") .
'" name="search_component_params_input" class="noborderbottom search_component_input" value="">';
10582 jQuery(".tagsearchdelete").click(function() {
10583 var filterid = $(this).parents().data("ufilterid");
10584 console.log("We click to delete a criteria nb "+filterid);
10585 // TODO Update the search_component_params_hidden with all data-ufilter except the one delete and post page
10606 global $langs, $user;
10610 $TModels = array();
10612 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
10613 $formmail =
new FormMail($this->db);
10614 $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs);
10617 $TModels[0] = $langs->trans(
'DefaultMailModel');
10620 foreach ($formmail->lines_model as $model) {
10621 $TModels[$model->id] = $model->label;
10625 $retstring .=
'<select class="flat" id="select_' . $prefix .
'model_mail" name="' . $prefix .
'model_mail">';
10627 foreach ($TModels as $id_model => $label_model) {
10628 $retstring .=
'<option value="' . $id_model .
'"';
10629 $retstring .=
">" . $label_model .
"</option>";
10632 $retstring .=
"</select>";
10635 $retstring .=
ajax_combobox(
'select_' . $prefix .
'model_mail');
10652 public function buttonsSaveCancel($save_label =
'Save', $cancel_label =
'Cancel', $morebuttons = array(), $withoutdiv = 0, $morecss =
'', $dol_openinpopup =
'')
10656 $buttons = array();
10660 'label_key' => $save_label,
10663 if ($save_label ==
'Create' || $save_label ==
'Add') {
10664 $save[
'name'] =
'add';
10665 } elseif ($save_label ==
'Modify') {
10666 $save[
'name'] =
'edit';
10670 'name' =>
'cancel',
10671 'label_key' =>
'Cancel',
10674 !empty($save_label) ? $buttons[] = $save :
'';
10676 if (!empty($morebuttons)) {
10677 $buttons[] = $morebuttons;
10680 !empty($cancel_label) ? $buttons[] = $cancel :
'';
10682 $retstring = $withoutdiv ?
'' :
'<div class="center">';
10684 foreach ($buttons as $button) {
10685 $addclass = empty($button[
'addclass']) ?
'' : $button[
'addclass'];
10686 $retstring .=
'<input type="submit" class="button button-' . $button[
'name'] . ($morecss ?
' ' . $morecss :
'') .
' ' . $addclass .
'" name="' . $button[
'name'] .
'" value="' .
dol_escape_htmltag($langs->trans($button[
'label_key'])) .
'">';
10688 $retstring .= $withoutdiv ?
'' :
'</div>';
10690 if ($dol_openinpopup) {
10691 $retstring .=
'<!-- buttons are shown into a $dol_openinpopup=' . $dol_openinpopup .
' context, so we enable the close of dialog on cancel -->' .
"\n";
10692 $retstring .=
'<script nonce="' .
getNonce() .
'">';
10693 $retstring .=
'jQuery(".button-cancel").click(function(e) {
10694 e.preventDefault(); console.log(\'We click on cancel in iframe popup ' . $dol_openinpopup .
'\');
10695 window.parent.jQuery(\
'#idfordialog' . $dol_openinpopup .
'\').dialog(\
'close\');
10697 $retstring .=
'</script>';
ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array(), $moreparams='')
Generic function that return javascript to add to a page to transform a common input field into an au...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
ajax_multiautocompleter($htmlname, $fields, $url, $option='', $minLength=2, $autoselect=0)
Generic function that return javascript to add to a page to transform a common input field into an au...
ajax_event($htmlname, $events)
Add event management script.
Class to manage bank accounts.
Class to manage categories.
Class to manage a WYSIWYG editor.
const STATUS_OPEN_INTERNAL
Warehouse open and only operations for stock transfers/corrections allowed (not for customer shipping...
const STATUS_OPEN_ALL
Warehouse open and any operations are allowed (customer shipping, supplier dispatch,...
const STATUS_CLOSED
Warehouse closed, inactive.
Class to manage invoices.
Class to parse product price expressions.
Class to manage predefined suppliers products.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
currency_name($code_iso, $withcode='', $outputlangs=null)
Return label of currency or code+label.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
getServerTimeZoneInt($refgmtdate='now')
Return server timezone int.
removeGlobalParenthesis($string)
Remove first and last parenthesis but only if first is the opening and last the closing of the same g...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0)
Format phone numbers according to country.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0)
Clean a string to keep only desirable HTML tags.
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...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea'), $cleanalsosomestyles=0)
Clean a string from some undesirable HTML tags.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='')
Return URL we can use for advanced preview links.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolIsAllowedForPreview($file)
Return if a file is qualified for preview.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
dol_print_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='float')
Show Url link.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
getNonce()
Return a random string to be used as a nonce value for js.
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...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e rowid
testSqlAndScriptInject($val, $type)
Security: WAF layer for SQL Injection and XSS Injection (scripts) protection (Filters on GET,...
ui dialog ui datepicker calendar ui widget content ui state ui datepicker calendar ui widget header ui state ui datepicker calendar ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
getMaxFileSizeArray()
Return the max allowed for file upload.