diff --git a/ChangeLog b/ChangeLog
index c75d64d8f5b..af9a2e81eba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,8 +4,8 @@ English Dolibarr ChangeLog
For users:
- New: POS module allow to choose which warehouse use.
-- New: Support "Department/State" field on company setup, contact
- and members card.
+- New: Support "Department/State" field on company setup, contact,
+ bank account and members card.
- New: Can reopen a refused/canceled supplier order.
- New: Add Gant diagramm on project module.
- New: Add a new mode for automatic stock increase: Can be increased
@@ -40,6 +40,7 @@ For users:
- New: IBAN value is called IFSC if country is India.
- New: Add option to choose firstname-name or name-firstname.
- New: Add company in fields exported by export of members tool.
+- New: Reorganise bank menu.
- Fix: Debug experimental module widthrawal.
- Fix: Format number was wrong for ar_AR language.
- Fix: Can change password if has only permission change password.
diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php
index 0b8107ef5a8..e8d22732fc6 100644
--- a/htdocs/adherents/fiche.php
+++ b/htdocs/adherents/fiche.php
@@ -800,7 +800,7 @@ if ($action == 'edit')
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
print '';
- // Department
+ // State
print '
'.$langs->trans('State').' ';
$htmlcompany->select_departement($adh->fk_departement,$adh->pays_code);
print ' ';
@@ -1228,7 +1228,7 @@ if ($rowid && $action != 'edit')
// Country
print ''.$langs->trans("Country").' '.getCountry($adh->pays_id).' ';
- // Department
+ // State
print ''.$langs->trans('State').' '.$adh->departement.' ';
// Tel pro.
diff --git a/htdocs/compta/bank/bankid_fr.php b/htdocs/compta/bank/bankid_fr.php
index d20a901620b..e6f2fff0945 100644
--- a/htdocs/compta/bank/bankid_fr.php
+++ b/htdocs/compta/bank/bankid_fr.php
@@ -28,6 +28,7 @@
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
$langs->load("banks");
@@ -61,6 +62,8 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
$account->domiciliation = trim($_POST["domiciliation"]);
$account->proprio = trim($_POST["proprio"]);
$account->adresse_proprio = trim($_POST["adresse_proprio"]);
+ $account->fk_departement = trim($_POST["fk_departement"]);
+ //$account->fk_pays = trim($_POST["fk_pays"]); // We do not change this.
if ($account->id)
{
@@ -146,12 +149,23 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit')
print $form->showrefnav($account,'ref','',1,'ref');
print ' ';
+ // Label
print ''.$langs->trans("Label").' ';
print ''.$account->label.' ';
+ // Type
print ''.$langs->trans("AccountType").' ';
print ''.$account->type_lib[$account->type].' ';
+ // Currency
+ print ''.$langs->trans("Currency").' ';
+ print '';
+ $selectedcode=$account->account_currency_code;
+ if (! $selectedcode) $selectedcode=$conf->monnaie;
+ print $langs->trans("Currency".$selectedcode);
+ print ' ';
+
+ // Status
print ''.$langs->trans("Status").' ';
print ''.$account->getLibStatut(4).' ';
@@ -182,16 +196,25 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit')
print '';
}
- print ''.$langs->trans("IBAN").' ';
+ $ibankey="IBANNumber";
+ $bickey="BICNumber";
+ if ($account->getCountryCode() == 'IN') $ibankey="IFSC";
+ if ($account->getCountryCode() == 'IN') $bickey="SWIFT";
+
+ print ''.$langs->trans($ibankey).' ';
print ''.$account->iban_prefix.' ';
- print ''.$langs->trans("BIC").' ';
+ print ''.$langs->trans($bickey).' ';
print ''.$account->bic.' ';
print ''.$langs->trans("BankAccountDomiciliation").' ';
print nl2br($account->domiciliation);
print " \n";
+ print ''.$langs->trans("BankAccountCountry").' ';
+ print getCountry($account->getCountryCode());
+ print " \n";
+
print ''.$langs->trans("BankAccountOwner").' ';
print $account->proprio;
print " \n";
@@ -200,9 +223,6 @@ if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit')
print nl2br($account->adresse_proprio);
print "\n";
- print ''.$langs->trans("CountryCode").' ';
- print $account->getCountryCode();
- print " \n";
}
print '';
@@ -253,14 +273,25 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure
print ''.$account->ref;
print ' ';
+ // Label
print ''.$langs->trans("Label").' ';
print ''.$account->label;
print ' ';
+ // Type
print ''.$langs->trans("AccountType").' ';
print ''.$account->type_lib[$account->type];
print ' ';
+ // Currency
+ print ''.$langs->trans("Currency").' ';
+ print '';
+ $selectedcode=$account->account_currency_code;
+ if (! $selectedcode) $selectedcode=$conf->monnaie;
+ print $langs->trans("Currency".$selectedcode);
+ print ' ';
+
+ // Status
print ''.$langs->trans("Status").' ';
print ''.$account->getLibStatut(4);
print ' ';
@@ -268,7 +299,7 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure
if ($account->type == 0 || $account->type == 1)
{
// If bank account
- print ''.$langs->trans("Bank").' ';
+ print ''.$langs->trans("BankName").' ';
print ' ';
print ' ';
@@ -295,11 +326,16 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure
print '';
}
+ $ibankey="IBANNumber";
+ $bickey="BICNumber";
+ if ($account->getCountryCode() == 'IN') $ibankey="IFSC";
+ if ($account->getCountryCode() == 'IN') $bickey="SWIFT";
+
// IBAN
- print ''.$langs->trans("IBAN").' ';
+ print ''.$langs->trans($ibankey).' ';
print ' ';
- print ''.$langs->trans("BIC").' ';
+ print ''.$langs->trans($bickey).' ';
print ' ';
print ''.$langs->trans("BankAccountDomiciliation").' ';
@@ -307,6 +343,10 @@ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configure
print $account->domiciliation;
print " ";
+ print ''.$langs->trans("BankAccountCountry").' ';
+ print getCountry($account->getCountryCode());
+ print " \n";
+
print ''.$langs->trans("BankAccountOwner").' ';
print ' ';
print ' ';
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index e11d278e045..fae5657155f 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -64,6 +64,15 @@ class Account extends CommonObject
var $iban_prefix;
var $proprio;
var $adresse_proprio;
+
+ var $fk_departement;
+ var $departement_code;
+ var $departement;
+
+ var $fk_pays;
+ var $pays_code;
+ var $pays;
+
var $type_lib=array();
var $account_number;
@@ -309,15 +318,23 @@ class Account extends CommonObject
// Check parameters
if (! $this->min_allowed) $this->min_allowed=0;
if (! $this->min_desired) $this->min_desired=0;
+ if (empty($this->fk_pays))
+ {
+ $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Country"));
+ dol_syslog("Account::update ".$this->error, LOG_ERR);
+ return -1;
+ }
+ if (empty($this->ref))
+ {
+ $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
+ dol_syslog("Account::update ".$this->error, LOG_ERR);
+ return -1;
+ }
// Chargement librairie pour acces fonction controle RIB
require_once DOL_DOCUMENT_ROOT.'/lib/bank.lib.php';
- if (! $this->ref)
- {
- $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
- return -1;
- }
+ $now=dol_now();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_account (";
$sql.= "datec";
@@ -330,8 +347,10 @@ class Account extends CommonObject
$sql.= ", min_allowed";
$sql.= ", min_desired";
$sql.= ", comment";
+ $sql.= ", fk_departement";
+ $sql.= ", fk_pays";
$sql.= ") VALUES (";
- $sql.= $this->db->idate(mktime());
+ $sql.= "'".$this->db->idate($now)."'";
$sql.= ", '".addslashes($this->ref)."'";
$sql.= ", '".addslashes($this->label)."'";
$sql.= ", ".$conf->entity;
@@ -341,6 +360,8 @@ class Account extends CommonObject
$sql.= ", ".price2num($this->min_allowed);
$sql.= ", ".price2num($this->min_desired);
$sql.= ", '".addslashes($this->comment)."'";
+ $sql.= ", ".($this->fk_departement>0?"'".$this->fk_departement."'":"null");
+ $sql.= ", ".$this->fk_pays;
$sql.= ")";
dol_syslog("Account::create sql=".$sql);
@@ -362,7 +383,7 @@ class Account extends CommonObject
$sql.= ", fk_type";
$sql.= ", rappro";
$sql.= ") VALUES (";
- $sql.= $this->db->idate(mktime());
+ $sql.= $this->db->idate($now);
$sql.= ", '(".$langs->trans("InitialBankBalance").")'";
$sql.= ", ".price2num($this->solde);
$sql.= ", '".$this->id."'";
@@ -405,10 +426,15 @@ class Account extends CommonObject
// Check parameters
if (! $this->min_allowed) $this->min_allowed=0;
if (! $this->min_desired) $this->min_desired=0;
-
- if (! $this->ref)
+ if (empty($this->fk_pays))
{
- $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref"));
+ $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Country"));
+ dol_syslog("Account::update ".$this->error, LOG_ERR);
+ return -1;
+ }
+ if (empty($this->ref))
+ {
+ $this->error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
dol_syslog("Account::update ".$this->error, LOG_ERR);
return -1;
}
@@ -431,6 +457,9 @@ class Account extends CommonObject
$sql.= ",min_desired = '".price2num($this->min_desired)."'";
$sql.= ",comment = '".addslashes($this->comment)."'";
+ $sql.= ",fk_departement = ".($this->fk_departement>0?"'".$this->fk_departement."'":"null");
+ $sql.= ",fk_pays = ".$this->fk_pays;
+
$sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
@@ -481,6 +510,8 @@ class Account extends CommonObject
$sql.= ",domiciliation='".addslashes($this->domiciliation)."'";
$sql.= ",proprio = '".addslashes($this->proprio)."'";
$sql.= ",adresse_proprio = '".addslashes($this->adresse_proprio)."'";
+ $sql.= ",fk_departement = ".($this->fk_departement>0?"'".$this->fk_departement."'":"null");
+ $sql.= ",fk_pays = ".$this->fk_pays;
$sql.= " WHERE rowid = ".$this->id;
$sql.= " AND entity = ".$conf->entity;
@@ -509,15 +540,19 @@ class Account extends CommonObject
{
global $conf;
- $sql = "SELECT rowid, ref, label, bank, number, courant, clos, rappro, url,";
- $sql.= " code_banque, code_guichet, cle_rib, bic, iban_prefix as iban,";
- $sql.= " domiciliation, proprio, adresse_proprio,";
- $sql.= " account_number, currency_code,";
- $sql.= " min_allowed, min_desired, comment";
- $sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
+ $sql = "SELECT ba.rowid, ba.ref, ba.label, ba.bank, ba.number, ba.courant, ba.clos, ba.rappro, ba.url,";
+ $sql.= " ba.code_banque, ba.code_guichet, ba.cle_rib, ba.bic, ba.iban_prefix as iban,";
+ $sql.= " ba.domiciliation, ba.proprio, ba.adresse_proprio, ba.fk_departement, ba.fk_pays,";
+ $sql.= " ba.account_number, ba.currency_code,";
+ $sql.= " ba.min_allowed, ba.min_desired, ba.comment,";
+ $sql.= ' p.code as pays_code, p.libelle as pays,';
+ $sql.= ' d.code_departement as departement_code, d.nom as departement';
+ $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_pays as p ON ba.fk_pays = p.rowid';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON ba.fk_departement = d.rowid';
$sql.= " WHERE entity = ".$conf->entity;
- if ($id) $sql.= " AND rowid = ".$id;
- if ($ref) $sql.= " AND ref = '".addslashes($ref)."'";
+ if ($id) $sql.= " AND ba.rowid = ".$id;
+ if ($ref) $sql.= " AND ba.ref = '".addslashes($ref)."'";
dol_syslog("Account::fetch sql=".$sql);
$result = $this->db->query($sql);
@@ -549,6 +584,14 @@ class Account extends CommonObject
$this->proprio = $obj->proprio;
$this->adresse_proprio = $obj->adresse_proprio;
+ $this->fk_departement = $obj->fk_departement;
+ $this->departement_code= $obj->departement_code;
+ $this->departement = $obj->departement;
+
+ $this->fk_pays = $obj->fk_pays;
+ $this->pays_code = $obj->pays_code;
+ $this->pays = $obj->pays;
+
$this->account_number = $obj->account_number;
$this->currency_code = $obj->currency_code;
@@ -824,21 +867,24 @@ class Account extends CommonObject
/**
* \brief Return account country code
* \return String country code
- * TODO Manage field with country in bank_account
*/
function getCountryCode()
{
global $mysoc;
+ // We return country code of bank account
+ if (! empty($this->pays_code)) return $this->pays_code;
+
+ // For backward compatibility, we try to guess country from other information
if (! empty($this->iban))
{
- if ($mysoc->pays_code === 'IN') return $mysoc->pays_code; // Test before to use IBAN
+ if ($mysoc->pays_code === 'IN') return $mysoc->pays_code; // Test to know if we can trust IBAN
// If IBAN defined, we can know country of account from it
if (preg_match("/^([a-zA-Z][a-zA-Z])/i",$this->iban,$reg)) return $reg[1];
}
- // We return country code
+ // We return country code of company
if (! empty($mysoc->pays_code)) return $mysoc->pays_code;
return '';
diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php
index 6e818201ab6..6a433da2fb0 100644
--- a/htdocs/compta/bank/fiche.php
+++ b/htdocs/compta/bank/fiche.php
@@ -28,8 +28,11 @@
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php");
$langs->load("banks");
+$langs->load("companies");
// Security check
if (isset($_GET["id"]) || isset($_GET["ref"]))
@@ -62,7 +65,9 @@ if ($_POST["action"] == 'add')
$account->date_solde = dol_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
$account->currency_code = trim($_POST["account_currency_code"]);
- $account->country_code = trim($_POST["account_country_code"]);
+
+ $account->fk_departement = $_POST["account_departement_id"];
+ $account->fk_pays = $_POST["account_country_id"];
$account->min_allowed = $_POST["account_min_allowed"];
$account->min_desired = $_POST["account_min_desired"];
@@ -77,11 +82,11 @@ if ($_POST["action"] == 'add')
}
else {
$message=''.$account->error().'
';
- $_GET["action"]='create'; // Force chargement page en mode creation
+ $_REQUEST["action"]='create'; // Force chargement page en mode creation
}
} else {
$message=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("LabelBankCashAccount")).'
';
- $_GET["action"]='create'; // Force chargement page en mode creation
+ $_REQUEST["action"]='create'; // Force chargement page en mode creation
}
}
@@ -113,7 +118,10 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
$account->account_number = trim($_POST["account_number"]);
$account->currency_code = trim($_POST["account_currency_code"]);
- $account->country_code = trim($_POST["account_country_code"]);
+
+ $account->fk_departement = $_POST["account_departement_id"];
+ $account->fk_pays = $_POST["account_country_id"];
+
$account->min_allowed = $_POST["account_min_allowed"];
$account->min_desired = $_POST["account_min_desired"];
@@ -129,11 +137,11 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"])
else
{
$message=''.$account->error().'
';
- $_GET["action"]='edit'; // Force chargement page edition
+ $_REQUEST["action"]='edit'; // Force chargement page edition
}
} else {
$message=''.$langs->trans("ErrorFieldRequired",$langs->transnoentities("LabelBankCashAccount")).'
';
- $_GET["action"]='create'; // Force chargement page en mode creation
+ $_REQUEST["action"]='create'; // Force chargement page en mode creation
}
}
@@ -152,9 +160,12 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user-
* View
*/
+$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
+
llxHeader();
$form = new Form($db);
+$htmlcompany = new FormCompany($db);
/* ************************************************************************** */
/* */
@@ -162,13 +173,15 @@ $form = new Form($db);
/* */
/* ************************************************************************** */
-if ($_GET["action"] == 'create')
+if ($_REQUEST["action"] == 'create')
{
+ $account=new Account($db);
+
print_fiche_titre($langs->trans("NewFinancialAccount"));
if ($message) { print "$message \n"; }
- print '