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