From 1be9c53b6c06039431d9a17e733474e7b00cd13a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 19 Mar 2016 19:39:18 +0100 Subject: [PATCH 1/3] NEW Created FormBank::getIBANLabel function to get the label of "IBAN" depending on bank account country --- htdocs/compta/bank/card.php | 9 +++------ htdocs/core/class/html.formbank.class.php | 15 +++++++++++++++ htdocs/core/lib/pdf.lib.php | 4 ++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index b33b0438552..e6721e1b73d 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -447,9 +447,8 @@ if ($action == 'create') } } } - $ibankey="IBANNumber"; + $ibankey = FormBank::getIBANLabel($account); $bickey="BICNumber"; - if ($account->getCountryCode() == 'IN') $ibankey="IFSC"; if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; // IBAN @@ -711,9 +710,8 @@ else } } - $ibankey="IBANNumber"; + $ibankey = FormBank::getIBANLabel($account); $bickey="BICNumber"; - if ($account->getCountryCode() == 'IN') $ibankey="IFSC"; if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; print ''.$langs->trans($ibankey).''; @@ -1000,9 +998,8 @@ else } } - $ibankey="IBANNumber"; + $ibankey = FormBank::getIBANLabel($account); $bickey="BICNumber"; - if ($account->getCountryCode() == 'IN') $ibankey="IFSC"; if ($account->getCountryCode() == 'IN') $bickey="SWIFT"; // IBAN diff --git a/htdocs/core/class/html.formbank.class.php b/htdocs/core/class/html.formbank.class.php index 450441cf54c..4ee00555b85 100644 --- a/htdocs/core/class/html.formbank.class.php +++ b/htdocs/core/class/html.formbank.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016 Marcos GarcĂ­a * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,5 +57,19 @@ class FormBank print Form::selectarray($htmlname, $account->type_lib, $selected); } + /** + * Returns the name of the Iban label. India uses 'IFSC' and the rest of the world 'IBAN' name. + * + * @param Account $account Account object + * @return string + */ + public static function getIBANLabel(Account $account) + { + if ($account->getCountryCode() == 'IN') { + return 'IFSC'; + } + + return 'IBANNumber'; + } } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index a952159b874..d9a6fea2131 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -749,8 +749,8 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default else if (! $usedetailedbban) $cury+=1; // Use correct name of bank id according to country - $ibankey="IBANNumber"; - if ($account->getCountryCode() == 'IN') $ibankey="IFSC"; + $ibankey = FormBank::getIBANLabel($account); + if (! empty($account->iban)) { //Remove whitespaces to ensure we are dealing with the format we expect From 8ef122ad99c963e6e932f391c90a2b2d95a98a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 19 Mar 2016 20:12:41 +0100 Subject: [PATCH 2/3] Fixed missing require bug --- htdocs/core/lib/pdf.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d9a6fea2131..8f9b7d44ada 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -602,6 +602,8 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) */ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default_font_size=10) { + require_once DOL_DOCUMENT_ROOT.'/core/class/FormBank.class.php'; + global $mysoc, $conf; $diffsizetitle=(empty($conf->global->PDF_DIFFSIZE_TITLE)?3:$conf->global->PDF_DIFFSIZE_TITLE); From 7fbf16a2025960f0952aca222097125d7fef7adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 19 Mar 2016 20:51:43 +0100 Subject: [PATCH 3/3] Fixed an error including FormBank class --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 8f9b7d44ada..9c70635a957 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -602,7 +602,7 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) */ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default_font_size=10) { - require_once DOL_DOCUMENT_ROOT.'/core/class/FormBank.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbank.class.php'; global $mysoc, $conf;