73 public $errors = array();
84 public $cache_types_paiements = array();
86 public $cache_conditions_paiements = array();
88 public $cache_transport_mode = array();
90 public $cache_availability = array();
92 public $cache_demand_reason = array();
94 public $cache_types_fees = array();
96 public $cache_vatrates = array();
98 public $cache_invoice_subtype = array();
100 public $cache_rule_for_lines_dates = array();
105 private $phoneInputSharedJsLoaded =
false;
130 'y' => $langs->trans(
'Years'),
131 'm' => $langs->trans(
'Month'),
132 'w' => $langs->trans(
'Weeks'),
133 'd' => $langs->trans(
'Days'),
134 'h' => $langs->trans(
'Hours'),
135 'i' => $langs->trans(
'Minutes'),
136 's' => $langs->trans(
'Seconds'),
140 "y" => $langs->trans(
"Year"),
141 "m" => $langs->trans(
"Month"),
142 "w" => $langs->trans(
"Week"),
143 "d" => $langs->trans(
"Day"),
144 "h" => $langs->trans(
"Hour"),
145 "i" => $langs->trans(
"Minute"),
146 's' => $langs->trans(
'Second'),
150 return array_reverse($arrayoftypes);
152 return $arrayoftypes;
172 public function editfieldkey($text, $htmlname, $preselected,
$object, $perm, $typeofdata =
'string', $moreparam =
'', $fieldrequired = 0, $notabletag = 0, $paramid =
'id', $help =
'')
179 if (
getDolGlobalString(
'MAIN_USE_EDIT_IN_PLACE') && !preg_match(
'/^select;/', $typeofdata)) {
181 $tmp = explode(
':', $typeofdata);
182 $ret .=
'<div class="editkey_' . $tmp[0] . (!empty($tmp[1]) ?
' ' . $tmp[1] :
'') .
'" id="' . $htmlname .
'">';
183 if ($fieldrequired) {
184 $ret .=
'<span class="fieldrequired">';
189 $ret .= $langs->trans($text);
191 if ($fieldrequired) {
194 $ret .=
'</div>' .
"\n";
196 if ($fieldrequired) {
197 $ret .=
'<span class="fieldrequired">';
202 $ret .= $langs->trans($text);
204 if ($fieldrequired) {
209 if (empty($notabletag) && $perm) {
210 $ret .=
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
212 if ($fieldrequired) {
213 $ret .=
'<span class="fieldrequired">';
218 $ret .= $langs->trans($text);
220 if ($fieldrequired) {
223 if (!empty($notabletag)) {
226 if (empty($notabletag) && $perm) {
229 if (empty($notabletag) && $perm) {
230 $ret .=
'<td class="right">';
232 if ($htmlname &&
GETPOST(
'action',
'aZ09') !=
'edit' . $htmlname && $perm && is_object(
$object)) {
233 $ret .=
'<a class="editfielda reposition" href="' .
dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'edit' . $htmlname, $paramid =>
$object->id],
true) . $moreparam .
'">';
234 $ret .=
img_edit($langs->trans(
'Edit'), ($notabletag ? 0 : 1));
237 if (!empty($notabletag) && $notabletag == 1) {
244 if (!empty($notabletag) && $notabletag == 3) {
247 if (empty($notabletag) && $perm) {
250 if (empty($notabletag) && $perm) {
251 $ret .=
'</tr></table>';
281 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 =
'')
283 global
$conf, $langs;
288 if (empty($typeofdata)) {
289 return 'ErrorBadParameter typeofdata is empty';
292 if ($typeofdata ==
'datetime') {
293 $typeofdata =
'dayhour';
296 if (preg_match(
'/^(\w+)\((\d+)\)$/', $typeofdata, $reg)) {
297 if ($reg[1] ==
'varchar') {
298 $typeofdata =
'string';
299 } elseif ($reg[1] ==
'int') {
300 $typeofdata =
'numeric';
302 return 'ErrorBadParameter ' . $typeofdata;
307 if (
getDolGlobalString(
'MAIN_USE_EDIT_IN_PLACE') && !preg_match(
'/^select;|day|datepicker|dayhour|datehourpicker/', $typeofdata)) {
308 $ret .= $this->
editInPlace(
$object, $value, $htmlname, ($perm ? 1 : 0), $typeofdata, $editvalue, $extObject, $custommsg);
310 if ($editaction ==
'') {
311 $editaction =
GETPOST(
'action',
'aZ09');
313 $editmode = ($editaction ==
'edit' . $htmlname);
315 $ret .=
"<!-- formeditfieldval -->\n";
316 $ret .=
'<form method="post" action="' . $_SERVER[
"PHP_SELF"] . ($moreparam ?
'?' . $moreparam :
'') .
'">';
317 $ret .=
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
318 $ret .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
319 $ret .=
'<input type="hidden" name="' . $paramid .
'" value="' .
$object->id .
'">';
320 if (empty($notabletag)) {
321 $ret .=
'<table class="nobordernopadding centpercent">';
323 if (empty($notabletag)) {
326 if (preg_match(
'/^(string|safehtmlstring|email|phone|url)/', $typeofdata)) {
327 $tmp = explode(
':', $typeofdata);
328 $ret .=
'<input type="text" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . ($editvalue ? $editvalue : $value) .
'"' . (empty($tmp[1]) ?
'' :
' size="' . $tmp[1] .
'"') .
' autofocus spellcheck="false">';
329 } elseif (preg_match(
'/^(integer)/', $typeofdata)) {
330 $tmp = explode(
':', $typeofdata);
331 $valuetoshow =
price2num($editvalue ? $editvalue : $value, 0);
332 $ret .=
'<input type="text" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $valuetoshow .
'"' . (empty($tmp[1]) ?
'' :
' size="' . $tmp[1] .
'"') .
' autofocus>';
333 } elseif (preg_match(
'/^(numeric|amount)/', $typeofdata)) {
334 $tmp = explode(
':', $typeofdata);
335 $valuetoshow =
price2num($editvalue ? $editvalue : $value);
336 $ret .=
'<input type="text" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . ($valuetoshow !=
'' ?
price($valuetoshow) :
'') .
'"' . (empty($tmp[1]) ?
'' :
' size="' . $tmp[1] .
'"') .
' autofocus>';
337 } elseif (preg_match(
'/^(checkbox)/', $typeofdata)) {
338 $tmp = explode(
':', $typeofdata);
339 $ret .=
'<input type="checkbox" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . ($value ? $value :
'on') .
'"' . ($value ?
' checked' :
'') . (empty($tmp[1]) ?
'' : $tmp[1]) .
'/>';
340 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) {
341 $tmp = explode(
':', $typeofdata);
342 $cols = (empty($tmp[2]) ?
'' : $tmp[2]);
344 if (preg_match(
'/%/', $cols)) {
345 $morealt =
' style="width: ' . $cols .
'"';
348 $valuetoshow = ($editvalue ? $editvalue : $value);
349 $ret .=
'<textarea id="' . $htmlname .
'" name="' . $htmlname .
'" wrap="soft" rows="' . (empty($tmp[1]) ?
'20' : $tmp[1]) .
'"' . ($cols ?
' cols="' . $cols .
'"' :
'class="quatrevingtpercent"') . $morealt .
'" autofocus>';
352 $valuetoshow = str_replace(
'&',
'&', $valuetoshow);
354 $ret .=
'</textarea><div class="clearboth"></div>';
355 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') {
356 $addnowlink = empty($moreoptions[
'addnowlink']) ? 0 : $moreoptions[
'addnowlink'];
357 $adddateof = empty($moreoptions[
'adddateof']) ?
'' : $moreoptions[
'adddateof'];
358 $labeladddateof = empty($moreoptions[
'labeladddateof']) ?
'' : $moreoptions[
'labeladddateof'];
359 $ret .= $this->
selectDate($value, $htmlname, 0, 0, 1,
'form' . $htmlname, 1, $addnowlink, 0,
'',
'', $adddateof,
'', 1, $labeladddateof,
'', $gm);
360 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') {
361 $addnowlink = empty($moreoptions[
'addnowlink']) ? 0 : $moreoptions[
'addnowlink'];
362 $adddateof = empty($moreoptions[
'adddateof']) ?
'' : $moreoptions[
'adddateof'];
363 $labeladddateof = empty($moreoptions[
'labeladddateof']) ?
'' : $moreoptions[
'labeladddateof'];
364 $ret .= $this->
selectDate($value, $htmlname, 1, 1, 1,
'form' . $htmlname, 1, $addnowlink, 0,
'',
'', $adddateof,
'', 1, $labeladddateof,
'', $gm);
365 } elseif (preg_match(
'/^select;/', $typeofdata)) {
366 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
367 $arraylist = array();
368 foreach ($arraydata as $val) {
369 $tmp = explode(
':', $val);
370 $tmpkey = str_replace(
'|',
':', $tmp[0]);
371 $arraylist[$tmpkey] = $tmp[1];
373 $ret .= $this->
selectarray($htmlname, $arraylist, $value);
374 } elseif (preg_match(
'/^link/', $typeofdata)) {
376 } elseif (preg_match(
'/^ckeditor/', $typeofdata)) {
377 $tmp = explode(
':', $typeofdata);
378 require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
379 $doleditor =
new DolEditor($htmlname, ($editvalue ? $editvalue : $value), (empty($tmp[2]) ?
'' : $tmp[2]), (empty($tmp[3]) ? 100 : (int) $tmp[3]), (empty($tmp[1]) ?
'dolibarr_notes' : $tmp[1]),
'In', (empty($tmp[5]) ? false : (bool) $tmp[5]), (isset($tmp[8]) ? ($tmp[8] ? true :
false) :
true),
true, (empty($tmp[6]) ? 20 : (int) $tmp[6]), (empty($tmp[7]) ?
'100' : $tmp[7]));
380 $ret .= $doleditor->Create(1);
381 } elseif ($typeofdata ==
'asis') {
382 $ret .= ($editvalue ? $editvalue : $value);
384 if (empty($notabletag)) {
389 if (empty($notabletag)) {
393 $ret .=
'<input type="submit" class="smallpaddingimp nomargingtop nomarginbottom button' . (empty($notabletag) ?
'' :
' ') .
'" name="modify" value="' . $langs->trans(
"Save") .
'">';
394 if (preg_match(
'/ckeditor|textarea/', $typeofdata) && empty($notabletag)) {
395 $ret .=
'<br>' .
"\n";
397 $ret .=
'<input type="submit" class="smallpaddingimp nomargingtop nomarginbottom button button-cancel' . (empty($notabletag) ?
'' :
' ') .
'" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
398 if (empty($notabletag)) {
402 if (empty($notabletag)) {
403 $ret .=
'</tr></table>' .
"\n";
405 $ret .=
'</form>' .
"\n";
407 if (preg_match(
'/^email/', $typeofdata)) {
409 } elseif (preg_match(
'/^phone/', $typeofdata)) {
411 } elseif (preg_match(
'/^url/', $typeofdata)) {
413 } elseif (preg_match(
'/^(amount|numeric)/', $typeofdata)) {
414 $ret .= ($value !=
'' ?
price($value, 0, $langs, 0, -1, -1,
$conf->currency) :
'');
415 } elseif (preg_match(
'/^checkbox/', $typeofdata)) {
416 $tmp = explode(
':', $typeofdata);
417 $ret .=
'<input type="checkbox" disabled id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $value .
'"' . ($value ?
' checked' :
'') . ($tmp[1] ? $tmp[1] :
'') .
'/>';
418 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) {
420 } elseif (preg_match(
'/^(safehtmlstring|restricthtml)/', $typeofdata)) {
422 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') {
423 $ret .=
'<span class="valuedate">' .
dol_print_date($value,
'day', $gm) .
'</span>';
424 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') {
425 $ret .=
'<span class="valuedate">' .
dol_print_date($value,
'dayhour', $gm) .
'</span>';
426 } elseif (preg_match(
'/^select;/', $typeofdata)) {
427 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
428 $arraylist = array();
429 foreach ($arraydata as $val) {
430 $tmp = explode(
':', $val);
431 $arraylist[$tmp[0]] = $tmp[1];
433 $ret .= $arraylist[$value];
434 if ($htmlname ==
'fk_product_type') {
436 $ret =
img_picto($langs->trans(
"Product"),
'product',
'class="paddingleftonly paddingrightonly colorgrey"') . $ret;
438 $ret =
img_picto($langs->trans(
"Service"),
'service',
'class="paddingleftonly paddingrightonly colorgrey"') . $ret;
441 } elseif (preg_match(
'/^ckeditor/', $typeofdata)) {
444 $firstline = preg_replace(
'/<br>.*/',
'', $tmpcontent);
445 $firstline = preg_replace(
'/[\n\r].*/',
'', $firstline);
446 $tmpcontent = $firstline . ((strlen($firstline) != strlen($tmpcontent)) ?
'...' :
'');
452 if (empty($moreoptions[
'valuealreadyhtmlescaped'])) {
460 if ($formatfunc && method_exists(
$object, $formatfunc)) {
461 $ret =
$object->$formatfunc($ret);
481 global
$conf, $langs, $extralanguages;
486 $arrayoflangcode = array();
491 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
492 if (!is_object($extralanguages)) {
493 include_once DOL_DOCUMENT_ROOT .
'/core/class/extralanguages.class.php';
496 $extralanguages->fetch_name_extralanguages(
'societe');
501 if (empty($extralanguages->attributes[
$object->element]) || !is_array($extralanguages->attributes[
$object->element]) || empty($extralanguages->attributes[
$object->element][$fieldname])) {
505 $result .=
'<!-- Widget for translation -->' .
"\n";
506 $result .=
'<div class="inline-block paddingleft image-' .
$object->element .
'-' . $fieldname .
'">';
507 $s =
img_picto($langs->trans(
"ShowOtherLanguages"),
'language',
'', 0, 0, 0,
'',
'fa-15 editfieldlang');
511 $result .=
'<div class="inline-block hidden field-' .
$object->element .
'-' . $fieldname .
'">';
513 $resultforextrlang =
'';
514 foreach ($arrayoflangcode as $langcode) {
515 $valuetoshow = GETPOSTISSET(
'field-' .
$object->element .
"-" . $fieldname .
"-" . $langcode) ?
GETPOST(
'field-' .
$object->element .
'-' . $fieldname .
"-" . $langcode, $check) :
'';
516 if (empty($valuetoshow)) {
517 $object->fetchValuesForExtraLanguages();
519 $valuetoshow =
$object->array_languages[$fieldname][$langcode];
523 $resultforextrlang .= $s;
526 if ($typeofdata ==
'textarea') {
527 $resultforextrlang .=
'<textarea name="field-' .
$object->element .
"-" . $fieldname .
"-" . $langcode .
'" id="' . $fieldname .
"-" . $langcode .
'" class="' . $morecss .
'" rows="' . ROWS_2 .
'" wrap="soft">';
528 $resultforextrlang .= $valuetoshow;
529 $resultforextrlang .=
'</textarea>';
531 $resultforextrlang .=
'<input type="text" class="inputfieldforlang ' . ($morecss ?
' ' . $morecss :
'') .
'" name="field-' .
$object->element .
'-' . $fieldname .
'-' . $langcode .
'" value="' . $valuetoshow .
'">';
534 $result .= $resultforextrlang;
537 $result .=
'<script nonce="' . getNonce() .
'">$(".image-' .
$object->element .
'-' . $fieldname .
'").click(function() { console.log("Toggle lang widget"); jQuery(".field-' .
$object->element .
'-' . $fieldname .
'").toggle(); });</script>';
556 protected function editInPlace(
$object, $value, $htmlname, $condition, $inputType =
'textarea', $editvalue =
null, $extObject =
null, $custommsg =
null)
561 if (preg_match(
'/^text/', $inputType)) {
563 } elseif (preg_match(
'/^numeric/', $inputType)) {
564 $value =
price($value);
565 } elseif ($inputType ==
'day' || $inputType ==
'datepicker') {
571 $table_element =
false;
575 $ext_element =
false;
576 $button_only =
false;
583 $table_element =
$object->table_element;
587 if (is_object($extObject)) {
588 $ext_element = $extObject->element;
591 if (preg_match(
'/^(string|email|numeric)/', $inputType)) {
592 $tmp = explode(
':', $inputType);
593 $inputType = $tmp[0];
594 if (!empty($tmp[1])) {
595 $inputOption = $tmp[1];
597 if (!empty($tmp[2])) {
598 $savemethod = $tmp[2];
600 $out .=
'<input id="width_' . $htmlname .
'" value="' . $inputOption .
'" type="hidden"/>' .
"\n";
601 } elseif ((preg_match(
'/^day$/', $inputType)) || (preg_match(
'/^datepicker/', $inputType)) || (preg_match(
'/^datehourpicker/', $inputType))) {
602 $tmp = explode(
':', $inputType);
603 $inputType = $tmp[0];
604 if (!empty($tmp[1])) {
605 $inputOption = $tmp[1];
607 if (!empty($tmp[2])) {
608 $savemethod = $tmp[2];
611 $out .=
'<input id="timestamp" type="hidden"/>' .
"\n";
612 } elseif (preg_match(
'/^(select|autocomplete)/', $inputType)) {
613 $tmp = explode(
':', $inputType);
614 $inputType = $tmp[0];
615 $loadmethod = $tmp[1];
616 if (!empty($tmp[2])) {
617 $savemethod = $tmp[2];
619 if (!empty($tmp[3])) {
622 } elseif (preg_match(
'/^textarea/', $inputType)) {
623 $tmp = explode(
':', $inputType);
624 $inputType = $tmp[0];
625 $rows = (empty($tmp[1]) ?
'8' : $tmp[1]);
626 $cols = (empty($tmp[2]) ?
'80' : $tmp[2]);
627 } elseif (preg_match(
'/^ckeditor/', $inputType)) {
628 $tmp = explode(
':', $inputType);
629 $inputType = $tmp[0];
631 if (!empty($tmp[2])) {
634 if (!empty($tmp[3])) {
637 if (!empty($tmp[4])) {
638 $savemethod = $tmp[4];
642 $out .=
'<input id="ckeditor_toolbar" value="' . $toolbar .
'" type="hidden"/>' .
"\n";
644 $inputType =
'textarea';
648 $out .=
'<input id="element_' . $htmlname .
'" value="' . $element .
'" type="hidden"/>' .
"\n";
649 $out .=
'<input id="table_element_' . $htmlname .
'" value="' . $table_element .
'" type="hidden"/>' .
"\n";
650 $out .=
'<input id="fk_element_' . $htmlname .
'" value="' . $fk_element .
'" type="hidden"/>' .
"\n";
651 $out .=
'<input id="loadmethod_' . $htmlname .
'" value="' . $loadmethod .
'" type="hidden"/>' .
"\n";
652 if (!empty($savemethod)) {
653 $out .=
'<input id="savemethod_' . $htmlname .
'" value="' . $savemethod .
'" type="hidden"/>' .
"\n";
655 if (!empty($ext_element)) {
656 $out .=
'<input id="ext_element_' . $htmlname .
'" value="' . $ext_element .
'" type="hidden"/>' .
"\n";
658 if (!empty($custommsg)) {
659 if (is_array($custommsg)) {
660 if (!empty($custommsg[
'success'])) {
661 $out .=
'<input id="successmsg_' . $htmlname .
'" value="' . $custommsg[
'success'] .
'" type="hidden"/>' .
"\n";
663 if (!empty($custommsg[
'error'])) {
664 $out .=
'<input id="errormsg_' . $htmlname .
'" value="' . $custommsg[
'error'] .
'" type="hidden"/>' .
"\n";
667 $out .=
'<input id="successmsg_' . $htmlname .
'" value="' . $custommsg .
'" type="hidden"/>' .
"\n";
670 if ($inputType ==
'textarea') {
671 $out .=
'<input id="textarea_' . $htmlname .
'_rows" value="' . $rows .
'" type="hidden"/>' .
"\n";
672 $out .=
'<input id="textarea_' . $htmlname .
'_cols" value="' . $cols .
'" type="hidden"/>' .
"\n";
674 $out .=
'<span id="viewval_' . $htmlname .
'" class="viewval_' . $inputType . ($button_only ?
' inactive' :
' active') .
'">' . $value .
'</span>' .
"\n";
675 $out .=
'<span id="editval_' . $htmlname .
'" class="editval_' . $inputType . ($button_only ?
' inactive' :
' active') .
' hideobject">' . (!empty($editvalue) ? $editvalue : $value) .
'</span>' .
"\n";
701 public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img =
'', $extracss =
'', $notabs = 3, $incbefore =
'', $noencodehtmltext = 0, $tooltiptrigger =
'', $forcenowrap = 0)
704 $text = $incbefore . $text;
709 $direction = (int) $direction;
719 $htmltext = str_replace(array(
"\r",
"\n"),
'', $htmltext);
722 if ($direction < 0) {
723 $extracss = ($extracss ? $extracss :
'') . ($notabs != 3 ?
' inline-block' :
'');
724 $extrastyle =
'padding: 0px; padding-left: 2px;';
726 if ($direction > 0) {
727 $extracss = ($extracss ? $extracss :
'') . ($notabs != 3 ?
' inline-block' :
'');
728 $extrastyle =
'padding: 0px; padding-right: 2px;';
731 $classfortooltip =
'classfortooltip';
736 if ($tooltiptrigger ==
'') {
737 $htmltext = str_replace(
'"',
'"', $htmltext);
739 $classfortooltip =
'classfortooltiponclick';
740 $textfordialog .=
'<div style="display: none;" id="idfortooltiponclick_' . $tooltiptrigger .
'" class="classfortooltiponclicktext"';
744 $textfordialog .=
' title="'.$langs->trans(
"Note").
'"';
746 $textfordialog .=
'>' . $htmltext .
'</div>';
748 if ($tooltipon == 2 || $tooltipon == 3) {
749 $paramfortooltipimg =
' class="' . $classfortooltip . ($notabs != 3 ?
' inline-block' :
'') . ($extracss ?
' ' . $extracss :
'') .
'" style="padding: 0px;' . ($extrastyle ?
' ' . $extrastyle :
'') .
'"';
750 if ($tooltiptrigger ==
'') {
751 $paramfortooltipimg .=
' title="' . ($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1, 0,
'span', 0, 1)) .
'"';
753 $paramfortooltipimg .=
' dolid="' . $tooltiptrigger .
'"';
756 $paramfortooltipimg = ($extracss ?
' class="' . $extracss .
'"' :
'') . ($extrastyle ?
' style="' . $extrastyle .
'"' :
'');
758 if ($tooltipon == 1 || $tooltipon == 3) {
759 $paramfortooltiptd =
' class="' . ($tooltipon == 3 ?
'cursorpointer ' :
'') . $classfortooltip . ($tag !=
'td' ?
' inline-block' :
'') . ($extracss ?
' ' . $extracss :
'') .
'" style="padding: 0px;' . ($extrastyle ?
' ' . $extrastyle :
'') .
'" ';
760 if ($tooltiptrigger ==
'') {
761 $paramfortooltiptd .=
' title="' . ($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1, 0,
'span', 0, 1)) .
'"';
763 $paramfortooltiptd .=
' dolid="' . $tooltiptrigger .
'"';
766 $paramfortooltiptd = ($extracss ?
' class="' . $extracss .
'"' :
'') . ($extrastyle ?
' style="' . $extrastyle .
'"' :
'');
768 if (empty($notabs)) {
769 $s .=
'<table class="nobordernopadding"><tr style="height: auto;">';
770 } elseif ($notabs == 2) {
771 $s .=
'<div class="inline-block' . ($forcenowrap ?
' nowrap' :
'') .
'">';
774 if ($direction < 0) {
775 $s .=
'<' . $tag . $paramfortooltipimg;
777 $s .=
' class="valigntop" width="14"';
779 $s .=
'>' . $textfordialog . $img .
'</' . $tag .
'>';
783 if ((
string) $text !=
'') {
784 $s .=
'<' . $tag . $paramfortooltiptd .
'>' . $text .
'</' . $tag .
'>';
787 if ($direction > 0) {
788 $s .=
'<' . $tag . $paramfortooltipimg;
790 $s .=
' class="valignmiddle" width="14"';
792 $s .=
'>' . $textfordialog . $img .
'</' . $tag .
'>';
794 if (empty($notabs)) {
795 $s .=
'</tr></table>';
796 } elseif ($notabs == 2) {
817 public function textwithpicto($text, $htmltooltip, $direction = 1, $type =
'help', $extracss =
'valignmiddle', $noencodehtmltext = 0, $notabs = 3, $tooltiptrigger =
'', $forcenowrap = 0)
819 global
$conf, $langs;
824 } elseif ($type ==
'1') {
828 $tooltiptrigger = preg_replace(
'/[^a-z0-9]/i',
'', $tooltiptrigger);
830 if (preg_match(
'/onsmartphone$/', $tooltiptrigger) && empty(
$conf->dol_no_mouse_hover)) {
831 $tooltiptrigger = preg_replace(
'/^.*onsmartphone$/',
'', $tooltiptrigger);
834 if ($tooltiptrigger) {
835 $alt = $langs->transnoentitiesnoconv(
"ClickToShowHelp");
839 if (empty(
$conf->use_javascript_ajax)) {
840 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable') {
849 if (!empty(
$conf->dol_no_mouse_hover) && empty($tooltiptrigger)) {
850 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable') {
861 if ($type ==
'info') {
862 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 0), $alt);
863 } elseif ($type ==
'help') {
864 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
865 } elseif ($type ==
'helpclickable') {
866 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
867 } elseif ($type ==
'warning') {
869 } elseif ($type !=
'none') {
874 $tooltipon = ((($tooltiptrigger && !$img) || strpos($type,
'clickable')) ? 3 : 2);
876 return $this->
textwithtooltip($text, $htmltooltip, $tooltipon, $direction, $img, $extracss, $notabs,
'', $noencodehtmltext, $tooltiptrigger, $forcenowrap);
889 public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0, $name =
'massaction', $cssclass =
'checkforselect')
891 global
$conf, $langs, $hookmanager;
894 $ret =
'<div class="centpercent center">';
895 $ret .=
'<select class="flat' . (empty(
$conf->use_javascript_ajax) ?
'' :
' hideobject') .
' ' . $name .
' ' . $name .
'select valignmiddle alignstart" id="' . $name .
'" name="' . $name .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
'>';
898 $parameters = array();
899 $reshook = $hookmanager->executeHooks(
'addMoreMassActions', $parameters);
902 if (is_array($arrayofaction) && count($arrayofaction) == 0 && empty($hookmanager->resPrint)) {
905 if (empty($reshook)) {
906 $ret .=
'<option value="0"' . ($disabled ?
' disabled="disabled"' :
'') .
'>-- ' . $langs->trans(
"SelectAction") .
' --</option>';
907 if (is_array($arrayofaction)) {
908 foreach ($arrayofaction as $code => $label) {
909 $ret .=
'<option value="' . $code .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' data-html="' .
dol_escape_htmltag($label) .
'">' . $label .
'</option>';
913 $ret .= $hookmanager->resPrint;
917 if (empty(
$conf->dol_optimize_smallscreen)) {
922 $ret .=
'<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">';
923 $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")) .
'">';
926 if (!empty(
$conf->use_javascript_ajax)) {
927 $ret .=
'<!-- JS CODE TO ENABLE mass action select -->
928 <script nonce="' . getNonce() .
'">
929 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 check for select boxes */
930 atleastoneselected=0;
931 jQuery("."+cssclass).each(function( index ) {
932 /* console.log( index + ": " + $( this ).text() ); */
933 if ($(this).is(\':checked\')) atleastoneselected++;
936 console.log("initCheckForSelect mode="+mode+" name="+name+" cssclass="+cssclass+" atleastoneselected="+atleastoneselected);
938 if (atleastoneselected || ' . ((int) $alwaysvisible) .
') {
939 jQuery("."+name).show();
940 ' . ($selected ?
'if (atleastoneselected) { jQuery("."+name+"select").val("' . $selected .
'").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', false); }' :
'') .
'
941 ' . ($selected ?
'if (! atleastoneselected) { jQuery("."+name+"select").val("0").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', true); } ' :
'') .
'
943 jQuery("."+name).hide();
944 jQuery("."+name+"other").hide();
948 jQuery(document).ready(function () {
949 initCheckForSelect(0, "' . $name .
'", "' . $cssclass .
'");
950 jQuery(".' . $cssclass .
'").change(function() {
951 console.log("A change was done on .' . $cssclass .
'");
952 initCheckForSelect(1, "' . $name .
'", "' . $cssclass .
'");
954 jQuery(".' . $name .
'select").change(function() {
955 var massaction = $( this ).val();
956 var urlform = $( this ).closest("form").attr("action").replace("#show_files","");
957 if (massaction == "builddoc") {
958 urlform = urlform + "#show_files";
960 $( this ).closest("form").attr("action", urlform);
961 console.log("we select a mass action name=' . $name .
' massaction="+massaction+" - "+urlform);
962 /* Warning: if you set submit button to disabled, post using Enter will no more work if there is no other button */
963 if ($(this).val() != \'0\') {
964 jQuery(".' . $name .
'confirmed").prop(\'disabled\', false);
965 jQuery(".' . $name .
'other").hide(); /* To disable if another div was open */
966 jQuery(".' . $name .
'"+massaction).show();
968 jQuery(".' . $name .
'confirmed").prop(\'disabled\', true);
969 jQuery(".' . $name .
'other").hide(); /* To disable any div open */
999 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, $forcecombo = 0)
1004 $langs->load(
"dict");
1006 $selected = (
string) $selected;
1010 $countryArray = array();
1011 $favorite = array();
1013 $atleastonefavorite = 0;
1015 $sql =
"SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite, eec";
1016 $sql .=
" FROM " . $this->db->prefix() .
"c_country";
1017 $sql .=
" WHERE active > 0";
1020 dol_syslog(get_class($this) .
"::select_country", LOG_DEBUG);
1022 $resql = $this->db->query($sql);
1024 $out .=
'<select id="select' . $htmlname .
'" class="flat maxwidth200onsmartphone selectcountry' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" ' . $htmloption .
'>';
1025 $num = $this->db->num_rows($resql);
1029 $obj = $this->db->fetch_object($resql);
1033 'rowid' => (
int) $obj->rowid,
1034 'code_iso' => (
string) $obj->code_iso,
1035 'code_iso3' => (
string) $obj->code_iso3,
1036 'label' => (
string) ($obj->code_iso && $langs->transnoentitiesnoconv(
"Country" . $obj->code_iso) !=
"Country" . $obj->code_iso ? $langs->transnoentitiesnoconv(
"Country" . $obj->code_iso) : ($obj->label !=
'-' ? $obj->label :
'')),
1037 'favorite' => (
string) $obj->favorite,
1038 'eec' => (
string) $obj->eec,
1040 $favorite[$i] = $obj->favorite;
1045 if (empty($disablefavorites)) {
1046 $array1_sort_order = SORT_DESC;
1047 $array2_sort_order = SORT_ASC;
1048 array_multisort($favorite, $array1_sort_order, $label, $array2_sort_order, $countryArray);
1054 if (is_numeric($showempty)) {
1055 $out .=
'<option value=""> </option>' .
"\n";
1057 $out .=
'<option value="-1">' . $langs->trans($showempty) .
'</option>' .
"\n";
1061 if ($addspecialentries) {
1063 $out .=
'<option value="special_allnotme"' . ($selected ==
'special_allnotme' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesExceptMe", $langs->transnoentitiesnoconv(
"Country" .
$mysoc->country_code)) .
'</option>';
1064 $out .=
'<option value="special_eec"' . ($selected ==
'special_eec' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesInEEC") .
'</option>';
1066 $out .=
'<option value="special_eecnotme"' . ($selected ==
'special_eecnotme' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesInEECExceptMe", $langs->transnoentitiesnoconv(
"Country" .
$mysoc->country_code)) .
'</option>';
1068 $out .=
'<option value="special_noteec"' . ($selected ==
'special_noteec' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesNotInEEC") .
'</option>';
1069 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
1072 foreach ($countryArray as $row) {
1074 if (empty($row[
'rowid'])) {
1077 if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row[
'code_iso'], $exclude_country_code)) {
1081 if (empty($disablefavorites) && $row[
'favorite'] && $row[
'code_iso']) {
1082 $atleastonefavorite++;
1084 if (empty($row[
'favorite']) && $atleastonefavorite) {
1085 $atleastonefavorite = 0;
1086 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
1090 if ($row[
'label']) {
1091 $labeltoshow .=
dol_trunc($row[
'label'], $maxlength,
'middle');
1093 $labeltoshow .=
' ';
1095 if ($row[
'code_iso']) {
1096 $labeltoshow .=
' <span class="opacitymedium">(' . $row[
'code_iso'] .
')</span>';
1097 if (empty($hideflags)) {
1098 $tmpflag =
picto_from_langcode($row[
'code_iso'],
'class="saturatemedium paddingrightonly"', 1);
1099 $labeltoshow = $tmpflag .
' ' . $labeltoshow;
1103 if ($selected && $selected !=
'-1' && ($selected == $row[
'rowid'] || $selected == $row[
'code_iso'] || $selected == $row[
'code_iso3'] || $selected == $row[
'label'])) {
1104 $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']) .
'">';
1106 $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']) .
'">';
1109 $out .=
'</option>' .
"\n";
1112 $out .=
'</select>';
1118 if (empty($forcecombo)) {
1119 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1120 $out .=
ajax_combobox(
'select' . $htmlname, array(), 0, 0,
'resolve');
1136 public function selectPhoneCode($selected =
'', $htmlname =
'phone_code', $morecss =
'maxwidth150', $showempty = 0, $country_id_hint = 0)
1140 $langs->load(
"dict");
1143 $codeArray = array();
1144 $favorite = array();
1146 $atleastonefavorite = 0;
1148 $sql =
"SELECT rowid, code, label, phone_code, favorite, trunk_prefix";
1149 $sql .=
" FROM ".$this->db->prefix().
"c_country";
1150 $sql .=
" WHERE active > 0 AND phone_code IS NOT NULL AND phone_code != ''";
1152 dol_syslog(get_class($this).
"::selectPhoneCode", LOG_DEBUG);
1153 $resql = $this->db->query($sql);
1155 $num = $this->db->num_rows($resql);
1158 $obj = $this->db->fetch_object($resql);
1160 $translabel = ($obj->code && $langs->transnoentitiesnoconv(
"Country".$obj->code) !=
"Country".$obj->code) ? $langs->transnoentitiesnoconv(
"Country".$obj->code) : $obj->label;
1162 $codeArray[$i][
'rowid'] = $obj->rowid;
1163 $codeArray[$i][
'code'] = $obj->code;
1164 $codeArray[$i][
'label'] = $translabel;
1165 $codeArray[$i][
'phone_code'] =
'+'.$obj->phone_code;
1166 $codeArray[$i][
'favorite'] = $obj->favorite;
1167 $codeArray[$i][
'trunk_prefix'] = $obj->trunk_prefix;
1168 $favorite[$i] = $obj->favorite;
1173 $array1_sort_order = SORT_DESC;
1174 $array2_sort_order = SORT_ASC;
1175 array_multisort($favorite, $array1_sort_order, $label, $array2_sort_order, $codeArray);
1177 $out .=
'<select id="select'.$htmlname.
'" class="flat selectphonecode'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
1180 $out .=
'<option value=""> </option>'.
"\n";
1185 $firstMatchIdx = -1;
1186 if ($selected !==
'') {
1187 foreach ($codeArray as $idx => $row) {
1188 if ($row[
'phone_code'] == $selected) {
1189 if ($firstMatchIdx < 0) {
1190 $firstMatchIdx = $idx;
1192 if ($country_id_hint > 0 && $row[
'rowid'] == $country_id_hint) {
1193 $selectedIdx = $idx;
1198 if ($selectedIdx < 0 && $firstMatchIdx >= 0) {
1199 $selectedIdx = $firstMatchIdx;
1203 foreach ($codeArray as $idx => $row) {
1204 if (empty($row[
'code'])) {
1208 if ($row[
'favorite']) {
1209 $atleastonefavorite++;
1211 if (empty($row[
'favorite']) && $atleastonefavorite) {
1212 $atleastonefavorite = 0;
1213 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
1216 $tmpflag =
picto_from_langcode($row[
'code'],
'class="saturatemedium paddingrightonly"', 1);
1219 $selectlabel = ($tmpflag ? $tmpflag.
' ' :
'').$row[
'code'];
1222 $labeltoshow = ($tmpflag ? $tmpflag.
' ' :
'').$row[
'label'].
' '.$row[
'phone_code'];
1224 $out .=
'<option value="'.dol_escape_htmltag($row[
'phone_code']).
'"';
1225 if ($idx === $selectedIdx) {
1226 $out .=
' selected';
1228 $out .=
' data-html="'.dol_escape_htmltag($labeltoshow).
'"';
1229 $out .=
' data-select-html="'.dol_escape_htmltag($selectlabel).
'"';
1230 $out .=
' data-country-id="'.((int) $row[
'rowid']).
'"';
1231 $out .=
' data-trunk-prefix="'.dol_escape_htmltag((
string) $row[
'trunk_prefix']).
'"';
1234 $out .=
'</option>'.
"\n";
1236 $out .=
'</select>';
1242 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1243 $out .=
ajax_combobox(
'select'.$htmlname, array(), 0, 0,
'resolve');
1264 public function showPhoneInput($phoneValue, $htmlname, $country_id_hint = 0, $picto =
'object_phoning', $morecss =
'maxwidth150', $maxlength = 0, $countrySelectorId =
'selectcountry_id')
1268 include_once DOL_DOCUMENT_ROOT.
'/core/lib/phone.lib.php';
1270 $codename = $htmlname.
'_code';
1273 if (empty($country_id_hint) && !empty(
$mysoc->country_id)) {
1274 $country_id_hint =
$mysoc->country_id;
1278 if (GETPOSTISSET($htmlname)) {
1281 $fullPhone = (
string) $phoneValue;
1290 $selectedCode = $phonecode;
1291 $numberValue = $parsed[
'number'];
1294 if ($numberValue !==
'' && $selectedCode !==
'') {
1296 if ($trunkPrefix !==
'' && strpos($numberValue, $trunkPrefix) !== 0) {
1297 $numberValue = $trunkPrefix.$numberValue;
1305 $out .=
img_picto(
'', $picto,
'class="pictofixedwidth"');
1308 $out .= $this->
selectPhoneCode($selectedCode, $codename,
'maxwidth75 phone_code_select', 0, $country_id_hint);
1311 $out .=
'<input type="tel" inputmode="numeric" pattern="[0-9]*" id="'.dol_escape_htmltag($htmlname).
'_input" class="'.
dol_escape_htmltag($morecss).
'"';
1312 if ($maxlength > 0) {
1313 $out .=
' maxlength="'.$maxlength.
'"';
1315 $out .=
' value="'.dol_escape_htmltag($numberValue).
'">';
1340 $selectId =
'select'.dol_escape_js($codename);
1342 $out =
"\n".
'<script type="text/javascript">'.
"\n";
1343 $out .=
'jQuery(document).ready(function() {'.
"\n";
1344 $out .=
' function syncPhoneField_'.$hiddenId.
'() {'.
"\n";
1345 $out .=
' var selectEl = jQuery("#'.$selectId.
'");'.
"\n";
1346 $out .=
' var code = selectEl.val() || "";'.
"\n";
1347 $out .=
' var number = (jQuery("#'.$inputId.
'").val() || "").replace(/[^0-9]/g, "");'.
"\n";
1348 $out .=
' if (code && number) {'.
"\n";
1349 $out .=
' var selOpt = selectEl[0] && selectEl[0].selectedOptions && selectEl[0].selectedOptions[0];'.
"\n";
1350 $out .=
' var trunkPrefix = selOpt ? (selOpt.getAttribute("data-trunk-prefix") || "") : "";'.
"\n";
1351 $out .=
' if (trunkPrefix !== "" && number.indexOf(trunkPrefix) === 0) {'.
"\n";
1352 $out .=
' number = number.substring(trunkPrefix.length);'.
"\n";
1354 $out .=
' jQuery("#'.$hiddenId.
'").val(code + " " + number);'.
"\n";
1355 $out .=
' } else if (number) {'.
"\n";
1356 $out .=
' jQuery("#'.$hiddenId.
'").val(number);'.
"\n";
1357 $out .=
' } else {'.
"\n";
1358 $out .=
' jQuery("#'.$hiddenId.
'").val("");'.
"\n";
1361 $out .=
' jQuery("#'.$selectId.
'").on("change", function() { syncPhoneField_'.$hiddenId.
'(); });'.
"\n";
1362 $out .=
' jQuery("#'.$inputId.
'").on("input change", function() { syncPhoneField_'.$hiddenId.
'(); });'.
"\n";
1364 $out .=
'</script>'.
"\n";
1380 if ($this->phoneInputSharedJsLoaded) {
1383 $this->phoneInputSharedJsLoaded =
true;
1385 $out =
"\n".
'<script type="text/javascript">'.
"\n";
1386 $out .=
'jQuery(document).ready(function() {'.
"\n";
1387 $out .=
' jQuery("#'.dol_escape_js($countrySelectorId).
'").on("change", function() {'.
"\n";
1388 $out .=
' var country_id = jQuery(this).val();'.
"\n";
1389 $out .=
' if (country_id) {'.
"\n";
1390 $out .=
' jQuery.getJSON("'.DOL_URL_ROOT.
'/core/ajax/getphonecode.php", {country_id: country_id, token: "'.currentToken().
'"}, function(data) {'.
"\n";
1391 $out .=
' if (data.phone_code) {'.
"\n";
1392 $out .=
' jQuery(".phone_code_select").each(function() {'.
"\n";
1393 $out .=
' jQuery(this).val(data.phone_code).trigger("change");'.
"\n";
1394 $out .=
' });'.
"\n";
1396 $out .=
' });'.
"\n";
1398 $out .=
' });'.
"\n";
1400 $out .=
'</script>'.
"\n";
1421 global $langs, $form;
1423 $form =
new Form($this->db);
1425 $htmltoenteralink =
'';
1429 $htmltoenteralink .=
'<tr class="liste_titre">';
1430 $htmltoenteralink .=
'<td class="nowrap"></td>';
1431 $htmltoenteralink .=
'<td>' . $langs->trans(
"Ref") .
'</td>';
1432 $htmltoenteralink .=
'<td>' . $langs->trans(
"RefCustomer") .
'</td>';
1433 $htmltoenteralink .=
'<td class="right">' . $langs->trans(
"AmountHTShort") .
'</td>';
1434 $htmltoenteralink .=
'<td>' . $langs->trans(
"Company") .
'</td>';
1435 $htmltoenteralink .=
'</tr>';
1439 $objp = $this->db->fetch_object($resqllist);
1440 $alreadylinked =
false;
1441 if (!empty(
$object->linkedObjectsIds[$possiblelink[
'linkname'] ?? $key])) {
1442 if (in_array($objp->rowid, array_values(
$object->linkedObjectsIds[$possiblelink[
'linkname'] ?? $key]))) {
1443 $alreadylinked =
true;
1446 $htmltoenteralink .=
'<tr class="oddeven">';
1447 $htmltoenteralink .=
'<td>';
1448 if ($alreadylinked) {
1449 $htmltoenteralink .=
img_picto(
'',
'link');
1451 $htmltoenteralink .=
'<input type="checkbox" name="idtolinkto[' . $key .
'_' . $objp->rowid .
']" id="' . $key .
'_' . $objp->rowid .
'" value="' . $objp->rowid .
'">';
1453 $htmltoenteralink .=
'</td>';
1454 $htmltoenteralink .=
'<td><label for="' . $key .
'_' . $objp->rowid .
'">' . $objp->ref .
'</label></td>';
1455 $htmltoenteralink .=
'<td>' . (!empty($objp->ref_client) ? $objp->ref_client : (!empty($objp->ref_supplier) ? $objp->ref_supplier :
'')) .
'</td>';
1456 $htmltoenteralink .=
'<td class="right">';
1457 if ($possiblelink[
'label'] ==
'LinkToContract') {
1458 $htmltoenteralink .= $form->textwithpicto(
'', $langs->trans(
"InformationOnLinkToContract")) .
' ';
1460 $htmltoenteralink .=
'<span class="amount">' . (isset($objp->total_ht) ?
price($objp->total_ht) :
'') .
'</span>';
1461 $htmltoenteralink .=
'</td>';
1462 $htmltoenteralink .=
'<td>' . $objp->name .
'</td>';
1463 $htmltoenteralink .=
'</tr>';
1467 return $htmltoenteralink;
1487 global $langs, $form;
1488 require_once DOL_DOCUMENT_ROOT .
'/eventorganization/class/conferenceorboothattendee.class.php';
1489 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
1490 require_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
1492 $companystatic =
new Societe($this->db);
1493 $projectstatic =
new Project($this->db);
1495 $form =
new Form($this->db);
1497 $htmltoenteralink =
'';
1501 $htmltoenteralink .=
'<tr class="liste_titre">';
1502 $htmltoenteralink .=
'<td class="nowrap"></td>';
1503 $htmltoenteralink .=
'<td>' . $langs->trans(
"Ref") .
'</td>';
1504 $htmltoenteralink .=
'<td>' . $langs->trans(
"Name") .
'</td>';
1505 $htmltoenteralink .=
'<td>' . $langs->trans(
"Email") .
'</td>';
1506 $htmltoenteralink .=
'<td>' . $langs->trans(
"Company") .
'</td>';
1507 $htmltoenteralink .=
'<td>' . $langs->trans(
"Project") .
'</td>';
1508 $htmltoenteralink .=
'<td>' . $langs->trans(
"DateOfRegistration") .
'</td>';
1509 $htmltoenteralink .=
'</tr>';
1513 $objp = $this->db->fetch_object($resqllist);
1514 $alreadylinked =
false;
1515 if (!empty(
$object->linkedObjectsIds[$possiblelink[
'linkname'] ?? $key])) {
1516 if (in_array($objp->rowid, array_values(
$object->linkedObjectsIds[$possiblelink[
'linkname'] ?? $key]))) {
1517 $alreadylinked =
true;
1520 $htmltoenteralink .=
'<tr class="oddeven">';
1521 $htmltoenteralink .=
'<td>';
1522 if ($alreadylinked) {
1523 $htmltoenteralink .=
img_picto(
'',
'link');
1525 $htmltoenteralink .=
'<input type="checkbox" name="idtolinkto[' . $key .
'_' . $objp->rowid .
']" id="' . $key .
'_' . $objp->rowid .
'" value="' . $objp->rowid .
'">';
1527 $htmltoenteralink .=
'</td>';
1528 $fetchattendee = $attendeestatic->fetch($objp->rowid);
1529 if ($fetchattendee) {
1530 $htmltoenteralink .=
'<td>' . $attendeestatic->getNomUrl(0).
'</td>';
1532 $htmltoenteralink .=
'<td><label for="' . $key .
'_' . $objp->rowid .
'">' . $objp->ref .
'</label></td>';
1534 $htmltoenteralink .=
'<td>' . $objp->name .
'</td>';
1535 $htmltoenteralink .=
'<td>' . $objp->email .
'</td>';
1536 $fetchcompany = $companystatic->fetch($objp->socid);
1537 if ($fetchcompany) {
1538 $htmltoenteralink .=
'<td>' . $companystatic->getNomUrl(0).
'</td>';
1540 $htmltoenteralink .=
'<td>' . $objp->name .
'</td>';
1542 $fetchcproject = $projectstatic->fetch($objp->fk_project);
1543 if ($fetchcproject) {
1544 $htmltoenteralink .=
'<td>' . $projectstatic->getNomUrl(0).
'</td>';
1546 $htmltoenteralink .=
'<td>' . $objp->fk_project .
'</td>';
1548 $htmltoenteralink .=
'<td>' . $objp->date_subscription .
'</td>';
1549 $htmltoenteralink .=
'</tr>';
1553 return $htmltoenteralink;
1571 public function select_incoterms($selected =
'', $location_incoterms =
'', $page =
'', $htmlname =
'incoterm_id', $htmloption =
'', $forcecombo = 1, $events = array(), $disableautocomplete = 0)
1574 global
$conf, $langs;
1576 $langs->load(
"dict");
1580 $incotermArray = array();
1582 $sql =
"SELECT rowid, code";
1583 $sql .=
" FROM " . $this->db->prefix() .
"c_incoterms";
1584 $sql .=
" WHERE active > 0";
1585 $sql .=
" ORDER BY code ASC";
1587 dol_syslog(get_class($this) .
"::select_incoterm", LOG_DEBUG);
1588 $resql = $this->db->query($sql);
1590 if (
$conf->use_javascript_ajax && !$forcecombo) {
1591 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1595 if (!empty($page)) {
1596 $out .=
'<form method="post" action="' . $page .
'">';
1597 $out .=
'<input type="hidden" name="action" value="set_incoterms">';
1598 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
1601 $out .=
'<select id="' . $htmlname .
'" class="flat selectincoterm width75" name="' . $htmlname .
'" ' . $htmloption .
'>';
1602 $out .=
'<option value="0"> </option>';
1603 $num = $this->db->num_rows($resql);
1607 $obj = $this->db->fetch_object($resql);
1608 $incotermArray[$i][
'rowid'] = $obj->rowid;
1609 $incotermArray[$i][
'code'] = $obj->code;
1613 foreach ($incotermArray as $row) {
1614 if ($selected && ($selected == $row[
'rowid'] || $selected == $row[
'code'])) {
1615 $out .=
'<option value="' . $row[
'rowid'] .
'" selected>';
1617 $out .=
'<option value="' . $row[
'rowid'] .
'">';
1621 $out .= $row[
'code'];
1624 $out .=
'</option>';
1627 $out .=
'</select>';
1630 if (
$conf->use_javascript_ajax && empty($disableautocomplete)) {
1631 $out .=
ajax_multiautocompleter(
'location_incoterms', array(), DOL_URL_ROOT .
'/core/ajax/locationincoterms.php') .
"\n";
1634 $out .=
'<input id="location_incoterms" class="maxwidthonsmartphone heightofcombo" type="text" name="location_incoterms" value="' . $location_incoterms .
'">' .
"\n";
1636 if (!empty($page)) {
1637 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp nomargintop nomarginbottom" value="' . $langs->trans(
"Modify") .
'"></form>';
1661 public function select_type_of_lines($selected =
'', $htmlname =
'type', $showempty = 0, $hidetext = 0, $forceall = 0, $morecss =
"", $useajaxcombo = 1)
1669 if (empty($hidetext)) {
1670 print $langs->trans(
"Type").
'...';
1673 print
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
1675 print
'<option value="-1" class="opacitymedium"'.($useajaxcombo ?
'' :
' disabled="disabled"');
1676 if ($selected == -1) {
1680 if (is_numeric($showempty)) {
1688 print
'<option value="0"';
1689 if (0 == $selected || ($selected == -1 &&
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') ==
'product')) {
1692 print
'>' . $langs->trans(
"Product");
1695 print
'<option value="1"';
1696 if (1 == $selected || ($selected == -1 &&
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') ==
'service')) {
1699 print
'>' . $langs->trans(
"Service");
1704 if ($useajaxcombo) {
1710 print $langs->trans(
"Service");
1711 print
'<input type="hidden" name="' . $htmlname .
'" value="1">';
1714 print $langs->trans(
"Product");
1715 print
'<input type="hidden" name="' . $htmlname .
'" value="0">';
1717 if ($forceall < 0) {
1718 print
'<input type="hidden" name="' . $htmlname .
'" value="1">';
1734 $num = count($this->cache_types_fees);
1741 $langs->load(
"trips");
1743 $sql =
"SELECT c.code, c.label";
1744 $sql .=
" FROM " . $this->db->prefix() .
"c_type_fees as c";
1745 $sql .=
" WHERE active > 0";
1747 $resql = $this->db->query($sql);
1749 $num = $this->db->num_rows($resql);
1753 $obj = $this->db->fetch_object($resql);
1756 $label = ($obj->code != $langs->trans($obj->code) ? $langs->trans($obj->code) : $langs->trans($obj->label));
1757 $this->cache_types_fees[$obj->code] = $label;
1761 asort($this->cache_types_fees);
1783 global $user, $langs;
1785 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
1789 print
'<select id="select_' . $htmlname .
'" class="flat" name="' . $htmlname .
'">';
1791 print
'<option value="-1"';
1792 if ($selected == -1) {
1795 print
'> </option>';
1798 foreach ($this->cache_types_fees as $key => $value) {
1799 print
'<option value="' . $key .
'"';
1800 if ($key == $selected) {
1810 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1839 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)
1842 global
$conf, $langs;
1846 if (!empty(
$conf->use_javascript_ajax) &&
getDolGlobalString(
'COMPANY_USE_SEARCH_TO_SELECT') && !$forcecombo) {
1847 if (is_null($ajaxoptions)) {
1848 $ajaxoptions = array();
1851 require_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1855 if ($selected && empty($selected_input_value)) {
1856 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
1857 $societetmp =
new Societe($this->db);
1858 $societetmp->fetch($selected);
1859 $selected_input_value = $societetmp->name;
1864 $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)) :
'') . ($limit ?
'&limit='.$limit :
'');
1866 $out .=
'<!-- force css to be higher than dialog popup --><style type="text/css">.ui-autocomplete { z-index: 1010; }</style>';
1867 if (empty($hidelabel)) {
1868 $out .= $langs->trans(
"RefOrLabel") .
' : ';
1869 } elseif ($hidelabel == 1 && !is_numeric($showempty)) {
1870 $placeholder = $langs->trans($showempty);
1871 } elseif ($hidelabel > 1) {
1872 $placeholder = $langs->trans(
"RefOrLabel");
1873 if ($hidelabel == 2) {
1874 $out .=
img_picto($langs->trans(
"Search"),
'search');
1877 $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' :
'') .
' spellcheck="false" />';
1878 if ($hidelabel == 3) {
1879 $out .=
img_picto($langs->trans(
"Search"),
'search');
1884 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/societe/ajax/company.php', $urloption,
getDolGlobalInt(
'COMPANY_USE_SEARCH_TO_SELECT'), 0, $ajaxoptions);
1887 $out .= $this->
select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events,
'', 0, $limit, $morecss, $moreparam, $multiple, $excludeids, $showcode);
1921 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 =
'')
1925 global
$conf, $langs;
1930 if ($nokeyifsocid && $socid > 0) {
1931 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1934 if (!empty(
$conf->use_javascript_ajax) &&
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && !$forcecombo) {
1935 $ajaxoptions = array();
1937 require_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1941 if ($selected && empty($selected_input_value)) {
1942 require_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
1943 $contacttmp =
new Contact($this->db);
1944 $contacttmp->fetch($selected);
1945 $selected_input_value = $contacttmp->getFullName($langs);
1948 if (!is_numeric($showempty)) {
1949 $placeholder = $showempty;
1953 $urloption =
'htmlname=' . urlencode((
string) (str_replace(
'.',
'_', $htmlname))) .
'&outjson=1&filter=' . urlencode((
string) ($filter)) . (empty($exclude) ?
'' :
'&exclude=' . urlencode($exclude)) . ($showsoc ?
'&showsoc=' . urlencode((
string) ($showsoc)) :
'');
1955 $out .=
'<!-- force css to be higher than dialog popup --><style type="text/css">.ui-autocomplete { z-index: 1010; }</style>';
1957 $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' :
'') .
' spellcheck="false" />';
1961 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/contact/ajax/contact.php', $urloption,
getDolGlobalInt(
'CONTACT_USE_SEARCH_TO_SELECT'), 0, $ajaxoptions);
1965 $disableifempty = 0;
1969 $out .= $this->
selectcontacts($socid, $selected, $htmlname, $showempty, $exclude, $limitto, $showfunction, $morecss, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid, $multiple, $disableifempty);
1972 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2003 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)
2006 global $user, $langs;
2007 global $hookmanager;
2009 $langs->loadLangs(array(
"companies",
"suppliers"));
2013 $outarray = array();
2015 if ($selected ===
'') {
2016 $selected = array();
2017 } elseif (!is_array($selected)) {
2018 $selected = array($selected);
2022 if (function_exists(
'testSqlAndScriptInject')) {
2025 return 'SQLInjectionTryDetected';
2029 if ($filter !=
'') {
2031 $filter = forgeSQLFromUniversalSearchCriteria($filter, $errormsg, 1);
2034 if (function_exists(
'testSqlAndScriptInject')) {
2037 return 'SQLInjectionTryDetected';
2043 $sql =
"SELECT s.rowid, s.nom as name, s.name_alias, s.tva_intra, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
2045 $sql .=
", s.address, s.zip, s.town";
2046 $sql .=
", dictp.code as country_code";
2048 $sql .=
" FROM " . $this->db->prefix() .
"societe as s";
2050 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_country as dictp ON dictp.rowid = s.fk_pays";
2052 if (!$user->hasRight(
'societe',
'client',
'voir')) {
2053 $sql .=
", " . $this->db->prefix() .
"societe_commerciaux as sc";
2055 $sql .=
" WHERE s.entity IN (" .
getEntity(
'societe') .
")";
2056 if (!empty($user->socid)) {
2057 $sql .=
" AND s.rowid = " . ((int) $user->socid);
2061 $sqlwhere = $filter;
2062 $sql .=
" AND (" . $sqlwhere .
")";
2064 if (!$user->hasRight(
'societe',
'client',
'voir')) {
2065 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = " . ((int) $user->id);
2068 $sql .=
" AND s.status <> 0";
2070 if (!empty($excludeids)) {
2071 $sql .=
" AND s.rowid NOT IN (" . $this->db->sanitize(implode(
',', $excludeids)) .
")";
2074 $parameters = array();
2075 $reshook = $hookmanager->executeHooks(
'selectThirdpartyListWhere', $parameters);
2076 $sql .= $hookmanager->resPrint;
2078 if ($filterkey && $filterkey !=
'') {
2082 $search_crit = explode(
' ', $filterkey);
2084 if (count($search_crit) > 1) {
2087 foreach ($search_crit as $crit) {
2091 $sql .=
"(s.nom LIKE '" . $this->db->escape($prefix . $crit) .
"%')";
2094 if (count($search_crit) > 1) {
2098 $sql .=
" OR s.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
2100 $sql .=
" OR s.code_client LIKE '" . $this->db->escape($prefix . $filterkey) .
"%' OR s.code_fournisseur LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
2101 $sql .=
" OR s.name_alias LIKE '" . $this->db->escape($prefix . $filterkey) .
"%' OR s.tva_intra LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
2104 $sql .= $this->db->order(
"nom",
"ASC");
2105 $sql .= $this->db->plimit($limit, 0);
2108 dol_syslog(get_class($this).
"::select_thirdparty_list", LOG_DEBUG);
2109 $resql = $this->db->query($sql);
2112 $out .=
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($moreparam ?
' ' . $moreparam :
'') .
' name="' . $htmlname . ($multiple ?
'[]' :
'') .
'"' . ($multiple ?
' multiple' :
'') .
'>' .
"\n";
2114 $textifempty = (($showempty && !is_numeric($showempty)) ? $langs->trans($showempty) :
'');
2118 if ($showempty && !is_numeric($showempty)) {
2119 $textifempty = $langs->trans($showempty);
2121 $textifempty .= $langs->trans(
"All");
2125 $out .=
'<option value="-1" data-html="' .
dol_escape_htmltag(
'<span class="opacitymedium">' . ($textifempty ? $textifempty :
' ') .
'</span>') .
'">' . $textifempty .
'</option>' .
"\n";
2128 $companytemp =
new Societe($this->db);
2130 $num = $this->db->num_rows($resql);
2134 $obj = $this->db->fetch_object($resql);
2137 if (($obj->client) && (!empty($obj->code_client))) {
2138 $label = $obj->code_client .
' - ';
2140 if (($obj->fournisseur) && (!empty($obj->code_fournisseur))) {
2141 $label .= $obj->code_fournisseur .
' - ';
2143 $label .=
' ' . $obj->name;
2145 $label = $obj->name;
2148 if (!empty($obj->name_alias)) {
2149 $label .=
' (' . $obj->name_alias .
')';
2153 $label .=
' - '.$obj->tva_intra;
2156 $labelhtml = $label;
2159 $companytemp->id = $obj->rowid;
2160 $companytemp->client = $obj->client;
2161 $companytemp->fournisseur = $obj->fournisseur;
2162 $tmptype = $companytemp->getTypeUrl(1,
'', 0,
'span');
2164 $labelhtml .=
' ' . $tmptype;
2167 if ($obj->client || $obj->fournisseur) {
2170 if ($obj->client == 1 || $obj->client == 3) {
2171 $label .= $langs->trans(
"Customer");
2173 if ($obj->client == 2 || $obj->client == 3) {
2174 $label .= ($obj->client == 3 ?
', ' :
'') . $langs->trans(
"Prospect");
2176 if ($obj->fournisseur) {
2177 $label .= ($obj->client ?
', ' :
'') . $langs->trans(
"Supplier");
2179 if ($obj->client || $obj->fournisseur) {
2185 $s = ($obj->address ?
' - ' . $obj->address :
'') . ($obj->zip ?
' - ' . $obj->zip :
'') . ($obj->town ?
' ' . $obj->town :
'');
2186 if (!empty($obj->country_code)) {
2187 $s .=
', ' . $langs->trans(
'Country' . $obj->country_code);
2193 if (empty($outputmode)) {
2194 if (in_array($obj->rowid, $selected)) {
2195 $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>';
2197 $out .=
'<option value="' . $obj->rowid .
'" data-html="' .
dol_escape_htmltag($labelhtml, 0, 0,
'', 0, 1) .
'">' .
dol_escape_htmltag($label, 0, 0,
'', 0, 1) .
'</option>';
2200 array_push($outarray, array(
'key' => $obj->rowid,
'value' => $label,
'label' => $label,
'labelhtml' => $labelhtml));
2204 if (($i % 10) == 0) {
2209 $out .=
'</select>' .
"\n";
2211 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
2218 $this->result = array(
'nbofthirdparties' => $num);
2252 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 =
'')
2254 global
$conf, $user, $langs, $hookmanager, $action;
2256 $langs->load(
'companies');
2258 if (empty($htmlid)) {
2259 $htmlid = $htmlname;
2263 $outarray = array();
2265 if ($selected ===
'') {
2266 $selected = array();
2267 } elseif (!is_array($selected)) {
2268 $selected = array((
int) $selected);
2272 if (function_exists(
'testSqlAndScriptInject')) {
2275 return 'SQLInjectionTryDetected';
2279 if ($filter !=
'') {
2280 if (preg_match(
'/[\(\)]/', $filter)) {
2283 $filter = forgeSQLFromUniversalSearchCriteria($filter, $errormsg, 1);
2286 if (function_exists(
'testSqlAndScriptInject')) {
2289 return 'SQLInjectionTryDetected';
2295 dol_syslog(
"Warning, select_thirdparty_list was called with a filter criteria not using the Universal Search Filter Syntax.", LOG_WARNING);
2299 if (!is_object($hookmanager)) {
2300 include_once DOL_DOCUMENT_ROOT .
'/core/class/hookmanager.class.php';
2305 $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";
2306 if ($showsoc > 0 ||
getDolGlobalString(
'CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST')) {
2307 $sql .=
", s.nom as company, s.town AS company_town";
2309 $sql .=
" FROM " . $this->db->prefix() .
"socpeople as sp";
2310 if ($showsoc > 0 ||
getDolGlobalString(
'CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST')) {
2311 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON s.rowid = sp.fk_soc";
2313 $sql .=
" WHERE sp.entity IN (" .
getEntity(
'contact') .
")";
2314 $sql .=
" AND ((sp.fk_user_creat = ".((int) $user->id).
" AND sp.priv = 1) OR sp.priv = 0)";
2315 if ($socid > 0 || $socid == -1) {
2316 $sql .=
" AND sp.fk_soc = " . ((int) $socid);
2319 $sql .=
" AND sp.statut <> 0";
2322 if (!$user->hasRight(
'societe',
'client',
'voir') && !$user->socid) {
2323 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = sp.fk_soc AND sc.fk_user = ".(int) $user->id .
")";
2325 if ($user->socid > 0) {
2326 $sql .=
" AND sp.fk_soc = ".((int) $user->socid);
2331 $sanitizedfilter = $filter;
2332 $sql .=
" AND (" . $sanitizedfilter .
")";
2335 $parameters = array();
2336 $reshook = $hookmanager->executeHooks(
'selectContactListWhere', $parameters);
2337 $sql .= $hookmanager->resPrint;
2338 $sql .=
" ORDER BY sp.lastname ASC";
2340 dol_syslog(get_class($this) .
"::selectcontacts", LOG_DEBUG);
2341 $resql = $this->db->query($sql);
2343 $num = $this->db->num_rows($resql);
2345 if ($htmlname !=
'none' && !$options_only) {
2346 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlid .
'" name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . (($num || empty($disableifempty)) ?
'' :
' disabled') . ($multiple ?
'multiple' :
'') .
' ' . (!empty($moreparam) ? $moreparam :
'') .
'>';
2349 if ($showempty && !is_numeric($showempty)) {
2350 $textforempty = $showempty;
2351 $out .=
'<option class="optiongrey" value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'>' . $textforempty .
'</option>';
2353 if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) {
2354 $out .=
'<option value="0"' . (in_array(0, $selected) ?
' selected' :
'') .
'> </option>';
2356 if ($showempty == 2) {
2357 $out .=
'<option value="0"' . (in_array(0, $selected) ?
' selected' :
'') .
'>-- ' . $langs->trans(
"Internal") .
' --</option>';
2363 include_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
2364 $contactstatic =
new Contact($this->db);
2367 $obj = $this->db->fetch_object($resql);
2370 $extendedInfos =
'';
2372 $extendedInfos = array();
2373 $email = trim($obj->email);
2374 if (!empty($email)) {
2375 $extendedInfos[] = $email;
2377 $phone = trim($obj->phone);
2378 $phone_perso = trim($obj->phone_perso);
2379 $phone_mobile = trim($obj->phone_mobile);
2380 if (!empty($phone)) {
2381 $extendedInfos[] = $phone;
2383 if (!empty($phone_perso)) {
2384 $extendedInfos[] = $phone_perso;
2386 if (!empty($phone_mobile)) {
2387 $extendedInfos[] = $phone_mobile;
2390 $contact_town = trim($obj->contact_town);
2391 $company_town = trim($obj->company_town);
2392 if (!empty($contact_town)) {
2393 $extendedInfos[] = $contact_town;
2394 } elseif (!empty($company_town)) {
2395 $extendedInfos[] = $company_town;
2397 $extendedInfos = implode(
' - ', $extendedInfos);
2398 if (!empty($extendedInfos)) {
2399 $extendedInfos =
' - ' . $extendedInfos;
2403 $contactstatic->id = $obj->rowid;
2404 $contactstatic->lastname = $obj->lastname;
2405 $contactstatic->firstname = $obj->firstname;
2406 if ($obj->statut == 1) {
2408 if ($htmlname !=
'none') {
2410 if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) {
2413 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
2416 if (!empty($selected) && in_array($obj->rowid, $selected)) {
2417 $out .=
'<option value="' . $obj->rowid .
'"';
2419 $out .=
' disabled';
2421 $out .=
' selected>';
2423 $tmplabel = $contactstatic->getFullName($langs) . $extendedInfos;
2424 if ($showfunction && $obj->poste) {
2425 $tmplabel .=
' (' . $obj->poste .
')';
2427 if (($showsoc > 0) && $obj->company) {
2428 $tmplabel .=
' - (' . $obj->company .
')';
2432 $out .=
'</option>';
2434 $out .=
'<option value="' . $obj->rowid .
'"';
2436 $out .=
' disabled';
2440 $tmplabel = $contactstatic->getFullName($langs) . $extendedInfos;
2441 if ($showfunction && $obj->poste) {
2442 $tmplabel .=
' (' . $obj->poste .
')';
2444 if (($showsoc > 0) && $obj->company) {
2445 $tmplabel .=
' - (' . $obj->company .
')';
2449 $out .=
'</option>';
2452 if (in_array($obj->rowid, $selected)) {
2453 $tmplabel = $contactstatic->getFullName($langs) . $extendedInfos;
2454 if ($showfunction && $obj->poste) {
2455 $tmplabel .=
' (' . $obj->poste .
')';
2457 if (($showsoc > 0) && $obj->company) {
2458 $tmplabel .=
' - (' . $obj->company .
')';
2465 if ($tmplabel !=
'') {
2466 array_push($outarray, array(
'key' => $obj->rowid,
'value' => $tmplabel,
'label' => $tmplabel,
'labelhtml' => $tmplabel));
2472 $labeltoshow = ($socid != -1) ? ($langs->trans($socid ?
"NoContactDefinedForThirdParty" :
"NoContactDefined")) : $langs->trans(
'SelectAThirdPartyFirst');
2473 $out .=
'<option class="disabled" value="-1"' . (($showempty == 2 || $multiple) ?
'' :
' selected') .
' disabled="disabled">';
2474 $out .= $labeltoshow;
2475 $out .=
'</option>';
2478 $parameters = array(
2480 'htmlname' => $htmlname,
2483 'showfunction' => $showfunction,
2484 'showsoc' => $showsoc,
2487 $reshook = $hookmanager->executeHooks(
'afterSelectContactOptions', $parameters, $this, $action);
2489 if ($htmlname !=
'none' && !$options_only) {
2490 $out .=
'</select>';
2493 if (
$conf->use_javascript_ajax && !$forcecombo && !$options_only) {
2494 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
2500 if ($options_only === 2) {
2528 global $langs,
$conf;
2531 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
2532 $sql .=
" re.description, re.fk_facture_source";
2533 $sql .=
" FROM " . $this->db->prefix() .
"societe_remise_except as re";
2534 $sql .=
" WHERE re.fk_soc = " . (int) $socid;
2535 $sql .=
" AND re.entity = " . ((int)
$conf->entity);
2537 $sanitizedfilter = $filter;
2538 $sql .=
" AND " . $sanitizedfilter;
2540 $sql .=
" ORDER BY re.description ASC";
2542 dol_syslog(get_class($this) .
"::select_remises", LOG_DEBUG);
2543 $resql = $this->db->query($sql);
2545 print
'<select id="select_' . $htmlname .
'" class="flat maxwidth200onsmartphone" name="' . $htmlname .
'">';
2546 $num = $this->db->num_rows($resql);
2548 $qualifiedlines = $num;
2552 print
'<option value="0"> </option>';
2554 $obj = $this->db->fetch_object($resql);
2555 $desc =
dol_trunc($obj->description, 40);
2556 if (preg_match(
'/\(CREDIT_NOTE\)/', $desc)) {
2557 $desc = preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $desc);
2559 if (preg_match(
'/\(DEPOSIT\)/', $desc)) {
2560 $desc = preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"Deposit"), $desc);
2562 if (preg_match(
'/\(EXCESS RECEIVED\)/', $desc)) {
2563 $desc = preg_replace(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"ExcessReceived"), $desc);
2565 if (preg_match(
'/\(EXCESS PAID\)/', $desc)) {
2566 $desc = preg_replace(
'/\(EXCESS PAID\)/', $langs->trans(
"ExcessPaid"), $desc);
2570 if ($selected > 0 && $selected == $obj->rowid) {
2571 $selectstring =
' selected';
2575 if ($maxvalue > 0 && $obj->amount_ttc > $maxvalue) {
2577 $disabled =
' disabled';
2580 if (
getDolGlobalString(
'MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST') && !empty($obj->fk_facture_source)) {
2581 $tmpfac =
new Facture($this->db);
2582 if ($tmpfac->fetch($obj->fk_facture_source) > 0) {
2583 $desc = $desc .
' - ' . $tmpfac->ref;
2587 print
'<option value="' . $obj->rowid .
'"' . $selectstring . $disabled .
'>' . $desc .
' (' .
price($obj->amount_ht) .
' ' . $langs->trans(
"HT") .
' - ' .
price($obj->amount_ttc) .
' ' . $langs->trans(
"TTC") .
')</option>';
2594 return $qualifiedlines;
2619 public function select_users($selected =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include =
'', $enableonly = array(), $force_entity =
'0')
2622 print $this->
select_dolusers($selected, $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity);
2651 public function select_dolusers($userselected =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'', $maxlength = 0, $showstatus = 0, $morefilter =
'', $showalso = 0, $enableonlytext =
'', $morecss =
'', $notdisabled = 0, $outputmode = 0, $multiple =
false, $forcecombo = 0)
2654 global
$conf, $user, $langs, $hookmanager;
2658 if (is_object($userselected)) {
2659 $selected = (int) $userselected->id;
2660 } elseif (is_numeric($userselected)) {
2661 $selected = (int) $userselected;
2662 } elseif (is_array($userselected)) {
2663 $selected = $userselected;
2669 if ((is_numeric($selected) && ((
int) $selected < -4 || empty($selected))) && !
getDolGlobalString(
'SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE')) {
2670 $selected = $user->id;
2674 if (!is_array($selected)) {
2675 if ($selected === -1 || $selected ===
'') {
2676 $selected = array();
2678 $selected = array($selected);
2683 $excludeUsers =
null;
2684 if (is_array($exclude)) {
2685 $excludeUsers = implode(
",", $exclude);
2689 $includeUsers =
null;
2690 $includeUsersArray = array();
2691 if (is_array($include)) {
2692 $includeUsersArray = $include;
2693 } elseif ($include ==
'hierarchy') {
2695 $includeUsersArray = $user->getAllChildIds(0);
2696 } elseif ($include ==
'hierarchyme') {
2698 $includeUsersArray = $user->getAllChildIds(1);
2713 $includeUsers = implode(
",", $includeUsersArray);
2718 $outarray = array();
2719 $outarray2 = array();
2722 $showlabelofentity =
isModEnabled(
'multicompany') && !
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') &&
$conf->entity == 1 && !empty($user->admin) && empty($user->entity) && !preg_match(
'/^search_/', $htmlname);
2723 $userissuperadminentityone =
isModEnabled(
'multicompany') &&
$conf->entity == 1 && $user->admin && empty($user->entity);
2726 $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";
2727 if ($showlabelofentity) {
2728 $sql .=
", e.label";
2730 $sql .=
" FROM " . $this->db->prefix() .
"user as u";
2731 if ($showlabelofentity) {
2732 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entity as e ON e.rowid = u.entity";
2735 if ($userissuperadminentityone && $force_entity !==
'default') {
2736 if (!empty($force_entity)) {
2737 $sql .=
" WHERE u.entity IN (0, " . $this->db->sanitize($force_entity) .
")";
2739 $sql .=
" WHERE u.entity IS NOT NULL";
2743 $sql .=
" WHERE u.rowid IN (SELECT ug.fk_user FROM ".$this->db->prefix().
"usergroup_user as ug WHERE ug.entity IN (".
getEntity(
'usergroup').
"))";
2745 $sql .=
" WHERE u.entity IN (" .
getEntity(
'user') .
")";
2749 if (!empty($user->socid)) {
2750 $sql .=
" AND u.fk_soc = " . ((int) $user->socid);
2752 if (is_array($exclude) && $excludeUsers) {
2753 $sql .=
" AND u.rowid NOT IN (" . $this->db->sanitize($excludeUsers) .
")";
2755 if ($includeUsers) {
2756 $sql .=
" AND u.rowid IN (" . $this->db->sanitize($includeUsers) .
")";
2759 $sql .=
" AND (u.statut <> 0";
2760 if (!empty($selected)) {
2761 $sql .=
" OR rowid IN (".$this->db->sanitize(implode(
',', $selected)).
")";
2766 $sql .=
" AND u.employee <> 0";
2769 $sql .=
" AND u.fk_soc IS NULL";
2771 if (!empty($morefilter)) {
2773 $sql .= forgeSQLFromUniversalSearchCriteria($morefilter, $errormessage);
2774 if ($errormessage) {
2775 $this->errors[] = $errormessage;
2776 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
2777 if ($outputmode == 0) {
2778 return 'Error bad param $morefilter';
2786 $reshook = $hookmanager->executeHooks(
'addSQLWhereFilterOnSelectUsers', array(), $this, $action);
2787 if (!empty($reshook)) {
2788 $sql .= $hookmanager->resPrint;
2792 $sql .=
" ORDER BY u.statut DESC, u.firstname ASC, u.lastname ASC";
2794 $sql .=
" ORDER BY u.statut DESC, u.lastname ASC, u.firstname ASC";
2797 dol_syslog(get_class($this) .
"::select_dolusers", LOG_DEBUG);
2799 $resql = $this->db->query($sql);
2801 $num = $this->db->num_rows($resql);
2805 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
' minwidth200') .
'" id="' . $htmlname .
'" name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
' ' . ($disabled ?
' disabled' :
'') .
'>';
2806 if ($show_empty && !$multiple) {
2807 $textforempty =
' ';
2808 if (!empty(
$conf->use_javascript_ajax)) {
2809 $textforempty =
' ';
2811 if (!is_numeric($show_empty)) {
2812 $textforempty = $show_empty;
2814 $out .=
'<option class="optiongrey" value="' . ($show_empty < 0 ? $show_empty : -1) .
'"' . ((empty($selected) || in_array(-1, $selected)) ?
' selected' :
'') .
'>' . $textforempty .
'</option>' .
"\n";
2816 $outarray[($show_empty < 0 ? $show_empty : -1)] = $textforempty;
2817 $outarray2[($show_empty < 0 ? $show_empty : -1)] = array(
2818 'id' => ($show_empty < 0 ? $show_empty : -1),
2819 'label' => $textforempty,
2820 'labelhtml' => $textforempty,
2825 if ($showalso == 2 || $showalso == 3) {
2826 $out .=
'<option value="-3"' . ((in_array(-3, $selected)) ?
' selected' :
'') .
'>-- ' . $langs->trans(
"MyTeam") .
' --</option>' .
"\n";
2828 $hasAtLeastOneSubordinate = (count($user->getAllChildIds(1)) > 1);
2829 if ($hasAtLeastOneSubordinate) {
2831 $outarray[-3] =
'-- ' . $langs->trans(
"MyTeam") .
' --';
2832 $outarray2[-3] = array(
2834 'label' =>
'-- ' . $langs->trans(
"MyTeam") .
' --',
2835 'labelhtml' =>
'-- ' . $langs->trans(
"MyTeam") .
' --',
2841 if ($showalso == 1 || $showalso == 3) {
2842 $out .=
'<option value="-2"' . ((in_array(-2, $selected)) ?
' selected' :
'') .
'>-- ' . $langs->trans(
"Everybody") .
' --</option>' .
"\n";
2844 $outarray[-2] =
'-- ' . $langs->trans(
"Everybody") .
' --';
2845 $outarray2[-2] = array(
2847 'label' =>
'-- ' . $langs->trans(
"Everybody") .
' --',
2848 'labelhtml' =>
'-- ' . $langs->trans(
"Everybody") .
' --',
2853 if ($showalso == 4) {
2854 $out .=
'<option value="-4"' . ((in_array(-4, $selected)) ?
' selected' :
'') .
'>-- ' . $langs->trans(
"AllProjectContacts") .
' --</option>' .
"\n";
2856 $outarray[-4] =
'-- ' . $langs->trans(
"AllProjectContacts") .
' --';
2857 $outarray2[-4] = array(
2859 'label' =>
'-- ' . $langs->trans(
"AllProjectContacts") .
' --',
2860 'labelhtml' =>
'-- ' . $langs->trans(
"AllProjectContacts") .
' --',
2866 $userstatic =
new User($this->db);
2869 $obj = $this->db->fetch_object($resql);
2871 $userstatic->id = $obj->rowid;
2872 $userstatic->lastname = $obj->lastname;
2873 $userstatic->firstname = $obj->firstname;
2874 $userstatic->photo = $obj->photo;
2875 $userstatic->status = $obj->status;
2876 $userstatic->entity = $obj->entity;
2877 $userstatic->admin = $obj->admin;
2878 $userstatic->gender = $obj->gender;
2881 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
2882 $disableline = ($enableonlytext ? $enableonlytext :
'1');
2886 $labeltoshowhtml =
'';
2893 $labeltoshow .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
2894 $labeltoshowhtml .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
2895 if (empty($obj->firstname) && empty($obj->lastname)) {
2896 $labeltoshow .= $obj->login;
2897 $labeltoshowhtml .= $obj->login;
2904 $moreinfo .= ($moreinfo ?
' - ' :
' (');
2905 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(');
2906 $moreinfo .= $obj->login;
2907 $moreinfohtml .= $obj->login;
2909 if ($showstatus >= 0) {
2910 if ($obj->status == 1 && $showstatus == 1) {
2911 $moreinfo .= ($moreinfo ?
' - ' :
' (') . $langs->trans(
'Enabled');
2912 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . $langs->trans(
'Enabled');
2914 if ($obj->status == 0 && $showstatus == 1) {
2915 $moreinfo .= ($moreinfo ?
' - ' :
' (') . $langs->trans(
'Disabled');
2916 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . $langs->trans(
'Disabled');
2919 if ($showlabelofentity) {
2920 if (empty($obj->entity)) {
2921 $moreinfo .= ($moreinfo ?
' - ' :
' (') . $langs->trans(
"AllEntities");
2922 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . $langs->trans(
"AllEntities");
2924 if ($obj->entity !=
$conf->entity) {
2925 $moreinfo .= ($moreinfo ?
' - ' :
' (') . ($obj->label ? $obj->label : $langs->trans(
"EntityNameNotDefined"));
2926 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(').($obj->label ? $obj->label : $langs->trans(
"EntityNameNotDefined"));
2930 $moreinfo .= (!empty($moreinfo) ?
')' :
'');
2931 $moreinfohtml .= (!empty($moreinfohtml) ?
')</span>' :
'');
2932 if (!empty($disableline) && $disableline !=
'1') {
2934 $moreinfo .=
' - ' . $disableline;
2935 $moreinfohtml .=
' - ' . $disableline;
2937 $labeltoshow .= $moreinfo;
2938 $labeltoshowhtml .= $moreinfohtml;
2940 $out .=
'<option value="' . $obj->rowid .
'"';
2941 if (!empty($disableline)) {
2942 $out .=
' disabled';
2944 if (in_array($obj->rowid, $selected)) {
2945 $out .=
' selected';
2947 $out .=
' data-html="';
2949 $outhtml = $userstatic->getNomUrl(-3,
'', 0, 1, 24, 1,
'login',
'', 1) .
' ';
2950 if ($showstatus >= 0 && $obj->status == 0) {
2951 $outhtml .=
'<strike class="opacitymediumxxx">';
2953 $outhtml .= $labeltoshowhtml;
2954 if ($showstatus >= 0 && $obj->status == 0) {
2955 $outhtml .=
'</strike>';
2957 $labeltoshowhtml = $outhtml;
2961 $out .= $labeltoshow;
2962 $out .=
'</option>';
2964 $outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength) . $moreinfo;
2965 $outarray2[$userstatic->id] = array(
2966 'id' => $userstatic->id,
2967 'label' => $labeltoshow,
2968 'labelhtml' => $labeltoshowhtml,
2976 $out .=
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'" disabled>';
2977 $out .=
'<option value="">' . $langs->trans(
"None") .
'</option>';
2979 $out .=
'</select>';
2981 if ($num && !$forcecombo) {
2983 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
2992 if ($outputmode == 2) {
2994 } elseif ($outputmode) {
3026 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(), $canremoveowner = 1)
3029 global $langs, $user;
3031 $userstatic =
new User($this->db);
3034 if (!empty($_SESSION[
'assignedtouser'])) {
3035 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
3036 if (!is_array($assignedtouser)) {
3037 $assignedtouser = array();
3040 $assignedtouser = array();
3042 $nbassignetouser = count($assignedtouser);
3045 if ($nbassignetouser) {
3046 $out .=
'<ul class="attendees">';
3050 foreach ($assignedtouser as $key => $value) {
3051 if ($value[
'id'] == $ownerid) {
3057 $userstatic->fetch($value[
'id']);
3058 $out .= $userstatic->getNomUrl(-4);
3061 $ownerid = $value[
'id'];
3062 $out .=
' (' . $langs->trans(
"Owner") .
')';
3065 if ($nbassignetouser > 1 && $action !=
'view') {
3066 $canremoveassignee = 1;
3069 if (!$canremoveowner) {
3070 $canremoveassignee = 0;
3072 if (!$user->hasRight(
'agenda',
'allactions',
'create')) {
3073 $canremoveassignee = 0;
3078 if ($canremoveassignee) {
3081 $out .=
' <input type="image" style="border: 0px;" src="' .
img_picto($langs->trans(
"Remove"),
'delete',
'', 0, 1) .
'" value="' . $userstatic->id .
'" class="noborderfocus removedassigned reposition" id="removedassigned_' . $userstatic->id .
'" name="removedassigned_' . $userstatic->id .
'">';
3085 if ($showproperties) {
3086 if ($ownerid == $value[
'id'] && is_array($listofuserid) && count($listofuserid) && in_array($ownerid, array_keys($listofuserid))) {
3087 $out .=
'<div class="myavailability inline-block">';
3088 $out .=
'<span class="hideonsmartphone"> - ';
3091 $out .=
' <input title="'.$langs->trans(
"Availability").
'" id="transparency" class="paddingrightonly" ' . ($action ==
'view' ?
'disabled' :
'') .
' type="checkbox" name="transparency"' . ($listofuserid[$ownerid][
'transparency'] ?
' checked' :
'') .
'><label for="transparency">' . $langs->trans(
"Busy") .
'</label>';
3101 if ($nbassignetouser) {
3106 if ($action !=
'view') {
3108 $out .=
'<div class="divadduser'.$htmlname.
'">';
3109 $out .=
'<input type="hidden" class="removedassignedhidden" name="removedassigned" value="">';
3110 $out .=
'<script nonce="' . getNonce() .
'" type="text/javascript">jQuery(document).ready(function () {';
3111 $out .=
'jQuery(".removedassigned").click(function() { jQuery(".removedassignedhidden").val(jQuery(this).val()); });';
3112 $out .=
'jQuery(".assignedtouser").change(function() { console.log(jQuery(".assignedtouser option:selected").val());';
3113 $out .=
' if (jQuery(".assignedtouser option:selected").val() > 0) { jQuery("#' . $action .
'assignedtouser").attr("disabled", false); }';
3114 $out .=
' else { jQuery("#' . $action .
'assignedtouser").attr("disabled", true); }';
3116 $out .=
'})</script>';
3117 $out .=
img_picto(
'',
'user',
'class="pictofixedwidth"');
3118 $out .= $this->
select_dolusers(
'', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter, 0,
'',
'minwidth200');
3119 $out .=
' <button type="submit" disabled class="button valignmiddle smallpaddingimp reposition butActionAdd" id="' . $action .
'assignedtouser" name="' . $action .
'assignedtouser" value="' .
dol_escape_htmltag($langs->trans(
"Add")) .
'">';
3120 $out .= $langs->trans(
"Add").
'</button>';
3148 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())
3153 require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
3154 require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
3159 if (!empty($_SESSION[
'assignedtoresource'])) {
3160 $assignedtoresource = json_decode($_SESSION[
'assignedtoresource'],
true);
3161 if (!is_array($assignedtoresource)) {
3162 $assignedtoresource = array();
3165 $assignedtoresource = array();
3167 $nbassignetoresource = count($assignedtoresource);
3170 if ($nbassignetoresource) {
3171 $out .=
'<ul class="attendees">';
3175 foreach ($assignedtoresource as $key => $value) {
3177 $resourcestatic->fetch($value[
'id']);
3178 $out .= $resourcestatic->getNomUrl(-1);
3179 if ($nbassignetoresource >= 1 && $action !=
'view') {
3180 $out .=
' <input type="image" style="border: 0px;" src="' .
img_picto($langs->trans(
"Remove"),
'delete',
'', 0, 1) .
'" value="' . $resourcestatic->id .
'" class="removedassignedresource reposition" id="removedassignedresource_' . $resourcestatic->id .
'" name="removedassignedresource_' . $resourcestatic->id .
'">';
3183 if ($showproperties) {
3184 if (is_array($listofresourceid) && count($listofresourceid)) {
3185 $out .=
'<div class="myavailability inline-block">';
3186 $out .=
'<span class="hideonsmartphone"> - ';
3189 $out .=
' <input title="'.$langs->trans(
"Availability").
'" id="transparencyresource'.$value[
'id'].
'" class="paddingrightonly" ' . ($action ==
'view' ?
'disabled' :
'') .
' type="checkbox" name="transparency"' . ($listofresourceid[$value[
'id']][
'transparency'] ?
' checked' :
'') .
'><label for="transparencyresource'.$value[
'id'].
'">' . $langs->trans(
"Busy") .
'</label>';
3199 if ($nbassignetoresource) {
3204 if ($action !=
'view') {
3205 $out .=
'<input type="hidden" class="removedassignedresourcehidden" name="removedassignedresource" value="">';
3206 $out .=
'<script nonce="' . getNonce() .
'" type="text/javascript">jQuery(document).ready(function () {';
3207 $out .=
'jQuery(".removedassignedresource").click(function() { jQuery(".removedassignedresourcehidden").val(jQuery(this).val()); });';
3208 $out .=
'jQuery(".assignedtoresource").change(function() { console.log(jQuery(".assignedtoresource option:selected").val());';
3209 $out .=
' if (jQuery(".assignedtoresource option:selected").val() > 0) { jQuery("#' . $action .
'assignedtoresource").attr("disabled", false); }';
3210 $out .=
' else { jQuery("#' . $action .
'assignedtoresource").attr("disabled", true); }';
3212 $out .=
'})</script>';
3215 if ($nbassignetoresource) {
3218 $out .=
img_picto(
'',
'resource',
'class="pictofixedwidth"');
3220 $out .= $formresources->select_resource_list(0, $htmlname,
'', 1, 1, 0, $events,
'', 2, 0,
'minwidth200');
3222 $out .=
' <button type="submit" disabled class="button valignmiddle smallpaddingimp reposition butActionAdd" id="' . $action .
'assignedtoresource" name="' . $action .
'assignedtoresource" value="' .
dol_escape_htmltag($langs->trans(
"Add")) .
'">';
3223 $out .= $langs->trans(
"Add");
3224 $out .=
'</button>';
3262 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, $warehouseId = 0)
3265 global $langs,
$conf;
3270 $price_level = (!empty($price_level) ? $price_level : 0);
3271 if (is_null($ajaxoptions)) {
3272 $ajaxoptions = array();
3284 $placeholder = (is_numeric($showempty) ?
'' :
'placeholder="'.dolPrintHTML($showempty).
'"');
3286 if ($selected && empty($selected_input_value)) {
3287 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
3288 $producttmpselect =
new Product($this->db);
3289 $producttmpselect->fetch($selected);
3290 $selected_input_value = $producttmpselect->ref;
3291 unset($producttmpselect);
3294 if ($filtertype ==
'') {
3302 $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;
3303 if ((
int) $warehouseId > 0) {
3304 $urloption .=
'&warehouseid=' . (int) $warehouseId;
3307 if (
isModEnabled(
'variants') && is_array($selected_combinations)) {
3313 <!-- script to auto show attributes select tags if a variant was selected -->
3314 <script nonce="' . getNonce() .
'">
3315 // auto show attributes fields
3316 selected = ' . json_encode($selected_combinations) .
';
3319 jQuery(document).ready(function () {
3321 jQuery("input[name=\'prod_entry_mode\']").change(function () {
3322 if (jQuery(this).val() == \'free\') {
3323 jQuery(\'div#attributes_box\').empty();
3327 jQuery("'.$htmltag.
'#' . $htmlname .
'").change(function () {
3329 if (!jQuery(this).val()) {
3330 jQuery(\'div#attributes_box\').empty();
3334 console.log("A change has started. We get variants fields to inject html select");
3336 jQuery.getJSON("' . DOL_URL_ROOT .
'/variants/ajax/getCombinations.php", {
3337 id: jQuery(this).val()
3338 }, function (data) {
3339 jQuery(\'div#attributes_box\').empty();
3341 jQuery.each(data, function (key, val) {
3343 combvalues[val.id] = val.values;
3345 var span = jQuery(document.createElement(\'div\')).css({
3346 \'display\': \'table-row\'
3350 jQuery(document.createElement(\'div\')).text(val.label).css({
3351 \'font-weight\': \'bold\',
3352 \'display\': \'table-cell\'
3356 var html = jQuery(document.createElement(\'select\')).attr(\'name\', \'combinations[\' + val.id + \']\').css({
3357 \'margin-left\': \'15px\',
3358 \'white-space\': \'pre\'
3360 jQuery(document.createElement(\'option\')).val(\'\')
3363 jQuery.each(combvalues[val.id], function (key, val) {
3364 var tag = jQuery(document.createElement(\'option\')).val(val.id).html(val.value);
3366 if (selected[val.fk_product_attribute] == val.id) {
3367 tag.attr(\'selected\', \'selected\');
3374 jQuery(\'div#attributes_box\').append(span);
3379 ' . ($selected ?
'jQuery("'.$htmltag.
'#' . $htmlname .
'").change();' :
'') .
'
3385 if (empty($hidelabel)) {
3387 } elseif ($hidelabel > 1) {
3389 if ($hidelabel == 2) {
3390 $out .=
img_picto($langs->trans(
"Search"),
'search');
3394 $out .=
'<input type="text" class="minwidth100' . ($morecss ?
' ' . $morecss :
'') .
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . $placeholder .
' ' . (
getDolGlobalString(
'PRODUCT_SEARCH_AUTOFOCUS') ?
'autofocus' :
'') .
' spellcheck="false" />';
3395 if ($hidelabel == 3) {
3396 $out .=
img_picto($langs->trans(
"Search"),
'search');
3399 $out .=
ajax_autocompleter((
string) $selected, $htmlname, DOL_URL_ROOT .
'/product/ajax/products.php', $urloption,
getDolGlobalInt(
'PRODUIT_USE_SEARCH_TO_SELECT'),
getDolGlobalInt(
'PRODUCT_SEARCH_AUTO_SELECT_IF_ONLY_ONE', 1), $ajaxoptions);
3401 $out .= $this->
select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level,
'', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus, $status_purchase, $warehouseId);
3403 if (
isModEnabled(
'variants') && is_array($selected_combinations)) {
3407 $htmltag =
'select';
3409 <!-- script to auto show attributes select tags if a variant was selected -->
3410 <script nonce="' . getNonce() .
'">
3411 // auto show attributes fields
3412 selected = ' . json_encode($selected_combinations) .
';
3415 jQuery(document).ready(function () {
3417 jQuery("input[name=\'prod_entry_mode\']").change(function () {
3418 if (jQuery(this).val() == \'free\') {
3419 jQuery(\'div#attributes_box\').empty();
3423 jQuery("'.$htmltag.
'#' . $htmlname .
'").change(function () {
3425 if (!jQuery(this).val()) {
3426 jQuery(\'div#attributes_box\').empty();
3430 console.log("A change has started. We get variants fields to inject html select");
3432 jQuery.getJSON("' . DOL_URL_ROOT .
'/variants/ajax/getCombinations.php", {
3433 id: jQuery(this).val()
3434 }, function (data) {
3435 jQuery(\'div#attributes_box\').empty();
3437 jQuery.each(data, function (key, val) {
3439 combvalues[val.id] = val.values;
3441 var span = jQuery(document.createElement(\'div\')).css({
3442 \'display\': \'table-row\'
3446 jQuery(document.createElement(\'div\')).text(val.label).css({
3447 \'font-weight\': \'bold\',
3448 \'display\': \'table-cell\'
3452 var html = jQuery(document.createElement(\'select\')).attr(\'name\', \'combinations[\' + val.id + \']\').css({
3453 \'margin-left\': \'15px\',
3454 \'white-space\': \'pre\'
3456 jQuery(document.createElement(\'option\')).val(\'\')
3459 jQuery.each(combvalues[val.id], function (key, val) {
3460 var tag = jQuery(document.createElement(\'option\')).val(val.id).html(val.value);
3462 if (selected[val.fk_product_attribute] == val.id) {
3463 tag.attr(\'selected\', \'selected\');
3470 jQuery(\'div#attributes_box\').append(span);
3475 ' . ($selected ?
'jQuery("'.$htmltag.
'#' . $htmlname .
'").change();' :
'') .
'
3482 if (empty($nooutput)) {
3506 public function select_bom($selected =
'', $htmlname =
'bom_id', $limit = 0, $status = 1, $type = 0, $showempty =
'1', $morecss =
'', $nooutput =
'', $forcecombo = 0, $TProducts = [])
3510 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
3516 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
3521 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
3523 $sql =
'SELECT b.rowid, b.ref, b.label as bomLabel, p.label as productLabel';
3524 $sql .=
' FROM ' . $this->db->prefix() .
'bom_bom as b';
3525 $sql .=
' INNER JOIN ' . $this->db->prefix() .
'product as p ON b.fk_product = p.rowid';
3526 $sql .=
' WHERE b.entity IN (' .
getEntity(
'bom') .
')';
3527 if (!empty($status)) {
3528 $sql .=
' AND status = ' . (int) $status;
3530 if (!empty($type)) {
3531 $sql .=
' AND bomtype = ' . (int) $type;
3533 if (!empty($TProducts)) {
3534 $sql .=
' AND fk_product IN (' . $this->db->sanitize(implode(
',', $TProducts)) .
')';
3536 if (!empty($limit)) {
3537 $sql .=
' LIMIT ' . (int) $limit;
3539 $resql = $this->db->query($sql);
3542 $out .=
'<option value="-1"';
3543 if (empty($selected)) {
3544 $out .=
' selected';
3546 $out .=
'> </option>';
3548 while ($obj = $this->db->fetch_object($resql)) {
3549 $out .=
'<option value="' . $obj->rowid .
'"';
3550 if ($obj->rowid == $selected) {
3553 $out .=
'>' . $obj->ref .
' - ' . $obj->productLabel .
' - ' . $obj->bomLabel .
'</option>';
3559 $out .=
'</select>';
3560 if (empty($nooutput)) {
3595 public function select_produits_list($selected = 0, $htmlname =
'productid', $filtertype =
'', $limit = 1000, $price_level = 0, $filterkey =
'', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty =
'1', $forcecombo = 0, $morecss =
'maxwidth500', $hidepriceinlabel = 0, $warehouseStatus =
'', $status_purchase = -1, $warehouseId = 0)
3599 global $hookmanager;
3602 $outarray = array();
3606 $langs->load(
'other');
3609 $warehouseStatusArray = array();
3610 if (!empty($warehouseStatus)) {
3611 require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/entrepot.class.php';
3612 if (preg_match(
'/warehouseclosed/', $warehouseStatus)) {
3615 if (preg_match(
'/warehouseopen/', $warehouseStatus)) {
3618 if (preg_match(
'/warehouseinternal/', $warehouseStatus)) {
3623 $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";
3624 if (count($warehouseStatusArray)) {
3625 $selectFieldsGrouped =
", SUM(" . $this->db->ifsql(
"e.statut IS NULL",
"0",
"ps.reel") .
") as stock";
3627 $selectFieldsGrouped =
", " . $this->db->ifsql(
"p.stock IS NULL",
'0',
"p.stock") .
" AS stock";
3633 $parameters = array();
3634 $reshook = $hookmanager->executeHooks(
'selectProductsListSelect', $parameters);
3635 if (empty($reshook)) {
3636 $sql .= $selectFields.$selectFieldsGrouped.$hookmanager->resPrint;
3638 $sql .= $hookmanager->resPrint;
3643 $sql .=
", (SELECT " . $this->db->prefix() .
"categorie_product.fk_categorie
3644 FROM " . $this->db->prefix() .
"categorie_product
3645 WHERE " . $this->db->prefix() .
"categorie_product.fk_product = p.rowid
3647 ) AS categorie_product_id";
3652 $sql .=
', pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,';
3653 $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, pcp.discount_percent as custdiscount_percent';
3654 $selectFields .=
", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx, custdefault_vat_code, custref, custdiscount_percent";
3658 $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";
3659 $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';
3664 $sql .=
", pl.label as label_translated";
3665 $sql .=
", pl.description as description_translated";
3666 $selectFields .=
", label_translated";
3667 $selectFields .=
", description_translated";
3671 $sql .=
", (SELECT pp.rowid FROM " . $this->db->prefix() .
"product_price as pp WHERE pp.fk_product = p.rowid";
3672 if ($price_level >= 1 &&
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
3673 $sql .=
" AND price_level = " . ((int) $price_level);
3675 $sql .=
" ORDER BY date_price";
3676 $sql .=
" DESC LIMIT 1) as price_rowid";
3677 $sql .=
", (SELECT pp.price_by_qty FROM " . $this->db->prefix() .
"product_price as pp WHERE pp.fk_product = p.rowid";
3678 if ($price_level >= 1 &&
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
3679 $sql .=
" AND price_level = " . ((int) $price_level);
3681 $sql .=
" ORDER BY date_price";
3682 $sql .=
" DESC LIMIT 1) as price_by_qty";
3683 $selectFields .=
", price_rowid, price_by_qty";
3688 $sql .=
" FROM ".$this->db->prefix().
"product as p";
3691 $sql .=
" USE INDEX (" . $this->db->sanitize(
getDolGlobalString(
'MAIN_PRODUCT_FORCE_INDEX')) .
")";
3695 $parameters = array(
3698 $reshook = $hookmanager->executeHooks(
'selectProductsListFrom', $parameters);
3699 $sql .= $hookmanager->resPrint;
3701 if (count($warehouseStatusArray)) {
3704 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_stock as ps ON ps.fk_product = p.rowid";
3705 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entrepot as e ON ps.fk_entrepot = e.rowid AND e.entity IN (" .
getEntity(
'stock') .
")";
3706 $sql .=
' AND e.statut IN (' . $this->db->sanitize($this->db->escape(implode(
',', $warehouseStatusArray))) .
')';
3712 $sql .=
" LEFT JOIN (";
3713 $sql .=
" SELECT pcp1.*";
3714 $sql .=
" FROM " . $this->db->prefix() .
"product_customer_price AS pcp1";
3715 $sql .=
" LEFT JOIN (";
3716 $sql .=
" SELECT fk_soc, fk_product, MIN(date_begin) AS date_begin";
3717 $sql .=
" FROM " . $this->db->prefix() .
"product_customer_price";
3718 $sql .=
" WHERE fk_soc = " . ((int) $socid);
3719 $sql .=
" AND date_begin <= '" . $this->db->idate($now) .
"'";
3720 $sql .=
" AND (date_end IS NULL OR '" . $this->db->idate($now) .
"' <= date_end)";
3721 $sql .=
" GROUP BY fk_soc, fk_product";
3722 $sql .=
" ) AS pcp2 ON pcp1.fk_soc = pcp2.fk_soc AND pcp1.fk_product = pcp2.fk_product AND pcp1.date_begin = pcp2.date_begin";
3723 $sql .=
" WHERE pcp2.fk_soc IS NOT NULL";
3724 $sql .=
" ) AS pcp ON pcp.fk_soc = " . ((int) $socid) .
" AND pcp.fk_product = p.rowid";
3728 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_units as u ON u.rowid = p.fk_unit";
3732 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_lang as pl ON pl.fk_product = p.rowid";
3734 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
3735 $soc =
new Societe($this->db);
3736 $result = $soc->fetch($socid);
3737 if ($result > 0 && !empty($soc->default_lang)) {
3738 $sql .=
" AND pl.lang = '" . $this->db->escape($soc->default_lang) .
"'";
3740 $sql .=
" AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) .
"'";
3743 $sql .=
" AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) .
"'";
3748 $sql .=
' WHERE p.entity IN (' .
getEntity(
'product') .
')';
3751 if (strlen($filterkey) != 13) {
3752 $sql .=
" AND NOT EXISTS (SELECT pac.rowid FROM ".$this->db->prefix().
"product_attribute_combination as pac WHERE pac.fk_product_child = p.rowid)";
3755 $sql .=
" AND NOT EXISTS (SELECT pac.rowid FROM ".$this->db->prefix().
"product_attribute_combination as pac WHERE pac.fk_product_child = p.rowid)";
3758 if ($finished == 0) {
3759 $sql .=
" AND p.finished = " . ((int) $finished);
3760 } elseif ($finished == 1) {
3761 $sql .=
" AND p.finished = ".((int) $finished);
3764 $sql .=
" AND p.tosell = ".((int) $status);
3766 if ($status_purchase >= 0) {
3767 $sql .=
" AND p.tobuy = " . ((int) $status_purchase);
3770 if (strval($filtertype) !=
'') {
3771 $sql .=
" AND p.fk_product_type = " . ((int) $filtertype);
3773 $sql .=
" AND p.fk_product_type = 1";
3775 $sql .=
" AND p.fk_product_type = 0";
3778 if ((
int) $warehouseId > 0) {
3779 $sql .=
" AND EXISTS (SELECT psw.fk_product FROM " . $this->db->prefix() .
"product_stock as psw WHERE psw.reel > 0 AND psw.fk_entrepot = ".(int) $warehouseId.
" AND psw.fk_product = p.rowid)";
3783 $parameters = array(
3784 'filterkey' => &$filterkey,
3787 $reshook = $hookmanager->executeHooks(
'selectProductsListWhere', $parameters);
3788 $sql .= $hookmanager->resPrint;
3790 if ($filterkey !=
'') {
3791 $sqlSupplierSearch =
'';
3796 $search_crit = explode(
' ', $filterkey);
3798 if (count($search_crit) > 1) {
3801 foreach ($search_crit as $crit) {
3805 $sql .=
"(p.ref LIKE '" . $this->db->escape($prefix . $crit) .
"%' OR p.label LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3807 $sql .=
" OR pl.label LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3810 $sql .=
" OR pcp.ref_customer LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3813 $sql .=
" OR p.description LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3815 $sql .=
" OR pl.description LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3821 $sqlSupplierSearch .= !empty($sqlSupplierSearch) ?
' AND ' :
'';
3822 $sqlSupplierSearch .=
" pfp.ref_fourn LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3827 if (count($search_crit) > 1) {
3831 $sql .=
" OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
3836 $sql .=
" OR EXISTS (SELECT pfp.fk_product FROM " . $this->db->prefix() .
"product_fournisseur_price as pfp WHERE p.rowid = pfp.fk_product";
3838 $sql .= $sqlSupplierSearch;
3844 if (count($warehouseStatusArray)) {
3845 $sql .=
" GROUP BY " . $this->db->sanitize($selectFields, 0, 0, 1);
3850 $sql .=
" ORDER BY categorie_product_id ".(getDolGlobalInt(
'PRODUCT_SORT_BY_CATEGORY') == 1 ?
"ASC" :
"DESC");
3852 $sql .= $this->db->order(
"p.ref");
3856 $sql .= $this->db->plimit($limit, 0);
3874 dol_syslog(get_class($this) .
"::select_produits_list search products", LOG_DEBUG);
3878 $result = $this->db->query($sql);
3881 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
3882 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3883 require_once DOL_DOCUMENT_ROOT .
'/core/lib/product.lib.php';
3885 $num = $this->db->num_rows($result);
3890 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
3894 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
3900 if ($showempty && !is_numeric($showempty)) {
3901 $textifempty = $langs->trans($showempty);
3903 $textifempty .= $langs->trans(
"All");
3906 if ($showempty && !is_numeric($showempty)) {
3907 $textifempty = $langs->trans($showempty);
3911 $out .=
'<option value="-1" selected>' . ($textifempty ? $textifempty :
' ') .
'</option>';
3915 while ($num && $i < $num) {
3918 $objp = $this->db->fetch_object($result);
3920 if ((
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY') ||
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1) {
3921 $sql =
"SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type";
3922 $sql .=
" FROM " . $this->db->prefix() .
"product_price_by_qty";
3923 $sql .=
" WHERE fk_product_price = " . ((int) $objp->price_rowid);
3924 $sql .=
" ORDER BY quantity ASC";
3926 dol_syslog(get_class($this) .
"::select_produits_list search prices by qty", LOG_DEBUG);
3927 $result2 = $this->db->query($sql);
3929 $nb_prices = $this->db->num_rows($result2);
3931 while ($nb_prices && $j < $nb_prices) {
3932 $objp2 = $this->db->fetch_object($result2);
3934 $objp->price_by_qty_rowid = $objp2->rowid;
3935 $objp->price_by_qty_price_base_type = $objp2->price_base_type;
3936 $objp->price_by_qty_quantity = $objp2->quantity;
3937 $objp->price_by_qty_unitprice = $objp2->unitprice;
3938 $objp->price_by_qty_remise_percent = $objp2->remise_percent;
3940 $objp->quantity = $objp2->quantity;
3941 $objp->price = $objp2->price;
3942 $objp->unitprice = $objp2->unitprice;
3943 $objp->remise_percent = $objp2->remise_percent;
3949 '@phan-var-force array{key:string,value:string,label:string,label2:string,desc:string,type:string,price_ht:string,price_ttc:string,price_ht_locale:string,price_ttc_locale:string,pricebasetype:string,tva_tx:string,default_vat_code:string,qty:string,discount:string,duration_value:string,duration_unit:string,pbq:string,labeltrans:string,desctrans:string,ref_customer:string} $optJson';
3956 array_push($outarray, $optJson);
3960 if (
isModEnabled(
'dynamicprices') && !empty($objp->fk_price_expression)) {
3961 $price_product =
new Product($this->db);
3962 $price_product->fetch($objp->rowid,
'',
'',
'1');
3964 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3966 $price_result = $priceparser->parseProduct($price_product);
3967 if ($price_result >= 0) {
3968 $objp->price = $price_result;
3969 $objp->unitprice = $price_result;
3971 $objp->price_ttc = (float)
price2num($objp->price) * (1 + ($objp->tva_tx / 100));
3972 $objp->price_ttc =
price2num($objp->price_ttc,
'MU');
3975 if (
getDolGlobalInt(
'PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES') && !empty($objp->custprice)) {
3983 array_push($outarray, $optJson);
3989 $out .=
'</select>';
3991 $this->db->free($result);
3993 if (empty($outputmode)) {
4020 protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey =
'', $novirtualstock = 0)
4022 global $langs,
$conf, $user;
4023 global $hookmanager;
4029 $outlabel_translated =
'';
4031 $outdesc_translated =
'';
4037 $outpricebasetype =
'';
4039 $outdefault_vat_code =
'';
4045 $label = $objp->label;
4046 if (!empty($objp->label_translated)) {
4047 $label = $objp->label_translated;
4049 if (!empty($filterkey) && $filterkey !=
'') {
4050 $label = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $label, 1);
4053 $outkey = $objp->rowid;
4054 $outref = $objp->ref;
4055 $outrefcust = empty($objp->custref) ?
'' : $objp->custref;
4056 $outlabel = $objp->label;
4057 $outdesc = $objp->description;
4059 $outlabel_translated = $objp->label_translated;
4060 $outdesc_translated = $objp->description_translated;
4062 $outbarcode = $objp->barcode;
4063 $outorigin = $objp->fk_country;
4064 $outpbq = empty($objp->price_by_qty_rowid) ?
'' : $objp->price_by_qty_rowid;
4066 $outtype = $objp->fk_product_type;
4071 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
4077 if (!empty($objp->unit_short)) {
4078 $outvalUnits .=
' - ' . $objp->unit_short;
4082 if (!empty($objp->weight) && $objp->weight_units !==
null) {
4084 $outvalUnits .=
' - ' . $unitToShow;
4086 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !==
null) {
4087 $unitToShow = $objp->length .
' x ' . $objp->width .
' x ' . $objp->height .
' ' .
measuringUnitString(0,
'size', $objp->length_units);
4088 $outvalUnits .=
' - ' . $unitToShow;
4090 if (!empty($objp->surface) && $objp->surface_units !==
null) {
4092 $outvalUnits .=
' - ' . $unitToShow;
4094 if (!empty($objp->volume) && $objp->volume_units !==
null) {
4096 $outvalUnits .=
' - ' . $unitToShow;
4099 if ($outdurationvalue && $outdurationunit) {
4101 'h' => $langs->trans(
'Hour'),
4102 'd' => $langs->trans(
'Day'),
4103 'w' => $langs->trans(
'Week'),
4104 'm' => $langs->trans(
'Month'),
4105 'y' => $langs->trans(
'Year')
4107 if (isset($da[$outdurationunit])) {
4108 $outvalUnits .=
' - ' . $outdurationvalue .
' ' . $langs->transnoentities($da[$outdurationunit] . ($outdurationvalue > 1 ?
's' :
''));
4115 if ($user->hasRight(
'stock',
'lire')) {
4116 if ($objp->stock > 0) {
4118 } elseif ($objp->stock <= 0) {
4126 $labeltoshow .= $objp->ref;
4127 if (!empty($objp->custref)) {
4128 $labeltoshow .=
' (' . $objp->custref .
')';
4131 $labeltoshow .=
' (' . $outbarcode .
')';
4133 $labeltoshow .=
' - ' .
dol_trunc($label, $maxlengtharticle);
4135 $labeltoshow .=
' (' .
getCountry($outorigin,
'1') .
')';
4139 $labeltoshowhtml =
'';
4140 $labeltoshowhtml .= $objp->ref;
4141 if (!empty($objp->custref)) {
4142 $labeltoshowhtml .=
' (' . $objp->custref .
')';
4144 if (!empty($filterkey) && $filterkey !=
'') {
4145 $labeltoshowhtml = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $labeltoshowhtml, 1);
4148 $labeltoshowhtml .=
' (' . $outbarcode .
')';
4150 $labeltoshowhtml .=
' - ' .
dol_trunc($label, $maxlengtharticle);
4152 $labeltoshowhtml .=
' (' .
getCountry($outorigin,
'1') .
')';
4156 $labeltoshowstock =
'';
4157 $labeltoshowhtmlstock =
'';
4159 if ($user->hasRight(
'stock',
'lire')) {
4160 $labeltoshowstock .=
' - ' . $langs->trans(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'), 0, $langs, 0, 0);
4162 if ($objp->stock > 0) {
4163 $labeltoshowhtmlstock .=
' - <span class="product_line_stock_ok">';
4164 } elseif ($objp->stock <= 0) {
4165 $labeltoshowhtmlstock .=
' - <span class="product_line_stock_too_low">';
4167 $labeltoshowhtmlstock .= $langs->transnoentities(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'), 0, $langs, 0, 0);
4168 $labeltoshowhtmlstock .=
'</span>';
4170 if (empty($novirtualstock) &&
getDolGlobalString(
'STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO')) {
4171 $langs->load(
"stocks");
4173 $tmpproduct =
new Product($this->db);
4174 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
4175 $tmpproduct->load_virtual_stock();
4176 $virtualstock = $tmpproduct->stock_theorique;
4178 $labeltoshowstock .=
' - ' . $langs->trans(
"VirtualStock") .
':' . $virtualstock;
4180 $labeltoshowhtmlstock .=
' - ' . $langs->transnoentities(
"VirtualStock") .
':';
4181 if ($virtualstock > 0) {
4182 $labeltoshowhtmlstock .=
'<span class="product_line_stock_ok">';
4183 } elseif ($virtualstock <= 0) {
4184 $labeltoshowhtmlstock .=
'<span class="product_line_stock_too_low">';
4186 $labeltoshowhtmlstock .= $virtualstock;
4187 $labeltoshowhtmlstock .=
'</span>';
4196 $labeltoshowprice =
'';
4197 $labeltoshowhtmlprice =
'';
4200 $sql =
"SELECT price, price_ttc, price_base_type, tva_tx, default_vat_code";
4201 $sql .=
" FROM " . $this->db->prefix() .
"product_price";
4202 $sql .=
" WHERE fk_product = " . ((int) $objp->rowid);
4203 $sql .=
" AND entity IN (" .
getEntity(
'productprice') .
")";
4204 $sql .=
" AND price_level = " . ((int) $price_level);
4205 $sql .=
" ORDER BY date_price DESC, rowid DESC";
4208 dol_syslog(get_class($this) .
'::constructProductListOption search price for product ' . $objp->rowid .
' AND level ' . $price_level, LOG_DEBUG);
4209 $result2 = $this->db->query($sql);
4211 $objp2 = $this->db->fetch_object($result2);
4214 if ($objp2->price_base_type ==
'HT') {
4215 $labeltoshowprice .=
' - ' .
price($objp2->price, 1, $langs, 0, 0, -1,
$conf->currency) .
' ' . $langs->trans(
"HT");
4216 $labeltoshowhtmlprice .=
' - ' .
price($objp2->price, 0, $langs, 0, 0, -1,
$conf->currency) .
' ' . $langs->transnoentities(
"HT");
4218 $labeltoshowprice .=
' - ' .
price($objp2->price_ttc, 1, $langs, 0, 0, -1,
$conf->currency) .
' ' . $langs->trans(
"TTC");
4219 $labeltoshowhtmlprice .=
' - ' .
price($objp2->price_ttc, 0, $langs, 0, 0, -1,
$conf->currency) .
' ' . $langs->transnoentities(
"TTC");
4221 $outprice_ht =
price($objp2->price);
4222 $outprice_ttc =
price($objp2->price_ttc);
4223 $outpricebasetype = $objp2->price_base_type;
4225 $outtva_tx = $objp2->tva_tx;
4226 $outdefault_vat_code = $objp2->default_vat_code;
4228 $outtva_tx = $objp->tva_tx;
4229 $outdefault_vat_code = $objp->default_vat_code;
4238 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1 && (
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY') ||
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'))) {
4240 $outqty = $objp->quantity;
4241 $outdiscount = $objp->remise_percent;
4242 if ($objp->quantity == 1) {
4243 $labeltoshowprice .=
' - ' .
price($objp->unitprice, 1, $langs, 0, 0, -1,
$conf->currency) .
"/";
4244 $labeltoshowhtmlprice .=
' - ' .
price($objp->unitprice, 0, $langs, 0, 0, -1,
$conf->currency) .
"/";
4245 $labeltoshowprice .= $langs->trans(
"Unit");
4246 $labeltoshowhtmlprice .= $langs->transnoentities(
"Unit");
4248 $labeltoshowprice .=
' - ' .
price($objp->price, 1, $langs, 0, 0, -1,
$conf->currency) .
"/" . $objp->quantity;
4249 $labeltoshowhtmlprice .=
' - ' .
price($objp->price, 0, $langs, 0, 0, -1,
$conf->currency) .
"/" . $objp->quantity;
4250 $labeltoshowprice .= $langs->trans(
"Units");
4251 $labeltoshowhtmlprice .= $langs->transnoentities(
"Units");
4254 $outprice_ht =
price($objp->unitprice);
4255 $outprice_ttc =
price($objp->unitprice * (1 + ($objp->tva_tx / 100)));
4256 $outpricebasetype = $objp->price_base_type;
4257 $outtva_tx = $objp->tva_tx;
4258 $outdefault_vat_code = $objp->default_vat_code;
4260 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1) {
4261 $labeltoshowprice .=
" (" .
price($objp->unitprice, 1, $langs, 0, 0, -1,
$conf->currency) .
"/" . $langs->trans(
"Unit") .
")";
4262 $labeltoshowhtmlprice .=
" (" .
price($objp->unitprice, 0, $langs, 0, 0, -1,
$conf->currency) .
"/" . $langs->transnoentities(
"Unit") .
")";
4264 if (empty($hidepriceinlabel) && !empty($objp->remise_percent) && $objp->remise_percent >= 1) {
4265 $labeltoshowprice .=
" - " . $langs->trans(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
4266 $labeltoshowhtmlprice .=
" - " . $langs->transnoentities(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
4271 if (!empty($objp->idprodcustprice)) {
4274 if ($objp->custprice_base_type ==
'HT') {
4275 $labeltoshowprice .=
' - ' .
price($objp->custprice, 1, $langs, 0, 0, -1,
$conf->currency) .
' ' . $langs->trans(
"HT");
4276 $labeltoshowhtmlprice .=
' - ' .
price($objp->custprice, 0, $langs, 0, 0, -1,
$conf->currency) .
' ' . $langs->transnoentities(
"HT");
4278 $labeltoshowprice .=
' - ' .
price($objp->custprice_ttc, 1, $langs, 0, 0, -1,
$conf->currency) .
' ' . $langs->trans(
"TTC");
4279 $labeltoshowhtmlprice .=
' - ' .
price($objp->custprice_ttc, 0, $langs, 0, 0, -1,
$conf->currency) .
' ' . $langs->transnoentities(
"TTC");
4282 $outprice_ht =
price($objp->custprice);
4283 $outprice_ttc =
price($objp->custprice_ttc);
4284 $outpricebasetype = $objp->custprice_base_type;
4285 $outtva_tx = $objp->custtva_tx;
4286 $outdefault_vat_code = $objp->custdefault_vat_code;
4287 $outdiscount = $objp->custdiscount_percent;
4292 if (empty($hidepriceinlabel) && !$found) {
4293 if ($objp->price_base_type ==
'HT') {
4294 $labeltoshowprice .=
' - ' .
price($objp->price, 1, $langs, 0, 0, -1,
$conf->currency) .
' ' . $langs->trans(
"HT");
4295 $labeltoshowhtmlprice .=
' - ' .
price($objp->price, 0, $langs, 0, 0, -1,
$conf->currency) .
' ' . $langs->transnoentities(
"HT");
4297 $labeltoshowprice .=
' - ' .
price($objp->price_ttc, 1, $langs, 0, 0, -1,
$conf->currency) .
' ' . $langs->trans(
"TTC");
4298 $labeltoshowhtmlprice .=
' - ' .
price($objp->price_ttc, 0, $langs, 0, 0, -1,
$conf->currency) .
' ' . $langs->transnoentities(
"TTC");
4300 $outprice_ht =
price($objp->price);
4301 $outprice_ttc =
price($objp->price_ttc);
4302 $outpricebasetype = $objp->price_base_type;
4303 $outtva_tx = $objp->tva_tx;
4304 $outdefault_vat_code = $objp->default_vat_code;
4308 $opt =
'<option value="' . $objp->rowid .
'"';
4309 $opt .= ($objp->rowid == $selected) ?
' selected' :
'';
4310 if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) {
4311 $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 .
'"';
4314 $opt .=
' data-labeltrans="' . $outlabel_translated .
'"';
4318 if ($stocktag == 1) {
4319 $opt .=
' class="product_line_stock_ok" data-html="'.$labeltoshowhtml.$outvalUnits.$labeltoshowhtmlprice.dolPrintHTMLForAttribute($labeltoshowhtmlstock).
'"';
4322 if ($stocktag == -1) {
4323 $opt .=
' class="product_line_stock_too_low" data-html="'.$labeltoshowhtml.$outvalUnits.$labeltoshowhtmlprice.dolPrintHTMLForAttribute($labeltoshowhtmlstock).
'"';
4330 $opt .= $labeltoshow;
4331 $outval .= $labeltoshowhtml;
4334 $opt .= $outvalUnits;
4335 $outval .= $outvalUnits;
4338 $opt .= $labeltoshowprice;
4339 $outval .= $labeltoshowhtmlprice;
4342 $opt .= $labeltoshowstock;
4343 $outval .= $labeltoshowhtmlstock;
4346 $parameters = array(
'objp' => $objp);
4347 $reshook = $hookmanager->executeHooks(
'constructProductListOption', $parameters);
4348 if (empty($reshook)) {
4349 $opt .= $hookmanager->resPrint;
4351 $opt = $hookmanager->resPrint;
4354 $opt .=
"</option>\n";
4359 'label2' => $outlabel,
4363 'price_ttc' =>
price2num($outprice_ttc),
4366 'pricebasetype' => $outpricebasetype,
4367 'tva_tx' => $outtva_tx,
4368 'default_vat_code' => $outdefault_vat_code,
4370 'discount' => $outdiscount,
4371 'duration_value' => $outdurationvalue,
4372 'duration_unit' => $outdurationunit,
4374 'labeltrans' => $outlabel_translated,
4375 'desctrans' => $outdesc_translated,
4376 'ref_customer' => $outrefcust
4398 public function select_produits_fournisseurs($socid, $selected =
'', $htmlname =
'productid', $filtertype =
'', $notused =
'', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss =
'', $placeholder =
'', $nooutput = 0)
4401 global $langs,
$conf;
4402 global $price_level, $status, $finished;
4404 if (!isset($status)) {
4408 $selected_input_value =
'';
4410 if ((
int) $selected > 0) {
4411 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
4412 $producttmpselect =
new Product($this->db);
4413 $producttmpselect->fetch((
int) $selected);
4414 $selected_input_value = $producttmpselect->ref;
4415 unset($producttmpselect);
4419 $urloption = ($socid > 0 ?
'socid=' . $socid .
'&' :
'') .
'htmlname=' . $htmlname .
'&outjson=1&price_level=' . $price_level .
'&type=' . $filtertype .
'&mode=2&status=' . $status .
'&finished=' . $finished .
'&alsoproductwithnosupplierprice=' . $alsoproductwithnosupplierprice;
4421 $s = ($hidelabel ?
'' : $langs->trans(
"RefOrLabel") .
' : ') .
'<input type="text" class="'.$morecss.
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . ($placeholder ?
' placeholder="' . $placeholder .
'"' :
'') .
'>';
4423 $s .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT .
'/product/ajax/products.php', $urloption,
getDolGlobalInt(
'PRODUIT_USE_SEARCH_TO_SELECT'), 0, $ajaxoptions);
4425 $s = $this->
select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $notused,
'', $status, 0, 0, $alsoproductwithnosupplierprice, $morecss,
getDolGlobalInt(
'SUPPLIER_SHOW_STOCK_IN_PRODUCTS_COMBO'), $placeholder);
4455 public function select_produits_fournisseurs_list($socid, $selected =
'', $htmlname =
'productid', $filtertype =
'', $notused =
'', $filterkey =
'', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss =
'', $showstockinlist = 0, $placeholder =
'')
4458 global $langs,
$conf, $user;
4459 global $hookmanager;
4462 $outarray = array();
4466 $langs->load(
'stocks');
4469 $langs->load(
'other');
4472 $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,";
4473 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice, pfp.barcode";
4474 $sql .=
", pfp.multicurrency_code, pfp.multicurrency_unitprice";
4475 $sql .=
", pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.default_vat_code, pfp.fk_soc, s.nom as name";
4476 $sql .=
", pfp.supplier_reputation";
4479 $sql .=
", pfp.desc_fourn as description";
4481 $sql .=
", p.description";
4485 $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";
4490 $reshook = $hookmanager->executeHooks(
'selectSuppliersProductsListSelect', $parameters);
4491 $sql .= $hookmanager->resPrint;
4493 $sql .=
" FROM " . $this->db->prefix() .
"product as p";
4497 $reshook = $hookmanager->executeHooks(
'selectSuppliersProductsListFrom', $parameters);
4498 $sql .= $hookmanager->resPrint;
4500 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (" .
getEntity(
'product') .
") )";
4502 $sql .=
" AND pfp.fk_soc = " . ((int) $socid);
4504 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON pfp.fk_soc = s.rowid";
4507 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_units u ON u.rowid = p.fk_unit";
4509 $sql .=
" WHERE p.entity IN (" .
getEntity(
'product') .
")";
4510 if ($statut != -1) {
4511 $sql .=
" AND p.tobuy = " . ((int) $statut);
4513 if (strval($filtertype) !=
'') {
4514 $sql .=
" AND p.fk_product_type = " . ((int) $filtertype);
4518 $parameters = array();
4519 $reshook = $hookmanager->executeHooks(
'selectSuppliersProductsListWhere', $parameters);
4520 $sql .= $hookmanager->resPrint;
4522 if ($filterkey !=
'') {
4526 $search_crit = explode(
' ', $filterkey);
4528 if (count($search_crit) > 1) {
4531 foreach ($search_crit as $crit) {
4535 $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) .
"%'";
4537 $sql .=
" OR pfp.desc_fourn LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
4542 if (count($search_crit) > 1) {
4546 $sql .=
" OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
4547 $sql .=
" OR pfp.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
4551 $sql .=
" ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
4552 $sql .= $this->db->plimit($limit, 0);
4556 dol_syslog(get_class($this) .
"::select_produits_fournisseurs_list", LOG_DEBUG);
4557 $result = $this->db->query($sql);
4559 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
4560 require_once DOL_DOCUMENT_ROOT .
'/core/lib/product.lib.php';
4562 $num = $this->db->num_rows($result);
4565 $out .=
'<select class="flat ' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'">';
4567 $out .=
'<option value="-1" selected>' . ($placeholder ? $placeholder :
' ') .
'</option>';
4569 $out .=
'<option value="-1">' . ($placeholder ? $placeholder :
' ') .
'</option>';
4574 $objp = $this->db->fetch_object($result);
4576 if (is_null($objp->idprodfournprice)) {
4578 $objp->tva_tx = $objp->tva_tx_sale;
4579 $objp->default_vat_code = $objp->default_vat_code_sale;
4582 $outkey = $objp->idprodfournprice;
4583 if (!$outkey && $alsoproductwithnosupplierprice) {
4584 $outkey =
'idprod_' . $objp->rowid;
4587 $outref = $objp->ref;
4588 $outbarcode = $objp->barcode;
4591 $outtype = $objp->fk_product_type;
4598 if (!empty($objp->unit_short)) {
4599 $outvalUnits .=
' - ' . $objp->unit_short;
4601 if (!empty($objp->weight) && $objp->weight_units !==
null) {
4603 $outvalUnits .=
' - ' . $unitToShow;
4605 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !==
null) {
4606 $unitToShow = $objp->length .
' x ' . $objp->width .
' x ' . $objp->height .
' ' .
measuringUnitString(0,
'size', $objp->length_units);
4607 $outvalUnits .=
' - ' . $unitToShow;
4609 if (!empty($objp->surface) && $objp->surface_units !==
null) {
4611 $outvalUnits .=
' - ' . $unitToShow;
4613 if (!empty($objp->volume) && $objp->volume_units !==
null) {
4615 $outvalUnits .=
' - ' . $unitToShow;
4617 if ($outdurationvalue && $outdurationunit) {
4619 'h' => $langs->trans(
'Hour'),
4620 'd' => $langs->trans(
'Day'),
4621 'w' => $langs->trans(
'Week'),
4622 'm' => $langs->trans(
'Month'),
4623 'y' => $langs->trans(
'Year')
4625 if (isset($da[$outdurationunit])) {
4626 $outvalUnits .=
' - ' . $outdurationvalue .
' ' . $langs->transnoentities($da[$outdurationunit] . ($outdurationvalue > 1 ?
's' :
''));
4631 $objRef = $objp->ref;
4632 if ($filterkey && $filterkey !=
'') {
4633 $objRef = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRef, 1);
4635 $objRefFourn = $objp->ref_fourn;
4636 if ($filterkey && $filterkey !=
'') {
4637 $objRefFourn = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRefFourn, 1);
4639 $label = $objp->label;
4640 if ($filterkey && $filterkey !=
'') {
4641 $label = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $label, 1);
4644 switch ($objp->fk_product_type) {
4656 if (empty($picto)) {
4659 $optlabel =
img_object(
'', $picto,
'class="paddingright classfortooltip"', 0, 0, 1);
4662 $optlabel .= $objp->ref;
4663 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
4664 $optlabel .=
' <span class="opacitymedium">(' . $objp->ref_fourn .
')</span>';
4666 if (
isModEnabled(
'barcode') && !empty($objp->barcode)) {
4667 $optlabel .=
' (' . $outbarcode .
')';
4669 $optlabel .=
' - ' .
dol_trunc($label, $maxlengtharticle);
4671 $outvallabel = $objRef;
4672 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
4673 $outvallabel .=
' (' . $objRefFourn .
')';
4675 if (
isModEnabled(
'barcode') && !empty($objp->barcode)) {
4676 $outvallabel .=
' (' . $outbarcode .
')';
4678 $outvallabel .=
' - ' .
dol_trunc($label, $maxlengtharticle);
4681 $optlabel .= $outvalUnits;
4682 $outvallabel .= $outvalUnits;
4684 if (!empty($objp->idprodfournprice)) {
4685 $outqty = $objp->quantity;
4686 $outdiscount = $objp->remise_percent;
4687 if (
isModEnabled(
'dynamicprices') && !empty($objp->fk_supplier_price_expression)) {
4689 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
4690 $prod_supplier->id = $objp->fk_product;
4691 $prod_supplier->fourn_qty = $objp->quantity;
4692 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
4693 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
4695 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
4697 $price_result = $priceparser->parseProductSupplier($prod_supplier);
4698 if ($price_result >= 0) {
4699 $objp->fprice = $price_result;
4700 if ($objp->quantity >= 1) {
4701 $objp->unitprice = $objp->fprice / $objp->quantity;
4705 if ($objp->quantity == 1) {
4706 $optlabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1,
$conf->currency) .
"/";
4707 $outvallabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1,
$conf->currency) .
"/";
4708 $optlabel .= $langs->trans(
"Unit");
4709 $outvallabel .= $langs->transnoentities(
"Unit");
4711 $optlabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1,
$conf->currency) .
"/" . $objp->quantity;
4712 $outvallabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1,
$conf->currency) .
"/" . $objp->quantity;
4713 $optlabel .=
' ' . $langs->trans(
"Units");
4714 $outvallabel .=
' ' . $langs->transnoentities(
"Units");
4717 if ($objp->quantity != 1) {
4718 $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") .
")";
4719 $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") .
")";
4721 if ($objp->remise_percent >= 1) {
4722 $optlabel .=
" - " . $langs->trans(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
4723 $outvallabel .=
" - " . $langs->transnoentities(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
4725 if ($objp->duration) {
4726 $optlabel .=
" - " . $objp->duration;
4727 $outvallabel .=
" - " . $objp->duration;
4730 $optlabel .=
" - " .
dol_trunc($objp->name, 8);
4731 $outvallabel .=
" - " .
dol_trunc($objp->name, 8);
4733 if ($objp->supplier_reputation) {
4735 $reputations = array(
'' => $langs->trans(
'Standard'),
'FAVORITE' => $langs->trans(
'Favorite'),
'NOTTHGOOD' => $langs->trans(
'NotTheGoodQualitySupplier'),
'DONOTORDER' => $langs->trans(
'DoNotOrderThisProductToThisSupplier'));
4737 $optlabel .=
" - " . $reputations[$objp->supplier_reputation];
4738 $outvallabel .=
" - " . $reputations[$objp->supplier_reputation];
4741 $optlabel .=
" - <span class='opacitymedium'>" . $langs->trans(
"NoPriceDefinedForThisSupplier") .
'</span>';
4742 $outvallabel .=
' - ' . $langs->transnoentities(
"NoPriceDefinedForThisSupplier");
4746 $novirtualstock = ($showstockinlist == 2);
4748 if ($user->hasRight(
'stock',
'lire')) {
4749 $outvallabel .=
' - ' . $langs->trans(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'), 0, $langs, 0, 0);
4751 if ($objp->stock > 0) {
4752 $optlabel .=
' - <span class="product_line_stock_ok">';
4753 } elseif ($objp->stock <= 0) {
4754 $optlabel .=
' - <span class="product_line_stock_too_low">';
4756 $optlabel .= $langs->transnoentities(
"Stock") .
':' .
price(
price2num($objp->stock,
'MS'));
4757 $optlabel .=
'</span>';
4758 if (empty($novirtualstock) &&
getDolGlobalString(
'STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO')) {
4759 $langs->load(
"stocks");
4761 $tmpproduct =
new Product($this->db);
4762 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
4763 $tmpproduct->load_virtual_stock();
4764 $virtualstock = $tmpproduct->stock_theorique;
4766 $outvallabel .=
' - ' . $langs->trans(
"VirtualStock") .
':' . $virtualstock;
4768 $optlabel .=
' - ' . $langs->transnoentities(
"VirtualStock") .
':';
4769 if ($virtualstock > 0) {
4770 $optlabel .=
'<span class="product_line_stock_ok">';
4771 } elseif ($virtualstock <= 0) {
4772 $optlabel .=
'<span class="product_line_stock_too_low">';
4774 $optlabel .= $virtualstock;
4775 $optlabel .=
'</span>';
4782 $optstart =
'<option value="' . $outkey .
'"';
4783 if ($selected && preg_match(
'/^idprod_/', (
string) $selected) && (
string) $selected ==
'idprod_'.$objp->rowid) {
4784 $optstart .=
' selected';
4785 } elseif ($selected && (
string) $selected == (
string) $objp->idprodfournprice) {
4786 $optstart .=
' selected';
4789 if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) {
4790 $optstart .=
' disabled';
4793 if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
4802 $optstart .=
' data-default-vat-code="' .
dol_escape_htmltag($objp->default_vat_code) .
'"';
4805 $optstart .=
' data-multicurrency-code="' .
dol_escape_htmltag($objp->multicurrency_code) .
'"';
4809 $optstart .=
' data-description="' .
dol_escape_htmltag($objp->description, 0, 1) .
'"';
4812 $outarrayentry = array(
4815 'label' => $outvallabel,
4816 'labelhtml' => $optlabel,
4818 'price_qty_ht' =>
price2num($objp->fprice,
'MU'),
4819 'price_unit_ht' =>
price2num($objp->unitprice,
'MU'),
4820 'price_ht' =>
price2num($objp->unitprice,
'MU'),
4821 'tva_tx_formated' =>
price($objp->tva_tx, 0, $langs, 1, -1, 2),
4823 'default_vat_code' => $objp->default_vat_code,
4824 'supplier_ref' => $objp->ref_fourn,
4825 'discount' => $outdiscount,
4827 'duration_value' => $outdurationvalue,
4828 'duration_unit' => $outdurationunit,
4829 'disabled' => empty($objp->idprodfournprice),
4830 'description' => $objp->description
4833 $outarrayentry[
'multicurrency_code'] = $objp->multicurrency_code;
4834 $outarrayentry[
'multicurrency_unitprice'] =
price2num($objp->multicurrency_unitprice,
'MU');
4836 $parameters = array(
4838 'optstart' => &$optstart,
4839 'optlabel' => &$optlabel,
4840 'outvallabel' => &$outvallabel,
4841 'outarrayentry' => &$outarrayentry,
4844 $reshook = $hookmanager->executeHooks(
'selectProduitsFournisseurListOption', $parameters, $this);
4850 $out .= $optstart .
' data-html="' .
dol_escape_htmltag($optlabel) .
'">' . $optlabel .
"</option>\n";
4851 $outarraypush = array(
4854 'label' => $outvallabel,
4855 'labelhtml' => $optlabel,
4857 'price_qty_ht' =>
price2num($objp->fprice,
'MU'),
4858 'price_qty_ht_locale' =>
price($objp->fprice),
4859 'price_unit_ht' =>
price2num($objp->unitprice,
'MU'),
4860 'price_unit_ht_locale' =>
price($objp->unitprice),
4861 'price_ht' =>
price2num($objp->unitprice,
'MU'),
4862 'tva_tx_formated' =>
price($objp->tva_tx),
4864 'default_vat_code' => $objp->default_vat_code,
4865 'supplier_ref' => $objp->ref_fourn,
4866 'discount' => $outdiscount,
4868 'duration_value' => $outdurationvalue,
4869 'duration_unit' => $outdurationunit,
4870 'disabled' => empty($objp->idprodfournprice),
4871 'description' => $objp->description
4874 $outarraypush[
'multicurrency_code'] = $objp->multicurrency_code;
4875 $outarraypush[
'multicurrency_unitprice'] =
price2num($objp->multicurrency_unitprice,
'MU');
4877 array_push($outarray, $outarraypush);
4890 $out .=
'</select>';
4892 $this->db->free($result);
4894 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
4900 if (empty($outputmode)) {
4919 global $langs,
$conf;
4921 $langs->load(
'stocks');
4923 $sql =
"SELECT p.rowid, p.ref, p.label, p.price, p.duration, pfp.fk_soc,";
4924 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,";
4925 $sql .=
" pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name";
4926 $sql .=
" FROM " . $this->db->prefix() .
"product as p";
4927 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
4928 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON pfp.fk_soc = s.rowid";
4929 $sql .=
" WHERE pfp.entity IN (" .
getEntity(
'productsupplierprice') .
")";
4930 $sql .=
" AND p.tobuy = 1";
4931 $sql .=
" AND s.fournisseur = 1";
4932 $sql .=
" AND p.rowid = " . ((int) $productid);
4934 $sql .=
" ORDER BY s.nom, pfp.ref_fourn DESC";
4936 $sql .=
" ORDER BY pfp.unitprice - pfp.unitprice * pfp.remise_percent / 100 ASC";
4939 dol_syslog(get_class($this) .
"::select_product_fourn_price", LOG_DEBUG);
4940 $result = $this->db->query($sql);
4943 $num = $this->db->num_rows($result);
4945 $form =
'<select class="flat" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
4948 $form .=
'<option value="0">-- ' . $langs->trans(
"NoSupplierPriceDefinedForThisProduct") .
' --</option>';
4950 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
4951 $form .=
'<option value="0"> </option>';
4955 $objp = $this->db->fetch_object($result);
4957 $opt =
'<option value="' . $objp->idprodfournprice .
'"';
4959 if ($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier) || ($i == 0 &&
getDolGlobalString(
'PRODUCT_BEST_SUPPLIER_PRICE_PRESELECTED'))) {
4960 $opt .=
' selected';
4962 $opt .=
'>' . $objp->name .
' - ' . $objp->ref_fourn .
' - ';
4964 if (
isModEnabled(
'dynamicprices') && !empty($objp->fk_supplier_price_expression)) {
4966 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
4967 $prod_supplier->id = $productid;
4968 $prod_supplier->fourn_qty = $objp->quantity;
4969 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
4970 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
4972 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
4974 $price_result = $priceparser->parseProductSupplier($prod_supplier);
4975 if ($price_result >= 0) {
4976 $objp->fprice = $price_result;
4977 if ($objp->quantity >= 1) {
4978 $objp->unitprice = $objp->fprice / $objp->quantity;
4982 if ($objp->quantity == 1) {
4983 $opt .=
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1,
$conf->currency) .
"/";
4986 $opt .= $objp->quantity .
' ';
4988 if ($objp->quantity == 1) {
4989 $opt .= $langs->trans(
"Unit");
4991 $opt .= $langs->trans(
"Units");
4993 if ($objp->quantity > 1) {
4995 $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");
4997 if ($objp->duration) {
4998 $opt .=
" - " . $objp->duration;
5000 $opt .=
"</option>\n";
5007 $form .=
'</select>';
5008 $this->db->free($result);
5026 global $langs, $hookmanager;
5028 $num = count($this->cache_conditions_paiements);
5035 $this->cache_conditions_paiements = array();
5037 $sql =
"SELECT rowid, code, libelle as label, deposit_percent, entity";
5038 $sql .=
" FROM " . $this->db->prefix() .
'c_payment_term';
5039 $sql .=
" WHERE entity IN (" .
getEntity(
'c_payment_term') .
")";
5040 $sql .=
" AND active > 0";
5041 $sql .=
" ORDER BY sortorder";
5043 $resql = $this->db->query($sql);
5045 $num = $this->db->num_rows($resql);
5048 $obj = $this->db->fetch_object($resql);
5051 $label = ($langs->trans(
"PaymentConditionShort" . $obj->code) !=
"PaymentConditionShort" . $obj->code ? $langs->trans(
"PaymentConditionShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
5053 $this->cache_conditions_paiements[$obj->rowid][
'code'] = (
string) $obj->code;
5054 $this->cache_conditions_paiements[$obj->rowid][
'label'] = (
string) $label;
5055 $this->cache_conditions_paiements[$obj->rowid][
'deposit_percent'] = (
string) $obj->deposit_percent;
5056 $this->cache_conditions_paiements[$obj->rowid][
'entity'] = (int) $obj->entity;
5061 $parameters = array(
'context' =>
'paymentterm');
5062 $reshook = $hookmanager->executeHooks(
'loadDictionaryCache', $parameters, $this);
5063 if (empty($reshook)) {
5064 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
5065 $this->cache_conditions_paiements = array_merge($this->cache_conditions_paiements, $hookmanager->resArray);
5068 $this->cache_conditions_paiements = $hookmanager->resArray;
5092 $this->cache_rule_for_lines_dates = $factureRec->fields[
'rule_for_lines_dates'][
'arrayofkeyval'];
5094 if (empty($this->cache_rule_for_lines_dates)) {
5113 $num = count($this->cache_availability);
5120 $this->cache_availability = array();
5122 $langs->load(
'propal');
5124 $sql =
"SELECT rowid, code, label, position";
5125 $sql .=
" FROM " . $this->db->prefix() .
'c_availability';
5126 $sql .=
" WHERE active > 0";
5128 $resql = $this->db->query($sql);
5130 $num = $this->db->num_rows($resql);
5133 $obj = $this->db->fetch_object($resql);
5136 $label = ($langs->trans(
"AvailabilityType" . $obj->code) !=
"AvailabilityType" . $obj->code ? $langs->trans(
"AvailabilityType" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
5137 $this->cache_availability[$obj->rowid][
'code'] = (
string) $obj->code;
5138 $this->cache_availability[$obj->rowid][
'label'] = (
string) $label;
5139 $this->cache_availability[$obj->rowid][
'position'] = (int) $obj->position;
5144 $this->cache_availability =
dol_sort_array($this->cache_availability,
'position',
'asc', 0, 0, 1);
5164 public function selectAvailabilityDelay($selected =
'', $htmlname =
'availid', $filtertype =
'', $addempty = 0, $morecss =
'', $noouput = 0)
5166 global $langs, $user;
5170 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
5172 $out =
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
5174 $out .=
'<option value="-1">'.(is_numeric($addempty) ?
' ' : $langs->trans($addempty)).
'</option>';
5176 foreach ($this->cache_availability as
$id => $arrayavailability) {
5177 if ($selected ==
$id) {
5178 $out .=
'<option value="' .
$id .
'" selected>';
5180 $out .=
'<option value="' .
$id .
'">';
5183 $out .=
'</option>';
5185 $out .=
'</select>';
5187 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
5204 public function loadCacheInputReason()
5208 $num = count($this->cache_demand_reason);
5213 $sql =
"SELECT rowid, code, label";
5214 $sql .=
" FROM " . $this->db->prefix() .
'c_input_reason';
5215 $sql .=
" WHERE active > 0";
5217 $resql = $this->db->query($sql);
5219 $num = $this->db->num_rows($resql);
5222 $tmparray = array();
5224 $obj = $this->db->fetch_object($resql);
5227 $label = ($obj->label !=
'-' ? (
string) $obj->label :
'');
5228 if ($langs->trans(
"DemandReasonType" . $obj->code) !=
"DemandReasonType" . $obj->code) {
5229 $label = $langs->trans(
"DemandReasonType" . $obj->code);
5231 if ($langs->trans($obj->code) != $obj->code) {
5232 $label = $langs->trans($obj->code);
5235 $tmparray[(int) $obj->rowid]
5237 'id' => (
int) $obj->rowid,
5238 'code' => (
string) $obj->code,
5244 $this->cache_demand_reason =
dol_sort_array($tmparray,
'label',
'asc', 0, 0, 1);
5266 public function selectInputReason($selected =
'', $htmlname =
'demandreasonid', $exclude =
'', $addempty = 0, $morecss =
'', $notooltip = 0)
5268 global $langs, $user;
5270 $this->loadCacheInputReason();
5272 print
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
5274 print
'<option value="0"' . (empty($selected) ?
' selected' :
'') .
'> </option>';
5276 foreach ($this->cache_demand_reason as
$id => $arraydemandreason) {
5277 if ($arraydemandreason[
'code'] == $exclude) {
5281 if ($selected && ($selected == $arraydemandreason[
'id'] || $selected == $arraydemandreason[
'code'])) {
5282 print
'<option value="' . $arraydemandreason[
'id'] .
'" selected>';
5284 print
'<option value="' . $arraydemandreason[
'id'] .
'">';
5286 $label = $arraydemandreason[
'label'];
5287 print $langs->trans($label);
5291 if ($user->admin && empty($notooltip)) {
5292 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
5307 global $langs, $hookmanager;
5309 $num = count($this->cache_types_paiements);
5316 $this->cache_types_paiements = array();
5318 $sql =
"SELECT id, code, libelle as label, type, entity, active";
5319 $sql .=
" FROM " . $this->db->prefix() .
"c_paiement";
5320 $sql .=
" WHERE entity IN (" .
getEntity(
'c_paiement') .
")";
5322 $resql = $this->db->query($sql);
5324 $num = $this->db->num_rows($resql);
5327 $obj = $this->db->fetch_object($resql);
5330 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) !=
"PaymentTypeShort" . $obj->code ? $langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
5331 $this->cache_types_paiements[$obj->id][
'id'] = (int) $obj->id;
5332 $this->cache_types_paiements[$obj->id][
'code'] = (
string) $obj->code;
5333 $this->cache_types_paiements[$obj->id][
'label'] = (
string) $label;
5334 $this->cache_types_paiements[$obj->id][
'type'] = (int) $obj->type;
5335 $this->cache_types_paiements[$obj->id][
'entity'] = (int) $obj->entity;
5336 $this->cache_types_paiements[$obj->id][
'active'] = (int) $obj->active;
5340 $parameters = array(
'context' =>
'paymenttype');
5341 $reshook = $hookmanager->executeHooks(
'loadDictionaryCache', $parameters, $this);
5342 if (empty($reshook)) {
5343 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
5344 $this->cache_types_paiements = array_merge($this->cache_types_paiements, $hookmanager->resArray);
5347 $this->cache_types_paiements = $hookmanager->resArray;
5350 $this->cache_types_paiements =
dol_sort_array($this->cache_types_paiements,
'label',
'asc', 0, 0, 1);
5380 public function select_conditions_paiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1, $noprint = 0)
5384 if (empty($noprint)) {
5408 public function getSelectConditionsPaiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1)
5410 global $langs, $user;
5413 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
5418 if (empty($selected) && strpos($htmlname,
'search_') !== 0 &&
getDolGlobalInt(
'MAIN_DEFAULT_PAYMENT_TERM_ID')) {
5419 dol_syslog(__METHOD__ .
"Using deprecated option MAIN_DEFAULT_PAYMENT_TERM_ID", LOG_NOTICE);
5423 $out .=
'<select id="' . $htmlname .
'" class="flat selectpaymentterms' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
5425 $out .=
'<option value="0"> </option>';
5428 $selectedDepositPercent =
null;
5430 foreach ($this->cache_conditions_paiements as
$id => $arrayconditions) {
5431 if ($filtertype <= 0 && !empty($arrayconditions[
'deposit_percent'])) {
5435 if ($selected ==
$id) {
5436 $selectedDepositPercent = $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'];
5437 $out .=
'<option value="' .
$id .
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'" selected>';
5439 $out .=
'<option value="' .
$id .
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'">';
5441 $label = $arrayconditions[
'label'];
5443 if (!empty($arrayconditions[
'deposit_percent'])) {
5444 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'], $label);
5448 $out .=
'</option>';
5450 $out .=
'</select>';
5451 if ($user->admin && empty($noinfoadmin)) {
5452 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
5456 if ($deposit_percent >= 0) {
5457 $out .=
' <span id="' . $htmlname .
'_deposit_percent_container"' . (empty($selectedDepositPercent) ?
' style="display: none"' :
'') .
'>';
5458 $out .= $langs->trans(
'DepositPercent') .
' : ';
5459 $out .=
'<input id="' . $htmlname .
'_deposit_percent" name="' . $htmlname .
'_deposit_percent" class="maxwidth50" value="' . $deposit_percent .
'" />';
5462 <script nonce="' . getNonce() .
'">
5463 $(document).ready(function () {
5464 $("#' . $htmlname .
'").change(function () {
5465 let $selected = $(this).find("option:selected");
5466 let depositPercent = $selected.attr("data-deposit_percent");
5468 if (depositPercent.length > 0) {
5469 $("#' . $htmlname .
'_deposit_percent_container").show().find("#' . $htmlname .
'_deposit_percent").val(depositPercent);
5471 $("#' . $htmlname .
'_deposit_percent_container").hide();
5500 $out .=
'<select id="' . $htmlname .
'" class="flat selectbillingterm" name="' . $htmlname .
'">';
5502 $out .=
'<option value="-1"> </option>';
5506 foreach ($this->cache_rule_for_lines_dates as $rule_for_lines_dates_key => $rule_for_lines_dates_name) {
5507 if ($selected == $rule_for_lines_dates_key) {
5508 $out .=
'<option value="' . $rule_for_lines_dates_key .
'" selected>';
5510 $out .=
'<option value="' . $rule_for_lines_dates_key .
'">';
5513 $out .= $langs->trans($rule_for_lines_dates_name);
5514 $out .=
'</option>';
5516 $out .=
'</select>';
5542 public function select_types_paiements($selected =
'', $htmlname =
'paiementtype', $filtertype =
'', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'', $nooutput = 0)
5545 global $langs, $user;
5549 dol_syslog(__METHOD__ .
" " . $selected .
", " . $htmlname .
", " . $filtertype .
", " . $format, LOG_DEBUG);
5551 $filterarray = array();
5552 if ($filtertype ==
'CRDT') {
5553 $filterarray = array(0, 2, 3);
5554 } elseif ($filtertype ==
'DBIT') {
5555 $filterarray = array(1, 2, 3);
5556 } elseif ($filtertype !=
'' && $filtertype !=
'-1') {
5557 $filterarray = explode(
',', $filtertype);
5563 if (empty($selected) && strpos($htmlname,
'search_') !== 0 &&
getDolGlobalString(
'MAIN_DEFAULT_PAYMENT_TYPE_ID')) {
5564 dol_syslog(__METHOD__ .
"Using deprecated option MAIN_DEFAULT_PAYMENT_TYPE_ID", LOG_NOTICE);
5568 $out .=
'<select id="select' . $htmlname .
'" class="flat selectpaymenttypes' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
5570 $out .=
'<option value=""> </option>';
5572 foreach ($this->cache_types_paiements as
$id => $arraytypes) {
5574 if ($active >= 0 && $arraytypes[
'active'] != $active) {
5579 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
5584 if ($empty && empty($arraytypes[
'code'])) {
5589 $out .=
'<option value="' .
$id .
'" data-code="'.$arraytypes[
'code'].
'"';
5590 } elseif ($format == 1) {
5591 $out .=
'<option value="' . $arraytypes[
'code'] .
'"';
5592 } elseif ($format == 2) {
5593 $out .=
'<option value="' . $arraytypes[
'code'] .
'"';
5594 } elseif ($format == 3) {
5595 $out .=
'<option value="' .
$id .
'"';
5598 if ($format == 1 || $format == 2) {
5599 if ($selected == $arraytypes[
'code']) {
5600 $out .=
' selected';
5603 if ($selected ==
$id) {
5604 $out .=
' selected';
5610 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
5611 } elseif ($format == 1) {
5612 $value = $arraytypes[
'code'];
5613 } elseif ($format == 2) {
5614 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
5615 } elseif ($format == 3) {
5616 $value = $arraytypes[
'code'];
5618 $out .= $value ? $value :
' ';
5619 $out .=
'</option>';
5621 $out .=
'</select>';
5622 if ($user->admin && !$noadmininfo) {
5623 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
5627 if (empty($nooutput)) {
5647 $return =
'<select class="flat maxwidth100" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
5649 'HT' => $langs->trans(
"HT"),
5650 'TTC' => $langs->trans(
"TTC")
5652 foreach ($options as
$id => $value) {
5653 if ($selected ==
$id) {
5654 $return .=
'<option value="' .
$id .
'" selected>' . $value;
5656 $return .=
'<option value="' .
$id .
'">' . $value;
5658 $return .=
'</option>';
5660 $return .=
'</select>';
5680 $num = count($this->cache_transport_mode);
5687 $this->cache_transport_mode = array();
5689 $sql =
"SELECT rowid, code, label, active";
5690 $sql .=
" FROM " . $this->db->prefix() .
"c_transport_mode";
5691 $sql .=
" WHERE entity IN (" .
getEntity(
'c_transport_mode') .
")";
5693 $resql = $this->db->query($sql);
5695 $num = $this->db->num_rows($resql);
5698 $obj = $this->db->fetch_object($resql);
5701 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) !=
"PaymentTypeShort" . $obj->code ? $langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
5702 $this->cache_transport_mode[(int) $obj->rowid]
5704 'rowid' => (
int) $obj->rowid,
5705 'code' => (
string) $obj->code,
5706 'label' => (
string) $label,
5707 'active' => (int) $obj->active,
5712 $this->cache_transport_mode =
dol_sort_array($this->cache_transport_mode,
'label',
'asc', 0, 0, 1);
5734 public function selectTransportMode($selected =
'', $htmlname =
'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'')
5736 global $langs, $user;
5738 dol_syslog(__METHOD__ .
" " . $selected .
", " . $htmlname .
", " . $format, LOG_DEBUG);
5742 print
'<select id="select' . $htmlname .
'" class="flat selectmodetransport' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
5744 print
'<option value=""> </option>';
5746 foreach ($this->cache_transport_mode as
$id => $arraytypes) {
5748 if ($active >= 0 && $arraytypes[
'active'] != $active) {
5753 if ($empty && empty($arraytypes[
'code'])) {
5758 print
'<option value="' .
$id .
'"';
5759 } elseif ($format == 1) {
5760 print
'<option value="' . $arraytypes[
'code'] .
'"';
5761 } elseif ($format == 2) {
5762 print
'<option value="' . $arraytypes[
'code'] .
'"';
5763 } elseif ($format == 3) {
5764 print
'<option value="' .
$id .
'"';
5767 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraytypes[
'code']) {
5769 } elseif ($selected ==
$id) {
5775 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
5776 } elseif ($format == 1) {
5777 $value = $arraytypes[
'code'];
5778 } elseif ($format == 2) {
5779 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
5780 } elseif ($format == 3) {
5781 $value = $arraytypes[
'code'];
5783 print $value ? $value :
' ';
5790 if ($user->admin && !$noadmininfo) {
5791 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
5807 public function selectShippingMethod($selected =
'', $htmlname =
'shipping_method_id', $filtre =
'', $useempty = 0, $moreattrib =
'', $noinfoadmin = 0, $morecss =
'')
5809 global $langs, $user;
5811 $langs->loadLangs(array(
"admin",
"sendings"));
5813 $sql =
"SELECT rowid, code, libelle as label";
5814 $sql .=
" FROM " . $this->db->prefix() .
"c_shipment_mode";
5815 $sql .=
" WHERE active > 0";
5817 $sql .= forgeSQLFromUniversalSearchCriteria($filtre);
5819 $sql .=
" ORDER BY libelle ASC";
5821 dol_syslog(get_class($this) .
"::selectShippingMode", LOG_DEBUG);
5823 $result = $this->db->query($sql);
5825 $num = $this->db->num_rows($result);
5828 print
'<select id="select' . $htmlname .
'" class="flat selectshippingmethod' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
5829 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
5830 print
'<option value="-1"> </option>';
5833 $obj = $this->db->fetch_object($result);
5834 if ($selected == $obj->rowid) {
5835 print
'<option value="' . $obj->rowid .
'" selected>';
5837 print
'<option value="' . $obj->rowid .
'">';
5839 print ($langs->trans(
"SendingMethod" . strtoupper($obj->code)) !=
"SendingMethod" . strtoupper($obj->code)) ? $langs->trans(
"SendingMethod" . strtoupper($obj->code)) : $obj->label;
5844 if ($user->admin && empty($noinfoadmin)) {
5845 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
5850 print $langs->trans(
"NoShippingMethodDefined");
5870 $langs->load(
"sendings");
5872 if ($htmlname !=
"none") {
5873 print
'<form method="POST" action="' . $page .
'">';
5874 print
'<input type="hidden" name="action" value="setshippingmethod">';
5875 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
5877 print
'<input type="submit" class="button valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
5881 $code = $langs->getLabelFromKey($this->db, $selected,
'c_shipment_mode',
'rowid',
'code');
5882 print $langs->trans(
"SendingMethod" . strtoupper($code));
5901 $langs->load(
'bills');
5905 $sql =
"SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc";
5906 $sql .=
' FROM ' . $this->db->prefix() .
'facture';
5907 $sql .=
' WHERE entity IN (' .
getEntity(
'invoice') .
')';
5908 $sql .=
' AND situation_counter >= 1';
5909 $sql .=
' AND fk_soc = ' . (int) $socid;
5910 $sql .=
' AND type <> 2';
5911 $sql .=
' ORDER by situation_cycle_ref, situation_counter desc';
5912 $resql = $this->db->query($sql);
5914 $nbSituationInvoiceForThirdparty = 0;
5916 if ($resql && $this->db->num_rows($resql) > 0) {
5919 while ($obj = $this->db->fetch_object($resql)) {
5921 if ($obj->situation_cycle_ref != $ref) {
5923 $ref = $obj->situation_cycle_ref;
5925 if ($obj->situation_final != 1) {
5927 if (substr($obj->ref, 1, 4) !=
'PROV') {
5928 $nbSituationInvoiceForThirdparty++;
5930 if ($selected == $obj->rowid) {
5931 $opt .=
'<option value="' . $obj->rowid .
'" selected>' . $obj->ref .
'</option>';
5933 $opt .=
'<option value="' . $obj->rowid .
'">' . $obj->ref .
'</option>';
5940 dol_syslog(
"Error sql=" . $sql .
", error=" . $this->error, LOG_ERR);
5943 if ($nbSituationInvoiceForThirdparty > 0) {
5944 $opt =
'<option class="minwidth100" value="" selected> </option>'.$opt;
5946 $opt =
'<option class="minwidth100" value="-1" selected>'.$langs->trans(
'NoSituations').
'</option>';
5961 public function selectUnits($selected =
'', $htmlname =
'units', $showempty = 0, $unit_type =
'')
5965 $langs->load(
'products');
5967 $return =
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'">';
5969 $sql =
"SELECT rowid, label, code FROM " . $this->db->prefix() .
"c_units";
5970 $sql .=
' WHERE active > 0';
5971 if (!empty($unit_type)) {
5972 $sql .=
" AND unit_type = '" . $this->db->escape($unit_type) .
"'";
5974 $sql .=
" ORDER BY sortorder";
5976 $resql = $this->db->query($sql);
5977 if ($resql && $this->db->num_rows($resql) > 0) {
5979 $return .=
'<option value="-1"></option>';
5982 while ($res = $this->db->fetch_object($resql)) {
5983 $unitLabel = $res->label;
5984 if (!empty($langs->tab_translate[
'unit' . $res->code])) {
5985 $unitLabel = $langs->trans(
'unit' . $res->code) != $res->label ? $langs->trans(
'unit' . $res->code) : $res->label;
5988 if ($selected == $res->rowid) {
5989 $return .=
'<option value="' . $res->rowid .
'" selected>' . $unitLabel .
'</option>';
5991 $return .=
'<option value="' . $res->rowid .
'">' . $unitLabel .
'</option>';
5994 $return .=
'</select>';
6018 public function select_comptes($selected =
'', $htmlname =
'accountid', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'', $showcurrency = 0, $morecss =
'', $nooutput = 0, $addentrynone = 0)
6025 $langs->loadLangs(array(
"admin",
"banks"));
6028 $sql =
"SELECT rowid, label, bank, clos as status, currency_code";
6029 $sql .=
" FROM " . $this->db->prefix() .
"bank_account";
6030 $sql .=
" WHERE entity IN (" .
getEntity(
'bank_account') .
")";
6032 $sql .=
" AND clos = " . (int) $status;
6035 $sql .= forgeSQLFromUniversalSearchCriteria($filtre);
6037 $sql .=
" ORDER BY label";
6039 dol_syslog(get_class($this) .
"::select_comptes", LOG_DEBUG);
6040 $result = $this->db->query($sql);
6042 $num = $this->db->num_rows($result);
6045 $out .=
'<select id="select' . $htmlname .
'" class="flat selectbankaccount' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
6049 $out .=
'<option class="opacitymedium" value="-1">' . $langs->trans(
"NoActiveBankAccountDefined") .
'</span>';
6051 $out .=
'<option class="opacitymedium" value="-1">' . $langs->trans(
"NoBankAccountDefined") .
'</span>';
6054 if (!empty($useempty) && !is_numeric($useempty)) {
6055 $out .=
'<option value="-1">'.$langs->trans($useempty).
'</option>';
6056 } elseif ($useempty == 1 || ($useempty == 2 && $num > 1)) {
6057 $out .=
'<option value="-1"> </option>';
6062 $obj = $this->db->fetch_object($result);
6064 $labeltoshow = trim($obj->label);
6065 $labeltoshowhtml = trim($obj->label);
6066 if ($showcurrency) {
6067 $labeltoshow .=
' (' . $obj->currency_code .
')';
6068 $labeltoshowhtml .=
' <span class="opacitymedium">(' . $obj->currency_code .
')</span>';
6070 if ($status == 2 && $obj->status == 1) {
6071 $labeltoshow .=
' (' . $langs->trans(
"Closed") .
')';
6072 $labeltoshowhtml .=
' <span class="opacitymedium">(' . $langs->trans(
"Closed") .
')</span>';
6075 if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected))) {
6076 $out .=
'<option value="' . $obj->rowid .
'" data-currency-code="' . $obj->currency_code .
'" data-html="'.dolPrintHTMLForAttribute($labeltoshowhtml).
'" selected>';
6078 $out .=
'<option value="' . $obj->rowid .
'" data-currency-code="' . $obj->currency_code .
'" data-html="'.dolPrintHTMLForAttribute($labeltoshowhtml).
'">';
6080 $out .= $labeltoshow;
6081 $out .=
'</option>';
6085 if (!empty($addentrynone)) {
6086 $out .=
'<option value="-2"'.($selected == -2 ?
' selected="selected"' :
'').
' data-html="'.
dolPrintHTMLForAttribute(
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>').
'">'.$langs->trans(
"None").
'</option>';
6089 $out .=
"</select>";
6096 if (empty($nooutput)) {
6118 public function selectRib($selected =
'', $htmlname =
'ribcompanyid', $filtre =
'', $useempty = 0, $moreattrib =
'', $showibanbic = 0, $morecss =
'', $nooutput = 0)
6125 $langs->loadLangs(array(
"admin",
"banks"));
6128 $sql =
"SELECT rowid, label, bank, status, iban_prefix, bic, default_rib";
6129 $sql .=
" FROM " . $this->db->prefix() .
"societe_rib";
6130 $sql .=
" WHERE type = 'ban'";
6132 $sql .= forgeSQLFromUniversalSearchCriteria($filtre);
6134 $sql .=
" ORDER BY label";
6135 dol_syslog(get_class($this) .
"::select_comptes", LOG_DEBUG);
6136 $result = $this->db->query($sql);
6138 $num = $this->db->num_rows($result);
6141 $out .=
'<select id="select' . $htmlname .
'" class="flat selectbankaccount' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
6144 $out .=
'<option class="opacitymedium" value="-1">' . $langs->trans(
"NoBankAccountDefined") .
'</span>';
6146 if (!empty($useempty) && !is_numeric($useempty)) {
6147 $out .=
'<option value="-1">'.$langs->trans($useempty).
'</option>';
6148 } elseif ($useempty == 1 || ($useempty == 2 && $num > 1)) {
6149 $out .=
'<option value="-1"> </option>';
6154 $obj = $this->db->fetch_object($result);
6156 if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected))) {
6157 $out .=
'<option value="' . $obj->rowid .
'" data-iban-prefix="' . $iban .
' data-bic="' . $obj->bic .
'" selected>';
6159 $out .=
'<option value="' . $obj->rowid .
'" data-iban-prefix="' . $iban .
' data-bic="' . $obj->bic .
'">';
6161 $out .= trim($obj->label);
6163 $out .=
' (' . $iban .
'/' .$obj->bic.
')' . ($obj->default_rib ?
' ['.$langs->trans(
"ByDefault").
']' :
'');
6165 $out .=
'</option>';
6168 $out .=
"</select>";
6175 if (empty($nooutput)) {
6195 public function selectEstablishments($selected =
'', $htmlname =
'entity', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'')
6199 $langs->load(
"admin");
6202 $sql =
"SELECT rowid, name, fk_country, status, entity";
6203 $sql .=
" FROM " . $this->db->prefix() .
"establishment";
6204 $sql .=
" WHERE 1=1";
6206 $sql .=
" AND status = " . (int) $status;
6209 $sql .= forgeSQLFromUniversalSearchCriteria($filtre);
6211 $sql .=
" ORDER BY name";
6213 dol_syslog(get_class($this) .
"::select_establishment", LOG_DEBUG);
6214 $result = $this->db->query($sql);
6216 $num = $this->db->num_rows($result);
6219 print
'<select id="select' . $htmlname .
'" class="flat selectestablishment" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
6220 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
6221 print
'<option value="-1"> </option>';
6225 $obj = $this->db->fetch_object($result);
6226 if ($selected == $obj->rowid) {
6227 print
'<option value="' . $obj->rowid .
'" selected>';
6229 print
'<option value="' . $obj->rowid .
'">';
6231 print trim($obj->name);
6232 if ($status == 2 && $obj->status == 1) {
6233 print
' (' . $langs->trans(
"Closed") .
')';
6241 print
'<span class="opacitymedium">' . $langs->trans(
"NoActiveEstablishmentDefined") .
'</span>';
6243 print
'<span class="opacitymedium">' . $langs->trans(
"NoEstablishmentFound") .
'</span>';
6266 if ($htmlname !=
"none") {
6267 print
'<form method="POST" action="' . $page .
'">';
6268 print
'<input type="hidden" name="action" value="setbankaccount">';
6269 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
6270 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
6271 $nbaccountfound = $this->
select_comptes($selected, $htmlname, 0,
'', $addempty);
6272 if ($nbaccountfound > 0) {
6273 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6277 $langs->load(
'banks');
6280 require_once DOL_DOCUMENT_ROOT .
'/compta/bank/class/account.class.php';
6281 $bankstatic =
new Account($this->db);
6282 $result = $bankstatic->fetch((
int) $selected);
6284 print $bankstatic->getNomUrl(1);
6303 public function formRib($page, $selected =
'', $htmlname =
'ribcompanyid', $filtre =
'', $addempty = 0, $showibanbic = 0)
6306 if ($htmlname !=
"none") {
6307 print
'<form method="POST" action="' . $page .
'">';
6308 print
'<input type="hidden" name="action" value="setbankaccountcustomer">';
6309 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
6310 $nbaccountfound = $this->
selectRib($selected, $htmlname, $filtre, $addempty,
'', $showibanbic);
6311 if ($nbaccountfound > 0) {
6312 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6316 $langs->load(
'banks');
6319 require_once DOL_DOCUMENT_ROOT .
'/societe/class/companybankaccount.class.php';
6321 $result = $bankstatic->fetch((
int) $selected);
6323 print $bankstatic->label;
6325 print
' (' . $bankstatic->iban .
'/' .$bankstatic->bic.
')';
6351 $arrayselected = array();
6353 $arrayselected =
GETPOST($htmlname,
'array:int');
6356 $cats =
$c->containing(
$object->id, $categtype);
6357 $arrayselected = array();
6358 foreach ($cats as $cat) {
6359 $arrayselected[] = $cat->id;
6363 $out .=
img_picto(
'',
'category',
'class="pictofixedwidth"');
6364 $out .= $this->
multiselectarray($htmlname, $cate_arbo, $arrayselected, 0, 0,
'minwidth100 widthcentpercentminusxx', 0, 0);
6368 $jsonclose =
'doJsCodeAfterPopupClose'.$htmlname.
'()';
6369 $urltoopen =
'/categories/categorie_list.php?type='.urlencode($categtype).
'&nosearch=1';
6374 $out .=
'<!-- Add js code to open the popup for category/edit/add -->'.
"\n";
6375 $out .=
'<script>function doJsCodeAfterPopupClose'.$htmlname.
'() {
6376 console.log("doJsCodeAfterPopupClose'.$htmlname.
' has been called, we refresh the combo content + refresh select2...");
6378 // Call an ajax to reload values and update the select
6379 // $("#'.
dol_escape_js($htmlname).
'").append(new Option("Option 4", "4"));
6381 // Refresh select2 to take account of new values (enough for small change)
6384 url: \''.DOL_URL_ROOT.
'/core/ajax/fetchCategories.php\',
6386 action: \'getCategories\',
6391 success: function (data) {
6392 var $select = $(\'#'.dol_escape_js($htmlname).
'\');
6393 var selectedValues = $select.val();
6394 console.log(selectedValues);
6396 $.each(data,
function (index, item) {
6397 $select.append(\
'<option value="\' + item.id + \'" data-html="\' + item.htmlforattribute + \'">\' + item.htmlforoption + \'</option>\');
6399 $select.val(selectedValues);
6401 error: function (xhr, status, error) {
6402 console.log("Error when loading ajax page : " + error);
6407 // Alternative if change in select is complex
6439 public function select_all_categories($type, $selected =
'', $htmlname =
"parent", $maxlength = 64, $fromid = 0, $outputmode = 0, $include = 0, $morecss =
'', $useempty = 1)
6444 include_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
6448 if (is_numeric($type)) {
6449 $type = array_search($type, $cat->MAP_ID);
6452 $cate_arbo = $cat->get_full_arbo($type, $fromid, $include);
6454 $outarray = array();
6455 $outarrayrichhtml = array();
6458 $output =
'<select class="flat minwidth100' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
6460 if (is_array($cate_arbo)) {
6461 $num = count($cate_arbo);
6464 $langs->load(
"categories");
6465 $output .=
'<option value="-1" disabled>' . $langs->trans(
"NoCategoriesDefined") .
'</option>';
6467 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
6468 $output .=
'<option value="-1"> </option>';
6470 foreach ($cate_arbo as $key => $value) {
6471 if ($cate_arbo[$key][
'id'] == $selected || ($selected ===
'auto' && count($cate_arbo) == 1)) {
6477 $labeltoshow =
img_picto(
'',
'category',
'class="pictofixedwidth"'.(empty($cate_arbo[$key][
'color']) ?
'' :
' style="color: #' . $cate_arbo[$key][
'color'] .
'"'));
6478 $labeltoshow .=
dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle');
6480 $outarray[$cate_arbo[$key][
'id']] = $cate_arbo[$key][
'fulllabel'];
6482 $outarrayrichhtml[$cate_arbo[$key][
'id']] = $labeltoshow;
6484 $output .=
'<option ' . $add .
'value="' . $cate_arbo[$key][
'id'] .
'"';
6493 $output .=
'</option>';
6495 $cate_arbo[$key][
'data-html'] = $labeltoshow;
6499 $output .=
'</select>';
6504 if ($outputmode == 2) {
6507 } elseif ($outputmode == 1) {
6509 } elseif ($outputmode == 3) {
6510 return $outarrayrichhtml;
6530 $html =
'<details class="dolibarr-help-block" style="margin-top:8px;">';
6531 $html .=
'<summary style="cursor:pointer; color:#0056b3; font-weight:normal; list-style:none; font-size:0.9em; display:flex; align-items:center;">';
6532 $html .=
'<span class="fa ' . $icon .
'" style="margin-right:6px;"></span>';
6533 $html .= $langs->trans(
"Help");
6534 $html .=
'</summary>';
6535 $html .=
'<div style="margin-top:6px; padding:10px; background:#f8f9fa; border:1px solid #dee2e6; border-radius:4px; font-size:0.9em; color:#555; line-height:1.5;">';
6538 $html .=
'</details>';
6563 public function form_confirm($page, $title, $question, $action, $formquestion = array(), $selectedchoice =
"", $useajax = 0, $height = 170, $width = 500)
6566 dol_syslog(__METHOD__ .
': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING);
6567 print $this->
formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width);
6599 public function formconfirm($page, $title, $question, $action, $formquestion =
'', $selectedchoice =
'', $useajax = 0, $height = 0, $width = 600, $disableformtag = 0, $labelbuttonyes =
'Yes', $labelbuttonno =
'No', $helpContent =
'')
6601 global $langs,
$conf;
6604 $formconfirm =
'<!-- formconfirm - before call, page=' .
dol_escape_htmltag($page) .
' -->';
6610 $newselectedchoice = empty($selectedchoice) ?
"no" : $selectedchoice;
6611 if (
$conf->browser->layout ==
'phone') {
6616 if (empty($height)) {
6618 if (is_array($formquestion)) {
6619 $height += (count($formquestion) * 40);
6626 if (is_array($formquestion) && !empty($formquestion)) {
6628 foreach ($formquestion as $key => $input) {
6629 if (is_array($input) && !empty($input)) {
6630 if ($input[
'type'] ==
'hidden') {
6631 $moreattr = (!empty($input[
'moreattr']) ?
' ' . $input[
'moreattr'] :
'');
6632 $morecss = (!empty($input[
'morecss']) ?
' ' . $input[
'morecss'] :
'');
6640 $moreonecolumn =
'';
6641 $more .=
'<div class="tagtable paddingtopbottomonly centpercent noborderspacing">' .
"\n";
6642 foreach ($formquestion as $key => $input) {
6643 if (is_array($input) && !empty($input)) {
6644 $size = (!empty($input[
'size']) ?
' size="' . $input[
'size'] .
'"' :
'');
6645 $moreattr = (!empty($input[
'moreattr']) ?
' ' . $input[
'moreattr'] :
'');
6646 $morecss = (!empty($input[
'morecss']) ?
' ' . $input[
'morecss'] :
'');
6648 if ($input[
'type'] ==
'text' || $input[
'type'] ==
'input') {
6649 $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 .
' spellcheck="false" /></div></div>' .
"\n";
6650 } elseif ($input[
'type'] ==
'password') {
6651 $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";
6652 } elseif ($input[
'type'] ==
'textarea') {
6653 $moreonecolumn .=
'<div class="margintoponly">';
6654 $moreonecolumn .= $input[
'label'] .
'<br>';
6656 $moreonecolumn .= $input[
'value'];
6657 $moreonecolumn .=
'</textarea>';
6658 $moreonecolumn .=
'</div>';
6659 } elseif (in_array($input[
'type'], [
'select',
'multiselect'])) {
6660 if (empty($morecss)) {
6661 $morecss =
'minwidth100';
6664 $show_empty = isset($input[
'select_show_empty']) ? $input[
'select_show_empty'] : 1;
6665 $key_in_label = isset($input[
'select_key_in_label']) ? $input[
'select_key_in_label'] : 0;
6666 $value_as_key = isset($input[
'select_value_as_key']) ? $input[
'select_value_as_key'] : 0;
6667 $translate = isset($input[
'select_translate']) ? $input[
'select_translate'] : 0;
6668 $maxlen = isset($input[
'select_maxlen']) ? $input[
'select_maxlen'] : 0;
6669 $disabled = isset($input[
'select_disabled']) ? $input[
'select_disabled'] : 0;
6670 $sort = isset($input[
'select_sort']) ? $input[
'select_sort'] :
'';
6672 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">';
6673 if (!empty($input[
'label'])) {
6674 $more .= $input[
'label'] .
'</div><div class="tagtd left">';
6676 if ($input[
'type'] ==
'select') {
6677 $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);
6679 $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);
6681 $more .=
'</div></div>' .
"\n";
6682 } elseif ($input[
'type'] ==
'checkbox') {
6683 $more .=
'<div class="tagtr">';
6684 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'"><label for="' .
dol_escape_htmltag($input[
'name']) .
'">' . $input[
'label'] .
'</label></div><div class="tagtd">';
6685 $more .=
'<input type="checkbox" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' .
dol_escape_htmltag($input[
'name']) .
'" name="' .
dol_escape_htmltag($input[
'name']) .
'"' . $moreattr;
6686 if (!is_bool($input[
'value']) && $input[
'value'] !=
'false' && $input[
'value'] !=
'0' && $input[
'value'] !=
'') {
6687 $more .=
' checked';
6689 if (is_bool($input[
'value']) && $input[
'value']) {
6690 $more .=
' checked';
6692 if (isset($input[
'disabled'])) {
6693 $more .=
' disabled';
6695 $more .=
' /></div>';
6696 $more .=
'</div>' .
"\n";
6697 } elseif ($input[
'type'] ==
'radio') {
6699 foreach ($input[
'values'] as $selkey => $selval) {
6700 $more .=
'<div class="tagtr">';
6701 if (isset($input[
'label'])) {
6703 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
' tdtop' : (
' tdtop ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div>';
6705 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' "' . $input[
'tdclass'])) .
'"> </div>';
6708 $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;
6709 if (!empty($input[
'disabled'])) {
6710 $more .=
' disabled';
6712 if (isset($input[
'default']) && $input[
'default'] === $selkey) {
6713 $more .=
' checked="checked"';
6716 $more .=
'<label for="' .
dol_escape_htmltag($input[
'name'] . $selkey) .
'" class="valignmiddle">' . $selval .
'</label>';
6717 $more .=
'</div></div>' .
"\n";
6720 } elseif ($input[
'type'] ==
'date' || $input[
'type'] ==
'datetime') {
6721 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div>';
6722 $more .=
'<div class="tagtd">';
6723 $addnowlink = (empty($input[
'datenow']) ? 0 : 1);
6725 if ($input[
'type'] ==
'datetime') {
6726 $h = isset($input[
'hours']) ? $input[
'hours'] : 1;
6727 $m = isset($input[
'minutes']) ? $input[
'minutes'] : 1;
6729 $more .= $this->
selectDate(isset($input[
'value']) ? $input[
'value'] : -1, $input[
'name'], $h, $m, 0,
'', 1, $addnowlink);
6730 $more .=
'</div></div>'.
"\n";
6731 $formquestion[] = array(
'name' => $input[
'name'].
'day');
6732 $formquestion[] = array(
'name' => $input[
'name'].
'month');
6733 $formquestion[] = array(
'name' => $input[
'name'].
'year');
6734 $formquestion[] = array(
'name' => $input[
'name'].
'hour');
6735 $formquestion[] = array(
'name' => $input[
'name'].
'min');
6736 } elseif ($input[
'type'] ==
'other') {
6737 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">';
6738 if (!empty($input[
'label'])) {
6739 $more .= $input[
'label'] .
'</div><div class="tagtd">';
6741 if (!empty($input[
'value'])) {
6742 $more .= $input[
'value'];
6744 $more .=
'</div></div>' .
"\n";
6745 } elseif ($input[
'type'] ==
'onecolumn') {
6746 $moreonecolumn .=
'<div class="margintoponly">';
6747 $moreonecolumn .= $input[
'value'];
6748 $moreonecolumn .=
'</div>' .
"\n";
6749 } elseif ($input[
'type'] ==
'hidden') {
6751 } elseif ($input[
'type'] ==
'separator') {
6754 $more .=
'Error type ' . $input[
'type'] .
' for the confirm box is not a supported type';
6758 $more .=
'</div>' .
"\n";
6759 $more .= $moreonecolumn;
6765 if (!empty(
$conf->dol_use_jmobile)) {
6768 if (empty(
$conf->use_javascript_ajax)) {
6774 $dialogconfirm =
'dialog-confirm';
6776 if (!is_numeric($useajax)) {
6780 $dialogconfirm .=
'-' . $button;
6782 $pageyes = $page . (preg_match(
'/\?/', $page) ?
'&' :
'?') .
'action=' . urlencode($action) .
'&confirm=yes';
6783 $pageno = ($useajax == 2 ? $page . (preg_match(
'/\?/', $page) ?
'&' :
'?') .
'action=' . urlencode($action) .
'&confirm=no' :
'');
6786 if (is_array($formquestion)) {
6787 foreach ($formquestion as $key => $input) {
6790 if (is_array($input) && isset($input[
'name'])) {
6791 if (strpos($input[
'name'],
',') > 0) {
6792 $inputok = array_merge($inputok, explode(
',', $input[
'name']));
6794 array_push($inputok, $input[
'name']);
6799 if (is_array($input) && isset($input[
'inputko']) && $input[
'inputko'] == 1 && isset($input[
'name'])) {
6800 array_push($inputko, $input[
'name']);
6807 $formconfirm .=
'<div id="' . $dialogconfirm .
'" title="' .
dol_escape_htmltag($title) .
'" style="display: none;">';
6808 $formconfirm .=
'<div style="display: flex; flex-direction: column; height: 100%;">';
6809 if (is_array($formquestion) && array_key_exists(
'text', $formquestion) && !empty($formquestion[
'text'])) {
6810 $formconfirm .=
'<div class="confirmtext">' . $formquestion[
'text'] .
'</div>' .
"\n";
6812 if (!empty($more)) {
6813 $formconfirm .=
'<div class="confirmquestions">' . $more .
'</div>' .
"\n";
6816 if (!empty($helpContent)) {
6817 $formconfirm .=
'<div style="text-align:left; margin-top:12px; padding-top:8px; border-top:1px solid #eee; clear:both;">';
6819 $formconfirm .=
'</div>';
6821 if (!empty($question)) {
6822 $formconfirm .=
'<div class="confirmmessage" style="padding-top: 15px;">';
6823 $formconfirm .=
img_help(0,
'') .
' ' . $question;
6824 $formconfirm .=
'</div>';
6826 $formconfirm .=
'</div>';
6827 $formconfirm .=
'</div>' .
"\n";
6829 $formconfirm .=
"\n<!-- begin code of popup for formconfirm page=" . $page .
" -->\n";
6830 $formconfirm .=
'<script nonce="' . getNonce() .
'" type="text/javascript">' .
"\n";
6831 $formconfirm .=
"/* Code for the jQuery('#dialogforpopup').dialog() */\n";
6832 $formconfirm .=
'jQuery(document).ready(function() {
6834 $( "#' . $dialogconfirm .
'" ).dialog({
6835 autoOpen: ' . ($autoOpen ?
"true" :
"false") .
',';
6836 if ($newselectedchoice ==
'no') {
6839 $(this).parent().find("button.ui-button:eq(2)").focus();
6844 if ($useajax == 1) {
6845 $jsforcursor =
'// The call to urljump can be slow, so we set the wait cursor' .
"\n";
6846 $jsforcursor .=
'jQuery("html,body,#id-container").addClass("cursorwait");' .
"\n";
6849 $postconfirmas =
'GET';
6856 closeOnEscape:
false,
6858 "' . dol_escape_js($langs->transnoentities($labelbuttonyes)) . '":
function() {
6859 var options =
"token=' . urlencode(newToken()) . '";
6860 var inputok =
' . json_encode($inputok) . ';
6861 var page = \
'' .
dol_escape_js(!empty($page) ? $page :
'') .
'\';
6862 var pageyes = \
'' .
dol_escape_js(!empty($pageyes) ? $pageyes :
'') .
'\';
6864 if (inputok.length > 0) {
6865 $.each(inputok,
function(i, inputname) {
6868 if ($(
"input[name=\'" + inputname +
"\']").attr(
"type") ==
"radio") {
6869 inputvalue = $(
"input[name=\'" + inputname +
"\']:checked").val();
6871 if ($(
"#" + inputname).attr(
"type") ==
"checkbox") { more =
":checked"; }
6872 inputvalue = $(
"#" + inputname + more).val();
6874 if (typeof inputvalue ==
"undefined") { inputvalue=
""; }
6875 console.log(
"formconfirm check inputname="+inputname+
" inputvalue="+inputvalue);
6876 options +=
"&" + inputname +
"=" + encodeURIComponent(inputvalue);
6879 var urljump = pageyes + (pageyes.indexOf(
"?") < 0 ?
"?" :
"&") + options;
6880 if (pageyes.length > 0) {
';
6881 if ($postconfirmas == 'GET
') {
6882 $formconfirm .= 'location.href = urljump;
';
6884 $formconfirm .= $jsforcursor;
6885 $formconfirm .= 'var post = $.post(
6888 function(data) { $(
"body").html(data); jQuery(
"html,body,#id-container").removeClass(
"cursorwait"); }
6892 console.log(
"after post ok");
6894 $(
this).dialog(
"close");
6896 "' . dol_escape_js($langs->transnoentities($labelbuttonno)) . '":
function() {
6897 var options =
"token=' . urlencode(newToken()) . '";
6898 var inputko =
' . json_encode($inputko) . ';
6899 var page =
"' . dol_escape_js(!empty($page) ? $page : '') . '";
6900 var pageno=
"' . dol_escape_js(!empty($pageno) ? $pageno : '') . '";
6901 if (inputko.length > 0) {
6902 $.each(inputko,
function(i, inputname) {
6904 if ($(
"#" + inputname).attr(
"type") ==
"checkbox") { more =
":checked"; }
6905 var inputvalue = $(
"#" + inputname + more).val();
6906 if (typeof inputvalue ==
"undefined") { inputvalue=
""; }
6907 options +=
"&" + inputname +
"=" + encodeURIComponent(inputvalue);
6910 var urljump=pageno + (pageno.indexOf(
"?") < 0 ?
"?" :
"&") + options;
6912 if (pageno.length > 0) {
';
6913 if ($postconfirmas == 'GET
') {
6914 $formconfirm .= 'location.href = urljump;
';
6916 $formconfirm .= $jsforcursor;
6917 $formconfirm .= 'var post = $.post(
6920 function(data) { $(
"body").html(data); jQuery(
"html,body,#id-container").removeClass(
"cursorwait"); }
6924 console.log(
"after post ko");
6926 $(
this).dialog(
"close");
6932 var
button =
"' . $button . '";
6934 $(
"#" +
button ).click(
function() {
6935 $(
"#' . $dialogconfirm . '").dialog(
"open");
6941 $formconfirm .= "<!-- end ajax formconfirm -->\n";
6943 $formconfirm .= "\n<!-- begin formconfirm page=" . dol_escape_htmltag($page) . " -->\n";
6945 if (empty($disableformtag)) {
6946 $formconfirm .= '<form method=
"POST" action=
"' . $page . '" class=
"notoptoleftnoright">
' . "\n";
6949 $formconfirm .= '<input
type=
"hidden" name=
"action" value=
"' . $action . '">
' . "\n";
6950 $formconfirm .= '<input
type=
"hidden" name=
"token" value=
"' . newToken() . '">
' . "\n";
6952 $formconfirm .= '<div
class=
"valid">
' . "\n";
6955 $formconfirm .= '<div
class=
"validtitre">
';
6956 $formconfirm .= img_picto('', 'pictoconfirm
') . ' ' . $title;
6957 $formconfirm .= '</div>
' . "\n";
6960 if (is_array($formquestion) && array_key_exists('text
', $formquestion) && !empty($formquestion['text
'])) {
6961 $formconfirm .= '<div
class=
"valid">
' . $formquestion['text
'] . '</div>
' . "\n";
6966 $formconfirm .= '<div>
' . "\n";
6967 $formconfirm .= $more;
6968 $formconfirm .= '</div>
' . "\n";
6971 // NEW: Help block row (between form fields and question)
6972 if (!empty($helpContent)) {
6973 $formconfirm .= '<div style=
"padding-top:8px; border-top:1px solid #888;">
';
6974 $formconfirm .= $this->getHelpBlock($helpContent);
6975 $formconfirm .= '</div>
' . "\n";
6978 // Let's add a row that acts as a spacer.
6979 $formconfirm .=
'<div style="padding-top: 20px;"></div>' .
"\n";
6982 $formconfirm .=
'<div class="inline-block">' . $question .
'</div>';
6984 $formconfirm .=
'<div class="inline-block">';
6985 $formconfirm .= $this->selectyesno(
"confirm", $newselectedchoice, 0,
false, 0, 0,
'marginleftonly marginrightonly', $labelbuttonyes, $labelbuttonno);
6986 $formconfirm .=
'<input class="button valignmiddle confirmvalidatebutton small" type="submit" value="' . $langs->trans(
"Validate") .
'">';
6987 $formconfirm .=
'</div>';
6989 $formconfirm .=
'</div>';
6991 if (empty($disableformtag)) {
6992 $formconfirm .=
"</form>\n";
6994 $formconfirm .=
'<br>';
6996 if (!empty(
$conf->use_javascript_ajax)) {
6997 $formconfirm .=
'<!-- code to disable button to avoid double clic -->';
6998 $formconfirm .=
'<script nonce="' . getNonce() .
'" type="text/javascript">' .
"\n";
7000 $(document).ready(function () {
7001 $(".confirmvalidatebutton").on("click", function() {
7002 console.log("We click on button confirmvalidatebutton");
7003 $(this).attr("disabled", "disabled");
7004 setTimeout(\'$(".confirmvalidatebutton").removeAttr("disabled")\', 3000);
7005 //console.log($(this).closest("form"));
7006 $(this).closest("form").submit();
7010 $formconfirm .=
'</script>' .
"\n";
7013 $formconfirm .=
"<!-- end formconfirm -->\n";
7016 return $formconfirm;
7037 public function form_project($page, $socid, $selected =
'', $htmlname =
'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0, $textifnoproject =
'', $morecss =
'', $option =
'')
7042 require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
7043 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
7049 $langs->load(
"project");
7050 if ($htmlname !=
"none") {
7051 $out .=
'<form method="post" action="' . $page .
'">';
7052 $out .=
'<input type="hidden" name="action" value="classin">';
7053 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
7054 $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0,
'', 1, 0, $morecss);
7055 $out .=
'<input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
7058 $out .=
'<span class="project_head_block">';
7059 if ($selected instanceof
Project) {
7060 $out .= $selected->getNomUrl(0, $option, 1);
7061 } elseif (is_numeric($selected)) {
7062 $projet =
new Project($this->db);
7063 $projet->fetch((
int) $selected);
7064 $out .= $projet->getNomUrl(0, $option, 1);
7066 $out .=
'<span class="opacitymedium">' . $textifnoproject .
'</span>';
7071 if (empty($nooutput)) {
7095 public function form_conditions_reglement($page, $selected =
'', $htmlname =
'cond_reglement_id', $addempty = 0, $type =
'', $filtertype = -1, $deposit_percent = -1, $nooutput = 0)
7100 $selected = (int) $selected;
7104 if ($htmlname !=
"none") {
7105 $out .=
'<form method="POST" action="' . $page .
'">';
7106 $out .=
'<input type="hidden" name="action" value="setconditions">';
7107 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
7109 $out .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
7111 $out .= $this->getSelectConditionsPaiements($selected, $htmlname, $filtertype, $addempty, 0,
'', $deposit_percent);
7112 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
7116 $this->load_cache_conditions_paiements();
7118 if (isset($this->cache_conditions_paiements[$selected])) {
7119 $label = $this->cache_conditions_paiements[$selected][
'label'];
7121 if (!empty($this->cache_conditions_paiements[$selected][
'deposit_percent'])) {
7122 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $this->cache_conditions_paiements[$selected][
'deposit_percent'], $label);
7127 $langs->load(
'errors');
7128 $out .= $langs->trans(
'ErrorNotInDictionaryPaymentConditions');
7135 if (empty($nooutput)) {
7161 if ($htmlname !=
'none') {
7162 $out .=
'<form method="POST" action="' . $page .
'">';
7163 $out .=
'<input type="hidden" name="action" value="setruleforlinesdates">';
7164 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
7165 $out .= $this->getSelectRuleForLinesDates($selected, $htmlname, $addempty);
7166 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
7169 if (isset($selected)) {
7170 $this->load_cache_rule_for_lines_dates();
7171 if (isset($this->cache_rule_for_lines_dates[$selected])) {
7172 $label = $this->cache_rule_for_lines_dates[$selected];
7173 $out .= $langs->trans($label);
7180 if (empty($nooutput)) {
7204 if ($htmlname !=
"none") {
7205 print
'<form method="post" action="' . $page .
'">';
7206 print
'<input type="hidden" name="action" value="setavailability">';
7207 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
7208 print $this->selectAvailabilityDelay($selected, $htmlname,
'', $addempty,
'', 1);
7209 print
'<input type="submit" name="modify" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
7210 print
'<input type="submit" name="cancel" class="button smallpaddingimp" value="' . $langs->trans(
"Cancel") .
'">';
7214 $this->load_cache_availability();
7216 if (isset($this->cache_availability[$selected])) {
7217 print $this->cache_availability[$selected][
'label'];
7238 public function formInputReason($page, $selected =
'', $htmlname =
'demandreason', $addempty = 0, $morecss =
'')
7241 if ($htmlname !=
"none") {
7242 print
'<form method="post" action="' . $page .
'">';
7243 print
'<input type="hidden" name="action" value="setdemandreason">';
7244 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
7245 $this->selectInputReason($selected, $htmlname,
'-1', $addempty, $morecss);
7246 print
'<input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
7250 $this->loadCacheInputReason();
7251 foreach ($this->cache_demand_reason as $key => $val) {
7252 if ($val[
'id'] == $selected) {
7253 print $val[
'label'];
7278 public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0, $type =
'')
7285 if ($htmlname !=
"none") {
7286 $ret .=
'<form method="POST" action="' . $page .
'" name="form' . $htmlname .
'">';
7287 $ret .=
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
7288 $ret .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
7290 $ret .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
7292 $ret .=
'<table class="nobordernopadding">';
7294 $ret .= $this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1,
'form' . $htmlname, 1, 0);
7296 $ret .=
'<td class="left"><input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'"></td>';
7297 $ret .=
'</tr></table></form>';
7306 if (empty($nooutput)) {
7325 public function form_users($page, $selected =
'', $htmlname =
'userid', $exclude = array(), $include = array())
7330 if ($htmlname !=
"none") {
7331 print
'<form method="POST" action="' . $page .
'" name="form' . $htmlname .
'">';
7332 print
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
7333 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
7334 print $this->select_dolusers($selected, $htmlname, 1, $exclude, 0, $include);
7335 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
7339 require_once DOL_DOCUMENT_ROOT .
'/user/class/user.class.php';
7340 $theuser =
new User($this->db);
7341 $theuser->fetch((
int) $selected);
7342 print $theuser->getNomUrl(1);
7365 public function form_modes_reglement($page, $selected =
'', $htmlname =
'mode_reglement_id', $filtertype =
'', $active = 1, $addempty = 0, $type =
'', $nooutput = 0)
7371 if ($htmlname !=
"none") {
7372 $out .=
'<form method="POST" action="' . $page .
'">';
7373 $out .=
'<input type="hidden" name="action" value="setmode">';
7374 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
7376 $out .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
7378 $out .= $this->select_types_paiements($selected, $htmlname, $filtertype, 0, $addempty, 0, 0, $active,
'', 1);
7379 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
7383 $this->load_cache_types_paiements();
7384 $out .= $this->cache_types_paiements[$selected][
'label'];
7411 if ($htmlname !=
"none") {
7412 print
'<form method="POST" action="' . $page .
'">';
7413 print
'<input type="hidden" name="action" value="settransportmode">';
7414 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
7415 $this->selectTransportMode($selected, $htmlname, 0, $addempty, 0, 0, $active);
7416 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
7420 $this->load_cache_transport_mode();
7421 print $this->cache_transport_mode[$selected][
'label'];
7442 if ($htmlname !=
"none") {
7443 print
'<form method="POST" action="' . $page .
'">';
7444 print
'<input type="hidden" name="action" value="setmulticurrencycode">';
7445 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
7446 print $this->selectMultiCurrency($selected, $htmlname, 0);
7447 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
7450 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
7451 print !empty($selected) ?
currency_name($selected, 1) :
' ';
7470 global $langs,
$conf;
7472 if ($htmlname !=
"none") {
7473 print
'<form method="POST" action="' . $page .
'">';
7474 print
'<input type="hidden" name="action" value="setmulticurrencyrate">';
7475 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
7476 print
'<input type="text" class="maxwidth75" name="' . $htmlname .
'" value="' . (!empty($rate) ?
price(
price2num($rate,
'CU')) : 1) .
'" spellcheck="false" /> ';
7477 print
'<select name="calculation_mode" id="calculation_mode">';
7478 print
'<option value="1">Change ' . $langs->trans(
"PriceUHT") .
' of lines</option>';
7479 print
'<option value="2">Change ' . $langs->trans(
"PriceUHTCurrency") .
' of lines</option>';
7482 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
7485 if (!empty($rate)) {
7486 print
price($rate, 1, $langs, 0, 0);
7487 if ($currency && $rate != 1) {
7494 print
' <span class="opacitymedium">(' .
price($rate_direct, 1, $langs, 0, 0) .
' ' .
$conf->currency .
' = 1 ' . $currency .
')</span>';
7496 print
' <span class="opacitymedium">(' .
price($rate, 1, $langs, 0, 0) .
' ' . $currency .
' = 1 ' .
$conf->currency .
')</span>';
7524 public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter =
'', $maxvalue = 0, $more =
'', $hidelist = 0, $discount_type = 0, $filterabsolutediscount = 0, $filtercreditnote = 0)
7527 global
$conf, $langs;
7529 if ($htmlname !=
"none") {
7530 print
'<form method="post" action="' . $page .
'" class="inline-block">';
7531 print
'<input type="hidden" name="action" value="setabsolutediscount">';
7532 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
7533 print
'<div class="inline-block">';
7534 if (!empty($discount_type)) {
7536 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL") {
7537 $translationKey =
'HasAbsoluteDiscountFromSupplier';
7539 $translationKey =
'HasCreditNoteFromSupplier';
7542 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
7543 $translationKey =
'HasAbsoluteDiscountFromSupplier';
7545 $translationKey =
'HasCreditNoteFromSupplier';
7550 if (!$filter || $filter ==
"fk_facture_source IS NULL") {
7551 $translationKey =
'CompanyHasAbsoluteDiscount';
7553 $translationKey =
'CompanyHasCreditNote';
7556 if (!$filter || $filter ==
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
7557 $translationKey =
'CompanyHasAbsoluteDiscount';
7559 $translationKey =
'CompanyHasCreditNote';
7563 print $langs->trans($translationKey,
price($amount, 0, $langs, 0, 0, -1,
$conf->currency));
7564 if (empty($hidelist)) {
7568 if (empty($hidelist)) {
7569 print
'<div class="inline-block" style="padding-right: 10px">';
7570 $newfilter =
'discount_type = ' . intval($discount_type);
7571 if (!empty($discount_type)) {
7572 $newfilter .=
' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL';
7574 $newfilter .=
' AND fk_facture IS NULL AND fk_facture_line IS NULL';
7577 $sanitizedfilter = $filter;
7578 $newfilter .=
' AND (' . $sanitizedfilter .
')';
7581 $nbqualifiedlines = $this->select_remises((
string) $selected, $htmlname, $newfilter, $socid, $maxvalue);
7582 if ($nbqualifiedlines > 0) {
7583 print
' <input type="submit" class="button smallpaddingimp" value="' .
dol_escape_htmltag($langs->trans(
"UseLine")) .
'"';
7584 if (!empty($discount_type) && $filter && $filter !=
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
7585 print
' title="' . $langs->trans(
"UseCreditNoteInInvoicePayment") .
'"';
7587 if (empty($discount_type) && $filter && $filter !=
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
7588 print
' title="' . $langs->trans(
"UseCreditNoteInInvoicePayment") .
'"';
7596 print
'<div class="inline-block">';
7622 public function form_contacts($page, $societe, $selected =
'', $htmlname =
'contactid')
7627 if ($htmlname !=
"none") {
7628 print
'<form method="post" action="' . $page .
'">';
7629 print
'<input type="hidden" name="action" value="set_contact">';
7630 print
'<input type="hidden" name="token" value="' . newToken() .
'">';
7631 print
'<table class="nobordernopadding">';
7633 print $this->selectcontacts($societe->id, $selected, $htmlname);
7636 $addcontact = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
7637 print
'<a href="' . DOL_URL_ROOT .
'/contact/card.php?socid=' . $societe->id .
'&action=create&backtoreferer=1">' . $addcontact .
'</a>';
7640 print
'<td class="left"><input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'"></td>';
7641 print
'</tr></table></form>';
7644 require_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
7645 $contact =
new Contact($this->db);
7646 $contact->fetch((
int) $selected);
7647 print $contact->getFullName($langs);
7672 public function form_thirdparty($page, $selected =
'', $htmlname =
'socid', $filter =
'', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0, $excludeids = array(), $textifnothirdparty =
'')
7678 if ($htmlname !=
"none") {
7681 $out .=
'<form method="post" action="' . $page .
'">';
7682 $out .=
'<input type="hidden" name="action" value="set_thirdparty">';
7683 $out .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
7684 $out .= $this->select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, $limit,
'minwidth100',
'',
'', 1, array(),
false, $excludeids);
7685 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
7689 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
7690 $soc =
new Societe($this->db);
7691 $soc->fetch((
int) $selected);
7692 $out .= $soc->getNomUrl(0,
'');
7694 $out .=
'<span class="opacitymedium">' . $textifnothirdparty .
'</span>';
7720 print $this->selectCurrency($selected, $htmlname);
7732 public function selectCurrency($selected =
'', $htmlname =
'currency_id', $mode = 0, $useempty =
'')
7734 global $langs, $user;
7736 $langs->loadCacheCurrencies(
'');
7740 if ($selected ==
'euro' || $selected ==
'euros') {
7744 $out .=
'<select class="flat maxwidth200onsmartphone minwidth300" name="' . $htmlname .
'" id="' . $htmlname .
'">';
7746 $out .=
'<option value="-1" selected></option>';
7748 foreach ($langs->cache_currencies as $code_iso => $currency) {
7749 $labeltoshow = $currency[
'label'];
7751 $labeltoshow .=
' <span class="opacitymedium">(' . $code_iso .
')</span>';
7752 } elseif ($mode == 2) {
7753 $labeltoshow .=
' <span class="opacitymedium">(' . $code_iso.
' - '.$langs->getCurrencySymbol($code_iso) .
')</span>';
7755 $labeltoshow .=
' <span class="opacitymedium">(' . $langs->getCurrencySymbol($code_iso) .
')</span>';
7758 if ($selected && $selected == $code_iso) {
7759 $out .=
'<option value="' . $code_iso .
'" selected data-html="' .
dol_escape_htmltag($labeltoshow) .
'">';
7761 $out .=
'<option value="' . $code_iso .
'" data-html="' .
dol_escape_htmltag($labeltoshow) .
'">';
7764 $out .=
'</option>';
7766 $out .=
'</select>';
7768 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
7772 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
7790 public function selectMultiCurrency($selected =
'', $htmlname =
'multicurrency_code', $useempty = 0, $filter =
'', $excludeConfCurrency =
false, $morecss =
'maxwidth200 widthcentpercentminusx')
7792 global
$conf, $langs;
7794 $langs->loadCacheCurrencies(
'');
7796 $TCurrency = array();
7798 $sql =
"SELECT code FROM " . $this->db->prefix() .
"multicurrency";
7799 $sql .=
" WHERE entity IN ('" .
getEntity(
'multicurrency') .
"')";
7801 $sql .= forgeSQLFromUniversalSearchCriteria($filter);
7803 $resql = $this->db->query($sql);
7805 while ($obj = $this->db->fetch_object($resql)) {
7806 $TCurrency[$obj->code] = $obj->code;
7811 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
7813 $out .=
'<option value=""> </option>';
7816 if (!in_array(
$conf->currency, $TCurrency) && !$excludeConfCurrency) {
7817 $TCurrency[
$conf->currency] =
$conf->currency;
7819 if (count($TCurrency) > 0) {
7820 foreach ($langs->cache_currencies as $code_iso => $currency) {
7821 if (isset($TCurrency[$code_iso])) {
7822 if (!empty($selected) && $selected == $code_iso) {
7823 $out .=
'<option value="' . $code_iso .
'" selected="selected">';
7825 $out .=
'<option value="' . $code_iso .
'">';
7828 $out .= $currency[
'label'];
7829 $out .=
' (' . $langs->getCurrencySymbol($code_iso) .
')';
7830 $out .=
'</option>';
7835 $out .=
'</select>';
7838 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
7855 global $langs, $user;
7857 $num = count($this->cache_vatrates);
7864 $sql =
"SELECT t.rowid, t.type_vat, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly, t.einvoice_vatex";
7865 $sql .=
" FROM ".$this->db->prefix().
"c_tva as t, ".$this->db->prefix().
"c_country as c";
7866 $sql .=
" WHERE t.fk_pays = c.rowid";
7867 $sql .=
" AND t.active > 0";
7868 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
7869 $sql .=
" AND c.code IN (" . $this->db->sanitize($country_code, 1) .
")";
7870 $sql .=
" ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC";
7872 $resql = $this->db->query($sql);
7874 $num = $this->db->num_rows($resql);
7876 for ($i = 0; $i < $num; $i++) {
7877 $obj = $this->db->fetch_object($resql);
7879 $tmparray = array();
7880 $tmparray[
'rowid'] = (int) $obj->rowid;
7881 $tmparray[
'type_vat'] = ($obj->type_vat <= 0 ? 0 : $obj->type_vat);
7882 $tmparray[
'code'] = $obj->code;
7883 $tmparray[
'txtva'] = $obj->taux;
7884 $tmparray[
'nprtva'] = $obj->recuperableonly;
7885 $tmparray[
'localtax1'] = $obj->localtax1;
7886 $tmparray[
'localtax1_type'] = $obj->localtax1_type;
7887 $tmparray[
'localtax2'] = $obj->localtax2;
7888 $tmparray[
'localtax2_type'] = $obj->localtax1_type;
7889 $tmparray[
'einvoice_vatex'] = $obj->einvoice_vatex;
7891 $tmparray[
'label'] = $obj->taux .
'%' . ($obj->code ?
' (' . $obj->code .
')' :
'');
7892 $tmparray[
'labelallrates'] = $obj->taux .
'/' . ($obj->localtax1 ? $obj->localtax1 :
'0') .
'/' . ($obj->localtax2 ? $obj->localtax2 :
'0') . ($obj->code ?
' (' . $obj->code .
')' :
'');
7893 $positiverates =
'';
7895 $positiverates .= ($positiverates ?
'/' :
'') . $obj->taux;
7897 if ($obj->localtax1) {
7898 $positiverates .= ($positiverates ?
'/' :
'') . $obj->localtax1;
7900 if ($obj->localtax2) {
7901 $positiverates .= ($positiverates ?
'/' :
'') . $obj->localtax2;
7903 if (empty($positiverates)) {
7904 $positiverates =
'0';
7906 $tmparray[
'labelpositiverates'] = $positiverates . ($obj->code ?
' (' . $obj->code .
')' :
'');
7908 $this->cache_vatrates[$obj->rowid] = $tmparray;
7913 $this->error =
'<span class="error">';
7914 $this->error .= $langs->trans(
"ErrorNoVATRateDefinedForSellerCountry", $country_code);
7916 if (!empty($user) && $user->admin && preg_match(
'/\'(..)\'/', $country_code, $reg)) {
7917 $langs->load(
"errors");
7918 $new_country_code = $reg[1];
7919 $country_id =
dol_getIdFromCode($this->db, $new_country_code,
'c_country',
'code',
'rowid');
7920 $this->error .=
'<br>'.$langs->trans(
"ErrorFixThisHere", DOL_URL_ROOT.
'/admin/dict.php?id=10'.($country_id > 0 ?
'&countryidforinsert='.$country_id :
''));
7922 $this->error .=
'</span>';
7926 $this->error =
'<span class="error">' . $this->db->error() .
'</span>';
7955 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)
7958 global $langs,
$mysoc, $hookmanager;
7960 $langs->load(
'errors');
7964 $hookmanager->initHooks(array(
'commonobject'));
7965 $info_bits == 1 ? $is_npr = 1 : $is_npr = 0;
7966 $parameters = array(
7967 'htmlname' => $htmlname,
7968 'selectedrate' => $selectedrate,
7969 'seller' => $societe_vendeuse,
7970 'buyer' => $societe_acheteuse,
7971 'idprod' => $idprod,
7972 'is_npr' => $is_npr,
7974 'options_only' => $options_only,
7976 'type_vat' => $type_vat
7978 $reshook = $hookmanager->executeHooks(
'load_tva', $parameters);
7980 return $hookmanager->resPrint;
7981 } elseif ($reshook === 0) {
7982 $return .= $hookmanager->resPrint;
7986 $defaultnpr = ($info_bits & 0x01);
7987 $defaultnpr = (preg_match(
'/\*/', $selectedrate) ? 1 : $defaultnpr);
7988 $defaulttx = str_replace(
'*',
'', $selectedrate);
7991 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
7992 $defaultcode = $reg[1];
7993 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
7998 if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
7999 if ($societe_vendeuse->id ==
$mysoc->id) {
8000 $return .=
'<span class="error">' . $langs->trans(
"ErrorYourCountryIsNotDefined") .
'</span>';
8002 $return .=
'<span class="error">' . $langs->trans(
"ErrorSupplierCountryIsNotDefined") .
'</span>';
8013 if (is_object($societe_vendeuse)) {
8014 $code_country =
"'" . $societe_vendeuse->country_code .
"'";
8016 $code_country =
"'" .
$mysoc->country_code .
"'";
8020 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
8024 if (is_object($societe_vendeuse) && is_object($societe_acheteuse) &&
isInEEC($societe_vendeuse) &&
isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()) {
8026 if (is_numeric($type)) {
8028 switch ($selectVatComboMode) {
8030 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
8033 $code_country =
"'" . $societe_acheteuse->country_code .
"'";
8037 } elseif (!$idprod) {
8038 switch ($selectVatComboMode) {
8040 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
8043 $code_country =
"'" . $societe_acheteuse->country_code .
"'";
8047 $prodstatic =
new Product($this->db);
8048 $prodstatic->fetch($idprod);
8050 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
8057 $this->load_cache_vatrates($code_country);
8060 $arrayofvatrates = array();
8061 foreach ($this->cache_vatrates as $cachevalue) {
8062 if (empty($cachevalue[
'type_vat']) || $cachevalue[
'type_vat'] == $type_vat) {
8063 $arrayofvatrates[] = $cachevalue;
8067 $num = count($arrayofvatrates);
8070 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
8072 $tmpthirdparty =
new Societe($this->db);
8073 $tmpthirdparty->country_code =
$mysoc->country_code;
8075 $defaulttx =
get_default_tva(is_object($societe_vendeuse) ? $societe_vendeuse : $tmpthirdparty, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
8076 $defaultnpr =
get_default_npr(is_object($societe_vendeuse) ? $societe_vendeuse : $tmpthirdparty, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
8078 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
8079 $defaultcode = $reg[1];
8080 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
8082 if (empty($defaulttx)) {
8089 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
8092 $defaulttx = $arrayofvatrates[$num - 1][
'txtva'];
8099 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
8100 $defaultcode = $reg[1];
8101 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
8109 if (is_object($societe_vendeuse) && $societe_vendeuse->id ==
$mysoc->id && empty($societe_vendeuse->tva_assuj)) {
8119 if (!$options_only) {
8120 $return .=
'<select class="flat valignmiddle minwidth75imp maxwidth100 right" id="' . $htmlname .
'" name="' . $htmlname .
'"' . ($disabled ?
' disabled' :
'') . $title .
'>';
8123 $selectedfound =
false;
8124 foreach ($arrayofvatrates as $rate) {
8126 if ($disabled && $rate[
'txtva'] != 0) {
8131 $key = $rate[
'txtva'];
8132 $key .= $rate[
'nprtva'] ?
'*' :
'';
8133 if ($mode > 0 && $rate[
'code']) {
8134 $key .=
' (' . $rate[
'code'] .
')';
8137 $key = $rate[
'rowid'];
8140 $return .=
'<option value="' . $key .
'" data-vatid="'.$rate[
'rowid'].
'"';
8141 if (!$selectedfound) {
8143 if ($defaultcode == $rate[
'code']) {
8144 $return .=
' selected';
8145 $selectedfound =
true;
8147 } elseif ($rate[
'txtva'] == $defaulttx && $rate[
'nprtva'] == $defaultnpr) {
8148 $return .=
' selected';
8149 $selectedfound =
true;
8157 $return .= $rate[
'labelpositiverates'];
8160 $return .=
vatrate($rate[
'label']);
8164 $return .= (empty($rate[
'code']) && $rate[
'nprtva']) ?
' *' :
'';
8166 $return .=
'</option>';
8169 if (!$options_only) {
8170 $return .=
'</select>';
8174 $return .= $this->error;
8208 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 =
'')
8211 dol_syslog(__METHOD__ .
': using select_date is deprecated. Use selectDate instead.', LOG_WARNING);
8212 $retstring = $this->selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof);
8213 if (!empty($nooutput)) {
8236 public function selectDateToDate($set_time =
'', $set_time_end =
'', $prefix =
're', $empty = 0, $forcenewline = 0)
8240 $ret = $this->selectDate($set_time, $prefix .
'_start', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"),
'tzuserrel');
8241 if ($forcenewline) {
8244 $ret .= $this->selectDate($set_time_end, $prefix .
'_end', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
8276 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', $calendarpicto =
'')
8278 global
$conf, $langs;
8280 if ($gm ===
'auto') {
8281 $gm = (empty(
$conf) ?
'tzserver' :
$conf->tzuserinputkey);
8286 if ($prefix ==
'') {
8297 if ($stepminutes <= 0 || $stepminutes > 30) {
8308 $orig_set_time = $set_time;
8310 if ($set_time ===
'' && $emptydate == 0) {
8311 include_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
8312 if ($gm ==
'tzuser' || $gm ==
'tzuserrel') {
8324 if (!empty($set_time) && preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', (
string) $set_time, $reg)) {
8326 $syear = (!empty($reg[1]) ? $reg[1] :
'');
8327 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
8328 $sday = (!empty($reg[3]) ? $reg[3] :
'');
8329 $shour = (!empty($reg[4]) ? $reg[4] :
'');
8330 $smin = (!empty($reg[5]) ? $reg[5] :
'');
8331 } elseif (strval($set_time) !=
'' && $set_time != -1) {
8336 if ($orig_set_time !=
'') {
8350 if ($h == 3 || $h == 4) {
8361 $usecalendar =
'combo';
8367 $usecalendar =
'html';
8372 if ($usecalendar !=
'combo') {
8374 $reduceformat = (!empty(
$conf->dol_optimize_smallscreen) ? 1 : 0);
8375 if ($reduceformat) {
8376 $format = str_replace(
'%Y',
'%y', $langs->transnoentitiesnoconv(
"FormatDateShortInput"));
8377 $formatjslong = $langs->transnoentitiesnoconv(
"FormatDateShortJavaInput");
8378 $formatjs = str_replace(
'yyyy',
'yy', $langs->transnoentitiesnoconv(
"FormatDateShortJavaInput"));
8379 $formatjquery = str_replace(
'yyyy',
'yy', $langs->trans(
"FormatDateShortJQueryInput"));
8381 $format = $langs->transnoentitiesnoconv(
"FormatDateShortInput");
8382 $formatjslong = $langs->transnoentitiesnoconv(
"FormatDateShortJavaInput");
8383 $formatjs = $langs->transnoentitiesnoconv(
"FormatDateShortJavaInput");
8384 $formatjquery = $langs->trans(
"FormatDateShortJQueryInput");
8388 $formatted_date =
'';
8389 if (strval($set_time) !=
'' && $set_time != -1) {
8394 if ($usecalendar ==
"eldy") {
8420 } elseif ($usecalendar ==
'jquery' || $usecalendar ==
'html') {
8421 if (!$disabled && $usecalendar !=
'html') {
8423 $minYear =
getDolGlobalInt(
'MIN_YEAR_SELECT_DATE', (idate(
'Y') - 100));
8424 $maxYear =
getDolGlobalInt(
'MAX_YEAR_SELECT_DATE', (idate(
'Y') + 100));
8426 $retstring .=
'<!-- datepicker usecalendar='.$usecalendar.
' --><script nonce="' . getNonce() .
'" type="text/javascript">';
8427 $retstring .=
"$(function(){ $('#" . $prefix .
"').datepicker({
8430 todayHighlight: true,
8431 yearRange: '" . $minYear .
":" . $maxYear .
"',";
8432 if (!empty(
$conf->dol_use_jmobile)) {
8434 beforeShow: function (input, datePicker) {
8435 input.disabled = true;
8437 onClose: function (dateText, datePicker) {
8438 this.disabled = false;
8444 $buttonImage = $calendarpicto ?: DOL_URL_ROOT .
"/theme/" .
dol_escape_js(
$conf->theme) .
"/img/object_calendarday.png";
8446 showOn: 'button', /* both has problem with autocompletion */
8447 buttonImage: '" . $buttonImage .
"',
8448 buttonImageOnly: true";
8452 $retstring .=
"</script>";
8456 $retstring .=
'<div class="nowraponall inline-block divfordateinput">';
8457 $retstring .=
'<input id="'.$prefix.
'" name="'.$prefix.
'" type="'.($usecalendar ==
'html' ?
"date" :
"text").
'" class="maxwidthdate'.(
getDolUserString(
'MAIN_OPTIMIZEFORTEXTBROWSER') ?
' textbrowser' :
'').
' center" maxlength="11" value="'.$formatted_date.
'"';
8458 $retstring .= ($disabled ?
' disabled' :
'');
8459 $retstring .= ($placeholder ?
' placeholder="' .
dol_escape_htmltag($placeholder) .
'"' :
'');
8460 $retstring .=
' onChange="dpChangeDay(\'' .
dol_escape_js($prefix) .
'\',\
'' .
dol_escape_js($usecalendar ==
'html' ?
'yyyy-mm-dd' : $formatjslong) .
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
8461 $retstring .= ' autocomplete="off
">';
8465 $retstringbutton = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
">' . img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink ui-datepicker-notrigger
"') . '</button>';
8466 $retstring .= $retstringbutton;
8469 $retstring .= '</div>';
8470 $retstring .= '<input type="hidden
" id="' . $prefix . 'day
" name="' . $prefix . 'day
" value="' . $sday . '">' . "\n
";
8471 $retstring .= '<input type="hidden
" id="' . $prefix . 'month
" name="' . $prefix . 'month
" value="' . $smonth . '">' . "\n
";
8472 $retstring .= '<input type="hidden
" id="' . $prefix . 'year
" name="' . $prefix . 'year
" value="' . $syear . '">' . "\n
";
8474 $retstring .= "Bad value of MAIN_POPUP_CALENDAR
";
8477 // Show date with combo selects
8479 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50imp
" id="' . $prefix . 'day
" name="' . $prefix . 'day
">';
8481 if ($emptydate || $set_time == -1) {
8482 $retstring .= '<option value="0
" selected> </option>';
8485 for ($day = 1; $day <= 31; $day++) {
8486 $retstring .= '<option value="' . $day . '"' . ($day == $sday ? ' selected' : '') . '>' . $day . '</option>';
8489 $retstring .= "</select>
";
8491 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp
" id="' . $prefix . 'month
" name="' . $prefix . 'month
">';
8492 if ($emptydate || $set_time == -1) {
8493 $retstring .= '<option value="0
" selected> </option>';
8497 for ($month = 1; $month <= 12; $month++) {
8498 $retstring .= '<option value="' . $month . '"' . ($month == $smonth ? ' selected' : '') . '>';
8499 $retstring .= dol_print_date(mktime(12, 0, 0, $month, 1, 2000), "%b
");
8500 $retstring .= "</option>
";
8502 $retstring .= "</select>
";
8505 if ($emptydate || $set_time == -1) {
8506 $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 . '">';
8508 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp
" id="' . $prefix . 'year
" name="' . $prefix . 'year
">';
8510 $syear = (int) $syear;
8511 for ($year = $syear - 10; $year < (int) $syear + 10; $year++) {
8512 $retstring .= '<option value="' . $year . '"' . ($year == $syear ? ' selected' : '') . '>' . $year . '</option>';
8514 $retstring .= "</select>\n
";
8520 $retstring .= (($h == 2 || $h == 4) ? '<br>' : ' ');
8521 $retstring .= '<span class="nowraponall
">';
8527 if ($openinghours != '') {
8528 $openinghours = explode(',', $openinghours);
8529 $hourstart = $openinghours[0];
8530 $hourend = $openinghours[1];
8531 if ($hourend < $hourstart) {
8532 $hourend = $hourstart;
8537 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75
'; // Note maxwidth50 generates truncated number on some desktops even with same version of chrome that works on others
8538 $retstring .= ($fullday ? $fullday . 'hour
' : '') . '" id="' . $prefix . 'hour
" name="' . $prefix . 'hour
">';
8540 $retstring .= '<option value="-1
"> </option>';
8542 for ($hour = $hourstart; $hour < $hourend; $hour++) {
8543 if (strlen($hour) < 2) {
8544 $hour = "0
" . $hour;
8546 $retstring .= '<option value="' . $hour . '"' . (($hour == $shour) ? ' selected' : '') . '>' . $hour;
8547 $retstring .= '</option>';
8549 $retstring .= '</select>';
8552 $retstring .= '<input type="hidden
" id="' . $prefix . 'hour
" name="' . $prefix . 'hour
" value="' . $shour . '">' . "\n
";
8561 $retstring .= '<select ' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75
'; // Note maxwidth50 generates truncated number on some desktops even with same version of chrome that works on others
8562 $retstring .= ($fullday ? $fullday . 'min
' : '') . '" id="' . $prefix . 'min
" name="' . $prefix . 'min
">';
8564 $retstring .= '<option value="-1
"> </option>';
8566 for ($min = 0; $min < 60; $min += $stepminutes) {
8567 $min_str = sprintf("%02d
", $min);
8568 $retstring .= '<option value="' . $min_str . '"' . (($min_str == $smin) ? ' selected' : '') . '>' . $min_str . '</option>';
8570 $retstring .= '</select>';
8572 $retstring .= '<input type="hidden
" id="' . $prefix . 'min
" name="' . $prefix . 'min
" value="' . $smin . '">' . "\n
";
8575 $retstring .= '<input type="hidden
" name="' . $prefix . 'sec
" value="' . $ssec . '">';
8579 $retstring .= '</span>';
8583 if (!empty($conf->use_javascript_ajax) && $addnowlink && !$disabled) {
8584 // Script which will be inserted in the onClick of the "Now
" link
8585 $reset_scripts = "";
8586 if ($addnowlink == 2) { // local computer time
8587 // pad add leading 0 on numbers
8588 $reset_scripts .= "Number.prototype.pad =
function(size) {
8589 var s = String(
this);
8590 while (s.length < (size || 2)) {s =
'0' + s;}
8593 var d =
new Date();
";
8596 // Generate the date part, depending on the use or not of the javascript calendar
8597 if ($addnowlink == 1) { // server time expressed in user time setup
8598 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'day', 'tzuserrel') . '\');';
8599 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
8600 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
8601 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
8602 } elseif ($addnowlink == 2) {
8603 /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix.
8604 * This break application for foreign languages.
8605 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));';
8606 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());';
8607 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);';
8608 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());';
8610 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'day', 'tzuserrel') . '\');';
8611 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
8612 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
8613 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
8615 /*if ($usecalendar == "eldy
")
8617 $base=DOL_URL_ROOT.'/core/';
8618 $reset_scripts .= 'resetDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput
").'\',\''.$langs->defaultlang.'\');';
8622 $reset_scripts .= 'this.form.elements[\''.$prefix.'day\'].value=formatDate(new Date(), \'d\'); ';
8623 $reset_scripts .= 'this.form.elements[\''.$prefix.'month\'].value=formatDate(new Date(), \'M\'); ';
8624 $reset_scripts .= 'this.form.elements[\''.$prefix.'year\'].value=formatDate(new Date(), \'yyyy\'); ';
8626 // Update the hour part
8629 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
8631 //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); ';
8632 if ($addnowlink == 1) {
8633 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date($nowgmt, '%H', 'tzuserrel') . '\');';
8634 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').change();';
8635 } elseif ($addnowlink == 2) {
8636 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(d.getHours().pad());';
8637 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').change();';
8641 $reset_scripts .= ' } ';
8644 // Update the minute part
8647 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
8649 //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); ';
8650 if ($addnowlink == 1) {
8651 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date($nowgmt, '%M', 'tzuserrel') . '\');';
8652 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').change();';
8653 } elseif ($addnowlink == 2) {
8654 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(d.getMinutes().pad());';
8655 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').change();';
8658 $reset_scripts .= ' } ';
8661 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
8662 if ($reset_scripts && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
8663 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="' . $prefix . 'ButtonNow
" type="button" name="_useless
" value="now
" onClick="' . $reset_scripts . '">';
8664 $retstring .= $langs->trans("Now
");
8665 $retstring .= '</button> ';
8669 // Add a "Plus one hour
" link
8670 if ($conf->use_javascript_ajax && $addplusone && !$disabled) {
8671 // Script which will be inserted in the onClick of the "Add plusone
" link
8672 $reset_scripts = "";
8674 // Generate the date part, depending on the use or not of the javascript calendar
8675 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'dayinputnoreduce', 'tzuserrel') . '\');';
8676 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
8677 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
8678 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
8679 // Update the hour part
8682 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
8684 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date($nowgmt, '%H', 'tzuserrel') . '\');';
8686 $reset_scripts .= ' } ';
8689 // Update the minute part
8692 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
8694 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date($nowgmt, '%M', 'tzuserrel') . '\');';
8696 $reset_scripts .= ' } ';
8699 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
8700 if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
8701 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="' . $prefix . 'ButtonPlusOne
" type="button" name="_useless2
" value="plusone
" onClick="' . $reset_scripts . '">';
8702 $retstring .= $langs->trans("DateStartPlusOne
");
8703 $retstring .= '</button> ';
8707 // Add a link to set data
8708 if ($conf->use_javascript_ajax && !empty($adddateof) && !$disabled) {
8709 if (!is_array($adddateof)) {
8710 $arrayofdateof = array(array('adddateof' => $adddateof, 'labeladddateof' => $labeladddateof));
8712 $arrayofdateof = $adddateof;
8714 foreach ($arrayofdateof as $valuedateof) {
8715 $tmpadddateof = empty($valuedateof['adddateof']) ? 0 : $valuedateof['adddateof'];
8716 $tmplabeladddateof = empty($valuedateof['labeladddateof']) ? '' : $valuedateof['labeladddateof'];
8717 $tmparray = dol_getdate($tmpadddateof);
8718 if (empty($tmplabeladddateof)) {
8719 $tmplabeladddateof = $langs->trans("DateInvoice
");
8721 $reset_scripts = 'console.log(\'Click on now link\'); ';
8722 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($tmpadddateof, 'dayinputnoreduce').'\');';
8723 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.$tmparray['mday'].'\');';
8724 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.$tmparray['mon'].'\');';
8725 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.$tmparray['year'].'\');';
8726 $retstring .= ' - <button class="dpInvisibleButtons datenowlink
" id="dateofinvoice
" type="button" name="_dateofinvoice
" value="now
" onclick="'.$reset_scripts.'">'.$tmplabeladddateof.'</button>';
8742 public function selectTypeDuration($prefix, $selected = 'i', $excludetypes = array(), $morecss = 'minwidth75 maxwidth100')
8746 $TDurationTypes = $this->getDurationTypes($langs);
8748 // Removed undesired duration types
8749 foreach ($excludetypes as $value) {
8750 unset($TDurationTypes[$value]);
8753 $retstring = '<select class="flat
'.($morecss ? ' '.$morecss : '').'" id="select_
' . $prefix . 'type_duration
" name="' . $prefix . 'type_duration
">';
8754 foreach ($TDurationTypes as $key => $typeduration) {
8755 $retstring .= '<option value="' . $key . '"';
8756 if ($key == $selected) {
8757 $retstring .= " selected
";
8759 $retstring .= ">
" . $typeduration . "</option>
";
8761 $retstring .= "</select>
";
8763 $retstring .= ajax_combobox('select_' . $prefix . 'type_duration');
8768 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
8783 public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0)
8788 $retstring = '<span class="nowraponall
">';
8794 if ($iSecond != '') {
8795 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
8797 $hourSelected = convertSecondToTime($iSecond, 'allhour');
8798 $minSelected = convertSecondToTime($iSecond, 'min');
8801 if ($typehour == 'select') {
8802 $retstring .= '<select class="flat
" id="select_
' . $prefix . 'hour
" name="' . $prefix . 'hour
"' . ($disabled ? ' disabled' : '') . '>';
8803 for ($hour = 0; $hour < 25; $hour++) { // For a duration, we allow 24 hours
8804 $retstring .= '<option value="' . $hour . '"';
8805 if (is_numeric($hourSelected) && $hourSelected == $hour) {
8806 $retstring .= " selected
";
8808 $retstring .= ">
" . $hour . "</option>
";
8810 $retstring .= "</select>
";
8811 } elseif ($typehour == 'text' || $typehour == 'textselect') {
8812 $retstring .= '<input placeholder="' . $langs->trans('HourShort
') . '" type="number
" min="0
" name="' . $prefix . 'hour
"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputhour right
" value="' . (($hourSelected != '') ? ((int) $hourSelected) : '') . '">';
8814 return 'BadValueForParameterTypeHour';
8817 if ($typehour != 'text') {
8818 $retstring .= ' ' . $langs->trans('HourShort');
8820 $retstring .= '<span class="">:</span>';
8824 if ($minunderhours) {
8825 $retstring .= '<br>';
8827 if ($typehour != 'text') {
8828 $retstring .= '<span class="hideonsmartphone
"> </span>';
8832 if ($typehour == 'select' || $typehour == 'textselect') {
8833 $retstring .= '<select class="flat
" id="select_
' . $prefix . 'min
" name="' . $prefix . 'min
"' . ($disabled ? ' disabled' : '') . '>';
8834 $step = getDolGlobalInt('MAIN_DURATION_STEP');
8835 $duration_step = ($step > 0) ? $step : 5;
8836 for ($min = 0; $min <= 59; $min += $duration_step) {
8837 $retstring .= '<option value="' . $min . '"';
8838 if (is_numeric($minSelected) && $minSelected == $min) {
8839 $retstring .= ' selected';
8841 $retstring .= '>' . $min . '</option>';
8843 $retstring .= "</select>
";
8844 } elseif ($typehour == 'text') {
8845 $retstring .= '<input placeholder="' . $langs->trans('MinuteShort
') . '" type="number
" min="0
" name="' . $prefix . 'min
"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputminute right
" value="' . (($minSelected != '') ? ((int) $minSelected) : '') . '">';
8848 if ($typehour != 'text') {
8849 $retstring .= ' ' . $langs->trans('MinuteShort');
8852 $retstring .= "</span>
";
8854 if (!empty($nooutput)) {
8882 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)
8884 global $langs, $conf;
8889 if (is_null($ajaxoptions)) {
8890 $ajaxoptions = array();
8893 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
8896 if ($selected && empty($selected_input_value)) {
8897 require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
8898 $tickettmpselect = new Ticket($this->db);
8899 $tickettmpselect->fetch((int) $selected);
8900 $selected_input_value = $tickettmpselect->ref;
8901 unset($tickettmpselect);
8905 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/ticket/ajax/tickets.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
8907 if (empty($hidelabel)) {
8908 $out .= $langs->trans("RefOrLabel
") . ' : ';
8909 } elseif ($hidelabel > 1) {
8910 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
8911 if ($hidelabel == 2) {
8912 $out .= img_picto($langs->trans("Search
"), 'search');
8915 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (getDolGlobalString('PRODUCT_SEARCH_AUTOFOCUS') ? 'autofocus' : '') . ' />';
8916 if ($hidelabel == 3) {
8917 $out .= img_picto($langs->trans("Search
"), 'search');
8920 $out .= $this->selectTicketsList($selected, $htmlname, $filtertype, $limit, '', $status, 0, $showempty, $forcecombo, $morecss);
8923 if (empty($nooutput)) {
8948 public function selectTicketsList($selected = '', $htmlname = 'ticketid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
8953 $outarray = array();
8955 $selectFields = " p.rowid, p.ref, p.message
";
8958 $sql .= $this->db->sanitize($selectFields, 0, 0, 1);
8959 $sql .= " FROM
" . $this->db->prefix() . "ticket as p
";
8960 $sql .= ' WHERE p.entity IN (' . getEntity('ticket') . ')';
8962 // Add criteria on ref/label
8963 if ($filterkey != '') {
8965 $prefix = getDolGlobalString('TICKET_DONOTSEARCH_ANYWHERE') ? '' : '%'; // Can use index if TICKET_DONOTSEARCH_ANYWHERE is on
8966 // For natural search
8967 $search_crit = explode(' ', $filterkey);
8969 if (count($search_crit) > 1) {
8972 foreach ($search_crit as $crit) {
8976 $sql .= "(p.ref LIKE
'" . $this->db->escape($prefix . $crit) . "%' OR p.subject LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
8980 if (count($search_crit) > 1) {
8986 $sql .= $this->db->plimit($limit, 0);
8988 // Build output string
8989 dol_syslog(get_class($this) . "::selectTicketsList search tickets
", LOG_DEBUG);
8990 $result = $this->db->query($sql);
8992 require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
8993 require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php';
8995 $num = $this->db->num_rows($result);
9000 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
9001 $out .= ajax_combobox($htmlname, $events, getDolGlobalInt('TICKET_USE_SEARCH_TO_SELECT'));
9004 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
9007 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
9008 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
9009 if (getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
9010 if ($showempty && !is_numeric($showempty)) {
9011 $textifempty = $langs->trans($showempty);
9013 $textifempty .= $langs->trans("All
");
9016 if ($showempty && !is_numeric($showempty)) {
9017 $textifempty = $langs->trans($showempty);
9021 $out .= '<option value="0
" selected>' . $textifempty . '</option>';
9025 while ($num && $i < $num) {
9028 $objp = $this->db->fetch_object($result);
9030 $this->constructTicketListOption($objp, $opt, $optJson, $selected, $filterkey);
9031 '@phan-var-force array{key:string,value:mixed,type:int} $optJson';
9033 // "key
" value of json key array is used by jQuery automatically as selected value
9034 // "label
" value of json key array is used by jQuery automatically as text for combo box
9036 array_push($outarray, $optJson);
9041 $out .= '</select>';
9043 $this->db->free($result);
9045 if (empty($outputmode)) {
9050 dol_print_error($this->db);
9067 protected function constructTicketListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
9073 $outkey = $objp->rowid;
9074 $outref = $objp->ref;
9076 $opt = '<option value="
' . $objp->rowid . '"';
9077 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
9080 $objRef = $objp->ref;
9081 if (!empty($filterkey) && $filterkey != '') {
9082 $objRef = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $objRef, 1);
9085 $opt .= "</option>\n
";
9086 $optJson = array('key' => $outkey, 'value' => $outref, 'type' => $outtype);
9108 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)
9110 global $langs, $conf;
9115 if (is_null($ajaxoptions)) {
9116 $ajaxoptions = array();
9119 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
9122 if ($selected && empty($selected_input_value)) {
9123 require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
9124 $projecttmpselect = new Project($this->db);
9125 $projecttmpselect->fetch((int) $selected);
9126 $selected_input_value = $projecttmpselect->ref;
9127 unset($projecttmpselect);
9131 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/projet/ajax/projects.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
9133 if (empty($hidelabel)) {
9134 $out .= $langs->trans("RefOrLabel
") . ' : ';
9135 } elseif ($hidelabel > 1) {
9136 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
9137 if ($hidelabel == 2) {
9138 $out .= img_picto($langs->trans("Search
"), 'search');
9141 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (getDolGlobalString('PRODUCT_SEARCH_AUTOFOCUS') ? 'autofocus' : '') . ' />';
9142 if ($hidelabel == 3) {
9143 $out .= img_picto($langs->trans("Search
"), 'search');
9146 $out .= $this->selectProjectsList($selected, $htmlname, $filtertype, $limit, '', $status, 0, $showempty, $forcecombo, $morecss);
9149 if (empty($nooutput)) {
9173 public function selectProjectsList($selected = '', $htmlname = 'projectid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
9175 global $langs, $conf;
9178 $outarray = array();
9180 $selectFields = " p.rowid, p.ref
";
9183 $sql .= $this->db->sanitize($selectFields, 0, 0, 1);
9184 $sql .= " FROM
" . $this->db->prefix() . "projet as p
";
9185 $sql .= ' WHERE p.entity IN (' . getEntity('project') . ')';
9187 // Add criteria on ref/label
9188 if ($filterkey != '') {
9190 $prefix = !getDolGlobalString('TICKET_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
9191 // For natural search
9192 $search_crit = explode(' ', $filterkey);
9194 if (count($search_crit) > 1) {
9197 foreach ($search_crit as $crit) {
9201 $sql .= "p.ref LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
9205 if (count($search_crit) > 1) {
9211 $sql .= $this->db->plimit($limit, 0);
9213 // Build output string
9214 dol_syslog(get_class($this) . "::selectProjectsList search projects
", LOG_DEBUG);
9215 $result = $this->db->query($sql);
9217 require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
9218 require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php';
9220 $num = $this->db->num_rows($result);
9225 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
9226 $out .= ajax_combobox($htmlname, $events, getDolGlobalInt('PROJECT_USE_SEARCH_TO_SELECT'));
9229 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
9232 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
9233 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
9234 if (getDolGlobalString('PROJECT_USE_SEARCH_TO_SELECT')) {
9235 if ($showempty && !is_numeric($showempty)) {
9236 $textifempty = $langs->trans($showempty);
9238 $textifempty .= $langs->trans("All
");
9241 if ($showempty && !is_numeric($showempty)) {
9242 $textifempty = $langs->trans($showempty);
9246 $out .= '<option value="0
" selected>' . $textifempty . '</option>';
9250 while ($num && $i < $num) {
9253 $objp = $this->db->fetch_object($result);
9255 $this->constructProjectListOption($objp, $opt, $optJson, $selected, $filterkey);
9257 // "key
" value of json key array is used by jQuery automatically as selected value
9258 // "label
" value of json key array is used by jQuery automatically as text for combo box
9260 array_push($outarray, $optJson);
9265 $out .= '</select>';
9267 $this->db->free($result);
9269 if (empty($outputmode)) {
9274 dol_print_error($this->db);
9293 protected function constructProjectListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
9299 $label = $objp->label;
9301 $outkey = $objp->rowid;
9302 $outref = $objp->ref;
9303 $outlabel = $objp->label;
9304 $outtype = $objp->fk_product_type;
9306 $opt = '<option value="
' . $objp->rowid . '"';
9307 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
9310 $objRef = $objp->ref;
9311 if (!empty($filterkey) && $filterkey != '') {
9312 $objRef = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $objRef, 1);
9315 $opt .= "</option>\n
";
9316 $optJson = array('key' => $outkey, 'value' => $outref, 'type' => $outtype);
9340 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, $excludeids = array())
9342 global $langs, $conf;
9347 if (is_null($ajaxoptions)) {
9348 $ajaxoptions = array();
9351 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
9354 if ($selected && empty($selected_input_value)) {
9355 require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
9356 $adherenttmpselect = new Adherent($this->db);
9357 $adherenttmpselect->fetch((int) $selected);
9358 $selected_input_value = $adherenttmpselect->ref;
9359 unset($adherenttmpselect);
9364 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/adherents/ajax/adherents.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
9366 if (empty($hidelabel)) {
9367 $out .= $langs->trans("RefOrLabel
") . ' : ';
9368 } elseif ($hidelabel > 1) {
9369 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
9370 if ($hidelabel == 2) {
9371 $out .= img_picto($langs->trans("Search
"), 'search');
9374 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (getDolGlobalString('PRODUCT_SEARCH_AUTOFOCUS') ? 'autofocus' : '') . ' />';
9375 if ($hidelabel == 3) {
9376 $out .= img_picto($langs->trans("Search
"), 'search');
9381 $out .= $this->selectMembersList($selected, $htmlname, $filtertype, $limit, $filterkey, $status, 0, $showempty, $forcecombo, $morecss, $excludeids);
9384 if (empty($nooutput)) {
9409 public function selectMembersList($selected = '', $htmlname = 'adherentid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $excludeids = array())
9411 global $langs, $conf;
9414 $outarray = array();
9416 $selectFields = " p.rowid, p.ref, p.firstname, p.lastname, p.fk_adherent_type
";
9419 $sql .= $this->db->sanitize($selectFields, 0, 0, 1);
9420 $sql .= " FROM
" . $this->db->prefix() . "adherent as p
";
9421 $sql .= ' WHERE p.entity IN (' . getEntity('adherent') . ')';
9423 // Add criteria on ref/label
9424 if ($filterkey != '') {
9426 $prefix = !getDolGlobalString('MEMBER_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
9427 // For natural search
9428 $search_crit = explode(' ', $filterkey);
9430 if (count($search_crit) > 1) {
9433 foreach ($search_crit as $crit) {
9437 $sql .= "(p.firstname LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
9438 $sql .= " OR p.lastname LIKE
'" . $this->db->escape($prefix . $crit) . "%')
";
9441 if (count($search_crit) > 1) {
9446 if ($status != -1) {
9447 $sql .= ' AND statut = ' . ((int) $status);
9449 if (!empty($excludeids)) {
9450 $sql .= " AND p.rowid NOT IN (
" . $this->db->sanitize(implode(',', $excludeids)) . ")
";
9452 $sql .= $this->db->plimit($limit, 0);
9454 // Build output string
9455 dol_syslog(get_class($this) . "::selectMembersList search adherents
", LOG_DEBUG);
9456 $result = $this->db->query($sql);
9458 require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
9459 require_once DOL_DOCUMENT_ROOT . '/core/lib/member.lib.php';
9461 $num = $this->db->num_rows($result);
9466 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
9467 $out .= ajax_combobox($htmlname, $events, getDolGlobalInt('PROJECT_USE_SEARCH_TO_SELECT'));
9470 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
9473 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
9474 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
9475 if (getDolGlobalString('PROJECT_USE_SEARCH_TO_SELECT')) {
9476 if ($showempty && !is_numeric($showempty)) {
9477 $textifempty = $langs->trans($showempty);
9479 $textifempty .= $langs->trans("All
");
9482 if ($showempty && !is_numeric($showempty)) {
9483 $textifempty = $langs->trans($showempty);
9487 $out .= '<option value="-1
" selected>' . $textifempty . '</option>';
9491 while ($num && $i < $num) {
9494 $objp = $this->db->fetch_object($result);
9496 $this->constructMemberListOption($objp, $opt, $optJson, $selected, $filterkey);
9499 // "key
" value of json key array is used by jQuery automatically as selected value
9500 // "label
" value of json key array is used by jQuery automatically as text for combo box
9502 array_push($outarray, $optJson);
9507 $out .= '</select>';
9509 $this->db->free($result);
9511 if (empty($outputmode)) {
9516 dol_print_error($this->db);
9533 protected function constructMemberListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
9539 $outkey = $objp->rowid;
9540 $outlabel = dolGetFirstLastname($objp->firstname, $objp->lastname);
9541 $outtype = $objp->fk_adherent_type;
9543 $opt = '<option value="
' . $objp->rowid . '"';
9544 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
9546 if (!empty($filterkey) && $filterkey != '') {
9547 $outlabel = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $outlabel, 1);
9550 $opt .= "</option>\n
";
9552 $optJson = array('key' => $outkey, 'value' => $outlabel, 'type' => $outtype);
9576 public function selectForForms($objectdesc, $htmlname, $preSelectedValue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '', $objectfield = '')
9578 global $conf, $extrafields, $user, $hookmanager, $action;
9580 // Example of common usage for a link to a thirdparty
9582 // We got this in a modulebuilder form of "
MyObject" of module "mymodule
".
9583 // When ->fields is array( ... "fk_soc
" => array("type"=>"integer:
Societe:societe/
class/societe.class.php:1:((
status:=:1) AND (entity:IN:__SHARED_ENTITIES__))
" ...), we have
9584 // $objectdesc = 'Societe'
9585 // $objectfield = Method 1: 'myobject@mymodule:fk_soc' ('fk_soc' is code to retrieve myobject->fields['fk_soc'])
9586 // Method 2 recommended (it can be the array): array("type"=>"integer:
Societe:societe/class/societe.class.php:1:((
status:=:1) AND (entity:IN:__SHARED_ENTITIES__))
" ...)
9588 // We got this when showing an extrafields on resource that is a link to societe
9589 // When extrafields 'link_to_societe' for object Resource is 'link' to 'Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', we have
9590 // $objectdesc = 'Societe'
9591 // $objectfield = Method 1: 'resource:options_link_to_societe'
9592 // Method 2 recommended (it can be the array): array("type"=>'Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))" ...)
9601 $objectdescorig = $objectdesc;
9603 $InfoFieldList = array();
9608 if (is_array($objectfield)) {
9609 $objectdesc = $objectfield[
'type'];
9610 $objectdesc = preg_replace(
'/^integer[^:]*:/',
'', $objectdesc);
9611 } elseif ($objectfield) {
9613 $tmparray = explode(
':', $objectfield);
9616 $objectforfieldstmp = fetchObjectByElement(0, strtolower($tmparray[0]));
9618 if (is_object($objectforfieldstmp)) {
9622 if (preg_match(
'/^options_(.*)$/', $tmparray[1], $reg)) {
9626 $extrafields->fetch_name_optionals_label($objectforfieldstmp->table_element);
9628 if (!empty($extrafields->attributes[$objectforfieldstmp->table_element][
'type'][$key]) && $extrafields->attributes[$objectforfieldstmp->table_element][
'type'][$key] ==
'link') {
9629 if (!empty($extrafields->attributes[$objectforfieldstmp->table_element][
'param'][$key][
'options'])) {
9630 $tmpextrafields = array_keys($extrafields->attributes[$objectforfieldstmp->table_element][
'param'][$key][
'options']);
9631 $objectdesc = $tmpextrafields[0];
9636 if (array_key_exists($tmparray[1], $objectforfieldstmp->fields)) {
9637 $objectdesc = $objectforfieldstmp->fields[$tmparray[1]][
'type'];
9638 $objectdesc = preg_replace(
'/^integer[^:]*:/',
'', $objectdesc);
9649 $InfoFieldList = explode(
":", $objectdesc, 4);
9650 $vartmp = (empty($InfoFieldList[3]) ?
'' : $InfoFieldList[3]);
9652 if (preg_match(
'/^.*:(\w*)$/', $vartmp, $reg)) {
9653 $InfoFieldList[4] = $reg[1];
9655 $InfoFieldList[3] = preg_replace(
'/:\w*$/',
'', $vartmp);
9657 $classname = $InfoFieldList[0];
9658 $classpath = empty($InfoFieldList[1]) ?
'' : $InfoFieldList[1];
9660 $filter = empty($InfoFieldList[3]) ?
'' : $InfoFieldList[3];
9661 $sortfield = empty($InfoFieldList[4]) ?
'' : $InfoFieldList[4];
9664 $objecttmp = fetchObjectByElement(0, strtolower($InfoFieldList[0]));
9667 if (empty($objecttmp) && !empty($classpath)) {
9670 if ($classname && class_exists($classname)) {
9671 $objecttmp =
new $classname($this->db);
9678 $sharedentities = (is_object($objecttmp) && property_exists($objecttmp,
'element')) ?
getEntity($objecttmp->element) : strtolower($classname);
9679 $filter = str_replace(
9680 array(
'__ENTITY__',
'__SHARED_ENTITIES__',
'__USER_ID__'),
9681 array(
$conf->entity, $sharedentities, $user->id),
9685 if (!is_object($objecttmp)) {
9686 dol_syslog(
'selectForForms: Error bad setup of field objectdescorig=' . $objectdescorig.
', objectfield='.(is_array($objectfield) ?
'array' : $objectfield).
', objectdesc='.$objectdesc, LOG_WARNING);
9687 return 'selectForForms: Error bad setup of field objectdescorig=' . $objectdescorig.
', objectfield='.(is_array($objectfield) ?
'array' : $objectfield).
', objectdesc='.$objectdesc;
9689 '@phan-var-force CommonObject $objecttmp';
9692 $prefixforautocompletemode = $objecttmp->element;
9693 if ($prefixforautocompletemode ==
'societe') {
9694 $prefixforautocompletemode =
'company';
9696 if ($prefixforautocompletemode ==
'product') {
9697 $prefixforautocompletemode =
'produit';
9700 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) .
'_USE_SEARCH_TO_SELECT';
9702 dol_syslog(get_class($this) .
"::selectForForms filter=" . $filter, LOG_DEBUG);
9710 if ($preSelectedValue && empty($selected_input_value)) {
9711 $objecttmp->fetch($preSelectedValue);
9712 $selected_input_value = ($prefixforautocompletemode ==
'company' ? $objecttmp->name : $objecttmp->ref);
9714 $oldValueForShowOnCombobox = 0;
9715 foreach ($objecttmp->fields as $fieldK => $fielV) {
9716 if (!array_key_exists(
'showoncombobox', $fielV) || !$fielV[
'showoncombobox'] || empty($objecttmp->$fieldK)) {
9720 if (!$oldValueForShowOnCombobox) {
9721 $selected_input_value =
'';
9724 $selected_input_value .= $oldValueForShowOnCombobox ?
' - ' :
'';
9725 $selected_input_value .= $objecttmp->$fieldK;
9726 $oldValueForShowOnCombobox = empty($fielV[
'showoncombobox']) ? 0 : $fielV[
'showoncombobox'];
9731 $urlforajaxcall = DOL_URL_ROOT .
'/core/ajax/selectobject.php';
9732 $urloption =
'htmlname=' . urlencode($htmlname) .
'&outjson=1&objectdesc=' . urlencode($objectdescorig) . (is_scalar($objectfield) ?
'&objectfield='.urlencode($objectfield) :
'') . ($sortfield ?
'&sortfield=' . urlencode($sortfield) :
'');
9736 $parameters = array(
9737 'urloption' => $urloption,
9738 'object' => $objecttmp,
9739 'htmlname' => $htmlname,
9740 'filter' => $filter,
9741 'searchkey' => $searchkey,
9743 $reshook = $hookmanager->executeHooks(
'selectForFormsListUrl', $parameters, $objecttmp, $action);
9744 if (!empty($reshook)) {
9745 $urloption = $hookmanager->resPrint;
9746 $hookmanager->resPrint =
'';
9751 $out .=
'<!-- force css to be higher than dialog popup --><style type="text/css">.ui-autocomplete { z-index: 1010; }</style>';
9752 $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) .
'"' :
'') .
' />';
9755 $out .= $this->selectForFormsList($objecttmp, $htmlname, $preSelectedValue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled, $sortfield, $filter);
9783 public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty =
'', $searchkey =
'', $placeholder =
'', $morecss =
'', $moreparams =
'', $forcecombo = 0, $outputmode = 0, $disabled = 0, $sortfield =
'', $filter =
'', $sortorder =
'ASC')
9785 global $langs, $user, $hookmanager;
9789 $prefixforautocompletemode = $objecttmp->element;
9790 if ($prefixforautocompletemode ==
'societe') {
9791 $prefixforautocompletemode =
'company';
9793 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) .
'_USE_SEARCH_TO_SELECT';
9796 if (!empty($objecttmp->fields)) {
9797 $tmpfieldstoshow =
'';
9798 foreach ($objecttmp->fields as $key => $val) {
9799 if (! (
int)
dol_eval((
string) $val[
'enabled'], 1, 1,
'1')) {
9802 if (!empty($val[
'showoncombobox'])) {
9803 $tmpfieldstoshow .= ($tmpfieldstoshow ?
',' :
'') .
't.' . $key;
9806 if ($tmpfieldstoshow) {
9807 $fieldstoshow = $tmpfieldstoshow;
9809 } elseif ($objecttmp->element ===
'category') {
9810 $fieldstoshow =
't.label';
9813 $objecttmp->fields[
'ref'] = array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'enabled' => 1,
'position' => 10,
'visible' => 4,
'showoncombobox' => 1);
9816 if (empty($fieldstoshow)) {
9817 if (!empty($objecttmp->parent_element)) {
9818 $fieldstoshow =
'o.ref';
9819 if (empty($sortfield)) {
9820 $sortfield =
'o.ref';
9822 if (in_array($objecttmp->element, [
'commandedet',
'propaldet',
'facturedet',
'expeditiondet'])) {
9823 $fieldstoshow .=
',p.ref AS p_ref,p.label,t.description';
9824 $sortfield .=
', p.ref';
9826 } elseif (isset($objecttmp->fields[
'ref'])) {
9827 $fieldstoshow =
't.ref';
9829 $langs->load(
"errors");
9830 $this->error = $langs->trans(
"ErrorNoFieldWithAttributeShowoncombobox");
9831 return $langs->trans(
'ErrorNoFieldWithAttributeShowoncombobox');
9836 $outarray = array();
9837 $tmparray = array();
9841 $sanitizedfieldstoshow = $fieldstoshow;
9844 $sql =
"SELECT t.rowid, " . $sanitizedfieldstoshow .
" FROM " . $this->db->prefix() . $this->db->sanitize($objecttmp->table_element) .
" as t";
9845 if (!empty($objecttmp->isextrafieldmanaged)) {
9846 $extrafieldTable = $objecttmp->table_element;
9847 if ($extrafieldTable ==
'categorie') {
9848 $extrafieldTable =
'categories';
9850 $sql .=
" LEFT JOIN " . $this->db->prefix() . $this->db->sanitize($extrafieldTable) .
"_extrafields as e ON t.rowid = e.fk_object";
9852 if (!empty($objecttmp->parent_element)) {
9853 '@phan-var-force CommonObjectLine $objecttmp';
9854 $parent_properties = getElementProperties($objecttmp->parent_element);
9855 $sql .=
" INNER JOIN " . $this->db->prefix() . $this->db->sanitize($parent_properties[
'table_element']) .
" as o ON o.rowid = t.".$objecttmp->fk_parent_attribute;
9857 if (!empty($objecttmp->parent_element) && in_array($objecttmp->parent_element, [
'commande',
'propal',
'facture',
'expedition'])) {
9858 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product as p ON p.rowid = t.fk_product";
9860 if (!empty($objecttmp->ismultientitymanaged)) {
9861 if ($objecttmp->ismultientitymanaged == 1) {
9864 if (!is_numeric($objecttmp->ismultientitymanaged)) {
9865 $tmparray = explode(
'@', $objecttmp->ismultientitymanaged);
9866 $sql .=
" INNER JOIN " . $this->db->prefix() . $this->db->sanitize($tmparray[1]) .
" as parenttable ON parenttable.rowid = t." . $this->db->sanitize($tmparray[0]);
9871 $parameters = array(
9872 'object' => $objecttmp,
9873 'htmlname' => $htmlname,
9874 'filter' => $filter,
9875 'searchkey' => $searchkey
9878 $reshook = $hookmanager->executeHooks(
'selectForFormsListWhere', $parameters);
9879 if (!empty($hookmanager->resPrint)) {
9880 $sql .= $hookmanager->resPrint;
9882 $sql .=
" WHERE 1=1";
9885 if (!empty($objecttmp->ismultientitymanaged)) {
9886 if ($objecttmp->ismultientitymanaged == 1) {
9887 $sql .=
" AND t.entity IN (" .
getEntity($objecttmp->element) .
")";
9889 if (!is_numeric($objecttmp->ismultientitymanaged)) {
9890 $sql .=
" AND parenttable.entity = t." . $this->db->sanitize($tmparray[0]);
9894 if ($objecttmp->ismultientitymanaged ===
'fk_soc@societe') {
9895 if (!$user->hasRight(
'societe',
'client',
'voir') && empty($user->socid)) {
9896 $sql .=
" AND EXISTS (SELECT sc.rowid FROM ".$this->db->prefix() .
"societe_commerciaux as sc";
9897 $sql .=
" WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $user->id).
")";
9903 if (!empty($user->socid)) {
9904 if ($objecttmp->element ==
'societe') {
9905 $sql .=
" AND t.rowid = " . ((int) $user->socid);
9906 } elseif (!empty($objecttmp->fields[
'fk_soc']) || !empty($objecttmp->fields[
't.fk_soc']) || property_exists($objecttmp,
'fk_soc') || property_exists($objecttmp,
'socid')) {
9907 $sql .=
" AND t.fk_soc = " . ((int) $user->socid);
9911 $splittedfieldstoshow = explode(
',', $fieldstoshow);
9912 foreach ($splittedfieldstoshow as &$field2) {
9913 if (is_numeric($pos = strpos($field2,
' '))) {
9914 $field2 = substr($field2, 0, $pos);
9917 if ($searchkey !=
'') {
9923 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
9924 if ($errormessage) {
9925 return 'Error forging a SQL request from an universal criteria: ' . $errormessage;
9929 $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow, $sortorder);
9934 $resql = $this->db->query($sql);
9937 $out .=
'<select id="' . $htmlname .
'" class="flat minwidth100' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') . ($moreparams ?
' ' . $moreparams :
'') .
' name="' . $htmlname .
'">' .
"\n";
9940 $textifempty =
' ';
9944 if ($showempty && !is_numeric($showempty)) {
9945 $textifempty = $langs->trans($showempty);
9947 $textifempty .= $langs->trans(
"All");
9951 $out .=
'<option value="-1">' . $textifempty .
'</option>' .
"\n";
9954 $num = $this->db->num_rows($resql);
9958 $obj = $this->db->fetch_object($resql);
9961 $tmparray = explode(
',', $fieldstoshow);
9962 $oldvalueforshowoncombobox = 0;
9963 foreach ($tmparray as $key => $val) {
9964 $val = preg_replace(
'/(t|p|o)\./',
'', $val);
9965 $label .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val][
'showoncombobox'] ?
' - ' :
' ') :
'');
9966 $labelhtml .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val][
'showoncombobox'] ?
' - ' :
' ') :
'');
9967 $label .= $obj->$val;
9968 $labelhtml .= $obj->$val;
9970 $oldvalueforshowoncombobox = empty($objecttmp->fields[$val][
'showoncombobox']) ? 0 : $objecttmp->fields[$val][
'showoncombobox'];
9972 if (empty($outputmode)) {
9973 if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
9974 $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>';
9976 $out .=
'<option value="' . $obj->rowid .
'" data-html="' .
dol_escape_htmltag($labelhtml, 0, 0,
'', 0, 1) .
'">' .
dol_escape_htmltag($label, 0, 0,
'', 0, 1) .
'</option>';
9979 array_push($outarray, array(
'key' => $obj->rowid,
'value' => $label,
'label' => $label));
9983 if (($i % 10) == 0) {
9989 $out .=
'</select>' .
"\n";
9992 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
9999 $this->result = array(
'nbofelement' => $num);
10017 public static function radio($htmlName, $radioItems, $selected =
'', $moreGlobalParams = [])
10021 'disabled' =>
false,
10024 'name' => $htmlName,
10026 'unescapedAttr' => [],
10028 'unescapedAttrLabel' => [],
10029 'labelIsHtml' => false
10033 $params = array_merge_recursive_distinct($defaultParams, $moreGlobalParams);
10036 if (!empty($radioItems)) {
10037 foreach ($radioItems as $key => $item) {
10039 if (!is_array($item)) {
10051 'value' => !isset($item[
'attr'][
'value']) ? $key :
'',
10057 $defaultItem = array_merge_recursive_distinct($params, $defaultItem);
10058 $item = array_merge_recursive_distinct($defaultItem, $item);
10061 if ((is_array($selected) && in_array($item[
'attr'][
'value'], $selected,
true)) || $selected === $item[
'attr'][
'value']) {
10062 $item[
'attr'][
'checked'] =
true;
10066 $inputAttributes = implode(
' ', commonHtmlAttributeBuilder($item[
'attr'], $item[
'unescapedAttr']));
10067 $labelAttributes = implode(
' ', commonHtmlAttributeBuilder($item[
'attrLabel'], $item[
'unescapedAttrLabel']));
10070 $text = $item[
'labelIsHtml'] ? $item[
'label'] : htmlspecialchars($item[
'label'], ENT_QUOTES | ENT_SUBSTITUTE);
10073 $out .=
'<label ' . $labelAttributes .
'><input ' . $inputAttributes .
' /> ' . $text .
'</label> ';
10104 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)
10106 global
$conf, $langs;
10113 if ($value_as_key) {
10114 $array = array_combine($array, $array);
10117 '@phan-var-force array{label:string,data-html:string,disable?:int<0,1>,css?:string} $array';
10121 if ($addjscombo < 0) {
10128 $idname = str_replace(array(
'[',
']'), array(
'',
''), $htmlname);
10129 $out .=
'<select id="' . preg_replace(
'/^\./',
'', $idname) .
'" ' . ($disabled ?
'disabled="disabled" ' :
'') .
'class="flat ' . (preg_replace(
'/^\./',
'', $htmlname)) . ($morecss ?
' ' . $morecss :
'') .
' selectformat"';
10130 $out .=
' name="' . preg_replace(
'/^\./',
'', $htmlname) .
'" ' . ($moreparam ? $moreparam :
'');
10134 $textforempty =
' ';
10135 if (!empty(
$conf->use_javascript_ajax)) {
10136 $textforempty =
' ';
10138 if (!is_numeric($show_empty)) {
10139 $textforempty = $show_empty;
10141 $out .=
'<option class="optiongrey" ' . ($moreparamonempty ? $moreparamonempty .
' ' :
'') .
'value="' . (((
int) $show_empty) < 0 ? $show_empty : -1) .
'"' . (
$id == $show_empty ?
' selected' :
'') .
'>' . $textforempty .
'</option>' .
"\n";
10143 if (is_array($array)) {
10146 foreach ($array as $key => $value) {
10147 if (!is_array($value)) {
10148 $array[$key] = $langs->trans($value);
10150 $array[$key][
'label'] = $langs->trans($value[
'label']);
10155 if ($sort ==
'ASC') {
10157 } elseif ($sort ==
'DESC') {
10161 foreach ($array as $key => $tmpvalue) {
10162 if (is_array($tmpvalue)) {
10163 $value = $tmpvalue[
'label'];
10165 $disabled = empty($tmpvalue[
'disabled']) ?
'' :
' disabled';
10166 $style = empty($tmpvalue[
'css']) ?
'' :
' class="' . $tmpvalue[
'css'] .
'"';
10168 $value = $tmpvalue;
10173 if (!empty($disablebademail)) {
10174 if (($disablebademail == 1 && !preg_match(
'/<.+@.+>/', $value))
10175 || ($disablebademail == 2 && preg_match(
'/---/', $value))) {
10176 $disabled =
' disabled';
10177 $style =
' class="warning"';
10180 if ($key_in_label) {
10181 if (empty($nohtmlescape)) {
10184 $selectOptionValue = $key .
' - ' . ($maxlen ?
dol_trunc($value, $maxlen) : $value);
10187 if (empty($nohtmlescape)) {
10190 $selectOptionValue = $maxlen ?
dol_trunc($value, $maxlen) : $value;
10192 if ($value ==
'' || $value ==
'-') {
10193 $selectOptionValue =
' ';
10196 $out .=
'<option value="' . $key .
'"';
10197 $out .= $style . $disabled;
10198 $out .= is_array($tmpvalue) && !empty($tmpvalue[
'parent']) ?
' parent="' .
dolPrintHTMLForAttribute($tmpvalue[
'parent']) .
'"' :
'';
10199 if (is_array(
$id)) {
10200 if (in_array($key,
$id) && !$disabled) {
10201 $out .=
' selected';
10205 if (
$id !=
'' && ((
$id == (
string) $key) || (
$id ==
'ifone' && count($array) == 1)) && !$disabled) {
10206 $out .=
' selected';
10210 if (is_array($tmpvalue)) {
10211 foreach ($tmpvalue as $keyforvalue => $valueforvalue) {
10212 if ($keyforvalue ==
'labelhtml') {
10213 $keyforvalue =
'data-html';
10215 if (preg_match(
'/^data-/', $keyforvalue)) {
10216 $out .=
' '.dol_escape_htmltag($keyforvalue).
'="'.
dol_escape_htmltag($valueforvalue).
'"';
10219 } elseif (!empty($nohtmlescape)) {
10224 $out .= $selectOptionValue;
10225 $out .=
"</option>\n";
10228 $out .=
"</select>";
10231 if ($addjscombo && $jsbeautify) {
10233 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
10234 $out .=
ajax_combobox($idname, array(), 0, 0,
'resolve', (((
int) $show_empty) < 0 ? (
string) $show_empty :
'-1'), $morecss);
10258 public static function selectArrayAjax($htmlname, $url,
$id =
'', $moreparam =
'', $moreparamtourl =
'', $disabled = 0, $minimumInputLength = 1, $morecss =
'', $callurlonselect = 0, $placeholder =
'', $acceptdelayedhtml = 0)
10261 global $delayedhtmlcontent;
10264 if (!
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') && !defined(
'REQUIRE_JQUERY_MULTISELECT')) {
10268 $out =
'<select type="text" class="' . $htmlname . ($morecss ?
' ' . $morecss :
'') .
'" ' . ($moreparam ? $moreparam .
' ' :
'') .
'name="' . $htmlname .
'"></select>';
10271 if (!empty(
$conf->use_javascript_ajax)) {
10272 $tmpplugin =
'select2';
10273 $outdelayed =
"\n" .
'<!-- JS CODE TO ENABLE ' . $tmpplugin .
' for id ' . $htmlname .
' -->
10274 <script nonce="' . getNonce() .
'">
10275 $(document).ready(function () {
10277 ' . ($callurlonselect ?
'var saveRemoteData = [];' :
'') .
'
10279 $(".' . $htmlname .
'").select2({
10282 url: "' . $url .
'",
10283 dataType: \'json\',
10285 data: function (params) {
10287 q: params.term, // search term
10291 processResults: function (data) {
10292 // parse the results into the format expected by Select2.
10293 // since we are using custom formatting functions we do not need to alter the remote JSON data
10294 //console.log(data);
10295 saveRemoteData = data;
10296 /* format json result for select2 */
10298 $.each( data, function( key, value ) {
10299 result.push({id: key, text: value.text});
10301 //return {results:[{id:\'none\', text:\'aa\'}, {id:\'rrr\', text:\'Red\'},{id:\'bbb\', text:\'Search a into projects\'}], more:false}
10302 //console.log(result);
10303 return {results: result, more: false}
10307 language: (typeof select2arrayoflanguage === \'undefined\') ? \'en\' : select2arrayoflanguage,
10308 containerCssClass: \':all:\', /* Line to add class from the original SELECT propagated to the new <span class="select2-selection...> tag */
10310 escapeMarkup:
function (markup) {
return markup; },
10311 minimumInputLength:
' . ((int) $minimumInputLength) . ',
10312 formatResult:
function (result, container, query, escapeMarkup) {
10313 return escapeMarkup(result.text);
10317 ' . ($callurlonselect ? '
10319 $(
".' . $htmlname . '").change(
function() {
10320 var selected = $(\
'.' .
dol_escape_js($htmlname) .
'\').val();
10321 console.log(
"We select in selectArrayAjax the entry "+selected)
10323 $.each( saveRemoteData,
function( key, value ) {
10324 if (key == selected)
10326 console.log(
"selectArrayAjax - Do a redirect to "+value.url)
10327 location.assign(value.url);
10336 if ($acceptdelayedhtml) {
10337 $delayedhtmlcontent .= $outdelayed;
10339 $out .= $outdelayed;
10363 public static function selectArrayFilter($htmlname, $array, $id = '
', $moreparam = '', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0, $textfortitle = '')
10366 global $delayedhtmlcontent; // Will be used later outside of this function
10368 // TODO Use an internal dolibarr component instead of select2
10369 if (!getDolGlobalString('MAIN_USE_JQUERY_MULTISELECT
') && !defined('REQUIRE_JQUERY_MULTISELECT
')) {
10373 $out = '<select
type=
"text"'.($textfortitle ? ' title=
"'.dol_escape_htmltag($textfortitle).'"' : '').' id=
"'.$htmlname.'" class=
"'.$htmlname.($morecss ? ' ' . $morecss : '').'"'.($moreparam ? ' '.$moreparam : '').' name=
"'.$htmlname.'"><option></option></select>
';
10375 $formattedarrayresult = array();
10377 foreach ($array as $key => $value) {
10378 $o = new stdClass();
10380 $o->text = $value['text
'];
10381 $o->url = $value['url
'];
10382 $formattedarrayresult[] = $o;
10386 if (!empty($conf->use_javascript_ajax)) {
10387 $tmpplugin = 'select2
';
10388 $outdelayed = "\n" . '<!-- JS CODE TO ENABLE
' . $tmpplugin . ' for id ' . $htmlname . ' -->
10389 <script nonce=
"' . getNonce() . '">
10390 $(document).ready(
function () {
10391 var data =
' . json_encode($formattedarrayresult) . ';
10393 ' . ($callurlonselect ? 'var saveRemoteData =
' . json_encode($array) . ';
' : '') . '
10397 language: (typeof select2arrayoflanguage === \
'undefined\') ? \'en\' : select2arrayoflanguage,
10398 containerCssClass: \':all:\', /* Line to add class from the original SELECT propagated to the new <span class="select2-selection...> tag */
10400 escapeMarkup:
function (markup) {
return markup; },
10401 minimumInputLength:
' . ((int) $minimumInputLength) . ',
10402 formatResult:
function (result, container, query, escapeMarkup) {
10403 return escapeMarkup(result.text);
10405 matcher:
function (params, data) {
10407 if(! data.id)
return null;
';
10409 if ($callurlonselect) {
10410 // We forge the url with 'sall=
'
10413 var urlBase = data.url;
10414 var separ = urlBase.indexOf(
"?") >= 0 ?
"&" :
"?";
10417 saveRemoteData[data.id].url = urlBase + separ +
"search_all=" + encodeURIComponent(params.term.replace(/\
"/g, ""));';
10420 if (!$disableFiltering) {
10423 if(data.text.match(new RegExp(params.term))) {
10438 ' . ($callurlonselect ? '
10439 /* Code to execute a GET when we select a value */
10440 $(\'.' . dol_escape_js($htmlname) . '\').change(function() {
10441 var selected = $(\'.' . dol_escape_js($htmlname) . '\').val();
10442 console.log("We select
"+selected)
10444 $(\'.' . dol_escape_js($htmlname) . '\').val(""); /* reset visible combo value */
10445 $.each( saveRemoteData, function( key, value ) {
10446 if (key == selected)
10448 console.log("selectArrayFilter - Do a redirect to
"+value.url)
10449 location.assign(value.url);
10458 if ($acceptdelayedhtml) {
10459 $delayedhtmlcontent .= $outdelayed;
10461 $out .= $outdelayed;
10484 public static function multiselectarray($htmlname, $array, $selected = array(), $key_in_label = 0, $value_as_key = 0, $morecss = '', $translate = 0, $width = 0, $moreattrib = '', $nu = '', $placeholder = '', $addjscombo = -1)
10486 global $conf, $langs;
10489 if ($addjscombo < 0) {
10490 if (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
10497 $useenhancedmultiselect = 0;
10498 if (!empty($conf->use_javascript_ajax) && !defined('MAIN_DO_NOT_USE_JQUERY_MULTISELECT') && (getDolGlobalString('MAIN_USE_JQUERY_MULTISELECT') || defined('REQUIRE_JQUERY_MULTISELECT'))) {
10500 $useenhancedmultiselect = 1; // Use the js multiselect in one line. Possible only if $addjscombo not 0.
10504 $out .= '<span class="multiselectarray
'.$htmlname.'">';
10506 // We need a hidden field because when using the multiselect, if we unselect all, there is no
10507 // variable submitted at all, so no way to make a difference between variable not submitted and variable
10508 // submitted to nothing.
10509 $out .= '<input type="hidden
" name="'.$htmlname.'_multiselect
" value="1
">';
10510 // Output select component
10511 $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
";
10512 if (is_array($array) && !empty($array)) {
10513 if ($value_as_key) {
10514 $array = array_combine($array, $array);
10517 if (!empty($array)) {
10518 foreach ($array as $key => $value) {
10520 $tmplabel = $value;
10521 $tmplabelhtml = '';
10525 if (is_array($value) && array_key_exists('id', $value) && array_key_exists('label', $value)) {
10526 $tmpkey = $value['id'];
10527 $tmplabel = empty($value['label']) ? '' : $value['label'];
10528 $tmplabelhtml = empty($value['labelhtml']) ? (empty($value['data-html']) ? '' : $value['data-html']) : $value['labelhtml'];
10529 $tmpcolor = empty($value['color']) ? '' : $value['color'];
10530 $tmppicto = empty($value['picto']) ? '' : $value['picto'];
10531 $tmpdisabled = empty($value['disabled']) ? '' : $value['disabled'];
10533 $newval = ($translate ? $langs->trans($tmplabel) : $tmplabel);
10534 $newval = ($key_in_label ? $tmpkey . ' - ' . $newval : $newval);
10536 $tmplabelhtml = ($translate ? $langs->trans($tmplabelhtml) : $tmplabelhtml);
10537 $tmplabelhtml = ($key_in_label ? $tmpkey . ' - ' . $tmplabelhtml : $tmplabelhtml);
10539 $out .= '<option value="' . $tmpkey . '"';
10540 if (is_array($selected) && !empty($selected) && in_array((string) $tmpkey, $selected) && ((string) $tmpkey != '')) {
10541 $out .= ' selected';
10543 $out .= is_array($value) && array_key_exists('parent', $value) && !empty($value['parent']) ? ' parent="' . dolPrintHTMLForAttribute($value['parent
']) . '"' : '';
10544 if ($tmpdisabled) {
10547 if (!empty($tmplabelhtml)) {
10548 $out .= ' data-html="' . dolPrintHTMLForAttribute($tmplabelhtml) . '"';
10550 $tmplabelhtml = ($tmppicto ? img_picto('', $tmppicto, 'class="pictofixedwidth
" style="color: #
' . $tmpcolor . '"') : '') . $newval;
10551 $out .= ' data-html="' . dolPrintHTMLForAttribute($tmplabelhtml) . '"';
10554 $out .= dol_htmlentitiesbr($newval);
10555 $out .= '</option>' . "\n
";
10559 $out .= '</select>' . "\n
";
10563 // Add code for jquery to use multiselect
10564 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('MAIN_USE_JQUERY_MULTISELECT') || defined('REQUIRE_JQUERY_MULTISELECT')) {
10565 $out .= "\n
" . '<!-- JS CODE TO ENABLE select for id ' . $htmlname . ', addjscombo=' . $addjscombo . ' -->';
10566 $out .= "\n
" . '<script nonce="' . getNonce() . '">' . "\n
";
10567 if ($addjscombo == 1) {
10568 $tmpplugin = getDolGlobalString('MAIN_USE_JQUERY_MULTISELECT', (defined('REQUIRE_JQUERY_MULTISELECT') ? constant('REQUIRE_JQUERY_MULTISELECT') : 'select2'));
10570 // If property data-html set, we decode html entities and use this.
10571 // Note that HTML content must have been sanitized from js with dol_escape_htmltag(xxx, 0, 0, '', 0, 1) when building the select option.
10572 // TODO Move this into common js ?
10573 $out .= 'function formatResult(record, container) {' . "\n
";
10574 $out .= ' if ($(record.element).attr("data-html
") != undefined && typeof htmlEntityDecodeJs === "function
") {';
10575 $out .= ' return htmlEntityDecodeJs($(record.element).attr("data-html
"));';
10577 $out .= ' return record.text;';
10578 $out .= '}' . "\n
";
10580 $out .= 'function formatSelection(record) {' . "\n
";
10581 $out .= ' return record.text;';
10582 $out .= '}' . "\n
";
10584 // Load the select2 enhancer
10585 //$out .= 'console.log(\'addjscombo=1 for htmlname=' . dol_escape_js($htmlname) . '\');';
10586 $out .= '$(document).ready(function () {
10587 $(\'#' . dol_escape_js($htmlname) . '\').' . $tmpplugin . '({';
10588 if ($placeholder) {
10592 text: \''.dol_escape_js($placeholder).'\'
10595 $out .= ' dir: \'ltr\',
10596 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag (ko with multiselect) */
10597 dropdownCssClass: \
'' .
dol_escape_js($morecss) .
'\', /* Line to add class on the new <span class="select2-selection...> tag (ok with multiselect). Need full version of select2. */
10598 // Specify format function for dropdown item
10599 formatResult: formatResult,
10600 templateResult: formatResult, /* For 4.0 */
10601 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
10602 // Specify format function for selected item
10603 formatSelection: formatSelection,
10604 templateSelection: formatSelection, /* For 4.0 */
10605 language: (typeof select2arrayoflanguage === \'undefined\') ? \'en\' : select2arrayoflanguage
10608 /* Add also morecss to the css .select2 that is after the #htmlname, for component that are shown dynamically after load, because select2 set
10609 the size only if component is not hidden by default on load */
10612 } elseif ($addjscombo == 2 && !defined(
'DISABLE_MULTISELECT')) {
10616 $out .=
'console.log(\'addjscombo=2 for htmlname=' .
dol_escape_js($htmlname) .
'\');
';
10617 $out .= '$(document).ready(
function () {
10619 containerHTML: \
'<div class="multi-select-container">\',
10620 menuHTML: \'<div class="multi-select-menu">\',
10621 buttonHTML: \'<span class="multi-select-button ' .
dol_escape_js($morecss) .
'">\',
10622 menuItemHTML: \'<label class="multi-select-menuitem">\',
10623 activeClass: \'multi-select-container--open\',
10628 $out .= '</script>
';
10648 public static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage, $pos = '
', $draganddrop = 0)
10650 global $conf, $langs, $user;
10652 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER
')) {
10655 if (empty($array)) {
10659 $tmpvar = "MAIN_SELECTEDFIELDS_" . $varpage; // To get list of saved selected fields to show
10661 if (!empty($user->conf->$tmpvar)) { // A list of fields was already customized for user
10662 $tmparray = explode(',
', $user->conf->$tmpvar);
10663 foreach ($array as $key => $val) {
10665 //var_dump($tmparray);
10666 if (in_array($key, $tmparray)) {
10667 $array[$key]['checked
'] = 1;
10669 $array[$key]['checked
'] = 0;
10672 } else { // There is no list of fields already customized for user
10673 foreach ($array as $key => $val) {
10674 if (!empty($array[$key]['checked
']) && $array[$key]['checked
'] < 0) {
10675 $array[$key]['checked
'] = 0;
10680 $listoffieldsforselection = '';
10681 $listcheckedstring = '';
10683 foreach ($array as $key => $val) {
10685 // var_dump(array_key_exists('enabled
', $val));
10686 // var_dump(!$val['enabled
']);
10687 if (array_key_exists('enabled
', $val) && isset($val['enabled
']) && !$val['enabled
']) {
10688 unset($array[$key]); // We don't want
this field
10691 if (!empty($val[
'type']) && $val[
'type'] ==
'separate') {
10696 if (!empty($val[
'label']) && $val[
'label']) {
10697 if (!empty($val[
'langfile']) && is_object($langs)) {
10698 $langs->load($val[
'langfile']);
10702 $listoffieldsforselection .=
'<li '.(!empty($draganddrop) ?
'class="fieldsortable" id="'.$key :
'').
'"><input type="checkbox" id="checkbox' . $key .
'" value="' . $key .
'"' . ((!array_key_exists(
'checked', $val) || empty($val[
'checked']) || $val[
'checked'] ==
'-1') ?
'' :
' checked="checked"') .
' data-position="'.(empty($val[
'position']) ?
'' : $val[
'position']).
'" />';
10703 $listoffieldsforselection .=
'<label for="checkbox' . $key .
'" class="paddingleft">';
10705 $listoffieldsforselection .=
'</label>';
10706 if (!empty($draganddrop)) {
10707 $listoffieldsforselection .=
img_picto($langs->trans(
"MoveField", !empty($key) ? $key :
'none'),
'grip_title',
'class="opacitymedium boxhandle hideonsmartphone cursormove marginleftonly"');
10709 $listoffieldsforselection .=
'</li>';
10710 $listcheckedstring .= (empty($val[
'checked']) ?
'' : $key .
',');
10714 $out =
'<!-- Component multiSelectArrayWithCheckbox ' . $htmlname .
' -->
10716 <dl class="dropdown">
10718 <a href="#' . $htmlname .
'" class="multiselectpicto">
10721 <input type="hidden" class="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $listcheckedstring .
'">
10723 <dd class="dropdowndd">
10724 <div class="multiselectcheckbox'.$htmlname.
'">
10725 <ul class="'.$htmlname.(((string) $pos ==
'1' || (
string) $pos ==
'left') ?
'left' :
'').(!empty($draganddrop) ?
' sortable' :
'').
'">
10726 <li class="liinputsearch">
10727 <input class="inputsearch_dropdownselectedfields width90p minwidth200imp" style="width:90%;" type="text" placeholder="'.$langs->trans(
'Search').
'">
10729 '.$listoffieldsforselection.
'
10736 function updateFieldOrder() {
10737 var positionfields = $(".sortable").sortable("toArray");
10739 url: \''.DOL_URL_ROOT.
'/core/ajax/changepositionfields.php?positionfields=\'+positionfields+\'&token='.newToken().
'&action=listafterchangingpositionfields&contextpage='.$varpage.
'&userid='.$user->id.
'\',
10741 success: function () {
10743 window.location.href = "'.$_SERVER[
"PHP_SELF"].
'";
10747 $( ".sortable" ).sortable({
10748 handle: \'.boxhandle\',
10749 revert: \'invalid\',
10750 items: \'.fieldsortable\',
10751 stop: function(event, ui) {
10752 console.log("We moved box so we call updateBoxOrder with ajax actions");
10753 updateFieldOrder(); /* 1 to avoid message after a move */
10758 <script nonce="' . getNonce() .
'" type="text/javascript">
10759 jQuery(document).ready(function () {
10760 $(\'.multiselectcheckbox' . $htmlname .
' input[type="checkbox"]\').on("click", function () {
10761 console.log("A new field was added/removed, we edit field input[name=formfilteraction]");
10763 $("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\'); // Update field so we know we changed something on selected fields after POST
10765 var title = $(this).val() + ",";
10766 if ($(this).is(\':checked\')) {
10767 $(\'.' . $htmlname .
'\').val(title + $(\'.' . $htmlname .
'\').val());
10770 $(\'.' . $htmlname .
'\').val( $(\'.' . $htmlname .
'\').val().replace(title, \'\') )
10772 // Now, we submit page
10773 //$(this).parents(\'form:first\').submit();
10776 $("input.inputsearch_dropdownselectedfields").on("keyup", function() {
10777 console.log("keyup on inputsearch_dropdownselectedfields");
10778 var value = $(this).val().toLowerCase();
10779 $(\'.multiselectcheckbox'.$htmlname.
' li > label\').filter(function() {
10780 $(this).parent().toggle($(this).text().toLowerCase().indexOf(value) > -1)
10784 if (empty(
$conf->browser->layout) ||
$conf->browser->layout !=
'phone') {
10786 $(".dropdown dt a").on("click", function () {
10787 console.log("Click on dropdown, we set focus to search field");
10788 setTimeout(() => { $(\'.inputsearch_dropdownselectedfields\').focus(); }, 200);
10812 include_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
10815 $categories = $cat->containing(
$id, $type);
10817 if ($rendermode == 1 || $rendermode == 2) {
10818 $toprint = array();
10819 foreach ($categories as
$c) {
10820 $ways =
$c->print_all_ways(
'auto', ($nolink ?
'none' :
''), 0, 1, ($rendermode == 2 ? 0 : 1));
10821 foreach ($ways as $way) {
10822 $color =
$c->color;
10823 $sfortag =
'<li class="select2-search-choice-dolibarr noborderoncategories'.(empty($toprint) ?
' nomarginleft' :
'');
10824 $forced_color =
'categtextwhite';
10825 if (
$c->color && colorIsLight(
$c->color)) {
10826 $forced_color =
'categtextblack';
10828 $sfortag .=
' '.$forced_color;
10830 $sfortag .= ($color ?
' style="background: #' . $color .
';"' :
' style="background: #bbb"');
10831 $titlestring = $ways[0];
10835 if ($rendermode == 1) {
10836 $sfortag .=
'<a href="'.DOL_URL_ROOT.
'/categories/viewcat.php?id='.((int)
$c->id).
'&type='.urlencode(
$c->type).
'" class="'.$forced_color.
'">';
10837 $sfortag .=
img_picto(
'',
'category',
'class="paddingright"');
10838 if (
$conf->dol_optimize_smallscreen) {
10843 $sfortag .=
'</a>';
10847 $sfortag .=
'</li>';
10849 $toprint[] = $sfortag;
10852 if (empty($toprint)) {
10855 return '<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
10859 if ($rendermode == 0) {
10860 $arrayselected = array();
10861 $cate_arbo = $this->select_all_categories($type,
'',
'parent', 64, 0, 3);
10862 foreach ($categories as
$c) {
10863 $arrayselected[(
string)
$c->id] = (
string)
$c->id;
10866 return $this->multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'', 0,
'100%',
'disabled',
'category');
10869 return 'ErrorBadValueForParameterRenderMode';
10883 global
$conf, $langs, $hookmanager;
10889 $object->fetchObjectLinked();
10892 $hookmanager->initHooks(array(
'commonobject'));
10893 $parameters = array(
10894 'morehtmlright' => $morehtmlright,
10895 'compatibleImportElementsList' => &$compatibleImportElementsList,
10897 $reshook = $hookmanager->executeHooks(
'showLinkedObjectBlock', $parameters,
$object, $action);
10899 $nbofdifferenttypes = count(
$object->linkedObjects);
10901 if (empty($reshook)) {
10902 print
'<!-- showLinkedObjectBlock -->';
10903 print
load_fiche_titre($langs->trans($title), $morehtmlright,
'', 0,
'',
'showlinkedobjectblock');
10906 print
'<div class="div-table-responsive-no-min">';
10907 print
'<table class="noborder allwidth" data-block="showLinkedObject" data-element="' .
$object->element .
'" data-elementid="' .
$object->id .
'" >';
10909 print
'<tr class="liste_titre">';
10910 print
'<td>' . $langs->trans(
"Type") .
'</td>';
10911 print
'<td>' . $langs->trans(
"Ref") .
'</td>';
10914 print
'<td class="right">' . $langs->trans(
"AmountHTShort") .
'</td>';
10915 print
'<td class="right">' . $langs->trans(
"Status") .
'</td>';
10919 $nboftypesoutput = 0;
10921 foreach (
$object->linkedObjects as $objecttype => $objects) {
10922 $tplpath = $element = $subelement = $objecttype;
10925 global $showImportButton;
10926 $showImportButton =
false;
10927 if (!empty($compatibleImportElementsList) && in_array($element, $compatibleImportElementsList)) {
10928 $showImportButton =
true;
10933 if ($objecttype !=
'supplier_proposal' && preg_match(
'/^([^_]+)_([^_]+)/i', $objecttype, $regs)) {
10934 $element = $regs[1];
10935 $subelement = $regs[2];
10936 $tplpath = $element .
'/' . $subelement;
10938 $tplname =
'linkedobjectblock';
10941 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $objecttype, $regs)) {
10942 $element = $regs[1];
10943 $module = $regs[2];
10944 $tplpath = $module.
'/' . $element;
10945 $tplname = $tplname.
'_'.$element;
10949 if ($objecttype ==
'facture') {
10950 $tplpath =
'compta/' . $element;
10954 } elseif ($objecttype ==
'facturerec') {
10955 $tplpath =
'compta/facture';
10956 $tplname =
'linkedobjectblockForRec';
10960 } elseif ($objecttype ==
'propal') {
10961 $tplpath =
'comm/' . $element;
10965 } elseif ($objecttype ==
'supplier_proposal') {
10969 } elseif ($objecttype ==
'shipping' || $objecttype ==
'shipment' || $objecttype ==
'expedition') {
10970 $tplpath =
'expedition';
10974 } elseif ($objecttype ==
'reception') {
10975 $tplpath =
'reception';
10979 } elseif ($objecttype ==
'delivery') {
10980 $tplpath =
'delivery';
10984 } elseif ($objecttype ==
'ficheinter') {
10985 $tplpath =
'fichinter';
10989 } elseif ($objecttype ==
'invoice_supplier') {
10990 $tplpath =
'fourn/facture';
10991 } elseif ($objecttype ==
'order_supplier') {
10992 $tplpath =
'fourn/commande';
10993 } elseif ($objecttype ==
'expensereport') {
10994 $tplpath =
'expensereport';
10995 } elseif ($objecttype ==
'subscription') {
10996 $tplpath =
'adherents';
10997 } elseif ($objecttype ==
'conferenceorbooth') {
10998 $tplpath =
'eventorganization';
10999 } elseif ($objecttype ==
'conferenceorboothattendee') {
11000 $tplpath =
'eventorganization';
11001 } elseif ($objecttype ==
'mo') {
11006 } elseif ($objecttype ==
'project_task') {
11007 $tplpath =
'projet/tasks';
11010 global $linkedObjectBlock;
11011 $linkedObjectBlock = $objects;
11014 $dirtpls = array_merge(
$conf->modules_parts[
'tpl'], array(
'/' . $tplpath .
'/tpl'));
11016 foreach ($dirtpls as $reldir) {
11017 $reldir = rtrim($reldir,
'/');
11018 if ($nboftypesoutput == ($nbofdifferenttypes - 1)) {
11019 global $noMoreLinkedObjectBlockAfter;
11020 $noMoreLinkedObjectBlockAfter = 1;
11022 $file =
dol_buildpath($reldir .
'/' . $tplname .
'.tpl.php');
11023 if (file_exists($file)) {
11024 $res = @include $file;
11026 $nboftypesoutput++;
11033 if (!$nboftypesoutput) {
11034 print
'<tr><td colspan="7"><span class="opacitymedium">' . $langs->trans(
"None") .
'</span></td></tr>';
11039 if (!empty($compatibleImportElementsList)) {
11040 $res = @include
dol_buildpath(
'core/tpl/objectlinked_lineimport.tpl.php');
11046 return $nbofdifferenttypes;
11060 global
$conf, $langs, $hookmanager, $form;
11065 if (empty($form)) {
11066 $form =
new Form($this->db);
11070 $linktoelemlist =
'';
11071 $listofidcompanytoscan =
'';
11073 if (!is_object(
$object->thirdparty)) {
11074 if (
$object->element ==
'subscription' && isset(
$object->fk_adherent)) {
11080 $fk_adherent = $subby->fk_adherent;
11081 $adh->fetch($fk_adherent);
11082 $thirdparty_id = $adh->fetch_thirdparty();
11085 $thirdparty_id =
$object->thirdparty->id;
11088 $possiblelinks = array();
11090 $dontIncludeCompletedItems =
getDolGlobalString(
'DONT_INCLUDE_COMPLETED_ELEMENTS_LINKS');
11092 if (!empty($thirdparty_id) && $thirdparty_id > 0) {
11093 $listofidcompanytoscan = (int) $thirdparty_id;
11095 $listofidcompanytoscan .=
',' . (int)
$object->thirdparty->parent;
11098 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
11099 $tmpproject =
new Project($this->db);
11100 $tmpproject->fetch((
int)
$object->fk_project);
11101 if ($tmpproject->socid > 0 && ($tmpproject->socid != $thirdparty_id)) {
11102 $listofidcompanytoscan .=
',' . (int) $tmpproject->socid;
11104 unset($tmpproject);
11107 $possiblelinks = array(
11111 'label' =>
'LinkToProposal',
11112 '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') .
')'.($dontIncludeCompletedItems ?
' AND t.fk_statut < 4' :
''),
11114 'shipping' => array(
11117 'label' =>
'LinkToExpedition',
11118 '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') .
')'.($dontIncludeCompletedItems ?
' AND t.fk_statut < 2' :
''),
11123 'label' =>
'LinkToOrder',
11124 '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') .
')'.($dontIncludeCompletedItems ?
' AND t.facture < 1' :
''),
11125 'linkname' =>
'commande',
11127 'subscription' => array(
11130 'label' =>
'LinkToMemberSubscription',
11131 'sql' =>
"SELECT a.fk_soc as socid, CONCAT(a.firstname, ' ', a.lastname) as name, a.entity as client, sub.rowid, sub.note as ref, '' as ref_client, sub.subscription as total_ht FROM " . $this->db->prefix() .
"adherent as a, " . $this->db->prefix() .
"subscription as sub WHERE sub.fk_adherent = a.rowid AND a.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) .
') AND a.entity IN (' .
getEntity(
'subscription') .
')',
11132 'linkname' =>
'subscription',
11134 'conferenceorboothattendee' => array(
11137 'label' =>
'LinkToConferenceOrBoothAttendee',
11138 'sql' =>
"SELECT s.rowid as socid, CONCAT(a.firstname, ' ', a.lastname) as name, a.rowid as rowid, a.fk_project as fk_project, a.ref as ref, a.email as email, a.date_subscription as date_subscription FROM " . $this->db->prefix() .
"societe as s, " . $this->db->prefix() .
"eventorganization_conferenceorboothattendee as a WHERE a.fk_soc = s.rowid AND a.fk_soc IN (" . $this->db->sanitize($listofidcompanytoscan) .
') AND s.entity IN (' .
getEntity(
'conferenceorboothattendee') .
')' . (empty(
$object->fk_project) ?
'' :
' AND a.fk_project = ' . (int)
$object->fk_project),
11139 'linkname' =>
'attendee'
11141 'invoice' => array(
11144 'label' =>
'LinkToInvoice',
11145 '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') .
')'.($dontIncludeCompletedItems ?
' AND t.paye < 1' :
''),
11146 'linkname' =>
'facture',
11148 'invoice_template' => array(
11151 'label' =>
'LinkToTemplateInvoice',
11152 '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') .
')',
11154 'contrat' => array(
11157 'label' =>
'LinkToContract',
11158 '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
11159 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',
11161 'fichinter' => array(
11164 'label' =>
'LinkToIntervention',
11165 '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') .
')',
11167 'supplier_proposal' => array(
11170 'label' =>
'LinkToSupplierProposal',
11171 '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') .
')'.($dontIncludeCompletedItems ?
' AND t.fk_statut < 4' :
''),
11173 'order_supplier' => array(
11176 'label' =>
'LinkToSupplierOrder',
11177 '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') .
')'.($dontIncludeCompletedItems ?
' AND t.billed < 1' :
''),
11179 'invoice_supplier' => array(
11181 'perms' => 1,
'label' =>
'LinkToSupplierInvoice',
11182 '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') .
')'.($dontIncludeCompletedItems ?
' AND t.paye < 1' :
''),
11187 'label' =>
'LinkToTicket',
11188 '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') .
')'.($dontIncludeCompletedItems ?
' AND t.fk_statut < 8' :
''),
11193 'label' =>
'LinkToMo',
11194 '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') .
')'.($dontIncludeCompletedItems ?
' AND t.status < 3' :
''),
11199 if (
$object->table_element ==
'commande_fournisseur') {
11200 $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').
')'.($dontIncludeCompletedItems ?
' AND t.status < 3' :
'');
11201 } elseif (
$object->table_element ==
'mrp_mo') {
11202 $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').
')'.($dontIncludeCompletedItems ?
' AND t.billed < 1' :
'');
11206 if (!empty($listofidcompanytoscan)) {
11208 $hookmanager->initHooks(array(
'commonobject'));
11209 $parameters = array(
'listofidcompanytoscan' => $listofidcompanytoscan,
'possiblelinks' => $possiblelinks);
11210 $reshook = $hookmanager->executeHooks(
'showLinkToObjectBlock', $parameters,
$object, $action);
11213 if (empty($reshook)) {
11214 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
11215 $possiblelinks = array_merge($possiblelinks, $hookmanager->resArray);
11217 } elseif ($reshook > 0) {
11218 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
11219 $possiblelinks = $hookmanager->resArray;
11223 if (!empty($possiblelinks)) {
11224 $object->fetchObjectLinked();
11228 $htmltoenteralink =
'';
11229 foreach ($possiblelinks as $key => $possiblelink) {
11231 if (empty($possiblelink[
'enabled'])) {
11238 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $key, $regs)) {
11240 $module = $regs[2];
11243 if (!empty($possiblelink[
'perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) {
11244 $htmltoenteralink .=
'<div id="' . $key .
'list"' . (empty(
$conf->use_javascript_ajax) ?
'' :
' style="display:none"') .
'>';
11248 $htmltoenteralink .=
'<br>'.
"\n";
11249 $htmltoenteralink .=
'<!-- form to add a link from anywhere -->'.
"\n";
11250 $htmltoenteralink .=
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="formlinkedbyref' . $key .
'">';
11251 $htmltoenteralink .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
11252 $htmltoenteralink .=
'<input type="hidden" name="action" value="addlinkbyref">';
11253 $htmltoenteralink .=
'<input type="hidden" name="id" value="' .
$object->id .
'">';
11254 $htmltoenteralink .=
'<input type="hidden" name="addlink" value="' . $key .(!empty($module) ?
'@'.$module :
'').
'">';
11255 $htmltoenteralink .=
'<table class="noborder">';
11256 $htmltoenteralink .=
'<tr class="liste_titre">';
11258 $htmltoenteralink .=
'<td class="center"><input type="text" placeholder="'.dol_escape_htmltag($langs->trans(
"Ref")).
'" name="reftolinkto" value="' .
dol_escape_htmltag(
GETPOST(
'reftolinkto',
'alpha')) .
'">';
11259 $htmltoenteralink .=
'<br>';
11260 $htmltoenteralink .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
'ToLink') .
'"> ';
11261 $htmltoenteralink .=
'<input type="submit" class="button smallpaddingimp" name="cancel" value="' . $langs->trans(
'Cancel') .
'">';
11262 $htmltoenteralink .=
'</td>';
11263 $htmltoenteralink .=
'</tr>';
11264 $htmltoenteralink .=
'</table>';
11265 $htmltoenteralink .=
'</form>';
11268 $sql = $possiblelink[
'sql'];
11270 $resqllist = $this->db->query($sql);
11272 $num = $this->db->num_rows($resqllist);
11277 $htmltoenteralink .=
'<br>';
11279 $htmltoenteralink .=
'<!-- form to add a link from object to same thirdparty -->'.
"\n";
11280 $htmltoenteralink .=
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="formlinked' . $key .
'">';
11281 $htmltoenteralink .=
'<input type="hidden" name="token" value="' . newToken() .
'">';
11282 $htmltoenteralink .=
'<input type="hidden" name="action" value="addlink">';
11283 $htmltoenteralink .=
'<input type="hidden" name="id" value="' .
$object->id .
'">';
11284 $htmltoenteralink .=
'<input type="hidden" name="addlink" value="' . $key . (!empty($module) ?
'@'.$module :
'').
'">';
11285 $htmltoenteralink .=
'<table class="noborder">';
11288 case 'conferenceorboothattendee':
11290 $htmltoenteralink .= $this->makeAddLinkToAttendee(
$object, $key, $possiblelink, $num, $resqllist);
11295 $htmltoenteralink .= $this->makeAddLinkToObject(
$object, $key, $possiblelink, $num, $resqllist);
11299 $htmltoenteralink .=
'</table>';
11300 $htmltoenteralink .=
'<div class="center">';
11302 $htmltoenteralink .=
'<input type="submit" class="button valignmiddle marginleftonly marginrightonly smallpaddingimp" value="' . $langs->trans(
'ToLink') .
'">';
11304 if (empty(
$conf->use_javascript_ajax)) {
11305 $htmltoenteralink .=
'<input type="submit" class="button button-cancel marginleftonly marginrightonly smallpaddingimp" name="cancel" value="' . $langs->trans(
"Cancel") .
'"></div>';
11307 $htmltoenteralink .=
'<input type="submit" onclick="jQuery(\'#' . $key .
'list\').toggle(); return false;" class="button button-cancel marginleftonly marginrightonly smallpaddingimp" name="cancel" value="' . $langs->trans(
"Cancel") .
'"></div>';
11309 $htmltoenteralink .=
'</form>';
11312 $this->db->free($resqllist);
11316 $htmltoenteralink .=
'</div>';
11321 $linktoelemlist .=
'<li><a href="#linkto' . $key .
'" class="linkto dropdowncloseonclick" rel="' . $key .
'">' . $langs->trans($possiblelink[
'label']) .
' (' . $num .
')</a></li>';
11324 $linktoelemlist .=
'<li><span class="linktodisabled">' . $langs->trans($possiblelink[
'label']) .
' (0)</span></li>';
11329 if ($linktoelemlist) {
11331 <dl class="dropdown" id="linktoobjectname">
11333 if (!empty(
$conf->use_javascript_ajax)) {
11334 $linktoelem .=
'<dt><a href="#linktoobjectname"><span class="fas fa-link paddingrightonly"></span>' . $langs->trans(
"LinkTo") .
'...</a></dt>';
11336 $linktoelem .=
'<dd>
11337 <div class="multiselectlinkto">
11338 <ul class="ulselectedfields">' . $linktoelemlist .
'
11347 if (!empty(
$conf->use_javascript_ajax)) {
11348 print
'<!-- Add js to show linkto box -->
11349 <script nonce="' . getNonce() .
'">
11350 jQuery(document).ready(function() {
11351 jQuery(".linkto").click(function() {
11352 console.log("We choose to show/hide links for rel="+jQuery(this).attr(\'rel\')+" so #"+jQuery(this).attr(\'rel\')+"list");
11353 jQuery("#"+jQuery(this).attr(\'rel\')+"list").toggle();
11361 return array(
'linktoelem' => $linktoelem,
'htmltoenteralink' => $htmltoenteralink);
11363 print $htmltoenteralink;
11366 return $linktoelem;
11383 public function selectyesno($htmlname, $value =
'', $option = 0, $disabled =
false, $useempty = 0, $addjscombo = 0, $morecss =
'yesno width75', $labelyes =
'Yes', $labelno =
'No')
11394 $disabled = ($disabled ?
' disabled' :
'');
11396 $resultyesno =
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'"' . $disabled .
'>' .
"\n";
11398 $resultyesno .=
'<option value="-1"' . (($value < 0) ?
' selected' :
'') .
'> </option>' .
"\n";
11400 if ((
"$value" ==
'yes') || ($value == 1)) {
11401 $resultyesno .=
'<option value="' . $yes .
'" selected>' . $langs->trans($labelyes) .
'</option>' .
"\n";
11402 $resultyesno .=
'<option value="' . $no .
'">' . $langs->trans($labelno) .
'</option>' .
"\n";
11404 $selected = (($useempty && $value !=
'0' && $value !=
'no') ?
'' :
' selected');
11405 $resultyesno .=
'<option value="' . $yes .
'">' . $langs->trans($labelyes) .
'</option>' .
"\n";
11406 $resultyesno .=
'<option value="' . $no .
'"' . $selected .
'>' . $langs->trans($labelno) .
'</option>' .
"\n";
11408 $resultyesno .=
'</select>' .
"\n";
11411 $resultyesno .=
ajax_combobox($htmlname, array(), 0, 0,
'resolve', ($useempty < 0 ? (
string) $useempty :
'-1'), $morecss);
11414 return $resultyesno;
11431 $sql =
"SELECT rowid, label";
11432 $sql .=
" FROM " . $this->db->prefix() .
"export_model";
11433 $sql .=
" WHERE type = '" . $this->db->escape($type) .
"'";
11434 $sql .=
" ORDER BY rowid";
11435 $result = $this->db->query($sql);
11437 print
'<select class="flat" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
11439 print
'<option value="-1"> </option>';
11442 $num = $this->db->num_rows($result);
11444 while ($i < $num) {
11445 $obj = $this->db->fetch_object($result);
11446 if ($selected == $obj->rowid) {
11447 print
'<option value="' . $obj->rowid .
'" selected>';
11449 print
'<option value="' . $obj->rowid .
'">';
11479 public function showrefnav(
$object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $morehtmlright =
'')
11481 global
$conf, $langs, $hookmanager, $extralanguages;
11484 if (empty($fieldid)) {
11485 $fieldid =
'rowid';
11487 if (empty($fieldref)) {
11492 $addgendertxt =
'';
11493 if (property_exists(
$object,
'gender') && !empty(
$object->gender)) {
11494 $addgendertxt =
' ';
11497 $addgendertxt .=
'<i class="fas fa-mars valignmiddle"></i>';
11500 $addgendertxt .=
'<i class="fas fa-venus valignmiddle"></i>';
11503 $addgendertxt .=
'<i class="fas fa-transgender valignmiddle"></i>';
11509 if (is_object($hookmanager)) {
11510 $parameters = array(
'showrefnav' =>
true);
11511 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object);
11512 if (!empty($hookmanager->resPrint)) {
11513 if (empty(
$object->next_prev_filter) && preg_match(
'/^\s*AND/i', $hookmanager->resPrint)) {
11514 $object->next_prev_filter = (
string) preg_replace(
'/^\s*AND\s*/i',
'', $hookmanager->resPrint);
11515 } elseif (!empty(
$object->next_prev_filter) && !preg_match(
'/^\s*AND/i', $hookmanager->resPrint)) {
11516 $object->next_prev_filter .=
' AND '.$hookmanager->resPrint;
11518 $object->next_prev_filter .= $hookmanager->resPrint;
11523 $previous_ref = $next_ref =
'';
11526 $object->load_previous_next_ref((isset(
$object->next_prev_filter) ?
$object->next_prev_filter :
''), $fieldid, $nodbprefix);
11528 $navurl = $_SERVER[
"PHP_SELF"];
11531 if ($paramid ==
'api_token_card') {
11532 if (preg_match(
'/\/user\/api_token/', $navurl)) {
11533 $navurl = preg_replace(
'/card/',
'list', $navurl);
11539 if ($paramid ==
'project_ref') {
11540 if (preg_match(
'/\/tasks\/(task|contact|note|document)\.php/', $navurl)) {
11541 $navurl = preg_replace(
'/\/tasks\/(task|contact|time|note|document)\.php/',
'/tasks.php', $navurl);
11546 $previous_ref =
$object->ref_previous ?
'<a accesskey="p" alt="'.dol_escape_htmltag($langs->trans(
"Previous")).
'" title="' .
$conf->browser->stringforfirstkey .
' p" class="classfortooltip reposition" 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>';
11547 $next_ref =
$object->ref_next ?
'<a accesskey="n" alt="'.dol_escape_htmltag($langs->trans(
"Next")).
'" title="' .
$conf->browser->stringforfirstkey .
' n" class="classfortooltip reposition" 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>';
11551 $ret .=
'<!-- Start banner content --><div style="vertical-align: middle">';
11554 if ($morehtmlright) {
11555 $ret .=
'<div class="inline-block floatleft">' . $morehtmlright .
'</div>';
11558 if ($previous_ref || $next_ref || $morehtml) {
11559 $ret .=
'<div class="pagination paginationref"><ul class="right">';
11561 if ($morehtml &&
getDolGlobalInt(
'MAIN_OPTIMIZEFORTEXTBROWSER') < 2) {
11562 $ret .=
'<!-- morehtml --><li class="noborder litext' . (($shownav && $previous_ref && $next_ref) ?
' clearbothonsmartphone' :
'') .
'">' . $morehtml .
'</li>';
11564 if ($shownav && ($previous_ref || $next_ref)) {
11565 $ret .=
'<li class="pagination">' . $previous_ref .
'</li>';
11566 $ret .=
'<li class="pagination">' . $next_ref .
'</li>';
11568 if ($previous_ref || $next_ref || $morehtml) {
11569 $ret .=
'</ul></div>';
11573 $parameters = array(
'morehtmlstatus' => $morehtmlstatus);
11574 $reshook = $hookmanager->executeHooks(
'moreHtmlStatus', $parameters,
$object);
11575 if (empty($reshook)) {
11576 $morehtmlstatus .= $hookmanager->resPrint;
11578 $morehtmlstatus = $hookmanager->resPrint;
11580 if ($morehtmlstatus) {
11581 $ret .=
'<!-- status --><div class="statusref">' . $morehtmlstatus .
'</div>';
11584 $parameters = array();
11585 $reshook = $hookmanager->executeHooks(
'moreHtmlRef', $parameters,
$object);
11586 if (empty($reshook)) {
11587 $morehtmlref .= $hookmanager->resPrint;
11588 } elseif ($reshook > 0) {
11589 $morehtmlref = $hookmanager->resPrint;
11593 if ($morehtmlleft) {
11594 if (
$conf->browser->layout ==
'phone') {
11595 $ret .=
'<!-- morehtmlleft --><div class="floatleft">' . $morehtmlleft .
'</div>';
11597 $ret .=
'<!-- morehtmlleft --><div class="inline-block floatleft">' . $morehtmlleft .
'</div>';
11602 $ret .=
'<!-- Ref or ID --><div class="inline-block floatleft valignmiddle maxwidth750 marginbottomonly refid' . (($shownav && ($previous_ref || $next_ref)) ?
' refidpadding' :
'') .
'">';
11605 if (
$object->element ==
'societe') {
11606 $ret .=
'<span class="valignmiddle">'.dolPrintHTML((
string)
$object->name).
'</span>';
11609 $arrayoflangcode = array();
11614 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
11615 if (!is_object($extralanguages)) {
11616 include_once DOL_DOCUMENT_ROOT .
'/core/class/extralanguages.class.php';
11619 $extralanguages->fetch_name_extralanguages(
'societe');
11623 if (!empty($extralanguages->attributes[
'societe']) && !empty($extralanguages->attributes[
'societe'][
'name'])) {
11624 $object->fetchValuesForExtraLanguages();
11628 foreach ($arrayoflangcode as $extralangcode) {
11630 if (
$object->array_languages[
'name'][$extralangcode]) {
11631 $htmltext .=
$object->array_languages[
'name'][$extralangcode];
11633 $htmltext .=
'<span class="opacitymedium">' . $langs->trans(
"SwitchInEditModeToAddTranslation") .
'</span>';
11636 $ret .=
'<!-- Show translations of name -->' .
"\n";
11637 $ret .= $this->textwithpicto(
'', $htmltext, -1,
'language',
'opacitymedium paddingleft');
11640 } elseif (
$object->element ==
'member') {
11641 '@phan-var-force Adherent $object';
11642 $ret .=
$object->ref .
'<br>';
11643 $fullname =
$object->getFullName($langs);
11645 $ret .=
'<span class="valignmiddle">'.dolPrintHTML((
string)
$object->societe) . ((!empty($fullname) &&
$object->societe != $fullname) ?
' (' .
dol_htmlentities($fullname) . $addgendertxt .
')' :
'').
'</span>';
11647 $ret .=
'<span class="valignmiddle">'.dolPrintHTML($fullname) . $addgendertxt . ((!empty(
$object->societe) &&
$object->societe != $fullname) ?
' (' .
dol_htmlentities((
string)
$object->societe) .
')' :
'').
'</span>';
11649 } elseif (in_array(
$object->element, array(
'contact',
'user'))) {
11650 $ret .=
'<span class="valignmiddle">'.dolPrintHTML(
$object->getFullName($langs)).
'</span>'.$addgendertxt;
11651 } elseif (
$object->element ==
'usergroup') {
11653 } elseif (in_array(
$object->element, array(
'action',
'agenda'))) {
11654 '@phan-var-force ActionComm $object';
11656 } elseif (in_array(
$object->element, array(
'adherent_type'))) {
11658 } elseif (
$object->element ==
'ecm_directories') {
11660 } elseif (
$object->element ==
'accountingbookkeeping' && !empty(
$object->context[
'mode']) &&
$object->context[
'mode'] ==
'_tmp') {
11661 $ret .=
'<span class="valignmiddle">'.$langs->trans(
"Draft").
'</span>';
11663 '@phan-var-force Ticket $object';
11664 $ret .=
'<span class="valignmiddle">'.dolPrintHTML(!empty(
$object->$fieldref) ?
$object->$fieldref :
"").
'</span>';
11665 $ret .=
' <span class="nobold small" title="'.dolPrintHTMLForAttribute($langs->trans(
"TicketTrackId")).
'">('.
$object->track_id.
')</span>';
11666 } elseif ($fieldref !=
'none') {
11668 $ret .=
'<span class="valignmiddle">'.dolPrintHTML(!empty(
$object->$fieldref) ?
$object->$fieldref :
"").
'</span>';
11670 if ($morehtmlref) {
11672 if (substr($morehtmlref, 0, 4) !=
'<div') {
11676 $ret .=
'<!-- morehtmlref -->'.$morehtmlref;
11681 $ret .=
'</div><!-- End banner content -->';
11698 if (empty(
$object->barcode)) {
11703 if (empty(
$object->barcode_type_code) || empty(
$object->barcode_type_coder)) {
11705 $result =
$object->fetchBarCode();
11708 return '<!-- ErrorFetchBarcode -->';
11713 $url = DOL_URL_ROOT .
'/viewimage.php?modulepart=barcode&generator=' . urlencode(
$object->barcode_type_coder) .
'&code=' . urlencode(
$object->barcode) .
'&encoding=' . urlencode(
$object->barcode_type_code);
11714 $out =
'<!-- url barcode = ' . $url .
' -->';
11715 $out .=
'<img src="' . $url .
'"' . ($morecss ?
' class="' . $morecss .
'"' :
'') .
'>';
11738 public static function showphoto($modulepart,
$object, $width = 100, $height = 0, $caneditfield = 0, $cssclass =
'photowithmargin', $imagesize =
'', $addlinktofullsize = 1, $cache = 0, $forcecapture =
'', $noexternsourceoverwrite = 0, $usesharelinkifavailable = 0)
11747 $originalfile =
'';
11751 if ($modulepart ==
'societe') {
11752 $dir =
$conf->societe->multidir_output[$entity];
11754 if (dolIsAllowedForPreview(
$object->logo)) {
11755 if ((
string) $imagesize ==
'mini') {
11756 $file =
get_exdir(0, 0, 0, 0,
$object,
'thirdparty') .
'logos/' . getImageFileNameForSize(
$object->logo,
'_mini');
11757 } elseif ((
string) $imagesize ==
'small') {
11758 $file =
get_exdir(0, 0, 0, 0,
$object,
'thirdparty') .
'logos/' . getImageFileNameForSize(
$object->logo,
'_small');
11766 } elseif ($modulepart ==
'contact') {
11767 $dir =
$conf->societe->multidir_output[$entity] .
'/contact';
11769 if (!empty($photo)) {
11770 if (dolIsAllowedForPreview($photo)) {
11771 if ((
string) $imagesize ==
'mini') {
11772 $file =
get_exdir(0, 0, 0, 0,
$object,
'contact') .
'photos/' . getImageFileNameForSize($photo,
'_mini');
11773 } elseif ((
string) $imagesize ==
'small') {
11774 $file =
get_exdir(0, 0, 0, 0,
$object,
'contact') .
'photos/' . getImageFileNameForSize($photo,
'_small');
11778 $originalfile =
get_exdir(0, 0, 0, 0,
$object,
'contact') .
'photos/' . $photo;
11783 } elseif ($modulepart ==
'userphoto') {
11784 $dir =
$conf->user->dir_output;
11786 if (!empty($photo)) {
11787 if (dolIsAllowedForPreview($photo)) {
11788 if ((
string) $imagesize ==
'mini') {
11789 $file =
get_exdir(0, 0, 0, 0,
$object,
'user') .
'photos/' . getImageFileNameForSize($photo,
'_mini');
11790 } elseif ((
string) $imagesize ==
'small') {
11791 $file =
get_exdir(0, 0, 0, 0,
$object,
'user') .
'photos/' . getImageFileNameForSize($photo,
'_small');
11795 $originalfile =
get_exdir(0, 0, 0, 0,
$object,
'user') .
'photos/' . $photo;
11799 $altfile =
$object->id .
".jpg";
11803 } elseif ($modulepart ==
'memberphoto') {
11804 $dir =
$conf->member->dir_output;
11806 if (!empty($photo)) {
11807 if (dolIsAllowedForPreview($photo)) {
11808 if ((
string) $imagesize ==
'mini') {
11809 $file =
get_exdir(0, 0, 0, 0,
$object,
'member') .
'photos/' . getImageFileNameForSize($photo,
'_mini');
11810 } elseif ((
string) $imagesize ==
'small') {
11811 $file =
get_exdir(0, 0, 0, 0,
$object,
'member') .
'photos/' . getImageFileNameForSize($photo,
'_small');
11815 $originalfile =
get_exdir(0, 0, 0, 0,
$object,
'member') .
'photos/' . $photo;
11819 $altfile =
$object->id .
".jpg";
11826 if ($modulepart !=
"unknown" && method_exists(
$object,
'getDataToShowPhoto')) {
11827 $tmpdata =
$object->getDataToShowPhoto($modulepart, $imagesize);
11829 $dir = $tmpdata[
'dir'];
11830 $file = $tmpdata[
'file'];
11831 $originalfile = $tmpdata[
'originalfile'];
11832 $altfile = $tmpdata[
'altfile'];
11833 $email = $tmpdata[
'email'];
11834 $capture = $tmpdata[
'capture'];
11838 if ($forcecapture) {
11839 $capture = $forcecapture;
11845 if ($file && file_exists($dir .
"/" . $file)) {
11846 if ($addlinktofullsize) {
11847 $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0,
'&entity=' . $entity);
11848 if ($urladvanced) {
11849 $ret .=
'<a href="' . $urladvanced .
'">';
11851 $ret .=
'<a href="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($originalfile) .
'&cache=' . $cache .
'">';
11856 if ($usesharelinkifavailable) {
11858 $relativefileforecm = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT.
'/',
'/').
'/',
'', $dir.
'/'.$originalfile);
11860 require_once DOL_DOCUMENT_ROOT .
'/ecm/class/ecmfiles.class.php';
11862 $ecmfiles->fetch(0,
'', $relativefileforecm);
11864 $sharekey = (
string) $ecmfiles->share;
11867 if (!empty($sharekey)) {
11868 $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?hashp=' . urlencode($sharekey) .
'&cache=' . urlencode((
string) $cache) .
'">';
11870 $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=' . urlencode($modulepart) .
'&entity=' . ((int) $entity) .
'&file=' . urlencode($file) .
'&cache=' . urlencode((
string) $cache) .
'">';
11872 if ($addlinktofullsize) {
11875 } elseif ($altfile && file_exists($dir .
"/" . $altfile)) {
11876 if ($addlinktofullsize) {
11877 $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0,
'&entity=' . $entity);
11878 if ($urladvanced) {
11879 $ret .=
'<a href="' . $urladvanced .
'">';
11881 $ret .=
'<a href="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($originalfile) .
'&cache=' . $cache .
'">';
11884 $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=' . urlencode($modulepart) .
'&entity=' . ((int) $entity) .
'&file=' . urlencode($altfile) .
'&cache=' . urlencode((
string) $cache) .
'">';
11885 if ($addlinktofullsize) {
11889 $nophoto =
'/public/theme/common/nophoto.png';
11890 $defaultimg =
'identicon';
11891 if (in_array($modulepart, array(
'societe',
'userphoto',
'contact',
'memberphoto'))) {
11892 if ($modulepart ==
'societe' || ($modulepart ==
'memberphoto' && !empty(
$object->morphy) && strpos(
$object->morphy,
'mor') !==
false)) {
11893 $nophoto =
'company';
11895 $nophoto =
'/public/theme/common/user_anonymous.png';
11897 $nophoto =
'/public/theme/common/user_man.png';
11900 $nophoto =
'/public/theme/common/user_woman.png';
11905 if (
isModEnabled(
'gravatar') && $email && empty($noexternsourceoverwrite)) {
11907 $ret .=
'<!-- Put link to gravatar -->';
11908 $ret .=
'<img class="gravatar photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" title="'.
dolPrintHTMLForAttribute(
'Gravatar avatar - '.$email).
'" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
' src="https://www.gravatar.com/avatar/' .
dol_hash(strtolower(trim($email)),
'sha256', 1) .
'?s=' . $width .
'&d=' . $defaultimg .
'">';
11910 if ($nophoto ==
'company') {
11911 $ret .=
'<div class="divforspanimg valignmiddle inline-block center photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
'>' .
img_picto(
'',
'company') .
'</div>';
11914 $ret .=
'<img class="photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
' src="' . DOL_URL_ROOT . $nophoto .
'">';
11919 if ($caneditfield) {
11923 $ret .=
'<table class="nobordernopadding centpercent">';
11925 $ret .=
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">' . $langs->trans(
"Delete") .
'</label><br><br></td></tr>';
11927 $ret .=
'<tr><td class="tdoverflow">';
11929 $maxmin = $maxfilesizearray[
'maxmin'];
11931 $ret .=
'<input type="hidden" name="MAX_FILE_SIZE" value="' . ($maxmin * 1024) .
'">';
11933 $ret .=
'<input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"' . ($capture ?
' capture="' .
dolPrintHTMLForAttribute($capture) .
'"' :
'') .
'>';
11934 $ret .=
'</td></tr>';
11935 $ret .=
'</table>';
11960 public function select_dolgroups($selected = 0, $htmlname =
'groupid', $show_empty = 0, $exclude =
'', $disabled = 0, $include =
'', $enableonly = array(), $force_entity =
'0', $multiple =
false, $morecss =
'minwidth200')
11963 global
$conf, $user, $langs;
11966 $excludeGroups =
null;
11967 if (is_array($exclude)) {
11968 $excludeGroups = implode(
",", $exclude);
11971 $includeGroups =
null;
11972 if (is_array($include)) {
11973 $includeGroups = implode(
",", $include);
11976 if (!is_array($selected)) {
11977 $selected = array($selected);
11983 $sql =
"SELECT ug.rowid, ug.nom as name";
11984 if (
isModEnabled(
'multicompany') &&
$conf->entity == 1 && $user->admin && !$user->entity) {
11985 $sql .=
", e.label";
11987 $sql .=
" FROM " . $this->db->prefix() .
"usergroup as ug ";
11988 if (
isModEnabled(
'multicompany') &&
$conf->entity == 1 && $user->admin && !$user->entity) {
11989 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entity as e ON e.rowid=ug.entity";
11990 if ($force_entity) {
11991 $sql .=
" WHERE ug.entity IN (0, " . $force_entity .
")";
11993 $sql .=
" WHERE ug.entity IS NOT NULL";
11996 $sql .=
" WHERE ug.entity IN (0, " . ((int)
$conf->entity) .
")";
11998 if (is_array($exclude) && $excludeGroups) {
11999 $sql .=
" AND ug.rowid NOT IN (" . $this->db->sanitize($excludeGroups) .
")";
12001 if (is_array($include) && $includeGroups) {
12002 $sql .=
" AND ug.rowid IN (" . $this->db->sanitize($includeGroups) .
")";
12004 $sql .=
" ORDER BY ug.nom ASC";
12006 dol_syslog(get_class($this) .
"::select_dolgroups", LOG_DEBUG);
12007 $resql = $this->db->query($sql);
12010 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
12012 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
' ' . ($disabled ?
' disabled' :
'') .
'>';
12014 $num = $this->db->num_rows($resql);
12017 if ($show_empty && !$multiple) {
12018 $out .=
'<option value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'> </option>' .
"\n";
12021 while ($i < $num) {
12022 $obj = $this->db->fetch_object($resql);
12024 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
12028 $label = $obj->name;
12029 $labelhtml = $obj->name;
12031 $label .=
" (" . $obj->label .
")";
12032 $labelhtml .=
' <span class="opacitymedium">(' . $obj->label .
')</span>';
12035 $out .=
'<option value="' . $obj->rowid .
'"';
12036 if ($disableline) {
12037 $out .=
' disabled';
12039 if ((isset($selected[0]) && is_object($selected[0]) && $selected[0]->
id == $obj->rowid)
12040 || ((!isset($selected[0]) || !is_object($selected[0])) && !empty($selected) && in_array($obj->rowid, $selected))) {
12041 $out .=
' selected';
12043 $out .=
' data-html="'.dol_escape_htmltag($labelhtml).
'"';
12046 $out .=
'</option>';
12051 $out .=
'<option value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'></option>' .
"\n";
12053 $out .=
'<option value="" disabled>' . $langs->trans(
"NoUserGroupDefined") .
'</option>';
12055 $out .=
'</select>';
12074 $out =
'<div class="nowraponall">';
12075 $out .=
'<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fas fa-search"></span></button>';
12076 $out .=
'<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fas fa-times"></span></button>';
12090 public function showCheckAddButtons($cssclass =
'checkforaction', $calljsfunction = 0, $massactionname =
"massaction")
12096 if (!empty(
$conf->use_javascript_ajax)) {
12097 $out .=
'<div class="inline-block checkallactions"><input type="checkbox" id="' . $cssclass .
's" name="' . $cssclass .
's" class="checkallactions"></div>';
12099 $out .=
'<script nonce="' . getNonce() .
'">
12100 $(document).ready(function() {
12101 $("#' . $cssclass .
's").click(function() {
12102 if($(this).is(\':checked\')){
12103 console.log("We check all ' . $cssclass .
' and trigger the change method");
12104 $(".' . $cssclass .
'").prop(\'checked\', true).trigger(\'change\');
12108 console.log("We uncheck all");
12109 $(".' . $cssclass .
'").prop(\'checked\', false).trigger(\'change\');
12111 if ($calljsfunction) {
12112 $out .=
'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "' . $massactionname .
'", "' . $cssclass .
'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
12116 $(".' . $cssclass .
'").change(function() {
12117 console.log("We check and change the tr class highlight after a change on .'.$cssclass.
'");
12118 var $row = $(this).closest("tr");
12120 var anyChecked = $row.find(\'input[type="checkbox"].checkforselect:checked\').length > 0;
12121 console.log("anychecked="+anyChecked);
12123 $row.removeClass("highlight");
12125 $row.addClass("highlight");
12147 $out = $this->showFilterButtons();
12148 if ($addcheckuncheckall) {
12149 $out .= $this->showCheckAddButtons($cssclass, $calljsfunction, $massactionname);
12167 public function selectExpenseCategories($selected =
'', $htmlname =
'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target =
'', $default_selected = 0, $params = array(), $info_admin = 1)
12169 global $langs, $user;
12172 $sql =
"SELECT rowid, label FROM " . $this->db->prefix() .
"c_exp_tax_cat WHERE active = 1";
12173 $sql .=
" AND entity IN (0," .
getEntity(
'exp_tax_cat') .
")";
12174 if (!empty($excludeid)) {
12175 $sql .=
" AND rowid NOT IN (" . $this->db->sanitize(implode(
',', $excludeid)) .
")";
12177 $sql .=
" ORDER BY label";
12179 $resql = $this->db->query($sql);
12181 $out =
'<select id="select_' . $htmlname .
'" name="' . $htmlname .
'" class="' . $htmlname .
' flat minwidth75imp maxwidth200">';
12183 $out .=
'<option value="0"> </option>';
12186 while ($obj = $this->db->fetch_object($resql)) {
12187 $out .=
'<option ' . ($selected == $obj->rowid ?
'selected="selected"' :
'') .
' value="' . $obj->rowid .
'">' . $langs->trans($obj->label) .
'</option>';
12189 $out .=
'</select>';
12192 if (!empty($htmlname) && $user->admin && $info_admin) {
12193 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
12196 if (!empty($target)) {
12197 $sql =
"SELECT c.id FROM " . $this->db->prefix() .
"c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1";
12198 $resql = $this->db->query($sql);
12200 if ($this->db->num_rows($resql) > 0) {
12201 $obj = $this->db->fetch_object($resql);
12202 $out .=
'<script nonce="' . getNonce() .
'">
12204 $("select[name=' . $target .
']").on("change", function() {
12205 var current_val = $(this).val();
12206 if (current_val == ' . $obj->id .
') {';
12207 if (!empty($default_selected) || !empty($selected)) {
12208 $out .=
'$("select[name=' . $htmlname .
']").val("' . ($default_selected > 0 ? $default_selected : $selected) .
'");';
12212 $("select[name=' . $htmlname .
']").change();
12216 $("select[name=' . $htmlname .
']").change(function() {
12218 if ($("select[name=' . $target .
']").val() == ' . $obj->id .
') {
12219 // get price of kilometer to fill the unit price
12223 data: { fk_c_exp_tax_cat: $(this).val(), token: \'' . currentToken() .
'\' },
12224 url:
"' . (DOL_URL_ROOT . '/expensereport/ajax/ajaxik.php?' . implode('&', $params)) . '",
12225 }).done(
function( data, textStatus, jqXHR ) {
12227 if (typeof data.up !=
"undefined") {
12228 $(
"input[name=value_unit]").val(data.up);
12229 $(
"select[name=' . $htmlname . ']").attr(
"title", data.title);
12231 $(
"input[name=value_unit]").val(
"");
12232 $(
"select[name=' . $htmlname . ']").attr(
"title",
"");
12243 dol_print_error($this->db);
12257 public function selectExpenseRanges($selected = '
', $htmlname = 'fk_range
', $useempty = 0)
12259 global $conf, $langs;
12262 $sql = "SELECT rowid, range_ik FROM " . $this->db->prefix() . "c_exp_tax_range";
12263 $sql .= " WHERE entity = " . ((int) $conf->entity) . " AND active = 1";
12265 $resql = $this->db->query($sql);
12267 $out = '<select
id=
"select_' . $htmlname . '" name=
"' . $htmlname . '" class=
"' . $htmlname . ' flat minwidth75imp">
';
12269 $out .= '<option value=
"0"></option>
';
12272 while ($obj = $this->db->fetch_object($resql)) {
12273 $out .= '<option
' . ($selected == $obj->rowid ? 'selected=
"selected"' : '') . ' value=
"' . $obj->rowid . '">
' . price($obj->range_ik, 0, $langs, 1, 0) . '</option>
';
12275 $out .= '</select>
';
12277 dol_print_error($this->db);
12293 public function selectExpenseFees($selected = '
', $htmlname = 'fk_c_type_fees
', $useempty = 0, $allchoice = 1, $useid = 0)
12298 $sql = "SELECT id, code, label";
12299 $sql .= " FROM ".$this->db->prefix()."c_type_fees";
12300 $sql .= " WHERE active = 1";
12302 $resql = $this->db->query($sql);
12304 $out = '<select
id=
"select_' . $htmlname . '" name=
"' . $htmlname . '" class=
"' . $htmlname . ' flat minwidth75imp">
';
12306 $out .= '<option value=
"0"></option>
';
12309 $out .= '<option value=
"-1">
' . $langs->trans('AllExpenseReport
') . '</option>
';
12317 while ($obj = $this->db->fetch_object($resql)) {
12318 $key = $langs->trans($obj->code);
12319 $out .= '<option
' . ($selected == $obj->{$field} ? 'selected=
"selected"' : '') . ' value=
"' . $obj->{$field} . '">
' . ($key != $obj->code ? $key : $obj->label) . '</option>
';
12321 $out .= '</select>
';
12323 $out .= ajax_combobox('select_
'.$htmlname);
12325 dol_print_error($this->db);
12349 public function selectInvoiceForTimeProject($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)
12351 global $user, $conf, $langs;
12353 require_once DOL_DOCUMENT_ROOT . '/projet/
class/project.class.php
';
12355 if (is_null($usertofilter)) {
12356 $usertofilter = $user;
12361 $hideunselectables = false;
12362 if (getDolGlobalString('INVOICE_HIDE_UNSELECTABLES
')) {
12363 $hideunselectables = true;
12366 if (empty($projectsListId)) {
12367 if (!$usertofilter->hasRight('projet
', 'all
', 'lire
')) {
12368 $projectstatic = new Project($this->db);
12369 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
12373 // Search all projects
12374 $sql = "SELECT f.rowid, f.ref as fref, 'nolabel
' as flabel, p.rowid as pid, f.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name";
12375 $sql .= " FROM " . $this->db->prefix() . "facture as f";
12376 $sql .= " INNER JOIN " . $this->db->prefix() . "projet as p ON p.entity IN (" . getEntity('project
') . ") AND f.fk_projet = p.rowid";
12377 $sql .= " LEFT JOIN " . $this->db->prefix() . "societe as s ON s.rowid = p.fk_soc";
12378 $sql .= " WHERE f.fk_statut = 0"; // Draft invoices only
12379 //if ($projectsListId) $sql.= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")";
12380 //if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
12381 //if ($socid > 0) $sql.= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)";
12382 $sql .= " ORDER BY p.ref, f.ref ASC";
12384 $resql = $this->db->query($sql);
12386 // Use select2 selector
12387 if (!empty($conf->use_javascript_ajax)) {
12388 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php
';
12389 $comboenhancement = ajax_combobox($htmlname, array(), 0, $forcefocus);
12390 $out .= $comboenhancement;
12391 $morecss = 'minwidth200imp maxwidth500
';
12394 if (empty($option_only)) {
12395 $out .= '<select
class=
"valignmiddle flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled=
"disabled"' : '') . ' id=
"' . $htmlname . '" name=
"' . $htmlname . '">
';
12397 if (!empty($show_empty)) {
12398 $out .= '<option value=
"0" class=
"optiongrey">
';
12399 if (!is_numeric($show_empty)) {
12400 $out .= $show_empty;
12404 $out .= '</option>
';
12406 $num = $this->db->num_rows($resql);
12409 while ($i < $num) {
12410 $obj = $this->db->fetch_object($resql);
12411 // 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.
12412 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$usertofilter->hasRight('societe
', 'lire
')) {
12415 if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED) {
12422 if ($showproject == 'all
') {
12423 $labeltoshow .= dol_trunc($obj->ref, 18); // Invoice ref
12425 $labeltoshow .= ' -
' . $obj->name; // Soc name
12429 if ($obj->fk_statut == Project::STATUS_DRAFT) {
12431 $labeltoshow .= ' -
' . $langs->trans("Draft");
12432 } elseif ($obj->fk_statut == Project::STATUS_CLOSED) {
12433 if ($discard_closed == 2) {
12436 $labeltoshow .= ' -
' . $langs->trans("Closed");
12437 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
12439 $labeltoshow .= ' -
' . $langs->trans("LinkedToAnotherCompany");
12443 if (!empty($selected) && $selected == $obj->rowid) {
12444 $out .= '<option value=
"' . $obj->rowid . '" selected
';
12445 //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected
if disabled
12446 $out .=
'>' . $labeltoshow .
'</option>';
12448 if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
12451 $resultat =
'<option value="' . $obj->rowid .
'"';
12453 $resultat .=
' disabled';
12458 $resultat .= $labeltoshow;
12459 $resultat .=
'</option>';
12467 if (empty($option_only)) {
12468 $out .=
'</select>';
12471 $this->db->free($resql);
12494 public function selectInvoiceRec($selected =
'', $htmlname =
'facrecid', $maxlength = 24, $option_only = 0, $show_empty =
'1', $forcefocus = 0, $disabled = 0, $morecss =
'maxwidth500')
12496 global
$conf, $langs;
12502 $sql =
'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc';
12503 $sql .=
' FROM ' . MAIN_DB_PREFIX .
'facture_rec as f';
12504 $sql .=
" WHERE f.entity IN (" .
getEntity(
'invoice') .
")";
12505 $sql .=
" ORDER BY f.titre ASC";
12507 $resql = $this->db->query($sql);
12510 if (!empty(
$conf->use_javascript_ajax)) {
12511 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
12512 $comboenhancement =
ajax_combobox($htmlname, array(), 0, $forcefocus);
12513 $out .= $comboenhancement;
12514 $morecss =
'minwidth200imp maxwidth500';
12517 if (empty($option_only)) {
12518 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' id="' . $htmlname .
'" name="' . $htmlname .
'">';
12520 if (!empty($show_empty)) {
12521 $out .=
'<option value="0" class="optiongrey">';
12522 if (!is_numeric($show_empty)) {
12523 $out .= $show_empty;
12527 $out .=
'</option>';
12529 $num = $this->db->num_rows($resql);
12531 while ($obj = $this->db->fetch_object($resql)) {
12532 $labeltoshow =
dol_trunc($obj->title, 18);
12535 if (!empty($obj->suspended)) {
12537 $labeltoshow .=
' - ' . $langs->trans(
"Closed");
12541 if (!empty($selected) && $selected == $obj->rowid) {
12542 $out .=
'<option value="' . $obj->rowid .
'" selected';
12544 $out .=
'>' . $labeltoshow .
'</option>';
12546 if ($disabled && ($selected != $obj->rowid)) {
12549 $resultat =
'<option value="' . $obj->rowid .
'"';
12551 $resultat .=
' disabled';
12554 $resultat .= $labeltoshow;
12555 $resultat .=
'</option>';
12561 if (empty($option_only)) {
12562 $out .=
'</select>';
12567 $this->db->free($resql);
12570 $this->errors[] = $this->db->lasterror;
12586 public function searchComponent($arrayofcriterias, $search_component_params, $arrayofinputfieldsalreadyoutput = array(), $search_component_params_hidden =
'', $arrayoffiltercriterias = array())
12589 global $langs, $form;
12594 if ($search_component_params_hidden !=
'' && !preg_match(
'/^\(.*\)$/', $search_component_params_hidden)) {
12595 $search_component_params_hidden =
'(' . $search_component_params_hidden .
')';
12598 $ret =
'<!-- searchComponent -->';
12600 $ret .=
'<div class="divadvancedsearchfieldcomp centpercent inline-block">';
12601 $ret .=
'<a href="#" class="dropdownsearch-toggle unsetcolor">';
12602 $ret .=
'<span class="fas fa-filter linkobject boxfilter paddingright pictofixedwidth" title="' .
dol_escape_htmltag($langs->trans(
"Filters")) .
'" id="idsubimgproductdistribution"></span>';
12605 $ret .=
'<div class="divadvancedsearchfieldcompinput inline-block minwidth500 maxwidth300onsmartphone">';
12608 $ret .=
'<div id="divsearch_component_params" name="divsearch_component_params" class="noborderbottom search_component_params inline-block valignmiddle">';
12610 if ($search_component_params_hidden) {
12614 $arrayofandtags = dolForgeExplodeAnd($search_component_params_hidden);
12618 foreach ($arrayofandtags as $tmpkey => $tmpval) {
12619 $errormessage =
'';
12620 $searchtags = forgeSQLFromUniversalSearchCriteria($tmpval, $errormessage, 1, 1);
12621 if ($errormessage) {
12622 $this->error =
'ERROR in parsing search string: '.$errormessage;
12625 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
12628 $ret .=
'<span class="marginleftonlyshort valignmiddle tagsearch" data-ufilterid="'.($tmpkey + 1).
'" data-ufilter="'.
dol_escape_htmltag($tmpval).
'">';
12629 $ret .=
'<span class="tagsearchdelete select2-selection__choice__remove" data-ufilterid="'.($tmpkey + 1).
'">x</span> ';
12641 $show_search_component_params_hidden = 1;
12642 if ($show_search_component_params_hidden) {
12643 $ret .=
'<input type="hidden" name="show_search_component_params_hidden" value="1">';
12645 $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%')) -->";
12646 $ret .=
'<input type="hidden" id="search_component_params_hidden" name="search_component_params_hidden" value="' .
dol_escape_htmltag($search_component_params_hidden) .
'">';
12651 foreach ($arrayofcriterias as $criteria) {
12652 foreach ($criteria as $criteriafamilykey => $criteriafamilyval) {
12653 if (in_array(
'search_' . $criteriafamilykey, $arrayofinputfieldsalreadyoutput)) {
12656 if (in_array($criteriafamilykey, array(
'rowid',
'ref_ext',
'entity',
'extraparams'))) {
12659 if (in_array($criteriafamilyval[
'type'], array(
'date',
'datetime',
'timestamp'))) {
12660 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_start">';
12661 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startyear">';
12662 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startmonth">';
12663 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startday">';
12664 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_end">';
12665 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endyear">';
12666 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endmonth">';
12667 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endday">';
12669 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'">';
12676 $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";
12677 $ret .=
'<input type="text" placeholder="' . $langs->trans(
"Filters") .
'" id="search_component_params_input" name="search_component_params_input" class="noborderall search_component_input" value="">';
12683 jQuery(".tagsearchdelete").click(function(e) {
12684 var filterid = $(this).parents().attr("data-ufilterid");
12685 console.log("We click to delete the criteria nb "+filterid);
12687 // Regenerate the search_component_params_hidden with all data-ufilter except the one to delete, and post the page
12688 var newparamstring = \'\';
12689 $(\'.tagsearch\').each(function(index, element) {
12690 tmpfilterid = $(this).attr("data-ufilterid");
12691 if (tmpfilterid != filterid) {
12692 // We keep this criteria
12693 if (newparamstring == \'\') {
12694 newparamstring = $(this).attr("data-ufilter");
12696 newparamstring = newparamstring + \' AND \' + $(this).attr("data-ufilter");
12700 console.log("newparamstring = "+newparamstring);
12702 jQuery("#search_component_params_hidden").val(newparamstring);
12704 // We repost the form
12705 $(this).closest(\'form\').submit();
12708 jQuery("#search_component_params_input").keydown(function(e) {
12709 console.log("We press a key on the filter field that is "+jQuery("#search_component_params_input").val());
12710 console.log(e.which);
12711 if (jQuery("#search_component_params_input").val() == "" && e.which == 8) {
12712 /* We click on back when the input field is already empty */
12713 event.preventDefault();
12714 jQuery("#divsearch_component_params .tagsearch").last().remove();
12715 /* Regenerate content of search_component_params_hidden from remaining .tagsearch */
12717 jQuery("#divsearch_component_params .tagsearch").each(function( index ) {
12721 s = s + $(this).attr("data-ufilter");
12723 console.log("New value for search_component_params_hidden = "+s);
12724 jQuery("#search_component_params_hidden").val(s);
12732 $arrayoffiltercriterias_json = json_encode($arrayoffiltercriterias);
12734 var arrayoffiltercriterias = ' . $arrayoffiltercriterias_json .
';
12738 $arrayoffilterfieldslabel = array();
12739 foreach ($arrayoffiltercriterias as $key => $val) {
12740 $arrayoffilterfieldslabel[$key][
'label'] = $val[
'label'];
12741 $arrayoffilterfieldslabel[$key][
'data-type'] = $val[
'type'];
12745 $ret .=
'<div class="search-component-assistance">';
12748 $ret .=
'<p class="assistance-title">' .
img_picto(
'',
'filter') .
' ' . $langs->trans(
'FilterAssistance') .
' </p>';
12750 $ret .=
'<p class="assistance-errors error" style="display:none">' . $langs->trans(
'AllFieldsRequired') .
' </p>';
12752 $ret .=
'<div class="operand">';
12753 $ret .= $form->selectarray(
'search_filter_field', $arrayoffilterfieldslabel,
'', $langs->trans(
"Fields"), 0, 0,
'', 0, 0, 0,
'',
'width200 combolargeelem', 1);
12756 $ret .=
'<span class="separator"></span>';
12759 $ret .=
'<div class="operator">';
12760 $ret .=
'<select class="operator-selector width150" id="operator-selector"">';
12761 $ret .=
'</select>';
12762 $ret .=
'<script>$(document).ready(function() {';
12763 $ret .=
' $(".operator-selector").select2({';
12764 $ret .=
' placeholder: \'' .
dol_escape_js($langs->transnoentitiesnoconv(
'Operator')) .
'\'';
12766 $ret .=
'});</script>';
12769 $ret .=
'<span class="separator"></span>';
12771 $ret .=
'<div class="value">';
12773 $ret .=
'<input type="text" class="flat width100 value-input" placeholder="' .
dolPrintHTML($langs->trans(
'Value')) .
'">';
12777 $ret .=
'<span class="date-one" style="display:none">';
12778 $ret .= $form->selectDate(($dateOne ? $dateOne : -1),
'dateone', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'');
12782 $ret .=
'<select class="value-selector width150" id="value-selector" style="display:none">';
12783 $ret .=
'</select>';
12785 $(document).ready(function() {
12786 $("#value-selector").select2({
12787 placeholder: "' .
dol_escape_js($langs->trans(
'Value')) .
'"
12789 $("#value-selector").hide();
12790 $("#value-selector").next(".select2-container").hide();
12796 $ret .=
'<div class="btn-div">';
12797 $ret .=
'<button class="button buttongen button-save add-filter-btn" type="button">' . $langs->trans(
"addToFilter") .
'</button>';
12808 $(document).ready(function() {
12809 $("#search_component_params_input").on("click", function() {
12810 const inputPosition = $(this).offset();
12811 const inputHeight = $(this).outerHeight();
12812 $(".search-component-assistance").css({
12813 top: inputPosition.top + inputHeight + 5 + "px",
12814 left: $("#divsearch_component_params").position().left
12815 }).slideToggle(200);
12817 $(document).on("click", function(e) {
12818 if (!$(e.target).closest("#search_component_params_input, .search-component-assistance, #ui-datepicker-div").length) {
12819 $(".search-component-assistance").hide();
12826 $(document).ready(function() {
12827 $(".search_filter_field").on("change", function() {
12828 console.log("We change search_filter_field");
12831 const selectedField = $(this).find(":selected");
12832 let fieldType = selectedField.data("type");
12833 const selectedFieldValue = selectedField.val();
12835 // If the selected field has an array of values then ask toshow the value selector instead of the value input
12836 if (arrayoffiltercriterias[selectedFieldValue]["arrayofkeyval"] !== undefined) {
12837 fieldType = "select";
12840 // If the selected field may be null then ask to append the "IsDefined" and "IsNotDefined" operators
12841 if (arrayoffiltercriterias[selectedFieldValue]["maybenull"] !== undefined) {
12844 const operators = getOperatorsForFieldType(fieldType, maybenull);
12845 const operatorSelector = $(".operator-selector");
12847 // Clear existing options
12848 operatorSelector.empty();
12850 // Populate operators
12851 Object.entries(operators).forEach(function([operator, label]) {
12852 operatorSelector.append("<option value=\'" + operator + "\'>" + label + "</option>");
12855 operatorSelector.trigger("change.select2");
12857 // Clear and hide all input elements initially
12858 $(".value-input, .dateone, .datemonth, .dateyear").val("").hide();
12859 $("#datemonth, #dateyear").val(null).trigger("change.select2");
12860 $("#dateone").datepicker("setDate", null);
12861 $(".date-one, .date-month, .date-year").hide();
12862 $("#value-selector").val("").hide();
12863 $("#value-selector").next(".select2-container").hide();
12864 $("#value-selector").val(null).trigger("change.select2");
12866 if (fieldType === "date" || fieldType === "datetime" || fieldType === "timestamp") {
12867 $(".date-one").show();
12868 } else if (arrayoffiltercriterias[selectedFieldValue]["arrayofkeyval"] !== undefined) {
12869 var arrayofkeyval = arrayoffiltercriterias[selectedFieldValue]["arrayofkeyval"];
12870 var valueSelector = $("#value-selector");
12871 valueSelector.empty();
12872 Object.entries(arrayofkeyval).forEach(function([key, val]) {
12873 valueSelector.append("<option value=\'" + key + "\'>" + val + "</option>");
12875 valueSelector.trigger("change.select2");
12877 $("#value-selector").show();
12878 $("#value-selector").next(".select2-container").show();
12880 $(".value-input").show();
12884 $("#operator-selector").on("change", function() {
12885 console.log("We change operator-selector");
12887 const selectedOperator = $(this).find(":selected").val();
12888 if (selectedOperator === "IsDefined" || selectedOperator === "IsNotDefined") {
12889 // Disable all value input elements
12890 $(".value-input, .dateone, .datemonth, .dateyear").val("").prop("disabled", true);
12891 $("#datemonth, #dateyear").val(null).trigger("change.select2");
12892 $("#dateone").datepicker("setDate", null).datepicker("option", "disabled", true);
12893 $(".date-one, .date-month, .date-year").prop("disabled", true);
12894 $("#value-selector").val("").prop("disabled", true);
12895 $("#value-selector").val(null).trigger("change.select2");
12897 // Enable all value input elements
12898 $(".value-input, .dateone, .datemonth, .dateyear").prop("disabled", false);
12899 $(".date-one, .date-month, .date-year").prop("disabled", false);
12900 $("#dateone").datepicker("option", "disabled", false);
12901 $("#value-selector").prop("disabled", false);
12905 $(".add-filter-btn").on("click", function(event) {
12906 console.log("We click on add-filter-btn");
12908 event.preventDefault();
12910 const field = $(".search_filter_field").val();
12911 const operator = $(".operator-selector").val();
12912 let value = $(".value-input").val();
12913 const fieldType = $(".search_filter_field").find(":selected").data("type");
12915 if (["date", "datetime", "timestamp"].includes(fieldType)) {
12916 const year = $("#dateoneyear").val().toString().padStart(4, "0");;
12917 const month = $("#dateonemonth").val().toString().padStart(2, "0");
12918 const day = $("#dateoneday").val().toString().padStart(2, "0");
12919 value = `${year}-${month}-${day}`;
12920 console.log("value="+value);
12923 // If the selected field has an array of values then take the selected value
12924 if (arrayoffiltercriterias[field]["arrayofkeyval"] !== undefined) {
12925 value = $("#value-selector").val();
12928 // If the operator is "IsDefined" or "IsNotDefined" then set the value to 1 (it will not be used)
12929 if (operator === "IsDefined" || operator === "IsNotDefined") {
12933 const filterString = generateFilterString(field, operator, value, fieldType);
12936 if (filterString !== "" && field !== "" && operator !== "" && value !== "") {
12937 $("#search_component_params_input").val($("#search_component_params_input").val() + " " + filterString);
12938 $("#search_component_params_input").closest("form").submit();
12940 $(".assistance-errors").show();
12960 public function selectModelMail($prefix, $modelType =
'', $default = 0, $addjscombo = 0, $selected = 0, $morecss =
'')
12962 global $langs, $user;
12966 $TModels = array();
12968 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
12969 $formmail =
new FormMail($this->db);
12970 $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs);
12973 $TModels[0] = $langs->trans(
'DefaultMailModel');
12976 foreach ($formmail->lines_model as $model) {
12977 $TModels[(int) $model->id] = $model->label;
12981 $retstring .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" id="select_' . $prefix .
'model_mail" name="' . $prefix .
'model_mail">';
12983 foreach ($TModels as $id_model => $label_model) {
12984 $retstring .=
'<option value="' . $id_model .
'"';
12985 if (!empty($selected) && ((int) $selected) == $id_model) {
12986 $retstring .=
"selected";
12988 $retstring .=
">" . $label_model .
"</option>";
12991 $retstring .=
"</select>";
12994 $retstring .=
ajax_combobox(
'select_' . $prefix .
'model_mail');
13011 public function buttonsSaveCancel($save_label =
'Save', $cancel_label =
'Cancel', $morebuttons = array(), $withoutdiv =
false, $morecss =
'', $dol_openinpopup =
'')
13015 $buttons = array();
13019 'label_key' => $save_label,
13022 if ($save_label ==
'Create' || $save_label ==
'Add') {
13023 $save[
'name'] =
'add';
13024 } elseif ($save_label ==
'Modify') {
13025 $save[
'name'] =
'edit';
13029 'name' =>
'cancel',
13030 'label_key' =>
'Cancel',
13035 !empty($save_label) ? $buttons[] = $save :
'';
13036 if (!empty($morebuttons)) {
13037 $buttons[] = $morebuttons;
13039 !empty($cancel_label) ? $buttons[] = $cancel :
'';
13041 if (!empty($morebuttons)) {
13042 $buttons[] = $morebuttons;
13044 !empty($cancel_label) ? $buttons[] = $cancel :
'';
13045 !empty($save_label) ? $buttons[] = $save :
'';
13048 $retstring = $withoutdiv ?
'' :
'<div class="center">';
13050 foreach ($buttons as $button) {
13051 $addclass = empty($button[
'addclass']) ?
'' : $button[
'addclass'];
13052 $retstring .=
'<input type="submit" class="button marginleftonly marginrightonly button-' . $button[
'name'] . ($morecss ?
' ' . $morecss :
'') .
' ' . $addclass .
'" name="' . $button[
'name'] .
'" value="' .
dol_escape_htmltag($langs->transnoentities($button[
'label_key'])) .
'">';
13054 $retstring .= $withoutdiv ?
'' :
'</div>';
13056 if ($dol_openinpopup) {
13057 $retstring .=
'<!-- buttons are shown into a $dol_openinpopup=' .
dol_escape_htmltag($dol_openinpopup) .
' context, so we enable the close of dialog on cancel -->' .
"\n";
13058 $retstring .=
'<script nonce="' . getNonce() .
'">';
13059 $retstring .=
'jQuery(".button-cancel").click(function(e) {
13060 e.preventDefault(); console.log(\'We click on cancel in iframe popup ' .
dol_escape_js($dol_openinpopup) .
'\');
13061 window.parent.jQuery(\
'#idfordialog' .
dol_escape_js($dol_openinpopup) .
'\').dialog(\
'close\');
13063 $retstring .=
'</script>';
13082 $num = count($this->cache_invoice_subtype);
13089 $sql =
"SELECT rowid, code, label as label";
13090 $sql .=
" FROM " . MAIN_DB_PREFIX .
'c_invoice_subtype';
13091 $sql .=
" WHERE active = 1";
13093 $resql = $this->db->query($sql);
13095 $num = $this->db->num_rows($resql);
13097 while ($i < $num) {
13098 $obj = $this->db->fetch_object($resql);
13101 $label = ($langs->trans(
"InvoiceSubtype" . $obj->rowid) !=
"InvoiceSubtype" . $obj->rowid) ? $langs->trans(
"InvoiceSubtype" . $obj->rowid) : (($obj->label !=
'-') ? $obj->label :
'');
13102 $this->cache_invoice_subtype[$obj->rowid][
'rowid'] = $obj->rowid;
13103 $this->cache_invoice_subtype[$obj->rowid][
'code'] = $obj->code;
13104 $this->cache_invoice_subtype[$obj->rowid][
'label'] = $label;
13108 $this->cache_invoice_subtype =
dol_sort_array($this->cache_invoice_subtype,
'code',
'asc', 0, 0, 1);
13130 global $langs, $user;
13133 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
13135 $this->load_cache_invoice_subtype();
13137 $out .=
'<select id="' . $htmlname .
'" class="flat selectsubtype' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
13139 $out .=
'<option value="0"> </option>';
13142 foreach ($this->cache_invoice_subtype as $rowid => $subtype) {
13143 $label = $subtype[
'label'];
13144 $out .=
'<option value="' . $subtype[
'rowid'] .
'"';
13145 if ($selected == $subtype[
'rowid']) {
13146 $out .=
' selected="selected"';
13150 $out .=
'</option>';
13153 $out .=
'</select>';
13154 if ($user->admin && empty($noinfoadmin)) {
13155 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
13176 'type' =>
'search',
13177 'name' => $htmlName,
13179 'class' =>
"search-tool-input",
13180 'placeholder' => $langs->trans(
'Search'),
13181 'autocomplete' =>
'off'
13189 if ($dataTarget !==
false) {
13190 $attr[
'data-search-tool-target'] = $dataTarget;
13194 if (!empty($params[
'attr']) && is_array($params[
'attr'])) {
13195 foreach ($params[
'attr'] as $key => $value) {
13196 if ($key ==
'class') {
13197 $attr[
'class'] .=
' '.$value;
13198 } elseif ($key ==
'classOverride') {
13199 $attr[
'class'] = $value;
13201 $attr[$key] = $value;
13207 if (!empty($attr[
'title']) && !empty($attr[
'class']) && strpos($attr[
'class'],
'classfortooltip') ===
false) {
13208 $attr[
'class'] .=
' classfortooltip';
13211 $TCompiledAttr = [];
13212 foreach ($attr as $key => $value) {
13213 if (in_array($key, [
'data-target'])
13214 || (!empty($params[
'use_unsecured_unescapedattr']) && is_array($params[
'use_unsecured_unescapedattr']) && in_array($key, $params[
'use_unsecured_unescapedattr']))) {
13220 $TCompiledAttr[] = $key .
'="' . $value .
'"';
13223 $compiledAttributes = implode(
' ', $TCompiledAttr);
13226 return '<div class="search-tool-container"><input '.$compiledAttributes.
'></div>';
13242 public function inputType($type, $name, $value =
'',
$id =
'', $morecss =
'', $moreparam =
'', $label =
'', $addInputLabel =
'')
13245 if ($label !=
'') {
13255 $out .= ($moreparam ?
' ' . $moreparam :
'');
13256 $out .=
' />' . $addInputLabel;
13257 if ($label !=
'') {
13258 $out .= $label .
'</label>';
13276 public function inputSelectAjax($htmlName, $array,
$id, $ajaxUrl, $ajaxData = [], $morecss =
'minwidth75', $moreparam =
'')
13280 $(document).ready(function () {
13281 $('#" . $htmlName .
"').select2({
13283 url: '" . $ajaxUrl .
"',
13285 delay: 250, // wait 250 milliseconds before triggering the request
13286 data: function (params) {
13288 search: params.term,
13289 page: params.page || 1";
13290 if (!empty($ajaxData) && is_array($ajaxData)) {
13291 foreach ($ajaxData as $key => $value) {
13292 $out .=
", " . $key .
": '" . $value .
"'";
13304 $out .= $this->selectarray($htmlName, $array,
$id, 0, 0, 0, $moreparam, 0, 0, 0,
'', $morecss);
13318 public function inputHtml($htmlName, $value, $morecss =
'', $moreparam =
'')
13320 require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
13321 $doleditor =
new DolEditor($htmlName, $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
isModEnabled(
'fckeditor') &&
getDolGlobalInt(
'FCKEDITOR_ENABLE_SOCIETE'), ROWS_5,
'90%');
13323 return (
string) $doleditor->Create(1,
'',
true,
'',
'', $moreparam, $morecss);
13336 public function inputText($htmlName, $value, $morecss =
'', $moreparam =
'', $options = array())
13341 if (!empty($options)) {
13343 $out .= $this->selectarray($htmlName .
"_multiinput", $options,
'', 1, 0, 0, $moreparam, 0, 0, 0,
'',
"flat maxwidthonphone" . $morecss);
13344 $out .=
'<input id="' . $htmlName .
'_multiinputadd" type="button" class="button" value="' . $langs->trans(
"Add") .
'">';
13345 $out .=
"<script>";
13347 function handlemultiinputdisabling(htmlname){
13348 console.log("We handle the disabling of used options for "+htmlname+"_multiinput");
13349 multiinput = $("#"+htmlname+"_multiinput");
13350 multiinput.find("option").each(function(){
13351 tmpval = $("#"+htmlname).val();
13352 tmpvalarray = tmpval.split("\n");
13353 valtotest = $(this).val();
13354 if(tmpvalarray.includes(valtotest)){
13355 $(this).prop("disabled",true);
13357 if($(this).prop("disabled") == true){
13358 console.log(valtotest)
13359 $(this).prop("disabled", false);
13365 $(document).ready(function () {
13366 $("#' . $htmlName .
'_multiinputadd").on("click",function() {
13367 tmpval = $("#' . $htmlName .
'").val();
13368 tmpvalarray = tmpval.split(",");
13369 valtotest = $("#' . $htmlName .
'_multiinput").val();
13370 if(valtotest != -1 && !tmpvalarray.includes(valtotest)){
13371 console.log("We add the selected value to the text area ' . $htmlName .
'");
13373 tmpval = valtotest;
13375 tmpval = tmpval + "\n" + valtotest;
13377 $("#' . $htmlName .
'").val(tmpval);
13378 handlemultiinputdisabling("' . $htmlName .
'");
13379 $("#' . $htmlName .
'_multiinput").val(-1);
13381 console.log("We add nothing the text area ' . $htmlName .
'");
13384 $("#' . $htmlName .
'").on("change",function(){
13385 handlemultiinputdisabling("' . $htmlName .
'");
13387 handlemultiinputdisabling("' . $htmlName .
'");
13389 $out .=
"</script>";
13390 $value = str_replace(
',',
"\n", $value);
13393 require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
13394 $doleditor =
new DolEditor($htmlName, (
string) $value,
'', 200,
'dolibarr_notes',
'In',
false,
false,
false, ROWS_5,
'90%');
13395 $out .= (
string) $doleditor->Create(1,
'',
true,
'',
'', $moreparam, $morecss);
13410 public function inputRadio($htmlName, $options, $selectedValue, $morecss =
'', $moreparam =
'')
13413 foreach ($options as $optionKey => $optionLabel) {
13414 $selected = ((
string) $selectedValue) === ((
string) $optionKey) ?
' checked="checked"' :
'';
13415 $optionId = $htmlName .
'_' . $optionKey;
13416 $out .=
'<input class="flat' . $morecss .
'" type="radio" name="' . $htmlName .
'" id="' . $optionId .
'" value="' .
dolPrintHTMLForAttribute((
string) $optionKey) .
'"' . $selected . $moreparam .
'/><label for="' . $optionId .
'">' . $optionLabel .
'</label><br>';
13432 public function inputStars($htmlName, $size, $value, $morecss =
'', $moreparam =
'')
13434 $out =
'<input type="hidden" class="flat ' . $morecss .
'" name="' . $htmlName .
'" id="' . $htmlName .
'" value="' .
dolPrintHTMLForAttribute((
string) $value) .
'"' . $moreparam .
'>';
13435 $out .=
'<div class="star-selection" id="' . $htmlName .
'_selection">';
13436 for ($i = 1; $i <= $size; $i++) {
13437 $out .=
'<span class="star" data-value="' . $i .
'">' .
img_picto(
'',
'fontawesome_star_fas') .
'</span>';
13441 jQuery(function($) { /* commonobject.class.php 1 */
13442 let container = $("#' . $htmlName .
'_selection");
13443 let selectedStars = parseInt($("#' . $htmlName .
'").val()) || 0;
13444 container.find(".star").each(function() {
13445 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
13447 container.find(".star").on("mouseover", function() {
13448 let selectedStar = $(this).data("value");
13449 container.find(".star").each(function() {
13450 $(this).toggleClass("active", $(this).data("value") <= selectedStar);
13453 container.on("mouseout", function() {
13454 container.find(".star").each(function() {
13455 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
13458 container.find(".star").off("click").on("click", function() {
13459 selectedStars = $(this).data("value");
13460 if (selectedStars === 1 && $("#' . $htmlName .
'").val() == 1) {
13463 $("#' . $htmlName .
'").val(selectedStars);
13464 container.find(".star").each(function() {
13465 $(this).toggleClass("active", $(this).data("value") <= selectedStars);
13483 public function inputIcon($htmlName, $value, $morecss =
'', $moreparam =
'')
13492 $out =
'<input type="text" class="form-control icp icp-auto iconpicker-element iconpicker-input flat ' . $morecss .
' maxwidthonsmartphone"';
13493 $out .=
' name="' . $htmlName .
'" id="' . $htmlName .
'" value="' .
dolPrintHTMLForAttribute((
string) $value) .
'" ' . ((
string) $moreparam) .
'>';
13495 $out .=
'<script>';
13496 $options =
"{ title: '<b>" . $langs->trans(
"IconFieldSelector") .
"</b>', placement: 'right', showFooter: false, templates: {";
13497 $options .=
"iconpicker: '<div class=\"iconpicker\"><div style=\"background-color:#EFEFEF;\" class=\"iconpicker-items\"></div></div>',";
13498 $options .=
"iconpickerItem: '<a role=\"button\" href=\"#\" class=\"iconpicker-item\" style=\"background-color:#DDDDDD;\"><i></i></a>',";
13501 $options .=
"footer: '<div class=\"popover-footer\" style=\"background-color:#EFEFEF;\"></div>',";
13502 $options .=
"search: '<input type=\"search\" class\"form-control iconpicker-search\" placeholder=\"" . $langs->trans(
"TypeToFilter") .
"\" />',";
13503 $options .=
"popover: '<div class=\"iconpicker-popover popover\">";
13504 $options .=
" <div class=\"arrow\" ></div>";
13505 $options .=
" <div class=\"popover-title\" style=\"text-align:center;background-color:#EFEFEF;\"></div>";
13506 $options .=
" <div class=\"popover-content \" ></div>";
13507 $options .=
"</div>'}}";
13508 $out .=
"$('#" . $htmlName .
"').iconpicker(" . $options .
");";
13509 $out .=
'</script>';
13525 require_once DOL_DOCUMENT_ROOT .
'/core/class/dolgeophp.class.php';
13526 require_once DOL_DOCUMENT_ROOT .
'/core/class/geomapeditor.class.php';
13532 if (!empty($value)) {
13533 $tmparray = $dolgeophp->parseGeoString($value);
13534 $geojson = $tmparray[
'geojson'];
13535 $centroidjson = $tmparray[
'centroidjson'];
13538 return $geomapeditor->getHtml($htmlName, $geojson, $centroidjson, $type);
13550 $toPrint = array();
13551 $values = is_array($values) ? $values : array();
13553 foreach ($values as $value) {
13554 $toPrint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $value .
'</li>';
13556 if (!empty($toPrint)) {
13557 $out =
'<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(
' ', $toPrint) .
'</ul></div>';
13573 for ($i = 1; $i <= $size; $i++) {
13574 $out .=
'<span class="star' . ($i <= $value ?
' active' :
'') .
'" data-value="' . $i .
'">' .
img_picto(
'',
'fontawesome_star_fas') .
'</span>';
13605 if (!empty($value)) {
13606 require_once DOL_DOCUMENT_ROOT .
'/core/class/dolgeophp.class.php';
13608 if ($type ==
'point') {
13609 $out = $dolgeophp->getXYString($value);
13611 $out = $dolgeophp->getPointString($value);
13632 public function getNomUrl(&
$object, $withpicto = 0, $option =
'', $maxlength = 0, $save_lastsearch_value = -1, $notooltip = 0, $morecss =
'', $add_label = 0, $sep =
' - ')
13634 if (is_object(
$object) && method_exists(
$object,
'getNomUrl')) {
13635 $out =
$object->getNomUrl($withpicto, $option, $maxlength, $save_lastsearch_value, $notooltip, $morecss, $add_label, $sep);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
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 members of a foundation.
Class to manage categories.
Class to manage bank accounts description of third parties.
Class for ConferenceOrBoothAttendee.
Class to manage a WYSIWYG editor.
Class to manage Geo processing Usage: $dolgeophp=new DolGeoPHP($db);.
Class to manage ECM files.
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 manage invoice templates.
Class to manage a Leaflet map width geometrics objects.
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 subscriptions of foundation members.
Class to manage translations.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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_now($mode='gmt')
Return date for now.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
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.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
dol_print_phone($phone, $countrycode='', $contactid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='paddingright')
Format phone numbers according to country.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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.
getDolUserString($key, $default='', $tmpuser=null)
Return Dolibarr user constant string value.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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_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...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea'), $cleanalsosomestyles=0)
Clean a string from some undesirable HTML tags.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
dol_print_email($email, $contactid=0, $socid=0, $addlink=0, $max=0, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
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 links.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0, $allowscript=0, $allowstyle=0, $allowphp=0)
Clean a string to keep only desirable HTML tags.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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_nboflines_bis($text, $maxlinesize=0, $charset='UTF-8')
Return nb of lines of a formatted text with and (WARNING: string must not have mixed and br sep...
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...
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
Class to generate the form for creating a new ticket.
dol_get_trunk_prefix($db, $phone_code)
Get the national trunk prefix for a phone code.
dol_parse_phone($phone)
Parse a stored phone number into country code and number parts.
dol_get_phone_code_from_country($db, $country_id)
Get the phone calling code for a country.
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
$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, $mode=0)
Returns a hash (non reversible encryption) of a string.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.
testSqlAndScriptInject($val, $type)
Security: WAF layer for SQL Injection and XSS Injection (scripts) protection (Filters on GET,...