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_customer_price as pcp ON pcp.fk_soc=" . ((int) $socid) .
" AND pcp.fk_product=p.rowid";
3008 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_units u ON u.rowid = p.fk_unit";
3012 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_lang as pl ON pl.fk_product = p.rowid ";
3014 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
3015 $soc =
new Societe($this->db);
3016 $result = $soc->fetch($socid);
3017 if ($result > 0 && !empty($soc->default_lang)) {
3018 $sql .=
" AND pl.lang = '" . $this->db->escape($soc->default_lang) .
"'";
3020 $sql .=
" AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) .
"'";
3023 $sql .=
" AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) .
"'";
3028 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_attribute_combination pac ON pac.fk_product_child = p.rowid";
3031 $sql .=
' WHERE p.entity IN (' .
getEntity(
'product') .
')';
3034 $sql .=
" AND pac.rowid IS NULL";
3037 if ($finished == 0) {
3038 $sql .=
" AND p.finished = " . ((int) $finished);
3039 } elseif ($finished == 1) {
3040 $sql .=
" AND p.finished = ".((int) $finished);
3043 $sql .=
" AND p.tosell = ".((int) $status);
3045 if ($status_purchase >= 0) {
3046 $sql .=
" AND p.tobuy = " . ((int) $status_purchase);
3049 if (strval($filtertype) !=
'') {
3050 $sql .=
" AND p.fk_product_type = " . ((int) $filtertype);
3051 } elseif (!isModEnabled(
'product')) {
3052 $sql .=
" AND p.fk_product_type = 1";
3053 } elseif (!isModEnabled(
'service')) {
3054 $sql .=
" AND p.fk_product_type = 0";
3057 $parameters = array();
3058 $reshook = $hookmanager->executeHooks(
'selectProductsListWhere', $parameters);
3059 $sql .= $hookmanager->resPrint;
3061 if ($filterkey !=
'') {
3062 $sqlSupplierSearch=
'';
3067 $search_crit = explode(
' ', $filterkey);
3069 if (count($search_crit) > 1) {
3072 foreach ($search_crit as $crit) {
3076 $sql .=
"(p.ref LIKE '" . $this->db->escape($prefix . $crit) .
"%' OR p.label LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3078 $sql .=
" OR pl.label LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3081 $sql .=
" OR pcp.ref_customer LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3084 $sql .=
" OR p.description LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3086 $sql .=
" OR pl.description LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3092 $sqlSupplierSearch .= !empty($sqlSupplierSearch) ?
' OR ':
'';
3093 $sqlSupplierSearch .=
" 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) .
"%'";
3107 $sql .=
" OR EXISTS (SELECT pfp.fk_product FROM " . $this->db->prefix() .
"product_fournisseur_price as pfp WHERE p.rowid = pfp.fk_product";
3109 $sql .= $sqlSupplierSearch;
3115 if (count($warehouseStatusArray)) {
3116 $sql .=
" GROUP BY " . $selectFields;
3121 $sql .=
" ORDER BY categorie_product_id ";
3123 (
getDolGlobalInt(
'PRODUCT_SORT_BY_CATEGORY') == 1) ? $sql .=
"ASC" : $sql .=
"DESC";
3125 $sql .= $this->db->order(
"p.ref");
3128 $sql .= $this->db->plimit($limit, 0);
3131 dol_syslog(get_class($this) .
"::select_produits_list search products", LOG_DEBUG);
3132 $result = $this->db->query($sql);
3134 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
3135 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3136 require_once DOL_DOCUMENT_ROOT .
'/core/lib/product.lib.php';
3138 $num = $this->db->num_rows($result);
3143 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
3147 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
3153 if ($showempty && !is_numeric($showempty)) {
3154 $textifempty = $langs->trans($showempty);
3156 $textifempty .= $langs->trans(
"All");
3159 if ($showempty && !is_numeric($showempty)) {
3160 $textifempty = $langs->trans($showempty);
3164 $out .=
'<option value="-1" selected>' . ($textifempty ? $textifempty :
' ') .
'</option>';
3168 while ($num && $i < $num) {
3171 $objp = $this->db->fetch_object($result);
3173 if ((
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY') ||
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1) {
3174 $sql =
"SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type";
3175 $sql .=
" FROM " . $this->db->prefix() .
"product_price_by_qty";
3176 $sql .=
" WHERE fk_product_price = " . ((int) $objp->price_rowid);
3177 $sql .=
" ORDER BY quantity ASC";
3179 dol_syslog(get_class($this) .
"::select_produits_list search prices by qty", LOG_DEBUG);
3180 $result2 = $this->db->query($sql);
3182 $nb_prices = $this->db->num_rows($result2);
3184 while ($nb_prices && $j < $nb_prices) {
3185 $objp2 = $this->db->fetch_object($result2);
3187 $objp->price_by_qty_rowid = $objp2->rowid;
3188 $objp->price_by_qty_price_base_type = $objp2->price_base_type;
3189 $objp->price_by_qty_quantity = $objp2->quantity;
3190 $objp->price_by_qty_unitprice = $objp2->unitprice;
3191 $objp->price_by_qty_remise_percent = $objp2->remise_percent;
3193 $objp->quantity = $objp2->quantity;
3194 $objp->price = $objp2->price;
3195 $objp->unitprice = $objp2->unitprice;
3196 $objp->remise_percent = $objp2->remise_percent;
3209 array_push($outarray, $optJson);
3213 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_price_expression)) {
3214 $price_product =
new Product($this->db);
3215 $price_product->fetch($objp->rowid,
'',
'', 1);
3217 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3219 $price_result = $priceparser->parseProduct($price_product);
3220 if ($price_result >= 0) {
3221 $objp->price = $price_result;
3222 $objp->unitprice = $price_result;
3224 $objp->price_ttc = (float)
price2num($objp->price) * (1 + ($objp->tva_tx / 100));
3225 $objp->price_ttc =
price2num($objp->price_ttc,
'MU');
3234 array_push($outarray, $optJson);
3240 $out .=
'</select>';
3242 $this->db->free($result);
3244 if (empty($outputmode)) {
3271 protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey =
'', $novirtualstock = 0)
3273 global $langs, $conf, $user;
3274 global $hookmanager;
3280 $outlabel_translated =
'';
3282 $outdesc_translated =
'';
3288 $outpricebasetype =
'';
3290 $outdefault_vat_code =
'';
3294 $maxlengtharticle = (!
getDolGlobalString(
'PRODUCT_MAX_LENGTH_COMBO') ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
3296 $label = $objp->label;
3297 if (!empty($objp->label_translated)) {
3298 $label = $objp->label_translated;
3300 if (!empty($filterkey) && $filterkey !=
'') {
3301 $label = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $label, 1);
3304 $outkey = $objp->rowid;
3305 $outref = $objp->ref;
3306 $outrefcust = empty($objp->custref) ?
'' : $objp->custref;
3307 $outlabel = $objp->label;
3308 $outdesc = $objp->description;
3310 $outlabel_translated = $objp->label_translated;
3311 $outdesc_translated = $objp->description_translated;
3313 $outbarcode = $objp->barcode;
3314 $outorigin = $objp->fk_country;
3315 $outpbq = empty($objp->price_by_qty_rowid) ?
'' : $objp->price_by_qty_rowid;
3317 $outtype = $objp->fk_product_type;
3322 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
3328 if (!empty($objp->unit_short)) {
3329 $outvalUnits .=
' - ' . $objp->unit_short;
3333 if (!empty($objp->weight) && $objp->weight_units !==
null) {
3335 $outvalUnits .=
' - ' . $unitToShow;
3337 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !==
null) {
3338 $unitToShow = $objp->length .
' x ' . $objp->width .
' x ' . $objp->height .
' ' .
measuringUnitString(0,
'size', $objp->length_units);
3339 $outvalUnits .=
' - ' . $unitToShow;
3341 if (!empty($objp->surface) && $objp->surface_units !==
null) {
3343 $outvalUnits .=
' - ' . $unitToShow;
3345 if (!empty($objp->volume) && $objp->volume_units !==
null) {
3347 $outvalUnits .=
' - ' . $unitToShow;
3350 if ($outdurationvalue && $outdurationunit) {
3352 'h' => $langs->trans(
'Hour'),
3353 'd' => $langs->trans(
'Day'),
3354 'w' => $langs->trans(
'Week'),
3355 'm' => $langs->trans(
'Month'),
3356 'y' => $langs->trans(
'Year')
3358 if (isset($da[$outdurationunit])) {
3359 $outvalUnits .=
' - ' . $outdurationvalue .
' ' . $langs->transnoentities($da[$outdurationunit] . ($outdurationvalue > 1 ?
's' :
''));
3363 $opt =
'<option value="' . $objp->rowid .
'"';
3364 $opt .= ($objp->rowid == $selected) ?
' selected' :
'';
3365 if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) {
3366 $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 .
'"';
3369 if ($user->hasRight(
'stock',
'lire')) {
3370 if ($objp->stock > 0) {
3371 $opt .=
' class="product_line_stock_ok"';
3372 } elseif ($objp->stock <= 0) {
3373 $opt .=
' class="product_line_stock_too_low"';
3378 $opt .=
' data-labeltrans="' . $outlabel_translated .
'"';
3383 if (!empty($objp->custref)) {
3384 $opt .=
' (' . $objp->custref .
')';
3387 $opt .=
' (' . $outbarcode .
')';
3389 $opt .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3391 $opt .=
' (' .
getCountry($outorigin, 1) .
')';
3394 $objRef = $objp->ref;
3395 if (!empty($objp->custref)) {
3396 $objRef .=
' (' . $objp->custref .
')';
3398 if (!empty($filterkey) && $filterkey !=
'') {
3399 $objRef = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRef, 1);
3403 $outval .=
' (' . $outbarcode .
')';
3405 $outval .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3407 $outval .=
' (' .
getCountry($outorigin, 1) .
')';
3411 $opt .= $outvalUnits;
3412 $outval .= $outvalUnits;
3419 $sql =
"SELECT price, price_ttc, price_base_type, tva_tx, default_vat_code";
3420 $sql .=
" FROM " . $this->db->prefix() .
"product_price";
3421 $sql .=
" WHERE fk_product = " . ((int) $objp->rowid);
3422 $sql .=
" AND entity IN (" .
getEntity(
'productprice') .
")";
3423 $sql .=
" AND price_level = " . ((int) $price_level);
3424 $sql .=
" ORDER BY date_price DESC, rowid DESC";
3427 dol_syslog(get_class($this) .
'::constructProductListOption search price for product ' . $objp->rowid .
' AND level ' . $price_level, LOG_DEBUG);
3428 $result2 = $this->db->query($sql);
3430 $objp2 = $this->db->fetch_object($result2);
3433 if ($objp2->price_base_type ==
'HT') {
3434 $opt .=
' - ' .
price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"HT");
3435 $outval .=
' - ' .
price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"HT");
3437 $opt .=
' - ' .
price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"TTC");
3438 $outval .=
' - ' .
price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"TTC");
3440 $outprice_ht =
price($objp2->price);
3441 $outprice_ttc =
price($objp2->price_ttc);
3442 $outpricebasetype = $objp2->price_base_type;
3444 $outtva_tx = $objp2->tva_tx;
3445 $outdefault_vat_code = $objp2->default_vat_code;
3447 $outtva_tx = $objp->tva_tx;
3448 $outdefault_vat_code = $objp->default_vat_code;
3457 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1 && (
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY') ||
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'))) {
3459 $outqty = $objp->quantity;
3460 $outdiscount = $objp->remise_percent;
3461 if ($objp->quantity == 1) {
3462 $opt .=
' - ' .
price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) .
"/";
3463 $outval .=
' - ' .
price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) .
"/";
3464 $opt .= $langs->trans(
"Unit");
3465 $outval .= $langs->transnoentities(
"Unit");
3467 $opt .=
' - ' .
price($objp->price, 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3468 $outval .=
' - ' .
price($objp->price, 0, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3469 $opt .= $langs->trans(
"Units");
3470 $outval .= $langs->transnoentities(
"Units");
3473 $outprice_ht =
price($objp->unitprice);
3474 $outprice_ttc =
price($objp->unitprice * (1 + ($objp->tva_tx / 100)));
3475 $outpricebasetype = $objp->price_base_type;
3476 $outtva_tx = $objp->tva_tx;
3477 $outdefault_vat_code = $objp->default_vat_code;
3479 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1) {
3480 $opt .=
" (" .
price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $langs->trans(
"Unit") .
")";
3481 $outval .=
" (" .
price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) .
"/" . $langs->transnoentities(
"Unit") .
")";
3483 if (empty($hidepriceinlabel) && !empty($objp->remise_percent) && $objp->remise_percent >= 1) {
3484 $opt .=
" - " . $langs->trans(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3485 $outval .=
" - " . $langs->transnoentities(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3490 if (!empty($objp->idprodcustprice)) {
3493 if ($objp->custprice_base_type ==
'HT') {
3494 $opt .=
' - ' .
price($objp->custprice, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"HT");
3495 $outval .=
' - ' .
price($objp->custprice, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"HT");
3497 $opt .=
' - ' .
price($objp->custprice_ttc, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"TTC");
3498 $outval .=
' - ' .
price($objp->custprice_ttc, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"TTC");
3501 $outprice_ht =
price($objp->custprice);
3502 $outprice_ttc =
price($objp->custprice_ttc);
3503 $outpricebasetype = $objp->custprice_base_type;
3504 $outtva_tx = $objp->custtva_tx;
3505 $outdefault_vat_code = $objp->custdefault_vat_code;
3510 if (empty($hidepriceinlabel) && !$found) {
3511 if ($objp->price_base_type ==
'HT') {
3512 $opt .=
' - ' .
price($objp->price, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"HT");
3513 $outval .=
' - ' .
price($objp->price, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"HT");
3515 $opt .=
' - ' .
price($objp->price_ttc, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"TTC");
3516 $outval .=
' - ' .
price($objp->price_ttc, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"TTC");
3518 $outprice_ht =
price($objp->price);
3519 $outprice_ttc =
price($objp->price_ttc);
3520 $outpricebasetype = $objp->price_base_type;
3521 $outtva_tx = $objp->tva_tx;
3522 $outdefault_vat_code = $objp->default_vat_code;
3526 if ($user->hasRight(
'stock',
'lire')) {
3527 $opt .=
' - ' . $langs->trans(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'), 0, $langs, 0, 0);
3529 if ($objp->stock > 0) {
3530 $outval .=
' - <span class="product_line_stock_ok">';
3531 } elseif ($objp->stock <= 0) {
3532 $outval .=
' - <span class="product_line_stock_too_low">';
3534 $outval .= $langs->transnoentities(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'));
3535 $outval .=
'</span>';
3536 if (empty($novirtualstock) &&
getDolGlobalString(
'STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO')) {
3537 $langs->load(
"stocks");
3539 $tmpproduct =
new Product($this->db);
3540 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3541 $tmpproduct->load_virtual_stock();
3542 $virtualstock = $tmpproduct->stock_theorique;
3544 $opt .=
' - ' . $langs->trans(
"VirtualStock") .
':' . $virtualstock;
3546 $outval .=
' - ' . $langs->transnoentities(
"VirtualStock") .
':';
3547 if ($virtualstock > 0) {
3548 $outval .=
'<span class="product_line_stock_ok">';
3549 } elseif ($virtualstock <= 0) {
3550 $outval .=
'<span class="product_line_stock_too_low">';
3552 $outval .= $virtualstock;
3553 $outval .=
'</span>';
3560 $parameters = array(
'objp' => $objp);
3561 $reshook = $hookmanager->executeHooks(
'constructProductListOption', $parameters);
3562 if (empty($reshook)) {
3563 $opt .= $hookmanager->resPrint;
3565 $opt = $hookmanager->resPrint;
3568 $opt .=
"</option>\n";
3573 'label2' => $outlabel,
3577 'price_ttc' =>
price2num($outprice_ttc),
3580 'pricebasetype' => $outpricebasetype,
3581 'tva_tx' => $outtva_tx,
3582 'default_vat_code' => $outdefault_vat_code,
3584 'discount' => $outdiscount,
3585 'duration_value' => $outdurationvalue,
3586 'duration_unit' => $outdurationunit,
3588 'labeltrans' => $outlabel_translated,
3589 'desctrans' => $outdesc_translated,
3590 'ref_customer' => $outrefcust
3611 public function select_produits_fournisseurs($socid, $selected =
'', $htmlname =
'productid', $filtertype =
'', $filtre =
'', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss =
'', $placeholder =
'')
3614 global $langs, $conf;
3615 global $price_level, $status, $finished;
3617 if (!isset($status)) {
3621 $selected_input_value =
'';
3622 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'PRODUIT_USE_SEARCH_TO_SELECT')) {
3623 if ($selected > 0) {
3624 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
3625 $producttmpselect =
new Product($this->db);
3626 $producttmpselect->fetch($selected);
3627 $selected_input_value = $producttmpselect->ref;
3628 unset($producttmpselect);
3632 $urloption = ($socid > 0 ?
'socid=' . $socid .
'&' :
'') .
'htmlname=' . $htmlname .
'&outjson=1&price_level=' . $price_level .
'&type=' . $filtertype .
'&mode=2&status=' . $status .
'&finished=' . $finished .
'&alsoproductwithnosupplierprice=' . $alsoproductwithnosupplierprice;
3635 print($hidelabel ?
'' : $langs->trans(
"RefOrLabel") .
' : ') .
'<input type="text" class="'.$morecss.
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . ($placeholder ?
' placeholder="' . $placeholder .
'"' :
'') .
'>';
3637 print $this->
select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre,
'', $status, 0, 0, $alsoproductwithnosupplierprice, $morecss, 0, $placeholder);
3661 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 =
'')
3664 global $langs, $conf, $user;
3665 global $hookmanager;
3668 $outarray = array();
3670 $maxlengtharticle = (!
getDolGlobalString(
'PRODUCT_MAX_LENGTH_COMBO') ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
3672 $langs->load(
'stocks');
3675 $langs->load(
'other');
3678 $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,";
3679 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice, pfp.barcode";
3680 $sql .=
", pfp.multicurrency_code, pfp.multicurrency_unitprice";
3681 $sql .=
", pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.default_vat_code, pfp.fk_soc, s.nom as name";
3682 $sql .=
", pfp.supplier_reputation";
3685 $sql .=
", pfp.desc_fourn as description";
3687 $sql .=
", p.description";
3691 $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";
3693 $sql .=
" FROM " . $this->db->prefix() .
"product as p";
3694 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (" .
getEntity(
'product') .
") )";
3696 $sql .=
" AND pfp.fk_soc = " . ((int) $socid);
3698 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON pfp.fk_soc = s.rowid";
3701 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_units u ON u.rowid = p.fk_unit";
3703 $sql .=
" WHERE p.entity IN (" .
getEntity(
'product') .
")";
3704 if ($statut != -1) {
3705 $sql .=
" AND p.tobuy = " . ((int) $statut);
3707 if (strval($filtertype) !=
'') {
3708 $sql .=
" AND p.fk_product_type = " . ((int) $filtertype);
3710 if (!empty($filtre)) {
3711 $sql .=
" " . $filtre;
3714 $parameters = array();
3715 $reshook = $hookmanager->executeHooks(
'selectSuppliersProductsListWhere', $parameters);
3716 $sql .= $hookmanager->resPrint;
3718 if ($filterkey !=
'') {
3722 $search_crit = explode(
' ', $filterkey);
3724 if (count($search_crit) > 1) {
3727 foreach ($search_crit as $crit) {
3731 $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) .
"%'";
3733 $sql .=
" OR pfp.desc_fourn LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3738 if (count($search_crit) > 1) {
3741 if (isModEnabled(
'barcode')) {
3742 $sql .=
" OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
3743 $sql .=
" OR pfp.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
3747 $sql .=
" ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
3748 $sql .= $this->db->plimit($limit, 0);
3752 dol_syslog(get_class($this) .
"::select_produits_fournisseurs_list", LOG_DEBUG);
3753 $result = $this->db->query($sql);
3755 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3756 require_once DOL_DOCUMENT_ROOT .
'/core/lib/product.lib.php';
3758 $num = $this->db->num_rows($result);
3761 $out .=
'<select class="flat ' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'">';
3763 $out .=
'<option value="-1" selected>' . ($placeholder ? $placeholder :
' ') .
'</option>';
3765 $out .=
'<option value="-1">' . ($placeholder ? $placeholder :
' ') .
'</option>';
3770 $objp = $this->db->fetch_object($result);
3772 if (is_null($objp->idprodfournprice)) {
3774 $objp->tva_tx = $objp->tva_tx_sale;
3775 $objp->default_vat_code = $objp->default_vat_code_sale;
3778 $outkey = $objp->idprodfournprice;
3779 if (!$outkey && $alsoproductwithnosupplierprice) {
3780 $outkey =
'idprod_' . $objp->rowid;
3783 $outref = $objp->ref;
3784 $outbarcode = $objp->barcode;
3787 $outtype = $objp->fk_product_type;
3794 if (!empty($objp->unit_short)) {
3795 $outvalUnits .=
' - ' . $objp->unit_short;
3797 if (!empty($objp->weight) && $objp->weight_units !==
null) {
3799 $outvalUnits .=
' - ' . $unitToShow;
3801 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !==
null) {
3802 $unitToShow = $objp->length .
' x ' . $objp->width .
' x ' . $objp->height .
' ' .
measuringUnitString(0,
'size', $objp->length_units);
3803 $outvalUnits .=
' - ' . $unitToShow;
3805 if (!empty($objp->surface) && $objp->surface_units !==
null) {
3807 $outvalUnits .=
' - ' . $unitToShow;
3809 if (!empty($objp->volume) && $objp->volume_units !==
null) {
3811 $outvalUnits .=
' - ' . $unitToShow;
3813 if ($outdurationvalue && $outdurationunit) {
3815 'h' => $langs->trans(
'Hour'),
3816 'd' => $langs->trans(
'Day'),
3817 'w' => $langs->trans(
'Week'),
3818 'm' => $langs->trans(
'Month'),
3819 'y' => $langs->trans(
'Year')
3821 if (isset($da[$outdurationunit])) {
3822 $outvalUnits .=
' - ' . $outdurationvalue .
' ' . $langs->transnoentities($da[$outdurationunit] . ($outdurationvalue > 1 ?
's' :
''));
3827 $objRef = $objp->ref;
3828 if ($filterkey && $filterkey !=
'') {
3829 $objRef = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRef, 1);
3831 $objRefFourn = $objp->ref_fourn;
3832 if ($filterkey && $filterkey !=
'') {
3833 $objRefFourn = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRefFourn, 1);
3835 $label = $objp->label;
3836 if ($filterkey && $filterkey !=
'') {
3837 $label = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $label, 1);
3840 switch ($objp->fk_product_type) {
3852 if (empty($picto)) {
3855 $optlabel =
img_object(
'', $picto,
'class="paddingright classfortooltip"', 0, 0, 1);
3858 $optlabel .= $objp->ref;
3859 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
3860 $optlabel .=
' <span class="opacitymedium">(' . $objp->ref_fourn .
')</span>';
3862 if (isModEnabled(
'barcode') && !empty($objp->barcode)) {
3863 $optlabel .=
' (' . $outbarcode .
')';
3865 $optlabel .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3867 $outvallabel = $objRef;
3868 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
3869 $outvallabel .=
' (' . $objRefFourn .
')';
3871 if (isModEnabled(
'barcode') && !empty($objp->barcode)) {
3872 $outvallabel .=
' (' . $outbarcode .
')';
3874 $outvallabel .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3877 $optlabel .= $outvalUnits;
3878 $outvallabel .= $outvalUnits;
3880 if (!empty($objp->idprodfournprice)) {
3881 $outqty = $objp->quantity;
3882 $outdiscount = $objp->remise_percent;
3883 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_supplier_price_expression)) {
3885 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
3886 $prod_supplier->id = $objp->fk_product;
3887 $prod_supplier->fourn_qty = $objp->quantity;
3888 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
3889 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
3891 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3893 $price_result = $priceparser->parseProductSupplier($prod_supplier);
3894 if ($price_result >= 0) {
3895 $objp->fprice = $price_result;
3896 if ($objp->quantity >= 1) {
3897 $objp->unitprice = $objp->fprice / $objp->quantity;
3901 if ($objp->quantity == 1) {
3902 $optlabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/";
3903 $outvallabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency) .
"/";
3904 $optlabel .= $langs->trans(
"Unit");
3905 $outvallabel .= $langs->transnoentities(
"Unit");
3907 $optlabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3908 $outvallabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3909 $optlabel .=
' ' . $langs->trans(
"Units");
3910 $outvallabel .=
' ' . $langs->transnoentities(
"Units");
3913 if ($objp->quantity > 1) {
3914 $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") .
")";
3915 $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") .
")";
3917 if ($objp->remise_percent >= 1) {
3918 $optlabel .=
" - " . $langs->trans(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3919 $outvallabel .=
" - " . $langs->transnoentities(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3921 if ($objp->duration) {
3922 $optlabel .=
" - " . $objp->duration;
3923 $outvallabel .=
" - " . $objp->duration;
3926 $optlabel .=
" - " .
dol_trunc($objp->name, 8);
3927 $outvallabel .=
" - " .
dol_trunc($objp->name, 8);
3929 if ($objp->supplier_reputation) {
3931 $reputations = array(
'' => $langs->trans(
'Standard'),
'FAVORITE' => $langs->trans(
'Favorite'),
'NOTTHGOOD' => $langs->trans(
'NotTheGoodQualitySupplier'),
'DONOTORDER' => $langs->trans(
'DoNotOrderThisProductToThisSupplier'));
3933 $optlabel .=
" - " . $reputations[$objp->supplier_reputation];
3934 $outvallabel .=
" - " . $reputations[$objp->supplier_reputation];
3937 $optlabel .=
" - <span class='opacitymedium'>" . $langs->trans(
"NoPriceDefinedForThisSupplier") .
'</span>';
3938 $outvallabel .=
' - ' . $langs->transnoentities(
"NoPriceDefinedForThisSupplier");
3942 $novirtualstock = ($showstockinlist == 2);
3944 if ($user->hasRight(
'stock',
'lire')) {
3945 $outvallabel .=
' - ' . $langs->trans(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'));
3947 if ($objp->stock > 0) {
3948 $optlabel .=
' - <span class="product_line_stock_ok">';
3949 } elseif ($objp->stock <= 0) {
3950 $optlabel .=
' - <span class="product_line_stock_too_low">';
3952 $optlabel .= $langs->transnoentities(
"Stock") .
':' .
price(
price2num($objp->stock,
'MS'));
3953 $optlabel .=
'</span>';
3954 if (empty($novirtualstock) &&
getDolGlobalString(
'STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO')) {
3955 $langs->load(
"stocks");
3957 $tmpproduct =
new Product($this->db);
3958 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3959 $tmpproduct->load_virtual_stock();
3960 $virtualstock = $tmpproduct->stock_theorique;
3962 $outvallabel .=
' - ' . $langs->trans(
"VirtualStock") .
':' . $virtualstock;
3964 $optlabel .=
' - ' . $langs->transnoentities(
"VirtualStock") .
':';
3965 if ($virtualstock > 0) {
3966 $optlabel .=
'<span class="product_line_stock_ok">';
3967 } elseif ($virtualstock <= 0) {
3968 $optlabel .=
'<span class="product_line_stock_too_low">';
3970 $optlabel .= $virtualstock;
3971 $optlabel .=
'</span>';
3978 $optstart =
'<option value="' . $outkey .
'"';
3979 if ($selected && $selected == $objp->idprodfournprice) {
3980 $optstart .=
' selected';
3982 if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) {
3983 $optstart .=
' disabled';
3986 if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
3995 $optstart .=
' data-default-vat-code="' .
dol_escape_htmltag($objp->default_vat_code) .
'"';
3997 if (isModEnabled(
'multicurrency')) {
3998 $optstart .=
' data-multicurrency-code="' .
dol_escape_htmltag($objp->multicurrency_code) .
'"';
4002 $optstart .=
' data-description="' .
dol_escape_htmltag($objp->description, 0, 1) .
'"';
4004 $outarrayentry = array(
4007 'label' => $outvallabel,
4009 'price_qty_ht' =>
price2num($objp->fprice,
'MU'),
4010 'price_unit_ht' =>
price2num($objp->unitprice,
'MU'),
4011 'price_ht' =>
price2num($objp->unitprice,
'MU'),
4012 'tva_tx_formated' =>
price($objp->tva_tx, 0, $langs, 1, -1, 2),
4014 'default_vat_code' => $objp->default_vat_code,
4015 'supplier_ref' => $objp->ref_fourn,
4016 'discount' => $outdiscount,
4018 'duration_value' => $outdurationvalue,
4019 'duration_unit' => $outdurationunit,
4020 'disabled' => empty($objp->idprodfournprice),
4021 'description' => $objp->description
4023 if (isModEnabled(
'multicurrency')) {
4024 $outarrayentry[
'multicurrency_code'] = $objp->multicurrency_code;
4025 $outarrayentry[
'multicurrency_unitprice'] =
price2num($objp->multicurrency_unitprice,
'MU');
4028 $parameters = array(
4030 'optstart' => &$optstart,
4031 'optlabel' => &$optlabel,
4032 'outvallabel' => &$outvallabel,
4033 'outarrayentry' => &$outarrayentry
4035 $reshook = $hookmanager->executeHooks(
'selectProduitsFournisseurListOption', $parameters, $this);
4041 $out .= $optstart .
' data-html="' .
dol_escape_htmltag($optlabel) .
'">' . $optlabel .
"</option>\n";
4042 $outarraypush = array(
4045 'label' => $outvallabel,
4047 'price_qty_ht' =>
price2num($objp->fprice,
'MU'),
4048 'price_qty_ht_locale' =>
price($objp->fprice),
4049 'price_unit_ht' =>
price2num($objp->unitprice,
'MU'),
4050 'price_unit_ht_locale' =>
price($objp->unitprice),
4051 'price_ht' =>
price2num($objp->unitprice,
'MU'),
4052 'tva_tx_formated' =>
price($objp->tva_tx),
4054 'default_vat_code' => $objp->default_vat_code,
4055 'supplier_ref' => $objp->ref_fourn,
4056 'discount' => $outdiscount,
4058 'duration_value' => $outdurationvalue,
4059 'duration_unit' => $outdurationunit,
4060 'disabled' => (empty($objp->idprodfournprice) ?
true :
false),
4061 'description' => $objp->description
4063 if (isModEnabled(
'multicurrency')) {
4064 $outarraypush[
'multicurrency_code'] = $objp->multicurrency_code;
4065 $outarraypush[
'multicurrency_unitprice'] =
price2num($objp->multicurrency_unitprice,
'MU');
4067 array_push($outarray, $outarraypush);
4080 $out .=
'</select>';
4082 $this->db->free($result);
4084 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
4090 if (empty($outputmode)) {
4109 global $langs, $conf;
4111 $langs->load(
'stocks');
4113 $sql =
"SELECT p.rowid, p.ref, p.label, p.price, p.duration, pfp.fk_soc,";
4114 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,";
4115 $sql .=
" pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name";
4116 $sql .=
" FROM " . $this->db->prefix() .
"product as p";
4117 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
4118 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON pfp.fk_soc = s.rowid";
4119 $sql .=
" WHERE pfp.entity IN (" .
getEntity(
'productsupplierprice') .
")";
4120 $sql .=
" AND p.tobuy = 1";
4121 $sql .=
" AND s.fournisseur = 1";
4122 $sql .=
" AND p.rowid = " . ((int) $productid);
4124 $sql .=
" ORDER BY s.nom, pfp.ref_fourn DESC";
4126 $sql .=
" ORDER BY pfp.unitprice ASC";
4129 dol_syslog(get_class($this) .
"::select_product_fourn_price", LOG_DEBUG);
4130 $result = $this->db->query($sql);
4133 $num = $this->db->num_rows($result);
4135 $form =
'<select class="flat" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
4138 $form .=
'<option value="0">-- ' . $langs->trans(
"NoSupplierPriceDefinedForThisProduct") .
' --</option>';
4140 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
4141 $form .=
'<option value="0"> </option>';
4145 $objp = $this->db->fetch_object($result);
4147 $opt =
'<option value="' . $objp->idprodfournprice .
'"';
4149 if ($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier) || ($i == 0 &&
getDolGlobalString(
'PRODUCT_BEST_SUPPLIER_PRICE_PRESELECTED'))) {
4150 $opt .=
' selected';
4152 $opt .=
'>' . $objp->name .
' - ' . $objp->ref_fourn .
' - ';
4154 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_supplier_price_expression)) {
4156 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
4157 $prod_supplier->id = $productid;
4158 $prod_supplier->fourn_qty = $objp->quantity;
4159 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
4160 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
4162 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
4164 $price_result = $priceparser->parseProductSupplier($prod_supplier);
4165 if ($price_result >= 0) {
4166 $objp->fprice = $price_result;
4167 if ($objp->quantity >= 1) {
4168 $objp->unitprice = $objp->fprice / $objp->quantity;
4172 if ($objp->quantity == 1) {
4173 $opt .=
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/";
4176 $opt .= $objp->quantity .
' ';
4178 if ($objp->quantity == 1) {
4179 $opt .= $langs->trans(
"Unit");
4181 $opt .= $langs->trans(
"Units");
4183 if ($objp->quantity > 1) {
4185 $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");
4187 if ($objp->duration) {
4188 $opt .=
" - " . $objp->duration;
4190 $opt .=
"</option>\n";
4197 $form .=
'</select>';
4198 $this->db->free($result);
4218 $num = count($this->cache_conditions_paiements);
4225 $sql =
"SELECT rowid, code, libelle as label, deposit_percent";
4226 $sql .=
" FROM " . $this->db->prefix() .
'c_payment_term';
4227 $sql .=
" WHERE entity IN (" .
getEntity(
'c_payment_term') .
")";
4228 $sql .=
" AND active > 0";
4229 $sql .=
" ORDER BY sortorder";
4231 $resql = $this->db->query($sql);
4233 $num = $this->db->num_rows($resql);
4236 $obj = $this->db->fetch_object($resql);
4239 $label = ($langs->trans(
"PaymentConditionShort" . $obj->code) !=
"PaymentConditionShort" . $obj->code ? $langs->trans(
"PaymentConditionShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4240 $this->cache_conditions_paiements[$obj->rowid][
'code'] = $obj->code;
4241 $this->cache_conditions_paiements[$obj->rowid][
'label'] = $label;
4242 $this->cache_conditions_paiements[$obj->rowid][
'deposit_percent'] = $obj->deposit_percent;
4267 $num = count($this->cache_availability);
4274 $langs->load(
'propal');
4276 $sql =
"SELECT rowid, code, label, position";
4277 $sql .=
" FROM " . $this->db->prefix() .
'c_availability';
4278 $sql .=
" WHERE active > 0";
4280 $resql = $this->db->query($sql);
4282 $num = $this->db->num_rows($resql);
4285 $obj = $this->db->fetch_object($resql);
4288 $label = ($langs->trans(
"AvailabilityType" . $obj->code) !=
"AvailabilityType" . $obj->code ? $langs->trans(
"AvailabilityType" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4289 $this->cache_availability[$obj->rowid][
'code'] = $obj->code;
4290 $this->cache_availability[$obj->rowid][
'label'] = $label;
4291 $this->cache_availability[$obj->rowid][
'position'] = $obj->position;
4295 $this->cache_availability =
dol_sort_array($this->cache_availability,
'position',
'asc', 0, 0, 1);
4316 global $langs, $user;
4320 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
4322 print
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4324 print
'<option value="0"> </option>';
4326 foreach ($this->cache_availability as $id => $arrayavailability) {
4327 if ($selected == $id) {
4328 print
'<option value="' . $id .
'" selected>';
4330 print
'<option value="' . $id .
'">';
4337 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4351 $num = count($this->cache_demand_reason);
4356 $sql =
"SELECT rowid, code, label";
4357 $sql .=
" FROM " . $this->db->prefix() .
'c_input_reason';
4358 $sql .=
" WHERE active > 0";
4360 $resql = $this->db->query($sql);
4362 $num = $this->db->num_rows($resql);
4364 $tmparray = array();
4366 $obj = $this->db->fetch_object($resql);
4369 $label = ($obj->label !=
'-' ? $obj->label :
'');
4370 if ($langs->trans(
"DemandReasonType" . $obj->code) !=
"DemandReasonType" . $obj->code) {
4371 $label = $langs->trans(
"DemandReasonType" . $obj->code);
4373 if ($langs->trans($obj->code) != $obj->code) {
4374 $label = $langs->trans($obj->code);
4377 $tmparray[$obj->rowid][
'id'] = $obj->rowid;
4378 $tmparray[$obj->rowid][
'code'] = $obj->code;
4379 $tmparray[$obj->rowid][
'label'] = $label;
4383 $this->cache_demand_reason =
dol_sort_array($tmparray,
'label',
'asc', 0, 0, 1);
4405 public function selectInputReason($selected =
'', $htmlname =
'demandreasonid', $exclude =
'', $addempty = 0, $morecss =
'', $notooltip = 0)
4407 global $langs, $user;
4411 print
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
4413 print
'<option value="0"' . (empty($selected) ?
' selected' :
'') .
'> </option>';
4415 foreach ($this->cache_demand_reason as $id => $arraydemandreason) {
4416 if ($arraydemandreason[
'code'] == $exclude) {
4420 if ($selected && ($selected == $arraydemandreason[
'id'] || $selected == $arraydemandreason[
'code'])) {
4421 print
'<option value="' . $arraydemandreason[
'id'] .
'" selected>';
4423 print
'<option value="' . $arraydemandreason[
'id'] .
'">';
4425 $label = $arraydemandreason[
'label'];
4426 print $langs->trans($label);
4430 if ($user->admin && empty($notooltip)) {
4431 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4448 $num = count($this->cache_types_paiements);
4455 $this->cache_types_paiements = array();
4457 $sql =
"SELECT id, code, libelle as label, type, active";
4458 $sql .=
" FROM " . $this->db->prefix() .
"c_paiement";
4459 $sql .=
" WHERE entity IN (" .
getEntity(
'c_paiement') .
")";
4461 $resql = $this->db->query($sql);
4463 $num = $this->db->num_rows($resql);
4466 $obj = $this->db->fetch_object($resql);
4469 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) !=
"PaymentTypeShort" . $obj->code ? $langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4470 $this->cache_types_paiements[$obj->id][
'id'] = $obj->id;
4471 $this->cache_types_paiements[$obj->id][
'code'] = $obj->code;
4472 $this->cache_types_paiements[$obj->id][
'label'] = $label;
4473 $this->cache_types_paiements[$obj->id][
'type'] = $obj->type;
4474 $this->cache_types_paiements[$obj->id][
'active'] = $obj->active;
4478 $this->cache_types_paiements =
dol_sort_array($this->cache_types_paiements,
'label',
'asc', 0, 0, 1);
4508 public function select_conditions_paiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1, $noprint = 0)
4512 if (empty($noprint)) {
4536 public function getSelectConditionsPaiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1)
4538 global $langs, $user, $conf;
4541 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
4547 dol_syslog(__METHOD__ .
"Using deprecated option MAIN_DEFAULT_PAYMENT_TERM_ID", LOG_NOTICE);
4551 $out .=
'<select id="' . $htmlname .
'" class="flat selectpaymentterms' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4553 $out .=
'<option value="0"> </option>';
4556 $selectedDepositPercent =
null;
4558 foreach ($this->cache_conditions_paiements as $id => $arrayconditions) {
4559 if ($filtertype <= 0 && !empty($arrayconditions[
'deposit_percent'])) {
4563 if ($selected == $id) {
4564 $selectedDepositPercent = $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'];
4565 $out .=
'<option value="' . $id .
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'" selected>';
4567 $out .=
'<option value="' . $id .
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'">';
4569 $label = $arrayconditions[
'label'];
4571 if (!empty($arrayconditions[
'deposit_percent'])) {
4572 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'], $label);
4576 $out .=
'</option>';
4578 $out .=
'</select>';
4579 if ($user->admin && empty($noinfoadmin)) {
4580 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4584 if ($deposit_percent >= 0) {
4585 $out .=
' <span id="' . $htmlname .
'_deposit_percent_container"' . (empty($selectedDepositPercent) ?
' style="display: none"' :
'') .
'>';
4586 $out .= $langs->trans(
'DepositPercent') .
' : ';
4587 $out .=
'<input id="' . $htmlname .
'_deposit_percent" name="' . $htmlname .
'_deposit_percent" class="maxwidth50" value="' . $deposit_percent .
'" />';
4590 <script nonce="' .
getNonce() .
'">
4591 $(document).ready(function () {
4592 $("#' . $htmlname .
'").change(function () {
4593 let $selected = $(this).find("option:selected");
4594 let depositPercent = $selected.attr("data-deposit_percent");
4596 if (depositPercent.length > 0) {
4597 $("#' . $htmlname .
'_deposit_percent_container").show().find("#' . $htmlname .
'_deposit_percent").val(depositPercent);
4599 $("#' . $htmlname .
'_deposit_percent_container").hide().find("#' . $htmlname .
'_deposit_percent").val(0);
4630 public function select_types_paiements($selected =
'', $htmlname =
'paiementtype', $filtertype =
'', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'', $nooutput = 0)
4633 global $langs, $user, $conf;
4637 dol_syslog(__METHOD__ .
" " . $selected .
", " . $htmlname .
", " . $filtertype .
", " . $format, LOG_DEBUG);
4639 $filterarray = array();
4640 if ($filtertype ==
'CRDT') {
4641 $filterarray = array(0, 2, 3);
4642 } elseif ($filtertype ==
'DBIT') {
4643 $filterarray = array(1, 2, 3);
4644 } elseif ($filtertype !=
'' && $filtertype !=
'-1') {
4645 $filterarray = explode(
',', $filtertype);
4652 dol_syslog(__METHOD__ .
"Using deprecated option MAIN_DEFAULT_PAYMENT_TYPE_ID", LOG_NOTICE);
4656 $out .=
'<select id="select' . $htmlname .
'" class="flat selectpaymenttypes' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4658 $out .=
'<option value=""> </option>';
4660 foreach ($this->cache_types_paiements as $id => $arraytypes) {
4662 if ($active >= 0 && $arraytypes[
'active'] != $active) {
4667 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
4672 if ($empty && empty($arraytypes[
'code'])) {
4677 $out .=
'<option value="' . $id .
'"';
4678 } elseif ($format == 1) {
4679 $out .=
'<option value="' . $arraytypes[
'code'] .
'"';
4680 } elseif ($format == 2) {
4681 $out .=
'<option value="' . $arraytypes[
'code'] .
'"';
4682 } elseif ($format == 3) {
4683 $out .=
'<option value="' . $id .
'"';
4686 if ($format == 1 || $format == 2) {
4687 if ($selected == $arraytypes[
'code']) {
4688 $out .=
' selected';
4691 if ($selected == $id) {
4692 $out .=
' selected';
4698 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4699 } elseif ($format == 1) {
4700 $value = $arraytypes[
'code'];
4701 } elseif ($format == 2) {
4702 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4703 } elseif ($format == 3) {
4704 $value = $arraytypes[
'code'];
4706 $out .= $value ? $value :
' ';
4707 $out .=
'</option>';
4709 $out .=
'</select>';
4710 if ($user->admin && !$noadmininfo) {
4711 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4715 if (empty($nooutput)) {
4735 $return =
'<select class="flat maxwidth100" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
4737 'HT' => $langs->trans(
"HT"),
4738 'TTC' => $langs->trans(
"TTC")
4740 foreach ($options as $id => $value) {
4741 if ($selected == $id) {
4742 $return .=
'<option value="' . $id .
'" selected>' . $value;
4744 $return .=
'<option value="' . $id .
'">' . $value;
4746 $return .=
'</option>';
4748 $return .=
'</select>';
4768 $num = count($this->cache_transport_mode);
4775 $this->cache_transport_mode = array();
4777 $sql =
"SELECT rowid, code, label, active";
4778 $sql .=
" FROM " . $this->db->prefix() .
"c_transport_mode";
4779 $sql .=
" WHERE entity IN (" .
getEntity(
'c_transport_mode') .
")";
4781 $resql = $this->db->query($sql);
4783 $num = $this->db->num_rows($resql);
4786 $obj = $this->db->fetch_object($resql);
4789 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) !=
"PaymentTypeShort" . $obj->code ? $langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4790 $this->cache_transport_mode[$obj->rowid][
'rowid'] = $obj->rowid;
4791 $this->cache_transport_mode[$obj->rowid][
'code'] = $obj->code;
4792 $this->cache_transport_mode[$obj->rowid][
'label'] = $label;
4793 $this->cache_transport_mode[$obj->rowid][
'active'] = $obj->active;
4797 $this->cache_transport_mode =
dol_sort_array($this->cache_transport_mode,
'label',
'asc', 0, 0, 1);
4819 public function selectTransportMode($selected =
'', $htmlname =
'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'')
4821 global $langs, $user;
4823 dol_syslog(__METHOD__ .
" " . $selected .
", " . $htmlname .
", " . $format, LOG_DEBUG);
4827 print
'<select id="select' . $htmlname .
'" class="flat selectmodetransport' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4829 print
'<option value=""> </option>';
4831 foreach ($this->cache_transport_mode as $id => $arraytypes) {
4833 if ($active >= 0 && $arraytypes[
'active'] != $active) {
4838 if ($empty && empty($arraytypes[
'code'])) {
4843 print
'<option value="' . $id .
'"';
4844 } elseif ($format == 1) {
4845 print
'<option value="' . $arraytypes[
'code'] .
'"';
4846 } elseif ($format == 2) {
4847 print
'<option value="' . $arraytypes[
'code'] .
'"';
4848 } elseif ($format == 3) {
4849 print
'<option value="' . $id .
'"';
4852 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraytypes[
'code']) {
4854 } elseif ($selected == $id) {
4860 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4861 } elseif ($format == 1) {
4862 $value = $arraytypes[
'code'];
4863 } elseif ($format == 2) {
4864 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4865 } elseif ($format == 3) {
4866 $value = $arraytypes[
'code'];
4868 print $value ? $value :
' ';
4872 if ($user->admin && !$noadmininfo) {
4873 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4889 public function selectShippingMethod($selected =
'', $htmlname =
'shipping_method_id', $filtre =
'', $useempty = 0, $moreattrib =
'', $noinfoadmin = 0, $morecss =
'')
4891 global $langs, $user;
4893 $langs->load(
"admin");
4894 $langs->load(
"deliveries");
4896 $sql =
"SELECT rowid, code, libelle as label";
4897 $sql .=
" FROM " . $this->db->prefix() .
"c_shipment_mode";
4898 $sql .=
" WHERE active > 0";
4900 $sql .=
" AND " . $filtre;
4902 $sql .=
" ORDER BY libelle ASC";
4904 dol_syslog(get_class($this) .
"::selectShippingMode", LOG_DEBUG);
4905 $result = $this->db->query($sql);
4907 $num = $this->db->num_rows($result);
4910 print
'<select id="select' . $htmlname .
'" class="flat selectshippingmethod' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
4911 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
4912 print
'<option value="-1"> </option>';
4915 $obj = $this->db->fetch_object($result);
4916 if ($selected == $obj->rowid) {
4917 print
'<option value="' . $obj->rowid .
'" selected>';
4919 print
'<option value="' . $obj->rowid .
'">';
4921 print ($langs->trans(
"SendingMethod" . strtoupper($obj->code)) !=
"SendingMethod" . strtoupper($obj->code)) ? $langs->trans(
"SendingMethod" . strtoupper($obj->code)) : $obj->label;
4926 if ($user->admin && empty($noinfoadmin)) {
4927 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4932 print $langs->trans(
"NoShippingMethodDefined");
4952 $langs->load(
"deliveries");
4954 if ($htmlname !=
"none") {
4955 print
'<form method="POST" action="' . $page .
'">';
4956 print
'<input type="hidden" name="action" value="setshippingmethod">';
4957 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
4959 print
'<input type="submit" class="button valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
4963 $code = $langs->getLabelFromKey($this->db, $selected,
'c_shipment_mode',
'rowid',
'code');
4964 print $langs->trans(
"SendingMethod" . strtoupper($code));
4983 $langs->load(
'bills');
4985 $opt =
'<option value="" selected></option>';
4986 $sql =
"SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc";
4987 $sql .=
' FROM ' . $this->db->prefix() .
'facture';
4988 $sql .=
' WHERE entity IN (' .
getEntity(
'invoice') .
')';
4989 $sql .=
' AND situation_counter >= 1';
4990 $sql .=
' AND fk_soc = ' . (int) $socid;
4991 $sql .=
' AND type <> 2';
4992 $sql .=
' ORDER by situation_cycle_ref, situation_counter desc';
4993 $resql = $this->db->query($sql);
4995 if ($resql && $this->db->num_rows($resql) > 0) {
4998 while ($obj = $this->db->fetch_object($resql)) {
5000 if ($obj->situation_cycle_ref != $ref) {
5002 $ref = $obj->situation_cycle_ref;
5004 if ($obj->situation_final != 1) {
5006 if (substr($obj->ref, 1, 4) !=
'PROV') {
5007 if ($selected == $obj->rowid) {
5008 $opt .=
'<option value="' . $obj->rowid .
'" selected>' . $obj->ref .
'</option>';
5010 $opt .=
'<option value="' . $obj->rowid .
'">' . $obj->ref .
'</option>';
5017 dol_syslog(
"Error sql=" . $sql .
", error=" . $this->error, LOG_ERR);
5019 if ($opt ==
'<option value ="" selected></option>') {
5020 $opt =
'<option value ="0" selected>' . $langs->trans(
'NoSituations') .
'</option>';
5034 public function selectUnits($selected =
'', $htmlname =
'units', $showempty = 0, $unit_type =
'')
5038 $langs->load(
'products');
5040 $return =
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'">';
5042 $sql =
"SELECT rowid, label, code FROM " . $this->db->prefix() .
"c_units";
5043 $sql .=
' WHERE active > 0';
5044 if (!empty($unit_type)) {
5045 $sql .=
" AND unit_type = '" . $this->db->escape($unit_type) .
"'";
5047 $sql .=
" ORDER BY sortorder";
5049 $resql = $this->db->query($sql);
5050 if ($resql && $this->db->num_rows($resql) > 0) {
5052 $return .=
'<option value="none"></option>';
5055 while ($res = $this->db->fetch_object($resql)) {
5056 $unitLabel = $res->label;
5057 if (!empty($langs->tab_translate[
'unit' . $res->code])) {
5058 $unitLabel = $langs->trans(
'unit' . $res->code) != $res->label ? $langs->trans(
'unit' . $res->code) : $res->label;
5061 if ($selected == $res->rowid) {
5062 $return .=
'<option value="' . $res->rowid .
'" selected>' . $unitLabel .
'</option>';
5064 $return .=
'<option value="' . $res->rowid .
'">' . $unitLabel .
'</option>';
5067 $return .=
'</select>';
5088 public function select_comptes($selected =
'', $htmlname =
'accountid', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'', $showcurrency = 0, $morecss =
'', $nooutput = 0)
5095 $langs->load(
"admin");
5098 $sql =
"SELECT rowid, label, bank, clos as status, currency_code";
5099 $sql .=
" FROM " . $this->db->prefix() .
"bank_account";
5100 $sql .=
" WHERE entity IN (" .
getEntity(
'bank_account') .
")";
5102 $sql .=
" AND clos = " . (int) $status;
5105 $sql .=
" AND " . $filtre;
5107 $sql .=
" ORDER BY label";
5109 dol_syslog(get_class($this) .
"::select_comptes", LOG_DEBUG);
5110 $result = $this->db->query($sql);
5112 $num = $this->db->num_rows($result);
5115 $out .=
'<select id="select' . $htmlname .
'" class="flat selectbankaccount' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
5117 if (!empty($useempty) && !is_numeric($useempty)) {
5118 $out .=
'<option value="-1">'.$langs->trans($useempty).
'</option>';
5119 } elseif ($useempty == 1 || ($useempty == 2 && $num > 1)) {
5120 $out .=
'<option value="-1"> </option>';
5124 $obj = $this->db->fetch_object($result);
5125 if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected))) {
5126 $out .=
'<option value="' . $obj->rowid .
'" data-currency-code="' . $obj->currency_code .
'" selected>';
5128 $out .=
'<option value="' . $obj->rowid .
'" data-currency-code="' . $obj->currency_code .
'">';
5130 $out .= trim($obj->label);
5131 if ($showcurrency) {
5132 $out .=
' (' . $obj->currency_code .
')';
5134 if ($status == 2 && $obj->status == 1) {
5135 $out .=
' (' . $langs->trans(
"Closed") .
')';
5137 $out .=
'</option>';
5140 $out .=
"</select>";
5144 $out .=
'<span class="opacitymedium">' . $langs->trans(
"NoActiveBankAccountDefined") .
'</span>';
5146 $out .=
'<span class="opacitymedium">' . $langs->trans(
"NoBankAccountFound") .
'</span>';
5154 if (empty($nooutput)) {
5174 public function selectEstablishments($selected =
'', $htmlname =
'entity', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'')
5178 $langs->load(
"admin");
5181 $sql =
"SELECT rowid, name, fk_country, status, entity";
5182 $sql .=
" FROM " . $this->db->prefix() .
"establishment";
5183 $sql .=
" WHERE 1=1";
5185 $sql .=
" AND status = " . (int) $status;
5188 $sql .=
" AND " . $filtre;
5190 $sql .=
" ORDER BY name";
5192 dol_syslog(get_class($this) .
"::select_establishment", LOG_DEBUG);
5193 $result = $this->db->query($sql);
5195 $num = $this->db->num_rows($result);
5198 print
'<select id="select' . $htmlname .
'" class="flat selectestablishment" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
5199 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
5200 print
'<option value="-1"> </option>';
5204 $obj = $this->db->fetch_object($result);
5205 if ($selected == $obj->rowid) {
5206 print
'<option value="' . $obj->rowid .
'" selected>';
5208 print
'<option value="' . $obj->rowid .
'">';
5210 print trim($obj->name);
5211 if ($status == 2 && $obj->status == 1) {
5212 print
' (' . $langs->trans(
"Closed") .
')';
5220 print
'<span class="opacitymedium">' . $langs->trans(
"NoActiveEstablishmentDefined") .
'</span>';
5222 print
'<span class="opacitymedium">' . $langs->trans(
"NoEstablishmentFound") .
'</span>';
5245 if ($htmlname !=
"none") {
5246 print
'<form method="POST" action="' . $page .
'">';
5247 print
'<input type="hidden" name="action" value="setbankaccount">';
5248 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
5249 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
5250 $nbaccountfound = $this->
select_comptes($selected, $htmlname, 0,
'', $addempty);
5251 if ($nbaccountfound > 0) {
5252 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
5256 $langs->load(
'banks');
5259 require_once DOL_DOCUMENT_ROOT .
'/compta/bank/class/account.class.php';
5260 $bankstatic =
new Account($this->db);
5261 $result = $bankstatic->fetch($selected);
5263 print $bankstatic->getNomUrl(1);
5292 public function select_all_categories($type, $selected =
'', $htmlname =
"parent", $maxlength = 64, $fromid = 0, $outputmode = 0, $include = 0, $morecss =
'', $useempty = 1)
5295 global $conf, $langs;
5296 $langs->load(
"categories");
5298 include_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
5301 if (is_numeric($type)) {
5302 dol_syslog(__METHOD__ .
': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
5305 if ($type === Categorie::TYPE_BANK_LINE) {
5307 $cate_arbo = array();
5308 $sql =
"SELECT c.label, c.rowid";
5309 $sql .=
" FROM " . $this->db->prefix() .
"bank_categ as c";
5310 $sql .=
" WHERE entity = " . $conf->entity;
5311 $sql .=
" ORDER BY c.label";
5312 $result = $this->db->query($sql);
5314 $num = $this->db->num_rows($result);
5317 $objp = $this->db->fetch_object($result);
5319 $cate_arbo[$objp->rowid] = array(
'id' => $objp->rowid,
'fulllabel' => $objp->label,
'color' =>
'',
'picto' =>
'category');
5323 $this->db->free($result);
5329 $cate_arbo = $cat->get_full_arbo($type, $fromid, $include);
5332 $outarray = array();
5333 $outarrayrichhtml = array();
5336 $output =
'<select class="flat minwidth100' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
5337 if (is_array($cate_arbo)) {
5338 $num = count($cate_arbo);
5341 $output .=
'<option value="-1" disabled>' . $langs->trans(
"NoCategoriesDefined") .
'</option>';
5343 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
5344 $output .=
'<option value="-1"> </option>';
5346 foreach ($cate_arbo as $key => $value) {
5347 if ($cate_arbo[$key][
'id'] == $selected || ($selected ===
'auto' && count($cate_arbo) == 1)) {
5353 $labeltoshow =
img_picto(
'',
'category',
'class="pictofixedwidth" style="color: #' . $cate_arbo[$key][
'color'] .
'"');
5354 $labeltoshow .=
dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle');
5356 $outarray[$cate_arbo[$key][
'id']] = $cate_arbo[$key][
'fulllabel'];
5358 $outarrayrichhtml[$cate_arbo[$key][
'id']] = $labeltoshow;
5360 $output .=
'<option ' . $add .
'value="' . $cate_arbo[$key][
'id'] .
'"';
5363 $output .=
dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle');
5364 $output .=
'</option>';
5366 $cate_arbo[$key][
'data-html'] = $labeltoshow;
5370 $output .=
'</select>';
5373 if ($outputmode == 2) {
5376 } elseif ($outputmode == 1) {
5378 } elseif ($outputmode == 3) {
5379 return $outarrayrichhtml;
5402 public function form_confirm($page, $title, $question, $action, $formquestion = array(), $selectedchoice =
"", $useajax = 0, $height = 170, $width = 500)
5405 dol_syslog(__METHOD__ .
': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING);
5406 print $this->
formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width);
5436 public function formconfirm($page, $title, $question, $action, $formquestion =
'', $selectedchoice =
'', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0, $labelbuttonyes =
'Yes', $labelbuttonno =
'No')
5438 global $langs, $conf;
5440 $more =
'<!-- formconfirm - before call, page=' .
dol_escape_htmltag($page) .
' -->';
5446 $newselectedchoice = empty($selectedchoice) ?
"no" : $selectedchoice;
5447 if ($conf->browser->layout ==
'phone') {
5452 if (empty($height)) {
5454 if (is_array($formquestion) && count($formquestion) > 2) {
5455 $height += ((count($formquestion) - 2) * 24);
5459 if (is_array($formquestion) && !empty($formquestion)) {
5461 foreach ($formquestion as $key => $input) {
5462 if (is_array($input) && !empty($input)) {
5463 if ($input[
'type'] ==
'hidden') {
5464 $moreattr = (!empty($input[
'moreattr']) ?
' ' . $input[
'moreattr'] :
'');
5465 $morecss = (!empty($input[
'morecss']) ?
' ' . $input[
'morecss'] :
'');
5473 $moreonecolumn =
'';
5474 $more .=
'<div class="tagtable paddingtopbottomonly centpercent noborderspacing">' .
"\n";
5475 foreach ($formquestion as $key => $input) {
5476 if (is_array($input) && !empty($input)) {
5477 $size = (!empty($input[
'size']) ?
' size="' . $input[
'size'] .
'"' :
'');
5478 $moreattr = (!empty($input[
'moreattr']) ?
' ' . $input[
'moreattr'] :
'');
5479 $morecss = (!empty($input[
'morecss']) ?
' ' . $input[
'morecss'] :
'');
5481 if ($input[
'type'] ==
'text') {
5482 $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";
5483 } elseif ($input[
'type'] ==
'password') {
5484 $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";
5485 } elseif ($input[
'type'] ==
'textarea') {
5491 $moreonecolumn .=
'<div class="margintoponly">';
5492 $moreonecolumn .= $input[
'label'] .
'<br>';
5494 $moreonecolumn .= $input[
'value'];
5495 $moreonecolumn .=
'</textarea>';
5496 $moreonecolumn .=
'</div>';
5497 } elseif (in_array($input[
'type'], [
'select',
'multiselect'])) {
5498 if (empty($morecss)) {
5499 $morecss =
'minwidth100';
5502 $show_empty = isset($input[
'select_show_empty']) ? $input[
'select_show_empty'] : 1;
5503 $key_in_label = isset($input[
'select_key_in_label']) ? $input[
'select_key_in_label'] : 0;
5504 $value_as_key = isset($input[
'select_value_as_key']) ? $input[
'select_value_as_key'] : 0;
5505 $translate = isset($input[
'select_translate']) ? $input[
'select_translate'] : 0;
5506 $maxlen = isset($input[
'select_maxlen']) ? $input[
'select_maxlen'] : 0;
5507 $disabled = isset($input[
'select_disabled']) ? $input[
'select_disabled'] : 0;
5508 $sort = isset($input[
'select_sort']) ? $input[
'select_sort'] :
'';
5510 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">';
5511 if (!empty($input[
'label'])) {
5512 $more .= $input[
'label'] .
'</div><div class="tagtd left">';
5514 if ($input[
'type'] ==
'select') {
5515 $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);
5517 $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);
5519 $more .=
'</div></div>' .
"\n";
5520 } elseif ($input[
'type'] ==
'checkbox') {
5521 $more .=
'<div class="tagtr">';
5522 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'"><label for="' .
dol_escape_htmltag($input[
'name']) .
'">' . $input[
'label'] .
'</label></div><div class="tagtd">';
5523 $more .=
'<input type="checkbox" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' .
dol_escape_htmltag($input[
'name']) .
'" name="' .
dol_escape_htmltag($input[
'name']) .
'"' . $moreattr;
5524 if (!is_bool($input[
'value']) && $input[
'value'] !=
'false' && $input[
'value'] !=
'0' && $input[
'value'] !=
'') {
5525 $more .=
' checked';
5527 if (is_bool($input[
'value']) && $input[
'value']) {
5528 $more .=
' checked';
5530 if (isset($input[
'disabled'])) {
5531 $more .=
' disabled';
5533 $more .=
' /></div>';
5534 $more .=
'</div>' .
"\n";
5535 } elseif ($input[
'type'] ==
'radio') {
5537 foreach ($input[
'values'] as $selkey => $selval) {
5538 $more .=
'<div class="tagtr">';
5539 if (isset($input[
'label'])) {
5541 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
' tdtop' : (
' tdtop ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div>';
5543 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' "' . $input[
'tdclass'])) .
'"> </div>';
5546 $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;
5547 if (!empty($input[
'disabled'])) {
5548 $more .=
' disabled';
5550 if (isset($input[
'default']) && $input[
'default'] === $selkey) {
5551 $more .=
' checked="checked"';
5554 $more .=
'<label for="' .
dol_escape_htmltag($input[
'name'] . $selkey) .
'" class="valignmiddle">' . $selval .
'</label>';
5555 $more .=
'</div></div>' .
"\n";
5558 } elseif ($input[
'type'] ==
'date' || $input[
'type'] ==
'datetime') {
5559 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div>';
5560 $more .=
'<div class="tagtd">';
5561 $addnowlink = (empty($input[
'datenow']) ? 0 : 1);
5563 if ($input[
'type'] ==
'datetime') {
5564 $h = isset($input[
'hours']) ? $input[
'hours'] : 1;
5565 $m = isset($input[
'minutes']) ? $input[
'minutes'] : 1;
5567 $more .= $this->
selectDate(isset($input[
'value']) ? $input[
'value'] : -1, $input[
'name'], $h, $m, 0,
'', 1, $addnowlink);
5568 $more .=
'</div></div>'.
"\n";
5569 $formquestion[] = array(
'name' => $input[
'name'].
'day');
5570 $formquestion[] = array(
'name' => $input[
'name'].
'month');
5571 $formquestion[] = array(
'name' => $input[
'name'].
'year');
5572 $formquestion[] = array(
'name' => $input[
'name'].
'hour');
5573 $formquestion[] = array(
'name' => $input[
'name'].
'min');
5574 } elseif ($input[
'type'] ==
'other') {
5575 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">';
5576 if (!empty($input[
'label'])) {
5577 $more .= $input[
'label'] .
'</div><div class="tagtd">';
5579 $more .= $input[
'value'];
5580 $more .=
'</div></div>' .
"\n";
5581 } elseif ($input[
'type'] ==
'onecolumn') {
5582 $moreonecolumn .=
'<div class="margintoponly">';
5583 $moreonecolumn .= $input[
'value'];
5584 $moreonecolumn .=
'</div>' .
"\n";
5585 } elseif ($input[
'type'] ==
'hidden') {
5587 } elseif ($input[
'type'] ==
'separator') {
5590 $more .=
'Error type ' . $input[
'type'] .
' for the confirm box is not a supported type';
5594 $more .=
'</div>' .
"\n";
5595 $more .= $moreonecolumn;
5601 if (!empty($conf->dol_use_jmobile)) {
5604 if (empty($conf->use_javascript_ajax)) {
5610 $dialogconfirm =
'dialog-confirm';
5612 if (!is_numeric($useajax)) {
5616 $dialogconfirm .=
'-' . $button;
5618 $pageyes = $page . (preg_match(
'/\?/', $page) ?
'&' :
'?') .
'action=' . urlencode($action) .
'&confirm=yes';
5619 $pageno = ($useajax == 2 ? $page . (preg_match(
'/\?/', $page) ?
'&' :
'?') .
'action=' . urlencode($action) .
'&confirm=no' :
'');
5622 if (is_array($formquestion)) {
5623 foreach ($formquestion as $key => $input) {
5626 if (is_array($input) && isset($input[
'name'])) {
5627 if (strpos($input[
'name'],
',') > 0) {
5628 $inputok = array_merge($inputok, explode(
',', $input[
'name']));
5630 array_push($inputok, $input[
'name']);
5635 if (is_array($input) && isset($input[
'inputko']) && $input[
'inputko'] == 1 && isset($input[
'name'])) {
5636 array_push($inputko, $input[
'name']);
5642 $formconfirm .=
'<div id="' . $dialogconfirm .
'" title="' .
dol_escape_htmltag($title) .
'" style="display: none;">';
5643 if (is_array($formquestion) && array_key_exists(
'text', $formquestion) && !empty($formquestion[
'text'])) {
5644 $formconfirm .=
'<div class="confirmtext">' . $formquestion[
'text'] .
'</div>' .
"\n";
5646 if (!empty($more)) {
5647 $formconfirm .=
'<div class="confirmquestions">' . $more .
'</div>' .
"\n";
5649 $formconfirm .= ($question ?
'<div class="confirmmessage">' .
img_help(0,
'') .
' ' . $question .
'</div>' :
'');
5650 $formconfirm .=
'</div>' .
"\n";
5652 $formconfirm .=
"\n<!-- begin code of popup for formconfirm page=" . $page .
" -->\n";
5653 $formconfirm .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">' .
"\n";
5654 $formconfirm .=
"/* Code for the jQuery('#dialogforpopup').dialog() */\n";
5655 $formconfirm .=
'jQuery(document).ready(function() {
5657 $( "#' . $dialogconfirm .
'" ).dialog(
5659 autoOpen: ' . ($autoOpen ?
"true" :
"false") .
',';
5660 if ($newselectedchoice ==
'no') {
5663 $(this).parent().find("button.ui-button:eq(2)").focus();
5668 if ($useajax == 1) {
5669 $jsforcursor =
'// The call to urljump can be slow, so we set the wait cursor' .
"\n";
5670 $jsforcursor .=
'jQuery("html,body,#id-container").addClass("cursorwait");' .
"\n";
5673 $postconfirmas =
'GET';
5677 height: "' . $height .
'",
5678 width: "' . $width .
'",
5680 closeOnEscape: false,
5682 "' .
dol_escape_js($langs->transnoentities($labelbuttonyes)) .
'": function() {
5683 var options = "token=' . urlencode(
newToken()) .
'";
5684 var inputok = ' . json_encode($inputok) .
'; /* List of fields into form */
5685 var page = "' .
dol_escape_js(!empty($page) ? $page :
'') .
'";
5686 var pageyes = "' .
dol_escape_js(!empty($pageyes) ? $pageyes :
'') .
'";
5688 if (inputok.length > 0) {
5689 $.each(inputok, function(i, inputname) {
5692 if ($("input[name=\'" + inputname + "\']").attr("type") == "radio") {
5693 inputvalue = $("input[name=\'" + inputname + "\']:checked").val();
5695 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
5696 inputvalue = $("#" + inputname + more).val();
5698 if (typeof inputvalue == "undefined") { inputvalue=""; }
5699 console.log("formconfirm check inputname="+inputname+" inputvalue="+inputvalue);
5700 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
5703 var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "&") + options;
5704 if (pageyes.length > 0) {';
5705 if ($postconfirmas ==
'GET') {
5706 $formconfirm .=
'location.href = urljump;';
5708 $formconfirm .= $jsforcursor;
5709 $formconfirm .=
'var post = $.post(
5712 function(data) { $("body").html(data); jQuery("html,body,#id-container").removeClass("cursorwait"); }
5716 console.log("after post ok");
5718 $(this).dialog("close");
5720 "' .
dol_escape_js($langs->transnoentities($labelbuttonno)) .
'": function() {
5721 var options = "token=' . urlencode(
newToken()) .
'";
5722 var inputko = ' . json_encode($inputko) .
'; /* List of fields into form */
5723 var page = "' .
dol_escape_js(!empty($page) ? $page :
'') .
'";
5724 var pageno="' .
dol_escape_js(!empty($pageno) ? $pageno :
'') .
'";
5725 if (inputko.length > 0) {
5726 $.each(inputko, function(i, inputname) {
5728 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
5729 var inputvalue = $("#" + inputname + more).val();
5730 if (typeof inputvalue == "undefined") { inputvalue=""; }
5731 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
5734 var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "&") + options;
5736 if (pageno.length > 0) {';
5737 if ($postconfirmas ==
'GET') {
5738 $formconfirm .=
'location.href = urljump;';
5740 $formconfirm .= $jsforcursor;
5741 $formconfirm .=
'var post = $.post(
5744 function(data) { $("body").html(data); jQuery("html,body,#id-container").removeClass("cursorwait"); }
5748 console.log("after post ko");
5750 $(this).dialog("close");
5756 var button = "' . $button .
'";
5757 if (button.length > 0) {
5758 $( "#" + button ).click(function() {
5759 $("#' . $dialogconfirm .
'").dialog("open");
5765 $formconfirm .=
"<!-- end ajax formconfirm -->\n";
5767 $formconfirm .=
"\n<!-- begin formconfirm page=" .
dol_escape_htmltag($page) .
" -->\n";
5769 if (empty($disableformtag)) {
5770 $formconfirm .=
'<form method="POST" action="' . $page .
'" class="notoptoleftroright">' .
"\n";
5773 $formconfirm .=
'<input type="hidden" name="action" value="' . $action .
'">' .
"\n";
5774 $formconfirm .=
'<input type="hidden" name="token" value="' .
newToken() .
'">' .
"\n";
5776 $formconfirm .=
'<table class="valid centpercent">' .
"\n";
5779 $formconfirm .=
'<tr class="validtitre"><td class="validtitre" colspan="2">';
5780 $formconfirm .=
img_picto(
'',
'pictoconfirm') .
' ' . $title;
5781 $formconfirm .=
'</td></tr>' .
"\n";
5784 if (is_array($formquestion) && array_key_exists(
'text', $formquestion) && !empty($formquestion[
'text'])) {
5785 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="2">' . $formquestion[
'text'] .
'</td></tr>' .
"\n";
5790 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="2">' .
"\n";
5791 $formconfirm .= $more;
5792 $formconfirm .=
'</td></tr>' .
"\n";
5796 $formconfirm .=
'<tr class="valid">';
5797 $formconfirm .=
'<td class="valid">' . $question .
'</td>';
5798 $formconfirm .=
'<td class="valid center">';
5799 $formconfirm .= $this->
selectyesno(
"confirm", $newselectedchoice, 0,
false, 0, 0,
'marginleftonly marginrightonly', $labelbuttonyes, $labelbuttonno);
5800 $formconfirm .=
'<input class="button valignmiddle confirmvalidatebutton small" type="submit" value="' . $langs->trans(
"Validate") .
'">';
5801 $formconfirm .=
'</td>';
5802 $formconfirm .=
'</tr>' .
"\n";
5804 $formconfirm .=
'</table>' .
"\n";
5806 if (empty($disableformtag)) {
5807 $formconfirm .=
"</form>\n";
5809 $formconfirm .=
'<br>';
5811 if (!empty($conf->use_javascript_ajax)) {
5812 $formconfirm .=
'<!-- code to disable button to avoid double clic -->';
5813 $formconfirm .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">' .
"\n";
5815 $(document).ready(function () {
5816 $(".confirmvalidatebutton").on("click", function() {
5817 console.log("We click on button confirmvalidatebutton");
5818 $(this).attr("disabled", "disabled");
5819 setTimeout(\'$(".confirmvalidatebutton").removeAttr("disabled")\', 3000);
5820 //console.log($(this).closest("form"));
5821 $(this).closest("form").submit();
5825 $formconfirm .=
'</script>' .
"\n";
5828 $formconfirm .=
"<!-- end formconfirm -->\n";
5831 return $formconfirm;
5852 public function form_project($page, $socid, $selected =
'', $htmlname =
'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0, $textifnoproject =
'', $morecss =
'')
5857 require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
5858 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
5864 $langs->load(
"project");
5865 if ($htmlname !=
"none") {
5866 $out .=
'<form method="post" action="' . $page .
'">';
5867 $out .=
'<input type="hidden" name="action" value="classin">';
5868 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
5869 $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0,
'', 1, 0, $morecss);
5870 $out .=
'<input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
5873 $out .=
'<span class="project_head_block">';
5875 $projet =
new Project($this->db);
5876 $projet->fetch($selected);
5877 $out .= $projet->getNomUrl(0,
'', 1);
5879 $out .=
'<span class="opacitymedium">' . $textifnoproject .
'</span>';
5884 if (empty($nooutput)) {
5908 public function form_conditions_reglement($page, $selected =
'', $htmlname =
'cond_reglement_id', $addempty = 0, $type =
'', $filtertype = -1, $deposit_percent = -1, $nooutput = 0)
5915 if ($htmlname !=
"none") {
5916 $out .=
'<form method="POST" action="' . $page .
'">';
5917 $out .=
'<input type="hidden" name="action" value="setconditions">';
5918 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
5920 $out .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
5923 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
5928 if (isset($this->cache_conditions_paiements[$selected])) {
5929 $label = $this->cache_conditions_paiements[$selected][
'label'];
5931 if (!empty($this->cache_conditions_paiements[$selected][
'deposit_percent'])) {
5932 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $this->cache_conditions_paiements[$selected][
'deposit_percent'], $label);
5937 $langs->load(
'errors');
5938 $out .= $langs->trans(
'ErrorNotInDictionaryPaymentConditions');
5945 if (empty($nooutput)) {
5967 if ($htmlname !=
"none") {
5968 print
'<form method="post" action="' . $page .
'">';
5969 print
'<input type="hidden" name="action" value="setavailability">';
5970 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
5972 print
'<input type="submit" name="modify" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
5973 print
'<input type="submit" name="cancel" class="button smallpaddingimp" value="' . $langs->trans(
"Cancel") .
'">';
5978 print $this->cache_availability[$selected][
'label'];
5995 public function formInputReason($page, $selected =
'', $htmlname =
'demandreason', $addempty = 0)
5998 if ($htmlname !=
"none") {
5999 print
'<form method="post" action="' . $page .
'">';
6000 print
'<input type="hidden" name="action" value="setdemandreason">';
6001 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6003 print
'<input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
6008 foreach ($this->cache_demand_reason as $key => $val) {
6009 if ($val[
'id'] == $selected) {
6010 print $val[
'label'];
6035 public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0, $type =
'')
6042 if ($htmlname !=
"none") {
6043 $ret .=
'<form method="POST" action="' . $page .
'" name="form' . $htmlname .
'">';
6044 $ret .=
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
6045 $ret .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6047 $ret .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
6049 $ret .=
'<table class="nobordernopadding">';
6051 $ret .= $this->
selectDate($selected, $htmlname, $displayhour, $displaymin, 1,
'form' . $htmlname, 1, 0);
6053 $ret .=
'<td class="left"><input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'"></td>';
6054 $ret .=
'</tr></table></form>';
6063 if (empty($nooutput)) {
6082 public function form_users($page, $selected =
'', $htmlname =
'userid', $exclude = array(), $include = array())
6087 if ($htmlname !=
"none") {
6088 print
'<form method="POST" action="' . $page .
'" name="form' . $htmlname .
'">';
6089 print
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
6090 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6091 print $this->
select_dolusers($selected, $htmlname, 1, $exclude, 0, $include);
6092 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6096 require_once DOL_DOCUMENT_ROOT .
'/user/class/user.class.php';
6097 $theuser =
new User($this->db);
6098 $theuser->fetch($selected);
6099 print $theuser->getNomUrl(1);
6122 public function form_modes_reglement($page, $selected =
'', $htmlname =
'mode_reglement_id', $filtertype =
'', $active = 1, $addempty = 0, $type =
'', $nooutput = 0)
6128 if ($htmlname !=
"none") {
6129 $out .=
'<form method="POST" action="' . $page .
'">';
6130 $out .=
'<input type="hidden" name="action" value="setmode">';
6131 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6133 $out .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
6135 $out .= $this->
select_types_paiements($selected, $htmlname, $filtertype, 0, $addempty, 0, 0, $active,
'', 1);
6136 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6141 $out .= $this->cache_types_paiements[$selected][
'label'];
6168 if ($htmlname !=
"none") {
6169 print
'<form method="POST" action="' . $page .
'">';
6170 print
'<input type="hidden" name="action" value="settransportmode">';
6171 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6173 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6178 print $this->cache_transport_mode[$selected][
'label'];
6199 if ($htmlname !=
"none") {
6200 print
'<form method="POST" action="' . $page .
'">';
6201 print
'<input type="hidden" name="action" value="setmulticurrencycode">';
6202 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6204 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6207 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
6208 print !empty($selected) ?
currency_name($selected, 1) :
' ';
6226 global $langs, $mysoc, $conf;
6228 if ($htmlname !=
"none") {
6229 print
'<form method="POST" action="' . $page .
'">';
6230 print
'<input type="hidden" name="action" value="setmulticurrencyrate">';
6231 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6232 print
'<input type="text" class="maxwidth100" name="' . $htmlname .
'" value="' . (!empty($rate) ?
price(
price2num($rate,
'CU')) : 1) .
'" /> ';
6233 print
'<select name="calculation_mode">';
6234 print
'<option value="1">Change ' . $langs->trans(
"PriceUHT") .
' of lines</option>';
6235 print
'<option value="2">Change ' . $langs->trans(
"PriceUHTCurrency") .
' of lines</option>';
6237 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6240 if (!empty($rate)) {
6241 print
price($rate, 1, $langs, 0, 0);
6242 if ($currency && $rate != 1) {
6243 print
' (' .
price($rate, 1, $langs, 0, 0) .
' ' . $currency .
' = 1 ' . $conf->currency .
')';
6269 public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter =
'', $maxvalue = 0, $more =
'', $hidelist = 0, $discount_type = 0)
6272 global $conf, $langs;
6273 if ($htmlname !=
"none") {
6274 print
'<form method="post" action="' . $page .
'">';
6275 print
'<input type="hidden" name="action" value="setabsolutediscount">';
6276 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6277 print
'<div class="inline-block">';
6278 if (!empty($discount_type)) {
6280 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL") {
6281 $translationKey =
'HasAbsoluteDiscountFromSupplier';
6283 $translationKey =
'HasCreditNoteFromSupplier';
6286 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
6287 $translationKey =
'HasAbsoluteDiscountFromSupplier';
6289 $translationKey =
'HasCreditNoteFromSupplier';
6294 if (!$filter || $filter ==
"fk_facture_source IS NULL") {
6295 $translationKey =
'CompanyHasAbsoluteDiscount';
6297 $translationKey =
'CompanyHasCreditNote';
6300 if (!$filter || $filter ==
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
6301 $translationKey =
'CompanyHasAbsoluteDiscount';
6303 $translationKey =
'CompanyHasCreditNote';
6307 print $langs->trans($translationKey,
price($amount, 0, $langs, 0, 0, -1, $conf->currency));
6308 if (empty($hidelist)) {
6312 if (empty($hidelist)) {
6313 print
'<div class="inline-block" style="padding-right: 10px">';
6314 $newfilter =
'discount_type=' . intval($discount_type);
6315 if (!empty($discount_type)) {
6316 $newfilter .=
' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL';
6318 $newfilter .=
' AND fk_facture IS NULL AND fk_facture_line IS NULL';
6321 $newfilter .=
' AND (' . $filter .
')';
6324 $nbqualifiedlines = $this->
select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue);
6325 if ($nbqualifiedlines > 0) {
6326 print
' <input type="submit" class="button smallpaddingimp" value="' .
dol_escape_htmltag($langs->trans(
"UseLine")) .
'"';
6327 if (!empty($discount_type) && $filter && $filter !=
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
6328 print
' title="' . $langs->trans(
"UseCreditNoteInInvoicePayment") .
'"';
6330 if (empty($discount_type) && $filter && $filter !=
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
6331 print
' title="' . $langs->trans(
"UseCreditNoteInInvoicePayment") .
'"';
6339 print
'<div class="inline-block">';
6365 public function form_contacts($page, $societe, $selected =
'', $htmlname =
'contactid')
6370 if ($htmlname !=
"none") {
6371 print
'<form method="post" action="' . $page .
'">';
6372 print
'<input type="hidden" name="action" value="set_contact">';
6373 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6374 print
'<table class="nobordernopadding">';
6379 $addcontact = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
6380 print
'<a href="' . DOL_URL_ROOT .
'/contact/card.php?socid=' . $societe->id .
'&action=create&backtoreferer=1">' . $addcontact .
'</a>';
6383 print
'<td class="left"><input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'"></td>';
6384 print
'</tr></table></form>';
6387 require_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
6388 $contact =
new Contact($this->db);
6389 $contact->fetch($selected);
6390 print $contact->getFullName($langs);
6415 public function form_thirdparty($page, $selected =
'', $htmlname =
'socid', $filter =
'', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0, $excludeids = array(), $textifnothirdparty =
'')
6421 if ($htmlname !=
"none") {
6422 $out .=
'<form method="post" action="' . $page .
'">';
6423 $out .=
'<input type="hidden" name="action" value="set_thirdparty">';
6424 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6425 $out .= $this->
select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, 0,
'minwidth100',
'',
'', 1, array(),
false, $excludeids);
6426 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6430 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
6431 $soc =
new Societe($this->db);
6432 $soc->fetch($selected);
6433 $out .= $soc->getNomUrl(0,
'');
6435 $out .=
'<span class="opacitymedium">' . $textifnothirdparty .
'</span>';
6473 public function selectCurrency($selected =
'', $htmlname =
'currency_id', $mode = 0, $useempty =
'')
6475 global $langs, $user;
6477 $langs->loadCacheCurrencies(
'');
6481 if ($selected ==
'euro' || $selected ==
'euros') {
6485 $out .=
'<select class="flat maxwidth200onsmartphone minwidth300" name="' . $htmlname .
'" id="' . $htmlname .
'">';
6487 $out .=
'<option value="-1" selected></option>';
6489 foreach ($langs->cache_currencies as $code_iso => $currency) {
6490 $labeltoshow = $currency[
'label'];
6492 $labeltoshow .=
' <span class="opacitymedium">(' . $code_iso .
')</span>';
6494 $labeltoshow .=
' <span class="opacitymedium">(' . $langs->getCurrencySymbol($code_iso) .
')</span>';
6497 if ($selected && $selected == $code_iso) {
6498 $out .=
'<option value="' . $code_iso .
'" selected data-html="' .
dol_escape_htmltag($labeltoshow) .
'">';
6500 $out .=
'<option value="' . $code_iso .
'" data-html="' .
dol_escape_htmltag($labeltoshow) .
'">';
6502 $out .= $labeltoshow;
6503 $out .=
'</option>';
6505 $out .=
'</select>';
6507 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
6511 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
6529 public function selectMultiCurrency($selected =
'', $htmlname =
'multicurrency_code', $useempty = 0, $filter =
'', $excludeConfCurrency =
false, $morecss =
'')
6531 global $conf, $langs;
6533 $langs->loadCacheCurrencies(
'');
6535 $TCurrency = array();
6537 $sql =
"SELECT code FROM " . $this->db->prefix() .
"multicurrency";
6538 $sql .=
" WHERE entity IN ('" .
getEntity(
'mutlicurrency') .
"')";
6540 $sql .=
" AND " . $filter;
6542 $resql = $this->db->query($sql);
6544 while ($obj = $this->db->fetch_object($resql)) {
6545 $TCurrency[$obj->code] = $obj->code;
6550 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
6552 $out .=
'<option value=""> </option>';
6555 if (!in_array($conf->currency, $TCurrency) && !$excludeConfCurrency) {
6556 $TCurrency[$conf->currency] = $conf->currency;
6558 if (count($TCurrency) > 0) {
6559 foreach ($langs->cache_currencies as $code_iso => $currency) {
6560 if (isset($TCurrency[$code_iso])) {
6561 if (!empty($selected) && $selected == $code_iso) {
6562 $out .=
'<option value="' . $code_iso .
'" selected="selected">';
6564 $out .=
'<option value="' . $code_iso .
'">';
6567 $out .= $currency[
'label'];
6568 $out .=
' (' . $langs->getCurrencySymbol($code_iso) .
')';
6569 $out .=
'</option>';
6574 $out .=
'</select>';
6577 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
6594 global $langs, $user;
6596 $num = count($this->cache_vatrates);
6603 $sql =
"SELECT t.rowid, t.type_vat, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly";
6604 $sql .=
" FROM ".$this->db->prefix().
"c_tva as t, ".$this->db->prefix().
"c_country as c";
6605 $sql .=
" WHERE t.fk_pays = c.rowid";
6606 $sql .=
" AND t.active > 0";
6607 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
6608 $sql .=
" AND c.code IN (" . $this->db->sanitize($country_code, 1) .
")";
6609 $sql .=
" ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC";
6611 $resql = $this->db->query($sql);
6613 $num = $this->db->num_rows($resql);
6615 for ($i = 0; $i < $num; $i++) {
6616 $obj = $this->db->fetch_object($resql);
6618 $tmparray = array();
6619 $tmparray[
'rowid'] = $obj->rowid;
6620 $tmparray[
'type_vat'] = $obj->type_vat;
6621 $tmparray[
'code'] = $obj->code;
6622 $tmparray[
'txtva'] = $obj->taux;
6623 $tmparray[
'nprtva'] = $obj->recuperableonly;
6624 $tmparray[
'localtax1'] = $obj->localtax1;
6625 $tmparray[
'localtax1_type'] = $obj->localtax1_type;
6626 $tmparray[
'localtax2'] = $obj->localtax2;
6627 $tmparray[
'localtax2_type'] = $obj->localtax1_type;
6628 $tmparray[
'label'] = $obj->taux .
'%' . ($obj->code ?
' (' . $obj->code .
')' :
'');
6629 $tmparray[
'labelallrates'] = $obj->taux .
'/' . ($obj->localtax1 ? $obj->localtax1 :
'0') .
'/' . ($obj->localtax2 ? $obj->localtax2 :
'0') . ($obj->code ?
' (' . $obj->code .
')' :
'');
6630 $positiverates =
'';
6632 $positiverates .= ($positiverates ?
'/' :
'') . $obj->taux;
6634 if ($obj->localtax1) {
6635 $positiverates .= ($positiverates ?
'/' :
'') . $obj->localtax1;
6637 if ($obj->localtax2) {
6638 $positiverates .= ($positiverates ?
'/' :
'') . $obj->localtax2;
6640 if (empty($positiverates)) {
6641 $positiverates =
'0';
6643 $tmparray[
'labelpositiverates'] = $positiverates . ($obj->code ?
' (' . $obj->code .
')' :
'');
6645 $this->cache_vatrates[$obj->rowid] = $tmparray;
6650 $this->error =
'<span class="error">';
6651 $this->error .= $langs->trans(
"ErrorNoVATRateDefinedForSellerCountry", $country_code);
6653 if (!empty($user) && $user->admin && preg_match(
'/\'(..)\'/', $country_code, $reg)) {
6654 $langs->load(
"errors");
6655 $new_country_code = $reg[1];
6656 $country_id =
dol_getIdFromCode($this->db, $new_country_code,
'c_pays',
'code',
'rowid');
6657 $this->error .=
'<br>'.$langs->trans(
"ErrorFixThisHere", DOL_URL_ROOT.
'/admin/dict.php?id=10'.($country_id > 0 ?
'&countryidforinsert='.$country_id :
''));
6659 $this->error .=
'</span>';
6663 $this->error =
'<span class="error">' . $this->db->error() .
'</span>';
6692 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)
6695 global $langs, $mysoc;
6697 $langs->load(
'errors');
6702 $defaultnpr = ($info_bits & 0x01);
6703 $defaultnpr = (preg_match(
'/\*/', $selectedrate) ? 1 : $defaultnpr);
6704 $defaulttx = str_replace(
'*',
'', $selectedrate);
6707 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6708 $defaultcode = $reg[1];
6709 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6714 if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
6715 if ($societe_vendeuse->id == $mysoc->id) {
6716 $return .=
'<span class="error">' . $langs->trans(
"ErrorYourCountryIsNotDefined") .
'</span>';
6718 $return .=
'<span class="error">' . $langs->trans(
"ErrorSupplierCountryIsNotDefined") .
'</span>';
6729 if (is_object($societe_vendeuse)) {
6730 $code_country =
"'" . $societe_vendeuse->country_code .
"'";
6732 $code_country =
"'" . $mysoc->country_code .
"'";
6735 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
6739 if (
isInEEC($societe_vendeuse) &&
isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()) {
6741 if (is_numeric($type)) {
6743 switch ($selectVatComboMode) {
6745 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
6748 $code_country =
"'" . $societe_acheteuse->country_code .
"'";
6752 } elseif (!$idprod) {
6753 switch ($selectVatComboMode) {
6755 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
6758 $code_country =
"'" . $societe_acheteuse->country_code .
"'";
6762 $prodstatic =
new Product($this->db);
6763 $prodstatic->fetch($idprod);
6765 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
6775 $arrayofvatrates = array();
6776 foreach ($this->cache_vatrates as $cachevalue) {
6777 if (empty($cachevalue[
'type_vat']) || $cachevalue[
'type_vat'] == $type_vat) {
6778 $arrayofvatrates[] = $cachevalue;
6782 $num = count($arrayofvatrates);
6786 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
6788 $tmpthirdparty =
new Societe($this->db);
6789 $tmpthirdparty->country_code = $mysoc->country_code;
6791 $defaulttx =
get_default_tva(is_object($societe_vendeuse) ? $societe_vendeuse : $tmpthirdparty, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
6792 $defaultnpr =
get_default_npr(is_object($societe_vendeuse) ? $societe_vendeuse : $tmpthirdparty, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
6794 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6795 $defaultcode = $reg[1];
6796 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6798 if (empty($defaulttx)) {
6805 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
6808 $defaulttx = $arrayofvatrates[$num - 1][
'txtva'];
6815 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6816 $defaultcode = $reg[1];
6817 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6825 if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj ==
"0") {
6834 if (!$options_only) {
6835 $return .=
'<select class="flat minwidth75imp maxwidth100 right" id="' . $htmlname .
'" name="' . $htmlname .
'"' . ($disabled ?
' disabled' :
'') . $title .
'>';
6838 $selectedfound =
false;
6839 foreach ($arrayofvatrates as $rate) {
6841 if ($disabled && $rate[
'txtva'] != 0) {
6846 $key = $rate[
'txtva'];
6847 $key .= $rate[
'nprtva'] ?
'*' :
'';
6848 if ($mode > 0 && $rate[
'code']) {
6849 $key .=
' (' . $rate[
'code'] .
')';
6852 $key = $rate[
'rowid'];
6855 $return .=
'<option value="' . $key .
'"';
6856 if (!$selectedfound) {
6858 if ($defaultcode == $rate[
'code']) {
6859 $return .=
' selected';
6860 $selectedfound =
true;
6862 } elseif ($rate[
'txtva'] == $defaulttx && $rate[
'nprtva'] == $defaultnpr) {
6863 $return .=
' selected';
6864 $selectedfound =
true;
6870 if ($mysoc->country_code ==
'IN' ||
getDolGlobalString(
'MAIN_VAT_LABEL_IS_POSITIVE_RATES')) {
6872 $return .= $rate[
'labelpositiverates'];
6875 $return .=
vatrate($rate[
'label']);
6879 $return .= (empty($rate[
'code']) && $rate[
'nprtva']) ?
' *' :
'';
6881 $return .=
'</option>';
6884 if (!$options_only) {
6885 $return .=
'</select>';
6889 $return .= $this->error;
6923 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 =
'')
6926 dol_syslog(__METHOD__ .
': using select_date is deprecated. Use selectDate instead.', LOG_WARNING);
6927 $retstring = $this->
selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof);
6928 if (!empty($nooutput)) {
6951 public function selectDateToDate($set_time =
'', $set_time_end =
'', $prefix =
're', $empty = 0, $forcenewline = 0)
6955 $ret = $this->
selectDate($set_time, $prefix .
'_start', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"),
'tzuserrel');
6956 if ($forcenewline) {
6959 $ret .= $this->
selectDate($set_time_end, $prefix .
'_end', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
6990 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')
6992 global $conf, $langs;
6994 if ($gm ===
'auto') {
6995 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
7000 if ($prefix ==
'') {
7011 if ($stepminutes <= 0 || $stepminutes > 30) {
7022 $orig_set_time = $set_time;
7024 if ($set_time ===
'' && $emptydate == 0) {
7025 include_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
7026 if ($gm ==
'tzuser' || $gm ==
'tzuserrel') {
7038 if (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg)) {
7040 $syear = (!empty($reg[1]) ? $reg[1] :
'');
7041 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
7042 $sday = (!empty($reg[3]) ? $reg[3] :
'');
7043 $shour = (!empty($reg[4]) ? $reg[4] :
'');
7044 $smin = (!empty($reg[5]) ? $reg[5] :
'');
7045 } elseif (strval($set_time) !=
'' && $set_time != -1) {
7050 if ($orig_set_time !=
'') {
7064 if ($h == 3 || $h == 4) {
7075 $usecalendar =
'combo';
7081 $usecalendar =
'html';
7086 if ($usecalendar !=
'combo') {
7087 $formatted_date =
'';
7089 if (strval($set_time) !=
'' && $set_time != -1) {
7091 $formatted_date =
dol_print_date($set_time, $langs->trans(
"FormatDateShortInput"), $gm);
7095 if ($usecalendar ==
"eldy") {
7097 $retstring .=
'<input id="' . $prefix .
'" name="' . $prefix .
'" type="text" class="maxwidthdate center" maxlength="11" value="' . $formatted_date .
'"';
7098 $retstring .= ($disabled ?
' disabled' :
'');
7099 $retstring .=
' onChange="dpChangeDay(\'' . $prefix .
'\',\
'' . $langs->trans(
"FormatDateShortJavaInput") .
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
7100 $retstring .= ' autocomplete="off
">';
7103 $retstringbuttom = '';
7105 $retstringbuttom = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
"';
7106 $base = DOL_URL_ROOT . '/core/';
7107 $retstringbuttom .= ' onClick="showDP(\
'' . $base .
'\',\
'' . $prefix .
'\',\
'' . $langs->trans(
"FormatDateShortJavaInput") .
'\',\
'' . $langs->defaultlang .
'\');
"';
7108 $retstringbuttom .= '>' . img_object($langs->trans("SelectDate
"), 'calendarday', 'class="datecallink
"') . '</button>';
7110 $retstringbuttom = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
">' . img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"') . '</button>';
7112 $retstring = $retstringbuttom . $retstring;
7114 $retstring .= '<input type="hidden
" id="' . $prefix . 'day
" name="' . $prefix . 'day
" value="' . $sday . '">' . "\n
";
7115 $retstring .= '<input type="hidden
" id="' . $prefix . 'month
" name="' . $prefix . 'month
" value="' . $smonth . '">' . "\n
";
7116 $retstring .= '<input type="hidden
" id="' . $prefix . 'year
" name="' . $prefix . 'year
" value="' . $syear . '">' . "\n
";
7117 } elseif ($usecalendar == 'jquery' || $usecalendar == 'html') {
7118 if (!$disabled && $usecalendar != 'html') {
7119 // Output javascript for datepicker
7120 $minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (idate('Y') - 100));
7121 $maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (idate('Y') + 100));
7123 $retstring .= '<script nonce="' . getNonce() . '" type="text/javascript
">';
7124 $retstring .= "$(
function(){ $(
'#" . $prefix . "').datepicker({
7125 dateFormat:
'" . $langs->trans("FormatDateShortJQueryInput") . "',
7127 todayHighlight:
true,
7128 yearRange:
'" . $minYear . ":" . $maxYear . "',
";
7129 if (!empty($conf->dol_use_jmobile)) {
7131 beforeShow:
function (input, datePicker) {
7132 input.disabled =
true;
7134 onClose:
function (dateText, datePicker) {
7139 // Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php
7140 if (!getDolGlobalString('MAIN_POPUP_CALENDAR_ON_FOCUS')) {
7143 buttonImage:
'" . DOL_URL_ROOT . "/theme/" . dol_escape_js($conf->theme) . "/img/object_calendarday.png',
7144 buttonImageOnly:
true";
7148 $retstring .= "</script>
";
7151 // Input area to enter date manually
7152 $retstring .= '<div class="nowraponall
inline-block divfordateinput
">';
7153 $retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text
" class="maxwidthdate center
" maxlength="11
" value="'.$formatted_date.'"';
7154 $retstring .= ($disabled ? ' disabled' : '');
7155 $retstring .= ($placeholder ? ' placeholder="' . dol_escape_htmltag($placeholder) . '"' : '');
7156 $retstring .= ' onChange="dpChangeDay(\
'' .
dol_escape_js($prefix) .
'\',\
'' .
dol_escape_js($langs->trans(
"FormatDateShortJavaInput")) .
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
7157 $retstring .= ' autocomplete="off
">';
7161 $retstringbutton = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
">' . img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"') . '</button>';
7162 $retstring = $retstringbutton . $retstring;
7165 $retstring .= '</div>';
7166 $retstring .= '<input type="hidden
" id="' . $prefix . 'day
" name="' . $prefix . 'day
" value="' . $sday . '">' . "\n
";
7167 $retstring .= '<input type="hidden
" id="' . $prefix . 'month
" name="' . $prefix . 'month
" value="' . $smonth . '">' . "\n
";
7168 $retstring .= '<input type="hidden
" id="' . $prefix . 'year
" name="' . $prefix . 'year
" value="' . $syear . '">' . "\n
";
7170 $retstring .= "Bad value of MAIN_POPUP_CALENDAR
";
7173 // Show date with combo selects
7175 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50imp
" id="' . $prefix . 'day
" name="' . $prefix . 'day
">';
7177 if ($emptydate || $set_time == -1) {
7178 $retstring .= '<option value="0
" selected> </option>';
7181 for ($day = 1; $day <= 31; $day++) {
7182 $retstring .= '<option value="' . $day . '"' . ($day == $sday ? ' selected' : '') . '>' . $day . '</option>';
7185 $retstring .= "</select>
";
7187 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp
" id="' . $prefix . 'month
" name="' . $prefix . 'month
">';
7188 if ($emptydate || $set_time == -1) {
7189 $retstring .= '<option value="0
" selected> </option>';
7193 for ($month = 1; $month <= 12; $month++) {
7194 $retstring .= '<option value="' . $month . '"' . ($month == $smonth ? ' selected' : '') . '>';
7195 $retstring .= dol_print_date(mktime(12, 0, 0, $month, 1, 2000), "%b
");
7196 $retstring .= "</option>
";
7198 $retstring .= "</select>
";
7201 if ($emptydate || $set_time == -1) {
7202 $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 . '">';
7204 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp
" id="' . $prefix . 'year
" name="' . $prefix . 'year
">';
7206 $syear = (int) $syear;
7207 for ($year = $syear - 10; $year < (int) $syear + 10; $year++) {
7208 $retstring .= '<option value="' . $year . '"' . ($year == $syear ? ' selected' : '') . '>' . $year . '</option>';
7210 $retstring .= "</select>\n
";
7216 $retstring .= (($h == 2 || $h == 4) ? '<br>' : ' ');
7217 $retstring .= '<span class="nowraponall
">';
7223 if ($openinghours != '') {
7224 $openinghours = explode(',', $openinghours);
7225 $hourstart = $openinghours[0];
7226 $hourend = $openinghours[1];
7227 if ($hourend < $hourstart) {
7228 $hourend = $hourstart;
7232 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50
' . ($fullday ? $fullday . 'hour
' : '') . '" id="' . $prefix . 'hour
" name="' . $prefix . 'hour
">';
7234 $retstring .= '<option value="-1
"> </option>';
7236 for ($hour = $hourstart; $hour < $hourend; $hour++) {
7237 if (strlen($hour) < 2) {
7238 $hour = "0
" . $hour;
7240 $retstring .= '<option value="' . $hour . '"' . (($hour == $shour) ? ' selected' : '') . '>' . $hour;
7241 //$retstring .= (empty($conf->dol_optimize_smallscreen) ? '' : 'H');
7242 $retstring .= '</option>';
7244 $retstring .= '</select>';
7245 //if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":
";
7253 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50
' . ($fullday ? $fullday . 'min
' : '') . '" id="' . $prefix . 'min
" name="' . $prefix . 'min
">';
7255 $retstring .= '<option value="-1
"> </option>';
7257 for ($min = 0; $min < 60; $min += $stepminutes) {
7258 $min_str = sprintf("%02d
", $min);
7259 $retstring .= '<option value="' . $min_str . '"' . (($min_str == $smin) ? ' selected' : '') . '>' . $min_str . '</option>';
7261 $retstring .= '</select>';
7263 $retstring .= '<input type="hidden
" name="' . $prefix . 'sec
" value="' . $ssec . '">';
7267 $retstring .= '</span>';
7271 if (!empty($conf->use_javascript_ajax) && $addnowlink) {
7272 // Script which will be inserted in the onClick of the "Now
" link
7273 $reset_scripts = "";
7274 if ($addnowlink == 2) { // local computer time
7275 // pad add leading 0 on numbers
7276 $reset_scripts .= "Number.prototype.pad =
function(size) {
7277 var s = String(
this);
7278 while (s.length < (size || 2)) {s =
'0' + s;}
7281 var d =
new Date();
";
7284 // Generate the date part, depending on the use or not of the javascript calendar
7285 if ($addnowlink == 1) { // server time expressed in user time setup
7286 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'day', 'tzuserrel') . '\');';
7287 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
7288 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
7289 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
7290 } elseif ($addnowlink == 2) {
7291 /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix.
7292 * This break application for foreign languages.
7293 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));';
7294 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());';
7295 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);';
7296 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());';
7298 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'day', 'tzuserrel') . '\');';
7299 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
7300 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
7301 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
7303 /*if ($usecalendar == "eldy
")
7305 $base=DOL_URL_ROOT.'/core/';
7306 $reset_scripts .= 'resetDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput
").'\',\''.$langs->defaultlang.'\');';
7310 $reset_scripts .= 'this.form.elements[\''.$prefix.'day\'].value=formatDate(new Date(), \'d\'); ';
7311 $reset_scripts .= 'this.form.elements[\''.$prefix.'month\'].value=formatDate(new Date(), \'M\'); ';
7312 $reset_scripts .= 'this.form.elements[\''.$prefix.'year\'].value=formatDate(new Date(), \'yyyy\'); ';
7314 // Update the hour part
7317 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7319 //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); ';
7320 if ($addnowlink == 1) {
7321 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date($nowgmt, '%H', 'tzuserrel') . '\');';
7322 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').change();';
7323 } elseif ($addnowlink == 2) {
7324 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(d.getHours().pad());';
7325 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').change();';
7329 $reset_scripts .= ' } ';
7332 // Update the minute part
7335 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7337 //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); ';
7338 if ($addnowlink == 1) {
7339 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date($nowgmt, '%M', 'tzuserrel') . '\');';
7340 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').change();';
7341 } elseif ($addnowlink == 2) {
7342 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(d.getMinutes().pad());';
7343 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').change();';
7346 $reset_scripts .= ' } ';
7349 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
7350 if ($reset_scripts && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
7351 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="' . $prefix . 'ButtonNow
" type="button" name="_useless
" value="now
" onClick="' . $reset_scripts . '">';
7352 $retstring .= $langs->trans("Now
");
7353 $retstring .= '</button> ';
7357 // Add a "Plus one hour
" link
7358 if ($conf->use_javascript_ajax && $addplusone) {
7359 // Script which will be inserted in the onClick of the "Add plusone
" link
7360 $reset_scripts = "";
7362 // Generate the date part, depending on the use or not of the javascript calendar
7363 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'dayinputnoreduce', 'tzuserrel') . '\');';
7364 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
7365 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
7366 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
7367 // Update the hour part
7370 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7372 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date($nowgmt, '%H', 'tzuserrel') . '\');';
7374 $reset_scripts .= ' } ';
7377 // Update the minute part
7380 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7382 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date($nowgmt, '%M', 'tzuserrel') . '\');';
7384 $reset_scripts .= ' } ';
7387 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
7388 if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
7389 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="' . $prefix . 'ButtonPlusOne
" type="button" name="_useless2
" value="plusone
" onClick="' . $reset_scripts . '">';
7390 $retstring .= $langs->trans("DateStartPlusOne
");
7391 $retstring .= '</button> ';
7395 // Add a link to set data
7396 if ($conf->use_javascript_ajax && !empty($adddateof)) {
7397 if (!is_array($adddateof)) {
7398 $arrayofdateof = array(array('adddateof' => $adddateof, 'labeladddateof' => $labeladddateof));
7400 $arrayofdateof = $adddateof;
7402 foreach ($arrayofdateof as $valuedateof) {
7403 $tmpadddateof = empty($valuedateof['adddateof']) ? 0 : $valuedateof['adddateof'];
7404 $tmplabeladddateof = empty($valuedateof['labeladddateof']) ? '' : $valuedateof['labeladddateof'];
7405 $tmparray = dol_getdate($tmpadddateof);
7406 if (empty($tmplabeladddateof)) {
7407 $tmplabeladddateof = $langs->trans("DateInvoice
");
7409 $reset_scripts = 'console.log(\'Click on now link\'); ';
7410 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($tmpadddateof, 'dayinputnoreduce').'\');';
7411 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.$tmparray['mday'].'\');';
7412 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.$tmparray['mon'].'\');';
7413 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.$tmparray['year'].'\');';
7414 $retstring .= ' - <button class="dpInvisibleButtons datenowlink
" id="dateofinvoice
" type="button" name="_dateofinvoice
" value="now
" onclick="'.$reset_scripts.'">'.$tmplabeladddateof.'</button>';
7429 public function selectTypeDuration($prefix, $selected = 'i', $excludetypes = array())
7433 $TDurationTypes = array(
7434 'y' => $langs->trans('Years'),
7435 'm' => $langs->trans('Month'),
7436 'w' => $langs->trans('Weeks'),
7437 'd' => $langs->trans('Days'),
7438 'h' => $langs->trans('Hours'),
7439 'i' => $langs->trans('Minutes')
7442 // Removed undesired duration types
7443 foreach ($excludetypes as $value) {
7444 unset($TDurationTypes[$value]);
7447 $retstring = '<select class="flat minwidth75 maxwidth100
" id="select_
' . $prefix . 'type_duration
" name="' . $prefix . 'type_duration
">';
7448 foreach ($TDurationTypes as $key => $typeduration) {
7449 $retstring .= '<option value="' . $key . '"';
7450 if ($key == $selected) {
7451 $retstring .= " selected
";
7453 $retstring .= ">
" . $typeduration . "</option>
";
7455 $retstring .= "</select>
";
7457 $retstring .= ajax_combobox('select_' . $prefix . 'type_duration');
7462 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
7477 public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0)
7482 $retstring = '<span class="nowraponall
">';
7488 if ($iSecond != '') {
7489 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
7491 $hourSelected = convertSecondToTime($iSecond, 'allhour');
7492 $minSelected = convertSecondToTime($iSecond, 'min');
7495 if ($typehour == 'select') {
7496 $retstring .= '<select class="flat
" id="select_
' . $prefix . 'hour
" name="' . $prefix . 'hour
"' . ($disabled ? ' disabled' : '') . '>';
7497 for ($hour = 0; $hour < 25; $hour++) { // For a duration, we allow 24 hours
7498 $retstring .= '<option value="' . $hour . '"';
7499 if (is_numeric($hourSelected) && $hourSelected == $hour) {
7500 $retstring .= " selected
";
7502 $retstring .= ">
" . $hour . "</option>
";
7504 $retstring .= "</select>
";
7505 } elseif ($typehour == 'text' || $typehour == 'textselect') {
7506 $retstring .= '<input placeholder="' . $langs->trans('HourShort
') . '" type="number
" min="0
" name="' . $prefix . 'hour
"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputhour right
" value="' . (($hourSelected != '') ? ((int) $hourSelected) : '') . '">';
7508 return 'BadValueForParameterTypeHour';
7511 if ($typehour != 'text') {
7512 $retstring .= ' ' . $langs->trans('HourShort');
7514 $retstring .= '<span class="">:</span>';
7518 if ($minunderhours) {
7519 $retstring .= '<br>';
7521 if ($typehour != 'text') {
7522 $retstring .= '<span class="hideonsmartphone
"> </span>';
7526 if ($typehour == 'select' || $typehour == 'textselect') {
7527 $retstring .= '<select class="flat
" id="select_
' . $prefix . 'min
" name="' . $prefix . 'min
"' . ($disabled ? ' disabled' : '') . '>';
7528 for ($min = 0; $min <= 55; $min += 5) {
7529 $retstring .= '<option value="' . $min . '"';
7530 if (is_numeric($minSelected) && $minSelected == $min) {
7531 $retstring .= ' selected';
7533 $retstring .= '>' . $min . '</option>';
7535 $retstring .= "</select>
";
7536 } elseif ($typehour == 'text') {
7537 $retstring .= '<input placeholder="' . $langs->trans('MinuteShort
') . '" type="number
" min="0
" name="' . $prefix . 'min
"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputminute right
" value="' . (($minSelected != '') ? ((int) $minSelected) : '') . '">';
7540 if ($typehour != 'text') {
7541 $retstring .= ' ' . $langs->trans('MinuteShort');
7544 $retstring .= "</span>
";
7546 if (!empty($nooutput)) {
7574 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)
7576 global $langs, $conf;
7581 if (is_null($ajaxoptions)) {
7582 $ajaxoptions = array();
7585 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
7588 if ($selected && empty($selected_input_value)) {
7589 require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
7590 $tickettmpselect = new Ticket($this->db);
7591 $tickettmpselect->fetch($selected);
7592 $selected_input_value = $tickettmpselect->ref;
7593 unset($tickettmpselect);
7597 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/ticket/ajax/tickets.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7599 if (empty($hidelabel)) {
7600 $out .= $langs->trans("RefOrLabel
") . ' : ';
7601 } elseif ($hidelabel > 1) {
7602 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
7603 if ($hidelabel == 2) {
7604 $out .= img_picto($langs->trans("Search
"), 'search');
7607 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (getDolGlobalString('PRODUCT_SEARCH_AUTOFOCUS') ? 'autofocus' : '') . ' />';
7608 if ($hidelabel == 3) {
7609 $out .= img_picto($langs->trans("Search
"), 'search');
7612 $out .= $this->selectTicketsList($selected, $htmlname, $filtertype, $limit, '', $status, 0, $showempty, $forcecombo, $morecss);
7615 if (empty($nooutput)) {
7640 public function selectTicketsList($selected = '', $htmlname = 'ticketid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7642 global $langs, $conf;
7645 $outarray = array();
7647 $selectFields = " p.rowid, p.ref, p.message
";
7650 $sql .= $selectFields;
7651 $sql .= " FROM
" . $this->db->prefix() . "ticket as p
";
7652 $sql .= ' WHERE p.entity IN (' . getEntity('ticket') . ')';
7654 // Add criteria on ref/label
7655 if ($filterkey != '') {
7657 $prefix = !getDolGlobalString('TICKET_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7658 // For natural search
7659 $search_crit = explode(' ', $filterkey);
7661 if (count($search_crit) > 1) {
7664 foreach ($search_crit as $crit) {
7668 $sql .= "(p.ref LIKE
'" . $this->db->escape($prefix . $crit) . "%' OR p.subject LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
7672 if (count($search_crit) > 1) {
7678 $sql .= $this->db->plimit($limit, 0);
7680 // Build output string
7682 $result = $this->db->query($sql);
7684 require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
7685 require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php';
7687 $num = $this->db->num_rows($result);
7692 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
7693 $out .= ajax_combobox($htmlname, $events, $conf->global->TICKET_USE_SEARCH_TO_SELECT);
7696 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
7699 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7700 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7701 if (getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
7702 if ($showempty && !is_numeric($showempty)) {
7703 $textifempty = $langs->trans($showempty);
7705 $textifempty .= $langs->trans("All
");
7708 if ($showempty && !is_numeric($showempty)) {
7709 $textifempty = $langs->trans($showempty);
7713 $out .= '<option value="0
" selected>' . $textifempty . '</option>';
7717 while ($num && $i < $num) {
7720 $objp = $this->db->fetch_object($result);
7722 $this->constructTicketListOption($objp, $opt, $optJson, $selected, $filterkey);
7724 // "key
" value of json key array is used by jQuery automatically as selected value
7725 // "label
" value of json key array is used by jQuery automatically as text for combo box
7727 array_push($outarray, $optJson);
7732 $out .= '</select>';
7734 $this->db->free($result);
7736 if (empty($outputmode)) {
7741 dol_print_error($this->db);
7758 protected function constructTicketListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7764 $outkey = $objp->rowid;
7765 $outref = $objp->ref;
7766 $outtype = $objp->fk_product_type;
7768 $opt = '<option value="
' . $objp->rowid . '"';
7769 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7772 $objRef = $objp->ref;
7773 if (!empty($filterkey) && $filterkey != '') {
7774 $objRef = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $objRef, 1);
7777 $opt .= "</option>\n
";
7778 $optJson = array('key' => $outkey, 'value' => $outref, 'type' => $outtype);
7800 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)
7802 global $langs, $conf;
7807 if (is_null($ajaxoptions)) {
7808 $ajaxoptions = array();
7811 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
7814 if ($selected && empty($selected_input_value)) {
7815 require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
7816 $projecttmpselect = new Project($this->db);
7817 $projecttmpselect->fetch($selected);
7818 $selected_input_value = $projecttmpselect->ref;
7819 unset($projecttmpselect);
7823 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/projet/ajax/projects.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7825 if (empty($hidelabel)) {
7826 $out .= $langs->trans("RefOrLabel
") . ' : ';
7827 } elseif ($hidelabel > 1) {
7828 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
7829 if ($hidelabel == 2) {
7830 $out .= img_picto($langs->trans("Search
"), 'search');
7833 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (getDolGlobalString('PRODUCT_SEARCH_AUTOFOCUS') ? 'autofocus' : '') . ' />';
7834 if ($hidelabel == 3) {
7835 $out .= img_picto($langs->trans("Search
"), 'search');
7838 $out .= $this->selectProjectsList($selected, $htmlname, $filtertype, $limit, '', $status, 0, $showempty, $forcecombo, $morecss);
7841 if (empty($nooutput)) {
7865 public function selectProjectsList($selected = '', $htmlname = 'projectid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7867 global $langs, $conf;
7870 $outarray = array();
7872 $selectFields = " p.rowid, p.ref
";
7875 $sql .= $selectFields;
7876 $sql .= " FROM
" . $this->db->prefix() . "projet as p
";
7877 $sql .= ' WHERE p.entity IN (' . getEntity('project') . ')';
7879 // Add criteria on ref/label
7880 if ($filterkey != '') {
7882 $prefix = !getDolGlobalString('TICKET_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7883 // For natural search
7884 $search_crit = explode(' ', $filterkey);
7886 if (count($search_crit) > 1) {
7889 foreach ($search_crit as $crit) {
7893 $sql .= "p.ref LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
7897 if (count($search_crit) > 1) {
7903 $sql .= $this->db->plimit($limit, 0);
7905 // Build output string
7907 $result = $this->db->query($sql);
7909 require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
7910 require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php';
7912 $num = $this->db->num_rows($result);
7917 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
7918 $out .= ajax_combobox($htmlname, $events, $conf->global->PROJECT_USE_SEARCH_TO_SELECT);
7921 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
7924 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7925 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7926 if (getDolGlobalString('PROJECT_USE_SEARCH_TO_SELECT')) {
7927 if ($showempty && !is_numeric($showempty)) {
7928 $textifempty = $langs->trans($showempty);
7930 $textifempty .= $langs->trans("All
");
7933 if ($showempty && !is_numeric($showempty)) {
7934 $textifempty = $langs->trans($showempty);
7938 $out .= '<option value="0
" selected>' . $textifempty . '</option>';
7942 while ($num && $i < $num) {
7945 $objp = $this->db->fetch_object($result);
7947 $this->constructProjectListOption($objp, $opt, $optJson, $selected, $filterkey);
7949 // "key
" value of json key array is used by jQuery automatically as selected value
7950 // "label
" value of json key array is used by jQuery automatically as text for combo box
7952 array_push($outarray, $optJson);
7957 $out .= '</select>';
7959 $this->db->free($result);
7961 if (empty($outputmode)) {
7966 dol_print_error($this->db);
7983 protected function constructProjectListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7989 $label = $objp->label;
7991 $outkey = $objp->rowid;
7992 $outref = $objp->ref;
7993 $outlabel = $objp->label;
7994 $outtype = $objp->fk_product_type;
7996 $opt = '<option value="
' . $objp->rowid . '"';
7997 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
8000 $objRef = $objp->ref;
8001 if (!empty($filterkey) && $filterkey != '') {
8002 $objRef = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $objRef, 1);
8005 $opt .= "</option>\n
";
8006 $optJson = array('key' => $outkey, 'value' => $outref, 'type' => $outtype);
8029 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)
8031 global $langs, $conf;
8036 if (is_null($ajaxoptions)) {
8037 $ajaxoptions = array();
8040 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
8043 if ($selected && empty($selected_input_value)) {
8044 require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
8045 $adherenttmpselect = new Adherent($this->db);
8046 $adherenttmpselect->fetch($selected);
8047 $selected_input_value = $adherenttmpselect->ref;
8048 unset($adherenttmpselect);
8053 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/adherents/ajax/adherents.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
8055 if (empty($hidelabel)) {
8056 $out .= $langs->trans("RefOrLabel
") . ' : ';
8057 } elseif ($hidelabel > 1) {
8058 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
8059 if ($hidelabel == 2) {
8060 $out .= img_picto($langs->trans("Search
"), 'search');
8063 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (getDolGlobalString('PRODUCT_SEARCH_AUTOFOCUS') ? 'autofocus' : '') . ' />';
8064 if ($hidelabel == 3) {
8065 $out .= img_picto($langs->trans("Search
"), 'search');
8070 $out .= $this->selectMembersList($selected, $htmlname, $filtertype, $limit, $filterkey, $status, 0, $showempty, $forcecombo, $morecss);
8073 if (empty($nooutput)) {
8097 public function selectMembersList($selected = '', $htmlname = 'adherentid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
8099 global $langs, $conf;
8102 $outarray = array();
8104 $selectFields = " p.rowid, p.ref, p.firstname, p.lastname, p.fk_adherent_type
";
8107 $sql .= $selectFields;
8108 $sql .= " FROM
" . $this->db->prefix() . "adherent as p
";
8109 $sql .= ' WHERE p.entity IN (' . getEntity('adherent') . ')';
8111 // Add criteria on ref/label
8112 if ($filterkey != '') {
8114 $prefix = !getDolGlobalString('MEMBER_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
8115 // For natural search
8116 $search_crit = explode(' ', $filterkey);
8118 if (count($search_crit) > 1) {
8121 foreach ($search_crit as $crit) {
8125 $sql .= "(p.firstname LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
8126 $sql .= " OR p.lastname LIKE
'" . $this->db->escape($prefix . $crit) . "%')
";
8129 if (count($search_crit) > 1) {
8134 if ($status != -1) {
8135 $sql .= ' AND statut = ' . ((int) $status);
8137 $sql .= $this->db->plimit($limit, 0);
8139 // Build output string
8141 $result = $this->db->query($sql);
8143 require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
8144 require_once DOL_DOCUMENT_ROOT . '/core/lib/member.lib.php';
8146 $num = $this->db->num_rows($result);
8151 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
8152 $out .= ajax_combobox($htmlname, $events, getDolGlobalString('PROJECT_USE_SEARCH_TO_SELECT') ? $conf->global->PROJECT_USE_SEARCH_TO_SELECT : '');
8155 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
8158 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
8159 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
8160 if (getDolGlobalString('PROJECT_USE_SEARCH_TO_SELECT')) {
8161 if ($showempty && !is_numeric($showempty)) {
8162 $textifempty = $langs->trans($showempty);
8164 $textifempty .= $langs->trans("All
");
8167 if ($showempty && !is_numeric($showempty)) {
8168 $textifempty = $langs->trans($showempty);
8172 $out .= '<option value="-1
" selected>' . $textifempty . '</option>';
8176 while ($num && $i < $num) {
8179 $objp = $this->db->fetch_object($result);
8181 $this->constructMemberListOption($objp, $opt, $optJson, $selected, $filterkey);
8184 // "key
" value of json key array is used by jQuery automatically as selected value
8185 // "label
" value of json key array is used by jQuery automatically as text for combo box
8187 array_push($outarray, $optJson);
8192 $out .= '</select>';
8194 $this->db->free($result);
8196 if (empty($outputmode)) {
8201 dol_print_error($this->db);
8218 protected function constructMemberListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
8224 $outkey = $objp->rowid;
8225 $outlabel = dolGetFirstLastname($objp->firstname, $objp->lastname);
8226 $outtype = $objp->fk_adherent_type;
8228 $opt = '<option value="
' . $objp->rowid . '"';
8229 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
8231 if (!empty($filterkey) && $filterkey != '') {
8232 $outlabel = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $outlabel, 1);
8235 $opt .= "</option>\n
";
8237 $optJson = array('key' => $outkey, 'value' => $outlabel, 'type' => $outtype);
8260 public function selectForForms($objectdesc, $htmlname, $preSelectedValue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '', $objectfield = '')
8262 global $conf, $extrafields, $user;
8264 // Example of common usage for a link to a thirdparty
8266 // We got this in a modulebuilder form of "
MyObject" of module "mymodule
".
8267 // ->fields is array( ... "fk_soc
" => array("type"=>"integer:
Societe:societe/class/societe.class.php:1:((
status:=:1) AND (entity:IN:__SHARED_ENTITIES__))
" ...)
8268 // $objectdesc = 'Societe'
8269 // $objectfield = 'myobject@mymodule:fk_soc' ('fk_soc' is code to retrieve myobject->fields['fk_soc'])
8271 // We got this when showing an extrafields on resource that is a link to societe
8272 // extrafields 'link_to_societe' of Resource is 'link' to 'Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))" ...)
'
8274 // $objectfield = 'resource:options_link_to_societe
'
8277 // $objectdesc = 'Societe:societe/class/societe.class.php:1:((
status:=:1) AND (entity:IN:__SHARED_ENTITIES__))
'
8278 // $objectfield = ''
8280 //var_dump($objectdesc.' '.$objectfield);
8281 //debug_print_backtrace();
8283 $objectdescorig = $objectdesc;
8285 $InfoFieldList = array();
8287 $filter = ''; // Ensure filter has value (for static analysis)
8288 $sortfield = ''; // Ensure filter has value (for static analysis)
8290 if ($objectfield) { // We must retrieve the objectdesc from the field or extrafield
8291 // Example: $objectfield = 'product:options_package
' or 'myobject@mymodule:options_myfield
'
8292 $tmparray = explode(':
', $objectfield);
8294 // Get instance of object from $element
8295 $objectforfieldstmp = fetchObjectByElement(0, strtolower($tmparray[0]));
8297 if (is_object($objectforfieldstmp)) {
8301 if (preg_match('/^options_(.*)$/
', $tmparray[1], $reg)) {
8302 // For a property in extrafields
8304 // fetch optionals attributes and labels
8305 $extrafields->fetch_name_optionals_label($objectforfieldstmp->table_element);
8307 if (!empty($extrafields->attributes[$objectforfieldstmp->table_element]['type'][$key]) && $extrafields->attributes[$objectforfieldstmp->table_element]['type'][$key] == 'link
') {
8308 if (!empty($extrafields->attributes[$objectforfieldstmp->table_element]['param
'][$key]['options
'])) {
8309 $tmpextrafields = array_keys($extrafields->attributes[$objectforfieldstmp->table_element]['param
'][$key]['options
']);
8310 $objectdesc = $tmpextrafields[0];
8314 // For a property in ->fields
8315 if (array_key_exists($tmparray[1], $objectforfieldstmp->fields)) {
8316 $objectdesc = $objectforfieldstmp->fields[$tmparray[1]]['type'];
8317 $objectdesc = preg_replace('/^integer[^:]*:/
', '', $objectdesc);
8324 // Example of value for $objectdesc:
8325 // Bom:bom/class/bom.class.php:0:t.status=1
8326 // Bom:bom/class/bom.class.php:0:t.status=1:ref
8327 // Bom:bom/class/bom.class.php:0:(t.status:=:1) OR (t.field2:=:2):ref
8328 $InfoFieldList = explode(":", $objectdesc, 4);
8329 $vartmp = (empty($InfoFieldList[3]) ? '' : $InfoFieldList[3]);
8331 if (preg_match('/^.*:(\w*)$/
', $vartmp, $reg)) {
8332 $InfoFieldList[4] = $reg[1]; // take the sort field
8334 $InfoFieldList[3] = preg_replace('/:\w*$/
', '', $vartmp); // take the filter field
8336 $classname = $InfoFieldList[0];
8337 $classpath = empty($InfoFieldList[1]) ? '' : $InfoFieldList[1];
8338 //$addcreatebuttonornot = empty($InfoFieldList[2]) ? 0 : $InfoFieldList[2];
8339 $filter = empty($InfoFieldList[3]) ? '' : $InfoFieldList[3];
8340 $sortfield = empty($InfoFieldList[4]) ? '' : $InfoFieldList[4];
8342 // Load object according to $id and $element
8343 $objecttmp = fetchObjectByElement(0, strtolower($InfoFieldList[0]));
8345 // Fallback to another solution to get $objecttmp
8346 if (empty($objecttmp) && !empty($classpath)) {
8347 dol_include_once($classpath);
8349 if ($classname && class_exists($classname)) {
8350 $objecttmp = new $classname($this->db);
8355 // Make some replacement in $filter. May not be used if we used the ajax mode with $objectfield. In such a case
8356 // we propagate the $objectfield and not the filter and replacement is done by the ajax/selectobject.php component.
8357 $sharedentities = (is_object($objecttmp) && property_exists($objecttmp, 'element
')) ? getEntity($objecttmp->element) : strtolower($classname);
8358 $filter = str_replace(
8359 array('__ENTITY__
', '__SHARED_ENTITIES__
', '__USER_ID__
'),
8360 array($conf->entity, $sharedentities, $user->id),
8364 if (!is_object($objecttmp)) {
8365 dol_syslog('selectForForms: Error bad setup of field objectdescorig=
' . $objectdescorig.', objectfield=
'.$objectfield.', objectdesc=
'.$objectdesc, LOG_WARNING);
8366 return 'selectForForms: Error bad setup of field objectdescorig=
' . $objectdescorig.', objectfield=
'.$objectfield.', objectdesc=
'.$objectdesc;
8370 //var_dump($filter);
8371 $prefixforautocompletemode = $objecttmp->element;
8372 if ($prefixforautocompletemode == 'societe
') {
8373 $prefixforautocompletemode = 'company
';
8375 if ($prefixforautocompletemode == 'product
') {
8376 $prefixforautocompletemode = 'produit
';
8378 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT
'; // For example COMPANY_USE_SEARCH_TO_SELECT
8380 dol_syslog(get_class($this) . "::selectForForms filter=" . $filter, LOG_DEBUG);
8382 // Generate the combo HTML component
8384 if (!empty($conf->use_javascript_ajax) && getDolGlobalString($confkeyforautocompletemode) && !$forcecombo) {
8385 // No immediate load of all database
8388 if ($preSelectedValue && empty($selected_input_value)) {
8389 $objecttmp->fetch($preSelectedValue);
8390 $selected_input_value = ($prefixforautocompletemode == 'company
' ? $objecttmp->name : $objecttmp->ref);
8392 $oldValueForShowOnCombobox = 0;
8393 foreach ($objecttmp->fields as $fieldK => $fielV) {
8394 if (!array_key_exists('showoncombobox
', $fielV) || !$fielV['showoncombobox
'] || empty($objecttmp->$fieldK)) {
8398 if (!$oldValueForShowOnCombobox) {
8399 $selected_input_value = '';
8402 $selected_input_value .= $oldValueForShowOnCombobox ? ' -
' : '';
8403 $selected_input_value .= $objecttmp->$fieldK;
8404 $oldValueForShowOnCombobox = empty($fielV['showoncombobox
']) ? 0 : $fielV['showoncombobox
'];
8408 // Set url and param to call to get json of the search results
8409 $urlforajaxcall = DOL_URL_ROOT . '/core/ajax/selectobject.php
';
8410 $urloption = 'htmlname=
' . urlencode($htmlname) . '&outjson=1&objectdesc=
' . urlencode($objectdescorig) . '&objectfield=
'.urlencode($objectfield) . ($sortfield ? '&sortfield=
' . urlencode($sortfield) : '');
8412 // Activate the auto complete using ajax call.
8413 $out .= ajax_autocompleter($preSelectedValue, $htmlname, $urlforajaxcall, $urloption, getDolGlobalString($confkeyforautocompletemode), 0);
8414 $out .= '<!-- force css to be higher than dialog popup --><style
type=
"text/css">.ui-autocomplete { z-index: 1010; }</style>
';
8415 $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) . '"' : '') . ' />
';
8417 // Immediate load of table record.
8418 $out .= $this->selectForFormsList($objecttmp, $htmlname, $preSelectedValue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled, $sortfield, $filter);
8445 public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '
', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0, $sortfield = '', $filter = '')
8447 global $langs, $user, $hookmanager;
8449 //print "$htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, $outputmode, $disabled";
8451 $prefixforautocompletemode = $objecttmp->element;
8452 if ($prefixforautocompletemode == 'societe
') {
8453 $prefixforautocompletemode = 'company
';
8455 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT
'; // For example COMPANY_USE_SEARCH_TO_SELECT
8457 if (!empty($objecttmp->fields)) { // For object that declare it, it is better to use declared fields (like societe, contact, ...)
8458 $tmpfieldstoshow = '';
8459 foreach ($objecttmp->fields as $key => $val) {
8460 if (! (int) dol_eval($val['enabled
'], 1, 1, '1
')) {
8463 if (!empty($val['showoncombobox
'])) {
8464 $tmpfieldstoshow .= ($tmpfieldstoshow ? ',
' : '') . 't.
' . $key;
8467 if ($tmpfieldstoshow) {
8468 $fieldstoshow = $tmpfieldstoshow;
8471 // For backward compatibility
8472 $objecttmp->fields['ref
'] = array('type' => 'varchar(30)
', 'label
' => 'Ref
', 'showoncombobox
' => 1);
8475 if (empty($fieldstoshow)) {
8476 if (isset($objecttmp->fields['ref'])) {
8477 $fieldstoshow = 't.ref
';
8479 $langs->load("errors");
8480 $this->error = $langs->trans("ErrorNoFieldWithAttributeShowoncombobox");
8481 return $langs->trans('ErrorNoFieldWithAttributeShowoncombobox
');
8486 $outarray = array();
8487 $tmparray = array();
8492 $sql = "SELECT t.rowid, " . $fieldstoshow . " FROM " . $this->db->prefix() . $objecttmp->table_element . " as t";
8493 if (!empty($objecttmp->isextrafieldmanaged)) {
8494 $sql .= " LEFT JOIN " . $this->db->prefix() . $objecttmp->table_element . "_extrafields as e ON t.rowid=e.fk_object";
8496 if (isset($objecttmp->ismultientitymanaged)) {
8497 if (!is_numeric($objecttmp->ismultientitymanaged)) {
8498 $tmparray = explode('@
', $objecttmp->ismultientitymanaged);
8499 $sql .= " INNER JOIN " . $this->db->prefix() . $tmparray[1] . " as parenttable ON parenttable.rowid = t." . $tmparray[0];
8501 if ($objecttmp->ismultientitymanaged === 'fk_soc@societe
') {
8502 if (!$user->hasRight('societe
', 'client
', 'voir
')) {
8503 $sql .= ", " . $this->db->prefix() . "societe_commerciaux as sc";
8508 // Add where from hooks
8509 $parameters = array(
8510 'object' => $objecttmp,
8511 'htmlname
' => $htmlname,
8512 'filter
' => $filter,
8513 'searchkey
' => $searchkey
8516 $reshook = $hookmanager->executeHooks('selectForFormsListWhere
', $parameters); // Note that $action and $object may have been modified by hook
8517 if (!empty($hookmanager->resPrint)) {
8518 $sql .= $hookmanager->resPrint;
8520 $sql .= " WHERE 1=1";
8521 if (isset($objecttmp->ismultientitymanaged)) {
8522 if ($objecttmp->ismultientitymanaged == 1) {
8523 $sql .= " AND t.entity IN (" . getEntity($objecttmp->table_element) . ")";
8525 if (!is_numeric($objecttmp->ismultientitymanaged)) {
8526 $sql .= " AND parenttable.entity = t." . $tmparray[0];
8528 if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
8529 if ($objecttmp->element == 'societe
') {
8530 $sql .= " AND t.rowid = " . ((int) $user->socid);
8532 $sql .= " AND t.fk_soc = " . ((int) $user->socid);
8535 if ($objecttmp->ismultientitymanaged === 'fk_soc@societe
') {
8536 if (!$user->hasRight('societe
', 'client
', 'voir
')) {
8537 $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = " . ((int) $user->id);
8541 if ($searchkey != '') {
8542 $sql .= natural_search(explode(',
', $fieldstoshow), $searchkey);
8545 if ($filter) { // Syntax example "(t.ref:like:'SO-%
') and (t.date_creation:<:'20160101
')"
8547 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
8548 if ($errormessage) {
8549 return 'Error forging a SQL request from an universal criteria:
' . $errormessage;
8553 $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow, "ASC");
8554 //$sql.=$this->db->plimit($limit, 0);
8557 // Build output string
8558 $resql = $this->db->query($sql);
8560 // Construct $out and $outarray
8561 $out .= '<select
id=
"' . $htmlname . '" class=
"flat minwidth100' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled=
"disabled"' : '') . ($moreparams ? ' ' . $moreparams : '') . ' name=
"' . $htmlname . '">
' . "\n";
8563 // Warning: Do not use textifempty = ' ' or '
' here, or search on key will search on ' key
'. Seems it is no more true with selec2 v4
8564 $textifempty = '
';
8566 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
8567 if (getDolGlobalInt($confkeyforautocompletemode)) {
8568 if ($showempty && !is_numeric($showempty)) {
8569 $textifempty = $langs->trans($showempty);
8571 $textifempty .= $langs->trans("All");
8575 $out .= '<option value=
"-1">
' . $textifempty . '</option>
' . "\n";
8578 $num = $this->db->num_rows($resql);
8582 $obj = $this->db->fetch_object($resql);
8585 $tmparray = explode(',
', $fieldstoshow);
8586 $oldvalueforshowoncombobox = 0;
8587 foreach ($tmparray as $key => $val) {
8588 $val = preg_replace('/t\./
', '', $val);
8589 $label .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val]['showoncombobox
'] ? ' -
' : ' ') : '');
8590 $labelhtml .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val]['showoncombobox
'] ? ' -
' : ' ') : '');
8591 $label .= $obj->$val;
8592 $labelhtml .= $obj->$val;
8594 $oldvalueforshowoncombobox = empty($objecttmp->fields[$val]['showoncombobox
']) ? 0 : $objecttmp->fields[$val]['showoncombobox
'];
8596 if (empty($outputmode)) {
8597 if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
8598 $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>
';
8600 $out .= '<option value=
"' . $obj->rowid . '" data-html=
"' . dol_escape_htmltag($labelhtml, 0, 0, '', 0, 1) . '">
' . dol_escape_htmltag($label, 0, 0, '', 0, 1) . '</option>
';
8603 array_push($outarray, array('key
' => $obj->rowid, 'value
' => $label, 'label
' => $label));
8607 if (($i % 10) == 0) {
8613 $out .= '</select>
' . "\n";
8616 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php
';
8617 $out .= ajax_combobox($htmlname, array(), getDolGlobalInt($confkeyforautocompletemode, 0));
8620 dol_print_error($this->db);
8623 $this->result = array('nbofelement
' => $num);
8655 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)
8657 global $conf, $langs;
8659 // Do we want a multiselect ?
8661 //if (preg_match('/^multi/
',$htmlname)) $jsbeautify = 1;
8664 if ($value_as_key) {
8665 $array = array_combine($array, $array);
8668 '@phan-var-force array{label:string,data-html:string,disable?:int<0,1>,css?:
string} $array
'; // Array combine breaks information
8672 if ($addjscombo < 0) {
8673 if (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER
')) {
8679 $idname = str_replace(array('[
', ']
'), array('', ''), $htmlname);
8680 $out .= '<select
id=
"' . preg_replace('/^\./', '', $idname) . '" ' . ($disabled ? 'disabled=
"disabled" ' : '') . 'class=
"flat ' . (preg_replace('/^\./', '', $htmlname)) . ($morecss ? ' ' . $morecss : '') . ' selectformat"';
8681 $out .= ' name=
"' . preg_replace('/^\./', '', $htmlname) . '" ' . ($moreparam ? $moreparam : '');
8685 $textforempty = ' ';
8686 if (!empty($conf->use_javascript_ajax)) {
8687 $textforempty = '
'; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
8689 if (!is_numeric($show_empty)) {
8690 $textforempty = $show_empty;
8692 $out .= '<option
class=
"optiongrey" ' . ($moreparamonempty ? $moreparamonempty . ' ' : '') . 'value=
"' . (((int) $show_empty) < 0 ? $show_empty : -1) . '"' . ($id == $show_empty ? ' selected
' : '') . '>
' . $textforempty . '</option>
' . "\n";
8694 if (is_array($array)) {
8697 foreach ($array as $key => $value) {
8698 if (!is_array($value)) {
8699 $array[$key] = $langs->trans($value);
8701 $array[$key]['label
'] = $langs->trans($value['label
']);
8706 if ($sort == 'ASC
') {
8708 } elseif ($sort == 'DESC
') {
8712 foreach ($array as $key => $tmpvalue) {
8713 if (is_array($tmpvalue)) {
8714 $value = $tmpvalue['label
'];
8715 //$valuehtml = empty($tmpvalue['data-html
']) ? $value : $tmpvalue['data-html
'];
8717 $style = empty($tmpvalue['css
']) ? '' : ' class=
"' . $tmpvalue['css'] . '"';
8720 //$valuehtml = $tmpvalue;
8724 if (!empty($disablebademail)) {
8725 if (($disablebademail == 1 && !preg_match('/<.+@.+>/
', $value))
8726 || ($disablebademail == 2 && preg_match('/---/
', $value))) {
8728 $style = ' class=
"warning"';
8731 if ($key_in_label) {
8732 if (empty($nohtmlescape)) {
8733 $selectOptionValue = dol_escape_htmltag($key . ' -
' . ($maxlen ? dol_trunc($value, $maxlen) : $value));
8735 $selectOptionValue = $key . ' -
' . ($maxlen ? dol_trunc($value, $maxlen) : $value);
8738 if (empty($nohtmlescape)) {
8739 $selectOptionValue = dol_escape_htmltag($maxlen ? dol_trunc($value, $maxlen) : $value);
8741 $selectOptionValue = $maxlen ? dol_trunc($value, $maxlen) : $value;
8743 if ($value == '' || $value == '-
') {
8744 $selectOptionValue = '
';
8747 $out .= '<option value=
"' . $key . '"';
8748 $out .= $style . $disabled;
8749 if (is_array($id)) {
8750 if (in_array($key, $id) && !$disabled) {
8751 $out .= ' selected
'; // To preselect a value
8754 $id = (string) $id; // if $id = 0, then $id = '0
'
8755 if ($id != '' && (($id == (string) $key) || ($id == 'ifone
' && count($array) == 1)) && !$disabled) {
8756 $out .= ' selected
'; // To preselect a value
8759 if (!empty($nohtmlescape)) { // deprecated. Use instead the key 'data-html
' into input $array, managed at next step to use HTML content.
8760 $out .= ' data-html=
"' . dol_escape_htmltag($selectOptionValue) . '"';
8763 if (is_array($tmpvalue)) {
8764 foreach ($tmpvalue as $keyforvalue => $valueforvalue) {
8765 if (preg_match('/^data-/
', $keyforvalue)) { // The best solution if you want to use HTML values into the list is to use data-html.
8766 $out .= ' '.dol_escape_htmltag($keyforvalue).'=
"'.dol_escape_htmltag($valueforvalue).'"';
8771 $out .= $selectOptionValue;
8772 $out .= "</option>\n";
8775 $out .= "</select>";
8777 // Add code for jquery to use multiselect
8778 if ($addjscombo && $jsbeautify) {
8779 // Enhance with select2
8780 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php
';
8781 $out .= ajax_combobox($idname, array(), 0, 0, 'resolve
', (((int) $show_empty) < 0 ? (string) $show_empty : '-1
'), $morecss);
8805 public static function selectArrayAjax($htmlname, $url, $id = '
', $moreparam = '', $moreparamtourl = '', $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0)
8807 global $conf, $langs;
8808 global $delayedhtmlcontent; // Will be used later outside of this function
8810 // TODO Use an internal dolibarr component instead of select2
8811 if (!getDolGlobalString('MAIN_USE_JQUERY_MULTISELECT
') && !defined('REQUIRE_JQUERY_MULTISELECT
')) {
8815 $out = '<select
type=
"text" class=
"' . $htmlname . ($morecss ? ' ' . $morecss : '') . '" ' . ($moreparam ? $moreparam . ' ' : '') . 'name=
"' . $htmlname . '"></select>
';
8818 if (!empty($conf->use_javascript_ajax)) {
8819 $tmpplugin = 'select2
';
8820 $outdelayed = "\n" . '<!-- JS CODE TO ENABLE
' . $tmpplugin . ' for id ' . $htmlname . ' -->
8821 <script nonce=
"' . getNonce() . '">
8822 $(document).ready(
function () {
8824 ' . ($callurlonselect ? 'var saveRemoteData = [];
' : '') . '
8826 $(
".' . $htmlname . '").select2({
8829 url:
"' . $url . '",
8832 data: function (params) {
8834 q: params.term, // search term
8838 processResults: function (data) {
8839 // parse the results into the format expected by Select2.
8840 // since we are using custom formatting functions we do not need to alter the remote JSON data
8841 //console.log(data);
8842 saveRemoteData = data;
8843 /* format json result for select2 */
8845 $.each( data, function( key, value ) {
8846 result.push({id: key, text: value.text});
8848 //return {results:[{id:\'none\', text:\'aa\'}, {id:\'rrr\', text:\'Red\'},{id:\'bbb\', text:\'Search a into projects\'}], more:false}
8849 //console.log(result);
8850 return {results: result, more: false}
8854 language: select2arrayoflanguage,
8855 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
8857 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
8858 minimumInputLength: ' . ((int) $minimumInputLength) .
',
8859 formatResult: function (result, container, query, escapeMarkup) {
8860 return escapeMarkup(result.text);
8864 ' . ($callurlonselect ?
'
8865 /* Code to execute a GET when we select a value */
8866 $(".' . $htmlname .
'").change(function() {
8867 var selected = $(".' . $htmlname .
'").val();
8868 console.log("We select in selectArrayAjax the entry "+selected)
8869 $(".' . $htmlname .
'").val(""); /* reset visible combo value */
8870 $.each( saveRemoteData, function( key, value ) {
8871 if (key == selected)
8873 console.log("selectArrayAjax - Do a redirect to "+value.url)
8874 location.assign(value.url);
8883 if ($acceptdelayedhtml) {
8884 $delayedhtmlcontent .= $outdelayed;
8886 $out .= $outdelayed;
8910 public static function selectArrayFilter($htmlname, $array, $id =
'', $moreparam =
'', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss =
'', $callurlonselect = 0, $placeholder =
'', $acceptdelayedhtml = 0, $textfortitle =
'')
8912 global $conf, $langs;
8913 global $delayedhtmlcontent;
8916 if (!
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') && !defined(
'REQUIRE_JQUERY_MULTISELECT')) {
8920 $out =
'<select type="text"'.($textfortitle ?
' title="'.dol_escape_htmltag($textfortitle).
'"' :
'').
' id="'.$htmlname.
'" class="'.$htmlname.($morecss ?
' ' . $morecss :
'').
'"'.($moreparam ?
' '.$moreparam :
'').
' name="'.$htmlname.
'"><option></option></select>';
8922 $formattedarrayresult = array();
8924 foreach ($array as $key => $value) {
8927 $o->text = $value[
'text'];
8928 $o->url = $value[
'url'];
8929 $formattedarrayresult[] = $o;
8933 if (!empty($conf->use_javascript_ajax)) {
8934 $tmpplugin =
'select2';
8935 $outdelayed =
"\n" .
'<!-- JS CODE TO ENABLE ' . $tmpplugin .
' for id ' . $htmlname .
' -->
8936 <script nonce="' .
getNonce() .
'">
8937 $(document).ready(function () {
8938 var data = ' . json_encode($formattedarrayresult) .
';
8940 ' . ($callurlonselect ?
'var saveRemoteData = ' . json_encode($array) .
';' :
'') .
'
8942 $(".' . $htmlname .
'").select2({
8944 language: select2arrayoflanguage,
8945 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
8947 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
8948 minimumInputLength: ' . $minimumInputLength .
',
8949 formatResult: function (result, container, query, escapeMarkup) {
8950 return escapeMarkup(result.text);
8952 matcher: function (params, data) {
8954 if(! data.id) return null;';
8956 if ($callurlonselect) {
8960 var urlBase = data.url;
8961 var separ = urlBase.indexOf("?") >= 0 ? "&" : "?";
8962 /* console.log("params.term="+params.term); */
8963 /* console.log("params.term encoded="+encodeURIComponent(params.term)); */
8964 saveRemoteData[data.id].url = urlBase + separ + "search_all=" + encodeURIComponent(params.term.replace(/\"/g, ""));';
8967 if (!$disableFiltering) {
8970 if(data.text.match(new RegExp(params.term))) {
8985 ' . ($callurlonselect ?
'
8986 /* Code to execute a GET when we select a value */
8987 $(".' . $htmlname .
'").change(function() {
8988 var selected = $(".' . $htmlname .
'").val();
8989 console.log("We select "+selected)
8991 $(".' . $htmlname .
'").val(""); /* reset visible combo value */
8992 $.each( saveRemoteData, function( key, value ) {
8993 if (key == selected)
8995 console.log("selectArrayFilter - Do a redirect to "+value.url)
8996 location.assign(value.url);
9005 if ($acceptdelayedhtml) {
9006 $delayedhtmlcontent .= $outdelayed;
9008 $out .= $outdelayed;
9031 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)
9033 global $conf, $langs;
9037 if ($addjscombo < 0) {
9045 $useenhancedmultiselect = 0;
9046 if (!empty($conf->use_javascript_ajax) && !defined(
'MAIN_DO_NOT_USE_JQUERY_MULTISELECT') && (
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') || defined(
'REQUIRE_JQUERY_MULTISELECT'))) {
9048 $useenhancedmultiselect = 1;
9055 $out .=
'<input type="hidden" name="'.$htmlname.
'_multiselect" value="1">';
9057 $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";
9058 if (is_array($array) && !empty($array)) {
9059 if ($value_as_key) {
9060 $array = array_combine($array, $array);
9063 if (!empty($array)) {
9064 foreach ($array as $key => $value) {
9070 if (is_array($value) && array_key_exists(
'id', $value) && array_key_exists(
'label', $value)) {
9071 $tmpkey = $value[
'id'];
9072 $tmpvalue = empty($value[
'label']) ?
'' : $value[
'label'];
9073 $tmpcolor = empty($value[
'color']) ?
'' : $value[
'color'];
9074 $tmppicto = empty($value[
'picto']) ?
'' : $value[
'picto'];
9075 $tmplabelhtml = empty($value[
'labelhtml']) ? (empty($value[
'data-html']) ?
'' : $value[
'data-html']): $value[
'labelhtml'];
9077 $newval = ($translate ? $langs->trans($tmpvalue) : $tmpvalue);
9078 $newval = ($key_in_label ? $tmpkey .
' - ' . $newval : $newval);
9080 $out .=
'<option value="' . $tmpkey .
'"';
9081 if (is_array($selected) && !empty($selected) && in_array((
string) $tmpkey, $selected) && ((string) $tmpkey !=
'')) {
9082 $out .=
' selected';
9084 if (!empty($tmplabelhtml)) {
9087 $tmplabelhtml = ($tmppicto ?
img_picto(
'', $tmppicto,
'class="pictofixedwidth" style="color: #' . $tmpcolor .
'"') :
'') . $newval;
9092 $out .=
'</option>' .
"\n";
9096 $out .=
'</select>' .
"\n";
9099 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') || defined(
'REQUIRE_JQUERY_MULTISELECT')) {
9100 $out .=
"\n" .
'<!-- JS CODE TO ENABLE select for id ' . $htmlname .
', addjscombo=' . $addjscombo .
' -->';
9101 $out .=
"\n" .
'<script nonce="' .
getNonce() .
'">' .
"\n";
9102 if ($addjscombo == 1) {
9103 $tmpplugin = !
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') ? constant(
'REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
9104 $out .=
'function formatResult(record, container) {' .
"\n";
9107 $out .=
' if ($(record.element).attr("data-html") != undefined && typeof htmlEntityDecodeJs === "function") {';
9109 $out .=
' return htmlEntityDecodeJs($(record.element).attr("data-html"));';
9111 $out .=
' return record.text;';
9113 $out .=
'function formatSelection(record) {' .
"\n";
9114 if ($elemtype ==
'category') {
9115 $out .=
'return \'<span><img src="' . DOL_URL_ROOT .
'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
9117 $out .=
'return record.text;';
9120 $out .=
'$(document).ready(function () {
9121 $(\'#' . $htmlname .
'\').
' . $tmpplugin . '({
';
9129 $out .= ' dir: \
'ltr\',
9130 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag (ko with multiselect) */
9131 dropdownCssClass: \'' . $morecss .
'\',
9133 formatResult: formatResult,
9134 templateResult: formatResult,
9135 escapeMarkup:
function (markup) {
return markup; },
9137 formatSelection: formatSelection,
9138 templateSelection: formatSelection,
9139 language: select2arrayoflanguage
9144 $(\
'#' . $htmlname .
' + .select2\').addClass(\'' . $morecss .
'\');
9146 } elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT
')) {
9148 // TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
9150 $out .= 'console.log(\
'addjscombo=2 for htmlname=' . $htmlname .
'\');
';
9151 $out .= '$(document).ready(
function () {
9152 $(\
'#' . $htmlname .
'\').multiSelect({
9153 containerHTML: \
'<div class="multi-select-container">\',
9154 menuHTML: \'<div class="multi-select-menu">\',
9155 buttonHTML: \'<span class="multi-select-button ' . $morecss .
'">\',
9156 menuItemHTML: \'<label class="multi-select-menuitem">\',
9157 activeClass: \'multi-select-container--open\',
9158 noneText: \'' . $placeholder .
'\'
9162 $out .= '</script>
';
9180 public static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage, $pos = '
')
9182 global $langs, $user;
9184 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER
')) {
9187 if (empty($array)) {
9191 $tmpvar = "MAIN_SELECTEDFIELDS_" . $varpage; // To get list of saved selected fields to show
9193 if (!empty($user->conf->$tmpvar)) { // A list of fields was already customized for user
9194 $tmparray = explode(',
', $user->conf->$tmpvar);
9195 foreach ($array as $key => $val) {
9197 //var_dump($tmparray);
9198 if (in_array($key, $tmparray)) {
9199 $array[$key]['checked
'] = 1;
9201 $array[$key]['checked
'] = 0;
9204 } else { // There is no list of fields already customized for user
9205 foreach ($array as $key => $val) {
9206 if (!empty($array[$key]['checked
']) && $array[$key]['checked
'] < 0) {
9207 $array[$key]['checked
'] = 0;
9212 $listoffieldsforselection = '';
9213 $listcheckedstring = '';
9215 foreach ($array as $key => $val) {
9217 // var_dump(array_key_exists('enabled
', $val));
9218 // var_dump(!$val['enabled
']);
9219 if (array_key_exists('enabled
', $val) && isset($val['enabled
']) && !$val['enabled
']) {
9220 unset($array[$key]); // We don't want
this field
9223 if (!empty($val[
'type']) && $val[
'type'] ==
'separate') {
9228 if (!empty($val[
'label']) && $val[
'label']) {
9229 if (!empty($val[
'langfile']) && is_object($langs)) {
9230 $langs->load($val[
'langfile']);
9234 $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>';
9235 $listcheckedstring .= (empty($val[
'checked']) ?
'' : $key .
',');
9239 $out =
'<!-- Component multiSelectArrayWithCheckbox ' . $htmlname .
' -->
9241 <dl class="dropdown">
9243 <a href="#' . $htmlname .
'">
9246 <input type="hidden" class="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $listcheckedstring .
'">
9248 <dd class="dropdowndd">
9249 <div class="multiselectcheckbox'.$htmlname.
'">
9250 <ul class="'.$htmlname.($pos ==
'1' ?
'left' :
'').
'">
9251 <li><input class="inputsearch_dropdownselectedfields width90p minwidth200imp" style="width:90%;" type="text" placeholder="'.$langs->trans(
'Search').
'"></li>
9252 '.$listoffieldsforselection.
'
9258 <script nonce="' .
getNonce() .
'" type="text/javascript">
9259 jQuery(document).ready(function () {
9260 $(\'.multiselectcheckbox' . $htmlname .
' input[type="checkbox"]\').on(\'click\', function () {
9261 console.log("A new field was added/removed, we edit field input[name=formfilteraction]");
9263 $("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\'); // Update field so we know we changed something on selected fields after POST
9265 var title = $(this).val() + ",";
9266 if ($(this).is(\':checked\')) {
9267 $(\'.' . $htmlname .
'\').val(title + $(\
'.' . $htmlname .
'\').val());
9270 $(\
'.' . $htmlname .
'\').val( $(\
'.' . $htmlname .
'\').val().replace(title, \
'\') )
9275 $(
"input.inputsearch_dropdownselectedfields").on(
"keyup",
function() {
9276 var value = $(
this).val().toLowerCase();
9277 $(\
'.multiselectcheckbox'.$htmlname.
' li > label\').filter(function() {
9278 $(this).parent().toggle($(this).text().toLowerCase().indexOf(value) > -1)
9301 include_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
9304 $categories = $cat->containing($id, $type);
9306 if ($rendermode == 1) {
9308 foreach ($categories as $c) {
9309 $ways = $c->print_all_ways(
' >> ', ($nolink ?
'none' :
''), 0, 1);
9310 foreach ($ways as $way) {
9311 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' . $way .
'</li>';
9314 if (empty($toprint)) {
9317 return '<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
9321 if ($rendermode == 0) {
9322 $arrayselected = array();
9324 foreach ($categories as $c) {
9325 $arrayselected[] = $c->id;
9328 return $this->
multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'', 0,
'100%',
'disabled',
'category');
9331 return 'ErrorBadValueForParameterRenderMode';
9345 global $conf, $langs, $hookmanager;
9346 global $bc, $action;
9351 $hookmanager->initHooks(array(
'commonobject'));
9352 $parameters = array(
9353 'morehtmlright' => $morehtmlright,
9354 'compatibleImportElementsList' => &$compatibleImportElementsList,
9356 $reshook = $hookmanager->executeHooks(
'showLinkedObjectBlock', $parameters,
$object, $action);
9358 $nbofdifferenttypes = count(
$object->linkedObjects);
9360 if (empty($reshook)) {
9361 print
'<!-- showLinkedObjectBlock -->';
9362 print
load_fiche_titre($langs->trans($title), $morehtmlright,
'', 0, 0,
'showlinkedobjectblock');
9365 print
'<div class="div-table-responsive-no-min">';
9366 print
'<table class="noborder allwidth" data-block="showLinkedObject" data-element="' .
$object->element .
'" data-elementid="' .
$object->id .
'" >';
9368 print
'<tr class="liste_titre">';
9369 print
'<td>' . $langs->trans(
"Type") .
'</td>';
9370 print
'<td>' . $langs->trans(
"Ref") .
'</td>';
9371 print
'<td class="center"></td>';
9372 print
'<td class="center">' . $langs->trans(
"Date") .
'</td>';
9373 print
'<td class="right">' . $langs->trans(
"AmountHTShort") .
'</td>';
9374 print
'<td class="right">' . $langs->trans(
"Status") .
'</td>';
9378 $nboftypesoutput = 0;
9380 foreach (
$object->linkedObjects as $objecttype => $objects) {
9381 $tplpath = $element = $subelement = $objecttype;
9384 $showImportButton =
false;
9385 if (!empty($compatibleImportElementsList) && in_array($element, $compatibleImportElementsList)) {
9386 $showImportButton =
true;
9390 if ($objecttype !=
'supplier_proposal' && preg_match(
'/^([^_]+)_([^_]+)/i', $objecttype, $regs)) {
9391 $element = $regs[1];
9392 $subelement = $regs[2];
9393 $tplpath = $element .
'/' . $subelement;
9395 $tplname =
'linkedobjectblock';
9398 if ($objecttype ==
'facture') {
9399 $tplpath =
'compta/' . $element;
9400 if (!isModEnabled(
'invoice')) {
9403 } elseif ($objecttype ==
'facturerec') {
9404 $tplpath =
'compta/facture';
9405 $tplname =
'linkedobjectblockForRec';
9406 if (!isModEnabled(
'invoice')) {
9409 } elseif ($objecttype ==
'propal') {
9410 $tplpath =
'comm/' . $element;
9411 if (!isModEnabled(
'propal')) {
9414 } elseif ($objecttype ==
'supplier_proposal') {
9415 if (!isModEnabled(
'supplier_proposal')) {
9418 } elseif ($objecttype ==
'shipping' || $objecttype ==
'shipment' || $objecttype ==
'expedition') {
9419 $tplpath =
'expedition';
9420 if (!isModEnabled(
'shipping')) {
9423 } elseif ($objecttype ==
'reception') {
9424 $tplpath =
'reception';
9425 if (!isModEnabled(
'reception')) {
9428 } elseif ($objecttype ==
'delivery') {
9429 $tplpath =
'delivery';
9433 } elseif ($objecttype ==
'ficheinter') {
9434 $tplpath =
'fichinter';
9435 if (!isModEnabled(
'intervention')) {
9438 } elseif ($objecttype ==
'invoice_supplier') {
9439 $tplpath =
'fourn/facture';
9440 } elseif ($objecttype ==
'order_supplier') {
9441 $tplpath =
'fourn/commande';
9442 } elseif ($objecttype ==
'expensereport') {
9443 $tplpath =
'expensereport';
9444 } elseif ($objecttype ==
'subscription') {
9445 $tplpath =
'adherents';
9446 } elseif ($objecttype ==
'conferenceorbooth') {
9447 $tplpath =
'eventorganization';
9448 } elseif ($objecttype ==
'conferenceorboothattendee') {
9449 $tplpath =
'eventorganization';
9450 } elseif ($objecttype ==
'mo') {
9452 if (!isModEnabled(
'mrp')) {
9457 global $linkedObjectBlock;
9458 $linkedObjectBlock = $objects;
9461 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/' . $tplpath .
'/tpl'));
9462 foreach ($dirtpls as $reldir) {
9463 $reldir = rtrim($reldir,
'/');
9464 if ($nboftypesoutput == ($nbofdifferenttypes - 1)) {
9465 global $noMoreLinkedObjectBlockAfter;
9466 $noMoreLinkedObjectBlockAfter = 1;
9469 $res = @include
dol_buildpath($reldir .
'/' . $tplname .
'.tpl.php');
9477 if (!$nboftypesoutput) {
9478 print
'<tr><td class="impair" colspan="7"><span class="opacitymedium">' . $langs->trans(
"None") .
'</span></td></tr>';
9483 if (!empty($compatibleImportElementsList)) {
9484 $res = @include
dol_buildpath(
'core/tpl/objectlinked_lineimport.tpl.php');
9490 return $nbofdifferenttypes;
9503 global $conf, $langs, $hookmanager;
9507 $linktoelemlist =
'';
9508 $listofidcompanytoscan =
'';
9510 if (!is_object(
$object->thirdparty)) {
9514 $possiblelinks = array();
9515 if (is_object(
$object->thirdparty) && !empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
9516 $listofidcompanytoscan =
$object->thirdparty->id;
9518 $listofidcompanytoscan .=
',' .
$object->thirdparty->parent;
9521 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
9522 $tmpproject =
new Project($this->db);
9523 $tmpproject->fetch(
$object->fk_project);
9524 if ($tmpproject->socid > 0 && ($tmpproject->socid !=
$object->thirdparty->id)) {
9525 $listofidcompanytoscan .=
',' . $tmpproject->socid;
9530 $possiblelinks = array(
9532 'enabled' => isModEnabled(
'propal'),
9534 'label' =>
'LinkToProposal',
9535 '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') .
')'),
9536 'shipping' => array(
9537 'enabled' => isModEnabled(
'shipping'),
9539 'label' =>
'LinkToExpedition',
9540 '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') .
')'),
9542 'enabled' => isModEnabled(
'order'),
9544 'label' =>
'LinkToOrder',
9545 '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') .
')'),
9547 'enabled' => isModEnabled(
'invoice'),
9549 'label' =>
'LinkToInvoice',
9550 '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') .
')'),
9551 'invoice_template' => array(
9552 'enabled' => isModEnabled(
'invoice'),
9554 'label' =>
'LinkToTemplateInvoice',
9555 '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') .
')'),
9557 'enabled' => isModEnabled(
'contract'),
9559 'label' =>
'LinkToContract',
9560 '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
9561 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'
9563 'fichinter' => array(
9564 'enabled' => isModEnabled(
'intervention'),
9566 'label' =>
'LinkToIntervention',
9567 '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') .
')'),
9568 'supplier_proposal' => array(
9569 'enabled' => isModEnabled(
'supplier_proposal'),
9571 'label' =>
'LinkToSupplierProposal',
9572 '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') .
')'),
9573 'order_supplier' => array(
9574 'enabled' => isModEnabled(
"supplier_order"),
9576 'label' =>
'LinkToSupplierOrder',
9577 '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') .
')'),
9578 'invoice_supplier' => array(
9579 'enabled' => isModEnabled(
"supplier_invoice"),
9580 'perms' => 1,
'label' =>
'LinkToSupplierInvoice',
9581 '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') .
')'),
9583 'enabled' => isModEnabled(
'ticket'),
9585 'label' =>
'LinkToTicket',
9586 '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') .
')'),
9588 'enabled' => isModEnabled(
'mrp'),
9590 'label' =>
'LinkToMo',
9591 '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') .
')')
9595 if (
$object->table_element ==
'commande_fournisseur') {
9596 $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').
')';
9597 } elseif (
$object->table_element ==
'mrp_mo') {
9598 $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').
')';
9602 if (!empty($listofidcompanytoscan)) {
9604 $hookmanager->initHooks(array(
'commonobject'));
9605 $parameters = array(
'listofidcompanytoscan' => $listofidcompanytoscan,
'possiblelinks' => $possiblelinks);
9606 $reshook = $hookmanager->executeHooks(
'showLinkToObjectBlock', $parameters,
$object, $action);
9609 if (empty($reshook)) {
9610 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
9611 $possiblelinks = array_merge($possiblelinks, $hookmanager->resArray);
9613 } elseif ($reshook > 0) {
9614 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
9615 $possiblelinks = $hookmanager->resArray;
9619 foreach ($possiblelinks as $key => $possiblelink) {
9622 if (empty($possiblelink[
'enabled'])) {
9626 if (!empty($possiblelink[
'perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) {
9627 print
'<div id="' . $key .
'list"' . (empty($conf->use_javascript_ajax) ?
'' :
' style="display:none"') .
'>';
9631 print
'<!-- form to add a link from anywhere -->'.
"\n";
9632 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="formlinkedbyref' . $key .
'">';
9633 print
'<input type="hidden" name="id" value="' .
$object->id .
'">';
9634 print
'<input type="hidden" name="action" value="addlinkbyref">';
9635 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
9636 print
'<input type="hidden" name="addlink" value="' . $key .
'">';
9637 print
'<table class="noborder">';
9640 print
'<td class="center"><input type="text" placeholder="'.dol_escape_htmltag($langs->trans(
"Ref")).
'" name="reftolinkto" value="' .
dol_escape_htmltag(
GETPOST(
'reftolinkto',
'alpha')) .
'"> ';
9641 print
'<input type="submit" class="button small valignmiddle" value="' . $langs->trans(
'ToLink') .
'"> ';
9642 print
'<input type="submit" class="button small" name="cancel" value="' . $langs->trans(
'Cancel') .
'"></td>';
9648 $sql = $possiblelink[
'sql'];
9650 $resqllist = $this->db->query($sql);
9652 $num = $this->db->num_rows($resqllist);
9656 print
'<!-- form to add a link from object to same thirdparty -->'.
"\n";
9657 print
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="formlinked' . $key .
'">';
9658 print
'<input type="hidden" name="action" value="addlink">';
9659 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
9660 print
'<input type="hidden" name="id" value="' .
$object->id .
'">';
9661 print
'<input type="hidden" name="addlink" value="' . $key .
'">';
9662 print
'<table class="noborder">';
9663 print
'<tr class="liste_titre">';
9664 print
'<td class="nowrap"></td>';
9665 print
'<td class="center">' . $langs->trans(
"Ref") .
'</td>';
9666 print
'<td class="left">' . $langs->trans(
"RefCustomer") .
'</td>';
9667 print
'<td class="right">' . $langs->trans(
"AmountHTShort") .
'</td>';
9668 print
'<td class="left">' . $langs->trans(
"Company") .
'</td>';
9671 $objp = $this->db->fetch_object($resqllist);
9673 print
'<tr class="oddeven">';
9674 print
'<td class="left">';
9675 print
'<input type="radio" name="idtolinkto" id="' . $key .
'_' . $objp->rowid .
'" value="' . $objp->rowid .
'">';
9677 print
'<td class="center"><label for="' . $key .
'_' . $objp->rowid .
'">' . $objp->ref .
'</label></td>';
9678 print
'<td>' . (!empty($objp->ref_client) ? $objp->ref_client : (!empty($objp->ref_supplier) ? $objp->ref_supplier :
'')) .
'</td>';
9679 print
'<td class="right">';
9680 if ($possiblelink[
'label'] ==
'LinkToContract') {
9681 $form =
new Form($this->db);
9682 print $form->textwithpicto(
'', $langs->trans(
"InformationOnLinkToContract")) .
' ';
9684 print
'<span class="amount">' . (isset($objp->total_ht) ?
price($objp->total_ht) :
'') .
'</span>';
9686 print
'<td>' . $objp->name .
'</td>';
9691 print
'<div class="center">';
9693 print
'<input type="submit" class="button valignmiddle marginleftonly marginrightonly small" value="' . $langs->trans(
'ToLink') .
'">';
9695 if (empty($conf->use_javascript_ajax)) {
9696 print
'<input type="submit" class="button button-cancel marginleftonly marginrightonly small" name="cancel" value="' . $langs->trans(
"Cancel") .
'"></div>';
9698 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>';
9701 $this->db->free($resqllist);
9709 $linktoelemlist .=
'<li><a href="#linkto' . $key .
'" class="linkto dropdowncloseonclick" rel="' . $key .
'">' . $langs->trans($possiblelink[
'label']) .
' (' . $num .
')</a></li>';
9712 $linktoelemlist .=
'<li><span class="linktodisabled">' . $langs->trans($possiblelink[
'label']) .
' (0)</span></li>';
9717 if ($linktoelemlist) {
9719 <dl class="dropdown" id="linktoobjectname">
9721 if (!empty($conf->use_javascript_ajax)) {
9722 $linktoelem .=
'<dt><a href="#linktoobjectname"><span class="fas fa-link paddingrightonly"></span>' . $langs->trans(
"LinkTo") .
'...</a></dt>';
9724 $linktoelem .=
'<dd>
9725 <div class="multiselectlinkto">
9726 <ul class="ulselectedfields">' . $linktoelemlist .
'
9735 if (!empty($conf->use_javascript_ajax)) {
9736 print
'<!-- Add js to show linkto box -->
9737 <script nonce="' .
getNonce() .
'">
9738 jQuery(document).ready(function() {
9739 jQuery(".linkto").click(function() {
9740 console.log("We choose to show/hide links for rel="+jQuery(this).attr(\'rel\')+" so #"+jQuery(this).attr(\'rel\')+"list");
9741 jQuery("#"+jQuery(this).attr(\'rel\')+"list").toggle();
9765 public function selectyesno($htmlname, $value =
'', $option = 0, $disabled =
false, $useempty = 0, $addjscombo = 0, $morecss =
'', $labelyes =
'Yes', $labelno =
'No')
9776 $disabled = ($disabled ?
' disabled' :
'');
9778 $resultyesno =
'<select class="flat width75' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'"' . $disabled .
'>' .
"\n";
9780 $resultyesno .=
'<option value="-1"' . (($value < 0) ?
' selected' :
'') .
'> </option>' .
"\n";
9782 if ((
"$value" ==
'yes') || ($value == 1)) {
9783 $resultyesno .=
'<option value="' . $yes .
'" selected>' . $langs->trans($labelyes) .
'</option>' .
"\n";
9784 $resultyesno .=
'<option value="' . $no .
'">' . $langs->trans($labelno) .
'</option>' .
"\n";
9786 $selected = (($useempty && $value !=
'0' && $value !=
'no') ?
'' :
' selected');
9787 $resultyesno .=
'<option value="' . $yes .
'">' . $langs->trans($labelyes) .
'</option>' .
"\n";
9788 $resultyesno .=
'<option value="' . $no .
'"' . $selected .
'>' . $langs->trans($labelno) .
'</option>' .
"\n";
9790 $resultyesno .=
'</select>' .
"\n";
9793 $resultyesno .=
ajax_combobox($htmlname, array(), 0, 0,
'resolve', ($useempty < 0 ? (
string) $useempty :
'-1'), $morecss);
9796 return $resultyesno;
9813 $sql =
"SELECT rowid, label";
9814 $sql .=
" FROM " . $this->db->prefix() .
"export_model";
9815 $sql .=
" WHERE type = '" . $this->db->escape($type) .
"'";
9816 $sql .=
" ORDER BY rowid";
9817 $result = $this->db->query($sql);
9819 print
'<select class="flat" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
9821 print
'<option value="-1"> </option>';
9824 $num = $this->db->num_rows($result);
9827 $obj = $this->db->fetch_object($result);
9828 if ($selected == $obj->rowid) {
9829 print
'<option value="' . $obj->rowid .
'" selected>';
9831 print
'<option value="' . $obj->rowid .
'">';
9861 public function showrefnav(
$object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $morehtmlright =
'')
9863 global $conf, $langs, $hookmanager, $extralanguages;
9866 if (empty($fieldid)) {
9869 if (empty($fieldref)) {
9875 if (property_exists(
$object,
'gender') && !empty(
$object->gender)) {
9876 $addgendertxt =
' ';
9879 $addgendertxt .=
'<i class="fas fa-mars"></i>';
9882 $addgendertxt .=
'<i class="fas fa-venus"></i>';
9885 $addgendertxt .=
'<i class="fas fa-transgender"></i>';
9891 if (is_object($hookmanager)) {
9892 $parameters = array(
'showrefnav' =>
true);
9893 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object);
9894 if (!empty($hookmanager->resPrint)) {
9895 if (empty(
$object->next_prev_filter) && preg_match(
'/^\s*AND/i', $hookmanager->resPrint)) {
9896 $object->next_prev_filter = preg_replace(
'/^\s*AND\s*/i',
'', $hookmanager->resPrint);
9897 } elseif (!empty(
$object->next_prev_filter) && !preg_match(
'/^\s*AND/i', $hookmanager->resPrint)) {
9898 $object->next_prev_filter .=
' AND '.$hookmanager->resPrint;
9900 $object->next_prev_filter .= $hookmanager->resPrint;
9905 $previous_ref = $next_ref =
'';
9908 $object->load_previous_next_ref((isset(
$object->next_prev_filter) ?
$object->next_prev_filter :
''), $fieldid, $nodbprefix);
9910 $navurl = $_SERVER[
"PHP_SELF"];
9912 if ($paramid ==
'project_ref') {
9913 if (preg_match(
'/\/tasks\/(task|contact|note|document)\.php/', $navurl)) {
9914 $navurl = preg_replace(
'/\/tasks\/(task|contact|time|note|document)\.php/',
'/tasks.php', $navurl);
9921 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
9922 if ($conf->browser->name ==
'chrome') {
9923 $stringforfirstkey .=
' ALT +';
9924 } elseif ($conf->browser->name ==
'firefox') {
9925 $stringforfirstkey .=
' ALT + SHIFT +';
9927 $stringforfirstkey .=
' CTL +';
9930 $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>';
9931 $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>';
9935 $ret .=
'<!-- Start banner content --><div style="vertical-align: middle">';
9938 if ($morehtmlright) {
9939 $ret .=
'<div class="inline-block floatleft">' . $morehtmlright .
'</div>';
9942 if ($previous_ref || $next_ref || $morehtml) {
9943 $ret .=
'<div class="pagination paginationref"><ul class="right">';
9945 if ($morehtml &&
getDolGlobalInt(
'MAIN_OPTIMIZEFORTEXTBROWSER') < 2) {
9946 $ret .=
'<!-- morehtml --><li class="noborder litext' . (($shownav && $previous_ref && $next_ref) ?
' clearbothonsmartphone' :
'') .
'">' . $morehtml .
'</li>';
9948 if ($shownav && ($previous_ref || $next_ref)) {
9949 $ret .=
'<li class="pagination">' . $previous_ref .
'</li>';
9950 $ret .=
'<li class="pagination">' . $next_ref .
'</li>';
9952 if ($previous_ref || $next_ref || $morehtml) {
9953 $ret .=
'</ul></div>';
9957 $parameters = array(
'morehtmlstatus' => $morehtmlstatus);
9958 $reshook = $hookmanager->executeHooks(
'moreHtmlStatus', $parameters,
$object);
9959 if (empty($reshook)) {
9960 $morehtmlstatus .= $hookmanager->resPrint;
9962 $morehtmlstatus = $hookmanager->resPrint;
9964 if ($morehtmlstatus) {
9965 $ret .=
'<div class="statusref">' . $morehtmlstatus .
'</div>';
9968 $parameters = array();
9969 $reshook = $hookmanager->executeHooks(
'moreHtmlRef', $parameters,
$object);
9970 if (empty($reshook)) {
9971 $morehtmlref .= $hookmanager->resPrint;
9972 } elseif ($reshook > 0) {
9973 $morehtmlref = $hookmanager->resPrint;
9977 if ($morehtmlleft) {
9978 if ($conf->browser->layout ==
'phone') {
9979 $ret .=
'<!-- morehtmlleft --><div class="floatleft">' . $morehtmlleft .
'</div>';
9981 $ret .=
'<!-- morehtmlleft --><div class="inline-block floatleft">' . $morehtmlleft .
'</div>';
9986 $ret .=
'<div class="inline-block floatleft valignmiddle maxwidth750 marginbottomonly refid' . (($shownav && ($previous_ref || $next_ref)) ?
' refidpadding' :
'') .
'">';
9989 if (
$object->element ==
'societe') {
9993 $arrayoflangcode = array();
9998 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
9999 if (!is_object($extralanguages)) {
10000 include_once DOL_DOCUMENT_ROOT .
'/core/class/extralanguages.class.php';
10003 $extralanguages->fetch_name_extralanguages(
'societe');
10005 if (!empty($extralanguages->attributes[
'societe'][
'name'])) {
10006 $object->fetchValuesForExtraLanguages();
10010 foreach ($arrayoflangcode as $extralangcode) {
10012 if (
$object->array_languages[
'name'][$extralangcode]) {
10013 $htmltext .=
$object->array_languages[
'name'][$extralangcode];
10015 $htmltext .=
'<span class="opacitymedium">' . $langs->trans(
"SwitchInEditModeToAddTranslation") .
'</span>';
10018 $ret .=
'<!-- Show translations of name -->' .
"\n";
10019 $ret .= $this->
textwithpicto(
'', $htmltext, -1,
'language',
'opacitymedium paddingleft');
10022 } elseif (
$object->element ==
'member') {
10023 '@phan-var-force Adherent $object';
10024 $ret .=
$object->ref .
'<br>';
10025 $fullname =
$object->getFullName($langs);
10031 } elseif (in_array(
$object->element, array(
'contact',
'user'))) {
10033 } elseif (
$object->element ==
'usergroup') {
10035 } elseif (in_array(
$object->element, array(
'action',
'agenda'))) {
10036 '@phan-var-force ActionComm $object';
10038 } elseif (in_array(
$object->element, array(
'adherent_type'))) {
10040 } elseif (
$object->element ==
'ecm_directories') {
10042 } elseif ($fieldref !=
'none') {
10045 if ($morehtmlref) {
10047 if (substr($morehtmlref, 0, 4) !=
'<div') {
10051 $ret .= $morehtmlref;
10056 $ret .=
'</div><!-- End banner content -->';
10075 if (empty(
$object->barcode)) {
10080 if (empty(
$object->barcode_type_code) || empty(
$object->barcode_type_coder)) {
10082 $result =
$object->fetch_barcode();
10085 return '<!-- ErrorFetchBarcode -->';
10090 $url = DOL_URL_ROOT .
'/viewimage.php?modulepart=barcode&generator=' . urlencode(
$object->barcode_type_coder) .
'&code=' . urlencode(
$object->barcode) .
'&encoding=' . urlencode(
$object->barcode_type_code);
10091 $out =
'<!-- url barcode = ' . $url .
' -->';
10092 $out .=
'<img src="' . $url .
'"' . ($morecss ?
' class="' . $morecss .
'"' :
'') .
'>';
10114 public static function showphoto($modulepart,
$object, $width = 100, $height = 0, $caneditfield = 0, $cssclass =
'photowithmargin', $imagesize =
'', $addlinktofullsize = 1, $cache = 0, $forcecapture =
'', $noexternsourceoverwrite = 0)
10116 global $conf, $langs;
10118 $entity = (empty(
$object->entity) ? $conf->entity :
$object->entity);
10123 $originalfile =
'';
10127 if ($modulepart ==
'societe') {
10128 $dir = $conf->societe->multidir_output[$entity];
10131 if ((
string) $imagesize ==
'mini') {
10133 } elseif ((
string) $imagesize ==
'small') {
10142 } elseif ($modulepart ==
'contact') {
10143 $dir = $conf->societe->multidir_output[$entity] .
'/contact';
10144 if (!empty(
$object->photo)) {
10146 if ((
string) $imagesize ==
'mini') {
10148 } elseif ((
string) $imagesize ==
'small') {
10158 } elseif ($modulepart ==
'userphoto') {
10159 $dir = $conf->user->dir_output;
10160 if (!empty(
$object->photo)) {
10162 if ((
string) $imagesize ==
'mini') {
10164 } elseif ((
string) $imagesize ==
'small') {
10173 $altfile =
$object->id .
".jpg";
10177 } elseif ($modulepart ==
'memberphoto') {
10178 $dir = $conf->adherent->dir_output;
10179 if (!empty(
$object->photo)) {
10181 if ((
string) $imagesize ==
'mini') {
10183 } elseif ((
string) $imagesize ==
'small') {
10192 $altfile =
$object->id .
".jpg";
10199 if ($modulepart !=
"unknown" && method_exists(
$object,
'getDataToShowPhoto')) {
10200 $tmpdata =
$object->getDataToShowPhoto($modulepart, $imagesize);
10202 $dir = $tmpdata[
'dir'];
10203 $file = $tmpdata[
'file'];
10204 $originalfile = $tmpdata[
'originalfile'];
10205 $altfile = $tmpdata[
'altfile'];
10206 $email = $tmpdata[
'email'];
10207 $capture = $tmpdata[
'capture'];
10211 if ($forcecapture) {
10212 $capture = $forcecapture;
10218 if ($file && file_exists($dir .
"/" . $file)) {
10219 if ($addlinktofullsize) {
10221 if ($urladvanced) {
10222 $ret .=
'<a href="' . $urladvanced .
'">';
10224 $ret .=
'<a href="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($originalfile) .
'&cache=' . $cache .
'">';
10227 $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 .
'">';
10228 if ($addlinktofullsize) {
10231 } elseif ($altfile && file_exists($dir .
"/" . $altfile)) {
10232 if ($addlinktofullsize) {
10234 if ($urladvanced) {
10235 $ret .=
'<a href="' . $urladvanced .
'">';
10237 $ret .=
'<a href="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($originalfile) .
'&cache=' . $cache .
'">';
10240 $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 .
'">';
10241 if ($addlinktofullsize) {
10245 $nophoto =
'/public/theme/common/nophoto.png';
10246 $defaultimg =
'identicon';
10247 if (in_array($modulepart, array(
'societe',
'userphoto',
'contact',
'memberphoto'))) {
10248 if ($modulepart ==
'societe' || ($modulepart ==
'memberphoto' && !empty(
$object->morphy) && strpos(
$object->morphy,
'mor') !==
false)) {
10249 $nophoto =
'company';
10251 $nophoto =
'/public/theme/common/user_anonymous.png';
10253 $nophoto =
'/public/theme/common/user_man.png';
10256 $nophoto =
'/public/theme/common/user_woman.png';
10261 if (isModEnabled(
'gravatar') && $email && empty($noexternsourceoverwrite)) {
10263 $ret .=
'<!-- Put link to gravatar -->';
10264 $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 .
'">';
10266 if ($nophoto ==
'company') {
10267 $ret .=
'<div class="divforspanimg valignmiddle center photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
'>' .
img_picto(
'',
'company') .
'</div>';
10270 $ret .=
'<img class="photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
' src="' . DOL_URL_ROOT . $nophoto .
'">';
10275 if ($caneditfield) {
10279 $ret .=
'<table class="nobordernopadding centpercent">';
10281 $ret .=
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">' . $langs->trans(
"Delete") .
'</label><br><br></td></tr>';
10283 $ret .=
'<tr><td class="tdoverflow">';
10285 $maxmin = $maxfilesizearray[
'maxmin'];
10287 $ret .=
'<input type="hidden" name="MAX_FILE_SIZE" value="' . ($maxmin * 1024) .
'">';
10289 $ret .=
'<input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"' . ($capture ?
' capture="' . $capture .
'"' :
'') .
'>';
10290 $ret .=
'</td></tr>';
10291 $ret .=
'</table>';
10316 public function select_dolgroups($selected = 0, $htmlname =
'groupid', $show_empty = 0, $exclude =
'', $disabled = 0, $include =
'', $enableonly = array(), $force_entity =
'0', $multiple =
false, $morecss =
'minwidth200')
10319 global $conf, $user, $langs;
10322 $excludeGroups =
null;
10323 if (is_array($exclude)) {
10324 $excludeGroups = implode(
",", $exclude);
10327 $includeGroups =
null;
10328 if (is_array($include)) {
10329 $includeGroups = implode(
",", $include);
10332 if (!is_array($selected)) {
10333 $selected = array($selected);
10339 $sql =
"SELECT ug.rowid, ug.nom as name";
10340 if (isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
10341 $sql .=
", e.label";
10343 $sql .=
" FROM " . $this->db->prefix() .
"usergroup as ug ";
10344 if (isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
10345 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entity as e ON e.rowid=ug.entity";
10346 if ($force_entity) {
10347 $sql .=
" WHERE ug.entity IN (0, " . $force_entity .
")";
10349 $sql .=
" WHERE ug.entity IS NOT NULL";
10352 $sql .=
" WHERE ug.entity IN (0, " . $conf->entity .
")";
10354 if (is_array($exclude) && $excludeGroups) {
10355 $sql .=
" AND ug.rowid NOT IN (" . $this->db->sanitize($excludeGroups) .
")";
10357 if (is_array($include) && $includeGroups) {
10358 $sql .=
" AND ug.rowid IN (" . $this->db->sanitize($includeGroups) .
")";
10360 $sql .=
" ORDER BY ug.nom ASC";
10362 dol_syslog(get_class($this) .
"::select_dolgroups", LOG_DEBUG);
10363 $resql = $this->db->query($sql);
10366 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
10368 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
' ' . ($disabled ?
' disabled' :
'') .
'>';
10370 $num = $this->db->num_rows($resql);
10373 if ($show_empty && !$multiple) {
10374 $out .=
'<option value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'> </option>' .
"\n";
10377 while ($i < $num) {
10378 $obj = $this->db->fetch_object($resql);
10380 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
10384 $label = $obj->name;
10385 $labelhtml = $obj->name;
10386 if (isModEnabled(
'multicompany') && !
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1) {
10387 $label .=
" (" . $obj->label .
")";
10388 $labelhtml .=
' <span class="opacitymedium">(' . $obj->label .
')</span>';
10391 $out .=
'<option value="' . $obj->rowid .
'"';
10392 if ($disableline) {
10393 $out .=
' disabled';
10395 if ((isset($selected[0]) && is_object($selected[0]) && $selected[0]->
id == $obj->rowid)
10396 || ((!isset($selected[0]) || !is_object($selected[0])) && !empty($selected) && in_array($obj->rowid, $selected))) {
10397 $out .=
' selected';
10399 $out .=
' data-html="'.dol_escape_htmltag($labelhtml).
'"';
10402 $out .=
'</option>';
10407 $out .=
'<option value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'></option>' .
"\n";
10409 $out .=
'<option value="" disabled>' . $langs->trans(
"NoUserGroupDefined") .
'</option>';
10411 $out .=
'</select>';
10430 $out =
'<div class="nowraponall">';
10431 $out .=
'<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fas fa-search"></span></button>';
10432 $out .=
'<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fas fa-times"></span></button>';
10446 public function showCheckAddButtons($cssclass =
'checkforaction', $calljsfunction = 0, $massactionname =
"massaction")
10452 if (!empty($conf->use_javascript_ajax)) {
10453 $out .=
'<div class="inline-block checkallactions"><input type="checkbox" id="' . $cssclass .
's" name="' . $cssclass .
's" class="checkallactions"></div>';
10455 $out .=
'<script nonce="' .
getNonce() .
'">
10456 $(document).ready(function() {
10457 $("#' . $cssclass .
's").click(function() {
10458 if($(this).is(\':checked\')){
10459 console.log("We check all ' . $cssclass .
' and trigger the change method");
10460 $(".' . $cssclass .
'").prop(\'checked\', true).trigger(\'change\');
10464 console.log("We uncheck all");
10465 $(".' . $cssclass .
'").prop(\'checked\', false).trigger(\'change\');
10467 if ($calljsfunction) {
10468 $out .=
'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "' . $massactionname .
'", "' . $cssclass .
'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
10471 $(".' . $cssclass .
'").change(function() {
10472 $(this).closest("tr").toggleClass("highlight", this.checked);
10492 if ($addcheckuncheckall) {
10511 public function selectExpenseCategories($selected =
'', $htmlname =
'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target =
'', $default_selected = 0, $params = array(), $info_admin = 1)
10513 global $langs, $user;
10516 $sql =
"SELECT rowid, label FROM " . $this->db->prefix() .
"c_exp_tax_cat WHERE active = 1";
10517 $sql .=
" AND entity IN (0," .
getEntity(
'exp_tax_cat') .
")";
10518 if (!empty($excludeid)) {
10519 $sql .=
" AND rowid NOT IN (" . $this->db->sanitize(implode(
',', $excludeid)) .
")";
10521 $sql .=
" ORDER BY label";
10523 $resql = $this->db->query($sql);
10525 $out =
'<select id="select_' . $htmlname .
'" name="' . $htmlname .
'" class="' . $htmlname .
' flat minwidth75imp maxwidth200">';
10527 $out .=
'<option value="0"> </option>';
10530 while ($obj = $this->db->fetch_object($resql)) {
10531 $out .=
'<option ' . ($selected == $obj->rowid ?
'selected="selected"' :
'') .
' value="' . $obj->rowid .
'">' . $langs->trans($obj->label) .
'</option>';
10533 $out .=
'</select>';
10536 if (!empty($htmlname) && $user->admin && $info_admin) {
10537 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
10540 if (!empty($target)) {
10541 $sql =
"SELECT c.id FROM " . $this->db->prefix() .
"c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1";
10542 $resql = $this->db->query($sql);
10544 if ($this->db->num_rows($resql) > 0) {
10545 $obj = $this->db->fetch_object($resql);
10546 $out .=
'<script nonce="' .
getNonce() .
'">
10548 $("select[name=' . $target .
']").on("change", function() {
10549 var current_val = $(this).val();
10550 if (current_val == ' . $obj->id .
') {';
10551 if (!empty($default_selected) || !empty($selected)) {
10552 $out .=
'$("select[name=' . $htmlname .
']").val("' . ($default_selected > 0 ? $default_selected : $selected) .
'");';
10556 $("select[name=' . $htmlname .
']").change();
10560 $("select[name=' . $htmlname .
']").change(function() {
10562 if ($("select[name=' . $target .
']").val() == ' . $obj->id .
') {
10563 // get price of kilometer to fill the unit price
10567 data: { fk_c_exp_tax_cat: $(this).val(), token: \'' .
currentToken() .
'\' },
10568 url:
"' . (DOL_URL_ROOT . '/expensereport/ajax/ajaxik.php?' . implode('&', $params)) . '",
10569 }).done(
function( data, textStatus, jqXHR ) {
10571 if (typeof data.up !=
"undefined") {
10572 $(
"input[name=value_unit]").val(data.up);
10573 $(
"select[name=' . $htmlname . ']").attr(
"title", data.title);
10575 $(
"input[name=value_unit]").val(
"");
10576 $(
"select[name=' . $htmlname . ']").attr(
"title",
"");
10587 dol_print_error($this->db);
10601 public function selectExpenseRanges($selected = '
', $htmlname = 'fk_range
', $useempty = 0)
10603 global $conf, $langs;
10606 $sql = "SELECT rowid, range_ik FROM " . $this->db->prefix() . "c_exp_tax_range";
10607 $sql .= " WHERE entity = " . $conf->entity . " AND active = 1";
10609 $resql = $this->db->query($sql);
10611 $out = '<select
id=
"select_' . $htmlname . '" name=
"' . $htmlname . '" class=
"' . $htmlname . ' flat minwidth75imp">
';
10613 $out .= '<option value=
"0"></option>
';
10616 while ($obj = $this->db->fetch_object($resql)) {
10617 $out .= '<option
' . ($selected == $obj->rowid ? 'selected=
"selected"' : '') . ' value=
"' . $obj->rowid . '">
' . price($obj->range_ik, 0, $langs, 1, 0) . '</option>
';
10619 $out .= '</select>
';
10621 dol_print_error($this->db);
10637 public function selectExpense($selected = '
', $htmlname = 'fk_c_type_fees
', $useempty = 0, $allchoice = 1, $useid = 0)
10642 $sql = "SELECT id, code, label";
10643 $sql .= " FROM ".$this->db->prefix()."c_type_fees";
10644 $sql .= " WHERE active = 1";
10646 $resql = $this->db->query($sql);
10648 $out = '<select
id=
"select_' . $htmlname . '" name=
"' . $htmlname . '" class=
"' . $htmlname . ' flat minwidth75imp">
';
10650 $out .= '<option value=
"0"></option>
';
10653 $out .= '<option value=
"-1">
' . $langs->trans('AllExpenseReport
') . '</option>
';
10661 while ($obj = $this->db->fetch_object($resql)) {
10662 $key = $langs->trans($obj->code);
10663 $out .= '<option
' . ($selected == $obj->{$field} ? 'selected=
"selected"' : '') . ' value=
"' . $obj->{$field} . '">
' . ($key != $obj->code ? $key : $obj->label) . '</option>
';
10665 $out .= '</select>
';
10667 $out .= ajax_combobox('select_
'.$htmlname);
10669 dol_print_error($this->db);
10693 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)
10695 global $user, $conf, $langs;
10697 require_once DOL_DOCUMENT_ROOT . '/projet/
class/project.class.php
';
10699 if (is_null($usertofilter)) {
10700 $usertofilter = $user;
10705 $hideunselectables = false;
10706 if (getDolGlobalString('PROJECT_HIDE_UNSELECTABLES
')) {
10707 $hideunselectables = true;
10710 if (empty($projectsListId)) {
10711 if (!$usertofilter->hasRight('projet
', 'all
', 'lire
')) {
10712 $projectstatic = new Project($this->db);
10713 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
10717 // Search all projects
10718 $sql = "SELECT f.rowid, f.ref as fref, 'nolabel
' as flabel, p.rowid as pid, f.ref,
10719 p.title, p.fk_soc, p.fk_statut, p.public,";
10720 $sql .= ' s.nom as
name';
10721 $sql .= ' FROM
' . $this->db->prefix() . 'projet as p
';
10722 $sql .= ' LEFT JOIN
' . $this->db->prefix() . 'societe as s ON s.rowid = p.fk_soc,
';
10723 $sql .= ' ' . $this->db->prefix() . 'facture as f
';
10724 $sql .= " WHERE p.entity IN (" . getEntity('project
') . ")";
10725 $sql .= " AND f.fk_projet = p.rowid AND f.fk_statut=0"; //Brouillons seulement
10726 //if ($projectsListId) $sql.= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")";
10727 //if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
10728 //if ($socid > 0) $sql.= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)";
10729 $sql .= " ORDER BY p.ref, f.ref ASC";
10731 $resql = $this->db->query($sql);
10733 // Use select2 selector
10734 if (!empty($conf->use_javascript_ajax)) {
10735 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php
';
10736 $comboenhancement = ajax_combobox($htmlname, array(), 0, $forcefocus);
10737 $out .= $comboenhancement;
10738 $morecss = 'minwidth200imp maxwidth500
';
10741 if (empty($option_only)) {
10742 $out .= '<select
class=
"valignmiddle flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled=
"disabled"' : '') . ' id=
"' . $htmlname . '" name=
"' . $htmlname . '">
';
10744 if (!empty($show_empty)) {
10745 $out .= '<option value=
"0" class=
"optiongrey">
';
10746 if (!is_numeric($show_empty)) {
10747 $out .= $show_empty;
10751 $out .= '</option>
';
10753 $num = $this->db->num_rows($resql);
10756 while ($i < $num) {
10757 $obj = $this->db->fetch_object($resql);
10758 // 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.
10759 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$usertofilter->hasRight('societe
', 'lire
')) {
10762 if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED) {
10769 if ($showproject == 'all
') {
10770 $labeltoshow .= dol_trunc($obj->ref, 18); // Invoice ref
10772 $labeltoshow .= ' -
' . $obj->name; // Soc name
10776 if ($obj->fk_statut == Project::STATUS_DRAFT) {
10778 $labeltoshow .= ' -
' . $langs->trans("Draft");
10779 } elseif ($obj->fk_statut == Project::STATUS_CLOSED) {
10780 if ($discard_closed == 2) {
10783 $labeltoshow .= ' -
' . $langs->trans("Closed");
10784 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
10786 $labeltoshow .= ' -
' . $langs->trans("LinkedToAnotherCompany");
10790 if (!empty($selected) && $selected == $obj->rowid) {
10791 $out .= '<option value=
"' . $obj->rowid . '" selected
';
10792 //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected
if disabled
10793 $out .=
'>' . $labeltoshow .
'</option>';
10795 if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
10798 $resultat =
'<option value="' . $obj->rowid .
'"';
10800 $resultat .=
' disabled';
10805 $resultat .= $labeltoshow;
10806 $resultat .=
'</option>';
10814 if (empty($option_only)) {
10815 $out .=
'</select>';
10818 $this->db->free($resql);
10840 public function selectInvoiceRec($selected =
'', $htmlname =
'facrecid', $maxlength = 24, $option_only = 0, $show_empty =
'1', $forcefocus = 0, $disabled = 0, $morecss =
'maxwidth500')
10842 global $conf, $langs;
10848 $sql =
'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc';
10850 $sql .=
' FROM ' . MAIN_DB_PREFIX .
'facture_rec as f';
10851 $sql .=
" WHERE f.entity IN (" .
getEntity(
'invoice') .
")";
10852 $sql .=
" ORDER BY f.titre ASC";
10854 $resql = $this->db->query($sql);
10857 if (!empty($conf->use_javascript_ajax)) {
10858 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
10859 $comboenhancement =
ajax_combobox($htmlname, array(), 0, $forcefocus);
10860 $out .= $comboenhancement;
10861 $morecss =
'minwidth200imp maxwidth500';
10864 if (empty($option_only)) {
10865 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' id="' . $htmlname .
'" name="' . $htmlname .
'">';
10867 if (!empty($show_empty)) {
10868 $out .=
'<option value="0" class="optiongrey">';
10869 if (!is_numeric($show_empty)) {
10870 $out .= $show_empty;
10874 $out .=
'</option>';
10876 $num = $this->db->num_rows($resql);
10878 while ($obj = $this->db->fetch_object($resql)) {
10879 $labeltoshow =
dol_trunc($obj->title, 18);
10882 if (!empty($obj->suspended)) {
10884 $labeltoshow .=
' - ' . $langs->trans(
"Closed");
10888 if (!empty($selected) && $selected == $obj->rowid) {
10889 $out .=
'<option value="' . $obj->rowid .
'" selected';
10891 $out .=
'>' . $labeltoshow .
'</option>';
10893 if ($disabled && ($selected != $obj->rowid)) {
10896 $resultat =
'<option value="' . $obj->rowid .
'"';
10898 $resultat .=
' disabled';
10901 $resultat .= $labeltoshow;
10902 $resultat .=
'</option>';
10908 if (empty($option_only)) {
10909 $out .=
'</select>';
10914 $this->db->free($resql);
10917 $this->errors[] = $this->db->lasterror;
10931 public function searchComponent($arrayofcriterias, $search_component_params, $arrayofinputfieldsalreadyoutput = array(), $search_component_params_hidden =
'')
10935 if ($search_component_params_hidden !=
'' && !preg_match(
'/^\(.*\)$/', $search_component_params_hidden)) {
10936 $search_component_params_hidden =
'(' . $search_component_params_hidden .
')';
10941 $ret .=
'<div class="divadvancedsearchfieldcomp centpercent inline-block">';
10942 $ret .=
'<a href="#" class="dropdownsearch-toggle unsetcolor">';
10943 $ret .=
'<span class="fas fa-filter linkobject boxfilter paddingright pictofixedwidth" title="' .
dol_escape_htmltag($langs->trans(
"Filters")) .
'" id="idsubimgproductdistribution"></span>';
10946 $ret .=
'<div class="divadvancedsearchfieldcompinput inline-block minwidth500 maxwidth300onsmartphone">';
10949 $ret .=
'<div id="divsearch_component_params" name="divsearch_component_params" class="noborderbottom search_component_params inline-block valignmiddle">';
10951 if ($search_component_params_hidden) {
10959 foreach ($arrayofandtags as $tmpkey => $tmpval) {
10960 $errormessage =
'';
10962 if ($errormessage) {
10963 $this->error =
'ERROR in parsing search string: '.$errormessage;
10966 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
10969 $ret .=
'<span class="marginleftonlyshort valignmiddle tagsearch" data-ufilterid="'.($tmpkey + 1).
'" data-ufilter="'.
dol_escape_htmltag($tmpval).
'">';
10970 $ret .=
'<span class="tagsearchdelete select2-selection__choice__remove" data-ufilterid="'.($tmpkey + 1).
'">x</span> ';
10982 $show_search_component_params_hidden = 1;
10983 if ($show_search_component_params_hidden) {
10984 $ret .=
'<input type="hidden" name="show_search_component_params_hidden" value="1">';
10986 $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%')) -->";
10987 $ret .=
'<input type="hidden" id="search_component_params_hidden" name="search_component_params_hidden" value="' .
dol_escape_htmltag($search_component_params_hidden) .
'">';
10991 foreach ($arrayofcriterias as $criteria) {
10992 foreach ($criteria as $criteriafamilykey => $criteriafamilyval) {
10993 if (in_array(
'search_' . $criteriafamilykey, $arrayofinputfieldsalreadyoutput)) {
10996 if (in_array($criteriafamilykey, array(
'rowid',
'ref_ext',
'entity',
'extraparams'))) {
10999 if (in_array($criteriafamilyval[
'type'], array(
'date',
'datetime',
'timestamp'))) {
11000 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_start">';
11001 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startyear">';
11002 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startmonth">';
11003 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startday">';
11004 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_end">';
11005 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endyear">';
11006 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endmonth">';
11007 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endday">';
11009 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'">';
11016 $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";
11017 $ret .=
'<input type="text" placeholder="' . $langs->trans(
"Filters") .
'" id="search_component_params_input" name="search_component_params_input" class="noborderbottom search_component_input" value="">';
11023 jQuery(".tagsearchdelete").click(function(e) {
11024 var filterid = $(this).parents().attr("data-ufilterid");
11025 console.log("We click to delete the criteria nb "+filterid);
11027 // Regenerate the search_component_params_hidden with all data-ufilter except the one to delete, and post the page
11028 var newparamstring = \'\';
11029 $(\'.tagsearch\').each(function(index, element) {
11030 tmpfilterid = $(this).attr("data-ufilterid");
11031 if (tmpfilterid != filterid) {
11032 // We keep this criteria
11033 if (newparamstring == \'\') {
11034 newparamstring = $(this).attr("data-ufilter");
11036 newparamstring = newparamstring + \' AND \' + $(this).attr("data-ufilter");
11040 console.log("newparamstring = "+newparamstring);
11042 jQuery("#search_component_params_hidden").val(newparamstring);
11044 // We repost the form
11045 $(this).closest(\'form\').submit();
11048 jQuery("#search_component_params_input").keydown(function(e) {
11049 console.log("We press a key on the filter field that is "+jQuery("#search_component_params_input").val());
11050 console.log(e.which);
11051 if (jQuery("#search_component_params_input").val() == "" && e.which == 8) {
11052 /* We click on back when the input field is already empty */
11053 event.preventDefault();
11054 jQuery("#divsearch_component_params .tagsearch").last().remove();
11055 /* Regenerate content of search_component_params_hidden from remaining .tagsearch */
11057 jQuery("#divsearch_component_params .tagsearch").each(function( index ) {
11061 s = s + $(this).attr("data-ufilter");
11063 console.log("New value for search_component_params_hidden = "+s);
11064 jQuery("#search_component_params_hidden").val(s);
11085 global $langs, $user;
11089 $TModels = array();
11091 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
11092 $formmail =
new FormMail($this->db);
11093 $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs);
11096 $TModels[0] = $langs->trans(
'DefaultMailModel');
11099 foreach ($formmail->lines_model as $model) {
11100 $TModels[$model->id] = $model->label;
11104 $retstring .=
'<select class="flat" id="select_' . $prefix .
'model_mail" name="' . $prefix .
'model_mail">';
11106 foreach ($TModels as $id_model => $label_model) {
11107 $retstring .=
'<option value="' . $id_model .
'"';
11108 $retstring .=
">" . $label_model .
"</option>";
11111 $retstring .=
"</select>";
11114 $retstring .=
ajax_combobox(
'select_' . $prefix .
'model_mail');
11131 public function buttonsSaveCancel($save_label =
'Save', $cancel_label =
'Cancel', $morebuttons = array(), $withoutdiv =
false, $morecss =
'', $dol_openinpopup =
'')
11135 $buttons = array();
11139 'label_key' => $save_label,
11142 if ($save_label ==
'Create' || $save_label ==
'Add') {
11143 $save[
'name'] =
'add';
11144 } elseif ($save_label ==
'Modify') {
11145 $save[
'name'] =
'edit';
11149 'name' =>
'cancel',
11150 'label_key' =>
'Cancel',
11153 !empty($save_label) ? $buttons[] = $save :
'';
11155 if (!empty($morebuttons)) {
11156 $buttons[] = $morebuttons;
11159 !empty($cancel_label) ? $buttons[] = $cancel :
'';
11161 $retstring = $withoutdiv ?
'' :
'<div class="center">';
11163 foreach ($buttons as $button) {
11164 $addclass = empty($button[
'addclass']) ?
'' : $button[
'addclass'];
11165 $retstring .=
'<input type="submit" class="button button-' . $button[
'name'] . ($morecss ?
' ' . $morecss :
'') .
' ' . $addclass .
'" name="' . $button[
'name'] .
'" value="' .
dol_escape_htmltag($langs->trans($button[
'label_key'])) .
'">';
11167 $retstring .= $withoutdiv ?
'' :
'</div>';
11169 if ($dol_openinpopup) {
11170 $retstring .=
'<!-- buttons are shown into a $dol_openinpopup=' .
dol_escape_htmltag($dol_openinpopup) .
' context, so we enable the close of dialog on cancel -->' .
"\n";
11171 $retstring .=
'<script nonce="' .
getNonce() .
'">';
11172 $retstring .=
'jQuery(".button-cancel").click(function(e) {
11173 e.preventDefault(); console.log(\'We click on cancel in iframe popup ' .
dol_escape_js($dol_openinpopup) .
'\');
11174 window.parent.jQuery(\
'#idfordialog' .
dol_escape_js($dol_openinpopup) .
'\').dialog(\
'close\');
11176 $retstring .=
'</script>';
11195 $num = count($this->cache_invoice_subtype);
11202 $sql =
"SELECT rowid, code, label as label";
11203 $sql .=
" FROM " . MAIN_DB_PREFIX .
'c_invoice_subtype';
11204 $sql .=
" WHERE active = 1";
11206 $resql = $this->db->query($sql);
11208 $num = $this->db->num_rows($resql);
11210 while ($i < $num) {
11211 $obj = $this->db->fetch_object($resql);
11214 $label = ($langs->trans(
"InvoiceSubtype" . $obj->rowid) !=
"InvoiceSubtype" . $obj->rowid) ? $langs->trans(
"InvoiceSubtype" . $obj->rowid) : (($obj->label !=
'-') ? $obj->label :
'');
11215 $this->cache_invoice_subtype[$obj->rowid][
'rowid'] = $obj->rowid;
11216 $this->cache_invoice_subtype[$obj->rowid][
'code'] = $obj->code;
11217 $this->cache_invoice_subtype[$obj->rowid][
'label'] = $label;
11221 $this->cache_invoice_subtype =
dol_sort_array($this->cache_invoice_subtype,
'code',
'asc', 0, 0, 1);
11243 global $langs, $user;
11246 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
11250 $out .=
'<select id="' . $htmlname .
'" class="flat selectsubtype' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
11252 $out .=
'<option value="0"> </option>';
11255 foreach ($this->cache_invoice_subtype as $rowid => $subtype) {
11256 $label = $subtype[
'label'];
11257 $out .=
'<option value="' . $subtype[
'rowid'] .
'"';
11258 if ($selected == $subtype[
'rowid']) {
11259 $out .=
' selected="selected"';
11263 $out .=
'</option>';
11266 $out .=
'</select>';
11267 if ($user->admin && empty($noinfoadmin)) {
11268 $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...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
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_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.