load("boxes"); $this->boxlabel=$langs->trans('BoxCurrentAccounts'); } /** * \brief Charge les données en mémoire pour affichage ultérieur * \param $max Nombre maximum d'enregistrements à charger */ function loadBox($max=5) { global $user, $langs, $db; $langs->load("boxes"); $this->info_box_head = array('text' => $langs->trans("BoxTitleCurrentAccounts")); if ($user->rights->banque->lire) { $sql = "SELECT rowid, label, bank, number"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql .= " WHERE clos = 0 AND courant = 1"; $sql .= " ORDER BY label"; $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; $solde_total = 0; while ($i < $num) { $objp = $db->fetch_object($result); $acc = new Account($db); $acc->fetch($objp->rowid); $solde_total += $acc->solde(); $this->info_box_contents[$i][0] = array('align' => 'left', 'logo' => $this->boximg, 'text' => stripslashes($objp->label), 'url' => DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid); $this->info_box_contents[$i][1] = array('align' => 'left', 'text' => stripslashes($objp->bank) ); $this->info_box_contents[$i][2] = array('align' => 'left', 'text' => stripslashes($objp->number) ); $this->info_box_contents[$i][3] = array('align' => 'right', 'text' => price( $acc->solde() ) ); $i++; } // Total $this->info_box_contents[$i][-1] = array('class' => 'liste_total'); $this->info_box_contents[$i][0] = array('align' => 'right', 'colspan' => '4', 'class' => 'liste_total', 'text' => $langs->trans('Total') ); $this->info_box_contents[$i][1] = array('align' => 'right', 'class' => 'liste_total', 'text' => price($solde_total) ); } else { dolibarr_print_error($db); } } else { $this->info_box_contents[0][0] = array('align' => 'left', 'text' => $langs->trans("ReadPermissionNotAllowed")); } } function showBox() { parent::showBox($this->info_box_head, $this->info_box_contents); } } ?>