From 22e1262ac663f84f7b7c419944eee1f0ee45a71e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Jan 2023 16:55:07 +0100 Subject: [PATCH] Can add a custom date with editfieldval --- htdocs/core/class/html.form.class.php | 10 +++++++--- htdocs/salaries/payment_salary/card.php | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c9332a839e7..4d8aa1e2b6e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -278,10 +278,14 @@ class Form $ret .= ''; } elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') { $addnowlink = empty($moreoptions['addnowlink']) ? 0 : $moreoptions['addnowlink']; - $ret .= $this->selectDate($value, $htmlname, 0, 0, 1, 'form'.$htmlname, 1, $addnowlink, 0, '', '', '', '', 1, '', '', $gm); + $adddateof = empty($moreoptions['adddateof']) ? '' : $moreoptions['adddateof']; + $labeladddateof = empty($moreoptions['labeladddateof']) ? '' : $moreoptions['labeladddateof']; + $ret .= $this->selectDate($value, $htmlname, 0, 0, 1, 'form'.$htmlname, 1, $addnowlink, 0, '', '', $adddateof, '', 1, $labeladddateof, '', $gm); } elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') { $addnowlink = empty($moreoptions['addnowlink']) ? 0 : $moreoptions['addnowlink']; - $ret .= $this->selectDate($value, $htmlname, 1, 1, 1, 'form'.$htmlname, 1, $addnowlink, 0, '', '', '', '', 1, '', '', $gm); + $adddateof = empty($moreoptions['adddateof']) ? '' : $moreoptions['adddateof']; + $labeladddateof = empty($moreoptions['labeladddateof']) ? '' : $moreoptions['labeladddateof']; + $ret .= $this->selectDate($value, $htmlname, 1, 1, 1, 'form'.$htmlname, 1, $addnowlink, 0, '', '', $adddateof, '', 1, $labeladddateof, '', $gm); } elseif (preg_match('/^select;/', $typeofdata)) { $arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata)); $arraylist = array(); @@ -6496,7 +6500,7 @@ class Form * @param int $disabled Disable input fields * @param int $fullday When a checkbox with id #fullday is checked, hours are set with 00:00 (if value if 'fulldaystart') or 23:59 (if value is 'fulldayend') * @param string $addplusone Add a link "+1 hour". Value must be name of another selectDate field. - * @param datetime $adddateof Add a link "Date of ..." using the following date. See also $labeladddateof for the label used. + * @param datetime|string $adddateof Add a link "Date of ..." using the following date. See also $labeladddateof for the label used. * @param string $openinghours Specify hour start and hour end for the select ex 8,20 * @param int $stepminutes Specify step for minutes between 1 and 30 * @param string $labeladddateof Label to use for the $adddateof parameter. diff --git a/htdocs/salaries/payment_salary/card.php b/htdocs/salaries/payment_salary/card.php index b35469ab27e..e66ef74a4ee 100644 --- a/htdocs/salaries/payment_salary/card.php +++ b/htdocs/salaries/payment_salary/card.php @@ -133,6 +133,8 @@ $linkback = ''.$langs->trans("B dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', ''); +$salary->fetch($object->fk_salary); + print '
'; print '
'; @@ -149,7 +151,7 @@ print '';*/ print ''; print $form->editfieldkey("Date", 'datep', $object->datep, $object, 1, 'datehourpicker'); print ''; -print $form->editfieldval("Date", 'datep', $object->datep, $object, 1, 'datehourpicker', '', null, null, '', 0, '', 'id', 'tzuserrel', array('addnowlink'=>1)); +print $form->editfieldval("Date", 'datep', $object->datep, $object, 1, 'datehourpicker', '', null, null, '', 0, '', 'id', 'tzuserrel', array('addnowlink'=>1, 'adddateof'=>$salary->datesp, 'labeladddateof'=>$langs->transnoentitiesnoconv("DateStart"))); print ""; print '';