66 $listofmodulesforexternal = explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
67 if (!in_array(
'banque', $listofmodulesforexternal) && !empty($user->socid)) {
71 $this->hidden = empty($user->rights->banque->lire);
82 global $user, $langs, $conf;
86 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleCurrentAccounts"));
88 if ($user->rights->banque->lire) {
89 $sql =
"SELECT b.rowid, b.ref, b.label, b.bank,b.number, b.courant, b.clos, b.rappro, b.url";
90 $sql .=
", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban";
91 $sql .=
", b.domiciliation, b.proprio, b.owner_address";
92 $sql .=
", b.account_number, b.currency_code";
93 $sql .=
", b.min_allowed, b.min_desired, comment";
94 $sql .=
', b.fk_accountancy_journal';
95 $sql .=
', aj.code as accountancy_journal';
96 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as b";
97 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal';
98 $sql .=
" WHERE b.entity = ".$conf->entity;
99 $sql .=
" AND clos = 0";
101 $sql .=
" ORDER BY label";
102 $sql .= $this->db->plimit($max, 0);
104 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
105 $result = $this->db->query($sql);
107 $num = $this->db->num_rows($result);
110 $solde_total = array();
112 $account_static =
new Account($this->db);
113 while ($line < $num) {
114 $objp = $this->db->fetch_object($result);
116 $account_static->id = $objp->rowid;
117 $account_static->ref = $objp->ref;
118 $account_static->label = $objp->label;
119 $account_static->number = $objp->number;
120 $account_static->account_number = $objp->account_number;
121 $account_static->currency_code = $objp->currency_code;
122 $account_static->accountancy_journal = $objp->accountancy_journal;
123 $solde = $account_static->solde(0);
125 if (!array_key_exists($objp->currency_code, $solde_total)) {
126 $solde_total[$objp->currency_code] = $solde;
128 $solde_total[$objp->currency_code] += $solde;
132 $this->info_box_contents[$line][] = array(
134 'text' => $account_static->getNomUrl(1),
138 $this->info_box_contents[$line][] = array(
140 'text' => $objp->number,
143 $this->info_box_contents[$line][] = array(
144 'td' =>
'class="nowraponall right amount"',
145 'text' =>
'<a href="'.DOL_URL_ROOT.
'/compta/bank/bankentries_list.php?id='.$account_static->id.
'">'
146 .price($solde, 0, $langs, 1, -1, -1, $objp->currency_code)
155 foreach ($solde_total as $key => $solde) {
156 $this->info_box_contents[$line][] = array(
157 'tr' =>
'class="liste_total"',
158 'td' =>
'class="liste_total left"',
159 'text' => $langs->trans(
'Total').
' '.$key,
161 $this->info_box_contents[$line][] = array(
162 'td' =>
'class="liste_total right"',
166 $this->info_box_contents[$line][] = array(
167 'td' =>
'class="liste_total nowraponall right amount"',
168 'text' =>
price($solde, 0, $langs, 0, -1, -1, $key)
173 $this->db->free($result);
175 $this->info_box_contents[0][0] = array(
178 'text' => ($this->db->error().
' sql='.$sql),
182 $this->info_box_contents[0][0] = array(
183 'td' =>
'class="nohover opacitymedium left"',
184 'text' => $langs->trans(
"ReadPermissionNotAllowed")