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