diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index d8f65c0830237d0d1db11c15cdb3b6284bd19ed2..0413692beac22ac4113ee4545205081e2f1c9200 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -1297,6 +1297,55 @@ class Account extends CommonObject
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"
*
diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php
index d820058d83b2bad9c0994c246022202640407483..62e6860adc4426618927b437af70faeff9a1f42d 100644
--- a/htdocs/societe/rib.php
+++ b/htdocs/societe/rib.php
@@ -72,17 +72,20 @@ if ($action == 'update' && ! $_POST["cancel"])
$action='update';
$error++;
}
- if (! GETPOST('iban'))
+ if ($account->needIBAN() == 1)
{
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
- $action='update';
- $error++;
- }
- if (! GETPOST('bic'))
- {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
- $action='update';
- $error++;
+ if (! GETPOST('iban'))
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
+ $action='update';
+ $error++;
+ }
+ if (! GETPOST('bic'))
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
+ $action='update';
+ $error++;
+ }
}
$account->fetch($id);
@@ -141,17 +144,20 @@ if ($action == 'add' && ! $_POST["cancel"])
$action='create';
$error++;
}
- if (! GETPOST('iban'))
+ if ($account->needIBAN() == 1)
{
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
- $action='create';
- $error++;
- }
- if (! GETPOST('bic'))
- {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
- $action='create';
- $error++;
+ if (! GETPOST('iban'))
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors');
+ $action='create';
+ $error++;
+ }
+ if (! GETPOST('bic'))
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors');
+ $action='create';
+ $error++;
+ }
}
if (! $error)
@@ -489,12 +495,12 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
$name = 'iban';
$size = 30;
$content = $account->iban;
- $require=true;
+ if ($account->needIBAN()) $require=true;
} elseif ($val == 'BIC') {
$name = 'bic';
$size = 12;
$content = $account->bic;
- $require=true;
+ if ($account->needIBAN()) $require=true;
}
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>';
// 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 '<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>';
// BBAN