24require_once DOL_DOCUMENT_ROOT .
'/core/class/fields/commonfield.class.php';
35 public $emptyValues = array(
'',
'-1',
'0', 0);
50 public function printInputSearchField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
52 $moreCss = $this->
getInputCss($fieldInfos, $moreCss);
53 $htmlName = $keyPrefix . $key . $keySuffix;
57 if (version_compare(DOL_VERSION,
'19.0.0') < 0) {
59 $objectDesc = $optionParams[
'all'];
60 if (strpos($objectDesc,
'$ID$') !==
false && !empty($fieldInfos->object->id)) {
61 $objectDesc = str_replace(
'$ID$', (
string) $fieldInfos->object->id, $objectDesc);
64 $out = self::$form->selectForForms($objectDesc, $htmlName, (
int) $value, 0,
'',
'', $moreCss, $moreAttrib);
68 $objectDesc = $optionParams[
'objectClass'] .
':' . $optionParams[
'pathToClass'];
73 $objectField = isset($fieldInfos->object) ? $fieldInfos->object->element . (!empty($fieldInfos->object->module) ?
'@' . $fieldInfos->object->module :
'') .
':' . ($fieldInfos->fieldType == FieldInfos::FIELD_TYPE_EXTRA_FIELD ?
'options_' :
'') . $fieldInfos->nameInClass :
'';
75 $out = self::$form->selectForForms($objectDesc, $htmlName, (
int) $value, 0,
'',
'', $moreCss, $moreAttrib, 0, 0,
'', $objectField);
93 public function printInputField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
97 $moreCss = $this->
getInputCss($fieldInfos, $moreCss);
98 $moreAttrib = trim((
string) $moreAttrib);
99 if (empty($moreAttrib)) $moreAttrib =
' ' . $moreAttrib;
100 $placeHolder = $fieldInfos->inputPlaceholder;
101 $autoFocus = $fieldInfos->inputAutofocus ?
' autofocus' :
'';
102 $htmlName = $keyPrefix . $key . $keySuffix;
103 $showEmpty = $fieldInfos->required && !$this->
isEmptyValue($fieldInfos, $fieldInfos->defaultValue) ? 0 : 1;
108 if ($optionParams[
'addCreateButton']) {
109 if (!empty($fieldInfos->picto)) {
110 $moreCss .=
' widthcentpercentminusxx';
112 $moreCss .=
' widthcentpercentminusx';
114 } elseif (!empty($fieldInfos->picto)) {
115 $moreCss .=
' widthcentpercentminusx';
118 if (version_compare(DOL_VERSION,
'19.0.0') < 0) {
120 $objectDesc = $optionParams[
'all'];
121 if (strpos($objectDesc,
'$ID$') !==
false && !empty($fieldInfos->object->id)) {
122 $objectDesc = str_replace(
'$ID$', (
string) $fieldInfos->object->id, $objectDesc);
125 $out = self::$form->selectForForms($objectDesc, $htmlName, (
int) $value, $showEmpty,
'', $placeHolder, $moreCss, $moreAttrib . $autoFocus, 0, $fieldInfos->inputDisabled ? 1 : 0);
129 $objectDesc = $optionParams[
'objectClass'] .
':' . $optionParams[
'pathToClass'];
134 $objectField = isset($fieldInfos->object) ? $fieldInfos->object->element . (!empty($fieldInfos->object->module) ?
'@' . $fieldInfos->object->module :
'') .
':' . ($fieldInfos->fieldType == FieldInfos::FIELD_TYPE_EXTRA_FIELD ?
'options_' :
'') . $fieldInfos->nameInClass :
'';
136 $out = self::$form->selectForForms($objectDesc, $htmlName, (
int) $value, $showEmpty,
'', $placeHolder, $moreCss, $moreAttrib . $autoFocus, 0, $fieldInfos->inputDisabled ? 1 : 0,
'', $objectField);
139 if ($optionParams[
'addCreateButton'] &&
140 (!GETPOSTISSET(
'backtopage') || strpos(
GETPOST(
'backtopage'), $_SERVER[
'PHP_SELF']) === 0) &&
141 !$fieldInfos->inputDisabled &&
142 empty($fieldInfos->otherParams[
'nonewbutton'])
144 $class = $optionParams[
'objectClass'];
145 $classfile = $optionParams[
'pathToClass'];
146 $classpath = dirname(dirname($classfile));
150 $url_path =
dol_buildpath($classpath .
'/' . strtolower($class) .
'_card.php', 1);
152 $paramforthenewlink =
'';
153 $paramforthenewlink .= (GETPOSTISSET(
'action') ?
'&action=' .
GETPOST(
'action',
'aZ09') :
'');
154 $paramforthenewlink .= (GETPOSTISSET(
'id') ?
'&id=' .
GETPOSTINT(
'id') :
'');
155 $paramforthenewlink .= (GETPOSTISSET(
'origin') ?
'&origin=' .
GETPOST(
'origin',
'aZ09') :
'');
156 $paramforthenewlink .= (GETPOSTISSET(
'originid') ?
'&originid=' .
GETPOSTINT(
'originid') :
'');
157 $paramforthenewlink .=
'&fk_' . strtolower($class) .
'=--IDFORBACKTOPAGE--';
159 $out .=
'<a class="butActionNew" title="' . $langs->trans(
"New") .
'" href="' . $url_path .
'?action=create&backtopage=' . urlencode($_SERVER[
'PHP_SELF'] . $paramforthenewlink) .
'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
177 public function printOutputField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
182 $classpath = $optionParams[
'pathToClass'];
183 if (!empty($classpath)) {
184 $classname = $optionParams[
'objectClass'];
188 '@phan-var-force CommonObject $object';
189 if (
$object->element ===
'product') {
190 '@phan-var-force Product $object';
191 $result =
$object->fetch((
int) $value,
'',
'',
'', 0, 1, 1);
193 $result =
$object->fetch($value);
196 $getNomUrlParam1 = $optionParams[
'getNomUrlParam1'];
197 $getNomUrlParam2 = $optionParams[
'getNomUrlParam2'];
199 if (
$object->element ===
'product') {
200 '@phan-var-force Product $object';
201 $get_name_url_param_arr = array($getNomUrlParam1, $getNomUrlParam2, 0, -1, 0,
'', 0,
' - ');
202 if (isset($fieldInfos->getNameUrlParams)) {
203 $get_name_url_params = explode(
':', $fieldInfos->getNameUrlParams);
204 if (!empty($get_name_url_params)) {
205 $param_num_max = count($get_name_url_param_arr) - 1;
206 foreach ($get_name_url_params as $param_num => $param_value) {
207 if ($param_num > $param_num_max) {
210 $get_name_url_param_arr[$param_num] = $param_value;
218 return self::$form->getNomUrl(
$object, (
int) $get_name_url_param_arr[0], $get_name_url_param_arr[1], (
int) $get_name_url_param_arr[2], (
int) $get_name_url_param_arr[3], (
int) $get_name_url_param_arr[4], $get_name_url_param_arr[5], (
int) $get_name_url_param_arr[6], $get_name_url_param_arr[7]);
219 } elseif (get_class(
$object) ==
'Categorie') {
222 $sfortag =
'<span class="noborderoncategories"' . ($color ?
' style="background: #' . $color .
';"' :
' style="background: #bbb"') .
'>';
223 $sfortag .= self::$form->getNomUrl(
$object, (
int) $getNomUrlParam1, $getNomUrlParam2);
224 $sfortag .=
'</span>';
227 return self::$form->getNomUrl(
$object, (
int) $getNomUrlParam1, $getNomUrlParam2);
231 dol_syslog(
'Error bad setup of field : ' . $key, LOG_WARNING);
232 return 'Error bad setup of field';
235 dol_syslog(
'Error bad setup of field : ' . $key, LOG_WARNING);
236 return 'Error bad setup of field';
252 public function getInputCss($fieldInfos, $moreCss =
'', $defaultCss =
'')
254 return parent::getInputCss($fieldInfos, $moreCss, $defaultCss ? $defaultCss :
'minwidth200imp');
268 $result = parent::verifyFieldValue($fieldInfos, $key, $value);
269 if ($result && !$this->
isEmptyValue($fieldInfos, $value)) {
271 $classname = $optionParams[
'objectClass'];
272 $classpath = $optionParams[
'pathToClass'];
274 if (isset(
$object) && method_exists(
$object,
'isExistingObject') && !self::$validator->isFetchable((
int) $value, $classname, $classpath)
275 && (version_compare(DOL_VERSION,
'19.0.0') < 0 || !self::$validator->isFetchableElement((
int) $value, $classname))
298 return parent::verifyPostFieldValue($fieldInfos, $key, $keyPrefix, $keySuffix);
312 public function getPostFieldValue($fieldInfos, $key, $defaultValue =
null, $keyPrefix =
'', $keySuffix =
'')
314 $htmlName = $keyPrefix . $key . $keySuffix;
316 if (GETPOSTISSET($htmlName)) {
319 $value = $defaultValue;
338 $htmlName = $keyPrefix . $key . $keySuffix;
340 if (GETPOSTISSET($htmlName)) {
341 $value =
GETPOST($htmlName,
'alphanohtml');
343 $value = $defaultValue;
361 $alias = $fieldInfos->sqlAlias ??
't.';
363 return natural_search($alias . ($fieldInfos->nameInTable ?? $key), $value, 2);
377 $options = is_array($options) ? $options : array();
378 $paramList = array_keys($options);
383 $all = (
string) $paramList[0];
384 $InfoFieldList = explode(
":", $all);
386 $objectClass = (
string) ($InfoFieldList[0] ??
'');
387 $pathToClass = (
string) ($InfoFieldList[1] ??
'');
388 $addCreateButton = !empty($InfoFieldList[2]) && is_numeric($InfoFieldList[2]);
389 $getNomUrlParam1 = 3;
390 $getNomUrlParam2 =
'';
391 if (preg_match(
'/#getnomurlparam1=([^#:]*)/', $all, $matches)) {
392 $getNomUrlParam1 = $matches[1];
394 if (preg_match(
'/#getnomurlparam2=([^#:]*)/', $all, $matches)) {
395 $getNomUrlParam2 = $matches[1];
397 $filter = (
string) ($InfoFieldList[3] ??
'');
398 $sortField = (
string) ($InfoFieldList[4] ??
'');
402 'objectClass' => $objectClass,
403 'pathToClass' => $pathToClass,
404 'addCreateButton' => $addCreateButton,
405 'getNomUrlParam1' => $getNomUrlParam1,
406 'getNomUrlParam2' => $getNomUrlParam2,
408 'sortField' => $sortField,
422 if ($objectClass && !class_exists($objectClass)) {
425 $element_prop = getElementProperties($objectClass);
427 $objectClass = $element_prop[
'classname'];
431 if ($objectClass && class_exists($objectClass)) {
432 return new $objectClass($this->db);
if(! $sortfield) if(! $sortorder) $object
printOutputField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to show a field into a page.
isEmptyValue($fieldInfos, $value, $emptyValues=null)
Check if the value is deemed as empty.
printInputSearchField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to put an input search field into a page.
getPostFieldValue($fieldInfos, $key, $defaultValue=null, $keyPrefix='', $keySuffix='')
Get field value from GET/POST.
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.
getOptionsParams($options)
Get all parameters in the options.
verifyPostFieldValue($fieldInfos, $key, $keyPrefix='', $keySuffix='')
Verify if the field value from GET/POST is valid.
sqlFilterSearchField($fieldInfos, $key, $value)
Get sql filter for search field.
getInputCss($fieldInfos, $moreCss='', $defaultCss='')
Get input CSS.
printInputField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to put an input field into a page.
getObject($objectClass, $pathToClass)
Get object handler.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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