27 include_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
28 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
36 public $boxcode =
"currentaccounts";
37 public $boximg =
"object_bill";
38 public $boxlabel =
"BoxCurrentAccounts";
39 public $depends = array(
"banque");
49 public $info_box_head = array();
50 public $info_box_contents = array();
66 $listofmodulesforexternal = explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
67 if (!in_array(
'banque', $listofmodulesforexternal) && !empty($user->socid)) $this->enabled = 0;
69 $this->hidden = !($user->rights->banque->lire);
80 global $user, $langs, $conf;
84 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleCurrentAccounts"));
86 if ($user->rights->banque->lire) {
87 $sql =
"SELECT b.rowid, b.ref, b.label, b.bank,b.number, b.courant, b.clos, b.rappro, b.url";
88 $sql .=
", b.code_banque, b.code_guichet, b.cle_rib, b.bic, b.iban_prefix as iban";
89 $sql .=
", b.domiciliation, b.proprio, b.owner_address";
90 $sql .=
", b.account_number, b.currency_code";
91 $sql .=
", b.min_allowed, b.min_desired, comment";
92 $sql .=
', b.fk_accountancy_journal';
93 $sql .=
', aj.code as accountancy_journal';
94 $sql .=
" FROM ".MAIN_DB_PREFIX.
"bank_account as b";
95 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'accounting_journal as aj ON aj.rowid=b.fk_accountancy_journal';
96 $sql .=
" WHERE b.entity = ".$conf->entity;
97 $sql .=
" AND clos = 0";
99 $sql .=
" ORDER BY label";
100 $sql .= $this->
db->plimit($max, 0);
102 dol_syslog(get_class($this).
"::loadBox", LOG_DEBUG);
103 $result = $this->
db->query($sql);
105 $num = $this->
db->num_rows($result);
108 $solde_total = array();
110 $account_static =
new Account($this->
db);
111 while ($line < $num) {
112 $objp = $this->
db->fetch_object($result);
114 $account_static->id = $objp->rowid;
115 $account_static->ref = $objp->ref;
116 $account_static->label = $objp->label;
117 $account_static->number = $objp->number;
118 $account_static->account_number = $objp->account_number;
119 $account_static->currency_code = $objp->currency_code;
120 $account_static->accountancy_journal = $objp->accountancy_journal;
121 $solde = $account_static->solde(0);
123 $solde_total[$objp->currency_code] += $solde;
125 $this->info_box_contents[$line][] = array(
127 'text' => $account_static->getNomUrl(1),
131 $this->info_box_contents[$line][] = array(
133 'text' => $objp->number,
136 $this->info_box_contents[$line][] = array(
137 'td' =>
'class="right nowraponall"',
138 'text' =>
price($solde, 0, $langs, 1, -1, -1, $objp->currency_code)
145 foreach ($solde_total as $key=>$solde) {
146 $this->info_box_contents[$line][] = array(
147 'tr' =>
'class="liste_total"',
148 'td' =>
'class="liste_total left"',
149 'text' => $langs->trans(
'Total').
' '.$key,
151 $this->info_box_contents[$line][] = array(
152 'td' =>
'class="liste_total right"',
156 $this->info_box_contents[$line][] = array(
157 'td' =>
'class="liste_total right nowraponall"',
158 'text' =>
price($solde, 0, $langs, 0, -1, -1, $key)
163 $this->
db->free($result);
165 $this->info_box_contents[0][0] = array(
168 'text' => ($this->
db->error().
' sql='.$sql),
172 $this->info_box_contents[0][0] = array(
173 'td' =>
'class="nohover opacitymedium left"',
174 'text' => $langs->trans(
"ReadPermissionNotAllowed")
187 public function showBox($head = null, $contents = null, $nooutput = 0)
189 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
$conf db
API class for accounts.
Class to manage bank accounts.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
__construct($db, $param= '')
Constructor.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
loadBox($max=5)
Load data into info_box_contents array to show array later.
Class to manage the box to show last users.