From d842a436ae7f2a870cccbb4bae364db21449d284 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 11 Apr 2020 17:06:50 +0200 Subject: [PATCH 1/2] New display of user bank account : same way as on thirdparty --- htdocs/societe/paymentmodes.php | 2 +- htdocs/user/bank.php | 200 ++++++++++++++++---------------- 2 files changed, 98 insertions(+), 104 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index c9fe7c41001..d440930bbf5 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1385,7 +1385,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create'); - print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, ''); + print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, 'bank'); $rib_list = $object->get_all_rib(); if (is_array($rib_list)) diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index af70ce966d2..c0ad414290b 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -67,6 +67,17 @@ if ($id > 0 || !empty($ref)) $object->getrights(); } +$account = new UserBankAccount($db); +if (!$bankid) +{ + $account->fetch(0, '', $id); +} +else +{ + $account->fetch($bankid); +} +if (empty($account->userid)) $account->userid = $object->id; + /* * Actions @@ -74,9 +85,6 @@ if ($id > 0 || !empty($ref)) if ($action == 'add' && !$cancel) { - // Modification - $account = new UserBankAccount($db); - $account->userid = $object->id; $account->bank = GETPOST('bank', 'alpha'); @@ -108,11 +116,6 @@ if ($action == 'add' && !$cancel) if ($action == 'update' && !$cancel) { - // Modification - $account = new UserBankAccount($db); - - $account->fetch($bankid); - $account->userid = $object->id; $account->bank = GETPOST('bank', 'alpha'); @@ -153,18 +156,6 @@ llxHeader(null, $langs->trans("BankAccounts")); $head = user_prepare_head($object); -$account = new UserBankAccount($db); -if (!$bankid) -{ - $account->fetch(0, '', $id); -} -else -{ - $account->fetch($bankid); -} -if (empty($account->userid)) $account->userid = $object->id; - - if ($id && $bankid && $action == 'edit' && $user->rights->user->user->creer) { print '
'; @@ -208,78 +199,6 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print ''; - print '
'; - - print load_fiche_titre($langs->trans("BAN")); - - print '
'; - print ''; - - print ''; - print ''; - - print ''; - print ''; - - // Show fields of bank account - foreach ($account->getFieldsToShow() as $val) { - if ($val == 'BankCode') { - $content = $account->code_banque; - } elseif ($val == 'DeskCode') { - $content = $account->code_guichet; - } elseif ($val == 'BankAccountNumber') { - $content = $account->number; - } elseif ($val == 'BankAccountNumberKey') { - $content = $account->cle_rib; - } - - print ''; - print ''; - print ''; - } - - print ''; - print ''; - - print ''; - print ''; - - print '\n"; - - print '\n"; - - print '\n"; - - print '
'.$langs->trans("LabelRIB").''.$account->label.'
'.$langs->trans("BankName").''.$account->bank.'
'.$langs->trans($val).''.$content.'
'.$langs->trans("IBAN").''.$account->iban.' '; - if (!empty($account->iban)) { - if (!checkIbanForAccount($account)) { - print img_picto($langs->trans("IbanNotValid"), 'warning'); - } else { - print img_picto($langs->trans("IbanValid"), 'info'); - } - } - print '
'.$langs->trans("BIC").''.$account->bic.' '; - if (!empty($account->bic)) { - if (!checkSwiftForAccount($account)) { - print img_picto($langs->trans("SwiftNotValid"), 'warning'); - } else { - print img_picto($langs->trans("SwiftValid"), 'info'); - } - } - print '
'.$langs->trans("BankAccountDomiciliation").''; - print $account->domiciliation; - print "
'.$langs->trans("BankAccountOwner").''; - print $account->proprio; - print "
'.$langs->trans("BankAccountOwnerAddress").''; - print $account->owner_address; - print "
'; - - // Check BBAN - if ($account->label && !checkBanForAccount($account)) - { - print '
'.$langs->trans("RIBControlError").'
'; - } - print '
'; // Nbre max d'elements des petites listes @@ -455,20 +374,95 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco dol_fiche_end(); - /* - * Barre d'actions - */ - print '
'; + // List of bank accounts (Currently only one bank account possible for each employee) - if ($user->rights->user->user->creer) - { - if ($account->id > 0) - print ''.$langs->trans("Edit").''; - else - print ''.$langs->trans("Create").''; + $morehtmlright = ''; + if ($account->id == 0) { + $morehtmlright = dolGetButtonTitle($langs->trans('Add'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=create'); } - print '
'; + print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, 'bank'); + + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print ''; + + print ''; + print_liste_field_titre("LabelRIB"); + print_liste_field_titre("Bank"); + print_liste_field_titre("RIB"); + print_liste_field_titre("IBAN"); + print_liste_field_titre("BIC"); + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + print "\n"; + + if($account->id > 0) { + print ''; + // Label + print ''; + // Bank name + print ''; + // Account number + print ''; + // IBAN + print ''; + // BIC + print ''; + + // Edit/Delete + print ''; + + print ''; + } + + + if ($account->id == 0) + { + $colspan = 6; + print ''; + } + +print '
' . $account->label . '' . $account->bank . ''; + $string = ''; + foreach ($account->getFieldsToShow() as $val) { + if ($val == 'BankCode') { + $string .= $account->code_banque . ' '; + } elseif ($val == 'BankAccountNumber') { + $string .= $account->number . ' '; + } elseif ($val == 'DeskCode') { + $string .= $account->code_guichet . ' '; + } elseif ($val == 'BankAccountNumberKey') { + $string .= $account->cle_rib . ' '; + } + } + if (!empty($account->label) && $account->number) { + if (!checkBanForAccount($account)) { + $string .= ' ' . img_picto($langs->trans("ValueIsNotValid"), 'warning'); + } else { + $string .= ' ' . img_picto($langs->trans("ValueIsValid"), 'info'); + } + } + + print $string; + print '' . $account->iban; + if (!empty($account->iban)) { + if (!checkIbanForAccount($account)) { + print ' ' . img_picto($langs->trans("IbanNotValid"), 'warning'); + } + } + print '' . $account->bic; + if (!empty($account->bic)) { + if (!checkSwiftForAccount($account)) { + print ' ' . img_picto($langs->trans("SwiftNotValid"), 'warning'); + } + } + print ''; + if ($user->rights->hrm->employee->write || $user->rights->user->creer) { + print ''; + print img_picto($langs->trans("Modify"), 'edit'); + print ''; + } + print '
'.$langs->trans("NoBANRecord").'
'; +print '
'; } // Edit From 9744efc3ec2d9a7d053bfc1481fb45b88f4f3d61 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 11 Apr 2020 15:12:11 +0000 Subject: [PATCH 2/2] Fixing style errors. --- htdocs/user/bank.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index c0ad414290b..186cc57d36e 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -461,8 +461,8 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco print ''.$langs->trans("NoBANRecord").''; } -print ''; -print '
'; + print ''; + print '
'; } // Edit