24require_once DOL_DOCUMENT_ROOT .
'/core/class/fields/commonfield.class.php';
35 public $emptyValues = array(
'');
49 public function printInputSearchField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
55 $htmlName = $keyPrefix . $key . $keySuffix;
57 'start' => $value[
'start'] ??
'',
58 'end' => $value[
'end'] ??
'',
62 $out =
'<div ' . $moreAttrib .
'><div class="nowrap">';
63 $out .= self::$form->selectDate($prefill[
'start'], $htmlName .
'_start', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"),
'tzuserrel');
64 $out .=
'</div><div class="nowrap">';
65 $out .= self::$form->selectDate($prefill[
'end'], $htmlName .
'_end', 1, 1, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"),
'tzuserrel');
66 $out .=
'</div></div>';
83 public function printInputField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
85 $required = $fieldInfos->required ? 1 : 0;
86 $htmlName = $keyPrefix . $key . $keySuffix;
89 if (!$required && $this->
isEmptyValue($fieldInfos, $value)) {
94 return self::$form->selectDate($value, $htmlName, 1, 1, $required,
'', 1, 1, 0, 1,
'',
'',
'', 1,
'',
'',
'tzuserrel');
109 public function printOutputField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
123 public function getInputCss($fieldInfos, $moreCss =
'', $defaultCss =
'')
125 return parent::getInputCss($fieldInfos, $moreCss, $defaultCss ? $defaultCss :
'minwidth200imp');
139 $result = parent::verifyFieldValue($fieldInfos, $key, $value);
140 if ($result && !$this->
isEmptyValue($fieldInfos, $value)) {
141 if (!self::$validator->isTimestamp($value)) {
163 return parent::verifyPostFieldValue($fieldInfos, $key, $keyPrefix, $keySuffix);
177 public function getPostFieldValue($fieldInfos, $key, $defaultValue =
null, $keyPrefix =
'', $keySuffix =
'')
179 $htmlName = $keyPrefix . $key . $keySuffix;
181 if (GETPOSTISSET($htmlName .
'hour') || GETPOSTISSET($htmlName .
'min') || GETPOSTISSET($htmlName .
'sec') || GETPOSTISSET($htmlName .
'month') || GETPOSTISSET($htmlName .
'day') || GETPOSTISSET($htmlName .
'year')) {
184 $value = $defaultValue;
203 $htmlName = $keyPrefix . $key . $keySuffix;
205 if (GETPOSTISSET($htmlName .
'_startmonth') || GETPOSTISSET($htmlName .
'_startday') || GETPOSTISSET($htmlName .
'_startyear')) {
208 $start = is_array($defaultValue) && isset($defaultValue[
'start']) ? $defaultValue[
'start'] :
'';
211 if (GETPOSTISSET($htmlName .
'_endmonth') || GETPOSTISSET($htmlName .
'_endday') || GETPOSTISSET($htmlName .
'_endyear')) {
214 $end = is_array($defaultValue) && isset($defaultValue[
'end']) ? $defaultValue[
'end'] :
'';
235 $alias = $fieldInfos->sqlAlias ??
't.';
236 $field = $this->db->sanitize($alias . ($fieldInfos->nameInTable ?? $key));
239 if (is_array($value)) {
240 $hasStart = !is_null($value[
'start']) && $value[
'start'] !==
'';
241 $hasEnd = !is_null($value[
'start']) && $value[
'start'] !==
'';
242 if ($hasStart && $hasEnd) {
243 $sql =
" AND (" . $field .
" BETWEEN '" . $this->db->idate($value[
'start']) .
"' AND '" . $this->db->idate($value[
'end']) .
"')";
244 } elseif ($hasStart) {
245 $sql =
" AND " . $field .
" >= '" . $this->db->idate($value[
'start']) .
"'";
247 $sql =
" AND " . $field .
" <= '" . $this->db->idate($value[
'end']) .
"'";
249 } elseif (is_numeric($value)) {
250 $sql =
" AND " . $field .
" = '" . $this->db->idate($value) .
"'";
isEmptyValue($fieldInfos, $value, $emptyValues=null)
Check if the value is deemed as empty.
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.
verifyFieldValue($fieldInfos, $key, $value)
Verify if the field value is valid.
printInputSearchField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to put an input search field into a page.
sqlFilterSearchField($fieldInfos, $key, $value)
Get sql filter for search field.
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.
getPostSearchFieldValue($fieldInfos, $key, $defaultValue=null, $keyPrefix='', $keySuffix='')
Get search field value from GET/POST.
getInputCss($fieldInfos, $moreCss='', $defaultCss='')
Get input CSS.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).