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 '
'; + print ''; print ''; print ''; print ''; @@ -179,9 +192,11 @@ if ($_GET["action"] == 'create') print ''.$langs->trans("Ref").''; print ''; + // Label print ''.$langs->trans("LabelBankCashAccount").''; print ''; + // Type print ''.$langs->trans("AccountType").''; print ''; print $form->select_type_comptes_financiers(isset($_POST["type"])?$_POST["type"]:1,"type"); @@ -201,21 +216,42 @@ if ($_GET["action"] == 'create') // Currency print ''.$langs->trans("Currency").''; print ''; - $selectedcode=$account->account_currency_code; if (! $selectedcode) $selectedcode=$conf->monnaie; - $form->select_currency($selectedcode, 'account_currency_code'); + $form->select_currency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->monnaie); //print ''; - print ''; - // Pays + // Status + print ''.$langs->trans("Status").''; + print ''; + $form->select_array("clos",array(0=>$account->status[0],1=>$account->status[1]),(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); + print ''; + + // Country print ''.$langs->trans("Country").''; print ''; - $selectedcode=$account->account_country_code; - if (! $selectedcode) $selectedcode=$mysoc->pays_code; - $form->select_pays($selectedcode, 'account_country_code'); + $selectedcode=''; + if (isset($_POST["account_country_id"])) + { + $selectedcode=$_POST["account_country_id"]?$_POST["account_country_id"]:$account->pays_code; + } + else if (empty($selectedcode)) $selectedcode=$mysoc->pays_code; + $form->select_pays($selectedcode,'account_country_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_create()"':''); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print ''; + + // State + print ''.$langs->trans('State').''; + if ($selectedcode) + { + $htmlcompany->select_departement(isset($_POST["account_departement_id"])?$_POST["account_departement_id"]:'',$selectedcode,'account_departement_id'); + } + else + { + print $countrynotdefined; + } print ''; // Web @@ -248,7 +284,7 @@ if ($_GET["action"] == 'create') print ''.$langs->trans("Date").''; print ''; - $form->select_date(time(), 're', 0, 0, 0, 'createbankaccount'); + $form->select_date(time(), 're', 0, 0, 0, 'formsoc'); print ''; print ''.$langs->trans("BalanceMinimalAllowed").''; @@ -268,7 +304,7 @@ if ($_GET["action"] == 'create') /* ************************************************************************** */ else { - if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit') + if (($_GET["id"] || $_GET["ref"]) && $_REQUEST["action"] != 'edit') { $account = new Account($db); if ($_GET["id"]) @@ -292,7 +328,7 @@ else /* * Confirmation to delete */ - if ($_GET["action"] == 'delete') + if ($_REQUEST["action"] == 'delete') { $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$account->id,$langs->trans("DeleteAccount"),$langs->trans("ConfirmDeleteAccount"),"confirm_delete"); if ($ret == 'html') print '
'; @@ -306,15 +342,37 @@ else 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).''; + // Country + print ''.$langs->trans("Country").''; + if ($account->fk_pays > 0) print getCountry($account->fk_pays); + print ''; + + // State + print ''.$langs->trans('State').''; + if ($account->fk_departement > 0) print getState($account->fk_departement); + print ''; + + // Conciliate print ''.$langs->trans("Conciliable").''; print ''; if ($account->type == 0 || $account->type == 1) print ($account->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')')); @@ -328,16 +386,6 @@ else print ''.$account->account_number.''; } - // Currency - print ''.$langs->trans("Currency").''; - print ''; - - $selectedcode=$account->account_currency_code; - if (! $selectedcode) $selectedcode=$conf->monnaie; - print $langs->trans("Currency".$selectedcode); - - print ''; - print ''.$langs->trans("BalanceMinimalAllowed").''; print ''.$account->min_allowed.''; @@ -385,40 +433,78 @@ else /* */ /* ************************************************************************** */ - if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configurer) + if ($_REQUEST["id"] && $_REQUEST["action"] == 'edit' && $user->rights->banque->configurer) { - $account = new Account($db, $_GET["id"]); - $account->fetch($_GET["id"]); + $account = new Account($db, $_REQUEST["id"]); + $account->fetch($_REQUEST["id"]); - print_titre($langs->trans("EditFinancialAccount")); + print_fiche_titre($langs->trans("EditFinancialAccount")); print "
"; if ($message) { print "$message
\n"; } - print ''; + print ''; print ''; print ''; - print ''."\n\n"; + print ''."\n\n"; print ''; // Ref - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + // Label + print ''; + print ''; - print ''; + // Type + print ''; print ''; - print ''; + // Currency + print ''; + print ''; + + // Status + print ''; print ''; + // Country + $account->pays_id=$account->pays_id?$account->pays_id:$mysoc->pays_id; + print ''; + print ''; + + // State + print ''; + print ''; print ''; - print ''; + print ''; } else { - print ''; + print 'account_number).'">'; } - // Currency - print ''; - print ''; - + // Balance print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Web print ''; - print ''; // Comment @@ -468,13 +541,13 @@ else if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_SOCIETE) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); - $doleditor=new DolEditor('account_comment',$account->comment,200,'dolibarr_notes','',false); + $doleditor=new DolEditor('account_comment',(isset($_POST["account_comment"])?$_POST["account_comment"]:$account->comment),200,'dolibarr_notes','',false); $doleditor->Create(); } else { print ''; + print dol_htmlentitiesbr_decode(isset($_POST["account_comment"])?$_POST["account_comment"]:$account->comment).''; } print ''; diff --git a/htdocs/compta/bank/pre.inc.php b/htdocs/compta/bank/pre.inc.php index 0de0776f744..af7caeb264c 100644 --- a/htdocs/compta/bank/pre.inc.php +++ b/htdocs/compta/bank/pre.inc.php @@ -40,33 +40,6 @@ function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0 top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers $menu = new Menu(); - if ($user->rights->banque->lire) - { - $sql = "SELECT rowid, label, courant"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " AND clos = 0"; - - $resql = $db->query($sql); - if ($resql) - { - $numr = $db->num_rows($resql); - $i = 0; - - while ($i < $numr) - { - $objp = $db->fetch_object($resql); - $menu->add(DOL_URL_ROOT."/compta/bank/fiche.php?id=".$objp->rowid,$objp->label,0,$user->rights->banque->lire); -/* - $menu->add_submenu(DOL_URL_ROOT."/compta/bank/annuel.php?account=".$objp->rowid ,$langs->trans("IOMonthlyReporting")); - $menu->add_submenu(DOL_URL_ROOT."/compta/bank/graph.php?account=".$objp->rowid ,$langs->trans("Graph")); - if ($objp->courant != 2) $menu->add_submenu(DOL_URL_ROOT."/compta/bank/releve.php?account=".$objp->rowid ,$langs->trans("AccountStatements")); -*/ - $i++; - } - } - $db->free($resql); - } $menu->add(DOL_URL_ROOT."/compta/bank/index.php",$langs->trans("MenuBankCash"),0,$user->rights->banque->lire); @@ -92,6 +65,37 @@ function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0 $menu->add_submenu(DOL_URL_ROOT."/compta/paiement/cheque/liste.php?leftmenu=bank&mainmenu=bank",$langs->trans("MenuChequesReceipts"),1,$user->rights->banque->cheque); } + // Entry for each bank account + if ($user->rights->banque->lire) + { + $sql = "SELECT rowid, label, courant"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; + $sql.= " WHERE entity = ".$conf->entity; + $sql.= " AND clos = 0"; + + $resql = $db->query($sql); + if ($resql) + { + $numr = $db->num_rows($resql); + $i = 0; + + if ($numr > 0) $menu->add(DOL_URL_ROOT."/compta/bank/index.php",$langs->trans("BankAccounts"),0,$user->rights->banque->lire); + + while ($i < $numr) + { + $objp = $db->fetch_object($resql); + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/fiche.php?id=".$objp->rowid,$objp->label,1,$user->rights->banque->lire); +/* + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/annuel.php?account=".$objp->rowid ,$langs->trans("IOMonthlyReporting")); + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/graph.php?account=".$objp->rowid ,$langs->trans("Graph")); + if ($objp->courant != 2) $menu->add_submenu(DOL_URL_ROOT."/compta/bank/releve.php?account=".$objp->rowid ,$langs->trans("AccountStatements")); +*/ + $i++; + } + } + $db->free($resql); + } + left_menu($menu->liste); } ?> diff --git a/htdocs/compta/paiement/cheque/pre.inc.php b/htdocs/compta/paiement/cheque/pre.inc.php index b6c8ff18931..fcce15db1a9 100644 --- a/htdocs/compta/paiement/cheque/pre.inc.php +++ b/htdocs/compta/paiement/cheque/pre.inc.php @@ -40,33 +40,6 @@ function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0 top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers $menu = new Menu(); - if ($user->rights->banque->lire) - { - $sql = "SELECT rowid, label, courant"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE entity = ".$conf->entity; - $sql.= " AND clos = 0"; - - $resql = $db->query($sql); - if ($resql) - { - $numr = $db->num_rows($resql); - $i = 0; - - while ($i < $numr) - { - $objp = $db->fetch_object($resql); - $menu->add(DOL_URL_ROOT."/compta/bank/fiche.php?id=".$objp->rowid,$objp->label,0,$user->rights->banque->lire); -/* - $menu->add_submenu(DOL_URL_ROOT."/compta/bank/annuel.php?account=".$objp->rowid ,$langs->trans("IOMonthlyReporting")); - $menu->add_submenu(DOL_URL_ROOT."/compta/bank/graph.php?account=".$objp->rowid ,$langs->trans("Graph")); - if ($objp->courant != 2) $menu->add_submenu(DOL_URL_ROOT."/compta/bank/releve.php?account=".$objp->rowid ,$langs->trans("AccountStatements")); -*/ - $i++; - } - } - $db->free($resql); - } $menu->add(DOL_URL_ROOT."/compta/bank/index.php",$langs->trans("MenuBankCash"),0,$user->rights->banque->lire); @@ -92,6 +65,37 @@ function llxHeader($head = '', $title='', $help_url='', $target='', $disablejs=0 $menu->add_submenu(DOL_URL_ROOT."/compta/paiement/cheque/liste.php?leftmenu=bank&mainmenu=bank",$langs->trans("MenuChequesReceipts"),1,$user->rights->banque->cheque); } + // Entry for each bank account + if ($user->rights->banque->lire) + { + $sql = "SELECT rowid, label, courant"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; + $sql.= " WHERE entity = ".$conf->entity; + $sql.= " AND clos = 0"; + + $resql = $db->query($sql); + if ($resql) + { + $numr = $db->num_rows($resql); + $i = 0; + + if ($numr > 0) $menu->add(DOL_URL_ROOT."/compta/bank/index.php",$langs->trans("BankAccounts"),0,$user->rights->banque->lire); + + while ($i < $numr) + { + $objp = $db->fetch_object($resql); + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/fiche.php?id=".$objp->rowid,$objp->label,1,$user->rights->banque->lire); +/* + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/annuel.php?account=".$objp->rowid ,$langs->trans("IOMonthlyReporting")); + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/graph.php?account=".$objp->rowid ,$langs->trans("Graph")); + if ($objp->courant != 2) $menu->add_submenu(DOL_URL_ROOT."/compta/bank/releve.php?account=".$objp->rowid ,$langs->trans("AccountStatements")); +*/ + $i++; + } + } + $db->free($resql); + } + left_menu($menu->liste); } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 0d0c015076e..8bc1084c7da 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -182,15 +182,15 @@ class FormCompany * \remarks La cle de la liste est le code (il peut y avoir plusieurs entree pour * un code donnee mais dans ce cas, le champ pays differe). * Ainsi les liens avec les departements se font sur un departement independemment de son nom. - * \param selected Code forme juridique a preselectionne - * \param pays_code 0=liste tous pays confondus, sinon code du pays a afficher + * \param selected Code state preselected + * \param pays_code 0=list for all countries, otherwise country code or country rowid to show * \param departement_id Id of department */ function select_departement($selected='',$pays_code=0, $htmlname='departement_id') { global $conf,$langs,$user; - dol_syslog("Form::select_departement selected=$selected, pays_code=$pays_code",LOG_DEBUG); + dol_syslog("FormCompany::select_departement selected=$selected, pays_code=$pays_code",LOG_DEBUG); $langs->load("dict"); @@ -199,10 +199,11 @@ class FormCompany $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_pays as p"; $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid"; $sql .= " AND d.active = 1 AND r.active = 1 AND p.active = 1"; - if ($pays_code) $sql .= " AND p.code = '".$pays_code."'"; + if ($pays_code && is_numeric($pays_code)) $sql .= " AND p.rowid = '".$pays_code."'"; + if ($pays_code && ! is_numeric($pays_code)) $sql .= " AND p.code = '".$pays_code."'"; $sql .= " ORDER BY p.code, d.code_departement"; - dol_syslog("Form::select_departement sql=".$sql); + dol_syslog("FormCompany::select_departement sql=".$sql); $result=$this->db->query($sql); if ($result) { @@ -210,7 +211,7 @@ class FormCompany if ($pays_code) print ''; $num = $this->db->num_rows($result); $i = 0; - dol_syslog("Form::select_departement num=$num",LOG_DEBUG); + dol_syslog("FormCompany::select_departement num=$num",LOG_DEBUG); if ($num) { $pays=''; diff --git a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql index 03a95ba4aa9..c28357d5a5a 100755 --- a/htdocs/install/mysql/migration/2.8.0-2.9.0.sql +++ b/htdocs/install/mysql/migration/2.8.0-2.9.0.sql @@ -11,8 +11,8 @@ -- V4.1 UPDATE llx_projet_task set fk_user_creat=NULL WHERE fk_user_creat IS NOT NULL AND fk_user_creat NOT IN (SELECT rowid from llx_user); -- V4.1 UPDATE llx_projet_task set fk_user_valid=NULL WHERE fk_user_valid IS NOT NULL AND fk_user_valid NOT IN (SELECT rowid from llx_user); -ALTER table llx_bank_account ADD COLUMN fk_pays integer DEFAULT 0 after domiciliation; - +ALTER table llx_bank_account ADD COLUMN fk_pays integer DEFAULT 0 NOT NULL after domiciliation; +ALTER TABLE llx_bank_account ADD COLUMN fk_departement integer DEFAULT NULL after domiciliation; ALTER TABLE llx_socpeople ADD COLUMN fk_departement integer DEFAULT NULL after ville; ALTER TABLE llx_adherent ADD COLUMN fk_departement integer DEFAULT NULL after ville; ALTER TABLE llx_entrepot ADD COLUMN fk_departement integer DEFAULT NULL after ville; diff --git a/htdocs/install/mysql/tables/llx_bank_account.sql b/htdocs/install/mysql/tables/llx_bank_account.sql index 41918c805dc..a18cd7b2ada 100644 --- a/htdocs/install/mysql/tables/llx_bank_account.sql +++ b/htdocs/install/mysql/tables/llx_bank_account.sql @@ -41,7 +41,8 @@ create table llx_bank_account country_iban varchar(2), -- deprecated cle_iban varchar(2), domiciliation varchar(255), - fk_pays integer DEFAULT 0, + fk_departement integer DEFAULT NULL, + fk_pays integer NOT NULL, proprio varchar(60), adresse_proprio varchar(255), courant smallint DEFAULT 0 NOT NULL, diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index b36dde2ee6f..19d378b1508 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -42,6 +42,7 @@ LastAccountStatements=Last account statements Rapprochement=Reconciliate IOMonthlyReporting=Monthly reporting BankAccountDomiciliation=Account address +BankAccountCountry=Account country BankAccountOwner=Account owner name BankAccountOwnerAddress=Account owner address RIBControlError=Inetgrity checks of values fails. This means information for this account number are not complete or wrong (check country, numbers and IBAN). diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index a008ddd4316..b1c03d57a4e 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -42,6 +42,7 @@ LastAccountStatements=Derniers relevés bancaires Rapprochement=Rapprochement IOMonthlyReporting=Rapport mensuel E/S BankAccountDomiciliation=Domiciliation du compte +BankAccountCountry=Pays du compte BankAccountOwner=Nom du propriétaire du compte BankAccountOwnerAddress=Adresse du propriétaire du compte RIBControlError=Les contrôles indiquent que les informations de ce compte bancaire sont incomplètes ou incorrectes (vérifier le pays, les numéros de compte ou IBAN). diff --git a/htdocs/lib/company.lib.php b/htdocs/lib/company.lib.php index 451865d5aec..b6e43b06d20 100644 --- a/htdocs/lib/company.lib.php +++ b/htdocs/lib/company.lib.php @@ -180,8 +180,8 @@ function societe_prepare_head2($objsoc) /** - * \brief Return country translated from an id - * \param id id of country + * \brief Return country translated from an id or a code + * \param id id or code of country * \param withcode 0=Return label, 1=Return code + label, 2=Return code * \return string String with country code or translated country name */ @@ -190,7 +190,8 @@ function getCountry($id,$withcode=0) global $db,$langs; $sql = "SELECT rowid, code, libelle FROM ".MAIN_DB_PREFIX."c_pays"; - $sql.= " WHERE rowid=".$id; + if (is_numeric($id)) $sql.= " WHERE rowid=".$id; + else $sql.= " WHERE code='".$id."'"; dol_syslog("Company.lib::getCountry sql=".$sql); $resql=$db->query($sql);
'.$langs->trans("Ref").'
'.$langs->trans("Ref").'ref).'">
'.$langs->trans("Label").'
'.$langs->trans("Label").'label).'">
'.$langs->trans("AccountType").'
'.$langs->trans("AccountType").''; - print $form->select_type_comptes_financiers($account->type,"type"); + print $form->select_type_comptes_financiers((isset($_POST["type"])?$_POST["type"]:$account->type),"type"); print '
'.$langs->trans("Status").'
'.$langs->trans("Currency"); + print ''; + print ''; + $selectedcode=$account->account_currency_code; + if (! $selectedcode) $selectedcode=$conf->monnaie; + $form->select_currency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); + //print $langs->trans("Currency".$conf->monnaie); + //print ''; + print '
'.$langs->trans("Status").''; - $form->select_array("clos",array(0=>$account->status[0],1=>$account->status[1]),$account->clos); + $form->select_array("clos",array(0=>$account->status[0],1=>$account->status[1]),(isset($_POST["clos"])?$_POST["clos"]:$account->clos)); print '
'.$langs->trans("Country").''; + $selectedcode=$account->pays_code; + if (isset($_POST["account_country_id"])) $selectedcode=$_POST["account_country_id"]; + else if (empty($selectedcode)) $selectedcode=$mysoc->pays_code; + $form->select_pays($selectedcode,'account_country_id',$conf->use_javascript_ajax?' onChange="company_save_refresh_edit()"':''); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'.$langs->trans('State').''; + if ($selectedcode) + { + $htmlcompany->select_departement(isset($_POST["account_departement_id"])?$_POST["account_departement_id"]:$account->fk_departement,$selectedcode,'account_departement_id'); + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans("Conciliable").''; if ($account->type == 0 || $account->type == 1) print 'rappro?'':'checked="true"').'"> '.$langs->trans("DisableConciliation"); @@ -429,36 +515,23 @@ else if ($conf->accounting->enabled) { print '
'.$langs->trans("AccountancyCode").'
account_number).'">
'.$langs->trans("Currency"); - print ''; - print ''; - - $selectedcode=$account->account_currency_code; - if (! $selectedcode) $selectedcode=$conf->monnaie; - $form->select_currency($selectedcode, 'account_currency_code'); - //print $langs->trans("Currency".$conf->monnaie); - //print ''; - - print '
'.$langs->trans("BalanceMinimalAllowed").'
min_allowed).'">
'.$langs->trans("BalanceMinimalDesired").'
min_desired).'">
'.$langs->trans("Web").''; + print 'url).'">'; print '