25require_once DOL_DOCUMENT_ROOT .
'/core/class/fields/commonselectfield.class.php';
36 public $emptyValues = array(
'');
51 public function printInputSearchField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
55 $moreCss = $this->
getInputCss($fieldInfos, $moreCss);
56 $moreAttrib = trim((
string) $moreAttrib);
57 if (empty($moreAttrib)) {
58 $moreAttrib =
' ' . $moreAttrib;
60 $htmlName = $keyPrefix . $key . $keySuffix;
61 $value = $this->
isEmptyValue($fieldInfos, $value) ? array() : (is_string($value) ? explode(
',', $value) : (is_array($value) ? $value : array($value)));
63 $optionsList = array();
64 $options = $this->
getOptions($fieldInfos, $key);
65 foreach ($options as $optionKey => $optionInfos) {
66 $options[$optionKey] = $optionInfos[
'label'];
69 return self::$form->multiselectarray($htmlName, $optionsList, $value, 0, 0, $moreCss, 0, 0, $moreAttrib,
'',
'', (
int) (!empty(
$conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_EXTRAFIELDS_DISABLE_SELECT2')));
84 public function printInputField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
86 $moreCss = $this->
getInputCss($fieldInfos, $moreCss);
87 $moreAttrib = trim((
string) $moreAttrib);
88 if (empty($moreAttrib)) {
89 $moreAttrib =
' ' . $moreAttrib;
91 $htmlName = $keyPrefix . $key . $keySuffix;
95 $options = $this->
getOptions($fieldInfos, $key,
true);
97 foreach ($options as $optionKey => $optionInfos) {
98 $values[$optionKey] = $optionInfos[
'label'];
101 return self::$form->inputRadio($htmlName, $values, $selectedValue, $moreCss, $moreAttrib);
116 public function printOutputField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
121 if ($fieldInfos->required && $this->isEmptyValue($fieldInfos, $value)) {
122 $langs->load(
'errors');
123 $value =
'<span class="opacitymedium">' . $langs->trans(
'ErrorNoValueForRadioType') .
'</span>';
125 $options = $this->
getOptions($fieldInfos, $key);
126 foreach ($options as $optionKey => $optionInfos) {
127 if (((
string) $optionKey) == $value) {
128 $value = $optionInfos[
'label'];
146 public function getInputCss($fieldInfos, $moreCss =
'', $defaultCss =
'')
148 return parent::getInputCss($fieldInfos, $moreCss, $defaultCss ? $defaultCss :
'width25');
165 $result = parent::verifyFieldValue($fieldInfos, $key, $value);
166 if ($result && !$this->
isEmptyValue($fieldInfos, $value)) {
167 $options = $this->
getOptions($fieldInfos, $key);
168 if (!isset($options[$value])) {
169 self::$validator->error = $langs->trans(
'RequireValidValue');
191 $htmlName = $keyPrefix . $key . $keySuffix;
192 $value =
GETPOST($htmlName,
'restricthtml');
193 $value = trim($value);
209 public function getPostFieldValue($fieldInfos, $key, $defaultValue =
null, $keyPrefix =
'', $keySuffix =
'')
211 $htmlName = $keyPrefix . $key . $keySuffix;
213 if (GETPOSTISSET($htmlName)) {
214 $value =
GETPOST($htmlName,
'alphanohtml');
216 $value = $defaultValue;
235 $htmlName = $keyPrefix . $key . $keySuffix;
237 if (GETPOSTISSET($htmlName)) {
238 $value =
GETPOST($htmlName,
'array');
240 $value = $defaultValue;
257 if (!$this->
isEmptyValue($fieldInfos, $value) && is_array($value)) {
258 $alias = $fieldInfos->sqlAlias ??
't.';
259 $field = $this->db->sanitize($alias . ($fieldInfos->nameInTable ?? $key));
261 $sanitizedSqlIn =
"'" . implode(
"','", array_map(array($this->db,
'escape'), $value)) .
"'";
262 $sqlPartialCond =
" AND " . $field .
" IN (" . $sanitizedSqlIn .
")";
263 return $sqlPartialCond;
278 public function getOptions($fieldInfos, $key, $addEmptyValue =
false, $reload =
false)
280 return parent::getOptions($fieldInfos, $key, $addEmptyValue, $reload);
isEmptyValue($fieldInfos, $value, $emptyValues=null)
Check if the value is deemed as empty.
Class to common select field.
getInputCss($fieldInfos, $moreCss='', $defaultCss='')
Get input CSS.
verifyPostFieldValue($fieldInfos, $key, $keyPrefix='', $keySuffix='')
Verify if the field value from GET/POST is valid.
printOutputField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to show a field into a page.
getPostFieldValue($fieldInfos, $key, $defaultValue=null, $keyPrefix='', $keySuffix='')
Get field value from GET/POST.
printInputField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to put an input field into a page.
printInputSearchField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to put an input search field into a page.
verifyFieldValue($fieldInfos, $key, $value)
Verify if the field value is valid.
getPostSearchFieldValue($fieldInfos, $key, $defaultValue=null, $keyPrefix='', $keySuffix='')
Get search field value from GET/POST.
getOptions($fieldInfos, $key, $addEmptyValue=false, $reload=false)
Get list of options.
sqlFilterSearchField($fieldInfos, $key, $value)
Get sql filter for search field.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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