diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php
index b653cfbf5c002dd1e6dc9aca370e1231587f25b7..e8961645c627c707e9bd312d1e325f8497333f60 100644
--- a/htdocs/core/lib/usergroups.lib.php
+++ b/htdocs/core/lib/usergroups.lib.php
@@ -1,6 +1,7 @@
 <?php
 /* Copyright (C) 2006-2012	Laurent Destailleur	<eldy@users.sourceforge.net>
  * Copyright (C) 2010-2012	Regis Houssin		<regis.houssin@capnetworks.com>
+ * Copyright (C) 2015	    Alexandre Spangaro	<aspangaro.dolibarr@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
@@ -93,6 +94,15 @@ function user_prepare_head($object)
     // $this->tabs = array('entity:-tabname);   												to remove a tab
     complete_head_from_modules($conf,$langs,$object,$head,$h,'user');
 
+	if (! empty($conf->hrm->enabled))
+    {
+		// Bank
+    	$head[$h][0] = DOL_URL_ROOT.'/user/bank.php?id='.$object->id;
+    	$head[$h][1] = $langs->trans("Bank");
+    	$head[$h][2] = 'bank';
+    	$h++;
+	}
+
     //Info on users is visible only by internal user
     if (empty($user->societe_id))
     {
diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql
index c15288d834ba0e18c466bfb47244d37461fe84fc..cf3aa3fdf98aec87e890e465be4e2b39b941aea9 100755
--- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql
+++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql
@@ -205,7 +205,24 @@ CREATE TABLE IF NOT EXISTS llx_establishment (
   status            smallint DEFAULT 1
 ) ENGINE=InnoDB;
 
-
+CREATE TABLE IF NOT EXISTS llx_user_rib (
+  rowid          integer AUTO_INCREMENT PRIMARY KEY,
+  fk_user        integer      NOT NULL,
+  entity         integer DEFAULT 1 NOT NULL,	-- multi company id
+  datec          datetime,
+  tms            timestamp,
+  label          varchar(30),
+  bank           varchar(255),  -- bank name
+  code_banque    varchar(128),  -- bank code
+  code_guichet   varchar(6),    -- desk code
+  number         varchar(255),  -- account number
+  cle_rib        varchar(5),    -- key of bank account
+  bic            varchar(11),   -- 11 according to ISO 9362
+  iban_prefix    varchar(34),	-- full iban. 34 according to ISO 13616
+  domiciliation  varchar(255),
+  proprio        varchar(60),
+  owner_address  varchar(255)
+)ENGINE=innodb;
 
 ALTER TABLE llx_projet_task_time ADD COLUMN invoice_id integer DEFAULT NULL;
 ALTER TABLE llx_projet_task_time ADD COLUMN invoice_line_id integer DEFAULT NULL;
diff --git a/htdocs/install/mysql/tables/llx_societe_rib.sql b/htdocs/install/mysql/tables/llx_societe_rib.sql
index e8f995130d4cb0983c6ccbbc738eff11a6d32a8f..e003b6d706e3c0f7b9f74fa866a3a398a9923463 100644
--- a/htdocs/install/mysql/tables/llx_societe_rib.sql
+++ b/htdocs/install/mysql/tables/llx_societe_rib.sql
@@ -19,10 +19,11 @@
 --
 -- =============================================================================
 
-create table llx_societe_rib
+create table llx_user_rib
 (
   rowid          integer AUTO_INCREMENT PRIMARY KEY,
-  fk_soc         integer NOT NULL,
+  fk_user        integer      NOT NULL,
+  entity         integer DEFAULT 1 NOT NULL,	-- multi company id
   datec          datetime,
   tms            timestamp,
   label          varchar(30),
@@ -31,15 +32,10 @@ create table llx_societe_rib
   code_guichet   varchar(6),    -- desk code
   number         varchar(255),  -- account number
   cle_rib        varchar(5),    -- key of bank account
-  bic            varchar(20),  -- 11 according to ISO 9362 (we keep 20 for backward compatibility)
+  bic            varchar(11),   -- 11 according to ISO 9362
   iban_prefix    varchar(34),	-- full iban. 34 according to ISO 13616
   domiciliation  varchar(255),
   proprio        varchar(60),
   owner_address  varchar(255),
-  default_rib    smallint NOT NULL DEFAULT 0,
-  
-  rum            varchar(32),	 				-- RUM value to use for SEPA generation
-  frstrecur      varchar(16) default 'FRST',  -- 'FRST' or 'RECUR'
-
-  import_key     varchar(14)    -- import key
+  default_rib    smallint NOT NULL DEFAULT 0
 )ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_user_rib.sql b/htdocs/install/mysql/tables/llx_user_rib.sql
new file mode 100644
index 0000000000000000000000000000000000000000..05738ce45826e5de8dcd2f63af3276bc533716a8
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_user_rib.sql
@@ -0,0 +1,37 @@
+-- =============================================================================
+-- Copyright (C) 2015     Alexandre Spangaro  <aspangaro.dolibarr@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
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+--
+-- =============================================================================
+
+create table llx_user_rib
+(
+  rowid          integer AUTO_INCREMENT PRIMARY KEY,
+  fk_user        integer      NOT NULL,
+  entity         integer DEFAULT 1 NOT NULL,	-- multi company id
+  datec          datetime,
+  tms            timestamp,
+  label          varchar(30),
+  bank           varchar(255),  -- bank name
+  code_banque    varchar(128),  -- bank code
+  code_guichet   varchar(6),    -- desk code
+  number         varchar(255),  -- account number
+  cle_rib        varchar(5),    -- key of bank account
+  bic            varchar(11),   -- 11 according to ISO 9362
+  iban_prefix    varchar(34),	-- full iban. 34 according to ISO 13616
+  domiciliation  varchar(255),
+  proprio        varchar(60),
+  owner_address  varchar(255)
+)ENGINE=innodb;
diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php
new file mode 100644
index 0000000000000000000000000000000000000000..0325fcd0a508f0c37e9dc0af5f4a0c8c01c92de2
--- /dev/null
+++ b/htdocs/user/bank.php
@@ -0,0 +1,390 @@
+<?php
+/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2003      Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2004-2015 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2009 Regis Houssin        <regis.houssin@capnetworks.com>
+ * Copyright (C) 2013      Peter Fontaine       <contact@peterfontaine.fr>
+ * Copyright (C) 2015      Marcos GarcĂ­a        <marcosgdf@gmail.com>
+ * Copyright (C) 2015	   Alexandre Spangaro	<aspangaro.dolibarr@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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/user/bank.php
+ *      \ingroup    HRM
+ *		\brief      BAN tab for users
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php';
+
+$langs->load("companies");
+$langs->load("commercial");
+$langs->load("banks");
+$langs->load("bills");
+
+$id = GETPOST('id','int');
+$action = GETPOST("action");
+
+// Security check
+$socid=0;
+if ($user->societe_id > 0) $socid = $user->societe_id;
+$feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
+if ($user->id == $id) $feature2=''; // A user can always read its own card
+$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
+
+$object = new User($db);
+if ($id > 0 || ! empty($ref))
+{
+	$result = $object->fetch($id, $ref);
+}
+
+/*
+ *	Actions
+ */
+
+if ($action == 'update' && ! $_POST["cancel"])
+{
+	// Modification
+	$account = new UserBankAccount($db);
+
+    $account->fetch($id);
+
+    $account->userid          = $object->id;
+
+	$account->bank            = $_POST["bank"];
+	$account->label           = $_POST["label"];
+	$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"];
+
+	$result = $account->update($user);
+	if (! $result)
+	{
+		setEventMessage($account->error, 'errors');
+		$_GET["action"]='edit';     // Force chargement page edition
+	}
+	else
+	{
+		$url=DOL_URL_ROOT.'/user/bank.php?id='.$object->id;
+        header('Location: '.$url);
+        exit;
+	}
+}
+
+/*
+ *	View
+ */
+
+$form = new Form($db);
+
+llxHeader();
+
+$head = user_prepare_head($object);
+
+$account = new UserBankAccount($db);
+if (! $id)
+    $account->fetch(0,$object->id);
+else
+    $account->fetch($id);
+if (empty($account->userid)) $account->userid=$object->id;
+
+
+if ($id && $action == 'edit' && $user->rights->user->user->creer)
+{
+    print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="action" value="update">';
+    print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
+}
+if ($id && $action == 'create' && $user->rights->user->user->creer)
+{
+    print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="action" value="add">';
+}
+
+
+// View
+if ($id && $action != 'edit')
+{
+	$title = $langs->trans("User");
+	dol_fiche_head($head, 'bank', $title, 0, 'user');
+
+	$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
+	
+    dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin);
+        
+    print '<div class="fichecenter">';
+
+    print '<div class="underbanner clearboth"></div>';
+    print '<table class="border centpercent">';
+
+    print '<tr><td class="titlefield">'.$langs->trans("LabelRIB").'</td>';
+    print '<td colspan="4">'.$account->label.'</td></tr>';
+
+	print '<tr><td>'.$langs->trans("BankName").'</td>';
+	print '<td colspan="4">'.$account->bank.'</td></tr>';
+
+	// Show fields of bank account
+	$fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey';
+	if (! empty($conf->global->BANK_SHOW_ORDER_OPTION))
+	{
+		if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION))
+		{
+			if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber';
+		}
+		else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION;
+	}
+	$fieldlistsarray=explode(' ',$fieldlists);
+
+	foreach($fieldlistsarray as $val)
+	{
+		if ($val == 'BankCode')
+		{
+			if ($account->useDetailedBBAN() == 1)
+			{
+				print '<tr><td>'.$langs->trans("BankCode").'</td>';
+				print '<td colspan="3">'.$account->code_banque.'</td>';
+				print '</tr>';
+			}
+		}
+		if ($val == 'DeskCode')
+		{
+			if ($account->useDetailedBBAN() == 1)
+			{
+				print '<tr><td>'.$langs->trans("DeskCode").'</td>';
+				print '<td colspan="3">'.$account->code_guichet.'</td>';
+				print '</tr>';
+			}
+		}
+
+		if ($val == 'BankCode')
+		{
+			if ($account->useDetailedBBAN() == 2)
+	        {
+	            print '<tr><td>'.$langs->trans("BankCode").'</td>';
+	            print '<td colspan="3">'.$account->code_banque.'</td>';
+	            print '</tr>';
+	        }
+		}
+
+		if ($val == 'AccountNumber')
+		{
+			print '<tr><td>'.$langs->trans("BankAccountNumber").'</td>';
+			print '<td colspan="3">'.$account->number.'</td>';
+			print '</tr>';
+		}
+
+		if ($val == 'BankAccountNumberKey')
+		{
+			if ($account->useDetailedBBAN() == 1)
+			{
+				print '<tr><td>'.$langs->trans("BankAccountNumberKey").'</td>';
+				print '<td colspan="3">'.$account->cle_rib.'</td>';
+				print '</tr>';
+			}
+		}
+	}
+
+	print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
+	print '<td colspan="4">'.$account->iban . '&nbsp;';
+    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.'&nbsp;';
+    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 $account->domiciliation;
+	print "</td></tr>\n";
+
+	print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td><td colspan="4">';
+	print $account->proprio;
+	print "</td></tr>\n";
+
+	print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="4">';
+	print $account->owner_address;
+	print "</td></tr>\n";
+
+	print '</table>';
+
+	// Check BBAN
+	if ($account->label && ! checkBanForAccount($account))
+	{
+		print '<div class="warning">'.$langs->trans("RIBControlError").'</div>';
+	}
+
+    print "</div>";
+    
+    dol_fiche_end();
+
+	/*
+	 * Barre d'actions
+	 */
+	print '<div class="tabsAction">';
+
+	if ($user->rights->user->user->creer)
+	{
+		print '<a class="butAction" href="bank.php?id='.$object->id.'&amp;action=edit">'.$langs->trans("Edit").'</a>';
+	}
+
+	print '</div>';
+}
+
+// Edit
+if ($id && $action == 'edit' && $user->rights->user->user->creer)
+{
+	$title = $langs->trans("User");
+	dol_fiche_head($head, 'bank', $title, 0, 'user');
+
+	$linkback = '<a href="'.DOL_URL_ROOT.'/user/index.php">'.$langs->trans("BackToList").'</a>';
+	
+    dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin);
+        
+    print '<div class="fichecenter">';
+    
+    print '<div class="underbanner clearboth"></div>';
+	print '<table class="border centpercent">';
+
+    print '<tr><td valign="top" width="35%" class="fieldrequired">'.$langs->trans("LabelRIB").'</td>';
+    print '<td colspan="4"><input size="30" type="text" name="label" value="'.$account->label.'"></td></tr>';
+
+    print '<tr><td class="fieldrequired">'.$langs->trans("BankName").'</td>';
+    print '<td><input size="30" type="text" name="bank" value="'.$account->bank.'"></td></tr>';
+
+	// Show fields of bank account
+	$fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey';
+	if (! empty($conf->global->BANK_SHOW_ORDER_OPTION))
+	{
+		if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION))
+		{
+			if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber';
+		}
+		else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION;
+	}
+	$fieldlistsarray=explode(' ',$fieldlists);
+
+	foreach($fieldlistsarray as $val)
+	{
+		if ($val == 'BankCode')
+		{
+			if ($account->useDetailedBBAN()  == 1)
+			{
+				print '<tr><td>'.$langs->trans("BankCode").'</td>';
+				print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
+				print '</tr>';
+			}
+		}
+
+		if ($val == 'DeskCode')
+		{
+			if ($account->useDetailedBBAN()  == 1)
+			{
+				print '<tr><td>'.$langs->trans("DeskCode").'</td>';
+				print '<td><input size="8" type="text" class="flat" name="code_guichet" value="'.$account->code_guichet.'"></td>';
+				print '</tr>';
+			}
+		}
+
+		if ($val == 'BankCode')
+		{
+			if ($account->useDetailedBBAN()  == 2)
+	        {
+	            print '<tr><td>'.$langs->trans("BankCode").'</td>';
+	            print '<td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
+	            print '</tr>';
+	        }
+		}
+
+		if ($val == 'AccountNumber')
+		{
+			print '<td class="fieldrequired">'.$langs->trans("BankAccountNumber").'</td>';
+			print '<td><input size="18" type="text" class="flat" name="number" value="'.$account->number.'"></td>';
+			print '</tr>';
+		}
+
+		if ($val == 'BankAccountNumberKey')
+		{
+			if ($account->useDetailedBBAN() == 1)
+			{
+				print '<td>'.$langs->trans("BankAccountNumberKey").'</td>';
+				print '<td><input size="3" type="text" class="flat" name="cle_rib" value="'.$account->cle_rib.'"></td>';
+				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 '<textarea name="domiciliation" rows="4" cols="40">';
+    print $account->domiciliation;
+    print "</textarea></td></tr>";
+
+    print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td>';
+    print '<td colspan="4"><input size="30" type="text" name="proprio" value="'.$account->proprio.'"></td></tr>';
+    print "</td></tr>\n";
+
+    print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="4">';
+    print "<textarea name=\"owner_address\" rows=\"4\" cols=\"40\">";
+    print $account->owner_address;
+    print "</textarea></td></tr>";
+
+    print '</table>';
+
+    print '</div>';
+    
+    dol_fiche_end();
+
+	print '<div align="center">';
+	print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">';
+    print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
+	print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
+    print '</div>';
+}
+
+llxFooter();
+
+$db->close();
diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php
new file mode 100644
index 0000000000000000000000000000000000000000..1f48be28187d7f10b9e37a7b1092d080a1739f25
--- /dev/null
+++ b/htdocs/user/class/userbankaccount.class.php
@@ -0,0 +1,284 @@
+<?php
+/* Copyright (C) 2004		Rodolphe Quiedeville	<rodolphe@quiedeville.org>
+ * Copyright (C) 2010-2013	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2012		Regis Houssin			<regis.houssin@capnetworks.com>
+ * Copyright (C) 2013   	Peter Fontaine          <contact@peterfontaine.fr>
+ * Copyright (C) 2015	    Alexandre Spangaro	    <aspangaro.dolibarr@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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * 		\file		htdocs/user/class/userbankaccount.class.php
+ *		\ingroup    user
+ *		\brief      File of class to manage bank accounts description of users
+ */
+
+require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
+
+
+/**
+ * 	Class to manage bank accounts description of third parties
+ */
+class UserBankAccount extends Account
+{
+    var $socid;
+
+    var $default_rib;
+
+    var $datec;
+    var $datem;
+
+
+    /**
+	 *  Constructor
+	 *
+	 *  @param      DoliDB		$db      Database handler
+     */
+    function __construct($db)
+    {
+        $this->db = $db;
+
+        $this->socid = 0;
+        $this->clos = 0;
+        $this->solde = 0;
+        $this->error_number = 0;
+        $this->default_rib = 0;
+        return 1;
+    }
+
+
+    /**
+     * Create bank information record
+     *
+     * @param   Object   $user		User
+     * @return	int					<0 if KO, >= 0 if OK
+     */
+    function create($user='')
+    {
+        $now=dol_now();
+
+        $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rib (fk_user, datec)";
+        $sql.= " VALUES (".$this->userid.", '".$this->db->idate($now)."')";
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            if ($this->db->affected_rows($resql))
+            {
+                $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."user_rib");
+                return 1;
+            }
+        }
+        else
+        {
+            print $this->db->error();
+            return 0;
+        }
+    }
+
+    /**
+     *	Update bank account
+     *
+     *	@param	User	$user	Object user
+     *	@return	int				<=0 if KO, >0 if OK
+     */
+    function update($user='')
+    {
+    	global $conf;
+
+        if (! $this->id)
+        {
+            $this->create();
+        }
+
+        $sql = "UPDATE ".MAIN_DB_PREFIX."user_rib SET";
+        $sql.= " bank = '" .$this->db->escape($this->bank)."'";
+        $sql.= ",code_banque='".$this->code_banque."'";
+        $sql.= ",code_guichet='".$this->code_guichet."'";
+        $sql.= ",number='".$this->number."'";
+        $sql.= ",cle_rib='".$this->cle_rib."'";
+        $sql.= ",bic='".$this->bic."'";
+        $sql.= ",iban_prefix = '".$this->iban."'";
+        $sql.= ",domiciliation='".$this->db->escape($this->domiciliation)."'";
+        $sql.= ",proprio = '".$this->db->escape($this->proprio)."'";
+        $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'";
+
+	    if (trim($this->label) != '')
+            $sql.= ",label = '".$this->db->escape($this->label)."'";
+        else
+            $sql.= ",label = NULL";
+        $sql.= " WHERE rowid = ".$this->id;
+
+        $result = $this->db->query($sql);
+        if ($result)
+        {
+            return 1;
+        }
+        else
+        {
+            dol_print_error($this->db);
+            return 0;
+        }
+    }
+
+    /**
+     * 	Load record from database
+     *
+     *	@param	int		$id			Id of record
+     * 	@param	int		$socid		Id of company. If this is filled, function will return the default RIB of company
+     * 	@return	int					<0 if KO, >0 if OK
+     */
+    function fetch($id, $socid=0)
+    {
+        if (empty($id) && empty($socid)) return -1;
+
+        $sql = "SELECT rowid, fk_user, entity, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
+        $sql.= " owner_address, default_rib, label, datec, tms as datem";
+        $sql.= " FROM ".MAIN_DB_PREFIX."user_rib";
+        if ($id)    $sql.= " WHERE rowid = ".$id;
+        if ($socid) $sql.= " WHERE fk_user  = ".$userid;
+
+        $resql = $this->db->query($sql);
+        if ($resql)
+        {
+            if ($this->db->num_rows($resql))
+            {
+                $obj = $this->db->fetch_object($resql);
+
+                $this->id			   = $obj->rowid;
+                $this->socid           = $obj->fk_soc;
+                $this->bank            = $obj->bank;
+                $this->code_banque     = $obj->code_banque;
+                $this->code_guichet    = $obj->code_guichet;
+                $this->number          = $obj->number;
+                $this->cle_rib         = $obj->cle_rib;
+                $this->bic             = $obj->bic;
+                $this->iban		       = $obj->iban;
+                $this->domiciliation   = $obj->domiciliation;
+                $this->proprio         = $obj->proprio;
+                $this->owner_address   = $obj->owner_address;
+                $this->label           = $obj->label;
+                $this->datec           = $this->db->jdate($obj->datec);
+                $this->datem           = $this->db->jdate($obj->datem);
+            }
+            $this->db->free($resql);
+
+            return 1;
+        }
+        else
+        {
+            dol_print_error($this->db);
+            return -1;
+        }
+    }
+
+    /**
+     *  Delete a rib from database
+     *
+     *	@param	User	$user	User deleting
+     *  @return int         	<0 if KO, >0 if OK
+     */
+    function delete($user)
+    {
+        global $conf;
+
+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rib";
+        $sql.= " WHERE rowid  = ".$this->id;
+
+        dol_syslog(get_class($this)."::delete", LOG_DEBUG);
+        $result = $this->db->query($sql);
+        if ($result) {
+            return 1;
+        }
+        else {
+            dol_print_error($this->db);
+            return -1;
+        }
+    }
+
+    /**
+     * Return RIB
+     *
+     * @param   boolean     $displayriblabel     Prepend or Hide Label
+     * @return	string		RIB
+     */
+    function getRibLabel($displayriblabel = true)
+    {
+    	global $langs,$conf;
+
+    	if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib)
+    	{
+            if ($this->label && $displayriblabel) $rib = $this->label." : ";
+
+    		// Show fields of bank account
+			$fieldlists='BankCode DeskCode AccountNumber BankAccountNumberKey';
+			if (! empty($conf->global->BANK_SHOW_ORDER_OPTION))
+			{
+				if (is_numeric($conf->global->BANK_SHOW_ORDER_OPTION))
+				{
+					if ($conf->global->BANK_SHOW_ORDER_OPTION == '1') $fieldlists='BankCode DeskCode BankAccountNumberKey AccountNumber';
+				}
+				else $fieldlists=$conf->global->BANK_SHOW_ORDER_OPTION;
+			}
+			$fieldlistsarray=explode(' ',$fieldlists);
+
+			foreach($fieldlistsarray as $val)
+			{
+				if ($val == 'BankCode')
+				{
+					if ($this->useDetailedBBAN()  == 1)
+					{
+						$rib.=$this->code_banque.'&nbsp;';
+					}
+				}
+
+				if ($val == 'DeskCode')
+				{
+					if ($this->useDetailedBBAN()  == 1)
+					{
+						$rib.=$this->code_guichet.'&nbsp;';
+					}
+				}
+
+				if ($val == 'BankCode')
+				{
+					if ($this->useDetailedBBAN()  == 2)
+			        {
+			            $rib.=$this->code_banque.'&nbsp;';
+			        }
+				}
+
+				if ($val == 'AccountNumber')
+				{
+					$rib.=$this->number.'&nbsp;';
+				}
+
+				if ($val == 'BankAccountNumberKey')
+				{
+					if ($this->useDetailedBBAN() == 1)
+					{
+						$rib.=$this->cle_rib.'&nbsp;';
+					}
+				}
+			}
+    	}
+    	else
+    	{
+    		$rib='';
+    	}
+
+    	return $rib;
+    }
+}
+