From a57925b0b7fd4c0c44a58d6d38356d6b1b243be7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Oct 2021 01:43:36 +0200 Subject: [PATCH] FIX edition of fields on credit transfer tab --- htdocs/compta/facture/prelevement.php | 12 ++++++---- htdocs/core/class/html.form.class.php | 34 ++++++++++++++++++--------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 24be588386c..55e4dcf61ca 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -398,7 +398,7 @@ if ($object->id > 0) { if ($object->type != $object::TYPE_CREDIT_NOTE) { if ($action == 'editinvoicedate') { - $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $object->date, 'invoicedate'); + print $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $object->date, 'invoicedate', 0, 0, 1, $type); } else { print dol_print_date($object->date, 'day'); } @@ -420,7 +420,7 @@ if ($object->id > 0) { print ''; if ($object->type != $object::TYPE_CREDIT_NOTE) { if ($action == 'editconditions') { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id'); + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 0, $type); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none'); } @@ -446,7 +446,7 @@ if ($object->id > 0) { } if ($action == 'editpaymentterm') { - $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $duedate, 'paymentterm'); + print $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $duedate, 'paymentterm', 0, 0, 1, $type); } else { print dol_print_date($duedate, 'day'); if ($object->hasDelay()) { @@ -468,8 +468,12 @@ if ($object->id > 0) { } print ''; print ''; + $filtertype = 'CRDT'; + if ($type == 'bank-transfer') { + $filtertype = 'DBIT'; + } if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', $filtertype, 1, 0, $type); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 37155a4566e..c69b794a011 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3884,8 +3884,8 @@ class Form * @param string $htmlname Nom de la zone select * @param int $filtertype Not used * @param int $addempty Add an empty entry - * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info - * @param string $morecss Add more CSS on select tag + * @param int $noinfoadmin 0=Add admin info, 1=Disable admin info + * @param string $morecss Add more CSS on select tag * @return void */ public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '') @@ -5108,17 +5108,21 @@ class Form * @param string $selected Id condition pre-selectionne * @param string $htmlname Name of select html field * @param int $addempty Add empty entry + * @param string $type Type ('direct-debit' or 'bank-transfer') * @return void */ - public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0) + public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0, $type = '') { // phpcs:enable global $langs; if ($htmlname != "none") { - print '
'; + print ''; print ''; print ''; - $this->select_conditions_paiements($selected, $htmlname, -1, $addempty); + if ($type) { + print ''; + } + $this->select_conditions_paiements($selected, $htmlname, -1, $addempty, 0, ''); print ''; print '
'; } else { @@ -5212,10 +5216,11 @@ class Form * @param int $displayhour Display hour selector * @param int $displaymin Display minutes selector * @param int $nooutput 1=No print output, return string + * @param string $type 'direct-debit' or 'bank-transfer' * @return string * @see selectDate() */ - public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0) + public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0, $type = '') { // phpcs:enable global $langs; @@ -5223,9 +5228,12 @@ class Form $ret = ''; if ($htmlname != "none") { - $ret .= '
'; + $ret .= ''; $ret .= ''; $ret .= ''; + if ($type) { + $ret .= ''; + } $ret .= ''; $ret .= '
'; $ret .= $this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1, 'form'.$htmlname, 1, 0); @@ -5290,12 +5298,13 @@ class Form * @param string $page Page * @param int $selected Id mode pre-selectionne * @param string $htmlname Name of select html field - * @param string $filtertype To filter on field type in llx_c_paiement (array('code'=>xx,'label'=>zz)) + * @param string $filtertype To filter on field type in llx_c_paiement ('CRDT' or 'DBIT' or array('code'=>xx,'label'=>zz)) * @param int $active Active or not, -1 = all - * @param int $addempty 1=Add empty entry + * @param int $addempty 1=Add empty entry + * @param string $type Type ('direct-debit' or 'bank-transfer') * @return void */ - public function form_modes_reglement($page, $selected = '', $htmlname = 'mode_reglement_id', $filtertype = '', $active = 1, $addempty = 0) + public function form_modes_reglement($page, $selected = '', $htmlname = 'mode_reglement_id', $filtertype = '', $active = 1, $addempty = 0, $type = '') { // phpcs:enable global $langs; @@ -5303,7 +5312,10 @@ class Form print ''; print ''; print ''; - $this->select_types_paiements($selected, $htmlname, $filtertype, 0, $addempty, 0, 0, $active); + if ($type) { + print ''; + } + print $this->select_types_paiements($selected, $htmlname, $filtertype, 0, $addempty, 0, 0, $active, '', 1); print ''; print ''; } else {