28 require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
70 public function inputType($type, $name, $value =
'', $id =
'', $morecss =
'', $moreparam =
'', $label =
'', $addInputLabel =
'')
74 $out .=
'<label for="' . $id .
'">';
76 $out .=
'<input type="' . $type .
'"';
77 $out .= ($morecss ?
' class="' . $morecss .
'"' :
'');
79 $out .=
' id="' . $id .
'"';
81 $out .=
' name="' . $name .
'"';
82 $out .=
' value="' . $value .
'"';
83 $out .= ($moreparam ?
' ' . $moreparam :
'');
84 $out .=
' />' . $addInputLabel;
86 $out .= $label .
'</label>';
103 public function inputDate($name, $value =
'', $placeholder =
'', $id =
'', $morecss =
'', $moreparam =
'')
108 if ($placeholder !=
'' && $value ==
'') {
110 $out .=
' type="text" placeholder="' . $placeholder .
'" onfocus="(this.type=\'date\')"';
112 $out .=
' type="date"';
114 $out .= ($morecss ?
' class="' . $morecss .
'"' :
'');
116 $out .=
' id="' . $id .
'"';
118 $out .=
' name="' . $name .
'"';
119 $out .=
' value="' . $value .
'"';
120 $out .= ($moreparam ?
' ' . $moreparam :
'');
149 public static function selectarray($htmlname, $array, $id =
'', $show_empty = 0, $key_in_label = 0, $value_as_key = 0, $moreparam =
'', $translate = 0, $maxlen = 0, $disabled = 0, $sort =
'', $morecss =
'minwidth75', $addjscombo = 1, $moreparamonempty =
'', $disablebademail = 0, $nohtmlescape = 0)
154 $array = array_combine($array, $array);
159 $idname = str_replace(array(
'[',
']'), array(
'',
''), $htmlname);
160 $out .=
'<select id="' . preg_replace(
'/^\./',
'', $idname) .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' class="' . ($morecss ?
' ' . $morecss :
'') .
'"';
161 $out .=
' name="' . preg_replace(
'/^\./',
'', $htmlname) .
'"' . ($moreparam ?
' ' . $moreparam :
'');
166 if (!is_numeric($show_empty)) {
167 $textforempty = $show_empty;
169 $out .=
'<option value="' . ($show_empty < 0 ? $show_empty : -1) .
'"' . ($id == $show_empty ?
' selected' :
'') .
'>' . $textforempty .
'</option>' .
"\n";
172 if (is_array($array)) {
175 foreach ($array as $key => $value) {
176 if (!is_array($value)) {
177 $array[$key] = $langs->trans($value);
179 $array[$key][
'label'] = $langs->trans($value[
'label']);
185 if ($sort ==
'ASC') {
187 } elseif ($sort ==
'DESC') {
191 foreach ($array as $key => $tmpvalue) {
192 if (is_array($tmpvalue)) {
193 $value = $tmpvalue[
'label'];
194 $disabled = empty($tmpvalue[
'disabled']) ?
'' :
' disabled';
204 if ($value ==
'' || $value ==
'-') {
205 $selectOptionValue =
' ';
209 $out .=
'<option value="' . $key .
'"';
212 if (in_array($key, $id) && !$disabled) {
217 if ($id !=
'' && ($id == $key || ($id ==
'ifone' && count($array) == 1)) && !$disabled) {
221 if (is_array($tmpvalue)) {
222 foreach ($tmpvalue as $keyforvalue => $valueforvalue) {
223 if (preg_match(
'/^data-/', $keyforvalue)) {
229 $out .= $selectOptionValue;
230 $out .=
"</option>\n";
252 public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter =
'', $morecss =
'', $allfiles = 0)
254 include_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
263 $this->infofiles = array(
'nboffiles' => 0,
'extensions' => array(),
'files' => array());
270 preg_match(
'/\/([0-9]+)\/[^\/]+\/' . preg_quote($modulesubdir,
'/') .
'$/', $filedir, $regs);
271 $entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1);
276 $filterforfilesearch =
'^' . preg_quote(basename($modulesubdir),
'/');
278 $filterforfilesearch =
'^' . preg_quote(basename($modulesubdir),
'/') .
'\.';
280 $file_list =
dol_dir_list($filedir,
'files', 0, $filterforfilesearch,
'\.meta$|\.png$');
284 $out .=
'<!-- html.formwebportal::getDocumentsLink -->' .
"\n";
285 if (!empty($file_list)) {
291 foreach ($file_list as $file) {
293 if ($filter && !preg_match(
'/' . $filter .
'/i', $file[
"name"])) {
299 $relativepath = $file[
"name"];
301 $relativepath = $modulesubdir .
"/" . $file[
"name"];
304 if ($modulepart ==
'donation') {
305 $relativepath =
get_exdir($modulesubdir, 2, 0, 0,
null,
'donation') . $file[
"name"];
307 if ($modulepart ==
'export') {
308 $relativepath = $file[
"name"];
311 $this->infofiles[
'nboffiles']++;
312 $this->infofiles[
'files'][] = $file[
'fullname'];
313 $ext = pathinfo($file[
"name"], PATHINFO_EXTENSION);
314 if (empty($this->infofiles[$ext])) {
315 $this->infofiles[
'extensions'][$ext] = 1;
317 $this->infofiles[
'extensions'][$ext]++;
321 $url = $context->getControllerUrl(
'document') .
'&modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($relativepath) .
'&soc_id=' . $context->logged_thirdparty->id;
322 $tmpout .=
'<a href="' . $url .
'"' . ($morecss ?
' class="' . $morecss .
'"' :
'') .
' role="downloadlink"';
324 if (preg_match(
'/text/', $mime)) {
325 $tmpout .=
' target="_blank" rel="noopener noreferrer"';
328 $tmpout .=
img_mime($relativepath, $file[
"name"]);
329 $tmpout .= strtoupper($ext);
361 public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty =
'', $searchkey =
'', $placeholder =
'', $morecss =
'', $moreparams =
'', $forcecombo = 0, $disabled = 0, $selected_input_value =
'', $objectfield =
'')
371 $InfoFieldList = explode(
":", $objectdesc, 4);
372 $vartmp = (empty($InfoFieldList[3]) ?
'' : $InfoFieldList[3]);
374 if (preg_match(
'/^.*:(\w*)$/', $vartmp, $reg)) {
375 $InfoFieldList[4] = $reg[1];
377 $InfoFieldList[3] = preg_replace(
'/:\w*$/',
'', $vartmp);
379 $classname = $InfoFieldList[0];
380 $classpath = $InfoFieldList[1];
381 $filter = empty($InfoFieldList[3]) ?
'' : $InfoFieldList[3];
382 $sortfield = empty($InfoFieldList[4]) ?
'' : $InfoFieldList[4];
384 if (!empty($classpath)) {
387 if ($classname && class_exists($classname)) {
388 $objecttmp =
new $classname($this->db);
391 $sharedentities =
getEntity(strtolower($classname));
392 $filter = str_replace(
393 array(
'__ENTITY__',
'__SHARED_ENTITIES__'),
394 array($conf->entity, $sharedentities),
399 if (!is_object($objecttmp)) {
400 dol_syslog(
'Error bad setup of type for field ' . implode(
',', $InfoFieldList), LOG_WARNING);
401 return 'Error bad setup of type for field ' . implode(
',', $InfoFieldList);
404 dol_syslog(__METHOD__ .
' filter=' . $filter, LOG_DEBUG);
407 $out .= $this->
selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled, $sortfield, $filter);
432 public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty =
'', $searchkey =
'', $placeholder =
'', $morecss =
'', $moreparams =
'', $forcecombo = 0, $outputmode = 0, $disabled = 0, $sortfield =
'', $filter =
'')
434 global $conf, $langs, $hookmanager;
436 $prefixforautocompletemode = $objecttmp->element;
437 if ($prefixforautocompletemode ==
'societe') {
438 $prefixforautocompletemode =
'company';
440 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) .
'_USE_SEARCH_TO_SELECT';
442 if (in_array($objecttmp->element, array(
'adherent_type'))) {
443 $fieldstoshow =
't.libelle';
445 if (!empty($objecttmp->fields)) {
446 $tmpfieldstoshow =
'';
447 foreach ($objecttmp->fields as $key => $val) {
448 if (! (
int)
dol_eval($val[
'enabled'], 1, 1,
'1')) {
451 if (!empty($val[
'showoncombobox'])) {
452 $tmpfieldstoshow .= ($tmpfieldstoshow ?
',' :
'') .
't.' . $key;
455 if ($tmpfieldstoshow) {
456 $fieldstoshow = $tmpfieldstoshow;
458 } elseif (!in_array($objecttmp->element, array(
'adherent_type'))) {
460 $objecttmp->fields[
'ref'] = array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'showoncombobox' => 1);
463 if (empty($fieldstoshow)) {
464 if (isset($objecttmp->fields[
'ref'])) {
465 $fieldstoshow =
't.ref';
467 $langs->load(
"errors");
468 $this->error = $langs->trans(
"ErrorNoFieldWithAttributeShowoncombobox");
469 return $langs->trans(
'ErrorNoFieldWithAttributeShowoncombobox');
480 $sql =
"SELECT t.rowid, " . $fieldstoshow .
" FROM " . $this->db->prefix() . $objecttmp->table_element .
" as t";
481 if (isset($objecttmp->ismultientitymanaged)) {
482 if (!is_numeric($objecttmp->ismultientitymanaged)) {
483 $tmparray = explode(
'@', $objecttmp->ismultientitymanaged);
484 $sql .=
" INNER JOIN " . $this->db->prefix() . $tmparray[1] .
" as parenttable ON parenttable.rowid = t." . $tmparray[0];
490 'object' => $objecttmp,
491 'htmlname' => $htmlname,
493 'searchkey' => $searchkey
496 $reshook = $hookmanager->executeHooks(
'selectForFormsListWhere', $parameters);
497 if (!empty($hookmanager->resPrint)) {
498 $sql .= $hookmanager->resPrint;
500 $sql .=
" WHERE 1=1";
501 if (isset($objecttmp->ismultientitymanaged)) {
502 if ($objecttmp->ismultientitymanaged == 1) {
503 $sql .=
" AND t.entity IN (" .
getEntity($objecttmp->table_element) .
")";
505 if (!is_numeric($objecttmp->ismultientitymanaged)) {
506 $sql .=
" AND parenttable.entity = t." . $tmparray[0];
509 if ($searchkey !=
'') {
517 return 'Error forging a SQL request from an universal criteria: ' . $errormessage;
521 $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow,
"ASC");
524 $resql = $this->db->query(
$sql);
527 $out .=
'<select id="' . $htmlname .
'" class="' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') . ($moreparams ?
' ' . $moreparams :
'') .
' name="' . $htmlname .
'">' .
"\n";
530 $textifempty =
' ';
533 if (!empty($conf->global->$confkeyforautocompletemode)) {
534 if ($showempty && !is_numeric($showempty)) {
535 $textifempty = $langs->trans($showempty);
537 $textifempty .= $langs->trans(
"All");
541 $out .=
'<option value="-1">' . $textifempty .
'</option>' .
"\n";
544 $num = $this->db->num_rows($resql);
548 $obj = $this->db->fetch_object($resql);
551 $tmparray = explode(
',', $fieldstoshow);
552 $oldvalueforshowoncombobox = 0;
553 foreach ($tmparray as $key => $val) {
554 $val = preg_replace(
'/t\./',
'', $val);
555 $label .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val][
'showoncombobox'] ?
' - ' :
' ') :
'');
556 $labelhtml .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val][
'showoncombobox'] ?
' - ' :
' ') :
'');
557 $label .= $obj->$val;
558 $labelhtml .= $obj->$val;
560 $oldvalueforshowoncombobox = empty($objecttmp->fields[$val][
'showoncombobox']) ? 0 : $objecttmp->fields[$val][
'showoncombobox'];
562 if (empty($outputmode)) {
563 if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
564 $out .=
'<option value="' . $obj->rowid .
'" selected data-html="' .
dol_escape_htmltag($labelhtml, 0, 0,
'', 0, 1) .
'">' .
dol_escape_htmltag($label, 0, 0,
'', 0, 1) .
'</option>';
566 $out .=
'<option value="' . $obj->rowid .
'" data-html="' .
dol_escape_htmltag($labelhtml, 0, 0,
'', 0, 1) .
'">' .
dol_escape_htmltag($label, 0, 0,
'', 0, 1) .
'</option>';
569 array_push($outarray, array(
'key' => $obj->rowid,
'value' => $label,
'label' => $label));
573 if (($i % 10) == 0) {
579 $out .=
'</select>' .
"\n";
584 $this->result = array(
'nbofelement' => $num);
606 public function showInputField($val, $key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'')
608 global $conf, $langs;
613 $size = !empty($val[
'size']) ? $val[
'size'] : 0;
615 if (preg_match(
'/^(integer|link):(.*):(.*):(.*):(.*)/i', $val[
'type'], $reg)) {
616 $param[
'options'] = array($reg[2] .
':' . $reg[3] .
':' . $reg[4] .
':' . $reg[5] =>
'N');
618 } elseif (preg_match(
'/^(integer|link):(.*):(.*):(.*)/i', $val[
'type'], $reg)) {
619 $param[
'options'] = array($reg[2] .
':' . $reg[3] .
':' . $reg[4] =>
'N');
621 } elseif (preg_match(
'/^(integer|link):(.*):(.*)/i', $val[
'type'], $reg)) {
622 $param[
'options'] = array($reg[2] .
':' . $reg[3] =>
'N');
624 } elseif (preg_match(
'/^(sellist):(.*):(.*):(.*):(.*)/i', $val[
'type'], $reg)) {
625 $param[
'options'] = array($reg[2] .
':' . $reg[3] .
':' . $reg[4] .
':' . $reg[5] =>
'N');
627 } elseif (preg_match(
'/^(sellist):(.*):(.*):(.*)/i', $val[
'type'], $reg)) {
628 $param[
'options'] = array($reg[2] .
':' . $reg[3] .
':' . $reg[4] =>
'N');
630 } elseif (preg_match(
'/^(sellist):(.*):(.*)/i', $val[
'type'], $reg)) {
631 $param[
'options'] = array($reg[2] .
':' . $reg[3] =>
'N');
633 } elseif (preg_match(
'/^varchar\((\d+)\)/', $val[
'type'], $reg)) {
634 $param[
'options'] = array();
637 } elseif (preg_match(
'/^varchar/', $val[
'type'])) {
638 $param[
'options'] = array();
640 } elseif (preg_match(
'/^double(\([0-9],[0-9]\)){0,1}/', $val[
'type'])) {
641 $param[
'options'] = array();
644 $param[
'options'] = array();
645 $type = $val[
'type'];
649 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
650 $param[
'options'] = $val[
'arrayofkeyval'];
651 $type = $val[
'type'] ==
'checkbox' ?
'checkbox' :
'select';
655 $default = (!empty($val[
'default']) ? $val[
'default'] :
'');
656 $computed = (!empty($val[
'computed']) ? $val[
'computed'] :
'');
658 $required = (!empty($val[
'required']) ? $val[
'required'] : 0);
659 $notNull = (!empty($val[
'notnull']) ? $val[
'notnull'] : 0);
663 $hidden = (in_array(abs($val[
'visible']), array(0, 2)) ? 1 : 0);
668 if (!preg_match(
'/^search_/', $keyprefix)) {
669 return '<span>' . $langs->trans(
"AutomaticallyCalculated") .
'</span>';
676 if (empty($morecss) && !empty($val[
'css'])) {
677 $morecss = $val[
'css'];
680 $htmlName = $keyprefix . $key . $keysuffix;
689 $dateArr = explode(
' ', $value);
690 if (count($dateArr) > 0) {
691 $valueDate = $dateArr[0];
692 if (isset($dateArr[1])) {
693 $valueTime = $dateArr[1];
696 $out = $this->
inputDate($htmlName, $valueDate,
'', $htmlId, $morecss, $moreparam);
698 if ($type ==
'datetime') {
700 $out .=
' ' . $this->
inputType(
'time', $htmlName.
'_time', $valueTime, $htmlId, $morecss, $moreparam);
710 $moreparam .= ($size > 0 ?
' maxlength="' . $size .
'"' :
'');
727 if (!empty($value)) {
728 $value =
price($value);
730 $addInputLabel =
' ' . $langs->getCurrencySymbol($conf->currency);
731 $out = $this->
inputType(
'text', $htmlName, $value, $htmlId, $morecss, $moreparam,
'', $addInputLabel);
735 if (!empty($value)) {
736 $value =
price($value);
738 $out = $this->
inputType(
'text', $htmlName, $value, $htmlId, $morecss, $moreparam);
742 $out = $this->
inputType(
'password', $htmlName, $value, $htmlId, $morecss, $moreparam);
746 foreach ($param[
'options'] as $keyopt => $valopt) {
747 $htmlId = $htmlName .
'_' . $keyopt;
748 $htmlMoreParam = $moreparam . ($value == $keyopt ?
' checked' :
'');
749 $out .= $this->
inputType(
'radio', $htmlName, $keyopt, $htmlId, $morecss, $htmlMoreParam, $valopt) .
'<br>';
754 $out =
'<select class="' . $morecss .
'" name="' . $htmlName .
'" id="' . $htmlId .
'"' . ($moreparam ?
' ' . $moreparam :
'') .
' >';
755 if ($default ==
'' || $notNull != 1) {
756 $out .=
'<option value="0"> </option>';
758 foreach ($param[
'options'] as $keyb => $valb) {
762 if (strpos($valb,
"|") !==
false) {
763 list($valb, $parent) = explode(
'|', $valb);
765 $out .=
'<option value="' . $keyb .
'"';
766 $out .= (((string) $value == $keyb) ?
' selected' :
'');
767 $out .= (!empty($parent) ?
' parent="' . $parent .
'"' :
'');
768 $out .=
'>' . $valb .
'</option>';
773 $out =
'<select class="' . $morecss .
'" name="' . $htmlName .
'" id="' . $htmlId .
'"' . ($moreparam ?
' ' . $moreparam :
'') .
'>';
775 $param_list = array_keys($param[
'options']);
776 $InfoFieldList = explode(
":", $param_list[0]);
786 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2] .
' as rowid');
788 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
789 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
790 $keyList =
'main.' . $InfoFieldList[2] .
' as rowid';
792 $keyList = $InfoFieldList[2] .
' as rowid';
795 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
796 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
797 $keyList .=
', ' . $parentField;
800 $filter_categorie =
false;
801 if (count($InfoFieldList) > 5) {
802 if ($InfoFieldList[0] ==
'categorie') {
803 $filter_categorie =
true;
807 if ($filter_categorie ===
false) {
808 $fields_label = explode(
'|', $InfoFieldList[1]);
809 if (is_array($fields_label)) {
811 $keyList .= implode(
', ', $fields_label);
815 $sql =
"SELECT " . $keyList;
816 $sql .=
" FROM " . $this->db->prefix() . $InfoFieldList[0];
817 if (!empty($InfoFieldList[4])) {
819 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
820 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
824 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
827 if (strpos($InfoFieldList[4],
'extra') !==
false) {
828 $sql .=
" as main, " . $this->db->prefix() . $InfoFieldList[0] .
"_extrafields as extra";
829 $sqlwhere .=
" WHERE extra.fk_object=main." . $InfoFieldList[2] .
" AND " . $InfoFieldList[4];
831 $sqlwhere .=
" WHERE " . $InfoFieldList[4];
834 $sqlwhere .=
' WHERE 1=1';
837 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
838 $sqlwhere .=
" AND entity = " . ((int) $conf->entity);
843 $sql .=
' ORDER BY ' . implode(
', ', $fields_label);
845 dol_syslog(get_class($this) .
'::showInputField type=sellist', LOG_DEBUG);
846 $resql = $this->db->query(
$sql);
848 $out .=
'<option value="0"> </option>';
849 $num = $this->db->num_rows($resql);
853 $obj = $this->db->fetch_object($resql);
857 $fields_label = explode(
'|', $InfoFieldList[1]);
858 if (count($fields_label) > 1) {
860 foreach ($fields_label as $field_toshow) {
861 $labeltoshow .= $obj->$field_toshow .
' ';
864 $labeltoshow = $obj->{$InfoFieldList[1]};
866 $labeltoshow =
dol_trunc($labeltoshow, 45);
868 if ($value == $obj->rowid) {
869 foreach ($fields_label as $field_toshow) {
870 $translabel = $langs->trans($obj->$field_toshow);
871 if ($translabel != $obj->$field_toshow) {
872 $labeltoshow =
dol_trunc($translabel) .
' ';
874 $labeltoshow =
dol_trunc($obj->$field_toshow) .
' ';
877 $out .=
'<option value="' . $obj->rowid .
'" selected>' . $labeltoshow .
'</option>';
880 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
881 if ($translabel != $obj->{$InfoFieldList[1]}) {
882 $labeltoshow =
dol_trunc($translabel, 18);
884 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]});
887 if (empty($labeltoshow)) {
888 $labeltoshow =
'(not defined)';
890 if ($value == $obj->rowid) {
891 $out .=
'<option value="' . $obj->rowid .
'" selected>' . $labeltoshow .
'</option>';
894 if (!empty($InfoFieldList[3]) && $parentField) {
895 $parent = $parentName .
':' . $obj->{$parentField};
899 $out .=
'<option value="' . $obj->rowid .
'"';
900 $out .= ($value == $obj->rowid ?
' selected' :
'');
901 $out .= (!empty($parent) ?
' parent="' . $parent .
'"' :
'');
902 $out .=
'>' . $labeltoshow .
'</option>';
907 $this->db->free($resql);
909 $out .=
'Error in request ' .
$sql .
' ' . $this->db->lasterror() .
'. Check setup of extra parameters.<br>';
912 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
913 $data = $this->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]],
'',
'parent', 64, $InfoFieldList[6], 1, 1);
914 $out .=
'<option value="0"> </option>';
915 foreach ($data as $data_key => $data_value) {
916 $out .=
'<option value="' . $data_key .
'"';
917 $out .= ($value == $data_key ?
' selected' :
'');
918 $out .=
'>' . $data_value .
'</option>';
925 $param_list = array_keys($param[
'options']);
926 $showempty = (($required && $default !=
'') ? 0 : 1);
928 $out = $this->selectForForms($param_list[0], $htmlName, $value, $showempty,
'',
'', $morecss, $moreparam, 0, empty($val[
'disabled']) ? 0 : 1);
933 if (!empty($hidden)) {
934 $out = $this->inputType(
'hidden', $htmlName, $value, $htmlId);
957 global $conf, $langs;
959 $label = empty($val[
'label']) ?
'' : $val[
'label'];
960 $type = empty($val[
'type']) ?
'' : $val[
'type'];
961 $css = empty($val[
'css']) ?
'' : $val[
'css'];
962 $picto = empty($val[
'picto']) ?
'' : $val[
'picto'];
966 if (preg_match(
'/varchar\((\d+)\)/', $type, $reg)) {
969 } elseif (preg_match(
'/varchar/', $type)) {
972 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
973 $type = $val[
'type'] ==
'checkbox' ?
'checkbox' :
'select';
975 if (preg_match(
'/^integer:(.*):(.*)/i', $val[
'type'], $reg)) {
979 $default = empty($val[
'default']) ?
'' : $val[
'default'];
980 $computed = empty($val[
'computed']) ?
'' : $val[
'computed'];
981 $unique = empty($val[
'unique']) ?
'' : $val[
'unique'];
982 $required = empty($val[
'required']) ?
'' : $val[
'required'];
984 $param[
'options'] = array();
986 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
987 $param[
'options'] = $val[
'arrayofkeyval'];
989 if (preg_match(
'/^integer:(.*):(.*)/i', $val[
'type'], $reg)) {
991 $stringforoptions = $reg[1] .
':' . $reg[2];
992 if ($reg[1] ==
'User') {
993 $stringforoptions .=
':-1';
995 $param[
'options'] = array($stringforoptions => $stringforoptions);
996 } elseif (preg_match(
'/^sellist:(.*):(.*):(.*):(.*)/i', $val[
'type'], $reg)) {
997 $param[
'options'] = array($reg[1] .
':' . $reg[2] .
':' . $reg[3] .
':' . $reg[4] =>
'N');
999 } elseif (preg_match(
'/^sellist:(.*):(.*):(.*)/i', $val[
'type'], $reg)) {
1000 $param[
'options'] = array($reg[1] .
':' . $reg[2] .
':' . $reg[3] =>
'N');
1002 } elseif (preg_match(
'/^sellist:(.*):(.*)/i', $val[
'type'], $reg)) {
1003 $param[
'options'] = array($reg[1] .
':' . $reg[2] =>
'N');
1005 } elseif (preg_match(
'/^chkbxlst:(.*)/i', $val[
'type'], $reg)) {
1006 $param[
'options'] = array($reg[1] =>
'N');
1010 $langfile = empty($val[
'langfile']) ?
'' : $val[
'langfile'];
1011 $list = (empty($val[
'list']) ?
'' : $val[
'list']);
1012 $help = (empty($val[
'help']) ?
'' : $val[
'help']);
1013 $hidden = (($val[
'visible'] == 0) ? 1 : 0);
1023 $value = (string)
dol_eval($computed, 1, 0,
'2');
1030 if (in_array($key, array(
'rowid',
'ref'))) {
1031 if (property_exists(
$object,
'ref')) {
1033 } elseif (property_exists(
$object,
'id')) {
1038 } elseif ($key ==
'status' && method_exists(
$object,
'getLibStatut')) {
1039 $value =
$object->getLibStatut(3);
1043 } elseif (is_array($value)) {
1046 if ($type ==
'array') {
1047 $value = implode(
'<br>', $value);
1049 dol_syslog(__METHOD__ .
'ERROR unexpected type=$type for array value='.((
string) json_encode($value)), LOG_ERR);
1054 } elseif ($type ==
'date') {
1055 if (!empty($value)) {
1060 } elseif ($type ==
'datetime' || $type ==
'timestamp') {
1061 if (!empty($value)) {
1066 } elseif ($type ==
'duration') {
1067 include_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
1068 if (!is_null($value) && $value !==
'') {
1071 } elseif ($type ==
'double' || $type ==
'real') {
1072 if (!is_null($value) && $value !==
'') {
1073 $value =
price($value);
1075 } elseif ($type ==
'boolean') {
1077 if (!empty($value)) {
1078 $checked =
' checked ';
1080 $value =
'<input type="checkbox" ' . $checked .
' ' . ($moreparam ? $moreparam :
'') .
' readonly disabled>';
1081 } elseif ($type ==
'mail' || $type ==
'email') {
1083 } elseif ($type ==
'url') {
1085 } elseif ($type ==
'phone') {
1087 } elseif ($type ==
'ip') {
1089 } elseif ($type ==
'price') {
1090 if (!is_null($value) && $value !==
'') {
1091 $value =
price($value, 0, $langs, 0, 0, -1, $conf->currency);
1093 } elseif ($type ==
'select') {
1094 $value = isset($param[
'options'][$value]) ? $param[
'options'][$value] :
'';
1095 } elseif ($type ==
'sellist') {
1096 $param_list = array_keys($param[
'options']);
1097 $InfoFieldList = explode(
":", $param_list[0]);
1099 $selectkey =
"rowid";
1102 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1103 $selectkey = $InfoFieldList[2];
1104 $keyList = $InfoFieldList[2] .
' as rowid';
1107 $fields_label = explode(
'|', $InfoFieldList[1]);
1108 if (is_array($fields_label)) {
1110 $keyList .= implode(
', ', $fields_label);
1113 $filter_categorie =
false;
1114 if (count($InfoFieldList) > 5) {
1115 if ($InfoFieldList[0] ==
'categorie') {
1116 $filter_categorie =
true;
1120 $sql =
"SELECT " . $keyList;
1121 $sql .=
' FROM ' . $this->db->prefix() . $InfoFieldList[0];
1122 if (strpos($InfoFieldList[4],
'extra') !==
false) {
1125 if ($selectkey ==
'rowid' && empty($value)) {
1126 $sql .=
" WHERE " . $selectkey .
" = 0";
1127 } elseif ($selectkey ==
'rowid') {
1128 $sql .=
" WHERE " . $selectkey .
" = " . ((int) $value);
1130 $sql .=
" WHERE " . $selectkey .
" = '" . $this->db->escape($value) .
"'";
1133 dol_syslog(__METHOD__ .
' type=sellist', LOG_DEBUG);
1134 $resql = $this->db->query(
$sql);
1136 if ($filter_categorie ===
false) {
1138 $numrows = $this->db->num_rows($resql);
1140 $obj = $this->db->fetch_object($resql);
1143 $fields_label = explode(
'|', $InfoFieldList[1]);
1145 if (is_array($fields_label) && count($fields_label) > 1) {
1146 foreach ($fields_label as $field_toshow) {
1148 if (!empty($obj->$field_toshow)) {
1149 $translabel = $langs->trans($obj->$field_toshow);
1151 if ($translabel != $field_toshow) {
1152 $value .=
dol_trunc($translabel, 18) .
' ';
1154 $value .= $obj->$field_toshow .
' ';
1159 if (!empty($obj->{$InfoFieldList[1]})) {
1160 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1162 if ($translabel != $obj->{$InfoFieldList[1]}) {
1165 $value = $obj->{$InfoFieldList[1]};
1170 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1173 $obj = $this->db->fetch_object($resql);
1175 $c->fetch($obj->rowid);
1176 $ways = $c->print_all_ways();
1177 foreach ($ways as $way) {
1178 $toprint[] =
'<li>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
1180 $value =
'<div><ul>' . implode(
' ', $toprint) .
'</ul></div>';
1183 dol_syslog(__METHOD__ .
' error ' . $this->db->lasterror(), LOG_WARNING);
1185 } elseif ($type ==
'radio') {
1186 $value = $param[
'options'][$value];
1187 } elseif ($type ==
'checkbox') {
1188 $value_arr = explode(
',', $value);
1190 if (is_array($value_arr) && count($value_arr) > 0) {
1192 foreach ($value_arr as $valueval) {
1193 if (!empty($valueval)) {
1194 $toprint[] =
'<li>' . $param[
'options'][$valueval] .
'</li>';
1197 if (!empty($toprint)) {
1198 $value =
'<div><ul>' . implode(
' ', $toprint) .
'</ul></div>';
1201 } elseif ($type ==
'chkbxlst') {
1202 $value_arr = explode(
',', $value);
1204 $param_list = array_keys($param[
'options']);
1205 $InfoFieldList = explode(
":", $param_list[0]);
1207 $selectkey =
"rowid";
1210 if (count($InfoFieldList) >= 3) {
1211 $selectkey = $InfoFieldList[2];
1212 $keyList = $InfoFieldList[2] .
' as rowid';
1215 $fields_label = explode(
'|', $InfoFieldList[1]);
1216 if (is_array($fields_label)) {
1218 $keyList .= implode(
', ', $fields_label);
1221 $filter_categorie =
false;
1222 if (count($InfoFieldList) > 5) {
1223 if ($InfoFieldList[0] ==
'categorie') {
1224 $filter_categorie =
true;
1228 $sql =
"SELECT " . $keyList;
1229 $sql .=
' FROM ' . $this->db->prefix() . $InfoFieldList[0];
1230 if (strpos($InfoFieldList[4],
'extra') !==
false) {
1236 dol_syslog(__METHOD__ .
' type=chkbxlst', LOG_DEBUG);
1237 $resql = $this->db->query(
$sql);
1239 if ($filter_categorie ===
false) {
1242 while ($obj = $this->db->fetch_object($resql)) {
1244 $fields_label = explode(
'|', $InfoFieldList[1]);
1245 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1246 if (is_array($fields_label) && count($fields_label) > 1) {
1247 foreach ($fields_label as $field_toshow) {
1249 if (!empty($obj->$field_toshow)) {
1250 $translabel = $langs->trans($obj->$field_toshow);
1252 if ($translabel != $field_toshow) {
1253 $toprint[] =
'<li>' .
dol_trunc($translabel, 18) .
'</li>';
1255 $toprint[] =
'<li>' . $obj->$field_toshow .
'</li>';
1260 if (!empty($obj->{$InfoFieldList[1]})) {
1261 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1263 if ($translabel != $obj->{$InfoFieldList[1]}) {
1264 $toprint[] =
'<li>' .
dol_trunc($translabel, 18) .
'</li>';
1266 $toprint[] =
'<li>' . $obj->{$InfoFieldList[1]} .
'</li>';
1272 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1275 while ($obj = $this->db->fetch_object($resql)) {
1276 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1278 $c->fetch($obj->rowid);
1279 $ways = $c->print_all_ways();
1280 foreach ($ways as $way) {
1281 $toprint[] =
'<li>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
1286 $value =
'<div><ul>' . implode(
' ', $toprint) .
'</ul></div>';
1288 dol_syslog(__METHOD__ .
' error ' . $this->db->lasterror(), LOG_WARNING);
1290 } elseif ($type ==
'link') {
1293 $param_list = array_keys($param[
'options']);
1295 $InfoFieldList = explode(
":", $param_list[0]);
1296 $classname = $InfoFieldList[0];
1297 $classpath = $InfoFieldList[1];
1298 if (!empty($classpath)) {
1300 if ($classname && class_exists($classname)) {
1301 $object =
new $classname($this->db);
1302 $result =
$object->fetch($value);
1305 if (property_exists(
$object,
'label')) {
1307 } elseif (property_exists(
$object,
'libelle')) {
1309 } elseif (property_exists(
$object,
'nom')) {
1315 dol_syslog(__METHOD__ .
' Error bad setup of field', LOG_WARNING);
1316 return 'Error bad setup of field';
1321 } elseif ($type ==
'password') {
1322 $value = preg_replace(
'/./i',
'*', $value);
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage categories.
static getInstance()
Singleton method to create one instance of this object.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_print_ip($ip, $mode=0)
Return an IP formatted to be shown on screen.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_print_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='')
Show Url link.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0)
Format phone numbers according to country.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
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...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...