From 6a91b169951f945e7e82f3ee83d2e50c677390a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 25 Nov 2017 12:13:03 +0100 Subject: [PATCH] info bank --- htdocs/compta/bank/class/account.class.php | 5 ++++- htdocs/compta/bank/list.php | 6 +++--- htdocs/core/boxes/box_comptes.php | 20 +++++++++++++------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index e9704d81c9e36..ff396f344e4bb 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -854,10 +854,12 @@ function fetch($id, $ref='') $sql.= " ba.datec as date_creation, ba.tms as date_update,"; $sql.= ' c.code as country_code, c.label as country,'; $sql.= ' d.code_departement as state_code, d.nom as state'; + $sql.= ' , aj.code as accountancy_journal'; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON ba.fk_pays = c.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON ba.state_id = d.rowid'; - $sql.= " WHERE entity IN (".getEntity($this->element).")"; + $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'accounting_journal as aj ON aj.rowid=ba.fk_accountancy_journal'; + $sql.= " WHERE ba.entity IN (".getEntity($this->element).")"; if ($id) $sql.= " AND ba.rowid = ".$id; if ($ref) $sql.= " AND ba.ref = '".$this->db->escape($ref)."'"; @@ -900,6 +902,7 @@ function fetch($id, $ref='') $this->account_number = $obj->account_number; $this->fk_accountancy_journal = $obj->fk_accountancy_journal; + $this->accountancy_journal = $obj->accountancy_journal; $this->currency_code = $obj->currency_code; $this->account_currency_code = $obj->currency_code; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 7d40b4820d147..9f90bd3996401 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -143,7 +143,7 @@ // Load array of financial accounts (opened by default) $accounts = array(); -$sql = "SELECT b.rowid, b.label, b.courant, b.rappro, b.account_number, b.fk_accountancy_journal, b.currency_code, b.datec as date_creation, b.tms as date_update"; +$sql = "SELECT b.rowid, b.label, b.courant, b.rappro, b.account_number, b.fk_accountancy_journal, b.currency_code, b.datec as date_creation, b.tms as date_update"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -152,7 +152,7 @@ $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account_extrafields as ef on (b.rowid = ef.fk_object)"; -$sql.= " WHERE entity IN (".getEntity('bank_account').")"; +$sql.= " WHERE b.entity IN (".getEntity('bank_account').")"; if ($search_status == 'opened') $sql.= " AND clos = 0"; if ($search_status == 'closed') $sql.= " AND clos = 1"; if ($search_ref != '') $sql.=natural_search('b.ref', $search_ref); @@ -509,7 +509,7 @@ if (! empty($conf->accounting->enabled)) { $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('',$obj->account_number); + $accountingaccount->fetch('',$obj->account_number, 1); print $accountingaccount->getNomUrl(0,1,1,'',1); } else diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index f68393df6a55c..52f8e6c7d9edb 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -80,13 +80,16 @@ function loadBox($max=5) $this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts")); if ($user->rights->banque->lire) { - $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, owner_address,"; - $sql.= " account_number, currency_code,"; - $sql.= " min_allowed, min_desired, comment"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; - $sql.= " WHERE entity = ".$conf->entity; + $sql = "SELECT b.rowid, b.ref, b.label, b.bank,b.number, b.courant, b.clos, b.rappro, b.url"; + $sql.= ", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban"; + $sql.= ", b.domiciliation, b.proprio, b.owner_address"; + $sql.= ", b.account_number, b.currency_code"; + $sql.= ", b.min_allowed, b.min_desired, comment"; + $sql.= ', b.fk_accountancy_journal'; + $sql.= ', aj.code as accountancy_journal'; + $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b"; + $sql.= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal'; + $sql.= " WHERE b.entity = ".$conf->entity; $sql.= " AND clos = 0"; //$sql.= " AND courant = 1"; $sql.= " ORDER BY label"; @@ -108,6 +111,9 @@ function loadBox($max=5) $account_static->ref = $objp->ref; $account_static->label = $objp->label; $account_static->number = $objp->number; + $account_static->account_number = $objp->account_number; + $account_static->currency_code = $objp->currency_code; + $account_static->accountancy_journal = $objp->accountancy_journal; $solde=$account_static->solde(0); $solde_total[$objp->currency_code] += $solde;