67 public $errors = array();
72 public $cache_types_paiements = array();
73 public $cache_conditions_paiements = array();
74 public $cache_transport_mode = array();
75 public $cache_availability = array();
76 public $cache_demand_reason = array();
77 public $cache_types_fees = array();
78 public $cache_vatrates = array();
107 public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata =
'string', $moreparam =
'', $fieldrequired = 0, $notabletag = 0, $paramid =
'id', $help =
'')
109 global $conf, $langs;
114 if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match(
'/^select;/', $typeofdata))
118 $tmp = explode(
':', $typeofdata);
119 $ret .=
'<div class="editkey_'.$tmp[0].(!empty($tmp[1]) ?
' '.$tmp[1] :
'').
'" id="'.$htmlname.
'">';
120 if ($fieldrequired) $ret .=
'<span class="fieldrequired">';
124 $ret .= $langs->trans($text);
126 if ($fieldrequired) $ret .=
'</span>';
127 $ret .=
'</div>'.
"\n";
129 if ($fieldrequired) $ret .=
'<span class="fieldrequired">';
133 $ret .= $langs->trans($text);
135 if ($fieldrequired) $ret .=
'</span>';
138 if (empty($notabletag) &&
GETPOST(
'action',
'aZ09') !=
'edit'.$htmlname && $perm) $ret .=
'<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
139 if ($fieldrequired) $ret .=
'<span class="fieldrequired">';
143 $ret .= $langs->trans($text);
145 if ($fieldrequired) $ret .=
'</span>';
146 if (!empty($notabletag)) $ret .=
' ';
147 if (empty($notabletag) &&
GETPOST(
'action',
'aZ09') !=
'edit'.$htmlname && $perm) $ret .=
'</td>';
148 if (empty($notabletag) &&
GETPOST(
'action',
'aZ09') !=
'edit'.$htmlname && $perm) $ret .=
'<td class="right">';
149 if ($htmlname &&
GETPOST(
'action',
'aZ09') !=
'edit'.$htmlname && $perm) $ret .=
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit'.$htmlname.
'&'.$paramid.
'='.$object->id.$moreparam.
'">'.
img_edit($langs->trans(
'Edit'), ($notabletag ? 0 : 1)).
'</a>';
150 if (!empty($notabletag) && $notabletag == 1) $ret .=
' : ';
151 if (!empty($notabletag) && $notabletag == 3) $ret .=
' ';
152 if (empty($notabletag) &&
GETPOST(
'action',
'aZ09') !=
'edit'.$htmlname && $perm) $ret .=
'</td>';
153 if (empty($notabletag) &&
GETPOST(
'action',
'aZ09') !=
'edit'.$htmlname && $perm) $ret .=
'</tr></table>';
177 public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata =
'string', $editvalue =
'', $extObject = null, $custommsg = null, $moreparam =
'', $notabletag = 0, $formatfunc =
'', $paramid =
'id')
179 global $conf, $langs, $db;
184 if (empty($typeofdata))
return 'ErrorBadParameter';
187 if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match(
'/^select;|datehourpicker/', $typeofdata))
189 $ret .= $this->
editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg);
191 $editmode = (
GETPOST(
'action',
'aZ09') ==
'edit'.$htmlname);
195 $ret .=
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].($moreparam ?
'?'.$moreparam :
'').
'">';
196 $ret .=
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
197 $ret .=
'<input type="hidden" name="token" value="'.newToken().
'">';
198 $ret .=
'<input type="hidden" name="'.$paramid.
'" value="'.$object->id.
'">';
199 if (empty($notabletag)) $ret .=
'<table class="nobordernopadding centpercent" cellpadding="0" cellspacing="0">';
200 if (empty($notabletag)) $ret .=
'<tr><td>';
201 if (preg_match(
'/^(string|safehtmlstring|email)/', $typeofdata))
203 $tmp = explode(
':', $typeofdata);
204 $ret .=
'<input type="text" id="'.$htmlname.
'" name="'.$htmlname.
'" value="'.($editvalue ? $editvalue : $value).
'"'.($tmp[1] ?
' size="'.$tmp[1].
'"' :
'').
' autofocus>';
205 } elseif (preg_match(
'/^(numeric|amount)/', $typeofdata))
207 $tmp = explode(
':', $typeofdata);
208 $valuetoshow =
price2num($editvalue ? $editvalue : $value);
209 $ret .=
'<input type="text" id="'.$htmlname.
'" name="'.$htmlname.
'" value="'.($valuetoshow !=
'' ?
price($valuetoshow) :
'').
'"'.($tmp[1] ?
' size="'.$tmp[1].
'"' :
'').
' autofocus>';
210 } elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata))
212 $tmp = explode(
':', $typeofdata);
215 if (preg_match(
'/%/', $cols))
217 $morealt =
' style="width: '.$cols.
'"';
221 $valuetoshow = ($editvalue ? $editvalue : $value);
222 $ret .=
'<textarea id="'.$htmlname.
'" name="'.$htmlname.
'" wrap="soft" rows="'.($tmp[1] ? $tmp[1] :
'20').
'"'.($cols ?
' cols="'.$cols.
'"' :
'class="quatrevingtpercent"').$morealt.
'" autofocus>';
225 $valuetoshow = str_replace(
'&',
'&', $valuetoshow);
227 $ret .=
'</textarea>';
228 } elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker')
230 $ret .= $this->
selectDate($value, $htmlname, 0, 0, 1,
'form'.$htmlname, 1, 0);
231 } elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker')
233 $ret .= $this->
selectDate($value, $htmlname, 1, 1, 1,
'form'.$htmlname, 1, 0);
234 } elseif (preg_match(
'/^select;/', $typeofdata))
236 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
237 $arraylist = array();
238 foreach ($arraydata as $val)
240 $tmp = explode(
':', $val);
241 $tmpkey = str_replace(
'|',
':', $tmp[0]);
242 $arraylist[$tmpkey] = $tmp[1];
244 $ret .= $this->
selectarray($htmlname, $arraylist, $value);
245 } elseif (preg_match(
'/^ckeditor/', $typeofdata))
247 $tmp = explode(
':', $typeofdata);
248 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
249 $doleditor =
new DolEditor($htmlname, ($editvalue ? $editvalue : $value), ($tmp[2] ? $tmp[2] :
''), ($tmp[3] ? $tmp[3] :
'100'), ($tmp[1] ? $tmp[1] :
'dolibarr_notes'),
'In', ($tmp[5] ? $tmp[5] : 0), (isset($tmp[8]) ? ($tmp[8] ?
true:
false) :
true),
true, ($tmp[6] ? $tmp[6] :
'20'), ($tmp[7] ? $tmp[7] :
'100'));
250 $ret .= $doleditor->Create(1);
252 if (empty($notabletag)) $ret .=
'</td>';
254 if (empty($notabletag)) $ret .=
'<td class="left">';
256 $ret .=
'<input type="submit" class="smallpaddingimp button'.(empty($notabletag) ?
'' :
' ').
'" name="modify" value="'.$langs->trans(
"Modify").
'">';
257 if (preg_match(
'/ckeditor|textarea/', $typeofdata) && empty($notabletag)) $ret .=
'<br>'.
"\n";
258 $ret .=
'<input type="submit" class="smallpaddingimp button button-cancel'.(empty($notabletag) ?
'' :
' ').
'" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
259 if (empty($notabletag)) $ret .=
'</td>';
261 if (empty($notabletag)) $ret .=
'</tr></table>'.
"\n";
262 $ret .=
'</form>'.
"\n";
264 if (preg_match(
'/^(email)/', $typeofdata)) $ret .=
dol_print_email($value, 0, 0, 0, 0, 1);
265 elseif (preg_match(
'/^(amount|numeric)/', $typeofdata)) $ret .= ($value !=
'' ?
price($value,
'', $langs, 0, -1, -1, $conf->currency) :
'');
266 elseif (preg_match(
'/^text/', $typeofdata) || preg_match(
'/^note/', $typeofdata)) $ret .=
dol_htmlentitiesbr($value);
269 elseif ($typeofdata ==
'day' || $typeofdata ==
'datepicker') $ret .=
'<span class="valuedate">'.dol_print_date($value,
'day').
'</span>';
270 elseif ($typeofdata ==
'dayhour' || $typeofdata ==
'datehourpicker') $ret .=
'<span class="valuedate">'.dol_print_date($value,
'dayhour').
'</span>';
271 elseif (preg_match(
'/^select;/', $typeofdata))
273 $arraydata = explode(
',', preg_replace(
'/^select;/',
'', $typeofdata));
274 $arraylist = array();
275 foreach ($arraydata as $val)
277 $tmp = explode(
':', $val);
278 $arraylist[$tmp[0]] = $tmp[1];
280 $ret .= $arraylist[$value];
281 } elseif (preg_match(
'/^ckeditor/', $typeofdata))
284 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB))
286 $firstline = preg_replace(
'/<br>.*/',
'', $tmpcontent);
287 $firstline = preg_replace(
'/[\n\r].*/',
'', $firstline);
288 $tmpcontent = $firstline.((strlen($firstline) != strlen($tmpcontent)) ?
'...' :
'');
297 if ($formatfunc && method_exists($object, $formatfunc))
299 $ret = $object->$formatfunc($ret);
317 public function widgetForTranslation($fieldname, $object, $perm, $typeofdata =
'string', $check =
'', $morecss =
'')
319 global $conf, $langs, $extralanguages;
324 $arrayoflangcode = array();
325 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
327 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
328 if (!is_object($extralanguages)) {
329 include_once DOL_DOCUMENT_ROOT.
'/core/class/extralanguages.class.php';
332 $extralanguages->fetch_name_extralanguages(
'societe');
334 if (!is_array($extralanguages->attributes[$object->element]) || empty($extralanguages->attributes[$object->element][$fieldname])) {
338 $result .=
'<!-- Widget for translation -->'.
"\n";
339 $result .=
'<div class="inline-block paddingleft image-'.$object->element.
'-'.$fieldname.
'">';
340 $s =
img_picto($langs->trans(
"ShowOtherLanguages"),
'language',
'',
false, 0, 0,
'',
'fa-15 editfieldlang');
344 $result .=
'<div class="inline-block hidden field-'.$object->element.
'-'.$fieldname.
'">';
346 $resultforextrlang =
'';
347 foreach ($arrayoflangcode as $langcode)
349 $valuetoshow =
GETPOSTISSET(
'field-'.$object->element.
"-".$fieldname.
"-".$langcode) ?
GETPOST(
'field-'.$object->element.
'-'.$fieldname.
"-".$langcode, $check) :
'';
350 if (empty($valuetoshow)) {
351 $object->fetchValuesForExtraLanguages();
353 $valuetoshow = $object->array_languages[$fieldname][$langcode];
357 $resultforextrlang .= $s;
360 if ($typeofdata ==
'textarea') {
361 $resultforextrlang .=
'<textarea name="field-'.$object->element.
"-".$fieldname.
"-".$langcode.
'" id="'.$fieldname.
"-".$langcode.
'" class="'.$morecss.
'" rows="'.ROWS_2.
'" wrap="soft">';
362 $resultforextrlang .= $valuetoshow;
363 $resultforextrlang .=
'</textarea>';
365 $resultforextrlang .=
'<input type="text" class="inputfieldforlang '.($morecss ?
' '.$morecss :
'').
'" name="field-'.$object->element.
'-'.$fieldname.
'-'.$langcode.
'" value="'.$valuetoshow.
'">';
368 $result .= $resultforextrlang;
371 $result .=
'<script>$(".image-'.$object->element.
'-'.$fieldname.
'").click(function() { console.log("Toggle lang widget"); jQuery(".field-'.$object->element.
'-'.$fieldname.
'").toggle(); });</script>';
390 protected function editInPlace($object, $value, $htmlname, $condition, $inputType =
'textarea', $editvalue = null, $extObject = null, $custommsg = null)
397 if (preg_match(
'/^text/', $inputType)) $value =
dol_nl2br($value);
398 elseif (preg_match(
'/^numeric/', $inputType)) $value =
price($value);
399 elseif ($inputType ==
'day' || $inputType ==
'datepicker') $value =
dol_print_date($value,
'day');
404 $table_element =
false;
408 $ext_element =
false;
409 $button_only =
false;
412 if (is_object($object))
414 $element = $object->element;
415 $table_element = $object->table_element;
416 $fk_element = $object->id;
419 if (is_object($extObject))
421 $ext_element = $extObject->element;
424 if (preg_match(
'/^(string|email|numeric)/', $inputType))
426 $tmp = explode(
':', $inputType);
427 $inputType = $tmp[0];
428 if (!empty($tmp[1])) $inputOption = $tmp[1];
429 if (!empty($tmp[2])) $savemethod = $tmp[2];
430 $out .=
'<input id="width_'.$htmlname.
'" value="'.$inputOption.
'" type="hidden"/>'.
"\n";
431 } elseif ((preg_match(
'/^day$/', $inputType)) || (preg_match(
'/^datepicker/', $inputType)) || (preg_match(
'/^datehourpicker/', $inputType)))
433 $tmp = explode(
':', $inputType);
434 $inputType = $tmp[0];
435 if (!empty($tmp[1])) $inputOption = $tmp[1];
436 if (!empty($tmp[2])) $savemethod = $tmp[2];
438 $out .=
'<input id="timestamp" type="hidden"/>'.
"\n";
439 } elseif (preg_match(
'/^(select|autocomplete)/', $inputType))
441 $tmp = explode(
':', $inputType);
442 $inputType = $tmp[0]; $loadmethod = $tmp[1];
443 if (!empty($tmp[2])) $savemethod = $tmp[2];
444 if (!empty($tmp[3])) $button_only =
true;
445 } elseif (preg_match(
'/^textarea/', $inputType))
447 $tmp = explode(
':', $inputType);
448 $inputType = $tmp[0];
449 $rows = (empty($tmp[1]) ?
'8' : $tmp[1]);
450 $cols = (empty($tmp[2]) ?
'80' : $tmp[2]);
451 } elseif (preg_match(
'/^ckeditor/', $inputType))
453 $tmp = explode(
':', $inputType);
454 $inputType = $tmp[0]; $toolbar = $tmp[1];
455 if (!empty($tmp[2])) $width = $tmp[2];
456 if (!empty($tmp[3])) $heigth = $tmp[3];
457 if (!empty($tmp[4])) $savemethod = $tmp[4];
459 if (!empty($conf->fckeditor->enabled))
461 $out .=
'<input id="ckeditor_toolbar" value="'.$toolbar.
'" type="hidden"/>'.
"\n";
463 $inputType =
'textarea';
467 $out .=
'<input id="element_'.$htmlname.
'" value="'.$element.
'" type="hidden"/>'.
"\n";
468 $out .=
'<input id="table_element_'.$htmlname.
'" value="'.$table_element.
'" type="hidden"/>'.
"\n";
469 $out .=
'<input id="fk_element_'.$htmlname.
'" value="'.$fk_element.
'" type="hidden"/>'.
"\n";
470 $out .=
'<input id="loadmethod_'.$htmlname.
'" value="'.$loadmethod.
'" type="hidden"/>'.
"\n";
471 if (!empty($savemethod)) $out .=
'<input id="savemethod_'.$htmlname.
'" value="'.$savemethod.
'" type="hidden"/>'.
"\n";
472 if (!empty($ext_element)) $out .=
'<input id="ext_element_'.$htmlname.
'" value="'.$ext_element.
'" type="hidden"/>'.
"\n";
473 if (!empty($custommsg))
475 if (is_array($custommsg))
477 if (!empty($custommsg[
'success']))
478 $out .=
'<input id="successmsg_'.$htmlname.
'" value="'.$custommsg[
'success'].
'" type="hidden"/>'.
"\n";
479 if (!empty($custommsg[
'error']))
480 $out .=
'<input id="errormsg_'.$htmlname.
'" value="'.$custommsg[
'error'].
'" type="hidden"/>'.
"\n";
481 }
else $out .=
'<input id="successmsg_'.$htmlname.
'" value="'.$custommsg.
'" type="hidden"/>'.
"\n";
483 if ($inputType ==
'textarea') {
484 $out .=
'<input id="textarea_'.$htmlname.
'_rows" value="'.$rows.
'" type="hidden"/>'.
"\n";
485 $out .=
'<input id="textarea_'.$htmlname.
'_cols" value="'.$cols.
'" type="hidden"/>'.
"\n";
487 $out .=
'<span id="viewval_'.$htmlname.
'" class="viewval_'.$inputType.($button_only ?
' inactive' :
' active').
'">'.$value.
'</span>'.
"\n";
488 $out .=
'<span id="editval_'.$htmlname.
'" class="editval_'.$inputType.($button_only ?
' inactive' :
' active').
' hideobject">'.(!empty($editvalue) ? $editvalue : $value).
'</span>'.
"\n";
514 public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img =
'', $extracss =
'', $notabs = 3, $incbefore =
'', $noencodehtmltext = 0, $tooltiptrigger =
'', $forcenowrap = 0)
516 if ($incbefore) $text = $incbefore.$text;
517 if (!$htmltext)
return $text;
520 if ($notabs == 2) $tag =
'div';
521 if ($notabs == 3) $tag =
'span';
523 $htmltext = str_replace(array(
"\r",
"\n"),
'', $htmltext);
526 if ($direction < 0) { $extracss = ($extracss ? $extracss.
' ' :
'').($notabs != 3 ?
'inline-block' :
''); $extrastyle =
'padding: 0px; padding-left: 3px !important;'; }
527 if ($direction > 0) { $extracss = ($extracss ? $extracss.
' ' :
'').($notabs != 3 ?
'inline-block' :
''); $extrastyle =
'padding: 0px; padding-right: 3px !important;'; }
529 $classfortooltip =
'classfortooltip';
531 $s =
''; $textfordialog =
'';
533 if ($tooltiptrigger ==
'')
535 $htmltext = str_replace(
'"',
'"', $htmltext);
537 $classfortooltip =
'classfortooltiponclick';
538 $textfordialog .=
'<div style="display: none;" id="idfortooltiponclick_'.$tooltiptrigger.
'" class="classfortooltiponclicktext">'.$htmltext.
'</div>';
540 if ($tooltipon == 2 || $tooltipon == 3)
542 $paramfortooltipimg =
' class="'.$classfortooltip.($notabs != 3 ?
' inline-block' :
'').($extracss ?
' '.$extracss :
'').
'" style="padding: 0px;'.($extrastyle ?
' '.$extrastyle :
'').
'"';
543 if ($tooltiptrigger ==
'') $paramfortooltipimg .=
' title="'.($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1)).
'"';
544 else $paramfortooltipimg .=
' dolid="'.$tooltiptrigger.
'"';
545 }
else $paramfortooltipimg = ($extracss ?
' class="'.$extracss.
'"' :
'').($extrastyle ?
' style="'.$extrastyle.
'"' :
'');
546 if ($tooltipon == 1 || $tooltipon == 3)
548 $paramfortooltiptd =
' class="'.($tooltipon == 3 ?
'cursorpointer ' :
'').$classfortooltip.
' inline-block'.($extracss ?
' '.$extracss :
'').
'" style="padding: 0px;'.($extrastyle ?
' '.$extrastyle :
'').
'" ';
549 if ($tooltiptrigger ==
'') $paramfortooltiptd .=
' title="'.($noencodehtmltext ? $htmltext :
dol_escape_htmltag($htmltext, 1)).
'"';
550 else $paramfortooltiptd .=
' dolid="'.$tooltiptrigger.
'"';
551 }
else $paramfortooltiptd = ($extracss ?
' class="'.$extracss.
'"' :
'').($extrastyle ?
' style="'.$extrastyle.
'"' :
'');
552 if (empty($notabs)) $s .=
'<table class="nobordernopadding"><tr style="height: auto;">';
553 elseif ($notabs == 2) $s .=
'<div class="inline-block'.($forcenowrap ?
' nowrap' :
'').
'">';
555 if ($direction < 0) {
556 $s .=
'<'.$tag.$paramfortooltipimg;
558 $s .=
' class=valigntop" width="14"';
560 $s .=
'>'.$textfordialog.$img.
'</'.$tag.
'>';
564 if ((
string) $text !=
'') $s .=
'<'.$tag.$paramfortooltiptd.
'>'.$text.
'</'.$tag.
'>';
566 if ($direction > 0) {
567 $s .=
'<'.$tag.$paramfortooltipimg;
568 if ($tag ==
'td') $s .=
' class="valignmiddle" width="14"';
569 $s .=
'>'.$textfordialog.$img.
'</'.$tag.
'>';
571 if (empty($notabs)) $s .=
'</tr></table>';
572 elseif ($notabs == 2) $s .=
'</div>';
591 public function textwithpicto($text, $htmltext, $direction = 1, $type =
'help', $extracss =
'', $noencodehtmltext = 0, $notabs = 3, $tooltiptrigger =
'', $forcenowrap = 0)
593 global $conf, $langs;
596 if ($tooltiptrigger) $alt = $langs->transnoentitiesnoconv(
"ClickToShowHelp");
599 if ($type ==
'0') $type =
'info';
600 elseif ($type ==
'1') $type =
'help';
603 if (empty($conf->use_javascript_ajax))
605 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable')
return $text;
613 if (!empty($conf->dol_no_mouse_hover) && empty($tooltiptrigger))
615 if ($type ==
'info' || $type ==
'infoclickable' || $type ==
'help' || $type ==
'helpclickable')
return $text;
624 if ($type ==
'info') $img =
img_help(0, $alt);
625 elseif ($type ==
'help') $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
626 elseif ($type ==
'helpclickable') $img =
img_help(($tooltiptrigger !=
'' ? 2 : 1), $alt);
627 elseif ($type ==
'superadmin') $img =
img_picto($alt,
'redstar');
628 elseif ($type ==
'admin') $img =
img_picto($alt,
'star');
629 elseif ($type ==
'warning') $img =
img_warning($alt);
630 elseif ($type !=
'none') $img =
img_picto($alt, $type);
632 return $this->
textwithtooltip($text, $htmltext, ((($tooltiptrigger && !$img) || strpos($type,
'clickable')) ? 3 : 2), $direction, $img, $extracss, $notabs,
'', $noencodehtmltext, $tooltiptrigger, $forcenowrap);
645 public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0, $name =
'massaction', $cssclass =
'checkforselect')
647 global $conf, $langs, $hookmanager;
651 $ret =
'<div class="centpercent center">';
652 $ret .=
'<select class="flat'.(empty($conf->use_javascript_ajax) ?
'' :
' hideobject').
' '.$name.
' '.$name.
'select valignmiddle alignstart" id="'.$name.
'" name="'.$name.
'"'.($disabled ?
' disabled="disabled"' :
'').
'>';
655 $parameters = array();
656 $reshook = $hookmanager->executeHooks(
'addMoreMassActions', $parameters);
658 if (count($arrayofaction) == 0 && empty($hookmanager->resPrint))
return;
661 $ret .=
'<option value="0"'.($disabled ?
' disabled="disabled"' :
'').
'>-- '.$langs->trans(
"SelectAction").
' --</option>';
662 foreach ($arrayofaction as $code => $label)
664 $ret .=
'<option value="'.$code.
'"'.($disabled ?
' disabled="disabled"' :
'').
' data-html="'.
dol_escape_htmltag($label).
'">'.$label.
'</option>';
667 $ret .= $hookmanager->resPrint;
671 if (empty($conf->dol_optimize_smallscreen)) $ret .=
ajax_combobox(
'.'.$name.
'select');
674 $ret .=
'<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">';
675 $ret .=
'<input type="submit" disabled name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax) ?
'' :
' hideobject').
' '.$name.
' '.$name.
'confirmed" value="'.
dol_escape_htmltag($langs->trans(
"Confirm")).
'">';
678 if (!empty($conf->use_javascript_ajax))
680 $ret .=
'<!-- JS CODE TO ENABLE mass action select -->
682 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 */
684 atleastoneselected=0;
685 jQuery("."+cssclass).each(function( index ) {
686 /* console.log( index + ": " + $( this ).text() ); */
687 if ($(this).is(\':checked\')) atleastoneselected++;
690 console.log("initCheckForSelect mode="+mode+" name="+name+" cssclass="+cssclass+" atleastoneselected="+atleastoneselected);
692 if (atleastoneselected || '.$alwaysvisible.
')
694 jQuery("."+name).show();
695 '.($selected ?
'if (atleastoneselected) { jQuery("."+name+"select").val("'.$selected.
'").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', false); }' :
'').
'
696 '.($selected ?
'if (! atleastoneselected) { jQuery("."+name+"select").val("0").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', true); } ' :
'').
'
700 jQuery("."+name).hide();
701 jQuery("."+name+"other").hide();
705 jQuery(document).ready(function () {
706 initCheckForSelect(0, "' . $name.
'", "'.$cssclass.
'");
707 jQuery(".' . $cssclass.
'").click(function() {
708 initCheckForSelect(1, "'.$name.
'", "'.$cssclass.
'");
710 jQuery(".' . $name.
'select").change(function() {
711 var massaction = $( this ).val();
712 var urlform = $( this ).closest("form").attr("action").replace("#show_files","");
713 if (massaction == "builddoc")
715 urlform = urlform + "#show_files";
717 $( this ).closest("form").attr("action", urlform);
718 console.log("we select a mass action name='.$name.
' massaction="+massaction+" - "+urlform);
719 /* Warning: if you set submit button to disabled, post using Enter will no more work if there is no other button */
720 if ($(this).val() != \'0\')
722 jQuery(".' . $name.
'confirmed").prop(\'disabled\', false);
723 jQuery(".' . $name.
'other").hide(); /* To disable if another div was open */
724 jQuery(".' . $name.
'"+massaction).show();
728 jQuery(".' . $name.
'confirmed").prop(\'disabled\', true);
729 jQuery(".' . $name.
'other").hide(); /* To disable any div open */
756 public function select_country($selected =
'', $htmlname =
'country_id', $htmloption =
'', $maxlength = 0, $morecss =
'minwidth300', $usecodeaskey =
'', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0, $exclude_country_code = array())
759 global $conf, $langs, $mysoc;
761 $langs->load(
"dict");
764 $countryArray = array();
767 $atleastonefavorite = 0;
769 $sql =
"SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite";
770 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_country";
771 $sql .=
" WHERE active > 0";
774 dol_syslog(get_class($this).
"::select_country", LOG_DEBUG);
778 $out .=
'<select id="select'.$htmlname.
'" class="flat maxwidth200onsmartphone selectcountry'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" '.$htmloption.
'>';
779 $num = $this->db->num_rows(
$resql);
785 $obj = $this->
db->fetch_object(
$resql);
787 $countryArray[$i][
'rowid'] = $obj->rowid;
788 $countryArray[$i][
'code_iso'] = $obj->code_iso;
789 $countryArray[$i][
'code_iso3'] = $obj->code_iso3;
790 $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 :
''));
791 $countryArray[$i][
'favorite'] = $obj->favorite;
792 $favorite[$i] = $obj->favorite;
797 if (empty($disablefavorites)) array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray);
802 $out .=
'<option value=""> </option>'.
"\n";
805 if ($addspecialentries)
808 $out .=
'<option value="special_allnotme"'.($selected ==
'special_allnotme' ?
' selected' :
'').
'>'.$langs->trans(
"CountriesExceptMe", $langs->transnoentitiesnoconv(
"Country".$mysoc->country_code)).
'</option>';
809 $out .=
'<option value="special_eec"'.($selected ==
'special_eec' ?
' selected' :
'').
'>'.$langs->trans(
"CountriesInEEC").
'</option>';
810 if ($mysoc->isInEEC()) $out .=
'<option value="special_eecnotme"'.($selected ==
'special_eecnotme' ?
' selected' :
'').
'>'.$langs->trans(
"CountriesInEECExceptMe", $langs->transnoentitiesnoconv(
"Country".$mysoc->country_code)).
'</option>';
811 $out .=
'<option value="special_noteec"'.($selected ==
'special_noteec' ?
' selected' :
'').
'>'.$langs->trans(
"CountriesNotInEEC").
'</option>';
812 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
815 foreach ($countryArray as $row)
818 if (empty($row[
'rowid']))
continue;
819 if (is_array($exclude_country_code) && count($exclude_country_code) && in_array($row[
'code_iso'], $exclude_country_code))
continue;
821 if (empty($disablefavorites) && $row[
'favorite'] && $row[
'code_iso']) $atleastonefavorite++;
822 if (empty($row[
'favorite']) && $atleastonefavorite)
824 $atleastonefavorite = 0;
825 $out .=
'<option value="" disabled class="selectoptiondisabledwhite">------------</option>';
829 if ($row[
'label']) $labeltoshow .=
dol_trunc($row[
'label'], $maxlength,
'middle');
830 else $labeltoshow .=
' ';
831 if ($row[
'code_iso']) {
832 $labeltoshow .=
' <span class="opacitymedium">('.$row[
'code_iso'].
')</span>';
833 $tmpflag =
picto_from_langcode($row[
'code_iso'],
'class="saturatemedium marginrightonly"');
834 $labeltoshow = $tmpflag.
' '.$labeltoshow;
837 if ($selected && $selected !=
'-1' && ($selected == $row[
'rowid'] || $selected == $row[
'code_iso'] || $selected == $row[
'code_iso3'] || $selected == $row[
'label'])) {
838 $out .=
'<option value="'.($usecodeaskey ? ($usecodeaskey ==
'code2' ? $row[
'code_iso'] : $row[
'code_iso3']) : $row[
'rowid']).
'" selected data-html="'.
dol_escape_htmltag($labeltoshow).
'">';
840 $out .=
'<option value="'.($usecodeaskey ? ($usecodeaskey ==
'code2' ? $row[
'code_iso'] : $row[
'code_iso3']) : $row[
'rowid']).
'" data-html="'.
dol_escape_htmltag($labeltoshow).
'">';
842 $out .= $labeltoshow;
852 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
871 public function select_incoterms($selected =
'', $location_incoterms =
'', $page =
'', $htmlname =
'incoterm_id', $htmloption =
'', $forcecombo = 1, $events = array())
874 global $conf, $langs;
876 $langs->load(
"dict");
879 $incotermArray = array();
881 $sql =
"SELECT rowid, code";
882 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_incoterms";
883 $sql .=
" WHERE active > 0";
884 $sql .=
" ORDER BY code ASC";
886 dol_syslog(get_class($this).
"::select_incoterm", LOG_DEBUG);
890 if ($conf->use_javascript_ajax && !$forcecombo)
892 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
898 $out .=
'<form method="post" action="'.$page.
'">';
899 $out .=
'<input type="hidden" name="action" value="set_incoterms">';
900 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
903 $out .=
'<select id="'.$htmlname.
'" class="flat selectincoterm minwidth100imp noenlargeonsmartphone" name="'.$htmlname.
'" '.$htmloption.
'>';
904 $out .=
'<option value="0"> </option>';
909 $foundselected =
false;
913 $obj = $this->
db->fetch_object(
$resql);
914 $incotermArray[$i][
'rowid'] = $obj->rowid;
915 $incotermArray[$i][
'code'] = $obj->code;
919 foreach ($incotermArray as $row)
921 if ($selected && ($selected == $row[
'rowid'] || $selected == $row[
'code']))
923 $out .=
'<option value="'.$row[
'rowid'].
'" selected>';
925 $out .=
'<option value="'.$row[
'rowid'].
'">';
928 if ($row[
'code']) $out .= $row[
'code'];
935 $out .=
'<input id="location_incoterms" class="maxwidth100onsmartphone" name="location_incoterms" value="'.$location_incoterms.
'">';
939 $out .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'"></form>';
960 public function select_type_of_lines($selected =
'', $htmlname =
'type', $showempty = 0, $hidetext = 0, $forceall = 0)
963 global $db, $langs, $user, $conf;
966 if ($forceall == 1 || (empty($forceall) && !empty($conf->product->enabled) && !empty($conf->service->enabled))
967 || (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled)))
969 if (empty($hidetext))
print $langs->trans(
"Type").
': ';
970 print '<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
973 print '<option value="-1"';
974 if ($selected == -1)
print ' selected';
975 print '> </option>';
978 print '<option value="0"';
979 if (0 == $selected)
print ' selected';
980 print '>'.$langs->trans(
"Product");
982 print '<option value="1"';
983 if (1 == $selected)
print ' selected';
984 print '>'.$langs->trans(
"Service");
989 if ((empty($forceall) && empty($conf->product->enabled) && !empty($conf->service->enabled)) || $forceall == 3)
991 print $langs->trans(
"Service");
992 print '<input type="hidden" name="'.$htmlname.
'" value="1">';
994 if ((empty($forceall) && !empty($conf->product->enabled) && empty($conf->service->enabled)) || $forceall == 2)
996 print $langs->trans(
"Product");
997 print '<input type="hidden" name="'.$htmlname.
'" value="0">';
1001 print '<input type="hidden" name="'.$htmlname.
'" value="1">';
1016 $num = count($this->cache_types_fees);
1017 if ($num > 0)
return 0;
1021 $langs->load(
"trips");
1023 $sql =
"SELECT c.code, c.label";
1024 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_fees as c";
1025 $sql .=
" WHERE active > 0";
1030 $num = $this->
db->num_rows(
$resql);
1035 $obj = $this->
db->fetch_object(
$resql);
1038 $label = ($obj->code != $langs->trans($obj->code) ? $langs->trans($obj->code) : $langs->trans($obj->label));
1039 $this->cache_types_fees[$obj->code] = $label;
1043 asort($this->cache_types_fees);
1064 global $user, $langs;
1066 dol_syslog(__METHOD__.
" selected=".$selected.
", htmlname=".$htmlname, LOG_DEBUG);
1070 print '<select id="select_'.$htmlname.
'" class="flat" name="'.$htmlname.
'">';
1073 print '<option value="-1"';
1074 if ($selected == -1)
print ' selected';
1075 print '> </option>';
1078 foreach ($this->cache_types_fees as $key => $value)
1080 print '<option value="'.$key.
'"';
1081 if ($key == $selected)
print ' selected';
1088 if ($user->admin)
print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1112 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)
1115 global $conf, $user, $langs;
1119 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && !$forcecombo)
1123 if ($selected && empty($selected_input_value))
1125 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1127 $societetmp->fetch($selected);
1128 $selected_input_value = $societetmp->name;
1132 $urloption =
'htmlname='.urlencode($htmlname).
'&outjson=1&filter='.urlencode($filter).($showtype ?
'&showtype='.urlencode($showtype) :
'');
1133 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
1134 $out .=
'<style type="text/css">.ui-autocomplete { z-index: 250; }</style>';
1135 if (empty($hidelabel))
print $langs->trans(
"RefOrLabel").
' : ';
1136 elseif ($hidelabel > 1) {
1137 $placeholder =
' placeholder="'.$langs->trans(
"RefOrLabel").
'"';
1138 if ($hidelabel == 2) {
1139 $out .=
img_picto($langs->trans(
"Search"),
'search');
1142 $out .=
'<input type="text" class="'.$morecss.
'" name="search_'.$htmlname.
'" id="search_'.$htmlname.
'" value="'.$selected_input_value.
'"'.$placeholder.
' '.(!empty($conf->global->THIRDPARTY_SEARCH_AUTOFOCUS) ?
'autofocus' :
'').
' />';
1143 if ($hidelabel == 3) {
1144 $out .=
img_picto($langs->trans(
"Search"),
'search');
1148 $out .= $this->
select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events,
'', 0, $limit, $morecss, $moreparam, $multiple);
1174 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)
1177 global $conf, $user, $langs;
1181 $outarray = array();
1183 if ($selected ===
'') $selected = array();
1184 elseif (!is_array($selected)) $selected = array($selected);
1187 if (function_exists(
'testSqlAndScriptInject')) {
1194 $sql =
"SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
1195 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1196 $sql .=
", s.address, s.zip, s.town";
1197 $sql .=
", dictp.code as country_code";
1199 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
1200 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1201 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as dictp ON dictp.rowid = s.fk_pays";
1203 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
1204 $sql .=
" WHERE s.entity IN (".getEntity(
'societe').
")";
1205 if (!empty($user->socid)) $sql .=
" AND s.rowid = ".$user->socid;
1206 if ($filter) $sql .=
" AND (".$filter.
")";
1207 if (!$user->rights->societe->client->voir && !$user->socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
1208 if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) $sql .=
" AND s.status <> 0";
1210 if ($filterkey && $filterkey !=
'')
1213 $prefix = empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE) ?
'%' :
'';
1215 $scrit = explode(
' ', $filterkey);
1217 if (count($scrit) > 1) $sql .=
"(";
1218 foreach ($scrit as $crit) {
1219 if ($i > 0) $sql .=
" AND ";
1220 $sql .=
"(s.nom LIKE '".$this->db->escape($prefix.$crit).
"%')";
1223 if (count($scrit) > 1) $sql .=
")";
1224 if (!empty($conf->barcode->enabled))
1226 $sql .=
" OR s.barcode LIKE '".$this->db->escape($prefix.$filterkey).
"%'";
1228 $sql .=
" OR s.code_client LIKE '".$this->db->escape($prefix.$filterkey).
"%' OR s.code_fournisseur LIKE '".$this->
db->escape($prefix.$filterkey).
"%'";
1231 $sql .= $this->
db->order(
"nom",
"ASC");
1232 $sql .= $this->
db->plimit($limit, 0);
1235 dol_syslog(get_class($this).
"::select_thirdparty_list", LOG_DEBUG);
1241 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1242 $out .=
ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
1246 $out .=
'<select id="'.$htmlname.
'" class="flat'.($morecss ?
' '.$morecss :
'').
'"'.($moreparam ?
' '.$moreparam :
'').
' name="'.$htmlname.($multiple ?
'[]' :
'').
'" '.($multiple ?
'multiple' :
'').
'>'.
"\n";
1248 $textifempty = (($showempty && !is_numeric($showempty)) ? $langs->trans($showempty) :
'');
1249 if (!empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT))
1253 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
1254 else $textifempty .= $langs->trans(
"All");
1256 if ($showempty) $out .=
'<option value="-1" data-html="'.dol_escape_htmltag(
'<span class="opacitymedium">'.$textifempty.
'</span>').
'">'.$textifempty.
'</option>'.
"\n";
1258 $num = $this->
db->num_rows(
$resql);
1264 $obj = $this->
db->fetch_object(
$resql);
1266 if ($conf->global->SOCIETE_ADD_REF_IN_LIST) {
1267 if (($obj->client) && (!empty($obj->code_client))) {
1268 $label = $obj->code_client.
' - ';
1270 if (($obj->fournisseur) && (!empty($obj->code_fournisseur))) {
1271 $label .= $obj->code_fournisseur.
' - ';
1273 $label .=
' '.$obj->name;
1275 $label = $obj->name;
1278 if (!empty($obj->name_alias)) {
1279 $label .=
' ('.$obj->name_alias.
')';
1284 if ($obj->client || $obj->fournisseur) $label .=
' (';
1285 if ($obj->client == 1 || $obj->client == 3) $label .= $langs->trans(
"Customer");
1286 if ($obj->client == 2 || $obj->client == 3) $label .= ($obj->client == 3 ?
', ' :
'').$langs->trans(
"Prospect");
1287 if ($obj->fournisseur) $label .= ($obj->client ?
', ' :
'').$langs->trans(
"Supplier");
1288 if ($obj->client || $obj->fournisseur) $label .=
')';
1291 if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) {
1292 $label .= ($obj->address ?
' - '.$obj->address :
'').($obj->zip ?
' - '.$obj->zip :
'').($obj->town ?
' '.$obj->town :
'');
1293 if (!empty($obj->country_code)) {
1294 $label .=
', '.$langs->trans(
'Country'.$obj->country_code);
1298 if (empty($outputmode))
1300 if (in_array($obj->rowid, $selected))
1302 $out .=
'<option value="'.$obj->rowid.
'" selected>'.$label.
'</option>';
1304 $out .=
'<option value="'.$obj->rowid.
'">'.$label.
'</option>';
1307 array_push($outarray, array(
'key'=>$obj->rowid,
'value'=>$label,
'label'=>$label));
1311 if (($i % 10) == 0) $out .=
"\n";
1314 $out .=
'</select>'.
"\n";
1319 $this->result = array(
'nbofthirdparties'=>$num);
1321 if ($outputmode)
return $outarray;
1340 global $langs, $conf;
1343 $sql =
"SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
1344 $sql .=
" re.description, re.fk_facture_source";
1345 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re";
1346 $sql .=
" WHERE re.fk_soc = ".(int) $socid;
1347 $sql .=
" AND re.entity = ".$conf->entity;
1348 if ($filter) $sql .=
" AND ".$filter;
1349 $sql .=
" ORDER BY re.description ASC";
1351 dol_syslog(get_class($this).
"::select_remises", LOG_DEBUG);
1355 print '<select id="select_'.$htmlname.
'" class="flat maxwidthonsmartphone" name="'.$htmlname.
'">';
1356 $num = $this->
db->num_rows(
$resql);
1358 $qualifiedlines = $num;
1363 print '<option value="0"> </option>';
1366 $obj = $this->
db->fetch_object(
$resql);
1367 $desc =
dol_trunc($obj->description, 40);
1368 if (preg_match(
'/\(CREDIT_NOTE\)/', $desc)) $desc = preg_replace(
'/\(CREDIT_NOTE\)/', $langs->trans(
"CreditNote"), $desc);
1369 if (preg_match(
'/\(DEPOSIT\)/', $desc)) $desc = preg_replace(
'/\(DEPOSIT\)/', $langs->trans(
"Deposit"), $desc);
1370 if (preg_match(
'/\(EXCESS RECEIVED\)/', $desc)) $desc = preg_replace(
'/\(EXCESS RECEIVED\)/', $langs->trans(
"ExcessReceived"), $desc);
1371 if (preg_match(
'/\(EXCESS PAID\)/', $desc)) $desc = preg_replace(
'/\(EXCESS PAID\)/', $langs->trans(
"ExcessPaid"), $desc);
1374 if ($selected > 0 && $selected == $obj->rowid) $selectstring =
' selected';
1377 if ($maxvalue > 0 && $obj->amount_ttc > $maxvalue)
1380 $disabled =
' disabled';
1383 if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->fk_facture_source))
1386 if ($tmpfac->fetch($obj->fk_facture_source) > 0) $desc = $desc.
' - '.$tmpfac->ref;
1389 print '<option value="'.$obj->rowid.
'"'.$selectstring.$disabled.
'>'.$desc.
' ('.
price($obj->amount_ht).
' '.$langs->trans(
"HT").
' - '.
price($obj->amount_ttc).
' '.$langs->trans(
"TTC").
')</option>';
1394 return $qualifiedlines;
1422 public function select_contacts($socid, $selected =
'', $htmlname =
'contactid', $showempty = 0, $exclude =
'', $limitto =
'', $showfunction = 0, $moreclass =
'', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only =
false, $moreparam =
'', $htmlid =
'')
1425 print $this->
selectcontacts($socid, $selected, $htmlname, $showempty, $exclude, $limitto, $showfunction, $moreclass, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid);
1453 public function selectcontacts($socid, $selected =
'', $htmlname =
'contactid', $showempty = 0, $exclude =
'', $limitto =
'', $showfunction = 0, $moreclass =
'', $options_only =
false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam =
'', $htmlid =
'', $multiple =
false, $disableifempty = 0)
1455 global $conf, $langs, $hookmanager, $action;
1457 $langs->load(
'companies');
1459 if (empty($htmlid)) $htmlid = $htmlname;
1462 if ($selected ===
'') $selected = array();
1463 elseif (!is_array($selected)) $selected = array($selected);
1466 if (!is_object($hookmanager))
1468 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
1473 $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";
1474 if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) $sql .=
", s.nom as company, s.town AS company_town";
1475 $sql .=
" FROM ".MAIN_DB_PREFIX.
"socpeople as sp";
1476 if ($showsoc > 0 || !empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) $sql .=
" LEFT OUTER JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid=sp.fk_soc";
1477 $sql .=
" WHERE sp.entity IN (".getEntity(
'socpeople').
")";
1478 if ($socid > 0 || $socid == -1) $sql .=
" AND sp.fk_soc=".$socid;
1479 if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql .=
" AND sp.statut <> 0";
1480 $sql .=
" ORDER BY sp.lastname ASC";
1482 dol_syslog(get_class($this).
"::select_contacts", LOG_DEBUG);
1486 $num = $this->
db->num_rows(
$resql);
1488 if ($conf->use_javascript_ajax && !$forcecombo && !$options_only)
1490 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1491 $out .=
ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT);
1494 if ($htmlname !=
'none' && !$options_only) {
1495 $out .=
'<select class="flat'.($moreclass ?
' '.$moreclass :
'').
'" id="'.$htmlid.
'" name="'.$htmlname.(($num || empty($disableifempty)) ?
'' :
' disabled').($multiple ?
'[]' :
'').
'" '.($multiple ?
'multiple' :
'').
' '.(!empty($moreparam) ? $moreparam :
'').
'>';
1498 if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple) $out .=
'<option value="0"'.(in_array(0, $selected) ?
' selected' :
'').
'> </option>';
1499 if ($showempty == 2) $out .=
'<option value="0"'.(in_array(0, $selected) ?
' selected' :
'').
'>-- '.$langs->trans(
"Internal").
' --</option>';
1504 include_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
1505 $contactstatic =
new Contact($this->
db);
1509 $obj = $this->
db->fetch_object(
$resql);
1512 $extendedInfos =
'';
1513 if (!empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) {
1514 $extendedInfos = array();
1515 $email = trim($obj->email);
1516 if (!empty($email)) $extendedInfos[] = $email;
1518 $phone = trim($obj->phone);
1519 $phone_perso = trim($obj->phone_perso);
1520 $phone_mobile = trim($obj->phone_mobile);
1521 if (!empty($phone)) $extendedInfos[] = $phone;
1522 if (!empty($phone_perso)) $extendedInfos[] = $phone_perso;
1523 if (!empty($phone_mobile)) $extendedInfos[] = $phone_mobile;
1525 $contact_town = trim($obj->contact_town);
1526 $company_town = trim($obj->company_town);
1527 if (!empty($contact_town)) $extendedInfos[] = $contact_town;
1528 elseif (!empty($company_town)) $extendedInfos[] = $company_town;
1529 $extendedInfos = implode(
' - ', $extendedInfos);
1530 if (!empty($extendedInfos)) $extendedInfos =
' - '.$extendedInfos;
1533 $contactstatic->id = $obj->rowid;
1534 $contactstatic->lastname = $obj->lastname;
1535 $contactstatic->firstname = $obj->firstname;
1536 if ($obj->statut == 1) {
1537 if ($htmlname !=
'none')
1540 if (is_array($exclude) && count($exclude) && in_array($obj->rowid, $exclude)) $disabled = 1;
1541 if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto)) $disabled = 1;
1542 if (!empty($selected) && in_array($obj->rowid, $selected))
1544 $out .=
'<option value="'.$obj->rowid.
'"';
1545 if ($disabled) $out .=
' disabled';
1546 $out .=
' selected>';
1547 $out .= $contactstatic->getFullName($langs).$extendedInfos;
1548 if ($showfunction && $obj->poste) $out .=
' ('.$obj->poste.
')';
1549 if (($showsoc > 0) && $obj->company) $out .=
' - ('.$obj->company.
')';
1550 $out .=
'</option>';
1552 $out .=
'<option value="'.$obj->rowid.
'"';
1553 if ($disabled) $out .=
' disabled';
1555 $out .= $contactstatic->getFullName($langs).$extendedInfos;
1556 if ($showfunction && $obj->poste) $out .=
' ('.$obj->poste.
')';
1557 if (($showsoc > 0) && $obj->company) $out .=
' - ('.$obj->company.
')';
1558 $out .=
'</option>';
1561 if (in_array($obj->rowid, $selected))
1563 $out .= $contactstatic->getFullName($langs).$extendedInfos;
1564 if ($showfunction && $obj->poste) $out .=
' ('.$obj->poste.
')';
1565 if (($showsoc > 0) && $obj->company) $out .=
' - ('.$obj->company.
')';
1572 $labeltoshow = ($socid != -1) ? ($langs->trans($socid ?
"NoContactDefinedForThirdParty" :
"NoContactDefined")) : $langs->trans(
'SelectAThirdPartyFirst');
1573 $out .=
'<option class="disabled" value="-1"'.(($showempty == 2 || $multiple) ?
'' :
' selected').
' disabled="disabled">';
1574 $out .= $labeltoshow;
1575 $out .=
'</option>';
1578 $parameters = array(
1580 'htmlname'=>$htmlname,
1583 'showfunction'=>$showfunction,
1584 'showsoc'=>$showsoc,
1587 $reshook = $hookmanager->executeHooks(
'afterSelectContactOptions', $parameters, $this, $action);
1589 if ($htmlname !=
'none' && !$options_only)
1591 $out .=
'</select>';
1618 public function select_users($selected =
'', $htmlname =
'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0')
1621 print $this->
select_dolusers($selected, $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity);
1648 public function select_dolusers($selected =
'', $htmlname =
'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0', $maxlength = 0, $showstatus = 0, $morefilter =
'', $show_every = 0, $enableonlytext =
'', $morecss =
'', $noactive = 0, $outputmode = 0, $multiple =
false)
1651 global $conf, $user, $langs, $hookmanager;
1654 if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected = $user->id;
1656 if ($selected ===
'') $selected = array();
1657 elseif (!is_array($selected)) $selected = array($selected);
1659 $excludeUsers = null;
1660 $includeUsers = null;
1663 if (is_array($exclude)) $excludeUsers = implode(
",", $exclude);
1665 if (is_array($include)) $includeUsers = implode(
",", $include);
1666 elseif ($include ==
'hierarchy')
1669 $includeUsers = implode(
",", $user->getAllChildIds(0));
1670 } elseif ($include ==
'hierarchyme')
1673 $includeUsers = implode(
",", $user->getAllChildIds(1));
1677 $outarray = array();
1680 $sql =
"SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut as status, u.login, u.admin, u.entity, u.photo";
1681 if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity)
1683 $sql .=
", e.label";
1685 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
1686 if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity)
1688 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"entity as e ON e.rowid=u.entity";
1689 if ($force_entity) $sql .=
" WHERE u.entity IN (0,".$force_entity.
")";
1690 else $sql .=
" WHERE u.entity IS NOT NULL";
1692 if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
1694 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"usergroup_user as ug";
1695 $sql .=
" ON ug.fk_user = u.rowid";
1696 $sql .=
" WHERE ug.entity = ".$conf->entity;
1698 $sql .=
" WHERE u.entity IN (0,".$conf->entity.
")";
1701 if (!empty($user->socid)) $sql .=
" AND u.fk_soc = ".$user->socid;
1702 if (is_array($exclude) && $excludeUsers) $sql .=
" AND u.rowid NOT IN (".$excludeUsers.
")";
1703 if ($includeUsers) $sql .=
" AND u.rowid IN (".$includeUsers.
")";
1704 if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql .=
" AND u.statut <> 0";
1705 if (!empty($morefilter)) $sql .=
" ".$morefilter;
1708 $reshook = $hookmanager->executeHooks(
'addSQLWhereFilterOnSelectUsers', array(), $this, $action);
1709 if (!empty($reshook)) $sql .= $hookmanager->resPrint;
1711 if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION))
1713 $sql .=
" ORDER BY u.firstname ASC";
1715 $sql .=
" ORDER BY u.lastname ASC";
1718 dol_syslog(get_class($this).
"::select_dolusers", LOG_DEBUG);
1722 $num = $this->
db->num_rows(
$resql);
1727 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
1731 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
' minwidth200').
'" id="'.$htmlname.
'" name="'.$htmlname.($multiple ?
'[]' :
'').
'" '.($multiple ?
'multiple' :
'').
' '.($disabled ?
' disabled' :
'').
'>';
1732 if ($show_empty && !$multiple) $out .=
'<option value="-1"'.((empty($selected) || in_array(-1, $selected)) ?
' selected' :
'').
'> </option>'.
"\n";
1733 if ($show_every) $out .=
'<option value="-2"'.((in_array(-2, $selected)) ?
' selected' :
'').
'>-- '.$langs->trans(
"Everybody").
' --</option>'.
"\n";
1735 $userstatic =
new User($this->
db);
1739 $obj = $this->
db->fetch_object(
$resql);
1741 $userstatic->id = $obj->rowid;
1742 $userstatic->lastname = $obj->lastname;
1743 $userstatic->firstname = $obj->firstname;
1744 $userstatic->photo = $obj->photo;
1745 $userstatic->statut = $obj->status;
1746 $userstatic->entity = $obj->entity;
1747 $userstatic->admin = $obj->admin;
1750 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) $disableline = ($enableonlytext ? $enableonlytext :
'1');
1756 if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION))
1760 $labeltoshow .= $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
1761 if (empty($obj->firstname) && empty($obj->lastname)) $labeltoshow .= $obj->login;
1765 if (!empty($conf->global->MAIN_SHOW_LOGIN))
1767 $moreinfo .= ($moreinfo ?
' - ' :
' (').$obj->login;
1769 if ($showstatus >= 0)
1771 if ($obj->status == 1 && $showstatus == 1)
1773 $moreinfo .= ($moreinfo ?
' - ' :
' (').$langs->trans(
'Enabled');
1775 if ($obj->status == 0 && $showstatus == 1)
1777 $moreinfo .= ($moreinfo ?
' - ' :
' (').$langs->trans(
'Disabled');
1780 if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity)
1784 $moreinfo .= ($moreinfo ?
' - ' :
' (').$langs->trans(
"AllEntities");
1786 $moreinfo .= ($moreinfo ?
' - ' :
' (').($obj->label ? $obj->label : $langs->trans(
"EntityNameNotDefined"));
1789 $moreinfo .= ($moreinfo ?
')' :
'');
1790 if ($disableline && $disableline !=
'1')
1792 $moreinfo .=
' - '.$disableline;
1794 $labeltoshow .= $moreinfo;
1796 $out .=
'<option value="'.$obj->rowid.
'"';
1797 if ($disableline) $out .=
' disabled';
1798 if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected))) {
1799 $out .=
' selected';
1801 $out .=
' data-html="';
1803 if (!empty($obj->photo))
1805 $outhtml .= $userstatic->getNomUrl(-3,
'', 0, 1, 24, 1,
'login',
'', 1).
' ';
1807 if ($showstatus >= 0 && $obj->status == 0) $outhtml .=
'<strike class="opacitymediumxxx">';
1808 $outhtml .= $labeltoshow;
1809 if ($showstatus >= 0 && $obj->status == 0) $outhtml .=
'</strike>';
1812 $out .= $labeltoshow;
1813 $out .=
'</option>';
1815 $outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength).$moreinfo;
1820 $out .=
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'" disabled>';
1821 $out .=
'<option value="">'.$langs->trans(
"None").
'</option>';
1823 $out .=
'</select>';
1828 if ($outputmode)
return $outarray;
1856 public function select_dolusers_forevent($action =
'', $htmlname =
'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0', $maxlength = 0, $showstatus = 0, $morefilter =
'', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array())
1859 global $conf, $user, $langs;
1861 $userstatic =
new User($this->
db);
1865 $assignedtouser = array();
1866 if (!empty($_SESSION[
'assignedtouser']))
1868 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
1870 $nbassignetouser = count($assignedtouser);
1873 if ($nbassignetouser) $out .=
'<ul class="attendees">';
1874 $i = 0; $ownerid = 0;
1875 foreach ($assignedtouser as $key => $value)
1877 if ($value[
'id'] == $ownerid)
continue;
1880 $userstatic->fetch($value[
'id']);
1881 $out .= $userstatic->getNomUrl(-1);
1882 if ($i == 0) { $ownerid = $value[
'id']; $out .=
' ('.$langs->trans(
"Owner").
')'; }
1883 if ($nbassignetouser > 1 && $action !=
'view')
1885 $out .=
' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans(
"Remove"),
'delete',
'', 0, 1).
'" value="'.$userstatic->id.
'" class="removedassigned" id="removedassigned_'.$userstatic->id.
'" name="removedassigned_'.$userstatic->id.
'">';
1888 if ($showproperties)
1890 if ($ownerid == $value[
'id'] && is_array($listofuserid) && count($listofuserid) && in_array($ownerid, array_keys($listofuserid)))
1892 $out .=
'<div class="myavailability inline-block">';
1893 $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>';
1903 if ($nbassignetouser) $out .=
'</ul>';
1906 if ($action !=
'view')
1908 $out .=
'<input type="hidden" class="removedassignedhidden" name="removedassigned" value="">';
1909 $out .=
'<script type="text/javascript" language="javascript">jQuery(document).ready(function () {';
1910 $out .=
'jQuery(".removedassigned").click(function() { jQuery(".removedassignedhidden").val(jQuery(this).val()); });';
1911 $out .=
'jQuery(".assignedtouser").change(function() { console.log(jQuery(".assignedtouser option:selected").val());';
1912 $out .=
' if (jQuery(".assignedtouser option:selected").val() > 0) { jQuery("#'.$action.
'assignedtouser").attr("disabled", false); }';
1913 $out .=
' else { jQuery("#'.$action.
'assignedtouser").attr("disabled", true); }';
1915 $out .=
'})</script>';
1916 $out .= $this->
select_dolusers(
'', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter);
1917 $out .=
' <input type="submit" disabled class="button valignmiddle smallpaddingimp" id="'.$action.
'assignedtouser" name="'.$action.
'assignedtouser" value="'.
dol_escape_htmltag($langs->trans(
"Add")).
'">';
1952 public function select_produits($selected =
'', $htmlname =
'productid', $filtertype =
'', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value =
'', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty =
'1', $forcecombo = 0, $morecss =
'', $hidepriceinlabel = 0, $warehouseStatus =
'', $selected_combinations = null, $nooutput = 0)
1955 global $langs, $conf;
1960 $price_level = (!empty($price_level) ? $price_level : 0);
1961 if (is_null($ajaxoptions)) $ajaxoptions = array();
1963 if (strval($filtertype) ===
'' && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
1964 if (!empty($conf->product->enabled) && empty($conf->service->enabled)) {
1966 } elseif (empty($conf->product->enabled) && !empty($conf->service->enabled)) {
1971 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT))
1975 if ($selected && empty($selected_input_value))
1977 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1978 $producttmpselect =
new Product($this->
db);
1979 $producttmpselect->fetch($selected);
1980 $selected_input_value = $producttmpselect->ref;
1981 unset($producttmpselect);
1984 if ($filtertype ==
'')
1986 if (empty($conf->product->enabled)) {
1988 } elseif (empty($conf->service->enabled)) {
1993 $urloption =
'htmlname='.$htmlname.
'&outjson=1&price_level='.$price_level.
'&type='.$filtertype.
'&mode=1&status='.$status.
'&finished='.$finished.
'&hidepriceinlabel='.$hidepriceinlabel.
'&warehousestatus='.$warehouseStatus;
1995 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
1996 $urloption .=
'&socid='.$socid;
1998 $out .=
ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
2000 if (!empty($conf->variants->enabled) && is_array($selected_combinations)) {
2004 <!-- script to auto show attributes select tags if a variant was selected -->
2006 // auto show attributes fields
2007 selected = '.json_encode($selected_combinations).
';
2010 jQuery(document).ready(function () {
2012 jQuery("input[name=\'prod_entry_mode\']").change(function () {
2013 if (jQuery(this).val() == \'free\') {
2014 jQuery(\'div#attributes_box\').empty();
2018 jQuery("input#'.$htmlname.
'").change(function () {
2020 if (!jQuery(this).val()) {
2021 jQuery(\'div#attributes_box\').empty();
2025 console.log("A change has started. We get variants fields to inject html select");
2027 jQuery.getJSON("'.DOL_URL_ROOT.
'/variants/ajax/getCombinations.php", {
2028 id: jQuery(this).val()
2029 }, function (data) {
2030 jQuery(\'div#attributes_box\').empty();
2032 jQuery.each(data, function (key, val) {
2034 combvalues[val.id] = val.values;
2036 var span = jQuery(document.createElement(\'div\')).css({
2037 \'display\': \'table-row\'
2041 jQuery(document.createElement(\'div\')).text(val.label).css({
2042 \'font-weight\': \'bold\',
2043 \'display\': \'table-cell\'
2047 var html = jQuery(document.createElement(\'select\')).attr(\'name\', \'combinations[\' + val.id + \']\').css({
2048 \'margin-left\': \'15px\',
2049 \'white-space\': \'pre\'
2051 jQuery(document.createElement(\'option\')).val(\'\')
2054 jQuery.each(combvalues[val.id], function (key, val) {
2055 var tag = jQuery(document.createElement(\'option\')).val(val.id).html(val.value);
2057 if (selected[val.fk_product_attribute] == val.id) {
2058 tag.attr(\'selected\', \'selected\');
2065 jQuery(\'div#attributes_box\').append(span);
2070 '.($selected ?
'jQuery("input#'.$htmlname.
'").change();' :
'').
'
2076 if (empty($hidelabel)) $out .= $langs->trans(
"RefOrLabel").
' : ';
2077 elseif ($hidelabel > 1) {
2078 $placeholder =
' placeholder="'.$langs->trans(
"RefOrLabel").
'"';
2079 if ($hidelabel == 2) {
2080 $out .=
img_picto($langs->trans(
"Search"),
'search');
2083 $out .=
'<input type="text" class="minwidth100" name="search_'.$htmlname.
'" id="search_'.$htmlname.
'" value="'.$selected_input_value.
'"'.$placeholder.
' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ?
'autofocus' :
'').
' />';
2084 if ($hidelabel == 3) {
2085 $out .=
img_picto($langs->trans(
"Search"),
'search');
2088 $out .= $this->
select_produits_list($selected, $htmlname, $filtertype, $limit, $price_level,
'', $status, $finished, 0, $socid, $showempty, $forcecombo, $morecss, $hidepriceinlabel, $warehouseStatus);
2091 if (empty($nooutput))
print $out;
2120 public function select_produits_list($selected =
'', $htmlname =
'productid', $filtertype =
'', $limit = 20, $price_level = 0, $filterkey =
'', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty =
'1', $forcecombo = 0, $morecss =
'', $hidepriceinlabel = 0, $warehouseStatus =
'')
2123 global $langs, $conf, $user, $db;
2126 $outarray = array();
2129 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2130 $langs->load(
'other');
2133 $warehouseStatusArray = array();
2134 if (!empty($warehouseStatus))
2136 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
2137 if (preg_match(
'/warehouseclosed/', $warehouseStatus))
2141 if (preg_match(
'/warehouseopen/', $warehouseStatus))
2145 if (preg_match(
'/warehouseinternal/', $warehouseStatus))
2151 $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.duration, p.fk_price_expression";
2152 if (count($warehouseStatusArray))
2154 $selectFieldsGrouped =
", sum(".$this->db->ifsql(
"e.statut IS NULL",
"0",
"ps.reel").
") as stock";
2156 $selectFieldsGrouped =
", ".$this->db->ifsql(
"p.stock IS NULL", 0,
"p.stock").
" AS stock";
2160 $sql .= $selectFields.$selectFieldsGrouped;
2162 if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY))
2165 $sql .=
", (SELECT ".MAIN_DB_PREFIX.
"categorie_product.fk_categorie
2166 FROM ".MAIN_DB_PREFIX.
"categorie_product
2167 WHERE ".MAIN_DB_PREFIX.
"categorie_product.fk_product=p.rowid
2169 ) AS categorie_product_id ";
2173 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid))
2175 $sql .=
', pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,';
2176 $sql .=
' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx';
2177 $selectFields .=
", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx";
2180 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2181 $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";
2182 $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';
2186 if (!empty($conf->global->MAIN_MULTILANGS))
2188 $sql .=
", pl.label as label_translated";
2189 $selectFields .=
", label_translated";
2192 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
2194 $sql .=
", (SELECT pp.rowid FROM ".MAIN_DB_PREFIX.
"product_price as pp WHERE pp.fk_product = p.rowid";
2195 if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $sql .=
" AND price_level=".$price_level;
2196 $sql .=
" ORDER BY date_price";
2197 $sql .=
" DESC LIMIT 1) as price_rowid";
2198 $sql .=
", (SELECT pp.price_by_qty FROM ".MAIN_DB_PREFIX.
"product_price as pp WHERE pp.fk_product = p.rowid";
2199 if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $sql .=
" AND price_level=".$price_level;
2200 $sql .=
" ORDER BY date_price";
2201 $sql .=
" DESC LIMIT 1) as price_by_qty";
2202 $selectFields .=
", price_rowid, price_by_qty";
2204 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
2205 if (count($warehouseStatusArray))
2207 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_stock as ps on ps.fk_product = p.rowid";
2208 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (".
getEntity(
'stock').
")";
2209 $sql .=
' AND e.statut IN ('.$this->db->sanitize($this->
db->escape(implode(
',', $warehouseStatusArray))).
')';
2213 if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF))
2215 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
2219 if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
2220 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_customer_price as pcp ON pcp.fk_soc=".$socid.
" AND pcp.fk_product=p.rowid";
2223 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2224 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_units u ON u.rowid = p.fk_unit";
2227 if (!empty($conf->global->MAIN_MULTILANGS))
2229 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='".$this->
db->escape($langs->getDefaultLang()).
"'";
2232 if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
2233 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_attribute_combination pac ON pac.fk_product_child = p.rowid";
2236 $sql .=
' WHERE p.entity IN ('.getEntity(
'product').
')';
2238 if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
2239 $sql .=
" AND pac.rowid IS NULL";
2244 $sql .=
" AND p.finished = ".$finished;
2245 } elseif ($finished == 1)
2247 $sql .=
" AND p.finished = ".$finished;
2248 if ($status >= 0) $sql .=
" AND p.tosell = ".$status;
2249 } elseif ($status >= 0)
2251 $sql .=
" AND p.tosell = ".$status;
2254 if (strval($filtertype) !=
'') $sql .=
" AND p.fk_product_type = ".$filtertype;
2255 elseif (empty($conf->product->enabled)) {
2256 $sql .=
" AND p.fk_product_type = 1";
2257 } elseif (empty($conf->service->enabled)) {
2258 $sql .=
" AND p.fk_product_type = 0";
2261 if ($filterkey !=
'')
2264 $prefix = empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE) ?
'%' :
'';
2266 $scrit = explode(
' ', $filterkey);
2268 if (count($scrit) > 1) $sql .=
"(";
2269 foreach ($scrit as $crit)
2271 if ($i > 0) $sql .=
" AND ";
2272 $sql .=
"(p.ref LIKE '".$this->db->escape($prefix.$crit).
"%' OR p.label LIKE '".$this->
db->escape($prefix.$crit).
"%'";
2273 if (!empty($conf->global->MAIN_MULTILANGS)) $sql .=
" OR pl.label LIKE '".$this->db->escape($prefix.$crit).
"%'";
2274 if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION))
2276 $sql .=
" OR p.description LIKE '".$this->db->escape($prefix.$crit).
"%'";
2277 if (!empty($conf->global->MAIN_MULTILANGS)) $sql .=
" OR pl.description LIKE '".$this->db->escape($prefix.$crit).
"%'";
2279 if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) $sql .=
" OR pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit).
"%'";
2283 if (count($scrit) > 1) $sql .=
")";
2284 if (!empty($conf->barcode->enabled)) $sql .=
" OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey).
"%'";
2287 if (count($warehouseStatusArray))
2289 $sql .=
' GROUP BY'.$selectFields;
2293 if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY))
2295 $sql .=
" ORDER BY categorie_product_id ";
2297 ($conf->global->PRODUCT_SORT_BY_CATEGORY == 1) ? $sql .=
"ASC" : $sql .=
"DESC";
2299 $sql .= $this->
db->order(
"p.ref");
2302 $sql .= $this->
db->plimit($limit, 0);
2305 dol_syslog(get_class($this).
"::select_produits_list search products", LOG_DEBUG);
2306 $result = $this->
db->query($sql);
2309 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
2310 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
2311 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
2313 $num = $this->
db->num_rows($result);
2319 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
2320 $out .=
ajax_combobox($htmlname, $events, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT);
2323 $out .=
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
2328 if (!empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT))
2330 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
2331 else $textifempty .= $langs->trans(
"All");
2333 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
2335 if ($showempty) $out .=
'<option value="0" selected>'.$textifempty.
'</option>';
2338 while ($num && $i < $num)
2342 $objp = $this->
db->fetch_object($result);
2344 if ((!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1)
2346 $sql =
"SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type";
2347 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_price_by_qty";
2348 $sql .=
" WHERE fk_product_price=".$objp->price_rowid;
2349 $sql .=
" ORDER BY quantity ASC";
2351 dol_syslog(get_class($this).
"::select_produits_list search prices by qty", LOG_DEBUG);
2352 $result2 = $this->
db->query($sql);
2355 $nb_prices = $this->
db->num_rows($result2);
2357 while ($nb_prices && $j < $nb_prices) {
2358 $objp2 = $this->
db->fetch_object($result2);
2360 $objp->price_by_qty_rowid = $objp2->rowid;
2361 $objp->price_by_qty_price_base_type = $objp2->price_base_type;
2362 $objp->price_by_qty_quantity = $objp2->quantity;
2363 $objp->price_by_qty_unitprice = $objp2->unitprice;
2364 $objp->price_by_qty_remise_percent = $objp2->remise_percent;
2366 $objp->quantity = $objp2->quantity;
2367 $objp->price = $objp2->price;
2368 $objp->unitprice = $objp2->unitprice;
2369 $objp->remise_percent = $objp2->remise_percent;
2370 $objp->remise = $objp2->remise;
2380 array_push($outarray, $optJson);
2384 if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression)) {
2385 $price_product =
new Product($this->
db);
2386 $price_product->fetch($objp->rowid,
'',
'', 1);
2388 $price_result = $priceparser->parseProduct($price_product);
2389 if ($price_result >= 0) {
2390 $objp->price = $price_result;
2391 $objp->unitprice = $price_result;
2393 $objp->price_ttc =
price2num($objp->price) * (1 + ($objp->tva_tx / 100));
2394 $objp->price_ttc =
price2num($objp->price_ttc,
'MU');
2403 array_push($outarray, $optJson);
2409 $out .=
'</select>';
2411 $this->
db->free($result);
2413 if (empty($outputmode))
return $out;
2434 protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey =
'', $novirtualstock = 0)
2436 global $langs, $conf, $user, $db;
2448 $outpricebasetype =
'';
2453 $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
2455 $label = $objp->label;
2456 if (!empty($objp->label_translated)) $label = $objp->label_translated;
2457 if (!empty($filterkey) && $filterkey !=
'') $label = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $label, 1);
2459 $outkey = $objp->rowid;
2460 $outref = $objp->ref;
2461 $outlabel = $objp->label;
2462 $outdesc = $objp->description;
2463 $outbarcode = $objp->barcode;
2464 $outorigin = $objp->fk_country;
2465 $outpbq = empty($objp->price_by_qty_rowid) ?
'' : $objp->price_by_qty_rowid;
2467 $outtype = $objp->fk_product_type;
2471 if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
2475 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2476 if (!empty($objp->unit_short)) {
2477 $outvalUnits .=
' - '.$objp->unit_short;
2480 if (!empty($conf->global->PRODUCT_SHOW_DIMENSIONS_IN_COMBO)) {
2481 if (!empty($objp->weight) && $objp->weight_units !== null) {
2483 $outvalUnits .=
' - '.$unitToShow;
2485 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) {
2486 $unitToShow = $objp->length.
' x '.$objp->width.
' x '.$objp->height.
' '.
measuringUnitString(0,
'size', $objp->length_units);
2487 $outvalUnits .=
' - '.$unitToShow;
2489 if (!empty($objp->surface) && $objp->surface_units !== null) {
2491 $outvalUnits .=
' - '.$unitToShow;
2493 if (!empty($objp->volume) && $objp->volume_units !== null) {
2495 $outvalUnits .=
' - '.$unitToShow;
2498 if ($outdurationvalue && $outdurationunit) {
2500 'h' => $langs->trans(
'Hour'),
2501 'd' => $langs->trans(
'Day'),
2502 'w' => $langs->trans(
'Week'),
2503 'm' => $langs->trans(
'Month'),
2504 'y' => $langs->trans(
'Year')
2506 if (isset($da[$outdurationunit])) {
2507 $outvalUnits .=
' - '.$outdurationvalue.
' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ?
's' :
''));
2511 $opt =
'<option value="'.$objp->rowid.
'"';
2512 $opt .= ($objp->rowid == $selected) ?
' selected' :
'';
2513 if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0)
2515 $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.
'"';
2517 if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)))
2519 if (!empty($user->rights->stock->lire)) {
2520 if ($objp->stock > 0) $opt .=
' class="product_line_stock_ok"';
2521 elseif ($objp->stock <= 0) $opt .=
' class="product_line_stock_too_low"';
2526 if ($outbarcode) $opt .=
' ('.$outbarcode.
')';
2527 $opt .=
' - '.dol_trunc($label, $maxlengtharticle);
2528 if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) $opt .=
' ('.getCountry($outorigin, 1).
')';
2530 $objRef = $objp->ref;
2531 if (!empty($filterkey) && $filterkey !=
'') $objRef = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $objRef, 1);
2533 if ($outbarcode) $outval .=
' ('.$outbarcode.
')';
2534 $outval .=
' - '.dol_trunc($label, $maxlengtharticle);
2535 if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) $outval .=
' ('.getCountry($outorigin, 1).
')';
2538 $opt .= $outvalUnits;
2539 $outval .= $outvalUnits;
2545 if (empty($hidepriceinlabel) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)))
2547 $sql =
"SELECT price, price_ttc, price_base_type, tva_tx";
2548 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_price";
2549 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
2550 $sql .=
" AND entity IN (".getEntity(
'productprice').
")";
2551 $sql .=
" AND price_level = ".((int) $price_level);
2552 $sql .=
" ORDER BY date_price DESC, rowid DESC";
2555 dol_syslog(get_class($this).
'::constructProductListOption search price for product '.$objp->rowid.
' AND level '.$price_level.
'', LOG_DEBUG);
2556 $result2 = $this->
db->query($sql);
2559 $objp2 = $this->
db->fetch_object($result2);
2563 if ($objp2->price_base_type ==
'HT')
2565 $opt .=
' - '.price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"HT");
2566 $outval .=
' - '.price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"HT");
2568 $opt .=
' - '.price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"TTC");
2569 $outval .=
' - '.price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"TTC");
2571 $outprice_ht =
price($objp2->price);
2572 $outprice_ttc =
price($objp2->price_ttc);
2573 $outpricebasetype = $objp2->price_base_type;
2574 $outtva_tx = $objp2->tva_tx;
2582 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1 && (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)))
2585 $outqty = $objp->quantity;
2586 $outdiscount = $objp->remise_percent;
2587 if ($objp->quantity == 1)
2589 $opt .=
' - '.price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency).
"/";
2590 $outval .=
' - '.price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency).
"/";
2591 $opt .= $langs->trans(
"Unit");
2592 $outval .= $langs->transnoentities(
"Unit");
2594 $opt .=
' - '.price($objp->price, 1, $langs, 0, 0, -1, $conf->currency).
"/".$objp->quantity;
2595 $outval .=
' - '.price($objp->price, 0, $langs, 0, 0, -1, $conf->currency).
"/".$objp->quantity;
2596 $opt .= $langs->trans(
"Units");
2597 $outval .= $langs->transnoentities(
"Units");
2600 $outprice_ht =
price($objp->unitprice);
2601 $outprice_ttc =
price($objp->unitprice * (1 + ($objp->tva_tx / 100)));
2602 $outpricebasetype = $objp->price_base_type;
2603 $outtva_tx = $objp->tva_tx;
2605 if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1)
2607 $opt .=
" (".price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency).
"/".$langs->trans(
"Unit").
")";
2608 $outval .=
" (".price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency).
"/".$langs->transnoentities(
"Unit").
")";
2610 if (empty($hidepriceinlabel) && !empty($objp->remise_percent) && $objp->remise_percent >= 1)
2612 $opt .=
" - ".$langs->trans(
"Discount").
" : ".
vatrate($objp->remise_percent).
' %';
2613 $outval .=
" - ".$langs->transnoentities(
"Discount").
" : ".
vatrate($objp->remise_percent).
' %';
2617 if (empty($hidepriceinlabel) && !empty($conf->global->PRODUIT_CUSTOMER_PRICES))
2619 if (!empty($objp->idprodcustprice))
2623 if ($objp->custprice_base_type ==
'HT')
2625 $opt .=
' - '.price($objp->custprice, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"HT");
2626 $outval .=
' - '.price($objp->custprice, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"HT");
2628 $opt .=
' - '.price($objp->custprice_ttc, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"TTC");
2629 $outval .=
' - '.price($objp->custprice_ttc, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"TTC");
2632 $outprice_ht =
price($objp->custprice);
2633 $outprice_ttc =
price($objp->custprice_ttc);
2634 $outpricebasetype = $objp->custprice_base_type;
2635 $outtva_tx = $objp->custtva_tx;
2640 if (empty($hidepriceinlabel) && !$found)
2642 if ($objp->price_base_type ==
'HT')
2644 $opt .=
' - '.price($objp->price, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"HT");
2645 $outval .=
' - '.price($objp->price, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"HT");
2647 $opt .=
' - '.price($objp->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).
' '.$langs->trans(
"TTC");
2648 $outval .=
' - '.price($objp->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).
' '.$langs->transnoentities(
"TTC");
2650 $outprice_ht =
price($objp->price);
2651 $outprice_ttc =
price($objp->price_ttc);
2652 $outpricebasetype = $objp->price_base_type;
2653 $outtva_tx = $objp->tva_tx;
2656 if (!empty($conf->stock->enabled) && isset($objp->stock) && ($objp->fk_product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)))
2658 if (!empty($user->rights->stock->lire)) {
2659 $opt .=
' - '.$langs->trans(
"Stock").
': '.
price(
price2num($objp->stock,
'MS'));
2661 if ($objp->stock > 0) {
2662 $outval .=
' - <span class="product_line_stock_ok">';
2663 } elseif ($objp->stock <= 0) {
2664 $outval .=
' - <span class="product_line_stock_too_low">';
2666 $outval .= $langs->transnoentities(
"Stock").
': '.
price(
price2num($objp->stock,
'MS'));
2667 $outval .=
'</span>';
2668 if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO))
2670 $langs->load(
"stocks");
2673 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
2674 $tmpproduct->load_virtual_stock();
2675 $virtualstock = $tmpproduct->stock_theorique;
2677 $opt .=
' - '.$langs->trans(
"VirtualStock").
':'.$virtualstock;
2679 $outval .=
' - '.$langs->transnoentities(
"VirtualStock").
':';
2680 if ($virtualstock > 0) {
2681 $outval .=
'<span class="product_line_stock_ok">';
2682 } elseif ($virtualstock <= 0) {
2683 $outval .=
'<span class="product_line_stock_too_low">';
2685 $outval .= $virtualstock;
2686 $outval .=
'</span>';
2693 $opt .=
"</option>\n";
2694 $optJson = array(
'key'=>$outkey,
'value'=>$outref,
'label'=>$outval,
'label2'=>$outlabel,
'desc'=>$outdesc,
'type'=>$outtype,
'price_ht'=>
price2num($outprice_ht),
'price_ttc'=>
price2num($outprice_ttc),
'pricebasetype'=>$outpricebasetype,
'tva_tx'=>$outtva_tx,
'qty'=>$outqty,
'discount'=>$outdiscount,
'duration_value'=>$outdurationvalue,
'duration_unit'=>$outdurationunit,
'pbq'=>$outpbq);
2712 public function select_produits_fournisseurs($socid, $selected =
'', $htmlname =
'productid', $filtertype =
'', $filtre =
'', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss =
'')
2715 global $langs, $conf;
2716 global $price_level, $status, $finished;
2718 $selected_input_value =
'';
2719 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT))
2723 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
2724 $producttmpselect =
new Product($this->
db);
2725 $producttmpselect->fetch($selected);
2726 $selected_input_value = $producttmpselect->ref;
2727 unset($producttmpselect);
2731 $urloption = ($socid > 0 ?
'socid='.$socid.
'&' :
'').
'htmlname='.$htmlname.
'&outjson=1&price_level='.$price_level.
'&type='.$filtertype.
'&mode=2&status='.$status.
'&finished='.$finished.
'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice;
2732 print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.
'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
2733 print ($hidelabel ?
'' : $langs->trans(
"RefOrLabel").
' : ').
'<input type="text" size="20" name="search_'.$htmlname.
'" id="search_'.$htmlname.
'" value="'.$selected_input_value.
'">';
2735 print $this->
select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre,
'', -1, 0, 0, $alsoproductwithnosupplierprice, $morecss);
2757 public function select_produits_fournisseurs_list($socid, $selected =
'', $htmlname =
'productid', $filtertype =
'', $filtre =
'', $filterkey =
'', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss =
'', $showstockinlist = 0)
2760 global $langs, $conf, $db, $user;
2763 $outarray = array();
2765 $maxlengtharticle = (empty($conf->global->PRODUCT_MAX_LENGTH_COMBO) ? 48 : $conf->global->PRODUCT_MAX_LENGTH_COMBO);
2767 $langs->load(
'stocks');
2769 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2770 $langs->load(
'other');
2773 $sql =
"SELECT p.rowid, p.ref, p.label, p.price, p.duration, p.fk_product_type, p.stock,";
2774 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
2775 $sql .=
" pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,";
2776 $sql .=
" pfp.supplier_reputation";
2778 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2779 $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";
2781 if (!empty($conf->barcode->enabled)) $sql .=
", pfp.barcode";
2782 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
2783 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp ON ( p.rowid = pfp.fk_product AND pfp.entity IN (".
getEntity(
'product').
") )";
2784 if ($socid) $sql .=
" AND pfp.fk_soc = ".$socid;
2785 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON pfp.fk_soc = s.rowid";
2787 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2788 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_units u ON u.rowid = p.fk_unit";
2790 $sql .=
" WHERE p.entity IN (".getEntity(
'product').
")";
2791 $sql .=
" AND p.tobuy = 1";
2792 if (strval($filtertype) !=
'') $sql .=
" AND p.fk_product_type=".$this->db->escape($filtertype);
2793 if (!empty($filtre)) $sql .=
" ".$filtre;
2795 if ($filterkey !=
'')
2798 $prefix = empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE) ?
'%' :
'';
2800 $scrit = explode(
' ', $filterkey);
2802 if (count($scrit) > 1) $sql .=
"(";
2803 foreach ($scrit as $crit)
2805 if ($i > 0) $sql .=
" AND ";
2806 $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).
"%')";
2809 if (count($scrit) > 1) $sql .=
")";
2810 if (!empty($conf->barcode->enabled)) {
2811 $sql .=
" OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey).
"%'";
2812 $sql .=
" OR pfp.barcode LIKE '".$this->db->escape($prefix.$filterkey).
"%'";
2816 $sql .=
" ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
2817 $sql .= $this->
db->plimit($limit, 0);
2821 dol_syslog(get_class($this).
"::select_produits_fournisseurs_list", LOG_DEBUG);
2822 $result = $this->
db->query($sql);
2825 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
2826 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
2828 $num = $this->
db->num_rows($result);
2831 $out .=
'<select class="flat maxwidthonsmartphone'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.
'">';
2832 if (!$selected) $out .=
'<option value="0" selected> </option>';
2833 else $out .=
'<option value="0"> </option>';
2838 $objp = $this->
db->fetch_object($result);
2840 $outkey = $objp->idprodfournprice;
2841 if (!$outkey && $alsoproductwithnosupplierprice) $outkey =
'idprod_'.$objp->rowid;
2843 $outref = $objp->ref;
2845 $outbarcode = $objp->barcode;
2848 $outtype = $objp->fk_product_type;
2854 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2855 if (!empty($objp->unit_short)) {
2856 $outvalUnits .=
' - '.$objp->unit_short;
2858 if (!empty($objp->weight) && $objp->weight_units !== null) {
2860 $outvalUnits .=
' - '.$unitToShow;
2862 if ((!empty($objp->length) || !empty($objp->width) || !empty($objp->height)) && $objp->length_units !== null) {
2863 $unitToShow = $objp->length.
' x '.$objp->width.
' x '.$objp->height.
' '.
measuringUnitString(0,
'size', $objp->length_units);
2864 $outvalUnits .=
' - '.$unitToShow;
2866 if (!empty($objp->surface) && $objp->surface_units !== null) {
2868 $outvalUnits .=
' - '.$unitToShow;
2870 if (!empty($objp->volume) && $objp->volume_units !== null) {
2872 $outvalUnits .=
' - '.$unitToShow;
2874 if ($outdurationvalue && $outdurationunit) {
2876 'h' => $langs->trans(
'Hour'),
2877 'd' => $langs->trans(
'Day'),
2878 'w' => $langs->trans(
'Week'),
2879 'm' => $langs->trans(
'Month'),
2880 'y' => $langs->trans(
'Year')
2882 if (isset($da[$outdurationunit])) {
2883 $outvalUnits .=
' - '.$outdurationvalue.
' '.$langs->transnoentities($da[$outdurationunit].($outdurationvalue > 1 ?
's' :
''));
2888 $objRef = $objp->ref;
2889 if ($filterkey && $filterkey !=
'') $objRef = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $objRef, 1);
2890 $objRefFourn = $objp->ref_fourn;
2891 if ($filterkey && $filterkey !=
'') $objRefFourn = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $objRefFourn, 1);
2892 $label = $objp->label;
2893 if ($filterkey && $filterkey !=
'') $label = preg_replace(
'/('.preg_quote($filterkey,
'/').
')/i',
'<strong>$1</strong>', $label, 1);
2895 $optlabel = $objp->ref;
2896 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
2897 $optlabel .=
' <span class=\'opacitymedium\'>('.$objp->ref_fourn.
')</span>';
2899 if (!empty($conf->barcode->enabled) && !empty($objp->barcode)) {
2900 $optlabel .=
' ('.$outbarcode.
')';
2902 $optlabel .=
' - '.dol_trunc($label, $maxlengtharticle);
2904 $outvallabel = $objRef;
2905 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn)) {
2906 $outvallabel .=
' ('.$objRefFourn.
')';
2908 if (!empty($conf->barcode->enabled) && !empty($objp->barcode)) {
2909 $outvallabel .=
' ('.$outbarcode.
')';
2911 $outvallabel .=
' - '.dol_trunc($label, $maxlengtharticle);
2914 $optlabel .= $outvalUnits;
2915 $outvallabel .= $outvalUnits;
2917 if (!empty($objp->idprodfournprice))
2919 $outqty = $objp->quantity;
2920 $outdiscount = $objp->remise_percent;
2921 if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_supplier_price_expression)) {
2923 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
2924 $prod_supplier->id = $objp->fk_product;
2925 $prod_supplier->fourn_qty = $objp->quantity;
2926 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
2927 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
2929 $price_result = $priceparser->parseProductSupplier($prod_supplier);
2930 if ($price_result >= 0) {
2931 $objp->fprice = $price_result;
2932 if ($objp->quantity >= 1)
2934 $objp->unitprice = $objp->fprice / $objp->quantity;
2938 if ($objp->quantity == 1)
2940 $optlabel .=
' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency).
"/";
2941 $outvallabel .=
' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency).
"/";
2942 $optlabel .= $langs->trans(
"Unit");
2943 $outvallabel .= $langs->transnoentities(
"Unit");
2945 $optlabel .=
' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency).
"/".$objp->quantity;
2946 $outvallabel .=
' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency).
"/".$objp->quantity;
2947 $optlabel .=
' '.$langs->trans(
"Units");
2948 $outvallabel .=
' '.$langs->transnoentities(
"Units");
2951 if ($objp->quantity > 1)
2953 $optlabel .=
" (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency).
"/".$langs->trans(
"Unit").
")";
2954 $outvallabel .=
" (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency).
"/".$langs->transnoentities(
"Unit").
")";
2956 if ($objp->remise_percent >= 1)
2958 $optlabel .=
" - ".$langs->trans(
"Discount").
" : ".
vatrate($objp->remise_percent).
' %';
2959 $outvallabel .=
" - ".$langs->transnoentities(
"Discount").
" : ".
vatrate($objp->remise_percent).
' %';
2961 if ($objp->duration)
2963 $optlabel .=
" - ".$objp->duration;
2964 $outvallabel .=
" - ".$objp->duration;
2968 $optlabel .=
" - ".dol_trunc($objp->name, 8);
2969 $outvallabel .=
" - ".dol_trunc($objp->name, 8);
2971 if ($objp->supplier_reputation)
2974 $reputations = array(
''=>$langs->trans(
'Standard'),
'FAVORITE'=>$langs->trans(
'Favorite'),
'NOTTHGOOD'=>$langs->trans(
'NotTheGoodQualitySupplier'),
'DONOTORDER'=>$langs->trans(
'DoNotOrderThisProductToThisSupplier'));
2976 $optlabel .=
" - ".$reputations[$objp->supplier_reputation];
2977 $outvallabel .=
" - ".$reputations[$objp->supplier_reputation];
2980 if (empty($alsoproductwithnosupplierprice))
2982 $optlabel .=
" - <span class='opacitymedium'>".$langs->trans(
"NoPriceDefinedForThisSupplier").
'</span>';
2983 $outvallabel .=
' - '.$langs->transnoentities(
"NoPriceDefinedForThisSupplier");
2986 $optlabel .=
" - <span class='opacitymedium'>".$langs->trans(
"NoPriceDefinedForThisSupplier").
'</span>';
2987 $outvallabel .=
' - '.$langs->transnoentities(
"NoPriceDefinedForThisSupplier");
2991 if (!empty($conf->stock->enabled) && $showstockinlist && isset($objp->stock) && ($objp->fk_product_type ==
Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)))
2993 $novirtualstock = ($showstockinlist == 2);
2995 if (!empty($user->rights->stock->lire)) {
2996 $outvallabel .=
' - '.$langs->trans(
"Stock").
': '.
price(
price2num($objp->stock,
'MS'));
2998 if ($objp->stock > 0) {
2999 $optlabel .=
' - <span class="product_line_stock_ok">';
3000 } elseif ($objp->stock <= 0) {
3001 $optlabel .=
' - <span class="product_line_stock_too_low">';
3003 $optlabel .= $langs->transnoentities(
"Stock").
':'.
price(
price2num($objp->stock,
'MS'));
3004 $optlabel .=
'</span>';
3005 if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO))
3007 $langs->load(
"stocks");
3010 $tmpproduct->fetch($objp->rowid,
'',
'',
'', 1, 1, 1);
3011 $tmpproduct->load_virtual_stock();
3012 $virtualstock = $tmpproduct->stock_theorique;
3014 $outvallabel .=
' - '.$langs->trans(
"VirtualStock").
':'.$virtualstock;
3016 $optlabel .=
' - '.$langs->transnoentities(
"VirtualStock").
':';
3017 if ($virtualstock > 0) {
3018 $optlabel .=
'<span class="product_line_stock_ok">';
3019 } elseif ($virtualstock <= 0) {
3020 $optlabel .=
'<span class="product_line_stock_too_low">';
3022 $optlabel .= $virtualstock;
3023 $optlabel .=
'</span>';
3030 $opt =
'<option value="'.$outkey.
'"';
3031 if ($selected && $selected == $objp->idprodfournprice) $opt .=
' selected';
3032 if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt .=
' disabled';
3033 if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0)
3035 $opt .=
' pbq="'.$objp->idprodfournprice.
'" data-pbq="'.$objp->idprodfournprice.
'" data-pbqqty="'.$objp->quantity.
'" data-pbqup="'.$objp->unitprice.
'" data-pbqpercent="'.$objp->remise_percent.
'"';
3037 $opt .=
' data-html="'.dol_escape_htmltag($optlabel).
'"';
3041 $outval .= $outvallabel;
3043 $opt .=
"</option>\n";
3050 array_push($outarray, array(
'key'=>$outkey,
'value'=>$outref,
'label'=>$outval,
'qty'=>$outqty,
'price_ht'=>
price2num($objp->unitprice,
'MT'),
'up'=>
price2num($objp->unitprice,
'MT'),
'discount'=>$outdiscount,
'type'=>$outtype,
'duration_value'=>$outdurationvalue,
'duration_unit'=>$outdurationunit,
'disabled'=>(empty($objp->idprodfournprice) ?
true:
false)));
3062 $out .=
'</select>';
3064 $this->
db->free($result);
3066 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
3069 if (empty($outputmode))
return $out;
3088 global $langs, $conf;
3090 $langs->load(
'stocks');
3092 $sql =
"SELECT p.rowid, p.ref, p.label, p.price, p.duration, pfp.fk_soc,";
3093 $sql .=
" pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,";
3094 $sql .=
" pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name";
3095 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product as p";
3096 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
3097 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON pfp.fk_soc = s.rowid";
3098 $sql .=
" WHERE pfp.entity IN (".getEntity(
'productsupplierprice').
")";
3099 $sql .=
" AND p.tobuy = 1";
3100 $sql .=
" AND s.fournisseur = 1";
3101 $sql .=
" AND p.rowid = ".$productid;
3102 $sql .=
" ORDER BY s.nom, pfp.ref_fourn DESC";
3104 dol_syslog(get_class($this).
"::select_product_fourn_price", LOG_DEBUG);
3105 $result = $this->
db->query($sql);
3109 $num = $this->
db->num_rows($result);
3111 $form =
'<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
3115 $form .=
'<option value="0">-- '.$langs->trans(
"NoSupplierPriceDefinedForThisProduct").
' --</option>';
3117 require_once DOL_DOCUMENT_ROOT.
'/product/dynamic_price/class/price_parser.class.php';
3118 $form .=
'<option value="0"> </option>';
3123 $objp = $this->
db->fetch_object($result);
3125 $opt =
'<option value="'.$objp->idprodfournprice.
'"';
3127 if ($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier)) {
3128 $opt .=
' selected';
3130 $opt .=
'>'.$objp->name.
' - '.$objp->ref_fourn.
' - ';
3132 if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_supplier_price_expression)) {
3134 $prod_supplier->product_fourn_price_id = $objp->idprodfournprice;
3135 $prod_supplier->id = $productid;
3136 $prod_supplier->fourn_qty = $objp->quantity;
3137 $prod_supplier->fourn_tva_tx = $objp->tva_tx;
3138 $prod_supplier->fk_supplier_price_expression = $objp->fk_supplier_price_expression;
3140 $price_result = $priceparser->parseProductSupplier($prod_supplier);
3141 if ($price_result >= 0) {
3142 $objp->fprice = $price_result;
3143 if ($objp->quantity >= 1)
3145 $objp->unitprice = $objp->fprice / $objp->quantity;
3149 if ($objp->quantity == 1)
3151 $opt .=
price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency).
"/";
3154 $opt .= $objp->quantity.
' ';
3156 if ($objp->quantity == 1)
3158 $opt .= $langs->trans(
"Unit");
3160 $opt .= $langs->trans(
"Units");
3162 if ($objp->quantity > 1)
3165 $opt .=
price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency).
"/".$langs->trans(
"Unit");
3167 if ($objp->duration) $opt .=
" - ".$objp->duration;
3168 $opt .=
"</option>\n";
3175 $form .=
'</select>';
3176 $this->
db->free($result);
3193 public function select_address($selected, $socid, $htmlname =
'address_id', $showempty = 0)
3197 $sql =
"SELECT a.rowid, a.label";
3198 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_address as a";
3199 $sql .=
" WHERE a.fk_soc = ".$socid;
3200 $sql .=
" ORDER BY a.label ASC";
3202 dol_syslog(get_class($this).
"::select_address", LOG_DEBUG);
3206 print '<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
3207 if ($showempty)
print '<option value="0"> </option>';
3208 $num = $this->
db->num_rows(
$resql);
3214 $obj = $this->
db->fetch_object(
$resql);
3216 if ($selected && $selected == $obj->rowid)
3218 print '<option value="'.$obj->rowid.
'" selected>'.$obj->label.
'</option>';
3220 print '<option value="'.$obj->rowid.
'">'.$obj->label.
'</option>';
3244 $num = count($this->cache_conditions_paiements);
3245 if ($num > 0)
return 0;
3249 $sql =
"SELECT rowid, code, libelle as label";
3250 $sql .=
" FROM ".MAIN_DB_PREFIX.
'c_payment_term';
3251 $sql .=
" WHERE entity IN (".getEntity(
'c_payment_term').
")";
3252 $sql .=
" AND active > 0";
3253 $sql .=
" ORDER BY sortorder";
3258 $num = $this->
db->num_rows(
$resql);
3262 $obj = $this->
db->fetch_object(
$resql);
3265 $label = ($langs->trans(
"PaymentConditionShort".$obj->code) != (
"PaymentConditionShort".$obj->code) ? $langs->trans(
"PaymentConditionShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
3266 $this->cache_conditions_paiements[$obj->rowid][
'code'] = $obj->code;
3267 $this->cache_conditions_paiements[$obj->rowid][
'label'] = $label;
3291 $num = count($this->cache_availability);
3292 if ($num > 0)
return 0;
3296 $langs->load(
'propal');
3298 $sql =
"SELECT rowid, code, label";
3299 $sql .=
" FROM ".MAIN_DB_PREFIX.
'c_availability';
3300 $sql .=
" WHERE active > 0";
3305 $num = $this->
db->num_rows(
$resql);
3309 $obj = $this->
db->fetch_object(
$resql);
3312 $label = ($langs->trans(
"AvailabilityType".$obj->code) != (
"AvailabilityType".$obj->code) ? $langs->trans(
"AvailabilityType".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
3313 $this->cache_availability[$obj->rowid][
'code'] = $obj->code;
3314 $this->cache_availability[$obj->rowid][
'label'] = $label;
3318 $this->cache_availability =
dol_sort_array($this->cache_availability,
'label',
'asc', 0, 0, 1);
3338 global $langs, $user;
3342 dol_syslog(__METHOD__.
" selected=".$selected.
", htmlname=".$htmlname, LOG_DEBUG);
3344 print '<select id="'.$htmlname.
'" class="flat" name="'.$htmlname.
'">';
3345 if ($addempty)
print '<option value="0"> </option>';
3346 foreach ($this->cache_availability as $id => $arrayavailability)
3348 if ($selected == $id)
3350 print '<option value="'.$id.
'" selected>';
3352 print '<option value="'.$id.
'">';
3354 print $arrayavailability[
'label'];
3358 if ($user->admin)
print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3371 $num = count($this->cache_demand_reason);
3372 if ($num > 0)
return 0;
3374 $sql =
"SELECT rowid, code, label";
3375 $sql .=
" FROM ".MAIN_DB_PREFIX.
'c_input_reason';
3376 $sql .=
" WHERE active > 0";
3381 $num = $this->
db->num_rows(
$resql);
3383 $tmparray = array();
3386 $obj = $this->
db->fetch_object(
$resql);
3389 $label = ($obj->label !=
'-' ? $obj->label :
'');
3390 if ($langs->trans(
"DemandReasonType".$obj->code) != (
"DemandReasonType".$obj->code)) $label = $langs->trans(
"DemandReasonType".$obj->code);
3391 if ($langs->trans($obj->code) != $obj->code) $label = $langs->trans($obj->code);
3393 $tmparray[$obj->rowid][
'id'] = $obj->rowid;
3394 $tmparray[$obj->rowid][
'code'] = $obj->code;
3395 $tmparray[$obj->rowid][
'label'] = $label;
3399 $this->cache_demand_reason =
dol_sort_array($tmparray,
'label',
'asc', 0, 0, 1);
3419 public function selectInputReason($selected =
'', $htmlname =
'demandreasonid', $exclude =
'', $addempty = 0)
3421 global $langs, $user;
3425 print '<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
3426 if ($addempty)
print '<option value="0"'.(empty($selected) ?
' selected' :
'').
'> </option>';
3427 foreach ($this->cache_demand_reason as $id => $arraydemandreason)
3429 if ($arraydemandreason[
'code'] == $exclude)
continue;
3431 if ($selected && ($selected == $arraydemandreason[
'id'] || $selected == $arraydemandreason[
'code']))
3433 print '<option value="'.$arraydemandreason[
'id'].
'" selected>';
3435 print '<option value="'.$arraydemandreason[
'id'].
'">';
3437 $label = $arraydemandreason[
'label'];
3438 print $langs->trans($label);
3442 if ($user->admin)
print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3457 $num = count($this->cache_types_paiements);
3458 if ($num > 0)
return $num;
3462 $this->cache_types_paiements = array();
3464 $sql =
"SELECT id, code, libelle as label, type, active";
3465 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_paiement";
3466 $sql .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
3472 $num = $this->
db->num_rows(
$resql);
3476 $obj = $this->
db->fetch_object(
$resql);
3479 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort".$obj->code) != (
"PaymentTypeShort".$obj->code) ? $langs->transnoentitiesnoconv(
"PaymentTypeShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
3480 $this->cache_types_paiements[$obj->id][
'id'] = $obj->id;
3481 $this->cache_types_paiements[$obj->id][
'code'] = $obj->code;
3482 $this->cache_types_paiements[$obj->id][
'label'] = $label;
3483 $this->cache_types_paiements[$obj->id][
'type'] = $obj->type;
3484 $this->cache_types_paiements[$obj->id][
'active'] = $obj->active;
3488 $this->cache_types_paiements =
dol_sort_array($this->cache_types_paiements,
'label',
'asc', 0, 0, 1);
3515 global $langs, $user, $conf;
3517 dol_syslog(__METHOD__.
" selected=".$selected.
", htmlname=".$htmlname, LOG_DEBUG);
3522 if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID;
3524 print '<select id="'.$htmlname.
'" class="flat selectpaymentterms'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
3525 if ($addempty)
print '<option value="0"> </option>';
3526 foreach ($this->cache_conditions_paiements as $id => $arrayconditions)
3528 if ($selected == $id)
3530 print '<option value="'.$id.
'" selected>';
3532 print '<option value="'.$id.
'">';
3534 print $arrayconditions[
'label'];
3538 if ($user->admin && empty($noinfoadmin))
print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3559 public function select_types_paiements($selected =
'', $htmlname =
'paiementtype', $filtertype =
'', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'')
3562 global $langs, $user, $conf;
3564 dol_syslog(__METHOD__.
" ".$selected.
", ".$htmlname.
", ".$filtertype.
", ".$format, LOG_DEBUG);
3566 $filterarray = array();
3567 if ($filtertype ==
'CRDT') $filterarray = array(0, 2, 3);
3568 elseif ($filtertype ==
'DBIT') $filterarray = array(1, 2, 3);
3569 elseif ($filtertype !=
'' && $filtertype !=
'-1') $filterarray = explode(
',', $filtertype);
3574 if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID)) $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TYPE_ID;
3576 print '<select id="select'.$htmlname.
'" class="flat selectpaymenttypes'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
3577 if ($empty)
print '<option value=""> </option>';
3578 foreach ($this->cache_types_paiements as $id => $arraytypes)
3581 if ($active >= 0 && $arraytypes[
'active'] != $active)
continue;
3584 if (count($filterarray) && !in_array($arraytypes[
'type'], $filterarray))
continue;
3587 if ($empty && empty($arraytypes[
'code']))
continue;
3589 if ($format == 0)
print '<option value="'.$id.
'"';
3590 elseif ($format == 1)
print '<option value="'.$arraytypes[
'code'].
'"';
3591 elseif ($format == 2)
print '<option value="'.$arraytypes[
'code'].
'"';
3592 elseif ($format == 3)
print '<option value="'.$id.
'"';
3594 if ($format == 1 || $format == 2) {
3595 if ($selected == $arraytypes[
'code'])
print ' selected';
3597 if ($selected == $id)
print ' selected';
3600 if ($format == 0) $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
3601 elseif ($format == 1) $value = $arraytypes[
'code'];
3602 elseif ($format == 2) $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
3603 elseif ($format == 3) $value = $arraytypes[
'code'];
3604 print $value ? $value :
' ';
3608 if ($user->admin && !$noadmininfo)
print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3625 $return =
'<select class="flat maxwidth100" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
3627 'HT'=>$langs->trans(
"HT"),
3628 'TTC'=>$langs->trans(
"TTC")
3630 foreach ($options as $id => $value)
3632 if ($selected == $id)
3634 $return .=
'<option value="'.$id.
'" selected>'.$value;
3636 $return .=
'<option value="'.$id.
'">'.$value;
3638 $return .=
'</option>';
3640 $return .=
'</select>';
3641 if ($addjscombo) $return .=
ajax_combobox(
'select_'.$htmlname);
3657 $num = count($this->cache_transport_mode);
3658 if ($num > 0)
return $num;
3662 $this->cache_transport_mode = array();
3664 $sql =
"SELECT rowid, code, label, active";
3665 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_transport_mode";
3666 $sql .=
" WHERE entity IN (".getEntity(
'c_transport_mode').
")";
3672 $num = $this->
db->num_rows(
$resql);
3676 $obj = $this->
db->fetch_object(
$resql);
3679 $label = ($langs->transnoentitiesnoconv(
"PaymentTypeShort".$obj->code) != (
"PaymentTypeShort".$obj->code) ? $langs->transnoentitiesnoconv(
"PaymentTypeShort".$obj->code) : ($obj->label !=
'-' ? $obj->label :
''));
3680 $this->cache_transport_mode[$obj->rowid][
'rowid'] = $obj->rowid;
3681 $this->cache_transport_mode[$obj->rowid][
'code'] = $obj->code;
3682 $this->cache_transport_mode[$obj->rowid][
'label'] = $label;
3683 $this->cache_transport_mode[$obj->rowid][
'active'] = $obj->active;
3687 $this->cache_transport_mode =
dol_sort_array($this->cache_transport_mode,
'label',
'asc', 0, 0, 1);
3710 public function selectTransportMode($selected =
'', $htmlname =
'transportmode', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss =
'')
3712 global $langs, $user;
3714 dol_syslog(__METHOD__.
" ".$selected.
", ".$htmlname.
", ".$format, LOG_DEBUG);
3718 print '<select id="select'.$htmlname.
'" class="flat selectmodetransport'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'">';
3719 if ($empty)
print '<option value=""> </option>';
3720 foreach ($this->cache_transport_mode as $id => $arraytypes)
3723 if ($active >= 0 && $arraytypes[
'active'] != $active)
continue;
3726 if ($empty && empty($arraytypes[
'code']))
continue;
3728 if ($format == 0)
print '<option value="'.$id.
'"';
3729 elseif ($format == 1)
print '<option value="'.$arraytypes[
'code'].
'"';
3730 elseif ($format == 2)
print '<option value="'.$arraytypes[
'code'].
'"';
3731 elseif ($format == 3)
print '<option value="'.$id.
'"';
3733 if (preg_match(
'/[a-z]/i', $selected) && $selected == $arraytypes[
'code'])
print ' selected';
3734 elseif ($selected == $id)
print ' selected';
3736 if ($format == 0) $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
3737 elseif ($format == 1) $value = $arraytypes[
'code'];
3738 elseif ($format == 2) $value = ($maxlength ?
dol_trunc($arraytypes[
'label'], $maxlength) : $arraytypes[
'label']);
3739 elseif ($format == 3) $value = $arraytypes[
'code'];
3740 print $value ? $value :
' ';
3744 if ($user->admin && !$noadmininfo)
print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3757 public function selectShippingMethod($selected =
'', $htmlname =
'shipping_method_id', $filtre =
'', $useempty = 0, $moreattrib =
'')
3759 global $langs, $conf, $user;
3761 $langs->load(
"admin");
3762 $langs->load(
"deliveries");
3764 $sql =
"SELECT rowid, code, libelle as label";
3765 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_shipment_mode";
3766 $sql .=
" WHERE active > 0";
3767 if ($filtre) $sql .=
" AND ".$filtre;
3768 $sql .=
" ORDER BY libelle ASC";
3770 dol_syslog(get_class($this).
"::selectShippingMode", LOG_DEBUG);
3771 $result = $this->
db->query($sql);
3773 $num = $this->
db->num_rows($result);
3776 print '<select id="select'.$htmlname.
'" class="flat selectshippingmethod" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
3777 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
3778 print '<option value="-1"> </option>';
3781 $obj = $this->
db->fetch_object($result);
3782 if ($selected == $obj->rowid) {
3783 print '<option value="'.$obj->rowid.
'" selected>';
3785 print '<option value="'.$obj->rowid.
'">';
3787 print ($langs->trans(
"SendingMethod".strtoupper($obj->code)) !=
"SendingMethod".strtoupper($obj->code)) ? $langs->trans(
"SendingMethod".strtoupper($obj->code)) : $obj->label;
3792 if ($user->admin)
print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
3796 print $langs->trans(
"NoShippingMethodDefined");
3816 $langs->load(
"deliveries");
3818 if ($htmlname !=
"none") {
3819 print '<form method="POST" action="'.$page.
'">';
3820 print '<input type="hidden" name="action" value="setshippingmethod">';
3821 print '<input type="hidden" name="token" value="'.newToken().
'">';
3823 print '<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
3827 $code = $langs->getLabelFromKey($db, $selected,
'c_shipment_mode',
'rowid',
'code');
3828 print $langs->trans(
"SendingMethod".strtoupper($code));
3847 $langs->load(
'bills');
3849 $opt =
'<option value ="" selected></option>';
3850 $sql =
'SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc';
3851 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture';
3852 $sql .=
' WHERE entity IN ('.getEntity(
'invoice').
')';
3853 $sql .=
' AND situation_counter >= 1';
3854 $sql .=
' AND fk_soc = '.(int) $socid;
3855 $sql .=
' AND type <> 2';
3856 $sql .=
' ORDER by situation_cycle_ref, situation_counter desc';
3862 while ($obj = $this->
db->fetch_object(
$resql)) {
3864 if ($obj->situation_cycle_ref != $ref) {
3866 $ref = $obj->situation_cycle_ref;
3868 if ($obj->situation_final != 1) {
3870 if (substr($obj->ref, 1, 4) !=
'PROV') {
3871 if ($selected == $obj->rowid) {
3872 $opt .=
'<option value="'.$obj->rowid.
'" selected>'.$obj->ref.
'</option>';
3874 $opt .=
'<option value="'.$obj->rowid.
'">'.$obj->ref.
'</option>';
3881 dol_syslog(
"Error sql=".$sql.
", error=".$this->error, LOG_ERR);
3883 if ($opt ==
'<option value ="" selected></option>')
3885 $opt =
'<option value ="0" selected>'.$langs->trans(
'NoSituations').
'</option>';
3898 public function selectUnits($selected =
'', $htmlname =
'units', $showempty = 0)
3902 $langs->load(
'products');
3904 $return =
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
3906 $sql =
'SELECT rowid, label, code from '.MAIN_DB_PREFIX.
'c_units';
3907 $sql .=
' WHERE active > 0';
3912 if ($showempty) $return .=
'<option value="none"></option>';
3914 while ($res = $this->
db->fetch_object(
$resql))
3916 $unitLabel = $res->label;
3917 if (!empty($langs->tab_translate[
'unit'.$res->code]))
3919 $unitLabel = $langs->trans(
'unit'.$res->code) != $res->label ? $langs->trans(
'unit'.$res->code) : $res->label;
3922 if ($selected == $res->rowid)
3924 $return .=
'<option value="'.$res->rowid.
'" selected>'.$unitLabel.
'</option>';
3926 $return .=
'<option value="'.$res->rowid.
'">'.$unitLabel.
'</option>';
3929 $return .=
'</select>';
3949 public function select_comptes($selected =
'', $htmlname =
'accountid', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'', $showcurrency = 0, $morecss =
'', $nooutput = 0)
3952 global $langs, $conf;
3956 $langs->load(
"admin");
3959 $sql =
"SELECT rowid, label, bank, clos as status, currency_code";
3960 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account";
3961 $sql .=
" WHERE entity IN (".getEntity(
'bank_account').
")";
3962 if ($status != 2) $sql .=
" AND clos = ".(int) $status;
3963 if ($filtre) $sql .=
" AND ".$filtre;
3964 $sql .=
" ORDER BY label";
3966 dol_syslog(get_class($this).
"::select_comptes", LOG_DEBUG);
3967 $result = $this->
db->query($sql);
3970 $num = $this->
db->num_rows($result);
3974 $out .=
'<select id="select'.$htmlname.
'" class="flat selectbankaccount'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
3975 if ($useempty == 1 || ($useempty == 2 && $num > 1))
3977 $out .=
'<option value="-1"> </option>';
3982 $obj = $this->
db->fetch_object($result);
3983 if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected)))
3985 $out .=
'<option value="'.$obj->rowid.
'" selected>';
3987 $out .=
'<option value="'.$obj->rowid.
'">';
3989 $out .= trim($obj->label);
3990 if ($showcurrency) $out .=
' ('.$obj->currency_code.
')';
3991 if ($status == 2 && $obj->status == 1) $out .=
' ('.$langs->trans(
"Closed").
')';
3992 $out .=
'</option>';
3995 $out .=
"</select>";
3998 if ($status == 0) $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoActiveBankAccountDefined").
'</span>';
3999 else $out .=
'<span class="opacitymedium">'.$langs->trans(
"NoBankAccountFound").
'</span>';
4006 if (empty($nooutput))
print $out;
4023 public function selectEstablishments($selected =
'', $htmlname =
'entity', $status = 0, $filtre =
'', $useempty = 0, $moreattrib =
'')
4026 global $langs, $conf;
4028 $langs->load(
"admin");
4031 $sql =
"SELECT rowid, name, fk_country, status, entity";
4032 $sql .=
" FROM ".MAIN_DB_PREFIX.
"establishment";
4033 $sql .=
" WHERE 1=1";
4034 if ($status != 2) $sql .=
" AND status = ".(int) $status;
4035 if ($filtre) $sql .=
" AND ".$filtre;
4036 $sql .=
" ORDER BY name";
4038 dol_syslog(get_class($this).
"::select_establishment", LOG_DEBUG);
4039 $result = $this->
db->query($sql);
4042 $num = $this->
db->num_rows($result);
4046 print '<select id="select'.$htmlname.
'" class="flat selectestablishment" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
4047 if ($useempty == 1 || ($useempty == 2 && $num > 1))
4049 print '<option value="-1"> </option>';
4054 $obj = $this->
db->fetch_object($result);
4055 if ($selected == $obj->rowid)
4057 print '<option value="'.$obj->rowid.
'" selected>';
4059 print '<option value="'.$obj->rowid.
'">';
4061 print trim($obj->name);
4062 if ($status == 2 && $obj->status == 1)
print ' ('.$langs->trans(
"Closed").
')';
4068 if ($status == 0)
print '<span class="opacitymedium">'.$langs->trans(
"NoActiveEstablishmentDefined").
'</span>';
4069 else print '<span class="opacitymedium">'.$langs->trans(
"NoEstablishmentFound").
'</span>';
4088 if ($htmlname !=
"none") {
4089 print '<form method="POST" action="'.$page.
'">';
4090 print '<input type="hidden" name="action" value="setbankaccount">';
4091 print '<input type="hidden" name="token" value="'.newToken().
'">';
4092 $nbaccountfound = $this->
select_comptes($selected, $htmlname, 0,
'', $addempty);
4093 if ($nbaccountfound > 0)
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
4096 $langs->load(
'banks');
4099 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
4101 $result = $bankstatic->fetch($selected);
4102 if ($result)
print $bankstatic->getNomUrl(1);
4128 public function select_all_categories($type, $selected =
'', $htmlname =
"parent", $maxlength = 64, $markafterid = 0, $outputmode = 0, $include = 0, $morecss =
'')
4131 global $conf, $langs;
4132 $langs->load(
"categories");
4134 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
4137 if (is_numeric($type))
4139 dol_syslog(__METHOD__.
': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
4142 if ($type === Categorie::TYPE_BANK_LINE)
4145 $cate_arbo = array();
4146 $sql =
"SELECT c.label, c.rowid";
4147 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_categ as c";
4148 $sql .=
" WHERE entity = ".$conf->entity;
4149 $sql .=
" ORDER BY c.label";
4150 $result = $this->
db->query($sql);
4153 $num = $this->
db->num_rows($result);
4157 $objp = $this->
db->fetch_object($result);
4158 if ($objp) $cate_arbo[$objp->rowid] = array(
'id'=>$objp->rowid,
'fulllabel'=>$objp->label);
4161 $this->
db->free($result);
4165 $cate_arbo = $cat->get_full_arbo($type, $markafterid, $include);
4168 $output =
'<select class="flat'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'" id="'.$htmlname.
'">';
4169 $outarray = array();
4170 if (is_array($cate_arbo))
4172 if (!count($cate_arbo)) $output .=
'<option value="-1" disabled>'.$langs->trans(
"NoCategoriesDefined").
'</option>';
4174 $output .=
'<option value="-1"> </option>';
4175 foreach ($cate_arbo as $key => $value)
4177 if ($cate_arbo[$key][
'id'] == $selected || ($selected ===
'auto' && count($cate_arbo) == 1))
4183 $output .=
'<option '.$add.
'value="'.$cate_arbo[$key][
'id'].
'">'.
dol_trunc($cate_arbo[$key][
'fulllabel'], $maxlength,
'middle').
'</option>';
4185 $outarray[$cate_arbo[$key][
'id']] = $cate_arbo[$key][
'fulllabel'];
4189 $output .=
'</select>';
4192 if ($outputmode)
return $outarray;
4213 public function form_confirm($page, $title, $question, $action, $formquestion =
'', $selectedchoice =
"", $useajax = 0, $height = 170, $width = 500)
4216 dol_syslog(__METHOD__.
': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING);
4217 print $this->
formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width);
4244 public function formconfirm($page, $title, $question, $action, $formquestion =
'', $selectedchoice =
'', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0)
4246 global $langs, $conf;
4248 $more =
'<!-- formconfirm for page='.dol_escape_htmltag($page).
' -->';
4254 $newselectedchoice = empty($selectedchoice) ?
"no" : $selectedchoice;
4255 if ($conf->browser->layout ==
'phone') $width =
'95%';
4258 if (empty($height)) {
4260 if (is_array($formquestion) && count($formquestion) > 2) {
4261 $height += ((count($formquestion) - 2) * 24);
4265 if (is_array($formquestion) && !empty($formquestion))
4268 foreach ($formquestion as $key => $input)
4270 if (is_array($input) && !empty($input))
4272 if ($input[
'type'] ==
'hidden')
4274 $more .=
'<input type="hidden" id="'.$input[
'name'].
'" name="'.$input[
'name'].
'" value="'.
dol_escape_htmltag($input[
'value']).
'">'.
"\n";
4280 $moreonecolumn =
'';
4281 $more .=
'<div class="tagtable paddingtopbottomonly centpercent noborderspacing">'.
"\n";
4282 foreach ($formquestion as $key => $input)
4284 if (is_array($input) && !empty($input))
4286 $size = (!empty($input[
'size']) ?
' size="'.$input[
'size'].
'"' :
'');
4287 $moreattr = (!empty($input[
'moreattr']) ?
' '.$input[
'moreattr'] :
'');
4288 $morecss = (!empty($input[
'morecss']) ?
' '.$input[
'morecss'] :
'');
4290 if ($input[
'type'] ==
'text')
4292 $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="'.$input[
'name'].
'" name="'.$input[
'name'].
'"'.$size.
' value="'.$input[
'value'].
'"'.$moreattr.
' /></div></div>'.
"\n";
4293 } elseif ($input[
'type'] ==
'password')
4295 $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="'.$input[
'name'].
'" name="'.$input[
'name'].
'"'.$size.
' value="'.$input[
'value'].
'"'.$moreattr.
' /></div></div>'.
"\n";
4296 } elseif ($input[
'type'] ==
'select')
4298 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">';
4299 if (!empty($input[
'label'])) $more .= $input[
'label'].
'</div><div class="tagtd left">';
4300 $more .= $this->
selectarray($input[
'name'], $input[
'values'], $input[
'default'], 1, 0, 0, $moreattr, 0, 0, 0,
'', $morecss);
4301 $more .=
'</div></div>'.
"\n";
4302 } elseif ($input[
'type'] ==
'checkbox')
4304 $more .=
'<div class="tagtr">';
4305 $more .=
'<div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">'.$input[
'label'].
' </div><div class="tagtd">';
4306 $more .=
'<input type="checkbox" class="flat'.$morecss.
'" id="'.$input[
'name'].
'" name="'.$input[
'name'].
'"'.$moreattr;
4307 if (!is_bool($input[
'value']) && $input[
'value'] !=
'false' && $input[
'value'] !=
'0') $more .=
' checked';
4308 if (is_bool($input[
'value']) && $input[
'value']) $more .=
' checked';
4309 if (isset($input[
'disabled'])) $more .=
' disabled';
4310 $more .=
' /></div>';
4311 $more .=
'</div>'.
"\n";
4312 } elseif ($input[
'type'] ==
'radio')
4315 foreach ($input[
'values'] as $selkey => $selval)
4317 $more .=
'<div class="tagtr">';
4318 if ($i == 0) $more .=
'<div class="tagtd'.(empty($input[
'tdclass']) ?
' tdtop' : (
' tdtop '.$input[
'tdclass'])).
'">'.$input[
'label'].
'</div>';
4319 else $more .=
'<div clas="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' "'.$input[
'tdclass'])).
'"> </div>';
4320 $more .=
'<div class="tagtd'.($i == 0 ?
' tdtop' :
'').
'"><input type="radio" class="flat'.$morecss.
'" id="'.$input[
'name'].$selkey.
'" name="'.$input[
'name'].
'" value="'.$selkey.
'"'.$moreattr;
4321 if ($input[
'disabled']) $more .=
' disabled';
4322 if (isset($input[
'default']) && $input[
'default'] === $selkey) $more .=
' checked="checked"';
4324 $more .=
'<label for="'.$input[
'name'].$selkey.
'">'.$selval.
'</label>';
4325 $more .=
'</div></div>'.
"\n";
4328 } elseif ($input[
'type'] ==
'date')
4330 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">'.$input[
'label'].
'</div>';
4331 $more .=
'<div class="tagtd">';
4332 $more .= $this->
selectDate($input[
'value'], $input[
'name'], 0, 0, 0,
'', 1, 0);
4333 $more .=
'</div></div>'.
"\n";
4334 $formquestion[] = array(
'name'=>$input[
'name'].
'day');
4335 $formquestion[] = array(
'name'=>$input[
'name'].
'month');
4336 $formquestion[] = array(
'name'=>$input[
'name'].
'year');
4337 $formquestion[] = array(
'name'=>$input[
'name'].
'hour');
4338 $formquestion[] = array(
'name'=>$input[
'name'].
'min');
4339 } elseif ($input[
'type'] ==
'other')
4341 $more .=
'<div class="tagtr"><div class="tagtd'.(empty($input[
'tdclass']) ?
'' : (
' '.$input[
'tdclass'])).
'">';
4342 if (!empty($input[
'label'])) $more .= $input[
'label'].
'</div><div class="tagtd">';
4343 $more .= $input[
'value'];
4344 $more .=
'</div></div>'.
"\n";
4345 } elseif ($input[
'type'] ==
'onecolumn')
4347 $moreonecolumn .=
'<div class="margintoponly">';
4348 $moreonecolumn .= $input[
'value'];
4349 $moreonecolumn .=
'</div>'.
"\n";
4353 $more .=
'</div>'.
"\n";
4354 $more .= $moreonecolumn;
4360 if (!empty($conf->dol_use_jmobile)) $useajax = 0;
4361 if (empty($conf->use_javascript_ajax)) $useajax = 0;
4366 $dialogconfirm =
'dialog-confirm';
4368 if (!is_numeric($useajax))
4373 $dialogconfirm .=
'-'.$button;
4375 $pageyes = $page.(preg_match(
'/\?/', $page) ?
'&' :
'?').
'action='.$action.
'&confirm=yes';
4376 $pageno = ($useajax == 2 ? $page.(preg_match(
'/\?/', $page) ?
'&' :
'?').
'confirm=no' :
'');
4378 if (is_array($formquestion))
4380 foreach ($formquestion as $key => $input)
4383 if (is_array($input) && isset($input[
'name'])) array_push($inputok, $input[
'name']);
4384 if (isset($input[
'inputko']) && $input[
'inputko'] == 1) array_push($inputko, $input[
'name']);
4388 $formconfirm .=
'<div id="'.$dialogconfirm.
'" title="'.
dol_escape_htmltag($title).
'" style="display: none;">';
4389 if (is_array($formquestion) && !empty($formquestion[
'text'])) {
4390 $formconfirm .=
'<div class="confirmtext">'.$formquestion[
'text'].
'</div>'.
"\n";
4392 if (!empty($more)) {
4393 $formconfirm .=
'<div class="confirmquestions">'.$more.
'</div>'.
"\n";
4395 $formconfirm .= ($question ?
'<div class="confirmmessage">'.img_help(
'',
'').
' '.$question.
'</div>' :
'');
4396 $formconfirm .=
'</div>'.
"\n";
4398 $formconfirm .=
"\n<!-- begin ajax formconfirm page=".$page.
" -->\n";
4399 $formconfirm .=
'<script type="text/javascript">'.
"\n";
4400 $formconfirm .=
'jQuery(document).ready(function() {
4402 $( "#'.$dialogconfirm.
'" ).dialog(
4404 autoOpen: '.($autoOpen ?
"true" :
"false").
',';
4405 if ($newselectedchoice ==
'no')
4409 $(this).parent().find("button.ui-button:eq(2)").focus();
4414 height: "'.$height.
'",
4415 width: "'.$width.
'",
4417 closeOnEscape: false,
4419 "'.
dol_escape_js($langs->transnoentities(
"Yes")).
'": function() {
4420 var options = "&token='.urlencode(
newToken()).
'";
4421 var inputok = '.json_encode($inputok).
'; /* List of fields into form */
4422 var pageyes = "'.
dol_escape_js(!empty($pageyes) ? $pageyes :
'').
'";
4423 if (inputok.length>0) {
4424 $.each(inputok, function(i, inputname) {
4427 if ($("input[name=\'" + inputname + "\']").attr("type") == "radio") {
4428 inputvalue = $("input[name=\'" + inputname + "\']").val();
4430 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
4431 inputvalue = $("#" + inputname + more).val();
4433 if (typeof inputvalue == "undefined") { inputvalue=""; }
4434 console.log("check inputname="+inputname+" inputvalue="+inputvalue);
4435 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
4438 var urljump = pageyes + (pageyes.indexOf("?") < 0 ? "?" : "") + options;
4439 if (pageyes.length > 0) { location.href = urljump; }
4440 $(this).dialog("close");
4442 "'.
dol_escape_js($langs->transnoentities(
"No")).
'": function() {
4443 var options = "&token='.urlencode(
newToken()).
'";
4444 var inputko = '.json_encode($inputko).
'; /* List of fields into form */
4445 var pageno="'.
dol_escape_js(!empty($pageno) ? $pageno :
'').
'";
4446 if (inputko.length>0) {
4447 $.each(inputko, function(i, inputname) {
4449 if ($("#" + inputname).attr("type") == "checkbox") { more = ":checked"; }
4450 var inputvalue = $("#" + inputname + more).val();
4451 if (typeof inputvalue == "undefined") { inputvalue=""; }
4452 options += "&" + inputname + "=" + encodeURIComponent(inputvalue);
4455 var urljump=pageno + (pageno.indexOf("?") < 0 ? "?" : "") + options;
4457 if (pageno.length > 0) { location.href = urljump; }
4458 $(this).dialog("close");
4464 var button = "'.$button.
'";
4465 if (button.length > 0) {
4466 $( "#" + button ).click(function() {
4467 $("#'.$dialogconfirm.
'").dialog("open");
4473 $formconfirm .=
"<!-- end ajax formconfirm -->\n";
4475 $formconfirm .=
"\n<!-- begin formconfirm page=".dol_escape_htmltag($page).
" -->\n";
4477 if (empty($disableformtag)) $formconfirm .=
'<form method="POST" action="'.$page.
'" class="notoptoleftroright">'.
"\n";
4479 $formconfirm .=
'<input type="hidden" name="action" value="'.$action.
'">'.
"\n";
4480 $formconfirm .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
4482 $formconfirm .=
'<table class="valid centpercent">'.
"\n";
4485 $formconfirm .=
'<tr class="validtitre"><td class="validtitre" colspan="3">'.img_picto(
'',
'recent').
' '.$title.
'</td></tr>'.
"\n";
4488 if (is_array($formquestion) && !empty($formquestion[
'text'])) {
4489 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="3">'.$formquestion[
'text'].
'</td></tr>'.
"\n";
4495 $formconfirm .=
'<tr class="valid"><td class="valid" colspan="3">'.
"\n";
4496 $formconfirm .= $more;
4497 $formconfirm .=
'</td></tr>'.
"\n";
4501 $formconfirm .=
'<tr class="valid">';
4502 $formconfirm .=
'<td class="valid">'.$question.
'</td>';
4503 $formconfirm .=
'<td class="valid">';
4504 $formconfirm .= $this->
selectyesno(
"confirm", $newselectedchoice);
4505 $formconfirm .=
'</td>';
4506 $formconfirm .=
'<td class="valid center"><input class="button valignmiddle confirmvalidatebutton" type="submit" value="'.$langs->trans(
"Validate").
'"></td>';
4507 $formconfirm .=
'</tr>'.
"\n";
4509 $formconfirm .=
'</table>'.
"\n";
4511 if (empty($disableformtag)) $formconfirm .=
"</form>\n";
4512 $formconfirm .=
'<br>';
4514 if (empty($conf->use_javascript_ajax)) {
4515 $formconfirm .=
'<!-- code to disable button to avoid double clic -->';
4516 $formconfirm .=
'<script type="text/javascript">'.
"\n";
4518 $(document).ready(function () {
4519 $(".confirmvalidatebutton").on("click", function() {
4520 console.log("We click on button");
4521 $(this).attr("disabled", "disabled");
4522 setTimeout(\'$(".confirmvalidatebutton").removeAttr("disabled")\', 3000);
4523 //console.log($(this).closest("form"));
4524 $(this).closest("form").submit();
4528 $formconfirm .=
'</script>'.
"\n";
4531 $formconfirm .=
"<!-- end formconfirm -->\n";
4534 return $formconfirm;
4552 public function form_project($page, $socid, $selected =
'', $htmlname =
'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0)
4557 require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
4558 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
4564 $langs->load(
"project");
4565 if ($htmlname !=
"none")
4568 $out .=
'<form method="post" action="'.$page.
'">';
4569 $out .=
'<input type="hidden" name="action" value="classin">';
4570 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
4571 $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0,
'', 1);
4572 $out .=
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
4578 $projet->fetch($selected);
4580 $out .= $projet->getNomUrl(0,
'', 1);
4586 if (empty($nooutput))
4608 if ($htmlname !=
"none")
4610 print '<form method="post" action="'.$page.
'">';
4611 print '<input type="hidden" name="action" value="setconditions">';
4612 print '<input type="hidden" name="token" value="'.newToken().
'">';
4614 print '<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
4620 print $this->cache_conditions_paiements[$selected][
'label'];
4641 if ($htmlname !=
"none")
4643 print '<form method="post" action="'.$page.
'">';
4644 print '<input type="hidden" name="action" value="setavailability">';
4645 print '<input type="hidden" name="token" value="'.newToken().
'">';
4647 print '<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
4653 print $this->cache_availability[$selected][
'label'];
4670 public function formInputReason($page, $selected =
'', $htmlname =
'demandreason', $addempty = 0)
4673 if ($htmlname !=
"none")
4675 print '<form method="post" action="'.$page.
'">';
4676 print '<input type="hidden" name="action" value="setdemandreason">';
4677 print '<input type="hidden" name="token" value="'.newToken().
'">';
4679 print '<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
4685 foreach ($this->cache_demand_reason as $key => $val)
4687 if ($val[
'id'] == $selected)
4689 print $val[
'label'];
4712 public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0)
4719 if ($htmlname !=
"none")
4721 $ret .=
'<form method="post" action="'.$page.
'" name="form'.$htmlname.
'">';
4722 $ret .=
'<input type="hidden" name="action" value="set'.$htmlname.
'">';
4723 $ret .=
'<input type="hidden" name="token" value="'.newToken().
'">';
4724 $ret .=
'<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
4726 $ret .= $this->
selectDate($selected, $htmlname, $displayhour, $displaymin, 1,
'form'.$htmlname, 1, 0);
4728 $ret .=
'<td class="left"><input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'"></td>';
4729 $ret .=
'</tr></table></form>';
4735 if (empty($nooutput))
print $ret;
4751 public function form_users($page, $selected =
'', $htmlname =
'userid', $exclude =
'', $include =
'')
4756 if ($htmlname !=
"none")
4758 print '<form method="POST" action="'.$page.
'" name="form'.$htmlname.
'">';
4759 print '<input type="hidden" name="action" value="set'.$htmlname.
'">';
4760 print '<input type="hidden" name="token" value="'.newToken().
'">';
4762 print '<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
4767 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
4768 $theuser =
new User($this->
db);
4769 $theuser->fetch($selected);
4770 print $theuser->getNomUrl(1);
4790 public function form_modes_reglement($page, $selected =
'', $htmlname =
'mode_reglement_id', $filtertype =
'', $active = 1, $addempty = 0)
4794 if ($htmlname !=
"none")
4796 print '<form method="POST" action="'.$page.
'">';
4797 print '<input type="hidden" name="action" value="setmode">';
4798 print '<input type="hidden" name="token" value="'.newToken().
'">';
4800 print '<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
4806 print $this->cache_types_paiements[$selected][
'label'];
4826 if ($htmlname !=
"none")
4828 print '<form method="POST" action="'.$page.
'">';
4829 print '<input type="hidden" name="action" value="setmode">';
4830 print '<input type="hidden" name="token" value="'.newToken().
'">';
4832 print '<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
4839 print $this->cache_transport_mode[$selected][
'label'];
4859 if ($htmlname !=
"none")
4861 print '<form method="POST" action="'.$page.
'">';
4862 print '<input type="hidden" name="action" value="setmulticurrencycode">';
4863 print '<input type="hidden" name="token" value="'.newToken().
'">';
4865 print '<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
4886 global $langs, $mysoc, $conf;
4888 if ($htmlname !=
"none")
4890 print '<form method="POST" action="'.$page.
'">';
4891 print '<input type="hidden" name="action" value="setmulticurrencyrate">';
4892 print '<input type="hidden" name="token" value="'.newToken().
'">';
4893 print '<input type="text" class="maxwidth100" name="'.$htmlname.
'" value="'.(!empty($rate) ?
price(
price2num($rate,
'CU')) : 1).
'" /> ';
4894 print '<select name="calculation_mode">';
4895 print '<option value="1">Change '.$langs->trans(
"PriceUHT").
' of lines</option>';
4896 print '<option value="2">Change '.$langs->trans(
"PriceUHTCurrency").
' of lines</option>';
4898 print '<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
4904 if ($currency && $rate != 1)
print ' ('.price($rate, 1, $langs, 1, 0).
' '.$currency.
' = 1 '.$conf->currency.
')';
4928 public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter =
'', $maxvalue = 0, $more =
'', $hidelist = 0, $discount_type = 0)
4931 global $conf, $langs;
4932 if ($htmlname !=
"none")
4934 print '<form method="post" action="'.$page.
'">';
4935 print '<input type="hidden" name="action" value="setabsolutediscount">';
4936 print '<input type="hidden" name="token" value="'.newToken().
'">';
4937 print '<div class="inline-block">';
4938 if (!empty($discount_type)) {
4939 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
4941 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL") $translationKey =
'HasAbsoluteDiscountFromSupplier';
4942 else $translationKey =
'HasCreditNoteFromSupplier';
4944 if (!$filter || $filter ==
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')") $translationKey =
'HasAbsoluteDiscountFromSupplier';
4945 else $translationKey =
'HasCreditNoteFromSupplier';
4948 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS))
4950 if (!$filter || $filter ==
"fk_facture_source IS NULL") $translationKey =
'CompanyHasAbsoluteDiscount';
4951 else $translationKey =
'CompanyHasCreditNote';
4953 if (!$filter || $filter ==
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')") $translationKey =
'CompanyHasAbsoluteDiscount';
4954 else $translationKey =
'CompanyHasCreditNote';
4957 print $langs->trans($translationKey,
price($amount, 0, $langs, 0, 0, -1, $conf->currency));
4958 if (empty($hidelist))
print ': ';
4960 if (empty($hidelist))
4962 print '<div class="inline-block" style="padding-right: 10px">';
4963 $newfilter =
'discount_type='.intval($discount_type);
4964 if (!empty($discount_type)) {
4965 $newfilter .=
' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL';
4967 $newfilter .=
' AND fk_facture IS NULL AND fk_facture_line IS NULL';
4969 if ($filter) $newfilter .=
' AND ('.$filter.
')';
4970 $nbqualifiedlines = $this->
select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue);
4971 if ($nbqualifiedlines > 0)
4973 print ' <input type="submit" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"UseLine")).
'"';
4974 if (!empty($discount_type) && $filter && $filter !=
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')")
4975 print ' title="'.$langs->trans(
"UseCreditNoteInInvoicePayment").
'"';
4976 if (empty($discount_type) && $filter && $filter !=
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')")
4977 print ' title="'.$langs->trans(
"UseCreditNoteInInvoicePayment").
'"';
4985 print '<div class="inline-block">';
5011 public function form_contacts($page, $societe, $selected =
'', $htmlname =
'contactid')
5014 global $langs, $conf;
5016 if ($htmlname !=
"none")
5018 print '<form method="post" action="'.$page.
'">';
5019 print '<input type="hidden" name="action" value="set_contact">';
5020 print '<input type="hidden" name="token" value="'.newToken().
'">';
5021 print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
5027 $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
5028 print '<a href="'.DOL_URL_ROOT.
'/contact/card.php?socid='.$societe->id.
'&action=create&backtoreferer=1">'.$addcontact.
'</a>';
5031 print '<td class="left"><input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'"></td>';
5032 print '</tr></table></form>';
5036 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
5038 $contact->fetch($selected);
5039 print $contact->getFullName($langs);
5061 public function form_thirdparty($page, $selected =
'', $htmlname =
'socid', $filter =
'', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0)
5067 if ($htmlname !=
"none")
5069 $out .=
'<form method="post" action="'.$page.
'">';
5070 $out .=
'<input type="hidden" name="action" value="set_thirdparty">';
5071 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
5072 $out .= $this->
select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events);
5073 $out .=
'<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans(
"Modify").
'">';
5078 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
5080 $soc->fetch($selected);
5081 $out .= $soc->getNomUrl($langs);
5087 if ($nooutput)
return $out;
5116 global $conf, $langs, $user;
5118 $langs->loadCacheCurrencies(
'');
5122 if ($selected ==
'euro' || $selected ==
'euros') $selected =
'EUR';
5124 $out .=
'<select class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.
'" id="'.$htmlname.
'">';
5125 foreach ($langs->cache_currencies as $code_iso => $currency)
5127 $labeltoshow = $currency[
'label'];
5130 $labeltoshow .=
' <span class="opacitymedium">('.$code_iso.
')</span>';
5132 $labeltoshow .=
' <span class="opacitymedium">('.$langs->getCurrencySymbol($code_iso).
')</span>';
5135 if ($selected && $selected == $code_iso)
5137 $out .=
'<option value="'.$code_iso.
'" selected data-html="'.
dol_escape_htmltag($labeltoshow).
'">';
5139 $out .=
'<option value="'.$code_iso.
'" data-html="'.
dol_escape_htmltag($labeltoshow).
'">';
5141 $out .= $labeltoshow;
5142 $out .=
'</option>';
5144 $out .=
'</select>';
5145 if ($user->admin) $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
5148 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5164 public function selectMultiCurrency($selected =
'', $htmlname =
'multicurrency_code', $useempty = 0, $filter =
'', $excludeConfCurrency =
false)
5166 global $db, $conf, $langs, $user;
5168 $langs->loadCacheCurrencies(
'');
5170 $TCurrency = array();
5172 $sql =
'SELECT code FROM '.MAIN_DB_PREFIX.
'multicurrency';
5173 $sql .=
" WHERE entity IN ('".getEntity(
'mutlicurrency').
"')";
5174 if ($filter) $sql .=
" AND ".$filter;
5178 while ($obj = $this->
db->fetch_object(
$resql)) $TCurrency[$obj->code] = $obj->code;
5182 $out .=
'<select class="flat" name="'.$htmlname.
'" id="'.$htmlname.
'">';
5183 if ($useempty) $out .=
'<option value=""> </option>';
5185 if (!in_array($conf->currency, $TCurrency) && !$excludeConfCurrency)
5187 $TCurrency[$conf->currency] = $conf->currency;
5189 if (count($TCurrency) > 0)
5191 foreach ($langs->cache_currencies as $code_iso => $currency)
5193 if (isset($TCurrency[$code_iso]))
5195 if (!empty($selected) && $selected == $code_iso) $out .=
'<option value="'.$code_iso.
'" selected="selected">';
5196 else $out .=
'<option value="'.$code_iso.
'">';
5198 $out .= $currency[
'label'];
5199 $out .=
' ('.$langs->getCurrencySymbol($code_iso).
')';
5200 $out .=
'</option>';
5205 $out .=
'</select>';
5207 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5225 $num = count($this->cache_vatrates);
5226 if ($num > 0)
return $num;
5230 $sql =
"SELECT DISTINCT t.rowid, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly";
5231 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
5232 $sql .=
" WHERE t.fk_pays = c.rowid";
5233 $sql .=
" AND t.active > 0";
5234 $sql .=
" AND c.code IN (".$country_code.
")";
5235 $sql .=
" ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC";
5240 $num = $this->
db->num_rows(
$resql);
5243 for ($i = 0; $i < $num; $i++)
5245 $obj = $this->
db->fetch_object(
$resql);
5246 $this->cache_vatrates[$i][
'rowid'] = $obj->rowid;
5247 $this->cache_vatrates[$i][
'code'] = $obj->code;
5248 $this->cache_vatrates[$i][
'txtva'] = $obj->taux;
5249 $this->cache_vatrates[$i][
'nprtva'] = $obj->recuperableonly;
5250 $this->cache_vatrates[$i][
'localtax1'] = $obj->localtax1;
5251 $this->cache_vatrates[$i][
'localtax1_type'] = $obj->localtax1_type;
5252 $this->cache_vatrates[$i][
'localtax2'] = $obj->localtax2;
5253 $this->cache_vatrates[$i][
'localtax2_type'] = $obj->localtax1_type;
5255 $this->cache_vatrates[$i][
'label'] = $obj->taux.
'%'.($obj->code ?
' ('.$obj->code.
')' :
'');
5256 $this->cache_vatrates[$i][
'labelallrates'] = $obj->taux.
'/'.($obj->localtax1 ? $obj->localtax1 :
'0').
'/'.($obj->localtax2 ? $obj->localtax2 :
'0').($obj->code ?
' ('.$obj->code.
')' :
'');
5257 $positiverates =
'';
5258 if ($obj->taux) $positiverates .= ($positiverates ?
'/' :
'').$obj->taux;
5259 if ($obj->localtax1) $positiverates .= ($positiverates ?
'/' :
'').$obj->localtax1;
5260 if ($obj->localtax2) $positiverates .= ($positiverates ?
'/' :
'').$obj->localtax2;
5261 if (empty($positiverates)) $positiverates =
'0';
5262 $this->cache_vatrates[$i][
'labelpositiverates'] = $positiverates.($obj->code ?
' ('.$obj->code.
')' :
'');
5267 $this->error =
'<font class="error">'.$langs->trans(
"ErrorNoVATRateDefinedForSellerCountry", $country_code).
'</font>';
5271 $this->error =
'<font class="error">'.$this->db->error().
'</font>';
5298 public function load_tva($htmlname =
'tauxtva', $selectedrate =
'', $societe_vendeuse =
'', $societe_acheteuse =
'', $idprod = 0, $info_bits = 0, $type =
'', $options_only =
false, $mode = 0)
5301 global $langs, $conf, $mysoc;
5303 $langs->load(
'errors');
5308 $defaultnpr = ($info_bits & 0x01);
5309 $defaultnpr = (preg_match(
'/\*/', $selectedrate) ? 1 : $defaultnpr);
5310 $defaulttx = str_replace(
'*',
'', $selectedrate);
5312 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg))
5314 $defaultcode = $reg[1];
5315 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
5320 if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code)
5322 if ($societe_vendeuse->id == $mysoc->id)
5324 $return .=
'<font class="error">'.$langs->trans(
"ErrorYourCountryIsNotDefined").
'</font>';
5326 $return .=
'<font class="error">'.$langs->trans(
"ErrorSupplierCountryIsNotDefined").
'</font>';
5337 if (is_object($societe_vendeuse))
5339 $code_country =
"'".$societe_vendeuse->country_code.
"'";
5341 $code_country =
"'".$mysoc->country_code.
"'";
5343 if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC))
5345 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
5346 if (!
isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (
isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany())))
5349 if (is_numeric($type))
5353 $code_country .=
",'".$societe_acheteuse->country_code.
"'";
5357 $code_country .=
",'".$societe_acheteuse->country_code.
"'";
5360 $prodstatic->fetch($idprod);
5363 $code_country .=
",'".$societe_acheteuse->country_code.
"'";
5375 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0)
5377 $tmpthirdparty =
new Societe($this->
db);
5378 $defaulttx =
get_default_tva($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
5379 $defaultnpr =
get_default_npr($societe_vendeuse, (is_object($societe_acheteuse) ? $societe_acheteuse : $tmpthirdparty), $idprod);
5380 if (preg_match(
'/\((.*)\)/', $defaulttx, $reg)) {
5381 $defaultcode = $reg[1];
5382 $defaulttx = preg_replace(
'/\s*\(.*\)/',
'', $defaulttx);
5384 if (empty($defaulttx)) $defaultnpr = 0;
5389 if ($defaulttx < 0 ||
dol_strlen($defaulttx) == 0)
5391 if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) $defaulttx = $this->cache_vatrates[$num - 1][
'txtva'];
5392 else $defaulttx = ($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS ==
'none' ?
'' : $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS);
5396 $disabled =
false; $title =
'';
5397 if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj ==
"0")
5401 if (empty($conf->global->EXPENSEREPORT_OVERRIDE_VAT))
5403 $title =
' title="'.$langs->trans(
'VATIsNotUsed').
'"';
5408 if (!$options_only) $return .=
'<select class="flat minwidth75imp" id="'.$htmlname.
'" name="'.$htmlname.
'"'.($disabled ?
' disabled' :
'').$title.
'>';
5410 $selectedfound =
false;
5411 foreach ($this->cache_vatrates as $rate)
5414 if ($disabled && $rate[
'txtva'] != 0)
continue;
5417 $key = $rate[
'txtva'];
5418 $key .= $rate[
'nprtva'] ?
'*' :
'';
5419 if ($mode > 0 && $rate[
'code']) $key .=
' ('.$rate[
'code'].
')';
5420 if ($mode < 0) $key = $rate[
'rowid'];
5422 $return .=
'<option value="'.$key.
'"';
5423 if (!$selectedfound)
5427 if ($defaultcode == $rate[
'code'])
5429 $return .=
' selected';
5430 $selectedfound =
true;
5432 } elseif ($rate[
'txtva'] == $defaulttx && $rate[
'nprtva'] == $defaultnpr)
5434 $return .=
' selected';
5435 $selectedfound =
true;
5440 if ($mysoc->country_code ==
'IN' || !empty($conf->global->MAIN_VAT_LABEL_IS_POSITIVE_RATES))
5442 $return .= $rate[
'labelpositiverates'];
5444 $return .=
vatrate($rate[
'label']);
5447 $return .= (empty($rate[
'code']) && $rate[
'nprtva']) ?
' *' :
'';
5449 $return .=
'</option>';
5452 if (!$options_only) $return .=
'</select>';
5454 $return .= $this->error;
5487 public function select_date($set_time =
'', $prefix =
're', $h = 0, $m = 0, $empty = 0, $form_name =
"", $d = 1, $addnowlink = 0, $nooutput = 0, $disabled = 0, $fullday =
'', $addplusone =
'', $adddateof =
'')
5490 $retstring = $this->
selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof);
5491 if (!empty($nooutput)) {
5512 public function selectDateToDate($set_time =
'', $set_time_end =
'', $prefix =
're', $empty = 0)
5516 $ret = $this->
selectDate($set_time, $prefix.
'_start', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"from"),
'tzuserrel');
5518 $ret .= $this->
selectDate($set_time_end, $prefix.
'_end', 0, 0, $empty,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
5549 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')
5551 global $conf, $langs;
5553 if ($gm ===
'auto') {
5554 $gm = (empty($conf) ?
'tzserver' : $conf->tzuserinputkey);
5559 if ($prefix ==
'') $prefix =
're';
5560 if ($h ==
'') $h = 0;
5561 if ($m ==
'') $m = 0;
5564 if ($stepminutes <= 0 || $stepminutes > 30) $stepminutes = 1;
5565 if ($empty == 1) { $emptydate = 1; $emptyhours = 1; }
5566 if ($empty == 2) { $emptydate = 0; $emptyhours = 1; }
5567 $orig_set_time = $set_time;
5569 if ($set_time ===
'' && $emptydate == 0)
5571 include_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
5572 if ($gm ==
'tzuser' || $gm ==
'tzuserrel') {
5581 if (preg_match(
'/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/', $set_time, $reg))
5584 $syear = (!empty($reg[1]) ? $reg[1] :
'');
5585 $smonth = (!empty($reg[2]) ? $reg[2] :
'');
5586 $sday = (!empty($reg[3]) ? $reg[3] :
'');
5587 $shour = (!empty($reg[4]) ? $reg[4] :
'');
5588 $smin = (!empty($reg[5]) ? $reg[5] :
'');
5589 } elseif (strval($set_time) !=
'' && $set_time != -1)
5595 if ($orig_set_time !=
'')
5610 $shour = !isset($conf->global->MAIN_DEFAULT_DATE_HOUR) ? ($h == -1 ?
'23' :
'') : $conf->global->MAIN_DEFAULT_DATE_HOUR;
5611 $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? ($h == -1 ?
'59' :
'') : $conf->global->MAIN_DEFAULT_DATE_MIN;
5612 $ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? ($h == -1 ?
'59' :
'') : $conf->global->MAIN_DEFAULT_DATE_SEC;
5614 if ($h == 3) $shour =
'';
5615 if ($m == 3) $smin =
'';
5621 $usecalendar =
'combo';
5622 if (!empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR !=
"none")) {
5623 $usecalendar = ((empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR ==
'eldy') ?
'jquery' : $conf->global->MAIN_POPUP_CALENDAR);
5629 if ($usecalendar !=
'combo')
5631 $formated_date =
'';
5633 if (strval($set_time) !=
'' && $set_time != -1)
5636 $formated_date =
dol_print_date($set_time, $langs->trans(
"FormatDateShortInput"), $gm);
5640 if ($usecalendar ==
"eldy")
5643 $retstring .=
'<input id="'.$prefix.
'" name="'.$prefix.
'" type="text" class="maxwidthdate" maxlength="11" value="'.$formated_date.
'"';
5644 $retstring .= ($disabled ?
' disabled' :
'');
5645 $retstring .=
' onChange="dpChangeDay(\''.$prefix.
'\',\
''.$langs->trans(
"FormatDateShortJavaInput").
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
5651 $retstring .= '<button id="'.$prefix.'Button
" type="button
" class="dpInvisibleButtons
"';
5652 $base = DOL_URL_ROOT.'/core/';
5653 $retstring .= ' onClick="showDP(\
''.$base.
'\',\
''.$prefix.
'\',\
''.$langs->trans(
"FormatDateShortJavaInput").
'\',\
''.$langs->defaultlang.
'\');
"';
5654 $retstring .= '>'.img_object($langs->trans("SelectDate
"), 'calendarday', 'class="datecallink
"').'</button>';
5655 } else $retstring .= '<button id="'.$prefix.'Button
" type="button
" class="dpInvisibleButtons
">'.img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"').'</button>';
5657 $retstring .= '<input type="hidden
" id="'.$prefix.'day
" name="'.$prefix.'day
" value="'.$sday.'">'."\n";
5658 $retstring .= '<input type="hidden
" id="'.$prefix.'month
" name="'.$prefix.'month
" value="'.$smonth.'">'."\n";
5659 $retstring .= '<input type="hidden
" id="'.$prefix.'year
" name="'.$prefix.'year
" value="'.$syear.'">'."\n";
5660 } elseif ($usecalendar == 'jquery')
5664 // Output javascript for datepicker
5665 $retstring .= "<script
type=
'text/javascript'>
";
5666 $retstring .= "$(
function(){ $(
'#".$prefix."').datepicker({
5667 dateFormat:
'".$langs->trans("FormatDateShortJQueryInput")."',
5669 todayHighlight:
true,
";
5670 if (!empty($conf->dol_use_jmobile))
5673 beforeShow:
function (input, datePicker) {
5674 input.disabled =
true;
5676 onClose:
function (dateText, datePicker) {
5677 this.disabled =
false;
5681 // Note: We don't need monthNames, monthNamesShort, dayNames, dayNamesShort, dayNamesMin, they are set globally on datepicker component in lib_head.js.php
5682 if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS))
5686 buttonImage:
'".DOL_URL_ROOT."/theme/".$conf->theme."/img/object_calendarday.png',
5687 buttonImageOnly:
true";
5691 $retstring .= "</script>
";
5694 // Zone de saisie manuelle de la date
5695 $retstring .= '<div class="nowrap
inline-block
">';
5696 $retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text
" class="maxwidthdate
" maxlength="11
" value="'.$formated_date.'"';
5697 $retstring .= ($disabled ? ' disabled' : '');
5698 $retstring .= ($placeholder ? ' placeholder="'.$placeholder.'"' : '');
5699 $retstring .= ' onChange="dpChangeDay(\
''.$prefix.
'\',\
''.$langs->trans(
"FormatDateShortJavaInput").
'\');
"'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
5705 /* Not required. Managed by option buttonImage of jquery
5706 $retstring.=img_object($langs->trans("SelectDate
"),'calendarday','id="'.$prefix.'id" class="datecallink
"');
5707 $retstring.="<script type=
'text/javascript'>
";
5708 $retstring.="jQuery(document).ready(
function() {
";
5709 $retstring.=' jQuery("#
'.$prefix.'id").click(function() {';
5710 $retstring.=" jQuery(
'#".$prefix."').focus();
";
5713 $retstring.="</script>
";*/
5715 $retstring .= '<button id="'.$prefix.'Button
" type="button
" class="dpInvisibleButtons
">'.img_object($langs->trans("Disabled
"), 'calendarday', 'class="datecallink
"').'</button>';
5718 $retstring .= '</div>';
5719 $retstring .= '<input type="hidden
" id="'.$prefix.'day
" name="'.$prefix.'day
" value="'.$sday.'">'."\n";
5720 $retstring .= '<input type="hidden
" id="'.$prefix.'month
" name="'.$prefix.'month
" value="'.$smonth.'">'."\n";
5721 $retstring .= '<input type="hidden
" id="'.$prefix.'year
" name="'.$prefix.'year
" value="'.$syear.'">'."\n";
5723 $retstring .= "Bad value of MAIN_POPUP_CALENDAR
";
5726 // Show date with combo selects
5729 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50imp
" id="'.$prefix.'day
" name="'.$prefix.'day
">';
5731 if ($emptydate || $set_time == -1)
5733 $retstring .= '<option value="0
" selected> </option>';
5736 for ($day = 1; $day <= 31; $day++)
5738 $retstring .= '<option value="'.$day.'"'.($day == $sday ? ' selected' : '').'>'.$day.'</option>';
5741 $retstring .= "</select>
";
5743 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth75imp
" id="'.$prefix.'month
" name="'.$prefix.'month
">';
5744 if ($emptydate || $set_time == -1)
5746 $retstring .= '<option value="0
" selected> </option>';
5750 for ($month = 1; $month <= 12; $month++)
5752 $retstring .= '<option value="'.$month.'"'.($month == $smonth ? ' selected' : '').'>';
5753 $retstring .= dol_print_date(mktime(12, 0, 0, $month, 1, 2000), "%b
");
5754 $retstring .= "</option>
";
5756 $retstring .= "</select>
";
5759 if ($emptydate || $set_time == -1)
5761 $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.'">';
5763 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth75imp
" id="'.$prefix.'year
" name="'.$prefix.'year
">';
5765 for ($year = $syear - 10; $year < $syear + 10; $year++)
5767 $retstring .= '<option value="'.$year.'"'.($year == $syear ? ' selected' : '').'>'.$year.'</option>';
5769 $retstring .= "</select>
\n";
5775 $retstring .= ($h == 2 ? '<br>' : ' ');
5776 $retstring .= '<span class="nowraponall
">';
5783 if ($openinghours != '') {
5784 $openinghours = explode(',', $openinghours);
5785 $hourstart = $openinghours[0];
5786 $hourend = $openinghours[1];
5787 if ($hourend < $hourstart) $hourend = $hourstart;
5790 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50
'.($fullday ? $fullday.'hour
' : '').'" id="'.$prefix.'hour
" name="'.$prefix.'hour
">';
5791 if ($emptyhours) $retstring .= '<option value="-1
"> </option>';
5792 for ($hour = $hourstart; $hour < $hourend; $hour++)
5794 if (strlen($hour) < 2) $hour = "0
".$hour;
5795 $retstring .= '<option value="'.$hour.'"'.(($hour == $shour) ? ' selected' : '').'>'.$hour;
5796 //$retstring .= (empty($conf->dol_optimize_smallscreen) ? '' : 'H');
5797 $retstring .= '</option>';
5799 $retstring .= '</select>';
5800 //if ($m && empty($conf->dol_optimize_smallscreen)) $retstring .= ":
";
5801 if ($m) $retstring .= ":
";
5807 $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50
'.($fullday ? $fullday.'min
' : '').'" id="'.$prefix.'min
" name="'.$prefix.'min
">';
5808 if ($emptyhours) $retstring .= '<option value="-1
"> </option>';
5809 for ($min = 0; $min < 60; $min += $stepminutes)
5811 if (strlen($min) < 2) $min = "0
".$min;
5812 $retstring .= '<option value="'.$min.'"'.(($min == $smin) ? ' selected' : '').'>'.$min.(empty($conf->dol_optimize_smallscreen) ? '' : '').'</option>';
5814 $retstring .= '</select>';
5816 $retstring .= '<input type="hidden
" name="'.$prefix.'sec
" value="'.$ssec.'">';
5820 $retstring .= '</span>';
5824 if ($conf->use_javascript_ajax && $addnowlink)
5826 // Script which will be inserted in the onClick of the "Now
" link
5827 $reset_scripts = "";
5828 if ($addnowlink == 2) { // local computer time
5829 // pad add leading 0 on numbers
5830 $reset_scripts .= "Number.prototype.pad =
function(size) {
5831 var s = String(
this);
5832 while (s.length < (size || 2)) {s =
'0' + s;}
5835 var d =
new Date();
";
5838 // Generate the date part, depending on the use or not of the javascript calendar
5839 if ($addnowlink == 1) { // server time expressed in user time setup
5840 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'day', 'tzuserrel').'\');';
5841 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');';
5842 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');';
5843 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');';
5844 } elseif ($addnowlink == 2) {
5845 /* Disabled because the output does not use the string format defined by FormatDateShort key to forge the value into #prefix.
5846 * This break application for foreign languages.
5847 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(d.toLocaleDateString(\''.str_replace('_', '-', $langs->defaultlang).'\'));';
5848 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(d.getDate().pad());';
5849 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(parseInt(d.getMonth().pad()) + 1);';
5850 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(d.getFullYear());';
5852 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'day', 'tzuserrel').'\');';
5853 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');';
5854 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');';
5855 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');';
5857 /*if ($usecalendar == "eldy
")
5859 $base=DOL_URL_ROOT.'/core/';
5860 $reset_scripts .= 'resetDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput
").'\',\''.$langs->defaultlang.'\');';
5864 $reset_scripts .= 'this.form.elements[\''.$prefix.'day\'].value=formatDate(new Date(), \'d\'); ';
5865 $reset_scripts .= 'this.form.elements[\''.$prefix.'month\'].value=formatDate(new Date(), \'M\'); ';
5866 $reset_scripts .= 'this.form.elements[\''.$prefix.'year\'].value=formatDate(new Date(), \'yyyy\'); ';
5868 // Update the hour part
5871 if ($fullday) $reset_scripts .= " if (jQuery(
'#fullday:checked').val() == null) {
";
5872 //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); ';
5873 if ($addnowlink == 1)
5875 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');';
5876 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();';
5877 } elseif ($addnowlink == 2)
5879 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(d.getHours().pad());';
5880 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').change();';
5883 if ($fullday) $reset_scripts .= ' } ';
5885 // Update the minute part
5888 if ($fullday) $reset_scripts .= " if (jQuery(
'#fullday:checked').val() == null) {
";
5889 //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); ';
5890 if ($addnowlink == 1)
5892 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');';
5893 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();';
5894 } elseif ($addnowlink == 2)
5896 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(d.getMinutes().pad());';
5897 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').change();';
5899 if ($fullday) $reset_scripts .= ' } ';
5901 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
5902 if ($reset_scripts && empty($conf->dol_optimize_smallscreen))
5904 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="'.$prefix.'ButtonNow
" type="button
" name="_useless
" value="now
" onClick="'.$reset_scripts.'">';
5905 $retstring .= $langs->trans("Now
");
5906 $retstring .= '</button> ';
5910 // Add a "Plus one hour
" link
5911 if ($conf->use_javascript_ajax && $addplusone)
5913 // Script which will be inserted in the onClick of the "Add plusone
" link
5914 $reset_scripts = "";
5916 // Generate the date part, depending on the use or not of the javascript calendar
5917 $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date($nowgmt, 'dayinputnoreduce', 'tzuserrel').'\');';
5918 $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date($nowgmt, '%d', 'tzuserrel').'\');';
5919 $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date($nowgmt, '%m', 'tzuserrel').'\');';
5920 $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date($nowgmt, '%Y', 'tzuserrel').'\');';
5921 // Update the hour part
5924 if ($fullday) $reset_scripts .= " if (jQuery(
'#fullday:checked').val() == null) {
";
5925 $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date($nowgmt, '%H', 'tzuserrel').'\');';
5926 if ($fullday) $reset_scripts .= ' } ';
5928 // Update the minute part
5931 if ($fullday) $reset_scripts .= " if (jQuery(
'#fullday:checked').val() == null) {
";
5932 $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date($nowgmt, '%M', 'tzuserrel').'\');';
5933 if ($fullday) $reset_scripts .= ' } ';
5935 // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
5936 if ($reset_scripts && empty($conf->dol_optimize_smallscreen))
5938 $retstring .= ' <button class="dpInvisibleButtons datenowlink
" id="'.$prefix.'ButtonPlusOne
" type="button
" name="_useless2
" value="plusone
" onClick="'.$reset_scripts.'">';
5939 $retstring .= $langs->trans("DateStartPlusOne
");
5940 $retstring .= '</button> ';
5944 // Add a link to set data
5945 if ($conf->use_javascript_ajax && $adddateof)
5947 $tmparray = dol_getdate($adddateof);
5948 if (empty($labeladddateof)) $labeladddateof = $langs->trans("DateInvoice
");
5949 $retstring .= ' - <button class="dpInvisibleButtons datenowlink
" id="dateofinvoice
" type="button
" name="_dateofinvoice
" value="now
" onclick="console.log(\
'Click on now link\'); jQuery(\'#re\').val(\''.
dol_print_date($adddateof,
'dayinputnoreduce').
'\');jQuery(\
'#reday\').val(\''.$tmparray[
'mday'].
'\');jQuery(\
'#remonth\').val(\''.$tmparray[
'mon'].
'\');jQuery(\
'#reyear\').val(\''.$tmparray[
'year'].
'\');
">'.$labeladddateof.'</a>';
5963 public function selectTypeDuration($prefix, $selected = 'i', $excludetypes = array())
5967 $TDurationTypes = array(
5968 'y'=>$langs->trans('Years'),
5969 'm'=>$langs->trans('Month'),
5970 'w'=>$langs->trans('Weeks'),
5971 'd'=>$langs->trans('Days'),
5972 'h'=>$langs->trans('Hours'),
5973 'i'=>$langs->trans('Minutes')
5976 // Removed undesired duration types
5977 foreach ($excludetypes as $value) {
5978 unset($TDurationTypes[$value]);
5981 $retstring = '<select class="flat
" id="select_
'.$prefix.'type_duration
" name="'.$prefix.'type_duration
">';
5982 foreach ($TDurationTypes as $key => $typeduration) {
5983 $retstring .= '<option value="'.$key.'"';
5984 if ($key == $selected) {
5985 $retstring .= " selected
";
5987 $retstring .= ">
".$typeduration."</option>
";
5989 $retstring .= "</select>
";
5991 $retstring .= ajax_combobox('select_'.$prefix.'type_duration');
5996 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
6010 public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0)
6017 $hourSelected = 0; $minSelected = 0;
6022 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
6024 $hourSelected = convertSecondToTime($iSecond, 'allhour');
6025 $minSelected = convertSecondToTime($iSecond, 'min');
6028 if ($typehour == 'select') {
6029 $retstring .= '<select class="flat
" id="select_
'.$prefix.'hour
" name="'.$prefix.'hour
"'.($disabled ? ' disabled' : '').'>';
6030 for ($hour = 0; $hour < 25; $hour++) // For a duration, we allow 24 hours
6032 $retstring .= '<option value="'.$hour.'"';
6033 if ($hourSelected == $hour)
6035 $retstring .= " selected
";
6037 $retstring .= ">
".$hour."</option>
";
6039 $retstring .= "</select>
";
6040 } elseif ($typehour == 'text' || $typehour == 'textselect') {
6041 $retstring .= '<input placeholder="'.$langs->trans('HourShort
').'" type="number
" min="0
" name="'.$prefix.'hour
"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputhour
" value="'.(($hourSelected != '') ? ((int) $hourSelected) : '').'">';
6043 return 'BadValueForParameterTypeHour';
6046 if ($typehour != 'text') $retstring .= ' '.$langs->trans('HourShort');
6047 else $retstring .= '<span class="hideonsmartphone
">:</span>';
6050 if ($minunderhours) $retstring .= '<br>';
6051 else $retstring .= '<span class="hideonsmartphone
"> </span>';
6053 if ($typehour == 'select' || $typehour == 'textselect')
6055 $retstring .= '<select class="flat
" id="select_
'.$prefix.'min
" name="'.$prefix.'min
"'.($disabled ? ' disabled' : '').'>';
6056 for ($min = 0; $min <= 55; $min = $min + 5)
6058 $retstring .= '<option value="'.$min.'"';
6059 if ($minSelected == $min) $retstring .= ' selected';
6060 $retstring .= '>'.$min.'</option>';
6062 $retstring .= "</select>
";
6063 } elseif ($typehour == 'text')
6065 $retstring .= '<input placeholder="'.$langs->trans('MinuteShort
').'" type="number
" min="0
" name="'.$prefix.'min
"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputminute
" value="'.(($minSelected != '') ? ((int) $minSelected) : '').'">';
6068 if ($typehour != 'text') $retstring .= ' '.$langs->trans('MinuteShort');
6070 //$retstring.="
";
6072 if (!empty($nooutput)) return $retstring;
6098 public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '')
6100 global $conf, $user;
6104 $InfoFieldList = explode(":
", $objectdesc);
6105 $classname = $InfoFieldList[0];
6106 $classpath = $InfoFieldList[1];
6107 $addcreatebuttonornot = empty($InfoFieldList[2]) ? 0 : $InfoFieldList[2];
6108 $filter = empty($InfoFieldList[3]) ? '' : $InfoFieldList[3];
6110 if (!empty($classpath))
6112 dol_include_once($classpath);
6114 if ($classname && class_exists($classname))
6116 $objecttmp = new $classname($this->db);
6117 // Make some replacement
6118 $sharedentities = getEntity(strtolower($classname));
6119 $objecttmp->filter = str_replace(
6120 array('__ENTITY__', '__SHARED_ENTITIES__', '__USER_ID__'),
6121 array($conf->entity, $sharedentities, $user->id),
6125 if (!is_object($objecttmp))
6127 dol_syslog('Error bad setup of type for field '.$InfoFieldList, LOG_WARNING);
6128 return 'Error bad setup of type for field '.join(',', $InfoFieldList);
6131 //var_dump($objecttmp->filter);
6132 $prefixforautocompletemode = $objecttmp->element;
6133 if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode = 'company';
6134 if ($prefixforautocompletemode == 'product') $prefixforautocompletemode = 'produit';
6135 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
6137 dol_syslog(get_class($this)."::selectForForms object->filter=
".$objecttmp->filter, LOG_DEBUG);
6139 if (!empty($conf->use_javascript_ajax) && !empty($conf->global->$confkeyforautocompletemode) && !$forcecombo)
6141 // No immediate load of all database
6143 if ($preselectedvalue && empty($selected_input_value))
6145 $objecttmp->fetch($preselectedvalue);
6146 $selected_input_value = ($prefixforautocompletemode == 'company' ? $objecttmp->name : $objecttmp->ref);
6147 //unset($objecttmp);
6150 $objectdesc = $classname.':'.$classpath.':'.$addcreatebuttonornot.':'.$filter;
6151 $urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php';
6153 // No immediate load of all database
6154 $urloption = 'htmlname='.$htmlname.'&outjson=1&objectdesc='.$objectdesc.'&filter='.urlencode($objecttmp->filter);
6155 // Activate the auto complete using ajax call.
6156 $out .= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array());
6157 $out .= '<style type="text/css
">.ui-autocomplete { z-index: 250; }</style>';
6158 if ($placeholder) $placeholder = ' placeholder="'.$placeholder.'"';
6159 $out .= '<input type="text
" class="'.$morecss.'"'.($disabled ? ' disabled="disabled
"' : '').' name="search_
'.$htmlname.'" id="search_
'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' />';
6161 // Immediate load of table record. Note: filter is inside $objecttmp->filter
6162 $out .= $this->selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled);
6174 protected static function forgeCriteriaCallback($matches)
6178 //dol_syslog("Convert matches
".$matches[1]);
6179 if (empty($matches[1])) return '';
6180 $tmp = explode(':', $matches[1]);
6181 if (count($tmp) < 3) return '';
6183 $tmpescaped = $tmp[2];
6185 if (preg_match('/^\'(.*)\'$/', $tmpescaped, $regbis))
6187 $tmpescaped = "'".$db->escape($regbis[1])."'";
6189 $tmpescaped = $db->escape($tmpescaped);
6191 return $db->escape($tmp[0]).' '.strtoupper($db->escape($tmp[1]))." ".$tmpescaped;
6212 public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0, $disabled = 0)
6214 global $conf, $langs, $user;
6216 //print "$objecttmp->filter, $htmlname, $preselectedvalue, $showempty =
'', $searchkey =
'', $placeholder =
'', $morecss =
'', $moreparams =
'', $forcecombo = 0, $outputmode = 0, $disabled
";
6218 $prefixforautocompletemode = $objecttmp->element;
6219 if ($prefixforautocompletemode == 'societe') $prefixforautocompletemode = 'company';
6220 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
6222 if (!empty($objecttmp->fields)) // For object that declare it, it is better to use declared fields (like societe, contact, ...)
6224 $tmpfieldstoshow = '';
6225 foreach ($objecttmp->fields as $key => $val)
6227 if (!dol_eval($val['enabled'], 1, 1)) continue;
6228 if ($val['showoncombobox']) $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '').'t.'.$key;
6230 if ($tmpfieldstoshow) $fieldstoshow = $tmpfieldstoshow;
6232 // For backward compatibility
6233 $objecttmp->fields['ref'] = array('type'=>'varchar(30)', 'label'=>'Ref', 'showoncombobox'=>1);
6236 if (empty($fieldstoshow))
6238 if (isset($objecttmp->fields['ref'])) {
6239 $fieldstoshow = 't.ref';
6241 $langs->load("errors
");
6242 $this->error = $langs->trans("ErrorNoFieldWithAttributeShowoncombobox
");
6243 return $langs->trans('ErrorNoFieldWithAttributeShowoncombobox');
6248 $outarray = array();
6253 $sql = "SELECT t.rowid,
".$fieldstoshow." FROM
".MAIN_DB_PREFIX.$objecttmp->table_element." as t
";
6254 if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) {
6255 $tmparray = explode('@', $objecttmp->ismultientitymanaged);
6256 $sql .= ' INNER JOIN '.MAIN_DB_PREFIX.$tmparray[1].' as parenttable ON parenttable.rowid = t.'.$tmparray[0];
6258 if ($objecttmp->ismultientitymanaged == 'fk_soc@societe')
6259 if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ",
".MAIN_DB_PREFIX."societe_commerciaux as sc
";
6260 $sql .= " WHERE 1=1
";
6261 if (isset($objecttmp->ismultientitymanaged) && $objecttmp->ismultientitymanaged == 1) $sql .= " AND t.entity IN (
".getEntity($objecttmp->table_element).")
";
6262 if (isset($objecttmp->ismultientitymanaged) && !is_numeric($objecttmp->ismultientitymanaged)) {
6263 $sql .= ' AND parenttable.entity = t.'.$tmparray[0];
6265 if ($objecttmp->ismultientitymanaged == 1 && !empty($user->socid)) {
6266 if ($objecttmp->element == 'societe') $sql .= " AND t.rowid =
".$user->socid;
6267 else $sql .= " AND t.fk_soc =
".$user->socid;
6269 if ($searchkey != '') $sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
6270 if ($objecttmp->ismultientitymanaged == 'fk_soc@societe') {
6271 if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user =
".$user->id;
6273 if ($objecttmp->filter) { // Syntax example "(t.ref:like:
'SO-%') and (t.date_creation:<:
'20160101')
"
6274 /*if (! DolibarrApi::_checkFilters($objecttmp->filter))
6276 throw new RestException(503, 'Error when validating parameter sqlfilters '.$objecttmp->filter);
6278 $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
6279 $sql .= " AND (
".preg_replace_callback('/'.$regexstring.'/', 'Form::forgeCriteriaCallback', $objecttmp->filter).")
";
6281 $sql .= $this->db->order($fieldstoshow, "ASC
");
6282 //$sql.=$this->db->plimit($limit, 0);
6285 // Build output string
6286 $resql = $this->db->query($sql);
6289 // Construct $out and $outarray
6290 $out .= '<select id="'.$htmlname.'" class="flat
'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled
"' : '').($moreparams ? ' '.$moreparams : '').' name="'.$htmlname.'">'."\n";
6292 // Warning: Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. Seems it is no more true with selec2 v4
6293 $textifempty = ' ';
6295 //if (! empty($conf->use_javascript_ajax) || $forcecombo) $textifempty='';
6296 if (!empty($conf->global->$confkeyforautocompletemode))
6298 if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
6299 else $textifempty .= $langs->trans("All
");
6301 if ($showempty) $out .= '<option value="-1
">'.$textifempty.'</option>'."\n";
6303 $num = $this->db->num_rows($resql);
6309 $obj = $this->db->fetch_object($resql);
6311 $tmparray = explode(',', $fieldstoshow);
6312 foreach ($tmparray as $key => $val)
6314 $val = preg_replace('/t\./', '', $val);
6315 $label .= (($label && $obj->$val) ? ' - ' : '').$obj->$val;
6317 if (empty($outputmode))
6319 if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
6320 $out .= '<option value="'.$obj->rowid.'" selected>'.$label.'</option>';
6322 $out .= '<option value="'.$obj->rowid.'">'.$label.'</option>';
6325 array_push($outarray, array('key'=>$obj->rowid, 'value'=>$label, 'label'=>$label));
6329 if (($i % 10) == 0) $out .= "\n";
6333 $out .= '</select>'."\n";
6336 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
6337 $out .= ajax_combobox($htmlname, null, $conf->global->$confkeyforautocompletemode);
6340 dol_print_error($this->db);
6343 $this->result = array('nbofelement'=>$num);
6345 if ($outputmode) return $outarray;
6373 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 = '', $addjscombo = 0, $moreparamonempty = '', $disablebademail = 0, $nohtmlescape = 0)
6375 global $conf, $langs;
6377 // Do we want a multiselect ?
6379 //if (preg_match('/^multi/',$htmlname)) $jsbeautify = 1;
6382 if ($value_as_key) $array = array_combine($array, $array);
6386 // Add code for jquery to use multiselect
6387 if ($addjscombo && $jsbeautify)
6389 $minLengthToAutocomplete = 0;
6390 $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ? (constant('REQUIRE_JQUERY_MULTISELECT') ?constant('REQUIRE_JQUERY_MULTISELECT') : 'select2') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
6392 // Enhance with select2
6393 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
6394 $out .= ajax_combobox($htmlname);
6397 $out .= '<select id="'.preg_replace('/^\./
', '', $htmlname).'" '.($disabled ? 'disabled="disabled
" ' : '').'class="flat
'.(preg_replace('/^\./
', '', $htmlname)).($morecss ? ' '.$morecss : '').'"';
6398 $out .= ' name="'.preg_replace('/^\./
', '', $htmlname).'" '.($moreparam ? $moreparam : '');
6403 $textforempty = ' ';
6404 if (!empty($conf->use_javascript_ajax)) $textforempty = ' '; // If we use ajaxcombo, we need here to avoid to have an empty element that is too small.
6405 if (!is_numeric($show_empty)) $textforempty = $show_empty;
6406 $out .= '<option class="optiongrey
" '.($moreparamonempty ? $moreparamonempty.' ' : '').'value="'.($show_empty < 0 ? $show_empty : -1).'"'.($id == $show_empty ? ' selected' : '').'>'.$textforempty.'</option>'."\n";
6409 if (is_array($array))
6414 foreach ($array as $key => $value)
6416 if (!is_array($value)) $array[$key] = $langs->trans($value);
6417 else $array[$key]['label'] = $langs->trans($value['label']);
6422 if ($sort == 'ASC') asort($array);
6423 elseif ($sort == 'DESC') arsort($array);
6425 foreach ($array as $key => $tmpvalue)
6427 if (is_array($tmpvalue)) {
6428 $value = $tmpvalue['label'];
6429 $disabled = empty($tmpvalue['disabled']) ? '' : ' disabled';
6430 $style = empty($tmpvalue['css']) ? ' class="'.$tmpvalue['css
'].'"' : '';
6433 $disabled = ''; $style = '';
6435 if (!empty($disablebademail)) {
6436 if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value))
6437 || ($disablebademail == 2 && preg_match('/---/', $value)))
6439 $disabled = ' disabled';
6440 $style = ' class="warning
"';
6444 if ($key_in_label) {
6445 if (empty($nohtmlescape)) $selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value));
6446 else $selectOptionValue = $key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value);
6448 if (empty($nohtmlescape)) $selectOptionValue = dol_escape_htmltag($maxlen ?dol_trunc($value, $maxlen) : $value);
6449 else $selectOptionValue = $maxlen ?dol_trunc($value, $maxlen) : $value;
6450 if ($value == '' || $value == '-') $selectOptionValue = ' ';
6453 $out .= '<option value="'.$key.'"';
6454 $out .= $style.$disabled;
6455 if (is_array($id)) {
6456 if (in_array($key, $id) && !$disabled) $out .= ' selected'; // To preselect a value
6458 $id = (string) $id; // if $id = 0, then $id = '0'
6459 if ($id != '' && $id == $key && !$disabled) $out .= ' selected'; // To preselect a value
6461 if ($nohtmlescape) $out .= ' data-html="'.dol_escape_htmltag($selectOptionValue).'"';
6462 if (is_array($tmpvalue))
6464 foreach ($tmpvalue as $keyforvalue => $valueforvalue)
6466 if (preg_match('/^data-/', $keyforvalue)) $out .= ' '.$keyforvalue.'="'.$valueforvalue.'"';
6470 //var_dump($selectOptionValue);
6471 $out .= $selectOptionValue;
6472 $out .= "</option>
\n";
6476 $out .= "</select>
";
6499 public static function selectArrayAjax($htmlname, $url, $id = '', $moreparam = '', $moreparamtourl = '', $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0)
6501 global $conf, $langs;
6502 global $delayedhtmlcontent;
6504 // TODO Use an internal dolibarr component instead of select2
6505 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) return '';
6507 $out = '<select type="text
" class="'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name="'.$htmlname.'"></select>';
6509 $tmpplugin = 'select2';
6510 $outdelayed = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
6512 $(document).ready(function () {
6514 '.($callurlonselect ? 'var saveRemoteData = [];' : '').'
6516 $(".
'.$htmlname.'").select2({
6522 data: function (params) {
6524 q: params.term, // search term
6528 processResults: function (data) {
6529 // parse the results into the format expected by Select2.
6530 // since we are using custom formatting functions we do not need to alter the remote JSON data
6531 //console.log(data);
6532 saveRemoteData = data;
6533 /* format json result for select2 */
6535 $.each( data, function( key, value ) {
6536 result.push({id: key, text: value.text});
6538 //return {results:[{id:\'none\', text:\'aa\'}, {id:\'rrr\', text:\'Red\'},{id:\'bbb\', text:\'Search a into projects\'}], more:false}
6539 //console.log(result);
6540 return {results: result, more: false}
6544 language: select2arrayoflanguage,
6545 containerCssClass: \':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
6546 placeholder:
"'.dol_escape_js($placeholder).'",
6547 escapeMarkup:
function (markup) {
return markup; },
6548 minimumInputLength:
'.$minimumInputLength.',
6549 formatResult:
function(result, container, query, escapeMarkup) {
6550 return escapeMarkup(result.text);
6554 '.($callurlonselect ? '
6556 $(
".'.$htmlname.'").change(
function() {
6557 var selected = $(
".'.$htmlname.'").val();
6558 console.log(
"We select in selectArrayAjax the entry "+selected)
6559 $(
".'.$htmlname.'").val(
"");
6560 $.each( saveRemoteData,
function( key, value ) {
6561 if (key == selected)
6563 console.log(
"selectArrayAjax - Do a redirect to "+value.url)
6564 location.assign(value.url);
6572 if ($acceptdelayedhtml)
6574 $delayedhtmlcontent .= $outdelayed;
6576 $out .= $outdelayed;
6599 public static function selectArrayFilter($htmlname, $array, $id = '', $moreparam = '', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0)
6601 global $conf, $langs;
6602 global $delayedhtmlcontent;
6604 // TODO Use an internal dolibarr component instead of select2
6605 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT
')) return '';
6607 $out = '<select type=
"text" class=
"'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name=
"'.$htmlname.'"><option></option></select>
';
6609 $formattedarrayresult = array();
6611 foreach ($array as $key => $value) {
6612 $o = new stdClass();
6614 $o->text = $value['text
'];
6615 $o->url = $value['url
'];
6616 $formattedarrayresult[] = $o;
6619 $tmpplugin = 'select2
';
6620 $outdelayed = "\n".'<!-- JS CODE TO ENABLE
'.$tmpplugin.' for id '.$htmlname.' -->
6622 $(document).ready(
function () {
6623 var data =
'.json_encode($formattedarrayresult).';
6625 '.($callurlonselect ? 'var saveRemoteData =
'.json_encode($array).';
' : '').'
6627 $(
".'.$htmlname.'").select2({
6630 containerCssClass: \
':all:\', /* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
6631 placeholder: "'.dol_escape_js($placeholder).
'",
6632 escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
6633 minimumInputLength: '.$minimumInputLength.
',
6634 formatResult: function(result, container, query, escapeMarkup) {
6635 return escapeMarkup(result.text);
6637 matcher: function (params, data) {
6639 if(! data.id) return null;';
6641 if ($callurlonselect) {
6644 var urlBase = data.url;
6645 var separ = urlBase.indexOf("?") >= 0 ? "&" : "?";
6646 /* console.log("params.term="+params.term); */
6647 /* console.log("params.term encoded="+encodeURIComponent(params.term)); */
6648 saveRemoteData[data.id].url = urlBase + separ + "sall=" + encodeURIComponent(params.term.replace(/\"/g, ""));';
6651 if (!$disableFiltering) {
6654 if(data.text.match(new RegExp(params.term))) {
6669 '.($callurlonselect ?
'
6670 /* Code to execute a GET when we select a value */
6671 $(".'.$htmlname.
'").change(function() {
6672 var selected = $(".'.$htmlname.
'").val();
6673 console.log("We select "+selected)
6675 $(".'.$htmlname.
'").val(""); /* reset visible combo value */
6676 $.each( saveRemoteData, function( key, value ) {
6677 if (key == selected)
6679 console.log("selectArrayFilter - Do a redirect to "+value.url)
6680 location.assign(value.url);
6688 if ($acceptdelayedhtml)
6690 $delayedhtmlcontent .= $outdelayed;
6692 $out .= $outdelayed;
6715 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)
6717 global $conf, $langs;
6721 if ($addjscombo < 0) {
6722 if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $addjscombo = 1;
6723 else $addjscombo = 0;
6727 if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined(
'REQUIRE_JQUERY_MULTISELECT'))
6729 $out .=
"\n".
'<!-- JS CODE TO ENABLE select for id '.$htmlname.
', addjscombo='.$addjscombo.
' -->
6731 if ($addjscombo == 1)
6733 $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant(
'REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
6734 $out .=
'function formatResult(record) {'.
"\n";
6735 if ($elemtype ==
'category')
6737 $out .=
'return \'<span><img src="'.DOL_URL_ROOT.
'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
6739 $out .=
'return record.text;';
6742 $out .=
'function formatSelection(record) {'.
"\n";
6743 if ($elemtype ==
'category')
6745 $out .=
'return \'<span><img src="'.DOL_URL_ROOT.
'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
6747 $out .=
'return record.text;';
6750 $out .=
'$(document).ready(function () {
6751 $(\'#'.$htmlname.
'\').
'.$tmpplugin.'({
6753 // Specify format function for dropdown item
6754 formatResult: formatResult,
6755 templateResult: formatResult, /* For 4.0 */
6756 // Specify format function for selected item
6757 formatSelection: formatSelection,
6758 templateSelection: formatSelection /* For 4.0 */
6761 /* Add also morecss to the css .select2 that is after the #htmlname, for component that are show dynamically after load, because select2 set
6762 the size only if component is not hidden by default on load */
6763 $(\'#'.$htmlname.
' + .select2\').addClass(\''.$morecss.
'\');
6765 } elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT
'))
6768 // TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
6770 $out .= 'console.log(\
'addjscombo=2 for htmlname='.$htmlname.
'\');
';
6771 $out .= '$(document).ready(
function () {
6772 $(\
'#'.$htmlname.
'\').multiSelect({
6773 containerHTML: \
'<div class="multi-select-container">\',
6774 menuHTML: \'<div class="multi-select-menu">\',
6775 buttonHTML: \'<span class="multi-select-button '.$morecss.
'">\',
6776 menuItemHTML: \'<label class="multi-select-menuitem">\',
6777 activeClass: \'multi-select-container--open\',
6778 noneText: \''.$placeholder.
'\'
6782 $out .= '</script>
';
6785 // Try also magic suggest
6786 $out .= '<select
id=
"'.$htmlname.'" class=
"multiselect'.($morecss ? ' '.$morecss : '').'" multiple
name=
"'.$htmlname.'[]"'.($moreattrib ? ' '.$moreattrib : '').($width ? ' style=
"width: '.(preg_match('/%/', $width) ? $width : $width.'px').'"' : '').'>
'."\n";
6787 if (is_array($array) && !empty($array))
6789 if ($value_as_key) $array = array_combine($array, $array);
6793 foreach ($array as $key => $value)
6795 $newval = ($translate ? $langs->trans($value) : $value);
6796 $newval = ($key_in_label ? $key.' -
'.$newval : $newval);
6798 $out .= '<option value=
"'.$key.'"';
6799 if (is_array($selected) && !empty($selected) && in_array((string) $key, $selected) && ((string) $key != ''))
6801 $out .= ' selected
';
6803 $out .= ' data-html=
"'.dol_escape_htmltag($newval).'"';
6805 $out .= dol_htmlentitiesbr($newval);
6806 $out .= '</option>
'."\n";
6810 $out .= '</select>
'."\n";
6825 public static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage)
6827 global $conf, $langs, $user, $extrafields;
6829 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return '';
6831 $tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; // To get list of saved seleteced properties
6832 if (!empty($user->conf->$tmpvar))
6834 $tmparray = explode(',
', $user->conf->$tmpvar);
6835 foreach ($array as $key => $val)
6838 //var_dump($tmparray);
6839 if (in_array($key, $tmparray)) $array[$key]['checked
'] = 1;
6840 else $array[$key]['checked
'] = 0;
6845 $listcheckedstring = '';
6847 foreach ($array as $key => $val)
6850 var_dump(array_key_exists('enabled
', $val));
6851 var_dump(!$val['enabled
']);*/
6852 if (array_key_exists('enabled
', $val) && isset($val['enabled
']) && !$val['enabled
'])
6854 unset($array[$key]); // We don't want
this field
6859 if (!empty($val[
'langfile']) && is_object($langs)) {
6860 $langs->load($val[
'langfile']);
6863 $lis .=
'<li><input type="checkbox" id="checkbox'.$key.
'" value="'.$key.
'"'.(empty($val[
'checked']) ?
'' :
' checked="checked"').
'/><label for="checkbox'.$key.
'">'.
dol_escape_htmltag($langs->trans($val[
'label'])).
'</label></li>';
6864 $listcheckedstring .= (empty($val[
'checked']) ?
'' : $key.
',');
6868 $out =
'<!-- Component multiSelectArrayWithCheckbox '.$htmlname.
' -->
6870 <dl class="dropdown">
6872 <a href="#'.$htmlname.
'">
6875 <input type="hidden" class="'.$htmlname.
'" name="'.$htmlname.
'" value="'.$listcheckedstring.
'">
6877 <dd class="dropdowndd">
6878 <div class="multiselectcheckbox'.$htmlname.
'">
6879 <ul class="ul'.$htmlname.
'">
6886 <script type="text/javascript">
6887 jQuery(document).ready(function () {
6888 $(\'.multiselectcheckbox'.$htmlname.
' input[type="checkbox"]\').on(\'click\', function () {
6889 console.log("A new field was added/removed, we edit field input[name=formfilteraction]");
6891 $("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\'); // Update field so we know we changed something on selected fields after POST
6893 var title = $(this).val() + ",";
6894 if ($(this).is(\':checked\')) {
6895 $(\'.'.$htmlname.
'\').val(title + $(\
'.'.$htmlname.
'\').val());
6898 $(\
'.'.$htmlname.
'\').val( $(\
'.'.$htmlname.
'\').val().replace(title, \
'\') )
6921 public function showCategories($id, $type, $rendermode = 0, $nolink = 0)
6925 include_once DOL_DOCUMENT_ROOT.'/categories/
class/categorie.class.php
';
6927 $cat = new Categorie($db);
6928 $categories = $cat->containing($id, $type);
6930 if ($rendermode == 1)
6933 foreach ($categories as $c)
6935 $ways = $c->print_all_ways(' >>
', ($nolink ? 'none
' : ''), 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
6936 foreach ($ways as $way)
6938 $toprint[] = '<li
class=
"select2-search-choice-dolibarr noborderoncategories"'.($c->color ? ' style=
"background: #'.$c->color.';"' : ' style=
"background: #bbb"').'>
'.$way.'</li>
';
6941 return '<div
class=
"select2-container-multi-dolibarr" style=
"width: 90%;"><ul
class=
"select2-choices-dolibarr">
'.implode(' ', $toprint).'</ul></div>
';
6944 if ($rendermode == 0)
6946 $arrayselected = array();
6947 $cate_arbo = $this->select_all_categories($type, '', 'parent
', 64, 0, 1);
6948 foreach ($categories as $c) {
6949 $arrayselected[] = $c->id;
6952 return $this->multiselectarray('categories
', $cate_arbo, $arrayselected, '', 0, '', 0, '100%
', 'disabled
', 'category
');
6955 return 'ErrorBadValueForParameterRenderMode
'; // Should not happened
6966 public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = false)
6968 global $conf, $langs, $hookmanager;
6969 global $bc, $action;
6971 $object->fetchObjectLinked();
6973 // Bypass the default method
6974 $hookmanager->initHooks(array('commonobject
'));
6975 $parameters = array(
6976 'morehtmlright
' => $morehtmlright,
6977 'compatibleImportElementsList
' => &$compatibleImportElementsList,
6979 $reshook = $hookmanager->executeHooks('showLinkedObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
6981 if (empty($reshook))
6983 $nbofdifferenttypes = count($object->linkedObjects);
6986 print load_fiche_titre($langs->trans('RelatedObjects
'), $morehtmlright, '', 0, 0, 'showlinkedobjectblock
');
6989 print '<div
class=
"div-table-responsive-no-min">
';
6990 print '<table
class=
"noborder allwidth" data-block=
"showLinkedObject" data-element=
"'.$object->element.'" data-elementid=
"'.$object->id.'" >
';
6992 print '<tr
class=
"liste_titre">
';
6993 print '<td>
'.$langs->trans("Type").'</td>
';
6994 print '<td>
'.$langs->trans("Ref").'</td>
';
6995 print '<td
class=
"center"></td>
';
6996 print '<td
class=
"center">
'.$langs->trans("Date").'</td>
';
6997 print '<td
class=
"right">
'.$langs->trans("AmountHTShort").'</td>
';
6998 print '<td
class=
"right">
'.$langs->trans("Status").'</td>
';
7002 $nboftypesoutput = 0;
7004 foreach ($object->linkedObjects as $objecttype => $objects)
7006 $tplpath = $element = $subelement = $objecttype;
7008 // to display inport button on tpl
7009 $showImportButton = false;
7010 if (!empty($compatibleImportElementsList) && in_array($element, $compatibleImportElementsList)) {
7011 $showImportButton = true;
7015 if ($objecttype != 'supplier_proposal
' && preg_match('/^([^_]+)_([^_]+)/i
', $objecttype, $regs))
7017 $element = $regs[1];
7018 $subelement = $regs[2];
7019 $tplpath = $element.'/
'.$subelement;
7021 $tplname = 'linkedobjectblock
';
7023 // To work with non standard path
7024 if ($objecttype == 'facture
') {
7025 $tplpath = 'compta/
'.$element;
7026 if (empty($conf->facture->enabled)) continue; // Do not show if module disabled
7027 } elseif ($objecttype == 'facturerec
') {
7028 $tplpath = 'compta/facture
';
7029 $tplname = 'linkedobjectblockForRec
';
7030 if (empty($conf->facture->enabled)) continue; // Do not show if module disabled
7031 } elseif ($objecttype == 'propal
') {
7032 $tplpath = 'comm/
'.$element;
7033 if (empty($conf->propal->enabled)) continue; // Do not show if module disabled
7034 } elseif ($objecttype == 'supplier_proposal
') {
7035 if (empty($conf->supplier_proposal->enabled)) continue; // Do not show if module disabled
7036 } elseif ($objecttype == 'shipping
' || $objecttype == 'shipment
') {
7037 $tplpath = 'expedition
';
7038 if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
7039 } elseif ($objecttype == 'reception
') {
7040 $tplpath = 'reception
';
7041 if (empty($conf->reception->enabled)) continue; // Do not show if module disabled
7042 } elseif ($objecttype == 'delivery
') {
7043 $tplpath = 'delivery
';
7044 if (empty($conf->expedition->enabled)) continue; // Do not show if module disabled
7045 } elseif ($objecttype == 'invoice_supplier
') {
7046 $tplpath = 'fourn/facture
';
7047 } elseif ($objecttype == 'order_supplier
') {
7048 $tplpath = 'fourn/commande
';
7049 } elseif ($objecttype == 'expensereport
') {
7050 $tplpath = 'expensereport
';
7051 } elseif ($objecttype == 'subscription
') {
7052 $tplpath = 'adherents
';
7055 global $linkedObjectBlock;
7056 $linkedObjectBlock = $objects;
7059 // Output template part (modules that overwrite templates must declare this into descriptor)
7060 $dirtpls = array_merge($conf->modules_parts['tpl
'], array('/
'.$tplpath.'/tpl
'));
7061 foreach ($dirtpls as $reldir)
7063 if ($nboftypesoutput == ($nbofdifferenttypes - 1)) // No more type to show after
7065 global $noMoreLinkedObjectBlockAfter;
7066 $noMoreLinkedObjectBlockAfter = 1;
7069 $res = @include dol_buildpath($reldir.'/
'.$tplname.'.tpl.php
');
7078 if (!$nboftypesoutput)
7080 print '<tr><td
class=
"impair opacitymedium" colspan=
"7">
'.$langs->trans("None").'</td></tr>
';
7085 if (!empty($compatibleImportElementsList))
7087 $res = @include dol_buildpath('core/tpl/ajax/objectlinked_lineimport.tpl.php
');
7093 return $nbofdifferenttypes;
7105 public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array())
7107 global $conf, $langs, $hookmanager;
7108 global $bc, $action;
7111 $linktoelemlist = '';
7112 $listofidcompanytoscan = '';
7114 if (!is_object($object->thirdparty)) $object->fetch_thirdparty();
7116 $possiblelinks = array();
7117 if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0)
7119 $listofidcompanytoscan = $object->thirdparty->id;
7120 if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO)) $listofidcompanytoscan .= ',
'.$object->thirdparty->parent;
7121 if (($object->fk_project > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO))
7123 include_once DOL_DOCUMENT_ROOT.'/projet/
class/project.class.php
';
7124 $tmpproject = new Project($this->db);
7125 $tmpproject->fetch($object->fk_project);
7126 if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id)) $listofidcompanytoscan .= ',
'.$tmpproject->socid;
7130 $possiblelinks = array(
7131 'propal
'=>array('enabled
'=>$conf->propal->enabled, 'perms
'=>1, 'label
'=>'LinkToProposal
', 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN (
'.getEntity('propal
').')
'),
7132 'order
'=>array('enabled
'=>$conf->commande->enabled, 'perms
'=>1, 'label
'=>'LinkToOrder
', 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN (
'.getEntity('commande
').')
'),
7133 'invoice
'=>array('enabled
'=>$conf->facture->enabled, 'perms
'=>1, 'label
'=>'LinkToInvoice
', 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN (
'.getEntity('invoice
').')
'),
7134 'invoice_template
'=>array('enabled
'=>$conf->facture->enabled, 'perms
'=>1, 'label
'=>'LinkToTemplateInvoice
', 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN (
'.getEntity('invoice
').')
'),
7135 'contrat
'=>array('enabled
'=>$conf->contrat->enabled, 'perms
'=>1, 'label
'=>'LinkToContract
',
7136 '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 FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t, ".MAIN_DB_PREFIX."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN (
'.getEntity('contract
').')
'),
7137 'fichinter
'=>array('enabled
'=>$conf->ficheinter->enabled, 'perms
'=>1, 'label
'=>'LinkToIntervention
', 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN (
'.getEntity('intervention
').')
'),
7138 'supplier_proposal
'=>array('enabled
'=>$conf->supplier_proposal->enabled, 'perms
'=>1, 'label
'=>'LinkToSupplierProposal
', 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN (
'.getEntity('supplier_proposal
').')
'),
7139 'order_supplier
'=>array('enabled
'=>$conf->supplier_order->enabled, 'perms
'=>1, 'label
'=>'LinkToSupplierOrder
', 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN (
'.getEntity('commande_fournisseur
').')
'),
7140 'invoice_supplier
'=>array('enabled
'=>$conf->supplier_invoice->enabled, 'perms
'=>1, 'label
'=>'LinkToSupplierInvoice
', 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN (
'.getEntity('facture_fourn
').')
'),
7141 'ticket
'=>array('enabled
'=>$conf->ticket->enabled, 'perms
'=>1, 'label
'=>'LinkToTicket
', 'sql
'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.track_id, '0
' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."ticket as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN (
'.getEntity('ticket
').')
')
7145 // Can complete the possiblelink array
7146 $hookmanager->initHooks(array('commonobject
'));
7147 $parameters = array('listofidcompanytoscan
' => $listofidcompanytoscan);
7149 if (!empty($listofidcompanytoscan)) // If empty, we don't have criteria to scan the
object we can link to
7151 $reshook = $hookmanager->executeHooks(
'showLinkToObjectBlock', $parameters, $object, $action);
7154 if (empty($reshook))
7156 if (is_array($hookmanager->resArray) && count($hookmanager->resArray))
7158 $possiblelinks = array_merge($possiblelinks, $hookmanager->resArray);
7160 } elseif ($reshook > 0)
7162 if (is_array($hookmanager->resArray) && count($hookmanager->resArray))
7164 $possiblelinks = $hookmanager->resArray;
7168 foreach ($possiblelinks as $key => $possiblelink)
7172 if (empty($possiblelink[
'enabled']))
continue;
7174 if (!empty($possiblelink[
'perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto)))
7176 print '<div id="'.$key.
'list"'.(empty($conf->use_javascript_ajax) ?
'' :
' style="display:none"').
'>';
7177 $sql = $possiblelink[
'sql'];
7179 $resqllist = $this->
db->query($sql);
7182 $num = $this->
db->num_rows($resqllist);
7186 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formlinked'.$key.
'">';
7187 print '<input type="hidden" name="action" value="addlink">';
7188 print '<input type="hidden" name="token" value="'.newToken().
'">';
7189 print '<input type="hidden" name="id" value="'.$object->id.
'">';
7190 print '<input type="hidden" name="addlink" value="'.$key.
'">';
7191 print '<table class="noborder">';
7192 print '<tr class="liste_titre">';
7193 print '<td class="nowrap"></td>';
7194 print '<td class="center">'.$langs->trans(
"Ref").
'</td>';
7195 print '<td class="left">'.$langs->trans(
"RefCustomer").
'</td>';
7196 print '<td class="right">'.$langs->trans(
"AmountHTShort").
'</td>';
7197 print '<td class="left">'.$langs->trans(
"Company").
'</td>';
7201 $objp = $this->
db->fetch_object($resqllist);
7203 print '<tr class="oddeven">';
7204 print '<td class="left">';
7205 print '<input type="radio" name="idtolinkto" value='.$objp->rowid.
'>';
7207 print '<td class="center">'.$objp->ref.
'</td>';
7208 print '<td>'.$objp->ref_client.
'</td>';
7209 print '<td class="right">';
7210 if ($possiblelink[label] ==
'LinkToContract') {
7211 $form =
new Form($db);
7212 print $form->textwithpicto(
'', $langs->trans(
"InformationOnLinkToContract")).
' ';
7215 print '<td>'.$objp->name.
'</td>';
7220 print '<div class="center"><input type="submit" class="button valignmiddle" value="'.$langs->trans(
'ToLink').
'"> <input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'"></div>';
7223 $this->
db->free($resqllist);
7233 if ($num > 0) $linktoelemlist .=
'<li><a href="#linkto'.$key.
'" class="linkto dropdowncloseonclick" rel="'.$key.
'">'.$langs->trans($possiblelink[
'label']).
' ('.$num.
')</a></li>';
7235 else $linktoelemlist .=
'<li><span class="linktodisabled">'.$langs->trans($possiblelink[
'label']).
' (0)</span></li>';
7239 if ($linktoelemlist)
7242 <dl class="dropdown" id="linktoobjectname">
7244 if (!empty($conf->use_javascript_ajax)) $linktoelem .=
'<dt><a href="#linktoobjectname">'.$langs->trans(
"LinkTo").
'...</a></dt>';
7245 $linktoelem .=
'<dd>
7246 <div class="multiselectlinkto">
7247 <ul class="ulselectedfields">'.$linktoelemlist.
'
7256 if (!empty($conf->use_javascript_ajax))
7258 print '<!-- Add js to show linkto box -->
7260 jQuery(document).ready(function() {
7261 jQuery(".linkto").click(function() {
7262 console.log("We choose to show/hide link for rel="+jQuery(this).attr(\'rel\'));
7263 jQuery("#"+jQuery(this).attr(\'rel\')+"list").toggle();
7284 public function selectyesno($htmlname, $value =
'', $option = 0, $disabled =
false, $useempty = 0, $addjscombo = 0)
7288 $yes =
"yes"; $no =
"no";
7295 $disabled = ($disabled ?
' disabled' :
'');
7297 $resultyesno =
'<select class="flat width75" id="'.$htmlname.
'" name="'.$htmlname.
'"'.$disabled.
'>'.
"\n";
7298 if ($useempty) $resultyesno .=
'<option value="-1"'.(($value < 0) ?
' selected' :
'').
'> </option>'.
"\n";
7299 if ((
"$value" ==
'yes') || ($value == 1))
7301 $resultyesno .=
'<option value="'.$yes.
'" selected>'.$langs->trans(
"Yes").
'</option>'.
"\n";
7302 $resultyesno .=
'<option value="'.$no.
'">'.$langs->trans(
"No").
'</option>'.
"\n";
7304 $selected = (($useempty && $value !=
'0' && $value !=
'no') ?
'' :
' selected');
7305 $resultyesno .=
'<option value="'.$yes.
'">'.$langs->trans(
"Yes").
'</option>'.
"\n";
7306 $resultyesno .=
'<option value="'.$no.
'"'.$selected.
'>'.$langs->trans(
"No").
'</option>'.
"\n";
7308 $resultyesno .=
'</select>'.
"\n";
7314 return $resultyesno;
7330 $sql =
"SELECT rowid, label";
7331 $sql .=
" FROM ".MAIN_DB_PREFIX.
"export_model";
7332 $sql .=
" WHERE type = '".$this->db->escape($type).
"'";
7333 $sql .=
" ORDER BY rowid";
7334 $result = $this->
db->query($sql);
7337 print '<select class="flat" id="select_'.$htmlname.
'" name="'.$htmlname.
'">';
7340 print '<option value="-1"> </option>';
7343 $num = $this->
db->num_rows($result);
7347 $obj = $this->
db->fetch_object($result);
7348 if ($selected == $obj->rowid)
7350 print '<option value="'.$obj->rowid.
'" selected>';
7352 print '<option value="'.$obj->rowid.
'">';
7382 public function showrefnav($object, $paramid, $morehtml =
'', $shownav = 1, $fieldid =
'rowid', $fieldref =
'ref', $morehtmlref =
'', $moreparam =
'', $nodbprefix = 0, $morehtmlleft =
'', $morehtmlstatus =
'', $morehtmlright =
'')
7384 global $langs, $conf, $hookmanager, $extralanguages;
7387 if (empty($fieldid)) $fieldid =
'rowid';
7388 if (empty($fieldref)) $fieldref =
'ref';
7391 if (is_object($hookmanager))
7393 $parameters = array();
7394 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object);
7395 $object->next_prev_filter .= $hookmanager->resPrint;
7397 $previous_ref = $next_ref =
'';
7401 $object->load_previous_next_ref((isset($object->next_prev_filter) ? $object->next_prev_filter :
''), $fieldid, $nodbprefix);
7405 if ($paramid ==
'project_ref')
7407 if (preg_match(
'/\/tasks\/(task|contact|note|document)\.php/', $navurl))
7409 $navurl = preg_replace(
'/\/tasks\/(task|contact|time|note|document)\.php/',
'/tasks.php', $navurl);
7416 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
7417 if ($conf->browser->name ==
'chrome')
7419 $stringforfirstkey .=
' ALT +';
7420 } elseif ($conf->browser->name ==
'firefox')
7422 $stringforfirstkey .=
' ALT + SHIFT +';
7424 $stringforfirstkey .=
' CTL +';
7427 $previous_ref = $object->ref_previous ?
'<a accesskey="p" title="'.$stringforfirstkey.
' p" class="classfortooltip" href="'.$navurl.
'?'.$paramid.
'='.urlencode($object->ref_previous).$moreparam.
'"><i class="fa fa-chevron-left"></i></a>' :
'<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>';
7428 $next_ref = $object->ref_next ?
'<a accesskey="n" title="'.$stringforfirstkey.
' n" class="classfortooltip" href="'.$navurl.
'?'.$paramid.
'='.urlencode($object->ref_next).$moreparam.
'"><i class="fa fa-chevron-right"></i></a>' :
'<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>';
7432 $ret .=
'<!-- Start banner content --><div style="vertical-align: middle">';
7435 if ($morehtmlright) $ret .=
'<div class="inline-block floatleft">'.$morehtmlright.
'</div>';
7437 if ($previous_ref || $next_ref || $morehtml)
7439 $ret .=
'<div class="pagination paginationref"><ul class="right">';
7443 $ret .=
'<li class="noborder litext'.(($shownav && $previous_ref && $next_ref) ?
' clearbothonsmartphone' :
'').
'">'.$morehtml.
'</li>';
7445 if ($shownav && ($previous_ref || $next_ref))
7447 $ret .=
'<li class="pagination">'.$previous_ref.
'</li>';
7448 $ret .=
'<li class="pagination">'.$next_ref.
'</li>';
7450 if ($previous_ref || $next_ref || $morehtml)
7452 $ret .=
'</ul></div>';
7455 $parameters = array();
7456 $reshook = $hookmanager->executeHooks(
'moreHtmlStatus', $parameters, $object);
7457 if (empty($reshook)) $morehtmlstatus .= $hookmanager->resPrint;
7458 else $morehtmlstatus = $hookmanager->resPrint;
7459 if ($morehtmlstatus) $ret .=
'<div class="statusref">'.$morehtmlstatus.
'</div>';
7461 $parameters = array();
7462 $reshook = $hookmanager->executeHooks(
'moreHtmlRef', $parameters, $object);
7463 if (empty($reshook)) $morehtmlref .= $hookmanager->resPrint;
7464 elseif ($reshook > 0) $morehtmlref = $hookmanager->resPrint;
7469 if ($conf->browser->layout ==
'phone') $ret .=
'<!-- morehtmlleft --><div class="floatleft">'.$morehtmlleft.
'</div>';
7470 else $ret .=
'<!-- morehtmlleft --><div class="inline-block floatleft">'.$morehtmlleft.
'</div>';
7474 $ret .=
'<div class="inline-block floatleft valignmiddle maxwidth750 marginbottomonly refid'.(($shownav && ($previous_ref || $next_ref)) ?
' refidpadding' :
'').
'">';
7477 if ($object->element ==
'societe')
7482 $arrayoflangcode = array();
7483 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE;
7485 if (is_array($arrayoflangcode) && count($arrayoflangcode)) {
7486 if (!is_object($extralanguages)) {
7487 include_once DOL_DOCUMENT_ROOT.
'/core/class/extralanguages.class.php';
7490 $extralanguages->fetch_name_extralanguages(
'societe');
7492 if (!empty($extralanguages->attributes[
'societe'][
'name']))
7494 $object->fetchValuesForExtraLanguages();
7498 foreach ($arrayoflangcode as $extralangcode) {
7500 if ($object->array_languages[
'name'][$extralangcode]) {
7501 $htmltext .= $object->array_languages[
'name'][$extralangcode];
7503 $htmltext .=
'<span class="opacitymedium">'.$langs->trans(
"SwitchInEditModeToAddTranslation").
'</span>';
7506 $ret .=
'<!-- Show translations of name -->'.
"\n";
7507 $ret .= $this->
textwithpicto(
'', $htmltext, -1,
'language',
'opacitymedium paddingleft');
7510 } elseif ($object->element ==
'member')
7512 $ret .= $object->ref.
'<br>';
7513 $fullname = $object->getFullName($langs);
7514 if ($object->morphy ==
'mor' && $object->societe) {
7519 } elseif (in_array($object->element, array(
'contact',
'user',
'usergroup')))
7522 } elseif (in_array($object->element, array(
'action',
'agenda')))
7524 $ret .= $object->ref.
'<br>'.$object->label;
7525 } elseif (in_array($object->element, array(
'adherent_type')))
7527 $ret .= $object->label;
7528 } elseif ($object->element ==
'ecm_directories')
7531 } elseif ($fieldref !=
'none')
7539 if (substr($morehtmlref, 0, 4) !=
'<div')
7544 $ret .= $morehtmlref;
7549 $ret .=
'</div><!-- End banner content -->';
7567 if (empty($object->barcode))
return '';
7570 if (empty($object->barcode_type_code) || empty($object->barcode_type_coder))
7572 $result = $object->fetch_barcode();
7574 if ($result < 1)
return '<!-- ErrorFetchBarcode -->';
7578 $url = DOL_URL_ROOT.
'/viewimage.php?modulepart=barcode&generator='.urlencode($object->barcode_type_coder).
'&code='.urlencode($object->barcode).
'&encoding='.urlencode($object->barcode_type_code);
7579 $out =
'<!-- url barcode = '.$url.
' -->';
7580 $out .=
'<img src="'.$url.
'">';
7600 public static function showphoto($modulepart, $object, $width = 100, $height = 0, $caneditfield = 0, $cssclass =
'photowithmargin', $imagesize =
'', $addlinktofullsize = 1, $cache = 0, $forcecapture =
'', $noexternsourceoverwrite = 0)
7602 global $conf, $langs;
7604 $entity = (!empty($object->entity) ? $object->entity : $conf->entity);
7605 $id = (!empty($object->id) ? $object->id : $object->rowid);
7607 $ret =
''; $dir =
''; $file =
''; $originalfile =
''; $altfile =
''; $email =
''; $capture =
'';
7608 if ($modulepart ==
'societe')
7610 $dir = $conf->societe->multidir_output[$entity];
7611 if (!empty($object->logo)) {
7614 else $file =
get_exdir(0, 0, 0, 0, $object,
'thirdparty').
'logos/'.$object->logo;
7615 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'thirdparty').
'logos/'.$object->logo;
7617 $email = $object->email;
7618 } elseif ($modulepart ==
'contact') {
7619 $dir = $conf->societe->multidir_output[$entity].
'/contact';
7620 if (!empty($object->photo))
7624 else $file =
get_exdir(0, 0, 0, 0, $object,
'contact').
'photos/'.$object->photo;
7625 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'contact').
'photos/'.$object->photo;
7627 $email = $object->email;
7629 } elseif ($modulepart ==
'userphoto') {
7630 $dir = $conf->user->dir_output;
7631 if (!empty($object->photo))
7633 if ((
string) $imagesize ==
'mini') $file =
get_exdir(0, 0, 0, 0, $object,
'user').getImageFileNameForSize($object->photo,
'_mini');
7634 elseif ((
string) $imagesize ==
'small') $file =
get_exdir(0, 0, 0, 0, $object,
'user').getImageFileNameForSize($object->photo,
'_small');
7635 else $file =
get_exdir(0, 0, 0, 0, $object,
'user').$object->photo;
7636 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'user').$object->photo;
7638 if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile = $object->id.
".jpg";
7639 $email = $object->email;
7641 } elseif ($modulepart ==
'memberphoto') {
7642 $dir = $conf->adherent->dir_output;
7643 if (!empty($object->photo))
7647 else $file =
get_exdir(0, 0, 0, 0, $object,
'member').
'photos/'.$object->photo;
7648 $originalfile =
get_exdir(0, 0, 0, 0, $object,
'member').
'photos/'.$object->photo;
7650 if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile = $object->id.
".jpg";
7651 $email = $object->email;
7655 $dir = $conf->$modulepart->dir_output;
7656 if (!empty($object->photo))
7660 else $file =
get_exdir($id, 2, 0, 0, $object, $modulepart).
'photos/'.$object->photo;
7661 $originalfile =
get_exdir($id, 2, 0, 0, $object, $modulepart).
'photos/'.$object->photo;
7663 if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile = $object->id.
".jpg";
7664 $email = $object->email;
7667 if ($forcecapture) $capture = $forcecapture;
7671 if ($file && file_exists($dir.
"/".$file))
7673 if ($addlinktofullsize) {
7675 if ($urladvanced) $ret .=
'<a href="'.$urladvanced.
'">';
7676 else $ret .=
'<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($originalfile).
'&cache='.$cache.
'">';
7678 $ret .=
'<img alt="Photo" class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
' photologo'.(preg_replace(
'/[^a-z]/i',
'_', $file)).
'" '.($width ?
' width="'.$width.
'"' :
'').($height ?
' height="'.$height.
'"' :
'').
' src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($file).
'&cache='.$cache.
'">';
7679 if ($addlinktofullsize) $ret .=
'</a>';
7680 } elseif ($altfile && file_exists($dir.
"/".$altfile)) {
7681 if ($addlinktofullsize) {
7683 if ($urladvanced) $ret .=
'<a href="'.$urladvanced.
'">';
7684 else $ret .=
'<a href="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($originalfile).
'&cache='.$cache.
'">';
7686 $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.
'">';
7687 if ($addlinktofullsize) $ret .=
'</a>';
7689 $nophoto =
'/public/theme/common/nophoto.png';
7690 if (in_array($modulepart, array(
'userphoto',
'contact',
'memberphoto'))) {
7691 if ($modulepart ==
'memberphoto' && strpos($object->morphy,
'mor') !==
false) {
7692 $nophoto =
'/public/theme/common/company.png';
7694 $nophoto =
'/public/theme/common/user_anonymous.png';
7695 if ($object->gender ==
'man') $nophoto =
'/public/theme/common/user_man.png';
7696 if ($object->gender ==
'woman') $nophoto =
'/public/theme/common/user_woman.png';
7700 if (!empty($conf->gravatar->enabled) && $email && empty($noexternsourceoverwrite)) {
7702 global $dolibarr_main_url_root;
7703 $ret .=
'<!-- Put link to gravatar -->';
7706 $ret .=
'<img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" alt="Gravatar avatar" title="'.$email.
' Gravatar avatar" '.($width ?
' width="'.$width.
'"' :
'').($height ?
' height="'.$height.
'"' :
'').
' src="https://www.gravatar.com/avatar/'.md5(strtolower(trim($email))).
'?s='.$width.
'&d='.$defaultimg.
'">';
7708 $ret .=
'<img class="photo'.$modulepart.($cssclass ?
' '.$cssclass :
'').
'" alt="No photo" '.($width ?
' width="'.$width.
'"' :
'').($height ?
' height="'.$height.
'"' :
'').
' src="'.DOL_URL_ROOT.$nophoto.
'">';
7714 if ($object->photo) $ret .=
"<br>\n";
7715 $ret .=
'<table class="nobordernopadding centpercent">';
7716 if ($object->photo) $ret .=
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans(
"Delete").
'<br><br></td></tr>';
7717 $ret .=
'<tr><td class="tdoverflow"><input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"'.($capture ?
' capture="'.$capture.
'"' :
'').
'></td></tr>';
7720 }
else dol_print_error(
'',
'Call of showphoto with wrong parameters modulepart='.$modulepart);
7742 public function select_dolgroups($selected =
'', $htmlname =
'groupid', $show_empty = 0, $exclude =
'', $disabled = 0, $include =
'', $enableonly =
'', $force_entity =
'0', $multiple =
false, $morecss =
'')
7745 global $conf, $user, $langs;
7748 if (is_array($exclude)) $excludeGroups = implode(
"','", $exclude);
7750 if (is_array($include)) $includeGroups = implode(
"','", $include);
7752 if (!is_array($selected)) $selected = array($selected);
7757 $sql =
"SELECT ug.rowid, ug.nom as name";
7758 if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity)
7760 $sql .=
", e.label";
7762 $sql .=
" FROM ".MAIN_DB_PREFIX.
"usergroup as ug ";
7763 if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity)
7765 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"entity as e ON e.rowid=ug.entity";
7766 if ($force_entity) $sql .=
" WHERE ug.entity IN (0, ".$force_entity.
")";
7767 else $sql .=
" WHERE ug.entity IS NOT NULL";
7769 $sql .=
" WHERE ug.entity IN (0, ".$conf->entity.
")";
7771 if (is_array($exclude) && $excludeGroups) $sql .=
" AND ug.rowid NOT IN ('".$excludeGroups.
"')";
7772 if (is_array($include) && $includeGroups) $sql .=
" AND ug.rowid IN ('".$includeGroups.
"')";
7773 $sql .=
" ORDER BY ug.nom ASC";
7775 dol_syslog(get_class($this).
"::select_dolgroups", LOG_DEBUG);
7780 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
7783 $out .=
'<select class="flat minwidth200'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.($multiple ?
'[]' :
'').
'" '.($multiple ?
'multiple' :
'').
' '.($disabled ?
' disabled' :
'').
'>';
7785 $num = $this->
db->num_rows(
$resql);
7789 if ($show_empty && !$multiple) $out .=
'<option value="-1"'.(in_array(-1, $selected) ?
' selected' :
'').
'> </option>'.
"\n";
7793 $obj = $this->
db->fetch_object(
$resql);
7795 if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly)) $disableline = 1;
7797 $out .=
'<option value="'.$obj->rowid.
'"';
7798 if ($disableline) $out .=
' disabled';
7799 if ((is_object($selected[0]) && $selected[0]->
id == $obj->rowid) || (!is_object($selected[0]) && in_array($obj->rowid, $selected)))
7801 $out .=
' selected';
7806 if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1)
7808 $out .=
" (".$obj->label.
")";
7811 $out .=
'</option>';
7815 if ($show_empty) $out .=
'<option value="-1"'.(in_array(-1, $selected) ?
' selected' :
'').
'></option>'.
"\n";
7816 $out .=
'<option value="" disabled>'.$langs->trans(
"NoUserGroupDefined").
'</option>';
7818 $out .=
'</select>';
7834 $out =
'<div class="nowrap">';
7835 $out .=
'<button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
7836 $out .=
'<button type="submit" class="liste_titre button_removefilter" name="button_removefilter_x" value="x"><span class="fa fa-remove"></span></button>';
7850 public function showCheckAddButtons($cssclass =
'checkforaction', $calljsfunction = 0, $massactionname =
"massaction")
7852 global $conf, $langs;
7856 if (!empty($conf->use_javascript_ajax)) $out .=
'<div class="inline-block checkallactions"><input type="checkbox" id="'.$cssclass.
's" name="'.$cssclass.
's" class="checkallactions"></div>';
7858 $(document).ready(function() {
7859 $("#' . $cssclass.
's").click(function() {
7860 if($(this).is(\':checked\')){
7861 console.log("We check all '.$cssclass.
' and trigger the change method");
7862 $(".'.$cssclass.
'").prop(\'checked\', true).trigger(\'change\');
7866 console.log("We uncheck all");
7867 $(".'.$cssclass.
'").prop(\'checked\', false).trigger(\'change\');
7869 if ($calljsfunction) $out .=
'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0, "'.$massactionname.
'", "'.$cssclass.
'"); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
7871 $(".' . $cssclass.
'").change(function() {
7872 $(this).closest("tr").toggleClass("highlight", this.checked);
7892 if ($addcheckuncheckall)
7912 public function selectExpenseCategories($selected =
'', $htmlname =
'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target =
'', $default_selected = 0, $params = array(), $info_admin = 1)
7914 global $db, $langs, $user;
7917 $sql =
'SELECT rowid, label FROM '.MAIN_DB_PREFIX.
'c_exp_tax_cat WHERE active = 1';
7918 $sql .=
' AND entity IN (0,'.getEntity(
'exp_tax_cat').
')';
7919 if (!empty($excludeid)) $sql .=
' AND rowid NOT IN ('.implode(
',', $excludeid).
')';
7920 $sql .=
' ORDER BY label';
7922 $resql = $db->query($sql);
7925 $out =
'<select id="select_'.$htmlname.
'" name="'.$htmlname.
'" class="'.$htmlname.
' flat minwidth75imp maxwidth200">';
7926 if ($useempty) $out .=
'<option value="0"> </option>';
7928 while ($obj = $db->fetch_object(
$resql))
7930 $out .=
'<option '.($selected == $obj->rowid ?
'selected="selected"' :
'').
' value="'.$obj->rowid.
'">'.$langs->trans($obj->label).
'</option>';
7932 $out .=
'</select>';
7935 if (!empty($htmlname) && $user->admin && $info_admin) $out .=
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
7937 if (!empty($target))
7939 $sql =
"SELECT c.id FROM ".MAIN_DB_PREFIX.
"c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1";
7940 $resql = $db->query($sql);
7943 if ($db->num_rows(
$resql) > 0)
7945 $obj = $db->fetch_object(
$resql);
7948 $("select[name='.$target.
']").on("change", function() {
7949 var current_val = $(this).val();
7950 if (current_val == '.$obj->id.
') {';
7951 if (!empty($default_selected) || !empty($selected)) $out .=
'$("select[name='.$htmlname.
']").val("'.($default_selected > 0 ? $default_selected : $selected).
'");';
7954 $("select[name='.$htmlname.
']").change();
7958 $("select[name='.$htmlname.
']").change(function() {
7960 if ($("select[name='.$target.
']").val() == '.$obj->id.
') {
7961 // get price of kilometer to fill the unit price
7962 var data = '.json_encode($params).
';
7963 data.fk_c_exp_tax_cat = $(this).val();
7969 url: "'.(DOL_URL_ROOT.
'/expensereport/ajax/ajaxik.php').
'",
7970 }).done(function( data, textStatus, jqXHR ) {
7972 if (typeof data.up != "undefined") {
7973 $("input[name=value_unit]").val(data.up);
7974 $("select[name='.$htmlname.
']").attr("title", data.title);
7976 $("input[name=value_unit]").val("");
7977 $("select[name='.$htmlname.
']").attr("title", "");
8004 global $db, $conf, $langs;
8007 $sql =
'SELECT rowid, range_ik FROM '.MAIN_DB_PREFIX.
'c_exp_tax_range';
8008 $sql .=
' WHERE entity = '.$conf->entity.
' AND active = 1';
8010 $resql = $db->query($sql);
8013 $out =
'<select id="select_'.$htmlname.
'" name="'.$htmlname.
'" class="'.$htmlname.
' flat minwidth75imp">';
8014 if ($useempty) $out .=
'<option value="0"></option>';
8016 while ($obj = $db->fetch_object(
$resql))
8018 $out .=
'<option '.($selected == $obj->rowid ?
'selected="selected"' :
'').
' value="'.$obj->rowid.
'">'.
price($obj->range_ik, 0, $langs, 1, 0).
'</option>';
8020 $out .=
'</select>';
8038 public function selectExpense($selected =
'', $htmlname =
'fk_c_type_fees', $useempty = 0, $allchoice = 1, $useid = 0)
8043 $sql =
'SELECT id, code, label FROM '.MAIN_DB_PREFIX.
'c_type_fees';
8044 $sql .=
' WHERE active = 1';
8046 $resql = $db->query($sql);
8049 $out =
'<select id="select_'.$htmlname.
'" name="'.$htmlname.
'" class="'.$htmlname.
' flat minwidth75imp">';
8050 if ($useempty) $out .=
'<option value="0"></option>';
8051 if ($allchoice) $out .=
'<option value="-1">'.$langs->trans(
'AllExpenseReport').
'</option>';
8054 if ($useid) $field =
'id';
8056 while ($obj = $db->fetch_object(
$resql))
8058 $key = $langs->trans($obj->code);
8059 $out .=
'<option '.($selected == $obj->{$field} ?
'selected="selected"' :
'').
' value="'.$obj->{$field}.
'">'.($key != $obj->code ? $key : $obj->label).
'</option>';
8061 $out .=
'</select>';
8087 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)
8089 global $user, $conf, $langs;
8091 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
8093 if (is_null($usertofilter))
8095 $usertofilter = $user;
8100 $hideunselectables =
false;
8101 if (!empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables =
true;
8103 if (empty($projectsListId))
8105 if (empty($usertofilter->rights->projet->all->lire))
8107 $projectstatic =
new Project($this->
db);
8108 $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter, 0, 1);
8113 $sql =
'SELECT f.rowid, f.ref as fref, "nolabel" as flabel, p.rowid as pid, f.ref,
8114 p.title, p.fk_soc, p.fk_statut, p.public,';
8115 $sql .=
' s.nom as name';
8116 $sql .=
' FROM '.MAIN_DB_PREFIX.
'projet as p';
8117 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe as s ON s.rowid = p.fk_soc,';
8118 $sql .=
' '.MAIN_DB_PREFIX.
'facture as f';
8119 $sql .=
" WHERE p.entity IN (".getEntity(
'project').
")";
8120 $sql .=
" AND f.fk_projet = p.rowid AND f.fk_statut=0";
8124 $sql .=
" GROUP BY f.ref ORDER BY p.ref, f.ref ASC";
8130 if (!empty($conf->use_javascript_ajax))
8132 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
8133 $comboenhancement =
ajax_combobox($htmlname,
'', 0, $forcefocus);
8134 $out .= $comboenhancement;
8135 $morecss =
'minwidth200imp maxwidth500';
8138 if (empty($option_only)) {
8139 $out .=
'<select class="valignmiddle flat'.($morecss ?
' '.$morecss :
'').
'"'.($disabled ?
' disabled="disabled"' :
'').
' id="'.$htmlname.
'" name="'.$htmlname.
'">';
8141 if (!empty($show_empty)) {
8142 $out .=
'<option value="0" class="optiongrey">';
8143 if (!is_numeric($show_empty)) $out .= $show_empty;
8144 else $out .=
' ';
8145 $out .=
'</option>';
8147 $num = $this->
db->num_rows(
$resql);
8153 $obj = $this->
db->fetch_object(
$resql);
8155 if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($usertofilter->rights->societe->lire))
8167 if ($showproject ==
'all')
8169 $labeltoshow .=
dol_trunc($obj->ref, 18);
8170 if ($obj->name) $labeltoshow .=
' - '.$obj->name;
8176 $labeltoshow .=
' - '.$langs->trans(
"Draft");
8179 if ($discard_closed == 2) $disabled = 1;
8180 $labeltoshow .=
' - '.$langs->trans(
"Closed");
8181 } elseif ($socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid))
8184 $labeltoshow .=
' - '.$langs->trans(
"LinkedToAnotherCompany");
8188 if (!empty($selected) && $selected == $obj->rowid)
8190 $out .=
'<option value="'.$obj->rowid.
'" selected';
8192 $out .=
'>'.$labeltoshow.
'</option>';
8194 if ($hideunselectables && $disabled && ($selected != $obj->rowid))
8198 $resultat =
'<option value="'.$obj->rowid.
'"';
8199 if ($disabled) $resultat .=
' disabled';
8203 $resultat .= $labeltoshow;
8204 $resultat .=
'</option>';
8212 if (empty($option_only)) {
8213 $out .=
'</select>';
8234 public function searchComponent($arrayofcriterias, $search_component_params, $arrayofinputfieldsalreadyoutput = array())
8240 $ret .=
'<div class="nowrap centpercent">';
8242 $ret .=
'<a href="#" class="dropdownsearch-toggle unsetcolor paddingright">';
8243 $ret .=
'<span class="fas fa-filter linkobject boxfilter" title="Filter" id="idsubimgproductdistribution"></span>';
8244 $ret .= $langs->trans(
"Filters");
8247 $ret .=
'<div name="search_component_params" class="search_component_params inline-block minwidth500 maxwidth300onsmartphone valignmiddle">';
8248 $texttoshow =
'<div class="opacitymedium inline-block search_component_searchtext">'.$langs->trans(
"Search").
'</div>';
8250 $ret .=
'<div class="search_component inline-block valignmiddle">'.$texttoshow.
'</div>';
8252 $ret .=
'<input type="hidden" name="search_component_params_hidden" class="search_component_params_hidden" value="'.GETPOST(
"search_component_params_hidden").
'">';
8254 foreach ($arrayofcriterias as $criterias) {
8255 foreach ($criterias as $criteriafamilykey => $criteriafamilyval) {
8256 if (in_array(
'search_'.$criteriafamilykey, $arrayofinputfieldsalreadyoutput))
continue;
8257 if (in_array($criteriafamilykey, array(
'rowid',
'ref_ext',
'entity',
'extraparams')))
continue;
8258 if (in_array($criteriafamilyval[
'type'], array(
'date',
'datetime',
'timestamp'))) {
8259 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_start">';
8260 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_startyear">';
8261 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_startmonth">';
8262 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_startday">';
8263 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_end">';
8264 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_endyear">';
8265 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_endmonth">';
8266 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'_endday">';
8268 $ret .=
'<input type="hidden" name="search_'.$criteriafamilykey.
'">';
8289 global $langs, $db, $user;
8295 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
8297 $result = $formmail->fetchAllEMailTemplate($modelType, $user, $langs);
8299 if ($default) $TModels[0] = $langs->trans(
'DefaultMailModel');
8301 foreach ($formmail->lines_model as $model) {
8302 $TModels[$model->id] = $model->label;
8306 $retstring .=
'<select class="flat" id="select_'.$prefix.
'model_mail" name="'.$prefix.
'model_mail">';
8308 foreach ($TModels as $id_model=>$label_model) {
8309 $retstring .=
'<option value="'.$id_model.
'"';
8310 $retstring .=
">".$label_model.
"</option>";
8313 $retstring .=
"</select>";
8315 if ($addjscombo) $retstring .=
ajax_combobox(
'select_'.$prefix.
'model_mail');
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
ajax_autocompleter($selected, $htmlname, $url, $urloption= '', $minLength=2, $autoselect=0, $ajaxoptions=array(), $moreparams= '')
Generic function that return javascript to add to a page to transform a common input field into an au...
const STATUS_CLOSED
Warehouse closed, inactive.
Class to parse product price expressions.
const STATUS_OPEN_ALL
Warehouse open and operations for customer shipping, supplier dispatch, internal stock transfers/corr...
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
Class to manage products or services.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_now($mode= 'auto')
Return date for now.
if(!empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) testSqlAndScriptInject($val, $type)
Security: WAF layer for SQL Injection and XSS Injection (scripts) protection (Filters on GET...
Class to manage Dolibarr users.
dol_htmlentities($string, $flags=null, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
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_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
const TYPE_SERVICE
Service.
const TYPE_PRODUCT
Regular product.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
$conf db name
Only used if Module[ID]Name translation string is not found.
const STATUS_CLOSED
Closed status.
$conf db
API class for accounts.
Class to manage bank accounts.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
select2arrayoflanguage
Set array used for select2 translations.
currency_name($code_iso, $withcode= '', $outputlangs=null)
Return label of currency or code+label.
getImageFileNameForSize($file, $extName, $extImgTarget= '')
Return the filename of file to get the thumbs.
const STATUS_OPEN_INTERNAL
Warehouse open and operations for stock transfers/corrections allowed (not for customer shipping and ...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea'), $cleanalsosomestyles=0)
Clean a string from some undesirable HTML tags.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to manage categories.
getServerTimeZoneInt($refgmtdate= 'now')
Return server timezone int.
Class to manage projects.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput= 'no')
Output a dimension with best unit.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
dol_string_unaccent($str)
Clean a string from all accent characters to be used as ref, login or by dol_sanitizeFileName.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0)
Clean a string to keep only desirable HTML tags.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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) Si ...
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Class to manage a WYSIWYG editor.
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.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param= '')
Return URL we can use for advanced preview links.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
picto_from_langcode($codelang, $moreatt= '')
Return img flag of country for a language code or country code.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
Class to manage predefined suppliers products.
measuringUnitString($unit, $measuring_style= '', $scale= '', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...