75 global $user, $langs, $conf;
79 $this->info_box_head = array(
80 'text' => $langs->trans(
"BoxTitleCurrentAccounts").
'<a class="paddingleft" href="'.DOL_URL_ROOT.
'/compta/bank/list.php?search_status=opened"><span class="badge">...</span></a>'
83 if ($user->hasRight(
'banque',
'lire')) {
84 $sql =
"SELECT b.rowid, b.ref, b.label, b.bank, b.number, b.courant, b.clos, b.rappro, b.url";
85 $sql .=
", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban";
86 $sql .=
", b.domiciliation as address, b.proprio, b.owner_address";
87 $sql .=
", b.account_number, b.currency_code";
88 $sql .=
", b.min_allowed, b.min_desired, comment";
89 $sql .=
', b.fk_accountancy_journal';
90 $sql .=
', aj.code as accountancy_journal';
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as b";
92 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'accounting_journal as aj ON aj.rowid = b.fk_accountancy_journal';
93 $sql .=
" WHERE b.entity = ".$conf->entity;
94 $sql .=
" AND clos = 0";
95 $sql .=
" ORDER BY label";
97 $sql .= $this->db->plimit($max, 0);
99 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
101 $result = $this->db->query($sql);
103 $num = $this->db->num_rows($result);
106 $solde_total = array();
108 $account_static =
new Account($this->db);
109 while ($line < $num) {
110 $objp = $this->db->fetch_object($result);
112 $account_static->id = $objp->rowid;
113 $account_static->ref = $objp->ref;
114 $account_static->label = $objp->label;
115 $account_static->number = $objp->number;
116 $account_static->account_number = $objp->account_number;
117 $account_static->currency_code = $objp->currency_code;
118 $account_static->accountancy_journal = $objp->accountancy_journal;
119 $solde = $account_static->solde(0);
121 if (!array_key_exists($objp->currency_code, $solde_total)) {
122 $solde_total[$objp->currency_code] = $solde;
124 $solde_total[$objp->currency_code] += $solde;
128 $this->info_box_contents[$line][] = array(
130 'text' => $account_static->getNomUrl(1),
134 $this->info_box_contents[$line][] = array(
136 'text' => $objp->number,
139 $this->info_box_contents[$line][] = array(
140 'td' =>
'class="nowraponall right amount"',
141 'text' =>
'<a href="'.DOL_URL_ROOT.
'/compta/bank/bankentries_list.php?id='.$account_static->id.
'">'
142 .price($solde, 0, $langs, 1, -1, -1, $objp->currency_code)
151 foreach ($solde_total as $key => $solde) {
152 $this->info_box_contents[$line][] = array(
153 'tr' =>
'class="liste_total"',
154 'td' =>
'class="liste_total left"',
155 'text' => $langs->trans(
'Total').
' '.$key,
157 $this->info_box_contents[$line][] = array(
158 'td' =>
'class="liste_total right"',
162 $this->info_box_contents[$line][] = array(
163 'td' =>
'class="liste_total nowraponall right amount"',
164 'text' =>
'<span class="amount">'.
price($solde, 0, $langs, 0, -1, -1, $key).
'</span>'
170 $this->db->free($result);
172 $this->info_box_contents[0][0] = array(
175 'text' => ($this->db->error().
' sql='.$sql),
179 $this->info_box_contents[0][0] = array(
180 'td' =>
'class="nohover left"',
181 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'