71 public $errors = array();
80 public $cache_types_paiements = array();
81 public $cache_conditions_paiements = array();
82 public $cache_transport_mode = array();
83 public $cache_availability = array();
84 public $cache_demand_reason = array();
85 public $cache_types_fees = array();
86 public $cache_vatrates = array();
87 public $cache_invoice_subtype = array();
116 public function editfieldkey($text, $htmlname, $preselected,
$object, $perm, $typeofdata =
'string', $moreparam =
'', $fieldrequired = 0, $notabletag = 0, $paramid =
'id', $help =
'')
123 if (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE') && !preg_match(
'/^select;/', $typeofdata)) {
125 $tmp = explode(
':', $typeofdata);
126 $ret .=
'<div class="editkey_' . $tmp[0] . (!empty($tmp[1]) ?
' ' . $tmp[1] :
'') .
'" id="' . $htmlname .
'">';
127 if ($fieldrequired) {
128 $ret .=
'<span class="fieldrequired">';
133 $ret .= $langs->trans($text);
135 if ($fieldrequired) {
138 $ret .=
'</div>' .
"\n";
140 if ($fieldrequired) {
141 $ret .=
'<span class="fieldrequired">';
146 $ret .= $langs->trans($text);
148 if ($fieldrequired) {
153 if (empty($notabletag) && $perm) {
154 $ret .=
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
156 if ($fieldrequired) {
157 $ret .=
'<span class="fieldrequired">';
162 $ret .= $langs->trans($text);
164 if ($fieldrequired) {
167 if (!empty($notabletag)) {
170 if (empty($notabletag) && $perm) {
173 if (empty($notabletag) && $perm) {
174 $ret .=
'<td class="right">';
176 if ($htmlname &&
GETPOST(
'action',
'aZ09') !=
'edit' . $htmlname && $perm) {
177 $ret .=
'<a class="editfielda reposition" href="' . $_SERVER[
"PHP_SELF"] .
'?action=edit' . $htmlname .
'&token=' .
newToken() .
'&' . $paramid .
'=' .
$object->id . $moreparam .
'">' .
img_edit($langs->trans(
'Edit'), ($notabletag ? 0 : 1)) .
'</a>';
179 if (!empty($notabletag) && $notabletag == 1) {
186 if (!empty($notabletag) && $notabletag == 3) {
189 if (empty($notabletag) && $perm) {
192 if (empty($notabletag) && $perm) {
193 $ret .=
'</tr></table>';
223 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 =
'')
225 global $conf, $langs;
230 if (empty($typeofdata)) {
231 return 'ErrorBadParameter typeofdata is empty';
234 if ($typeofdata ==
'datetime') {
235 $typeofdata =
'dayhour';
238 if (preg_match(
'/^(\w+)\((\d+)\)$/', $typeofdata, $reg)) {
239 if ($reg[1] ==
'varchar') {
240 $typeofdata =
'string';
241 } elseif ($reg[1] ==
'int') {
242 $typeofdata =
'numeric';
244 return 'ErrorBadParameter ' . $typeofdata;
249 if (
getDolGlobalString(
'MAIN_USE_JQUERY_JEDITABLE') && !preg_match(
'/^select;|day|datepicker|dayhour|datehourpicker/', $typeofdata)) {
250 $ret .= $this->
editInPlace(
$object, $value, $htmlname, ($perm ? 1 : 0), $typeofdata, $editvalue, $extObject, $custommsg);
252 if ($editaction ==
'') {
253 $editaction =
GETPOST(
'action',
'aZ09');
255 $editmode = ($editaction ==
'edit' . $htmlname);
257 $ret .=
"<!-- formeditfieldval -->\n";
258 $ret .=
'<form method="post" action="' . $_SERVER[
"PHP_SELF"] . ($moreparam ?
'?' . $moreparam :
'') .
'">';
259 $ret .=
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
260 $ret .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
261 $ret .=
'<input type="hidden" name="' . $paramid .
'" value="' .
$object->id .
'">';
262 if (empty($notabletag)) {
263 $ret .=
'<table class="nobordernopadding centpercent">';
265 if (empty($notabletag)) {
268 if (preg_match(
'/^(string|safehtmlstring|email|phone|url)/', $typeofdata)) {
269 $tmp = explode(
':', $typeofdata);
270 $ret .=
'<input type="text" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . ($editvalue ? $editvalue : $value) .
'"' . (empty($tmp[1]) ?
'' :
' size="' . $tmp[1] .
'"') .
' autofocus>';
271 } elseif (preg_match(
'/^(integer)/', $typeofdata)) {
272 $tmp = explode(
':', $typeofdata);
273 $valuetoshow =
price2num($editvalue ? $editvalue : $value, 0);
274 $ret .=
'<input type="text" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $valuetoshow .
'"' . (empty($tmp[1]) ?
'' :
' size="' . $tmp[1] .
'"') .
' autofocus>';
275 } elseif (preg_match(
'/^(numeric|amount)/', $typeofdata)) {
276 $tmp = explode(
':', $typeofdata);
277 $valuetoshow =
price2num($editvalue ? $editvalue : $value);
278 $ret .=
'<input type="text" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . ($valuetoshow !=
'' ?
price($valuetoshow) :
'') .
'"' . (empty($tmp[1]) ?
'' :
' size="' . $tmp[1] .
'"') .
' autofocus>';
279 } elseif (preg_match(
'/^(checkbox)/', $typeofdata)) {
280 $tmp = explode(
':', $typeofdata);
281 $ret .=
'<input type="checkbox" id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . ($value ? $value :
'on') .
'"' . ($value ?
' checked' :
'') . (empty($tmp[1]) ?
'' : $tmp[1]) .
'/>';
282 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) {
283 $tmp = explode(
':', $typeofdata);
284 $cols = (empty($tmp[2]) ?
'' : $tmp[2]);
286 if (preg_match(
'/%/', $cols)) {
287 $morealt =
' style="width: ' . $cols .
'"';
290 $valuetoshow = ($editvalue ? $editvalue : $value);
291 $ret .=
'<textarea id="' . $htmlname .
'" name="' . $htmlname .
'" wrap="soft" rows="' . (empty($tmp[1]) ?
'20' : $tmp[1]) .
'"' . ($cols ?
' cols="' . $cols .
'"' :
'class="quatrevingtpercent"') . $morealt .
'" autofocus>';
294 $valuetoshow = str_replace(
'&',
'&', $valuetoshow);
296 $ret .=
'</textarea><div class="clearboth"></div>';
297 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') {
298 $addnowlink = empty($moreoptions[
'addnowlink']) ? 0 : $moreoptions[
'addnowlink'];
299 $adddateof = empty($moreoptions[
'adddateof']) ?
'' : $moreoptions[
'adddateof'];
300 $labeladddateof = empty($moreoptions[
'labeladddateof']) ?
'' : $moreoptions[
'labeladddateof'];
301 $ret .= $this->
selectDate($value, $htmlname, 0, 0, 1,
'form' . $htmlname, 1, $addnowlink, 0,
'',
'', $adddateof,
'', 1, $labeladddateof,
'', $gm);
302 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') {
303 $addnowlink = empty($moreoptions[
'addnowlink']) ? 0 : $moreoptions[
'addnowlink'];
304 $adddateof = empty($moreoptions[
'adddateof']) ?
'' : $moreoptions[
'adddateof'];
305 $labeladddateof = empty($moreoptions[
'labeladddateof']) ?
'' : $moreoptions[
'labeladddateof'];
306 $ret .= $this->
selectDate($value, $htmlname, 1, 1, 1,
'form' . $htmlname, 1, $addnowlink, 0,
'',
'', $adddateof,
'', 1, $labeladddateof,
'', $gm);
307 } elseif (preg_match(
'/^select;/', $typeofdata)) {
308 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
309 $arraylist = array();
310 foreach ($arraydata as $val) {
311 $tmp = explode(
':', $val);
312 $tmpkey = str_replace(
'|',
':', $tmp[0]);
313 $arraylist[$tmpkey] = $tmp[1];
315 $ret .= $this->
selectarray($htmlname, $arraylist, $value);
316 } elseif (preg_match(
'/^link/', $typeofdata)) {
318 } elseif (preg_match(
'/^ckeditor/', $typeofdata)) {
319 $tmp = explode(
':', $typeofdata);
320 require_once DOL_DOCUMENT_ROOT .
'/core/class/doleditor.class.php';
321 $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]));
322 $ret .= $doleditor->Create(1);
323 } elseif ($typeofdata ==
'asis') {
324 $ret .= ($editvalue ? $editvalue : $value);
326 if (empty($notabletag)) {
331 if (empty($notabletag)) {
335 $ret .=
'<input type="submit" class="smallpaddingimp nomargingtop nomarginbottom button' . (empty($notabletag) ?
'' :
' ') .
'" name="modify" value="' . $langs->trans(
"Modify") .
'">';
336 if (preg_match(
'/ckeditor|textarea/', $typeofdata) && empty($notabletag)) {
337 $ret .=
'<br>' .
"\n";
339 $ret .=
'<input type="submit" class="smallpaddingimp nomargingtop nomarginbottom button button-cancel' . (empty($notabletag) ?
'' :
' ') .
'" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
340 if (empty($notabletag)) {
344 if (empty($notabletag)) {
345 $ret .=
'</tr></table>' .
"\n";
347 $ret .=
'</form>' .
"\n";
349 if (preg_match(
'/^email/', $typeofdata)) {
351 } elseif (preg_match(
'/^phone/', $typeofdata)) {
353 } elseif (preg_match(
'/^url/', $typeofdata)) {
355 } elseif (preg_match(
'/^(amount|numeric)/', $typeofdata)) {
356 $ret .= ($value !=
'' ?
price($value, 0, $langs, 0, -1, -1, $conf->currency) :
'');
357 } elseif (preg_match(
'/^checkbox/', $typeofdata)) {
358 $tmp = explode(
':', $typeofdata);
359 $ret .=
'<input type="checkbox" disabled id="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $value .
'"' . ($value ?
' checked' :
'') . ($tmp[1] ? $tmp[1] :
'') .
'/>';
360 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) {
362 } elseif (preg_match(
'/^(safehtmlstring|restricthtml)/', $typeofdata)) {
364 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') {
365 $ret .=
'<span class="valuedate">' .
dol_print_date($value,
'day', $gm) .
'</span>';
366 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') {
367 $ret .=
'<span class="valuedate">' .
dol_print_date($value,
'dayhour', $gm) .
'</span>';
368 } elseif (preg_match(
'/^select;/', $typeofdata)) {
369 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
370 $arraylist = array();
371 foreach ($arraydata as $val) {
372 $tmp = explode(
':', $val);
373 $arraylist[$tmp[0]] = $tmp[1];
375 $ret .= $arraylist[$value];
376 if ($htmlname ==
'fk_product_type') {
378 $ret =
img_picto($langs->trans(
"Product"),
'product',
'class="paddingleftonly paddingrightonly colorgrey"') . $ret;
380 $ret =
img_picto($langs->trans(
"Service"),
'service',
'class="paddingleftonly paddingrightonly colorgrey"') . $ret;
383 } elseif (preg_match(
'/^ckeditor/', $typeofdata)) {
386 $firstline = preg_replace(
'/<br>.*/',
'', $tmpcontent);
387 $firstline = preg_replace(
'/[\n\r].*/',
'', $firstline);
388 $tmpcontent = $firstline . ((strlen($firstline) != strlen($tmpcontent)) ?
'...' :
'');
394 if (empty($moreoptions[
'valuealreadyhtmlescaped'])) {
402 if ($formatfunc && method_exists(
$object, $formatfunc)) {
403 $ret =
$object->$formatfunc($ret);
423 global $conf, $langs, $extralanguages;
428 $arrayoflangcode = array();
433 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
434 if (!is_object($extralanguages)) {
435 include_once DOL_DOCUMENT_ROOT .
'/core/class/extralanguages.class.php';
438 $extralanguages->fetch_name_extralanguages(
'societe');
440 if (!is_array($extralanguages->attributes[
$object->element]) || empty($extralanguages->attributes[
$object->element][$fieldname])) {
444 $result .=
'<!-- Widget for translation -->' .
"\n";
445 $result .=
'<div class="inline-block paddingleft image-' .
$object->element .
'-' . $fieldname .
'">';
446 $s =
img_picto($langs->trans(
"ShowOtherLanguages"),
'language',
'', 0, 0, 0,
'',
'fa-15 editfieldlang');
450 $result .=
'<div class="inline-block hidden field-' .
$object->element .
'-' . $fieldname .
'">';
452 $resultforextrlang =
'';
453 foreach ($arrayoflangcode as $langcode) {
454 $valuetoshow = GETPOSTISSET(
'field-' .
$object->element .
"-" . $fieldname .
"-" . $langcode) ?
GETPOST(
'field-' .
$object->element .
'-' . $fieldname .
"-" . $langcode, $check) :
'';
455 if (empty($valuetoshow)) {
456 $object->fetchValuesForExtraLanguages();
458 $valuetoshow =
$object->array_languages[$fieldname][$langcode];
462 $resultforextrlang .= $s;
465 if ($typeofdata ==
'textarea') {
466 $resultforextrlang .=
'<textarea name="field-' .
$object->element .
"-" . $fieldname .
"-" . $langcode .
'" id="' . $fieldname .
"-" . $langcode .
'" class="' . $morecss .
'" rows="' . ROWS_2 .
'" wrap="soft">';
467 $resultforextrlang .= $valuetoshow;
468 $resultforextrlang .=
'</textarea>';
470 $resultforextrlang .=
'<input type="text" class="inputfieldforlang ' . ($morecss ?
' ' . $morecss :
'') .
'" name="field-' .
$object->element .
'-' . $fieldname .
'-' . $langcode .
'" value="' . $valuetoshow .
'">';
473 $result .= $resultforextrlang;
476 $result .=
'<script nonce="' .
getNonce() .
'">$(".image-' .
$object->element .
'-' . $fieldname .
'").click(function() { console.log("Toggle lang widget"); jQuery(".field-' .
$object->element .
'-' . $fieldname .
'").toggle(); });</script>';
495 protected function editInPlace(
$object, $value, $htmlname, $condition, $inputType =
'textarea', $editvalue =
null, $extObject =
null, $custommsg =
null)
500 if (preg_match(
'/^text/', $inputType)) {
502 } elseif (preg_match(
'/^numeric/', $inputType)) {
503 $value =
price($value);
504 } elseif ($inputType ==
'day' || $inputType ==
'datepicker') {
510 $table_element =
false;
514 $ext_element =
false;
515 $button_only =
false;
522 $table_element =
$object->table_element;
526 if (is_object($extObject)) {
527 $ext_element = $extObject->element;
530 if (preg_match(
'/^(string|email|numeric)/', $inputType)) {
531 $tmp = explode(
':', $inputType);
532 $inputType = $tmp[0];
533 if (!empty($tmp[1])) {
534 $inputOption = $tmp[1];
536 if (!empty($tmp[2])) {
537 $savemethod = $tmp[2];
539 $out .=
'<input id="width_' . $htmlname .
'" value="' . $inputOption .
'" type="hidden"/>' .
"\n";
540 } elseif ((preg_match(
'/^day$/', $inputType)) || (preg_match(
'/^datepicker/', $inputType)) || (preg_match(
'/^datehourpicker/', $inputType))) {
541 $tmp = explode(
':', $inputType);
542 $inputType = $tmp[0];
543 if (!empty($tmp[1])) {
544 $inputOption = $tmp[1];
546 if (!empty($tmp[2])) {
547 $savemethod = $tmp[2];
550 $out .=
'<input id="timestamp" type="hidden"/>' .
"\n";
551 } elseif (preg_match(
'/^(select|autocomplete)/', $inputType)) {
552 $tmp = explode(
':', $inputType);
553 $inputType = $tmp[0];
554 $loadmethod = $tmp[1];
555 if (!empty($tmp[2])) {
556 $savemethod = $tmp[2];
558 if (!empty($tmp[3])) {
561 } elseif (preg_match(
'/^textarea/', $inputType)) {
562 $tmp = explode(
':', $inputType);
563 $inputType = $tmp[0];
564 $rows = (empty($tmp[1]) ?
'8' : $tmp[1]);
565 $cols = (empty($tmp[2]) ?
'80' : $tmp[2]);
566 } elseif (preg_match(
'/^ckeditor/', $inputType)) {
567 $tmp = explode(
':', $inputType);
568 $inputType = $tmp[0];
570 if (!empty($tmp[2])) {
573 if (!empty($tmp[3])) {
576 if (!empty($tmp[4])) {
577 $savemethod = $tmp[4];
580 if (isModEnabled(
'fckeditor')) {
581 $out .=
'<input id="ckeditor_toolbar" value="' . $toolbar .
'" type="hidden"/>' .
"\n";
583 $inputType =
'textarea';
587 $out .=
'<input id="element_' . $htmlname .
'" value="' . $element .
'" type="hidden"/>' .
"\n";
588 $out .=
'<input id="table_element_' . $htmlname .
'" value="' . $table_element .
'" type="hidden"/>' .
"\n";
589 $out .=
'<input id="fk_element_' . $htmlname .
'" value="' . $fk_element .
'" type="hidden"/>' .
"\n";
590 $out .=
'<input id="loadmethod_' . $htmlname .
'" value="' . $loadmethod .
'" type="hidden"/>' .
"\n";
591 if (!empty($savemethod)) {
592 $out .=
'<input id="savemethod_' . $htmlname .
'" value="' . $savemethod .
'" type="hidden"/>' .
"\n";
594 if (!empty($ext_element)) {
595 $out .=
'<input id="ext_element_' . $htmlname .
'" value="' . $ext_element .
'" type="hidden"/>' .
"\n";
597 if (!empty($custommsg)) {
598 if (is_array($custommsg)) {
599 if (!empty($custommsg[
'success'])) {
600 $out .=
'<input id="successmsg_' . $htmlname .
'" value="' . $custommsg[
'success'] .
'" type="hidden"/>' .
"\n";
602 if (!empty($custommsg[
'error'])) {
603 $out .=
'<input id="errormsg_' . $htmlname .
'" value="' . $custommsg[
'error'] .
'" type="hidden"/>' .
"\n";
606 $out .=
'<input id="successmsg_' . $htmlname .
'" value="' . $custommsg .
'" type="hidden"/>' .
"\n";
609 if ($inputType ==
'textarea') {
610 $out .=
'<input id="textarea_' . $htmlname .
'_rows" value="' . $rows .
'" type="hidden"/>' .
"\n";
611 $out .=
'<input id="textarea_' . $htmlname .
'_cols" value="' . $cols .
'" type="hidden"/>' .
"\n";
613 $out .=
'<span id="viewval_' . $htmlname .
'" class="viewval_' . $inputType . ($button_only ?
' inactive' :
' active') .
'">' . $value .
'</span>' .
"\n";
614 $out .=
'<span id="editval_' . $htmlname .
'" class="editval_' . $inputType . ($button_only ?
' inactive' :
' active') .
' hideobject">' . (!empty($editvalue) ? $editvalue : $value) .
'</span>' .
"\n";
640 public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img =
'', $extracss =
'', $notabs = 3, $incbefore =
'', $noencodehtmltext = 0, $tooltiptrigger =
'', $forcenowrap = 0)
643 $text = $incbefore . $text;
648 $direction = (int) $direction;
658 $htmltext = str_replace(array(
"\r",
"\n"),
'', $htmltext);
661 if ($direction < 0) {
662 $extracss = ($extracss ? $extracss :
'') . ($notabs != 3 ?
' inline-block' :
'');
663 $extrastyle =
'padding: 0px; padding-left: 2px;';
665 if ($direction > 0) {
666 $extracss = ($extracss ? $extracss :
'') . ($notabs != 3 ?
' inline-block' :
'');
667 $extrastyle =
'padding: 0px; padding-right: 2px;';
670 $classfortooltip =
'classfortooltip';
675 if ($tooltiptrigger ==
'') {
676 $htmltext = str_replace(
'"',
'"', $htmltext);
678 $classfortooltip =
'classfortooltiponclick';
679 $textfordialog .=
'<div style="display: none;" id="idfortooltiponclick_' . $tooltiptrigger .
'" class="classfortooltiponclicktext">' . $htmltext .
'</div>';
681 if ($tooltipon == 2 || $tooltipon == 3) {
682 $paramfortooltipimg =
' class="' . $classfortooltip . ($notabs != 3 ?
' inline-block' :
'') . ($extracss ?
' ' . $extracss :
'') .
'" style="padding: 0px;' . ($extrastyle ?
' ' . $extrastyle :
'') .
'"';
683 if ($tooltiptrigger ==
'') {
684 $paramfortooltipimg .=
' title="' . ($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1)) .
'"';
686 $paramfortooltipimg .=
' dolid="' . $tooltiptrigger .
'"';
689 $paramfortooltipimg = ($extracss ?
' class="' . $extracss .
'"' :
'') . ($extrastyle ?
' style="' . $extrastyle .
'"' :
'');
691 if ($tooltipon == 1 || $tooltipon == 3) {
692 $paramfortooltiptd =
' class="' . ($tooltipon == 3 ?
'cursorpointer ' :
'') . $classfortooltip .
' inline-block' . ($extracss ?
' ' . $extracss :
'') .
'" style="padding: 0px;' . ($extrastyle ?
' ' . $extrastyle :
'') .
'" ';
693 if ($tooltiptrigger ==
'') {
694 $paramfortooltiptd .=
' title="' . ($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1)) .
'"';
696 $paramfortooltiptd .=
' dolid="' . $tooltiptrigger .
'"';
699 $paramfortooltiptd = ($extracss ?
' class="' . $extracss .
'"' :
'') . ($extrastyle ?
' style="' . $extrastyle .
'"' :
'');
701 if (empty($notabs)) {
702 $s .=
'<table class="nobordernopadding"><tr style="height: auto;">';
703 } elseif ($notabs == 2) {
704 $s .=
'<div class="inline-block' . ($forcenowrap ?
' nowrap' :
'') .
'">';
707 if ($direction < 0) {
708 $s .=
'<' . $tag . $paramfortooltipimg;
710 $s .=
' class="valigntop" width="14"';
712 $s .=
'>' . $textfordialog . $img .
'</' . $tag .
'>';
716 if ((
string) $text !=
'') {
717 $s .=
'<' . $tag . $paramfortooltiptd .
'>' . $text .
'</' . $tag .
'>';
720 if ($direction > 0) {
721 $s .=
'<' . $tag . $paramfortooltipimg;
723 $s .=
' class="valignmiddle" width="14"';
725 $s .=
'>' . $textfordialog . $img .
'</' . $tag .
'>';
727 if (empty($notabs)) {
728 $s .=
'</tr></table>';
729 } elseif ($notabs == 2) {
750 public function textwithpicto($text, $htmltext, $direction = 1, $type =
'help', $extracss =
'valignmiddle', $noencodehtmltext = 0, $notabs = 3, $tooltiptrigger =
'', $forcenowrap = 0)
752 global $conf, $langs;
757 } elseif ($type ==
'1') {
761 $tooltiptrigger = preg_replace(
'/[^a-z0-9]/i',
'', $tooltiptrigger);
763 if (preg_match(
'/onsmartphone$/', $tooltiptrigger) && empty($conf->dol_no_mouse_hover)) {
764 $tooltiptrigger = preg_replace(
'/^.*onsmartphone$/',
'', $tooltiptrigger);
767 if ($tooltiptrigger) {
768 $alt = $langs->transnoentitiesnoconv(
"ClickToShowHelp");
772 if (empty($conf->use_javascript_ajax)) {
773 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable') {
782 if (!empty($conf->dol_no_mouse_hover) && empty($tooltiptrigger)) {
783 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable') {
794 if ($type ==
'info') {
796 } elseif ($type ==
'help') {
797 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
798 } elseif ($type ==
'helpclickable') {
799 $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
800 } elseif ($type ==
'superadmin') {
803 } elseif ($type ==
'admin') {
806 } elseif ($type ==
'warning') {
808 } elseif ($type !=
'none') {
813 return $this->
textwithtooltip($text, $htmltext, ((($tooltiptrigger && !$img) || strpos($type,
'clickable')) ? 3 : 2), $direction, $img, $extracss, $notabs,
'', $noencodehtmltext, $tooltiptrigger, $forcenowrap);
826 public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0, $name =
'massaction', $cssclass =
'checkforselect')
828 global $conf, $langs, $hookmanager;
831 $ret =
'<div class="centpercent center">';
832 $ret .=
'<select class="flat' . (empty($conf->use_javascript_ajax) ?
'' :
' hideobject') .
' ' . $name .
' ' . $name .
'select valignmiddle alignstart" id="' . $name .
'" name="' . $name .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
'>';
835 $parameters = array();
836 $reshook = $hookmanager->executeHooks(
'addMoreMassActions', $parameters);
839 if (is_array($arrayofaction) && count($arrayofaction) == 0 && empty($hookmanager->resPrint)) {
842 if (empty($reshook)) {
843 $ret .=
'<option value="0"' . ($disabled ?
' disabled="disabled"' :
'') .
'>-- ' . $langs->trans(
"SelectAction") .
' --</option>';
844 if (is_array($arrayofaction)) {
845 foreach ($arrayofaction as $code => $label) {
846 $ret .=
'<option value="' . $code .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' data-html="' .
dol_escape_htmltag($label) .
'">' . $label .
'</option>';
850 $ret .= $hookmanager->resPrint;
854 if (empty($conf->dol_optimize_smallscreen)) {
859 $ret .=
'<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">';
860 $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")) .
'">';
863 if (!empty($conf->use_javascript_ajax)) {
864 $ret .=
'<!-- JS CODE TO ENABLE mass action select -->
866 function initCheckForSelect(mode, name, cssclass) /* mode is 0 during init of page or click all, 1 when we click on 1 checkboxi, "name" refers to the class of the massaction button, "cssclass" to the class of the checkfor select boxes */
868 atleastoneselected=0;
869 jQuery("."+cssclass).each(function( index ) {
870 /* console.log( index + ": " + $( this ).text() ); */
871 if ($(this).is(\':checked\')) atleastoneselected++;
874 console.log("initCheckForSelect mode="+mode+" name="+name+" cssclass="+cssclass+" atleastoneselected="+atleastoneselected);
876 if (atleastoneselected || ' . $alwaysvisible .
')
878 jQuery("."+name).show();
879 ' . ($selected ?
'if (atleastoneselected) { jQuery("."+name+"select").val("' . $selected .
'").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', false); }' :
'') .
'
880 ' . ($selected ?
'if (! atleastoneselected) { jQuery("."+name+"select").val("0").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', true); } ' :
'') .
'
884 jQuery("."+name).hide();
885 jQuery("."+name+"other").hide();
889 jQuery(document).ready(function () {
890 initCheckForSelect(0, "' . $name .
'", "' . $cssclass .
'");
891 jQuery(".' . $cssclass .
'").click(function() {
892 initCheckForSelect(1, "' . $name .
'", "' . $cssclass .
'");
894 jQuery(".' . $name .
'select").change(function() {
895 var massaction = $( this ).val();
896 var urlform = $( this ).closest("form").attr("action").replace("#show_files","");
897 if (massaction == "builddoc") {
898 urlform = urlform + "#show_files";
900 $( this ).closest("form").attr("action", urlform);
901 console.log("we select a mass action name=' . $name .
' massaction="+massaction+" - "+urlform);
902 /* Warning: if you set submit button to disabled, post using Enter will no more work if there is no other button */
903 if ($(this).val() != \'0\') {
904 jQuery(".' . $name .
'confirmed").prop(\'disabled\', false);
905 jQuery(".' . $name .
'other").hide(); /* To disable if another div was open */
906 jQuery(".' . $name .
'"+massaction).show();
908 jQuery(".' . $name .
'confirmed").prop(\'disabled\', true);
909 jQuery(".' . $name .
'other").hide(); /* To disable any div open */
938 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)
941 global $conf, $langs, $mysoc;
943 $langs->load(
"dict");
946 $countryArray = array();
949 $atleastonefavorite = 0;
951 $sql =
"SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite, eec";
952 $sql .=
" FROM " . $this->db->prefix() .
"c_country";
953 $sql .=
" WHERE active > 0";
956 dol_syslog(get_class($this) .
"::select_country", LOG_DEBUG);
957 $resql = $this->db->query($sql);
959 $out .=
'<select id="select' . $htmlname .
'" class="flat maxwidth200onsmartphone selectcountry' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" ' . $htmloption .
'>';
960 $num = $this->db->num_rows($resql);
964 $obj = $this->db->fetch_object($resql);
966 $countryArray[$i][
'rowid'] = $obj->rowid;
967 $countryArray[$i][
'code_iso'] = $obj->code_iso;
968 $countryArray[$i][
'code_iso3'] = $obj->code_iso3;
969 $countryArray[$i][
'label'] = ($obj->code_iso && $langs->transnoentitiesnoconv(
"Country" . $obj->code_iso) !=
"Country" . $obj->code_iso ? $langs->transnoentitiesnoconv(
"Country" . $obj->code_iso) : ($obj->label !=
'-' ? $obj->label :
''));
970 $countryArray[$i][
'favorite'] = $obj->favorite;
971 $countryArray[$i][
'eec'] = $obj->eec;
972 $favorite[$i] = $obj->favorite;
977 if (empty($disablefavorites)) {
978 $array1_sort_order = SORT_DESC;
979 $array2_sort_order = SORT_ASC;
980 array_multisort($favorite, $array1_sort_order, $label, $array2_sort_order, $countryArray);
986 if (is_numeric($showempty)) {
987 $out .=
'<option value=""> </option>' .
"\n";
989 $out .=
'<option value="-1">' . $langs->trans($showempty) .
'</option>' .
"\n";
993 if ($addspecialentries) {
995 $out .=
'<option value="special_allnotme"' . ($selected ==
'special_allnotme' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesExceptMe", $langs->transnoentitiesnoconv(
"Country" . $mysoc->country_code)) .
'</option>';
996 $out .=
'<option value="special_eec"' . ($selected ==
'special_eec' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesInEEC") .
'</option>';
997 if ($mysoc->isInEEC()) {
998 $out .=
'<option value="special_eecnotme"' . ($selected ==
'special_eecnotme' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesInEECExceptMe", $langs->transnoentitiesnoconv(
"Country" . $mysoc->country_code)) .
'</option>';
1000 $out .=
'<option value="special_noteec"' . ($selected ==
'special_noteec' ?
' selected' :
'') .
'>' . $langs->trans(
"CountriesNotInEEC") .
'</option>';
1001 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
1004 foreach ($countryArray as $row) {
1006 if (empty($row[
'rowid'])) {
1009 if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row[
'code_iso'], $exclude_country_code)) {
1013 if (empty($disablefavorites) && $row[
'favorite'] && $row[
'code_iso']) {
1014 $atleastonefavorite++;
1016 if (empty($row[
'favorite']) && $atleastonefavorite) {
1017 $atleastonefavorite = 0;
1018 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
1022 if ($row[
'label']) {
1023 $labeltoshow .=
dol_trunc($row[
'label'], $maxlength,
'middle');
1025 $labeltoshow .=
' ';
1027 if ($row[
'code_iso']) {
1028 $labeltoshow .=
' <span class="opacitymedium">(' . $row[
'code_iso'] .
')</span>';
1029 if (empty($hideflags)) {
1030 $tmpflag =
picto_from_langcode($row[
'code_iso'],
'class="saturatemedium paddingrightonly"', 1);
1031 $labeltoshow = $tmpflag .
' ' . $labeltoshow;
1035 if ($selected && $selected !=
'-1' && ($selected == $row[
'rowid'] || $selected == $row[
'code_iso'] || $selected == $row[
'code_iso3'] || $selected == $row[
'label'])) {
1036 $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']) .
'">';
1038 $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']) .
'">';
1040 $out .= $labeltoshow;
1041 $out .=
'</option>' .
"\n";
1044 $out .=
'</select>';
1050 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1051 $out .=
ajax_combobox(
'select' . $htmlname, array(), 0, 0,
'resolve');
1071 public function select_incoterms($selected =
'', $location_incoterms =
'', $page =
'', $htmlname =
'incoterm_id', $htmloption =
'', $forcecombo = 1, $events = array(), $disableautocomplete = 0)
1074 global $conf, $langs;
1076 $langs->load(
"dict");
1080 $incotermArray = array();
1082 $sql =
"SELECT rowid, code";
1083 $sql .=
" FROM " . $this->db->prefix() .
"c_incoterms";
1084 $sql .=
" WHERE active > 0";
1085 $sql .=
" ORDER BY code ASC";
1087 dol_syslog(get_class($this) .
"::select_incoterm", LOG_DEBUG);
1088 $resql = $this->db->query($sql);
1090 if ($conf->use_javascript_ajax && !$forcecombo) {
1091 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1095 if (!empty($page)) {
1096 $out .=
'<form method="post" action="' . $page .
'">';
1097 $out .=
'<input type="hidden" name="action" value="set_incoterms">';
1098 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
1101 $out .=
'<select id="' . $htmlname .
'" class="flat selectincoterm width75" name="' . $htmlname .
'" ' . $htmloption .
'>';
1102 $out .=
'<option value="0"> </option>';
1103 $num = $this->db->num_rows($resql);
1107 $obj = $this->db->fetch_object($resql);
1108 $incotermArray[$i][
'rowid'] = $obj->rowid;
1109 $incotermArray[$i][
'code'] = $obj->code;
1113 foreach ($incotermArray as $row) {
1114 if ($selected && ($selected == $row[
'rowid'] || $selected == $row[
'code'])) {
1115 $out .=
'<option value="' . $row[
'rowid'] .
'" selected>';
1117 $out .=
'<option value="' . $row[
'rowid'] .
'">';
1121 $out .= $row[
'code'];
1124 $out .=
'</option>';
1127 $out .=
'</select>';
1130 if ($conf->use_javascript_ajax && empty($disableautocomplete)) {
1131 $out .=
ajax_multiautocompleter(
'location_incoterms', array(), DOL_URL_ROOT .
'/core/ajax/locationincoterms.php') .
"\n";
1132 $moreattrib .=
' autocomplete="off"';
1134 $out .=
'<input id="location_incoterms" class="maxwidthonsmartphone type="text" name="location_incoterms" value="' . $location_incoterms .
'">' .
"\n";
1136 if (!empty($page)) {
1137 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp nomargintop nomarginbottom" value="' . $langs->trans(
"Modify") .
'"></form>';
1160 public function select_type_of_lines($selected =
'', $htmlname =
'type', $showempty = 0, $hidetext = 0, $forceall = 0, $morecss =
"")
1166 if ($forceall == 1 || (empty($forceall) && isModEnabled(
"product") && isModEnabled(
"service"))
1167 || (empty($forceall) && !isModEnabled(
'product') && !isModEnabled(
'service'))) {
1168 if (empty($hidetext)) {
1169 print $langs->trans(
"Type") .
': ';
1171 print
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
1173 print
'<option value="-1"';
1174 if ($selected == -1) {
1178 if (is_numeric($showempty)) {
1186 print
'<option value="0"';
1187 if (0 == $selected || ($selected == -1 &&
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') ==
'product')) {
1190 print
'>' . $langs->trans(
"Product");
1192 print
'<option value="1"';
1193 if (1 == $selected || ($selected == -1 &&
getDolGlobalString(
'MAIN_FREE_PRODUCT_CHECKED_BY_DEFAULT') ==
'service')) {
1196 print
'>' . $langs->trans(
"Service");
1202 if ((empty($forceall) && !isModEnabled(
'product') && isModEnabled(
"service")) || $forceall == 3) {
1203 print $langs->trans(
"Service");
1204 print
'<input type="hidden" name="' . $htmlname .
'" value="1">';
1206 if ((empty($forceall) && isModEnabled(
"product") && !isModEnabled(
'service')) || $forceall == 2) {
1207 print $langs->trans(
"Product");
1208 print
'<input type="hidden" name="' . $htmlname .
'" value="0">';
1210 if ($forceall < 0) {
1211 print
'<input type="hidden" name="' . $htmlname .
'" value="1">';
1227 $num = count($this->cache_types_fees);
1234 $langs->load(
"trips");
1236 $sql =
"SELECT c.code, c.label";
1237 $sql .=
" FROM " . $this->db->prefix() .
"c_type_fees as c";
1238 $sql .=
" WHERE active > 0";
1240 $resql = $this->db->query($sql);
1242 $num = $this->db->num_rows($resql);
1246 $obj = $this->db->fetch_object($resql);
1249 $label = ($obj->code != $langs->trans($obj->code) ? $langs->trans($obj->code) : $langs->trans($obj->label));
1250 $this->cache_types_fees[$obj->code] = $label;
1254 asort($this->cache_types_fees);
1276 global $user, $langs;
1278 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
1282 print
'<select id="select_' . $htmlname .
'" class="flat" name="' . $htmlname .
'">';
1284 print
'<option value="-1"';
1285 if ($selected == -1) {
1288 print
'> </option>';
1291 foreach ($this->cache_types_fees as $key => $value) {
1292 print
'<option value="' . $key .
'"';
1293 if ($key == $selected) {
1303 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1332 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)
1335 global $conf, $langs;
1339 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'COMPANY_USE_SEARCH_TO_SELECT') && !$forcecombo) {
1340 if (is_null($ajaxoptions)) {
1341 $ajaxoptions = array();
1344 require_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1348 if ($selected && empty($selected_input_value)) {
1349 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
1350 $societetmp =
new Societe($this->db);
1351 $societetmp->fetch($selected);
1352 $selected_input_value = $societetmp->name;
1357 $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)) :
'');
1359 $out .=
'<!-- force css to be higher than dialog popup --><style type="text/css">.ui-autocomplete { z-index: 1010; }</style>';
1360 if (empty($hidelabel)) {
1361 $out .= $langs->trans(
"RefOrLabel") .
' : ';
1362 } elseif ($hidelabel == 1 && !is_numeric($showempty)) {
1363 $placeholder = $langs->trans($showempty);
1364 } elseif ($hidelabel > 1) {
1365 $placeholder = $langs->trans(
"RefOrLabel");
1366 if ($hidelabel == 2) {
1367 $out .=
img_picto($langs->trans(
"Search"),
'search');
1370 $out .=
'<input type="text" class="' . $morecss .
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . ($placeholder ?
' placeholder="' .
dol_escape_htmltag($placeholder) .
'"' :
'') .
' ' . (
getDolGlobalString(
'THIRDPARTY_SEARCH_AUTOFOCUS') ?
'autofocus' :
'') .
' />';
1371 if ($hidelabel == 3) {
1372 $out .=
img_picto($langs->trans(
"Search"),
'search');
1377 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/societe/ajax/company.php', $urloption,
getDolGlobalInt(
'COMPANY_USE_SEARCH_TO_SELECT'), 0, $ajaxoptions);
1380 $out .= $this->
select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events,
'', 0, $limit, $morecss, $moreparam, $multiple, $excludeids, $showcode);
1414 public function select_contact($socid, $selected =
'', $htmlname =
'contactid', $showempty = 0, $exclude =
'', $limitto =
'', $showfunction = 0, $morecss =
'', $nokeyifsocid =
true, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam =
'', $htmlid =
'', $selected_input_value =
'', $filter =
'')
1418 global $conf, $langs;
1423 if ($nokeyifsocid && $socid > 0) {
1424 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1427 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && !$forcecombo) {
1428 if (is_null($events)) {
1432 require_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1436 if ($selected && empty($selected_input_value)) {
1437 require_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
1438 $contacttmp =
new Contact($this->db);
1439 $contacttmp->fetch($selected);
1440 $selected_input_value = $contacttmp->getFullName($langs);
1443 if (!is_numeric($showempty)) {
1444 $placeholder = $showempty;
1448 $urloption =
'htmlname=' . urlencode((
string) (str_replace(
'.',
'_', $htmlname))) .
'&outjson=1&filter=' . urlencode((
string) ($filter)) . (empty($exclude) ?
'' :
'&exclude=' . urlencode($exclude)) . ($showsoc ?
'&showsoc=' . urlencode((
string) ($showsoc)) :
'');
1450 $out .=
'<!-- force css to be higher than dialog popup --><style type="text/css">.ui-autocomplete { z-index: 1010; }</style>';
1452 $out .=
'<input type="text" class="' . $morecss .
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . ($placeholder ?
' placeholder="' .
dol_escape_htmltag($placeholder) .
'"' :
'') .
' ' . (
getDolGlobalString(
'CONTACT_SEARCH_AUTOFOCUS') ?
'autofocus' :
'') .
' />';
1456 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/contact/ajax/contact.php', $urloption,
getDolGlobalInt(
'CONTACT_USE_SEARCH_TO_SELECT'), 0, $events);
1460 $disableifempty = 0;
1464 $out .= $this->
selectcontacts($socid, $selected, $htmlname, $showempty, $exclude, $limitto, $showfunction, $morecss, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid, $multiple, $disableifempty);
1467 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1499 public function select_thirdparty_list($selected =
'', $htmlname =
'socid', $filter =
'', $showempty =
'', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey =
'', $outputmode = 0, $limit = 0, $morecss =
'minwidth100', $moreparam =
'', $multiple =
false, $excludeids = array(), $showcode = 0)
1502 global $user, $langs;
1503 global $hookmanager;
1507 $outarray = array();
1509 if ($selected ===
'') {
1510 $selected = array();
1511 } elseif (!is_array($selected)) {
1512 $selected = array($selected);
1516 if (function_exists(
'testSqlAndScriptInject')) {
1519 return 'SQLInjectionTryDetected';
1523 if ($filter !=
'') {
1524 if (preg_match(
'/[\(\)]/', $filter)) {
1530 if (function_exists(
'testSqlAndScriptInject')) {
1533 return 'SQLInjectionTryDetected';
1539 dol_syslog(
"Warning, select_thirdparty_list was called with a filter criteria not using the Universal Search Syntax.", LOG_WARNING);
1544 $sql =
"SELECT s.rowid, s.nom as name, s.name_alias, s.tva_intra, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
1546 $sql .=
", s.address, s.zip, s.town";
1547 $sql .=
", dictp.code as country_code";
1549 $sql .=
" FROM " . $this->db->prefix() .
"societe as s";
1551 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_country as dictp ON dictp.rowid = s.fk_pays";
1553 if (!$user->hasRight(
'societe',
'client',
'voir')) {
1554 $sql .=
", " . $this->db->prefix() .
"societe_commerciaux as sc";
1556 $sql .=
" WHERE s.entity IN (" .
getEntity(
'societe') .
")";
1557 if (!empty($user->socid)) {
1558 $sql .=
" AND s.rowid = " . ((int) $user->socid);
1563 $sql .=
" AND (" . $filter .
")";
1565 if (!$user->hasRight(
'societe',
'client',
'voir')) {
1566 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = " . ((int) $user->id);
1569 $sql .=
" AND s.status <> 0";
1571 if (!empty($excludeids)) {
1572 $sql .=
" AND s.rowid NOT IN (" . $this->db->sanitize(implode(
',', $excludeids)) .
")";
1575 $parameters = array();
1576 $reshook = $hookmanager->executeHooks(
'selectThirdpartyListWhere', $parameters);
1577 $sql .= $hookmanager->resPrint;
1579 if ($filterkey && $filterkey !=
'') {
1583 $search_crit = explode(
' ', $filterkey);
1585 if (count($search_crit) > 1) {
1588 foreach ($search_crit as $crit) {
1592 $sql .=
"(s.nom LIKE '" . $this->db->escape($prefix . $crit) .
"%')";
1595 if (count($search_crit) > 1) {
1598 if (isModEnabled(
'barcode')) {
1599 $sql .=
" OR s.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
1601 $sql .=
" OR s.code_client LIKE '" . $this->db->escape($prefix . $filterkey) .
"%' OR s.code_fournisseur LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
1602 $sql .=
" OR s.name_alias LIKE '" . $this->db->escape($prefix . $filterkey) .
"%' OR s.tva_intra LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
1605 $sql .= $this->db->order(
"nom",
"ASC");
1606 $sql .= $this->db->plimit($limit, 0);
1609 dol_syslog(get_class($this).
"::select_thirdparty_list", LOG_DEBUG);
1610 $resql = $this->db->query($sql);
1613 $out .=
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($moreparam ?
' ' . $moreparam :
'') .
' name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
'>' .
"\n";
1615 $textifempty = (($showempty && !is_numeric($showempty)) ? $langs->trans($showempty) :
'');
1619 if ($showempty && !is_numeric($showempty)) {
1620 $textifempty = $langs->trans($showempty);
1622 $textifempty .= $langs->trans(
"All");
1626 $out .=
'<option value="-1" data-html="' .
dol_escape_htmltag(
'<span class="opacitymedium">' . ($textifempty ? $textifempty :
' ') .
'</span>') .
'">' . $textifempty .
'</option>' .
"\n";
1629 $companytemp =
new Societe($this->db);
1631 $num = $this->db->num_rows($resql);
1635 $obj = $this->db->fetch_object($resql);
1638 if (($obj->client) && (!empty($obj->code_client))) {
1639 $label = $obj->code_client .
' - ';
1641 if (($obj->fournisseur) && (!empty($obj->code_fournisseur))) {
1642 $label .= $obj->code_fournisseur .
' - ';
1644 $label .=
' ' . $obj->name;
1646 $label = $obj->name;
1649 if (!empty($obj->name_alias)) {
1650 $label .=
' (' . $obj->name_alias .
')';
1654 $label .=
' - '.$obj->tva_intra;
1657 $labelhtml = $label;
1660 $companytemp->id = $obj->rowid;
1661 $companytemp->client = $obj->client;
1662 $companytemp->fournisseur = $obj->fournisseur;
1663 $tmptype = $companytemp->getTypeUrl(1,
'', 0,
'span');
1665 $labelhtml .=
' ' . $tmptype;
1668 if ($obj->client || $obj->fournisseur) {
1671 if ($obj->client == 1 || $obj->client == 3) {
1672 $label .= $langs->trans(
"Customer");
1674 if ($obj->client == 2 || $obj->client == 3) {
1675 $label .= ($obj->client == 3 ?
', ' :
'') . $langs->trans(
"Prospect");
1677 if ($obj->fournisseur) {
1678 $label .= ($obj->client ?
', ' :
'') . $langs->trans(
"Supplier");
1680 if ($obj->client || $obj->fournisseur) {
1686 $s = ($obj->address ?
' - ' . $obj->address :
'') . ($obj->zip ?
' - ' . $obj->zip :
'') . ($obj->town ?
' ' . $obj->town :
'');
1687 if (!empty($obj->country_code)) {
1688 $s .=
', ' . $langs->trans(
'Country' . $obj->country_code);
1694 if (empty($outputmode)) {
1695 if (in_array($obj->rowid, $selected)) {
1696 $out .=
'<option value="' . $obj->rowid .
'" selected data-html="' .
dol_escape_htmltag($labelhtml, 0, 0,
'', 0, 1) .
'">' .
dol_escape_htmltag($label, 0, 0,
'', 0, 1) .
'</option>';
1698 $out .=
'<option value="' . $obj->rowid .
'" data-html="' .
dol_escape_htmltag($labelhtml, 0, 0,
'', 0, 1) .
'">' .
dol_escape_htmltag($label, 0, 0,
'', 0, 1) .
'</option>';
1701 array_push($outarray, array(
'key' => $obj->rowid,
'value' => $label,
'label' => $label,
'labelhtml' => $labelhtml));
1705 if (($i % 10) == 0) {
1710 $out .=
'</select>' .
"\n";
1712 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1719 $this->result = array(
'nbofthirdparties' => $num);
1753 public function selectcontacts($socid, $selected = array(), $htmlname =
'contactid', $showempty = 0, $exclude =
'', $limitto =
'', $showfunction = 0, $morecss =
'', $options_only = 0, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam =
'', $htmlid =
'', $multiple =
false, $disableifempty = 0, $filter =
'')
1755 global $conf, $user, $langs, $hookmanager, $action;
1757 $langs->load(
'companies');
1759 if (empty($htmlid)) {
1760 $htmlid = $htmlname;
1764 $outarray = array();
1766 if ($selected ===
'') {
1767 $selected = array();
1768 } elseif (!is_array($selected)) {
1769 $selected = array((
int) $selected);
1773 if (function_exists(
'testSqlAndScriptInject')) {
1776 return 'SQLInjectionTryDetected';
1780 if ($filter !=
'') {
1781 if (preg_match(
'/[\(\)]/', $filter)) {
1787 if (function_exists(
'testSqlAndScriptInject')) {
1790 return 'SQLInjectionTryDetected';
1796 dol_syslog(
"Warning, select_thirdparty_list was called with a filter criteria not using the Universal Search Filter Syntax.", LOG_WARNING);
1800 if (!is_object($hookmanager)) {
1801 include_once DOL_DOCUMENT_ROOT .
'/core/class/hookmanager.class.php';
1806 $sql =
"SELECT sp.rowid, sp.lastname, sp.statut, sp.firstname, sp.poste, sp.email, sp.phone, sp.phone_perso, sp.phone_mobile, sp.town AS contact_town";
1807 if ($showsoc > 0 ||
getDolGlobalString(
'CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST')) {
1808 $sql .=
", s.nom as company, s.town AS company_town";
1810 $sql .=
" FROM " . $this->db->prefix() .
"socpeople as sp";
1811 if ($showsoc > 0 ||
getDolGlobalString(
'CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST')) {
1812 $sql .=
" LEFT OUTER JOIN " . $this->db->prefix() .
"societe as s ON s.rowid=sp.fk_soc";
1814 $sql .=
" WHERE sp.entity IN (" .
getEntity(
'contact') .
")";
1815 $sql .=
" AND ((sp.fk_user_creat = ".((int) $user->id).
" AND sp.priv = 1) OR sp.priv = 0)";
1816 if ($socid > 0 || $socid == -1) {
1817 $sql .=
" AND sp.fk_soc = " . ((int) $socid);
1820 $sql .=
" AND sp.statut <> 0";
1825 $sql .=
" AND (" . $filter .
")";
1828 $parameters = array();
1829 $reshook = $hookmanager->executeHooks(
'selectContactListWhere', $parameters);
1830 $sql .= $hookmanager->resPrint;
1831 $sql .=
" ORDER BY sp.lastname ASC";
1833 dol_syslog(get_class($this) .
"::selectcontacts", LOG_DEBUG);
1834 $resql = $this->db->query($sql);
1836 $num = $this->db->num_rows($resql);
1838 if ($htmlname !=
'none' && !$options_only) {
1839 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlid .
'" name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . (($num || empty($disableifempty)) ?
'' :
' disabled') . ($multiple ?
'multiple' :
'') .
' ' . (!empty($moreparam) ? $moreparam :
'') .
'>';
1842 if ($showempty && !is_numeric($showempty)) {
1843 $textforempty = $showempty;
1844 $out .=
'<option class="optiongrey" value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'>' . $textforempty .
'</option>';
1846 if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) {
1847 $out .=
'<option value="0"' . (in_array(0, $selected) ?
' selected' :
'') .
'> </option>';
1849 if ($showempty == 2) {
1850 $out .=
'<option value="0"' . (in_array(0, $selected) ?
' selected' :
'') .
'>-- ' . $langs->trans(
"Internal") .
' --</option>';
1856 include_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
1857 $contactstatic =
new Contact($this->db);
1860 $obj = $this->db->fetch_object($resql);
1863 $extendedInfos =
'';
1865 $extendedInfos = array();
1866 $email = trim($obj->email);
1867 if (!empty($email)) {
1868 $extendedInfos[] = $email;
1870 $phone = trim($obj->phone);
1871 $phone_perso = trim($obj->phone_perso);
1872 $phone_mobile = trim($obj->phone_mobile);
1873 if (!empty($phone)) {
1874 $extendedInfos[] = $phone;
1876 if (!empty($phone_perso)) {
1877 $extendedInfos[] = $phone_perso;
1879 if (!empty($phone_mobile)) {
1880 $extendedInfos[] = $phone_mobile;
1883 $contact_town = trim($obj->contact_town);
1884 $company_town = trim($obj->company_town);
1885 if (!empty($contact_town)) {
1886 $extendedInfos[] = $contact_town;
1887 } elseif (!empty($company_town)) {
1888 $extendedInfos[] = $company_town;
1890 $extendedInfos = implode(
' - ', $extendedInfos);
1891 if (!empty($extendedInfos)) {
1892 $extendedInfos =
' - ' . $extendedInfos;
1896 $contactstatic->id = $obj->rowid;
1897 $contactstatic->lastname = $obj->lastname;
1898 $contactstatic->firstname = $obj->firstname;
1899 if ($obj->statut == 1) {
1901 if ($htmlname !=
'none') {
1903 if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) {
1906 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) {
1909 if (!empty($selected) && in_array($obj->rowid, $selected)) {
1910 $out .=
'<option value="' . $obj->rowid .
'"';
1912 $out .=
' disabled';
1914 $out .=
' selected>';
1916 $tmplabel = $contactstatic->getFullName($langs) . $extendedInfos;
1917 if ($showfunction && $obj->poste) {
1918 $tmplabel .=
' (' . $obj->poste .
')';
1920 if (($showsoc > 0) && $obj->company) {
1921 $tmplabel .=
' - (' . $obj->company .
')';
1925 $out .=
'</option>';
1927 $out .=
'<option value="' . $obj->rowid .
'"';
1929 $out .=
' disabled';
1933 $tmplabel = $contactstatic->getFullName($langs) . $extendedInfos;
1934 if ($showfunction && $obj->poste) {
1935 $tmplabel .=
' (' . $obj->poste .
')';
1937 if (($showsoc > 0) && $obj->company) {
1938 $tmplabel .=
' - (' . $obj->company .
')';
1942 $out .=
'</option>';
1945 if (in_array($obj->rowid, $selected)) {
1946 $tmplabel = $contactstatic->getFullName($langs) . $extendedInfos;
1947 if ($showfunction && $obj->poste) {
1948 $tmplabel .=
' (' . $obj->poste .
')';
1950 if (($showsoc > 0) && $obj->company) {
1951 $tmplabel .=
' - (' . $obj->company .
')';
1958 if ($tmplabel !=
'') {
1959 array_push($outarray, array(
'key' => $obj->rowid,
'value' => $tmplabel,
'label' => $tmplabel,
'labelhtml' => $tmplabel));
1965 $labeltoshow = ($socid != -1) ? ($langs->trans($socid ?
"NoContactDefinedForThirdParty" :
"NoContactDefined")) : $langs->trans(
'SelectAThirdPartyFirst');
1966 $out .=
'<option class="disabled" value="-1"' . (($showempty == 2 || $multiple) ?
'' :
' selected') .
' disabled="disabled">';
1967 $out .= $labeltoshow;
1968 $out .=
'</option>';
1971 $parameters = array(
1973 'htmlname' => $htmlname,
1976 'showfunction' => $showfunction,
1977 'showsoc' => $showsoc,
1980 $reshook = $hookmanager->executeHooks(
'afterSelectContactOptions', $parameters, $this, $action);
1982 if ($htmlname !=
'none' && !$options_only) {
1983 $out .=
'</select>';
1986 if ($conf->use_javascript_ajax && !$forcecombo && !$options_only) {
1987 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
1993 if ($options_only === 2) {
2021 global $langs, $conf;
2024 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
2025 $sql .=
" re.description, re.fk_facture_source";
2026 $sql .=
" FROM " . $this->db->prefix() .
"societe_remise_except as re";
2027 $sql .=
" WHERE re.fk_soc = " . (int) $socid;
2028 $sql .=
" AND re.entity = " . $conf->entity;
2030 $sql .=
" AND " . $filter;
2032 $sql .=
" ORDER BY re.description ASC";
2034 dol_syslog(get_class($this) .
"::select_remises", LOG_DEBUG);
2035 $resql = $this->db->query($sql);
2037 print
'<select id="select_' . $htmlname .
'" class="flat maxwidthonsmartphone" name="' . $htmlname .
'">';
2038 $num = $this->db->num_rows($resql);
2040 $qualifiedlines = $num;
2044 print
'<option value="0"> </option>';
2046 $obj = $this->db->fetch_object($resql);
2047 $desc =
dol_trunc($obj->description, 40);
2048 if (preg_match(
'/\(CREDIT_NOTE\)/', $desc)) {
2049 $desc = preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $desc);
2051 if (preg_match(
'/\(DEPOSIT\)/', $desc)) {
2052 $desc = preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"Deposit"), $desc);
2054 if (preg_match(
'/\(EXCESS RECEIVED\)/', $desc)) {
2055 $desc = preg_replace(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"ExcessReceived"), $desc);
2057 if (preg_match(
'/\(EXCESS PAID\)/', $desc)) {
2058 $desc = preg_replace(
'/\(EXCESS PAID\)/', $langs->trans(
"ExcessPaid"), $desc);
2062 if ($selected > 0 && $selected == $obj->rowid) {
2063 $selectstring =
' selected';
2067 if ($maxvalue > 0 && $obj->amount_ttc > $maxvalue) {
2069 $disabled =
' disabled';
2072 if (
getDolGlobalString(
'MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST') && !empty($obj->fk_facture_source)) {
2073 $tmpfac =
new Facture($this->db);
2074 if ($tmpfac->fetch($obj->fk_facture_source) > 0) {
2075 $desc = $desc .
' - ' . $tmpfac->ref;
2079 print
'<option value="' . $obj->rowid .
'"' . $selectstring . $disabled .
'>' . $desc .
' (' .
price($obj->amount_ht) .
' ' . $langs->trans(
"HT") .
' - ' .
price($obj->amount_ttc) .
' ' . $langs->trans(
"TTC") .
')</option>';
2086 return $qualifiedlines;
2111 public function select_users($selected =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include =
'', $enableonly = array(), $force_entity =
'0')
2114 print $this->
select_dolusers($selected, $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity);
2143 public function select_dolusers($selected =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'', $maxlength = 0, $showstatus = 0, $morefilter =
'', $show_every = 0, $enableonlytext =
'', $morecss =
'', $notdisabled = 0, $outputmode = 0, $multiple =
false, $forcecombo = 0)
2146 global $conf, $user, $langs, $hookmanager;
2150 if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && !
getDolGlobalString(
'SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE')) {
2151 $selected = $user->id;
2154 if ($selected ===
'') {
2155 $selected = array();
2156 } elseif (!is_array($selected)) {
2157 $selected = array($selected);
2160 $excludeUsers =
null;
2161 $includeUsers =
null;
2164 if (is_array($exclude)) {
2165 $excludeUsers = implode(
",", $exclude);
2168 if (is_array($include)) {
2169 $includeUsers = implode(
",", $include);
2170 } elseif ($include ==
'hierarchy') {
2172 $includeUsers = implode(
",", $user->getAllChildIds(0));
2173 } elseif ($include ==
'hierarchyme') {
2175 $includeUsers = implode(
",", $user->getAllChildIds(1));
2181 $outarray = array();
2182 $outarray2 = array();
2185 $showlabelofentity = isModEnabled(
'multicompany') && !
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1 && !empty($user->admin) && empty($user->entity);
2186 $userissuperadminentityone = isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && empty($user->entity);
2189 $sql =
"SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut as status, u.login, u.admin, u.entity, u.gender, u.photo";
2190 if ($showlabelofentity) {
2191 $sql .=
", e.label";
2193 $sql .=
" FROM " . $this->db->prefix() .
"user as u";
2194 if ($showlabelofentity) {
2195 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entity as e ON e.rowid = u.entity";
2198 if ($userissuperadminentityone && $force_entity !=
'default') {
2199 if (!empty($force_entity)) {
2200 $sql .=
" WHERE u.entity IN (0, " . $this->db->sanitize($force_entity) .
")";
2202 $sql .=
" WHERE u.entity IS NOT NULL";
2205 if (isModEnabled(
'multicompany') &&
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE')) {
2206 $sql .=
" WHERE u.rowid IN (SELECT ug.fk_user FROM ".$this->db->prefix().
"usergroup_user as ug WHERE ug.entity IN (".
getEntity(
'usergroup').
"))";
2208 $sql .=
" WHERE u.entity IN (" .
getEntity(
'user') .
")";
2212 if (!empty($user->socid)) {
2213 $sql .=
" AND u.fk_soc = " . ((int) $user->socid);
2215 if (is_array($exclude) && $excludeUsers) {
2216 $sql .=
" AND u.rowid NOT IN (" . $this->db->sanitize($excludeUsers) .
")";
2218 if ($includeUsers) {
2219 $sql .=
" AND u.rowid IN (" . $this->db->sanitize($includeUsers) .
")";
2222 $sql .=
" AND u.statut <> 0";
2225 $sql .=
" AND u.employee <> 0";
2228 $sql .=
" AND u.fk_soc IS NULL";
2230 if (!empty($morefilter)) {
2231 $sql .=
" " . $morefilter;
2235 $reshook = $hookmanager->executeHooks(
'addSQLWhereFilterOnSelectUsers', array(), $this, $action);
2236 if (!empty($reshook)) {
2237 $sql .= $hookmanager->resPrint;
2241 $sql .=
" ORDER BY u.statut DESC, u.firstname ASC, u.lastname ASC";
2243 $sql .=
" ORDER BY u.statut DESC, u.lastname ASC, u.firstname ASC";
2246 dol_syslog(get_class($this) .
"::select_dolusers", LOG_DEBUG);
2248 $resql = $this->db->query($sql);
2250 $num = $this->db->num_rows($resql);
2254 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
' minwidth200') .
'" id="' . $htmlname .
'" name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
' ' . ($disabled ?
' disabled' :
'') .
'>';
2255 if ($show_empty && !$multiple) {
2256 $textforempty =
' ';
2257 if (!empty($conf->use_javascript_ajax)) {
2258 $textforempty =
' ';
2260 if (!is_numeric($show_empty)) {
2261 $textforempty = $show_empty;
2263 $out .=
'<option class="optiongrey" value="' . ($show_empty < 0 ? $show_empty : -1) .
'"' . ((empty($selected) || in_array(-1, $selected)) ?
' selected' :
'') .
'>' . $textforempty .
'</option>' .
"\n";
2265 $outarray[($show_empty < 0 ? $show_empty : -1)] = $textforempty;
2266 $outarray2[($show_empty < 0 ? $show_empty : -1)] = array(
2267 'id' => ($show_empty < 0 ? $show_empty : -1),
2268 'label' => $textforempty,
2269 'labelhtml' => $textforempty,
2275 $out .=
'<option value="-2"' . ((in_array(-2, $selected)) ?
' selected' :
'') .
'>-- ' . $langs->trans(
"Everybody") .
' --</option>' .
"\n";
2277 $outarray[-2] =
'-- ' . $langs->trans(
"Everybody") .
' --';
2278 $outarray2[-2] = array(
2280 'label' =>
'-- ' . $langs->trans(
"Everybody") .
' --',
2281 'labelhtml' =>
'-- ' . $langs->trans(
"Everybody") .
' --',
2287 $userstatic =
new User($this->db);
2290 $obj = $this->db->fetch_object($resql);
2292 $userstatic->id = $obj->rowid;
2293 $userstatic->lastname = $obj->lastname;
2294 $userstatic->firstname = $obj->firstname;
2295 $userstatic->photo = $obj->photo;
2296 $userstatic->status = $obj->status;
2297 $userstatic->entity = $obj->entity;
2298 $userstatic->admin = $obj->admin;
2299 $userstatic->gender = $obj->gender;
2302 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
2303 $disableline = ($enableonlytext ? $enableonlytext :
'1');
2307 $labeltoshowhtml =
'';
2314 $labeltoshow .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
2315 $labeltoshowhtml .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
2316 if (empty($obj->firstname) && empty($obj->lastname)) {
2317 $labeltoshow .= $obj->login;
2318 $labeltoshowhtml .= $obj->login;
2325 $moreinfo .= ($moreinfo ?
' - ' :
' (');
2326 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(');
2327 $moreinfo .= $obj->login;
2328 $moreinfohtml .= $obj->login;
2330 if ($showstatus >= 0) {
2331 if ($obj->status == 1 && $showstatus == 1) {
2332 $moreinfo .= ($moreinfo ?
' - ' :
' (') . $langs->trans(
'Enabled');
2333 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . $langs->trans(
'Enabled');
2335 if ($obj->status == 0 && $showstatus == 1) {
2336 $moreinfo .= ($moreinfo ?
' - ' :
' (') . $langs->trans(
'Disabled');
2337 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . $langs->trans(
'Disabled');
2340 if ($showlabelofentity) {
2341 if (empty($obj->entity)) {
2342 $moreinfo .= ($moreinfo ?
' - ' :
' (') . $langs->trans(
"AllEntities");
2343 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(') . $langs->trans(
"AllEntities");
2345 if ($obj->entity != $conf->entity) {
2346 $moreinfo .= ($moreinfo ?
' - ' :
' (') . ($obj->label ? $obj->label : $langs->trans(
"EntityNameNotDefined"));
2347 $moreinfohtml .= ($moreinfohtml ?
' - ' :
' <span class="opacitymedium">(').($obj->label ? $obj->label : $langs->trans(
"EntityNameNotDefined"));
2351 $moreinfo .= (!empty($moreinfo) ?
')' :
'');
2352 $moreinfohtml .= (!empty($moreinfohtml) ?
')</span>' :
'');
2353 if (!empty($disableline) && $disableline !=
'1') {
2355 $moreinfo .=
' - ' . $disableline;
2356 $moreinfohtml .=
' - ' . $disableline;
2358 $labeltoshow .= $moreinfo;
2359 $labeltoshowhtml .= $moreinfohtml;
2361 $out .=
'<option value="' . $obj->rowid .
'"';
2362 if (!empty($disableline)) {
2363 $out .=
' disabled';
2365 if ((!empty($selected[0]) && is_object($selected[0])) ? $selected[0]->id == $obj->rowid : in_array($obj->rowid, $selected)) {
2366 $out .=
' selected';
2368 $out .=
' data-html="';
2370 $outhtml = $userstatic->getNomUrl(-3,
'', 0, 1, 24, 1,
'login',
'', 1) .
' ';
2371 if ($showstatus >= 0 && $obj->status == 0) {
2372 $outhtml .=
'<strike class="opacitymediumxxx">';
2374 $outhtml .= $labeltoshowhtml;
2375 if ($showstatus >= 0 && $obj->status == 0) {
2376 $outhtml .=
'</strike>';
2378 $labeltoshowhtml = $outhtml;
2382 $out .= $labeltoshow;
2383 $out .=
'</option>';
2385 $outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength) . $moreinfo;
2386 $outarray2[$userstatic->id] = array(
2387 'id' => $userstatic->id,
2388 'label' => $labeltoshow,
2389 'labelhtml' => $labeltoshowhtml,
2397 $out .=
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'" disabled>';
2398 $out .=
'<option value="">' . $langs->trans(
"None") .
'</option>';
2400 $out .=
'</select>';
2402 if ($num && !$forcecombo) {
2404 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
2413 if ($outputmode == 2) {
2415 } elseif ($outputmode) {
2446 public function select_dolusers_forevent($action =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include = array(), $enableonly = array(), $force_entity =
'0', $maxlength = 0, $showstatus = 0, $morefilter =
'', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array())
2451 $userstatic =
new User($this->db);
2454 if (!empty($_SESSION[
'assignedtouser'])) {
2455 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
2456 if (!is_array($assignedtouser)) {
2457 $assignedtouser = array();
2460 $assignedtouser = array();
2462 $nbassignetouser = count($assignedtouser);
2465 if ($nbassignetouser) {
2466 $out .=
'<ul class="attendees">';
2470 foreach ($assignedtouser as $key => $value) {
2471 if ($value[
'id'] == $ownerid) {
2476 $userstatic->fetch($value[
'id']);
2477 $out .= $userstatic->getNomUrl(-1);
2479 $ownerid = $value[
'id'];
2480 $out .=
' (' . $langs->trans(
"Owner") .
')';
2482 if ($nbassignetouser > 1 && $action !=
'view') {
2483 $out .=
' <input type="image" style="border: 0px;" src="' .
img_picto($langs->trans(
"Remove"),
'delete',
'', 0, 1) .
'" value="' . $userstatic->id .
'" class="removedassigned reposition" id="removedassigned_' . $userstatic->id .
'" name="removedassigned_' . $userstatic->id .
'">';
2486 if ($showproperties) {
2487 if ($ownerid == $value[
'id'] && is_array($listofuserid) && count($listofuserid) && in_array($ownerid, array_keys($listofuserid))) {
2488 $out .=
'<div class="myavailability inline-block">';
2489 $out .=
'<span class="hideonsmartphone"> - <span class="opacitymedium">' . $langs->trans(
"Availability") .
':</span> </span><input id="transparency" class="paddingrightonly" ' . ($action ==
'view' ?
'disabled' :
'') .
' type="checkbox" name="transparency"' . ($listofuserid[$ownerid][
'transparency'] ?
' checked' :
'') .
'><label for="transparency">' . $langs->trans(
"Busy") .
'</label>';
2499 if ($nbassignetouser) {
2504 if ($action !=
'view') {
2505 $out .=
'<input type="hidden" class="removedassignedhidden" name="removedassigned" value="">';
2506 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">jQuery(document).ready(function () {';
2507 $out .=
'jQuery(".removedassigned").click(function() { jQuery(".removedassignedhidden").val(jQuery(this).val()); });';
2508 $out .=
'jQuery(".assignedtouser").change(function() { console.log(jQuery(".assignedtouser option:selected").val());';
2509 $out .=
' if (jQuery(".assignedtouser option:selected").val() > 0) { jQuery("#' . $action .
'assignedtouser").attr("disabled", false); }';
2510 $out .=
' else { jQuery("#' . $action .
'assignedtouser").attr("disabled", true); }';
2512 $out .=
'})</script>';
2513 $out .= $this->
select_dolusers(
'', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter);
2514 $out .=
' <input type="submit" disabled class="button valignmiddle smallpaddingimp reposition" id="' . $action .
'assignedtouser" name="' . $action .
'assignedtouser" value="' .
dol_escape_htmltag($langs->trans(
"Add")) .
'">';
2541 public function select_dolresources_forevent($action =
'', $htmlname =
'userid', $show_empty = 0, $exclude =
null, $disabled = 0, $include = array(), $enableonly = array(), $force_entity =
'0', $maxlength = 0, $showstatus = 0, $morefilter =
'', $showproperties = 0, $listofresourceid = array())
2546 require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
2547 require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
2552 if (!empty($_SESSION[
'assignedtoresource'])) {
2553 $assignedtoresource = json_decode($_SESSION[
'assignedtoresource'],
true);
2554 if (!is_array($assignedtoresource)) {
2555 $assignedtoresource = array();
2558 $assignedtoresource = array();
2560 $nbassignetoresource = count($assignedtoresource);
2563 if ($nbassignetoresource) {
2564 $out .=
'<ul class="attendees">';
2568 foreach ($assignedtoresource as $key => $value) {
2570 $resourcestatic->fetch($value[
'id']);
2571 $out .= $resourcestatic->getNomUrl(-1);
2572 if ($nbassignetoresource >= 1 && $action !=
'view') {
2573 $out .=
' <input type="image" style="border: 0px;" src="' .
img_picto($langs->trans(
"Remove"),
'delete',
'', 0, 1) .
'" value="' . $resourcestatic->id .
'" class="removedassignedresource reposition" id="removedassignedresource_' . $resourcestatic->id .
'" name="removedassignedresource_' . $resourcestatic->id .
'">';
2576 if ($showproperties) {
2577 if (is_array($listofresourceid) && count($listofresourceid)) {
2578 $out .=
'<div class="myavailability inline-block">';
2579 $out .=
'<span class="hideonsmartphone"> - <span class="opacitymedium">' . $langs->trans(
"Availability") .
':</span> </span><input id="transparencyresource" class="paddingrightonly" ' . ($action ==
'view' ?
'disabled' :
'') .
' type="checkbox" name="transparency"' . ($listofresourceid[$value[
'id']][
'transparency'] ?
' checked' :
'') .
'><label for="transparency">' . $langs->trans(
"Busy") .
'</label>';
2589 if ($nbassignetoresource) {
2594 if ($action !=
'view') {
2595 $out .=
'<input type="hidden" class="removedassignedresourcehidden" name="removedassignedresource" value="">';
2596 $out .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">jQuery(document).ready(function () {';
2597 $out .=
'jQuery(".removedassignedresource").click(function() { jQuery(".removedassignedresourcehidden").val(jQuery(this).val()); });';
2598 $out .=
'jQuery(".assignedtoresource").change(function() { console.log(jQuery(".assignedtoresource option:selected").val());';
2599 $out .=
' if (jQuery(".assignedtoresource option:selected").val() > 0) { jQuery("#' . $action .
'assignedtoresource").attr("disabled", false); }';
2600 $out .=
' else { jQuery("#' . $action .
'assignedtoresource").attr("disabled", true); }';
2602 $out .=
'})</script>';
2605 $out .=
img_picto(
'',
'resource',
'class="pictofixedwidth"');
2606 $out .= $formresources->select_resource_list(0, $htmlname, [], 1, 1, 0, $events, array(), 2, 0);
2608 $out .=
' <input type="submit" disabled class="button valignmiddle smallpaddingimp reposition" id="' . $action .
'assignedtoresource" name="' . $action .
'assignedtoresource" value="' .
dol_escape_htmltag($langs->trans(
"Add")) .
'">';
2647 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)
2650 global $langs, $conf;
2655 $price_level = (!empty($price_level) ? $price_level : 0);
2656 if (is_null($ajaxoptions)) {
2657 $ajaxoptions = array();
2660 if (strval($filtertype) ===
'' && (isModEnabled(
"product") || isModEnabled(
"service"))) {
2661 if (isModEnabled(
"product") && !isModEnabled(
'service')) {
2663 } elseif (!isModEnabled(
'product') && isModEnabled(
"service")) {
2668 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'PRODUIT_USE_SEARCH_TO_SELECT')) {
2671 if ($selected && empty($selected_input_value)) {
2672 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
2673 $producttmpselect =
new Product($this->db);
2674 $producttmpselect->fetch($selected);
2675 $selected_input_value = $producttmpselect->ref;
2676 unset($producttmpselect);
2679 if ($filtertype ==
'') {
2680 if (!isModEnabled(
'product')) {
2682 } elseif (!isModEnabled(
'service')) {
2687 $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;
2688 if ((
int) $warehouseId > 0) {
2689 $urloption .=
'&warehouseid=' . (int) $warehouseId;
2691 $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);
2693 if (isModEnabled(
'variants') && is_array($selected_combinations)) {
2697 <!-- script to auto show attributes select tags if a variant was selected -->
2698 <script nonce="' .
getNonce() .
'">
2699 // auto show attributes fields
2700 selected = ' . json_encode($selected_combinations) .
';
2703 jQuery(document).ready(function () {
2705 jQuery("input[name=\'prod_entry_mode\']").change(function () {
2706 if (jQuery(this).val() == \'free\') {
2707 jQuery(\'div#attributes_box\').empty();
2711 jQuery("input#' . $htmlname .
'").change(function () {
2713 if (!jQuery(this).val()) {
2714 jQuery(\'div#attributes_box\').empty();
2718 console.log("A change has started. We get variants fields to inject html select");
2720 jQuery.getJSON("' . DOL_URL_ROOT .
'/variants/ajax/getCombinations.php", {
2721 id: jQuery(this).val()
2722 }, function (data) {
2723 jQuery(\'div#attributes_box\').empty();
2725 jQuery.each(data, function (key, val) {
2727 combvalues[val.id] = val.values;
2729 var span = jQuery(document.createElement(\'div\')).css({
2730 \'display\': \'table-row\'
2734 jQuery(document.createElement(\'div\')).text(val.label).css({
2735 \'font-weight\': \'bold\',
2736 \'display\': \'table-cell\'
2740 var html = jQuery(document.createElement(\'select\')).attr(\'name\', \'combinations[\' + val.id + \']\').css({
2741 \'margin-left\': \'15px\',
2742 \'white-space\': \'pre\'
2744 jQuery(document.createElement(\'option\')).val(\'\')
2747 jQuery.each(combvalues[val.id], function (key, val) {
2748 var tag = jQuery(document.createElement(\'option\')).val(val.id).html(val.value);
2750 if (selected[val.fk_product_attribute] == val.id) {
2751 tag.attr(\'selected\', \'selected\');
2758 jQuery(\'div#attributes_box\').append(span);
2763 ' . ($selected ?
'jQuery("input#' . $htmlname .
'").change();' :
'') .
'
2769 if (empty($hidelabel)) {
2770 $out .= $langs->trans(
"RefOrLabel") .
' : ';
2771 } elseif ($hidelabel > 1) {
2772 $placeholder =
' placeholder="' . $langs->trans(
"RefOrLabel") .
'"';
2773 if ($hidelabel == 2) {
2774 $out .=
img_picto($langs->trans(
"Search"),
'search');
2777 $out .=
'<input type="text" class="minwidth100' . ($morecss ?
' ' . $morecss :
'') .
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . $placeholder .
' ' . (
getDolGlobalString(
'PRODUCT_SEARCH_AUTOFOCUS') ?
'autofocus' :
'') .
' />';
2778 if ($hidelabel == 3) {
2779 $out .=
img_picto($langs->trans(
"Search"),
'search');
2782 $out .= $this->
select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level,
'', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus, $status_purchase, $warehouseId);
2785 if (empty($nooutput)) {
2809 public function select_bom($selected =
'', $htmlname =
'bom_id', $limit = 0, $status = 1, $type = 0, $showempty =
'1', $morecss =
'', $nooutput =
'', $forcecombo = 0, $TProducts = [])
2814 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
2820 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
2825 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
2827 $sql =
'SELECT b.rowid, b.ref, b.label, b.fk_product';
2828 $sql .=
' FROM ' . MAIN_DB_PREFIX .
'bom_bom as b';
2829 $sql .=
' WHERE b.entity IN (' .
getEntity(
'bom') .
')';
2830 if (!empty($status)) {
2831 $sql .=
' AND status = ' . (int) $status;
2833 if (!empty($type)) {
2834 $sql .=
' AND bomtype = ' . (int) $type;
2836 if (!empty($TProducts)) {
2837 $sql .=
' AND fk_product IN (' . $this->db->sanitize(implode(
',', $TProducts)) .
')';
2839 if (!empty($limit)) {
2840 $sql .=
' LIMIT ' . (int) $limit;
2842 $resql = $db->query($sql);
2845 $out .=
'<option value="-1"';
2846 if (empty($selected)) {
2847 $out .=
' selected';
2849 $out .=
'> </option>';
2851 while ($obj = $db->fetch_object($resql)) {
2853 $res = $product->fetch($obj->fk_product);
2854 $out .=
'<option value="' . $obj->rowid .
'"';
2855 if ($obj->rowid == $selected) {
2858 $out .=
'>' . $obj->ref .
' - ' . $product->label .
' - ' . $obj->label .
'</option>';
2864 $out .=
'</select>';
2865 if (empty($nooutput)) {
2900 public function select_produits_list($selected = 0, $htmlname =
'productid', $filtertype =
'', $limit = 20, $price_level = 0, $filterkey =
'', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty =
'1', $forcecombo = 0, $morecss =
'maxwidth500', $hidepriceinlabel = 0, $warehouseStatus =
'', $status_purchase = -1, $warehouseId = 0)
2904 global $hookmanager;
2907 $outarray = array();
2911 $langs->load(
'other');
2914 $warehouseStatusArray = array();
2915 if (!empty($warehouseStatus)) {
2916 require_once DOL_DOCUMENT_ROOT .
'/product/stock/class/entrepot.class.php';
2917 if (preg_match(
'/warehouseclosed/', $warehouseStatus)) {
2920 if (preg_match(
'/warehouseopen/', $warehouseStatus)) {
2923 if (preg_match(
'/warehouseinternal/', $warehouseStatus)) {
2928 $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";
2929 if (count($warehouseStatusArray)) {
2930 $selectFieldsGrouped =
", sum(" . $this->db->ifsql(
"e.statut IS NULL",
"0",
"ps.reel") .
") as stock";
2932 $selectFieldsGrouped =
", " . $this->db->ifsql(
"p.stock IS NULL", 0,
"p.stock") .
" AS stock";
2938 $parameters = array();
2939 $reshook = $hookmanager->executeHooks(
'selectProductsListSelect', $parameters);
2940 if (empty($reshook)) {
2941 $sql .= $selectFields.$selectFieldsGrouped.$hookmanager->resPrint;
2943 $sql .= $hookmanager->resPrint;
2948 $sql .=
", (SELECT " . $this->db->prefix() .
"categorie_product.fk_categorie
2949 FROM " . $this->db->prefix() .
"categorie_product
2950 WHERE " . $this->db->prefix() .
"categorie_product.fk_product=p.rowid
2952 ) AS categorie_product_id ";
2957 $sql .=
', pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,';
2958 $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';
2959 $selectFields .=
", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx, custdefault_vat_code, custref";
2963 $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";
2964 $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';
2969 $sql .=
", pl.label as label_translated";
2970 $sql .=
", pl.description as description_translated";
2971 $selectFields .=
", label_translated";
2972 $selectFields .=
", description_translated";
2976 $sql .=
", (SELECT pp.rowid FROM " . $this->db->prefix() .
"product_price as pp WHERE pp.fk_product = p.rowid";
2977 if ($price_level >= 1 &&
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
2978 $sql .=
" AND price_level = " . ((int) $price_level);
2980 $sql .=
" ORDER BY date_price";
2981 $sql .=
" DESC LIMIT 1) as price_rowid";
2982 $sql .=
", (SELECT pp.price_by_qty FROM " . $this->db->prefix() .
"product_price as pp WHERE pp.fk_product = p.rowid";
2983 if ($price_level >= 1 &&
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
2984 $sql .=
" AND price_level = " . ((int) $price_level);
2986 $sql .=
" ORDER BY date_price";
2987 $sql .=
" DESC LIMIT 1) as price_by_qty";
2988 $selectFields .=
", price_rowid, price_by_qty";
2991 $sql .=
" FROM ".$this->db->prefix().
"product as p";
2994 $sql .=
" USE INDEX (" . $this->db->sanitize(
getDolGlobalString(
'MAIN_PRODUCT_FORCE_INDEX')) .
")";
2998 $parameters = array();
2999 $reshook = $hookmanager->executeHooks(
'selectProductsListFrom', $parameters);
3000 $sql .= $hookmanager->resPrint;
3002 if (count($warehouseStatusArray)) {
3003 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_stock as ps on ps.fk_product = p.rowid";
3004 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (" .
getEntity(
'stock') .
")";
3005 $sql .=
' AND e.statut IN (' . $this->db->sanitize($this->db->escape(implode(
',', $warehouseStatusArray))) .
')';
3010 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
3015 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_customer_price as pcp ON pcp.fk_soc=" . ((int) $socid) .
" AND pcp.fk_product=p.rowid";
3019 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_units u ON u.rowid = p.fk_unit";
3023 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_lang as pl ON pl.fk_product = p.rowid ";
3025 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
3026 $soc =
new Societe($this->db);
3027 $result = $soc->fetch($socid);
3028 if ($result > 0 && !empty($soc->default_lang)) {
3029 $sql .=
" AND pl.lang = '" . $this->db->escape($soc->default_lang) .
"'";
3031 $sql .=
" AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) .
"'";
3034 $sql .=
" AND pl.lang = '" . $this->db->escape($langs->getDefaultLang()) .
"'";
3039 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_attribute_combination pac ON pac.fk_product_child = p.rowid";
3042 $sql .=
' WHERE p.entity IN (' .
getEntity(
'product') .
')';
3045 $sql .=
" AND pac.rowid IS NULL";
3048 if ($finished == 0) {
3049 $sql .=
" AND p.finished = " . ((int) $finished);
3050 } elseif ($finished == 1) {
3051 $sql .=
" AND p.finished = ".((int) $finished);
3054 $sql .=
" AND p.tosell = ".((int) $status);
3056 if ($status_purchase >= 0) {
3057 $sql .=
" AND p.tobuy = " . ((int) $status_purchase);
3060 if (strval($filtertype) !=
'') {
3061 $sql .=
" AND p.fk_product_type = " . ((int) $filtertype);
3062 } elseif (!isModEnabled(
'product')) {
3063 $sql .=
" AND p.fk_product_type = 1";
3064 } elseif (!isModEnabled(
'service')) {
3065 $sql .=
" AND p.fk_product_type = 0";
3068 if ((
int) $warehouseId > 0) {
3069 $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)";
3073 $parameters = array();
3074 $reshook = $hookmanager->executeHooks(
'selectProductsListWhere', $parameters);
3075 $sql .= $hookmanager->resPrint;
3077 if ($filterkey !=
'') {
3081 $search_crit = explode(
' ', $filterkey);
3083 if (count($search_crit) > 1) {
3086 foreach ($search_crit as $crit) {
3090 $sql .=
"(p.ref LIKE '" . $this->db->escape($prefix . $crit) .
"%' OR p.label LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3092 $sql .=
" OR pl.label LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3095 $sql .=
" OR pcp.ref_customer LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3098 $sql .=
" OR p.description LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3100 $sql .=
" OR pl.description LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3104 $sql .=
" OR pfp.ref_fourn LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3109 if (count($search_crit) > 1) {
3112 if (isModEnabled(
'barcode')) {
3113 $sql .=
" OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
3117 if (count($warehouseStatusArray)) {
3118 $sql .=
" GROUP BY " . $selectFields;
3123 $sql .=
" ORDER BY categorie_product_id ";
3125 (
getDolGlobalInt(
'PRODUCT_SORT_BY_CATEGORY') == 1) ? $sql .=
"ASC" : $sql .=
"DESC";
3127 $sql .= $this->db->order(
"p.ref");
3130 $sql .= $this->db->plimit($limit, 0);
3133 dol_syslog(get_class($this) .
"::select_produits_list search products", LOG_DEBUG);
3134 $result = $this->db->query($sql);
3136 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
3137 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3138 require_once DOL_DOCUMENT_ROOT .
'/core/lib/product.lib.php';
3140 $num = $this->db->num_rows($result);
3145 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
3149 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
3155 if ($showempty && !is_numeric($showempty)) {
3156 $textifempty = $langs->trans($showempty);
3158 $textifempty .= $langs->trans(
"All");
3161 if ($showempty && !is_numeric($showempty)) {
3162 $textifempty = $langs->trans($showempty);
3166 $out .=
'<option value="-1" selected>' . ($textifempty ? $textifempty :
' ') .
'</option>';
3170 while ($num && $i < $num) {
3173 $objp = $this->db->fetch_object($result);
3175 if ((
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY') ||
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1) {
3176 $sql =
"SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type";
3177 $sql .=
" FROM " . $this->db->prefix() .
"product_price_by_qty";
3178 $sql .=
" WHERE fk_product_price = " . ((int) $objp->price_rowid);
3179 $sql .=
" ORDER BY quantity ASC";
3181 dol_syslog(get_class($this) .
"::select_produits_list search prices by qty", LOG_DEBUG);
3182 $result2 = $this->db->query($sql);
3184 $nb_prices = $this->db->num_rows($result2);
3186 while ($nb_prices && $j < $nb_prices) {
3187 $objp2 = $this->db->fetch_object($result2);
3189 $objp->price_by_qty_rowid = $objp2->rowid;
3190 $objp->price_by_qty_price_base_type = $objp2->price_base_type;
3191 $objp->price_by_qty_quantity = $objp2->quantity;
3192 $objp->price_by_qty_unitprice = $objp2->unitprice;
3193 $objp->price_by_qty_remise_percent = $objp2->remise_percent;
3195 $objp->quantity = $objp2->quantity;
3196 $objp->price = $objp2->price;
3197 $objp->unitprice = $objp2->unitprice;
3198 $objp->remise_percent = $objp2->remise_percent;
3204 '@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';
3211 array_push($outarray, $optJson);
3215 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_price_expression)) {
3216 $price_product =
new Product($this->db);
3217 $price_product->fetch($objp->rowid,
'',
'', 1);
3219 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3221 $price_result = $priceparser->parseProduct($price_product);
3222 if ($price_result >= 0) {
3223 $objp->price = $price_result;
3224 $objp->unitprice = $price_result;
3226 $objp->price_ttc = (float)
price2num($objp->price) * (1 + ($objp->tva_tx / 100));
3227 $objp->price_ttc =
price2num($objp->price_ttc,
'MU');
3230 if (
getDolGlobalInt(
'PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES') && !empty($objp->custprice)) {
3238 array_push($outarray, $optJson);
3244 $out .=
'</select>';
3246 $this->db->free($result);
3248 if (empty($outputmode)) {
3275 protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey =
'', $novirtualstock = 0)
3277 global $langs, $conf, $user;
3278 global $hookmanager;
3284 $outlabel_translated =
'';
3286 $outdesc_translated =
'';
3292 $outpricebasetype =
'';
3294 $outdefault_vat_code =
'';
3298 $maxlengtharticle = (!
getDolGlobalString(
'PRODUCT_MAX_LENGTH_COMBO') ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
3300 $label = $objp->label;
3301 if (!empty($objp->label_translated)) {
3302 $label = $objp->label_translated;
3304 if (!empty($filterkey) && $filterkey !=
'') {
3305 $label = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $label, 1);
3308 $outkey = $objp->rowid;
3309 $outref = $objp->ref;
3310 $outrefcust = empty($objp->custref) ?
'' : $objp->custref;
3311 $outlabel = $objp->label;
3312 $outdesc = $objp->description;
3314 $outlabel_translated = $objp->label_translated;
3315 $outdesc_translated = $objp->description_translated;
3317 $outbarcode = $objp->barcode;
3318 $outorigin = $objp->fk_country;
3319 $outpbq = empty($objp->price_by_qty_rowid) ?
'' : $objp->price_by_qty_rowid;
3321 $outtype = $objp->fk_product_type;
3326 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
3332 if (!empty($objp->unit_short)) {
3333 $outvalUnits .=
' - ' . $objp->unit_short;
3337 if (!empty($objp->weight) && $objp->weight_units !==
null) {
3339 $outvalUnits .=
' - ' . $unitToShow;
3341 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !==
null) {
3342 $unitToShow = $objp->length .
' x ' . $objp->width .
' x ' . $objp->height .
' ' .
measuringUnitString(0,
'size', $objp->length_units);
3343 $outvalUnits .=
' - ' . $unitToShow;
3345 if (!empty($objp->surface) && $objp->surface_units !==
null) {
3347 $outvalUnits .=
' - ' . $unitToShow;
3349 if (!empty($objp->volume) && $objp->volume_units !==
null) {
3351 $outvalUnits .=
' - ' . $unitToShow;
3354 if ($outdurationvalue && $outdurationunit) {
3356 'h' => $langs->trans(
'Hour'),
3357 'd' => $langs->trans(
'Day'),
3358 'w' => $langs->trans(
'Week'),
3359 'm' => $langs->trans(
'Month'),
3360 'y' => $langs->trans(
'Year')
3362 if (isset($da[$outdurationunit])) {
3363 $outvalUnits .=
' - ' . $outdurationvalue .
' ' . $langs->transnoentities($da[$outdurationunit] . ($outdurationvalue > 1 ?
's' :
''));
3370 if ($user->hasRight(
'stock',
'lire')) {
3371 if ($objp->stock > 0) {
3373 } elseif ($objp->stock <= 0) {
3381 $labeltoshow .= $objp->ref;
3382 if (!empty($objp->custref)) {
3383 $labeltoshow .=
' (' . $objp->custref .
')';
3386 $labeltoshow .=
' (' . $outbarcode .
')';
3388 $labeltoshow .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3390 $labeltoshow .=
' (' .
getCountry($outorigin,
'1') .
')';
3394 $labeltoshowhtml =
'';
3395 $labeltoshowhtml .= $objp->ref;
3396 if (!empty($objp->custref)) {
3397 $labeltoshowhtml .=
' (' . $objp->custref .
')';
3399 if (!empty($filterkey) && $filterkey !=
'') {
3400 $labeltoshowhtml = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $labeltoshowhtml, 1);
3403 $labeltoshowhtml .=
' (' . $outbarcode .
')';
3405 $labeltoshowhtml .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3407 $labeltoshowhtml .=
' (' .
getCountry($outorigin,
'1') .
')';
3411 $labeltoshowstock =
'';
3412 $labeltoshowhtmlstock =
'';
3414 if ($user->hasRight(
'stock',
'lire')) {
3415 $labeltoshowstock .=
' - ' . $langs->trans(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'), 0, $langs, 0, 0);
3417 if ($objp->stock > 0) {
3418 $labeltoshowhtmlstock .=
' - <span class="product_line_stock_ok">';
3419 } elseif ($objp->stock <= 0) {
3420 $labeltoshowhtmlstock .=
' - <span class="product_line_stock_too_low">';
3422 $labeltoshowhtmlstock .= $langs->transnoentities(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'), 0, $langs, 0, 0);
3423 $labeltoshowhtmlstock .=
'</span>';
3425 if (empty($novirtualstock) &&
getDolGlobalString(
'STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO')) {
3426 $langs->load(
"stocks");
3428 $tmpproduct =
new Product($this->db);
3429 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3430 $tmpproduct->load_virtual_stock();
3431 $virtualstock = $tmpproduct->stock_theorique;
3433 $labeltoshowstock .=
' - ' . $langs->trans(
"VirtualStock") .
':' . $virtualstock;
3435 $labeltoshowhtmlstock .=
' - ' . $langs->transnoentities(
"VirtualStock") .
':';
3436 if ($virtualstock > 0) {
3437 $labeltoshowhtmlstock .=
'<span class="product_line_stock_ok">';
3438 } elseif ($virtualstock <= 0) {
3439 $labeltoshowhtmlstock .=
'<span class="product_line_stock_too_low">';
3441 $labeltoshowhtmlstock .= $virtualstock;
3442 $labeltoshowhtmlstock .=
'</span>';
3451 $labeltoshowprice =
'';
3452 $labeltoshowhtmlprice =
'';
3455 $sql =
"SELECT price, price_ttc, price_base_type, tva_tx, default_vat_code";
3456 $sql .=
" FROM " . $this->db->prefix() .
"product_price";
3457 $sql .=
" WHERE fk_product = " . ((int) $objp->rowid);
3458 $sql .=
" AND entity IN (" .
getEntity(
'productprice') .
")";
3459 $sql .=
" AND price_level = " . ((int) $price_level);
3460 $sql .=
" ORDER BY date_price DESC, rowid DESC";
3463 dol_syslog(get_class($this) .
'::constructProductListOption search price for product ' . $objp->rowid .
' AND level ' . $price_level, LOG_DEBUG);
3464 $result2 = $this->db->query($sql);
3466 $objp2 = $this->db->fetch_object($result2);
3469 if ($objp2->price_base_type ==
'HT') {
3470 $labeltoshowprice .=
' - ' .
price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"HT");
3471 $labeltoshowhtmlprice .=
' - ' .
price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"HT");
3473 $labeltoshowprice .=
' - ' .
price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"TTC");
3474 $labeltoshowhtmlprice .=
' - ' .
price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"TTC");
3476 $outprice_ht =
price($objp2->price);
3477 $outprice_ttc =
price($objp2->price_ttc);
3478 $outpricebasetype = $objp2->price_base_type;
3480 $outtva_tx = $objp2->tva_tx;
3481 $outdefault_vat_code = $objp2->default_vat_code;
3483 $outtva_tx = $objp->tva_tx;
3484 $outdefault_vat_code = $objp->default_vat_code;
3493 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1 && (
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY') ||
getDolGlobalString(
'PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES'))) {
3495 $outqty = $objp->quantity;
3496 $outdiscount = $objp->remise_percent;
3497 if ($objp->quantity == 1) {
3498 $labeltoshowprice .=
' - ' .
price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) .
"/";
3499 $labeltoshowhtmlprice .=
' - ' .
price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) .
"/";
3500 $labeltoshowprice .= $langs->trans(
"Unit");
3501 $labeltoshowhtmlprice .= $langs->transnoentities(
"Unit");
3503 $labeltoshowprice .=
' - ' .
price($objp->price, 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3504 $labeltoshowhtmlprice .=
' - ' .
price($objp->price, 0, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3505 $labeltoshowprice .= $langs->trans(
"Units");
3506 $labeltoshowhtmlprice .= $langs->transnoentities(
"Units");
3509 $outprice_ht =
price($objp->unitprice);
3510 $outprice_ttc =
price($objp->unitprice * (1 + ($objp->tva_tx / 100)));
3511 $outpricebasetype = $objp->price_base_type;
3512 $outtva_tx = $objp->tva_tx;
3513 $outdefault_vat_code = $objp->default_vat_code;
3515 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1) {
3516 $labeltoshowprice .=
" (" .
price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $langs->trans(
"Unit") .
")";
3517 $labeltoshowhtmlprice .=
" (" .
price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) .
"/" . $langs->transnoentities(
"Unit") .
")";
3519 if (empty($hidepriceinlabel) && !empty($objp->remise_percent) && $objp->remise_percent >= 1) {
3520 $labeltoshowprice .=
" - " . $langs->trans(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3521 $labeltoshowhtmlprice .=
" - " . $langs->transnoentities(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3526 if (!empty($objp->idprodcustprice)) {
3529 if ($objp->custprice_base_type ==
'HT') {
3530 $labeltoshowprice .=
' - ' .
price($objp->custprice, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"HT");
3531 $labeltoshowhtmlprice .=
' - ' .
price($objp->custprice, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"HT");
3533 $labeltoshowprice .=
' - ' .
price($objp->custprice_ttc, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"TTC");
3534 $labeltoshowhtmlprice .=
' - ' .
price($objp->custprice_ttc, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"TTC");
3537 $outprice_ht =
price($objp->custprice);
3538 $outprice_ttc =
price($objp->custprice_ttc);
3539 $outpricebasetype = $objp->custprice_base_type;
3540 $outtva_tx = $objp->custtva_tx;
3541 $outdefault_vat_code = $objp->custdefault_vat_code;
3546 if (empty($hidepriceinlabel) && !$found) {
3547 if ($objp->price_base_type ==
'HT') {
3548 $labeltoshowprice .=
' - ' .
price($objp->price, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"HT");
3549 $labeltoshowhtmlprice .=
' - ' .
price($objp->price, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"HT");
3551 $labeltoshowprice .=
' - ' .
price($objp->price_ttc, 1, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->trans(
"TTC");
3552 $labeltoshowhtmlprice .=
' - ' .
price($objp->price_ttc, 0, $langs, 0, 0, -1, $conf->currency) .
' ' . $langs->transnoentities(
"TTC");
3554 $outprice_ht =
price($objp->price);
3555 $outprice_ttc =
price($objp->price_ttc);
3556 $outpricebasetype = $objp->price_base_type;
3557 $outtva_tx = $objp->tva_tx;
3558 $outdefault_vat_code = $objp->default_vat_code;
3562 $opt =
'<option value="' . $objp->rowid .
'"';
3563 $opt .= ($objp->rowid == $selected) ?
' selected' :
'';
3564 if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) {
3565 $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 .
'"';
3568 $opt .=
' data-labeltrans="' . $outlabel_translated .
'"';
3572 if ($stocktag == 1) {
3573 $opt .=
' class="product_line_stock_ok" data-html="'.$labeltoshowhtml.$outvalUnits.$labeltoshowhtmlprice.dolPrintHTMLForAttribute($labeltoshowhtmlstock).
'"';
3576 if ($stocktag == -1) {
3577 $opt .=
' class="product_line_stock_too_low" data-html="'.$labeltoshowhtml.$outvalUnits.$labeltoshowhtmlprice.dolPrintHTMLForAttribute($labeltoshowhtmlstock).
'"';
3584 $opt .= $labeltoshow;
3585 $outval .= $labeltoshowhtml;
3588 $opt .= $outvalUnits;
3589 $outval .= $outvalUnits;
3592 $opt .= $labeltoshowprice;
3593 $outval .= $labeltoshowhtmlprice;
3596 $opt .= $labeltoshowstock;
3597 $outval .= $labeltoshowhtmlstock;
3600 $parameters = array(
'objp' => $objp);
3601 $reshook = $hookmanager->executeHooks(
'constructProductListOption', $parameters);
3602 if (empty($reshook)) {
3603 $opt .= $hookmanager->resPrint;
3605 $opt = $hookmanager->resPrint;
3608 $opt .=
"</option>\n";
3613 'label2' => $outlabel,
3617 'price_ttc' =>
price2num($outprice_ttc),
3620 'pricebasetype' => $outpricebasetype,
3621 'tva_tx' => $outtva_tx,
3622 'default_vat_code' => $outdefault_vat_code,
3624 'discount' => $outdiscount,
3625 'duration_value' => $outdurationvalue,
3626 'duration_unit' => $outdurationunit,
3628 'labeltrans' => $outlabel_translated,
3629 'desctrans' => $outdesc_translated,
3630 'ref_customer' => $outrefcust
3651 public function select_produits_fournisseurs($socid, $selected =
'', $htmlname =
'productid', $filtertype =
'', $filtre =
'', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss =
'', $placeholder =
'')
3654 global $langs, $conf;
3655 global $price_level, $status, $finished;
3657 if (!isset($status)) {
3661 $selected_input_value =
'';
3662 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'PRODUIT_USE_SEARCH_TO_SELECT')) {
3663 if ($selected > 0) {
3664 require_once DOL_DOCUMENT_ROOT .
'/product/class/product.class.php';
3665 $producttmpselect =
new Product($this->db);
3666 $producttmpselect->fetch($selected);
3667 $selected_input_value = $producttmpselect->ref;
3668 unset($producttmpselect);
3672 $urloption = ($socid > 0 ?
'socid=' . $socid .
'&' :
'') .
'htmlname=' . $htmlname .
'&outjson=1&price_level=' . $price_level .
'&type=' . $filtertype .
'&mode=2&status=' . $status .
'&finished=' . $finished .
'&alsoproductwithnosupplierprice=' . $alsoproductwithnosupplierprice;
3673 print
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT .
'/product/ajax/products.php', $urloption,
getDolGlobalInt(
'PRODUIT_USE_SEARCH_TO_SELECT'), 0, $ajaxoptions);
3675 print($hidelabel ?
'' : $langs->trans(
"RefOrLabel") .
' : ') .
'<input type="text" class="'.$morecss.
'" name="search_' . $htmlname .
'" id="search_' . $htmlname .
'" value="' . $selected_input_value .
'"' . ($placeholder ?
' placeholder="' . $placeholder .
'"' :
'') .
'>';
3677 print $this->
select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre,
'', $status, 0, 0, $alsoproductwithnosupplierprice, $morecss, 0, $placeholder);
3701 public function select_produits_fournisseurs_list($socid, $selected =
'', $htmlname =
'productid', $filtertype =
'', $filtre =
'', $filterkey =
'', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss =
'', $showstockinlist = 0, $placeholder =
'')
3704 global $langs, $conf, $user;
3705 global $hookmanager;
3708 $outarray = array();
3710 $maxlengtharticle = (!
getDolGlobalString(
'PRODUCT_MAX_LENGTH_COMBO') ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
3712 $langs->load(
'stocks');
3715 $langs->load(
'other');
3718 $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,";
3719 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice, pfp.barcode";
3720 $sql .=
", pfp.multicurrency_code, pfp.multicurrency_unitprice";
3721 $sql .=
", pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.default_vat_code, pfp.fk_soc, s.nom as name";
3722 $sql .=
", pfp.supplier_reputation";
3725 $sql .=
", pfp.desc_fourn as description";
3727 $sql .=
", p.description";
3731 $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";
3733 $sql .=
" FROM " . $this->db->prefix() .
"product as p";
3734 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (" .
getEntity(
'product') .
") )";
3736 $sql .=
" AND pfp.fk_soc = " . ((int) $socid);
3738 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON pfp.fk_soc = s.rowid";
3741 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"c_units u ON u.rowid = p.fk_unit";
3743 $sql .=
" WHERE p.entity IN (" .
getEntity(
'product') .
")";
3744 if ($statut != -1) {
3745 $sql .=
" AND p.tobuy = " . ((int) $statut);
3747 if (strval($filtertype) !=
'') {
3748 $sql .=
" AND p.fk_product_type = " . ((int) $filtertype);
3750 if (!empty($filtre)) {
3751 $sql .=
" " . $filtre;
3754 $parameters = array();
3755 $reshook = $hookmanager->executeHooks(
'selectSuppliersProductsListWhere', $parameters);
3756 $sql .= $hookmanager->resPrint;
3758 if ($filterkey !=
'') {
3762 $search_crit = explode(
' ', $filterkey);
3764 if (count($search_crit) > 1) {
3767 foreach ($search_crit as $crit) {
3771 $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) .
"%'";
3773 $sql .=
" OR pfp.desc_fourn LIKE '" . $this->db->escape($prefix . $crit) .
"%'";
3778 if (count($search_crit) > 1) {
3781 if (isModEnabled(
'barcode')) {
3782 $sql .=
" OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
3783 $sql .=
" OR pfp.barcode LIKE '" . $this->db->escape($prefix . $filterkey) .
"%'";
3787 $sql .=
" ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
3788 $sql .= $this->db->plimit($limit, 0);
3792 dol_syslog(get_class($this) .
"::select_produits_fournisseurs_list", LOG_DEBUG);
3793 $result = $this->db->query($sql);
3795 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3796 require_once DOL_DOCUMENT_ROOT .
'/core/lib/product.lib.php';
3798 $num = $this->db->num_rows($result);
3801 $out .=
'<select class="flat ' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'">';
3803 $out .=
'<option value="-1" selected>' . ($placeholder ? $placeholder :
' ') .
'</option>';
3805 $out .=
'<option value="-1">' . ($placeholder ? $placeholder :
' ') .
'</option>';
3810 $objp = $this->db->fetch_object($result);
3812 if (is_null($objp->idprodfournprice)) {
3814 $objp->tva_tx = $objp->tva_tx_sale;
3815 $objp->default_vat_code = $objp->default_vat_code_sale;
3818 $outkey = $objp->idprodfournprice;
3819 if (!$outkey && $alsoproductwithnosupplierprice) {
3820 $outkey =
'idprod_' . $objp->rowid;
3823 $outref = $objp->ref;
3824 $outbarcode = $objp->barcode;
3827 $outtype = $objp->fk_product_type;
3834 if (!empty($objp->unit_short)) {
3835 $outvalUnits .=
' - ' . $objp->unit_short;
3837 if (!empty($objp->weight) && $objp->weight_units !==
null) {
3839 $outvalUnits .=
' - ' . $unitToShow;
3841 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !==
null) {
3842 $unitToShow = $objp->length .
' x ' . $objp->width .
' x ' . $objp->height .
' ' .
measuringUnitString(0,
'size', $objp->length_units);
3843 $outvalUnits .=
' - ' . $unitToShow;
3845 if (!empty($objp->surface) && $objp->surface_units !==
null) {
3847 $outvalUnits .=
' - ' . $unitToShow;
3849 if (!empty($objp->volume) && $objp->volume_units !==
null) {
3851 $outvalUnits .=
' - ' . $unitToShow;
3853 if ($outdurationvalue && $outdurationunit) {
3855 'h' => $langs->trans(
'Hour'),
3856 'd' => $langs->trans(
'Day'),
3857 'w' => $langs->trans(
'Week'),
3858 'm' => $langs->trans(
'Month'),
3859 'y' => $langs->trans(
'Year')
3861 if (isset($da[$outdurationunit])) {
3862 $outvalUnits .=
' - ' . $outdurationvalue .
' ' . $langs->transnoentities($da[$outdurationunit] . ($outdurationvalue > 1 ?
's' :
''));
3867 $objRef = $objp->ref;
3868 if ($filterkey && $filterkey !=
'') {
3869 $objRef = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRef, 1);
3871 $objRefFourn = $objp->ref_fourn;
3872 if ($filterkey && $filterkey !=
'') {
3873 $objRefFourn = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $objRefFourn, 1);
3875 $label = $objp->label;
3876 if ($filterkey && $filterkey !=
'') {
3877 $label = preg_replace(
'/(' . preg_quote($filterkey,
'/') .
')/i',
'<strong>$1</strong>', $label, 1);
3880 switch ($objp->fk_product_type) {
3892 if (empty($picto)) {
3895 $optlabel =
img_object(
'', $picto,
'class="paddingright classfortooltip"', 0, 0, 1);
3898 $optlabel .= $objp->ref;
3899 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
3900 $optlabel .=
' <span class="opacitymedium">(' . $objp->ref_fourn .
')</span>';
3902 if (isModEnabled(
'barcode') && !empty($objp->barcode)) {
3903 $optlabel .=
' (' . $outbarcode .
')';
3905 $optlabel .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3907 $outvallabel = $objRef;
3908 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
3909 $outvallabel .=
' (' . $objRefFourn .
')';
3911 if (isModEnabled(
'barcode') && !empty($objp->barcode)) {
3912 $outvallabel .=
' (' . $outbarcode .
')';
3914 $outvallabel .=
' - ' .
dol_trunc($label, $maxlengtharticle);
3917 $optlabel .= $outvalUnits;
3918 $outvallabel .= $outvalUnits;
3920 if (!empty($objp->idprodfournprice)) {
3921 $outqty = $objp->quantity;
3922 $outdiscount = $objp->remise_percent;
3923 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_supplier_price_expression)) {
3925 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
3926 $prod_supplier->id = $objp->fk_product;
3927 $prod_supplier->fourn_qty = $objp->quantity;
3928 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
3929 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
3931 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
3933 $price_result = $priceparser->parseProductSupplier($prod_supplier);
3934 if ($price_result >= 0) {
3935 $objp->fprice = $price_result;
3936 if ($objp->quantity >= 1) {
3937 $objp->unitprice = $objp->fprice / $objp->quantity;
3941 if ($objp->quantity == 1) {
3942 $optlabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/";
3943 $outvallabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency) .
"/";
3944 $optlabel .= $langs->trans(
"Unit");
3945 $outvallabel .= $langs->transnoentities(
"Unit");
3947 $optlabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3948 $outvallabel .=
' - ' .
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency) .
"/" . $objp->quantity;
3949 $optlabel .=
' ' . $langs->trans(
"Units");
3950 $outvallabel .=
' ' . $langs->transnoentities(
"Units");
3953 if ($objp->quantity > 1) {
3954 $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") .
")";
3955 $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") .
")";
3957 if ($objp->remise_percent >= 1) {
3958 $optlabel .=
" - " . $langs->trans(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3959 $outvallabel .=
" - " . $langs->transnoentities(
"Discount") .
" : " .
vatrate($objp->remise_percent) .
' %';
3961 if ($objp->duration) {
3962 $optlabel .=
" - " . $objp->duration;
3963 $outvallabel .=
" - " . $objp->duration;
3966 $optlabel .=
" - " .
dol_trunc($objp->name, 8);
3967 $outvallabel .=
" - " .
dol_trunc($objp->name, 8);
3969 if ($objp->supplier_reputation) {
3971 $reputations = array(
'' => $langs->trans(
'Standard'),
'FAVORITE' => $langs->trans(
'Favorite'),
'NOTTHGOOD' => $langs->trans(
'NotTheGoodQualitySupplier'),
'DONOTORDER' => $langs->trans(
'DoNotOrderThisProductToThisSupplier'));
3973 $optlabel .=
" - " . $reputations[$objp->supplier_reputation];
3974 $outvallabel .=
" - " . $reputations[$objp->supplier_reputation];
3977 $optlabel .=
" - <span class='opacitymedium'>" . $langs->trans(
"NoPriceDefinedForThisSupplier") .
'</span>';
3978 $outvallabel .=
' - ' . $langs->transnoentities(
"NoPriceDefinedForThisSupplier");
3982 $novirtualstock = ($showstockinlist == 2);
3984 if ($user->hasRight(
'stock',
'lire')) {
3985 $outvallabel .=
' - ' . $langs->trans(
"Stock") .
': ' .
price(
price2num($objp->stock,
'MS'), 0, $langs, 0, 0);
3987 if ($objp->stock > 0) {
3988 $optlabel .=
' - <span class="product_line_stock_ok">';
3989 } elseif ($objp->stock <= 0) {
3990 $optlabel .=
' - <span class="product_line_stock_too_low">';
3992 $optlabel .= $langs->transnoentities(
"Stock") .
':' .
price(
price2num($objp->stock,
'MS'));
3993 $optlabel .=
'</span>';
3994 if (empty($novirtualstock) &&
getDolGlobalString(
'STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO')) {
3995 $langs->load(
"stocks");
3997 $tmpproduct =
new Product($this->db);
3998 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3999 $tmpproduct->load_virtual_stock();
4000 $virtualstock = $tmpproduct->stock_theorique;
4002 $outvallabel .=
' - ' . $langs->trans(
"VirtualStock") .
':' . $virtualstock;
4004 $optlabel .=
' - ' . $langs->transnoentities(
"VirtualStock") .
':';
4005 if ($virtualstock > 0) {
4006 $optlabel .=
'<span class="product_line_stock_ok">';
4007 } elseif ($virtualstock <= 0) {
4008 $optlabel .=
'<span class="product_line_stock_too_low">';
4010 $optlabel .= $virtualstock;
4011 $optlabel .=
'</span>';
4018 $optstart =
'<option value="' . $outkey .
'"';
4019 if ($selected && $selected == $objp->idprodfournprice) {
4020 $optstart .=
' selected';
4022 if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) {
4023 $optstart .=
' disabled';
4026 if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
4035 $optstart .=
' data-default-vat-code="' .
dol_escape_htmltag($objp->default_vat_code) .
'"';
4037 if (isModEnabled(
'multicurrency')) {
4038 $optstart .=
' data-multicurrency-code="' .
dol_escape_htmltag($objp->multicurrency_code) .
'"';
4039 $optstart .=
' data-multicurrency-unitprice="' .
dol_escape_htmltag($objp->multicurrency_unitprice) .
'"';
4042 $optstart .=
' data-description="' .
dol_escape_htmltag($objp->description, 0, 1) .
'"';
4044 $outarrayentry = array(
4047 'label' => $outvallabel,
4049 'price_qty_ht' =>
price2num($objp->fprice,
'MU'),
4050 'price_unit_ht' =>
price2num($objp->unitprice,
'MU'),
4051 'price_ht' =>
price2num($objp->unitprice,
'MU'),
4052 'tva_tx_formated' =>
price($objp->tva_tx, 0, $langs, 1, -1, 2),
4054 'default_vat_code' => $objp->default_vat_code,
4055 'supplier_ref' => $objp->ref_fourn,
4056 'discount' => $outdiscount,
4058 'duration_value' => $outdurationvalue,
4059 'duration_unit' => $outdurationunit,
4060 'disabled' => empty($objp->idprodfournprice),
4061 'description' => $objp->description
4063 if (isModEnabled(
'multicurrency')) {
4064 $outarrayentry[
'multicurrency_code'] = $objp->multicurrency_code;
4065 $outarrayentry[
'multicurrency_unitprice'] =
price2num($objp->multicurrency_unitprice,
'MU');
4068 $parameters = array(
4070 'optstart' => &$optstart,
4071 'optlabel' => &$optlabel,
4072 'outvallabel' => &$outvallabel,
4073 'outarrayentry' => &$outarrayentry,
4076 $reshook = $hookmanager->executeHooks(
'selectProduitsFournisseurListOption', $parameters, $this);
4082 $out .= $optstart .
' data-html="' .
dol_escape_htmltag($optlabel) .
'">' . $optlabel .
"</option>\n";
4083 $outarraypush = array(
4086 'label' => $outvallabel,
4088 'price_qty_ht' =>
price2num($objp->fprice,
'MU'),
4089 'price_qty_ht_locale' =>
price($objp->fprice),
4090 'price_unit_ht' =>
price2num($objp->unitprice,
'MU'),
4091 'price_unit_ht_locale' =>
price($objp->unitprice),
4092 'price_ht' =>
price2num($objp->unitprice,
'MU'),
4093 'tva_tx_formated' =>
price($objp->tva_tx),
4095 'default_vat_code' => $objp->default_vat_code,
4096 'supplier_ref' => $objp->ref_fourn,
4097 'discount' => $outdiscount,
4099 'duration_value' => $outdurationvalue,
4100 'duration_unit' => $outdurationunit,
4101 'disabled' => empty($objp->idprodfournprice),
4102 'description' => $objp->description
4104 if (isModEnabled(
'multicurrency')) {
4105 $outarraypush[
'multicurrency_code'] = $objp->multicurrency_code;
4106 $outarraypush[
'multicurrency_unitprice'] =
price2num($objp->multicurrency_unitprice,
'MU');
4108 array_push($outarray, $outarraypush);
4121 $out .=
'</select>';
4123 $this->db->free($result);
4125 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
4131 if (empty($outputmode)) {
4150 global $langs, $conf;
4152 $langs->load(
'stocks');
4154 $sql =
"SELECT p.rowid, p.ref, p.label, p.price, p.duration, pfp.fk_soc,";
4155 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,";
4156 $sql .=
" pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name";
4157 $sql .=
" FROM " . $this->db->prefix() .
"product as p";
4158 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
4159 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"societe as s ON pfp.fk_soc = s.rowid";
4160 $sql .=
" WHERE pfp.entity IN (" .
getEntity(
'productsupplierprice') .
")";
4161 $sql .=
" AND p.tobuy = 1";
4162 $sql .=
" AND s.fournisseur = 1";
4163 $sql .=
" AND p.rowid = " . ((int) $productid);
4165 $sql .=
" ORDER BY s.nom, pfp.ref_fourn DESC";
4167 $sql .=
" ORDER BY pfp.unitprice ASC";
4170 dol_syslog(get_class($this) .
"::select_product_fourn_price", LOG_DEBUG);
4171 $result = $this->db->query($sql);
4174 $num = $this->db->num_rows($result);
4176 $form =
'<select class="flat" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
4179 $form .=
'<option value="0">-- ' . $langs->trans(
"NoSupplierPriceDefinedForThisProduct") .
' --</option>';
4181 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
4182 $form .=
'<option value="0"> </option>';
4186 $objp = $this->db->fetch_object($result);
4188 $opt =
'<option value="' . $objp->idprodfournprice .
'"';
4190 if ($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier) || ($i == 0 &&
getDolGlobalString(
'PRODUCT_BEST_SUPPLIER_PRICE_PRESELECTED'))) {
4191 $opt .=
' selected';
4193 $opt .=
'>' . $objp->name .
' - ' . $objp->ref_fourn .
' - ';
4195 if (isModEnabled(
'dynamicprices') && !empty($objp->fk_supplier_price_expression)) {
4197 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
4198 $prod_supplier->id = $productid;
4199 $prod_supplier->fourn_qty = $objp->quantity;
4200 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
4201 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
4203 require_once DOL_DOCUMENT_ROOT .
'/product/dynamic_price/class/price_parser.class.php';
4205 $price_result = $priceparser->parseProductSupplier($prod_supplier);
4206 if ($price_result >= 0) {
4207 $objp->fprice = $price_result;
4208 if ($objp->quantity >= 1) {
4209 $objp->unitprice = $objp->fprice / $objp->quantity;
4213 if ($objp->quantity == 1) {
4214 $opt .=
price($objp->fprice * (
getDolGlobalString(
'DISPLAY_DISCOUNTED_SUPPLIER_PRICE') ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency) .
"/";
4217 $opt .= $objp->quantity .
' ';
4219 if ($objp->quantity == 1) {
4220 $opt .= $langs->trans(
"Unit");
4222 $opt .= $langs->trans(
"Units");
4224 if ($objp->quantity > 1) {
4226 $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");
4228 if ($objp->duration) {
4229 $opt .=
" - " . $objp->duration;
4231 $opt .=
"</option>\n";
4238 $form .=
'</select>';
4239 $this->db->free($result);
4259 $num = count($this->cache_conditions_paiements);
4266 $sql =
"SELECT rowid, code, libelle as label, deposit_percent";
4267 $sql .=
" FROM " . $this->db->prefix() .
'c_payment_term';
4268 $sql .=
" WHERE entity IN (" .
getEntity(
'c_payment_term') .
")";
4269 $sql .=
" AND active > 0";
4270 $sql .=
" ORDER BY sortorder";
4272 $resql = $this->db->query($sql);
4274 $num = $this->db->num_rows($resql);
4277 $obj = $this->db->fetch_object($resql);
4280 $label = ($langs->trans(
"PaymentConditionShort" . $obj->code) !=
"PaymentConditionShort" . $obj->code ? $langs->trans(
"PaymentConditionShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4281 $this->cache_conditions_paiements[$obj->rowid][
'code'] = $obj->code;
4282 $this->cache_conditions_paiements[$obj->rowid][
'label'] = $label;
4283 $this->cache_conditions_paiements[$obj->rowid][
'deposit_percent'] = $obj->deposit_percent;
4308 $num = count($this->cache_availability);
4315 $langs->load(
'propal');
4317 $sql =
"SELECT rowid, code, label, position";
4318 $sql .=
" FROM " . $this->db->prefix() .
'c_availability';
4319 $sql .=
" WHERE active > 0";
4321 $resql = $this->db->query($sql);
4323 $num = $this->db->num_rows($resql);
4326 $obj = $this->db->fetch_object($resql);
4329 $label = ($langs->trans(
"AvailabilityType" . $obj->code) !=
"AvailabilityType" . $obj->code ? $langs->trans(
"AvailabilityType" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4330 $this->cache_availability[$obj->rowid][
'code'] = $obj->code;
4331 $this->cache_availability[$obj->rowid][
'label'] = $label;
4332 $this->cache_availability[$obj->rowid][
'position'] = $obj->position;
4336 $this->cache_availability =
dol_sort_array($this->cache_availability,
'position',
'asc', 0, 0, 1);
4357 global $langs, $user;
4361 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
4363 print
'<select id="' . $htmlname .
'" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4365 print
'<option value="0"> </option>';
4367 foreach ($this->cache_availability as
$id => $arrayavailability) {
4368 if ($selected ==
$id) {
4369 print
'<option value="' .
$id .
'" selected>';
4371 print
'<option value="' .
$id .
'">';
4378 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4392 $num = count($this->cache_demand_reason);
4397 $sql =
"SELECT rowid, code, label";
4398 $sql .=
" FROM " . $this->db->prefix() .
'c_input_reason';
4399 $sql .=
" WHERE active > 0";
4401 $resql = $this->db->query($sql);
4403 $num = $this->db->num_rows($resql);
4405 $tmparray = array();
4407 $obj = $this->db->fetch_object($resql);
4410 $label = ($obj->label !=
'-' ? $obj->label :
'');
4411 if ($langs->trans(
"DemandReasonType" . $obj->code) !=
"DemandReasonType" . $obj->code) {
4412 $label = $langs->trans(
"DemandReasonType" . $obj->code);
4414 if ($langs->trans($obj->code) != $obj->code) {
4415 $label = $langs->trans($obj->code);
4418 $tmparray[$obj->rowid][
'id'] = $obj->rowid;
4419 $tmparray[$obj->rowid][
'code'] = $obj->code;
4420 $tmparray[$obj->rowid][
'label'] = $label;
4424 $this->cache_demand_reason =
dol_sort_array($tmparray,
'label',
'asc', 0, 0, 1);
4446 public function selectInputReason($selected =
'', $htmlname =
'demandreasonid', $exclude =
'', $addempty = 0, $morecss =
'', $notooltip = 0)
4448 global $langs, $user;
4452 print
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
4454 print
'<option value="0"' . (empty($selected) ?
' selected' :
'') .
'> </option>';
4456 foreach ($this->cache_demand_reason as
$id => $arraydemandreason) {
4457 if ($arraydemandreason[
'code'] == $exclude) {
4461 if ($selected && ($selected == $arraydemandreason[
'id'] || $selected == $arraydemandreason[
'code'])) {
4462 print
'<option value="' . $arraydemandreason[
'id'] .
'" selected>';
4464 print
'<option value="' . $arraydemandreason[
'id'] .
'">';
4466 $label = $arraydemandreason[
'label'];
4467 print $langs->trans($label);
4471 if ($user->admin && empty($notooltip)) {
4472 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4489 $num = count($this->cache_types_paiements);
4496 $this->cache_types_paiements = array();
4498 $sql =
"SELECT id, code, libelle as label, type, active";
4499 $sql .=
" FROM " . $this->db->prefix() .
"c_paiement";
4500 $sql .=
" WHERE entity IN (" .
getEntity(
'c_paiement') .
")";
4502 $resql = $this->db->query($sql);
4504 $num = $this->db->num_rows($resql);
4507 $obj = $this->db->fetch_object($resql);
4510 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) !=
"PaymentTypeShort" . $obj->code ? $langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4511 $this->cache_types_paiements[$obj->id][
'id'] = $obj->id;
4512 $this->cache_types_paiements[$obj->id][
'code'] = $obj->code;
4513 $this->cache_types_paiements[$obj->id][
'label'] = $label;
4514 $this->cache_types_paiements[$obj->id][
'type'] = $obj->type;
4515 $this->cache_types_paiements[$obj->id][
'active'] = $obj->active;
4519 $this->cache_types_paiements =
dol_sort_array($this->cache_types_paiements,
'label',
'asc', 0, 0, 1);
4549 public function select_conditions_paiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1, $noprint = 0)
4553 if (empty($noprint)) {
4577 public function getSelectConditionsPaiements($selected = 0, $htmlname =
'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss =
'', $deposit_percent = -1)
4579 global $langs, $user, $conf;
4582 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
4588 dol_syslog(__METHOD__ .
"Using deprecated option MAIN_DEFAULT_PAYMENT_TERM_ID", LOG_NOTICE);
4592 $out .=
'<select id="' . $htmlname .
'" class="flat selectpaymentterms' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4594 $out .=
'<option value="0"> </option>';
4597 $selectedDepositPercent =
null;
4599 foreach ($this->cache_conditions_paiements as
$id => $arrayconditions) {
4600 if ($filtertype <= 0 && !empty($arrayconditions[
'deposit_percent'])) {
4604 if ($selected ==
$id) {
4605 $selectedDepositPercent = $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'];
4606 $out .=
'<option value="' .
$id .
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'" selected>';
4608 $out .=
'<option value="' .
$id .
'" data-deposit_percent="' . $arrayconditions[
'deposit_percent'] .
'">';
4610 $label = $arrayconditions[
'label'];
4612 if (!empty($arrayconditions[
'deposit_percent'])) {
4613 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $arrayconditions[
'deposit_percent'], $label);
4617 $out .=
'</option>';
4619 $out .=
'</select>';
4620 if ($user->admin && empty($noinfoadmin)) {
4621 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4625 if ($deposit_percent >= 0) {
4626 $out .=
' <span id="' . $htmlname .
'_deposit_percent_container"' . (empty($selectedDepositPercent) ?
' style="display: none"' :
'') .
'>';
4627 $out .= $langs->trans(
'DepositPercent') .
' : ';
4628 $out .=
'<input id="' . $htmlname .
'_deposit_percent" name="' . $htmlname .
'_deposit_percent" class="maxwidth50" value="' . $deposit_percent .
'" />';
4631 <script nonce="' .
getNonce() .
'">
4632 $(document).ready(function () {
4633 $("#' . $htmlname .
'").change(function () {
4634 let $selected = $(this).find("option:selected");
4635 let depositPercent = $selected.attr("data-deposit_percent");
4637 if (depositPercent.length > 0) {
4638 $("#' . $htmlname .
'_deposit_percent_container").show().find("#' . $htmlname .
'_deposit_percent").val(depositPercent);
4640 $("#' . $htmlname .
'_deposit_percent_container").hide();
4671 public function select_types_paiements($selected =
'', $htmlname =
'paiementtype', $filtertype =
'', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'', $nooutput = 0)
4674 global $langs, $user, $conf;
4678 dol_syslog(__METHOD__ .
" " . $selected .
", " . $htmlname .
", " . $filtertype .
", " . $format, LOG_DEBUG);
4680 $filterarray = array();
4681 if ($filtertype ==
'CRDT') {
4682 $filterarray = array(0, 2, 3);
4683 } elseif ($filtertype ==
'DBIT') {
4684 $filterarray = array(1, 2, 3);
4685 } elseif ($filtertype !=
'' && $filtertype !=
'-1') {
4686 $filterarray = explode(
',', $filtertype);
4693 dol_syslog(__METHOD__ .
"Using deprecated option MAIN_DEFAULT_PAYMENT_TYPE_ID", LOG_NOTICE);
4697 $out .=
'<select id="select' . $htmlname .
'" class="flat selectpaymenttypes' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4699 $out .=
'<option value=""> </option>';
4701 foreach ($this->cache_types_paiements as
$id => $arraytypes) {
4703 if ($active >= 0 && $arraytypes[
'active'] != $active) {
4708 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray)) {
4713 if ($empty && empty($arraytypes[
'code'])) {
4718 $out .=
'<option value="' .
$id .
'"';
4719 } elseif ($format == 1) {
4720 $out .=
'<option value="' . $arraytypes[
'code'] .
'"';
4721 } elseif ($format == 2) {
4722 $out .=
'<option value="' . $arraytypes[
'code'] .
'"';
4723 } elseif ($format == 3) {
4724 $out .=
'<option value="' .
$id .
'"';
4727 if ($format == 1 || $format == 2) {
4728 if ($selected == $arraytypes[
'code']) {
4729 $out .=
' selected';
4732 if ($selected ==
$id) {
4733 $out .=
' selected';
4739 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4740 } elseif ($format == 1) {
4741 $value = $arraytypes[
'code'];
4742 } elseif ($format == 2) {
4743 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4744 } elseif ($format == 3) {
4745 $value = $arraytypes[
'code'];
4747 $out .= $value ? $value :
' ';
4748 $out .=
'</option>';
4750 $out .=
'</select>';
4751 if ($user->admin && !$noadmininfo) {
4752 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4756 if (empty($nooutput)) {
4775 public function selectTypesIban($selected =
'', $htmlname =
'ribList', $empty = 0, $morecss =
'', $nooutput = 0, $ribForSelection = [])
4777 $out =
'<select id="select' . $htmlname .
'" class="flat selectrib' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4779 $out .=
'<option value=""> </option>';
4782 foreach ($ribForSelection as $rib) {
4783 $selectedAttribute = $selected == $rib ?
'selected' :
'';
4784 $out .=
'<option value="' . $rib .
'" '.$selectedAttribute.
'>';
4786 $out .=
'</option>';
4788 $out .=
'</select>';
4791 if (empty($nooutput)) {
4811 $return =
'<select class="flat maxwidth100" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
4813 'HT' => $langs->trans(
"HT"),
4814 'TTC' => $langs->trans(
"TTC")
4816 foreach ($options as
$id => $value) {
4817 if ($selected ==
$id) {
4818 $return .=
'<option value="' .
$id .
'" selected>' . $value;
4820 $return .=
'<option value="' .
$id .
'">' . $value;
4822 $return .=
'</option>';
4824 $return .=
'</select>';
4844 $num = count($this->cache_transport_mode);
4851 $this->cache_transport_mode = array();
4853 $sql =
"SELECT rowid, code, label, active";
4854 $sql .=
" FROM " . $this->db->prefix() .
"c_transport_mode";
4855 $sql .=
" WHERE entity IN (" .
getEntity(
'c_transport_mode') .
")";
4857 $resql = $this->db->query($sql);
4859 $num = $this->db->num_rows($resql);
4862 $obj = $this->db->fetch_object($resql);
4865 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) !=
"PaymentTypeShort" . $obj->code ? $langs->transnoentitiesnoconv(
"PaymentTypeShort" . $obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
4866 $this->cache_transport_mode[$obj->rowid][
'rowid'] = $obj->rowid;
4867 $this->cache_transport_mode[$obj->rowid][
'code'] = $obj->code;
4868 $this->cache_transport_mode[$obj->rowid][
'label'] = $label;
4869 $this->cache_transport_mode[$obj->rowid][
'active'] = $obj->active;
4873 $this->cache_transport_mode =
dol_sort_array($this->cache_transport_mode,
'label',
'asc', 0, 0, 1);
4895 public function selectTransportMode($selected =
'', $htmlname =
'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'')
4897 global $langs, $user;
4899 dol_syslog(__METHOD__ .
" " . $selected .
", " . $htmlname .
", " . $format, LOG_DEBUG);
4903 print
'<select id="select' . $htmlname .
'" class="flat selectmodetransport' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
4905 print
'<option value=""> </option>';
4907 foreach ($this->cache_transport_mode as
$id => $arraytypes) {
4909 if ($active >= 0 && $arraytypes[
'active'] != $active) {
4914 if ($empty && empty($arraytypes[
'code'])) {
4919 print
'<option value="' .
$id .
'"';
4920 } elseif ($format == 1) {
4921 print
'<option value="' . $arraytypes[
'code'] .
'"';
4922 } elseif ($format == 2) {
4923 print
'<option value="' . $arraytypes[
'code'] .
'"';
4924 } elseif ($format == 3) {
4925 print
'<option value="' .
$id .
'"';
4928 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraytypes[
'code']) {
4930 } elseif ($selected ==
$id) {
4936 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4937 } elseif ($format == 1) {
4938 $value = $arraytypes[
'code'];
4939 } elseif ($format == 2) {
4940 $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
4941 } elseif ($format == 3) {
4942 $value = $arraytypes[
'code'];
4944 print $value ? $value :
' ';
4951 if ($user->admin && !$noadmininfo) {
4952 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4968 public function selectShippingMethod($selected =
'', $htmlname =
'shipping_method_id', $filtre =
'', $useempty = 0, $moreattrib =
'', $noinfoadmin = 0, $morecss =
'')
4970 global $langs, $user;
4972 $langs->load(
"admin");
4973 $langs->load(
"deliveries");
4975 $sql =
"SELECT rowid, code, libelle as label";
4976 $sql .=
" FROM " . $this->db->prefix() .
"c_shipment_mode";
4977 $sql .=
" WHERE active > 0";
4979 $sql .=
" AND " . $filtre;
4981 $sql .=
" ORDER BY libelle ASC";
4983 dol_syslog(get_class($this) .
"::selectShippingMode", LOG_DEBUG);
4984 $result = $this->db->query($sql);
4986 $num = $this->db->num_rows($result);
4989 print
'<select id="select' . $htmlname .
'" class="flat selectshippingmethod' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
4990 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
4991 print
'<option value="-1"> </option>';
4994 $obj = $this->db->fetch_object($result);
4995 if ($selected == $obj->rowid) {
4996 print
'<option value="' . $obj->rowid .
'" selected>';
4998 print
'<option value="' . $obj->rowid .
'">';
5000 print ($langs->trans(
"SendingMethod" . strtoupper($obj->code)) !=
"SendingMethod" . strtoupper($obj->code)) ? $langs->trans(
"SendingMethod" . strtoupper($obj->code)) : $obj->label;
5005 if ($user->admin && empty($noinfoadmin)) {
5006 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
5011 print $langs->trans(
"NoShippingMethodDefined");
5031 $langs->load(
"deliveries");
5033 if ($htmlname !=
"none") {
5034 print
'<form method="POST" action="' . $page .
'">';
5035 print
'<input type="hidden" name="action" value="setshippingmethod">';
5036 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
5038 print
'<input type="submit" class="button valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
5042 $code = $langs->getLabelFromKey($this->db, $selected,
'c_shipment_mode',
'rowid',
'code');
5043 print $langs->trans(
"SendingMethod" . strtoupper($code));
5062 $langs->load(
'bills');
5064 $opt =
'<option value="" selected></option>';
5065 $sql =
"SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc";
5066 $sql .=
' FROM ' . $this->db->prefix() .
'facture';
5067 $sql .=
' WHERE entity IN (' .
getEntity(
'invoice') .
')';
5068 $sql .=
' AND situation_counter >= 1';
5069 $sql .=
' AND fk_soc = ' . (int) $socid;
5070 $sql .=
' AND type <> 2';
5071 $sql .=
' ORDER by situation_cycle_ref, situation_counter desc';
5072 $resql = $this->db->query($sql);
5074 if ($resql && $this->db->num_rows($resql) > 0) {
5077 while ($obj = $this->db->fetch_object($resql)) {
5079 if ($obj->situation_cycle_ref != $ref) {
5081 $ref = $obj->situation_cycle_ref;
5083 if ($obj->situation_final != 1) {
5085 if (substr($obj->ref, 1, 4) !=
'PROV') {
5086 if ($selected == $obj->rowid) {
5087 $opt .=
'<option value="' . $obj->rowid .
'" selected>' . $obj->ref .
'</option>';
5089 $opt .=
'<option value="' . $obj->rowid .
'">' . $obj->ref .
'</option>';
5096 dol_syslog(
"Error sql=" . $sql .
", error=" . $this->error, LOG_ERR);
5098 if ($opt ==
'<option value ="" selected></option>') {
5099 $opt =
'<option value ="0" selected>' . $langs->trans(
'NoSituations') .
'</option>';
5113 public function selectUnits($selected =
'', $htmlname =
'units', $showempty = 0, $unit_type =
'')
5117 $langs->load(
'products');
5119 $return =
'<select class="flat" id="' . $htmlname .
'" name="' . $htmlname .
'">';
5121 $sql =
"SELECT rowid, label, code FROM " . $this->db->prefix() .
"c_units";
5122 $sql .=
' WHERE active > 0';
5123 if (!empty($unit_type)) {
5124 $sql .=
" AND unit_type = '" . $this->db->escape($unit_type) .
"'";
5126 $sql .=
" ORDER BY sortorder";
5128 $resql = $this->db->query($sql);
5129 if ($resql && $this->db->num_rows($resql) > 0) {
5131 $return .=
'<option value="none"></option>';
5134 while ($res = $this->db->fetch_object($resql)) {
5135 $unitLabel = $res->label;
5136 if (!empty($langs->tab_translate[
'unit' . $res->code])) {
5137 $unitLabel = $langs->trans(
'unit' . $res->code) != $res->label ? $langs->trans(
'unit' . $res->code) : $res->label;
5140 if ($selected == $res->rowid) {
5141 $return .=
'<option value="' . $res->rowid .
'" selected>' . $unitLabel .
'</option>';
5143 $return .=
'<option value="' . $res->rowid .
'">' . $unitLabel .
'</option>';
5146 $return .=
'</select>';
5167 public function select_comptes($selected =
'', $htmlname =
'accountid', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'', $showcurrency = 0, $morecss =
'', $nooutput = 0)
5174 $langs->load(
"admin");
5177 $sql =
"SELECT rowid, label, bank, clos as status, currency_code";
5178 $sql .=
" FROM " . $this->db->prefix() .
"bank_account";
5179 $sql .=
" WHERE entity IN (" .
getEntity(
'bank_account') .
")";
5181 $sql .=
" AND clos = " . (int) $status;
5184 $sql .=
" AND " . $filtre;
5186 $sql .=
" ORDER BY label";
5188 dol_syslog(get_class($this) .
"::select_comptes", LOG_DEBUG);
5189 $result = $this->db->query($sql);
5191 $num = $this->db->num_rows($result);
5194 $out .=
'<select id="select' . $htmlname .
'" class="flat selectbankaccount' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
5198 $out .=
'<option class="opacitymedium" value="-1">' . $langs->trans(
"NoActiveBankAccountDefined") .
'</span>';
5200 $out .=
'<option class="opacitymedium" value="-1">' . $langs->trans(
"NoBankAccountFound") .
'</span>';
5203 if (!empty($useempty) && !is_numeric($useempty)) {
5204 $out .=
'<option value="-1">'.$langs->trans($useempty).
'</option>';
5205 } elseif ($useempty == 1 || ($useempty == 2 && $num > 1)) {
5206 $out .=
'<option value="-1"> </option>';
5211 $obj = $this->db->fetch_object($result);
5213 $labeltoshow = trim($obj->label);
5214 $labeltoshowhtml = trim($obj->label);
5215 if ($showcurrency) {
5216 $labeltoshow .=
' (' . $obj->currency_code .
')';
5217 $labeltoshowhtml .=
' <span class="opacitymedium">(' . $obj->currency_code .
')</span>';
5219 if ($status == 2 && $obj->status == 1) {
5220 $labeltoshow .=
' (' . $langs->trans(
"Closed") .
')';
5221 $labeltoshowhtml .=
' <span class="opacitymedium">(' . $langs->trans(
"Closed") .
')</span>';
5224 if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected))) {
5225 $out .=
'<option value="' . $obj->rowid .
'" data-currency-code="' . $obj->currency_code .
'" data-html="'.dolPrintHTMLForAttribute($labeltoshowhtml).
'" selected>';
5227 $out .=
'<option value="' . $obj->rowid .
'" data-currency-code="' . $obj->currency_code .
'" data-html="'.dolPrintHTMLForAttribute($labeltoshowhtml).
'">';
5229 $out .= $labeltoshow;
5230 $out .=
'</option>';
5233 $out .=
"</select>";
5240 if (empty($nooutput)) {
5260 public function selectEstablishments($selected =
'', $htmlname =
'entity', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'')
5264 $langs->load(
"admin");
5267 $sql =
"SELECT rowid, name, fk_country, status, entity";
5268 $sql .=
" FROM " . $this->db->prefix() .
"establishment";
5269 $sql .=
" WHERE 1=1";
5271 $sql .=
" AND status = " . (int) $status;
5274 $sql .=
" AND " . $filtre;
5276 $sql .=
" ORDER BY name";
5278 dol_syslog(get_class($this) .
"::select_establishment", LOG_DEBUG);
5279 $result = $this->db->query($sql);
5281 $num = $this->db->num_rows($result);
5284 print
'<select id="select' . $htmlname .
'" class="flat selectestablishment" name="' . $htmlname .
'"' . ($moreattrib ?
' ' . $moreattrib :
'') .
'>';
5285 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
5286 print
'<option value="-1"> </option>';
5290 $obj = $this->db->fetch_object($result);
5291 if ($selected == $obj->rowid) {
5292 print
'<option value="' . $obj->rowid .
'" selected>';
5294 print
'<option value="' . $obj->rowid .
'">';
5296 print trim($obj->name);
5297 if ($status == 2 && $obj->status == 1) {
5298 print
' (' . $langs->trans(
"Closed") .
')';
5306 print
'<span class="opacitymedium">' . $langs->trans(
"NoActiveEstablishmentDefined") .
'</span>';
5308 print
'<span class="opacitymedium">' . $langs->trans(
"NoEstablishmentFound") .
'</span>';
5331 if ($htmlname !=
"none") {
5332 print
'<form method="POST" action="' . $page .
'">';
5333 print
'<input type="hidden" name="action" value="setbankaccount">';
5334 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
5335 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
5336 $nbaccountfound = $this->
select_comptes($selected, $htmlname, 0,
'', $addempty);
5337 if ($nbaccountfound > 0) {
5338 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
5342 $langs->load(
'banks');
5345 require_once DOL_DOCUMENT_ROOT .
'/compta/bank/class/account.class.php';
5346 $bankstatic =
new Account($this->db);
5347 $result = $bankstatic->fetch($selected);
5349 print $bankstatic->getNomUrl(1);
5378 public function select_all_categories($type, $selected =
'', $htmlname =
"parent", $maxlength = 64, $fromid = 0, $outputmode = 0, $include = 0, $morecss =
'', $useempty = 1)
5381 global $conf, $langs;
5382 $langs->load(
"categories");
5384 include_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
5387 if (is_numeric($type)) {
5388 dol_syslog(__METHOD__ .
': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
5391 if ($type === Categorie::TYPE_BANK_LINE) {
5394 $cate_arbo = array();
5395 $sql =
"SELECT c.label, c.rowid";
5396 $sql .=
" FROM " . $this->db->prefix() .
"categorie as c";
5397 $sql .=
" WHERE entity = " . $conf->entity .
" AND type = " . ((int) $cat->getMapId()[$type]);
5398 $sql .=
" ORDER BY c.label";
5399 $result = $this->db->query($sql);
5401 $num = $this->db->num_rows($result);
5404 $objp = $this->db->fetch_object($result);
5406 $cate_arbo[$objp->rowid] = array(
'id' => $objp->rowid,
'fulllabel' => $objp->label,
'color' =>
'',
'picto' =>
'category');
5410 $this->db->free($result);
5416 $cate_arbo = $cat->get_full_arbo($type, $fromid, $include);
5419 $outarray = array();
5420 $outarrayrichhtml = array();
5423 $output =
'<select class="flat minwidth100' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
5424 if (is_array($cate_arbo)) {
5425 $num = count($cate_arbo);
5428 $output .=
'<option value="-1" disabled>' . $langs->trans(
"NoCategoriesDefined") .
'</option>';
5430 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
5431 $output .=
'<option value="-1"> </option>';
5433 foreach ($cate_arbo as $key => $value) {
5434 if ($cate_arbo[$key][
'id'] == $selected || ($selected ===
'auto' && count($cate_arbo) == 1)) {
5440 $labeltoshow =
img_picto(
'',
'category',
'class="pictofixedwidth" style="color: #' . $cate_arbo[$key][
'color'] .
'"');
5441 $labeltoshow .=
dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle');
5443 $outarray[$cate_arbo[$key][
'id']] = $cate_arbo[$key][
'fulllabel'];
5445 $outarrayrichhtml[$cate_arbo[$key][
'id']] = $labeltoshow;
5447 $output .=
'<option ' . $add .
'value="' . $cate_arbo[$key][
'id'] .
'"';
5450 $output .=
dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle');
5451 $output .=
'</option>';
5453 $cate_arbo[$key][
'data-html'] = $labeltoshow;
5457 $output .=
'</select>';
5460 if ($outputmode == 2) {
5463 } elseif ($outputmode == 1) {
5465 } elseif ($outputmode == 3) {
5466 return $outarrayrichhtml;
5491 public function form_confirm($page, $title, $question, $action, $formquestion = array(), $selectedchoice =
"", $useajax = 0, $height = 170, $width = 500)
5494 dol_syslog(__METHOD__ .
': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING);
5495 print $this->
formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width);
5525 public function formconfirm($page, $title, $question, $action, $formquestion =
'', $selectedchoice =
'', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0, $labelbuttonyes =
'Yes', $labelbuttonno =
'No')
5527 global $langs, $conf;
5529 $more =
'<!-- formconfirm - before call, page=' .
dol_escape_htmltag($page) .
' -->';
5535 $newselectedchoice = empty($selectedchoice) ?
"no" : $selectedchoice;
5536 if ($conf->browser->layout ==
'phone') {
5541 if (empty($height)) {
5543 if (is_array($formquestion) && count($formquestion) > 2) {
5544 $height += ((count($formquestion) - 2) * 24);
5548 if (is_array($formquestion) && !empty($formquestion)) {
5550 foreach ($formquestion as $key => $input) {
5551 if (is_array($input) && !empty($input)) {
5552 if ($input[
'type'] ==
'hidden') {
5553 $moreattr = (!empty($input[
'moreattr']) ?
' ' . $input[
'moreattr'] :
'');
5554 $morecss = (!empty($input[
'morecss']) ?
' ' . $input[
'morecss'] :
'');
5562 $moreonecolumn =
'';
5563 $more .=
'<div class="tagtable paddingtopbottomonly centpercent noborderspacing">' .
"\n";
5564 foreach ($formquestion as $key => $input) {
5565 if (is_array($input) && !empty($input)) {
5566 $size = (!empty($input[
'size']) ?
' size="' . $input[
'size'] .
'"' :
'');
5567 $moreattr = (!empty($input[
'moreattr']) ?
' ' . $input[
'moreattr'] :
'');
5568 $morecss = (!empty($input[
'morecss']) ?
' ' . $input[
'morecss'] :
'');
5570 if ($input[
'type'] ==
'text') {
5571 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div><div class="tagtd"><input type="text" class="flat' . $morecss .
'" id="' .
dol_escape_htmltag($input[
'name']) .
'" name="' .
dol_escape_htmltag($input[
'name']) .
'"' . $size .
' value="' . (empty($input[
'value']) ?
'' : $input[
'value']) .
'"' . $moreattr .
' /></div></div>' .
"\n";
5572 } elseif ($input[
'type'] ==
'password') {
5573 $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";
5574 } elseif ($input[
'type'] ==
'textarea') {
5580 $moreonecolumn .=
'<div class="margintoponly">';
5581 $moreonecolumn .= $input[
'label'] .
'<br>';
5583 $moreonecolumn .= $input[
'value'];
5584 $moreonecolumn .=
'</textarea>';
5585 $moreonecolumn .=
'</div>';
5586 } elseif (in_array($input[
'type'], [
'select',
'multiselect'])) {
5587 if (empty($morecss)) {
5588 $morecss =
'minwidth100';
5591 $show_empty = isset($input[
'select_show_empty']) ? $input[
'select_show_empty'] : 1;
5592 $key_in_label = isset($input[
'select_key_in_label']) ? $input[
'select_key_in_label'] : 0;
5593 $value_as_key = isset($input[
'select_value_as_key']) ? $input[
'select_value_as_key'] : 0;
5594 $translate = isset($input[
'select_translate']) ? $input[
'select_translate'] : 0;
5595 $maxlen = isset($input[
'select_maxlen']) ? $input[
'select_maxlen'] : 0;
5596 $disabled = isset($input[
'select_disabled']) ? $input[
'select_disabled'] : 0;
5597 $sort = isset($input[
'select_sort']) ? $input[
'select_sort'] :
'';
5599 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">';
5600 if (!empty($input[
'label'])) {
5601 $more .= $input[
'label'] .
'</div><div class="tagtd left">';
5603 if ($input[
'type'] ==
'select') {
5604 $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);
5606 $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);
5608 $more .=
'</div></div>' .
"\n";
5609 } elseif ($input[
'type'] ==
'checkbox') {
5610 $more .=
'<div class="tagtr">';
5611 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'"><label for="' .
dol_escape_htmltag($input[
'name']) .
'">' . $input[
'label'] .
'</label></div><div class="tagtd">';
5612 $more .=
'<input type="checkbox" class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' .
dol_escape_htmltag($input[
'name']) .
'" name="' .
dol_escape_htmltag($input[
'name']) .
'"' . $moreattr;
5613 if (!is_bool($input[
'value']) && $input[
'value'] !=
'false' && $input[
'value'] !=
'0' && $input[
'value'] !=
'') {
5614 $more .=
' checked';
5616 if (is_bool($input[
'value']) && $input[
'value']) {
5617 $more .=
' checked';
5619 if (isset($input[
'disabled'])) {
5620 $more .=
' disabled';
5622 $more .=
' /></div>';
5623 $more .=
'</div>' .
"\n";
5624 } elseif ($input[
'type'] ==
'radio') {
5626 foreach ($input[
'values'] as $selkey => $selval) {
5627 $more .=
'<div class="tagtr">';
5628 if (isset($input[
'label'])) {
5630 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
' tdtop' : (
' tdtop ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div>';
5632 $more .=
'<div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' "' . $input[
'tdclass'])) .
'"> </div>';
5635 $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;
5636 if (!empty($input[
'disabled'])) {
5637 $more .=
' disabled';
5639 if (isset($input[
'default']) && $input[
'default'] === $selkey) {
5640 $more .=
' checked="checked"';
5643 $more .=
'<label for="' .
dol_escape_htmltag($input[
'name'] . $selkey) .
'" class="valignmiddle">' . $selval .
'</label>';
5644 $more .=
'</div></div>' .
"\n";
5647 } elseif ($input[
'type'] ==
'date' || $input[
'type'] ==
'datetime') {
5648 $more .=
'<div class="tagtr"><div class="tagtd' . (empty($input[
'tdclass']) ?
'' : (
' ' . $input[
'tdclass'])) .
'">' . $input[
'label'] .
'</div>';
5649 $more .=
'<div class="tagtd">';
5650 $addnowlink = (empty($input[
'datenow']) ? 0 : 1);
5652 if ($input[
'type'] ==
'datetime') {
5653 $h = isset($input[
'hours']) ? $input[
'hours'] : 1;
5654 $m = isset($input[
'minutes']) ? $input[
'minutes'] : 1;
5656 $more .= $this->
selectDate(isset($input[
'value']) ? $input[
'value'] : -1, $input[
'name'], $h, $m, 0,
'', 1, $addnowlink);
5657 $more .=
'</div></div>'.
"\n";
5658 $formquestion[] = array(
'name' => $input[
'name'].
'day');
5659 $formquestion[] = array(
'name' => $input[
'name'].
'month');
5660 $formquestion[] = array(
'name' => $input[
'name'].
'year');
5661 $formquestion[] = array(
'name' => $input[
'name'].
'hour');
5662 $formquestion[] = array(
'name' => $input[
'name'].
'min');
5663 } elseif ($input[
'type'] ==
'other') {
5664 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">';
5665 if (!empty($input[
'label'])) {
5666 $more .= $input[
'label'] .
'</div><div class="tagtd">';
5668 $more .= $input[
'value'];
5669 $more .=
'</div></div>' .
"\n";
5670 } elseif ($input[
'type'] ==
'onecolumn') {
5671 $moreonecolumn .=
'<div class="margintoponly">';
5672 $moreonecolumn .= $input[
'value'];
5673 $moreonecolumn .=
'</div>' .
"\n";
5674 } elseif ($input[
'type'] ==
'hidden') {
5676 } elseif ($input[
'type'] ==
'separator') {
5679 $more .=
'Error type ' . $input[
'type'] .
' for the confirm box is not a supported type';
5683 $more .=
'</div>' .
"\n";
5684 $more .= $moreonecolumn;
5690 if (!empty($conf->dol_use_jmobile)) {
5693 if (empty($conf->use_javascript_ajax)) {
5699 $dialogconfirm =
'dialog-confirm';
5701 if (!is_numeric($useajax)) {
5705 $dialogconfirm .=
'-' . $button;
5707 $pageyes = $page . (preg_match(
'/\?/', $page) ?
'&' :
'?') .
'action=' . urlencode($action) .
'&confirm=yes';
5708 $pageno = ($useajax == 2 ? $page . (preg_match(
'/\?/', $page) ?
'&' :
'?') .
'action=' . urlencode($action) .
'&confirm=no' :
'');
5711 if (is_array($formquestion)) {
5712 foreach ($formquestion as $key => $input) {
5715 if (is_array($input) && isset($input[
'name'])) {
5716 if (strpos($input[
'name'],
',') > 0) {
5717 $inputok = array_merge($inputok, explode(
',', $input[
'name']));
5719 array_push($inputok, $input[
'name']);
5724 if (is_array($input) && isset($input[
'inputko']) && $input[
'inputko'] == 1 && isset($input[
'name'])) {
5725 array_push($inputko, $input[
'name']);
5731 $formconfirm .=
'<div id="' . $dialogconfirm .
'" title="' .
dol_escape_htmltag($title) .
'" style="display: none;">';
5732 if (is_array($formquestion) && array_key_exists(
'text', $formquestion) && !empty($formquestion[
'text'])) {
5733 $formconfirm .=
'<div class="confirmtext">' . $formquestion[
'text'] .
'</div>' .
"\n";
5735 if (!empty($more)) {
5736 $formconfirm .=
'<div class="confirmquestions">' . $more .
'</div>' .
"\n";
5738 $formconfirm .= ($question ?
'<div class="confirmmessage">' .
img_help(0,
'') .
' ' . $question .
'</div>' :
'');
5739 $formconfirm .=
'</div>' .
"\n";
5741 $formconfirm .=
"\n<!-- begin code of popup for formconfirm page=" . $page .
" -->\n";
5742 $formconfirm .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">' .
"\n";
5743 $formconfirm .=
"/* Code for the jQuery('#dialogforpopup').dialog() */\n";
5744 $formconfirm .=
'jQuery(document).ready(function() {
5746 $( "#' . $dialogconfirm .
'" ).dialog(
5748 autoOpen: ' . ($autoOpen ?
"true" :
"false") .
',';
5749 if ($newselectedchoice ==
'no') {
5752 $(this).parent().find("button.ui-button:eq(2)").focus();
5757 if ($useajax == 1) {
5758 $jsforcursor =
'// The call to urljump can be slow, so we set the wait cursor' .
"\n";
5759 $jsforcursor .=
'jQuery("html,body,#id-container").addClass("cursorwait");' .
"\n";
5762 $postconfirmas =
'GET';
5766 height: "' . $height .
'",
5767 width: "' . $width .
'",
5769 closeOnEscape: false,
5771 "' .
dol_escape_js($langs->transnoentities($labelbuttonyes)) .
'": function() {
5772 var options = "token=' . urlencode(
newToken()) .
'";
5773 var inputok = ' . json_encode($inputok) .
'; /* List of fields into form */
5774 var page = "' .
dol_escape_js(!empty($page) ? $page :
'') .
'";
5775 var pageyes = "' .
dol_escape_js(!empty($pageyes) ? $pageyes :
'') .
'";
5777 if (inputok.length > 0) {
5778 $.each(inputok, function(i, inputname) {
5781 if ($("input[name=\'" + inputname + "\']").attr("type") == "radio") {
5782 inputvalue = $("input[name=\'" + inputname + "\']:checked").val();
5784 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
5785 inputvalue = $("#" + inputname + more).val();
5787 if (typeof inputvalue == "undefined") { inputvalue=""; }
5788 console.log("formconfirm check inputname="+inputname+" inputvalue="+inputvalue);
5789 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
5792 var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "&") + options;
5793 if (pageyes.length > 0) {';
5794 if ($postconfirmas ==
'GET') {
5795 $formconfirm .=
'location.href = urljump;';
5797 $formconfirm .= $jsforcursor;
5798 $formconfirm .=
'var post = $.post(
5801 function(data) { $("body").html(data); jQuery("html,body,#id-container").removeClass("cursorwait"); }
5805 console.log("after post ok");
5807 $(this).dialog("close");
5809 "' .
dol_escape_js($langs->transnoentities($labelbuttonno)) .
'": function() {
5810 var options = "token=' . urlencode(
newToken()) .
'";
5811 var inputko = ' . json_encode($inputko) .
'; /* List of fields into form */
5812 var page = "' .
dol_escape_js(!empty($page) ? $page :
'') .
'";
5813 var pageno="' .
dol_escape_js(!empty($pageno) ? $pageno :
'') .
'";
5814 if (inputko.length > 0) {
5815 $.each(inputko, function(i, inputname) {
5817 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
5818 var inputvalue = $("#" + inputname + more).val();
5819 if (typeof inputvalue == "undefined") { inputvalue=""; }
5820 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
5823 var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "&") + options;
5825 if (pageno.length > 0) {';
5826 if ($postconfirmas ==
'GET') {
5827 $formconfirm .=
'location.href = urljump;';
5829 $formconfirm .= $jsforcursor;
5830 $formconfirm .=
'var post = $.post(
5833 function(data) { $("body").html(data); jQuery("html,body,#id-container").removeClass("cursorwait"); }
5837 console.log("after post ko");
5839 $(this).dialog("close");
5845 var button = "' . $button .
'";
5846 if (button.length > 0) {
5847 $( "#" + button ).click(function() {
5848 $("#' . $dialogconfirm .
'").dialog("open");
5854 $formconfirm .=
"<!-- end ajax formconfirm -->\n";
5856 $formconfirm .=
"\n<!-- begin formconfirm page=" .
dol_escape_htmltag($page) .
" -->\n";
5858 if (empty($disableformtag)) {
5859 $formconfirm .=
'<form method="POST" action="' . $page .
'" class="notoptoleftnoright">' .
"\n";
5862 $formconfirm .=
'<input type="hidden" name="action" value="' . $action .
'">' .
"\n";
5863 $formconfirm .=
'<input type="hidden" name="token" value="' .
newToken() .
'">' .
"\n";
5865 $formconfirm .=
'<table class="valid centpercent">' .
"\n";
5868 $formconfirm .=
'<tr class="validtitre"><td class="validtitre" colspan="2">';
5869 $formconfirm .=
img_picto(
'',
'pictoconfirm') .
' ' . $title;
5870 $formconfirm .=
'</td></tr>' .
"\n";
5873 if (is_array($formquestion) && array_key_exists(
'text', $formquestion) && !empty($formquestion[
'text'])) {
5874 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="2">' . $formquestion[
'text'] .
'</td></tr>' .
"\n";
5879 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="2">' .
"\n";
5880 $formconfirm .= $more;
5881 $formconfirm .=
'</td></tr>' .
"\n";
5885 $formconfirm .=
'<tr class="valid">';
5886 $formconfirm .=
'<td class="valid">' . $question .
'</td>';
5887 $formconfirm .=
'<td class="valid center">';
5888 $formconfirm .= $this->
selectyesno(
"confirm", $newselectedchoice, 0,
false, 0, 0,
'marginleftonly marginrightonly', $labelbuttonyes, $labelbuttonno);
5889 $formconfirm .=
'<input class="button valignmiddle confirmvalidatebutton small" type="submit" value="' . $langs->trans(
"Validate") .
'">';
5890 $formconfirm .=
'</td>';
5891 $formconfirm .=
'</tr>' .
"\n";
5893 $formconfirm .=
'</table>' .
"\n";
5895 if (empty($disableformtag)) {
5896 $formconfirm .=
"</form>\n";
5898 $formconfirm .=
'<br>';
5900 if (!empty($conf->use_javascript_ajax)) {
5901 $formconfirm .=
'<!-- code to disable button to avoid double clic -->';
5902 $formconfirm .=
'<script nonce="' .
getNonce() .
'" type="text/javascript">' .
"\n";
5904 $(document).ready(function () {
5905 $(".confirmvalidatebutton").on("click", function() {
5906 console.log("We click on button confirmvalidatebutton");
5907 $(this).attr("disabled", "disabled");
5908 setTimeout(\'$(".confirmvalidatebutton").removeAttr("disabled")\', 3000);
5909 //console.log($(this).closest("form"));
5910 $(this).closest("form").submit();
5914 $formconfirm .=
'</script>' .
"\n";
5917 $formconfirm .=
"<!-- end formconfirm -->\n";
5920 return $formconfirm;
5941 public function form_project($page, $socid, $selected =
'', $htmlname =
'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0, $textifnoproject =
'', $morecss =
'')
5946 require_once DOL_DOCUMENT_ROOT .
'/core/lib/project.lib.php';
5947 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.formprojet.class.php';
5953 $langs->load(
"project");
5954 if ($htmlname !=
"none") {
5955 $out .=
'<form method="post" action="' . $page .
'">';
5956 $out .=
'<input type="hidden" name="action" value="classin">';
5957 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
5958 $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0,
'', 1, 0, $morecss);
5959 $out .=
'<input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
5962 $out .=
'<span class="project_head_block">';
5964 $projet =
new Project($this->db);
5965 $projet->fetch($selected);
5966 $out .= $projet->getNomUrl(0,
'', 1);
5968 $out .=
'<span class="opacitymedium">' . $textifnoproject .
'</span>';
5973 if (empty($nooutput)) {
5997 public function form_conditions_reglement($page, $selected =
'', $htmlname =
'cond_reglement_id', $addempty = 0, $type =
'', $filtertype = -1, $deposit_percent = -1, $nooutput = 0)
6004 if ($htmlname !=
"none") {
6005 $out .=
'<form method="POST" action="' . $page .
'">';
6006 $out .=
'<input type="hidden" name="action" value="setconditions">';
6007 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6009 $out .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
6012 $out .=
'<input type="submit" class="button valignmiddle smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
6017 if (isset($this->cache_conditions_paiements[$selected])) {
6018 $label = $this->cache_conditions_paiements[$selected][
'label'];
6020 if (!empty($this->cache_conditions_paiements[$selected][
'deposit_percent'])) {
6021 $label = str_replace(
'__DEPOSIT_PERCENT__', $deposit_percent > 0 ? $deposit_percent : $this->cache_conditions_paiements[$selected][
'deposit_percent'], $label);
6026 $langs->load(
'errors');
6027 $out .= $langs->trans(
'ErrorNotInDictionaryPaymentConditions');
6034 if (empty($nooutput)) {
6056 if ($htmlname !=
"none") {
6057 print
'<form method="post" action="' . $page .
'">';
6058 print
'<input type="hidden" name="action" value="setavailability">';
6059 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6061 print
'<input type="submit" name="modify" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
6062 print
'<input type="submit" name="cancel" class="button smallpaddingimp" value="' . $langs->trans(
"Cancel") .
'">';
6067 print $this->cache_availability[$selected][
'label'];
6084 public function formInputReason($page, $selected =
'', $htmlname =
'demandreason', $addempty = 0)
6087 if ($htmlname !=
"none") {
6088 print
'<form method="post" action="' . $page .
'">';
6089 print
'<input type="hidden" name="action" value="setdemandreason">';
6090 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6092 print
'<input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'">';
6097 foreach ($this->cache_demand_reason as $key => $val) {
6098 if ($val[
'id'] == $selected) {
6099 print $val[
'label'];
6124 public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0, $type =
'')
6131 if ($htmlname !=
"none") {
6132 $ret .=
'<form method="POST" action="' . $page .
'" name="form' . $htmlname .
'">';
6133 $ret .=
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
6134 $ret .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6136 $ret .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
6138 $ret .=
'<table class="nobordernopadding">';
6140 $ret .= $this->
selectDate($selected, $htmlname, $displayhour, $displaymin, 1,
'form' . $htmlname, 1, 0);
6142 $ret .=
'<td class="left"><input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'"></td>';
6143 $ret .=
'</tr></table></form>';
6152 if (empty($nooutput)) {
6171 public function form_users($page, $selected =
'', $htmlname =
'userid', $exclude = array(), $include = array())
6176 if ($htmlname !=
"none") {
6177 print
'<form method="POST" action="' . $page .
'" name="form' . $htmlname .
'">';
6178 print
'<input type="hidden" name="action" value="set' . $htmlname .
'">';
6179 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6180 print $this->
select_dolusers($selected, $htmlname, 1, $exclude, 0, $include);
6181 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6185 require_once DOL_DOCUMENT_ROOT .
'/user/class/user.class.php';
6186 $theuser =
new User($this->db);
6187 $theuser->fetch($selected);
6188 print $theuser->getNomUrl(1);
6211 public function form_modes_reglement($page, $selected =
'', $htmlname =
'mode_reglement_id', $filtertype =
'', $active = 1, $addempty = 0, $type =
'', $nooutput = 0)
6217 if ($htmlname !=
"none") {
6218 $out .=
'<form method="POST" action="' . $page .
'">';
6219 $out .=
'<input type="hidden" name="action" value="setmode">';
6220 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6222 $out .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
6224 $out .= $this->
select_types_paiements($selected, $htmlname, $filtertype, 0, $addempty, 0, 0, $active,
'', 1);
6225 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6230 $out .= $this->cache_types_paiements[$selected][
'label'];
6257 if ($htmlname !=
"none") {
6258 print
'<form method="POST" action="' . $page .
'">';
6259 print
'<input type="hidden" name="action" value="settransportmode">';
6260 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6262 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6267 print $this->cache_transport_mode[$selected][
'label'];
6288 if ($htmlname !=
"none") {
6289 print
'<form method="POST" action="' . $page .
'">';
6290 print
'<input type="hidden" name="action" value="setmulticurrencycode">';
6291 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6293 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6296 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
6297 print !empty($selected) ?
currency_name($selected, 1) :
' ';
6315 global $langs, $mysoc, $conf;
6317 if ($htmlname !=
"none") {
6318 print
'<form method="POST" action="' . $page .
'">';
6319 print
'<input type="hidden" name="action" value="setmulticurrencyrate">';
6320 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6321 print
'<input type="text" class="maxwidth75" name="' . $htmlname .
'" value="' . (!empty($rate) ?
price(
price2num($rate,
'CU')) : 1) .
'" /> ';
6322 print
'<select name="calculation_mode" id="calculation_mode">';
6323 print
'<option value="1">Change ' . $langs->trans(
"PriceUHT") .
' of lines</option>';
6324 print
'<option value="2">Change ' . $langs->trans(
"PriceUHTCurrency") .
' of lines</option>';
6327 print
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6330 if (!empty($rate)) {
6331 print
price($rate, 1, $langs, 0, 0);
6332 if ($currency && $rate != 1) {
6333 print
' <span class="opacitymedium">(' .
price($rate, 1, $langs, 0, 0) .
' ' . $currency .
' = 1 ' . $conf->currency .
')</span>';
6352 public function formIban(
string $selected =
'',
string $htmlname =
'ribList',
int $addempty = 0,
string $type =
'',
int $nooutput = 0, $ribForSelection = [])
6355 if ($htmlname !=
"none") {
6356 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6358 $out .=
'<input type="hidden" name="type" value="' .
dol_escape_htmltag($type) .
'">';
6360 $out .= $this->
selectTypesIban($selected, $htmlname, $addempty,
'', 1, $ribForSelection);
6373 return array_search($selected, $ribForSelection);
6393 public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter =
'', $maxvalue = 0, $more =
'', $hidelist = 0, $discount_type = 0)
6396 global $conf, $langs;
6397 if ($htmlname !=
"none") {
6398 print
'<form method="post" action="' . $page .
'">';
6399 print
'<input type="hidden" name="action" value="setabsolutediscount">';
6400 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6401 print
'<div class="inline-block">';
6402 if (!empty($discount_type)) {
6404 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL") {
6405 $translationKey =
'HasAbsoluteDiscountFromSupplier';
6407 $translationKey =
'HasCreditNoteFromSupplier';
6410 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
6411 $translationKey =
'HasAbsoluteDiscountFromSupplier';
6413 $translationKey =
'HasCreditNoteFromSupplier';
6418 if (!$filter || $filter ==
"fk_facture_source IS NULL") {
6419 $translationKey =
'CompanyHasAbsoluteDiscount';
6421 $translationKey =
'CompanyHasCreditNote';
6424 if (!$filter || $filter ==
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
6425 $translationKey =
'CompanyHasAbsoluteDiscount';
6427 $translationKey =
'CompanyHasCreditNote';
6431 print $langs->trans($translationKey,
price($amount, 0, $langs, 0, 0, -1, $conf->currency));
6432 if (empty($hidelist)) {
6436 if (empty($hidelist)) {
6437 print
'<div class="inline-block" style="padding-right: 10px">';
6438 $newfilter =
'discount_type=' . intval($discount_type);
6439 if (!empty($discount_type)) {
6440 $newfilter .=
' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL';
6442 $newfilter .=
' AND fk_facture IS NULL AND fk_facture_line IS NULL';
6445 $newfilter .=
' AND (' . $filter .
')';
6448 $nbqualifiedlines = $this->
select_remises((
string) $selected, $htmlname, $newfilter, $socid, $maxvalue);
6449 if ($nbqualifiedlines > 0) {
6450 print
' <input type="submit" class="button smallpaddingimp" value="' .
dol_escape_htmltag($langs->trans(
"UseLine")) .
'"';
6451 if (!empty($discount_type) && $filter && $filter !=
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") {
6452 print
' title="' . $langs->trans(
"UseCreditNoteInInvoicePayment") .
'"';
6454 if (empty($discount_type) && $filter && $filter !=
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") {
6455 print
' title="' . $langs->trans(
"UseCreditNoteInInvoicePayment") .
'"';
6463 print
'<div class="inline-block">';
6489 public function form_contacts($page, $societe, $selected =
'', $htmlname =
'contactid')
6494 if ($htmlname !=
"none") {
6495 print
'<form method="post" action="' . $page .
'">';
6496 print
'<input type="hidden" name="action" value="set_contact">';
6497 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6498 print
'<table class="nobordernopadding">';
6503 $addcontact = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
6504 print
'<a href="' . DOL_URL_ROOT .
'/contact/card.php?socid=' . $societe->id .
'&action=create&backtoreferer=1">' . $addcontact .
'</a>';
6507 print
'<td class="left"><input type="submit" class="button smallpaddingimp" value="' . $langs->trans(
"Modify") .
'"></td>';
6508 print
'</tr></table></form>';
6511 require_once DOL_DOCUMENT_ROOT .
'/contact/class/contact.class.php';
6512 $contact =
new Contact($this->db);
6513 $contact->fetch($selected);
6514 print $contact->getFullName($langs);
6539 public function form_thirdparty($page, $selected =
'', $htmlname =
'socid', $filter =
'', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0, $excludeids = array(), $textifnothirdparty =
'')
6545 if ($htmlname !=
"none") {
6546 $out .=
'<form method="post" action="' . $page .
'">';
6547 $out .=
'<input type="hidden" name="action" value="set_thirdparty">';
6548 $out .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
6549 $out .= $this->
select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, 0,
'minwidth100',
'',
'', 1, array(),
false, $excludeids);
6550 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
"Modify") .
'">';
6554 require_once DOL_DOCUMENT_ROOT .
'/societe/class/societe.class.php';
6555 $soc =
new Societe($this->db);
6556 $soc->fetch($selected);
6557 $out .= $soc->getNomUrl(0,
'');
6559 $out .=
'<span class="opacitymedium">' . $textifnothirdparty .
'</span>';
6597 public function selectCurrency($selected =
'', $htmlname =
'currency_id', $mode = 0, $useempty =
'')
6599 global $langs, $user;
6601 $langs->loadCacheCurrencies(
'');
6605 if ($selected ==
'euro' || $selected ==
'euros') {
6609 $out .=
'<select class="flat maxwidth200onsmartphone minwidth300" name="' . $htmlname .
'" id="' . $htmlname .
'">';
6611 $out .=
'<option value="-1" selected></option>';
6613 foreach ($langs->cache_currencies as $code_iso => $currency) {
6614 $labeltoshow = $currency[
'label'];
6616 $labeltoshow .=
' <span class="opacitymedium">(' . $code_iso .
')</span>';
6618 $labeltoshow .=
' <span class="opacitymedium">(' . $langs->getCurrencySymbol($code_iso) .
')</span>';
6621 if ($selected && $selected == $code_iso) {
6622 $out .=
'<option value="' . $code_iso .
'" selected data-html="' .
dol_escape_htmltag($labeltoshow) .
'">';
6624 $out .=
'<option value="' . $code_iso .
'" data-html="' .
dol_escape_htmltag($labeltoshow) .
'">';
6626 $out .= $labeltoshow;
6627 $out .=
'</option>';
6629 $out .=
'</select>';
6631 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
6635 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
6653 public function selectMultiCurrency($selected =
'', $htmlname =
'multicurrency_code', $useempty = 0, $filter =
'', $excludeConfCurrency =
false, $morecss =
'')
6655 global $conf, $langs;
6657 $langs->loadCacheCurrencies(
'');
6659 $TCurrency = array();
6661 $sql =
"SELECT code FROM " . $this->db->prefix() .
"multicurrency";
6662 $sql .=
" WHERE entity IN ('" .
getEntity(
'mutlicurrency') .
"')";
6664 $sql .=
" AND " . $filter;
6666 $resql = $this->db->query($sql);
6668 while ($obj = $this->db->fetch_object($resql)) {
6669 $TCurrency[$obj->code] = $obj->code;
6674 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'" id="' . $htmlname .
'">';
6676 $out .=
'<option value=""> </option>';
6679 if (!in_array($conf->currency, $TCurrency) && !$excludeConfCurrency) {
6680 $TCurrency[$conf->currency] = $conf->currency;
6682 if (count($TCurrency) > 0) {
6683 foreach ($langs->cache_currencies as $code_iso => $currency) {
6684 if (isset($TCurrency[$code_iso])) {
6685 if (!empty($selected) && $selected == $code_iso) {
6686 $out .=
'<option value="' . $code_iso .
'" selected="selected">';
6688 $out .=
'<option value="' . $code_iso .
'">';
6691 $out .= $currency[
'label'];
6692 $out .=
' (' . $langs->getCurrencySymbol($code_iso) .
')';
6693 $out .=
'</option>';
6698 $out .=
'</select>';
6701 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
6718 global $langs, $user;
6720 $num = count($this->cache_vatrates);
6727 $sql =
"SELECT t.rowid, t.type_vat, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly";
6728 $sql .=
" FROM ".$this->db->prefix().
"c_tva as t, ".$this->db->prefix().
"c_country as c";
6729 $sql .=
" WHERE t.fk_pays = c.rowid";
6730 $sql .=
" AND t.active > 0";
6731 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
6732 $sql .=
" AND c.code IN (" . $this->db->sanitize($country_code, 1) .
")";
6733 $sql .=
" ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC";
6735 $resql = $this->db->query($sql);
6737 $num = $this->db->num_rows($resql);
6739 for ($i = 0; $i < $num; $i++) {
6740 $obj = $this->db->fetch_object($resql);
6742 $tmparray = array();
6743 $tmparray[
'rowid'] = $obj->rowid;
6744 $tmparray[
'type_vat'] = $obj->type_vat;
6745 $tmparray[
'code'] = $obj->code;
6746 $tmparray[
'txtva'] = $obj->taux;
6747 $tmparray[
'nprtva'] = $obj->recuperableonly;
6748 $tmparray[
'localtax1'] = $obj->localtax1;
6749 $tmparray[
'localtax1_type'] = $obj->localtax1_type;
6750 $tmparray[
'localtax2'] = $obj->localtax2;
6751 $tmparray[
'localtax2_type'] = $obj->localtax1_type;
6752 $tmparray[
'label'] = $obj->taux .
'%' . ($obj->code ?
' (' . $obj->code .
')' :
'');
6753 $tmparray[
'labelallrates'] = $obj->taux .
'/' . ($obj->localtax1 ? $obj->localtax1 :
'0') .
'/' . ($obj->localtax2 ? $obj->localtax2 :
'0') . ($obj->code ?
' (' . $obj->code .
')' :
'');
6754 $positiverates =
'';
6756 $positiverates .= ($positiverates ?
'/' :
'') . $obj->taux;
6758 if ($obj->localtax1) {
6759 $positiverates .= ($positiverates ?
'/' :
'') . $obj->localtax1;
6761 if ($obj->localtax2) {
6762 $positiverates .= ($positiverates ?
'/' :
'') . $obj->localtax2;
6764 if (empty($positiverates)) {
6765 $positiverates =
'0';
6767 $tmparray[
'labelpositiverates'] = $positiverates . ($obj->code ?
' (' . $obj->code .
')' :
'');
6769 $this->cache_vatrates[$obj->rowid] = $tmparray;
6774 $this->error =
'<span class="error">';
6775 $this->error .= $langs->trans(
"ErrorNoVATRateDefinedForSellerCountry", $country_code);
6777 if (!empty($user) && $user->admin && preg_match(
'/\'(..)\'/', $country_code, $reg)) {
6778 $langs->load(
"errors");
6779 $new_country_code = $reg[1];
6780 $country_id =
dol_getIdFromCode($this->db, $new_country_code,
'c_pays',
'code',
'rowid');
6781 $this->error .=
'<br>'.$langs->trans(
"ErrorFixThisHere", DOL_URL_ROOT.
'/admin/dict.php?id=10'.($country_id > 0 ?
'&countryidforinsert='.$country_id :
''));
6783 $this->error .=
'</span>';
6787 $this->error =
'<span class="error">' . $this->db->error() .
'</span>';
6816 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)
6819 global $langs, $mysoc;
6821 $langs->load(
'errors');
6826 $defaultnpr = ($info_bits & 0x01);
6827 $defaultnpr = (preg_match(
'/\*/', $selectedrate) ? 1 : $defaultnpr);
6828 $defaulttx = str_replace(
'*',
'', $selectedrate);
6831 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6832 $defaultcode = $reg[1];
6833 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6838 if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
6839 if ($societe_vendeuse->id == $mysoc->id) {
6840 $return .=
'<span class="error">' . $langs->trans(
"ErrorYourCountryIsNotDefined") .
'</span>';
6842 $return .=
'<span class="error">' . $langs->trans(
"ErrorSupplierCountryIsNotDefined") .
'</span>';
6853 if (is_object($societe_vendeuse)) {
6854 $code_country =
"'" . $societe_vendeuse->country_code .
"'";
6856 $code_country =
"'" . $mysoc->country_code .
"'";
6859 require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
6863 if (
isInEEC($societe_vendeuse) &&
isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()) {
6865 if (is_numeric($type)) {
6867 switch ($selectVatComboMode) {
6869 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
6872 $code_country =
"'" . $societe_acheteuse->country_code .
"'";
6876 } elseif (!$idprod) {
6877 switch ($selectVatComboMode) {
6879 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
6882 $code_country =
"'" . $societe_acheteuse->country_code .
"'";
6886 $prodstatic =
new Product($this->db);
6887 $prodstatic->fetch($idprod);
6889 $code_country .=
",'" . $societe_acheteuse->country_code .
"'";
6899 $arrayofvatrates = array();
6900 foreach ($this->cache_vatrates as $cachevalue) {
6901 if (empty($cachevalue[
'type_vat']) || $cachevalue[
'type_vat'] != $type_vat) {
6902 $arrayofvatrates[] = $cachevalue;
6906 $num = count($arrayofvatrates);
6910 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
6911 $tmpthirdparty =
new Societe($this->db);
6913 $defaulttx =
get_default_tva($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
6914 $defaultnpr =
get_default_npr($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
6916 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6917 $defaultcode = $reg[1];
6918 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6920 if (empty($defaulttx)) {
6927 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0) {
6930 $defaulttx = $arrayofvatrates[$num - 1][
'txtva'];
6937 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
6938 $defaultcode = $reg[1];
6939 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
6947 if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj ==
"0") {
6956 if (!$options_only) {
6957 $return .=
'<select class="flat minwidth75imp maxwidth100 right" id="' . $htmlname .
'" name="' . $htmlname .
'"' . ($disabled ?
' disabled' :
'') . $title .
'>';
6960 $selectedfound =
false;
6961 foreach ($arrayofvatrates as $rate) {
6963 if ($disabled && $rate[
'txtva'] != 0) {
6968 $key = $rate[
'txtva'];
6969 $key .= $rate[
'nprtva'] ?
'*' :
'';
6970 if ($mode > 0 && $rate[
'code']) {
6971 $key .=
' (' . $rate[
'code'] .
')';
6974 $key = $rate[
'rowid'];
6977 $return .=
'<option value="' . $key .
'"';
6978 if (!$selectedfound) {
6980 if ($defaultcode == $rate[
'code']) {
6981 $return .=
' selected';
6982 $selectedfound =
true;
6984 } elseif ($rate[
'txtva'] == $defaulttx && $rate[
'nprtva'] == $defaultnpr) {
6985 $return .=
' selected';
6986 $selectedfound =
true;
6992 if ($mysoc->country_code ==
'IN' ||
getDolGlobalString(
'MAIN_VAT_LABEL_IS_POSITIVE_RATES')) {
6994 $return .= $rate[
'labelpositiverates'];
6997 $return .=
vatrate($rate[
'label']);
7001 $return .= (empty($rate[
'code']) && $rate[
'nprtva']) ?
' *' :
'';
7003 $return .=
'</option>';
7006 if (!$options_only) {
7007 $return .=
'</select>';
7011 $return .= $this->error;
7045 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 =
'')
7048 dol_syslog(__METHOD__ .
': using select_date is deprecated. Use selectDate instead.', LOG_WARNING);
7049 $retstring = $this->
selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof);
7050 if (!empty($nooutput)) {
7073 public function selectDateToDate($set_time =
'', $set_time_end =
'', $prefix =
're', $empty = 0, $forcenewline = 0)
7077 $ret = $this->
selectDate($set_time, $prefix .
'_start', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"),
'tzuserrel');
7078 if ($forcenewline) {
7081 $ret .= $this->
selectDate($set_time_end, $prefix .
'_end', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
7112 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')
7114 global $conf, $langs;
7116 if ($gm ===
'auto') {
7117 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
7122 if ($prefix ==
'') {
7133 if ($stepminutes <= 0 || $stepminutes > 30) {
7144 $orig_set_time = $set_time;
7146 if ($set_time ===
'' && $emptydate == 0) {
7147 include_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
7148 if ($gm ==
'tzuser' || $gm ==
'tzuserrel') {
7160 if (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg)) {
7162 $syear = (!empty($reg[1]) ? $reg[1] :
'');
7163 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
7164 $sday = (!empty($reg[3]) ? $reg[3] :
'');
7165 $shour = (!empty($reg[4]) ? $reg[4] :
'');
7166 $smin = (!empty($reg[5]) ? $reg[5] :
'');
7167 } elseif (strval($set_time) !=
'' && $set_time != -1) {
7172 if ($orig_set_time !=
'') {
7186 if ($h == 3 || $h == 4) {
7197 $usecalendar =
'combo';
7203 $usecalendar =
'html';
7208 if ($usecalendar !=
'combo') {
7209 $formated_date =
'';
7211 if (strval($set_time) !=
'' && $set_time != -1) {
7213 $formated_date =
dol_print_date($set_time, $langs->trans(
"FormatDateShortInput"), $gm);
7217 if ($usecalendar ==
"eldy") {
7219 $retstring .=
'<input id="' . $prefix .
'" name="' . $prefix .
'" type="text" class="maxwidthdate center" maxlength="11" value="' . $formated_date .
'"';
7220 $retstring .= ($disabled ?
' disabled' :
'');
7221 $retstring .=
' onChange="dpChangeDay(\'' . $prefix .
'\',\
'' . $langs->trans(
"FormatDateShortJavaInput") .
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
7222 $retstring .= ' autocomplete="off
">';
7225 $retstringbuttom = '';
7227 $retstringbuttom = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
"';
7228 $base = DOL_URL_ROOT . '/core/';
7229 $retstringbuttom .= ' onClick="showDP(\
'' . $base .
'\',\
'' . $prefix .
'\',\
'' . $langs->trans(
"FormatDateShortJavaInput") .
'\',\
'' . $langs->defaultlang .
'\');
"';
7230 $retstringbuttom .= '>' . img_object($langs->trans("SelectDate
"), 'calendarday', 'class="datecallink
"') . '</button>';
7232 $retstringbuttom = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
">' . img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"') . '</button>';
7234 $retstring = $retstringbuttom . $retstring;
7236 $retstring .= '<input type="hidden
" id="' . $prefix . 'day
" name="' . $prefix . 'day
" value="' . $sday . '">' . "\n
";
7237 $retstring .= '<input type="hidden
" id="' . $prefix . 'month
" name="' . $prefix . 'month
" value="' . $smonth . '">' . "\n
";
7238 $retstring .= '<input type="hidden
" id="' . $prefix . 'year
" name="' . $prefix . 'year
" value="' . $syear . '">' . "\n
";
7239 } elseif ($usecalendar == 'jquery' || $usecalendar == 'html') {
7240 if (!$disabled && $usecalendar != 'html') {
7241 // Output javascript for datepicker
7242 $minYear = getDolGlobalInt('MIN_YEAR_SELECT_DATE', (idate('Y') - 100));
7243 $maxYear = getDolGlobalInt('MAX_YEAR_SELECT_DATE', (idate('Y') + 100));
7245 $retstring .= '<script nonce="' . getNonce() . '" type="text/javascript
">';
7246 $retstring .= "$(
function(){ $(
'#" . $prefix . "').datepicker({
7247 dateFormat:
'" . $langs->trans("FormatDateShortJQueryInput") . "',
7249 todayHighlight:
true,
7250 yearRange:
'" . $minYear . ":" . $maxYear . "',
";
7251 if (!empty($conf->dol_use_jmobile)) {
7253 beforeShow:
function (input, datePicker) {
7254 input.disabled =
true;
7256 onClose:
function (dateText, datePicker) {
7261 // Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php
7262 if (!getDolGlobalString('MAIN_POPUP_CALENDAR_ON_FOCUS')) {
7265 buttonImage:
'" . DOL_URL_ROOT . "/theme/" . dol_escape_js($conf->theme) . "/img/object_calendarday.png',
7266 buttonImageOnly:
true";
7270 $retstring .= "</script>
";
7273 // Input area to enter date manually
7274 $retstring .= '<div class="nowraponall
inline-block divfordateinput
">';
7275 $retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text
" class="maxwidthdate center
" maxlength="11
" value="'.$formated_date.'"';
7276 $retstring .= ($disabled ? ' disabled' : '');
7277 $retstring .= ($placeholder ? ' placeholder="' . dol_escape_htmltag($placeholder) . '"' : '');
7278 $retstring .= ' onChange="dpChangeDay(\
'' .
dol_escape_js($prefix) .
'\',\
'' .
dol_escape_js($langs->trans(
"FormatDateShortJavaInput")) .
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
7279 $retstring .= ' autocomplete="off
">';
7283 $retstringbutton = '<button id="' . $prefix . 'Button
" type="button" class="dpInvisibleButtons
">' . img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"') . '</button>';
7284 $retstring = $retstringbutton . $retstring;
7287 $retstring .= '</div>';
7288 $retstring .= '<input type="hidden
" id="' . $prefix . 'day
" name="' . $prefix . 'day
" value="' . $sday . '">' . "\n
";
7289 $retstring .= '<input type="hidden
" id="' . $prefix . 'month
" name="' . $prefix . 'month
" value="' . $smonth . '">' . "\n
";
7290 $retstring .= '<input type="hidden
" id="' . $prefix . 'year
" name="' . $prefix . 'year
" value="' . $syear . '">' . "\n
";
7292 $retstring .= "Bad value of MAIN_POPUP_CALENDAR
";
7295 // Show date with combo selects
7297 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50imp
" id="' . $prefix . 'day
" name="' . $prefix . 'day
">';
7299 if ($emptydate || $set_time == -1) {
7300 $retstring .= '<option value="0
" selected> </option>';
7303 for ($day = 1; $day <= 31; $day++) {
7304 $retstring .= '<option value="' . $day . '"' . ($day == $sday ? ' selected' : '') . '>' . $day . '</option>';
7307 $retstring .= "</select>
";
7309 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp
" id="' . $prefix . 'month
" name="' . $prefix . 'month
">';
7310 if ($emptydate || $set_time == -1) {
7311 $retstring .= '<option value="0
" selected> </option>';
7315 for ($month = 1; $month <= 12; $month++) {
7316 $retstring .= '<option value="' . $month . '"' . ($month == $smonth ? ' selected' : '') . '>';
7317 $retstring .= dol_print_date(mktime(12, 0, 0, $month, 1, 2000), "%b
");
7318 $retstring .= "</option>
";
7320 $retstring .= "</select>
";
7323 if ($emptydate || $set_time == -1) {
7324 $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 . '">';
7326 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp
" id="' . $prefix . 'year
" name="' . $prefix . 'year
">';
7328 $syear = (int) $syear;
7329 for ($year = $syear - 10; $year < (int) $syear + 10; $year++) {
7330 $retstring .= '<option value="' . $year . '"' . ($year == $syear ? ' selected' : '') . '>' . $year . '</option>';
7332 $retstring .= "</select>\n
";
7338 $retstring .= (($h == 2 || $h == 4) ? '<br>' : ' ');
7339 $retstring .= '<span class="nowraponall
">';
7345 if ($openinghours != '') {
7346 $openinghours = explode(',', $openinghours);
7347 $hourstart = $openinghours[0];
7348 $hourend = $openinghours[1];
7349 if ($hourend < $hourstart) {
7350 $hourend = $hourstart;
7354 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50
' . ($fullday ? $fullday . 'hour
' : '') . '" id="' . $prefix . 'hour
" name="' . $prefix . 'hour
">';
7356 $retstring .= '<option value="-1
"> </option>';
7358 for ($hour = $hourstart; $hour < $hourend; $hour++) {
7359 if (strlen($hour) < 2) {
7360 $hour = "0
" . $hour;
7362 $retstring .= '<option value="' . $hour . '"' . (($hour == $shour) ? ' selected' : '') . '>' . $hour;
7363 //$retstring .= (empty($conf->dol_optimize_smallscreen) ? '' : 'H');
7364 $retstring .= '</option>';
7366 $retstring .= '</select>';
7367 //if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":
";
7375 $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50
' . ($fullday ? $fullday . 'min
' : '') . '" id="' . $prefix . 'min
" name="' . $prefix . 'min
">';
7377 $retstring .= '<option value="-1
"> </option>';
7379 for ($min = 0; $min < 60; $min += $stepminutes) {
7380 $min_str = sprintf("%02d
", $min);
7381 $retstring .= '<option value="' . $min_str . '"' . (($min_str == $smin) ? ' selected' : '') . '>' . $min_str . '</option>';
7383 $retstring .= '</select>';
7385 $retstring .= '<input type="hidden
" name="' . $prefix . 'sec
" value="' . $ssec . '">';
7389 $retstring .= '</span>';
7393 if (!empty($conf->use_javascript_ajax) && $addnowlink) {
7394 // Script which will be inserted in the onClick of the "Now
" link
7395 $reset_scripts = "";
7396 if ($addnowlink == 2) { // local computer time
7397 // pad add leading 0 on numbers
7398 $reset_scripts .= "Number.prototype.pad =
function(size) {
7399 var s = String(
this);
7400 while (s.length < (size || 2)) {s =
'0' + s;}
7403 var d =
new Date();
";
7406 // Generate the date part, depending on the use or not of the javascript calendar
7407 if ($addnowlink == 1) { // server time expressed in user time setup
7408 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'day', 'tzuserrel') . '\');';
7409 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
7410 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
7411 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
7412 } elseif ($addnowlink == 2) {
7413 /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix.
7414 * This break application for foreign languages.
7415 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));';
7416 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());';
7417 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);';
7418 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());';
7420 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'day', 'tzuserrel') . '\');';
7421 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
7422 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
7423 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
7425 /*if ($usecalendar == "eldy
")
7427 $base=DOL_URL_ROOT.'/core/';
7428 $reset_scripts .= 'resetDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput
").'\',\''.$langs->defaultlang.'\');';
7432 $reset_scripts .= 'this.form.elements[\''.$prefix.'day\'].value=formatDate(new Date(), \'d\'); ';
7433 $reset_scripts .= 'this.form.elements[\''.$prefix.'month\'].value=formatDate(new Date(), \'M\'); ';
7434 $reset_scripts .= 'this.form.elements[\''.$prefix.'year\'].value=formatDate(new Date(), \'yyyy\'); ';
7436 // Update the hour part
7439 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7441 //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); ';
7442 if ($addnowlink == 1) {
7443 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date($nowgmt, '%H', 'tzuserrel') . '\');';
7444 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').change();';
7445 } elseif ($addnowlink == 2) {
7446 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(d.getHours().pad());';
7447 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').change();';
7451 $reset_scripts .= ' } ';
7454 // Update the minute part
7457 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7459 //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); ';
7460 if ($addnowlink == 1) {
7461 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date($nowgmt, '%M', 'tzuserrel') . '\');';
7462 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').change();';
7463 } elseif ($addnowlink == 2) {
7464 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(d.getMinutes().pad());';
7465 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').change();';
7468 $reset_scripts .= ' } ';
7471 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
7472 if ($reset_scripts && !getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
7473 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="' . $prefix . 'ButtonNow
" type="button" name="_useless
" value="now
" onClick="' . $reset_scripts . '">';
7474 $retstring .= $langs->trans("Now
");
7475 $retstring .= '</button> ';
7479 // Add a "Plus one hour
" link
7480 if ($conf->use_javascript_ajax && $addplusone) {
7481 // Script which will be inserted in the onClick of the "Add plusone
" link
7482 $reset_scripts = "";
7484 // Generate the date part, depending on the use or not of the javascript calendar
7485 $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date($nowgmt, 'dayinputnoreduce', 'tzuserrel') . '\');';
7486 $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date($nowgmt, '%d', 'tzuserrel') . '\');';
7487 $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date($nowgmt, '%m', 'tzuserrel') . '\');';
7488 $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date($nowgmt, '%Y', 'tzuserrel') . '\');';
7489 // Update the hour part
7492 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7494 $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date($nowgmt, '%H', 'tzuserrel') . '\');';
7496 $reset_scripts .= ' } ';
7499 // Update the minute part
7502 $reset_scripts .= " if (jQuery(
'#fullday:checked').val() ==
null) {
";
7504 $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date($nowgmt, '%M', 'tzuserrel') . '\');';
7506 $reset_scripts .= ' } ';
7509 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
7510 if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
7511 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="' . $prefix . 'ButtonPlusOne
" type="button" name="_useless2
" value="plusone
" onClick="' . $reset_scripts . '">';
7512 $retstring .= $langs->trans("DateStartPlusOne
");
7513 $retstring .= '</button> ';
7517 // Add a link to set data
7518 if ($conf->use_javascript_ajax && !empty($adddateof)) {
7519 if (!is_array($adddateof)) {
7520 $arrayofdateof = array(array('adddateof' => $adddateof, 'labeladddateof' => $labeladddateof));
7522 $arrayofdateof = $adddateof;
7524 foreach ($arrayofdateof as $valuedateof) {
7525 $tmpadddateof = empty($valuedateof['adddateof']) ? 0 : $valuedateof['adddateof'];
7526 $tmplabeladddateof = empty($valuedateof['labeladddateof']) ? '' : $valuedateof['labeladddateof'];
7527 $tmparray = dol_getdate($tmpadddateof);
7528 if (empty($tmplabeladddateof)) {
7529 $tmplabeladddateof = $langs->trans("DateInvoice
");
7531 $reset_scripts = 'console.log(\'Click on now link\'); ';
7532 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($tmpadddateof, 'dayinputnoreduce').'\');';
7533 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.$tmparray['mday'].'\');';
7534 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.$tmparray['mon'].'\');';
7535 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.$tmparray['year'].'\');';
7536 $retstring .= ' - <button class="dpInvisibleButtons datenowlink
" id="dateofinvoice
" type="button" name="_dateofinvoice
" value="now
" onclick="'.$reset_scripts.'">'.$tmplabeladddateof.'</button>';
7551 public function selectTypeDuration($prefix, $selected = 'i', $excludetypes = array())
7555 $TDurationTypes = array(
7556 'y' => $langs->trans('Years'),
7557 'm' => $langs->trans('Month'),
7558 'w' => $langs->trans('Weeks'),
7559 'd' => $langs->trans('Days'),
7560 'h' => $langs->trans('Hours'),
7561 'i' => $langs->trans('Minutes')
7564 // Removed undesired duration types
7565 foreach ($excludetypes as $value) {
7566 unset($TDurationTypes[$value]);
7569 $retstring = '<select class="flat minwidth75 maxwidth100
" id="select_
' . $prefix . 'type_duration
" name="' . $prefix . 'type_duration
">';
7570 foreach ($TDurationTypes as $key => $typeduration) {
7571 $retstring .= '<option value="' . $key . '"';
7572 if ($key == $selected) {
7573 $retstring .= " selected
";
7575 $retstring .= ">
" . $typeduration . "</option>
";
7577 $retstring .= "</select>
";
7579 $retstring .= ajax_combobox('select_' . $prefix . 'type_duration');
7584 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
7599 public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0)
7604 $retstring = '<span class="nowraponall
">';
7610 if ($iSecond != '') {
7611 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
7613 $hourSelected = convertSecondToTime($iSecond, 'allhour');
7614 $minSelected = convertSecondToTime($iSecond, 'min');
7617 if ($typehour == 'select') {
7618 $retstring .= '<select class="flat
" id="select_
' . $prefix . 'hour
" name="' . $prefix . 'hour
"' . ($disabled ? ' disabled' : '') . '>';
7619 for ($hour = 0; $hour < 25; $hour++) { // For a duration, we allow 24 hours
7620 $retstring .= '<option value="' . $hour . '"';
7621 if (is_numeric($hourSelected) && $hourSelected == $hour) {
7622 $retstring .= " selected
";
7624 $retstring .= ">
" . $hour . "</option>
";
7626 $retstring .= "</select>
";
7627 } elseif ($typehour == 'text' || $typehour == 'textselect') {
7628 $retstring .= '<input placeholder="' . $langs->trans('HourShort
') . '" type="number
" min="0
" name="' . $prefix . 'hour
"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputhour right
" value="' . (($hourSelected != '') ? ((int) $hourSelected) : '') . '">';
7630 return 'BadValueForParameterTypeHour';
7633 if ($typehour != 'text') {
7634 $retstring .= ' ' . $langs->trans('HourShort');
7636 $retstring .= '<span class="">:</span>';
7640 if ($minunderhours) {
7641 $retstring .= '<br>';
7643 if ($typehour != 'text') {
7644 $retstring .= '<span class="hideonsmartphone
"> </span>';
7648 if ($typehour == 'select' || $typehour == 'textselect') {
7649 $retstring .= '<select class="flat
" id="select_
' . $prefix . 'min
" name="' . $prefix . 'min
"' . ($disabled ? ' disabled' : '') . '>';
7650 for ($min = 0; $min <= 55; $min += 5) {
7651 $retstring .= '<option value="' . $min . '"';
7652 if (is_numeric($minSelected) && $minSelected == $min) {
7653 $retstring .= ' selected';
7655 $retstring .= '>' . $min . '</option>';
7657 $retstring .= "</select>
";
7658 } elseif ($typehour == 'text') {
7659 $retstring .= '<input placeholder="' . $langs->trans('MinuteShort
') . '" type="number
" min="0
" name="' . $prefix . 'min
"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputminute right
" value="' . (($minSelected != '') ? ((int) $minSelected) : '') . '">';
7662 if ($typehour != 'text') {
7663 $retstring .= ' ' . $langs->trans('MinuteShort');
7666 $retstring .= "</span>
";
7668 if (!empty($nooutput)) {
7696 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)
7698 global $langs, $conf;
7703 if (is_null($ajaxoptions)) {
7704 $ajaxoptions = array();
7707 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
7710 if ($selected && empty($selected_input_value)) {
7711 require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
7712 $tickettmpselect = new Ticket($this->db);
7713 $tickettmpselect->fetch($selected);
7714 $selected_input_value = $tickettmpselect->ref;
7715 unset($tickettmpselect);
7719 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/ticket/ajax/tickets.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7721 if (empty($hidelabel)) {
7722 $out .= $langs->trans("RefOrLabel
") . ' : ';
7723 } elseif ($hidelabel > 1) {
7724 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
7725 if ($hidelabel == 2) {
7726 $out .= img_picto($langs->trans("Search
"), 'search');
7729 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (getDolGlobalString('PRODUCT_SEARCH_AUTOFOCUS') ? 'autofocus' : '') . ' />';
7730 if ($hidelabel == 3) {
7731 $out .= img_picto($langs->trans("Search
"), 'search');
7734 $out .= $this->selectTicketsList($selected, $htmlname, $filtertype, $limit, '', $status, 0, $showempty, $forcecombo, $morecss);
7737 if (empty($nooutput)) {
7762 public function selectTicketsList($selected = '', $htmlname = 'ticketid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7764 global $langs, $conf;
7767 $outarray = array();
7769 $selectFields = " p.rowid, p.ref, p.message
";
7772 $sql .= $selectFields;
7773 $sql .= " FROM
" . $this->db->prefix() . "ticket as p
";
7774 $sql .= ' WHERE p.entity IN (' . getEntity('ticket') . ')';
7776 // Add criteria on ref/label
7777 if ($filterkey != '') {
7779 $prefix = !getDolGlobalString('TICKET_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
7780 // For natural search
7781 $search_crit = explode(' ', $filterkey);
7783 if (count($search_crit) > 1) {
7786 foreach ($search_crit as $crit) {
7790 $sql .= "(p.ref LIKE
'" . $this->db->escape($prefix . $crit) . "%' OR p.subject LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
7794 if (count($search_crit) > 1) {
7800 $sql .= $this->db->plimit($limit, 0);
7802 // Build output string
7804 $result = $this->db->query($sql);
7806 require_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php';
7807 require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php';
7809 $num = $this->db->num_rows($result);
7814 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
7815 $out .= ajax_combobox($htmlname, $events, getDolGlobalInt('TICKET_USE_SEARCH_TO_SELECT'));
7818 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
7821 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
7822 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
7823 if (getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
7824 if ($showempty && !is_numeric($showempty)) {
7825 $textifempty = $langs->trans($showempty);
7827 $textifempty .= $langs->trans("All
");
7830 if ($showempty && !is_numeric($showempty)) {
7831 $textifempty = $langs->trans($showempty);
7835 $out .= '<option value="0
" selected>' . $textifempty . '</option>';
7839 while ($num && $i < $num) {
7842 $objp = $this->db->fetch_object($result);
7844 $this->constructTicketListOption($objp, $opt, $optJson, $selected, $filterkey);
7845 '@phan-var-force array{key:string,value:mixed,type:int} $optJson';
7847 // "key
" value of json key array is used by jQuery automatically as selected value
7848 // "label
" value of json key array is used by jQuery automatically as text for combo box
7850 array_push($outarray, $optJson);
7855 $out .= '</select>';
7857 $this->db->free($result);
7859 if (empty($outputmode)) {
7864 dol_print_error($this->db);
7881 protected function constructTicketListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
7887 $outkey = $objp->rowid;
7888 $outref = $objp->ref;
7890 $opt = '<option value="
' . $objp->rowid . '"';
7891 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
7894 $objRef = $objp->ref;
7895 if (!empty($filterkey) && $filterkey != '') {
7896 $objRef = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $objRef, 1);
7899 $opt .= "</option>\n
";
7900 $optJson = array('key' => $outkey, 'value' => $outref, 'type' => $outtype);
7922 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)
7924 global $langs, $conf;
7929 if (is_null($ajaxoptions)) {
7930 $ajaxoptions = array();
7933 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
7936 if ($selected && empty($selected_input_value)) {
7937 require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
7938 $projecttmpselect = new Project($this->db);
7939 $projecttmpselect->fetch($selected);
7940 $selected_input_value = $projecttmpselect->ref;
7941 unset($projecttmpselect);
7945 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/projet/ajax/projects.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
7947 if (empty($hidelabel)) {
7948 $out .= $langs->trans("RefOrLabel
") . ' : ';
7949 } elseif ($hidelabel > 1) {
7950 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
7951 if ($hidelabel == 2) {
7952 $out .= img_picto($langs->trans("Search
"), 'search');
7955 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (getDolGlobalString('PRODUCT_SEARCH_AUTOFOCUS') ? 'autofocus' : '') . ' />';
7956 if ($hidelabel == 3) {
7957 $out .= img_picto($langs->trans("Search
"), 'search');
7960 $out .= $this->selectProjectsList($selected, $htmlname, $filtertype, $limit, '', $status, 0, $showempty, $forcecombo, $morecss);
7963 if (empty($nooutput)) {
7987 public function selectProjectsList($selected = '', $htmlname = 'projectid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
7989 global $langs, $conf;
7992 $outarray = array();
7994 $selectFields = " p.rowid, p.ref
";
7997 $sql .= $selectFields;
7998 $sql .= " FROM
" . $this->db->prefix() . "projet as p
";
7999 $sql .= ' WHERE p.entity IN (' . getEntity('project') . ')';
8001 // Add criteria on ref/label
8002 if ($filterkey != '') {
8004 $prefix = !getDolGlobalString('TICKET_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
8005 // For natural search
8006 $search_crit = explode(' ', $filterkey);
8008 if (count($search_crit) > 1) {
8011 foreach ($search_crit as $crit) {
8015 $sql .= "p.ref LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
8019 if (count($search_crit) > 1) {
8025 $sql .= $this->db->plimit($limit, 0);
8027 // Build output string
8029 $result = $this->db->query($sql);
8031 require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
8032 require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php';
8034 $num = $this->db->num_rows($result);
8039 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
8040 $out .= ajax_combobox($htmlname, $events, getDolGlobalInt('PROJECT_USE_SEARCH_TO_SELECT'));
8043 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
8046 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
8047 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
8048 if (getDolGlobalString('PROJECT_USE_SEARCH_TO_SELECT')) {
8049 if ($showempty && !is_numeric($showempty)) {
8050 $textifempty = $langs->trans($showempty);
8052 $textifempty .= $langs->trans("All
");
8055 if ($showempty && !is_numeric($showempty)) {
8056 $textifempty = $langs->trans($showempty);
8060 $out .= '<option value="0
" selected>' . $textifempty . '</option>';
8064 while ($num && $i < $num) {
8067 $objp = $this->db->fetch_object($result);
8069 $this->constructProjectListOption($objp, $opt, $optJson, $selected, $filterkey);
8071 // "key
" value of json key array is used by jQuery automatically as selected value
8072 // "label
" value of json key array is used by jQuery automatically as text for combo box
8074 array_push($outarray, $optJson);
8079 $out .= '</select>';
8081 $this->db->free($result);
8083 if (empty($outputmode)) {
8088 dol_print_error($this->db);
8105 protected function constructProjectListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
8111 $label = $objp->label;
8113 $outkey = $objp->rowid;
8114 $outref = $objp->ref;
8115 $outlabel = $objp->label;
8116 $outtype = $objp->fk_product_type;
8118 $opt = '<option value="
' . $objp->rowid . '"';
8119 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
8122 $objRef = $objp->ref;
8123 if (!empty($filterkey) && $filterkey != '') {
8124 $objRef = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $objRef, 1);
8127 $opt .= "</option>\n
";
8128 $optJson = array('key' => $outkey, 'value' => $outref, 'type' => $outtype);
8151 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)
8153 global $langs, $conf;
8158 if (is_null($ajaxoptions)) {
8159 $ajaxoptions = array();
8162 if (!empty($conf->use_javascript_ajax) && getDolGlobalString('TICKET_USE_SEARCH_TO_SELECT')) {
8165 if ($selected && empty($selected_input_value)) {
8166 require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
8167 $adherenttmpselect = new Adherent($this->db);
8168 $adherenttmpselect->fetch($selected);
8169 $selected_input_value = $adherenttmpselect->ref;
8170 unset($adherenttmpselect);
8175 $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/adherents/ajax/adherents.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
8177 if (empty($hidelabel)) {
8178 $out .= $langs->trans("RefOrLabel
") . ' : ';
8179 } elseif ($hidelabel > 1) {
8180 $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
8181 if ($hidelabel == 2) {
8182 $out .= img_picto($langs->trans("Search
"), 'search');
8185 $out .= '<input type="text
" class="minwidth100
" name="search_
' . $htmlname . '" id="search_
' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (getDolGlobalString('PRODUCT_SEARCH_AUTOFOCUS') ? 'autofocus' : '') . ' />';
8186 if ($hidelabel == 3) {
8187 $out .= img_picto($langs->trans("Search
"), 'search');
8192 $out .= $this->selectMembersList($selected, $htmlname, $filtertype, $limit, $filterkey, $status, 0, $showempty, $forcecombo, $morecss);
8195 if (empty($nooutput)) {
8219 public function selectMembersList($selected = '', $htmlname = 'adherentid', $filtertype = '', $limit = 20, $filterkey = '', $status = 1, $outputmode = 0, $showempty = '1', $forcecombo = 0, $morecss = '')
8221 global $langs, $conf;
8224 $outarray = array();
8226 $selectFields = " p.rowid, p.ref, p.firstname, p.lastname, p.fk_adherent_type
";
8229 $sql .= $selectFields;
8230 $sql .= " FROM
" . $this->db->prefix() . "adherent as p
";
8231 $sql .= ' WHERE p.entity IN (' . getEntity('adherent') . ')';
8233 // Add criteria on ref/label
8234 if ($filterkey != '') {
8236 $prefix = !getDolGlobalString('MEMBER_DONOTSEARCH_ANYWHERE') ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
8237 // For natural search
8238 $search_crit = explode(' ', $filterkey);
8240 if (count($search_crit) > 1) {
8243 foreach ($search_crit as $crit) {
8247 $sql .= "(p.firstname LIKE
'" . $this->db->escape($prefix . $crit) . "%'";
8248 $sql .= " OR p.lastname LIKE
'" . $this->db->escape($prefix . $crit) . "%')
";
8251 if (count($search_crit) > 1) {
8256 if ($status != -1) {
8257 $sql .= ' AND statut = ' . ((int) $status);
8259 $sql .= $this->db->plimit($limit, 0);
8261 // Build output string
8263 $result = $this->db->query($sql);
8265 require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
8266 require_once DOL_DOCUMENT_ROOT . '/core/lib/member.lib.php';
8268 $num = $this->db->num_rows($result);
8273 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
8274 $out .= ajax_combobox($htmlname, $events, getDolGlobalString('PROJECT_USE_SEARCH_TO_SELECT') ? $conf->global->PROJECT_USE_SEARCH_TO_SELECT : '');
8277 $out .= '<select class="flat
' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
8280 // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'.
8281 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
8282 if (getDolGlobalString('PROJECT_USE_SEARCH_TO_SELECT')) {
8283 if ($showempty && !is_numeric($showempty)) {
8284 $textifempty = $langs->trans($showempty);
8286 $textifempty .= $langs->trans("All
");
8289 if ($showempty && !is_numeric($showempty)) {
8290 $textifempty = $langs->trans($showempty);
8294 $out .= '<option value="-1
" selected>' . $textifempty . '</option>';
8298 while ($num && $i < $num) {
8301 $objp = $this->db->fetch_object($result);
8303 $this->constructMemberListOption($objp, $opt, $optJson, $selected, $filterkey);
8306 // "key
" value of json key array is used by jQuery automatically as selected value
8307 // "label
" value of json key array is used by jQuery automatically as text for combo box
8309 array_push($outarray, $optJson);
8314 $out .= '</select>';
8316 $this->db->free($result);
8318 if (empty($outputmode)) {
8323 dol_print_error($this->db);
8340 protected function constructMemberListOption(&$objp, &$opt, &$optJson, $selected, $filterkey = '')
8346 $outkey = $objp->rowid;
8347 $outlabel = dolGetFirstLastname($objp->firstname, $objp->lastname);
8348 $outtype = $objp->fk_adherent_type;
8350 $opt = '<option value="
' . $objp->rowid . '"';
8351 $opt .= ($objp->rowid == $selected) ? ' selected' : '';
8353 if (!empty($filterkey) && $filterkey != '') {
8354 $outlabel = preg_replace('/(' . preg_quote($filterkey, '/') . ')/i', '<strong>$1</strong>', $outlabel, 1);
8357 $opt .= "</option>\n
";
8359 $optJson = array('key' => $outkey, 'value' => $outlabel, 'type' => $outtype);
8382 public function selectForForms($objectdesc, $htmlname, $preSelectedValue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '', $objectfield = '')
8384 global $conf, $extrafields, $user;
8386 // Example of common usage for a link to a thirdparty
8388 // We got this in a modulebuilder form of "
MyObject" of module "mymodule
".
8389 // ->fields is array( ... "fk_soc
" => array("type"=>"integer:
Societe:societe/class/societe.class.php:1:((
status:=:1) AND (entity:IN:__SHARED_ENTITIES__))
" ...)
8390 // $objectdesc = 'Societe'
8391 // $objectfield = 'myobject@mymodule:fk_soc' ('fk_soc' is code to retrieve myobject->fields['fk_soc'])
8393 // We got this when showing an extrafields on resource that is a link to societe
8394 // extrafields 'link_to_societe' of Resource is 'link' to 'Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))" ...)
'
8396 // $objectfield = 'resource:options_link_to_societe
'
8399 // $objectdesc = 'Societe:societe/class/societe.class.php:1:((
status:=:1) AND (entity:IN:__SHARED_ENTITIES__))
'
8400 // $objectfield = ''
8402 //var_dump($objectdesc.' '.$objectfield);
8403 //debug_print_backtrace();
8405 $objectdescorig = $objectdesc;
8407 $InfoFieldList = array();
8409 $filter = ''; // Ensure filter has value (for static analysis)
8410 $sortfield = ''; // Ensure filter has value (for static analysis)
8412 if ($objectfield) { // We must retrieve the objectdesc from the field or extrafield
8413 // Example: $objectfield = 'product:options_package
' or 'myobject@mymodule:options_myfield
'
8414 $tmparray = explode(':
', $objectfield);
8416 // Get instance of object from $element
8417 $objectforfieldstmp = fetchObjectByElement(0, strtolower($tmparray[0]));
8419 if (is_object($objectforfieldstmp)) {
8423 if (preg_match('/^options_(.*)$/
', $tmparray[1], $reg)) {
8424 // For a property in extrafields
8426 // fetch optionals attributes and labels
8427 $extrafields->fetch_name_optionals_label($objectforfieldstmp->table_element);
8429 if (!empty($extrafields->attributes[$objectforfieldstmp->table_element]['type'][$key]) && $extrafields->attributes[$objectforfieldstmp->table_element]['type'][$key] == 'link
') {
8430 if (!empty($extrafields->attributes[$objectforfieldstmp->table_element]['param
'][$key]['options
'])) {
8431 $tmpextrafields = array_keys($extrafields->attributes[$objectforfieldstmp->table_element]['param
'][$key]['options
']);
8432 $objectdesc = $tmpextrafields[0];
8436 // For a property in ->fields
8437 if (array_key_exists($tmparray[1], $objectforfieldstmp->fields)) {
8438 $objectdesc = $objectforfieldstmp->fields[$tmparray[1]]['type'];
8439 $objectdesc = preg_replace('/^integer[^:]*:/
', '', $objectdesc);
8446 // Example of value for $objectdesc:
8447 // Bom:bom/class/bom.class.php:0:t.status=1
8448 // Bom:bom/class/bom.class.php:0:t.status=1:ref
8449 // Bom:bom/class/bom.class.php:0:(t.status:=:1) OR (t.field2:=:2):ref
8450 $InfoFieldList = explode(":", $objectdesc, 4);
8451 $vartmp = (empty($InfoFieldList[3]) ? '' : $InfoFieldList[3]);
8453 if (preg_match('/^.*:(\w*)$/
', $vartmp, $reg)) {
8454 $InfoFieldList[4] = $reg[1]; // take the sort field
8456 $InfoFieldList[3] = preg_replace('/:\w*$/
', '', $vartmp); // take the filter field
8458 $classname = $InfoFieldList[0];
8459 $classpath = empty($InfoFieldList[1]) ? '' : $InfoFieldList[1];
8460 //$addcreatebuttonornot = empty($InfoFieldList[2]) ? 0 : $InfoFieldList[2];
8461 $filter = empty($InfoFieldList[3]) ? '' : $InfoFieldList[3];
8462 $sortfield = empty($InfoFieldList[4]) ? '' : $InfoFieldList[4];
8464 // Load object according to $id and $element
8465 $objecttmp = fetchObjectByElement(0, strtolower($InfoFieldList[0]));
8467 // Fallback to another solution to get $objecttmp
8468 if (empty($objecttmp) && !empty($classpath)) {
8469 dol_include_once($classpath);
8471 if ($classname && class_exists($classname)) {
8472 $objecttmp = new $classname($this->db);
8477 // Make some replacement in $filter. May not be used if we used the ajax mode with $objectfield. In such a case
8478 // we propagate the $objectfield and not the filter and replacement is done by the ajax/selectobject.php component.
8479 $sharedentities = (is_object($objecttmp) && property_exists($objecttmp, 'element
')) ? getEntity($objecttmp->element) : strtolower($classname);
8480 $filter = str_replace(
8481 array('__ENTITY__
', '__SHARED_ENTITIES__
', '__USER_ID__
'),
8482 array($conf->entity, $sharedentities, $user->id),
8486 if (!is_object($objecttmp)) {
8487 dol_syslog('selectForForms: Error bad setup of field objectdescorig=
' . $objectdescorig.', objectfield=
'.$objectfield.', objectdesc=
'.$objectdesc, LOG_WARNING);
8488 return 'selectForForms: Error bad setup of field objectdescorig=
' . $objectdescorig.', objectfield=
'.$objectfield.', objectdesc=
'.$objectdesc;
8492 //var_dump($filter);
8493 $prefixforautocompletemode = $objecttmp->element;
8494 if ($prefixforautocompletemode == 'societe
') {
8495 $prefixforautocompletemode = 'company
';
8497 if ($prefixforautocompletemode == 'product
') {
8498 $prefixforautocompletemode = 'produit
';
8500 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT
'; // For example COMPANY_USE_SEARCH_TO_SELECT
8502 dol_syslog(get_class($this) . "::selectForForms filter=" . $filter, LOG_DEBUG);
8504 // Generate the combo HTML component
8506 if (!empty($conf->use_javascript_ajax) && getDolGlobalString($confkeyforautocompletemode) && !$forcecombo) {
8507 // No immediate load of all database
8510 if ($preSelectedValue && empty($selected_input_value)) {
8511 $objecttmp->fetch($preSelectedValue);
8512 $selected_input_value = ($prefixforautocompletemode == 'company
' ? $objecttmp->name : $objecttmp->ref);
8514 $oldValueForShowOnCombobox = 0;
8515 foreach ($objecttmp->fields as $fieldK => $fielV) {
8516 if (!array_key_exists('showoncombobox
', $fielV) || !$fielV['showoncombobox
'] || empty($objecttmp->$fieldK)) {
8520 if (!$oldValueForShowOnCombobox) {
8521 $selected_input_value = '';
8524 $selected_input_value .= $oldValueForShowOnCombobox ? ' -
' : '';
8525 $selected_input_value .= $objecttmp->$fieldK;
8526 $oldValueForShowOnCombobox = empty($fielV['showoncombobox
']) ? 0 : $fielV['showoncombobox
'];
8530 // Set url and param to call to get json of the search results
8531 $urlforajaxcall = DOL_URL_ROOT . '/core/ajax/selectobject.php
';
8532 $urloption = 'htmlname=
' . urlencode($htmlname) . '&outjson=1&objectdesc=
' . urlencode($objectdescorig) . '&objectfield=
'.urlencode($objectfield) . ($sortfield ? '&sortfield=
' . urlencode($sortfield) : '');
8534 // Activate the auto complete using ajax call.
8535 $out .= ajax_autocompleter((string) $preSelectedValue, $htmlname, $urlforajaxcall, $urloption, getDolGlobalInt($confkeyforautocompletemode), 0);
8536 $out .= '<!-- force css to be higher than dialog popup --><style
type=
"text/css">.ui-autocomplete { z-index: 1010; }</style>
';
8537 $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) . '"' : '') . ' />
';
8539 // Immediate load of table record.
8540 $out .= $this->selectForFormsList($objecttmp, $htmlname, $preSelectedValue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled, $sortfield, $filter);
8567 public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '
', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0, $sortfield = '', $filter = '')
8569 global $langs, $user, $hookmanager;
8571 //print "$htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, $outputmode, $disabled";
8573 $prefixforautocompletemode = $objecttmp->element;
8574 if ($prefixforautocompletemode == 'societe
') {
8575 $prefixforautocompletemode = 'company
';
8577 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT
'; // For example COMPANY_USE_SEARCH_TO_SELECT
8579 if (!empty($objecttmp->fields)) { // For object that declare it, it is better to use declared fields (like societe, contact, ...)
8580 $tmpfieldstoshow = '';
8581 foreach ($objecttmp->fields as $key => $val) {
8582 if (! (int) dol_eval($val['enabled
'], 1, 1, '1
')) {
8585 if (!empty($val['showoncombobox
'])) {
8586 $tmpfieldstoshow .= ($tmpfieldstoshow ? ',
' : '') . 't.
' . $key;
8589 if ($tmpfieldstoshow) {
8590 $fieldstoshow = $tmpfieldstoshow;
8593 // For backward compatibility
8594 $objecttmp->fields['ref
'] = array('type' => 'varchar(30)
', 'label
' => 'Ref
', 'showoncombobox
' => 1);
8597 if (empty($fieldstoshow)) {
8598 if (!empty($objecttmp->parent_element)) {
8599 $fieldstoshow = 'o.ref
';
8600 if (empty($sortfield)) {
8601 $sortfield = 'o.ref
';
8603 if (in_array($objecttmp->element, ['commandedet
', 'propaldet
', 'facturedet
', 'expeditiondet
'])) {
8604 $fieldstoshow .= ',p.ref AS p_ref,p.label,t.description
';
8605 $sortfield .= ', p.ref
';
8607 } elseif (isset($objecttmp->fields['ref'])) {
8608 $fieldstoshow = 't.ref
';
8610 $langs->load("errors");
8611 $this->error = $langs->trans("ErrorNoFieldWithAttributeShowoncombobox");
8612 return $langs->trans('ErrorNoFieldWithAttributeShowoncombobox
');
8617 $outarray = array();
8618 $tmparray = array();
8623 $sql = "SELECT t.rowid, " . $fieldstoshow . " FROM " . $this->db->prefix() . $this->db->sanitize($objecttmp->table_element) . " as t";
8624 if (!empty($objecttmp->isextrafieldmanaged)) {
8625 $sql .= " LEFT JOIN " . $this->db->prefix() . $this->db->sanitize($objecttmp->table_element) . "_extrafields as e ON t.rowid = e.fk_object";
8627 if (!empty($objecttmp->parent_element)) {
8628 $parent_properties = getElementProperties($objecttmp->parent_element);
8629 $sql .= " INNER JOIN " . $this->db->prefix() . $this->db->sanitize($parent_properties['table_element
']) . " as o ON o.rowid = t.".$objecttmp->fk_parent_attribute;
8631 if (in_array($objecttmp->parent_element, ['commande
', 'propal
', 'facture
', 'expedition
'])) {
8632 $sql .= " LEFT JOIN " . $this->db->prefix() . "product as p ON p.rowid = t.fk_product";
8634 if (isset($objecttmp->ismultientitymanaged)) {
8635 if (!is_numeric($objecttmp->ismultientitymanaged)) {
8636 $tmparray = explode('@
', $objecttmp->ismultientitymanaged);
8637 $sql .= " INNER JOIN " . $this->db->prefix() . $this->db->sanitize($tmparray[1]) . " as parenttable ON parenttable.rowid = t." . $this->db->sanitize($tmparray[0]);
8639 if ($objecttmp->ismultientitymanaged === 'fk_soc@societe
') {
8640 if (!$user->hasRight('societe
', 'client
', 'voir
')) {
8641 $sql .= ", " . $this->db->prefix() . "societe_commerciaux as sc";
8646 // Add where from hooks
8647 $parameters = array(
8648 'object' => $objecttmp,
8649 'htmlname
' => $htmlname,
8650 'filter
' => $filter,
8651 'searchkey
' => $searchkey
8654 $reshook = $hookmanager->executeHooks('selectForFormsListWhere
', $parameters); // Note that $action and $object may have been modified by hook
8655 if (!empty($hookmanager->resPrint)) {
8656 $sql .= $hookmanager->resPrint;
8658 $sql .= " WHERE 1=1";
8659 if (isset($objecttmp->ismultientitymanaged)) {
8660 if ($objecttmp->ismultientitymanaged == 1) {
8661 $sql .= " AND t.entity IN (" . getEntity($objecttmp->table_element) . ")";
8663 if (!is_numeric($objecttmp->ismultientitymanaged)) {
8664 $sql .= " AND parenttable.entity = t." . $this->db->sanitize($tmparray[0]);
8666 if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
8667 if ($objecttmp->element == 'societe
') {
8668 $sql .= " AND t.rowid = " . ((int) $user->socid);
8670 $sql .= " AND t.fk_soc = " . ((int) $user->socid);
8673 if ($objecttmp->ismultientitymanaged === 'fk_soc@societe
') {
8674 if (!$user->hasRight('societe
', 'client
', 'voir
')) {
8675 $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = " . ((int) $user->id);
8679 $splittedfieldstoshow = explode(',
', $fieldstoshow);
8680 foreach ($splittedfieldstoshow as &$field2) {
8681 if (is_numeric($pos=strpos($field2, ' '))) {
8682 $field2 = substr($field2, 0, $pos);
8685 if ($searchkey != '') {
8686 $sql .= natural_search($splittedfieldstoshow, $searchkey);
8689 if ($filter) { // Syntax example "(t.ref:like:'SO-%
') and (t.date_creation:<:'20160101
')"
8691 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
8692 if ($errormessage) {
8693 return 'Error forging a SQL request from an universal criteria:
' . $errormessage;
8697 $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow, "ASC");
8698 //$sql.=$this->db->plimit($limit, 0);
8701 // Build output string
8702 $resql = $this->db->query($sql);
8704 // Construct $out and $outarray
8705 $out .= '<select
id=
"' . $htmlname . '" class=
"flat minwidth100' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled=
"disabled"' : '') . ($moreparams ? ' ' . $moreparams : '') . ' name=
"' . $htmlname . '">
' . "\n";
8707 // Warning: Do not use textifempty = ' ' or '
' here, or search on key will search on ' key
'. Seems it is no more true with selec2 v4
8708 $textifempty = '
';
8710 //if (!empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
8711 if (getDolGlobalInt($confkeyforautocompletemode)) {
8712 if ($showempty && !is_numeric($showempty)) {
8713 $textifempty = $langs->trans($showempty);
8715 $textifempty .= $langs->trans("All");
8719 $out .= '<option value=
"-1">
' . $textifempty . '</option>
' . "\n";
8722 $num = $this->db->num_rows($resql);
8726 $obj = $this->db->fetch_object($resql);
8729 $tmparray = explode(',
', $fieldstoshow);
8730 $oldvalueforshowoncombobox = 0;
8731 foreach ($tmparray as $key => $val) {
8732 $val = preg_replace('/(t|p|o)\./
', '', $val);
8733 $label .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val]['showoncombobox
'] ? ' -
' : ' ') : '');
8734 $labelhtml .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val]['showoncombobox
'] ? ' -
' : ' ') : '');
8735 $label .= $obj->$val;
8736 $labelhtml .= $obj->$val;
8738 $oldvalueforshowoncombobox = empty($objecttmp->fields[$val]['showoncombobox
']) ? 0 : $objecttmp->fields[$val]['showoncombobox
'];
8740 if (empty($outputmode)) {
8741 if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
8742 $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>
';
8744 $out .= '<option value=
"' . $obj->rowid . '" data-html=
"' . dol_escape_htmltag($labelhtml, 0, 0, '', 0, 1) . '">
' . dol_escape_htmltag($label, 0, 0, '', 0, 1) . '</option>
';
8747 array_push($outarray, array('key
' => $obj->rowid, 'value
' => $label, 'label
' => $label));
8751 if (($i % 10) == 0) {
8757 $out .= '</select>
' . "\n";
8760 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php
';
8761 $out .= ajax_combobox($htmlname, array(), getDolGlobalInt($confkeyforautocompletemode, 0));
8764 dol_print_error($this->db);
8767 $this->result = array('nbofelement
' => $num);
8799 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)
8801 global $conf, $langs;
8803 // Do we want a multiselect ?
8805 //if (preg_match('/^multi/
',$htmlname)) $jsbeautify = 1;
8808 if ($value_as_key) {
8809 $array = array_combine($array, $array);
8812 '@phan-var-force array{label:string,data-html:string,disable?:int<0,1>,css?:string} $array
'; // Array combine breaks information
8816 if ($addjscombo < 0) {
8817 if (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER
')) {
8823 $idname = str_replace(array('[
', ']
'), array('', ''), $htmlname);
8824 $out .= '<select id=
"' . preg_replace('/^\./', '', $idname) . '" ' . ($disabled ? 'disabled=
"disabled" ' : '') . 'class=
"flat ' . (preg_replace('/^\./', '', $htmlname)) . ($morecss ? ' ' . $morecss : '') . ' selectformat"';
8825 $out .= ' name=
"' . preg_replace('/^\./', '', $htmlname) . '" ' . ($moreparam ? $moreparam : '');
8829 $textforempty = ' ';
8830 if (!empty($conf->use_javascript_ajax)) {
8831 $textforempty = '
'; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
8833 if (!is_numeric($show_empty)) {
8834 $textforempty = $show_empty;
8836 $out .= '<option
class=
"optiongrey" ' . ($moreparamonempty ? $moreparamonempty . ' ' : '') . 'value=
"' . (((int) $show_empty) < 0 ? $show_empty : -1) . '"' . ($id == $show_empty ? ' selected
' : '') . '>
' . $textforempty . '</option>
' . "\n";
8838 if (is_array($array)) {
8841 foreach ($array as $key => $value) {
8842 if (!is_array($value)) {
8843 $array[$key] = $langs->trans($value);
8845 $array[$key]['label
'] = $langs->trans($value['label
']);
8850 if ($sort == 'ASC
') {
8852 } elseif ($sort == 'DESC
') {
8856 foreach ($array as $key => $tmpvalue) {
8857 if (is_array($tmpvalue)) {
8858 $value = $tmpvalue['label
'];
8859 //$valuehtml = empty($tmpvalue['data-html
']) ? $value : $tmpvalue['data-html
'];
8861 $style = empty($tmpvalue['css
']) ? '' : ' class=
"' . $tmpvalue['css'] . '"';
8864 //$valuehtml = $tmpvalue;
8868 if (!empty($disablebademail)) {
8869 if (($disablebademail == 1 && !preg_match('/<.+@.+>/
', $value))
8870 || ($disablebademail == 2 && preg_match('/---/
', $value))) {
8872 $style = ' class=
"warning"';
8875 if ($key_in_label) {
8876 if (empty($nohtmlescape)) {
8877 $selectOptionValue = dol_escape_htmltag($key . ' -
' . ($maxlen ? dol_trunc($value, $maxlen) : $value));
8879 $selectOptionValue = $key . ' -
' . ($maxlen ? dol_trunc($value, $maxlen) : $value);
8882 if (empty($nohtmlescape)) {
8883 $selectOptionValue = dol_escape_htmltag($maxlen ? dol_trunc($value, $maxlen) : $value);
8885 $selectOptionValue = $maxlen ? dol_trunc($value, $maxlen) : $value;
8887 if ($value == '' || $value == '-
') {
8888 $selectOptionValue = '
';
8891 $out .= '<option value=
"' . $key . '"';
8892 $out .= $style . $disabled;
8893 if (is_array($id)) {
8894 if (in_array($key, $id) && !$disabled) {
8895 $out .= ' selected
'; // To preselect a value
8898 $id = (string) $id; // if $id = 0, then $id = '0
'
8899 if ($id != '' && (($id == (string) $key) || ($id == 'ifone
' && count($array) == 1)) && !$disabled) {
8900 $out .= ' selected
'; // To preselect a value
8903 if (!empty($nohtmlescape)) { // deprecated. Use instead the key 'data-html
' into input $array, managed at next step to use HTML content.
8904 $out .= ' data-html=
"' . dol_escape_htmltag($selectOptionValue) . '"';
8907 if (is_array($tmpvalue)) {
8908 foreach ($tmpvalue as $keyforvalue => $valueforvalue) {
8909 if ($keyforvalue == 'labelhtml
') {
8910 $keyforvalue = 'data-html
';
8912 if (preg_match('/^data-/
', $keyforvalue)) { // The best solution if you want to use HTML values into the list is to use data-html.
8913 $out .= ' '.dol_escape_htmltag($keyforvalue).'=
"'.dol_escape_htmltag($valueforvalue).'"';
8918 $out .= $selectOptionValue;
8919 $out .= "</option>\n";
8922 $out .= "</select>";
8924 // Add code for jquery to use multiselect
8925 if ($addjscombo && $jsbeautify) {
8926 // Enhance with select2
8927 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php
';
8928 $out .= ajax_combobox($idname, array(), 0, 0, 'resolve
', (((int) $show_empty) < 0 ? (string) $show_empty : '-1
'), $morecss);
8952 public static function selectArrayAjax($htmlname, $url, $id = '
', $moreparam = '', $moreparamtourl = '', $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0)
8954 global $conf, $langs;
8955 global $delayedhtmlcontent; // Will be used later outside of this function
8957 // TODO Use an internal dolibarr component instead of select2
8958 if (!getDolGlobalString('MAIN_USE_JQUERY_MULTISELECT
') && !defined('REQUIRE_JQUERY_MULTISELECT
')) {
8962 $out = '<select
type=
"text" class=
"' . $htmlname . ($morecss ? ' ' . $morecss : '') . '" ' . ($moreparam ? $moreparam . ' ' : '') . 'name=
"' . $htmlname . '"></select>
';
8965 if (!empty($conf->use_javascript_ajax)) {
8966 $tmpplugin = 'select2
';
8967 $outdelayed = "\n" . '<!-- JS CODE TO ENABLE
' . $tmpplugin . ' for id ' . $htmlname . ' -->
8968 <script nonce=
"' . getNonce() . '">
8969 $(document).ready(
function () {
8971 ' . ($callurlonselect ? 'var saveRemoteData = [];
' : '') . '
8973 $(
".' . $htmlname . '").select2({
8976 url:
"' . $url . '",
8979 data: function (params) {
8981 q: params.term, // search term
8985 processResults: function (data) {
8986 // parse the results into the format expected by Select2.
8987 // since we are using custom formatting functions we do not need to alter the remote JSON data
8988 //console.log(data);
8989 saveRemoteData = data;
8990 /* format json result for select2 */
8992 $.each( data, function( key, value ) {
8993 result.push({id: key, text: value.text});
8995 //return {results:[{id:\'none\', text:\'aa\'}, {id:\'rrr\', text:\'Red\'},{id:\'bbb\', text:\'Search a into projects\'}], more:false}
8996 //console.log(result);
8997 return {results: result, more: false}
9001 language: select2arrayoflanguage,
9002 containerCssClass: \':all:\', /* Line to add class from the original SELECT propagated to the new <span class="select2-selection...> tag */
9004 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
9005 minimumInputLength: ' . ((int) $minimumInputLength) .
',
9006 formatResult: function (result, container, query, escapeMarkup) {
9007 return escapeMarkup(result.text);
9011 ' . ($callurlonselect ?
'
9012 /* Code to execute a GET when we select a value */
9013 $(".' . $htmlname .
'").change(function() {
9014 var selected = $(".' . $htmlname .
'").val();
9015 console.log("We select in selectArrayAjax the entry "+selected)
9016 $(".' . $htmlname .
'").val(""); /* reset visible combo value */
9017 $.each( saveRemoteData, function( key, value ) {
9018 if (key == selected)
9020 console.log("selectArrayAjax - Do a redirect to "+value.url)
9021 location.assign(value.url);
9030 if ($acceptdelayedhtml) {
9031 $delayedhtmlcontent .= $outdelayed;
9033 $out .= $outdelayed;
9057 public static function selectArrayFilter($htmlname, $array,
$id =
'', $moreparam =
'', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss =
'', $callurlonselect = 0, $placeholder =
'', $acceptdelayedhtml = 0, $textfortitle =
'')
9059 global $conf, $langs;
9060 global $delayedhtmlcontent;
9063 if (!
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') && !defined(
'REQUIRE_JQUERY_MULTISELECT')) {
9067 $out =
'<select type="text"'.($textfortitle ?
' title="'.dol_escape_htmltag($textfortitle).
'"' :
'').
' id="'.$htmlname.
'" class="'.$htmlname.($morecss ?
' ' . $morecss :
'').
'"'.($moreparam ?
' '.$moreparam :
'').
' name="'.$htmlname.
'"><option></option></select>';
9069 $formattedarrayresult = array();
9071 foreach ($array as $key => $value) {
9074 $o->text = $value[
'text'];
9075 $o->url = $value[
'url'];
9076 $formattedarrayresult[] = $o;
9080 if (!empty($conf->use_javascript_ajax)) {
9081 $tmpplugin =
'select2';
9082 $outdelayed =
"\n" .
'<!-- JS CODE TO ENABLE ' . $tmpplugin .
' for id ' . $htmlname .
' -->
9083 <script nonce="' .
getNonce() .
'">
9084 $(document).ready(function () {
9085 var data = ' . json_encode($formattedarrayresult) .
';
9087 ' . ($callurlonselect ?
'var saveRemoteData = ' . json_encode($array) .
';' :
'') .
'
9089 $(".' . $htmlname .
'").select2({
9091 language: select2arrayoflanguage,
9092 containerCssClass: \':all:\', /* Line to add class from the original SELECT propagated to the new <span class="select2-selection...> tag */
9094 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
9095 minimumInputLength: ' . $minimumInputLength .
',
9096 formatResult: function (result, container, query, escapeMarkup) {
9097 return escapeMarkup(result.text);
9099 matcher: function (params, data) {
9101 if(! data.id) return null;';
9103 if ($callurlonselect) {
9107 var urlBase = data.url;
9108 var separ = urlBase.indexOf("?") >= 0 ? "&" : "?";
9109 /* console.log("params.term="+params.term); */
9110 /* console.log("params.term encoded="+encodeURIComponent(params.term)); */
9111 saveRemoteData[data.id].url = urlBase + separ + "search_all=" + encodeURIComponent(params.term.replace(/\"/g, ""));';
9114 if (!$disableFiltering) {
9117 if(data.text.match(new RegExp(params.term))) {
9132 ' . ($callurlonselect ?
'
9133 /* Code to execute a GET when we select a value */
9134 $(".' . $htmlname .
'").change(function() {
9135 var selected = $(".' . $htmlname .
'").val();
9136 console.log("We select "+selected)
9138 $(".' . $htmlname .
'").val(""); /* reset visible combo value */
9139 $.each( saveRemoteData, function( key, value ) {
9140 if (key == selected)
9142 console.log("selectArrayFilter - Do a redirect to "+value.url)
9143 location.assign(value.url);
9152 if ($acceptdelayedhtml) {
9153 $delayedhtmlcontent .= $outdelayed;
9155 $out .= $outdelayed;
9178 public static function multiselectarray($htmlname, $array, $selected = array(), $key_in_label = 0, $value_as_key = 0, $morecss =
'', $translate = 0, $width = 0, $moreattrib =
'', $elemtype =
'', $placeholder =
'', $addjscombo = -1)
9180 global $conf, $langs;
9184 if ($addjscombo < 0) {
9192 $useenhancedmultiselect = 0;
9193 if (!empty($conf->use_javascript_ajax) && !defined(
'MAIN_DO_NOT_USE_JQUERY_MULTISELECT') && (
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') || defined(
'REQUIRE_JQUERY_MULTISELECT'))) {
9195 $useenhancedmultiselect = 1;
9202 $out .=
'<input type="hidden" name="'.$htmlname.
'_multiselect" value="1">';
9204 $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";
9205 if (is_array($array) && !empty($array)) {
9206 if ($value_as_key) {
9207 $array = array_combine($array, $array);
9210 if (!empty($array)) {
9211 foreach ($array as $key => $value) {
9217 if (is_array($value) && array_key_exists(
'id', $value) && array_key_exists(
'label', $value)) {
9218 $tmpkey = $value[
'id'];
9219 $tmpvalue = empty($value[
'label']) ?
'' : $value[
'label'];
9220 $tmpcolor = empty($value[
'color']) ?
'' : $value[
'color'];
9221 $tmppicto = empty($value[
'picto']) ?
'' : $value[
'picto'];
9222 $tmplabelhtml = empty($value[
'labelhtml']) ? (empty($value[
'data-html']) ?
'' : $value[
'data-html']) : $value[
'labelhtml'];
9224 $newval = ($translate ? $langs->trans($tmpvalue) : $tmpvalue);
9225 $newval = ($key_in_label ? $tmpkey .
' - ' . $newval : $newval);
9227 $out .=
'<option value="' . $tmpkey .
'"';
9228 if (is_array($selected) && !empty($selected) && in_array((
string) $tmpkey, $selected) && ((string) $tmpkey !=
'')) {
9229 $out .=
' selected';
9231 if (!empty($tmplabelhtml)) {
9234 $tmplabelhtml = ($tmppicto ?
img_picto(
'', $tmppicto,
'class="pictofixedwidth" style="color: #' . $tmpcolor .
'"') :
'') . $newval;
9239 $out .=
'</option>' .
"\n";
9243 $out .=
'</select>' .
"\n";
9246 if (!empty($conf->use_javascript_ajax) &&
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') || defined(
'REQUIRE_JQUERY_MULTISELECT')) {
9247 $out .=
"\n" .
'<!-- JS CODE TO ENABLE select for id ' . $htmlname .
', addjscombo=' . $addjscombo .
' -->';
9248 $out .=
"\n" .
'<script nonce="' .
getNonce() .
'">' .
"\n";
9249 if ($addjscombo == 1) {
9250 $tmpplugin = !
getDolGlobalString(
'MAIN_USE_JQUERY_MULTISELECT') ? constant(
'REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
9251 $out .=
'function formatResult(record, container) {' .
"\n";
9254 $out .=
' if ($(record.element).attr("data-html") != undefined && typeof htmlEntityDecodeJs === "function") {';
9256 $out .=
' return htmlEntityDecodeJs($(record.element).attr("data-html"));';
9258 $out .=
' return record.text;';
9260 $out .=
'function formatSelection(record) {' .
"\n";
9261 if ($elemtype ==
'category') {
9262 $out .=
'return \'<span><img src="' . DOL_URL_ROOT .
'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
9264 $out .=
'return record.text;';
9267 $out .=
'$(document).ready(function () {
9268 $(\'#' . $htmlname .
'\').
' . $tmpplugin . '({
';
9276 $out .= ' dir: \
'ltr\',
9277 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag (ko with multiselect) */
9278 dropdownCssClass: \'' . $morecss .
'\',
9280 formatResult: formatResult,
9281 templateResult: formatResult,
9282 escapeMarkup:
function (markup) {
return markup; },
9284 formatSelection: formatSelection,
9285 templateSelection: formatSelection
9290 $(\
'#' . $htmlname .
' + .select2\').addClass(\'' . $morecss .
'\');
9292 } elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT
')) {
9294 // TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
9296 $out .= 'console.log(\
'addjscombo=2 for htmlname=' . $htmlname .
'\');
';
9297 $out .= '$(document).ready(
function () {
9298 $(\
'#' . $htmlname .
'\').multiSelect({
9299 containerHTML: \
'<div class="multi-select-container">\',
9300 menuHTML: \'<div class="multi-select-menu">\',
9301 buttonHTML: \'<span class="multi-select-button ' . $morecss .
'">\',
9302 menuItemHTML: \'<label class="multi-select-menuitem">\',
9303 activeClass: \'multi-select-container--open\',
9304 noneText: \'' . $placeholder .
'\'
9308 $out .= '</script>
';
9326 public static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage, $pos = '
')
9328 global $langs, $user;
9330 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER
')) {
9333 if (empty($array)) {
9337 $tmpvar = "MAIN_SELECTEDFIELDS_" . $varpage; // To get list of saved selected fields to show
9339 if (!empty($user->conf->$tmpvar)) { // A list of fields was already customized for user
9340 $tmparray = explode(',
', $user->conf->$tmpvar);
9341 foreach ($array as $key => $val) {
9343 //var_dump($tmparray);
9344 if (in_array($key, $tmparray)) {
9345 $array[$key]['checked
'] = 1;
9347 $array[$key]['checked
'] = 0;
9350 } else { // There is no list of fields already customized for user
9351 foreach ($array as $key => $val) {
9352 if (!empty($array[$key]['checked
']) && $array[$key]['checked
'] < 0) {
9353 $array[$key]['checked
'] = 0;
9358 $listoffieldsforselection = '';
9359 $listcheckedstring = '';
9361 foreach ($array as $key => $val) {
9363 // var_dump(array_key_exists('enabled
', $val));
9364 // var_dump(!$val['enabled
']);
9365 if (array_key_exists('enabled
', $val) && isset($val['enabled
']) && !$val['enabled
']) {
9366 unset($array[$key]); // We don't want
this field
9369 if (!empty($val[
'type']) && $val[
'type'] ==
'separate') {
9374 if (!empty($val[
'label']) && $val[
'label']) {
9375 if (!empty($val[
'langfile']) && is_object($langs)) {
9376 $langs->load($val[
'langfile']);
9380 $listoffieldsforselection .=
'<li><input type="checkbox" id="checkbox' . $key .
'" value="' . $key .
'"' . ((!array_key_exists(
'checked', $val) || empty($val[
'checked']) || $val[
'checked'] ==
'-1') ?
'' :
' checked="checked"') .
'/><label for="checkbox' . $key .
'">' .
dol_escape_htmltag($langs->trans($val[
'label'])) .
'</label></li>';
9381 $listcheckedstring .= (empty($val[
'checked']) ?
'' : $key .
',');
9385 $out =
'<!-- Component multiSelectArrayWithCheckbox ' . $htmlname .
' -->
9387 <dl class="dropdown">
9389 <a href="#' . $htmlname .
'">
9392 <input type="hidden" class="' . $htmlname .
'" name="' . $htmlname .
'" value="' . $listcheckedstring .
'">
9394 <dd class="dropdowndd">
9395 <div class="multiselectcheckbox'.$htmlname.
'">
9396 <ul class="'.$htmlname.($pos ==
'1' ?
'left' :
'').
'">
9397 <li class="liinputsearch"><input class="inputsearch_dropdownselectedfields width90p minwidth200imp" style="width:90%;" type="text" placeholder="'.$langs->trans(
'Search').
'"></li>
9398 '.$listoffieldsforselection.
'
9404 <script nonce="' .
getNonce() .
'" type="text/javascript">
9405 jQuery(document).ready(function () {
9406 $(\'.multiselectcheckbox' . $htmlname .
' input[type="checkbox"]\').on(\'click\', function () {
9407 console.log("A new field was added/removed, we edit field input[name=formfilteraction]");
9409 $("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\'); // Update field so we know we changed something on selected fields after POST
9411 var title = $(this).val() + ",";
9412 if ($(this).is(\':checked\')) {
9413 $(\'.' . $htmlname .
'\').val(title + $(\
'.' . $htmlname .
'\').val());
9416 $(\
'.' . $htmlname .
'\').val( $(\
'.' . $htmlname .
'\').val().replace(title, \
'\') )
9421 $(
"input.inputsearch_dropdownselectedfields").on(
"keyup",
function() {
9422 var value = $(
this).val().toLowerCase();
9423 $(\
'.multiselectcheckbox'.$htmlname.
' li > label\').filter(function() {
9424 $(this).parent().toggle($(this).text().toLowerCase().indexOf(value) > -1)
9447 include_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
9450 $categories = $cat->containing(
$id, $type);
9452 if ($rendermode == 1) {
9454 foreach ($categories as $c) {
9455 $ways = $c->print_all_ways(
' >> ', ($nolink ?
'none' :
''), 0, 1);
9456 foreach ($ways as $way) {
9457 $toprint[] =
'<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ?
' style="background: #' . $c->color .
';"' :
' style="background: #bbb"') .
'>' . $way .
'</li>';
9460 if (empty($toprint)) {
9463 return '<div class="select2-container-multi-dolibarr"><ul class="select2-choices-dolibarr">' . implode(
' ', $toprint) .
'</ul></div>';
9467 if ($rendermode == 0) {
9468 $arrayselected = array();
9470 foreach ($categories as $c) {
9471 $arrayselected[] = $c->id;
9474 return $this->
multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'', 0,
'100%',
'disabled',
'category');
9477 return 'ErrorBadValueForParameterRenderMode';
9491 global $conf, $langs, $hookmanager;
9497 $hookmanager->initHooks(array(
'commonobject'));
9498 $parameters = array(
9499 'morehtmlright' => $morehtmlright,
9500 'compatibleImportElementsList' => &$compatibleImportElementsList,
9502 $reshook = $hookmanager->executeHooks(
'showLinkedObjectBlock', $parameters,
$object, $action);
9504 $nbofdifferenttypes = count(
$object->linkedObjects);
9506 if (empty($reshook)) {
9507 print
'<!-- showLinkedObjectBlock -->';
9508 print
load_fiche_titre($langs->trans($title), $morehtmlright,
'', 0,
'',
'showlinkedobjectblock');
9511 print
'<div class="div-table-responsive-no-min">';
9512 print
'<table class="noborder allwidth" data-block="showLinkedObject" data-element="' .
$object->element .
'" data-elementid="' .
$object->id .
'" >';
9514 print
'<tr class="liste_titre">';
9515 print
'<td>' . $langs->trans(
"Type") .
'</td>';
9516 print
'<td>' . $langs->trans(
"Ref") .
'</td>';
9517 print
'<td class="center"></td>';
9518 print
'<td class="center">' . $langs->trans(
"Date") .
'</td>';
9519 print
'<td class="right">' . $langs->trans(
"AmountHTShort") .
'</td>';
9520 print
'<td class="right">' . $langs->trans(
"Status") .
'</td>';
9524 $nboftypesoutput = 0;
9526 foreach (
$object->linkedObjects as $objecttype => $objects) {
9527 $tplpath = $element = $subelement = $objecttype;
9530 $showImportButton =
false;
9531 if (!empty($compatibleImportElementsList) && in_array($element, $compatibleImportElementsList)) {
9532 $showImportButton =
true;
9536 if ($objecttype !=
'supplier_proposal' && preg_match(
'/^([^_]+)_([^_]+)/i', $objecttype, $regs)) {
9537 $element = $regs[1];
9538 $subelement = $regs[2];
9539 $tplpath = $element .
'/' . $subelement;
9541 $tplname =
'linkedobjectblock';
9544 if ($objecttype ==
'facture') {
9545 $tplpath =
'compta/' . $element;
9546 if (!isModEnabled(
'invoice')) {
9549 } elseif ($objecttype ==
'facturerec') {
9550 $tplpath =
'compta/facture';
9551 $tplname =
'linkedobjectblockForRec';
9552 if (!isModEnabled(
'invoice')) {
9555 } elseif ($objecttype ==
'propal') {
9556 $tplpath =
'comm/' . $element;
9557 if (!isModEnabled(
'propal')) {
9560 } elseif ($objecttype ==
'supplier_proposal') {
9561 if (!isModEnabled(
'supplier_proposal')) {
9564 } elseif ($objecttype ==
'shipping' || $objecttype ==
'shipment' || $objecttype ==
'expedition') {
9565 $tplpath =
'expedition';
9566 if (!isModEnabled(
'shipping')) {
9569 } elseif ($objecttype ==
'reception') {
9570 $tplpath =
'reception';
9571 if (!isModEnabled(
'reception')) {
9574 } elseif ($objecttype ==
'delivery') {
9575 $tplpath =
'delivery';
9579 } elseif ($objecttype ==
'ficheinter') {
9580 $tplpath =
'fichinter';
9581 if (!isModEnabled(
'intervention')) {
9584 } elseif ($objecttype ==
'invoice_supplier') {
9585 $tplpath =
'fourn/facture';
9586 } elseif ($objecttype ==
'order_supplier') {
9587 $tplpath =
'fourn/commande';
9588 } elseif ($objecttype ==
'expensereport') {
9589 $tplpath =
'expensereport';
9590 } elseif ($objecttype ==
'subscription') {
9591 $tplpath =
'adherents';
9592 } elseif ($objecttype ==
'conferenceorbooth') {
9593 $tplpath =
'eventorganization';
9594 } elseif ($objecttype ==
'conferenceorboothattendee') {
9595 $tplpath =
'eventorganization';
9596 } elseif ($objecttype ==
'mo') {
9598 if (!isModEnabled(
'mrp')) {
9601 } elseif ($objecttype ==
'project_task') {
9602 $tplpath =
'projet/tasks';
9605 global $linkedObjectBlock;
9606 $linkedObjectBlock = $objects;
9609 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/' . $tplpath .
'/tpl'));
9610 foreach ($dirtpls as $reldir) {
9611 $reldir = rtrim($reldir,
'/');
9612 if ($nboftypesoutput == ($nbofdifferenttypes - 1)) {
9613 global $noMoreLinkedObjectBlockAfter;
9614 $noMoreLinkedObjectBlockAfter = 1;
9617 $res = @include
dol_buildpath($reldir .
'/' . $tplname .
'.tpl.php');
9625 if (!$nboftypesoutput) {
9626 print
'<tr><td colspan="7"><span class="opacitymedium">' . $langs->trans(
"None") .
'</span></td></tr>';
9631 if (!empty($compatibleImportElementsList)) {
9632 $res = @include
dol_buildpath(
'core/tpl/objectlinked_lineimport.tpl.php');
9638 return $nbofdifferenttypes;
9652 global $conf, $langs, $hookmanager;
9655 $form =
new Form($this->db);
9658 $linktoelemlist =
'';
9659 $listofidcompanytoscan =
'';
9661 if (!is_object(
$object->thirdparty)) {
9665 $possiblelinks = array();
9667 $dontIncludeCompletedItems =
getDolGlobalString(
'DONT_INCLUDE_COMPLETED_ELEMENTS_LINKS');
9669 if (is_object(
$object->thirdparty) && !empty(
$object->thirdparty->id) &&
$object->thirdparty->id > 0) {
9670 $listofidcompanytoscan =
$object->thirdparty->id;
9672 $listofidcompanytoscan .=
',' .
$object->thirdparty->parent;
9675 include_once DOL_DOCUMENT_ROOT .
'/projet/class/project.class.php';
9676 $tmpproject =
new Project($this->db);
9677 $tmpproject->fetch(
$object->fk_project);
9678 if ($tmpproject->socid > 0 && ($tmpproject->socid !=
$object->thirdparty->id)) {
9679 $listofidcompanytoscan .=
',' . $tmpproject->socid;
9684 $possiblelinks = array(
9686 'enabled' => isModEnabled(
'propal'),
9688 'label' =>
'LinkToProposal',
9689 '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' :
'')),
9690 'shipping' => array(
9691 'enabled' => isModEnabled(
'shipping'),
9693 'label' =>
'LinkToExpedition',
9694 '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' :
'')),
9696 'enabled' => isModEnabled(
'order'),
9698 'label' =>
'LinkToOrder',
9699 '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' :
'')),
9701 'enabled' => isModEnabled(
'invoice'),
9703 'label' =>
'LinkToInvoice',
9704 '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' :
'')),
9705 'invoice_template' => array(
9706 'enabled' => isModEnabled(
'invoice'),
9708 'label' =>
'LinkToTemplateInvoice',
9709 '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') .
')'.($dontIncludeCompletedItems ?
' AND t.paye < 1' :
'')),
9711 'enabled' => isModEnabled(
'contract'),
9713 'label' =>
'LinkToContract',
9714 '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
9715 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'
9717 'fichinter' => array(
9718 'enabled' => isModEnabled(
'intervention'),
9720 'label' =>
'LinkToIntervention',
9721 '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') .
')'),
9722 'supplier_proposal' => array(
9723 'enabled' => isModEnabled(
'supplier_proposal'),
9725 'label' =>
'LinkToSupplierProposal',
9726 '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' :
'')),
9727 'order_supplier' => array(
9728 'enabled' => isModEnabled(
"supplier_order"),
9730 'label' =>
'LinkToSupplierOrder',
9731 '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' :
'')),
9732 'invoice_supplier' => array(
9733 'enabled' => isModEnabled(
"supplier_invoice"),
9734 'perms' => 1,
'label' =>
'LinkToSupplierInvoice',
9735 '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' :
'')),
9737 'enabled' => isModEnabled(
'ticket'),
9739 'label' =>
'LinkToTicket',
9740 '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' :
'')),
9742 'enabled' => isModEnabled(
'mrp'),
9744 'label' =>
'LinkToMo',
9745 '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' :
''))
9749 if (
$object->table_element ==
'commande_fournisseur') {
9750 $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' :
'');
9751 } elseif (
$object->table_element ==
'mrp_mo') {
9752 $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' :
'');
9756 if (!empty($listofidcompanytoscan)) {
9758 $hookmanager->initHooks(array(
'commonobject'));
9759 $parameters = array(
'listofidcompanytoscan' => $listofidcompanytoscan,
'possiblelinks' => $possiblelinks);
9760 $reshook = $hookmanager->executeHooks(
'showLinkToObjectBlock', $parameters,
$object, $action);
9763 if (empty($reshook)) {
9764 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
9765 $possiblelinks = array_merge($possiblelinks, $hookmanager->resArray);
9767 } elseif ($reshook > 0) {
9768 if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
9769 $possiblelinks = $hookmanager->resArray;
9774 $htmltoenteralink =
'';
9775 foreach ($possiblelinks as $key => $possiblelink) {
9778 if (empty($possiblelink[
'enabled'])) {
9782 if (!empty($possiblelink[
'perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) {
9783 $htmltoenteralink .=
'<div id="' . $key .
'list"' . (empty($conf->use_javascript_ajax) ?
'' :
' style="display:none"') .
'>';
9787 $htmltoenteralink .=
'<br>'.
"\n";
9788 $htmltoenteralink .=
'<!-- form to add a link from anywhere -->'.
"\n";
9789 $htmltoenteralink .=
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="formlinkedbyref' . $key .
'">';
9790 $htmltoenteralink .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
9791 $htmltoenteralink .=
'<input type="hidden" name="action" value="addlinkbyref">';
9792 $htmltoenteralink .=
'<input type="hidden" name="id" value="' .
$object->id .
'">';
9793 $htmltoenteralink .=
'<input type="hidden" name="addlink" value="' . $key .
'">';
9794 $htmltoenteralink .=
'<table class="noborder">';
9795 $htmltoenteralink .=
'<tr class="liste_titre">';
9797 $htmltoenteralink .=
'<td class="center"><input type="text" placeholder="'.dol_escape_htmltag($langs->trans(
"Ref")).
'" name="reftolinkto" value="' .
dol_escape_htmltag(
GETPOST(
'reftolinkto',
'alpha')) .
'"> ';
9798 $htmltoenteralink .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="' . $langs->trans(
'ToLink') .
'"> ';
9799 $htmltoenteralink .=
'<input type="submit" class="button smallpaddingimp" name="cancel" value="' . $langs->trans(
'Cancel') .
'"></td>';
9800 $htmltoenteralink .=
'</tr>';
9801 $htmltoenteralink .=
'</table>';
9802 $htmltoenteralink .=
'</form>';
9805 $sql = $possiblelink[
'sql'];
9807 $resqllist = $this->db->query($sql);
9809 $num = $this->db->num_rows($resqllist);
9815 $htmltoenteralink .=
'<br>';
9817 $htmltoenteralink .=
'<!-- form to add a link from object to same thirdparty -->'.
"\n";
9818 $htmltoenteralink .=
'<form action="' . $_SERVER[
"PHP_SELF"] .
'" method="POST" name="formlinked' . $key .
'">';
9819 $htmltoenteralink .=
'<input type="hidden" name="token" value="' .
newToken() .
'">';
9820 $htmltoenteralink .=
'<input type="hidden" name="action" value="addlink">';
9821 $htmltoenteralink .=
'<input type="hidden" name="id" value="' .
$object->id .
'">';
9822 $htmltoenteralink .=
'<input type="hidden" name="addlink" value="' . $key .
'">';
9823 $htmltoenteralink .=
'<table class="noborder">';
9824 $htmltoenteralink .=
'<tr class="liste_titre">';
9825 $htmltoenteralink .=
'<td class="nowrap"></td>';
9826 $htmltoenteralink .=
'<td>' . $langs->trans(
"Ref") .
'</td>';
9827 $htmltoenteralink .=
'<td>' . $langs->trans(
"RefCustomer") .
'</td>';
9828 $htmltoenteralink .=
'<td class="right">' . $langs->trans(
"AmountHTShort") .
'</td>';
9829 $htmltoenteralink .=
'<td>' . $langs->trans(
"Company") .
'</td>';
9830 $htmltoenteralink .=
'</tr>';
9832 $objp = $this->db->fetch_object($resqllist);
9834 $htmltoenteralink .=
'<tr class="oddeven">';
9835 $htmltoenteralink .=
'<td>';
9836 $htmltoenteralink .=
'<input type="checkbox" name="idtolinkto[' . $key .
'_' . $objp->rowid .
']" id="' . $key .
'_' . $objp->rowid .
'" value="' . $objp->rowid .
'">';
9837 $htmltoenteralink .=
'</td>';
9838 $htmltoenteralink .=
'<td><label for="' . $key .
'_' . $objp->rowid .
'">' . $objp->ref .
'</label></td>';
9839 $htmltoenteralink .=
'<td>' . (!empty($objp->ref_client) ? $objp->ref_client : (!empty($objp->ref_supplier) ? $objp->ref_supplier :
'')) .
'</td>';
9840 $htmltoenteralink .=
'<td class="right">';
9841 if ($possiblelink[
'label'] ==
'LinkToContract') {
9842 $htmltoenteralink .= $form->textwithpicto(
'', $langs->trans(
"InformationOnLinkToContract")) .
' ';
9844 $htmltoenteralink .=
'<span class="amount">' . (isset($objp->total_ht) ?
price($objp->total_ht) :
'') .
'</span>';
9845 $htmltoenteralink .=
'</td>';
9846 $htmltoenteralink .=
'<td>' . $objp->name .
'</td>';
9847 $htmltoenteralink .=
'</tr>';
9850 $htmltoenteralink .=
'</table>';
9851 $htmltoenteralink .=
'<div class="center">';
9853 $htmltoenteralink .=
'<input type="submit" class="button valignmiddle marginleftonly marginrightonly smallpaddingimp" value="' . $langs->trans(
'ToLink') .
'">';
9855 if (empty($conf->use_javascript_ajax)) {
9856 $htmltoenteralink .=
'<input type="submit" class="button button-cancel marginleftonly marginrightonly smallpaddingimp" name="cancel" value="' . $langs->trans(
"Cancel") .
'"></div>';
9858 $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>';
9860 $htmltoenteralink .=
'</form>';
9863 $this->db->free($resqllist);
9867 $htmltoenteralink .=
'</div>';
9872 $linktoelemlist .=
'<li><a href="#linkto' . $key .
'" class="linkto dropdowncloseonclick" rel="' . $key .
'">' . $langs->trans($possiblelink[
'label']) .
' (' . $num .
')</a></li>';
9875 $linktoelemlist .=
'<li><span class="linktodisabled">' . $langs->trans($possiblelink[
'label']) .
' (0)</span></li>';
9880 if ($linktoelemlist) {
9882 <dl class="dropdown" id="linktoobjectname">
9884 if (!empty($conf->use_javascript_ajax)) {
9885 $linktoelem .=
'<dt><a href="#linktoobjectname"><span class="fas fa-link paddingrightonly"></span>' . $langs->trans(
"LinkTo") .
'...</a></dt>';
9887 $linktoelem .=
'<dd>
9888 <div class="multiselectlinkto">
9889 <ul class="ulselectedfields">' . $linktoelemlist .
'
9898 if (!empty($conf->use_javascript_ajax)) {
9899 print
'<!-- Add js to show linkto box -->
9900 <script nonce="' .
getNonce() .
'">
9901 jQuery(document).ready(function() {
9902 jQuery(".linkto").click(function() {
9903 console.log("We choose to show/hide links for rel="+jQuery(this).attr(\'rel\')+" so #"+jQuery(this).attr(\'rel\')+"list");
9904 jQuery("#"+jQuery(this).attr(\'rel\')+"list").toggle();
9912 return array(
'linktoelem' => $linktoelem,
'htmltoenteralink' => $htmltoenteralink);
9914 print $htmltoenteralink;
9934 public function selectyesno($htmlname, $value =
'', $option = 0, $disabled =
false, $useempty = 0, $addjscombo = 0, $morecss =
'width75', $labelyes =
'Yes', $labelno =
'No')
9945 $disabled = ($disabled ?
' disabled' :
'');
9947 $resultyesno =
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname .
'"' . $disabled .
'>' .
"\n";
9949 $resultyesno .=
'<option value="-1"' . (($value < 0) ?
' selected' :
'') .
'> </option>' .
"\n";
9951 if ((
"$value" ==
'yes') || ($value == 1)) {
9952 $resultyesno .=
'<option value="' . $yes .
'" selected>' . $langs->trans($labelyes) .
'</option>' .
"\n";
9953 $resultyesno .=
'<option value="' . $no .
'">' . $langs->trans($labelno) .
'</option>' .
"\n";
9955 $selected = (($useempty && $value !=
'0' && $value !=
'no') ?
'' :
' selected');
9956 $resultyesno .=
'<option value="' . $yes .
'">' . $langs->trans($labelyes) .
'</option>' .
"\n";
9957 $resultyesno .=
'<option value="' . $no .
'"' . $selected .
'>' . $langs->trans($labelno) .
'</option>' .
"\n";
9959 $resultyesno .=
'</select>' .
"\n";
9962 $resultyesno .=
ajax_combobox($htmlname, array(), 0, 0,
'resolve', ($useempty < 0 ? (
string) $useempty :
'-1'), $morecss);
9965 return $resultyesno;
9982 $sql =
"SELECT rowid, label";
9983 $sql .=
" FROM " . $this->db->prefix() .
"export_model";
9984 $sql .=
" WHERE type = '" . $this->db->escape($type) .
"'";
9985 $sql .=
" ORDER BY rowid";
9986 $result = $this->db->query($sql);
9988 print
'<select class="flat" id="select_' . $htmlname .
'" name="' . $htmlname .
'">';
9990 print
'<option value="-1"> </option>';
9993 $num = $this->db->num_rows($result);
9996 $obj = $this->db->fetch_object($result);
9997 if ($selected == $obj->rowid) {
9998 print
'<option value="' . $obj->rowid .
'" selected>';
10000 print
'<option value="' . $obj->rowid .
'">';
10030 public function showrefnav(
$object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $morehtmlright =
'')
10032 global $conf, $langs, $hookmanager, $extralanguages;
10035 if (empty($fieldid)) {
10036 $fieldid =
'rowid';
10038 if (empty($fieldref)) {
10043 $addgendertxt =
'';
10044 if (property_exists(
$object,
'gender') && !empty(
$object->gender)) {
10045 $addgendertxt =
' ';
10048 $addgendertxt .=
'<i class="fas fa-mars valignmiddle"></i>';
10051 $addgendertxt .=
'<i class="fas fa-venus valignmiddle"></i>';
10054 $addgendertxt .=
'<i class="fas fa-transgender valignmiddle"></i>';
10060 if (is_object($hookmanager)) {
10061 $parameters = array(
'showrefnav' =>
true);
10062 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters,
$object);
10063 $object->next_prev_filter .= $hookmanager->resPrint;
10066 $previous_ref = $next_ref =
'';
10069 $object->load_previous_next_ref((isset(
$object->next_prev_filter) ?
$object->next_prev_filter :
''), $fieldid, $nodbprefix);
10071 $navurl = $_SERVER[
"PHP_SELF"];
10073 if ($paramid ==
'project_ref') {
10074 if (preg_match(
'/\/tasks\/(task|contact|note|document)\.php/', $navurl)) {
10075 $navurl = preg_replace(
'/\/tasks\/(task|contact|time|note|document)\.php/',
'/tasks.php', $navurl);
10082 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
10083 if ($conf->browser->name ==
'chrome') {
10084 $stringforfirstkey .=
' ALT +';
10085 } elseif ($conf->browser->name ==
'firefox') {
10086 $stringforfirstkey .=
' ALT + SHIFT +';
10088 $stringforfirstkey .=
' CTL +';
10091 $previous_ref =
$object->ref_previous ?
'<a accesskey="p" alt="'.dol_escape_htmltag($langs->trans(
"Previous")).
'" title="' . $stringforfirstkey .
' p" class="classfortooltip" href="' . $navurl .
'?' . $paramid .
'=' . urlencode(
$object->ref_previous) . $moreparam .
'"><i class="fa fa-chevron-left"></i></a>' :
'<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>';
10092 $next_ref =
$object->ref_next ?
'<a accesskey="n" alt="'.dol_escape_htmltag($langs->trans(
"Next")).
'" title="' . $stringforfirstkey .
' n" class="classfortooltip" href="' . $navurl .
'?' . $paramid .
'=' . urlencode(
$object->ref_next) . $moreparam .
'"><i class="fa fa-chevron-right"></i></a>' :
'<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>';
10096 $ret .=
'<!-- Start banner content --><div style="vertical-align: middle">';
10099 if ($morehtmlright) {
10100 $ret .=
'<div class="inline-block floatleft">' . $morehtmlright .
'</div>';
10103 if ($previous_ref || $next_ref || $morehtml) {
10104 $ret .=
'<div class="pagination paginationref"><ul class="right">';
10106 if ($morehtml &&
getDolGlobalInt(
'MAIN_OPTIMIZEFORTEXTBROWSER') < 2) {
10107 $ret .=
'<!-- morehtml --><li class="noborder litext' . (($shownav && $previous_ref && $next_ref) ?
' clearbothonsmartphone' :
'') .
'">' . $morehtml .
'</li>';
10109 if ($shownav && ($previous_ref || $next_ref)) {
10110 $ret .=
'<li class="pagination">' . $previous_ref .
'</li>';
10111 $ret .=
'<li class="pagination">' . $next_ref .
'</li>';
10113 if ($previous_ref || $next_ref || $morehtml) {
10114 $ret .=
'</ul></div>';
10118 $parameters = array(
'morehtmlstatus' => $morehtmlstatus);
10119 $reshook = $hookmanager->executeHooks(
'moreHtmlStatus', $parameters,
$object);
10120 if (empty($reshook)) {
10121 $morehtmlstatus .= $hookmanager->resPrint;
10123 $morehtmlstatus = $hookmanager->resPrint;
10125 if ($morehtmlstatus) {
10126 $ret .=
'<div class="statusref">' . $morehtmlstatus .
'</div>';
10129 $parameters = array();
10130 $reshook = $hookmanager->executeHooks(
'moreHtmlRef', $parameters,
$object);
10131 if (empty($reshook)) {
10132 $morehtmlref .= $hookmanager->resPrint;
10133 } elseif ($reshook > 0) {
10134 $morehtmlref = $hookmanager->resPrint;
10138 if ($morehtmlleft) {
10139 if ($conf->browser->layout ==
'phone') {
10140 $ret .=
'<!-- morehtmlleft --><div class="floatleft">' . $morehtmlleft .
'</div>';
10142 $ret .=
'<!-- morehtmlleft --><div class="inline-block floatleft">' . $morehtmlleft .
'</div>';
10147 $ret .=
'<div class="inline-block floatleft valignmiddle maxwidth750 marginbottomonly refid' . (($shownav && ($previous_ref || $next_ref)) ?
' refidpadding' :
'') .
'">';
10150 if (
$object->element ==
'societe') {
10154 $arrayoflangcode = array();
10159 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
10160 if (!is_object($extralanguages)) {
10161 include_once DOL_DOCUMENT_ROOT .
'/core/class/extralanguages.class.php';
10164 $extralanguages->fetch_name_extralanguages(
'societe');
10166 if (!empty($extralanguages->attributes[
'societe'][
'name'])) {
10167 $object->fetchValuesForExtraLanguages();
10171 foreach ($arrayoflangcode as $extralangcode) {
10173 if (
$object->array_languages[
'name'][$extralangcode]) {
10174 $htmltext .=
$object->array_languages[
'name'][$extralangcode];
10176 $htmltext .=
'<span class="opacitymedium">' . $langs->trans(
"SwitchInEditModeToAddTranslation") .
'</span>';
10179 $ret .=
'<!-- Show translations of name -->' .
"\n";
10180 $ret .= $this->
textwithpicto(
'', $htmltext, -1,
'language',
'opacitymedium paddingleft');
10183 } elseif (
$object->element ==
'member') {
10184 '@phan-var-force Adherent $object';
10185 $ret .=
$object->ref .
'<br>';
10186 $fullname =
$object->getFullName($langs);
10192 } elseif (in_array(
$object->element, array(
'contact',
'user'))) {
10193 $ret .=
'<span class="valignmiddle">'.dol_htmlentities(
$object->getFullName($langs)).
'</span>'.$addgendertxt;
10194 } elseif (
$object->element ==
'usergroup') {
10196 } elseif (in_array(
$object->element, array(
'action',
'agenda'))) {
10197 '@phan-var-force ActionComm $object';
10199 } elseif (in_array(
$object->element, array(
'adherent_type'))) {
10201 } elseif (
$object->element ==
'ecm_directories') {
10203 } elseif ($fieldref !=
'none') {
10206 if ($morehtmlref) {
10208 if (substr($morehtmlref, 0, 4) !=
'<div') {
10212 $ret .=
'<!-- morehtmlref -->'.$morehtmlref;
10217 $ret .=
'</div><!-- End banner content -->';
10236 if (empty(
$object->barcode)) {
10241 if (empty(
$object->barcode_type_code) || empty(
$object->barcode_type_coder)) {
10243 $result =
$object->fetch_barcode();
10246 return '<!-- ErrorFetchBarcode -->';
10251 $url = DOL_URL_ROOT .
'/viewimage.php?modulepart=barcode&generator=' . urlencode(
$object->barcode_type_coder) .
'&code=' . urlencode(
$object->barcode) .
'&encoding=' . urlencode(
$object->barcode_type_code);
10252 $out =
'<!-- url barcode = ' . $url .
' -->';
10253 $out .=
'<img src="' . $url .
'"' . ($morecss ?
' class="' . $morecss .
'"' :
'') .
'>';
10275 public static function showphoto($modulepart,
$object, $width = 100, $height = 0, $caneditfield = 0, $cssclass =
'photowithmargin', $imagesize =
'', $addlinktofullsize = 1, $cache = 0, $forcecapture =
'', $noexternsourceoverwrite = 0)
10277 global $conf, $langs;
10279 $entity = (empty(
$object->entity) ? $conf->entity :
$object->entity);
10284 $originalfile =
'';
10288 if ($modulepart ==
'societe') {
10289 $dir = $conf->societe->multidir_output[$entity];
10292 if ((
string) $imagesize ==
'mini') {
10294 } elseif ((
string) $imagesize ==
'small') {
10303 } elseif ($modulepart ==
'contact') {
10304 $dir = $conf->societe->multidir_output[$entity] .
'/contact';
10305 if (!empty(
$object->photo)) {
10307 if ((
string) $imagesize ==
'mini') {
10309 } elseif ((
string) $imagesize ==
'small') {
10319 } elseif ($modulepart ==
'userphoto') {
10320 $dir = $conf->user->dir_output;
10321 if (!empty(
$object->photo)) {
10323 if ((
string) $imagesize ==
'mini') {
10325 } elseif ((
string) $imagesize ==
'small') {
10334 $altfile =
$object->id .
".jpg";
10338 } elseif ($modulepart ==
'memberphoto') {
10339 $dir = $conf->adherent->dir_output;
10340 if (!empty(
$object->photo)) {
10342 if ((
string) $imagesize ==
'mini') {
10344 } elseif ((
string) $imagesize ==
'small') {
10353 $altfile =
$object->id .
".jpg";
10360 if ($modulepart !=
"unknown" && method_exists(
$object,
'getDataToShowPhoto')) {
10361 $tmpdata =
$object->getDataToShowPhoto($modulepart, $imagesize);
10363 $dir = $tmpdata[
'dir'];
10364 $file = $tmpdata[
'file'];
10365 $originalfile = $tmpdata[
'originalfile'];
10366 $altfile = $tmpdata[
'altfile'];
10367 $email = $tmpdata[
'email'];
10368 $capture = $tmpdata[
'capture'];
10372 if ($forcecapture) {
10373 $capture = $forcecapture;
10379 if ($file && file_exists($dir .
"/" . $file)) {
10380 if ($addlinktofullsize) {
10382 if ($urladvanced) {
10383 $ret .=
'<a href="' . $urladvanced .
'">';
10385 $ret .=
'<a href="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($originalfile) .
'&cache=' . $cache .
'">';
10388 $ret .=
'<img alt="" class="photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
' photologo' . (preg_replace(
'/[^a-z]/i',
'_', $file)) .
'" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
' src="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($file) .
'&cache=' . $cache .
'">';
10389 if ($addlinktofullsize) {
10392 } elseif ($altfile && file_exists($dir .
"/" . $altfile)) {
10393 if ($addlinktofullsize) {
10395 if ($urladvanced) {
10396 $ret .=
'<a href="' . $urladvanced .
'">';
10398 $ret .=
'<a href="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($originalfile) .
'&cache=' . $cache .
'">';
10401 $ret .=
'<img class="photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="Photo alt" id="photologo' . (preg_replace(
'/[^a-z]/i',
'_', $file)) .
'" class="' . $cssclass .
'" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
' src="' . DOL_URL_ROOT .
'/viewimage.php?modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($altfile) .
'&cache=' . $cache .
'">';
10402 if ($addlinktofullsize) {
10406 $nophoto =
'/public/theme/common/nophoto.png';
10407 $defaultimg =
'identicon';
10408 if (in_array($modulepart, array(
'societe',
'userphoto',
'contact',
'memberphoto'))) {
10409 if ($modulepart ==
'societe' || ($modulepart ==
'memberphoto' && !empty(
$object->morphy) && strpos(
$object->morphy,
'mor') !==
false)) {
10410 $nophoto =
'company';
10412 $nophoto =
'/public/theme/common/user_anonymous.png';
10414 $nophoto =
'/public/theme/common/user_man.png';
10417 $nophoto =
'/public/theme/common/user_woman.png';
10422 if (isModEnabled(
'gravatar') && $email && empty($noexternsourceoverwrite)) {
10424 $ret .=
'<!-- Put link to gravatar -->';
10425 $ret .=
'<img class="photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" title="' . $email .
' Gravatar avatar" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
' src="https://www.gravatar.com/avatar/' .
dol_hash(strtolower(trim($email)),
'sha256', 1) .
'?s=' . $width .
'&d=' . $defaultimg .
'">';
10427 if ($nophoto ==
'company') {
10428 $ret .=
'<div class="divforspanimg valignmiddle center photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
'>' .
img_picto(
'',
'company') .
'</div>';
10431 $ret .=
'<img class="photo' . $modulepart . ($cssclass ?
' ' . $cssclass :
'') .
'" alt="" ' . ($width ?
' width="' . $width .
'"' :
'') . ($height ?
' height="' . $height .
'"' :
'') .
' src="' . DOL_URL_ROOT . $nophoto .
'">';
10436 if ($caneditfield) {
10440 $ret .=
'<table class="nobordernopadding centpercent">';
10442 $ret .=
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">' . $langs->trans(
"Delete") .
'</label><br><br></td></tr>';
10444 $ret .=
'<tr><td class="tdoverflow">';
10446 $maxmin = $maxfilesizearray[
'maxmin'];
10448 $ret .=
'<input type="hidden" name="MAX_FILE_SIZE" value="' . ($maxmin * 1024) .
'">';
10450 $ret .=
'<input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"' . ($capture ?
' capture="' . $capture .
'"' :
'') .
'>';
10451 $ret .=
'</td></tr>';
10452 $ret .=
'</table>';
10477 public function select_dolgroups($selected = 0, $htmlname =
'groupid', $show_empty = 0, $exclude =
'', $disabled = 0, $include =
'', $enableonly = array(), $force_entity =
'0', $multiple =
false, $morecss =
'minwidth200')
10480 global $conf, $user, $langs;
10483 $excludeGroups =
null;
10484 if (is_array($exclude)) {
10485 $excludeGroups = implode(
",", $exclude);
10488 $includeGroups =
null;
10489 if (is_array($include)) {
10490 $includeGroups = implode(
",", $include);
10493 if (!is_array($selected)) {
10494 $selected = array($selected);
10500 $sql =
"SELECT ug.rowid, ug.nom as name";
10501 if (isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
10502 $sql .=
", e.label";
10504 $sql .=
" FROM " . $this->db->prefix() .
"usergroup as ug ";
10505 if (isModEnabled(
'multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) {
10506 $sql .=
" LEFT JOIN " . $this->db->prefix() .
"entity as e ON e.rowid=ug.entity";
10507 if ($force_entity) {
10508 $sql .=
" WHERE ug.entity IN (0, " . $force_entity .
")";
10510 $sql .=
" WHERE ug.entity IS NOT NULL";
10513 $sql .=
" WHERE ug.entity IN (0, " . $conf->entity .
")";
10515 if (is_array($exclude) && $excludeGroups) {
10516 $sql .=
" AND ug.rowid NOT IN (" . $this->db->sanitize($excludeGroups) .
")";
10518 if (is_array($include) && $includeGroups) {
10519 $sql .=
" AND ug.rowid IN (" . $this->db->sanitize($includeGroups) .
")";
10521 $sql .=
" ORDER BY ug.nom ASC";
10523 dol_syslog(get_class($this) .
"::select_dolgroups", LOG_DEBUG);
10524 $resql = $this->db->query($sql);
10527 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
10529 $out .=
'<select class="flat' . ($morecss ?
' ' . $morecss :
'') .
'" id="' . $htmlname .
'" name="' . $htmlname . ($multiple ?
'[]' :
'') .
'" ' . ($multiple ?
'multiple' :
'') .
' ' . ($disabled ?
' disabled' :
'') .
'>';
10531 $num = $this->db->num_rows($resql);
10534 if ($show_empty && !$multiple) {
10535 $out .=
'<option value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'> </option>' .
"\n";
10538 while ($i < $num) {
10539 $obj = $this->db->fetch_object($resql);
10541 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) {
10545 $label = $obj->name;
10546 $labelhtml = $obj->name;
10547 if (isModEnabled(
'multicompany') && !
getDolGlobalInt(
'MULTICOMPANY_TRANSVERSE_MODE') && $conf->entity == 1) {
10548 $label .=
" (" . $obj->label .
")";
10549 $labelhtml .=
' <span class="opacitymedium">(' . $obj->label .
')</span>';
10552 $out .=
'<option value="' . $obj->rowid .
'"';
10553 if ($disableline) {
10554 $out .=
' disabled';
10556 if ((isset($selected[0]) && is_object($selected[0]) && $selected[0]->
id == $obj->rowid)
10557 || ((!isset($selected[0]) || !is_object($selected[0])) && !empty($selected) && in_array($obj->rowid, $selected))) {
10558 $out .=
' selected';
10560 $out .=
' data-html="'.dol_escape_htmltag($labelhtml).
'"';
10563 $out .=
'</option>';
10568 $out .=
'<option value="-1"' . (in_array(-1, $selected) ?
' selected' :
'') .
'></option>' .
"\n";
10570 $out .=
'<option value="" disabled>' . $langs->trans(
"NoUserGroupDefined") .
'</option>';
10572 $out .=
'</select>';
10591 $out =
'<div class="nowraponall">';
10592 $out .=
'<button type="submit" class="liste_titre button_search reposition" name="button_search_x" value="x"><span class="fas fa-search"></span></button>';
10593 $out .=
'<button type="submit" class="liste_titre button_removefilter reposition" name="button_removefilter_x" value="x"><span class="fas fa-times"></span></button>';
10607 public function showCheckAddButtons($cssclass =
'checkforaction', $calljsfunction = 0, $massactionname =
"massaction")
10613 if (!empty($conf->use_javascript_ajax)) {
10614 $out .=
'<div class="inline-block checkallactions"><input type="checkbox" id="' . $cssclass .
's" name="' . $cssclass .
's" class="checkallactions"></div>';
10616 $out .=
'<script nonce="' .
getNonce() .
'">
10617 $(document).ready(function() {
10618 $("#' . $cssclass .
's").click(function() {
10619 if($(this).is(\':checked\')){
10620 console.log("We check all ' . $cssclass .
' and trigger the change method");
10621 $(".' . $cssclass .
'").prop(\'checked\', true).trigger(\'change\');
10625 console.log("We uncheck all");
10626 $(".' . $cssclass .
'").prop(\'checked\', false).trigger(\'change\');
10628 if ($calljsfunction) {
10629 $out .=
'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "' . $massactionname .
'", "' . $cssclass .
'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
10632 $(".' . $cssclass .
'").change(function() {
10633 $(this).closest("tr").toggleClass("highlight", this.checked);
10653 if ($addcheckuncheckall) {
10672 public function selectExpenseCategories($selected =
'', $htmlname =
'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target =
'', $default_selected = 0, $params = array(), $info_admin = 1)
10674 global $langs, $user;
10677 $sql =
"SELECT rowid, label FROM " . $this->db->prefix() .
"c_exp_tax_cat WHERE active = 1";
10678 $sql .=
" AND entity IN (0," .
getEntity(
'exp_tax_cat') .
")";
10679 if (!empty($excludeid)) {
10680 $sql .=
" AND rowid NOT IN (" . $this->db->sanitize(implode(
',', $excludeid)) .
")";
10682 $sql .=
" ORDER BY label";
10684 $resql = $this->db->query($sql);
10686 $out =
'<select id="select_' . $htmlname .
'" name="' . $htmlname .
'" class="' . $htmlname .
' flat minwidth75imp maxwidth200">';
10688 $out .=
'<option value="0"> </option>';
10691 while ($obj = $this->db->fetch_object($resql)) {
10692 $out .=
'<option ' . ($selected == $obj->rowid ?
'selected="selected"' :
'') .
' value="' . $obj->rowid .
'">' . $langs->trans($obj->label) .
'</option>';
10694 $out .=
'</select>';
10697 if (!empty($htmlname) && $user->admin && $info_admin) {
10698 $out .=
' ' .
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
10701 if (!empty($target)) {
10702 $sql =
"SELECT c.id FROM " . $this->db->prefix() .
"c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1";
10703 $resql = $this->db->query($sql);
10705 if ($this->db->num_rows($resql) > 0) {
10706 $obj = $this->db->fetch_object($resql);
10707 $out .=
'<script nonce="' .
getNonce() .
'">
10709 $("select[name=' . $target .
']").on("change", function() {
10710 var current_val = $(this).val();
10711 if (current_val == ' . $obj->id .
') {';
10712 if (!empty($default_selected) || !empty($selected)) {
10713 $out .=
'$("select[name=' . $htmlname .
']").val("' . ($default_selected > 0 ? $default_selected : $selected) .
'");';
10717 $("select[name=' . $htmlname .
']").change();
10721 $("select[name=' . $htmlname .
']").change(function() {
10723 if ($("select[name=' . $target .
']").val() == ' . $obj->id .
') {
10724 // get price of kilometer to fill the unit price
10728 data: { fk_c_exp_tax_cat: $(this).val(), token: \'' .
currentToken() .
'\' },
10729 url:
"' . (DOL_URL_ROOT . '/expensereport/ajax/ajaxik.php?' . implode('&', $params)) . '",
10730 }).done(
function( data, textStatus, jqXHR ) {
10732 if (typeof data.up !=
"undefined") {
10733 $(
"input[name=value_unit]").val(data.up);
10734 $(
"select[name=' . $htmlname . ']").attr(
"title", data.title);
10736 $(
"input[name=value_unit]").val(
"");
10737 $(
"select[name=' . $htmlname . ']").attr(
"title",
"");
10748 dol_print_error($this->db);
10762 public function selectExpenseRanges($selected = '
', $htmlname = 'fk_range
', $useempty = 0)
10764 global $conf, $langs;
10767 $sql = "SELECT rowid, range_ik FROM " . $this->db->prefix() . "c_exp_tax_range";
10768 $sql .= " WHERE entity = " . $conf->entity . " AND active = 1";
10770 $resql = $this->db->query($sql);
10772 $out = '<select
id=
"select_' . $htmlname . '" name=
"' . $htmlname . '" class=
"' . $htmlname . ' flat minwidth75imp">
';
10774 $out .= '<option value=
"0"></option>
';
10777 while ($obj = $this->db->fetch_object($resql)) {
10778 $out .= '<option
' . ($selected == $obj->rowid ? 'selected=
"selected"' : '') . ' value=
"' . $obj->rowid . '">
' . price($obj->range_ik, 0, $langs, 1, 0) . '</option>
';
10780 $out .= '</select>
';
10782 dol_print_error($this->db);
10798 public function selectExpense($selected = '
', $htmlname = 'fk_c_type_fees
', $useempty = 0, $allchoice = 1, $useid = 0)
10803 $sql = "SELECT id, code, label";
10804 $sql .= " FROM ".$this->db->prefix()."c_type_fees";
10805 $sql .= " WHERE active = 1";
10807 $resql = $this->db->query($sql);
10809 $out = '<select
id=
"select_' . $htmlname . '" name=
"' . $htmlname . '" class=
"' . $htmlname . ' flat minwidth75imp">
';
10811 $out .= '<option value=
"0"></option>
';
10814 $out .= '<option value=
"-1">
' . $langs->trans('AllExpenseReport
') . '</option>
';
10822 while ($obj = $this->db->fetch_object($resql)) {
10823 $key = $langs->trans($obj->code);
10824 $out .= '<option
' . ($selected == $obj->{$field} ? 'selected=
"selected"' : '') . ' value=
"' . $obj->{$field} . '">
' . ($key != $obj->code ? $key : $obj->label) . '</option>
';
10826 $out .= '</select>
';
10828 $out .= ajax_combobox('select_
'.$htmlname);
10830 dol_print_error($this->db);
10854 public function selectInvoice($socid = -1, $selected = '
', $htmlname = 'invoiceid
', $maxlength = 24, $option_only = 0, $show_empty = '1
', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500
', $projectsListId = '', $showproject = 'all
', $usertofilter = null)
10856 global $user, $conf, $langs;
10858 require_once DOL_DOCUMENT_ROOT . '/projet/
class/project.class.php
';
10860 if (is_null($usertofilter)) {
10861 $usertofilter = $user;
10866 $hideunselectables = false;
10867 if (getDolGlobalString('PROJECT_HIDE_UNSELECTABLES
')) {
10868 $hideunselectables = true;
10871 if (empty($projectsListId)) {
10872 if (!$usertofilter->hasRight('projet
', 'all
', 'lire
')) {
10873 $projectstatic = new Project($this->db);
10874 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
10878 // Search all projects
10879 $sql = "SELECT f.rowid, f.ref as fref, 'nolabel
' as flabel, p.rowid as pid, f.ref,
10880 p.title, p.fk_soc, p.fk_statut, p.public,";
10881 $sql .= ' s.nom as
name';
10882 $sql .= ' FROM
' . $this->db->prefix() . 'projet as p
';
10883 $sql .= ' LEFT JOIN
' . $this->db->prefix() . 'societe as s ON s.rowid = p.fk_soc,
';
10884 $sql .= ' ' . $this->db->prefix() . 'facture as f
';
10885 $sql .= " WHERE p.entity IN (" . getEntity('project
') . ")";
10886 $sql .= " AND f.fk_projet = p.rowid AND f.fk_statut=0"; //Brouillons seulement
10887 //if ($projectsListId) $sql.= " AND p.rowid IN (".$this->db->sanitize($projectsListId).")";
10888 //if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
10889 //if ($socid > 0) $sql.= " AND (p.fk_soc=".((int) $socid)." OR p.fk_soc IS NULL)";
10890 $sql .= " ORDER BY p.ref, f.ref ASC";
10892 $resql = $this->db->query($sql);
10894 // Use select2 selector
10895 if (!empty($conf->use_javascript_ajax)) {
10896 include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php
';
10897 $comboenhancement = ajax_combobox($htmlname, array(), 0, $forcefocus);
10898 $out .= $comboenhancement;
10899 $morecss = 'minwidth200imp maxwidth500
';
10902 if (empty($option_only)) {
10903 $out .= '<select
class=
"valignmiddle flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($disabled ? ' disabled=
"disabled"' : '') . ' id=
"' . $htmlname . '" name=
"' . $htmlname . '">
';
10905 if (!empty($show_empty)) {
10906 $out .= '<option value=
"0" class=
"optiongrey">
';
10907 if (!is_numeric($show_empty)) {
10908 $out .= $show_empty;
10912 $out .= '</option>
';
10914 $num = $this->db->num_rows($resql);
10917 while ($i < $num) {
10918 $obj = $this->db->fetch_object($resql);
10919 // 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.
10920 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && !$usertofilter->hasRight('societe
', 'lire
')) {
10923 if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED) {
10930 if ($showproject == 'all
') {
10931 $labeltoshow .= dol_trunc($obj->ref, 18); // Invoice ref
10933 $labeltoshow .= ' -
' . $obj->name; // Soc name
10937 if ($obj->fk_statut == Project::STATUS_DRAFT) {
10939 $labeltoshow .= ' -
' . $langs->trans("Draft");
10940 } elseif ($obj->fk_statut == Project::STATUS_CLOSED) {
10941 if ($discard_closed == 2) {
10944 $labeltoshow .= ' -
' . $langs->trans("Closed");
10945 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) {
10947 $labeltoshow .= ' -
' . $langs->trans("LinkedToAnotherCompany");
10951 if (!empty($selected) && $selected == $obj->rowid) {
10952 $out .= '<option value=
"' . $obj->rowid . '" selected
';
10953 //if ($disabled) $out.=' disabled'; // with select2, field can't be preselected
if disabled
10954 $out .=
'>' . $labeltoshow .
'</option>';
10956 if ($hideunselectables && $disabled && ($selected != $obj->rowid)) {
10959 $resultat =
'<option value="' . $obj->rowid .
'"';
10961 $resultat .=
' disabled';
10966 $resultat .= $labeltoshow;
10967 $resultat .=
'</option>';
10975 if (empty($option_only)) {
10976 $out .=
'</select>';
10979 $this->db->free($resql);
11001 public function selectInvoiceRec($selected =
'', $htmlname =
'facrecid', $maxlength = 24, $option_only = 0, $show_empty =
'1', $forcefocus = 0, $disabled = 0, $morecss =
'maxwidth500')
11003 global $conf, $langs;
11009 $sql =
'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc';
11011 $sql .=
' FROM ' . MAIN_DB_PREFIX .
'facture_rec as f';
11012 $sql .=
" WHERE f.entity IN (" .
getEntity(
'invoice') .
")";
11013 $sql .=
" ORDER BY f.titre ASC";
11015 $resql = $this->db->query($sql);
11018 if (!empty($conf->use_javascript_ajax)) {
11019 include_once DOL_DOCUMENT_ROOT .
'/core/lib/ajax.lib.php';
11020 $comboenhancement =
ajax_combobox($htmlname, array(), 0, $forcefocus);
11021 $out .= $comboenhancement;
11022 $morecss =
'minwidth200imp maxwidth500';
11025 if (empty($option_only)) {
11026 $out .=
'<select class="valignmiddle flat' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' id="' . $htmlname .
'" name="' . $htmlname .
'">';
11028 if (!empty($show_empty)) {
11029 $out .=
'<option value="0" class="optiongrey">';
11030 if (!is_numeric($show_empty)) {
11031 $out .= $show_empty;
11035 $out .=
'</option>';
11037 $num = $this->db->num_rows($resql);
11039 while ($obj = $this->db->fetch_object($resql)) {
11040 $labeltoshow =
dol_trunc($obj->title, 18);
11043 if (!empty($obj->suspended)) {
11045 $labeltoshow .=
' - ' . $langs->trans(
"Closed");
11049 if (!empty($selected) && $selected == $obj->rowid) {
11050 $out .=
'<option value="' . $obj->rowid .
'" selected';
11052 $out .=
'>' . $labeltoshow .
'</option>';
11054 if ($disabled && ($selected != $obj->rowid)) {
11057 $resultat =
'<option value="' . $obj->rowid .
'"';
11059 $resultat .=
' disabled';
11062 $resultat .= $labeltoshow;
11063 $resultat .=
'</option>';
11069 if (empty($option_only)) {
11070 $out .=
'</select>';
11075 $this->db->free($resql);
11078 $this->errors[] = $this->db->lasterror;
11093 public function searchComponent($arrayofcriterias, $search_component_params, $arrayofinputfieldsalreadyoutput = array(), $search_component_params_hidden =
'', $arrayoffiltercriterias = array())
11096 global $langs, $form;
11098 require_once DOL_DOCUMENT_ROOT.
"/core/class/html.formother.class.php";
11101 if ($search_component_params_hidden !=
'' && !preg_match(
'/^\(.*\)$/', $search_component_params_hidden)) {
11102 $search_component_params_hidden =
'(' . $search_component_params_hidden .
')';
11107 $ret .=
'<div class="divadvancedsearchfieldcomp centpercent inline-block">';
11108 $ret .=
'<a href="#" class="dropdownsearch-toggle unsetcolor">';
11109 $ret .=
'<span class="fas fa-filter linkobject boxfilter paddingright pictofixedwidth" title="' .
dol_escape_htmltag($langs->trans(
"Filters")) .
'" id="idsubimgproductdistribution"></span>';
11112 $ret .=
'<div class="divadvancedsearchfieldcompinput inline-block minwidth500 maxwidth300onsmartphone">';
11115 $ret .=
'<div id="divsearch_component_params" name="divsearch_component_params" class="noborderbottom search_component_params inline-block valignmiddle">';
11117 if ($search_component_params_hidden) {
11125 foreach ($arrayofandtags as $tmpkey => $tmpval) {
11126 $errormessage =
'';
11128 if ($errormessage) {
11129 $this->error =
'ERROR in parsing search string: '.$errormessage;
11132 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
11135 $ret .=
'<span class="marginleftonlyshort valignmiddle tagsearch" data-ufilterid="'.($tmpkey + 1).
'" data-ufilter="'.
dol_escape_htmltag($tmpval).
'">';
11136 $ret .=
'<span class="tagsearchdelete select2-selection__choice__remove" data-ufilterid="'.($tmpkey + 1).
'">x</span> ';
11148 $show_search_component_params_hidden = 1;
11149 if ($show_search_component_params_hidden) {
11150 $ret .=
'<input type="hidden" name="show_search_component_params_hidden" value="1">';
11152 $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%')) -->";
11153 $ret .=
'<input type="hidden" id="search_component_params_hidden" name="search_component_params_hidden" value="' .
dol_escape_htmltag($search_component_params_hidden) .
'">';
11158 foreach ($arrayofcriterias as $criteria) {
11159 foreach ($criteria as $criteriafamilykey => $criteriafamilyval) {
11160 if (in_array(
'search_' . $criteriafamilykey, $arrayofinputfieldsalreadyoutput)) {
11163 if (in_array($criteriafamilykey, array(
'rowid',
'ref_ext',
'entity',
'extraparams'))) {
11166 if (in_array($criteriafamilyval[
'type'], array(
'date',
'datetime',
'timestamp'))) {
11167 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_start">';
11168 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startyear">';
11169 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startmonth">';
11170 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_startday">';
11171 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_end">';
11172 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endyear">';
11173 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endmonth">';
11174 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'_endday">';
11176 $ret .=
'<input type="hidden" name="search_' . $criteriafamilykey .
'">';
11183 $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";
11184 $ret .=
'<input type="text" placeholder="' . $langs->trans(
"Filters") .
'" id="search_component_params_input" name="search_component_params_input" class="noborderbottom search_component_input" value="">';
11190 jQuery(".tagsearchdelete").click(function(e) {
11191 var filterid = $(this).parents().attr("data-ufilterid");
11192 console.log("We click to delete the criteria nb "+filterid);
11194 // Regenerate the search_component_params_hidden with all data-ufilter except the one to delete, and post the page
11195 var newparamstring = \'\';
11196 $(\'.tagsearch\').each(function(index, element) {
11197 tmpfilterid = $(this).attr("data-ufilterid");
11198 if (tmpfilterid != filterid) {
11199 // We keep this criteria
11200 if (newparamstring == \'\') {
11201 newparamstring = $(this).attr("data-ufilter");
11203 newparamstring = newparamstring + \' AND \' + $(this).attr("data-ufilter");
11207 console.log("newparamstring = "+newparamstring);
11209 jQuery("#search_component_params_hidden").val(newparamstring);
11211 // We repost the form
11212 $(this).closest(\'form\').submit();
11215 jQuery("#search_component_params_input").keydown(function(e) {
11216 console.log("We press a key on the filter field that is "+jQuery("#search_component_params_input").val());
11217 console.log(e.which);
11218 if (jQuery("#search_component_params_input").val() == "" && e.which == 8) {
11219 /* We click on back when the input field is already empty */
11220 event.preventDefault();
11221 jQuery("#divsearch_component_params .tagsearch").last().remove();
11222 /* Regenerate content of search_component_params_hidden from remaining .tagsearch */
11224 jQuery("#divsearch_component_params .tagsearch").each(function( index ) {
11228 s = s + $(this).attr("data-ufilter");
11230 console.log("New value for search_component_params_hidden = "+s);
11231 jQuery("#search_component_params_hidden").val(s);
11238 $arrayoffilterfieldslabel = array();
11239 foreach ($arrayoffiltercriterias as $key => $val) {
11240 $arrayoffilterfieldslabel[$key][
'label'] = $val[
'label'];
11241 $arrayoffilterfieldslabel[$key][
'data-type'] = $val[
'type'];
11245 $ret .=
'<div class="search-component-assistance">';
11247 $ret .=
'<table><tbody>';
11249 $ret .=
'<p class="assistance-title">' .
img_picto(
'',
'help') .
' ' . $langs->trans(
'FilterAssistance') .
' </p>';
11251 $ret .=
'<p class="assistance-errors error" style="display:none">' . $langs->trans(
'AllFieldsRequired') .
' </p>';
11253 $ret .=
'<tr><td>';
11254 $ret .= $form->selectarray(
'search_filter_field', $arrayoffilterfieldslabel,
'', $langs->trans(
"Fields"), 0, 0,
'', 0, 0, 0,
'',
'maxwidth250', 1);
11257 $ret .=
'<td><span class="separator"></span>';
11259 $ret .=
'<select class="operator-selector" id="operator-selector"">';
11260 $ret .=
'</select>';
11261 $ret .=
'<script>$(document).ready(function() {';
11262 $ret .=
' $(".operator-selector").select2({';
11263 $ret .=
' placeholder: "' . $langs->trans(
'Operator') .
'"';
11265 $ret .=
'});</script>';
11268 $ret .=
'<td><span class="separator"></span>';
11270 $ret .=
'<input type="text" class="flat width100 value-input" placeholder="' . $langs->trans(
'Value') .
'">';
11274 $ret .=
'<span class="date-one" style="display:none">';
11275 $ret .= $form->selectDate(($dateOne ? $dateOne : -1),
'dateone', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'');
11278 $ret .=
'<span class="end-separator"></span> </td>';
11281 $ret .=
'<button class="button buttongen button-save small add-filter-btn" type="button">' . $langs->trans(
"addToFilter") .
'</button>';
11285 $ret .=
'</tbody></table>';
11292 $(document).ready(function() {
11293 $("#search_component_params_input").on("click", function() {
11294 const inputPosition = $(this).offset();
11295 const inputHeight = $(this).outerHeight();
11296 $(".search-component-assistance").css({
11297 top: inputPosition.top + inputHeight + 5 + "px",
11298 left: $("#divadvancedsearchfieldcompinput").css("left")
11299 }).slideToggle(200);
11301 $(document).on("click", function(e) {
11302 if (!$(e.target).closest("#search_component_params_input, .search-component-assistance, #ui-datepicker-div").length) {
11303 $(".search-component-assistance").hide();
11310 $(document).ready(function() {
11311 $(".search_filter_field").on("change", function() {
11312 const selectedField = $(this).find(":selected");
11313 const fieldType = selectedField.data("type");
11314 const selectedFieldValue = selectedField.val();
11315 const operators = getOperatorsForFieldType(fieldType);
11316 const operatorSelector = $(".operator-selector");
11318 // Clear existing options
11319 operatorSelector.empty();
11321 // Populate operators
11322 Object.entries(operators).forEach(function([operator, label]) {
11323 operatorSelector.append("<option value=\'" + operator + "\'>" + label + "</option>");
11326 operatorSelector.trigger("change.select2");
11328 // Clear and hide all input elements initially
11329 $(".value-input, .dateone, .datemonth, .dateyear").val("").hide();
11330 $("#datemonth, #dateyear").val(null).trigger("change.select2");
11331 $("#dateone").datepicker("setDate", null);
11332 $(".date-one, .date-month, .date-year").hide();
11334 if (fieldType === "date" || fieldType === "datetime" || fieldType === "timestamp") {
11335 $(".date-one").show();
11337 $(".value-input").show();
11341 $(".add-filter-btn").on("click", function(event) {
11342 event.preventDefault();
11344 const field = $(".search_filter_field").val();
11345 const operator = $(".operator-selector").val();
11346 let value = $(".value-input").val();
11347 const fieldType = $(".search_filter_field").find(":selected").data("type");
11349 if (["date", "datetime", "timestamp"].includes(fieldType)) {
11350 const parsedDate = new Date($("#dateone").val());
11351 if (!isNaN(parsedDate)) {
11352 const year = parsedDate.getFullYear();
11353 const month = String(parsedDate.getMonth() + 1).padStart(2, "0");
11354 const day = String(parsedDate.getDate()).padStart(2, "0");
11355 value = `${year}-${month}-${day}`;
11358 const filterString = generateFilterString(field, operator, value, fieldType);
11361 if (filterString !== "" && field !== "" && operator !== "" && value !== "") {
11362 $("#search_component_params_input").val($("#search_component_params_input").val() + " " + filterString);
11363 $("#search_component_params_input").closest("form").submit();
11365 $(".assistance-errors").show();
11384 public function selectModelMail($prefix, $modelType =
'', $default = 0, $addjscombo = 0, $selected =
'')
11386 global $langs, $user;
11390 $TModels = array();
11392 include_once DOL_DOCUMENT_ROOT .
'/core/class/html.formmail.class.php';
11393 $formmail =
new FormMail($this->db);
11394 $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs);
11397 $TModels[0] = $langs->trans(
'DefaultMailModel');
11400 foreach ($formmail->lines_model as $model) {
11401 $TModels[$model->id] = $model->label;
11405 $retstring .=
'<select class="flat" id="select_' . $prefix .
'model_mail" name="' . $prefix .
'model_mail">';
11407 foreach ($TModels as $id_model => $label_model) {
11408 $retstring .=
'<option value="' . $id_model .
'"';
11409 if (!empty($selected) && $selected == $id_model) {
11410 $retstring .=
"selected";
11412 $retstring .=
">" . $label_model .
"</option>";
11415 $retstring .=
"</select>";
11418 $retstring .=
ajax_combobox(
'select_' . $prefix .
'model_mail');
11435 public function buttonsSaveCancel($save_label =
'Save', $cancel_label =
'Cancel', $morebuttons = array(), $withoutdiv =
false, $morecss =
'', $dol_openinpopup =
'')
11439 $buttons = array();
11443 'label_key' => $save_label,
11446 if ($save_label ==
'Create' || $save_label ==
'Add') {
11447 $save[
'name'] =
'add';
11448 } elseif ($save_label ==
'Modify') {
11449 $save[
'name'] =
'edit';
11453 'name' =>
'cancel',
11454 'label_key' =>
'Cancel',
11457 !empty($save_label) ? $buttons[] = $save :
'';
11459 if (!empty($morebuttons)) {
11460 $buttons[] = $morebuttons;
11463 !empty($cancel_label) ? $buttons[] = $cancel :
'';
11465 $retstring = $withoutdiv ?
'' :
'<div class="center">';
11467 foreach ($buttons as $button) {
11468 $addclass = empty($button[
'addclass']) ?
'' : $button[
'addclass'];
11469 $retstring .=
'<input type="submit" class="button button-' . $button[
'name'] . ($morecss ?
' ' . $morecss :
'') .
' ' . $addclass .
'" name="' . $button[
'name'] .
'" value="' .
dol_escape_htmltag($langs->trans($button[
'label_key'])) .
'">';
11471 $retstring .= $withoutdiv ?
'' :
'</div>';
11473 if ($dol_openinpopup) {
11474 $retstring .=
'<!-- buttons are shown into a $dol_openinpopup=' .
dol_escape_htmltag($dol_openinpopup) .
' context, so we enable the close of dialog on cancel -->' .
"\n";
11475 $retstring .=
'<script nonce="' .
getNonce() .
'">';
11476 $retstring .=
'jQuery(".button-cancel").click(function(e) {
11477 e.preventDefault(); console.log(\'We click on cancel in iframe popup ' .
dol_escape_js($dol_openinpopup) .
'\');
11478 window.parent.jQuery(\
'#idfordialog' .
dol_escape_js($dol_openinpopup) .
'\').dialog(\
'close\');
11480 $retstring .=
'</script>';
11499 $num = count($this->cache_invoice_subtype);
11506 $sql =
"SELECT rowid, code, label as label";
11507 $sql .=
" FROM " . MAIN_DB_PREFIX .
'c_invoice_subtype';
11508 $sql .=
" WHERE active = 1";
11510 $resql = $this->db->query($sql);
11512 $num = $this->db->num_rows($resql);
11514 while ($i < $num) {
11515 $obj = $this->db->fetch_object($resql);
11518 $label = ($langs->trans(
"InvoiceSubtype" . $obj->rowid) !=
"InvoiceSubtype" . $obj->rowid) ? $langs->trans(
"InvoiceSubtype" . $obj->rowid) : (($obj->label !=
'-') ? $obj->label :
'');
11519 $this->cache_invoice_subtype[$obj->rowid][
'rowid'] = $obj->rowid;
11520 $this->cache_invoice_subtype[$obj->rowid][
'code'] = $obj->code;
11521 $this->cache_invoice_subtype[$obj->rowid][
'label'] = $label;
11525 $this->cache_invoice_subtype =
dol_sort_array($this->cache_invoice_subtype,
'code',
'asc', 0, 0, 1);
11547 global $langs, $user;
11550 dol_syslog(__METHOD__ .
" selected=" . $selected .
", htmlname=" . $htmlname, LOG_DEBUG);
11554 $out .=
'<select id="' . $htmlname .
'" class="flat selectsubtype' . ($morecss ?
' ' . $morecss :
'') .
'" name="' . $htmlname .
'">';
11556 $out .=
'<option value="0"> </option>';
11559 foreach ($this->cache_invoice_subtype as $rowid => $subtype) {
11560 $label = $subtype[
'label'];
11561 $out .=
'<option value="' . $subtype[
'rowid'] .
'"';
11562 if ($selected == $subtype[
'rowid']) {
11563 $out .=
' selected="selected"';
11567 $out .=
'</option>';
11570 $out .=
'</select>';
11571 if ($user->admin && empty($noinfoadmin)) {
11572 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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 categories.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Class to manage a WYSIWYG editor.
const STATUS_OPEN_INTERNAL
Warehouse open and only operations for stock transfers/corrections allowed (not for customer shipping...
const STATUS_OPEN_ALL
Warehouse open and any operations are allowed (customer shipping, supplier dispatch,...
const STATUS_CLOSED
Warehouse closed, inactive.
Class to manage invoices.
Class to parse product price expressions.
Class to manage predefined suppliers products.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dolForgeExplodeAnd($sqlfilters)
Explode an universal search string with AND parts.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted for view output Used into pdf and HTML pages.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0, $allowscript=0, $allowstyle=0)
Clean a string to keep only desirable HTML tags.
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='paddingright')
Format phone numbers according to country.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_print_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='')
Show Url link.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea'), $cleanalsosomestyles=0)
Clean a string from some undesirable HTML tags.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='')
Return URL we can use for advanced preview links.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolIsAllowedForPreview($file)
Return if a file is qualified for preview.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getNonce()
Return a random string to be used as a nonce value for js.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox=0, $check='restricthtml')
Sanitize a HTML to remove js, dangerous content and external link.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
ui state ui widget content ui state ui widget header ui state a ui button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
testSqlAndScriptInject($val, $type)
Security: WAF layer for SQL Injection and XSS Injection (scripts) protection (Filters on GET,...
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
getMaxFileSizeArray()
Return the max allowed for file upload.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.