dolibarr  13.0.2
releve.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
6  * Copyright (C) 2017 Patrick Delcroix <pmpdelcroix@gmail.com>
7  * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 require '../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
44 //show files
45 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
47 
48 // Load translation files required by the page
49 $langs->loadLangs(array("banks", "categories", "companies", "bills", "trips", "donations", "loan"));
50 
51 $action = GETPOST('action', 'aZ09');
52 $id = GETPOST('account', 'int') ? GETPOST('account', 'int') : GETPOST('id', 'int');
53 $ref = GETPOST('ref', 'alpha');
54 $dvid = GETPOST('dvid', 'alpha');
55 $numref = GETPOST('num', 'alpha');
56 $ve = GETPOST("ve", 'alpha');
57 $brref = GETPOST('brref', 'alpha');
58 $oldbankreceipt = GETPOST('oldbankreceipt', 'alpha');
59 $newbankreceipt = GETPOST('newbankreceipt', 'alpha');
60 
61 // Security check
62 $fieldid = (!empty($ref) ? $ref : $id);
63 $fieldname = isset($ref) ? 'ref' : 'rowid';
64 if ($user->socid) $socid = $user->socid;
65 $result = restrictedArea($user, 'banque', $fieldid, 'bank_account', '', '', $fieldname);
66 
67 if ($user->rights->banque->consolidate && $action == 'dvnext' && !empty($dvid))
68 {
69  $al = new AccountLine($db);
70  $al->datev_next($dvid);
71 }
72 
73 if ($user->rights->banque->consolidate && $action == 'dvprev' && !empty($dvid))
74 {
75  $al = new AccountLine($db);
76  $al->datev_previous($dvid);
77 }
78 
79 
80 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
81 $sortfield = GETPOST("sortfield", 'alpha');
82 $sortorder = GETPOST("sortorder", 'alpha');
83 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
84 $pageplusone = GETPOST("pageplusone", 'int');
85 if ($pageplusone) $page = $pageplusone - 1;
86 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
87 $offset = $limit * $page;
88 $pageprev = $page - 1;
89 $pagenext = $page + 1;
90 if (!$sortorder) $sortorder = "ASC";
91 if (!$sortfield) $sortfield = "s.nom";
92 
93 $object = new Account($db);
94 if ($id > 0 || !empty($ref))
95 {
96  $result = $object->fetch($id, $ref);
97  $account = $object->id; // Force the search field on id of account
98 }
99 
100 
101 // Initialize technical object to manage context to save list fields
102 $contextpage = 'banktransactionlist'.(empty($object->ref) ? '' : '-'.$object->id);
103 
104 
105 // Define number of receipt to show (current, previous or next one ?)
106 $found = false;
107 if ($_GET["rel"] == 'prev')
108 {
109  // Recherche valeur pour num = numero releve precedent
110  $sql = "SELECT DISTINCT(b.num_releve) as num";
111  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
112  $sql .= " WHERE b.num_releve < '".$db->escape($numref)."'";
113  $sql .= " AND b.fk_account = ".$object->id;
114  $sql .= " ORDER BY b.num_releve DESC";
115 
116  dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
117  $resql = $db->query($sql);
118  if ($resql)
119  {
120  $numrows = $db->num_rows($resql);
121  if ($numrows > 0)
122  {
123  $obj = $db->fetch_object($resql);
124  $numref = $obj->num;
125  $found = true;
126  }
127  }
128 } elseif ($_GET["rel"] == 'next')
129 {
130  // Recherche valeur pour num = numero releve precedent
131  $sql = "SELECT DISTINCT(b.num_releve) as num";
132  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
133  $sql .= " WHERE b.num_releve > '".$db->escape($numref)."'";
134  $sql .= " AND b.fk_account = ".$object->id;
135  $sql .= " ORDER BY b.num_releve ASC";
136 
137  dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
138  $resql = $db->query($sql);
139  if ($resql)
140  {
141  $numrows = $db->num_rows($resql);
142  if ($numrows > 0)
143  {
144  $obj = $db->fetch_object($resql);
145  $numref = $obj->num;
146  $found = true;
147  }
148  }
149 } else {
150  // On veut le releve num
151  $found = true;
152 }
153 
154 
155 $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,";
156 $sql .= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
157 $sql .= " b.fk_bordereau,";
158 $sql .= " bc.ref,";
159 $sql .= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel";
160 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
161 $sql .= ", ".MAIN_DB_PREFIX."bank as b";
162 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau';
163 $sql .= " WHERE b.num_releve='".$db->escape($numref)."'";
164 if (empty($numref)) $sql .= " OR b.num_releve is null";
165 $sql .= " AND b.fk_account = ".$object->id;
166 $sql .= " AND b.fk_account = ba.rowid";
167 $sql .= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
168 
169 $sqlrequestforbankline = $sql;
170 
171 
172 
173 /*
174  * Actions
175  */
176 
177 if ($action == 'confirm_editbankreceipt' && !empty($oldbankreceipt) && !empty($newbankreceipt))
178 {
179  // TODO Add a test to check newbankreceipt does not exists yet
180  $sqlupdate = 'UPDATE '.MAIN_DB_PREFIX.'bank SET num_releve = "'.$db->escape($newbankreceipt).'" WHERE num_releve = "'.$db->escape($oldbankreceipt).'" AND fk_account = '.$id;
181  $result = $db->query($sqlupdate);
182  if ($result < 0) dol_print_error($db);
183 
184  $action = 'view';
185 }
186 
187 
188 /*
189  * View
190  */
191 
192 $title = $langs->trans("FinancialAccount").' - '.$langs->trans("AccountStatements");
193 $helpurl = "";
194 llxHeader('', $title, $helpurl);
195 
196 $form = new Form($db);
197 $societestatic = new Societe($db);
198 $chargestatic = new ChargeSociales($db);
199 $memberstatic = new Adherent($db);
200 $paymentstatic = new Paiement($db);
201 $paymentsupplierstatic = new PaiementFourn($db);
202 $paymentvatstatic = new TVA($db);
203 $bankstatic = new Account($db);
204 $banklinestatic = new AccountLine($db);
205 $remisestatic = new RemiseCheque($db);
206 $paymentdonationstatic = new PaymentDonation($db);
207 $paymentloanstatic = new PaymentLoan($db);
208 $paymentvariousstatic = new PaymentVarious($db);
209 
210 // Must be before button action
211 $param = '';
212 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
213 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
214 if ($id > 0) $param .= '&id='.urlencode($id);
215 
216 
217 if (empty($numref))
218 {
219  $sortfield = 'numr';
220  $sortorder = 'DESC';
221 
222  // List of all standing receipts
223  $sql = "SELECT DISTINCT(b.num_releve) as numr";
224  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
225  $sql .= " WHERE b.fk_account = ".$object->id;
226  $sql .= $db->order($sortfield, $sortorder);
227 
228  // Count total nb of records
229  $nbtotalofrecords = '';
230  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
231  {
232  $result = $db->query($sql);
233  $nbtotalofrecords = $db->num_rows($result);
234  }
235 
236  $sql .= $db->plimit($conf->liste_limit + 1, $offset);
237 
238  $result = $db->query($sql);
239  if ($result)
240  {
241  $numrows = $db->num_rows($result);
242  $i = 0;
243 
244  // Onglets
245  $head = bank_prepare_head($object);
246  print dol_get_fiche_head($head, 'statement', $langs->trans("FinancialAccount"), 0, 'account');
247 
248  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
249 
250  $morehtmlref = '';
251 
252  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
253 
255 
256 
257  print '<div class="tabsAction">';
258 
259  if ($object->canBeConciliated() > 0) {
260  // If not cash account and can be reconciliate
261  if ($user->rights->banque->consolidate) {
262  print '<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.'">'.$langs->trans("Conciliate").'</a>';
263  } else {
264  print '<a class="butActionRefused classfortooltip" title="'.$langs->trans("NotEnoughPermissions").'" href="#">'.$langs->trans("Conciliate").'</a>';
265  }
266  }
267 
268  print '</div>';
269 
270 
271  print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder, '', $numrows, $totalnboflines, '');
272 
273  print '<form name="aaa" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
274  print '<input type="hidden" name="token" value="'.newToken().'">';
275  print '<input type="hidden" name="action" value="confirm_editbankreceipt">';
276  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
277  print '<input type="hidden" name="account" value="'.$object->id.'">';
278  print '<input type="hidden" name="page" value="'.$page.'">';
279 
280  print '<table class="noborder centpercent">';
281  print '<tr class="liste_titre">';
282  print '<td>'.$langs->trans("Ref").'</td>';
283  print '<td class="right">'.$langs->trans("InitialBankBalance").'</td>';
284  print '<td class="right">'.$langs->trans("EndBankBalance").'</td>';
285  print '<td></td>';
286  print '</tr>';
287 
288  $balancestart = array();
289  $content = array();
290 
291  while ($i < min($numrows, $conf->liste_limit))
292  {
293  $objp = $db->fetch_object($result);
294 
295  if (!isset($objp->numr))
296  {
297  //
298  } else {
299  print '<tr class="oddeven">';
300  print '<td>';
301  if ($action != 'editbankreceipt' || $objp->numr != $brref)
302  {
303  print '<a href="releve.php?num='.$objp->numr.'&account='.$object->id.'">'.$objp->numr.'</a>';
304  } else {
305  print '<input type="hidden" name="oldbankreceipt" value="'.$objp->numr.'">';
306  print '<input type="text" name="newbankreceipt" value="'.$objp->numr.'">';
307  print '<input type="submit" class="button" name="actionnewbankreceipt" value="'.$langs->trans("Rename").'">';
308  print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
309  }
310  print '</td>';
311 
312  // Calculate start amount
313  $sql = "SELECT sum(b.amount) as amount";
314  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
315  $sql .= " WHERE b.num_releve < '".$db->escape($objp->numr)."'";
316  $sql .= " AND b.fk_account = ".$object->id;
317  $resql = $db->query($sql);
318  if ($resql)
319  {
320  $obj = $db->fetch_object($resql);
321  $balancestart[$objp->numr] = $obj->amount;
322  $db->free($resql);
323  }
324  print '<td class="right">'.price($balancestart[$objp->numr], '', $langs, 1, -1, -1, $conf->currency).'</td>';
325 
326  // Calculate end amount
327  $sql = "SELECT sum(b.amount) as amount";
328  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
329  $sql .= " WHERE b.num_releve = '".$db->escape($objp->numr)."'";
330  $sql .= " AND b.fk_account = ".$object->id;
331  $resql = $db->query($sql);
332  if ($resql)
333  {
334  $obj = $db->fetch_object($resql);
335  $content[$objp->numr] = $obj->amount;
336  $db->free($resql);
337  }
338  print '<td class="right">'.price(($balancestart[$objp->numr] + $content[$objp->numr]), '', $langs, 1, -1, -1, $conf->currency).'</td>';
339 
340  print '<td class="center">';
341  if ($user->rights->banque->consolidate && $action != 'editbankreceipt') {
342  print '<a href="'.$_SERVER["PHP_SELF"].'?account='.$object->id.($page > 0 ? '&page='.$page : '').'&action=editbankreceipt&brref='.$objp->numr.'">'.img_edit().'</a>';
343  }
344  print '</td>';
345 
346  print '</tr>'."\n";
347  }
348  $i++;
349  }
350  print "</table>\n";
351  print '</form>';
352 
353  print "\n</div>\n";
354  } else {
355  dol_print_error($db);
356  }
357 } else {
362  // Onglets
363  $head = account_statement_prepare_head($object, $numref);
364  print dol_get_fiche_head($head, 'statement', $langs->trans("AccountStatement"), -1, 'account');
365 
366 
367  $morehtmlright = '';
368  $morehtmlright .= '<div class="pagination"><ul>';
369  $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>';
370  $morehtmlright .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
371  $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>';
372  $morehtmlright .= '</ul></div>';
373 
374  $title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
375  print load_fiche_titre($title, $morehtmlright, '');
376  //print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'bank_account', 0, '', '', 0, 1);
377 
378  print "<form method=\"post\" action=\"releve.php\">";
379  print '<input type="hidden" name="token" value="'.newToken().'">';
380  print '<input type="hidden" name="action" value="add">';
381 
382  print '<div class="div-table-responsive">';
383  print '<table class="noborder centpercent">';
384  print '<tr class="liste_titre">';
385  print '<td class="center">'.$langs->trans("DateOperationShort").'</td>';
386  print '<td class="center">'.$langs->trans("DateValueShort").'</td>';
387  print '<td>'.$langs->trans("Type").'</td>';
388  print '<td>'.$langs->trans("Description").'</td>';
389  print '<td class="right" width="60">'.$langs->trans("Debit").'</td>';
390  print '<td class="right" width="60">'.$langs->trans("Credit").'</td>';
391  print '<td class="right">'.$langs->trans("Balance").'</td>';
392  print '<td>&nbsp;</td>';
393  print "</tr>\n";
394 
395  // Calcul du solde de depart du releve
396  $sql = "SELECT sum(b.amount) as amount";
397  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
398  $sql .= " WHERE b.num_releve < '".$db->escape($numref)."'";
399  $sql .= " AND b.fk_account = ".$object->id;
400 
401  $resql = $db->query($sql);
402  if ($resql)
403  {
404  $obj = $db->fetch_object($resql);
405  $total = $obj->amount;
406  $db->free($resql);
407  }
408 
409  // Recherche les ecritures pour le releve
410  $sql = $sqlrequestforbankline;
411 
412  $result = $db->query($sql);
413  if ($result)
414  {
415  $numrows = $db->num_rows($result);
416  $i = 0;
417 
418  // Ligne Solde debut releve
419  print '<tr class="oddeven"><td colspan="3"></td>';
420  print '<td colspan="3"><b>'.$langs->trans("InitialBankBalance")." :</b></td>";
421  print '<td class="right"><b>'.price($total).'</b></td><td>&nbsp;</td>';
422  print "</tr>\n";
423 
424  while ($i < $numrows)
425  {
426  $objp = $db->fetch_object($result);
427  $total = $total + $objp->amount;
428 
429  print '<tr class="oddeven">';
430 
431  // Date operation
432  print '<td class="nowrap center">'.dol_print_date($db->jdate($objp->do), "day").'</td>';
433 
434  // Date de valeur
435  print '<td valign="center" class="center nowrap">';
436  print dol_print_date($db->jdate($objp->dv), "day").' ';
437  print '<a class="ajax reposition" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&amp;num='.$numref.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
438  print img_edit_remove()."</a> ";
439  print '<a class="ajax reposition" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&amp;num='.$numref.'&amp;account='.$object->id.'&amp;dvid='.$objp->rowid.'">';
440  print img_edit_add()."</a>";
441  print "</td>\n";
442 
443  // Type and num
444  if ($objp->fk_type == 'SOLD') {
445  $type_label = '&nbsp;';
446  } else {
447  $type_label = ($langs->trans("PaymentTypeShort".$objp->fk_type) != "PaymentTypeShort".$objp->fk_type) ? $langs->trans("PaymentTypeShort".$objp->fk_type) : $objp->fk_type;
448  }
449  $link = '';
450  if ($objp->fk_bordereau > 0) {
451  $remisestatic->id = $objp->fk_bordereau;
452  $remisestatic->ref = $objp->ref;
453  $link = ' '.$remisestatic->getNomUrl(1);
454  }
455  print '<td class="nowrap">'.$type_label.' '.($objp->num_chq ? $objp->num_chq : '').$link.'</td>';
456 
457  // Description
458  print '<td valign="center">';
459  print '<a href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$objp->rowid.'&amp;account='.$object->id.'">';
460  $reg = array();
461  preg_match('/\((.+)\)/i', $objp->label, $reg); // Si texte entoure de parenthese on tente recherche de traduction
462  if ($reg[1] && $langs->trans($reg[1]) != $reg[1]) print $langs->trans($reg[1]);
463  else print $objp->label;
464  print '</a>';
465 
466  /*
467  * Ajout les liens (societe, company...)
468  */
469  $newline = 1;
470  $links = $object->get_url($objp->rowid);
471  foreach ($links as $key=>$val)
472  {
473  if (!$newline) print ' - ';
474  else print '<br>';
475  if ($links[$key]['type'] == 'payment')
476  {
477  $paymentstatic->id = $links[$key]['url_id'];
478  $paymentstatic->ref = $langs->trans("Payment");
479  print ' '.$paymentstatic->getNomUrl(1);
480  $newline = 0;
481  } elseif ($links[$key]['type'] == 'payment_supplier')
482  {
483  $paymentsupplierstatic->id = $links[$key]['url_id'];
484  $paymentsupplierstatic->ref = $langs->trans("Payment");
485  print ' '.$paymentsupplierstatic->getNomUrl(1);
486  $newline = 0;
487  } elseif ($links[$key]['type'] == 'payment_sc')
488  {
489  print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">';
490  print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
491  print $langs->trans("SocialContributionPayment");
492  print '</a>';
493  $newline = 0;
494  } elseif ($links[$key]['type'] == 'payment_vat')
495  {
496  $paymentvatstatic->id = $links[$key]['url_id'];
497  $paymentvatstatic->ref = $langs->trans("Payment");
498  print ' '.$paymentvatstatic->getNomUrl(1);
499  } elseif ($links[$key]['type'] == 'payment_salary')
500  {
501  print '<a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$links[$key]['url_id'].'">';
502  print ' '.img_object($langs->trans('ShowPayment'), 'payment').' ';
503  print $langs->trans("Payment");
504  print '</a>';
505  $newline = 0;
506  } elseif ($links[$key]['type'] == 'payment_donation')
507  {
508  $paymentdonationstatic->id = $links[$key]['url_id'];
509  $paymentdonationstatic->ref = $langs->trans("Payment");
510  print ' '.$paymentdonationstatic->getNomUrl(1);
511  $newline = 0;
512  } elseif ($links[$key]['type'] == 'payment_loan')
513  {
514  $paymentloanstatic->id = $links[$key]['url_id'];
515  $paymentloanstatic->ref = $langs->trans("Payment");
516  print ' '.$paymentloanstatic->getNomUrl(1);
517  $newline = 0;
518  } elseif ($links[$key]['type'] == 'payment_various')
519  {
520  $paymentvariousstatic->id = $links[$key]['url_id'];
521  $paymentvariousstatic->ref = $langs->trans("Payment");
522  print ' '.$paymentvariousstatic->getNomUrl(1);
523  $newline = 0;
524  } elseif ($links[$key]['type'] == 'banktransfert') {
525  // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
526  if ($objp->amount > 0)
527  {
528  $banklinestatic->fetch($links[$key]['url_id']);
529  $bankstatic->id = $banklinestatic->fk_account;
530  $bankstatic->label = $banklinestatic->bank_account_label;
531  print ' ('.$langs->trans("from").' ';
532  print $bankstatic->getNomUrl(1, 'transactions');
533  print ' '.$langs->trans("toward").' ';
534  $bankstatic->id = $objp->bankid;
535  $bankstatic->label = $objp->bankref;
536  print $bankstatic->getNomUrl(1, '');
537  print ')';
538  } else {
539  $bankstatic->id = $objp->bankid;
540  $bankstatic->label = $objp->bankref;
541  print ' ('.$langs->trans("from").' ';
542  print $bankstatic->getNomUrl(1, '');
543  print ' '.$langs->trans("toward").' ';
544  $banklinestatic->fetch($links[$key]['url_id']);
545  $bankstatic->id = $banklinestatic->fk_account;
546  $bankstatic->label = $banklinestatic->bank_account_label;
547  print $bankstatic->getNomUrl(1, 'transactions');
548  print ')';
549  }
550  } elseif ($links[$key]['type'] == 'company') {
551  $societestatic->id = $links[$key]['url_id'];
552  $societestatic->name = $links[$key]['label'];
553  print $societestatic->getNomUrl(1, 'company', 24);
554  $newline = 0;
555  } elseif ($links[$key]['type'] == 'member') {
556  print '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$links[$key]['url_id'].'">';
557  print img_object($langs->trans('ShowMember'), 'user').' ';
558  print $links[$key]['label'];
559  print '</a>';
560  $newline = 0;
561  } elseif ($links[$key]['type'] == 'user') {
562  print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$links[$key]['url_id'].'">';
563  print img_object($langs->trans('ShowUser'), 'user').' ';
564  print $links[$key]['label'];
565  print '</a>';
566  $newline = 0;
567  } elseif ($links[$key]['type'] == 'sc') {
568  print '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$links[$key]['url_id'].'">';
569  print img_object($langs->trans('ShowBill'), 'bill').' ';
570  print $langs->trans("SocialContribution");
571  print '</a>';
572  $newline = 0;
573  } else {
574  print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
575  print $links[$key]['label'];
576  print '</a>';
577  $newline = 0;
578  }
579  }
580 
581  // Categories
582  if ($ve)
583  {
584  $sql = "SELECT label";
585  $sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as ct";
586  $sql .= ", ".MAIN_DB_PREFIX."bank_class as cl";
587  $sql .= " WHERE ct.rowid = cl.fk_categ";
588  $sql .= " AND ct.entity = ".$conf->entity;
589  $sql .= " AND cl.lineid = ".$objp->rowid;
590 
591  $resc = $db->query($sql);
592  if ($resc)
593  {
594  $numc = $db->num_rows($resc);
595  $ii = 0;
596  if ($numc && !$newline) print '<br>';
597  while ($ii < $numc)
598  {
599  $objc = $db->fetch_object($resc);
600  print "<br>-&nbsp;<i>".$objc->label."</i>";
601  $ii++;
602  }
603  } else {
604  dol_print_error($db);
605  }
606  }
607 
608  print "</td>";
609 
610  if ($objp->amount < 0)
611  {
612  $totald = $totald + abs($objp->amount);
613  print '<td class="nowrap right">'.price($objp->amount * -1)."</td><td>&nbsp;</td>\n";
614  } else {
615  $totalc = $totalc + abs($objp->amount);
616  print '<td>&nbsp;</td><td class="nowrap right">'.price($objp->amount)."</td>\n";
617  }
618 
619  print '<td class="nowrap right">'.price(price2num($total, 'MT'))."</td>\n";
620 
621  if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
622  {
623  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).'">';
624  print img_edit();
625  print "</a></td>";
626  } else {
627  print "<td class=\"center\">&nbsp;</td>";
628  }
629  print "</tr>";
630  $i++;
631  }
632  $db->free($result);
633  }
634 
635  // Line Total
636  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>";
637 
638  // Line Balance
639  print "\n<tr>";
640  print "<td class=\"right\" colspan=\"3\">&nbsp;</td><td colspan=\"3\"><b>".$langs->trans("EndBankBalance")." :</b></td>";
641  print '<td class="right"><b>'.price(price2num($total, 'MT'))."</b></td><td>&nbsp;</td>";
642  print "</tr>\n";
643  print "</table>";
644 
645  print "</div>";
646 
647  print "</form>\n";
648 }
649 
650 // End of page
651 llxFooter();
652 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
Class to manage various payments.
bank_prepare_head(Account $object)
Prepare array with list of tabs.
Definition: bank.lib.php:35
account_statement_prepare_head($object, $num)
Prepare array with list of tabs.
Definition: bank.lib.php:168
Class to manage bank transaction lines.
Class to manage bank accounts.
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...
llxHeader()
Empty header.
Definition: wrapper.php:45
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.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
Class to manage payments of loans.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage payments of customer invoices.
Class to manage members of a foundation.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
Class to manage payments of donations.
print $_SERVER["PHP_SELF"]
Edit parameters.
img_edit_add($titlealt= 'default', $other= '')
Show logo +.
img_edit_remove($titlealt= 'default', $other= '')
Show logo -.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
Class to manage payments for supplier invoices.
llxFooter()
Empty footer.
Definition: wrapper.php:59
Classe permettant la gestion des paiements des charges La tva collectee n&#39;est calculee que sur les fa...
Class to manage cheque delivery receipts.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...