dolibarr 24.0.0-beta
releve.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
6 * Copyright (C) 2017 Patrick Delcroix <pmpdelcroix@gmail.com>
7 * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
8 * Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
9 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
10 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
32// Load Dolibarr environment
33require '../../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
36require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
37require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
38require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
39require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
40require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
41require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
42require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
43require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
44require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
45require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
46require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php';
47require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
48//show files
49require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
50require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
51
60// Load translation files required by the page
61$langs->loadLangs(array("banks", "categories", "companies", "bills", "trips", "donations", "loan", "salaries"));
62
63$action = GETPOST('action', 'aZ09');
64$id = GETPOSTINT('account') ? GETPOSTINT('account') : GETPOSTINT('id');
65$ref = GETPOST('ref', 'alpha');
66$dvid = GETPOST('dvid', 'alpha');
67$numref = GETPOST('num', 'alpha');
68$ve = GETPOST("ve", 'alpha');
69$brref = GETPOST('brref', 'alpha');
70$oldbankreceipt = GETPOST('oldbankreceipt', 'alpha');
71$newbankreceipt = GETPOST('newbankreceipt', 'alpha');
72$rel = GETPOST("rel", 'alphanohtml');
73$backtopage = GETPOST('backtopage', 'alpha');
74
75// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
76$hookmanager->initHooks(array('bankaccountstatement', 'globalcard'));
77
78if ($user->hasRight('banque', 'consolidate') && $action == 'dvnext' && !empty($dvid)) {
79 $al = new AccountLine($db);
80 $al->datev_next((int) $dvid);
81}
82
83if ($user->hasRight('banque', 'consolidate') && $action == 'dvprev' && !empty($dvid)) {
84 $al = new AccountLine($db);
85 $al->datev_previous((int) $dvid);
86}
87
88
89$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
90$sortfield = GETPOST('sortfield', 'aZ09comma');
91$sortorder = GETPOST('sortorder', 'aZ09comma');
92$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
93if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
94 // If $page is not defined, or '' or -1 or if we click on clear filters
95 $page = 0;
96}
97$offset = $limit * $page;
98$pageprev = $page - 1;
99$pagenext = $page + 1;
100if (!$sortorder) {
101 $sortorder = "ASC";
102}
103if (!$sortfield) {
104 $sortfield = "s.nom";
105}
106
107$object = new Account($db);
108if ($id > 0 || !empty($ref)) {
109 $result = $object->fetch($id, $ref);
110 // if fetch from ref, $id may be empty
111 $id = $object->id; // Force the search field on id of account
112}
113
114// Initialize a technical object to manage context to save list fields
115$contextpage = 'banktransactionlist'.(empty($object->ref) ? '' : '-'.$object->id);
116
117// Security check
118$fieldid = (!empty($ref) ? $ref : $id);
119$fieldname = (!empty($ref) ? 'ref' : 'rowid');
120if ($user->socid) {
121 $socid = $user->socid;
122}
123
124$result = restrictedArea($user, 'banque', $fieldid, 'bank_account', '', '', $fieldname);
125
126$error = 0;
127
128// Define number of receipt to show (current, previous or next one ?)
129$foundprevious = '';
130$foundnext = '';
131// Search previous receipt number
132$sql = "SELECT b.num_releve as num";
133$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
134$sql .= " WHERE b.num_releve < '".$db->escape($numref)."'";
135$sql .= " AND b.num_releve <> ''";
136$sql .= " AND b.fk_account = ".((int) $object->id);
137$sql .= " ORDER BY b.num_releve DESC";
138$sql .= $db->plimit(1);
139
140dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
141$resql = $db->query($sql);
142if ($resql) {
143 $numrows = $db->num_rows($resql);
144 if ($numrows > 0) {
145 $obj = $db->fetch_object($resql);
146 if ($rel == 'prev') {
147 $numref = $obj->num;
148 }
149 $foundprevious = $obj->num;
150 }
151} else {
153}
154// Search next receipt
155$sql = "SELECT b.num_releve as num";
156$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
157$sql .= " WHERE b.num_releve > '".$db->escape($numref)."'";
158$sql .= " AND b.fk_account = ".((int) $object->id);
159$sql .= " ORDER BY b.num_releve ASC";
160$sql .= $db->plimit(1);
161
162dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
163$resql = $db->query($sql);
164if ($resql) {
165 $numrows = $db->num_rows($resql);
166 if ($numrows > 0) {
167 $obj = $db->fetch_object($resql);
168 if ($rel == 'next') {
169 $numref = $obj->num;
170 }
171 $foundnext = $obj->num;
172 }
173} else {
175}
176
177$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,";
178$sql .= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
179$sql .= " b.fk_bordereau,";
180$sql .= " bc.ref,";
181$sql .= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel";
182$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba,";
183$sql .= " ".MAIN_DB_PREFIX."bank as b";
184$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau';
185$sql .= " WHERE b.num_releve = '".$db->escape($numref)."'";
186if (empty($numref)) {
187 $sql .= " OR b.num_releve is null";
188}
189$sql .= " AND b.fk_account = ".((int) $object->id);
190$sql .= " AND b.fk_account = ba.rowid";
191$sql .= " AND ba.entity IN (".getEntity($object->element).")";
192$sql .= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
193
194$sqlrequestforbankline = $sql;
195
196
197/*
198 * Actions
199 */
200
201if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt) && $user->hasRight('banque', 'consolidate')) {
202 // Test to check newbankreceipt does not exists yet
203 $sqltest = "SELECT b.rowid FROM ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba";
204 $sqltest .= " WHERE b.fk_account = ba.rowid AND ba.entity = ".((int) $conf->entity);
205 $sqltest .= " AND num_releve = '".$db->escape($newbankreceipt)."'";
206 $sqltest .= $db->plimit(1); // Need the first one only
207
208 $resql = $db->query($sqltest);
209 if ($resql) {
210 $obj = $db->fetch_object($resql);
211 if ($obj && $obj->rowid) {
212 setEventMessages('ErrorBankReceiptAlreadyExists', null, 'errors');
213 $error++;
214 }
215 } else {
217 }
218
219 // Update bank receipt name
220 if (!$error) {
221 $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."bank SET num_releve = '".$db->escape($newbankreceipt)."'";
222 $sqlupdate .= " WHERE num_releve = '".$db->escape($oldbankreceipt)."' AND fk_account = ".((int) $id);
223
224 $resql = $db->query($sqlupdate);
225 if (!$resql) {
227 }
228 }
229
230 $action = 'view';
231}
232
233
234/*
235 * View
236 */
237
238$form = new Form($db);
239$societestatic = new Societe($db);
240$chargestatic = new ChargeSociales($db);
241$memberstatic = new Adherent($db);
242$paymentstatic = new Paiement($db);
243$paymentsupplierstatic = new PaiementFourn($db);
244$paymentvatstatic = new Tva($db);
245$bankstatic = new Account($db);
246$banklinestatic = new AccountLine($db);
247$remisestatic = new RemiseCheque($db);
248$paymentdonationstatic = new PaymentDonation($db);
249$paymentloanstatic = new PaymentLoan($db);
250$paymentvariousstatic = new PaymentVarious($db);
251
252// Must be before button action
253$param = '';
254if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
255 $param .= '&contextpage='.$contextpage;
256}
257if ($limit > 0 && $limit != $conf->liste_limit) {
258 $param .= '&limit='.$limit;
259}
260if ($id > 0) {
261 $param .= '&id='.urlencode((string) ($id));
262}
263
264if (empty($numref)) {
265 $title = $object->ref.' - '.$langs->trans("AccountStatements");
266 $helpurl = "";
267} else {
268 $title = $langs->trans("FinancialAccount").' - '.$langs->trans("AccountStatements");
269 $helpurl = "";
270}
271
272
273llxHeader('', $title, $helpurl);
274
275
276if (empty($numref)) {
277 $sortfield = 'numr';
278 $sortorder = 'DESC';
279
280 // List of all standing receipts
281 $sql = "SELECT DISTINCT(b.num_releve) as numr";
282 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
283 $sql .= " WHERE b.fk_account = ".((int) $object->id);
284 $sql .= " AND b.num_releve IS NOT NULL AND b.num_releve <> '' AND b.num_releve <> '0'";
285 $sql .= $db->order($sortfield, $sortorder);
286
287 // Count total nb of records
288 $totalnboflines = 0;
289 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
290 $result = $db->query($sql);
291 $totalnboflines = $db->num_rows($result);
292 }
293
294 $sql .= $db->plimit($limit + 1, $offset);
295
296 $resql = $db->query($sql);
297 if ($resql) {
298 $num = $db->num_rows($resql);
299 $i = 0;
300
301 // Onglets
302 $head = bank_prepare_head($object);
303 print dol_get_fiche_head($head, 'statement', $langs->trans("FinancialAccount"), 0, 'account');
304
305 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
306
307 $morehtmlref = '';
308
309 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
310
311 print dol_get_fiche_end();
312
313 /* Moved as a tab
314 if ($object->canBeConciliated() > 0) {
315 $allowautomaticconciliation = false; // TODO
316 $titletoconciliatemanual = $langs->trans("Conciliate");
317 $titletoconciliateauto = $langs->trans("Conciliate");
318 if ($allowautomaticconciliation) {
319 $titletoconciliatemanual .= ' ('.$langs->trans("Manual").')';
320 $titletoconciliateauto .= ' ('.$langs->trans("Auto").')';
321 }
322
323 // If not cash account and can be reconciliate
324 if ($user->hasRight('banque', 'consolidate')) {
325 $buttonreconcile = '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?action=reconcile&sortfield=b.datev,b.dateo,b.rowid&sortorder=asc,asc,asc&search_conciliated=0&search_account='.$id.$param.'">'.$titletoconciliatemanual.'</a>';
326 } else {
327 $buttonreconcile = '<a class="butActionRefused classfortooltip" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$titletoconciliatemanual.'</a>';
328 }
329
330
331 if ($allowautomaticconciliation) {
332 // If not cash account and can be reconciliate
333 if ($user->hasRight('banque', 'consolidate')) {
334 $newparam = $param;
335 $newparam = preg_replace('/search_conciliated=\d+/i', '', $newparam);
336 $buttonreconcile .= ' <a class="butAction" style="margin-bottom: 5px !important; margin-top: 5px !important" href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?action=reconcile&sortfield=b.datev,b.dateo,b.rowid&sortorder=asc,asc,asc&search_conciliated=0'.$newparam.'">'.$titletoconciliateauto.'</a>';
337 } else {
338 $buttonreconcile .= ' <a class="butActionRefused" style="margin-bottom: 5px !important; margin-top: 5px !important" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$titletoconciliateauto.'</a>';
339 }
340 }
341 }
342 */
343
344 // List of mass actions available
345 $arrayofmassactions = array(
346 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
347 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
348 );
349 //if (in_array($massaction, array('presend', 'predelete'))) {
350 // $arrayofmassactions = array();
351 //}
352 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
353
354 $morehtml = '';
355
356 print '<form name="aaa" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
357 print '<input type="hidden" name="token" value="'.newToken().'">';
358 print '<input type="hidden" name="action" value="confirm_editbankreceipt">';
359 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
360 print '<input type="hidden" name="account" value="'.$object->id.'">';
361 print '<input type="hidden" name="page" value="'.$page.'">';
362
363 $param = "&account=".$object->id.($limit ? '&limit='.$limit : '');
364 print_barre_liste($langs->trans("AccountStatements"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton.$morehtml, $num, $totalnboflines, '', 0, '', '', $limit, 0, 0, 1);
365
366 print '<table class="noborder centpercent">';
367 print '<tr class="liste_titre">';
368 print '<td>'.$langs->trans("Ref").'</td>';
369 print '<td class="right">'.$langs->trans("InitialBankBalance").'</td>';
370 print '<td class="right">'.$langs->trans("EndBankBalance").'</td>';
371 print '<td></td>';
372 print '</tr>';
373
374 $balancestart = array();
375 $content = array();
376
377 $imaxinloop = ($limit ? min($num, $limit) : $num);
378 while ($i < $imaxinloop) {
379 $objp = $db->fetch_object($resql);
380
381 print '<tr class="oddeven">';
382 print '<td>';
383 if ($action != 'editbankreceipt' || $objp->numr != $brref) {
384 print '<a href="releve.php?num='.$objp->numr.'&account='.$object->id.'">'.$objp->numr.'</a>';
385 } else {
386 print '<input type="hidden" name="oldbankreceipt" value="'.$objp->numr.'">';
387 print '<input type="text" name="newbankreceipt" value="'.$objp->numr.'">';
388 print '<input type="submit" class="button smallpaddingimp" name="actionnewbankreceipt" value="'.$langs->trans("Save").'">';
389 print '<input type="submit" class="button button-cancel smallpaddingimp" name="cancel" value="'.$langs->trans("Cancel").'">';
390 }
391 print '</td>';
392
393 // Calculate start amount
394 $sql = "SELECT sum(b.amount) as amount";
395 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
396 $sql .= " WHERE b.num_releve < '".$db->escape($objp->numr)."'";
397 $sql .= " AND b.num_releve <> ''";
398 $sql .= " AND b.fk_account = ".((int) $object->id);
399 $resqlstart = $db->query($sql);
400 if ($resqlstart) {
401 $obj = $db->fetch_object($resqlstart);
402 $balancestart[$objp->numr] = $obj->amount;
403 $db->free($resqlstart);
404 }
405 print '<td class="right"><span class="amount">'.price($balancestart[$objp->numr], 0, $langs, 1, -1, -1, empty($object->currency_code) ? $conf->currency : $object->currency_code).'</span></td>';
406
407 // Calculate end amount
408 $sql = "SELECT sum(b.amount) as amount";
409 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
410 $sql .= " WHERE b.num_releve = '".$db->escape($objp->numr)."'";
411 $sql .= " AND b.fk_account = ".((int) $object->id);
412 $resqlend = $db->query($sql);
413 if ($resqlend) {
414 $obj = $db->fetch_object($resqlend);
415 $content[$objp->numr] = $obj->amount;
416 $db->free($resqlend);
417 }
418 print '<td class="right"><span class="amount">'.price(($balancestart[$objp->numr] + $content[$objp->numr]), 0, $langs, 1, -1, -1, empty($object->currency_code) ? $conf->currency : $object->currency_code).'</span></td>';
419
420 print '<td class="center">';
421 if ($user->hasRight('banque', 'consolidate') && $action != 'editbankreceipt') {
422 print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?account='.$object->id.($page > 0 ? '&page='.$page : '').'&action=editbankreceipt&token='.newToken().'&brref='.urlencode($objp->numr).'">'.img_edit().'</a>';
423 }
424 print '</td>';
425
426 print '</tr>'."\n";
427
428
429 $i++;
430 }
431
432 if (empty($num)) {
433 print '<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
434 }
435
436 print "</table>\n";
437 print '</form>';
438
439 print "\n</div>\n";
440 } else {
442 }
443} else {
448 // Onglets
449 $head = account_statement_prepare_head($object, $numref);
450 print dol_get_fiche_head($head, 'statement', $langs->trans("AccountStatement"), -1, 'account');
451
452
453 $morehtmlright = '';
454 $morehtmlright .= '<div class="pagination"><ul>';
455 if ($foundprevious) {
456 $morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?num='.urlencode($foundprevious).'&amp;ve='.urlencode($ve).'&amp;account='.((int) $object->id).'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
457 }
458 $morehtmlright .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
459 if ($foundnext) {
460 $morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?num='.urlencode($foundnext).'&amp;ve='.urlencode($ve).'&amp;account='.((int) $object->id).'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
461 }
462 $morehtmlright .= '</ul></div>';
463
464 $title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
465 print load_fiche_titre($title, $morehtmlright, '');
466
467 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
468 print '<input type="hidden" name="token" value="'.newToken().'">';
469 print '<input type="hidden" name="action" value="add">';
470
471 print '<div class="div-table-responsive">';
472 print '<table class="noborder centpercent">';
473 print '<tr class="liste_titre">';
474 print '<td class="center">'.$langs->trans("DateOperationShort").'</td>';
475 print '<td class="center">'.$langs->trans("DateValueShort").'</td>';
476 print '<td>'.$langs->trans("Type").'</td>';
477 print '<td>'.$langs->trans("Description").'</td>';
478 print '<td class="right" width="60">'.$langs->trans("Debit").'</td>';
479 print '<td class="right" width="60">'.$langs->trans("Credit").'</td>';
480 print '<td class="right">'.$langs->trans("Balance").'</td>';
481 print '<td>&nbsp;</td>';
482 print "</tr>\n";
483
484 // Calcul du solde de depart du releve
485 $sql = "SELECT sum(b.amount) as amount";
486 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
487 $sql .= " WHERE b.num_releve < '".$db->escape($numref)."'";
488 $sql .= " AND b.num_releve <> ''";
489 $sql .= " AND b.fk_account = ".((int) $object->id);
490
491 $resql = $db->query($sql);
492 if ($resql) {
493 $obj = $db->fetch_object($resql);
494 $total = $obj->amount;
495 $db->free($resql);
496 } else {
497 $total = 0;
498 }
499
500 $totalc = $totald = 0;
501
502 // Recherche les ecritures pour le releve
503 $sql = $sqlrequestforbankline;
504
505 $resql = $db->query($sql);
506 if ($resql) {
507 $num = $db->num_rows($resql);
508 $i = 0;
509
510 // Row with the start balance of the bank statement
511 print '<tr class="oddeven"><td colspan="3"></td>';
512 print '<td colspan="3"><b>'.$langs->trans("InitialBankBalance")." :</b></td>";
513 print '<td class="right"><b>'.price($total).'</b></td><td>&nbsp;</td>';
514 print "</tr>\n";
515
516 while ($i < $num) {
517 $objp = $db->fetch_object($resql);
518 $total += $objp->amount;
519
520 print '<tr class="oddeven">';
521
522 // Date operation
523 print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->do), "day").'</td>';
524
525 // Date de valeur
526 print '<td valign="center" class="center nowrap">';
527 print '<span class="spanforajaxedit">'.dol_print_date($db->jdate($objp->dv), "day").'</span>';
528 print '&nbsp;';
529 print '<span class="inline-block">';
530 print '<a class="ajaxforbankoperationchange reposition" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;num='.urlencode($numref).'&amp;account='.$object->id.'&amp;rowid='.$objp->rowid.'&amp;dvid='.$objp->rowid.'">';
531 print img_edit_remove()."</a> ";
532 print '<a class="ajaxforbankoperationchange reposition" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;num='.urlencode($numref).'&amp;account='.$object->id.'&amp;rowid='.$objp->rowid.'&amp;dvid='.$objp->rowid.'">';
533 print img_edit_add()."</a>";
534 print '</span>';
535 print "</td>\n";
536
537 // Type and num
538 if ($objp->fk_type == 'SOLD') {
539 $type_label = '&nbsp;';
540 } else {
541 $type_label = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $objp->fk_type;
542 }
543 $link = '';
544 if ($objp->fk_bordereau > 0) {
545 $remisestatic->id = $objp->fk_bordereau;
546 $remisestatic->ref = $objp->ref;
547 $link = ' '.$remisestatic->getNomUrl(1);
548 }
549 print '<td class="nowrap">'.$type_label.' '.($objp->num_chq ? $objp->num_chq : '').$link.'</td>';
550
551 // Description
552 print '<td valign="center">';
553 print '<a href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$objp->rowid.'&account='.$object->id.'">';
554 $reg = array();
555
556 preg_match('/\‍((.+)\‍)/i', $objp->label, $reg); // If text rounded by parenthesis, we try to search translation
557 if (!empty($reg[1]) && $langs->trans($reg[1]) != $reg[1]) {
558 print $langs->trans($reg[1]);
559 } else {
560 print dol_escape_htmltag($objp->label);
561 }
562 print '</a>';
563
564 /*
565 * Add links under the label (link to payment, company, user, social contribution...)
566 */
567 $newline = 1;
568 $links = $object->get_url($objp->rowid);
569 foreach ($links as $key => $val) {
570 if (!$newline) {
571 print ' - ';
572 } else {
573 print '<br>';
574 }
575 if ($links[$key]['type'] == 'payment') {
576 $paymentstatic->id = $links[$key]['url_id'];
577 $paymentstatic->ref = $langs->trans("Payment");
578 print ' '.$paymentstatic->getNomUrl(1);
579 $newline = 0;
580 } elseif ($links[$key]['type'] == 'payment_supplier') {
581 $paymentsupplierstatic->id = $links[$key]['url_id'];
582 $paymentsupplierstatic->ref = $langs->trans("Payment");
583 print ' '.$paymentsupplierstatic->getNomUrl(1);
584 $newline = 0;
585 } elseif ($links[$key]['type'] == 'payment_sc') {
586 print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">';
587 print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
588 print $langs->trans("SocialContributionPayment");
589 print '</a>';
590 $newline = 0;
591 } elseif ($links[$key]['type'] == 'payment_vat') {
592 $paymentvatstatic->id = $links[$key]['url_id'];
593 $paymentvatstatic->ref = $langs->trans("Payment");
594 print ' '.$paymentvatstatic->getNomUrl(1);
595 } elseif ($links[$key]['type'] == 'payment_salary') {
596 print '<a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$links[$key]['url_id'].'">';
597 print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
598 print $langs->trans("Payment");
599 print '</a>';
600 $newline = 0;
601 } elseif ($links[$key]['type'] == 'payment_donation') {
602 $paymentdonationstatic->id = $links[$key]['url_id'];
603 $paymentdonationstatic->ref = $langs->trans("Payment");
604 print ' '.$paymentdonationstatic->getNomUrl(1);
605 $newline = 0;
606 } elseif ($links[$key]['type'] == 'payment_loan') {
607 $paymentloanstatic->id = $links[$key]['url_id'];
608 $paymentloanstatic->ref = $langs->trans("Payment");
609 print ' '.$paymentloanstatic->getNomUrl(1);
610 $newline = 0;
611 } elseif ($links[$key]['type'] == 'payment_various') {
612 $paymentvariousstatic->id = $links[$key]['url_id'];
613 $paymentvariousstatic->ref = $langs->trans("Payment");
614 print ' '.$paymentvariousstatic->getNomUrl(1);
615 $newline = 0;
616 } elseif ($links[$key]['type'] == 'banktransfert') {
617 // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
618 if ($objp->amount > 0) {
619 $banklinestatic->fetch($links[$key]['url_id']);
620 $bankstatic->id = $banklinestatic->fk_account;
621 $bankstatic->label = $banklinestatic->bank_account_label;
622 print ' ('.$langs->trans("from").' ';
623 print $bankstatic->getNomUrl(1, 'transactions');
624 print ' '.$langs->trans("toward").' ';
625 $bankstatic->id = $objp->bankid;
626 $bankstatic->label = $objp->bankref;
627 print $bankstatic->getNomUrl(1, '');
628 print ')';
629 } else {
630 $bankstatic->id = $objp->bankid;
631 $bankstatic->label = $objp->bankref;
632 print ' ('.$langs->trans("from").' ';
633 print $bankstatic->getNomUrl(1, '');
634 print ' '.$langs->trans("toward").' ';
635 $banklinestatic->fetch($links[$key]['url_id']);
636 $bankstatic->id = $banklinestatic->fk_account;
637 $bankstatic->label = $banklinestatic->bank_account_label;
638 print $bankstatic->getNomUrl(1, 'transactions');
639 print ')';
640 }
641 } elseif ($links[$key]['type'] == 'company') {
642 $societestatic->id = $links[$key]['url_id'];
643 $societestatic->name = $links[$key]['label'];
644 print $societestatic->getNomUrl(1, 'company', 24);
645 $newline = 0;
646 } elseif ($links[$key]['type'] == 'member') {
647 print '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$links[$key]['url_id'].'">';
648 print img_object($langs->trans('ShowMember'), 'user').' ';
649 print $links[$key]['label'];
650 print '</a>';
651 $newline = 0;
652 } elseif ($links[$key]['type'] == 'user') {
653 print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$links[$key]['url_id'].'">';
654 print img_object($langs->trans('ShowUser'), 'user').' ';
655 print $links[$key]['label'];
656 print '</a>';
657 $newline = 0;
658 } elseif ($links[$key]['type'] == 'sc') {
659 print '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$links[$key]['url_id'].'">';
660 print img_object($langs->trans('ShowBill'), 'bill').' ';
661 print $langs->trans("SocialContribution");
662 print '</a>';
663 $newline = 0;
664 } else {
665 print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
666 print $links[$key]['label'];
667 print '</a>';
668 $newline = 0;
669 }
670 }
671
672 // Categories
673 if ($ve) {
674 $sql = "SELECT label";
675 $sql .= " FROM ".MAIN_DB_PREFIX."categorie as ct";
676 $sql .= ", ".MAIN_DB_PREFIX."category_bankline as cl";
677 $sql .= " WHERE ct.rowid = cl.fk_categ";
678 $sql .= " AND ct.entity = ".((int) $conf->entity);
679 $sql .= " AND cl.lineid = ".((int) $objp->rowid);
680
681 $resc = $db->query($sql);
682 if ($resc) {
683 $numc = $db->num_rows($resc);
684 $ii = 0;
685 if ($numc && !$newline) {
686 print '<br>';
687 }
688 while ($ii < $numc) {
689 $objc = $db->fetch_object($resc);
690 print "<br>-&nbsp;<i>".$objc->label."</i>";
691 $ii++;
692 }
693 } else {
695 }
696 }
697
698 print "</td>";
699
700 if ($objp->amount < 0) {
701 $totald += abs($objp->amount);
702 print '<td class="nowrap right">'.price($objp->amount * -1)."</td><td>&nbsp;</td>\n";
703 } else {
704 $totalc += abs($objp->amount);
705 print '<td>&nbsp;</td><td class="nowrap right">'.price($objp->amount)."</td>\n";
706 }
707
708 print '<td class="nowrap right">'.price(price2num($total, 'MT'))."</td>\n";
709
710 if ($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consolidate')) {
711 print '<td class="center"><a class="editfielda reposition" href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$objp->rowid.'&account='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?account='.$object->id.'&num='.urlencode($numref)).'">';
712 print img_edit();
713 print "</a></td>";
714 } else {
715 print "<td class=\"center\">&nbsp;</td>";
716 }
717 print "</tr>";
718 $i++;
719 }
720 $db->free($resql);
721 } else {
723 }
724
725 // Line Total
726 print "\n".'<tr class="liste_total"><td class="right" colspan="4">'.$langs->trans("Total").' :</td><td class="right">'.price($totald).'</td><td class="right">'.price($totalc)."</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
727
728 // Line Balance
729 print "\n<tr>";
730 print "<td class=\"right\" colspan=\"3\">&nbsp;</td><td colspan=\"3\"><b>".$langs->trans("EndBankBalance")." :</b></td>";
731 print '<td class="right"><b>'.price(price2num($total, 'MT'))."</b></td><td>&nbsp;</td>";
732 print "</tr>\n";
733 print "</table>";
734
735 // Code to adjust value date with plus and less picto using an Ajax call instead of a full reload of page
736 $urlajax = DOL_URL_ROOT.'/core/ajax/bankconciliate.php?token='.currentToken();
737 print '
738 <script type="text/javascript">
739 $(function() {
740 $("a.ajaxforbankoperationchange").each(function(){
741 var current = $(this);
742 current.click(function()
743 {
744 var url = "'.$urlajax.'&"+current.attr("href").split("?")[1];
745 console.log("We click on ajaxforbankoperationchange url="+url);
746 $.get(url, function(data)
747 {
748 console.log(data);
749 current.parent().parent().find(".spanforajaxedit").replaceWith(data);
750 });
751 return false;
752 });
753 });
754 });
755 </script>
756 ';
757
758 print "</div>";
759
760 print "</form>\n";
761}
762
763// End of page
764llxFooter();
765$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
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
account_statement_prepare_head($object, $num)
Prepare array with list of tabs.
Definition bank.lib.php:281
bank_prepare_head(Account $object)
Prepare array with list of tabs.
Definition bank.lib.php:40
Class to manage bank accounts.
Class to manage bank transaction lines.
Class to manage members of a foundation.
Class for managing the social charges.
Class to manage generation of HTML components Only common components must be here.
Class to manage payments for supplier invoices.
Class to manage payments of customer invoices.
Class to manage payments of donations.
Class to manage payments of loans.
Class to manage various payments.
Class to manage cheque delivery receipts.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage VAT - Value-added tax (also known in French as TVA)
Definition tva.class.php:39
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
img_edit_add($titlealt='default', $other='')
Show logo "+".
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
img_edit_remove($titlealt='default', $other='')
Show logo "-".
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.