dolibarr 24.0.0-beta
commonselectfield.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2025 Open-Dsi <support@open-dsi.fr>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
24require_once DOL_DOCUMENT_ROOT . '/core/class/fields/commonfield.class.php';
25
26
31{
35 public static $options = array();
36
46 public function getOptions($fieldInfos, $key, $addEmptyValue = false, $reload = false)
47 {
48 global $langs;
49
50 if (!isset(self::$options[$key]) || $reload) {
51 $options = array();
52 if (!empty($fieldInfos->options) && is_array($fieldInfos->options)) {
53 foreach ($fieldInfos->options as $optionKey => $optionLabel) {
54 $optionKey = (string) $optionKey;
55 $optionLabel = (string) $optionLabel;
56 if ($optionKey == '') {
57 continue;
58 }
59
60 // Manage dependency list
61 $fieldValueParent = '';
62 if (strpos($optionLabel, "|") !== false) {
63 list($optionLabel, $valueParent) = explode('|', $optionLabel);
64 $fieldValueParent = trim($fieldValueParent);
65 }
66
67 if (empty($optionLabel)) {
68 $optionLabel = '(not defined)';
69 } else {
70 $optionLabel = $langs->trans($optionLabel);
71 }
72
73 $options[$optionKey] = array(
74 'id' => $optionKey,
75 'label' => $optionLabel,
76 'parent' => $fieldValueParent,
77 );
78 }
79 }
80 if ($addEmptyValue && (!$fieldInfos->required || count($options) > 1)) {
81 // For preserve the numeric key indexes
82 $options = array(
83 '' => array(
84 'id' => '',
85 'label' => '&nbsp;',
86 'parent' => '',
87 )
88 ) + $options;
89 }
90
91 self::$options[$key] = $options;
92 }
93
94 return self::$options[$key];
95 }
96}
Class to common field.
Class to common select field.
getOptions($fieldInfos, $key, $addEmptyValue=false, $reload=false)
Get list of options.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php