dolibarr 25.0.0-alpha
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-2026 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';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
43require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
44require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
45require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
46require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
47require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
48require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
49require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
50require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
51require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
52require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
53require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php';
54require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
55//show files
56require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
57
58// Load translation files required by the page
59$langs->loadLangs(array("banks", "categories", "companies", "bills", "trips", "donations", "loan", "salaries"));
60
61$action = GETPOST('action', 'aZ09');
62$id = GETPOSTINT('account') ? GETPOSTINT('account') : GETPOSTINT('id');
63$ref = GETPOST('ref', 'alpha');
64$dvid = GETPOST('dvid', 'alpha');
65$numref = GETPOST('num', 'alpha');
66$ve = GETPOST("ve", 'alpha');
67$brref = GETPOST('brref', 'alpha');
68$oldbankreceipt = GETPOST('oldbankreceipt', 'alpha');
69$newbankreceipt = GETPOST('newbankreceipt', 'alpha');
70$rel = GETPOST("rel", 'alphanohtml');
71$backtopage = GETPOST('backtopage', 'alpha');
72
73// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
74$hookmanager->initHooks(array('bankaccountstatement', 'globalcard'));
75
76if ($user->hasRight('banque', 'consolidate') && $action == 'dvnext' && !empty($dvid)) {
77 $al = new AccountLine($db);
78 $al->datev_next((int) $dvid);
79}
80
81if ($user->hasRight('banque', 'consolidate') && $action == 'dvprev' && !empty($dvid)) {
82 $al = new AccountLine($db);
83 $al->datev_previous((int) $dvid);
84}
85
86
87$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
88$sortfield = GETPOST('sortfield', 'aZ09comma');
89$sortorder = GETPOST('sortorder', 'aZ09comma');
90$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
91if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
92 // If $page is not defined, or '' or -1 or if we click on clear filters
93 $page = 0;
94}
95$offset = $limit * $page;
96$pageprev = $page - 1;
97$pagenext = $page + 1;
98if (!$sortorder) {
99 $sortorder = "ASC";
100}
101if (!$sortfield) {
102 $sortfield = "s.nom";
103}
104
105$object = new Account($db);
106if ($id > 0 || !empty($ref)) {
107 $result = $object->fetch($id, $ref);
108 // if fetch from ref, $id may be empty
109 $id = $object->id; // Force the search field on id of account
110}
111
112// Initialize a technical object to manage context to save list fields
113$contextpage = 'banktransactionlist'.(empty($object->ref) ? '' : '-'.$object->id);
114
115// Security check
116$fieldid = (!empty($ref) ? $ref : $id);
117$fieldname = (!empty($ref) ? 'ref' : 'rowid');
118if ($user->socid) {
119 $socid = $user->socid;
120}
121
122$result = restrictedArea($user, 'banque', $fieldid, 'bank_account', '', '', $fieldname);
123
124$error = 0;
125
126// Define number of receipt to show (current, previous or next one ?)
127$foundprevious = '';
128$foundnext = '';
129// Search previous receipt number
130$sql = "SELECT b.num_releve as num";
131$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
132$sql .= " WHERE b.num_releve < '".$db->escape($numref)."'";
133$sql .= " AND b.num_releve <> ''";
134$sql .= " AND b.fk_account = ".((int) $object->id);
135$sql .= " ORDER BY b.num_releve DESC";
136$sql .= $db->plimit(1);
137
138dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
139$resql = $db->query($sql);
140if ($resql) {
141 $numrows = $db->num_rows($resql);
142 if ($numrows > 0) {
143 $obj = $db->fetch_object($resql);
144 if ($rel == 'prev') {
145 $numref = $obj->num;
146 }
147 $foundprevious = $obj->num;
148 }
149} else {
151}
152// Search next receipt
153$sql = "SELECT b.num_releve as num";
154$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
155$sql .= " WHERE b.num_releve > '".$db->escape($numref)."'";
156$sql .= " AND b.fk_account = ".((int) $object->id);
157$sql .= " ORDER BY b.num_releve ASC";
158$sql .= $db->plimit(1);
159
160dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
161$resql = $db->query($sql);
162if ($resql) {
163 $numrows = $db->num_rows($resql);
164 if ($numrows > 0) {
165 $obj = $db->fetch_object($resql);
166 if ($rel == 'next') {
167 $numref = $obj->num;
168 }
169 $foundnext = $obj->num;
170 }
171} else {
173}
174
175$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,";
176$sql .= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
177$sql .= " b.fk_bordereau,";
178$sql .= " bc.ref,";
179$sql .= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel";
180$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba,";
181$sql .= " ".MAIN_DB_PREFIX."bank as b";
182$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau';
183$sql .= " WHERE b.num_releve = '".$db->escape($numref)."'";
184if (empty($numref)) {
185 $sql .= " OR b.num_releve is null";
186}
187$sql .= " AND b.fk_account = ".((int) $object->id);
188$sql .= " AND b.fk_account = ba.rowid";
189$sql .= " AND ba.entity IN (".getEntity($object->element).")";
190$sql .= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
191
192$sqlrequestforbankline = $sql;
193
194
195/*
196 * Actions
197 */
198
199if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt) && $user->hasRight('banque', 'consolidate')) {
200 // Test to check newbankreceipt does not exists yet
201 $sqltest = "SELECT b.rowid FROM ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba";
202 $sqltest .= " WHERE b.fk_account = ba.rowid AND ba.entity = ".((int) $conf->entity);
203 $sqltest .= " AND num_releve = '".$db->escape($newbankreceipt)."'";
204 $sqltest .= $db->plimit(1); // Need the first one only
205
206 $resql = $db->query($sqltest);
207 if ($resql) {
208 $obj = $db->fetch_object($resql);
209 if ($obj && $obj->rowid) {
210 setEventMessages('ErrorBankReceiptAlreadyExists', null, 'errors');
211 $error++;
212 }
213 } else {
215 }
216
217 // Update bank receipt name
218 if (!$error) {
219 $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."bank SET num_releve = '".$db->escape($newbankreceipt)."'";
220 $sqlupdate .= " WHERE num_releve = '".$db->escape($oldbankreceipt)."' AND fk_account = ".((int) $id);
221
222 $resql = $db->query($sqlupdate);
223 if (!$resql) {
225 }
226 }
227
228 $action = 'view';
229}
230
231
232/*
233 * View
234 */
235
236$form = new Form($db);
237$societestatic = new Societe($db);
238$chargestatic = new ChargeSociales($db);
239$memberstatic = new Adherent($db);
240$paymentstatic = new Paiement($db);
241$paymentsupplierstatic = new PaiementFourn($db);
242$paymentvatstatic = new Tva($db);
243$bankstatic = new Account($db);
244$banklinestatic = new AccountLine($db);
245$remisestatic = new RemiseCheque($db);
246$paymentdonationstatic = new PaymentDonation($db);
247$paymentloanstatic = new PaymentLoan($db);
248$paymentvariousstatic = new PaymentVarious($db);
249
250// Must be before button action
251$param = '';
252if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
253 $param .= '&contextpage='.$contextpage;
254}
255if ($limit > 0 && $limit != $conf->liste_limit) {
256 $param .= '&limit='.$limit;
257}
258if ($id > 0) {
259 $param .= '&id='.urlencode((string) ($id));
260}
261
262if (empty($numref)) {
263 $title = $object->ref.' - '.$langs->trans("AccountStatements");
264 $helpurl = "";
265} else {
266 $title = $langs->trans("FinancialAccount").' - '.$langs->trans("AccountStatements");
267 $helpurl = "";
268}
269
270
271llxHeader('', $title, $helpurl);
272
273
274if (empty($numref)) {
275 $sortfield = 'numr';
276 $sortorder = 'DESC';
277
278 // List of all standing receipts
279 $sql = "SELECT DISTINCT(b.num_releve) as numr";
280 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
281 $sql .= " WHERE b.fk_account = ".((int) $object->id);
282 $sql .= " AND b.num_releve IS NOT NULL AND b.num_releve <> '' AND b.num_releve <> '0'";
283 $sql .= $db->order($sortfield, $sortorder);
284
285 // Count total nb of records
286 $totalnboflines = 0;
287 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
288 $result = $db->query($sql);
289 $totalnboflines = $db->num_rows($result);
290 }
291
292 $sql .= $db->plimit($limit + 1, $offset);
293
294 $resql = $db->query($sql);
295 if ($resql) {
296 $num = $db->num_rows($resql);
297 $i = 0;
298
299 // Onglets
300 $head = bank_prepare_head($object);
301 print dol_get_fiche_head($head, 'statement', $langs->trans("FinancialAccount"), 0, 'account');
302
303 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
304
305 $morehtmlref = '';
306
307 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
308
309 print dol_get_fiche_end();
310
311 /* Moved as a tab
312 if ($object->canBeConciliated() > 0) {
313 $allowautomaticconciliation = false; // TODO
314 $titletoconciliatemanual = $langs->trans("Conciliate");
315 $titletoconciliateauto = $langs->trans("Conciliate");
316 if ($allowautomaticconciliation) {
317 $titletoconciliatemanual .= ' ('.$langs->trans("Manual").')';
318 $titletoconciliateauto .= ' ('.$langs->trans("Auto").')';
319 }
320
321 // If not cash account and can be reconciliate
322 if ($user->hasRight('banque', 'consolidate')) {
323 $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>';
324 } else {
325 $buttonreconcile = '<a class="butActionRefused classfortooltip" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$titletoconciliatemanual.'</a>';
326 }
327
328
329 if ($allowautomaticconciliation) {
330 // If not cash account and can be reconciliate
331 if ($user->hasRight('banque', 'consolidate')) {
332 $newparam = $param;
333 $newparam = preg_replace('/search_conciliated=\d+/i', '', $newparam);
334 $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>';
335 } else {
336 $buttonreconcile .= ' <a class="butActionRefused" style="margin-bottom: 5px !important; margin-top: 5px !important" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$titletoconciliateauto.'</a>';
337 }
338 }
339 }
340 */
341
342 // List of mass actions available
343 $arrayofmassactions = array(
344 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
345 //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
346 );
347 //if (in_array($massaction, array('presend', 'predelete'))) {
348 // $arrayofmassactions = array();
349 //}
350 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
351
352 $morehtml = '';
353
354 print '<form name="aaa" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
355 print '<input type="hidden" name="token" value="'.newToken().'">';
356 print '<input type="hidden" name="action" value="confirm_editbankreceipt">';
357 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
358 print '<input type="hidden" name="account" value="'.$object->id.'">';
359 print '<input type="hidden" name="page" value="'.$page.'">';
360
361 $param = "&account=".$object->id.($limit ? '&limit='.$limit : '');
362 print_barre_liste($langs->trans("AccountStatements"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton.$morehtml, $num, $totalnboflines, '', 0, '', '', $limit, 0, 0, 1);
363
364 print '<table class="noborder centpercent">';
365 print '<tr class="liste_titre">';
366 print '<td>'.$langs->trans("Ref").'</td>';
367 print '<td class="right">'.$langs->trans("InitialBankBalance").'</td>';
368 print '<td class="right">'.$langs->trans("EndBankBalance").'</td>';
369 print '<td></td>';
370 print '</tr>';
371
372 $balancestart = array();
373 $content = array();
374
375 $imaxinloop = ($limit ? min($num, $limit) : $num);
376 while ($i < $imaxinloop) {
377 $objp = $db->fetch_object($resql);
378
379 print '<tr class="oddeven">';
380 print '<td>';
381 if ($action != 'editbankreceipt' || $objp->numr != $brref) {
382 print '<a href="releve.php?num='.$objp->numr.'&account='.$object->id.'">'.$objp->numr.'</a>';
383 } else {
384 print '<input type="hidden" name="oldbankreceipt" value="'.$objp->numr.'">';
385 print '<input type="text" name="newbankreceipt" value="'.$objp->numr.'">';
386 print '<input type="submit" class="button smallpaddingimp" name="actionnewbankreceipt" value="'.$langs->trans("Save").'">';
387 print '<input type="submit" class="button button-cancel smallpaddingimp" name="cancel" value="'.$langs->trans("Cancel").'">';
388 }
389 print '</td>';
390
391 // Calculate start amount
392 $sql = "SELECT sum(b.amount) as amount";
393 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
394 $sql .= " WHERE b.num_releve < '".$db->escape($objp->numr)."'";
395 $sql .= " AND b.num_releve <> ''";
396 $sql .= " AND b.fk_account = ".((int) $object->id);
397 $resqlstart = $db->query($sql);
398 if ($resqlstart) {
399 $obj = $db->fetch_object($resqlstart);
400 $balancestart[$objp->numr] = $obj->amount;
401 $db->free($resqlstart);
402 }
403 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>';
404
405 // Calculate end amount
406 $sql = "SELECT sum(b.amount) as amount";
407 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
408 $sql .= " WHERE b.num_releve = '".$db->escape($objp->numr)."'";
409 $sql .= " AND b.fk_account = ".((int) $object->id);
410 $resqlend = $db->query($sql);
411 if ($resqlend) {
412 $obj = $db->fetch_object($resqlend);
413 $content[$objp->numr] = $obj->amount;
414 $db->free($resqlend);
415 }
416 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>';
417
418 print '<td class="center">';
419 if ($user->hasRight('banque', 'consolidate') && $action != 'editbankreceipt') {
420 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>';
421 }
422 print '</td>';
423
424 print '</tr>'."\n";
425
426
427 $i++;
428 }
429
430 if (empty($num)) {
431 print '<tr><td colspan="5"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
432 }
433
434 print "</table>\n";
435 print '</form>';
436
437 print "\n</div>\n";
438 } else {
440 }
441} else {
446 // Onglets
447 $head = account_statement_prepare_head($object, $numref);
448 print dol_get_fiche_head($head, 'statement', $langs->trans("AccountStatement"), -1, 'account');
449
450
451 $morehtmlright = '';
452 $morehtmlright .= '<div class="pagination"><ul>';
453 if ($foundprevious) {
454 $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>';
455 }
456 $morehtmlright .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
457 if ($foundnext) {
458 $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>';
459 }
460 $morehtmlright .= '</ul></div>';
461
462 $title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
463 print load_fiche_titre($title, $morehtmlright, '');
464
465 print '<form method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
466 print '<input type="hidden" name="token" value="'.newToken().'">';
467 print '<input type="hidden" name="action" value="add">';
468
469 print '<div class="div-table-responsive">';
470 print '<table class="noborder centpercent">';
471 print '<tr class="liste_titre">';
472 print '<td class="center">'.$langs->trans("DateOperationShort").'</td>';
473 print '<td class="center">'.$langs->trans("DateValueShort").'</td>';
474 print '<td>'.$langs->trans("Type").'</td>';
475 print '<td>'.$langs->trans("Description").'</td>';
476 print '<td class="right" width="60">'.$langs->trans("Debit").'</td>';
477 print '<td class="right" width="60">'.$langs->trans("Credit").'</td>';
478 print '<td class="right">'.$langs->trans("Balance").'</td>';
479 print '<td>&nbsp;</td>';
480 print "</tr>\n";
481
482 // Calculate the opening balance of the statement
483 $sql = "SELECT sum(b.amount) as amount";
484 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
485 $sql .= " WHERE b.num_releve < '".$db->escape($numref)."'";
486 $sql .= " AND b.num_releve <> ''";
487 $sql .= " AND b.fk_account = ".((int) $object->id);
488
489 $resql = $db->query($sql);
490 if ($resql) {
491 $obj = $db->fetch_object($resql);
492 $total = $obj->amount;
493 $db->free($resql);
494 } else {
495 $total = 0;
496 }
497
498 $totalc = $totald = 0;
499
500 // Search entries for the statement
501 $sql = $sqlrequestforbankline;
502
503 $resql = $db->query($sql);
504 if ($resql) {
505 $num = $db->num_rows($resql);
506 $i = 0;
507
508 // Row with the start balance of the bank statement
509 print '<tr class="oddeven"><td colspan="3"></td>';
510 print '<td colspan="3"><b>'.$langs->trans("InitialBankBalance")." :</b></td>";
511 print '<td class="right"><b>'.price($total).'</b></td><td>&nbsp;</td>';
512 print "</tr>\n";
513
514 while ($i < $num) {
515 $objp = $db->fetch_object($resql);
516 $total += $objp->amount;
517
518 print '<tr class="oddeven">';
519
520 // Date operation
521 print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->do), "day").'</td>';
522
523 // Value date
524 print '<td valign="center" class="center nowrap">';
525 print '<span class="spanforajaxedit">'.dol_print_date($db->jdate($objp->dv), "day").'</span>';
526 print '&nbsp;';
527 print '<span class="inline-block">';
528 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.'">';
529 print img_edit_remove()."</a> ";
530 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.'">';
531 print img_edit_add()."</a>";
532 print '</span>';
533 print "</td>\n";
534
535 // Type and num
536 if ($objp->fk_type == 'SOLD') {
537 $type_label = '&nbsp;';
538 } else {
539 $type_label = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $objp->fk_type;
540 }
541 $link = '';
542 if ($objp->fk_bordereau > 0) {
543 $remisestatic->id = $objp->fk_bordereau;
544 $remisestatic->ref = $objp->ref;
545 $link = ' '.$remisestatic->getNomUrl(1);
546 }
547 print '<td class="nowrap">'.$type_label.' '.($objp->num_chq ? $objp->num_chq : '').$link.'</td>';
548
549 // Description
550 print '<td valign="center">';
551 print '<a href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$objp->rowid.'&account='.$object->id.'">';
552 $reg = array();
553
554 preg_match('/\‍((.+)\‍)/i', $objp->label, $reg); // If text rounded by parenthesis, we try to search translation
555 if (!empty($reg[1]) && $langs->trans($reg[1]) != $reg[1]) {
556 print $langs->trans($reg[1]);
557 } else {
558 print dol_escape_htmltag($objp->label);
559 }
560 print '</a>';
561
562 /*
563 * Add links under the label (link to payment, company, user, social contribution...)
564 */
565 $newline = 1;
566 $links = $object->get_url($objp->rowid);
567 foreach ($links as $key => $val) {
568 if (!$newline) {
569 print ' - ';
570 } else {
571 print '<br>';
572 }
573 if ($links[$key]['type'] == 'payment') {
574 $paymentstatic->id = $links[$key]['url_id'];
575 $paymentstatic->ref = $langs->trans("Payment");
576 print ' '.$paymentstatic->getNomUrl(1);
577 $newline = 0;
578 } elseif ($links[$key]['type'] == 'payment_supplier') {
579 $paymentsupplierstatic->id = $links[$key]['url_id'];
580 $paymentsupplierstatic->ref = $langs->trans("Payment");
581 print ' '.$paymentsupplierstatic->getNomUrl(1);
582 $newline = 0;
583 } elseif ($links[$key]['type'] == 'payment_sc') {
584 print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">';
585 print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
586 print $langs->trans("SocialContributionPayment");
587 print '</a>';
588 $newline = 0;
589 } elseif ($links[$key]['type'] == 'payment_vat') {
590 $paymentvatstatic->id = $links[$key]['url_id'];
591 $paymentvatstatic->ref = $langs->trans("Payment");
592 print ' '.$paymentvatstatic->getNomUrl(1);
593 } elseif ($links[$key]['type'] == 'payment_salary') {
594 print '<a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$links[$key]['url_id'].'">';
595 print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
596 print $langs->trans("Payment");
597 print '</a>';
598 $newline = 0;
599 } elseif ($links[$key]['type'] == 'payment_donation') {
600 $paymentdonationstatic->id = $links[$key]['url_id'];
601 $paymentdonationstatic->ref = $langs->trans("Payment");
602 print ' '.$paymentdonationstatic->getNomUrl(1);
603 $newline = 0;
604 } elseif ($links[$key]['type'] == 'payment_loan') {
605 $paymentloanstatic->id = $links[$key]['url_id'];
606 $paymentloanstatic->ref = $langs->trans("Payment");
607 print ' '.$paymentloanstatic->getNomUrl(1);
608 $newline = 0;
609 } elseif ($links[$key]['type'] == 'payment_various') {
610 $paymentvariousstatic->id = $links[$key]['url_id'];
611 $paymentvariousstatic->ref = $langs->trans("Payment");
612 print ' '.$paymentvariousstatic->getNomUrl(1);
613 $newline = 0;
614 } elseif ($links[$key]['type'] == 'banktransfert') {
615 // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
616 if ($objp->amount > 0) {
617 $banklinestatic->fetch($links[$key]['url_id']);
618 $bankstatic->id = $banklinestatic->fk_account;
619 $bankstatic->label = $banklinestatic->bank_account_label;
620 print ' ('.$langs->trans("from").' ';
621 print $bankstatic->getNomUrl(1, 'transactions');
622 print ' '.$langs->trans("toward").' ';
623 $bankstatic->id = $objp->bankid;
624 $bankstatic->label = $objp->bankref;
625 print $bankstatic->getNomUrl(1, '');
626 print ')';
627 } else {
628 $bankstatic->id = $objp->bankid;
629 $bankstatic->label = $objp->bankref;
630 print ' ('.$langs->trans("from").' ';
631 print $bankstatic->getNomUrl(1, '');
632 print ' '.$langs->trans("toward").' ';
633 $banklinestatic->fetch($links[$key]['url_id']);
634 $bankstatic->id = $banklinestatic->fk_account;
635 $bankstatic->label = $banklinestatic->bank_account_label;
636 print $bankstatic->getNomUrl(1, 'transactions');
637 print ')';
638 }
639 } elseif ($links[$key]['type'] == 'company') {
640 $societestatic->id = $links[$key]['url_id'];
641 $societestatic->name = $links[$key]['label'];
642 print $societestatic->getNomUrl(1, 'company', 24);
643 $newline = 0;
644 } elseif ($links[$key]['type'] == 'member') {
645 print '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$links[$key]['url_id'].'">';
646 print img_object($langs->trans('ShowMember'), 'user').' ';
647 print $links[$key]['label'];
648 print '</a>';
649 $newline = 0;
650 } elseif ($links[$key]['type'] == 'user') {
651 print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$links[$key]['url_id'].'">';
652 print img_object($langs->trans('ShowUser'), 'user').' ';
653 print $links[$key]['label'];
654 print '</a>';
655 $newline = 0;
656 } elseif ($links[$key]['type'] == 'sc') {
657 print '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$links[$key]['url_id'].'">';
658 print img_object($langs->trans('ShowBill'), 'bill').' ';
659 print $langs->trans("SocialContribution");
660 print '</a>';
661 $newline = 0;
662 } else {
663 print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
664 print $links[$key]['label'];
665 print '</a>';
666 $newline = 0;
667 }
668 }
669
670 // Categories
671 if ($ve) {
672 $sql = "SELECT label";
673 $sql .= " FROM ".MAIN_DB_PREFIX."categorie as ct";
674 $sql .= ", ".MAIN_DB_PREFIX."category_bankline as cl";
675 $sql .= " WHERE ct.rowid = cl.fk_categ";
676 $sql .= " AND ct.entity = ".((int) $conf->entity);
677 $sql .= " AND cl.lineid = ".((int) $objp->rowid);
678
679 $resc = $db->query($sql);
680 if ($resc) {
681 $numc = $db->num_rows($resc);
682 $ii = 0;
683 if ($numc && !$newline) {
684 print '<br>';
685 }
686 while ($ii < $numc) {
687 $objc = $db->fetch_object($resc);
688 print "<br>-&nbsp;<i>".$objc->label."</i>";
689 $ii++;
690 }
691 } else {
693 }
694 }
695
696 print "</td>";
697
698 if ($objp->amount < 0) {
699 $totald += abs($objp->amount);
700 print '<td class="nowrap right">'.price($objp->amount * -1)."</td><td>&nbsp;</td>\n";
701 } else {
702 $totalc += abs($objp->amount);
703 print '<td>&nbsp;</td><td class="nowrap right">'.price($objp->amount)."</td>\n";
704 }
705
706 print '<td class="nowrap right">'.price(price2num($total, 'MT'))."</td>\n";
707
708 if ($user->hasRight('banque', 'modifier') || $user->hasRight('banque', 'consolidate')) {
709 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)).'">';
710 print img_edit();
711 print "</a></td>";
712 } else {
713 print "<td class=\"center\">&nbsp;</td>";
714 }
715 print "</tr>";
716 $i++;
717 }
718 $db->free($resql);
719 } else {
721 }
722
723 // Line Total
724 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>";
725
726 // Line Balance
727 print "\n<tr>";
728 print "<td class=\"right\" colspan=\"3\">&nbsp;</td><td colspan=\"3\"><b>".$langs->trans("EndBankBalance")." :</b></td>";
729 print '<td class="right"><b>'.price(price2num($total, 'MT'))."</b></td><td>&nbsp;</td>";
730 print "</tr>\n";
731 print "</table>";
732
733 // Code to adjust value date with plus and less picto using an Ajax call instead of a full reload of page
734 $urlajax = DOL_URL_ROOT.'/core/ajax/bankconciliate.php?token='.currentToken();
735 print '
736 <script type="text/javascript">
737 $(function() {
738 $("a.ajaxforbankoperationchange").each(function(){
739 var current = $(this);
740 current.click(function()
741 {
742 var url = "'.$urlajax.'&"+current.attr("href").split("?")[1];
743 console.log("We click on ajaxforbankoperationchange url="+url);
744 $.get(url, function(data)
745 {
746 console.log(data);
747 current.parent().parent().find(".spanforajaxedit").replaceWith(data);
748 });
749 return false;
750 });
751 });
752 });
753 </script>
754 ';
755
756 print "</div>";
757
758 print "</form>\n";
759}
760
761// End of page
762llxFooter();
763$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.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
currentToken()
Return the value of token currently saved into session with name 'token'.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.
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.
Definition html.lib.php:519
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:717
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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.
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...
Definition html.lib.php:172
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.