Fix #5353
This commit is contained in:
parent
bdba5dce3a
commit
d431e73ec8
@ -258,6 +258,10 @@ class Account extends CommonObject
|
|||||||
$string .= $this->code_guichet.' ';
|
$string .= $this->code_guichet.' ';
|
||||||
} elseif ($val == 'BankAccountNumberKey') {
|
} elseif ($val == 'BankAccountNumberKey') {
|
||||||
$string .= $this->cle_rib.' ';
|
$string .= $this->cle_rib.' ';
|
||||||
|
}elseif ($val == 'BIC') {
|
||||||
|
$string .= $this->bic.' ';
|
||||||
|
}elseif ($val == 'IBAN') {
|
||||||
|
$string .= $this->iban.' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1324,12 +1328,16 @@ class Account extends CommonObject
|
|||||||
|
|
||||||
if ($detailedBBAN == 0) {
|
if ($detailedBBAN == 0) {
|
||||||
return array(
|
return array(
|
||||||
'BankAccountNumber'
|
'IBAN',
|
||||||
|
'BIC',
|
||||||
|
'BankAccountNumber'
|
||||||
);
|
);
|
||||||
} elseif ($detailedBBAN == 2) {
|
} elseif ($detailedBBAN == 2) {
|
||||||
return array(
|
return array(
|
||||||
'BankCode',
|
'IBAN',
|
||||||
'BankAccountNumber'
|
'BIC',
|
||||||
|
'BankCode',
|
||||||
|
'BankAccountNumber'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1352,16 +1360,20 @@ class Account extends CommonObject
|
|||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$fieldlists = array(
|
$fieldlists = array(
|
||||||
'BankCode',
|
'IBAN',
|
||||||
'DeskCode',
|
'BIC',
|
||||||
'BankAccountNumber',
|
'BankCode',
|
||||||
'BankAccountNumberKey'
|
'DeskCode',
|
||||||
|
'BankAccountNumber',
|
||||||
|
'BankAccountNumberKey'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!empty($conf->global->BANK_SHOW_ORDER_OPTION)) {
|
if (!empty($conf->global->BANK_SHOW_ORDER_OPTION)) {
|
||||||
if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) {
|
if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION)) {
|
||||||
if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') {
|
if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') {
|
||||||
$fieldlists = array(
|
$fieldlists = array(
|
||||||
|
'IBAN',
|
||||||
|
'BIC',
|
||||||
'BankCode',
|
'BankCode',
|
||||||
'DeskCode',
|
'DeskCode',
|
||||||
'BankAccountNumberKey',
|
'BankAccountNumberKey',
|
||||||
|
|||||||
@ -706,8 +706,12 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default
|
|||||||
// Key
|
// Key
|
||||||
$tmplength = 13;
|
$tmplength = 13;
|
||||||
$content = $account->cle_rib;
|
$content = $account->cle_rib;
|
||||||
|
}elseif ($val == 'IBAN' || $val == 'BIC') {
|
||||||
|
// Key
|
||||||
|
$tmplength = 0;
|
||||||
|
$content = '';
|
||||||
} else {
|
} else {
|
||||||
dol_print_error($this->db, 'Unexpected value for getFieldsToShow: '.$val);
|
dol_print_error($account->db, 'Unexpected value for getFieldsToShow: '.$val);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -233,7 +233,7 @@ class CompanyBankAccount extends Account
|
|||||||
{
|
{
|
||||||
$rib = '';
|
$rib = '';
|
||||||
|
|
||||||
if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) {
|
if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib || $this->iban || $this->bic ) {
|
||||||
|
|
||||||
if ($this->label && $displayriblabel) {
|
if ($this->label && $displayriblabel) {
|
||||||
$rib = $this->label." : ";
|
$rib = $this->label." : ";
|
||||||
|
|||||||
@ -2195,6 +2195,7 @@ class Societe extends CommonObject
|
|||||||
function display_rib($mode='label')
|
function display_rib($mode='label')
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
|
||||||
|
|
||||||
$bac = new CompanyBankAccount($this->db);
|
$bac = new CompanyBankAccount($this->db);
|
||||||
$bac->fetch(0,$this->id);
|
$bac->fetch(0,$this->id);
|
||||||
|
|
||||||
@ -2206,6 +2207,7 @@ class Societe extends CommonObject
|
|||||||
{
|
{
|
||||||
if (empty($bac->rum))
|
if (empty($bac->rum))
|
||||||
{
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/bonprelevement.class.php';
|
||||||
$prelevement = new BonPrelevement($this->db);
|
$prelevement = new BonPrelevement($this->db);
|
||||||
$bac->fetch_thirdparty();
|
$bac->fetch_thirdparty();
|
||||||
$bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id);
|
$bac->rum = $prelevement->buildRumNumber($bac->thirdparty->code_client, $bac->datec, $bac->id);
|
||||||
|
|||||||
@ -59,43 +59,70 @@ if ($action == 'update' && ! $_POST["cancel"])
|
|||||||
// Modification
|
// Modification
|
||||||
$account = new CompanyBankAccount($db);
|
$account = new CompanyBankAccount($db);
|
||||||
|
|
||||||
|
|
||||||
|
if (! GETPOST('label'))
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||||
|
$action='update';
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
if (! GETPOST('bank'))
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), 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);
|
$account->fetch($id);
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$account->socid = $object->id;
|
||||||
|
|
||||||
$account->socid = $object->id;
|
$account->bank = GETPOST('bank','alpha');
|
||||||
|
$account->label = GETPOST('label','alpha');
|
||||||
|
$account->courant = GETPOST('courant','alpha');
|
||||||
|
$account->clos = GETPOST('clos','alpha');
|
||||||
|
$account->code_banque = GETPOST('code_banque','alpha');
|
||||||
|
$account->code_guichet = GETPOST('code_guichet','alpha');
|
||||||
|
$account->number = GETPOST('number','alpha');
|
||||||
|
$account->cle_rib = GETPOST('cle_rib','alpha');
|
||||||
|
$account->bic = GETPOST('bic','alpha');
|
||||||
|
$account->iban = GETPOST('iban','alpha');
|
||||||
|
$account->domiciliation = GETPOST('domiciliation','alpha');
|
||||||
|
$account->proprio = GETPOST('proprio','alpha');
|
||||||
|
$account->owner_address = GETPOST('owner_address','alpha');
|
||||||
|
$account->frstrecur = GETPOST('frstrecur','alpha');
|
||||||
|
|
||||||
$account->bank = $_POST["bank"];
|
$result = $account->update($user);
|
||||||
$account->label = $_POST["label"];
|
if (! $result)
|
||||||
$account->courant = $_POST["courant"];
|
|
||||||
$account->clos = $_POST["clos"];
|
|
||||||
$account->code_banque = $_POST["code_banque"];
|
|
||||||
$account->code_guichet = $_POST["code_guichet"];
|
|
||||||
$account->number = $_POST["number"];
|
|
||||||
$account->cle_rib = $_POST["cle_rib"];
|
|
||||||
$account->bic = $_POST["bic"];
|
|
||||||
$account->iban = $_POST["iban"];
|
|
||||||
$account->domiciliation = $_POST["domiciliation"];
|
|
||||||
$account->proprio = $_POST["proprio"];
|
|
||||||
$account->owner_address = $_POST["owner_address"];
|
|
||||||
$account->frstrecur = GETPOST('frstrecur');
|
|
||||||
|
|
||||||
$result = $account->update($user);
|
|
||||||
if (! $result)
|
|
||||||
{
|
|
||||||
setEventMessages($account->error, $account->errors, 'errors');
|
|
||||||
$_GET["action"]='edit'; // Force chargement page edition
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If this account is the default bank account, we disable others
|
|
||||||
if ($account->default_rib)
|
|
||||||
{
|
{
|
||||||
$account->setAsDefault($id); // This will make sure there is only one default rib
|
setEventMessages($account->error, $account->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If this account is the default bank account, we disable others
|
||||||
|
if ($account->default_rib)
|
||||||
|
{
|
||||||
|
$account->setAsDefault($id); // This will make sure there is only one default rib
|
||||||
|
}
|
||||||
|
|
||||||
$url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
|
$url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
|
||||||
header('Location: '.$url);
|
header('Location: '.$url);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'add' && ! $_POST["cancel"])
|
if ($action == 'add' && ! $_POST["cancel"])
|
||||||
@ -114,6 +141,18 @@ if ($action == 'add' && ! $_POST["cancel"])
|
|||||||
$action='create';
|
$action='create';
|
||||||
$error++;
|
$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)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@ -122,19 +161,19 @@ if ($action == 'add' && ! $_POST["cancel"])
|
|||||||
|
|
||||||
$account->socid = $object->id;
|
$account->socid = $object->id;
|
||||||
|
|
||||||
$account->bank = $_POST["bank"];
|
$account->bank = GETPOST('bank','alpha');
|
||||||
$account->label = $_POST["label"];
|
$account->label = GETPOST('label','alpha');
|
||||||
$account->courant = $_POST["courant"];
|
$account->courant = GETPOST('courant','alpha');
|
||||||
$account->clos = $_POST["clos"];
|
$account->clos = GETPOST('clos','alpha');
|
||||||
$account->code_banque = $_POST["code_banque"];
|
$account->code_banque = GETPOST('code_banque','alpha');
|
||||||
$account->code_guichet = $_POST["code_guichet"];
|
$account->code_guichet = GETPOST('code_guichet','alpha');
|
||||||
$account->number = $_POST["number"];
|
$account->number = GETPOST('number','alpha');
|
||||||
$account->cle_rib = $_POST["cle_rib"];
|
$account->cle_rib = GETPOST('cle_rib','alpha');
|
||||||
$account->bic = $_POST["bic"];
|
$account->bic = GETPOST('bic','alpha');
|
||||||
$account->iban = $_POST["iban"];
|
$account->iban = GETPOST('iban','alpha');
|
||||||
$account->domiciliation = $_POST["domiciliation"];
|
$account->domiciliation = GETPOST('domiciliation','alpha');
|
||||||
$account->proprio = $_POST["proprio"];
|
$account->proprio = GETPOST('proprio','alpha');
|
||||||
$account->owner_address = $_POST["owner_address"];
|
$account->owner_address = GETPOST('owner_address','alpha');
|
||||||
$account->frstrecur = GETPOST('frstrecur');
|
$account->frstrecur = GETPOST('frstrecur');
|
||||||
|
|
||||||
$result = $account->update($user); // TODO Use create and include update into create method
|
$result = $account->update($user); // TODO Use create and include update into create method
|
||||||
@ -265,35 +304,31 @@ if ($socid && $action != 'edit' && $action != "create")
|
|||||||
$content = $account->number;
|
$content = $account->number;
|
||||||
} elseif ($val == 'BankAccountNumberKey') {
|
} elseif ($val == 'BankAccountNumberKey') {
|
||||||
$content = $account->cle_rib;
|
$content = $account->cle_rib;
|
||||||
|
}elseif ($val == 'IBAN') {
|
||||||
|
$content = $account->iban;
|
||||||
|
if (! empty($account->iban)) {
|
||||||
|
if (! checkIbanForAccount($account)) {
|
||||||
|
$content.= img_picto($langs->trans("IbanNotValid"),'warning');
|
||||||
|
} else {
|
||||||
|
$content.= img_picto($langs->trans("IbanValid"),'info');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}elseif ($val == 'BIC') {
|
||||||
|
$content = $account->bic;
|
||||||
|
if (! empty($account->bic)) {
|
||||||
|
if (! checkSwiftForAccount($account)) {
|
||||||
|
$content.= img_picto($langs->trans("SwiftNotValid"),'warning');
|
||||||
|
} else {
|
||||||
|
$content.= img_picto($langs->trans("SwiftValid"),'info');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans($val).'</td>';
|
print '<tr><td>'.$langs->trans($val).'</td>';
|
||||||
print '<td colspan="3">'.$content.'</td>';
|
print '<td colspan="4">'.$content.'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
|
|
||||||
print '<td colspan="4">'.$account->iban . ' ';
|
|
||||||
if (! empty($account->iban)) {
|
|
||||||
if (! checkIbanForAccount($account)) {
|
|
||||||
print img_picto($langs->trans("IbanNotValid"),'warning');
|
|
||||||
} else {
|
|
||||||
print img_picto($langs->trans("IbanValid"),'info');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
|
|
||||||
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 '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
|
||||||
print $account->domiciliation;
|
print $account->domiciliation;
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
@ -432,6 +467,8 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
|||||||
|
|
||||||
// Show fields of bank account
|
// Show fields of bank account
|
||||||
foreach ($account->getFieldsToShow() as $val) {
|
foreach ($account->getFieldsToShow() as $val) {
|
||||||
|
|
||||||
|
$require=false;
|
||||||
if ($val == 'BankCode') {
|
if ($val == 'BankCode') {
|
||||||
$name = 'code_banque';
|
$name = 'code_banque';
|
||||||
$size = 8;
|
$size = 8;
|
||||||
@ -448,20 +485,23 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
|
|||||||
$name = 'cle_rib';
|
$name = 'cle_rib';
|
||||||
$size = 3;
|
$size = 3;
|
||||||
$content = $account->cle_rib;
|
$content = $account->cle_rib;
|
||||||
|
} elseif ($val == 'IBAN') {
|
||||||
|
$name = 'iban';
|
||||||
|
$size = 30;
|
||||||
|
$content = $account->iban;
|
||||||
|
$require=true;
|
||||||
|
} elseif ($val == 'BIC') {
|
||||||
|
$name = 'bic';
|
||||||
|
$size = 12;
|
||||||
|
$content = $account->bic;
|
||||||
|
$require=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans($val).'</td>';
|
print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>';
|
||||||
print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
|
print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// IBAN
|
|
||||||
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("IBAN").'</td>';
|
|
||||||
print '<td colspan="4"><input size="30" type="text" name="iban" value="'.$account->iban.'"></td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td valign="top" class="fieldrequired">'.$langs->trans("BIC").'</td>';
|
|
||||||
print '<td colspan="4"><input size="12" type="text" name="bic" value="'.$account->bic.'"></td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
|
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
|
||||||
print '<textarea name="domiciliation" rows="4" cols="40">';
|
print '<textarea name="domiciliation" rows="4" cols="40">';
|
||||||
print $account->domiciliation;
|
print $account->domiciliation;
|
||||||
@ -527,6 +567,13 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
|
|||||||
print '<tr><td class="fieldrequired">'.$langs->trans("Bank").'</td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans("Bank").'</td>';
|
||||||
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
|
||||||
|
print '<tr><td valign="top" 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 '<td colspan="4"><input size="12" type="text" name="bic" value="'.GETPOST('bic').'"></td></tr>';
|
||||||
|
|
||||||
// BBAN
|
// BBAN
|
||||||
if ($account->useDetailedBBAN() == 1)
|
if ($account->useDetailedBBAN() == 1)
|
||||||
{
|
{
|
||||||
@ -556,13 +603,6 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// IBAN
|
|
||||||
print '<tr><td valign="top">'.$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">'.$langs->trans("BIC").'</td>';
|
|
||||||
print '<td colspan="4"><input size="12" type="text" name="bic" value="'.GETPOST('bic').'"></td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
|
print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="4">';
|
||||||
print '<textarea name="domiciliation" rows="4" cols="40">';
|
print '<textarea name="domiciliation" rows="4" cols="40">';
|
||||||
print GETPOST('domiciliation');
|
print GETPOST('domiciliation');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user