Add BIC/SWIFT Validation
This commit is contained in:
parent
f652cf4e97
commit
4bbbff8d69
@ -256,7 +256,15 @@ if (($_GET["id"] || $_GET["ref"]) && $action != 'edit')
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans($bickey).'</td>';
|
||||
print '<td colspan="3">'.$account->bic.'</td></tr>';
|
||||
print '<td colspan="3">'.$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 '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="3">';
|
||||
print nl2br($account->domiciliation);
|
||||
|
||||
@ -121,7 +121,24 @@ function bank_admin_prepare_head($object)
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'bank_admin', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check SWIFT informations for a bank account
|
||||
*
|
||||
* @param Account $account A bank account
|
||||
* @return int True if informations are valid, false otherwise
|
||||
*/
|
||||
function checkSwiftForAccount($account)
|
||||
{
|
||||
$swift = $account->bic;
|
||||
if (eregi("^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$", $swift)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check IBAN number informations for a bank account
|
||||
@ -134,13 +151,9 @@ function checkIbanForAccount($account)
|
||||
require_once DOL_DOCUMENT_ROOT.'/includes/php-iban/oophp-iban.php';
|
||||
$iban = new Iban($account->iban);
|
||||
$check = $iban->Verify();
|
||||
//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;
|
||||
}
|
||||
|
||||
|
||||
@ -33,9 +33,11 @@ AllTime=From start
|
||||
Reconciliation=Reconciliation
|
||||
RIB=Bank Account Number
|
||||
IBAN=IBAN number
|
||||
IbanValid=Valid IBAN
|
||||
IbanNotValid=Not Valid IBAN
|
||||
IbanValid=IBAN is Valid
|
||||
IbanNotValid=IBAN is Not Valid
|
||||
BIC=BIC/SWIFT number
|
||||
SwiftValid=BIC/SWIFT is Valid
|
||||
SwiftNotValid=BIC/SWIFT is Not Valid
|
||||
StandingOrders=Standing orders
|
||||
StandingOrder=Standing order
|
||||
Withdrawals=Withdrawals
|
||||
|
||||
@ -304,7 +304,15 @@ if ($socid && $action != 'edit' && $action != "create")
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
|
||||
print '<td colspan="4">'.$account->bic.'</td></tr>';
|
||||
print '<td colspan="4">'.$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 '</td></tr>';
|
||||
|
||||
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
|
||||
print $account->domiciliation;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user