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', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"From"));
64 $out .=
'</div><div class="nowrap">';
65 $out .= self::$form->selectDate($prefill[
'end'], $htmlName .
'_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
"to"));
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)) {
95 if (in_array($fieldInfos->key, array(
'birth'))) {
100 return self::$form->selectDate($value, $htmlName, 0, 0, $required,
'', 1, $addnowlink, 0, 1);
115 public function printOutputField($fieldInfos, $key, $value, $keyPrefix =
'', $keySuffix =
'', $moreCss =
'', $moreAttrib =
'')
130 public function getInputCss($fieldInfos, $moreCss =
'', $defaultCss =
'')
132 return parent::getInputCss($fieldInfos, $moreCss, $defaultCss ? $defaultCss :
'minwidth100imp');
146 $result = parent::verifyFieldValue($fieldInfos, $key, $value);
147 if ($result && !$this->
isEmptyValue($fieldInfos, $value)) {
171 return parent::verifyPostFieldValue($fieldInfos, $key, $keyPrefix, $keySuffix);
185 public function getPostFieldValue($fieldInfos, $key, $defaultValue =
null, $keyPrefix =
'', $keySuffix =
'')
187 $htmlName = $keyPrefix . $key . $keySuffix;
189 if (GETPOSTISSET($htmlName .
'month') || GETPOSTISSET($htmlName .
'day') || GETPOSTISSET($htmlName .
'year')) {
192 $value = $defaultValue;
211 $htmlName = $keyPrefix . $key . $keySuffix;
213 if (GETPOSTISSET($htmlName .
'_startmonth') || GETPOSTISSET($htmlName .
'_startday') || GETPOSTISSET($htmlName .
'_startyear')) {
216 $start = is_array($defaultValue) && isset($defaultValue[
'start']) ? $defaultValue[
'start'] :
'';
219 if (GETPOSTISSET($htmlName .
'_endmonth') || GETPOSTISSET($htmlName .
'_endday') || GETPOSTISSET($htmlName .
'_endyear')) {
222 $end = is_array($defaultValue) && isset($defaultValue[
'end']) ? $defaultValue[
'end'] :
'';
243 $alias = $fieldInfos->sqlAlias ??
't.';
244 $field = $this->db->sanitize($alias . ($fieldInfos->nameInTable ?? $key));
247 if (is_array($value)) {
248 $hasStart = !is_null($value[
'start']) && $value[
'start'] !==
'';
249 $hasEnd = !is_null($value[
'start']) && $value[
'start'] !==
'';
250 if ($hasStart && $hasEnd) {
251 $sql =
" AND (" . $field .
" BETWEEN '" . $this->db->idate($value[
'start']) .
"' AND '" . $this->db->idate($value[
'end']) .
"')";
252 } elseif ($hasStart) {
253 $sql =
" AND " . $field .
" >= '" . $this->db->idate($value[
'start']) .
"'";
255 $sql =
" AND " . $field .
" <= '" . $this->db->idate($value[
'end']) .
"'";
257 } elseif (is_numeric($value)) {
258 include_once DOL_DOCUMENT_ROOT .
'/core/lib/date.lib.php';
260 $sql =
" AND " . $field .
" = '" . $this->db->idate($value) .
"'";
isEmptyValue($fieldInfos, $value, $emptyValues=null)
Check if the value is deemed as empty.
sqlFilterSearchField($fieldInfos, $key, $value)
Get sql filter for search field.
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.
printOutputField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to show a field into a page.
printInputField($fieldInfos, $key, $value, $keyPrefix='', $keySuffix='', $moreCss='', $moreAttrib='')
Return HTML string to put an input field into a page.
verifyPostFieldValue($fieldInfos, $key, $keyPrefix='', $keySuffix='')
Verify if the field value from GET/POST is valid.
getInputCss($fieldInfos, $moreCss='', $defaultCss='')
Get input CSS.
getPostSearchFieldValue($fieldInfos, $key, $defaultValue=null, $keyPrefix='', $keySuffix='')
Get search field value from GET/POST.
verifyFieldValue($fieldInfos, $key, $value)
Verify if the field value is valid.
dol_get_first_hour($date, $gm='tzserver')
Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
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).