29require_once DOL_DOCUMENT_ROOT .
'/core/class/html.form.class.php';
71 public function inputType($type, $name, $value =
'',
$id =
'', $morecss =
'', $moreparam =
'', $label =
'', $addInputLabel =
'')
75 $out .=
'<label for="' .
$id .
'">';
77 $out .=
'<input type="' . $type .
'"';
78 $out .= ($morecss ?
' class="' . $morecss .
'"' :
'');
80 $out .=
' id="' .
$id .
'"';
82 $out .=
' name="' . $name .
'"';
83 $out .=
' value="' . $value .
'"';
84 $out .= ($moreparam ?
' ' . $moreparam :
'');
85 $out .=
' />' . $addInputLabel;
87 $out .= $label .
'</label>';
104 public function inputDate($name, $value =
'', $placeholder =
'',
$id =
'', $morecss =
'', $moreparam =
'')
129 $out = $this->
selectDate($value ===
'' ? -1 : $value, $name, 0, 0, 0,
"", 1, 0, 0,
'');
156 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)
161 $array = array_combine($array, $array);
166 $idname = str_replace(array(
'[',
']'), array(
'',
''), $htmlname);
167 $out .=
'<select id="' . preg_replace(
'/^\./',
'', $idname) .
'"' . ($disabled ?
' disabled="disabled"' :
'') .
' class="' . ($morecss ?
' ' . $morecss :
'') .
'"';
168 $out .=
' name="' . preg_replace(
'/^\./',
'', $htmlname) .
'"' . ($moreparam ?
' ' . $moreparam :
'');
173 if (!is_numeric($show_empty)) {
174 $textforempty = $show_empty;
176 $out .=
'<option value="' . ($show_empty < 0 ? $show_empty : -1) .
'"' . (
$id == $show_empty ?
' selected' :
'') .
'>' . $textforempty .
'</option>' .
"\n";
179 if (is_array($array)) {
182 foreach ($array as $key => $value) {
183 if (!is_array($value)) {
184 $array[$key] = $langs->trans($value);
186 $array[$key][
'label'] = $langs->trans($value[
'label']);
192 if ($sort ==
'ASC') {
194 } elseif ($sort ==
'DESC') {
198 foreach ($array as $key => $tmpvalue) {
199 if (is_array($tmpvalue)) {
200 $value = $tmpvalue[
'label'];
201 $disabled = empty($tmpvalue[
'disabled']) ?
'' :
' disabled';
211 if ($value ==
'' || $value ==
'-') {
212 $selectOptionValue =
' ';
216 $out .=
'<option value="' . $key .
'"';
219 if (in_array($key,
$id) && !$disabled) {
224 if (
$id !=
'' && (
$id == $key || (
$id ==
'ifone' && count($array) == 1)) && !$disabled) {
228 if (is_array($tmpvalue)) {
229 foreach ($tmpvalue as $keyforvalue => $valueforvalue) {
230 if (preg_match(
'/^data-/', $keyforvalue)) {
236 $out .= $selectOptionValue;
237 $out .=
"</option>\n";
259 public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter =
'', $morecss =
'', $allfiles = 0)
261 include_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
270 $this->infofiles = array(
'nboffiles' => 0,
'extensions' => array(),
'files' => array());
275 if (isModEnabled(
'multicompany')) {
277 preg_match(
'/\/([0-9]+)\/[^\/]+\/' . preg_quote($modulesubdir,
'/') .
'$/', $filedir, $regs);
278 $entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1);
283 $filterforfilesearch =
'^' . preg_quote(basename($modulesubdir),
'/');
285 $filterforfilesearch =
'^' . preg_quote(basename($modulesubdir),
'/') .
'\.';
287 $file_list =
dol_dir_list($filedir,
'files', 0, $filterforfilesearch,
'\.meta$|\.png$');
291 $out .=
'<!-- html.formwebportal::getDocumentsLink -->' .
"\n";
292 if (!empty($file_list)) {
298 foreach ($file_list as $file) {
300 if ($filter && !preg_match(
'/' . $filter .
'/i', $file[
"name"])) {
306 $relativepath = $file[
"name"];
308 $relativepath = $modulesubdir .
"/" . $file[
"name"];
311 if ($modulepart ==
'donation') {
312 $relativepath =
get_exdir($modulesubdir, 2, 0, 0,
null,
'donation') . $file[
"name"];
314 if ($modulepart ==
'export') {
315 $relativepath = $file[
"name"];
318 $this->infofiles[
'nboffiles']++;
319 $this->infofiles[
'files'][] = $file[
'fullname'];
320 $ext = pathinfo($file[
"name"], PATHINFO_EXTENSION);
321 if (empty($this->infofiles[
'extensions'][$ext])) {
322 $this->infofiles[
'extensions'][$ext] = 1;
325 $this->infofiles[
'extensions'][$ext]++;
329 $url =
$context->getControllerUrl(
'document') .
'&modulepart=' . $modulepart .
'&entity=' . $entity .
'&file=' . urlencode($relativepath) .
'&soc_id=' .
$context->logged_thirdparty->id;
330 $tmpout .=
'<a href="' . $url .
'"' . ($morecss ?
' class="' . $morecss .
'"' :
'') .
' role="downloadlink"';
332 if (preg_match(
'/text/', $mime)) {
333 $tmpout .=
' target="_blank" rel="noopener noreferrer"';
336 $tmpout .=
img_mime($relativepath, $file[
"name"]);
337 $tmpout .= strtoupper($ext);
362 require_once DOL_DOCUMENT_ROOT.
'/core/lib/signature.lib.php';
363 $out =
'<!-- html.formwebportal::getSignatureLink -->' .
"\n";
364 $url = getOnlineSignatureUrl(0, $modulepart,
$object->ref, 1,
$object);
366 $out .=
'<a target="_blank" rel="noopener noreferrer" href="' . $url .
'"' . ($morecss ?
' class="' . $morecss .
'"' :
'') .
' role="signaturelink">';
367 $out .=
'<i class="fa fa-file-signature"></i>';
368 $out .= $langs->trans(
"Sign");
394 public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty =
'', $searchkey =
'', $placeholder =
'', $morecss =
'', $moreparams =
'', $forcecombo = 0, $disabled = 0, $selected_input_value =
'', $objectfield =
'')
404 $InfoFieldList = explode(
":", $objectdesc, 4);
405 $vartmp = (empty($InfoFieldList[3]) ?
'' : $InfoFieldList[3]);
407 if (preg_match(
'/^.*:(\w*)$/', $vartmp, $reg)) {
408 $InfoFieldList[4] = $reg[1];
410 $InfoFieldList[3] = preg_replace(
'/:\w*$/',
'', $vartmp);
412 $classname = $InfoFieldList[0];
413 $classpath = $InfoFieldList[1];
414 $filter = empty($InfoFieldList[3]) ?
'' : $InfoFieldList[3];
415 $sortfield = empty($InfoFieldList[4]) ?
'' : $InfoFieldList[4];
416 if (!empty($classpath)) {
419 if ($classname && class_exists($classname)) {
420 $objecttmp =
new $classname($this->db);
423 $sharedentities =
getEntity(strtolower($classname));
424 $filter = str_replace(
425 array(
'__ENTITY__',
'__SHARED_ENTITIES__'),
426 array(
$conf->entity, $sharedentities),
431 if (!is_object($objecttmp)) {
432 dol_syslog(
'Error bad setup of type for field ' . implode(
',', $InfoFieldList), LOG_WARNING);
433 return 'Error bad setup of type for field ' . implode(
',', $InfoFieldList);
436 dol_syslog(__METHOD__ .
' filter=' . $filter, LOG_DEBUG);
439 $out .= $this->
selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty, $searchkey, $placeholder, $morecss, $moreparams, $forcecombo, 0, $disabled, $sortfield, $filter);
464 public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty =
'', $searchkey =
'', $placeholder =
'', $morecss =
'', $moreparams =
'', $forcecombo = 0, $outputmode = 0, $disabled = 0, $sortfield =
'', $filter =
'')
466 global
$conf, $langs, $hookmanager;
468 $prefixforautocompletemode = $objecttmp->element;
469 if ($prefixforautocompletemode ==
'societe') {
470 $prefixforautocompletemode =
'company';
472 $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) .
'_USE_SEARCH_TO_SELECT';
474 if (in_array($objecttmp->element, array(
'adherent_type'))) {
475 $fieldstoshow =
't.libelle';
477 if (!empty($objecttmp->fields)) {
478 $tmpfieldstoshow =
'';
479 foreach ($objecttmp->fields as $key => $val) {
480 if (! (
int)
dol_eval($val[
'enabled'], 1, 1,
'1')) {
483 if (!empty($val[
'showoncombobox'])) {
484 $tmpfieldstoshow .= ($tmpfieldstoshow ?
',' :
'') .
't.' . $key;
487 if ($tmpfieldstoshow) {
488 $fieldstoshow = $tmpfieldstoshow;
490 } elseif (!in_array($objecttmp->element, array(
'adherent_type'))) {
492 $objecttmp->fields[
'ref'] = array(
'type' =>
'varchar(30)',
'label' =>
'Ref',
'showoncombobox' => 1);
495 if (empty($fieldstoshow)) {
496 if (isset($objecttmp->fields[
'ref'])) {
497 $fieldstoshow =
't.ref';
499 $langs->load(
"errors");
500 $this->error = $langs->trans(
"ErrorNoFieldWithAttributeShowoncombobox");
501 return $langs->trans(
'ErrorNoFieldWithAttributeShowoncombobox');
512 $sql =
"SELECT t.rowid, " . $fieldstoshow .
" FROM " . $this->db->prefix() . $objecttmp->table_element .
" as t";
513 if (isset($objecttmp->ismultientitymanaged)) {
514 if (!is_numeric($objecttmp->ismultientitymanaged)) {
515 $tmparray = explode(
'@', $objecttmp->ismultientitymanaged);
516 $sql .=
" INNER JOIN " . $this->db->prefix() . $tmparray[1] .
" as parenttable ON parenttable.rowid = t." . $tmparray[0];
520 if (!empty($objecttmp->isextrafieldmanaged)) {
521 $sql .=
" LEFT JOIN " . $this->db->prefix() . $this->db->sanitize($objecttmp->table_element) .
"_extrafields as e ON t.rowid = e.fk_object";
526 'object' => $objecttmp,
527 'htmlname' => $htmlname,
529 'searchkey' => $searchkey
532 $reshook = $hookmanager->executeHooks(
'selectForFormsListWhere', $parameters);
533 if (!empty($hookmanager->resPrint)) {
534 $sql .= $hookmanager->resPrint;
536 $sql .=
" WHERE 1=1";
537 if (isset($objecttmp->ismultientitymanaged)) {
538 if ($objecttmp->ismultientitymanaged == 1) {
539 $sql .=
" AND t.entity IN (" .
getEntity($objecttmp->table_element) .
")";
541 if (!is_numeric($objecttmp->ismultientitymanaged)) {
542 $sql .=
" AND parenttable.entity = t." . $tmparray[0];
545 if ($searchkey !=
'') {
553 return 'Error forging a SQL request from an universal criteria: ' . $errormessage;
557 $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow,
"ASC");
560 $resql = $this->db->query($sql);
563 $out .=
'<select id="' . $htmlname .
'" class="' . ($morecss ?
' ' . $morecss :
'') .
'"' . ($disabled ?
' disabled="disabled"' :
'') . ($moreparams ?
' ' . $moreparams :
'') .
' name="' . $htmlname .
'">' .
"\n";
566 $textifempty =
' ';
570 if ($showempty && !is_numeric($showempty)) {
571 $textifempty = $langs->trans($showempty);
573 $textifempty .= $langs->trans(
"All");
577 $out .=
'<option value="-1">' . $textifempty .
'</option>' .
"\n";
580 $num = $this->db->num_rows($resql);
584 $obj = $this->db->fetch_object($resql);
587 $tmparray = explode(
',', $fieldstoshow);
588 $oldvalueforshowoncombobox = 0;
589 foreach ($tmparray as $key => $val) {
590 $val = preg_replace(
'/t\./',
'', $val);
591 $label .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val][
'showoncombobox'] ?
' - ' :
' ') :
'');
592 $labelhtml .= (($label && $obj->$val) ? ($oldvalueforshowoncombobox != $objecttmp->fields[$val][
'showoncombobox'] ?
' - ' :
' ') :
'');
593 $label .= $obj->$val;
594 $labelhtml .= $obj->$val;
596 $oldvalueforshowoncombobox = empty($objecttmp->fields[$val][
'showoncombobox']) ? 0 : $objecttmp->fields[$val][
'showoncombobox'];
598 if (empty($outputmode)) {
599 if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
600 $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>';
602 $out .=
'<option value="' . $obj->rowid .
'" data-html="' .
dol_escape_htmltag($labelhtml, 0, 0,
'', 0, 1) .
'">' .
dol_escape_htmltag($label, 0, 0,
'', 0, 1) .
'</option>';
605 array_push($outarray, array(
'key' => $obj->rowid,
'value' => $label,
'label' => $label));
609 if (($i % 10) == 0) {
615 $out .=
'</select>' .
"\n";
620 $this->result = array(
'nbofelement' => $num);
642 public function showInputField($val, $key, $value, $moreparam =
'', $keysuffix =
'', $keyprefix =
'', $morecss =
'')
644 global
$conf, $langs;
649 $size = !empty($val[
'size']) ? $val[
'size'] : 0;
651 if (preg_match(
'/^(integer|link):(.*):(.*):(.*):(.*)/i', $val[
'type'], $reg)) {
652 $param[
'options'] = array($reg[2] .
':' . $reg[3] .
':' . $reg[4] .
':' . $reg[5] =>
'N');
654 } elseif (preg_match(
'/^(integer|link):(.*):(.*):(.*)/i', $val[
'type'], $reg)) {
655 $param[
'options'] = array($reg[2] .
':' . $reg[3] .
':' . $reg[4] =>
'N');
657 } elseif (preg_match(
'/^(integer|link):(.*):(.*)/i', $val[
'type'], $reg)) {
658 $param[
'options'] = array($reg[2] .
':' . $reg[3] =>
'N');
660 } elseif (preg_match(
'/^(sellist):(.*):(.*):(.*):(.*)/i', $val[
'type'], $reg)) {
661 $param[
'options'] = array($reg[2] .
':' . $reg[3] .
':' . $reg[4] .
':' . $reg[5] =>
'N');
663 } elseif (preg_match(
'/^(sellist):(.*):(.*):(.*)/i', $val[
'type'], $reg)) {
664 $param[
'options'] = array($reg[2] .
':' . $reg[3] .
':' . $reg[4] =>
'N');
666 } elseif (preg_match(
'/^(sellist):(.*):(.*)/i', $val[
'type'], $reg)) {
667 $param[
'options'] = array($reg[2] .
':' . $reg[3] =>
'N');
669 } elseif (preg_match(
'/^varchar\((\d+)\)/', $val[
'type'], $reg)) {
670 $param[
'options'] = array();
673 } elseif (preg_match(
'/^varchar/', $val[
'type'])) {
674 $param[
'options'] = array();
676 } elseif (preg_match(
'/^double(\([0-9],[0-9]\)){0,1}/', $val[
'type'])) {
677 $param[
'options'] = array();
680 $param[
'options'] = array();
681 $type = $val[
'type'];
685 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
686 $param[
'options'] = $val[
'arrayofkeyval'];
687 $type = $val[
'type'] ==
'checkbox' ?
'checkbox' :
'select';
691 $default = (!empty($val[
'default']) ? $val[
'default'] :
'');
692 $computed = (!empty($val[
'computed']) ? $val[
'computed'] :
'');
694 $required = (!empty($val[
'required']) ? $val[
'required'] : 0);
695 $notNull = (!empty($val[
'notnull']) ? $val[
'notnull'] : 0);
699 $hidden = (in_array(abs($val[
'visible']), array(0, 2)) ? 1 : 0);
704 if (!preg_match(
'/^search_/', $keyprefix)) {
705 return '<span>' . $langs->trans(
"AutomaticallyCalculated") .
'</span>';
712 if (empty($morecss) && !empty($val[
'css'])) {
713 $morecss = $val[
'css'];
716 $htmlName = $keyprefix . $key . $keysuffix;
725 $dateArr = explode(
' ', $value);
726 if (count($dateArr) > 0) {
727 $valueDate = $dateArr[0];
728 if (isset($dateArr[1])) {
729 $valueTime = $dateArr[1];
732 $out = $this->
inputDate($htmlName, $valueDate,
'', $htmlId, $morecss, $moreparam);
734 if ($type ==
'datetime') {
736 $out .=
' ' . $this->
inputType(
'time', $htmlName.
'_time', $valueTime, $htmlId, $morecss, $moreparam);
746 $moreparam .= ($size > 0 ?
' maxlength="' . $size .
'"' :
'');
763 if (!empty($value)) {
764 $value =
price($value);
766 $addInputLabel =
' ' . $langs->getCurrencySymbol(
$conf->currency);
767 $out = $this->
inputType(
'text', $htmlName, $value, $htmlId, $morecss, $moreparam,
'', $addInputLabel);
771 if (!empty($value)) {
772 $value =
price($value);
774 $out = $this->
inputType(
'text', $htmlName, $value, $htmlId, $morecss, $moreparam);
778 $out = $this->
inputType(
'password', $htmlName, $value, $htmlId, $morecss, $moreparam);
782 foreach ($param[
'options'] as $keyopt => $valopt) {
783 $htmlId = $htmlName .
'_' . $keyopt;
784 $htmlMoreParam = $moreparam . ($value == $keyopt ?
' checked' :
'');
785 $out .= $this->
inputType(
'radio', $htmlName, $keyopt, $htmlId, $morecss, $htmlMoreParam, $valopt) .
'<br>';
790 $out =
'<select class="' . $morecss .
'" name="' . $htmlName .
'" id="' . $htmlId .
'"' . ($moreparam ?
' ' . $moreparam :
'') .
' >';
791 if ($default ==
'' || $notNull != 1) {
792 $out .=
'<option value="0"> </option>';
794 foreach ($param[
'options'] as $keyb => $valb) {
798 if (strpos($valb,
"|") !==
false) {
799 list($valb, $parent) = explode(
'|', $valb);
801 $out .=
'<option value="' . $keyb .
'"';
802 $out .= (((string) $value == $keyb) ?
' selected' :
'');
803 $out .= (!empty($parent) ?
' parent="' . $parent .
'"' :
'');
804 $out .=
'>' . $valb .
'</option>';
809 $out =
'<select class="' . $morecss .
'" name="' . $htmlName .
'" id="' . $htmlId .
'"' . ($moreparam ?
' ' . $moreparam :
'') .
'>';
811 $param_list = array_keys($param[
'options']);
812 $InfoFieldList = explode(
":", $param_list[0]);
822 $keyList = (empty($InfoFieldList[2]) ?
'rowid' : $InfoFieldList[2] .
' as rowid');
824 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
825 if (strpos($InfoFieldList[4],
'extra.') !==
false) {
826 $keyList =
'main.' . $InfoFieldList[2] .
' as rowid';
828 $keyList = $InfoFieldList[2] .
' as rowid';
831 if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
832 list($parentName, $parentField) = explode(
'|', $InfoFieldList[3]);
833 $keyList .=
', ' . $parentField;
836 $filter_categorie =
false;
837 if (count($InfoFieldList) > 5) {
838 if ($InfoFieldList[0] ==
'categorie') {
839 $filter_categorie =
true;
843 if (!$filter_categorie) {
844 $fields_label = explode(
'|', $InfoFieldList[1]);
845 if (is_array($fields_label)) {
847 $keyList .= implode(
', ', $fields_label);
851 $sql =
"SELECT " . $keyList;
852 $sql .=
" FROM " . $this->db->prefix() . $InfoFieldList[0];
853 if (!empty($InfoFieldList[4])) {
855 if (strpos($InfoFieldList[4],
'$SEL$') !==
false) {
856 $InfoFieldList[4] = str_replace(
'$SEL$',
'SELECT', $InfoFieldList[4]);
860 $InfoFieldList[4] = str_replace(
'$ID$',
'0', $InfoFieldList[4]);
863 if (strpos($InfoFieldList[4],
'extra') !==
false) {
864 $sql .=
" as main, " . $this->db->prefix() . $InfoFieldList[0] .
"_extrafields as extra";
865 $sqlwhere .=
" WHERE extra.fk_object=main." . $InfoFieldList[2] .
" AND " . $InfoFieldList[4];
867 $sqlwhere .=
" WHERE " . $InfoFieldList[4];
870 $sqlwhere .=
' WHERE 1=1';
873 if (in_array($InfoFieldList[0], array(
'tablewithentity'))) {
874 $sqlwhere .=
" AND entity = " . ((int)
$conf->entity);
879 $sql .=
' ORDER BY ' . implode(
', ', $fields_label);
881 dol_syslog(get_class($this) .
'::showInputField type=sellist', LOG_DEBUG);
882 $resql = $this->db->query($sql);
884 $out .=
'<option value="0"> </option>';
885 $num = $this->db->num_rows($resql);
889 $obj = $this->db->fetch_object($resql);
893 $fields_label = explode(
'|', $InfoFieldList[1]);
894 if (count($fields_label) > 1) {
896 foreach ($fields_label as $field_toshow) {
897 $labeltoshow .= $obj->$field_toshow .
' ';
900 $labeltoshow = $obj->{$InfoFieldList[1]};
902 $labeltoshow =
dol_trunc($labeltoshow, 45);
904 if ($value == $obj->rowid) {
905 foreach ($fields_label as $field_toshow) {
906 $translabel = $langs->trans($obj->$field_toshow);
907 if ($translabel != $obj->$field_toshow) {
908 $labeltoshow =
dol_trunc($translabel) .
' ';
910 $labeltoshow =
dol_trunc($obj->$field_toshow) .
' ';
913 $out .=
'<option value="' . $obj->rowid .
'" selected>' . $labeltoshow .
'</option>';
916 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
917 if ($translabel != $obj->{$InfoFieldList[1]}) {
918 $labeltoshow =
dol_trunc($translabel, 18);
920 $labeltoshow =
dol_trunc($obj->{$InfoFieldList[1]});
923 if (empty($labeltoshow)) {
924 $labeltoshow =
'(not defined)';
926 if ($value == $obj->rowid) {
927 $out .=
'<option value="' . $obj->rowid .
'" selected>' . $labeltoshow .
'</option>';
930 if (!empty($InfoFieldList[3]) && $parentField) {
931 $parent = $parentName .
':' . $obj->{$parentField};
935 $out .=
'<option value="' . $obj->rowid .
'"';
936 $out .= ($value == $obj->rowid ?
' selected' :
'');
937 $out .= (!empty($parent) ?
' parent="' . $parent .
'"' :
'');
938 $out .=
'>' . $labeltoshow .
'</option>';
943 $this->db->free($resql);
945 $out .=
'Error in request ' . $sql .
' ' . $this->db->lasterror() .
'. Check setup of extra parameters.<br>';
948 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
949 $categorytype = $InfoFieldList[5];
950 if (is_numeric($categorytype)) {
951 $categorytype = Categorie::$MAP_ID_TO_CODE[(int) $categorytype];
953 $data = $this->select_all_categories($categorytype,
'',
'parent', 64, $InfoFieldList[6], 1, 1);
954 $out .=
'<option value="0"> </option>';
955 foreach ($data as $data_key => $data_value) {
956 $out .=
'<option value="' . $data_key .
'"';
957 $out .= ($value == $data_key ?
' selected' :
'');
958 $out .=
'>' . $data_value .
'</option>';
965 $param_list = array_keys($param[
'options']);
966 $showempty = (($required && $default !=
'') ?
'0' :
'1');
968 $out = $this->selectForForms($param_list[0], $htmlName, $value, $showempty,
'',
'', $morecss, $moreparam, 0, empty($val[
'disabled']) ? 0 : 1);
973 if (!empty($hidden)) {
974 $out = $this->inputType(
'hidden', $htmlName, $value, $htmlId);
997 global
$conf, $langs;
999 $label = empty($val[
'label']) ?
'' : $val[
'label'];
1000 $type = empty($val[
'type']) ?
'' : $val[
'type'];
1001 $css = empty($val[
'css']) ?
'' : $val[
'css'];
1002 $picto = empty($val[
'picto']) ?
'' : $val[
'picto'];
1006 if (preg_match(
'/varchar\((\d+)\)/', $type, $reg)) {
1009 } elseif (preg_match(
'/varchar/', $type)) {
1012 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
1013 $type = $val[
'type'] ==
'checkbox' ?
'checkbox' :
'select';
1015 if (preg_match(
'/^integer:(.*):(.*)/i', $val[
'type'], $reg)) {
1019 $default = empty($val[
'default']) ?
'' : $val[
'default'];
1020 $computed = empty($val[
'computed']) ?
'' : $val[
'computed'];
1021 $unique = empty($val[
'unique']) ?
'' : $val[
'unique'];
1022 $required = empty($val[
'required']) ?
'' : $val[
'required'];
1024 $param[
'options'] = array();
1026 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
1027 $param[
'options'] = $val[
'arrayofkeyval'];
1029 if (preg_match(
'/^integer:(.*):(.*)/i', $val[
'type'], $reg)) {
1031 $stringforoptions = $reg[1] .
':' . $reg[2];
1032 if ($reg[1] ==
'User') {
1033 $stringforoptions .=
':-1';
1035 $param[
'options'] = array($stringforoptions => $stringforoptions);
1036 } elseif (preg_match(
'/^sellist:(.*):(.*):(.*):(.*)/i', $val[
'type'], $reg)) {
1037 $param[
'options'] = array($reg[1] .
':' . $reg[2] .
':' . $reg[3] .
':' . $reg[4] =>
'N');
1039 } elseif (preg_match(
'/^sellist:(.*):(.*):(.*)/i', $val[
'type'], $reg)) {
1040 $param[
'options'] = array($reg[1] .
':' . $reg[2] .
':' . $reg[3] =>
'N');
1042 } elseif (preg_match(
'/^sellist:(.*):(.*)/i', $val[
'type'], $reg)) {
1043 $param[
'options'] = array($reg[1] .
':' . $reg[2] =>
'N');
1045 } elseif (preg_match(
'/^chkbxlst:(.*)/i', $val[
'type'], $reg)) {
1046 $param[
'options'] = array($reg[1] =>
'N');
1050 $langfile = empty($val[
'langfile']) ?
'' : $val[
'langfile'];
1051 $list = (empty($val[
'list']) ?
'' : $val[
'list']);
1052 $help = (empty($val[
'help']) ?
'' : $val[
'help']);
1053 $hidden = (($val[
'visible'] == 0) ? 1 : 0);
1063 $value = (string)
dol_eval($computed, 1, 0,
'2');
1070 if (in_array($key, array(
'rowid',
'ref'))) {
1071 if (property_exists(
$object,
'ref')) {
1073 } elseif (property_exists(
$object,
'id')) {
1078 } elseif ($key ==
'status' && method_exists(
$object,
'getLibStatut')) {
1079 $value =
$object->getLibStatut(3);
1083 } elseif (is_array($value)) {
1086 if ($type ==
'array') {
1087 $value = implode(
'<br>', $value);
1089 dol_syslog(__METHOD__.
"Unexpected type=".$type.
" for array value=".((
string) json_encode($value)), LOG_ERR);
1094 } elseif ($type ==
'date') {
1095 if (!empty($value)) {
1100 } elseif ($type ==
'datetime' || $type ==
'timestamp') {
1101 if (!empty($value)) {
1106 } elseif ($type ==
'duration') {
1107 include_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
1108 if (!is_null($value) && $value !==
'') {
1114 } elseif ($type ==
'double' || $type ==
'real') {
1115 if (!is_null($value) && $value !==
'') {
1116 $value =
price($value);
1121 } elseif ($type ==
'boolean') {
1123 if (!empty($value)) {
1124 $checked =
' checked ';
1126 $value =
'<input type="checkbox" ' . $checked .
' ' . ($moreparam ? $moreparam :
'') .
' readonly disabled>';
1127 } elseif ($type ==
'mail' || $type ==
'email') {
1129 } elseif ($type ==
'url') {
1131 } elseif ($type ==
'phone') {
1133 } elseif ($type ==
'ip') {
1135 } elseif ($type ==
'price') {
1136 if (!is_null($value) && $value !==
'') {
1137 $value =
price($value, 0, $langs, 0, 0, -1,
$conf->currency);
1142 } elseif ($type ==
'select') {
1143 $value = isset($param[
'options'][$value]) ? $param[
'options'][$value] :
'';
1144 } elseif ($type ==
'sellist') {
1145 $param_list = array_keys($param[
'options']);
1146 $InfoFieldList = explode(
":", $param_list[0]);
1148 $selectkey =
"rowid";
1151 if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
1152 $selectkey = $InfoFieldList[2];
1153 $keyList = $InfoFieldList[2] .
' as rowid';
1156 $fields_label = explode(
'|', $InfoFieldList[1]);
1157 if (is_array($fields_label)) {
1159 $keyList .= implode(
', ', $fields_label);
1162 $filter_categorie =
false;
1163 if (count($InfoFieldList) > 5) {
1164 if ($InfoFieldList[0] ==
'categorie') {
1165 $filter_categorie =
true;
1169 $sql =
"SELECT " . $keyList;
1170 $sql .=
' FROM ' . $this->db->prefix() . $InfoFieldList[0];
1171 if (strpos($InfoFieldList[4],
'extra') !==
false) {
1174 if ($selectkey ==
'rowid' && empty($value)) {
1175 $sql .=
" WHERE " . $selectkey .
" = 0";
1176 } elseif ($selectkey ==
'rowid') {
1177 $sql .=
" WHERE " . $selectkey .
" = " . ((int) $value);
1179 $sql .=
" WHERE " . $selectkey .
" = '" . $this->db->escape($value) .
"'";
1182 dol_syslog(__METHOD__ .
' type=sellist', LOG_DEBUG);
1183 $resql = $this->db->query($sql);
1185 if (!$filter_categorie) {
1187 $numrows = $this->db->num_rows($resql);
1189 $obj = $this->db->fetch_object($resql);
1192 $fields_label = explode(
'|', $InfoFieldList[1]);
1194 if (is_array($fields_label) && count($fields_label) > 1) {
1195 foreach ($fields_label as $field_toshow) {
1197 if (!empty($obj->$field_toshow)) {
1198 $translabel = $langs->trans($obj->$field_toshow);
1200 if ($translabel != $field_toshow) {
1201 $value .=
dol_trunc($translabel, 18) .
' ';
1203 $value .= $obj->$field_toshow .
' ';
1208 if (!empty($obj->{$InfoFieldList[1]})) {
1209 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1211 if ($translabel != $obj->{$InfoFieldList[1]}) {
1214 $value = $obj->{$InfoFieldList[1]};
1219 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1222 $obj = $this->db->fetch_object($resql);
1224 $c->fetch($obj->rowid);
1225 $ways =
$c->print_all_ways();
1226 foreach ($ways as $way) {
1227 $toprint[] =
'<li>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
1229 $value =
'<div><ul>' . implode(
' ', $toprint) .
'</ul></div>';
1232 dol_syslog(__METHOD__ .
' error ' . $this->db->lasterror(), LOG_WARNING);
1234 } elseif ($type ==
'radio') {
1235 $value = (string) $param[
'options'][$value];
1236 } elseif ($type ==
'checkbox') {
1237 $value_arr = explode(
',', $value);
1239 if (is_array($value_arr) && count($value_arr) > 0) {
1241 foreach ($value_arr as $valueval) {
1242 if (!empty($valueval)) {
1243 $toprint[] =
'<li>' . $param[
'options'][$valueval] .
'</li>';
1246 if (!empty($toprint)) {
1247 $value =
'<div><ul>' . implode(
' ', $toprint) .
'</ul></div>';
1250 } elseif ($type ==
'chkbxlst') {
1251 $value_arr = explode(
',', $value);
1253 $param_list = array_keys($param[
'options']);
1254 $InfoFieldList = explode(
":", $param_list[0]);
1256 $selectkey =
"rowid";
1259 if (count($InfoFieldList) >= 3) {
1260 $selectkey = $InfoFieldList[2];
1261 $keyList = $InfoFieldList[2] .
' as rowid';
1264 $fields_label = explode(
'|', $InfoFieldList[1]);
1265 if (is_array($fields_label)) {
1267 $keyList .= implode(
', ', $fields_label);
1270 $filter_categorie =
false;
1271 if (count($InfoFieldList) > 5) {
1272 if ($InfoFieldList[0] ==
'categorie') {
1273 $filter_categorie =
true;
1277 $sql =
"SELECT " . $keyList;
1278 $sql .=
' FROM ' . $this->db->prefix() . $InfoFieldList[0];
1279 if (strpos($InfoFieldList[4],
'extra') !==
false) {
1285 dol_syslog(__METHOD__ .
' type=chkbxlst', LOG_DEBUG);
1286 $resql = $this->db->query($sql);
1288 if (!$filter_categorie) {
1291 while ($obj = $this->db->fetch_object($resql)) {
1293 $fields_label = explode(
'|', $InfoFieldList[1]);
1294 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1295 if (is_array($fields_label) && count($fields_label) > 1) {
1296 foreach ($fields_label as $field_toshow) {
1298 if (!empty($obj->$field_toshow)) {
1299 $translabel = $langs->trans($obj->$field_toshow);
1301 if ($translabel != $field_toshow) {
1302 $toprint[] =
'<li>' .
dol_trunc($translabel, 18) .
'</li>';
1304 $toprint[] =
'<li>' . $obj->$field_toshow .
'</li>';
1309 if (!empty($obj->{$InfoFieldList[1]})) {
1310 $translabel = $langs->trans($obj->{$InfoFieldList[1]});
1312 if ($translabel != $obj->{$InfoFieldList[1]}) {
1313 $toprint[] =
'<li>' .
dol_trunc($translabel, 18) .
'</li>';
1315 $toprint[] =
'<li>' . $obj->{$InfoFieldList[1]} .
'</li>';
1321 require_once DOL_DOCUMENT_ROOT .
'/categories/class/categorie.class.php';
1324 while ($obj = $this->db->fetch_object($resql)) {
1325 if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
1327 $c->fetch($obj->rowid);
1328 $ways =
$c->print_all_ways();
1329 foreach ($ways as $way) {
1330 $toprint[] =
'<li>' .
img_object(
'',
'category') .
' ' . $way .
'</li>';
1335 $value =
'<div><ul>' . implode(
' ', $toprint) .
'</ul></div>';
1337 dol_syslog(__METHOD__ .
' error ' . $this->db->lasterror(), LOG_WARNING);
1339 } elseif ($type ==
'link') {
1342 $param_list = array_keys($param[
'options']);
1344 $InfoFieldList = explode(
":", $param_list[0]);
1345 $classname = $InfoFieldList[0];
1346 $classpath = $InfoFieldList[1];
1347 if (!empty($classpath)) {
1349 if ($classname && class_exists($classname)) {
1350 $object =
new $classname($this->db);
1351 '@phan-var-force CommonObject $object';
1352 $result =
$object->fetch($value);
1355 if (property_exists(
$object,
'label')) {
1357 } elseif (property_exists(
$object,
'libelle')) {
1359 } elseif (property_exists(
$object,
'nom')) {
1365 dol_syslog(__METHOD__ .
' Error bad setup of field', LOG_WARNING);
1366 return 'Error bad setup of field';
1371 } elseif ($type ==
'password') {
1372 $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.
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.
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_print_phone($phone, $countrycode='', $cid=0, $socid=0, $addlink='', $separ=" ", $withpicto='', $titlealt='', $adddivfloat=0, $morecss='paddingright')
Format phone numbers according to country.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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
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).
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_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
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 a Dolibarr global constant string value.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$context
@method int call_trigger(string $triggerName, User $user)