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