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