72 global $user, $langs, $conf;
76 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleCurrentAccounts"));
78 if ($user->hasRight(
'banque',
'lire')) {
79 $sql =
"SELECT b.rowid, b.ref, b.label, b.bank, b.number, b.courant, b.clos, b.rappro, b.url";
80 $sql .=
", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban";
81 $sql .=
", b.domiciliation as address, b.proprio, b.owner_address";
82 $sql .=
", b.account_number, b.currency_code";
83 $sql .=
", b.min_allowed, b.min_desired, comment";
84 $sql .=
', b.fk_accountancy_journal';
85 $sql .=
', aj.code as accountancy_journal';
86 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as b";
87 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'accounting_journal as aj ON aj.rowid = b.fk_accountancy_journal';
88 $sql .=
" WHERE b.entity = ".$conf->entity;
89 $sql .=
" AND clos = 0";
90 $sql .=
" ORDER BY label";
92 $sql .= $this->db->plimit($max, 0);
94 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
96 $result = $this->db->query($sql);
98 $num = $this->db->num_rows($result);
101 $solde_total = array();
103 $account_static =
new Account($this->db);
104 while ($line < $num) {
105 $objp = $this->db->fetch_object($result);
107 $account_static->id = $objp->rowid;
108 $account_static->ref = $objp->ref;
109 $account_static->label = $objp->label;
110 $account_static->number = $objp->number;
111 $account_static->account_number = $objp->account_number;
112 $account_static->currency_code = $objp->currency_code;
113 $account_static->accountancy_journal = $objp->accountancy_journal;
114 $solde = $account_static->solde(0);
116 if (!array_key_exists($objp->currency_code, $solde_total)) {
117 $solde_total[$objp->currency_code] = $solde;
119 $solde_total[$objp->currency_code] += $solde;
123 $this->info_box_contents[$line][] = array(
125 'text' => $account_static->getNomUrl(1),
129 $this->info_box_contents[$line][] = array(
131 'text' => $objp->number,
134 $this->info_box_contents[$line][] = array(
135 'td' =>
'class="nowraponall right amount"',
136 'text' =>
'<a href="'.DOL_URL_ROOT.
'/compta/bank/bankentries_list.php?id='.$account_static->id.
'">'
137 .price($solde, 0, $langs, 1, -1, -1, $objp->currency_code)
146 foreach ($solde_total as $key => $solde) {
147 $this->info_box_contents[$line][] = array(
148 'tr' =>
'class="liste_total"',
149 'td' =>
'class="liste_total left"',
150 'text' => $langs->trans(
'Total').
' '.$key,
152 $this->info_box_contents[$line][] = array(
153 'td' =>
'class="liste_total right"',
157 $this->info_box_contents[$line][] = array(
158 'td' =>
'class="liste_total nowraponall right amount"',
159 'text' =>
'<span class="amount">'.
price($solde, 0, $langs, 0, -1, -1, $key).
'</span>'
164 $this->db->free($result);
166 $this->info_box_contents[0][0] = array(
169 'text' => ($this->db->error().
' sql='.$sql),
173 $this->info_box_contents[0][0] = array(
174 'td' =>
'class="nohover left"',
175 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'