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