From 9d0ffb7e85d6e06d5ab861869b2a3e611e32784b Mon Sep 17 00:00:00 2001 From: frederic34 Date: Tue, 17 Feb 2015 10:23:31 +0100 Subject: [PATCH] Add php-iban and check IBAN --- htdocs/core/lib/bank.lib.php | 23 +++++++++++++++++++++++ htdocs/societe/rib.php | 10 +++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index e3fb787657b..77b92447d3f 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -123,6 +123,29 @@ function bank_admin_prepare_head($object) return $head; } +/** + * Check IBAN number informations for a bank account + * + * @param Account $account A bank account + * @return int True if informations are valid, false otherwise + */ +function checkIbanForAccount($account) +{ + require_once DOL_DOCUMENT_ROOT.'/includes/php-iban/oophp-iban.php'; + $iban = new Iban(); + $check = $iban->Verify($account->iban); + //print '
'.print_r($iban, true).'
'; + if ($check) { + //print '
OK
'; + return true; + } else { + //$suggest = $iban->MistranscriptionSuggestions($account->iban); + //print '
'.print_r($suggest, true).'
'; + return false; + } + +} + /** * Check account number informations for a bank account * diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index f57eb6a5b70..a615577a8c4 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -293,7 +293,15 @@ if ($socid && $action != 'edit' && $action != "create") } print ''.$langs->trans("IBAN").''; - print ''.$account->iban.''; + print ''.$account->iban . ' '; + if (! empty($account->iban)) { + if (! checkIbanForAccount($account)) { + print img_picto($langs->trans("NotValid"),'warning'); + } else { + print img_picto($langs->trans("IsValid"),'info'); + } + } + print ''; print ''.$langs->trans("BIC").''; print ''.$account->bic.'';