2
0
forked from Wavyzz/dolibarr

Add php-iban and check IBAN

This commit is contained in:
frederic34
2015-02-17 10:23:31 +01:00
parent 23562a01ab
commit 9d0ffb7e85
2 changed files with 32 additions and 1 deletions

View File

@@ -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 '<pre>'.print_r($iban, true).'</pre>';
if ($check) {
//print '<pre>OK</pre>';
return true;
} else {
//$suggest = $iban->MistranscriptionSuggestions($account->iban);
//print '<pre>'.print_r($suggest, true).'</pre>';
return false;
}
}
/**
* Check account number informations for a bank account
*

View File

@@ -293,7 +293,15 @@ if ($socid && $action != 'edit' && $action != "create")
}
print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
print '<td colspan="4">'.$account->iban.'</td></tr>';
print '<td colspan="4">'.$account->iban . '&nbsp;';
if (! empty($account->iban)) {
if (! checkIbanForAccount($account)) {
print img_picto($langs->trans("NotValid"),'warning');
} else {
print img_picto($langs->trans("IsValid"),'info');
}
}
print '</td></tr>';
print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
print '<td colspan="4">'.$account->bic.'</td></tr>';