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