better way to manamge IBAN/BIC Mandatory
This commit is contained in:
parent
d431e73ec8
commit
1e4916bd53
@ -1297,6 +1297,55 @@ class Account extends CommonObject
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return 1 is IBAN is need for UE country
|
||||||
|
*
|
||||||
|
* @return int 1 yes / 0 No
|
||||||
|
*/
|
||||||
|
function needIBAN()
|
||||||
|
{
|
||||||
|
$country_code=$this->getCountryCode();
|
||||||
|
|
||||||
|
$country_code_in_EEC=array(
|
||||||
|
'AT', // Austria
|
||||||
|
'BE', // Belgium
|
||||||
|
'BG', // Bulgaria
|
||||||
|
'CY', // Cyprus
|
||||||
|
'CZ', // Czech republic
|
||||||
|
'DE', // Germany
|
||||||
|
'DK', // Danemark
|
||||||
|
'EE', // Estonia
|
||||||
|
'ES', // Spain
|
||||||
|
'FI', // Finland
|
||||||
|
'FR', // France
|
||||||
|
'GB', // United Kingdom
|
||||||
|
'GR', // Greece
|
||||||
|
'HR', // Croatia
|
||||||
|
'NL', // Holland
|
||||||
|
'HU', // Hungary
|
||||||
|
'IE', // Ireland
|
||||||
|
'IM', // Isle of Man - Included in UK
|
||||||
|
'IT', // Italy
|
||||||
|
'LT', // Lithuania
|
||||||
|
'LU', // Luxembourg
|
||||||
|
'LV', // Latvia
|
||||||
|
'MC', // Monaco - Included in France
|
||||||
|
'MT', // Malta
|
||||||
|
//'NO', // Norway
|
||||||
|
'PL', // Poland
|
||||||
|
'PT', // Portugal
|
||||||
|
'RO', // Romania
|
||||||
|
'SE', // Sweden
|
||||||
|
'SK', // Slovakia
|
||||||
|
'SI', // Slovenia
|
||||||
|
'UK', // United Kingdom
|
||||||
|
//'CH', // Switzerland - No. Swizerland in not in EEC
|
||||||
|
);
|
||||||
|
|
||||||
|
if (in_array($country_code,$country_code_in_EEC)) return 1; // France, Spain, Gabon, ...
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load miscellaneous information for tab "Info"
|
* Load miscellaneous information for tab "Info"
|
||||||
*
|
*
|
||||||
|
|||||||
@ -72,6 +72,8 @@ if ($action == 'update' && ! $_POST["cancel"])
|
|||||||
$action='update';
|
$action='update';
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
if ($account->needIBAN() == 1)
|
||||||
|
{
|
||||||
if (! GETPOST('iban'))
|
if (! GETPOST('iban'))
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
|
||||||
@ -84,6 +86,7 @@ if ($action == 'update' && ! $_POST["cancel"])
|
|||||||
$action='update';
|
$action='update';
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$account->fetch($id);
|
$account->fetch($id);
|
||||||
if (! $error)
|
if (! $error)
|
||||||
@ -141,6 +144,8 @@ if ($action == 'add' && ! $_POST["cancel"])
|
|||||||
$action='create';
|
$action='create';
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
if ($account->needIBAN() == 1)
|
||||||
|
{
|
||||||
if (! GETPOST('iban'))
|
if (! GETPOST('iban'))
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
|
||||||
@ -153,6 +158,7 @@ if ($action == 'add' && ! $_POST["cancel"])
|
|||||||
$action='create';
|
$action='create';
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@ -489,12 +495,12 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
|||||||
$name = 'iban';
|
$name = 'iban';
|
||||||
$size = 30;
|
$size = 30;
|
||||||
$content = $account->iban;
|
$content = $account->iban;
|
||||||
$require=true;
|
if ($account->needIBAN()) $require=true;
|
||||||
} elseif ($val == 'BIC') {
|
} elseif ($val == 'BIC') {
|
||||||
$name = 'bic';
|
$name = 'bic';
|
||||||
$size = 12;
|
$size = 12;
|
||||||
$content = $account->bic;
|
$content = $account->bic;
|
||||||
$require=true;
|
if ($account->needIBAN()) $require=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
|
print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
|
||||||
@ -568,10 +574,10 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
|
|||||||
print '<td><input size="30" type="text" name="bank" value="'.GETPOST('bank').'"></td></tr>';
|
print '<td><input size="30" type="text" name="bank" value="'.GETPOST('bank').'"></td></tr>';
|
||||||
|
|
||||||
// IBAN
|
// IBAN
|
||||||
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("IBAN").'</td>';
|
print '<tr><td valign="top" '.($account->needIBAN()?' class="fieldrequired" ':'').'>'.$langs->trans("IBAN").'</td>';
|
||||||
print '<td colspan="4"><input size="30" type="text" name="iban" value="'.GETPOST('iban').'"></td></tr>';
|
print '<td colspan="4"><input size="30" type="text" name="iban" value="'.GETPOST('iban').'"></td></tr>';
|
||||||
|
|
||||||
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("BIC").'</td>';
|
print '<tr><td valign="top" '.($account->needIBAN()?' class="fieldrequired" ':'').'>'.$langs->trans("BIC").'</td>';
|
||||||
print '<td colspan="4"><input size="12" type="text" name="bic" value="'.GETPOST('bic').'"></td></tr>';
|
print '<td colspan="4"><input size="12" type="text" name="bic" value="'.GETPOST('bic').'"></td></tr>';
|
||||||
|
|
||||||
// BBAN
|
// BBAN
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user