From cb97a29fc0e0b4fec1d18aadddbaed69a35a093a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 8 Sep 2018 12:00:11 +0200 Subject: [PATCH] introduce seletDate --- htdocs/accountancy/admin/fiscalyear_card.php | 8 ++-- htdocs/core/class/html.form.class.php | 43 ++++++++++++++++---- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index cc3d65fcad8..f8821b5713d 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -169,12 +169,12 @@ if ($action == 'create') // Date start print '' . $langs->trans("DateStart") . ''; - $form->select_date(($date_start ? $date_start : ''), 'fiscalyear'); + print $form->selectDate(($date_start ? $date_start : ''), 'fiscalyear'); print ''; // Date end print '' . $langs->trans("DateEnd") . ''; - $form->select_date(($date_end ? $date_end : - 1), 'fiscalyearend'); + print $form->selectDate(($date_end ? $date_end : - 1), 'fiscalyearend'); print ''; /* @@ -225,12 +225,12 @@ if ($action == 'create') // Date start print '' . $langs->trans("DateStart") . ''; - $form->select_date($object->date_start ? $object->date_start : - 1, 'fiscalyear'); + print $form->selectDate($object->date_start ? $object->date_start : - 1, 'fiscalyear'); print ''; // Date end print '' . $langs->trans("DateEnd") . ''; - $form->select_date($object->date_end ? $object->date_end : - 1, 'fiscalyearend'); + print $form->selectDate($object->date_end ? $object->date_end : - 1, 'fiscalyearend'); print ''; // Statut diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 27d7fe521fe..5fdfd6f991c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4885,11 +4885,43 @@ class Form * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field. * @param datetime $adddateof Add a link "Date of invoice" using the following date. - * @return string|null Nothing or string if nooutput is 1 - * @see form_date, select_month, select_year, select_dayofweek + * @return string|null Nothing or string if nooutput is 1 + * @deprecated + * @see form_date, select_month, select_year, select_dayofweek */ // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='', $adddateof='') + function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='', $adddateof='') + { + $retstring = selectDate($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $disabled=0, $fullday='', $addplusone='', $adddateof=''); + if (! empty($nooutput)) return $retstring; + + print $retstring; + return; + } + + /** + * Show a HTML widget to input a date or combo list for day, month, years and optionaly hours and minutes. + * Fields are preselected with : + * - set_time date (must be a local PHP server timestamp or string date with format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM') + * - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location) + * - Empty (fields empty), if set_time is -1 (in this case, parameter empty must also have value 1) + * + * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). + * @param string $prefix Prefix for fields name + * @param int $h 1 or 2=Show also hours (2=hours on a new line), -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show hour always empty + * @param int $m 1=Show also minutes, -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show minutes always empty + * @param int $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only + * @param string $form_name Not used + * @param int $d 1=Show days, month, years + * @param int $addnowlink Add a link "Now" + * @param int $disabled Disable input fields + * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 + * @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field. + * @param datetime $adddateof Add a link "Date of invoice" using the following date. + * @return string Html for selectDate + * @see form_date, select_month, select_year, select_dayofweek + */ + function selectDate($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $disabled=0, $fullday='', $addplusone='', $adddateof='') { global $conf,$langs; @@ -5235,10 +5267,7 @@ class Form $retstring.=' -