70 public $errors = array();
79 public $cache_types_paiements = array();
80 public $cache_conditions_paiements = array();
81 public $cache_transport_mode = array();
82 public $cache_availability = array();
83 public $cache_demand_reason = array();
84 public $cache_types_fees = array();
85 public $cache_vatrates = array();
86 public $cache_invoice_subtype = array();
115 public function editfieldkey($text, $htmlname, $preselected,
$object, $perm, $typeofdata =
'string', $moreparam =
'', $fieldrequired = 0, $notabletag = 0, $paramid =
'id', $help =
'')
122 if (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE') && !preg_match(
'/^select;/', $typeofdata)) {
124 $tmp = explode(
':', $typeofdata);
125 $ret .=
'<div class="editkey_' . $tmp[0] . (!empty($tmp[1]) ?
' ' . $tmp[1] :
'') .
'" id="' . $htmlname .
'">';
126 if ($fieldrequired) {
127 $ret .=
'<span class="fieldrequired">';
132 $ret .= $langs->trans($text);
134 if ($fieldrequired) {
137 $ret .=
'</div>' .
"\n";
139 if ($fieldrequired) {
140 $ret .=
'<span class="fieldrequired">';
145 $ret .= $langs->trans($text);
147 if ($fieldrequired) {
152 if (empty($notabletag) && $perm) {
153 $ret .=
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
155 if ($fieldrequired) {
156 $ret .=
'<span class="fieldrequired">';
161 $ret .= $langs->trans($text);
163 if ($fieldrequired) {
166 if (!empty($notabletag)) {
169 if (empty($notabletag) && $perm) {
172 if (empty($notabletag) && $perm) {
173 $ret .=
'<td class="right">';
175 if ($htmlname &&
GETPOST(
'action',
'aZ09') !=
'edit' . $htmlname && $perm) {
176 $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>';
178 if (!empty($notabletag) && $notabletag == 1) {
185 if (!empty($notabletag) && $notabletag == 3) {
188 if (empty($notabletag) && $perm) {
191 if (empty($notabletag) && $perm) {
192 $ret .=
'</tr></table>';
222 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 =
'')
224 global $conf, $langs;
229 if (empty($typeofdata)) {
230 return 'ErrorBadParameter typeofdata is empty';
233 if ($typeofdata ==
'datetime') {
234 $typeofdata =
'dayhour';
237 if (preg_match(
'/^(\w+)\((\d+)\)$/', $typeofdata, $reg)) {
238 if ($reg[1] ==
'varchar') {
239 $typeofdata =
'string';
240 } elseif ($reg[1] ==
'int') {
241 $typeofdata =
'numeric';
243 return 'ErrorBadParameter ' . $typeofdata;
248 if (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE') && !preg_match(
'/^select;|day|datepicker|dayhour|datehourpicker/', $typeofdata)) {
249 $ret .= $this->
editInPlace(
$object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg);
251 if ($editaction ==
'') {
252 $editaction =
GETPOST(
'action',
'aZ09');
254 $editmode = ($editaction ==
'edit' . $htmlname);
257 $ret .=
'<form method="post" action="' . $_SERVER[
"PHP_SELF"] . ($moreparam ?
'?' . $moreparam :
'') .
'">';
258 $ret .=
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
259 $ret .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
260 $ret .=
'<input type="hidden" name="' . $paramid .
'" value="' .
$object->id .
'">';
261 if (empty($notabletag)) {
262 $ret .=
'<table class="nobordernopadding centpercent">';
264 if (empty($notabletag)) {
267 if (preg_match(
'/^(string|safehtmlstring|email|phone|url)/', $typeofdata)) {
268 $tmp = explode(
':', $typeofdata);
269 $ret .=
'<input type="text" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . ($editvalue ? $editvalue : $value) .
'"' . (empty($tmp[1]) ?
'' :
' size="' . $tmp[1] .
'"') .
' autofocus>';
270 } elseif (preg_match(
'/^(integer)/', $typeofdata)) {
271 $tmp = explode(
':', $typeofdata);
272 $valuetoshow =
price2num($editvalue ? $editvalue : $value, 0);
273 $ret .=
'<input type="text" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $valuetoshow .
'"' . (empty($tmp[1]) ?
'' :
' size="' . $tmp[1] .
'"') .
' autofocus>';
274 } elseif (preg_match(
'/^(numeric|amount)/', $typeofdata)) {
275 $tmp = explode(
':', $typeofdata);
276 $valuetoshow =
price2num($editvalue ? $editvalue : $value);
277 $ret .=
'<input type="text" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . ($valuetoshow !=
'' ?
price($valuetoshow) :
'') .
'"' . (empty($tmp[1]) ?
'' :
' size="' . $tmp[1] .
'"') .
' autofocus>';
278 } elseif (preg_match(
'/^(checkbox)/', $typeofdata)) {
279 $tmp = explode(
':', $typeofdata);
280 $ret .=
'<input type="checkbox" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . ($value ? $value :
'on') .
'"' . ($value ?
' checked' :
'') . (empty($tmp[1]) ?
'' : $tmp[1]) .
'/>';
281 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) {
282 $tmp = explode(
':', $typeofdata);
283 $cols = (empty($tmp[2]) ?
'' : $tmp[2]);
285 if (preg_match(
'/%/', $cols)) {
286 $morealt =
' style="width: ' . $cols .
'"';
289 $valuetoshow = ($editvalue ? $editvalue : $value);
290 $ret .=
'<textarea id="' . $htmlname .
'" name="' . $htmlname .
'" wrap="soft" rows="' . (empty($tmp[1]) ?
'20' : $tmp[1]) .
'"' . ($cols ?
' cols="' . $cols .
'"' :
'class="quatrevingtpercent"') . $morealt .
'" autofocus>';
293 $valuetoshow = str_replace(
'&',
'&', $valuetoshow);
295 $ret .=
'</textarea><div class="clearboth"></div>';
296 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') {
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, 0, 0, 1,
'form' . $htmlname, 1, $addnowlink, 0,
'',
'', $adddateof,
'', 1, $labeladddateof,
'', $gm);
301 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') {
302 $addnowlink = empty($moreoptions[
'addnowlink']) ? 0 : $moreoptions[
'addnowlink'];
303 $adddateof = empty($moreoptions[
'adddateof']) ?
'' : $moreoptions[
'adddateof'];
304 $labeladddateof = empty($moreoptions[
'labeladddateof']) ?
'' : $moreoptions[
'labeladddateof'];
305 $ret .= $this->
selectDate($value, $htmlname, 1, 1, 1,
'form' . $htmlname, 1, $addnowlink, 0,
'',
'', $adddateof,
'', 1, $labeladddateof,
'', $gm);
306 } elseif (preg_match(
'/^select;/', $typeofdata)) {
307 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
308 $arraylist = array();
309 foreach ($arraydata as $val) {
310 $tmp = explode(
':', $val);
311 $tmpkey = str_replace(
'|',
':', $tmp[0]);
312 $arraylist[$tmpkey] = $tmp[1];
314 $ret .= $this->
selectarray($htmlname, $arraylist, $value);
315 } elseif (preg_match(
'/^link/', $typeofdata)) {
317 } elseif (preg_match(
'/^ckeditor/', $typeofdata)) {
318 $tmp = explode(
':', $typeofdata);
319 require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
320 $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]));
321 $ret .= $doleditor->Create(1);
322 } elseif ($typeofdata ==
'asis') {
323 $ret .= ($editvalue ? $editvalue : $value);
325 if (empty($notabletag)) {
330 if (empty($notabletag)) {
334 $ret .=
'<input type="submit" class="smallpaddingimp button' . (empty($notabletag) ?
'' :
' ') .
'" name="modify" value="' . $langs->trans(
"Modify") .
'">';
335 if (preg_match(
'/ckeditor|textarea/', $typeofdata) && empty($notabletag)) {
336 $ret .=
'<br>' .
"\n";
338 $ret .=
'<input type="submit" class="smallpaddingimp button button-cancel' . (empty($notabletag) ?
'' :
' ') .
'" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
339 if (empty($notabletag)) {
343 if (empty($notabletag)) {
344 $ret .=
'</tr></table>' .
"\n";
346 $ret .=
'</form>' .
"\n";
348 if (preg_match(
'/^email/', $typeofdata)) {
350 } elseif (preg_match(
'/^phone/', $typeofdata)) {
352 } elseif (preg_match(
'/^url/', $typeofdata)) {
354 } elseif (preg_match(
'/^(amount|numeric)/', $typeofdata)) {
355 $ret .= ($value !=
'' ?
price($value, 0, $langs, 0, -1, -1, $conf->currency) :
'');
356 } elseif (preg_match(
'/^checkbox/', $typeofdata)) {
357 $tmp = explode(
':', $typeofdata);
358 $ret .=
'<input type="checkbox" disabled id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $value .
'"' . ($value ?
' checked' :
'') . ($tmp[1] ? $tmp[1] :
'') .
'/>';
359 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) {
361 } elseif (preg_match(
'/^(safehtmlstring|restricthtml)/', $typeofdata)) {
363 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') {
364 $ret .=
'<span class="valuedate">' .
dol_print_date($value,
'day', $gm) .
'</span>';
365 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') {
366 $ret .=
'<span class="valuedate">' .
dol_print_date($value,
'dayhour', $gm) .
'</span>';
367 } elseif (preg_match(
'/^select;/', $typeofdata)) {
368 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
369 $arraylist = array();
370 foreach ($arraydata as $val) {
371 $tmp = explode(
':', $val);
372 $arraylist[$tmp[0]] = $tmp[1];
374 $ret .= $arraylist[$value];
375 if ($htmlname ==
'fk_product_type') {
377 $ret =
img_picto($langs->trans(
"Product"),
'product',
'class="paddingleftonly paddingrightonly colorgrey"') . $ret;
379 $ret =
img_picto($langs->trans(
"Service"),
'service',
'class="paddingleftonly paddingrightonly colorgrey"') . $ret;
382 } elseif (preg_match(
'/^ckeditor/', $typeofdata)) {
385 $firstline = preg_replace(
'/<br>.*/',
'', $tmpcontent);
386 $firstline = preg_replace(
'/[\n\r].*/',
'', $firstline);
387 $tmpcontent = $firstline . ((strlen($firstline) != strlen($tmpcontent)) ?
'...' :
'');
393 if (empty($moreoptions[
'valuealreadyhtmlescaped'])) {
401 if ($formatfunc && method_exists(
$object, $formatfunc)) {
402 $ret =
$object->$formatfunc($ret);
422 global $conf, $langs, $extralanguages;
427 $arrayoflangcode = array();
432 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
433 if (!is_object($extralanguages)) {
434 include_once DOL_DOCUMENT_ROOT .
'/core/class/extralanguages.class.php';
437 $extralanguages->fetch_name_extralanguages(
'societe');
439 if (!is_array($extralanguages->attributes[
$object->element]) || empty($extralanguages->attributes[
$object->element][$fieldname])) {
443 $result .=
'<!-- Widget for translation -->' .
"\n";
444 $result .=
'<div class="inline-block paddingleft image-' .
$object->element .
'-' . $fieldname .
'">';
445 $s =
img_picto($langs->trans(
"ShowOtherLanguages"),
'language',
'',
false, 0, 0,
'',
'fa-15 editfieldlang');
449 $result .=
'<div class="inline-block hidden field-' .
$object->element .
'-' . $fieldname .
'">';
451 $resultforextrlang =
'';
452 foreach ($arrayoflangcode as $langcode) {
453 $valuetoshow = GETPOSTISSET(
'field-' .
$object->element .
"-" . $fieldname .
"-" . $langcode) ?
GETPOST(
'field-' .
$object->element .
'-' . $fieldname .
"-" . $langcode, $check) :
'';
454 if (empty($valuetoshow)) {
455 $object->fetchValuesForExtraLanguages();
457 $valuetoshow =
$object->array_languages[$fieldname][$langcode];
461 $resultforextrlang .= $s;
464 if ($typeofdata ==
'textarea') {
465 $resultforextrlang .=
'<textarea name="field-' .
$object->element .
"-" . $fieldname .
"-" . $langcode .
'" id="' . $fieldname .
"-" . $langcode .
'" class="' . $morecss .
'" rows="' . ROWS_2 .
'" wrap="soft">';
466 $resultforextrlang .= $valuetoshow;
467 $resultforextrlang .=
'</textarea>';
469 $resultforextrlang .=
'<input type="text" class="inputfieldforlang ' . ($morecss ?
' ' . $morecss :
'') .
'" name="field-' .
$object->element .
'-' . $fieldname .
'-' . $langcode .
'" value="' . $valuetoshow .
'">';
472 $result .= $resultforextrlang;
475 $result .=
'<script nonce="' .
getNonce() .
'">$(".image-' .
$object->element .
'-' . $fieldname .
'").click(function() { console.log("Toggle lang widget"); jQuery(".field-' .
$object->element .
'-' . $fieldname .
'").toggle(); });</script>';
494 protected function editInPlace(
$object, $value, $htmlname, $condition, $inputType =
'textarea', $editvalue =
null, $extObject =
null, $custommsg =
null)
499 if (preg_match(
'/^text/', $inputType)) {
501 } elseif (preg_match(
'/^numeric/', $inputType)) {
502 $value =
price($value);
503 } elseif ($inputType ==
'day' || $inputType ==
'datepicker') {
509 $table_element =
false;
513 $ext_element =
false;
514 $button_only =
false;
521 $table_element =
$object->table_element;
525 if (is_object($extObject)) {
526 $ext_element = $extObject->element;
529 if (preg_match(
'/^(string|email|numeric)/', $inputType)) {
530 $tmp = explode(
':', $inputType);
531 $inputType = $tmp[0];
532 if (!empty($tmp[1])) {
533 $inputOption = $tmp[1];
535 if (!empty($tmp[2])) {
536 $savemethod = $tmp[2];
538 $out .=
'<input id="width_' . $htmlname .
'" value="' . $inputOption .
'" type="hidden"/>' .
"\n";
539 } elseif ((preg_match(
'/^day$/', $inputType)) || (preg_match(
'/^datepicker/', $inputType)) || (preg_match(
'/^datehourpicker/', $inputType))) {
540 $tmp = explode(
':', $inputType);
541 $inputType = $tmp[0];
542 if (!empty($tmp[1])) {
543 $inputOption = $tmp[1];
545 if (!empty($tmp[2])) {
546 $savemethod = $tmp[2];
549 $out .=
'<input id="timestamp" type="hidden"/>' .
"\n";
550 } elseif (preg_match(
'/^(select|autocomplete)/', $inputType)) {
551 $tmp = explode(
':', $inputType);
552 $inputType = $tmp[0];
553 $loadmethod = $tmp[1];
554 if (!empty($tmp[2])) {
555 $savemethod = $tmp[2];
557 if (!empty($tmp[3])) {
560 } elseif (preg_match(
'/^textarea/', $inputType)) {
561 $tmp = explode(
':', $inputType);
562 $inputType = $tmp[0];
563 $rows = (empty($tmp[1]) ?
'8' : $tmp[1]);
564 $cols = (empty($tmp[2]) ?
'80' : $tmp[2]);
565 } elseif (preg_match(
'/^ckeditor/', $inputType)) {
566 $tmp = explode(
':', $inputType);
567 $inputType = $tmp[0];
569 if (!empty($tmp[2])) {
572 if (!empty($tmp[3])) {
575 if (!empty($tmp[4])) {
576 $savemethod = $tmp[4];
579 if (isModEnabled(
'fckeditor')) {
580 $out .=
'<input id="ckeditor_toolbar" value="' . $toolbar .
'" type="hidden"/>' .
"\n";
582 $inputType =
'textarea';
586 $out .=
'<input id="element_' . $htmlname .
'" value="' . $element .
'" type="hidden"/>' .
"\n";
587 $out .=
'<input id="table_element_' . $htmlname .
'" value="' . $table_element .
'" type="hidden"/>' .
"\n";
588 $out .=
'<input id="fk_element_' . $htmlname .
'" value="' . $fk_element .
'" type="hidden"/>' .
"\n";
589 $out .=
'<input id="loadmethod_' . $htmlname .
'" value="' . $loadmethod .
'" type="hidden"/>' .
"\n";
590 if (!empty($savemethod)) {
591 $out .=
'<input id="savemethod_' . $htmlname .
'" value="' . $savemethod .
'" type="hidden"/>' .
"\n";
593 if (!empty($ext_element)) {
594 $out .=
'<input id="ext_element_' . $htmlname .
'" value="' . $ext_element .
'" type="hidden"/>' .
"\n";
596 if (!empty($custommsg)) {
597 if (is_array($custommsg)) {
598 if (!empty($custommsg[
'success'])) {
599 $out .=
'<input id="successmsg_' . $htmlname .
'" value="' . $custommsg[
'success'] .
'" type="hidden"/>' .
"\n";
601 if (!empty($custommsg[
'error'])) {
602 $out .=
'<input id="errormsg_' . $htmlname .
'" value="' . $custommsg[
'error'] .
'" type="hidden"/>' .
"\n";
605 $out .=
'<input id="successmsg_' . $htmlname .
'" value="' . $custommsg .
'" type="hidden"/>' .
"\n";
608 if ($inputType ==
'textarea') {
609 $out .=
'<input id="textarea_' . $htmlname .
'_rows" value="' . $rows .
'" type="hidden"/>' .
"\n";
610 $out .=
'<input id="textarea_' . $htmlname .
'_cols" value="' . $cols .
'" type="hidden"/>' .
"\n";
612 $out .=
'<span id="viewval_' . $htmlname .
'" class="viewval_' . $inputType . ($button_only ?
' inactive' :
' active') .
'">' . $value .
'</span>' .
"\n";
613 $out .=
'<span id="editval_' . $htmlname .
'" class="editval_' . $inputType . ($button_only ?
' inactive' :
' active') .
' hideobject">' . (!empty($editvalue) ? $editvalue : $value) .
'</span>' .
"\n";
639 public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img =
'', $extracss =
'', $notabs = 3, $incbefore =
'', $noencodehtmltext = 0, $tooltiptrigger =
'', $forcenowrap = 0)
642 $text = $incbefore . $text;
647 $direction = (int) $direction;
657 $htmltext = str_replace(array(
"\r",
"\n"),
'', $htmltext);
660 if ($direction < 0) {
661 $extracss = ($extracss ? $extracss .
' ' :
'') . ($notabs != 3 ?
'inline-block' :
'');
662 $extrastyle =
'padding: 0px; padding-left: 2px;';
664 if ($direction > 0) {
665 $extracss = ($extracss ? $extracss .
' ' :
'') . ($notabs != 3 ?
'inline-block' :
'');
666 $extrastyle =
'padding: 0px; padding-right: 2px;';
669 $classfortooltip =
'classfortooltip';
674 if ($tooltiptrigger ==
'') {
675 $htmltext = str_replace(
'"',
'"', $htmltext);
677 $classfortooltip =
'classfortooltiponclick';
678 $textfordialog .=
'<div style="display: none;" id="idfortooltiponclick_' . $tooltiptrigger .
'" class="classfortooltiponclicktext">' . $htmltext .
'</div>';
680 if ($tooltipon == 2 || $tooltipon == 3) {
681 $paramfortooltipimg =
' class="' . $classfortooltip . ($notabs != 3 ?
' inline-block' :
'') . ($extracss ?
' ' . $extracss :
'') .
'" style="padding: 0px;' . ($extrastyle ?
' ' . $extrastyle :
'') .
'"';
682 if ($tooltiptrigger ==
'') {
683 $paramfortooltipimg .=
' title="' . ($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1)) .
'"';
685 $paramfortooltipimg .=
' dolid="' . $tooltiptrigger .
'"';
688 $paramfortooltipimg = ($extracss ?
' class="' . $extracss .
'"' :
'') . ($extrastyle ?
' style="' . $extrastyle .
'"' :
'');
690 if ($tooltipon == 1 || $tooltipon == 3) {
691 $paramfortooltiptd =
' class="' . ($tooltipon == 3 ?
'cursorpointer ' :
'') . $classfortooltip .
' inline-block' . ($extracss ?
' ' . $extracss :
'') .
'" style="padding: 0px;' . ($extrastyle ?
' ' . $extrastyle :
'') .
'" ';
692 if ($tooltiptrigger ==
'') {
693 $paramfortooltiptd .=
' title="' . ($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1)) .
'"';
695 $paramfortooltiptd .=
' dolid="' . $tooltiptrigger .
'"';
698 $paramfortooltiptd = ($extracss ?
' class="' . $extracss .
'"' :
'') . ($extrastyle ?
' style="' . $extrastyle .
'"' :
'');
700 if (empty($notabs)) {
701 $s .=
'<table class="nobordernopadding"><tr style="height: auto;">';
702 } elseif ($notabs == 2) {
703 $s .=
'<div class="inline-block' . ($forcenowrap ?
' nowrap' :
'') .
'">';
706 if ($direction < 0) {
707 $s .=
'<' . $tag . $paramfortooltipimg;
709 $s .=
' class="valigntop" width="14"';
711 $s .=
'>' . $textfordialog . $img .
'</' . $tag .
'>';
715 if ((
string) $text !=
'') {
716 $s .=
'<' . $tag . $paramfortooltiptd .
'>' . $text .
'</' . $tag .
'>';
719 if ($direction > 0) {
720 $s .=
'<' . $tag . $paramfortooltipimg;
722 $s .=
' class="valignmiddle" width="14"';
724 $s .=
'>' . $textfordialog . $img .
'</' . $tag .
'>';
726 if (empty($notabs)) {
727 $s .=
'</tr></table>';
728 } elseif ($notabs == 2) {
749 public function textwithpicto($text, $htmltext, $direction = 1, $type =
'help', $extracss =
'', $noencodehtmltext = 0, $notabs = 3, $tooltiptrigger =
'', $forcenowrap = 0)
751 global $conf, $langs;
756 } elseif ($type ==
'1') {
760 $tooltiptrigger = preg_replace(
'/[^a-z0-9]/i',
'', $tooltiptrigger);
762 if (preg_match(
'/onsmartphone$/', $tooltiptrigger) && empty($conf->dol_no_mouse_hover)) {
763 $tooltiptrigger = preg_replace(
'/^.*onsmartphone$/',
'', $tooltiptrigger);
766 if ($tooltiptrigger) {
767 $alt = $langs->transnoentitiesnoconv(
"ClickToShowHelp");
771 if (empty($conf->use_javascript_ajax)) {
772 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable') {
781 if (!empty($conf->dol_no_mouse_hover) && empty($tooltiptrigger)) {
782 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable') {
793 if ($type ==
'info') {
795 } elseif ($type ==
'help') {
796 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
797 } elseif ($type ==
'helpclickable') {
798 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
799 } elseif ($type ==
'superadmin') {
802 } elseif ($type ==
'admin') {
805 } elseif ($type ==
'warning') {
807 } elseif ($type !=
'none') {
812 return $this->
textwithtooltip($text, $htmltext, ((($tooltiptrigger && !$img) || strpos($type,
'clickable')) ? 3 : 2), $direction, $img, $extracss, $notabs,
'', $noencodehtmltext, $tooltiptrigger, $forcenowrap);
825 public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0, $name =
'massaction', $cssclass =
'checkforselect')
827 global $conf, $langs, $hookmanager;
830 $ret =
'<div class="centpercent center">';
831 $ret .=
'<select class="flat' . (empty($conf->use_javascript_ajax) ?
'' :
' hideobject') .
' ' . $name .
' ' . $name .
'select valignmiddle alignstart" id="' . $name .
'" name="' . $name .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
'>';
834 $parameters = array();
835 $reshook = $hookmanager->executeHooks(
'addMoreMassActions', $parameters);
838 if (is_array($arrayofaction) && count($arrayofaction) == 0 && empty($hookmanager->resPrint)) {
841 if (empty($reshook)) {
842 $ret .=
'<option value="0"' . ($disabled ?
' disabled="disabled"' :
'') .
'>-- ' . $langs->trans(
"SelectAction") .
' --</option>';
843 if (is_array($arrayofaction)) {
844 foreach ($arrayofaction as $code => $label) {
845 $ret .=
'<option value="' . $code .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' data-html="' .
dol_escape_htmltag($label) .
'">' . $label .
'</option>';
849 $ret .= $hookmanager->resPrint;
853 if (empty($conf->dol_optimize_smallscreen)) {
858 $ret .=
'<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">';
859 $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")) .
'">';
862 if (!empty($conf->use_javascript_ajax)) {
863 $ret .=
'<!-- JS CODE TO ENABLE mass action select -->
865 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 */
867 atleastoneselected=0;
868 jQuery("."+cssclass).each(function( index ) {
869 /* console.log( index + ": " + $( this ).text() ); */
870 if ($(this).is(\':checked\')) atleastoneselected++;
873 console.log("initCheckForSelect mode="+mode+" name="+name+" cssclass="+cssclass+" atleastoneselected="+atleastoneselected);
875 if (atleastoneselected || ' . $alwaysvisible .
')
877 jQuery("."+name).show();
878 ' . ($selected ?
'if (atleastoneselected) { jQuery("."+name+"select").val("' . $selected .
'").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', false); }' :
'') .
'
879 ' . ($selected ?
'if (! atleastoneselected) { jQuery("."+name+"select").val("0").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', true); } ' :
'') .
'
883 jQuery("."+name).hide();
884 jQuery("."+name+"other").hide();
888 jQuery(document).ready(function () {
889 initCheckForSelect(0, "' . $name .
'", "' . $cssclass .
'");
890 jQuery(".' . $cssclass .
'").click(function() {
891 initCheckForSelect(1, "' . $name .
'", "' . $cssclass .
'");
893 jQuery(".' . $name .
'select").change(function() {
894 var massaction = $( this ).val();
895 var urlform = $( this ).closest("form").attr("action").replace("#show_files","");
896 if (massaction == "builddoc")
898 urlform = urlform + "#show_files";
900 $( this ).closest("form").attr("action", urlform);
901 console.log("we select a mass action name=' . $name .
' massaction="+massaction+" - "+urlform);
902 /* Warning: if you set submit button to disabled, post using Enter will no more work if there is no other button */
903 if ($(this).val() != \'0\')
905 jQuery(".' . $name .
'confirmed").prop(\'disabled\', false);
906 jQuery(".' . $name .
'other").hide(); /* To disable if another div was open */
907 jQuery(".' . $name .
'"+massaction).show();
911 jQuery(".' . $name .
'confirmed").prop(\'disabled\', true);
912 jQuery(".' . $name .
'other").hide(); /* To disable any div open */
941 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)
944 global $conf, $langs, $mysoc;
946 $langs->load(
"dict");
949 $countryArray = array();
952 $atleastonefavorite = 0;
954 $sql =
"SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite, eec";
955 $sql .=
" FROM " . $this->db->prefix() .
"c_country";
956 $sql .=
" WHERE active > 0";
959 dol_syslog(get_class($this) .
"::select_country", LOG_DEBUG);
960 $resql = $this->db->query($sql);
962 $out .=
'<select id="select' . $htmlname .
'" class="flat maxwidth200onsmartphone selectcountry' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" ' . $htmloption .
'>';
963 $num = $this->db->num_rows($resql);
967 $obj = $this->db->fetch_object($resql);
969 $countryArray[$i][
'rowid'] = $obj->rowid;
970 $countryArray[$i][
'code_iso'] = $obj->code_iso;
971 $countryArray[$i][
'code_iso3'] = $obj->code_iso3;
972 $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 :
''));
973 $countryArray[$i][
'favorite'] = $obj->favorite;
974 $countryArray[$i][
'eec'] = $obj->eec;
975 $favorite[$i] = $obj->favorite;
980 if (empty($disablefavorites)) {
981 $array1_sort_order = SORT_DESC;
982 $array2_sort_order = SORT_ASC;
983 array_multisort($favorite, $array1_sort_order, $label, $array2_sort_order, $countryArray);
989 if (is_numeric($showempty)) {
990 $out .=
'<option value=""> </option>' .
"\n";
992 $out .=
'<option value="-1">' . $langs->trans($showempty) .
'</option>' .
"\n";
996 if ($addspecialentries) {
998 $out .=
'<option value="special_allnotme"' . ($selected ==
'special_allnotme' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesExceptMe", $langs->transnoentitiesnoconv(
"Country" . $mysoc->country_code)) .
'</option>';
999 $out .=
'<option value="special_eec"' . ($selected ==
'special_eec' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesInEEC") .
'</option>';
1000 if ($mysoc->isInEEC()) {
1001 $out .=
'<option value="special_eecnotme"' . ($selected ==
'special_eecnotme' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesInEECExceptMe", $langs->transnoentitiesnoconv(
"Country" . $mysoc->country_code)) .
'</option>';
1003 $out .=
'<option value="special_noteec"' . ($selected ==
'special_noteec' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesNotInEEC") .
'</option>';
1004 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
1007 foreach ($countryArray as $row) {
1009 if (empty($row[
'rowid'])) {
1012 if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row[
'code_iso'], $exclude_country_code)) {
1016 if (empty($disablefavorites) && $row[
'favorite'] && $row[
'code_iso']) {
1017 $atleastonefavorite++;
1019 if (empty($row[
'favorite']) && $atleastonefavorite) {
1020 $atleastonefavorite = 0;
1021 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
1025 if ($row[
'label']) {
1026 $labeltoshow .=
dol_trunc($row[
'label'], $maxlength,
'middle');
1028 $labeltoshow .=
' ';
1030 if ($row[
'code_iso']) {
1031 $labeltoshow .=
' <span class="opacitymedium">(' . $row[
'code_iso'] .
')</span>';
1032 if (empty($hideflags)) {
1033 $tmpflag =
picto_from_langcode($row[
'code_iso'],
'class="saturatemedium paddingrightonly"', 1);
1034 $labeltoshow = $tmpflag .
' ' . $labeltoshow;
1038 if ($selected && $selected !=
'-1' && ($selected == $row[
'rowid'] || $selected == $row[
'code_iso'] || $selected == $row[
'code_iso3'] || $selected == $row[
'label'])) {
1039 $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']) .
'">';
1041 $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']) .
'">';
1043 $out .= $labeltoshow;
1044 $out .=
'</option>' .
"\n";
1047 $out .=
'</select>';
1053 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1054 $out .=
ajax_combobox(
'select' . $htmlname, array(), 0, 0,
'resolve');
1074 public function select_incoterms($selected =
'', $location_incoterms =
'', $page =
'', $htmlname =
'incoterm_id', $htmloption =
'', $forcecombo = 1, $events = array(), $disableautocomplete = 0)
1077 global $conf, $langs;
1079 $langs->load(
"dict");
1083 $incotermArray = array();
1085 $sql =
"SELECT rowid, code";
1086 $sql .=
" FROM " . $this->db->prefix() .
"c_incoterms";
1087 $sql .=
" WHERE active > 0";
1088 $sql .=
" ORDER BY code ASC";
1090 dol_syslog(get_class($this) .
"::select_incoterm", LOG_DEBUG);
1091 $resql = $this->db->query($sql);
1093 if ($conf->use_javascript_ajax && !$forcecombo) {
1094 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1098 if (!empty($page)) {
1099 $out .=
'<form method="post" action="' . $page .
'">';
1100 $out .=
'<input type="hidden" name="action" value="set_incoterms">';
1101 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1104 $out .=
'<select id="' . $htmlname .
'" class="flat selectincoterm width75" name="' . $htmlname .
'" ' . $htmloption .
'>';
1105 $out .=
'<option value="0"> </option>';
1106 $num = $this->db->num_rows($resql);
1110 $obj = $this->db->fetch_object($resql);
1111 $incotermArray[$i][
'rowid'] = $obj->rowid;
1112 $incotermArray[$i][
'code'] = $obj->code;
1116 foreach ($incotermArray as $row) {
1117 if ($selected && ($selected == $row[
'rowid'] || $selected == $row[
'code'])) {
1118 $out .=
'<option value="' . $row[
'rowid'] .
'" selected>';
1120 $out .=
'<option value="' . $row[
'rowid'] .
'">';
1124 $out .= $row[
'code'];
1127 $out .=
'</option>';
1130 $out .=
'</select>';
1132 if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
1133 $out .=
ajax_multiautocompleter(
'location_incoterms', array(), DOL_URL_ROOT .
'/core/ajax/locationincoterms.php') .
"\n";
1134 $moreattrib .=
' autocomplete="off"';
1136 $out .=
'<input id="location_incoterms" class="maxwidthonsmartphone type="text" name="location_incoterms" value="' . $location_incoterms .
'">' .
"\n";
1138 if (!empty($page)) {
1139 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp nomargintop nomarginbottom" value="' . $langs->trans(
"Modify") .
'"></form>';
1162 public function select_type_of_lines($selected =
'', $htmlname =
'type', $showempty = 0, $hidetext = 0, $forceall = 0, $morecss =
"")
1168 if ($forceall == 1 || (empty($forceall) && isModEnabled(
"product") && isModEnabled(
"service"))
1169 || (empty($forceall) && !isModEnabled(
'product') && !isModEnabled(
'service'))) {
1170 if (empty($hidetext)) {
1171 print $langs->trans(
"Type") .
': ';
1173 print
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
1175 print
'<option value="-1"';
1176 if ($selected == -1) {
1180 if (is_numeric($showempty)) {
1188 print
'<option value="0"';
1189 if (0 == $selected || ($selected == -1 &&
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') ==
'product')) {
1192 print
'>' . $langs->trans(
"Product");
1194 print
'<option value="1"';
1195 if (1 == $selected || ($selected == -1 &&
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') ==
'service')) {
1198 print
'>' . $langs->trans(
"Service");
1204 if ((empty($forceall) && !isModEnabled(
'product') && isModEnabled(
"service")) || $forceall == 3) {
1205 print $langs->trans(
"Service");
1206 print
'<input type="hidden" name="' . $htmlname .
'" value="1">';
1208 if ((empty($forceall) && isModEnabled(
"product") && !isModEnabled(
'service')) || $forceall == 2) {
1209 print $langs->trans(
"Product");
1210 print
'<input type="hidden" name="' . $htmlname .
'" value="0">';
1212 if ($forceall < 0) {
1213 print
'<input type="hidden" name="' . $htmlname .
'" value="1">';
1229 $num = count($this->cache_types_fees);
1236 $langs->load(
"trips");
1238 $sql =
"SELECT c.code, c.label";
1239 $sql .=
" FROM " . $this->db->prefix() .
"c_type_fees as c";
1240 $sql .=
" WHERE active > 0";
1242 $resql = $this->db->query($sql);
1244 $num = $this->db->num_rows($resql);
1248 $obj = $this->db->fetch_object($resql);
1251 $label = ($obj->code != $langs->trans($obj->code) ? $langs->trans($obj->code) : $langs->trans($obj->label));
1252 $this->cache_types_fees[$obj->code] = $label;
1256 asort($this->cache_types_fees);
1278 global $user, $langs;
1280 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
1284 print
'<select id="select_' . $htmlname .
'" class="flat" name="' . $htmlname .
'">';
1286 print
'<option value="-1"';
1287 if ($selected == -1) {
1290 print
'> </option>';
1293 foreach ($this->cache_types_fees as $key => $value) {
1294 print
'<option value="' . $key .
'"';
1295 if ($key == $selected) {
1305 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1334 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)
1337 global $conf, $langs;
1341 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'COMPANY_USE_SEARCH_TO_SELECT') && !$forcecombo) {
1342 if (is_null($ajaxoptions)) {
1343 $ajaxoptions = array();
1346 require_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1350 if ($selected && empty($selected_input_value)) {
1351 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
1352 $societetmp =
new Societe($this->db);
1353 $societetmp->fetch($selected);
1354 $selected_input_value = $societetmp->name;
1359 $urloption =
'htmlname=' . urlencode((
string) (str_replace(
'.',
'_', $htmlname))) .
'&outjson=1&filter=' . urlencode((
string) ($filter)) . (empty($excludeids) ?
'' :
'&excludeids=' . implode(
',', $excludeids)) . ($showtype ?
'&showtype=' . urlencode((
string) ($showtype)) :
'') . ($showcode ?
'&showcode=' . urlencode((
string) ($showcode)) :
'');
1361 $out .=
'<!-- force css to be higher than dialog popup --><style type="text/css">.ui-autocomplete { z-index: 1010; }</style>';
1362 if (empty($hidelabel)) {
1363 $out .= $langs->trans(
"RefOrLabel") .
' : ';
1364 } elseif ($hidelabel > 1) {
1365 $placeholder = $langs->trans(
"RefOrLabel");
1366 if ($hidelabel == 2) {
1367 $out .=
img_picto($langs->trans(
"Search"),
'search');
1370 $out .=
'<input type="text" class="' . $morecss .
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . ($placeholder ?
' placeholder="' .
dol_escape_htmltag($placeholder) .
'"' :
'') .
' ' . (
getDolGlobalString(
'THIRDPARTY_SEARCH_AUTOFOCUS') ?
'autofocus' :
'') .
' />';
1371 if ($hidelabel == 3) {
1372 $out .=
img_picto($langs->trans(
"Search"),
'search');
1380 $out .= $this->
select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events,
'', 0, $limit, $morecss, $moreparam, $multiple, $excludeids, $showcode);
1414 public function select_contact($socid, $selected =
'', $htmlname =
'contactid', $showempty = 0, $exclude =
'', $limitto =
'', $showfunction = 0, $morecss =
'', $nokeyifsocid =
true, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam =
'', $htmlid =
'', $selected_input_value =
'', $filter =
'')
1418 global $conf, $langs;
1423 if ($nokeyifsocid && $socid > 0) {
1424 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1427 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && !$forcecombo) {
1428 if (is_null($events)) {
1432 require_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1436 if ($selected && empty($selected_input_value)) {
1437 require_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
1438 $contacttmp =
new Contact($this->db);
1439 $contacttmp->fetch($selected);
1440 $selected_input_value = $contacttmp->getFullName($langs);
1443 if (!is_numeric($showempty)) {
1444 $placeholder = $showempty;
1448 $urloption =
'htmlname=' . urlencode((
string) (str_replace(
'.',
'_', $htmlname))) .
'&outjson=1&filter=' . urlencode((
string) ($filter)) . (empty($exclude) ?
'' :
'&exclude=' . urlencode($exclude)) . ($showsoc ?
'&showsoc=' . urlencode((
string) ($showsoc)) :
'');
1450 $out .=
'<!-- force css to be higher than dialog popup --><style type="text/css">.ui-autocomplete { z-index: 1010; }</style>';
1452 $out .=
'<input type="text" class="' . $morecss .
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . ($placeholder ?
' placeholder="' .
dol_escape_htmltag($placeholder) .
'"' :
'') .
' ' . (
getDolGlobalString(
'CONTACT_SEARCH_AUTOFOCUS') ?
'autofocus' :
'') .
' />';
1460 $disableifempty = 0;
1461 $options_only =
false;
1464 $out .= $this->
selectcontacts($socid, $selected, $htmlname, $showempty, $exclude, $limitto, $showfunction, $morecss, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid, $multiple, $disableifempty);
1467 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1499 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)
1502 global $user, $langs;
1503 global $hookmanager;
1507 $outarray = array();
1509 if ($selected ===
'') {
1510 $selected = array();
1511 } elseif (!is_array($selected)) {
1512 $selected = array($selected);
1516 if (function_exists(
'testSqlAndScriptInject')) {
1519 return 'SQLInjectionTryDetected';
1523 if ($filter !=
'') {
1524 if (preg_match(
'/[\(\)]/', $filter)) {
1530 if (function_exists(
'testSqlAndScriptInject')) {
1533 return 'SQLInjectionTryDetected';
1539 dol_syslog(
"Warning, select_thirdparty_list was called with a filter criteria not using the Universal Search Syntax.", LOG_WARNING);
1544 $sql =
"SELECT s.rowid, s.nom as name, s.name_alias, s.tva_intra, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
1546 $sql .=
", s.address, s.zip, s.town";
1547 $sql .=
", dictp.code as country_code";
1549 $sql .=
" FROM " . $this->db->prefix() .
"societe as s";
1551 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_country as dictp ON dictp.rowid = s.fk_pays";
1553 if (!$user->hasRight(
'societe',
'client',
'voir')) {
1554 $sql .=
", " . $this->db->prefix() .
"societe_commerciaux as sc";
1556 $sql .=
" WHERE s.entity IN (" .
getEntity(
'societe') .
")";
1557 if (!empty($user->socid)) {
1558 $sql .=
" AND s.rowid = " . ((int) $user->socid);
1563 $sql .=
" AND (" . $filter .
")";
1565 if (!$user->hasRight(
'societe',
'client',
'voir')) {
1566 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = " . ((int) $user->id);
1569 $sql .=
" AND s.status <> 0";
1571 if (!empty($excludeids)) {
1572 $sql .=
" AND s.rowid NOT IN (" . $this->db->sanitize(implode(
',', $excludeids)) .
")";
1575 $parameters = array();
1576 $reshook = $hookmanager->executeHooks(
'selectThirdpartyListWhere', $parameters);
1577 $sql .= $hookmanager->resPrint;
1579 if ($filterkey && $filterkey !=
'') {
1583 $search_crit = explode(
' ', $filterkey);
1585 if (count($search_crit) > 1) {
1588 foreach ($search_crit as $crit) {
1592 $sql .=
"(s.nom LIKE '" . $this->db->escape($prefix . $crit) .
"%')";
1595 if (count($search_crit) > 1) {
1598 if (isModEnabled(
'barcode')) {
1599 $sql .=
" OR s.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
1601 $sql .=
" OR s.code_client LIKE '" . $this->db->escape($prefix . $filterkey) .
"%' OR s.code_fournisseur LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
1602 $sql .=
" OR s.name_alias LIKE '" . $this->db->escape($prefix . $filterkey) .
"%' OR s.tva_intra LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
1605 $sql .= $this->db->order(
"nom",
"ASC");
1606 $sql .= $this->db->plimit($limit, 0);
1609 dol_syslog(get_class($this).
"::select_thirdparty_list", LOG_DEBUG);
1610 $resql = $this->db->query($sql);
1613 $out .=
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($moreparam ?
' ' . $moreparam :
'') .
' name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
'>' .
"\n";
1615 $textifempty = (($showempty && !is_numeric($showempty)) ? $langs->trans($showempty) :
'');
1619 if ($showempty && !is_numeric($showempty)) {
1620 $textifempty = $langs->trans($showempty);
1622 $textifempty .= $langs->trans(
"All");
1626 $out .=
'<option value="-1" data-html="' .
dol_escape_htmltag(
'<span class="opacitymedium">' . ($textifempty ? $textifempty :
' ') .
'</span>') .
'">' . $textifempty .
'</option>' .
"\n";
1629 $companytemp =
new Societe($this->db);
1631 $num = $this->db->num_rows($resql);
1635 $obj = $this->db->fetch_object($resql);
1638 if (($obj->client) && (!empty($obj->code_client))) {
1639 $label = $obj->code_client .
' - ';
1641 if (($obj->fournisseur) && (!empty($obj->code_fournisseur))) {
1642 $label .= $obj->code_fournisseur .
' - ';
1644 $label .=
' ' . $obj->name;
1646 $label = $obj->name;
1649 if (!empty($obj->name_alias)) {
1650 $label .=
' (' . $obj->name_alias .
')';
1654 $label .=
' - '.$obj->tva_intra;
1657 $labelhtml = $label;
1660 $companytemp->id = $obj->rowid;
1661 $companytemp->client = $obj->client;
1662 $companytemp->fournisseur = $obj->fournisseur;
1663 $tmptype = $companytemp->getTypeUrl(1,
'', 0,
'span');
1665 $labelhtml .=
' ' . $tmptype;
1668 if ($obj->client || $obj->fournisseur) {
1671 if ($obj->client == 1 || $obj->client == 3) {
1672 $label .= $langs->trans(
"Customer");
1674 if ($obj->client == 2 || $obj->client == 3) {
1675 $label .= ($obj->client == 3 ?
', ' :
'') . $langs->trans(
"Prospect");
1677 if ($obj->fournisseur) {
1678 $label .= ($obj->client ?
', ' :
'') . $langs->trans(
"Supplier");
1680 if ($obj->client || $obj->fournisseur) {
1686 $s = ($obj->address ?
' - ' . $obj->address :
'') . ($obj->zip ?
' - ' . $obj->zip :
'') . ($obj->town ?
' ' . $obj->town :
'');
1687 if (!empty($obj->country_code)) {
1688 $s .=
', ' . $langs->trans(
'Country' . $obj->country_code);
1694 if (empty($outputmode)) {
1695 if (in_array($obj->rowid, $selected)) {
1696 $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>';
1698 $out .=
'<option value="' . $obj->rowid .
'" data-html="' .
dol_escape_htmltag($labelhtml, 0, 0,
'', 0, 1) .
'">' .
dol_escape_htmltag($label, 0, 0,
'', 0, 1) .
'</option>';
1701 array_push($outarray, array(
'key' => $obj->rowid,
'value' => $label,
'label' => $label,
'labelhtml' => $labelhtml));
1705 if (($i % 10) == 0) {
1710 $out .=
'</select>' .
"\n";
1712 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1719 $this->result = array(
'nbofthirdparties' => $num);
1753 public function selectcontacts($socid, $selected = array(), $htmlname =
'contactid', $showempty = 0, $exclude =
'', $limitto =
'', $showfunction = 0, $morecss =
'', $options_only = 0, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam =
'', $htmlid =
'', $multiple =
false, $disableifempty = 0, $filter =
'')
1755 global $conf, $user, $langs, $hookmanager, $action;
1757 $langs->load(
'companies');
1759 if (empty($htmlid)) {
1760 $htmlid = $htmlname;
1764 $outarray = array();
1766 if ($selected ===
'') {
1767 $selected = array();
1768 } elseif (!is_array($selected)) {
1769 $selected = array((
int) $selected);
1773 if (function_exists(
'testSqlAndScriptInject')) {
1776 return 'SQLInjectionTryDetected';
1780 if ($filter !=
'') {
1781 if (preg_match(
'/[\(\)]/', $filter)) {
1787 if (function_exists(
'testSqlAndScriptInject')) {
1790 return 'SQLInjectionTryDetected';
1796 dol_syslog(
"Warning, select_thirdparty_list was called with a filter criteria not using the Universal Search Filter Syntax.", LOG_WARNING);
1800 if (!is_object($hookmanager)) {
1801 include_once DOL_DOCUMENT_ROOT .
'/core/class/hookmanager.class.php';
1806 $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";
1807 if ($showsoc > 0 ||
getDolGlobalString(
'CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST')) {
1808 $sql .=
", s.nom as company, s.town AS company_town";
1810 $sql .=
" FROM " . $this->db->prefix() .
"socpeople as sp";
1811 if ($showsoc > 0 ||
getDolGlobalString(
'CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST')) {
1812 $sql .=
" LEFT OUTER JOIN " . $this->db->prefix() .
"societe as s ON s.rowid=sp.fk_soc";
1814 $sql .=
" WHERE sp.entity IN (" .
getEntity(
'contact') .
")";
1815 $sql .=
" AND ((sp.fk_user_creat = ".((int) $user->id).
" AND sp.priv = 1) OR sp.priv = 0)";
1816 if ($socid > 0 || $socid == -1) {
1817 $sql .=
" AND sp.fk_soc = " . ((int) $socid);
1820 $sql .=
" AND sp.statut <> 0";
1825 $sql .=
" AND (" . $filter .
")";
1828 $parameters = array();
1829 $reshook = $hookmanager->executeHooks(
'selectContactListWhere', $parameters);
1830 $sql .= $hookmanager->resPrint;
1831 $sql .=
" ORDER BY sp.lastname ASC";
1833 dol_syslog(get_class($this) .
"::selectcontacts", LOG_DEBUG);
1834 $resql = $this->db->query($sql);
1836 $num = $this->db->num_rows($resql);
1838 if ($htmlname !=
'none' && !$options_only) {
1839 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlid .
'" name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . (($num || empty($disableifempty)) ?
'' :
' disabled') . ($multiple ?
'multiple' :
'') .
' ' . (!empty($moreparam) ? $moreparam :
'') .
'>';
1842 if ($showempty && !is_numeric($showempty)) {
1843 $textforempty = $showempty;
1844 $out .=
'<option class="optiongrey" value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'>' . $textforempty .
'</option>';
1846 if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) {
1847 $out .=
'<option value="0"' . (in_array(0, $selected) ?
' selected' :
'') .
'> </option>';
1849 if ($showempty == 2) {
1850 $out .=
'<option value="0"' . (in_array(0, $selected) ?
' selected' :
'') .
'>-- ' . $langs->trans(
"Internal") .
' --</option>';
1856 include_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
1857 $contactstatic =
new Contact($this->db);
1860 $obj = $this->db->fetch_object($resql);
1863 $extendedInfos =
'';
1865 $extendedInfos = array();
1866 $email = trim($obj->email);
1867 if (!empty($email)) {
1868 $extendedInfos[] = $email;
1870 $phone = trim($obj->phone);
1871 $phone_perso = trim($obj->phone_perso);
1872 $phone_mobile = trim($obj->phone_mobile);
1873 if (!empty($phone)) {
1874 $extendedInfos[] = $phone;
1876 if (!empty($phone_perso)) {
1877 $extendedInfos[] = $phone_perso;
1879 if (!empty($phone_mobile)) {
1880 $extendedInfos[] = $phone_mobile;
1883 $contact_town = trim($obj->contact_town);
1884 $company_town = trim($obj->company_town);
1885 if (!empty($contact_town)) {
1886 $extendedInfos[] = $contact_town;
1887 } elseif (!empty($company_town)) {
1888 $extendedInfos[] = $company_town;
1890 $extendedInfos = implode(
' - ', $extendedInfos);
1891 if (!empty($extendedInfos)) {
1892 $extendedInfos =
' - ' . $extendedInfos;
1896 $contactstatic->id = $obj->rowid;
1897 $contactstatic->lastname = $obj->lastname;
1898 $contactstatic->firstname = $obj->firstname;
1899 if ($obj->statut == 1) {
1901 if ($htmlname !=
'none') {
1903 if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) {
1906 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
1909 if (!empty($selected) && in_array($obj->rowid, $selected)) {
1910 $out .=
'<option value="' . $obj->rowid .
'"';
1912 $out .=
' disabled';
1914 $out .=
' selected>';
1916 $tmplabel = $contactstatic->getFullName($langs) . $extendedInfos;
1917 if ($showfunction && $obj->poste) {
1918 $tmplabel .=
' (' . $obj->poste .
')';
1920 if (($showsoc > 0) && $obj->company) {
1921 $tmplabel .=
' - (' . $obj->company .
')';
1925 $out .=
'</option>';
1927 $out .=
'<option value="' . $obj->rowid .
'"';
1929 $out .=
' disabled';
1933 $tmplabel = $contactstatic->getFullName($langs) . $extendedInfos;
1934 if ($showfunction && $obj->poste) {
1935 $tmplabel .=
' (' . $obj->poste .
')';
1937 if (($showsoc > 0) && $obj->company) {
1938 $tmplabel .=
' - (' . $obj->company .
')';
1942 $out .=
'</option>';
1945 if (in_array($obj->rowid, $selected)) {
1946 $tmplabel = $contactstatic->getFullName($langs) . $extendedInfos;
1947 if ($showfunction && $obj->poste) {
1948 $tmplabel .=
' (' . $obj->poste .
')';
1950 if (($showsoc > 0) && $obj->company) {
1951 $tmplabel .=
' - (' . $obj->company .
')';
1958 if ($tmplabel !=
'') {
1959 array_push($outarray, array(
'key' => $obj->rowid,
'value' => $tmplabel,
'label' => $tmplabel,
'labelhtml' => $tmplabel));
1965 $labeltoshow = ($socid != -1) ? ($langs->trans($socid ?
"NoContactDefinedForThirdParty" :
"NoContactDefined")) : $langs->trans(
'SelectAThirdPartyFirst');
1966 $out .=
'<option class="disabled" value="-1"' . (($showempty == 2 || $multiple) ?
'' :
' selected') .
' disabled="disabled">';
1967 $out .= $labeltoshow;
1968 $out .=
'</option>';
1971 $parameters = array(
1973 'htmlname' => $htmlname,
1976 'showfunction' => $showfunction,
1977 'showsoc' => $showsoc,
1980 $reshook = $hookmanager->executeHooks(
'afterSelectContactOptions', $parameters, $this, $action);
1982 if ($htmlname !=
'none' && !$options_only) {
1983 $out .=
'</select>';
1986 if ($conf->use_javascript_ajax && !$forcecombo && !$options_only) {
1987 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1993 if ($options_only === 2) {
2021 global $langs, $conf;
2024 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
2025 $sql .=
" re.description, re.fk_facture_source";
2026 $sql .=
" FROM " . $this->db->prefix() .
"societe_remise_except as re";
2027 $sql .=
" WHERE re.fk_soc = " . (int) $socid;
2028 $sql .=
" AND re.entity = " . $conf->entity;
2030 $sql .=
" AND " . $filter;
2032 $sql .=
" ORDER BY re.description ASC";
2034 dol_syslog(get_class($this) .
"::select_remises", LOG_DEBUG);
2035 $resql = $this->db->query($sql);
2037 print
'<select id="select_' . $htmlname .
'" class="flat maxwidthonsmartphone" name="' . $htmlname .
'">';
2038 $num = $this->db->num_rows($resql);
2040 $qualifiedlines = $num;
2044 print
'<option value="0"> </option>';
2046 $obj = $this->db->fetch_object($resql);
2047 $desc =
dol_trunc($obj->description, 40);
2048 if (preg_match(
'/\(CREDIT_NOTE\)/', $desc)) {
2049 $desc = preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $desc);
2051 if (preg_match(
'/\(DEPOSIT\)/', $desc)) {
2052 $desc = preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"Deposit"), $desc);
2054 if (preg_match(
'/\(EXCESS RECEIVED\)/', $desc)) {
2055 $desc = preg_replace(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"ExcessReceived"), $desc);
2057 if (preg_match(
'/\(EXCESS PAID\)/', $desc)) {
2058 $desc = preg_replace(
'/\(EXCESS PAID\)/', $langs->trans(
"ExcessPaid"), $desc);
2062 if ($selected > 0 && $selected == $obj->rowid) {
2063 $selectstring =
' selected';
2067 if ($maxvalue > 0 && $obj->amount_ttc > $maxvalue) {
2069 $disabled =
' disabled';
2072 if (
getDolGlobalString(
'MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST') && !empty($obj->fk_facture_source)) {
2073 $tmpfac =
new Facture($this->db);
2074 if ($tmpfac->fetch($obj->fk_facture_source) > 0) {
2075 $desc = $desc .
' - ' . $tmpfac->ref;
2079 print
'<option value="' . $obj->rowid .
'"' . $selectstring . $disabled .
'>' . $desc .
' (' .
price($obj->amount_ht) .
' ' . $langs->trans(
"HT") .
' - ' .
price($obj->amount_ttc) .
' ' . $langs->trans(
"TTC") .
')</option>';
2086 return $qualifiedlines;
2111 public function select_users($selected =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include =
'', $enableonly = array(), $force_entity =
'0')
2114 print $this->
select_dolusers($selected, $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity);
2143 public function select_dolusers($selected =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'', $maxlength = 0, $showstatus = 0, $morefilter =
'', $show_every = 0, $enableonlytext =
'', $morecss =
'', $notdisabled = 0, $outputmode = 0, $multiple =
false, $forcecombo = 0)
2146 global $conf, $user, $langs, $hookmanager;
2150 if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && !
getDolGlobalString(
'SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE')) {
2151 $selected = $user->id;
2154 if ($selected ===
'') {
2155 $selected = array();
2156 } elseif (!is_array($selected)) {
2157 $selected = array($selected);
2160 $excludeUsers =
null;
2161 $includeUsers =
null;
2164 if (is_array($exclude)) {
2165 $excludeUsers = implode(
",", $exclude);
2168 if (is_array($include)) {
2169 $includeUsers = implode(
",", $include);
2170 } elseif ($include ==
'hierarchy') {
2172 $includeUsers = implode(
",", $user->getAllChildIds(0));
2173 } elseif ($include ==
'hierarchyme') {
2175 $includeUsers = implode(
",", $user->getAllChildIds(1));
2181 $outarray = array();
2182 $outarray2 = array();
2185 $showlabelofentity = isModEnabled(
'multicompany') && !
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && !empty($user->admin) && empty($user->entity);
2186 $userissuperadminentityone = isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && empty($user->entity);
2189 $sql =
"SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut as status, u.login, u.admin, u.entity, u.gender, u.photo";
2190 if ($showlabelofentity) {
2191 $sql .=
", e.label";
2193 $sql .=
" FROM " . $this->db->prefix() .
"user as u";
2194 if ($showlabelofentity) {
2195 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entity as e ON e.rowid = u.entity";
2198 if ($userissuperadminentityone && $force_entity !=
'default') {
2199 if (!empty($force_entity)) {
2200 $sql .=
" WHERE u.entity IN (0, " . $this->db->sanitize($force_entity) .
")";
2202 $sql .=
" WHERE u.entity IS NOT NULL";
2205 if (isModEnabled(
'multicompany') &&
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE')) {
2206 $sql .=
" WHERE u.rowid IN (SELECT ug.fk_user FROM ".$this->db->prefix().
"usergroup_user as ug WHERE ug.entity IN (".
getEntity(
'usergroup').
"))";
2208 $sql .=
" WHERE u.entity IN (" .
getEntity(
'user') .
")";
2212 if (!empty($user->socid)) {
2213 $sql .=
" AND u.fk_soc = " . ((int) $user->socid);
2215 if (is_array($exclude) && $excludeUsers) {
2216 $sql .=
" AND u.rowid NOT IN (" . $this->db->sanitize($excludeUsers) .
")";
2218 if ($includeUsers) {
2219 $sql .=
" AND u.rowid IN (" . $this->db->sanitize($includeUsers) .
")";
2222 $sql .=
" AND u.statut <> 0";
2225 $sql .=
" AND u.employee <> 0";
2228 $sql .=
" AND u.fk_soc IS NULL";
2230 if (!empty($morefilter)) {
2231 $sql .=
" " . $morefilter;
2235 $reshook = $hookmanager->executeHooks(
'addSQLWhereFilterOnSelectUsers', array(), $this, $action);
2236 if (!empty($reshook)) {
2237 $sql .= $hookmanager->resPrint;
2241 $sql .=
" ORDER BY u.statut DESC, u.firstname ASC, u.lastname ASC";
2243 $sql .=
" ORDER BY u.statut DESC, u.lastname ASC, u.firstname ASC";
2246 dol_syslog(get_class($this) .
"::select_dolusers", LOG_DEBUG);
2248 $resql = $this->db->query($sql);
2250 $num = $this->db->num_rows($resql);
2254 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
' minwidth200') .
'" id="' . $htmlname .
'" name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
' ' . ($disabled ?
' disabled' :
'') .
'>';
2255 if ($show_empty && !$multiple) {
2256 $textforempty =
' ';
2257 if (!empty($conf->use_javascript_ajax)) {
2258 $textforempty =
' ';
2260 if (!is_numeric($show_empty)) {
2261 $textforempty = $show_empty;
2263 $out .=
'<option class="optiongrey" value="' . ($show_empty < 0 ? $show_empty : -1) .
'"' . ((empty($selected) || in_array(-1, $selected)) ?
' selected' :
'') .
'>' . $textforempty .
'</option>' .
"\n";
2265 $outarray[($show_empty < 0 ? $show_empty : -1)] = $textforempty;
2266 $outarray2[($show_empty < 0 ? $show_empty : -1)] = array(
2267 'id' => ($show_empty < 0 ? $show_empty : -1),
2268 'label' => $textforempty,
2269 'labelhtml' => $textforempty,
2275 $out .=
'<option value="-2"' . ((in_array(-2, $selected)) ?
' selected' :
'') .
'>-- ' . $langs->trans(
"Everybody") .
' --</option>' .
"\n";
2277 $outarray[-2] =
'-- ' . $langs->trans(
"Everybody") .
' --';
2278 $outarray2[-2] = array(
2280 'label' =>
'-- ' . $langs->trans(
"Everybody") .
' --',
2281 'labelhtml' =>
'-- ' . $langs->trans(
"Everybody") .
' --',
2287 $userstatic =
new User($this->db);
2290 $obj = $this->db->fetch_object($resql);
2292 $userstatic->id = $obj->rowid;
2293 $userstatic->lastname = $obj->lastname;
2294 $userstatic->firstname = $obj->firstname;
2295 $userstatic->photo = $obj->photo;
2296 $userstatic->status = $obj->status;
2297 $userstatic->entity = $obj->entity;
2298 $userstatic->admin = $obj->admin;
2299 $userstatic->gender = $obj->gender;
2302 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
2303 $disableline = ($enableonlytext ? $enableonlytext :
'1');
2307 $labeltoshowhtml =
'';
2314 $labeltoshow .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
2315 $labeltoshowhtml .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
2316 if (empty($obj->firstname) && empty($obj->lastname)) {
2317 $labeltoshow .= $obj->login;
2318 $labeltoshowhtml .= $obj->login;
2325 $moreinfo .= ($moreinfo ?
' - ' :
' (');
2326 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(');
2327 $moreinfo .= $obj->login;
2328 $moreinfohtml .= $obj->login;
2330 if ($showstatus >= 0) {
2331 if ($obj->status == 1 && $showstatus == 1) {
2332 $moreinfo .= ($moreinfo ?
' - ' :
' (') . $langs->trans(
'Enabled');
2333 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . $langs->trans(
'Enabled');
2335 if ($obj->status == 0 && $showstatus == 1) {
2336 $moreinfo .= ($moreinfo ?
' - ' :
' (') . $langs->trans(
'Disabled');
2337 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . $langs->trans(
'Disabled');
2340 if ($showlabelofentity) {
2341 if (empty($obj->entity)) {
2342 $moreinfo .= ($moreinfo ?
' - ' :
' (') . $langs->trans(
"AllEntities");
2343 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . $langs->trans(
"AllEntities");
2345 if ($obj->entity != $conf->entity) {
2346 $moreinfo .= ($moreinfo ?
' - ' :
' (') . ($obj->label ? $obj->label : $langs->trans(
"EntityNameNotDefined"));
2347 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(').($obj->label ? $obj->label : $langs->trans(
"EntityNameNotDefined"));
2351 $moreinfo .= (!empty($moreinfo) ?
')' :
'');
2352 $moreinfohtml .= (!empty($moreinfohtml) ?
')</span>' :
'');
2353 if (!empty($disableline) && $disableline !=
'1') {
2355 $moreinfo .=
' - ' . $disableline;
2356 $moreinfohtml .=
' - ' . $disableline;
2358 $labeltoshow .= $moreinfo;
2359 $labeltoshowhtml .= $moreinfohtml;
2361 $out .=
'<option value="' . $obj->rowid .
'"';
2362 if (!empty($disableline)) {
2363 $out .=
' disabled';
2365 if ((!empty($selected[0]) && is_object($selected[0])) ? $selected[0]->id == $obj->rowid : in_array($obj->rowid, $selected)) {
2366 $out .=
' selected';
2368 $out .=
' data-html="';
2370 $outhtml = $userstatic->getNomUrl(-3,
'', 0, 1, 24, 1,
'login',
'', 1) .
' ';
2371 if ($showstatus >= 0 && $obj->status == 0) {
2372 $outhtml .=
'<strike class="opacitymediumxxx">';
2374 $outhtml .= $labeltoshowhtml;
2375 if ($showstatus >= 0 && $obj->status == 0) {
2376 $outhtml .=
'</strike>';
2378 $labeltoshowhtml = $outhtml;
2382 $out .= $labeltoshow;
2383 $out .=
'</option>';
2385 $outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength) . $moreinfo;
2386 $outarray2[$userstatic->id] = array(
2387 'id' => $userstatic->id,
2388 'label' => $labeltoshow,
2389 'labelhtml' => $labeltoshowhtml,
2397 $out .=
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'" disabled>';
2398 $out .=
'<option value="">' . $langs->trans(
"None") .
'</option>';
2400 $out .=
'</select>';
2402 if ($num && !$forcecombo) {
2404 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
2413 if ($outputmode == 2) {
2415 } elseif ($outputmode) {
2446 public function select_dolusers_forevent($action =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include = array(), $enableonly = array(), $force_entity =
'0', $maxlength = 0, $showstatus = 0, $morefilter =
'', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array())
2451 $userstatic =
new User($this->db);
2454 if (!empty($_SESSION[
'assignedtouser'])) {
2455 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
2456 if (!is_array($assignedtouser)) {
2457 $assignedtouser = array();
2460 $assignedtouser = array();
2462 $nbassignetouser = count($assignedtouser);
2465 if ($nbassignetouser) {
2466 $out .=
'<ul class="attendees">';
2470 foreach ($assignedtouser as $key => $value) {
2471 if ($value[
'id'] == $ownerid) {
2476 $userstatic->fetch($value[
'id']);
2477 $out .= $userstatic->getNomUrl(-1);
2479 $ownerid = $value[
'id'];
2480 $out .=
' (' . $langs->trans(
"Owner") .
')';
2482 if ($nbassignetouser > 1 && $action !=
'view') {
2483 $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 .
'">';
2486 if ($showproperties) {
2487 if ($ownerid == $value[
'id'] && is_array($listofuserid) && count($listofuserid) && in_array($ownerid, array_keys($listofuserid))) {
2488 $out .=
'<div class="myavailability inline-block">';
2489 $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>';
2499 if ($nbassignetouser) {
2504 if ($action !=
'view') {
2505 $out .=
'<input type="hidden" class="removedassignedhidden" name="removedassigned" value="">';
2506 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">jQuery(document).ready(function () {';
2507 $out .=
'jQuery(".removedassigned").click(function() { jQuery(".removedassignedhidden").val(jQuery(this).val()); });';
2508 $out .=
'jQuery(".assignedtouser").change(function() { console.log(jQuery(".assignedtouser option:selected").val());';
2509 $out .=
' if (jQuery(".assignedtouser option:selected").val() > 0) { jQuery("#' . $action .
'assignedtouser").attr("disabled", false); }';
2510 $out .=
' else { jQuery("#' . $action .
'assignedtouser").attr("disabled", true); }';
2512 $out .=
'})</script>';
2513 $out .= $this->
select_dolusers(
'', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter);
2514 $out .=
' <input type="submit" disabled class="button valignmiddle smallpaddingimp reposition" id="' . $action .
'assignedtouser" name="' . $action .
'assignedtouser" value="' .
dol_escape_htmltag($langs->trans(
"Add")) .
'">';
2541 public function select_dolresources_forevent($action =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include = array(), $enableonly = array(), $force_entity =
'0', $maxlength = 0, $showstatus = 0, $morefilter =
'', $showproperties = 0, $listofresourceid = array())
2546 require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
2547 require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
2552 if (!empty($_SESSION[
'assignedtoresource'])) {
2553 $assignedtoresource = json_decode($_SESSION[
'assignedtoresource'],
true);
2554 if (!is_array($assignedtoresource)) {
2555 $assignedtoresource = array();
2558 $assignedtoresource = array();
2560 $nbassignetoresource = count($assignedtoresource);
2563 if ($nbassignetoresource) {
2564 $out .=
'<ul class="attendees">';
2568 foreach ($assignedtoresource as $key => $value) {
2570 $resourcestatic->fetch($value[
'id']);
2571 $out .= $resourcestatic->getNomUrl(-1);
2572 if ($nbassignetoresource > 1 && $action !=
'view') {
2573 $out .=
' <input type="image" style="border: 0px;" src="' .
img_picto($langs->trans(
"Remove"),
'delete',
'', 0, 1) .
'" value="' . $resourcestatic->id .
'" class="removedassigned reposition" id="removedassignedresource_' . $resourcestatic->id .
'" name="removedassignedresource_' . $resourcestatic->id .
'">';
2576 if ($showproperties) {
2577 if (is_array($listofresourceid) && count($listofresourceid)) {
2578 $out .=
'<div class="myavailability inline-block">';
2579 $out .=
'<span class="hideonsmartphone"> - <span class="opacitymedium">' . $langs->trans(
"Availability") .
':</span> </span><input id="transparencyresource" class="paddingrightonly" ' . ($action ==
'view' ?
'disabled' :
'') .
' type="checkbox" name="transparency"' . ($listofresourceid[$value[
'id']][
'transparency'] ?
' checked' :
'') .
'><label for="transparency">' . $langs->trans(
"Busy") .
'</label>';
2589 if ($nbassignetoresource) {
2594 if ($action !=
'view') {
2595 $out .=
'<input type="hidden" class="removedassignedhidden" name="removedassignedresource" value="">';
2596 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">jQuery(document).ready(function () {';
2597 $out .=
'jQuery(".removedassignedresource").click(function() { jQuery(".removedassignedresourcehidden").val(jQuery(this).val()); });';
2598 $out .=
'jQuery(".assignedtoresource").change(function() { console.log(jQuery(".assignedtoresource option:selected").val());';
2599 $out .=
' if (jQuery(".assignedtoresource option:selected").val() > 0) { jQuery("#' . $action .
'assignedtoresource").attr("disabled", false); }';
2600 $out .=
' else { jQuery("#' . $action .
'assignedtoresource").attr("disabled", true); }';
2602 $out .=
'})</script>';
2605 $out .=
img_picto(
'',
'resource',
'class="pictofixedwidth"');
2606 $out .= $formresources->select_resource_list(0, $htmlname, [], 1, 1, 0, $events, array(), 2, 0);
2608 $out .=
' <input type="submit" disabled class="button valignmiddle smallpaddingimp reposition" id="' . $action .
'assignedtoresource" name="' . $action .
'assignedtoresource" value="' .
dol_escape_htmltag($langs->trans(
"Add")) .
'">';
2645 public function select_produits($selected = 0, $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)
2648 global $langs, $conf;
2653 $price_level = (!empty($price_level) ? $price_level : 0);
2654 if (is_null($ajaxoptions)) {
2655 $ajaxoptions = array();
2658 if (strval($filtertype) ===
'' && (isModEnabled(
"product") || isModEnabled(
"service"))) {
2659 if (isModEnabled(
"product") && !isModEnabled(
'service')) {
2661 } elseif (!isModEnabled(
'product') && isModEnabled(
"service")) {
2666 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'PRODUIT_USE_SEARCH_TO_SELECT')) {
2669 if ($selected && empty($selected_input_value)) {
2670 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
2671 $producttmpselect =
new Product($this->db);
2672 $producttmpselect->fetch($selected);
2673 $selected_input_value = $producttmpselect->ref;
2674 unset($producttmpselect);
2677 if ($filtertype ==
'') {
2678 if (!isModEnabled(
'product')) {
2680 } elseif (!isModEnabled(
'service')) {
2685 $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;
2686 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT .
'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
2688 if (isModEnabled(
'variants') && is_array($selected_combinations)) {
2692 <!-- script to auto show attributes select tags if a variant was selected -->
2693 <script nonce="' .
getNonce() .
'">
2694 // auto show attributes fields
2695 selected = ' . json_encode($selected_combinations) .
';
2698 jQuery(document).ready(function () {
2700 jQuery("input[name=\'prod_entry_mode\']").change(function () {
2701 if (jQuery(this).val() == \'free\') {
2702 jQuery(\'div#attributes_box\').empty();
2706 jQuery("input#' . $htmlname .
'").change(function () {
2708 if (!jQuery(this).val()) {
2709 jQuery(\'div#attributes_box\').empty();
2713 console.log("A change has started. We get variants fields to inject html select");
2715 jQuery.getJSON("' . DOL_URL_ROOT .
'/variants/ajax/getCombinations.php", {
2716 id: jQuery(this).val()
2717 }, function (data) {
2718 jQuery(\'div#attributes_box\').empty();
2720 jQuery.each(data, function (key, val) {
2722 combvalues[val.id] = val.values;
2724 var span = jQuery(document.createElement(\'div\')).css({
2725 \'display\': \'table-row\'
2729 jQuery(document.createElement(\'div\')).text(val.label).css({
2730 \'font-weight\': \'bold\',
2731 \'display\': \'table-cell\'
2735 var html = jQuery(document.createElement(\'select\')).attr(\'name\', \'combinations[\' + val.id + \']\').css({
2736 \'margin-left\': \'15px\',
2737 \'white-space\': \'pre\'
2739 jQuery(document.createElement(\'option\')).val(\'\')
2742 jQuery.each(combvalues[val.id], function (key, val) {
2743 var tag = jQuery(document.createElement(\'option\')).val(val.id).html(val.value);
2745 if (selected[val.fk_product_attribute] == val.id) {
2746 tag.attr(\'selected\', \'selected\');
2753 jQuery(\'div#attributes_box\').append(span);
2758 ' . ($selected ?
'jQuery("input#' . $htmlname .
'").change();' :
'') .
'
2764 if (empty($hidelabel)) {
2765 $out .= $langs->trans(
"RefOrLabel") .
' : ';
2766 } elseif ($hidelabel > 1) {
2767 $placeholder =
' placeholder="' . $langs->trans(
"RefOrLabel") .
'"';
2768 if ($hidelabel == 2) {
2769 $out .=
img_picto($langs->trans(
"Search"),
'search');
2772 $out .=
'<input type="text" class="minwidth100' . ($morecss ?
' ' . $morecss :
'') .
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . $placeholder .
' ' . (
getDolGlobalString(
'PRODUCT_SEARCH_AUTOFOCUS') ?
'autofocus' :
'') .
' />';
2773 if ($hidelabel == 3) {
2774 $out .=
img_picto($langs->trans(
"Search"),
'search');
2777 $out .= $this->
select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level,
'', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus, $status_purchase);
2780 if (empty($nooutput)) {
2804 public function select_bom($selected =
'', $htmlname =
'bom_id', $limit = 0, $status = 1, $type = 0, $showempty =
'1', $morecss =
'', $nooutput =
'', $forcecombo = 0, $TProducts = [])
2809 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
2815 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
2820 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
2822 $sql =
'SELECT b.rowid, b.ref, b.label, b.fk_product';
2823 $sql .=
' FROM ' . MAIN_DB_PREFIX .
'bom_bom as b';
2824 $sql .=
' WHERE b.entity IN (' .
getEntity(
'bom') .
')';
2825 if (!empty($status)) {
2826 $sql .=
' AND status = ' . (int) $status;
2828 if (!empty($type)) {
2829 $sql .=
' AND bomtype = ' . (int) $type;
2831 if (!empty($TProducts)) {
2832 $sql .=
' AND fk_product IN (' . $this->db->sanitize(implode(
',', $TProducts)) .
')';
2834 if (!empty($limit)) {
2835 $sql .=
' LIMIT ' . (int) $limit;
2837 $resql = $db->query($sql);
2840 $out .=
'<option value="-1"';
2841 if (empty($selected)) {
2842 $out .=
' selected';
2844 $out .=
'> </option>';
2846 while ($obj = $db->fetch_object($resql)) {
2848 $res = $product->fetch($obj->fk_product);
2849 $out .=
'<option value="' . $obj->rowid .
'"';
2850 if ($obj->rowid == $selected) {
2853 $out .=
'>' . $obj->ref .
' - ' . $product->label .
' - ' . $obj->label .
'</option>';
2859 $out .=
'</select>';
2860 if (empty($nooutput)) {
2894 public function select_produits_list($selected = 0, $htmlname =
'productid', $filtertype =
'', $limit = 20, $price_level = 0, $filterkey =
'', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty =
'1', $forcecombo = 0, $morecss =
'maxwidth500', $hidepriceinlabel = 0, $warehouseStatus =
'', $status_purchase = -1)
2898 global $hookmanager;
2901 $outarray = array();
2905 $langs->load(
'other');
2908 $warehouseStatusArray = array();
2909 if (!empty($warehouseStatus)) {
2910 require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/entrepot.class.php';
2911 if (preg_match(
'/warehouseclosed/', $warehouseStatus)) {
2914 if (preg_match(
'/warehouseopen/', $warehouseStatus)) {
2917 if (preg_match(
'/warehouseinternal/', $warehouseStatus)) {
2922 $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";
2923 if (count($warehouseStatusArray)) {
2924 $selectFieldsGrouped =
", sum(" . $this->db->ifsql(
"e.statut IS NULL",
"0",
"ps.reel") .
") as stock";
2926 $selectFieldsGrouped =
", " . $this->db->ifsql(
"p.stock IS NULL", 0,
"p.stock") .
" AS stock";
2932 $parameters = array();
2933 $reshook = $hookmanager->executeHooks(
'selectProductsListSelect', $parameters);
2934 if (empty($reshook)) {
2935 $sql .= $selectFields.$selectFieldsGrouped.$hookmanager->resPrint;
2937 $sql .= $hookmanager->resPrint;
2942 $sql .=
", (SELECT " . $this->db->prefix() .
"categorie_product.fk_categorie
2943 FROM " . $this->db->prefix() .
"categorie_product
2944 WHERE " . $this->db->prefix() .
"categorie_product.fk_product=p.rowid
2946 ) AS categorie_product_id ";
2951 $sql .=
', pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,';
2952 $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';
2953 $selectFields .=
", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx, custdefault_vat_code, custref";
2957 $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";
2958 $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';
2963 $sql .=
", pl.label as label_translated";
2964 $sql .=
", pl.description as description_translated";
2965 $selectFields .=
", label_translated";
2966 $selectFields .=
", description_translated";
2970 $sql .=
", (SELECT pp.rowid FROM " . $this->db->prefix() .
"product_price as pp WHERE pp.fk_product = p.rowid";
2971 if ($price_level >= 1 &&
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
2972 $sql .=
" AND price_level = " . ((int) $price_level);
2974 $sql .=
" ORDER BY date_price";
2975 $sql .=
" DESC LIMIT 1) as price_rowid";
2976 $sql .=
", (SELECT pp.price_by_qty FROM " . $this->db->prefix() .
"product_price as pp WHERE pp.fk_product = p.rowid";
2977 if ($price_level >= 1 &&
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
2978 $sql .=
" AND price_level = " . ((int) $price_level);
2980 $sql .=
" ORDER BY date_price";
2981 $sql .=
" DESC LIMIT 1) as price_by_qty";
2982 $selectFields .=
", price_rowid, price_by_qty";
2985 $sql .=
" FROM ".$this->db->prefix().
"product as p";
2988 $sql .=
" USE INDEX (" . $this->db->sanitize(
getDolGlobalString(
'MAIN_PRODUCT_FORCE_INDEX')) .
")";
2992 $parameters = array();
2993 $reshook = $hookmanager->executeHooks(
'selectProductsListFrom', $parameters);
2994 $sql .= $hookmanager->resPrint;
2996 if (count($warehouseStatusArray)) {
2997 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_stock as ps on ps.fk_product = p.rowid";
2998 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (" .
getEntity(
'stock') .
")";
2999 $sql .=
' AND e.statut IN (' . $this->db->sanitize($this->db->escape(implode(
',', $warehouseStatusArray))) .
')';
3004 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
3009 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_customer_price as pcp ON pcp.fk_soc=" . ((int) $socid) .
" AND pcp.fk_product=p.rowid";
3013 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_units u ON u.rowid = p.fk_unit";
3017 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_lang as pl ON pl.fk_product = p.rowid ";
3019 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
3020 $soc =
new Societe($this->db);
3021 $result = $soc->fetch($socid);
3022 if ($result > 0 && !empty($soc->default_lang)) {
3023 $sql .=
" AND pl.lang = '" . $this->db->escape($soc->default_lang) .
"'";
3025 $sql .=
" AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) .
"'";
3028 $sql .=
" AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) .
"'";
3033 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_attribute_combination pac ON pac.fk_product_child = p.rowid";
3036 $sql .=
' WHERE p.entity IN (' .
getEntity(
'product') .
')';
3039 $sql .=
" AND pac.rowid IS NULL";
3042 if ($finished == 0) {
3043 $sql .=
" AND p.finished = " . ((int) $finished);
3044 } elseif ($finished == 1) {
3045 $sql .=
" AND p.finished = ".((int) $finished);
3048 $sql .=
" AND p.tosell = ".((int) $status);
3050 if ($status_purchase >= 0) {
3051 $sql .=
" AND p.tobuy = " . ((int) $status_purchase);
3054 if (strval($filtertype) !=
'') {
3055 $sql .=
" AND p.fk_product_type = " . ((int) $filtertype);
3056 } elseif (!isModEnabled(
'product')) {
3057 $sql .=
" AND p.fk_product_type = 1";
3058 } elseif (!isModEnabled(
'service')) {
3059 $sql .=
" AND p.fk_product_type = 0";
3062 $parameters = array();
3063 $reshook = $hookmanager->executeHooks(
'selectProductsListWhere', $parameters);
3064 $sql .= $hookmanager->resPrint;
3066 if ($filterkey !=
'') {
3070 $search_crit = explode(
' ', $filterkey);
3072 if (count($search_crit) > 1) {
3075 foreach ($search_crit as $crit) {
3079 $sql .=
"(p.ref LIKE '" . $this->db->escape($prefix . $crit) .
"%' OR p.label LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3081 $sql .=
" OR pl.label LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3084 $sql .=
" OR pcp.ref_customer LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3087 $sql .=
" OR p.description LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3089 $sql .=
" OR pl.description LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3093 $sql .=
" OR pfp.ref_fourn LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3098 if (count($search_crit) > 1) {
3101 if (isModEnabled(
'barcode')) {
3102 $sql .=
" OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
3106 if (count($warehouseStatusArray)) {
3107 $sql .=
" GROUP BY " . $selectFields;
3112 $sql .=
" ORDER BY categorie_product_id ";
3114 (
getDolGlobalInt(
'PRODUCT_SORT_BY_CATEGORY') == 1) ? $sql .=
"ASC" : $sql .=
"DESC";
3116 $sql .= $this->db->order(
"p.ref");
3119 $sql .= $this->db->plimit($limit, 0);
3122 dol_syslog(get_class($this) .
"::select_produits_list search products", LOG_DEBUG);
3123 $result = $this->db->query($sql);
3125 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
3126 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3127 require_once DOL_DOCUMENT_ROOT .
'/core/lib/product.lib.php';
3129 $num = $this->db->num_rows($result);
3134 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
3138 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
3144 if ($showempty && !is_numeric($showempty)) {
3145 $textifempty = $langs->trans($showempty);
3147 $textifempty .= $langs->trans(
"All");
3150 if ($showempty && !is_numeric($showempty)) {
3151 $textifempty = $langs->trans($showempty);
3155 $out .=
'<option value="-1" selected>' . ($textifempty ? $textifempty :
' ') .
'</option>';
3159 while ($num && $i < $num) {
3162 $objp = $this->db->fetch_object($result);
3164 if ((
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY') ||
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1) {
3165 $sql =
"SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type";
3166 $sql .=
" FROM " . $this->db->prefix() .
"product_price_by_qty";
3167 $sql .=
" WHERE fk_product_price = " . ((int) $objp->price_rowid);
3168 $sql .=
" ORDER BY quantity ASC";
3170 dol_syslog(get_class($this) .
"::select_produits_list search prices by qty", LOG_DEBUG);
3171 $result2 = $this->db->query($sql);
3173 $nb_prices = $this->db->num_rows($result2);
3175 while ($nb_prices && $j < $nb_prices) {
3176 $objp2 = $this->db->fetch_object($result2);
3178 $objp->price_by_qty_rowid = $objp2->rowid;
3179 $objp->price_by_qty_price_base_type = $objp2->price_base_type;
3180 $objp->price_by_qty_quantity = $objp2->quantity;
3181 $objp->price_by_qty_unitprice = $objp2->unitprice;
3182 $objp->price_by_qty_remise_percent = $objp2->remise_percent;
3184 $objp->quantity = $objp2->quantity;
3185 $objp->price = $objp2->price;
3186 $objp->unitprice = $objp2->unitprice;
3187 $objp->remise_percent = $objp2->remise_percent;
3200 array_push($outarray, $optJson);
3204 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_price_expression)) {
3205 $price_product =
new Product($this->db);
3206 $price_product->fetch($objp->rowid,
'',
'', 1);
3208 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3210 $price_result = $priceparser->parseProduct($price_product);
3211 if ($price_result >= 0) {
3212 $objp->price = $price_result;
3213 $objp->unitprice = $price_result;
3215 $objp->price_ttc = (float)
price2num($objp->price) * (1 + ($objp->tva_tx / 100));
3216 $objp->price_ttc =
price2num($objp->price_ttc,
'MU');
3225 array_push($outarray, $optJson);
3231 $out .=
'</select>';
3233 $this->db->free($result);
3235 if (empty($outputmode)) {
3262 protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey =
'', $novirtualstock = 0)
3264 global $langs, $conf, $user;
3265 global $hookmanager;
3271 $outlabel_translated =
'';
3273 $outdesc_translated =
'';
3279 $outpricebasetype =
'';
3281 $outdefault_vat_code =
'';
3285 $maxlengtharticle = (!
getDolGlobalString(
'PRODUCT_MAX_LENGTH_COMBO') ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
3287 $label = $objp->label;
3288 if (!empty($objp->label_translated)) {
3289 $label = $objp->label_translated;
3291 if (!empty($filterkey) && $filterkey !=
'') {
3292 $label = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $label, 1);
3295 $outkey = $objp->rowid;
3296 $outref = $objp->ref;
3297 $outrefcust = empty($objp->custref) ?
'' : $objp->custref;
3298 $outlabel = $objp->label;
3299 $outdesc = $objp->description;
3301 $outlabel_translated = $objp->label_translated;
3302 $outdesc_translated = $objp->description_translated;
3304 $outbarcode = $objp->barcode;
3305 $outorigin = $objp->fk_country;
3306 $outpbq = empty($objp->price_by_qty_rowid) ?
'' : $objp->price_by_qty_rowid;
3308 $outtype = $objp->fk_product_type;
3313 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
3319 if (!empty($objp->unit_short)) {
3320 $outvalUnits .=
' - ' . $objp->unit_short;
3324 if (!empty($objp->weight) && $objp->weight_units !==
null) {
3326 $outvalUnits .=
' - ' . $unitToShow;
3328 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !==
null) {
3329 $unitToShow = $objp->length .
' x ' . $objp->width .
' x ' . $objp->height .
' ' .
measuringUnitString(0,
'size', $objp->length_units);
3330 $outvalUnits .=
' - ' . $unitToShow;
3332 if (!empty($objp->surface) && $objp->surface_units !==
null) {
3334 $outvalUnits .=
' - ' . $unitToShow;
3336 if (!empty($objp->volume) && $objp->volume_units !==
null) {
3338 $outvalUnits .=
' - ' . $unitToShow;
3341 if ($outdurationvalue && $outdurationunit) {
3343 'h' => $langs->trans(
'Hour'),
3344 'd' => $langs->trans(
'Day'),
3345 'w' => $langs->trans(
'Week'),
3346 'm' => $langs->trans(
'Month'),
3347 'y' => $langs->trans(
'Year')
3349 if (isset($da[$outdurationunit])) {
3350 $outvalUnits .=
' - ' . $outdurationvalue .
' ' . $langs->transnoentities($da[$outdurationunit] . ($outdurationvalue > 1 ?
's' :
''));
3354 $opt =
'<option value="' . $objp->rowid .
'"';
3355 $opt .= ($objp->rowid == $selected) ?
' selected' :
'';
3356 if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) {
3357 $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 .
'"';
3360 if ($user->hasRight(
'stock',
'lire')) {
3361 if ($objp->stock > 0) {
3362 $opt .=
' class="product_line_stock_ok"';
3363 } elseif ($objp->stock <= 0) {
3364 $opt .=
' class="product_line_stock_too_low"';
3369 $opt .=
' data-labeltrans="' . $outlabel_translated .
'"';
3374 if (!empty($objp->custref)) {
3375 $opt .=
' (' . $objp->custref .
')';
3378 $opt .=
' (' . $outbarcode .
')';
3380 $opt .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3382 $opt .=
' (' .
getCountry($outorigin, 1) .
')';
3385 $objRef = $objp->ref;
3386 if (!empty($objp->custref)) {
3387 $objRef .=
' (' . $objp->custref .
')';
3389 if (!empty($filterkey) && $filterkey !=
'') {
3390 $objRef = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRef, 1);
3394 $outval .=
' (' . $outbarcode .
')';
3396 $outval .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3398 $outval .=
' (' .
getCountry($outorigin, 1) .
')';
3402 $opt .= $outvalUnits;
3403 $outval .= $outvalUnits;
3410 $sql =
"SELECT price, price_ttc, price_base_type, tva_tx, default_vat_code";
3411 $sql .=
" FROM " . $this->db->prefix() .
"product_price";
3412 $sql .=
" WHERE fk_product = " . ((int) $objp->rowid);
3413 $sql .=
" AND entity IN (" .
getEntity(
'productprice') .
")";
3414 $sql .=
" AND price_level = " . ((int) $price_level);
3415 $sql .=
" ORDER BY date_price DESC, rowid DESC";
3418 dol_syslog(get_class($this) .
'::constructProductListOption search price for product ' . $objp->rowid .
' AND level ' . $price_level, LOG_DEBUG);
3419 $result2 = $this->db->query($sql);
3421 $objp2 = $this->db->fetch_object($result2);
3424 if ($objp2->price_base_type ==
'HT') {
3425 $opt .=
' - ' .
price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"HT");
3426 $outval .=
' - ' .
price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"HT");
3428 $opt .=
' - ' .
price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"TTC");
3429 $outval .=
' - ' .
price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"TTC");
3431 $outprice_ht =
price($objp2->price);
3432 $outprice_ttc =
price($objp2->price_ttc);
3433 $outpricebasetype = $objp2->price_base_type;
3435 $outtva_tx = $objp2->tva_tx;
3436 $outdefault_vat_code = $objp2->default_vat_code;
3438 $outtva_tx = $objp->tva_tx;
3439 $outdefault_vat_code = $objp->default_vat_code;
3448 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1 && (
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY') ||
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'))) {
3450 $outqty = $objp->quantity;
3451 $outdiscount = $objp->remise_percent;
3452 if ($objp->quantity == 1) {
3453 $opt .=
' - ' .
price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) .
"/";
3454 $outval .=
' - ' .
price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) .
"/";
3455 $opt .= $langs->trans(
"Unit");
3456 $outval .= $langs->transnoentities(
"Unit");
3458 $opt .=
' - ' .
price($objp->price, 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3459 $outval .=
' - ' .
price($objp->price, 0, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3460 $opt .= $langs->trans(
"Units");
3461 $outval .= $langs->transnoentities(
"Units");
3464 $outprice_ht =
price($objp->unitprice);
3465 $outprice_ttc =
price($objp->unitprice * (1 + ($objp->tva_tx / 100)));
3466 $outpricebasetype = $objp->price_base_type;
3467 $outtva_tx = $objp->tva_tx;
3468 $outdefault_vat_code = $objp->default_vat_code;
3470 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1) {
3471 $opt .=
" (" .
price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $langs->trans(
"Unit") .
")";
3472 $outval .=
" (" .
price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) .
"/" . $langs->transnoentities(
"Unit") .
")";
3474 if (empty($hidepriceinlabel) && !empty($objp->remise_percent) && $objp->remise_percent >= 1) {
3475 $opt .=
" - " . $langs->trans(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3476 $outval .=
" - " . $langs->transnoentities(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3481 if (!empty($objp->idprodcustprice)) {
3484 if ($objp->custprice_base_type ==
'HT') {
3485 $opt .=
' - ' .
price($objp->custprice, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"HT");
3486 $outval .=
' - ' .
price($objp->custprice, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"HT");
3488 $opt .=
' - ' .
price($objp->custprice_ttc, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"TTC");
3489 $outval .=
' - ' .
price($objp->custprice_ttc, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"TTC");
3492 $outprice_ht =
price($objp->custprice);
3493 $outprice_ttc =
price($objp->custprice_ttc);
3494 $outpricebasetype = $objp->custprice_base_type;
3495 $outtva_tx = $objp->custtva_tx;
3496 $outdefault_vat_code = $objp->custdefault_vat_code;
3501 if (empty($hidepriceinlabel) && !$found) {
3502 if ($objp->price_base_type ==
'HT') {
3503 $opt .=
' - ' .
price($objp->price, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"HT");
3504 $outval .=
' - ' .
price($objp->price, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"HT");
3506 $opt .=
' - ' .
price($objp->price_ttc, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"TTC");
3507 $outval .=
' - ' .
price($objp->price_ttc, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"TTC");
3509 $outprice_ht =
price($objp->price);
3510 $outprice_ttc =
price($objp->price_ttc);
3511 $outpricebasetype = $objp->price_base_type;
3512 $outtva_tx = $objp->tva_tx;
3513 $outdefault_vat_code = $objp->default_vat_code;
3517 if ($user->hasRight(
'stock',
'lire')) {
3518 $opt .=
' - ' . $langs->trans(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'), 0, $langs, 0, 0);
3520 if ($objp->stock > 0) {
3521 $outval .=
' - <span class="product_line_stock_ok">';
3522 } elseif ($objp->stock <= 0) {
3523 $outval .=
' - <span class="product_line_stock_too_low">';
3525 $outval .= $langs->transnoentities(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'));
3526 $outval .=
'</span>';
3527 if (empty($novirtualstock) &&
getDolGlobalString(
'STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO')) {
3528 $langs->load(
"stocks");
3530 $tmpproduct =
new Product($this->db);
3531 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3532 $tmpproduct->load_virtual_stock();
3533 $virtualstock = $tmpproduct->stock_theorique;
3535 $opt .=
' - ' . $langs->trans(
"VirtualStock") .
':' . $virtualstock;
3537 $outval .=
' - ' . $langs->transnoentities(
"VirtualStock") .
':';
3538 if ($virtualstock > 0) {
3539 $outval .=
'<span class="product_line_stock_ok">';
3540 } elseif ($virtualstock <= 0) {
3541 $outval .=
'<span class="product_line_stock_too_low">';
3543 $outval .= $virtualstock;
3544 $outval .=
'</span>';
3551 $parameters = array(
'objp' => $objp);
3552 $reshook = $hookmanager->executeHooks(
'constructProductListOption', $parameters);
3553 if (empty($reshook)) {
3554 $opt .= $hookmanager->resPrint;
3556 $opt = $hookmanager->resPrint;
3559 $opt .=
"</option>\n";
3564 'label2' => $outlabel,
3568 'price_ttc' =>
price2num($outprice_ttc),
3571 'pricebasetype' => $outpricebasetype,
3572 'tva_tx' => $outtva_tx,
3573 'default_vat_code' => $outdefault_vat_code,
3575 'discount' => $outdiscount,
3576 'duration_value' => $outdurationvalue,
3577 'duration_unit' => $outdurationunit,
3579 'labeltrans' => $outlabel_translated,
3580 'desctrans' => $outdesc_translated,
3581 'ref_customer' => $outrefcust
3602 public function select_produits_fournisseurs($socid, $selected =
'', $htmlname =
'productid', $filtertype =
'', $filtre =
'', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss =
'', $placeholder =
'')
3605 global $langs, $conf;
3606 global $price_level, $status, $finished;
3608 if (!isset($status)) {
3612 $selected_input_value =
'';
3613 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'PRODUIT_USE_SEARCH_TO_SELECT')) {
3614 if ($selected > 0) {
3615 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
3616 $producttmpselect =
new Product($this->db);
3617 $producttmpselect->fetch($selected);
3618 $selected_input_value = $producttmpselect->ref;
3619 unset($producttmpselect);
3623 $urloption = ($socid > 0 ?
'socid=' . $socid .
'&' :
'') .
'htmlname=' . $htmlname .
'&outjson=1&price_level=' . $price_level .
'&type=' . $filtertype .
'&mode=2&status=' . $status .
'&finished=' . $finished .
'&alsoproductwithnosupplierprice=' . $alsoproductwithnosupplierprice;
3626 print($hidelabel ?
'' : $langs->trans(
"RefOrLabel") .
' : ') .
'<input type="text" class="'.$morecss.
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . ($placeholder ?
' placeholder="' . $placeholder .
'"' :
'') .
'>';
3628 print $this->
select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre,
'', $status, 0, 0, $alsoproductwithnosupplierprice, $morecss, 0, $placeholder);
3652 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 =
'')
3655 global $langs, $conf, $user;
3656 global $hookmanager;
3659 $outarray = array();
3661 $maxlengtharticle = (!
getDolGlobalString(
'PRODUCT_MAX_LENGTH_COMBO') ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
3663 $langs->load(
'stocks');
3666 $langs->load(
'other');
3669 $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,";
3670 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice, pfp.barcode";
3671 $sql .=
", pfp.multicurrency_code, pfp.multicurrency_unitprice";
3672 $sql .=
", pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.default_vat_code, pfp.fk_soc, s.nom as name";
3673 $sql .=
", pfp.supplier_reputation";
3676 $sql .=
", pfp.desc_fourn as description";
3678 $sql .=
", p.description";
3682 $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";
3684 $sql .=
" FROM " . $this->db->prefix() .
"product as p";
3685 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (" .
getEntity(
'product') .
") )";
3687 $sql .=
" AND pfp.fk_soc = " . ((int) $socid);
3689 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON pfp.fk_soc = s.rowid";
3692 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_units u ON u.rowid = p.fk_unit";
3694 $sql .=
" WHERE p.entity IN (" .
getEntity(
'product') .
")";
3695 if ($statut != -1) {
3696 $sql .=
" AND p.tobuy = " . ((int) $statut);
3698 if (strval($filtertype) !=
'') {
3699 $sql .=
" AND p.fk_product_type = " . ((int) $filtertype);
3701 if (!empty($filtre)) {
3702 $sql .=
" " . $filtre;
3705 $parameters = array();
3706 $reshook = $hookmanager->executeHooks(
'selectSuppliersProductsListWhere', $parameters);
3707 $sql .= $hookmanager->resPrint;
3709 if ($filterkey !=
'') {
3713 $search_crit = explode(
' ', $filterkey);
3715 if (count($search_crit) > 1) {
3718 foreach ($search_crit as $crit) {
3722 $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) .
"%'";
3724 $sql .=
" OR pfp.desc_fourn LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3729 if (count($search_crit) > 1) {
3732 if (isModEnabled(
'barcode')) {
3733 $sql .=
" OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
3734 $sql .=
" OR pfp.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
3738 $sql .=
" ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
3739 $sql .= $this->db->plimit($limit, 0);
3743 dol_syslog(get_class($this) .
"::select_produits_fournisseurs_list", LOG_DEBUG);
3744 $result = $this->db->query($sql);
3746 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3747 require_once DOL_DOCUMENT_ROOT .
'/core/lib/product.lib.php';
3749 $num = $this->db->num_rows($result);
3752 $out .=
'<select class="flat ' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'">';
3754 $out .=
'<option value="-1" selected>' . ($placeholder ? $placeholder :
' ') .
'</option>';
3756 $out .=
'<option value="-1">' . ($placeholder ? $placeholder :
' ') .
'</option>';
3761 $objp = $this->db->fetch_object($result);
3763 if (is_null($objp->idprodfournprice)) {
3765 $objp->tva_tx = $objp->tva_tx_sale;
3766 $objp->default_vat_code = $objp->default_vat_code_sale;
3769 $outkey = $objp->idprodfournprice;
3770 if (!$outkey && $alsoproductwithnosupplierprice) {
3771 $outkey =
'idprod_' . $objp->rowid;
3774 $outref = $objp->ref;
3775 $outbarcode = $objp->barcode;
3778 $outtype = $objp->fk_product_type;
3785 if (!empty($objp->unit_short)) {
3786 $outvalUnits .=
' - ' . $objp->unit_short;
3788 if (!empty($objp->weight) && $objp->weight_units !==
null) {
3790 $outvalUnits .=
' - ' . $unitToShow;
3792 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !==
null) {
3793 $unitToShow = $objp->length .
' x ' . $objp->width .
' x ' . $objp->height .
' ' .
measuringUnitString(0,
'size', $objp->length_units);
3794 $outvalUnits .=
' - ' . $unitToShow;
3796 if (!empty($objp->surface) && $objp->surface_units !==
null) {
3798 $outvalUnits .=
' - ' . $unitToShow;
3800 if (!empty($objp->volume) && $objp->volume_units !==
null) {
3802 $outvalUnits .=
' - ' . $unitToShow;
3804 if ($outdurationvalue && $outdurationunit) {
3806 'h' => $langs->trans(
'Hour'),
3807 'd' => $langs->trans(
'Day'),
3808 'w' => $langs->trans(
'Week'),
3809 'm' => $langs->trans(
'Month'),
3810 'y' => $langs->trans(
'Year')
3812 if (isset($da[$outdurationunit])) {
3813 $outvalUnits .=
' - ' . $outdurationvalue .
' ' . $langs->transnoentities($da[$outdurationunit] . ($outdurationvalue > 1 ?
's' :
''));
3818 $objRef = $objp->ref;
3819 if ($filterkey && $filterkey !=
'') {
3820 $objRef = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRef, 1);
3822 $objRefFourn = $objp->ref_fourn;
3823 if ($filterkey && $filterkey !=
'') {
3824 $objRefFourn = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRefFourn, 1);
3826 $label = $objp->label;
3827 if ($filterkey && $filterkey !=
'') {
3828 $label = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $label, 1);
3831 switch ($objp->fk_product_type) {
3843 if (empty($picto)) {
3846 $optlabel =
img_object(
'', $picto,
'class="paddingright classfortooltip"', 0, 0, 1);
3849 $optlabel .= $objp->ref;
3850 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
3851 $optlabel .=
' <span class="opacitymedium">(' . $objp->ref_fourn .
')</span>';
3853 if (isModEnabled(
'barcode') && !empty($objp->barcode)) {
3854 $optlabel .=
' (' . $outbarcode .
')';
3856 $optlabel .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3858 $outvallabel = $objRef;
3859 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
3860 $outvallabel .=
' (' . $objRefFourn .
')';
3862 if (isModEnabled(
'barcode') && !empty($objp->barcode)) {
3863 $outvallabel .=
' (' . $outbarcode .
')';
3865 $outvallabel .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3868 $optlabel .= $outvalUnits;
3869 $outvallabel .= $outvalUnits;
3871 if (!empty($objp->idprodfournprice)) {
3872 $outqty = $objp->quantity;
3873 $outdiscount = $objp->remise_percent;
3874 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_supplier_price_expression)) {
3876 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
3877 $prod_supplier->id = $objp->fk_product;
3878 $prod_supplier->fourn_qty = $objp->quantity;
3879 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
3880 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
3882 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3884 $price_result = $priceparser->parseProductSupplier($prod_supplier);
3885 if ($price_result >= 0) {
3886 $objp->fprice = $price_result;
3887 if ($objp->quantity >= 1) {
3888 $objp->unitprice = $objp->fprice / $objp->quantity;
3892 if ($objp->quantity == 1) {
3893 $optlabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/";
3894 $outvallabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency) .
"/";
3895 $optlabel .= $langs->trans(
"Unit");
3896 $outvallabel .= $langs->transnoentities(
"Unit");
3898 $optlabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3899 $outvallabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3900 $optlabel .=
' ' . $langs->trans(
"Units");
3901 $outvallabel .=
' ' . $langs->transnoentities(
"Units");
3904 if ($objp->quantity > 1) {
3905 $optlabel .=
" (" .
price($objp->unitprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $langs->trans(
"Unit") .
")";
3906 $outvallabel .=
" (" .
price($objp->unitprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency) .
"/" . $langs->transnoentities(
"Unit") .
")";
3908 if ($objp->remise_percent >= 1) {
3909 $optlabel .=
" - " . $langs->trans(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3910 $outvallabel .=
" - " . $langs->transnoentities(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3912 if ($objp->duration) {
3913 $optlabel .=
" - " . $objp->duration;
3914 $outvallabel .=
" - " . $objp->duration;
3917 $optlabel .=
" - " .
dol_trunc($objp->name, 8);
3918 $outvallabel .=
" - " .
dol_trunc($objp->name, 8);
3920 if ($objp->supplier_reputation) {
3922 $reputations = array(
'' => $langs->trans(
'Standard'),
'FAVORITE' => $langs->trans(
'Favorite'),
'NOTTHGOOD' => $langs->trans(
'NotTheGoodQualitySupplier'),
'DONOTORDER' => $langs->trans(
'DoNotOrderThisProductToThisSupplier'));
3924 $optlabel .=
" - " . $reputations[$objp->supplier_reputation];
3925 $outvallabel .=
" - " . $reputations[$objp->supplier_reputation];
3928 $optlabel .=
" - <span class='opacitymedium'>" . $langs->trans(
"NoPriceDefinedForThisSupplier") .
'</span>';
3929 $outvallabel .=
' - ' . $langs->transnoentities(
"NoPriceDefinedForThisSupplier");
3933 $novirtualstock = ($showstockinlist == 2);
3935 if ($user->hasRight(
'stock',
'lire')) {
3936 $outvallabel .=
' - ' . $langs->trans(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'));
3938 if ($objp->stock > 0) {
3939 $optlabel .=
' - <span class="product_line_stock_ok">';
3940 } elseif ($objp->stock <= 0) {
3941 $optlabel .=
' - <span class="product_line_stock_too_low">';
3943 $optlabel .= $langs->transnoentities(
"Stock") .
':' .
price(
price2num($objp->stock,
'MS'));
3944 $optlabel .=
'</span>';
3945 if (empty($novirtualstock) &&
getDolGlobalString(
'STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO')) {
3946 $langs->load(
"stocks");
3948 $tmpproduct =
new Product($this->db);
3949 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3950 $tmpproduct->load_virtual_stock();
3951 $virtualstock = $tmpproduct->stock_theorique;
3953 $outvallabel .=
' - ' . $langs->trans(
"VirtualStock") .
':' . $virtualstock;
3955 $optlabel .=
' - ' . $langs->transnoentities(
"VirtualStock") .
':';
3956 if ($virtualstock > 0) {
3957 $optlabel .=
'<span class="product_line_stock_ok">';
3958 } elseif ($virtualstock <= 0) {
3959 $optlabel .=
'<span class="product_line_stock_too_low">';
3961 $optlabel .= $virtualstock;
3962 $optlabel .=
'</span>';
3969 $optstart =
'<option value="' . $outkey .
'"';
3970 if ($selected && $selected == $objp->idprodfournprice) {
3971 $optstart .=
' selected';
3973 if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) {
3974 $optstart .=
' disabled';
3977 if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
3986 $optstart .=
' data-default-vat-code="' .
dol_escape_htmltag($objp->default_vat_code) .
'"';
3988 if (isModEnabled(
'multicurrency')) {
3989 $optstart .=
' data-multicurrency-code="' .
dol_escape_htmltag($objp->multicurrency_code) .
'"';
3990 $optstart .=
' data-multicurrency-up="' .
dol_escape_htmltag($objp->multicurrency_unitprice) .
'"';
3993 $optstart .=
' data-description="' .
dol_escape_htmltag($objp->description, 0, 1) .
'"';
3995 $outarrayentry = array(
3998 'label' => $outvallabel,
4000 'price_qty_ht' =>
price2num($objp->fprice,
'MU'),
4001 'price_unit_ht' =>
price2num($objp->unitprice,
'MU'),
4002 'price_ht' =>
price2num($objp->unitprice,
'MU'),
4003 'tva_tx_formated' =>
price($objp->tva_tx, 0, $langs, 1, -1, 2),
4005 'default_vat_code' => $objp->default_vat_code,
4006 'supplier_ref' => $objp->ref_fourn,
4007 'discount' => $outdiscount,
4009 'duration_value' => $outdurationvalue,
4010 'duration_unit' => $outdurationunit,
4011 'disabled' => empty($objp->idprodfournprice),
4012 'description' => $objp->description
4014 if (isModEnabled(
'multicurrency')) {
4015 $outarrayentry[
'multicurrency_code'] = $objp->multicurrency_code;
4016 $outarrayentry[
'multicurrency_unitprice'] =
price2num($objp->multicurrency_unitprice,
'MU');
4019 $parameters = array(
4021 'optstart' => &$optstart,
4022 'optlabel' => &$optlabel,
4023 'outvallabel' => &$outvallabel,
4024 'outarrayentry' => &$outarrayentry
4026 $reshook = $hookmanager->executeHooks(
'selectProduitsFournisseurListOption', $parameters, $this);
4032 $out .= $optstart .
' data-html="' .
dol_escape_htmltag($optlabel) .
'">' . $optlabel .
"</option>\n";
4033 $outarraypush = array(
4036 'label' => $outvallabel,
4038 'price_qty_ht' =>
price2num($objp->fprice,
'MU'),
4039 'price_qty_ht_locale' =>
price($objp->fprice),
4040 'price_unit_ht' =>
price2num($objp->unitprice,
'MU'),
4041 'price_unit_ht_locale' =>
price($objp->unitprice),
4042 'price_ht' =>
price2num($objp->unitprice,
'MU'),
4043 'tva_tx_formated' =>
price($objp->tva_tx),
4045 'default_vat_code' => $objp->default_vat_code,
4046 'supplier_ref' => $objp->ref_fourn,
4047 'discount' => $outdiscount,
4049 'duration_value' => $outdurationvalue,
4050 'duration_unit' => $outdurationunit,
4051 'disabled' => (empty($objp->idprodfournprice) ?
true :
false),
4052 'description' => $objp->description
4054 if (isModEnabled(
'multicurrency')) {
4055 $outarraypush[
'multicurrency_code'] = $objp->multicurrency_code;
4056 $outarraypush[
'multicurrency_unitprice'] =
price2num($objp->multicurrency_unitprice,
'MU');
4058 array_push($outarray, $outarraypush);
4071 $out .=
'</select>';
4073 $this->db->free($result);
4075 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
4081 if (empty($outputmode)) {
4100 global $langs, $conf;
4102 $langs->load(
'stocks');
4104 $sql =
"SELECT p.rowid, p.ref, p.label, p.price, p.duration, pfp.fk_soc,";
4105 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,";
4106 $sql .=
" pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name";
4107 $sql .=
" FROM " . $this->db->prefix() .
"product as p";
4108 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
4109 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON pfp.fk_soc = s.rowid";
4110 $sql .=
" WHERE pfp.entity IN (" .
getEntity(
'productsupplierprice') .
")";
4111 $sql .=
" AND p.tobuy = 1";
4112 $sql .=
" AND s.fournisseur = 1";
4113 $sql .=
" AND p.rowid = " . ((int) $productid);
4115 $sql .=
" ORDER BY s.nom, pfp.ref_fourn DESC";
4117 $sql .=
" ORDER BY pfp.unitprice ASC";
4120 dol_syslog(get_class($this) .
"::select_product_fourn_price", LOG_DEBUG);
4121 $result = $this->db->query($sql);
4124 $num = $this->db->num_rows($result);
4126 $form =
'<select class="flat" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
4129 $form .=
'<option value="0">-- ' . $langs->trans(
"NoSupplierPriceDefinedForThisProduct") .
' --</option>';
4131 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
4132 $form .=
'<option value="0"> </option>';
4136 $objp = $this->db->fetch_object($result);
4138 $opt =
'<option value="' . $objp->idprodfournprice .
'"';
4140 if ($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier) || ($i == 0 &&
getDolGlobalString(
'PRODUCT_BEST_SUPPLIER_PRICE_PRESELECTED'))) {
4141 $opt .=
' selected';
4143 $opt .=
'>' . $objp->name .
' - ' . $objp->ref_fourn .
' - ';
4145 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_supplier_price_expression)) {
4147 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
4148 $prod_supplier->id = $productid;
4149 $prod_supplier->fourn_qty = $objp->quantity;
4150 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
4151 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
4153 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
4155 $price_result = $priceparser->parseProductSupplier($prod_supplier);
4156 if ($price_result >= 0) {
4157 $objp->fprice = $price_result;
4158 if ($objp->quantity >= 1) {
4159 $objp->unitprice = $objp->fprice / $objp->quantity;
4163 if ($objp->quantity == 1) {
4164 $opt .=
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/";
4167 $opt .= $objp->quantity .
' ';
4169 if ($objp->quantity == 1) {
4170 $opt .= $langs->trans(
"Unit");
4172 $opt .= $langs->trans(
"Units");
4174 if ($objp->quantity > 1) {
4176 $opt .=
price($objp->unitprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $langs->trans(
"Unit");
4178 if ($objp->duration) {
4179 $opt .=
" - " . $objp->duration;
4181 $opt .=
"</option>\n";
4188 $form .=
'</select>';
4189 $this->db->free($result);
4209 $num = count($this->cache_conditions_paiements);
4216 $sql =
"SELECT rowid, code, libelle as label, deposit_percent";
4217 $sql .=
" FROM " . $this->db->prefix() .
'c_payment_term';
4218 $sql .=
" WHERE entity IN (" .
getEntity(
'c_payment_term') .
")";
4219 $sql .=
" AND active > 0";
4220 $sql .=
" ORDER BY sortorder";
4222 $resql = $this->db->query($sql);
4224 $num = $this->db->num_rows($resql);
4227 $obj = $this->db->fetch_object($resql);
4230 $label = ($langs->trans(
"PaymentConditionShort" . $obj->code) !=
"PaymentConditionShort" . $obj->code ? $langs->trans(
"PaymentConditionShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4231 $this->cache_conditions_paiements[$obj->rowid][
'code'] = $obj->code;
4232 $this->cache_conditions_paiements[$obj->rowid][
'label'] = $label;
4233 $this->cache_conditions_paiements[$obj->rowid][
'deposit_percent'] = $obj->deposit_percent;
4258 $num = count($this->cache_availability);
4265 $langs->load(
'propal');
4267 $sql =
"SELECT rowid, code, label, position";
4268 $sql .=
" FROM " . $this->db->prefix() .
'c_availability';
4269 $sql .=
" WHERE active > 0";
4271 $resql = $this->db->query($sql);
4273 $num = $this->db->num_rows($resql);
4276 $obj = $this->db->fetch_object($resql);
4279 $label = ($langs->trans(
"AvailabilityType" . $obj->code) !=
"AvailabilityType" . $obj->code ? $langs->trans(
"AvailabilityType" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4280 $this->cache_availability[$obj->rowid][
'code'] = $obj->code;
4281 $this->cache_availability[$obj->rowid][
'label'] = $label;
4282 $this->cache_availability[$obj->rowid][
'position'] = $obj->position;
4286 $this->cache_availability =
dol_sort_array($this->cache_availability,
'position',
'asc', 0, 0, 1);
4307 global $langs, $user;
4311 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
4313 print
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4315 print
'<option value="0"> </option>';
4317 foreach ($this->cache_availability as $id => $arrayavailability) {
4318 if ($selected == $id) {
4319 print
'<option value="' . $id .
'" selected>';
4321 print
'<option value="' . $id .
'">';
4328 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4342 $num = count($this->cache_demand_reason);
4347 $sql =
"SELECT rowid, code, label";
4348 $sql .=
" FROM " . $this->db->prefix() .
'c_input_reason';
4349 $sql .=
" WHERE active > 0";
4351 $resql = $this->db->query($sql);
4353 $num = $this->db->num_rows($resql);
4355 $tmparray = array();
4357 $obj = $this->db->fetch_object($resql);
4360 $label = ($obj->label !=
'-' ? $obj->label :
'');
4361 if ($langs->trans(
"DemandReasonType" . $obj->code) !=
"DemandReasonType" . $obj->code) {
4362 $label = $langs->trans(
"DemandReasonType" . $obj->code);
4364 if ($langs->trans($obj->code) != $obj->code) {
4365 $label = $langs->trans($obj->code);
4368 $tmparray[$obj->rowid][
'id'] = $obj->rowid;
4369 $tmparray[$obj->rowid][
'code'] = $obj->code;
4370 $tmparray[$obj->rowid][
'label'] = $label;
4374 $this->cache_demand_reason =
dol_sort_array($tmparray,
'label',
'asc', 0, 0, 1);
4396 public function selectInputReason($selected =
'', $htmlname =
'demandreasonid', $exclude =
'', $addempty = 0, $morecss =
'', $notooltip = 0)
4398 global $langs, $user;
4402 print
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
4404 print
'<option value="0"' . (empty($selected) ?
' selected' :
'') .
'> </option>';
4406 foreach ($this->cache_demand_reason as $id => $arraydemandreason) {
4407 if ($arraydemandreason[
'code'] == $exclude) {
4411 if ($selected && ($selected == $arraydemandreason[
'id'] || $selected == $arraydemandreason[
'code'])) {
4412 print
'<option value="' . $arraydemandreason[
'id'] .
'" selected>';
4414 print
'<option value="' . $arraydemandreason[
'id'] .
'">';
4416 $label = $arraydemandreason[
'label'];
4417 print $langs->trans($label);
4421 if ($user->admin && empty($notooltip)) {
4422 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4439 $num = count($this->cache_types_paiements);
4446 $this->cache_types_paiements = array();
4448 $sql =
"SELECT id, code, libelle as label, type, active";
4449 $sql .=
" FROM " . $this->db->prefix() .
"c_paiement";
4450 $sql .=
" WHERE entity IN (" .
getEntity(
'c_paiement') .
")";
4452 $resql = $this->db->query($sql);
4454 $num = $this->db->num_rows($resql);
4457 $obj = $this->db->fetch_object($resql);
4460 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) !=
"PaymentTypeShort" . $obj->code ? $langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4461 $this->cache_types_paiements[$obj->id][
'id'] = $obj->id;
4462 $this->cache_types_paiements[$obj->id][
'code'] = $obj->code;
4463 $this->cache_types_paiements[$obj->id][
'label'] = $label;
4464 $this->cache_types_paiements[$obj->id][
'type'] = $obj->type;
4465 $this->cache_types_paiements[$obj->id][
'active'] = $obj->active;
4469 $this->cache_types_paiements =
dol_sort_array($this->cache_types_paiements,
'label',
'asc', 0, 0, 1);
4499 public function select_conditions_paiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1, $noprint = 0)
4503 if (empty($noprint)) {
4527 public function getSelectConditionsPaiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1)
4529 global $langs, $user, $conf;
4532 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
4538 dol_syslog(__METHOD__ .
"Using deprecated option MAIN_DEFAULT_PAYMENT_TERM_ID", LOG_NOTICE);
4542 $out .=
'<select id="' . $htmlname .
'" class="flat selectpaymentterms' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4544 $out .=
'<option value="0"> </option>';
4547 $selectedDepositPercent =
null;
4549 foreach ($this->cache_conditions_paiements as $id => $arrayconditions) {
4550 if ($filtertype <= 0 && !empty($arrayconditions[
'deposit_percent'])) {
4554 if ($selected == $id) {
4555 $selectedDepositPercent = $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'];
4556 $out .=
'<option value="' . $id .
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'" selected>';
4558 $out .=
'<option value="' . $id .
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'">';
4560 $label = $arrayconditions[
'label'];
4562 if (!empty($arrayconditions[
'deposit_percent'])) {
4563 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'], $label);
4567 $out .=
'</option>';
4569 $out .=
'</select>';
4570 if ($user->admin && empty($noinfoadmin)) {
4571 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4575 if ($deposit_percent >= 0) {
4576 $out .=
' <span id="' . $htmlname .
'_deposit_percent_container"' . (empty($selectedDepositPercent) ?
' style="display: none"' :
'') .
'>';
4577 $out .= $langs->trans(
'DepositPercent') .
' : ';
4578 $out .=
'<input id="' . $htmlname .
'_deposit_percent" name="' . $htmlname .
'_deposit_percent" class="maxwidth50" value="' . $deposit_percent .
'" />';
4581 <script nonce="' .
getNonce() .
'">
4582 $(document).ready(function () {
4583 $("#' . $htmlname .
'").change(function () {
4584 let $selected = $(this).find("option:selected");
4585 let depositPercent = $selected.attr("data-deposit_percent");
4587 if (depositPercent.length > 0) {
4588 $("#' . $htmlname .
'_deposit_percent_container").show().find("#' . $htmlname .
'_deposit_percent").val(depositPercent);
4590 $("#' . $htmlname .
'_deposit_percent_container").hide();
4621 public function select_types_paiements($selected =
'', $htmlname =
'paiementtype', $filtertype =
'', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'', $nooutput = 0)
4624 global $langs, $user, $conf;
4628 dol_syslog(__METHOD__ .
" " . $selected .
", " . $htmlname .
", " . $filtertype .
", " . $format, LOG_DEBUG);
4630 $filterarray = array();
4631 if ($filtertype ==
'CRDT') {
4632 $filterarray = array(0, 2, 3);
4633 } elseif ($filtertype ==
'DBIT') {
4634 $filterarray = array(1, 2, 3);
4635 } elseif ($filtertype !=
'' && $filtertype !=
'-1') {
4636 $filterarray = explode(
',', $filtertype);
4643 dol_syslog(__METHOD__ .
"Using deprecated option MAIN_DEFAULT_PAYMENT_TYPE_ID", LOG_NOTICE);
4647 $out .=
'<select id="select' . $htmlname .
'" class="flat selectpaymenttypes' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4649 $out .=
'<option value=""> </option>';
4651 foreach ($this->cache_types_paiements as $id => $arraytypes) {
4653 if ($active >= 0 && $arraytypes[
'active'] != $active) {
4658 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
4663 if ($empty && empty($arraytypes[
'code'])) {
4668 $out .=
'<option value="' . $id .
'"';
4669 } elseif ($format == 1) {
4670 $out .=
'<option value="' . $arraytypes[
'code'] .
'"';
4671 } elseif ($format == 2) {
4672 $out .=
'<option value="' . $arraytypes[
'code'] .
'"';
4673 } elseif ($format == 3) {
4674 $out .=
'<option value="' . $id .
'"';
4677 if ($format == 1 || $format == 2) {
4678 if ($selected == $arraytypes[
'code']) {
4679 $out .=
' selected';
4682 if ($selected == $id) {
4683 $out .=
' selected';
4689 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4690 } elseif ($format == 1) {
4691 $value = $arraytypes[
'code'];
4692 } elseif ($format == 2) {
4693 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4694 } elseif ($format == 3) {
4695 $value = $arraytypes[
'code'];
4697 $out .= $value ? $value :
' ';
4698 $out .=
'</option>';
4700 $out .=
'</select>';
4701 if ($user->admin && !$noadmininfo) {
4702 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4706 if (empty($nooutput)) {
4726 $return =
'<select class="flat maxwidth100" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
4728 'HT' => $langs->trans(
"HT"),
4729 'TTC' => $langs->trans(
"TTC")
4731 foreach ($options as $id => $value) {
4732 if ($selected == $id) {
4733 $return .=
'<option value="' . $id .
'" selected>' . $value;
4735 $return .=
'<option value="' . $id .
'">' . $value;
4737 $return .=
'</option>';
4739 $return .=
'</select>';
4759 $num = count($this->cache_transport_mode);
4766 $this->cache_transport_mode = array();
4768 $sql =
"SELECT rowid, code, label, active";
4769 $sql .=
" FROM " . $this->db->prefix() .
"c_transport_mode";
4770 $sql .=
" WHERE entity IN (" .
getEntity(
'c_transport_mode') .
")";
4772 $resql = $this->db->query($sql);
4774 $num = $this->db->num_rows($resql);
4777 $obj = $this->db->fetch_object($resql);
4780 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) !=
"PaymentTypeShort" . $obj->code ? $langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4781 $this->cache_transport_mode[$obj->rowid][
'rowid'] = $obj->rowid;
4782 $this->cache_transport_mode[$obj->rowid][
'code'] = $obj->code;
4783 $this->cache_transport_mode[$obj->rowid][
'label'] = $label;
4784 $this->cache_transport_mode[$obj->rowid][
'active'] = $obj->active;
4788 $this->cache_transport_mode =
dol_sort_array($this->cache_transport_mode,
'label',
'asc', 0, 0, 1);
4810 public function selectTransportMode($selected =
'', $htmlname =
'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'')
4812 global $langs, $user;
4814 dol_syslog(__METHOD__ .
" " . $selected .
", " . $htmlname .
", " . $format, LOG_DEBUG);
4818 print
'<select id="select' . $htmlname .
'" class="flat selectmodetransport' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4820 print
'<option value=""> </option>';
4822 foreach ($this->cache_transport_mode as $id => $arraytypes) {
4824 if ($active >= 0 && $arraytypes[
'active'] != $active) {
4829 if ($empty && empty($arraytypes[
'code'])) {
4834 print
'<option value="' . $id .
'"';
4835 } elseif ($format == 1) {
4836 print
'<option value="' . $arraytypes[
'code'] .
'"';
4837 } elseif ($format == 2) {
4838 print
'<option value="' . $arraytypes[
'code'] .
'"';
4839 } elseif ($format == 3) {
4840 print
'<option value="' . $id .
'"';
4843 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraytypes[
'code']) {
4845 } elseif ($selected == $id) {
4851 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4852 } elseif ($format == 1) {
4853 $value = $arraytypes[
'code'];
4854 } elseif ($format == 2) {
4855 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4856 } elseif ($format == 3) {
4857 $value = $arraytypes[
'code'];
4859 print $value ? $value :
' ';
4863 if ($user->admin && !$noadmininfo) {
4864 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4880 public function selectShippingMethod($selected =
'', $htmlname =
'shipping_method_id', $filtre =
'', $useempty = 0, $moreattrib =
'', $noinfoadmin = 0, $morecss =
'')
4882 global $langs, $user;
4884 $langs->load(
"admin");
4885 $langs->load(
"deliveries");
4887 $sql =
"SELECT rowid, code, libelle as label";
4888 $sql .=
" FROM " . $this->db->prefix() .
"c_shipment_mode";
4889 $sql .=
" WHERE active > 0";
4891 $sql .=
" AND " . $filtre;
4893 $sql .=
" ORDER BY libelle ASC";
4895 dol_syslog(get_class($this) .
"::selectShippingMode", LOG_DEBUG);
4896 $result = $this->db->query($sql);
4898 $num = $this->db->num_rows($result);
4901 print
'<select id="select' . $htmlname .
'" class="flat selectshippingmethod' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
4902 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
4903 print
'<option value="-1"> </option>';
4906 $obj = $this->db->fetch_object($result);
4907 if ($selected == $obj->rowid) {
4908 print
'<option value="' . $obj->rowid .
'" selected>';
4910 print
'<option value="' . $obj->rowid .
'">';
4912 print ($langs->trans(
"SendingMethod" . strtoupper($obj->code)) !=
"SendingMethod" . strtoupper($obj->code)) ? $langs->trans(
"SendingMethod" . strtoupper($obj->code)) : $obj->label;
4917 if ($user->admin && empty($noinfoadmin)) {
4918 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4923 print $langs->trans(
"NoShippingMethodDefined");
4943 $langs->load(
"deliveries");
4945 if ($htmlname !=
"none") {
4946 print
'<form method="POST" action="' . $page .
'">';
4947 print
'<input type="hidden" name="action" value="setshippingmethod">';
4948 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
4950 print
'<input type="submit" class="button valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
4954 $code = $langs->getLabelFromKey($this->db, $selected,
'c_shipment_mode',
'rowid',
'code');
4955 print $langs->trans(
"SendingMethod" . strtoupper($code));
4974 $langs->load(
'bills');
4976 $opt =
'<option value="" selected></option>';
4977 $sql =
"SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc";
4978 $sql .=
' FROM ' . $this->db->prefix() .
'facture';
4979 $sql .=
' WHERE entity IN (' .
getEntity(
'invoice') .
')';
4980 $sql .=
' AND situation_counter >= 1';
4981 $sql .=
' AND fk_soc = ' . (int) $socid;
4982 $sql .=
' AND type <> 2';
4983 $sql .=
' ORDER by situation_cycle_ref, situation_counter desc';
4984 $resql = $this->db->query($sql);
4986 if ($resql && $this->db->num_rows($resql) > 0) {
4989 while ($obj = $this->db->fetch_object($resql)) {
4991 if ($obj->situation_cycle_ref != $ref) {
4993 $ref = $obj->situation_cycle_ref;
4995 if ($obj->situation_final != 1) {
4997 if (substr($obj->ref, 1, 4) !=
'PROV') {
4998 if ($selected == $obj->rowid) {
4999 $opt .=
'<option value="' . $obj->rowid .
'" selected>' . $obj->ref .
'</option>';
5001 $opt .=
'<option value="' . $obj->rowid .
'">' . $obj->ref .
'</option>';
5008 dol_syslog(
"Error sql=" . $sql .
", error=" . $this->error, LOG_ERR);
5010 if ($opt ==
'<option value ="" selected></option>') {
5011 $opt =
'<option value ="0" selected>' . $langs->trans(
'NoSituations') .
'</option>';
5025 public function selectUnits($selected =
'', $htmlname =
'units', $showempty = 0, $unit_type =
'')
5029 $langs->load(
'products');
5031 $return =
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'">';
5033 $sql =
"SELECT rowid, label, code FROM " . $this->db->prefix() .
"c_units";
5034 $sql .=
' WHERE active > 0';
5035 if (!empty($unit_type)) {
5036 $sql .=
" AND unit_type = '" . $this->db->escape($unit_type) .
"'";
5038 $sql .=
" ORDER BY sortorder";
5040 $resql = $this->db->query($sql);
5041 if ($resql && $this->db->num_rows($resql) > 0) {
5043 $return .=
'<option value="none"></option>';
5046 while ($res = $this->db->fetch_object($resql)) {
5047 $unitLabel = $res->label;
5048 if (!empty($langs->tab_translate[
'unit' . $res->code])) {
5049 $unitLabel = $langs->trans(
'unit' . $res->code) != $res->label ? $langs->trans(
'unit' . $res->code) : $res->label;
5052 if ($selected == $res->rowid) {
5053 $return .=
'<option value="' . $res->rowid .
'" selected>' . $unitLabel .
'</option>';
5055 $return .=
'<option value="' . $res->rowid .
'">' . $unitLabel .
'</option>';
5058 $return .=
'</select>';
5079 public function select_comptes($selected =
'', $htmlname =
'accountid', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'', $showcurrency = 0, $morecss =
'', $nooutput = 0)
5086 $langs->load(
"admin");
5089 $sql =
"SELECT rowid, label, bank, clos as status, currency_code";
5090 $sql .=
" FROM " . $this->db->prefix() .
"bank_account";
5091 $sql .=
" WHERE entity IN (" .
getEntity(
'bank_account') .
")";
5093 $sql .=
" AND clos = " . (int) $status;
5096 $sql .=
" AND " . $filtre;
5098 $sql .=
" ORDER BY label";
5100 dol_syslog(get_class($this) .
"::select_comptes", LOG_DEBUG);
5101 $result = $this->db->query($sql);
5103 $num = $this->db->num_rows($result);
5106 $out .=
'<select id="select' . $htmlname .
'" class="flat selectbankaccount' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
5108 if (!empty($useempty) && !is_numeric($useempty)) {
5109 $out .=
'<option value="-1">'.$langs->trans($useempty).
'</option>';
5110 } elseif ($useempty == 1 || ($useempty == 2 && $num > 1)) {
5111 $out .=
'<option value="-1"> </option>';
5115 $obj = $this->db->fetch_object($result);
5116 if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected))) {
5117 $out .=
'<option value="' . $obj->rowid .
'" data-currency-code="' . $obj->currency_code .
'" selected>';
5119 $out .=
'<option value="' . $obj->rowid .
'" data-currency-code="' . $obj->currency_code .
'">';
5121 $out .= trim($obj->label);
5122 if ($showcurrency) {
5123 $out .=
' (' . $obj->currency_code .
')';
5125 if ($status == 2 && $obj->status == 1) {
5126 $out .=
' (' . $langs->trans(
"Closed") .
')';
5128 $out .=
'</option>';
5131 $out .=
"</select>";
5135 $out .=
'<span class="opacitymedium">' . $langs->trans(
"NoActiveBankAccountDefined") .
'</span>';
5137 $out .=
'<span class="opacitymedium">' . $langs->trans(
"NoBankAccountFound") .
'</span>';
5145 if (empty($nooutput)) {
5165 public function selectEstablishments($selected =
'', $htmlname =
'entity', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'')
5169 $langs->load(
"admin");
5172 $sql =
"SELECT rowid, name, fk_country, status, entity";
5173 $sql .=
" FROM " . $this->db->prefix() .
"establishment";
5174 $sql .=
" WHERE 1=1";
5176 $sql .=
" AND status = " . (int) $status;
5179 $sql .=
" AND " . $filtre;
5181 $sql .=
" ORDER BY name";
5183 dol_syslog(get_class($this) .
"::select_establishment", LOG_DEBUG);
5184 $result = $this->db->query($sql);
5186 $num = $this->db->num_rows($result);
5189 print
'<select id="select' . $htmlname .
'" class="flat selectestablishment" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
5190 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
5191 print
'<option value="-1"> </option>';
5195 $obj = $this->db->fetch_object($result);
5196 if ($selected == $obj->rowid) {
5197 print
'<option value="' . $obj->rowid .
'" selected>';
5199 print
'<option value="' . $obj->rowid .
'">';
5201 print trim($obj->name);
5202 if ($status == 2 && $obj->status == 1) {
5203 print
' (' . $langs->trans(
"Closed") .
')';
5211 print
'<span class="opacitymedium">' . $langs->trans(
"NoActiveEstablishmentDefined") .
'</span>';
5213 print
'<span class="opacitymedium">' . $langs->trans(
"NoEstablishmentFound") .
'</span>';
5236 if ($htmlname !=
"none") {
5237 print
'<form method="POST" action="' . $page .
'">';
5238 print
'<input type="hidden" name="action" value="setbankaccount">';
5239 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
5240 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
5241 $nbaccountfound = $this->
select_comptes($selected, $htmlname, 0,
'', $addempty);
5242 if ($nbaccountfound > 0) {
5243 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
5247 $langs->load(
'banks');
5250 require_once DOL_DOCUMENT_ROOT .
'/compta/bank/class/account.class.php';
5251 $bankstatic =
new Account($this->db);
5252 $result = $bankstatic->fetch($selected);
5254 print $bankstatic->getNomUrl(1);
5283 public function select_all_categories($type, $selected =
'', $htmlname =
"parent", $maxlength = 64, $fromid = 0, $outputmode = 0, $include = 0, $morecss =
'', $useempty = 1)
5286 global $conf, $langs;
5287 $langs->load(
"categories");
5289 include_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
5292 if (is_numeric($type)) {
5293 dol_syslog(__METHOD__ .
': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
5296 if ($type === Categorie::TYPE_BANK_LINE) {
5298 $cate_arbo = array();
5299 $sql =
"SELECT c.label, c.rowid";
5300 $sql .=
" FROM " . $this->db->prefix() .
"bank_categ as c";
5301 $sql .=
" WHERE entity = " . $conf->entity;
5302 $sql .=
" ORDER BY c.label";
5303 $result = $this->db->query($sql);
5305 $num = $this->db->num_rows($result);
5308 $objp = $this->db->fetch_object($result);
5310 $cate_arbo[$objp->rowid] = array(
'id' => $objp->rowid,
'fulllabel' => $objp->label,
'color' =>
'',
'picto' =>
'category');
5314 $this->db->free($result);
5320 $cate_arbo = $cat->get_full_arbo($type, $fromid, $include);
5323 $outarray = array();
5324 $outarrayrichhtml = array();
5327 $output =
'<select class="flat minwidth100' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
5328 if (is_array($cate_arbo)) {
5329 $num = count($cate_arbo);
5332 $output .=
'<option value="-1" disabled>' . $langs->trans(
"NoCategoriesDefined") .
'</option>';
5334 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
5335 $output .=
'<option value="-1"> </option>';
5337 foreach ($cate_arbo as $key => $value) {
5338 if ($cate_arbo[$key][
'id'] == $selected || ($selected ===
'auto' && count($cate_arbo) == 1)) {
5344 $labeltoshow =
img_picto(
'',
'category',
'class="pictofixedwidth" style="color: #' . $cate_arbo[$key][
'color'] .
'"');
5345 $labeltoshow .=
dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle');
5347 $outarray[$cate_arbo[$key][
'id']] = $cate_arbo[$key][
'fulllabel'];
5349 $outarrayrichhtml[$cate_arbo[$key][
'id']] = $labeltoshow;
5351 $output .=
'<option ' . $add .
'value="' . $cate_arbo[$key][
'id'] .
'"';
5354 $output .=
dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle');
5355 $output .=
'</option>';
5357 $cate_arbo[$key][
'data-html'] = $labeltoshow;
5361 $output .=
'</select>';
5364 if ($outputmode == 2) {
5367 } elseif ($outputmode == 1) {
5369 } elseif ($outputmode == 3) {
5370 return $outarrayrichhtml;
5393 public function form_confirm($page, $title, $question, $action, $formquestion = array(), $selectedchoice =
"", $useajax = 0, $height = 170, $width = 500)
5396 dol_syslog(__METHOD__ .
': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING);
5397 print $this->
formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width);
5427 public function formconfirm($page, $title, $question, $action, $formquestion =
'', $selectedchoice =
'', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0, $labelbuttonyes =
'Yes', $labelbuttonno =
'No')
5429 global $langs, $conf;
5431 $more =
'<!-- formconfirm - before call, page=' .
dol_escape_htmltag($page) .
' -->';
5437 $newselectedchoice = empty($selectedchoice) ?
"no" : $selectedchoice;
5438 if ($conf->browser->layout ==
'phone') {
5443 if (empty($height)) {
5445 if (is_array($formquestion) && count($formquestion) > 2) {
5446 $height += ((count($formquestion) - 2) * 24);
5450 if (is_array($formquestion) && !empty($formquestion)) {
5452 foreach ($formquestion as $key => $input) {
5453 if (is_array($input) && !empty($input)) {
5454 if ($input[
'type'] ==
'hidden') {
5455 $moreattr = (!empty($input[
'moreattr']) ?
' ' . $input[
'moreattr'] :
'');
5456 $morecss = (!empty($input[
'morecss']) ?
' ' . $input[
'morecss'] :
'');
5464 $moreonecolumn =
'';
5465 $more .=
'<div class="tagtable paddingtopbottomonly centpercent noborderspacing">' .
"\n";
5466 foreach ($formquestion as $key => $input) {
5467 if (is_array($input) && !empty($input)) {
5468 $size = (!empty($input[
'size']) ?
' size="' . $input[
'size'] .
'"' :
'');
5469 $moreattr = (!empty($input[
'moreattr']) ?
' ' . $input[
'moreattr'] :
'');
5470 $morecss = (!empty($input[
'morecss']) ?
' ' . $input[
'morecss'] :
'');
5472 if ($input[
'type'] ==
'text') {
5473 $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";
5474 } elseif ($input[
'type'] ==
'password') {
5475 $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";
5476 } elseif ($input[
'type'] ==
'textarea') {
5482 $moreonecolumn .=
'<div class="margintoponly">';
5483 $moreonecolumn .= $input[
'label'] .
'<br>';
5485 $moreonecolumn .= $input[
'value'];
5486 $moreonecolumn .=
'</textarea>';
5487 $moreonecolumn .=
'</div>';
5488 } elseif (in_array($input[
'type'], [
'select',
'multiselect'])) {
5489 if (empty($morecss)) {
5490 $morecss =
'minwidth100';
5493 $show_empty = isset($input[
'select_show_empty']) ? $input[
'select_show_empty'] : 1;
5494 $key_in_label = isset($input[
'select_key_in_label']) ? $input[
'select_key_in_label'] : 0;
5495 $value_as_key = isset($input[
'select_value_as_key']) ? $input[
'select_value_as_key'] : 0;
5496 $translate = isset($input[
'select_translate']) ? $input[
'select_translate'] : 0;
5497 $maxlen = isset($input[
'select_maxlen']) ? $input[
'select_maxlen'] : 0;
5498 $disabled = isset($input[
'select_disabled']) ? $input[
'select_disabled'] : 0;
5499 $sort = isset($input[
'select_sort']) ? $input[
'select_sort'] :
'';
5501 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">';
5502 if (!empty($input[
'label'])) {
5503 $more .= $input[
'label'] .
'</div><div class="tagtd left">';
5505 if ($input[
'type'] ==
'select') {
5506 $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);
5508 $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);
5510 $more .=
'</div></div>' .
"\n";
5511 } elseif ($input[
'type'] ==
'checkbox') {
5512 $more .=
'<div class="tagtr">';
5513 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'"><label for="' .
dol_escape_htmltag($input[
'name']) .
'">' . $input[
'label'] .
'</label></div><div class="tagtd">';
5514 $more .=
'<input type="checkbox" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' .
dol_escape_htmltag($input[
'name']) .
'" name="' .
dol_escape_htmltag($input[
'name']) .
'"' . $moreattr;
5515 if (!is_bool($input[
'value']) && $input[
'value'] !=
'false' && $input[
'value'] !=
'0' && $input[
'value'] !=
'') {
5516 $more .=
' checked';
5518 if (is_bool($input[
'value']) && $input[
'value']) {
5519 $more .=
' checked';
5521 if (isset($input[
'disabled'])) {
5522 $more .=
' disabled';
5524 $more .=
' /></div>';
5525 $more .=
'</div>' .
"\n";
5526 } elseif ($input[
'type'] ==
'radio') {
5528 foreach ($input[
'values'] as $selkey => $selval) {
5529 $more .=
'<div class="tagtr">';
5530 if (isset($input[
'label'])) {
5532 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
' tdtop' : (
' tdtop ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div>';
5534 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' "' . $input[
'tdclass'])) .
'"> </div>';
5537 $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;
5538 if (!empty($input[
'disabled'])) {
5539 $more .=
' disabled';
5541 if (isset($input[
'default']) && $input[
'default'] === $selkey) {
5542 $more .=
' checked="checked"';
5545 $more .=
'<label for="' .
dol_escape_htmltag($input[
'name'] . $selkey) .
'" class="valignmiddle">' . $selval .
'</label>';
5546 $more .=
'</div></div>' .
"\n";
5549 } elseif ($input[
'type'] ==
'date' || $input[
'type'] ==
'datetime') {
5550 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div>';
5551 $more .=
'<div class="tagtd">';
5552 $addnowlink = (empty($input[
'datenow']) ? 0 : 1);
5554 if ($input[
'type'] ==
'datetime') {
5555 $h = isset($input[
'hours']) ? $input[
'hours'] : 1;
5556 $m = isset($input[
'minutes']) ? $input[
'minutes'] : 1;
5558 $more .= $this->
selectDate(isset($input[
'value']) ? $input[
'value'] : -1, $input[
'name'], $h, $m, 0,
'', 1, $addnowlink);
5559 $more .=
'</div></div>'.
"\n";
5560 $formquestion[] = array(
'name' => $input[
'name'].
'day');
5561 $formquestion[] = array(
'name' => $input[
'name'].
'month');
5562 $formquestion[] = array(
'name' => $input[
'name'].
'year');
5563 $formquestion[] = array(
'name' => $input[
'name'].
'hour');
5564 $formquestion[] = array(
'name' => $input[
'name'].
'min');
5565 } elseif ($input[
'type'] ==
'other') {
5566 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">';
5567 if (!empty($input[
'label'])) {
5568 $more .= $input[
'label'] .
'</div><div class="tagtd">';
5570 $more .= $input[
'value'];
5571 $more .=
'</div></div>' .
"\n";
5572 } elseif ($input[
'type'] ==
'onecolumn') {
5573 $moreonecolumn .=
'<div class="margintoponly">';
5574 $moreonecolumn .= $input[
'value'];
5575 $moreonecolumn .=
'</div>' .
"\n";
5576 } elseif ($input[
'type'] ==
'hidden') {
5578 } elseif ($input[
'type'] ==
'separator') {
5581 $more .=
'Error type ' . $input[
'type'] .
' for the confirm box is not a supported type';
5585 $more .=
'</div>' .
"\n";
5586 $more .= $moreonecolumn;
5592 if (!empty($conf->dol_use_jmobile)) {
5595 if (empty($conf->use_javascript_ajax)) {
5601 $dialogconfirm =
'dialog-confirm';
5603 if (!is_numeric($useajax)) {
5607 $dialogconfirm .=
'-' . $button;
5609 $pageyes = $page . (preg_match(
'/\?/', $page) ?
'&' :
'?') .
'action=' . urlencode($action) .
'&confirm=yes';
5610 $pageno = ($useajax == 2 ? $page . (preg_match(
'/\?/', $page) ?
'&' :
'?') .
'action=' . urlencode($action) .
'&confirm=no' :
'');
5613 if (is_array($formquestion)) {
5614 foreach ($formquestion as $key => $input) {
5617 if (is_array($input) && isset($input[
'name'])) {
5618 if (strpos($input[
'name'],
',') > 0) {
5619 $inputok = array_merge($inputok, explode(
',', $input[
'name']));
5621 array_push($inputok, $input[
'name']);
5626 if (is_array($input) && isset($input[
'inputko']) && $input[
'inputko'] == 1 && isset($input[
'name'])) {
5627 array_push($inputko, $input[
'name']);
5633 $formconfirm .=
'<div id="' . $dialogconfirm .
'" title="' .
dol_escape_htmltag($title) .
'" style="display: none;">';
5634 if (is_array($formquestion) && array_key_exists(
'text', $formquestion) && !empty($formquestion[
'text'])) {
5635 $formconfirm .=
'<div class="confirmtext">' . $formquestion[
'text'] .
'</div>' .
"\n";
5637 if (!empty($more)) {
5638 $formconfirm .=
'<div class="confirmquestions">' . $more .
'</div>' .
"\n";
5640 $formconfirm .= ($question ?
'<div class="confirmmessage">' .
img_help(0,
'') .
' ' . $question .
'</div>' :
'');
5641 $formconfirm .=
'</div>' .
"\n";
5643 $formconfirm .=
"\n<!-- begin code of popup for formconfirm page=" . $page .
" -->\n";
5644 $formconfirm .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">' .
"\n";
5645 $formconfirm .=
"/* Code for the jQuery('#dialogforpopup').dialog() */\n";
5646 $formconfirm .=
'jQuery(document).ready(function() {
5648 $( "#' . $dialogconfirm .
'" ).dialog(
5650 autoOpen: ' . ($autoOpen ?
"true" :
"false") .
',';
5651 if ($newselectedchoice ==
'no') {
5654 $(this).parent().find("button.ui-button:eq(2)").focus();
5659 if ($useajax == 1) {
5660 $jsforcursor =
'// The call to urljump can be slow, so we set the wait cursor' .
"\n";
5661 $jsforcursor .=
'jQuery("html,body,#id-container").addClass("cursorwait");' .
"\n";
5664 $postconfirmas =
'GET';
5668 height: "' . $height .
'",
5669 width: "' . $width .
'",
5671 closeOnEscape: false,
5673 "' .
dol_escape_js($langs->transnoentities($labelbuttonyes)) .
'": function() {
5674 var options = "token=' . urlencode(
newToken()) .
'";
5675 var inputok = ' . json_encode($inputok) .
'; /* List of fields into form */
5676 var page = "' .
dol_escape_js(!empty($page) ? $page :
'') .
'";
5677 var pageyes = "' .
dol_escape_js(!empty($pageyes) ? $pageyes :
'') .
'";
5679 if (inputok.length > 0) {
5680 $.each(inputok, function(i, inputname) {
5683 if ($("input[name=\'" + inputname + "\']").attr("type") == "radio") {
5684 inputvalue = $("input[name=\'" + inputname + "\']:checked").val();
5686 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
5687 inputvalue = $("#" + inputname + more).val();
5689 if (typeof inputvalue == "undefined") { inputvalue=""; }
5690 console.log("formconfirm check inputname="+inputname+" inputvalue="+inputvalue);
5691 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
5694 var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "&") + options;
5695 if (pageyes.length > 0) {';
5696 if ($postconfirmas ==
'GET') {
5697 $formconfirm .=
'location.href = urljump;';
5699 $formconfirm .= $jsforcursor;
5700 $formconfirm .=
'var post = $.post(
5703 function(data) { $("body").html(data); jQuery("html,body,#id-container").removeClass("cursorwait"); }
5707 console.log("after post ok");
5709 $(this).dialog("close");
5711 "' .
dol_escape_js($langs->transnoentities($labelbuttonno)) .
'": function() {
5712 var options = "token=' . urlencode(
newToken()) .
'";
5713 var inputko = ' . json_encode($inputko) .
'; /* List of fields into form */
5714 var page = "' .
dol_escape_js(!empty($page) ? $page :
'') .
'";
5715 var pageno="' .
dol_escape_js(!empty($pageno) ? $pageno :
'') .
'";
5716 if (inputko.length > 0) {
5717 $.each(inputko, function(i, inputname) {
5719 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
5720 var inputvalue = $("#" + inputname + more).val();
5721 if (typeof inputvalue == "undefined") { inputvalue=""; }
5722 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
5725 var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "&") + options;
5727 if (pageno.length > 0) {';
5728 if ($postconfirmas ==
'GET') {
5729 $formconfirm .=
'location.href = urljump;';
5731 $formconfirm .= $jsforcursor;
5732 $formconfirm .=
'var post = $.post(
5735 function(data) { $("body").html(data); jQuery("html,body,#id-container").removeClass("cursorwait"); }
5739 console.log("after post ko");
5741 $(this).dialog("close");
5747 var button = "' . $button .
'";
5748 if (button.length > 0) {
5749 $( "#" + button ).click(function() {
5750 $("#' . $dialogconfirm .
'").dialog("open");
5756 $formconfirm .=
"<!-- end ajax formconfirm -->\n";
5758 $formconfirm .=
"\n<!-- begin formconfirm page=" .
dol_escape_htmltag($page) .
" -->\n";
5760 if (empty($disableformtag)) {
5761 $formconfirm .=
'<form method="POST" action="' . $page .
'" class="notoptoleftroright">' .
"\n";
5764 $formconfirm .=
'<input type="hidden" name="action" value="' . $action .
'">' .
"\n";
5765 $formconfirm .=
'<input type="hidden" name="token" value="' .
newToken() .
'">' .
"\n";
5767 $formconfirm .=
'<table class="valid centpercent">' .
"\n";
5770 $formconfirm .=
'<tr class="validtitre"><td class="validtitre" colspan="2">';
5771 $formconfirm .=
img_picto(
'',
'pictoconfirm') .
' ' . $title;
5772 $formconfirm .=
'</td></tr>' .
"\n";
5775 if (is_array($formquestion) && array_key_exists(
'text', $formquestion) && !empty($formquestion[
'text'])) {
5776 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="2">' . $formquestion[
'text'] .
'</td></tr>' .
"\n";
5781 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="2">' .
"\n";
5782 $formconfirm .= $more;
5783 $formconfirm .=
'</td></tr>' .
"\n";
5787 $formconfirm .=
'<tr class="valid">';
5788 $formconfirm .=
'<td class="valid">' . $question .
'</td>';
5789 $formconfirm .=
'<td class="valid center">';
5790 $formconfirm .= $this->
selectyesno(
"confirm", $newselectedchoice, 0,
false, 0, 0,
'marginleftonly marginrightonly', $labelbuttonyes, $labelbuttonno);
5791 $formconfirm .=
'<input class="button valignmiddle confirmvalidatebutton small" type="submit" value="' . $langs->trans(
"Validate") .
'">';
5792 $formconfirm .=
'</td>';
5793 $formconfirm .=
'</tr>' .
"\n";
5795 $formconfirm .=
'</table>' .
"\n";
5797 if (empty($disableformtag)) {
5798 $formconfirm .=
"</form>\n";
5800 $formconfirm .=
'<br>';
5802 if (!empty($conf->use_javascript_ajax)) {
5803 $formconfirm .=
'<!-- code to disable button to avoid double clic -->';
5804 $formconfirm .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">' .
"\n";
5806 $(document).ready(function () {
5807 $(".confirmvalidatebutton").on("click", function() {
5808 console.log("We click on button confirmvalidatebutton");
5809 $(this).attr("disabled", "disabled");
5810 setTimeout(\'$(".confirmvalidatebutton").removeAttr("disabled")\', 3000);
5811 //console.log($(this).closest("form"));
5812 $(this).closest("form").submit();
5816 $formconfirm .=
'</script>' .
"\n";
5819 $formconfirm .=
"<!-- end formconfirm -->\n";
5822 return $formconfirm;
5843 public function form_project($page, $socid, $selected =
'', $htmlname =
'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0, $textifnoproject =
'', $morecss =
'')
5848 require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
5849 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
5855 $langs->load(
"project");
5856 if ($htmlname !=
"none") {
5857 $out .=
'<form method="post" action="' . $page .
'">';
5858 $out .=
'<input type="hidden" name="action" value="classin">';
5859 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
5860 $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0,
'', 1, 0, $morecss);
5861 $out .=
'<input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
5864 $out .=
'<span class="project_head_block">';
5866 $projet =
new Project($this->db);
5867 $projet->fetch($selected);
5868 $out .= $projet->getNomUrl(0,
'', 1);
5870 $out .=
'<span class="opacitymedium">' . $textifnoproject .
'</span>';
5875 if (empty($nooutput)) {
5899 public function form_conditions_reglement($page, $selected =
'', $htmlname =
'cond_reglement_id', $addempty = 0, $type =
'', $filtertype = -1, $deposit_percent = -1, $nooutput = 0)
5906 if ($htmlname !=
"none") {
5907 $out .=
'<form method="POST" action="' . $page .
'">';
5908 $out .=
'<input type="hidden" name="action" value="setconditions">';
5909 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
5911 $out .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
5914 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
5919 if (isset($this->cache_conditions_paiements[$selected])) {
5920 $label = $this->cache_conditions_paiements[$selected][
'label'];
5922 if (!empty($this->cache_conditions_paiements[$selected][
'deposit_percent'])) {
5923 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $this->cache_conditions_paiements[$selected][
'deposit_percent'], $label);
5928 $langs->load(
'errors');
5929 $out .= $langs->trans(
'ErrorNotInDictionaryPaymentConditions');
5936 if (empty($nooutput)) {
5958 if ($htmlname !=
"none") {
5959 print
'<form method="post" action="' . $page .
'">';
5960 print
'<input type="hidden" name="action" value="setavailability">';
5961 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
5963 print
'<input type="submit" name="modify" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
5964 print
'<input type="submit" name="cancel" class="button smallpaddingimp" value="' . $langs->trans(
"Cancel") .
'">';
5969 print $this->cache_availability[$selected][
'label'];
5986 public function formInputReason($page, $selected =
'', $htmlname =
'demandreason', $addempty = 0)
5989 if ($htmlname !=
"none") {
5990 print
'<form method="post" action="' . $page .
'">';
5991 print
'<input type="hidden" name="action" value="setdemandreason">';
5992 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
5994 print
'<input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
5999 foreach ($this->cache_demand_reason as $key => $val) {
6000 if ($val[
'id'] == $selected) {
6001 print $val[
'label'];
6026 public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0, $type =
'')
6033 if ($htmlname !=
"none") {
6034 $ret .=
'<form method="POST" action="' . $page .
'" name="form' . $htmlname .
'">';
6035 $ret .=
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
6036 $ret .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6038 $ret .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
6040 $ret .=
'<table class="nobordernopadding">';
6042 $ret .= $this->
selectDate($selected, $htmlname, $displayhour, $displaymin, 1,
'form' . $htmlname, 1, 0);
6044 $ret .=
'<td class="left"><input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'"></td>';
6045 $ret .=
'</tr></table></form>';
6054 if (empty($nooutput)) {
6073 public function form_users($page, $selected =
'', $htmlname =
'userid', $exclude = array(), $include = array())
6078 if ($htmlname !=
"none") {
6079 print
'<form method="POST" action="' . $page .
'" name="form' . $htmlname .
'">';
6080 print
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
6081 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6082 print $this->
select_dolusers($selected, $htmlname, 1, $exclude, 0, $include);
6083 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6087 require_once DOL_DOCUMENT_ROOT .
'/user/class/user.class.php';
6088 $theuser =
new User($this->db);
6089 $theuser->fetch($selected);
6090 print $theuser->getNomUrl(1);
6113 public function form_modes_reglement($page, $selected =
'', $htmlname =
'mode_reglement_id', $filtertype =
'', $active = 1, $addempty = 0, $type =
'', $nooutput = 0)
6119 if ($htmlname !=
"none") {
6120 $out .=
'<form method="POST" action="' . $page .
'">';
6121 $out .=
'<input type="hidden" name="action" value="setmode">';
6122 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6124 $out .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
6126 $out .= $this->
select_types_paiements($selected, $htmlname, $filtertype, 0, $addempty, 0, 0, $active,
'', 1);
6127 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6132 $out .= $this->cache_types_paiements[$selected][
'label'];
6159 if ($htmlname !=
"none") {
6160 print
'<form method="POST" action="' . $page .
'">';
6161 print
'<input type="hidden" name="action" value="settransportmode">';
6162 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6164 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6169 print $this->cache_transport_mode[$selected][
'label'];
6190 if ($htmlname !=
"none") {
6191 print
'<form method="POST" action="' . $page .
'">';
6192 print
'<input type="hidden" name="action" value="setmulticurrencycode">';
6193 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6195 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6198 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
6199 print !empty($selected) ?
currency_name($selected, 1) :
' ';
6217 global $langs, $mysoc, $conf;
6219 if ($htmlname !=
"none") {
6220 print
'<form method="POST" action="' . $page .
'">';
6221 print
'<input type="hidden" name="action" value="setmulticurrencyrate">';
6222 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6223 print
'<input type="text" class="maxwidth100" name="' . $htmlname .
'" value="' . (!empty($rate) ?
price(
price2num($rate,
'CU')) : 1) .
'" /> ';
6224 print
'<select name="calculation_mode">';
6225 print
'<option value="1">Change ' . $langs->trans(
"PriceUHT") .
' of lines</option>';
6226 print
'<option value="2">Change ' . $langs->trans(
"PriceUHTCurrency") .
' of lines</option>';
6228 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6231 if (!empty($rate)) {
6232 print
price($rate, 1, $langs, 0, 0);
6233 if ($currency && $rate != 1) {
6234 print
' (' .
price($rate, 1, $langs, 0, 0) .
' ' . $currency .
' = 1 ' . $conf->currency .
')';
6260 public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter =
'', $maxvalue = 0, $more =
'', $hidelist = 0, $discount_type = 0)
6263 global $conf, $langs;
6264 if ($htmlname !=
"none") {
6265 print
'<form method="post" action="' . $page .
'">';
6266 print
'<input type="hidden" name="action" value="setabsolutediscount">';
6267 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6268 print
'<div class="inline-block">';
6269 if (!empty($discount_type)) {
6271 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL") {
6272 $translationKey =
'HasAbsoluteDiscountFromSupplier';
6274 $translationKey =
'HasCreditNoteFromSupplier';
6277 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
6278 $translationKey =
'HasAbsoluteDiscountFromSupplier';
6280 $translationKey =
'HasCreditNoteFromSupplier';
6285 if (!$filter || $filter ==
"fk_facture_source IS NULL") {
6286 $translationKey =
'CompanyHasAbsoluteDiscount';
6288 $translationKey =
'CompanyHasCreditNote';
6291 if (!$filter || $filter ==
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
6292 $translationKey =
'CompanyHasAbsoluteDiscount';
6294 $translationKey =
'CompanyHasCreditNote';
6298 print $langs->trans($translationKey,
price($amount, 0, $langs, 0, 0, -1, $conf->currency));
6299 if (empty($hidelist)) {
6303 if (empty($hidelist)) {
6304 print
'<div class="inline-block" style="padding-right: 10px">';
6305 $newfilter =
'discount_type=' . intval($discount_type);
6306 if (!empty($discount_type)) {
6307 $newfilter .=
' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL';
6309 $newfilter .=
' AND fk_facture IS NULL AND fk_facture_line IS NULL';
6312 $newfilter .=
' AND (' . $filter .
')';
6315 $nbqualifiedlines = $this->
select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue);
6316 if ($nbqualifiedlines > 0) {
6317 print
' <input type="submit" class="button smallpaddingimp" value="' .
dol_escape_htmltag($langs->trans(
"UseLine")) .
'"';
6318 if (!empty($discount_type) && $filter && $filter !=
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
6319 print
' title="' . $langs->trans(
"UseCreditNoteInInvoicePayment") .
'"';
6321 if (empty($discount_type) && $filter && $filter !=
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
6322 print
' title="' . $langs->trans(
"UseCreditNoteInInvoicePayment") .
'"';
6330 print
'<div class="inline-block">';
6356 public function form_contacts($page, $societe, $selected =
'', $htmlname =
'contactid')
6361 if ($htmlname !=
"none") {
6362 print
'<form method="post" action="' . $page .
'">';
6363 print
'<input type="hidden" name="action" value="set_contact">';
6364 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6365 print
'<table class="nobordernopadding">';
6370 $addcontact = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
6371 print
'<a href="' . DOL_URL_ROOT .
'/contact/card.php?socid=' . $societe->id .
'&action=create&backtoreferer=1">' . $addcontact .
'</a>';
6374 print
'<td class="left"><input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'"></td>';
6375 print
'</tr></table></form>';
6378 require_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
6379 $contact =
new Contact($this->db);
6380 $contact->fetch($selected);
6381 print $contact->getFullName($langs);
6406 public function form_thirdparty($page, $selected =
'', $htmlname =
'socid', $filter =
'', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0, $excludeids = array(), $textifnothirdparty =
'')
6412 if ($htmlname !=
"none") {
6413 $out .=
'<form method="post" action="' . $page .
'">';
6414 $out .=
'<input type="hidden" name="action" value="set_thirdparty">';
6415 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6416 $out .= $this->
select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, 0,
'minwidth100',
'',
'', 1, array(),
false, $excludeids);
6417 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6421 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
6422 $soc =
new Societe($this->db);
6423 $soc->fetch($selected);
6424 $out .= $soc->getNomUrl(0,
'');
6426 $out .=
'<span class="opacitymedium">' . $textifnothirdparty .
'</span>';
6464 public function selectCurrency($selected =
'', $htmlname =
'currency_id', $mode = 0, $useempty =
'')
6466 global $langs, $user;
6468 $langs->loadCacheCurrencies(
'');
6472 if ($selected ==
'euro' || $selected ==
'euros') {
6476 $out .=
'<select class="flat maxwidth200onsmartphone minwidth300" name="' . $htmlname .
'" id="' . $htmlname .
'">';
6478 $out .=
'<option value="-1" selected></option>';
6480 foreach ($langs->cache_currencies as $code_iso => $currency) {
6481 $labeltoshow = $currency[
'label'];
6483 $labeltoshow .=
' <span class="opacitymedium">(' . $code_iso .
')</span>';
6485 $labeltoshow .=
' <span class="opacitymedium">(' . $langs->getCurrencySymbol($code_iso) .
')</span>';
6488 if ($selected && $selected == $code_iso) {
6489 $out .=
'<option value="' . $code_iso .
'" selected data-html="' .
dol_escape_htmltag($labeltoshow) .
'">';
6491 $out .=
'<option value="' . $code_iso .
'" data-html="' .
dol_escape_htmltag($labeltoshow) .
'">';
6493 $out .= $labeltoshow;
6494 $out .=
'</option>';
6496 $out .=
'</select>';
6498 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
6502 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
6520 public function selectMultiCurrency($selected =
'', $htmlname =
'multicurrency_code', $useempty = 0, $filter =
'', $excludeConfCurrency =
false, $morecss =
'')
6522 global $conf, $langs;
6524 $langs->loadCacheCurrencies(
'');
6526 $TCurrency = array();
6528 $sql =
"SELECT code FROM " . $this->db->prefix() .
"multicurrency";
6529 $sql .=
" WHERE entity IN ('" .
getEntity(
'mutlicurrency') .
"')";
6531 $sql .=
" AND " . $filter;
6533 $resql = $this->db->query($sql);
6535 while ($obj = $this->db->fetch_object($resql)) {
6536 $TCurrency[$obj->code] = $obj->code;
6541 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
6543 $out .=
'<option value=""> </option>';
6546 if (!in_array($conf->currency, $TCurrency) && !$excludeConfCurrency) {
6547 $TCurrency[$conf->currency] = $conf->currency;
6549 if (count($TCurrency) > 0) {
6550 foreach ($langs->cache_currencies as $code_iso => $currency) {
6551 if (isset($TCurrency[$code_iso])) {
6552 if (!empty($selected) && $selected == $code_iso) {
6553 $out .=
'<option value="' . $code_iso .
'" selected="selected">';
6555 $out .=
'<option value="' . $code_iso .
'">';
6558 $out .= $currency[
'label'];
6559 $out .=
' (' . $langs->getCurrencySymbol($code_iso) .
')';
6560 $out .=
'</option>';
6565 $out .=
'</select>';
6568 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
6585 global $langs, $user;
6587 $num = count($this->cache_vatrates);
6594 $sql =
"SELECT t.rowid, t.type_vat, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly";
6595 $sql .=
" FROM ".$this->db->prefix().
"c_tva as t, ".$this->db->prefix().
"c_country as c";
6596 $sql .=
" WHERE t.fk_pays = c.rowid";
6597 $sql .=
" AND t.active > 0";
6598 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
6599 $sql .=
" AND c.code IN (" . $this->db->sanitize($country_code, 1) .
")";
6600 $sql .=
" ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC";
6602 $resql = $this->db->query($sql);
6604 $num = $this->db->num_rows($resql);
6606 for ($i = 0; $i < $num; $i++) {
6607 $obj = $this->db->fetch_object($resql);
6609 $tmparray = array();
6610 $tmparray[
'rowid'] = $obj->rowid;
6611 $tmparray[
'type_vat'] = $obj->type_vat;
6612 $tmparray[
'code'] = $obj->code;
6613 $tmparray[
'txtva'] = $obj->taux;
6614 $tmparray[
'nprtva'] = $obj->recuperableonly;
6615 $tmparray[
'localtax1'] = $obj->localtax1;
6616 $tmparray[
'localtax1_type'] = $obj->localtax1_type;
6617 $tmparray[
'localtax2'] = $obj->localtax2;
6618 $tmparray[
'localtax2_type'] = $obj->localtax1_type;
6619 $tmparray[
'label'] = $obj->taux .
'%' . ($obj->code ?
' (' . $obj->code .
')' :
'');
6620 $tmparray[
'labelallrates'] = $obj->taux .
'/' . ($obj->localtax1 ? $obj->localtax1 :
'0') .
'/' . ($obj->localtax2 ? $obj->localtax2 :
'0') . ($obj->code ?
' (' . $obj->code .
')' :
'');
6621 $positiverates =
'';
6623 $positiverates .= ($positiverates ?
'/' :
'') . $obj->taux;
6625 if ($obj->localtax1) {
6626 $positiverates .= ($positiverates ?
'/' :
'') . $obj->localtax1;
6628 if ($obj->localtax2) {
6629 $positiverates .= ($positiverates ?
'/' :
'') . $obj->localtax2;
6631 if (empty($positiverates)) {
6632 $positiverates =
'0';
6634 $tmparray[
'labelpositiverates'] = $positiverates . ($obj->code ?
' (' . $obj->code .
')' :
'');
6636 $this->cache_vatrates[$obj->rowid] = $tmparray;
6641 $this->error =
'<span class="error">';
6642 $this->error .= $langs->trans(
"ErrorNoVATRateDefinedForSellerCountry", $country_code);
6644 if (!empty($user) && $user->admin && preg_match(
'/\'(..)\'/', $country_code, $reg)) {
6645 $langs->load(
"errors");
6646 $new_country_code = $reg[1];
6647 $country_id =
dol_getIdFromCode($this->db, $new_country_code,
'c_pays',
'code',
'rowid');
6648 $this->error .=
'<br>'.$langs->trans(
"ErrorFixThisHere", DOL_URL_ROOT.
'/admin/dict.php?id=10'.($country_id > 0 ?
'&countryidforinsert='.$country_id :
''));
6650 $this->error .=
'</span>';
6654 $this->error =
'<span class="error">' . $this->db->error() .
'</span>';
6683 public function load_tva($htmlname =
'tauxtva', $selectedrate =
'', $societe_vendeuse =
null, $societe_acheteuse =
null, $idprod = 0, $info_bits = 0, $type =
'', $options_only =
false, $mode = 0, $type_vat = 0)
6686 global $langs, $mysoc;
6688 $langs->load(
'errors');
6693 $defaultnpr = ($info_bits & 0x01);
6694 $defaultnpr = (preg_match(
'/\*/', $selectedrate) ? 1 : $defaultnpr);
6695 $defaulttx = str_replace(
'*',
'', $selectedrate);
6698 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6699 $defaultcode = $reg[1];
6700 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6705 if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
6706 if ($societe_vendeuse->id == $mysoc->id) {
6707 $return .=
'<span class="error">' . $langs->trans(
"ErrorYourCountryIsNotDefined") .
'</span>';
6709 $return .=
'<span class="error">' . $langs->trans(
"ErrorSupplierCountryIsNotDefined") .
'</span>';
6720 if (is_object($societe_vendeuse)) {
6721 $code_country =
"'" . $societe_vendeuse->country_code .
"'";
6723 $code_country =
"'" . $mysoc->country_code .
"'";
6726 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
6730 if (
isInEEC($societe_vendeuse) &&
isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()) {
6732 if (is_numeric($type)) {
6734 switch ($selectVatComboMode) {
6736 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
6739 $code_country =
"'" . $societe_acheteuse->country_code .
"'";
6743 } elseif (!$idprod) {
6744 switch ($selectVatComboMode) {
6746 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
6749 $code_country =
"'" . $societe_acheteuse->country_code .
"'";
6753 $prodstatic =
new Product($this->db);
6754 $prodstatic->fetch($idprod);
6756 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
6766 $arrayofvatrates = array();
6767 foreach ($this->cache_vatrates as $cachevalue) {
6768 if (empty($cachevalue[
'type_vat']) || $cachevalue[
'type_vat'] != $type_vat) {
6769 $arrayofvatrates[] = $cachevalue;
6773 $num = count($arrayofvatrates);
6777 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
6778 $tmpthirdparty =
new Societe($this->db);
6780 $defaulttx =
get_default_tva($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
6781 $defaultnpr =
get_default_npr($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
6783 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6784 $defaultcode = $reg[1];
6785 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6787 if (empty($defaulttx)) {
6794 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
6797 $defaulttx = $arrayofvatrates[$num - 1][
'txtva'];
6804 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6805 $defaultcode = $reg[1];
6806 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6814 if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj ==
"0") {
6823 if (!$options_only) {
6824 $return .=
'<select class="flat minwidth75imp maxwidth100 right" id="' . $htmlname .
'" name="' . $htmlname .
'"' . ($disabled ?
' disabled' :
'') . $title .
'>';
6827 $selectedfound =
false;
6828 foreach ($arrayofvatrates as $rate) {
6830 if ($disabled && $rate[
'txtva'] != 0) {
6835 $key = $rate[
'txtva'];
6836 $key .= $rate[
'nprtva'] ?
'*' :
'';
6837 if ($mode > 0 && $rate[
'code']) {
6838 $key .=
' (' . $rate[
'code'] .
')';
6841 $key = $rate[
'rowid'];
6844 $return .=
'<option value="' . $key .
'"';
6845 if (!$selectedfound) {
6847 if ($defaultcode == $rate[
'code']) {
6848 $return .=
' selected';
6849 $selectedfound =
true;
6851 } elseif ($rate[
'txtva'] == $defaulttx && $rate[
'nprtva'] == $defaultnpr) {
6852 $return .=
' selected';
6853 $selectedfound =
true;
6859 if ($mysoc->country_code ==
'IN' ||
getDolGlobalString(
'MAIN_VAT_LABEL_IS_POSITIVE_RATES')) {
6861 $return .= $rate[
'labelpositiverates'];
6864 $return .=
vatrate($rate[
'label']);
6868 $return .= (empty($rate[
'code']) && $rate[
'nprtva']) ?
' *' :
'';
6870 $return .=
'</option>';
6873 if (!$options_only) {
6874 $return .=
'</select>';
6878 $return .= $this->error;
6912 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 = 0, $addplusone =
'', $adddateof =
'')
6915 dol_syslog(__METHOD__ .
': using select_date is deprecated. Use selectDate instead.', LOG_WARNING);
6916 $retstring = $this->
selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof);
6917 if (!empty($nooutput)) {
6940 public function selectDateToDate($set_time =
'', $set_time_end =
'', $prefix =
're', $empty = 0, $forcenewline = 0)
6944 $ret = $this->
selectDate($set_time, $prefix .
'_start', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"),
'tzuserrel');
6945 if ($forcenewline) {
6948 $ret .= $this->
selectDate($set_time_end, $prefix .
'_end', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
6979 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')
6981 global $conf, $langs;
6983 if ($gm ===
'auto') {
6984 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
6989 if ($prefix ==
'') {
7000 if ($stepminutes <= 0 || $stepminutes > 30) {
7011 $orig_set_time = $set_time;
7013 if ($set_time ===
'' && $emptydate == 0) {
7014 include_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
7015 if ($gm ==
'tzuser' || $gm ==
'tzuserrel') {
7027 if (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg)) {
7029 $syear = (!empty($reg[1]) ? $reg[1] :
'');
7030 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
7031 $sday = (!empty($reg[3]) ? $reg[3] :
'');
7032 $shour = (!empty($reg[4]) ? $reg[4] :
'');
7033 $smin = (!empty($reg[5]) ? $reg[5] :
'');
7034 } elseif (strval($set_time) !=
'' && $set_time != -1) {
7039 if ($orig_set_time !=
'') {
7053 if ($h == 3 || $h == 4) {
7064 $usecalendar =
'combo';
7070 $usecalendar =
'html';
7075 if ($usecalendar !=
'combo') {
7076 $formated_date =
'';
7078 if (strval($set_time) !=
'' && $set_time != -1) {
7080 $formated_date =
dol_print_date($set_time, $langs->trans(
"FormatDateShortInput"), $gm);
7084 if ($usecalendar ==
"eldy") {
7086 $retstring .=
'<input id="' . $prefix .
'" name="' . $prefix .
'" type="text" class="maxwidthdate center" maxlength="11" value="' . $formated_date .
'"';
7087 $retstring .= ($disabled ?
' disabled' :
'');
7088 $retstring .=
' onChange="dpChangeDay(\'' . $prefix .
'\',\
'' . $langs->trans(
"FormatDateShortJavaInput") .
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
7089 $retstring .= ' autocomplete="off
">';
7092 $retstringbuttom = '';
7094 $retstringbuttom = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
"';
7095 $base = DOL_URL_ROOT . '/core/';
7096 $retstringbuttom .= ' onClick="showDP(\
'' . $base .
'\',\
'' . $prefix .
'\',\
'' . $langs->trans(
"FormatDateShortJavaInput") .
'\',\
'' . $langs->defaultlang .
'\');
"';
7097 $retstringbuttom .= '>' . img_object($langs->trans("SelectDate
"), 'calendarday', 'class="datecallink
"') . '</button>';
7099 $retstringbuttom = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
">' . img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"') . '</button>';
7101 $retstring = $retstringbuttom . $retstring;
7103 $retstring .= '<input type="hidden
" id="' . $prefix . 'day
" name="' . $prefix . 'day
" value="' . $sday . '">' . "\n
";
7104 $retstring .= '<input type="hidden
" id="' . $prefix . 'month
" name="' . $prefix . 'month
" value="' . $smonth . '">' . "\n
";
7105 $retstring .= '<input type="hidden
" id="' . $prefix . 'year
" name="' . $prefix . 'year
" value="' . $syear . '">' . "\n
";
7106 } elseif ($usecalendar == 'jquery' || $usecalendar == 'html') {
7107 if (!$disabled && $usecalendar != 'html') {
7108 // Output javascript for datepicker
7109 $minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (idate('Y') - 100));
7110 $maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (idate('Y') + 100));
7112 $retstring .= '<script nonce="' . getNonce() . '" type="text/javascript
">';
7113 $retstring .= "$(
function(){ $(
'#" . $prefix . "').datepicker({
7114 dateFormat:
'" . $langs->trans("FormatDateShortJQueryInput") . "',
7116 todayHighlight:
true,
7117 yearRange:
'" . $minYear . ":" . $maxYear . "',
";
7118 if (!empty($conf->dol_use_jmobile)) {
7120 beforeShow:
function (input, datePicker) {
7121 input.disabled =
true;
7123 onClose:
function (dateText, datePicker) {
7128 // Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php
7129 if (!getDolGlobalString('MAIN_POPUP_CALENDAR_ON_FOCUS')) {
7132 buttonImage:
'" . DOL_URL_ROOT . "/theme/" . dol_escape_js($conf->theme) . "/img/object_calendarday.png',
7133 buttonImageOnly:
true";
7137 $retstring .= "</script>
";
7140 // Input area to enter date manually
7141 $retstring .= '<div class="nowraponall
inline-block divfordateinput
">';
7142 $retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text
" class="maxwidthdate center
" maxlength="11
" value="'.$formated_date.'"';
7143 $retstring .= ($disabled ? ' disabled' : '');
7144 $retstring .= ($placeholder ? ' placeholder="' . dol_escape_htmltag($placeholder) . '"' : '');
7145 $retstring .= ' onChange="dpChangeDay(\
'' .
dol_escape_js($prefix) .
'\',\
'' .
dol_escape_js($langs->trans(
"FormatDateShortJavaInput")) .
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
7146 $retstring .= ' autocomplete="off
">';
7150 $retstringbutton = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
">' . img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"') . '</button>';
7151 $retstring = $retstringbutton . $retstring;
7154 $retstring .= '</div>';
7155 $retstring .= '<input type="hidden
" id="' . $prefix . 'day
" name="' . $prefix . 'day
" value="' . $sday . '">' . "\n
";
7156 $retstring .= '<input type="hidden
" id="' . $prefix . 'month
" name="' . $prefix . 'month
" value="' . $smonth . '">' . "\n
";
7157 $retstring .= '<input type="hidden
" id="' . $prefix . 'year
" name="' . $prefix . 'year
" value="' . $syear . '">' . "\n
";
7159 $retstring .= "Bad value of MAIN_POPUP_CALENDAR
";
7162 // Show date with combo selects
7164 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50imp
" id="' . $prefix . 'day
" name="' . $prefix . 'day
">';
7166 if ($emptydate || $set_time == -1) {
7167 $retstring .= '<option value="0
" selected> </option>';
7170 for ($day = 1; $day <= 31; $day++) {
7171 $retstring .= '<option value="' . $day . '"' . ($day == $sday ? ' selected' : '') . '>' . $day . '</option>';
7174 $retstring .= "</select>
";
7176 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp
" id="' . $prefix . 'month
" name="' . $prefix . 'month
">';
7177 if ($emptydate || $set_time == -1) {
7178 $retstring .= '<option value="0
" selected> </option>';
7182 for ($month = 1; $month <= 12; $month++) {
7183 $retstring .= '<option value="' . $month . '"' . ($month == $smonth ? ' selected' : '') . '>';
7184 $retstring .= dol_print_date(mktime(12, 0, 0, $month, 1, 2000), "%b
");
7185 $retstring .= "</option>
";
7187 $retstring .= "</select>
";
7190 if ($emptydate || $set_time == -1) {
7191 $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 . '">';
7193 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp
" id="' . $prefix . 'year
" name="' . $prefix . 'year
">';
7195 $syear = (int) $syear;
7196 for ($year = $syear - 10; $year < (int) $syear + 10; $year++) {
7197 $retstring .= '<option value="' . $year . '"' . ($year == $syear ? ' selected' : '') . '>' . $year . '</option>';
7199 $retstring .= "</select>\n
";
7205 $retstring .= (($h == 2 || $h == 4) ? '<br>' : ' ');
7206 $retstring .= '<span class="nowraponall
">';
7212 if ($openinghours != '') {
7213 $openinghours = explode(',', $openinghours);
7214 $hourstart = $openinghours[0];
7215 $hourend = $openinghours[1];
7216 if ($hourend < $hourstart) {
7217 $hourend = $hourstart;
7221 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50
' . ($fullday ? $fullday . 'hour
' : '') . '" id="' . $prefix . 'hour
" name="' . $prefix . 'hour
">';
7223 $retstring .= '<option value="-1
"> </option>';
7225 for ($hour = $hourstart; $hour < $hourend; $hour++) {
7226 if (strlen($hour) < 2) {
7227 $hour = "0
" . $hour;
7229 $retstring .= '<option value="' . $hour . '"' . (($hour == $shour) ? ' selected' : '') . '>' . $hour;
7230 //$retstring .= (empty($conf->dol_optimize_smallscreen) ? '' : 'H');
7231 $retstring .= '</option>';
7233 $retstring .= '</select>';
7234 //if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":
";
7242 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50
' . ($fullday ? $fullday . 'min
' : '') . '" id="' . $prefix . 'min
" name="' . $prefix . 'min
">';
7244 $retstring .= '<option value="-1
"> </option>';
7246 for ($min = 0; $min < 60; $min += $stepminutes) {
7247 $min_str = sprintf("%02d
", $min);
7248 $retstring .= '<option value="' . $min_str . '"' . (($min_str == $smin) ? ' selected' : '') . '>' . $min_str . '</option>';
7250 $retstring .= '</select>';
7252 $retstring .= '<input type="hidden
" name="' . $prefix . 'sec
" value="' . $ssec . '">';
7256 $retstring .= '</span>';
7260 if (!empty($conf->use_javascript_ajax) && $addnowlink) {
7261 // Script which will be inserted in the onClick of the "Now
" link
7262 $reset_scripts = "";
7263 if ($addnowlink == 2) { // local computer time
7264 // pad add leading 0 on numbers
7265 $reset_scripts .= "Number.prototype.pad =
function(size) {
7266 var s = String(
this);
7267 while (s.length < (size || 2)) {s =
'0' + s;}
7270 var d =
new Date();
";
7273 // Generate the date part, depending on the use or not of the javascript calendar
7274 if ($addnowlink == 1) { // server time expressed in user time setup
7275 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'day', 'tzuserrel') . '\');';
7276 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
7277 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
7278 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
7279 } elseif ($addnowlink == 2) {
7280 /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix.
7281 * This break application for foreign languages.
7282 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));';
7283 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());';
7284 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);';
7285 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());';
7287 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'day', 'tzuserrel') . '\');';
7288 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
7289 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
7290 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
7292 /*if ($usecalendar == "eldy
")
7294 $base=DOL_URL_ROOT.'/core/';
7295 $reset_scripts .= 'resetDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput
").'\',\''.$langs->defaultlang.'\');';
7299 $reset_scripts .= 'this.form.elements[\''.$prefix.'day\'].value=formatDate(new Date(), \'d\'); ';
7300 $reset_scripts .= 'this.form.elements[\''.$prefix.'month\'].value=formatDate(new Date(), \'M\'); ';
7301 $reset_scripts .= 'this.form.elements[\''.$prefix.'year\'].value=formatDate(new Date(), \'yyyy\'); ';
7303 // Update the hour part
7306 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7308 //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); ';
7309 if ($addnowlink == 1) {
7310 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date($nowgmt, '%H', 'tzuserrel') . '\');';
7311 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').change();';
7312 } elseif ($addnowlink == 2) {
7313 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(d.getHours().pad());';
7314 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').change();';
7318 $reset_scripts .= ' } ';
7321 // Update the minute part
7324 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7326 //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); ';
7327 if ($addnowlink == 1) {
7328 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date($nowgmt, '%M', 'tzuserrel') . '\');';
7329 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').change();';
7330 } elseif ($addnowlink == 2) {
7331 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(d.getMinutes().pad());';
7332 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').change();';
7335 $reset_scripts .= ' } ';
7338 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
7339 if ($reset_scripts && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
7340 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="' . $prefix . 'ButtonNow
" type="button" name="_useless
" value="now
" onClick="' . $reset_scripts . '">';
7341 $retstring .= $langs->trans("Now
");
7342 $retstring .= '</button> ';
7346 // Add a "Plus one hour
" link
7347 if ($conf->use_javascript_ajax && $addplusone) {
7348 // Script which will be inserted in the onClick of the "Add plusone
" link
7349 $reset_scripts = "";
7351 // Generate the date part, depending on the use or not of the javascript calendar
7352 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'dayinputnoreduce', 'tzuserrel') . '\');';
7353 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
7354 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
7355 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
7356 // Update the hour part
7359 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7361 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date($nowgmt, '%H', 'tzuserrel') . '\');';
7363 $reset_scripts .= ' } ';
7366 // Update the minute part
7369 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7371 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date($nowgmt, '%M', 'tzuserrel') . '\');';
7373 $reset_scripts .= ' } ';
7376 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
7377 if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
7378 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="' . $prefix . 'ButtonPlusOne
" type="button" name="_useless2
" value="plusone
" onClick="' . $reset_scripts . '">';
7379 $retstring .= $langs->trans("DateStartPlusOne
");
7380 $retstring .= '</button> ';
7384 // Add a link to set data
7385 if ($conf->use_javascript_ajax && !empty($adddateof)) {
7386 if (!is_array($adddateof)) {
7387 $arrayofdateof = array(array('adddateof' => $adddateof, 'labeladddateof' => $labeladddateof));
7389 $arrayofdateof = $adddateof;
7391 foreach ($arrayofdateof as $valuedateof) {
7392 $tmpadddateof = empty($valuedateof['adddateof']) ? 0 : $valuedateof['adddateof'];
7393 $tmplabeladddateof = empty($valuedateof['labeladddateof']) ? '' : $valuedateof['labeladddateof'];
7394 $tmparray = dol_getdate($tmpadddateof);
7395 if (empty($tmplabeladddateof)) {
7396 $tmplabeladddateof = $langs->trans("DateInvoice
");
7398 $reset_scripts = 'console.log(\'Click on now link\'); ';
7399 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($tmpadddateof, 'dayinputnoreduce').'\');';
7400 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.$tmparray['mday'].'\');';
7401 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.$tmparray['mon'].'\');';
7402 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.$tmparray['year'].'\');';
7403 $retstring .= ' - <button class="dpInvisibleButtons datenowlink
" id="dateofinvoice
" type="button" name="_dateofinvoice
" value="now
" onclick="'.$reset_scripts.'">'.$tmplabeladddateof.'</button>';
7418 public function selectTypeDuration($prefix, $selected = 'i', $excludetypes = array())
7422 $TDurationTypes = array(
7423 'y' => $langs->trans('Years'),
7424 'm' => $langs->trans('Month'),
7425 'w' => $langs->trans('Weeks'),
7426 'd' => $langs->trans('Days'),
7427 'h' => $langs->trans('Hours'),
7428 'i' => $langs->trans('Minutes')
7431 // Removed undesired duration types
7432 foreach ($excludetypes as $value) {
7433 unset($TDurationTypes[$value]);
7436 $retstring = '<select class="flat minwidth75 maxwidth100
" id="select_
' . $prefix . 'type_duration
" name="' . $prefix . 'type_duration
">';
7437 foreach ($TDurationTypes as $key => $typeduration) {
7438 $retstring .= '<option value="' . $key . '"';
7439 if ($key == $selected) {
7440 $retstring .= " selected
";
7442 $retstring .= ">
" . $typeduration . "</option>
";
7444 $retstring .= "</select>
";
7446 $retstring .= ajax_combobox('select_' . $prefix . 'type_duration');
7451 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
7466 public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0)
7471 $retstring = '<span class="nowraponall
">';
7477 if ($iSecond != '') {
7478 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
7480 $hourSelected = convertSecondToTime($iSecond, 'allhour');
7481 $minSelected = convertSecondToTime($iSecond, 'min');
7484 if ($typehour == 'select') {
7485 $retstring .= '<select class="flat
" id="select_
' . $prefix . 'hour
" name="' . $prefix . 'hour
"' . ($disabled ? ' disabled' : '') . '>';
7486 for ($hour = 0; $hour < 25; $hour++) { // For a duration, we allow 24 hours
7487 $retstring .= '<option value="' . $hour . '"';
7488 if (is_numeric($hourSelected) && $hourSelected == $hour) {
7489 $retstring .= " selected
";
7491 $retstring .= ">
" . $hour . "</option>
";
7493 $retstring .= "</select>
";
7494 } elseif ($typehour == 'text' || $typehour == 'textselect') {
7495 $retstring .= '<input placeholder="' . $langs->trans('HourShort
') . '" type="number
" min="0
" name="' . $prefix . 'hour
"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputhour right
" value="' . (($hourSelected != '') ? ((int) $hourSelected) : '') . '">';
7497 return 'BadValueForParameterTypeHour';
7500 if ($typehour != 'text') {
7501 $retstring .= ' ' . $langs->trans('HourShort');
7503 $retstring .= '<span class="">:</span>';
7507 if ($minunderhours) {
7508 $retstring .= '<br>';
7510 if ($typehour != 'text') {
7511 $retstring .= '<span class="hideonsmartphone
"> </span>';
7515 if ($typehour == 'select' || $typehour == 'textselect') {
7516 $retstring .= '<select class="flat
" id="select_
' . $prefix . 'min
" name="' . $prefix . 'min
"' . ($disabled ? ' disabled' : '') . '>';
7517 for ($min = 0; $min <= 55; $min += 5) {
7518 $retstring .= '<option value="' . $min . '"';
7519 if (is_numeric($minSelected) && $minSelected == $min) {
7520 $retstring .= ' selected';
7522 $retstring .= '>' . $min . '</option>';
7524 $retstring .= "</select>
";
7525 } elseif ($typehour == 'text') {
7526 $retstring .= '<input placeholder="' . $langs->trans('MinuteShort
') . '" type="number
" min="0
" name="' . $prefix . 'min
"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputminute right
" value="' . (($minSelected != '') ? ((int) $minSelected) : '') . '">';
7529 if ($typehour != 'text') {
7530 $retstring .= ' ' . $langs->trans('MinuteShort');
7533 $retstring .= "</span>
";
7535 if (!empty($nooutput)) {
7563 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)
7565 global $langs, $conf;
7570 if (is_null($ajaxoptions)) {
7571 $ajaxoptions = array();
7574 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
7577 if ($selected && empty($selected_input_value)) {
7578 require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
7579 $tickettmpselect = new Ticket($this->db);
7580 $tickettmpselect->fetch($selected);
7581 $selected_input_value = $tickettmpselect->ref;
7582 unset($tickettmpselect);
7586 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/ticket/ajax/tickets.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7588 if (empty($hidelabel)) {
7589 $out .= $langs->trans("RefOrLabel
") . ' : ';
7590 } elseif ($hidelabel > 1) {
7591 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
7592 if ($hidelabel == 2) {
7593 $out .= img_picto($langs->trans("Search
"), 'search');
7596 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (getDolGlobalString('PRODUCT_SEARCH_AUTOFOCUS') ? 'autofocus' : '') . ' />';
7597 if ($hidelabel == 3) {
7598 $out .= img_picto($langs->trans("Search
"), 'search');
7601 $out .= $this->selectTicketsList($selected, $htmlname, $filtertype, $limit, '', $status, 0, $showempty, $forcecombo, $morecss);
7604 if (empty($nooutput)) {
7629 public function selectTicketsList($selected = '', $htmlname = 'ticketid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7631 global $langs, $conf;
7634 $outarray = array();
7636 $selectFields = " p.rowid, p.ref, p.message
";
7639 $sql .= $selectFields;
7640 $sql .= " FROM
" . $this->db->prefix() . "ticket as p
";
7641 $sql .= ' WHERE p.entity IN (' . getEntity('ticket') . ')';
7643 // Add criteria on ref/label
7644 if ($filterkey != '') {
7646 $prefix = !getDolGlobalString('TICKET_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7647 // For natural search
7648 $search_crit = explode(' ', $filterkey);
7650 if (count($search_crit) > 1) {
7653 foreach ($search_crit as $crit) {
7657 $sql .= "(p.ref LIKE
'" . $this->db->escape($prefix . $crit) . "%' OR p.subject LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
7661 if (count($search_crit) > 1) {
7667 $sql .= $this->db->plimit($limit, 0);
7669 // Build output string
7671 $result = $this->db->query($sql);
7673 require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
7674 require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php';
7676 $num = $this->db->num_rows($result);
7681 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
7682 $out .= ajax_combobox($htmlname, $events, $conf->global->TICKET_USE_SEARCH_TO_SELECT);
7685 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
7688 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7689 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7690 if (getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
7691 if ($showempty && !is_numeric($showempty)) {
7692 $textifempty = $langs->trans($showempty);
7694 $textifempty .= $langs->trans("All
");
7697 if ($showempty && !is_numeric($showempty)) {
7698 $textifempty = $langs->trans($showempty);
7702 $out .= '<option value="0
" selected>' . $textifempty . '</option>';
7706 while ($num && $i < $num) {
7709 $objp = $this->db->fetch_object($result);
7711 $this->constructTicketListOption($objp, $opt, $optJson, $selected, $filterkey);
7713 // "key
" value of json key array is used by jQuery automatically as selected value
7714 // "label
" value of json key array is used by jQuery automatically as text for combo box
7716 array_push($outarray, $optJson);
7721 $out .= '</select>';
7723 $this->db->free($result);
7725 if (empty($outputmode)) {
7730 dol_print_error($this->db);
7747 protected function constructTicketListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7753 $outkey = $objp->rowid;
7754 $outref = $objp->ref;
7755 $outtype = $objp->fk_product_type;
7757 $opt = '<option value="
' . $objp->rowid . '"';
7758 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7761 $objRef = $objp->ref;
7762 if (!empty($filterkey) && $filterkey != '') {
7763 $objRef = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $objRef, 1);
7766 $opt .= "</option>\n
";
7767 $optJson = array('key' => $outkey, 'value' => $outref, 'type' => $outtype);
7789 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)
7791 global $langs, $conf;
7796 if (is_null($ajaxoptions)) {
7797 $ajaxoptions = array();
7800 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
7803 if ($selected && empty($selected_input_value)) {
7804 require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
7805 $projecttmpselect = new Project($this->db);
7806 $projecttmpselect->fetch($selected);
7807 $selected_input_value = $projecttmpselect->ref;
7808 unset($projecttmpselect);
7812 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/projet/ajax/projects.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7814 if (empty($hidelabel)) {
7815 $out .= $langs->trans("RefOrLabel
") . ' : ';
7816 } elseif ($hidelabel > 1) {
7817 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
7818 if ($hidelabel == 2) {
7819 $out .= img_picto($langs->trans("Search
"), 'search');
7822 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (getDolGlobalString('PRODUCT_SEARCH_AUTOFOCUS') ? 'autofocus' : '') . ' />';
7823 if ($hidelabel == 3) {
7824 $out .= img_picto($langs->trans("Search
"), 'search');
7827 $out .= $this->selectProjectsList($selected, $htmlname, $filtertype, $limit, '', $status, 0, $showempty, $forcecombo, $morecss);
7830 if (empty($nooutput)) {
7854 public function selectProjectsList($selected = '', $htmlname = 'projectid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7856 global $langs, $conf;
7859 $outarray = array();
7861 $selectFields = " p.rowid, p.ref
";
7864 $sql .= $selectFields;
7865 $sql .= " FROM
" . $this->db->prefix() . "projet as p
";
7866 $sql .= ' WHERE p.entity IN (' . getEntity('project') . ')';
7868 // Add criteria on ref/label
7869 if ($filterkey != '') {
7871 $prefix = !getDolGlobalString('TICKET_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7872 // For natural search
7873 $search_crit = explode(' ', $filterkey);
7875 if (count($search_crit) > 1) {
7878 foreach ($search_crit as $crit) {
7882 $sql .= "p.ref LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
7886 if (count($search_crit) > 1) {
7892 $sql .= $this->db->plimit($limit, 0);
7894 // Build output string
7896 $result = $this->db->query($sql);
7898 require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
7899 require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php';
7901 $num = $this->db->num_rows($result);
7906 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
7907 $out .= ajax_combobox($htmlname, $events, $conf->global->PROJECT_USE_SEARCH_TO_SELECT);
7910 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
7913 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7914 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7915 if (getDolGlobalString('PROJECT_USE_SEARCH_TO_SELECT')) {
7916 if ($showempty && !is_numeric($showempty)) {
7917 $textifempty = $langs->trans($showempty);
7919 $textifempty .= $langs->trans("All
");
7922 if ($showempty && !is_numeric($showempty)) {
7923 $textifempty = $langs->trans($showempty);
7927 $out .= '<option value="0
" selected>' . $textifempty . '</option>';
7931 while ($num && $i < $num) {
7934 $objp = $this->db->fetch_object($result);
7936 $this->constructProjectListOption($objp, $opt, $optJson, $selected, $filterkey);
7938 // "key
" value of json key array is used by jQuery automatically as selected value
7939 // "label
" value of json key array is used by jQuery automatically as text for combo box
7941 array_push($outarray, $optJson);
7946 $out .= '</select>';
7948 $this->db->free($result);
7950 if (empty($outputmode)) {
7955 dol_print_error($this->db);
7972 protected function constructProjectListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7978 $label = $objp->label;
7980 $outkey = $objp->rowid;
7981 $outref = $objp->ref;
7982 $outlabel = $objp->label;
7983 $outtype = $objp->fk_product_type;
7985 $opt = '<option value="
' . $objp->rowid . '"';
7986 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7989 $objRef = $objp->ref;
7990 if (!empty($filterkey) && $filterkey != '') {
7991 $objRef = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $objRef, 1);
7994 $opt .= "</option>\n
";
7995 $optJson = array('key' => $outkey, 'value' => $outref, 'type' => $outtype);
8018 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)
8020 global $langs, $conf;
8025 if (is_null($ajaxoptions)) {
8026 $ajaxoptions = array();
8029 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
8032 if ($selected && empty($selected_input_value)) {
8033 require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
8034 $adherenttmpselect = new Adherent($this->db);
8035 $adherenttmpselect->fetch($selected);
8036 $selected_input_value = $adherenttmpselect->ref;
8037 unset($adherenttmpselect);
8042 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/adherents/ajax/adherents.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
8044 if (empty($hidelabel)) {
8045 $out .= $langs->trans("RefOrLabel
") . ' : ';
8046 } elseif ($hidelabel > 1) {
8047 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
8048 if ($hidelabel == 2) {
8049 $out .= img_picto($langs->trans("Search
"), 'search');
8052 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (getDolGlobalString('PRODUCT_SEARCH_AUTOFOCUS') ? 'autofocus' : '') . ' />';
8053 if ($hidelabel == 3) {
8054 $out .= img_picto($langs->trans("Search
"), 'search');
8059 $out .= $this->selectMembersList($selected, $htmlname, $filtertype, $limit, $filterkey, $status, 0, $showempty, $forcecombo, $morecss);
8062 if (empty($nooutput)) {
8086 public function selectMembersList($selected = '', $htmlname = 'adherentid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
8088 global $langs, $conf;
8091 $outarray = array();
8093 $selectFields = " p.rowid, p.ref, p.firstname, p.lastname, p.fk_adherent_type
";
8096 $sql .= $selectFields;
8097 $sql .= " FROM
" . $this->db->prefix() . "adherent as p
";
8098 $sql .= ' WHERE p.entity IN (' . getEntity('adherent') . ')';
8100 // Add criteria on ref/label
8101 if ($filterkey != '') {
8103 $prefix = !getDolGlobalString('MEMBER_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
8104 // For natural search
8105 $search_crit = explode(' ', $filterkey);
8107 if (count($search_crit) > 1) {
8110 foreach ($search_crit as $crit) {
8114 $sql .= "(p.firstname LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
8115 $sql .= " OR p.lastname LIKE
'" . $this->db->escape($prefix . $crit) . "%')
";
8118 if (count($search_crit) > 1) {
8123 if ($status != -1) {
8124 $sql .= ' AND statut = ' . ((int) $status);
8126 $sql .= $this->db->plimit($limit, 0);
8128 // Build output string
8130 $result = $this->db->query($sql);
8132 require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
8133 require_once DOL_DOCUMENT_ROOT . '/core/lib/member.lib.php';
8135 $num = $this->db->num_rows($result);
8140 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
8141 $out .= ajax_combobox($htmlname, $events, getDolGlobalString('PROJECT_USE_SEARCH_TO_SELECT') ? $conf->global->PROJECT_USE_SEARCH_TO_SELECT : '');
8144 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
8147 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
8148 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
8149 if (getDolGlobalString('PROJECT_USE_SEARCH_TO_SELECT')) {
8150 if ($showempty && !is_numeric($showempty)) {
8151 $textifempty = $langs->trans($showempty);
8153 $textifempty .= $langs->trans("All
");
8156 if ($showempty && !is_numeric($showempty)) {
8157 $textifempty = $langs->trans($showempty);
8161 $out .= '<option value="-1
" selected>' . $textifempty . '</option>';
8165 while ($num && $i < $num) {
8168 $objp = $this->db->fetch_object($result);
8170 $this->constructMemberListOption($objp, $opt, $optJson, $selected, $filterkey);
8173 // "key
" value of json key array is used by jQuery automatically as selected value
8174 // "label
" value of json key array is used by jQuery automatically as text for combo box
8176 array_push($outarray, $optJson);
8181 $out .= '</select>';
8183 $this->db->free($result);
8185 if (empty($outputmode)) {
8190 dol_print_error($this->db);
8207 protected function constructMemberListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
8213 $outkey = $objp->rowid;
8214 $outlabel = dolGetFirstLastname($objp->firstname, $objp->lastname);
8215 $outtype = $objp->fk_adherent_type;
8217 $opt = '<option value="
' . $objp->rowid . '"';
8218 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
8220 if (!empty($filterkey) && $filterkey != '') {
8221 $outlabel = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $outlabel, 1);
8224 $opt .= "</option>\n
";
8226 $optJson = array('key' => $outkey, 'value' => $outlabel, 'type' => $outtype);
8249 public function selectForForms($objectdesc, $htmlname, $preSelectedValue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '', $objectfield = '')
8251 global $conf, $extrafields, $user;
8253 // Example of common usage for a link to a thirdparty
8255 // We got this in a modulebuilder form of "
MyObject" of module "mymodule
".
8256 // ->fields is array( ... "fk_soc
" => array("type"=>"integer:
Societe:societe/class/societe.class.php:1:((
status:=:1) AND (entity:IN:__SHARED_ENTITIES__))
" ...)
8257 // $objectdesc = 'Societe'
8258 // $objectfield = 'myobject@mymodule:fk_soc' ('fk_soc' is code to retrieve myobject->fields['fk_soc'])
8260 // We got this when showing an extrafields on resource that is a link to societe
8261 // extrafields 'link_to_societe' of Resource is 'link' to 'Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))" ...)
'
8263 // $objectfield = 'resource:options_link_to_societe
'
8266 // $objectdesc = 'Societe:societe/class/societe.class.php:1:((
status:=:1) AND (entity:IN:__SHARED_ENTITIES__))
'
8267 // $objectfield = ''
8269 //var_dump($objectdesc.' '.$objectfield);
8270 //debug_print_backtrace();
8272 $objectdescorig = $objectdesc;
8274 $InfoFieldList = array();
8276 $filter = ''; // Ensure filter has value (for static analysis)
8277 $sortfield = ''; // Ensure filter has value (for static analysis)
8279 if ($objectfield) { // We must retrieve the objectdesc from the field or extrafield
8280 // Example: $objectfield = 'product:options_package
' or 'myobject@mymodule:options_myfield
'
8281 $tmparray = explode(':
', $objectfield);
8283 // Get instance of object from $element
8284 $objectforfieldstmp = fetchObjectByElement(0, strtolower($tmparray[0]));
8286 if (is_object($objectforfieldstmp)) {
8290 if (preg_match('/^options_(.*)$/
', $tmparray[1], $reg)) {
8291 // For a property in extrafields
8293 // fetch optionals attributes and labels
8294 $extrafields->fetch_name_optionals_label($objectforfieldstmp->table_element);
8296 if (!empty($extrafields->attributes[$objectforfieldstmp->table_element]['type'][$key]) && $extrafields->attributes[$objectforfieldstmp->table_element]['type'][$key] == 'link
') {
8297 if (!empty($extrafields->attributes[$objectforfieldstmp->table_element]['param
'][$key]['options
'])) {
8298 $tmpextrafields = array_keys($extrafields->attributes[$objectforfieldstmp->table_element]['param
'][$key]['options
']);
8299 $objectdesc = $tmpextrafields[0];
8303 // For a property in ->fields
8304 if (array_key_exists($tmparray[1], $objectforfieldstmp->fields)) {
8305 $objectdesc = $objectforfieldstmp->fields[$tmparray[1]]['type'];
8306 $objectdesc = preg_replace('/^integer[^:]*:/
', '', $objectdesc);
8313 // Example of value for $objectdesc:
8314 // Bom:bom/class/bom.class.php:0:t.status=1
8315 // Bom:bom/class/bom.class.php:0:t.status=1:ref
8316 // Bom:bom/class/bom.class.php:0:(t.status:=:1) OR (t.field2:=:2):ref
8317 $InfoFieldList = explode(":", $objectdesc, 4);
8318 $vartmp = (empty($InfoFieldList[3]) ? '' : $InfoFieldList[3]);
8320 if (preg_match('/^.*:(\w*)$/
', $vartmp, $reg)) {
8321 $InfoFieldList[4] = $reg[1]; // take the sort field
8323 $InfoFieldList[3] = preg_replace('/:\w*$/
', '', $vartmp); // take the filter field
8325 $classname = $InfoFieldList[0];
8326 $classpath = empty($InfoFieldList[1]) ? '' : $InfoFieldList[1];
8327 //$addcreatebuttonornot = empty($InfoFieldList[2]) ? 0 : $InfoFieldList[2];
8328 $filter = empty($InfoFieldList[3]) ? '' : $InfoFieldList[3];
8329 $sortfield = empty($InfoFieldList[4]) ? '' : $InfoFieldList[4];
8331 // Load object according to $id and $element
8332 $objecttmp = fetchObjectByElement(0, strtolower($InfoFieldList[0]));
8334 // Fallback to another solution to get $objecttmp
8335 if (empty($objecttmp) && !empty($classpath)) {
8336 dol_include_once($classpath);
8338 if ($classname && class_exists($classname)) {
8339 $objecttmp = new $classname($this->db);
8344 // Make some replacement in $filter. May not be used if we used the ajax mode with $objectfield. In such a case
8345 // we propagate the $objectfield and not the filter and replacement is done by the ajax/selectobject.php component.
8346 $sharedentities = (is_object($objecttmp) && property_exists($objecttmp, 'element
')) ? getEntity($objecttmp->element) : strtolower($classname);
8347 $filter = str_replace(
8348 array('__ENTITY__
', '__SHARED_ENTITIES__
', '__USER_ID__
'),
8349 array($conf->entity, $sharedentities, $user->id),
8353 if (!is_object($objecttmp)) {
8354 dol_syslog('selectForForms: Error bad setup of field objectdescorig=
' . $objectdescorig.', objectfield=
'.$objectfield.', objectdesc=
'.$objectdesc, LOG_WARNING);
8355 return 'selectForForms: Error bad setup of field objectdescorig=
' . $objectdescorig.', objectfield=
'.$objectfield.', objectdesc=
'.$objectdesc;
8359 //var_dump($filter);
8360 $prefixforautocompletemode = $objecttmp->element;
8361 if ($prefixforautocompletemode == 'societe
') {
8362 $prefixforautocompletemode = 'company
';
8364 if ($prefixforautocompletemode == 'product
') {
8365 $prefixforautocompletemode = 'produit
';
8367 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT
'; // For example COMPANY_USE_SEARCH_TO_SELECT
8369 dol_syslog(get_class($this) . "::selectForForms filter=" . $filter, LOG_DEBUG);
8371 // Generate the combo HTML component
8373 if (!empty($conf->use_javascript_ajax) && getDolGlobalString($confkeyforautocompletemode) && !$forcecombo) {
8374 // No immediate load of all database
8377 if ($preSelectedValue && empty($selected_input_value)) {
8378 $objecttmp->fetch($preSelectedValue);
8379 $selected_input_value = ($prefixforautocompletemode == 'company
' ? $objecttmp->name : $objecttmp->ref);
8381 $oldValueForShowOnCombobox = 0;
8382 foreach ($objecttmp->fields as $fieldK => $fielV) {
8383 if (!array_key_exists('showoncombobox
', $fielV) || !$fielV['showoncombobox
'] || empty($objecttmp->$fieldK)) {
8387 if (!$oldValueForShowOnCombobox) {
8388 $selected_input_value = '';
8391 $selected_input_value .= $oldValueForShowOnCombobox ? ' -
' : '';
8392 $selected_input_value .= $objecttmp->$fieldK;
8393 $oldValueForShowOnCombobox = empty($fielV['showoncombobox
']) ? 0 : $fielV['showoncombobox
'];
8397 // Set url and param to call to get json of the search results
8398 $urlforajaxcall = DOL_URL_ROOT . '/core/ajax/selectobject.php
';
8399 $urloption = 'htmlname=
' . urlencode($htmlname) . '&outjson=1&objectdesc=
' . urlencode($objectdescorig) . '&objectfield=
'.urlencode($objectfield) . ($sortfield ? '&sortfield=
' . urlencode($sortfield) : '');
8401 // Activate the auto complete using ajax call.
8402 $out .= ajax_autocompleter($preSelectedValue, $htmlname, $urlforajaxcall, $urloption, getDolGlobalString($confkeyforautocompletemode), 0);
8403 $out .= '<!-- force css to be higher than dialog popup --><style
type=
"text/css">.ui-autocomplete { z-index: 1010; }</style>
';
8404 $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) . '"' : '') . ' />
';
8406 // Immediate load of table record.
8407 $out .= $this->selectForFormsList($objecttmp, $htmlname, $preSelectedValue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled, $sortfield, $filter);
8434 public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '
', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0, $sortfield = '', $filter = '')
8436 global $langs, $user, $hookmanager;
8438 //print "$htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, $outputmode, $disabled";
8440 $prefixforautocompletemode = $objecttmp->element;
8441 if ($prefixforautocompletemode == 'societe
') {
8442 $prefixforautocompletemode = 'company
';
8444 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT
'; // For example COMPANY_USE_SEARCH_TO_SELECT
8446 if (!empty($objecttmp->fields)) { // For object that declare it, it is better to use declared fields (like societe, contact, ...)
8447 $tmpfieldstoshow = '';
8448 foreach ($objecttmp->fields as $key => $val) {
8449 if (! (int) dol_eval($val['enabled
'], 1, 1, '1
')) {
8452 if (!empty($val['showoncombobox
'])) {
8453 $tmpfieldstoshow .= ($tmpfieldstoshow ? ',
' : '') . 't.
' . $key;
8456 if ($tmpfieldstoshow) {
8457 $fieldstoshow = $tmpfieldstoshow;
8460 // For backward compatibility
8461 $objecttmp->fields['ref
'] = array('type' => 'varchar(30)
', 'label
' => 'Ref
', 'showoncombobox
' => 1);
8464 if (empty($fieldstoshow)) {
8465 if (isset($objecttmp->fields['ref'])) {
8466 $fieldstoshow = 't.ref
';
8468 $langs->load("errors");
8469 $this->error = $langs->trans("ErrorNoFieldWithAttributeShowoncombobox");
8470 return $langs->trans('ErrorNoFieldWithAttributeShowoncombobox
');
8475 $outarray = array();
8476 $tmparray = array();
8481 $sql = "SELECT t.rowid, " . $fieldstoshow . " FROM " . $this->db->prefix() . $objecttmp->table_element . " as t";
8482 if (!empty($objecttmp->isextrafieldmanaged)) {
8483 $sql .= " LEFT JOIN " . $this->db->prefix() . $objecttmp->table_element . "_extrafields as e ON t.rowid=e.fk_object";
8485 if (isset($objecttmp->ismultientitymanaged)) {
8486 if (!is_numeric($objecttmp->ismultientitymanaged)) {
8487 $tmparray = explode('@
', $objecttmp->ismultientitymanaged);
8488 $sql .= " INNER JOIN " . $this->db->prefix() . $tmparray[1] . " as parenttable ON parenttable.rowid = t." . $tmparray[0];
8490 if ($objecttmp->ismultientitymanaged === 'fk_soc@societe
') {
8491 if (!$user->hasRight('societe
', 'client
', 'voir
')) {
8492 $sql .= ", " . $this->db->prefix() . "societe_commerciaux as sc";
8497 // Add where from hooks
8498 $parameters = array(
8499 'object' => $objecttmp,
8500 'htmlname
' => $htmlname,
8501 'filter
' => $filter,
8502 'searchkey
' => $searchkey
8505 $reshook = $hookmanager->executeHooks('selectForFormsListWhere
', $parameters); // Note that $action and $object may have been modified by hook
8506 if (!empty($hookmanager->resPrint)) {
8507 $sql .= $hookmanager->resPrint;
8509 $sql .= " WHERE 1=1";
8510 if (isset($objecttmp->ismultientitymanaged)) {
8511 if ($objecttmp->ismultientitymanaged == 1) {
8512 $sql .= " AND t.entity IN (" . getEntity($objecttmp->table_element) . ")";
8514 if (!is_numeric($objecttmp->ismultientitymanaged)) {
8515 $sql .= " AND parenttable.entity = t." . $tmparray[0];
8517 if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
8518 if ($objecttmp->element == 'societe
') {
8519 $sql .= " AND t.rowid = " . ((int) $user->socid);
8521 $sql .= " AND t.fk_soc = " . ((int) $user->socid);
8524 if ($objecttmp->ismultientitymanaged === 'fk_soc@societe
') {
8525 if (!$user->hasRight('societe
', 'client
', 'voir
')) {
8526 $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = " . ((int) $user->id);
8530 if ($searchkey != '') {
8531 $sql .= natural_search(explode(',
', $fieldstoshow), $searchkey);
8534 if ($filter) { // Syntax example "(t.ref:like:'SO-%
') and (t.date_creation:<:'20160101
')"
8536 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
8537 if ($errormessage) {
8538 return 'Error forging a SQL request from an universal criteria:
' . $errormessage;
8542 $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow, "ASC");
8543 //$sql.=$this->db->plimit($limit, 0);
8546 // Build output string
8547 $resql = $this->db->query($sql);
8549 // Construct $out and $outarray
8550 $out .= '<select
id=
"' . $htmlname . '" class=
"flat minwidth100' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled=
"disabled"' : '') . ($moreparams ? ' ' . $moreparams : '') . ' name=
"' . $htmlname . '">
' . "\n";
8552 // Warning: Do not use textifempty = ' ' or '
' here, or search on key will search on ' key
'. Seems it is no more true with selec2 v4
8553 $textifempty = '
';
8555 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
8556 if (getDolGlobalInt($confkeyforautocompletemode)) {
8557 if ($showempty && !is_numeric($showempty)) {
8558 $textifempty = $langs->trans($showempty);
8560 $textifempty .= $langs->trans("All");
8564 $out .= '<option value=
"-1">
' . $textifempty . '</option>
' . "\n";
8567 $num = $this->db->num_rows($resql);
8571 $obj = $this->db->fetch_object($resql);
8574 $tmparray = explode(',
', $fieldstoshow);
8575 $oldvalueforshowoncombobox = 0;
8576 foreach ($tmparray as $key => $val) {
8577 $val = preg_replace('/t\./
', '', $val);
8578 $label .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val]['showoncombobox
'] ? ' -
' : ' ') : '');
8579 $labelhtml .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val]['showoncombobox
'] ? ' -
' : ' ') : '');
8580 $label .= $obj->$val;
8581 $labelhtml .= $obj->$val;
8583 $oldvalueforshowoncombobox = empty($objecttmp->fields[$val]['showoncombobox
']) ? 0 : $objecttmp->fields[$val]['showoncombobox
'];
8585 if (empty($outputmode)) {
8586 if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
8587 $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>
';
8589 $out .= '<option value=
"' . $obj->rowid . '" data-html=
"' . dol_escape_htmltag($labelhtml, 0, 0, '', 0, 1) . '">
' . dol_escape_htmltag($label, 0, 0, '', 0, 1) . '</option>
';
8592 array_push($outarray, array('key
' => $obj->rowid, 'value
' => $label, 'label
' => $label));
8596 if (($i % 10) == 0) {
8602 $out .= '</select>
' . "\n";
8605 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php
';
8606 $out .= ajax_combobox($htmlname, array(), getDolGlobalInt($confkeyforautocompletemode, 0));
8609 dol_print_error($this->db);
8612 $this->result = array('nbofelement
' => $num);
8644 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)
8646 global $conf, $langs;
8648 // Do we want a multiselect ?
8650 //if (preg_match('/^multi/
',$htmlname)) $jsbeautify = 1;
8653 if ($value_as_key) {
8654 $array = array_combine($array, $array);
8657 '@phan-var-force array{label:string,data-html:string,disable?:int<0,1>,css?:
string} $array
'; // Array combine breaks information
8661 if ($addjscombo < 0) {
8662 if (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER
')) {
8668 $idname = str_replace(array('[
', ']
'), array('', ''), $htmlname);
8669 $out .= '<select
id=
"' . preg_replace('/^\./', '', $idname) . '" ' . ($disabled ? 'disabled=
"disabled" ' : '') . 'class=
"flat ' . (preg_replace('/^\./', '', $htmlname)) . ($morecss ? ' ' . $morecss : '') . ' selectformat"';
8670 $out .= ' name=
"' . preg_replace('/^\./', '', $htmlname) . '" ' . ($moreparam ? $moreparam : '');
8674 $textforempty = ' ';
8675 if (!empty($conf->use_javascript_ajax)) {
8676 $textforempty = '
'; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
8678 if (!is_numeric($show_empty)) {
8679 $textforempty = $show_empty;
8681 $out .= '<option
class=
"optiongrey" ' . ($moreparamonempty ? $moreparamonempty . ' ' : '') . 'value=
"' . (((int) $show_empty) < 0 ? $show_empty : -1) . '"' . ($id == $show_empty ? ' selected
' : '') . '>
' . $textforempty . '</option>
' . "\n";
8683 if (is_array($array)) {
8686 foreach ($array as $key => $value) {
8687 if (!is_array($value)) {
8688 $array[$key] = $langs->trans($value);
8690 $array[$key]['label
'] = $langs->trans($value['label
']);
8695 if ($sort == 'ASC
') {
8697 } elseif ($sort == 'DESC
') {
8701 foreach ($array as $key => $tmpvalue) {
8702 if (is_array($tmpvalue)) {
8703 $value = $tmpvalue['label
'];
8704 //$valuehtml = empty($tmpvalue['data-html
']) ? $value : $tmpvalue['data-html
'];
8706 $style = empty($tmpvalue['css
']) ? '' : ' class=
"' . $tmpvalue['css'] . '"';
8709 //$valuehtml = $tmpvalue;
8713 if (!empty($disablebademail)) {
8714 if (($disablebademail == 1 && !preg_match('/<.+@.+>/
', $value))
8715 || ($disablebademail == 2 && preg_match('/---/
', $value))) {
8717 $style = ' class=
"warning"';
8720 if ($key_in_label) {
8721 if (empty($nohtmlescape)) {
8722 $selectOptionValue = dol_escape_htmltag($key . ' -
' . ($maxlen ? dol_trunc($value, $maxlen) : $value));
8724 $selectOptionValue = $key . ' -
' . ($maxlen ? dol_trunc($value, $maxlen) : $value);
8727 if (empty($nohtmlescape)) {
8728 $selectOptionValue = dol_escape_htmltag($maxlen ? dol_trunc($value, $maxlen) : $value);
8730 $selectOptionValue = $maxlen ? dol_trunc($value, $maxlen) : $value;
8732 if ($value == '' || $value == '-
') {
8733 $selectOptionValue = '
';
8736 $out .= '<option value=
"' . $key . '"';
8737 $out .= $style . $disabled;
8738 if (is_array($id)) {
8739 if (in_array($key, $id) && !$disabled) {
8740 $out .= ' selected
'; // To preselect a value
8743 $id = (string) $id; // if $id = 0, then $id = '0
'
8744 if ($id != '' && (($id == (string) $key) || ($id == 'ifone
' && count($array) == 1)) && !$disabled) {
8745 $out .= ' selected
'; // To preselect a value
8748 if (!empty($nohtmlescape)) { // deprecated. Use instead the key 'data-html
' into input $array, managed at next step to use HTML content.
8749 $out .= ' data-html=
"' . dol_escape_htmltag($selectOptionValue) . '"';
8752 if (is_array($tmpvalue)) {
8753 foreach ($tmpvalue as $keyforvalue => $valueforvalue) {
8754 if (preg_match('/^data-/
', $keyforvalue)) { // The best solution if you want to use HTML values into the list is to use data-html.
8755 $out .= ' '.dol_escape_htmltag($keyforvalue).'=
"'.dol_escape_htmltag($valueforvalue).'"';
8760 $out .= $selectOptionValue;
8761 $out .= "</option>\n";
8764 $out .= "</select>";
8766 // Add code for jquery to use multiselect
8767 if ($addjscombo && $jsbeautify) {
8768 // Enhance with select2
8769 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php
';
8770 $out .= ajax_combobox($idname, array(), 0, 0, 'resolve
', (((int) $show_empty) < 0 ? (string) $show_empty : '-1
'), $morecss);
8794 public static function selectArrayAjax($htmlname, $url, $id = '
', $moreparam = '', $moreparamtourl = '', $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0)
8796 global $conf, $langs;
8797 global $delayedhtmlcontent; // Will be used later outside of this function
8799 // TODO Use an internal dolibarr component instead of select2
8800 if (!getDolGlobalString('MAIN_USE_JQUERY_MULTISELECT
') && !defined('REQUIRE_JQUERY_MULTISELECT
')) {
8804 $out = '<select
type=
"text" class=
"' . $htmlname . ($morecss ? ' ' . $morecss : '') . '" ' . ($moreparam ? $moreparam . ' ' : '') . 'name=
"' . $htmlname . '"></select>
';
8807 if (!empty($conf->use_javascript_ajax)) {
8808 $tmpplugin = 'select2
';
8809 $outdelayed = "\n" . '<!-- JS CODE TO ENABLE
' . $tmpplugin . ' for id ' . $htmlname . ' -->
8810 <script nonce=
"' . getNonce() . '">
8811 $(document).ready(
function () {
8813 ' . ($callurlonselect ? 'var saveRemoteData = [];
' : '') . '
8815 $(
".' . $htmlname . '").select2({
8818 url:
"' . $url . '",
8821 data: function (params) {
8823 q: params.term, // search term
8827 processResults: function (data) {
8828 // parse the results into the format expected by Select2.
8829 // since we are using custom formatting functions we do not need to alter the remote JSON data
8830 //console.log(data);
8831 saveRemoteData = data;
8832 /* format json result for select2 */
8834 $.each( data, function( key, value ) {
8835 result.push({id: key, text: value.text});
8837 //return {results:[{id:\'none\', text:\'aa\'}, {id:\'rrr\', text:\'Red\'},{id:\'bbb\', text:\'Search a into projects\'}], more:false}
8838 //console.log(result);
8839 return {results: result, more: false}
8843 language: select2arrayoflanguage,
8844 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
8846 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
8847 minimumInputLength: ' . ((int) $minimumInputLength) .
',
8848 formatResult: function (result, container, query, escapeMarkup) {
8849 return escapeMarkup(result.text);
8853 ' . ($callurlonselect ?
'
8854 /* Code to execute a GET when we select a value */
8855 $(".' . $htmlname .
'").change(function() {
8856 var selected = $(".' . $htmlname .
'").val();
8857 console.log("We select in selectArrayAjax the entry "+selected)
8858 $(".' . $htmlname .
'").val(""); /* reset visible combo value */
8859 $.each( saveRemoteData, function( key, value ) {
8860 if (key == selected)
8862 console.log("selectArrayAjax - Do a redirect to "+value.url)
8863 location.assign(value.url);
8872 if ($acceptdelayedhtml) {
8873 $delayedhtmlcontent .= $outdelayed;
8875 $out .= $outdelayed;
8899 public static function selectArrayFilter($htmlname, $array, $id =
'', $moreparam =
'', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss =
'', $callurlonselect = 0, $placeholder =
'', $acceptdelayedhtml = 0, $textfortitle =
'')
8901 global $conf, $langs;
8902 global $delayedhtmlcontent;
8905 if (!
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') && !defined(
'REQUIRE_JQUERY_MULTISELECT')) {
8909 $out =
'<select type="text"'.($textfortitle ?
' title="'.dol_escape_htmltag($textfortitle).
'"' :
'').
' id="'.$htmlname.
'" class="'.$htmlname.($morecss ?
' ' . $morecss :
'').
'"'.($moreparam ?
' '.$moreparam :
'').
' name="'.$htmlname.
'"><option></option></select>';
8911 $formattedarrayresult = array();
8913 foreach ($array as $key => $value) {
8916 $o->text = $value[
'text'];
8917 $o->url = $value[
'url'];
8918 $formattedarrayresult[] = $o;
8922 if (!empty($conf->use_javascript_ajax)) {
8923 $tmpplugin =
'select2';
8924 $outdelayed =
"\n" .
'<!-- JS CODE TO ENABLE ' . $tmpplugin .
' for id ' . $htmlname .
' -->
8925 <script nonce="' .
getNonce() .
'">
8926 $(document).ready(function () {
8927 var data = ' . json_encode($formattedarrayresult) .
';
8929 ' . ($callurlonselect ?
'var saveRemoteData = ' . json_encode($array) .
';' :
'') .
'
8931 $(".' . $htmlname .
'").select2({
8933 language: select2arrayoflanguage,
8934 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
8936 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
8937 minimumInputLength: ' . $minimumInputLength .
',
8938 formatResult: function (result, container, query, escapeMarkup) {
8939 return escapeMarkup(result.text);
8941 matcher: function (params, data) {
8943 if(! data.id) return null;';
8945 if ($callurlonselect) {
8949 var urlBase = data.url;
8950 var separ = urlBase.indexOf("?") >= 0 ? "&" : "?";
8951 /* console.log("params.term="+params.term); */
8952 /* console.log("params.term encoded="+encodeURIComponent(params.term)); */
8953 saveRemoteData[data.id].url = urlBase + separ + "search_all=" + encodeURIComponent(params.term.replace(/\"/g, ""));';
8956 if (!$disableFiltering) {
8959 if(data.text.match(new RegExp(params.term))) {
8974 ' . ($callurlonselect ?
'
8975 /* Code to execute a GET when we select a value */
8976 $(".' . $htmlname .
'").change(function() {
8977 var selected = $(".' . $htmlname .
'").val();
8978 console.log("We select "+selected)
8980 $(".' . $htmlname .
'").val(""); /* reset visible combo value */
8981 $.each( saveRemoteData, function( key, value ) {
8982 if (key == selected)
8984 console.log("selectArrayFilter - Do a redirect to "+value.url)
8985 location.assign(value.url);
8994 if ($acceptdelayedhtml) {
8995 $delayedhtmlcontent .= $outdelayed;
8997 $out .= $outdelayed;
9020 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)
9022 global $conf, $langs;
9026 if ($addjscombo < 0) {
9034 $useenhancedmultiselect = 0;
9035 if (!empty($conf->use_javascript_ajax) && !defined(
'MAIN_DO_NOT_USE_JQUERY_MULTISELECT') && (
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') || defined(
'REQUIRE_JQUERY_MULTISELECT'))) {
9037 $useenhancedmultiselect = 1;
9044 $out .=
'<input type="hidden" name="'.$htmlname.
'_multiselect" value="1">';
9046 $out .=
'<select id="' . $htmlname .
'" class="multiselect' . ($useenhancedmultiselect ?
' multiselectononeline' :
'') . ($morecss ?
' ' . $morecss :
'') .
'" multiple name="' . $htmlname .
'[]"' . ($moreattrib ?
' ' . $moreattrib :
'') . ($width ?
' style="width: ' . (preg_match(
'/%/', (
string) $width) ? $width : $width .
'px') .
'"' :
'') .
'>' .
"\n";
9047 if (is_array($array) && !empty($array)) {
9048 if ($value_as_key) {
9049 $array = array_combine($array, $array);
9052 if (!empty($array)) {
9053 foreach ($array as $key => $value) {
9059 if (is_array($value) && array_key_exists(
'id', $value) && array_key_exists(
'label', $value)) {
9060 $tmpkey = $value[
'id'];
9061 $tmpvalue = empty($value[
'label']) ?
'' : $value[
'label'];
9062 $tmpcolor = empty($value[
'color']) ?
'' : $value[
'color'];
9063 $tmppicto = empty($value[
'picto']) ?
'' : $value[
'picto'];
9064 $tmplabelhtml = empty($value[
'labelhtml']) ? (empty($value[
'data-html']) ?
'' : $value[
'data-html']): $value[
'labelhtml'];
9066 $newval = ($translate ? $langs->trans($tmpvalue) : $tmpvalue);
9067 $newval = ($key_in_label ? $tmpkey .
' - ' . $newval : $newval);
9069 $out .=
'<option value="' . $tmpkey .
'"';
9070 if (is_array($selected) && !empty($selected) && in_array((
string) $tmpkey, $selected) && ((string) $tmpkey !=
'')) {
9071 $out .=
' selected';
9073 if (!empty($tmplabelhtml)) {
9076 $tmplabelhtml = ($tmppicto ?
img_picto(
'', $tmppicto,
'class="pictofixedwidth" style="color: #' . $tmpcolor .
'"') :
'') . $newval;
9081 $out .=
'</option>' .
"\n";
9085 $out .=
'</select>' .
"\n";
9088 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') || defined(
'REQUIRE_JQUERY_MULTISELECT')) {
9089 $out .=
"\n" .
'<!-- JS CODE TO ENABLE select for id ' . $htmlname .
', addjscombo=' . $addjscombo .
' -->';
9090 $out .=
"\n" .
'<script nonce="' .
getNonce() .
'">' .
"\n";
9091 if ($addjscombo == 1) {
9092 $tmpplugin = !
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') ? constant(
'REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
9093 $out .=
'function formatResult(record, container) {' .
"\n";
9096 $out .=
' if ($(record.element).attr("data-html") != undefined && typeof htmlEntityDecodeJs === "function") {';
9098 $out .=
' return htmlEntityDecodeJs($(record.element).attr("data-html"));';
9100 $out .=
' return record.text;';
9102 $out .=
'function formatSelection(record) {' .
"\n";
9103 if ($elemtype ==
'category') {
9104 $out .=
'return \'<span><img src="' . DOL_URL_ROOT .
'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
9106 $out .=
'return record.text;';
9109 $out .=
'$(document).ready(function () {
9110 $(\'#' . $htmlname .
'\').
' . $tmpplugin . '({
';
9118 $out .= ' dir: \
'ltr\',
9119 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag (ko with multiselect) */
9120 dropdownCssClass: \'' . $morecss .
'\',
9122 formatResult: formatResult,
9123 templateResult: formatResult,
9124 escapeMarkup:
function (markup) {
return markup; },
9126 formatSelection: formatSelection,
9127 templateSelection: formatSelection
9132 $(\
'#' . $htmlname .
' + .select2\').addClass(\'' . $morecss .
'\');
9134 } elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT
')) {
9136 // TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
9138 $out .= 'console.log(\
'addjscombo=2 for htmlname=' . $htmlname .
'\');
';
9139 $out .= '$(document).ready(
function () {
9140 $(\
'#' . $htmlname .
'\').multiSelect({
9141 containerHTML: \
'<div class="multi-select-container">\',
9142 menuHTML: \'<div class="multi-select-menu">\',
9143 buttonHTML: \'<span class="multi-select-button ' . $morecss .
'">\',
9144 menuItemHTML: \'<label class="multi-select-menuitem">\',
9145 activeClass: \'multi-select-container--open\',
9146 noneText: \'' . $placeholder .
'\'
9150 $out .= '</script>
';
9168 public static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage, $pos = '
')
9170 global $langs, $user;
9172 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER
')) {
9175 if (empty($array)) {
9179 $tmpvar = "MAIN_SELECTEDFIELDS_" . $varpage; // To get list of saved selected fields to show
9181 if (!empty($user->conf->$tmpvar)) { // A list of fields was already customized for user
9182 $tmparray = explode(',
', $user->conf->$tmpvar);
9183 foreach ($array as $key => $val) {
9185 //var_dump($tmparray);
9186 if (in_array($key, $tmparray)) {
9187 $array[$key]['checked
'] = 1;
9189 $array[$key]['checked
'] = 0;
9192 } else { // There is no list of fields already customized for user
9193 foreach ($array as $key => $val) {
9194 if (!empty($array[$key]['checked
']) && $array[$key]['checked
'] < 0) {
9195 $array[$key]['checked
'] = 0;
9200 $listoffieldsforselection = '';
9201 $listcheckedstring = '';
9203 foreach ($array as $key => $val) {
9205 // var_dump(array_key_exists('enabled
', $val));
9206 // var_dump(!$val['enabled
']);
9207 if (array_key_exists('enabled
', $val) && isset($val['enabled
']) && !$val['enabled
']) {
9208 unset($array[$key]); // We don't want
this field
9211 if (!empty($val[
'type']) && $val[
'type'] ==
'separate') {
9216 if (!empty($val[
'label']) && $val[
'label']) {
9217 if (!empty($val[
'langfile']) && is_object($langs)) {
9218 $langs->load($val[
'langfile']);
9222 $listoffieldsforselection .=
'<li><input type="checkbox" id="checkbox' . $key .
'" value="' . $key .
'"' . ((!array_key_exists(
'checked', $val) || empty($val[
'checked']) || $val[
'checked'] ==
'-1') ?
'' :
' checked="checked"') .
'/><label for="checkbox' . $key .
'">' .
dol_escape_htmltag($langs->trans($val[
'label'])) .
'</label></li>';
9223 $listcheckedstring .= (empty($val[
'checked']) ?
'' : $key .
',');
9227 $out =
'<!-- Component multiSelectArrayWithCheckbox ' . $htmlname .
' -->
9229 <dl class="dropdown">
9231 <a href="#' . $htmlname .
'">
9234 <input type="hidden" class="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $listcheckedstring .
'">
9236 <dd class="dropdowndd">
9237 <div class="multiselectcheckbox'.$htmlname.
'">
9238 <ul class="'.$htmlname.($pos ==
'1' ?
'left' :
'').
'">
9239 <li><input class="inputsearch_dropdownselectedfields width90p minwidth200imp" style="width:90%;" type="text" placeholder="'.$langs->trans(
'Search').
'"></li>
9240 '.$listoffieldsforselection.
'
9246 <script nonce="' .
getNonce() .
'" type="text/javascript">
9247 jQuery(document).ready(function () {
9248 $(\'.multiselectcheckbox' . $htmlname .
' input[type="checkbox"]\').on(\'click\', function () {
9249 console.log("A new field was added/removed, we edit field input[name=formfilteraction]");
9251 $("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\'); // Update field so we know we changed something on selected fields after POST
9253 var title = $(this).val() + ",";
9254 if ($(this).is(\':checked\')) {
9255 $(\'.' . $htmlname .
'\').val(title + $(\
'.' . $htmlname .
'\').val());
9258 $(\
'.' . $htmlname .
'\').val( $(\
'.' . $htmlname .
'\').val().replace(title, \
'\') )
9263 $(
"input.inputsearch_dropdownselectedfields").on(
"keyup",
function() {
9264 var value = $(
this).val().toLowerCase();
9265 $(\
'.multiselectcheckbox'.$htmlname.
' li > label\').filter(function() {
9266 $(this).parent().toggle($(this).text().toLowerCase().indexOf(value) > -1)
9289 include_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
9292 $categories = $cat->containing($id, $type);
9294 if ($rendermode == 1) {
9296 foreach ($categories as $c) {
9297 $ways = $c->print_all_ways(
' >> ', ($nolink ?
'none' :
''), 0, 1);
9298 foreach ($ways as $way) {
9299 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' . $way .
'</li>';
9302 if (empty($toprint)) {
9305 return '<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
9309 if ($rendermode == 0) {
9310 $arrayselected = array();
9312 foreach ($categories as $c) {
9313 $arrayselected[] = $c->id;
9316 return $this->
multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'', 0,
'100%',
'disabled',
'category');
9319 return 'ErrorBadValueForParameterRenderMode';
9333 global $conf, $langs, $hookmanager;
9334 global $bc, $action;
9339 $hookmanager->initHooks(array(
'commonobject'));
9340 $parameters = array(
9341 'morehtmlright' => $morehtmlright,
9342 'compatibleImportElementsList' => &$compatibleImportElementsList,
9344 $reshook = $hookmanager->executeHooks(
'showLinkedObjectBlock', $parameters,
$object, $action);
9346 $nbofdifferenttypes = count(
$object->linkedObjects);
9348 if (empty($reshook)) {
9349 print
'<!-- showLinkedObjectBlock -->';
9350 print
load_fiche_titre($langs->trans($title), $morehtmlright,
'', 0, 0,
'showlinkedobjectblock');
9353 print
'<div class="div-table-responsive-no-min">';
9354 print
'<table class="noborder allwidth" data-block="showLinkedObject" data-element="' .
$object->element .
'" data-elementid="' .
$object->id .
'" >';
9356 print
'<tr class="liste_titre">';
9357 print
'<td>' . $langs->trans(
"Type") .
'</td>';
9358 print
'<td>' . $langs->trans(
"Ref") .
'</td>';
9359 print
'<td class="center"></td>';
9360 print
'<td class="center">' . $langs->trans(
"Date") .
'</td>';
9361 print
'<td class="right">' . $langs->trans(
"AmountHTShort") .
'</td>';
9362 print
'<td class="right">' . $langs->trans(
"Status") .
'</td>';
9366 $nboftypesoutput = 0;
9368 foreach (
$object->linkedObjects as $objecttype => $objects) {
9369 $tplpath = $element = $subelement = $objecttype;
9372 $showImportButton =
false;
9373 if (!empty($compatibleImportElementsList) && in_array($element, $compatibleImportElementsList)) {
9374 $showImportButton =
true;
9378 if ($objecttype !=
'supplier_proposal' && preg_match(
'/^([^_]+)_([^_]+)/i', $objecttype, $regs)) {
9379 $element = $regs[1];
9380 $subelement = $regs[2];
9381 $tplpath = $element .
'/' . $subelement;
9383 $tplname =
'linkedobjectblock';
9386 if ($objecttype ==
'facture') {
9387 $tplpath =
'compta/' . $element;
9388 if (!isModEnabled(
'invoice')) {
9391 } elseif ($objecttype ==
'facturerec') {
9392 $tplpath =
'compta/facture';
9393 $tplname =
'linkedobjectblockForRec';
9394 if (!isModEnabled(
'invoice')) {
9397 } elseif ($objecttype ==
'propal') {
9398 $tplpath =
'comm/' . $element;
9399 if (!isModEnabled(
'propal')) {
9402 } elseif ($objecttype ==
'supplier_proposal') {
9403 if (!isModEnabled(
'supplier_proposal')) {
9406 } elseif ($objecttype ==
'shipping' || $objecttype ==
'shipment' || $objecttype ==
'expedition') {
9407 $tplpath =
'expedition';
9408 if (!isModEnabled(
'shipping')) {
9411 } elseif ($objecttype ==
'reception') {
9412 $tplpath =
'reception';
9413 if (!isModEnabled(
'reception')) {
9416 } elseif ($objecttype ==
'delivery') {
9417 $tplpath =
'delivery';
9421 } elseif ($objecttype ==
'ficheinter') {
9422 $tplpath =
'fichinter';
9423 if (!isModEnabled(
'intervention')) {
9426 } elseif ($objecttype ==
'invoice_supplier') {
9427 $tplpath =
'fourn/facture';
9428 } elseif ($objecttype ==
'order_supplier') {
9429 $tplpath =
'fourn/commande';
9430 } elseif ($objecttype ==
'expensereport') {
9431 $tplpath =
'expensereport';
9432 } elseif ($objecttype ==
'subscription') {
9433 $tplpath =
'adherents';
9434 } elseif ($objecttype ==
'conferenceorbooth') {
9435 $tplpath =
'eventorganization';
9436 } elseif ($objecttype ==
'conferenceorboothattendee') {
9437 $tplpath =
'eventorganization';
9438 } elseif ($objecttype ==
'mo') {
9440 if (!isModEnabled(
'mrp')) {
9445 global $linkedObjectBlock;
9446 $linkedObjectBlock = $objects;
9449 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/' . $tplpath .
'/tpl'));
9450 foreach ($dirtpls as $reldir) {
9451 $reldir = rtrim($reldir,
'/');
9452 if ($nboftypesoutput == ($nbofdifferenttypes - 1)) {
9453 global $noMoreLinkedObjectBlockAfter;
9454 $noMoreLinkedObjectBlockAfter = 1;
9457 $res = @include
dol_buildpath($reldir .
'/' . $tplname .
'.tpl.php');
9465 if (!$nboftypesoutput) {
9466 print
'<tr><td class="impair" colspan="7"><span class="opacitymedium">' . $langs->trans(
"None") .
'</span></td></tr>';
9471 if (!empty($compatibleImportElementsList)) {
9472 $res = @include
dol_buildpath(
'core/tpl/objectlinked_lineimport.tpl.php');
9478 return $nbofdifferenttypes;
9491 global $conf, $langs, $hookmanager;
9495 $linktoelemlist =
'';
9496 $listofidcompanytoscan =
'';
9498 if (!is_object(
$object->thirdparty)) {
9502 $possiblelinks = array();
9503 if (is_object(
$object->thirdparty) && !empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
9504 $listofidcompanytoscan =
$object->thirdparty->id;
9506 $listofidcompanytoscan .=
',' .
$object->thirdparty->parent;
9509 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
9510 $tmpproject =
new Project($this->db);
9511 $tmpproject->fetch(
$object->fk_project);
9512 if ($tmpproject->socid > 0 && ($tmpproject->socid !=
$object->thirdparty->id)) {
9513 $listofidcompanytoscan .=
',' . $tmpproject->socid;
9518 $possiblelinks = array(
9520 'enabled' => isModEnabled(
'propal'),
9522 'label' =>
'LinkToProposal',
9523 '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') .
')'),
9524 'shipping' => array(
9525 'enabled' => isModEnabled(
'shipping'),
9527 'label' =>
'LinkToExpedition',
9528 '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') .
')'),
9530 'enabled' => isModEnabled(
'order'),
9532 'label' =>
'LinkToOrder',
9533 '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') .
')'),
9535 'enabled' => isModEnabled(
'invoice'),
9537 'label' =>
'LinkToInvoice',
9538 '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') .
')'),
9539 'invoice_template' => array(
9540 'enabled' => isModEnabled(
'invoice'),
9542 'label' =>
'LinkToTemplateInvoice',
9543 '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') .
')'),
9545 'enabled' => isModEnabled(
'contract'),
9547 'label' =>
'LinkToContract',
9548 '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
9549 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'
9551 'fichinter' => array(
9552 'enabled' => isModEnabled(
'intervention'),
9554 'label' =>
'LinkToIntervention',
9555 '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') .
')'),
9556 'supplier_proposal' => array(
9557 'enabled' => isModEnabled(
'supplier_proposal'),
9559 'label' =>
'LinkToSupplierProposal',
9560 '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') .
')'),
9561 'order_supplier' => array(
9562 'enabled' => isModEnabled(
"supplier_order"),
9564 'label' =>
'LinkToSupplierOrder',
9565 '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') .
')'),
9566 'invoice_supplier' => array(
9567 'enabled' => isModEnabled(
"supplier_invoice"),
9568 'perms' => 1,
'label' =>
'LinkToSupplierInvoice',
9569 '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') .
')'),
9571 'enabled' => isModEnabled(
'ticket'),
9573 'label' =>
'LinkToTicket',
9574 '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') .
')'),
9576 'enabled' => isModEnabled(
'mrp'),
9578 'label' =>
'LinkToMo',
9579 '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') .
')')
9583 if (
$object->table_element ==
'commande_fournisseur') {
9584 $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').
')';
9585 } elseif (
$object->table_element ==
'mrp_mo') {
9586 $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').
')';
9590 if (!empty($listofidcompanytoscan)) {
9592 $hookmanager->initHooks(array(
'commonobject'));
9593 $parameters = array(
'listofidcompanytoscan' => $listofidcompanytoscan,
'possiblelinks' => $possiblelinks);
9594 $reshook = $hookmanager->executeHooks(
'showLinkToObjectBlock', $parameters,
$object, $action);
9597 if (empty($reshook)) {
9598 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
9599 $possiblelinks = array_merge($possiblelinks, $hookmanager->resArray);
9601 } elseif ($reshook > 0) {
9602 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
9603 $possiblelinks = $hookmanager->resArray;
9607 foreach ($possiblelinks as $key => $possiblelink) {
9610 if (empty($possiblelink[
'enabled'])) {
9614 if (!empty($possiblelink[
'perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) {
9615 print
'<div id="' . $key .
'list"' . (empty($conf->use_javascript_ajax) ?
'' :
' style="display:none"') .
'>';
9619 print
'<!-- form to add a link from anywhere -->'.
"\n";
9620 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="formlinkedbyref' . $key .
'">';
9621 print
'<input type="hidden" name="id" value="' .
$object->id .
'">';
9622 print
'<input type="hidden" name="action" value="addlinkbyref">';
9623 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
9624 print
'<input type="hidden" name="addlink" value="' . $key .
'">';
9625 print
'<table class="noborder">';
9628 print
'<td class="center"><input type="text" placeholder="'.dol_escape_htmltag($langs->trans(
"Ref")).
'" name="reftolinkto" value="' .
dol_escape_htmltag(
GETPOST(
'reftolinkto',
'alpha')) .
'"> ';
9629 print
'<input type="submit" class="button small valignmiddle" value="' . $langs->trans(
'ToLink') .
'"> ';
9630 print
'<input type="submit" class="button small" name="cancel" value="' . $langs->trans(
'Cancel') .
'"></td>';
9636 $sql = $possiblelink[
'sql'];
9638 $resqllist = $this->db->query($sql);
9640 $num = $this->db->num_rows($resqllist);
9644 print
'<!-- form to add a link from object to same thirdparty -->'.
"\n";
9645 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="formlinked' . $key .
'">';
9646 print
'<input type="hidden" name="action" value="addlink">';
9647 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
9648 print
'<input type="hidden" name="id" value="' .
$object->id .
'">';
9649 print
'<input type="hidden" name="addlink" value="' . $key .
'">';
9650 print
'<table class="noborder">';
9651 print
'<tr class="liste_titre">';
9652 print
'<td class="nowrap"></td>';
9653 print
'<td class="center">' . $langs->trans(
"Ref") .
'</td>';
9654 print
'<td class="left">' . $langs->trans(
"RefCustomer") .
'</td>';
9655 print
'<td class="right">' . $langs->trans(
"AmountHTShort") .
'</td>';
9656 print
'<td class="left">' . $langs->trans(
"Company") .
'</td>';
9659 $objp = $this->db->fetch_object($resqllist);
9661 print
'<tr class="oddeven">';
9662 print
'<td class="left">';
9663 print
'<input type="radio" name="idtolinkto" id="' . $key .
'_' . $objp->rowid .
'" value="' . $objp->rowid .
'">';
9665 print
'<td class="center"><label for="' . $key .
'_' . $objp->rowid .
'">' . $objp->ref .
'</label></td>';
9666 print
'<td>' . (!empty($objp->ref_client) ? $objp->ref_client : (!empty($objp->ref_supplier) ? $objp->ref_supplier :
'')) .
'</td>';
9667 print
'<td class="right">';
9668 if ($possiblelink[
'label'] ==
'LinkToContract') {
9669 $form =
new Form($this->db);
9670 print $form->textwithpicto(
'', $langs->trans(
"InformationOnLinkToContract")) .
' ';
9672 print
'<span class="amount">' . (isset($objp->total_ht) ?
price($objp->total_ht) :
'') .
'</span>';
9674 print
'<td>' . $objp->name .
'</td>';
9679 print
'<div class="center">';
9681 print
'<input type="submit" class="button valignmiddle marginleftonly marginrightonly small" value="' . $langs->trans(
'ToLink') .
'">';
9683 if (empty($conf->use_javascript_ajax)) {
9684 print
'<input type="submit" class="button button-cancel marginleftonly marginrightonly small" name="cancel" value="' . $langs->trans(
"Cancel") .
'"></div>';
9686 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>';
9689 $this->db->free($resqllist);
9697 $linktoelemlist .=
'<li><a href="#linkto' . $key .
'" class="linkto dropdowncloseonclick" rel="' . $key .
'">' . $langs->trans($possiblelink[
'label']) .
' (' . $num .
')</a></li>';
9700 $linktoelemlist .=
'<li><span class="linktodisabled">' . $langs->trans($possiblelink[
'label']) .
' (0)</span></li>';
9705 if ($linktoelemlist) {
9707 <dl class="dropdown" id="linktoobjectname">
9709 if (!empty($conf->use_javascript_ajax)) {
9710 $linktoelem .=
'<dt><a href="#linktoobjectname"><span class="fas fa-link paddingrightonly"></span>' . $langs->trans(
"LinkTo") .
'...</a></dt>';
9712 $linktoelem .=
'<dd>
9713 <div class="multiselectlinkto">
9714 <ul class="ulselectedfields">' . $linktoelemlist .
'
9723 if (!empty($conf->use_javascript_ajax)) {
9724 print
'<!-- Add js to show linkto box -->
9725 <script nonce="' .
getNonce() .
'">
9726 jQuery(document).ready(function() {
9727 jQuery(".linkto").click(function() {
9728 console.log("We choose to show/hide links for rel="+jQuery(this).attr(\'rel\')+" so #"+jQuery(this).attr(\'rel\')+"list");
9729 jQuery("#"+jQuery(this).attr(\'rel\')+"list").toggle();
9753 public function selectyesno($htmlname, $value =
'', $option = 0, $disabled =
false, $useempty = 0, $addjscombo = 0, $morecss =
'', $labelyes =
'Yes', $labelno =
'No')
9764 $disabled = ($disabled ?
' disabled' :
'');
9766 $resultyesno =
'<select class="flat width75' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'"' . $disabled .
'>' .
"\n";
9768 $resultyesno .=
'<option value="-1"' . (($value < 0) ?
' selected' :
'') .
'> </option>' .
"\n";
9770 if ((
"$value" ==
'yes') || ($value == 1)) {
9771 $resultyesno .=
'<option value="' . $yes .
'" selected>' . $langs->trans($labelyes) .
'</option>' .
"\n";
9772 $resultyesno .=
'<option value="' . $no .
'">' . $langs->trans($labelno) .
'</option>' .
"\n";
9774 $selected = (($useempty && $value !=
'0' && $value !=
'no') ?
'' :
' selected');
9775 $resultyesno .=
'<option value="' . $yes .
'">' . $langs->trans($labelyes) .
'</option>' .
"\n";
9776 $resultyesno .=
'<option value="' . $no .
'"' . $selected .
'>' . $langs->trans($labelno) .
'</option>' .
"\n";
9778 $resultyesno .=
'</select>' .
"\n";
9781 $resultyesno .=
ajax_combobox($htmlname, array(), 0, 0,
'resolve', ($useempty < 0 ? (
string) $useempty :
'-1'), $morecss);
9784 return $resultyesno;
9801 $sql =
"SELECT rowid, label";
9802 $sql .=
" FROM " . $this->db->prefix() .
"export_model";
9803 $sql .=
" WHERE type = '" . $this->db->escape($type) .
"'";
9804 $sql .=
" ORDER BY rowid";
9805 $result = $this->db->query($sql);
9807 print
'<select class="flat" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
9809 print
'<option value="-1"> </option>';
9812 $num = $this->db->num_rows($result);
9815 $obj = $this->db->fetch_object($result);
9816 if ($selected == $obj->rowid) {
9817 print
'<option value="' . $obj->rowid .
'" selected>';
9819 print
'<option value="' . $obj->rowid .
'">';
9849 public function showrefnav(
$object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $morehtmlright =
'')
9851 global $conf, $langs, $hookmanager, $extralanguages;
9854 if (empty($fieldid)) {
9857 if (empty($fieldref)) {
9863 if (property_exists(
$object,
'gender') && !empty(
$object->gender)) {
9864 $addgendertxt =
' ';
9867 $addgendertxt .=
'<i class="fas fa-mars"></i>';
9870 $addgendertxt .=
'<i class="fas fa-venus"></i>';
9873 $addgendertxt .=
'<i class="fas fa-transgender"></i>';
9879 if (is_object($hookmanager)) {
9880 $parameters = array(
'showrefnav' =>
true);
9881 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object);
9882 $object->next_prev_filter .= $hookmanager->resPrint;
9885 $previous_ref = $next_ref =
'';
9888 $object->load_previous_next_ref((isset(
$object->next_prev_filter) ?
$object->next_prev_filter :
''), $fieldid, $nodbprefix);
9890 $navurl = $_SERVER[
"PHP_SELF"];
9892 if ($paramid ==
'project_ref') {
9893 if (preg_match(
'/\/tasks\/(task|contact|note|document)\.php/', $navurl)) {
9894 $navurl = preg_replace(
'/\/tasks\/(task|contact|time|note|document)\.php/',
'/tasks.php', $navurl);
9901 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
9902 if ($conf->browser->name ==
'chrome') {
9903 $stringforfirstkey .=
' ALT +';
9904 } elseif ($conf->browser->name ==
'firefox') {
9905 $stringforfirstkey .=
' ALT + SHIFT +';
9907 $stringforfirstkey .=
' CTL +';
9910 $previous_ref =
$object->ref_previous ?
'<a accesskey="p" alt="'.dol_escape_htmltag($langs->trans(
"Previous")).
'" 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>';
9911 $next_ref =
$object->ref_next ?
'<a accesskey="n" alt="'.dol_escape_htmltag($langs->trans(
"Next")).
'" 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>';
9915 $ret .=
'<!-- Start banner content --><div style="vertical-align: middle">';
9918 if ($morehtmlright) {
9919 $ret .=
'<div class="inline-block floatleft">' . $morehtmlright .
'</div>';
9922 if ($previous_ref || $next_ref || $morehtml) {
9923 $ret .=
'<div class="pagination paginationref"><ul class="right">';
9925 if ($morehtml &&
getDolGlobalInt(
'MAIN_OPTIMIZEFORTEXTBROWSER') < 2) {
9926 $ret .=
'<!-- morehtml --><li class="noborder litext' . (($shownav && $previous_ref && $next_ref) ?
' clearbothonsmartphone' :
'') .
'">' . $morehtml .
'</li>';
9928 if ($shownav && ($previous_ref || $next_ref)) {
9929 $ret .=
'<li class="pagination">' . $previous_ref .
'</li>';
9930 $ret .=
'<li class="pagination">' . $next_ref .
'</li>';
9932 if ($previous_ref || $next_ref || $morehtml) {
9933 $ret .=
'</ul></div>';
9937 $parameters = array(
'morehtmlstatus' => $morehtmlstatus);
9938 $reshook = $hookmanager->executeHooks(
'moreHtmlStatus', $parameters,
$object);
9939 if (empty($reshook)) {
9940 $morehtmlstatus .= $hookmanager->resPrint;
9942 $morehtmlstatus = $hookmanager->resPrint;
9944 if ($morehtmlstatus) {
9945 $ret .=
'<div class="statusref">' . $morehtmlstatus .
'</div>';
9948 $parameters = array();
9949 $reshook = $hookmanager->executeHooks(
'moreHtmlRef', $parameters,
$object);
9950 if (empty($reshook)) {
9951 $morehtmlref .= $hookmanager->resPrint;
9952 } elseif ($reshook > 0) {
9953 $morehtmlref = $hookmanager->resPrint;
9957 if ($morehtmlleft) {
9958 if ($conf->browser->layout ==
'phone') {
9959 $ret .=
'<!-- morehtmlleft --><div class="floatleft">' . $morehtmlleft .
'</div>';
9961 $ret .=
'<!-- morehtmlleft --><div class="inline-block floatleft">' . $morehtmlleft .
'</div>';
9966 $ret .=
'<div class="inline-block floatleft valignmiddle maxwidth750 marginbottomonly refid' . (($shownav && ($previous_ref || $next_ref)) ?
' refidpadding' :
'') .
'">';
9969 if (
$object->element ==
'societe') {
9973 $arrayoflangcode = array();
9978 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
9979 if (!is_object($extralanguages)) {
9980 include_once DOL_DOCUMENT_ROOT .
'/core/class/extralanguages.class.php';
9983 $extralanguages->fetch_name_extralanguages(
'societe');
9985 if (!empty($extralanguages->attributes[
'societe'][
'name'])) {
9986 $object->fetchValuesForExtraLanguages();
9990 foreach ($arrayoflangcode as $extralangcode) {
9992 if (
$object->array_languages[
'name'][$extralangcode]) {
9993 $htmltext .=
$object->array_languages[
'name'][$extralangcode];
9995 $htmltext .=
'<span class="opacitymedium">' . $langs->trans(
"SwitchInEditModeToAddTranslation") .
'</span>';
9998 $ret .=
'<!-- Show translations of name -->' .
"\n";
9999 $ret .= $this->
textwithpicto(
'', $htmltext, -1,
'language',
'opacitymedium paddingleft');
10002 } elseif (
$object->element ==
'member') {
10003 '@phan-var-force Adherent $object';
10004 $ret .=
$object->ref .
'<br>';
10005 $fullname =
$object->getFullName($langs);
10011 } elseif (in_array(
$object->element, array(
'contact',
'user'))) {
10013 } elseif (
$object->element ==
'usergroup') {
10015 } elseif (in_array(
$object->element, array(
'action',
'agenda'))) {
10016 '@phan-var-force ActionComm $object';
10018 } elseif (in_array(
$object->element, array(
'adherent_type'))) {
10020 } elseif (
$object->element ==
'ecm_directories') {
10022 } elseif ($fieldref !=
'none') {
10025 if ($morehtmlref) {
10027 if (substr($morehtmlref, 0, 4) !=
'<div') {
10031 $ret .= $morehtmlref;
10036 $ret .=
'</div><!-- End banner content -->';
10055 if (empty(
$object->barcode)) {
10060 if (empty(
$object->barcode_type_code) || empty(
$object->barcode_type_coder)) {
10062 $result =
$object->fetch_barcode();
10065 return '<!-- ErrorFetchBarcode -->';
10070 $url = DOL_URL_ROOT .
'/viewimage.php?modulepart=barcode&generator=' . urlencode(
$object->barcode_type_coder) .
'&code=' . urlencode(
$object->barcode) .
'&encoding=' . urlencode(
$object->barcode_type_code);
10071 $out =
'<!-- url barcode = ' . $url .
' -->';
10072 $out .=
'<img src="' . $url .
'"' . ($morecss ?
' class="' . $morecss .
'"' :
'') .
'>';
10094 public static function showphoto($modulepart,
$object, $width = 100, $height = 0, $caneditfield = 0, $cssclass =
'photowithmargin', $imagesize =
'', $addlinktofullsize = 1, $cache = 0, $forcecapture =
'', $noexternsourceoverwrite = 0)
10096 global $conf, $langs;
10098 $entity = (empty(
$object->entity) ? $conf->entity :
$object->entity);
10103 $originalfile =
'';
10107 if ($modulepart ==
'societe') {
10108 $dir = $conf->societe->multidir_output[$entity];
10111 if ((
string) $imagesize ==
'mini') {
10113 } elseif ((
string) $imagesize ==
'small') {
10122 } elseif ($modulepart ==
'contact') {
10123 $dir = $conf->societe->multidir_output[$entity] .
'/contact';
10124 if (!empty(
$object->photo)) {
10126 if ((
string) $imagesize ==
'mini') {
10128 } elseif ((
string) $imagesize ==
'small') {
10138 } elseif ($modulepart ==
'userphoto') {
10139 $dir = $conf->user->dir_output;
10140 if (!empty(
$object->photo)) {
10142 if ((
string) $imagesize ==
'mini') {
10144 } elseif ((
string) $imagesize ==
'small') {
10153 $altfile =
$object->id .
".jpg";
10157 } elseif ($modulepart ==
'memberphoto') {
10158 $dir = $conf->adherent->dir_output;
10159 if (!empty(
$object->photo)) {
10161 if ((
string) $imagesize ==
'mini') {
10163 } elseif ((
string) $imagesize ==
'small') {
10172 $altfile =
$object->id .
".jpg";
10179 if ($modulepart !=
"unknown" && method_exists(
$object,
'getDataToShowPhoto')) {
10180 $tmpdata =
$object->getDataToShowPhoto($modulepart, $imagesize);
10182 $dir = $tmpdata[
'dir'];
10183 $file = $tmpdata[
'file'];
10184 $originalfile = $tmpdata[
'originalfile'];
10185 $altfile = $tmpdata[
'altfile'];
10186 $email = $tmpdata[
'email'];
10187 $capture = $tmpdata[
'capture'];
10191 if ($forcecapture) {
10192 $capture = $forcecapture;
10198 if ($file && file_exists($dir .
"/" . $file)) {
10199 if ($addlinktofullsize) {
10201 if ($urladvanced) {
10202 $ret .=
'<a href="' . $urladvanced .
'">';
10204 $ret .=
'<a href="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($originalfile) .
'&cache=' . $cache .
'">';
10207 $ret .=
'<img alt="" 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 .
'">';
10208 if ($addlinktofullsize) {
10211 } elseif ($altfile && file_exists($dir .
"/" . $altfile)) {
10212 if ($addlinktofullsize) {
10214 if ($urladvanced) {
10215 $ret .=
'<a href="' . $urladvanced .
'">';
10217 $ret .=
'<a href="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($originalfile) .
'&cache=' . $cache .
'">';
10220 $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 .
'">';
10221 if ($addlinktofullsize) {
10225 $nophoto =
'/public/theme/common/nophoto.png';
10226 $defaultimg =
'identicon';
10227 if (in_array($modulepart, array(
'societe',
'userphoto',
'contact',
'memberphoto'))) {
10228 if ($modulepart ==
'societe' || ($modulepart ==
'memberphoto' && !empty(
$object->morphy) && strpos(
$object->morphy,
'mor') !==
false)) {
10229 $nophoto =
'company';
10231 $nophoto =
'/public/theme/common/user_anonymous.png';
10233 $nophoto =
'/public/theme/common/user_man.png';
10236 $nophoto =
'/public/theme/common/user_woman.png';
10241 if (isModEnabled(
'gravatar') && $email && empty($noexternsourceoverwrite)) {
10243 $ret .=
'<!-- Put link to gravatar -->';
10244 $ret .=
'<img class="photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" title="' . $email .
' Gravatar avatar" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
' src="https://www.gravatar.com/avatar/' .
dol_hash(strtolower(trim($email)),
'sha256', 1) .
'?s=' . $width .
'&d=' . $defaultimg .
'">';
10246 if ($nophoto ==
'company') {
10247 $ret .=
'<div class="divforspanimg valignmiddle center photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
'>' .
img_picto(
'',
'company') .
'</div>';
10250 $ret .=
'<img class="photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
' src="' . DOL_URL_ROOT . $nophoto .
'">';
10255 if ($caneditfield) {
10259 $ret .=
'<table class="nobordernopadding centpercent">';
10261 $ret .=
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">' . $langs->trans(
"Delete") .
'</label><br><br></td></tr>';
10263 $ret .=
'<tr><td class="tdoverflow">';
10265 $maxmin = $maxfilesizearray[
'maxmin'];
10267 $ret .=
'<input type="hidden" name="MAX_FILE_SIZE" value="' . ($maxmin * 1024) .
'">';
10269 $ret .=
'<input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"' . ($capture ?
' capture="' . $capture .
'"' :
'') .
'>';
10270 $ret .=
'</td></tr>';
10271 $ret .=
'</table>';
10296 public function select_dolgroups($selected = 0, $htmlname =
'groupid', $show_empty = 0, $exclude =
'', $disabled = 0, $include =
'', $enableonly = array(), $force_entity =
'0', $multiple =
false, $morecss =
'minwidth200')
10299 global $conf, $user, $langs;
10302 $excludeGroups =
null;
10303 if (is_array($exclude)) {
10304 $excludeGroups = implode(
",", $exclude);
10307 $includeGroups =
null;
10308 if (is_array($include)) {
10309 $includeGroups = implode(
",", $include);
10312 if (!is_array($selected)) {
10313 $selected = array($selected);
10319 $sql =
"SELECT ug.rowid, ug.nom as name";
10320 if (isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
10321 $sql .=
", e.label";
10323 $sql .=
" FROM " . $this->db->prefix() .
"usergroup as ug ";
10324 if (isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
10325 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entity as e ON e.rowid=ug.entity";
10326 if ($force_entity) {
10327 $sql .=
" WHERE ug.entity IN (0, " . $force_entity .
")";
10329 $sql .=
" WHERE ug.entity IS NOT NULL";
10332 $sql .=
" WHERE ug.entity IN (0, " . $conf->entity .
")";
10334 if (is_array($exclude) && $excludeGroups) {
10335 $sql .=
" AND ug.rowid NOT IN (" . $this->db->sanitize($excludeGroups) .
")";
10337 if (is_array($include) && $includeGroups) {
10338 $sql .=
" AND ug.rowid IN (" . $this->db->sanitize($includeGroups) .
")";
10340 $sql .=
" ORDER BY ug.nom ASC";
10342 dol_syslog(get_class($this) .
"::select_dolgroups", LOG_DEBUG);
10343 $resql = $this->db->query($sql);
10346 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
10348 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
' ' . ($disabled ?
' disabled' :
'') .
'>';
10350 $num = $this->db->num_rows($resql);
10353 if ($show_empty && !$multiple) {
10354 $out .=
'<option value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'> </option>' .
"\n";
10357 while ($i < $num) {
10358 $obj = $this->db->fetch_object($resql);
10360 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
10364 $label = $obj->name;
10365 $labelhtml = $obj->name;
10366 if (isModEnabled(
'multicompany') && !
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1) {
10367 $label .=
" (" . $obj->label .
")";
10368 $labelhtml .=
' <span class="opacitymedium">(' . $obj->label .
')</span>';
10371 $out .=
'<option value="' . $obj->rowid .
'"';
10372 if ($disableline) {
10373 $out .=
' disabled';
10375 if ((isset($selected[0]) && is_object($selected[0]) && $selected[0]->
id == $obj->rowid)
10376 || ((!isset($selected[0]) || !is_object($selected[0])) && !empty($selected) && in_array($obj->rowid, $selected))) {
10377 $out .=
' selected';
10379 $out .=
' data-html="'.dol_escape_htmltag($labelhtml).
'"';
10382 $out .=
'</option>';
10387 $out .=
'<option value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'></option>' .
"\n";
10389 $out .=
'<option value="" disabled>' . $langs->trans(
"NoUserGroupDefined") .
'</option>';
10391 $out .=
'</select>';
10410 $out =
'<div class="nowraponall">';
10411 $out .=
'<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fas fa-search"></span></button>';
10412 $out .=
'<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fas fa-times"></span></button>';
10426 public function showCheckAddButtons($cssclass =
'checkforaction', $calljsfunction = 0, $massactionname =
"massaction")
10432 if (!empty($conf->use_javascript_ajax)) {
10433 $out .=
'<div class="inline-block checkallactions"><input type="checkbox" id="' . $cssclass .
's" name="' . $cssclass .
's" class="checkallactions"></div>';
10435 $out .=
'<script nonce="' .
getNonce() .
'">
10436 $(document).ready(function() {
10437 $("#' . $cssclass .
's").click(function() {
10438 if($(this).is(\':checked\')){
10439 console.log("We check all ' . $cssclass .
' and trigger the change method");
10440 $(".' . $cssclass .
'").prop(\'checked\', true).trigger(\'change\');
10444 console.log("We uncheck all");
10445 $(".' . $cssclass .
'").prop(\'checked\', false).trigger(\'change\');
10447 if ($calljsfunction) {
10448 $out .=
'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "' . $massactionname .
'", "' . $cssclass .
'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
10451 $(".' . $cssclass .
'").change(function() {
10452 $(this).closest("tr").toggleClass("highlight", this.checked);
10472 if ($addcheckuncheckall) {
10491 public function selectExpenseCategories($selected =
'', $htmlname =
'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target =
'', $default_selected = 0, $params = array(), $info_admin = 1)
10493 global $langs, $user;
10496 $sql =
"SELECT rowid, label FROM " . $this->db->prefix() .
"c_exp_tax_cat WHERE active = 1";
10497 $sql .=
" AND entity IN (0," .
getEntity(
'exp_tax_cat') .
")";
10498 if (!empty($excludeid)) {
10499 $sql .=
" AND rowid NOT IN (" . $this->db->sanitize(implode(
',', $excludeid)) .
")";
10501 $sql .=
" ORDER BY label";
10503 $resql = $this->db->query($sql);
10505 $out =
'<select id="select_' . $htmlname .
'" name="' . $htmlname .
'" class="' . $htmlname .
' flat minwidth75imp maxwidth200">';
10507 $out .=
'<option value="0"> </option>';
10510 while ($obj = $this->db->fetch_object($resql)) {
10511 $out .=
'<option ' . ($selected == $obj->rowid ?
'selected="selected"' :
'') .
' value="' . $obj->rowid .
'">' . $langs->trans($obj->label) .
'</option>';
10513 $out .=
'</select>';
10516 if (!empty($htmlname) && $user->admin && $info_admin) {
10517 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
10520 if (!empty($target)) {
10521 $sql =
"SELECT c.id FROM " . $this->db->prefix() .
"c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1";
10522 $resql = $this->db->query($sql);
10524 if ($this->db->num_rows($resql) > 0) {
10525 $obj = $this->db->fetch_object($resql);
10526 $out .=
'<script nonce="' .
getNonce() .
'">
10528 $("select[name=' . $target .
']").on("change", function() {
10529 var current_val = $(this).val();
10530 if (current_val == ' . $obj->id .
') {';
10531 if (!empty($default_selected) || !empty($selected)) {
10532 $out .=
'$("select[name=' . $htmlname .
']").val("' . ($default_selected > 0 ? $default_selected : $selected) .
'");';
10536 $("select[name=' . $htmlname .
']").change();
10540 $("select[name=' . $htmlname .
']").change(function() {
10542 if ($("select[name=' . $target .
']").val() == ' . $obj->id .
') {
10543 // get price of kilometer to fill the unit price
10547 data: { fk_c_exp_tax_cat: $(this).val(), token: \'' .
currentToken() .
'\' },
10548 url:
"' . (DOL_URL_ROOT . '/expensereport/ajax/ajaxik.php?' . implode('&', $params)) . '",
10549 }).done(
function( data, textStatus, jqXHR ) {
10551 if (typeof data.up !=
"undefined") {
10552 $(
"input[name=value_unit]").val(data.up);
10553 $(
"select[name=' . $htmlname . ']").attr(
"title", data.title);
10555 $(
"input[name=value_unit]").val(
"");
10556 $(
"select[name=' . $htmlname . ']").attr(
"title",
"");
10567 dol_print_error($this->db);
10581 public function selectExpenseRanges($selected = '
', $htmlname = 'fk_range
', $useempty = 0)
10583 global $conf, $langs;
10586 $sql = "SELECT rowid, range_ik FROM " . $this->db->prefix() . "c_exp_tax_range";
10587 $sql .= " WHERE entity = " . $conf->entity . " AND active = 1";
10589 $resql = $this->db->query($sql);
10591 $out = '<select
id=
"select_' . $htmlname . '" name=
"' . $htmlname . '" class=
"' . $htmlname . ' flat minwidth75imp">
';
10593 $out .= '<option value=
"0"></option>
';
10596 while ($obj = $this->db->fetch_object($resql)) {
10597 $out .= '<option
' . ($selected == $obj->rowid ? 'selected=
"selected"' : '') . ' value=
"' . $obj->rowid . '">
' . price($obj->range_ik, 0, $langs, 1, 0) . '</option>
';
10599 $out .= '</select>
';
10601 dol_print_error($this->db);
10617 public function selectExpense($selected = '
', $htmlname = 'fk_c_type_fees
', $useempty = 0, $allchoice = 1, $useid = 0)
10622 $sql = "SELECT id, code, label";
10623 $sql .= " FROM ".$this->db->prefix()."c_type_fees";
10624 $sql .= " WHERE active = 1";
10626 $resql = $this->db->query($sql);
10628 $out = '<select
id=
"select_' . $htmlname . '" name=
"' . $htmlname . '" class=
"' . $htmlname . ' flat minwidth75imp">
';
10630 $out .= '<option value=
"0"></option>
';
10633 $out .= '<option value=
"-1">
' . $langs->trans('AllExpenseReport
') . '</option>
';
10641 while ($obj = $this->db->fetch_object($resql)) {
10642 $key = $langs->trans($obj->code);
10643 $out .= '<option
' . ($selected == $obj->{$field} ? 'selected=
"selected"' : '') . ' value=
"' . $obj->{$field} . '">
' . ($key != $obj->code ? $key : $obj->label) . '</option>
';
10645 $out .= '</select>
';
10647 $out .= ajax_combobox('select_
'.$htmlname);
10649 dol_print_error($this->db);
10673 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)
10675 global $user, $conf, $langs;
10677 require_once DOL_DOCUMENT_ROOT . '/projet/
class/project.class.php
';
10679 if (is_null($usertofilter)) {
10680 $usertofilter = $user;
10685 $hideunselectables = false;
10686 if (getDolGlobalString('PROJECT_HIDE_UNSELECTABLES
')) {
10687 $hideunselectables = true;
10690 if (empty($projectsListId)) {
10691 if (!$usertofilter->hasRight('projet
', 'all
', 'lire
')) {
10692 $projectstatic = new Project($this->db);
10693 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
10697 // Search all projects
10698 $sql = "SELECT f.rowid, f.ref as fref, 'nolabel
' as flabel, p.rowid as pid, f.ref,
10699 p.title, p.fk_soc, p.fk_statut, p.public,";
10700 $sql .= ' s.nom as
name';
10701 $sql .= ' FROM
' . $this->db->prefix() . 'projet as p
';
10702 $sql .= ' LEFT JOIN
' . $this->db->prefix() . 'societe as s ON s.rowid = p.fk_soc,
';
10703 $sql .= ' ' . $this->db->prefix() . 'facture as f
';
10704 $sql .= " WHERE p.entity IN (" . getEntity('project
') . ")";
10705 $sql .= " AND f.fk_projet = p.rowid AND f.fk_statut=0"; //Brouillons seulement
10706 //if ($projectsListId) $sql.= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")";
10707 //if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
10708 //if ($socid > 0) $sql.= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)";
10709 $sql .= " ORDER BY p.ref, f.ref ASC";
10711 $resql = $this->db->query($sql);
10713 // Use select2 selector
10714 if (!empty($conf->use_javascript_ajax)) {
10715 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php
';
10716 $comboenhancement = ajax_combobox($htmlname, array(), 0, $forcefocus);
10717 $out .= $comboenhancement;
10718 $morecss = 'minwidth200imp maxwidth500
';
10721 if (empty($option_only)) {
10722 $out .= '<select
class=
"valignmiddle flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled=
"disabled"' : '') . ' id=
"' . $htmlname . '" name=
"' . $htmlname . '">
';
10724 if (!empty($show_empty)) {
10725 $out .= '<option value=
"0" class=
"optiongrey">
';
10726 if (!is_numeric($show_empty)) {
10727 $out .= $show_empty;
10731 $out .= '</option>
';
10733 $num = $this->db->num_rows($resql);
10736 while ($i < $num) {
10737 $obj = $this->db->fetch_object($resql);
10738 // 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.
10739 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$usertofilter->hasRight('societe
', 'lire
')) {
10742 if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED) {
10749 if ($showproject == 'all
') {
10750 $labeltoshow .= dol_trunc($obj->ref, 18); // Invoice ref
10752 $labeltoshow .= ' -
' . $obj->name; // Soc name
10756 if ($obj->fk_statut == Project::STATUS_DRAFT) {
10758 $labeltoshow .= ' -
' . $langs->trans("Draft");
10759 } elseif ($obj->fk_statut == Project::STATUS_CLOSED) {
10760 if ($discard_closed == 2) {
10763 $labeltoshow .= ' -
' . $langs->trans("Closed");
10764 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
10766 $labeltoshow .= ' -
' . $langs->trans("LinkedToAnotherCompany");
10770 if (!empty($selected) && $selected == $obj->rowid) {
10771 $out .= '<option value=
"' . $obj->rowid . '" selected
';
10772 //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected
if disabled
10773 $out .=
'>' . $labeltoshow .
'</option>';
10775 if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
10778 $resultat =
'<option value="' . $obj->rowid .
'"';
10780 $resultat .=
' disabled';
10785 $resultat .= $labeltoshow;
10786 $resultat .=
'</option>';
10794 if (empty($option_only)) {
10795 $out .=
'</select>';
10798 $this->db->free($resql);
10820 public function selectInvoiceRec($selected =
'', $htmlname =
'facrecid', $maxlength = 24, $option_only = 0, $show_empty =
'1', $forcefocus = 0, $disabled = 0, $morecss =
'maxwidth500')
10822 global $conf, $langs;
10828 $sql =
'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc';
10830 $sql .=
' FROM ' . MAIN_DB_PREFIX .
'facture_rec as f';
10831 $sql .=
" WHERE f.entity IN (" .
getEntity(
'invoice') .
")";
10832 $sql .=
" ORDER BY f.titre ASC";
10834 $resql = $this->db->query($sql);
10837 if (!empty($conf->use_javascript_ajax)) {
10838 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
10839 $comboenhancement =
ajax_combobox($htmlname, array(), 0, $forcefocus);
10840 $out .= $comboenhancement;
10841 $morecss =
'minwidth200imp maxwidth500';
10844 if (empty($option_only)) {
10845 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' id="' . $htmlname .
'" name="' . $htmlname .
'">';
10847 if (!empty($show_empty)) {
10848 $out .=
'<option value="0" class="optiongrey">';
10849 if (!is_numeric($show_empty)) {
10850 $out .= $show_empty;
10854 $out .=
'</option>';
10856 $num = $this->db->num_rows($resql);
10858 while ($obj = $this->db->fetch_object($resql)) {
10859 $labeltoshow =
dol_trunc($obj->title, 18);
10862 if (!empty($obj->suspended)) {
10864 $labeltoshow .=
' - ' . $langs->trans(
"Closed");
10868 if (!empty($selected) && $selected == $obj->rowid) {
10869 $out .=
'<option value="' . $obj->rowid .
'" selected';
10871 $out .=
'>' . $labeltoshow .
'</option>';
10873 if ($disabled && ($selected != $obj->rowid)) {
10876 $resultat =
'<option value="' . $obj->rowid .
'"';
10878 $resultat .=
' disabled';
10881 $resultat .= $labeltoshow;
10882 $resultat .=
'</option>';
10888 if (empty($option_only)) {
10889 $out .=
'</select>';
10894 $this->db->free($resql);
10897 $this->errors[] = $this->db->lasterror;
10911 public function searchComponent($arrayofcriterias, $search_component_params, $arrayofinputfieldsalreadyoutput = array(), $search_component_params_hidden =
'')
10915 if ($search_component_params_hidden !=
'' && !preg_match(
'/^\(.*\)$/', $search_component_params_hidden)) {
10916 $search_component_params_hidden =
'(' . $search_component_params_hidden .
')';
10921 $ret .=
'<div class="divadvancedsearchfieldcomp centpercent inline-block">';
10922 $ret .=
'<a href="#" class="dropdownsearch-toggle unsetcolor">';
10923 $ret .=
'<span class="fas fa-filter linkobject boxfilter paddingright pictofixedwidth" title="' .
dol_escape_htmltag($langs->trans(
"Filters")) .
'" id="idsubimgproductdistribution"></span>';
10926 $ret .=
'<div class="divadvancedsearchfieldcompinput inline-block minwidth500 maxwidth300onsmartphone">';
10929 $ret .=
'<div id="divsearch_component_params" name="divsearch_component_params" class="noborderbottom search_component_params inline-block valignmiddle">';
10931 if ($search_component_params_hidden) {
10939 foreach ($arrayofandtags as $tmpkey => $tmpval) {
10940 $errormessage =
'';
10942 if ($errormessage) {
10943 $this->error =
'ERROR in parsing search string: '.$errormessage;
10946 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
10949 $ret .=
'<span class="marginleftonlyshort valignmiddle tagsearch" data-ufilterid="'.($tmpkey + 1).
'" data-ufilter="'.
dol_escape_htmltag($tmpval).
'">';
10950 $ret .=
'<span class="tagsearchdelete select2-selection__choice__remove" data-ufilterid="'.($tmpkey + 1).
'">x</span> ';
10962 $show_search_component_params_hidden = 1;
10963 if ($show_search_component_params_hidden) {
10964 $ret .=
'<input type="hidden" name="show_search_component_params_hidden" value="1">';
10966 $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%')) -->";
10967 $ret .=
'<input type="hidden" id="search_component_params_hidden" name="search_component_params_hidden" value="' .
dol_escape_htmltag($search_component_params_hidden) .
'">';
10971 foreach ($arrayofcriterias as $criteria) {
10972 foreach ($criteria as $criteriafamilykey => $criteriafamilyval) {
10973 if (in_array(
'search_' . $criteriafamilykey, $arrayofinputfieldsalreadyoutput)) {
10976 if (in_array($criteriafamilykey, array(
'rowid',
'ref_ext',
'entity',
'extraparams'))) {
10979 if (in_array($criteriafamilyval[
'type'], array(
'date',
'datetime',
'timestamp'))) {
10980 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_start">';
10981 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startyear">';
10982 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startmonth">';
10983 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startday">';
10984 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_end">';
10985 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endyear">';
10986 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endmonth">';
10987 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endday">';
10989 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'">';
10996 $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";
10997 $ret .=
'<input type="text" placeholder="' . $langs->trans(
"Filters") .
'" id="search_component_params_input" name="search_component_params_input" class="noborderbottom search_component_input" value="">';
11003 jQuery(".tagsearchdelete").click(function(e) {
11004 var filterid = $(this).parents().attr("data-ufilterid");
11005 console.log("We click to delete the criteria nb "+filterid);
11007 // Regenerate the search_component_params_hidden with all data-ufilter except the one to delete, and post the page
11008 var newparamstring = \'\';
11009 $(\'.tagsearch\').each(function(index, element) {
11010 tmpfilterid = $(this).attr("data-ufilterid");
11011 if (tmpfilterid != filterid) {
11012 // We keep this criteria
11013 if (newparamstring == \'\') {
11014 newparamstring = $(this).attr("data-ufilter");
11016 newparamstring = newparamstring + \' AND \' + $(this).attr("data-ufilter");
11020 console.log("newparamstring = "+newparamstring);
11022 jQuery("#search_component_params_hidden").val(newparamstring);
11024 // We repost the form
11025 $(this).closest(\'form\').submit();
11028 jQuery("#search_component_params_input").keydown(function(e) {
11029 console.log("We press a key on the filter field that is "+jQuery("#search_component_params_input").val());
11030 console.log(e.which);
11031 if (jQuery("#search_component_params_input").val() == "" && e.which == 8) {
11032 /* We click on back when the input field is already empty */
11033 event.preventDefault();
11034 jQuery("#divsearch_component_params .tagsearch").last().remove();
11035 /* Regenerate content of search_component_params_hidden from remaining .tagsearch */
11037 jQuery("#divsearch_component_params .tagsearch").each(function( index ) {
11041 s = s + $(this).attr("data-ufilter");
11043 console.log("New value for search_component_params_hidden = "+s);
11044 jQuery("#search_component_params_hidden").val(s);
11065 global $langs, $user;
11069 $TModels = array();
11071 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
11072 $formmail =
new FormMail($this->db);
11073 $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs);
11076 $TModels[0] = $langs->trans(
'DefaultMailModel');
11079 foreach ($formmail->lines_model as $model) {
11080 $TModels[$model->id] = $model->label;
11084 $retstring .=
'<select class="flat" id="select_' . $prefix .
'model_mail" name="' . $prefix .
'model_mail">';
11086 foreach ($TModels as $id_model => $label_model) {
11087 $retstring .=
'<option value="' . $id_model .
'"';
11088 $retstring .=
">" . $label_model .
"</option>";
11091 $retstring .=
"</select>";
11094 $retstring .=
ajax_combobox(
'select_' . $prefix .
'model_mail');
11111 public function buttonsSaveCancel($save_label =
'Save', $cancel_label =
'Cancel', $morebuttons = array(), $withoutdiv =
false, $morecss =
'', $dol_openinpopup =
'')
11115 $buttons = array();
11119 'label_key' => $save_label,
11122 if ($save_label ==
'Create' || $save_label ==
'Add') {
11123 $save[
'name'] =
'add';
11124 } elseif ($save_label ==
'Modify') {
11125 $save[
'name'] =
'edit';
11129 'name' =>
'cancel',
11130 'label_key' =>
'Cancel',
11133 !empty($save_label) ? $buttons[] = $save :
'';
11135 if (!empty($morebuttons)) {
11136 $buttons[] = $morebuttons;
11139 !empty($cancel_label) ? $buttons[] = $cancel :
'';
11141 $retstring = $withoutdiv ?
'' :
'<div class="center">';
11143 foreach ($buttons as $button) {
11144 $addclass = empty($button[
'addclass']) ?
'' : $button[
'addclass'];
11145 $retstring .=
'<input type="submit" class="button button-' . $button[
'name'] . ($morecss ?
' ' . $morecss :
'') .
' ' . $addclass .
'" name="' . $button[
'name'] .
'" value="' .
dol_escape_htmltag($langs->trans($button[
'label_key'])) .
'">';
11147 $retstring .= $withoutdiv ?
'' :
'</div>';
11149 if ($dol_openinpopup) {
11150 $retstring .=
'<!-- buttons are shown into a $dol_openinpopup=' .
dol_escape_htmltag($dol_openinpopup) .
' context, so we enable the close of dialog on cancel -->' .
"\n";
11151 $retstring .=
'<script nonce="' .
getNonce() .
'">';
11152 $retstring .=
'jQuery(".button-cancel").click(function(e) {
11153 e.preventDefault(); console.log(\'We click on cancel in iframe popup ' .
dol_escape_js($dol_openinpopup) .
'\');
11154 window.parent.jQuery(\
'#idfordialog' .
dol_escape_js($dol_openinpopup) .
'\').dialog(\
'close\');
11156 $retstring .=
'</script>';
11175 $num = count($this->cache_invoice_subtype);
11182 $sql =
"SELECT rowid, code, label as label";
11183 $sql .=
" FROM " . MAIN_DB_PREFIX .
'c_invoice_subtype';
11184 $sql .=
" WHERE active = 1";
11186 $resql = $this->db->query($sql);
11188 $num = $this->db->num_rows($resql);
11190 while ($i < $num) {
11191 $obj = $this->db->fetch_object($resql);
11194 $label = ($langs->trans(
"InvoiceSubtype" . $obj->rowid) !=
"InvoiceSubtype" . $obj->rowid) ? $langs->trans(
"InvoiceSubtype" . $obj->rowid) : (($obj->label !=
'-') ? $obj->label :
'');
11195 $this->cache_invoice_subtype[$obj->rowid][
'rowid'] = $obj->rowid;
11196 $this->cache_invoice_subtype[$obj->rowid][
'code'] = $obj->code;
11197 $this->cache_invoice_subtype[$obj->rowid][
'label'] = $label;
11201 $this->cache_invoice_subtype =
dol_sort_array($this->cache_invoice_subtype,
'code',
'asc', 0, 0, 1);
11223 global $langs, $user;
11226 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
11230 $out .=
'<select id="' . $htmlname .
'" class="flat selectsubtype' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
11232 $out .=
'<option value="0"> </option>';
11235 foreach ($this->cache_invoice_subtype as $rowid => $subtype) {
11236 $label = $subtype[
'label'];
11237 $out .=
'<option value="' . $subtype[
'rowid'] .
'"';
11238 if ($selected == $subtype[
'rowid']) {
11239 $out .=
' selected="selected"';
11243 $out .=
'</option>';
11246 $out .=
'</select>';
11247 if ($user->admin && empty($noinfoadmin)) {
11248 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array(), $moreparams='')
Generic function that return javascript to add to transform a common input text or select field into ...
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 text field into ...
ajax_event($htmlname, $events)
Add event management script.
Class to manage bank accounts.
Class to manage categories.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
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.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
currency_name($code_iso, $withcode=0, $outputlangs=null)
Return label of currency or code+label.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dolForgeExplodeAnd($sqlfilters)
Explode an universal search string with AND parts.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='')
Format phone numbers according to country.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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_print_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='')
Show Url link.
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.
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_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_string_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.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox=0, $check='restricthtml')
Sanitize a HTML to remove js, dangerous content and external link.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify 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...
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
testSqlAndScriptInject($val, $type)
Security: WAF layer for SQL Injection and XSS Injection (scripts) protection (Filters on GET,...
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.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.