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