dolibarr 25.0.0-alpha
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2026 Frédéric France <frederic.france@free.fr>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
24// Load Dolibarr environment
25require '../../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
27require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
28
37// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
38$hookmanager->initHooks(['bankindex']);
39
40// Load translation files required by the page
41$langs->loadLangs(['banks', 'bills', 'compta']);
42
43// Security check
44$result = restrictedArea($user, 'banque');
45
46$max = getDolUserInt('MAIN_SIZE_SHORTLIST_LIMIT', getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5));
47
48
49/*
50 * Actions
51 */
52
53if (GETPOST('addbox')) {
54 // Add box (when submit is done from a form when ajax disabled)
55 require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
56 $zone = GETPOSTINT('areacode');
57 $userid = GETPOSTINT('userid');
58 $boxorder = GETPOST('boxorder', 'aZ09');
59 $boxorder .= GETPOST('boxcombo', 'aZ09');
60 $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
61 if ($result > 0) {
62 setEventMessages($langs->trans("BoxAdded"), null);
63 }
64}
65
66
67/*
68 * View
69 */
70
71$accountstatic = new Account($db);
72$accountlinestatic = new AccountLine($db);
73
74$title = $langs->trans('MenuBankCash');
75$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:Módulo_Bancos_y_Cajas|DE:Modul_Banken_und_Barvermögen';
76
77// Load $resultboxes
78$resultboxes = FormOther::getBoxesArea($user, "29");
79
80llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-bank page-index');
81
82print load_fiche_titre($langs->trans("BankArea"), $resultboxes['selectboxlist'], 'bank_account');
83
84
85print '<div class="fichecenter">';
86
87print '<div class="twocolumns">';
88
89print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
90
91
92/*
93 * Open accounts with their balance
94 */
95
96$sql = "SELECT b.rowid, b.ref, b.label, b.number, b.courant, b.currency_code, b.account_number";
97$sql .= ", SUM(bl.amount) as solde";
98$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b";
99$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as bl ON bl.fk_account = b.rowid";
100$sql .= " WHERE b.entity IN (".getEntity('bank_account').")";
101$sql .= " AND b.clos = 0";
102$sql .= " GROUP BY b.rowid, b.ref, b.label, b.number, b.courant, b.currency_code, b.account_number";
103$sql .= $db->order("b.label", "ASC");
104
105$resql = $db->query($sql);
106if ($resql) {
107 print '<div class="div-table-responsive-no-min">';
108 print '<table class="noborder centpercent">';
109 print '<tr class="liste_titre">';
110 print '<th colspan="2">'.$langs->trans("BankAccounts");
111 $lastmodified = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?search_status=opened" title="'.$langs->trans("FullList").'">';
112 $lastmodified .= '<span class="badge marginleftonlyshort">...</span>';
113 $lastmodified .= '</a>';
114 print $lastmodified;
115 print '</th>';
116 print '<th class="right">'.$langs->trans("Balance").'</th>';
117 print '</tr>';
118
119 $num = $db->num_rows($resql);
120 if ($num) {
121 $solde_total = [];
122 $i = 0;
123 while ($i < $num) {
124 $obj = $db->fetch_object($resql);
125
126 $accountstatic->id = $obj->rowid;
127 $accountstatic->ref = $obj->ref;
128 $accountstatic->label = $obj->label;
129 $accountstatic->number = $obj->number;
130 $accountstatic->account_number = $obj->account_number;
131 $accountstatic->currency_code = $obj->currency_code;
132 $accountstatic->type = $obj->courant;
133
134 $currency_code = ($obj->currency_code ? $obj->currency_code : $conf->currency);
135 $solde = (float) price2num($obj->solde, 'MU');
136 if (!array_key_exists($currency_code, $solde_total)) {
137 $solde_total[$currency_code] = 0;
138 }
139 $solde_total[$currency_code] += $solde;
140
141 print '<tr class="oddeven">';
142 print '<td>'.$accountstatic->getNomUrl(1).'</td>';
143 print '<td>'.dol_escape_htmltag($obj->number).'</td>';
144 print '<td class="nowraponall right amount">';
145 print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?id='.((int) $obj->rowid).'">';
146 print price($solde, 0, $langs, 1, -1, -1, $currency_code);
147 print '</a>';
148 print '</td>';
149 print '</tr>';
150 $i++;
151 }
152
153 // Total per currency
154 foreach ($solde_total as $currency_code => $total) {
155 print '<tr class="liste_total">';
156 print '<td class="liste_total" colspan="2">'.$langs->trans("Total").' ('.dol_escape_htmltag((string) $currency_code).')</td>';
157 print '<td class="liste_total nowraponall right amount">'.price($total, 0, $langs, 1, -1, -1, $currency_code).'</td>';
158 print '</tr>';
159 }
160 } else {
161 print '<tr class="oddeven">';
162 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
163 print '</tr>';
164 }
165 print '</table>';
166 print '</div>';
167 print '<br>';
168 $db->free($resql);
169} else {
170 dol_print_error($db);
171}
172
173
174print $resultboxes['boxlista'];
175
176print '</div><div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
177
178
179/*
180 * Last modified bank transactions
181 */
182
183$sql = "SELECT bl.rowid, bl.label, bl.amount, bl.dateo, bl.datev, bl.tms as datem, bl.fk_account";
184$sql .= ", b.rowid as bankid, b.ref as bankref, b.label as banklabel, b.currency_code";
185$sql .= " FROM ".MAIN_DB_PREFIX."bank as bl";
186$sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank_account as b ON b.rowid = bl.fk_account";
187$sql .= " WHERE b.entity IN (".getEntity('bank_account').")";
188$sql .= $db->order("bl.tms", "DESC");
189$sql .= $db->plimit($max, 0);
190
191$resql = $db->query($sql);
192if ($resql) {
193 print '<div class="div-table-responsive-no-min">';
194 print '<table class="noborder centpercent">';
195 print '<tr class="liste_titre">';
196 print '<th colspan="3">'.$langs->trans("LatestBankTransactionsModified", $max);
197 $lastmodified = '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?sortfield=b.tms&sortorder=DESC" title="'.$langs->trans("FullList").'">';
198 $lastmodified .= '<span class="badge marginleftonlyshort">...</span>';
199 $lastmodified .= '</a>';
200 print $lastmodified;
201 print '</th>';
202 print '<th class="right">'.$langs->trans("Amount").'</th>';
203 print '</tr>';
204
205 $num = $db->num_rows($resql);
206 if ($num) {
207 $i = 0;
208 while ($i < $num) {
209 $obj = $db->fetch_object($resql);
210
211 $accountlinestatic->id = $obj->rowid;
212 $accountlinestatic->ref = (string) $obj->rowid;
213 $accountlinestatic->label = $obj->label;
214 $accountlinestatic->amount = $obj->amount;
215
216 $accountstatic->id = $obj->bankid;
217 $accountstatic->ref = $obj->bankref;
218 $accountstatic->label = $obj->banklabel;
219 $accountstatic->currency_code = $obj->currency_code;
220
221 print '<tr class="oddeven">';
222 print '<td class="nowraponall">'.$accountlinestatic->getNomUrl(1).'</td>';
223 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).'">'.dol_escape_htmltag($obj->label).'</td>';
224 print '<td class="nowraponall">'.$accountstatic->getNomUrl(1).'</td>';
225 print '<td class="nowraponall right amount">'.price($obj->amount, 0, $langs, 1, -1, -1, $obj->currency_code).'</td>';
226 print '</tr>';
227 $i++;
228 }
229 } else {
230 print '<tr class="oddeven">';
231 print '<td colspan="4"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
232 print '</tr>';
233 }
234 print '</table>';
235 print '</div>';
236 print '<br>';
237 $db->free($resql);
238} else {
239 dol_print_error($db);
240}
241
242
243print $resultboxes['boxlistb'];
244
245print '</div></div></div>';
246
247$object = new stdClass();
248$parameters = [
249 'user' => $user,
250];
251$reshook = $hookmanager->executeHooks('dashboardBank', $parameters, $object);
252
253// End of page
254llxFooter();
255$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage bank accounts.
Class to manage bank transaction lines.
static getBoxesArea($user, $areacode)
Get array with HTML tabs with widgets/boxes of a particular area including personalized choices of us...
static saveboxorder($dbs, $zone, $boxorder, $userid=0)
Save order of boxes for area and user.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:181
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.