From 1be9c53b6c06039431d9a17e733474e7b00cd13a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?=
 <marcosgdf@gmail.com>
Date: Sat, 19 Mar 2016 19:39:18 +0100
Subject: [PATCH] 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 '<tr><td>'.$langs->trans($ibankey).'</td>';
@@ -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 @@
 <?php
 /* Copyright (C) 2012		Laurent Destailleur	<eldy@users.sourceforge.net>
  * Copyright (C) 2015		Alexandre Spangaro	<aspangaro.dolibarr@gmail.com>
+ * Copyright (C) 2016       Marcos GarcĂ­a       <marcosgdf@gmail.com>
  *
  * 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
-- 
GitLab