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