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