From 756a971dadf049ded467dc4e5fca14747331e32c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Jan 2023 11:23:19 +0100 Subject: [PATCH] NEW Bank name no more mandatory on creation. Can be generated if empty. --- htdocs/societe/paymentmodes.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 0166a3a5635..bf4e1135f96 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -257,13 +257,8 @@ if (empty($reshook)) { if ($action == 'add') { $error = 0; - if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha')) { - if (!GETPOST('label', 'alpha')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); - } - if (!GETPOST('bank', 'alpha')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); - } + if (!GETPOST('label', 'alpha')) { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); $action = 'create'; $error++; } @@ -274,6 +269,8 @@ if (empty($reshook)) { $companybankaccount->socid = $object->id; + $companybankaccount->fetch_thirdparty(); + $companybankaccount->bank = GETPOST('bank', 'alpha'); $companybankaccount->label = GETPOST('label', 'alpha'); $companybankaccount->courant = GETPOST('courant', 'alpha'); @@ -293,6 +290,12 @@ if (empty($reshook)) { $companybankaccount->datec = dol_now(); $companybankaccount->status = 1; + $companybankaccount->bank = trim($companybankaccount->bank); + if (empty($companybankaccount->bank) && !empty($companybankaccount->thirdparty)) { + $companybankaccount->bank = $langs->trans("Bank").' '.$companybankaccount->thirdparty->name; + } + $companybankaccount->bic = str_replace(' ', '', $companybankaccount->bic); + $db->begin(); // This test can be done only once properties were set @@ -1980,7 +1983,7 @@ if ($socid && $action == 'create' && $permissiontoaddupdatepaymentinformation) { print ''.$langs->trans("Label").''; print ''; - print ''.$langs->trans("Bank").''; + print ''.$langs->trans("Bank").''; print ''; // Show fields of bank account