dolibarr  16.0.5
line.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2003 Xavier DUTOIT <doli@sydesy.com>
4  * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
6  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
7  * Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
8  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
9  * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
10  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
11  * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <https://www.gnu.org/licenses/>.
25  */
26 
33 require '../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
37 
38 // Load translation files required by the page
39 $langs->loadLangs(array('banks', 'categories', 'compta', 'bills', 'other'));
40 if (isModEnabled('adherent')) {
41  $langs->load("members");
42 }
43 if (isModEnabled('don')) {
44  $langs->load("donations");
45 }
46 if (isModEnabled('loan')) {
47  $langs->load("loan");
48 }
49 if (isModEnabled('salaries')) {
50  $langs->load("salaries");
51 }
52 
53 
54 $id = GETPOST('rowid', 'int');
55 $rowid = GETPOST("rowid", 'int');
56 $accountoldid = GETPOST('account', 'int'); // GETPOST('account') is old account id
57 $accountid = GETPOST('accountid', 'int'); // GETPOST('accountid') is new account id
58 $ref = GETPOST('ref', 'alpha');
59 $action = GETPOST('action', 'aZ09');
60 $confirm = GETPOST('confirm', 'alpha');
61 $orig_account = GETPOST("orig_account");
62 $backtopage = GETPOST('backtopage', 'alpha');
63 $cancel = GETPOST('cancel', 'alpha');
64 
65 // Security check
66 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
67 $fieldtype = (!empty($ref) ? 'ref' : 'rowid');
68 $socid = 0;
69 if ($user->socid) {
70  $socid = $user->socid;
71 }
72 
73 $result = restrictedArea($user, 'banque', $accountoldid, 'bank_account');
74 if (empty($user->rights->banque->lire) && empty($user->rights->banque->consolidate)) {
76 }
77 
78 $hookmanager->initHooks(array('bankline'));
79 
80 
81 /*
82  * Actions
83  */
84 
85 $parameters = array('socid' => $socid);
86 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
87 if ($reshook < 0) {
88  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
89 }
90 if ($cancel) {
91  if ($backtopage) {
92  header("Location: ".$backtopage);
93  exit;
94  }
95 }
96 
97 
98 if ($user->rights->banque->consolidate && $action == 'donext') {
99  $al = new AccountLine($db);
100  $al->dateo_next(GETPOST("rowid", 'int'));
101 } elseif ($user->rights->banque->consolidate && $action == 'doprev') {
102  $al = new AccountLine($db);
103  $al->dateo_previous(GETPOST("rowid", 'int'));
104 } elseif ($user->rights->banque->consolidate && $action == 'dvnext') {
105  $al = new AccountLine($db);
106  $al->datev_next(GETPOST("rowid", 'int'));
107 } elseif ($user->rights->banque->consolidate && $action == 'dvprev') {
108  $al = new AccountLine($db);
109  $al->datev_previous(GETPOST("rowid", 'int'));
110 }
111 
112 if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->banque->modifier) {
113  $cat1 = GETPOST("cat1", 'int');
114  if (!empty($rowid) && !empty($cat1)) {
115  $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".((int) $rowid)." AND fk_categ = ".((int) $cat1);
116  if (!$db->query($sql)) {
117  dol_print_error($db);
118  }
119  } else {
120  setEventMessages($langs->trans("MissingIds"), null, 'errors');
121  }
122 }
123 
124 if ($user->rights->banque->modifier && $action == "update") {
125  $error = 0;
126 
127  $acline = new AccountLine($db);
128  $result = $acline->fetch($rowid);
129  if ($result <= 0) {
130  dol_syslog('Failed to read bank line with id '.$rowid, LOG_WARNING); // This happens due to old bug that has set fk_account to null.
131  $acline->id = $rowid;
132  }
133 
134  $acsource = new Account($db);
135  $acsource->fetch($accountoldid);
136 
137  $actarget = new Account($db);
138  if (GETPOST('accountid', 'int') > 0 && !$acline->rappro && !$acline->getVentilExportCompta()) { // We ask to change bank account
139  $actarget->fetch(GETPOST('accountid', 'int'));
140  } else {
141  $actarget->fetch($accountoldid);
142  }
143 
144  if (!($actarget->id > 0)) {
145  setEventMessages($langs->trans("ErrorFailedToLoadBankAccount"), null, 'errors');
146  $error++;
147  }
148  if ($actarget->courant == Account::TYPE_CASH && GETPOST('value', 'alpha') != 'LIQ') {
149  setEventMessages($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), null, 'errors');
150  $error++;
151  }
152 
153  if (!$error) {
154  $db->begin();
155 
156  $amount = price2num(GETPOST('amount'));
157  $dateop = dol_mktime(12, 0, 0, GETPOST("dateomonth"), GETPOST("dateoday"), GETPOST("dateoyear"));
158  $dateval = dol_mktime(12, 0, 0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear"));
159  $sql = "UPDATE ".MAIN_DB_PREFIX."bank";
160  $sql .= " SET ";
161  // Always opened
162  if (GETPOSTISSET('value')) {
163  $sql .= " fk_type='".$db->escape(GETPOST('value'))."',";
164  }
165  if (GETPOSTISSET('num_chq')) {
166  $sql .= " num_chq='".$db->escape(GETPOST("num_chq"))."',";
167  }
168  if (GETPOSTISSET('banque')) {
169  $sql .= " banque='".$db->escape(GETPOST("banque"))."',";
170  }
171  if (GETPOSTISSET('emetteur')) {
172  $sql .= " emetteur='".$db->escape(GETPOST("emetteur"))."',";
173  }
174  // Blocked when conciliated
175  if (!$acline->rappro) {
176  if (GETPOSTISSET('label')) {
177  $sql .= " label = '".$db->escape(GETPOST("label"))."',";
178  }
179  if (GETPOSTISSET('amount')) {
180  $sql .= " amount= '".$db->escape($amount)."',";
181  }
182  if (GETPOSTISSET('dateomonth')) {
183  $sql .= " dateo = '".$db->idate($dateop)."',";
184  }
185  if (GETPOSTISSET('datevmonth')) {
186  $sql .= " datev = '".$db->idate($dateval)."',";
187  }
188  }
189  $sql .= " fk_account = ".((int) $actarget->id);
190  $sql .= " WHERE rowid = ".((int) $acline->id);
191 
192  $result = $db->query($sql);
193  if (!$result) {
194  $error++;
195  }
196 
197  if (!$error) {
198  $arrayofcategs = GETPOST('custcats', 'array');
199  $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".((int) $rowid);
200  if (!$db->query($sql)) {
201  $error++;
202  dol_print_error($db);
203  }
204  if (count($arrayofcategs)) {
205  foreach ($arrayofcategs as $val) {
206  $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".((int) $rowid).", ".((int) $val).")";
207  if (!$db->query($sql)) {
208  $error++;
209  dol_print_error($db);
210  }
211  }
212  // $arrayselected will be loaded after in page output
213  }
214  }
215 
216  if (!$error) {
217  setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
218  $db->commit();
219  } else {
220  $db->rollback();
221  dol_print_error($db);
222  }
223  }
224 }
225 
226 // Reconcile
227 if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == 'setreconcile')) {
228  $num_rel = trim(GETPOST("num_rel"));
229  $rappro = GETPOST('reconciled') ? 1 : 0;
230 
231  // Check parameters
232  if ($rappro && empty($num_rel)) {
233  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountStatement")), null, 'errors');
234  $error++;
235  }
236 
237  if (!$error) {
238  $db->begin();
239 
240  $sql = "UPDATE ".MAIN_DB_PREFIX."bank";
241  $sql .= " SET num_releve = ".($num_rel ? "'".$db->escape($num_rel)."'" : "null");
242  if (empty($num_rel)) {
243  $sql .= ", rappro = 0";
244  } else {
245  $sql .= ", rappro = ".((int) $rappro);
246  }
247  $sql .= " WHERE rowid = ".((int) $rowid);
248 
249  dol_syslog("line.php", LOG_DEBUG);
250  $result = $db->query($sql);
251  if ($result) {
252  setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
253  $db->commit();
254  } else {
255  $db->rollback();
256  dol_print_error($db);
257  }
258  }
259 }
260 
261 
262 
263 /*
264  * View
265  */
266 
267 $form = new Form($db);
268 
269 llxHeader('', $langs->trans("BankTransaction"));
270 
271 $arrayselected = array();
272 
273 $c = new Categorie($db);
274 $cats = $c->containing($rowid, Categorie::TYPE_BANK_LINE);
275 if (is_array($cats)) {
276  foreach ($cats as $cat) {
277  $arrayselected[] = $cat->id;
278  }
279 }
280 
281 $head = bankline_prepare_head($rowid);
282 
283 
284 $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro,";
285 $sql .= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account, b.fk_bordereau as receiptid,";
286 $sql .= " b.emetteur,b.banque";
287 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
288 $sql .= " WHERE rowid=".((int) $rowid);
289 $sql .= " ORDER BY dateo ASC";
290 $result = $db->query($sql);
291 if ($result) {
292  $i = 0;
293  $total = 0;
294  if ($db->num_rows($result)) {
295  $objp = $db->fetch_object($result);
296 
297  $total = $total + $objp->amount;
298 
299  $acct = new Account($db);
300  $acct->fetch($objp->fk_account);
301  $account = $acct->id;
302 
303  $bankline = new AccountLine($db);
304  $bankline->fetch($rowid, $ref);
305 
306  $links = $acct->get_url($rowid);
307  $bankline->load_previous_next_ref('', 'rowid');
308 
309  // Confirmations
310  if ($action == 'delete_categ') {
311  print $form->formconfirm($_SERVER['PHP_SELF']."?rowid=".urlencode($rowid)."&cat1=".urlencode(GETPOST("fk_categ", 'int'))."&orig_account=".urlencode($orig_account), $langs->trans("RemoveFromRubrique"), $langs->trans("RemoveFromRubriqueConfirm"), "confirm_delete_categ", '', 'yes', 1);
312  }
313 
314  print '<form name="update" method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$rowid.'">';
315  print '<input type="hidden" name="token" value="'.newToken().'">';
316  print '<input type="hidden" name="action" value="update">';
317  print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
318  print '<input type="hidden" name="account" value="'.$acct->id.'">';
319 
320  print dol_get_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'accountline', 0);
321 
322  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
323 
324 
325  dol_banner_tab($bankline, 'rowid', $linkback);
326 
327  print '<div class="fichecenter2">';
328 
329  print '<div class="underbanner clearboth"></div>';
330  print '<table class="border centpercent tableforfield">';
331 
332  $i++;
333 
334  // Bank account
335  print '<tr><td class="titlefieldcreate">'.$langs->trans("Account").'</td>';
336  print '<td>';
337  // $objp->fk_account may be not > 0 if data was lost by an old bug. In such a case, we let a chance to user to fix it.
338  if (($objp->rappro || $bankline->getVentilExportCompta()) && $objp->fk_account > 0) {
339  print $acct->getNomUrl(1, 'transactions', 'reflabel');
340  } else {
341  print img_picto('', 'bank_account', 'class="paddingright"');
342  print $form->select_comptes($acct->id, 'accountid', 0, '', ($acct->id > 0 ? $acct->id : 1), '', 0, '', 1);
343  }
344  print '</td>';
345  print '</tr>';
346 
347  // Show links of bank transactions
348  if (count($links)) {
349  print '<tr><td class="tdtop">'.$langs->trans("Links").'</td>';
350  print '<td>';
351  foreach ($links as $key => $val) {
352  if ($key) {
353  print '<br>';
354  }
355  if ($links[$key]['type'] == 'payment') {
356  require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
357  $paymenttmp = new Paiement($db);
358  $paymenttmp->fetch($links[$key]['url_id']);
359  $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref;
360  /*print '<a href="'.DOL_URL_ROOT.'/compta/paiement/card.php?id='.$links[$key]['url_id'].'">';
361  print img_object($langs->trans('Payment'),'payment').' ';
362  print $langs->trans("Payment");
363  print '</a>';*/
364  print $paymenttmp->getNomUrl(1);
365  } elseif ($links[$key]['type'] == 'payment_supplier') {
366  require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
367  $paymenttmp = new PaiementFourn($db);
368  $paymenttmp->fetch($links[$key]['url_id']);
369  $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref;
370  /*print '<a href="'.DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$links[$key]['url_id'].'">';
371  print img_object($langs->trans('Payment'),'payment').' ';
372  print $langs->trans("Payment");
373  print '</a>';*/
374  print $paymenttmp->getNomUrl(1);
375  } elseif ($links[$key]['type'] == 'company') {
376  $societe = new Societe($db);
377  $societe->fetch($links[$key]['url_id']);
378  print $societe->getNomUrl(1);
379  } elseif ($links[$key]['type'] == 'sc') {
380  print '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$links[$key]['url_id'].'">';
381  print img_object($langs->trans('SocialContribution'), 'bill').' ';
382  print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : '');
383  print '</a>';
384  } elseif ($links[$key]['type'] == 'vat') {
385  print '<a href="'.DOL_URL_ROOT.'/compta/tva/card.php?id='.$links[$key]['url_id'].'">';
386  print img_object($langs->trans('VATDeclaration'), 'bill').' ';
387  print $langs->trans("VATDeclaration").($links[$key]['label'] ? '&nbsp;'.$links[$key]['label'] : '');
388  print '</a>';
389  } elseif ($links[$key]['type'] == 'salary') {
390  print '<a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$links[$key]['url_id'].'">';
391  print img_object($langs->trans('Salary'), 'bill').' ';
392  print $langs->trans("Salary").($links[$key]['label'] ? ' - '.$links[$key]['label'] : '');
393  print '</a>';
394  } elseif ($links[$key]['type'] == 'payment_sc') {
395  print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">';
396  print img_object($langs->trans('Payment'), 'payment').' ';
397  print $langs->trans("SocialContributionPayment");
398  print '</a>';
399  } elseif ($links[$key]['type'] == 'payment_vat') {
400  print '<a href="'.DOL_URL_ROOT.'/compta/payment_vat/card.php?id='.$links[$key]['url_id'].'">';
401  print img_object($langs->trans('VATPayment'), 'payment').' ';
402  print $langs->trans("VATPayment");
403  print '</a>';
404  } elseif ($links[$key]['type'] == 'payment_salary') {
405  print '<a href="'.DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='.$links[$key]['url_id'].'">';
406  print img_object($langs->trans('PaymentSalary'), 'payment').' ';
407  print $langs->trans("SalaryPayment");
408  print '</a>';
409  } elseif ($links[$key]['type'] == 'payment_loan') {
410  print '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$links[$key]['url_id'].'">';
411  print img_object($langs->trans('LoanPayment'), 'payment').' ';
412  print $langs->trans("PaymentLoan");
413  print '</a>';
414  } elseif ($links[$key]['type'] == 'loan') {
415  print '<a href="'.DOL_URL_ROOT.'/loan/card.php?id='.$links[$key]['url_id'].'">';
416  print img_object($langs->trans('Loan'), 'bill').' ';
417  print $langs->trans("Loan");
418  print '</a>';
419  } elseif ($links[$key]['type'] == 'member') {
420  print '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$links[$key]['url_id'].'">';
421  print img_object($langs->trans('Member'), 'user').' ';
422  print $links[$key]['label'];
423  print '</a>';
424  } elseif ($links[$key]['type'] == 'payment_donation') {
425  print '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$links[$key]['url_id'].'">';
426  print img_object($langs->trans('Donation'), 'payment').' ';
427  print $langs->trans("DonationPayment");
428  print '</a>';
429  } elseif ($links[$key]['type'] == 'banktransfert') {
430  print '<a href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$links[$key]['url_id'].'">';
431  print img_object($langs->trans('Transaction'), 'payment').' ';
432  print $langs->trans("TransactionOnTheOtherAccount");
433  print '</a>';
434  } elseif ($links[$key]['type'] == 'user') {
435  print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$links[$key]['url_id'].'">';
436  print img_object($langs->trans('User'), 'user').' ';
437  print $langs->trans("User");
438  print '</a>';
439  } elseif ($links[$key]['type'] == 'payment_various') {
440  print '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$links[$key]['url_id'].'">';
441  print img_object($langs->trans('VariousPayment'), 'payment').' ';
442  print $langs->trans("VariousPayment");
443  print '</a>';
444  } else {
445  print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
446  print img_object('', 'generic').' ';
447  print $links[$key]['label'];
448  print '</a>';
449  }
450  }
451  print '</td></tr>';
452  }
453 
454  //$user->rights->banque->modifier=false;
455  //$user->rights->banque->consolidate=true;
456 
457  // Type of payment / Number
458  print "<tr><td>".$langs->trans("Type")." / ".$langs->trans("Numero");
459  print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
460  print "</td>";
461  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
462  print '<td>';
463  $form->select_types_paiements($objp->fk_type, "value", '', 2);
464  print '<input type="text" class="flat" name="num_chq" value="'.(empty($objp->num_chq) ? '' : $objp->num_chq).'">';
465  if ($objp->receiptid) {
466  include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
467  $receipt = new RemiseCheque($db);
468  $receipt->fetch($objp->receiptid);
469  print ' &nbsp; &nbsp; '.$langs->trans("CheckReceipt").': '.$receipt->getNomUrl(2);
470  }
471  print '</td>';
472  } else {
473  print '<td>'.$objp->fk_type.' '.dol_escape_htmltag($objp->num_chq).'</td>';
474  }
475  print "</tr>";
476 
477  // Transmitter
478  print "<tr><td>".$langs->trans("CheckTransmitter");
479  print ' <em>('.$langs->trans("ChequeMaker").')</em>';
480  print "</td>";
481  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
482  print '<td>';
483  print '<input type="text" class="flat minwidth200" name="emetteur" value="'.(empty($objp->emetteur) ? '' : dol_escape_htmltag($objp->emetteur)).'">';
484  print '</td>';
485  } else {
486  print '<td>'.$objp->emetteur.'</td>';
487  }
488  print "</tr>";
489 
490  // Bank of cheque
491  print "<tr><td>".$langs->trans("Bank");
492  print ' <em>('.$langs->trans("ChequeBank").')</em>';
493  print "</td>";
494  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
495  print '<td>';
496  print '<input type="text" class="flat minwidth200" name="banque" value="'.(empty($objp->banque) ? '' : dol_escape_htmltag($objp->banque)).'">';
497  print '</td>';
498  } else {
499  print '<td>'.dol_escape_htmltag($objp->banque).'</td>';
500  }
501  print "</tr>";
502 
503  // Date ope
504  print '<tr><td>'.$langs->trans("DateOperation").'</td>';
505  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
506  print '<td>';
507  print $form->selectDate($db->jdate($objp->do), 'dateo', '', '', '', 'update', 1, 0, $objp->rappro);
508  if (!$objp->rappro) {
509  print ' &nbsp; ';
510  print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=doprev&id='.$objp->fk_account.'&rowid='.$objp->rowid.'&token='.newToken().'">';
511  print img_edit_remove()."</a> ";
512  print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=donext&id='.$objp->fk_account.'&rowid='.$objp->rowid.'&token='.newToken().'">';
513  print img_edit_add()."</a>";
514  }
515  print '</td>';
516  } else {
517  print '<td>';
518  print dol_print_date($db->jdate($objp->do), "day");
519  print '</td>';
520  }
521  print '</tr>';
522 
523  // Value date
524  print "<tr><td>".$langs->trans("DateValue")."</td>";
525  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
526  print '<td>';
527  print $form->selectDate($db->jdate($objp->dv), 'datev', '', '', '', 'update', 1, 0, $objp->rappro);
528  if (!$objp->rappro) {
529  print ' &nbsp; ';
530  print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&id='.$objp->fk_account.'&rowid='.$objp->rowid.'&token='.newToken().'">';
531  print img_edit_remove()."</a> ";
532  print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&id='.$objp->fk_account.'&rowid='.$objp->rowid.'&token='.newToken().'">';
533  print img_edit_add()."</a>";
534  }
535  print '</td>';
536  } else {
537  print '<td>';
538  print dol_print_date($db->jdate($objp->dv), "day");
539  print '</td>';
540  }
541  print "</tr>";
542 
543  // Description
544  $reg = array();
545  print "<tr><td>".$langs->trans("Label")."</td>";
546  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
547  print '<td>';
548  print '<input name="label" class="flat minwidth300" '.($objp->rappro ? ' disabled' : '').' value="';
549  if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) {
550  // Label generique car entre parentheses. On l'affiche en le traduisant
551  print $langs->trans($reg[1]);
552  } else {
553  print dol_escape_htmltag($objp->label);
554  }
555  print '">';
556  print '</td>';
557  } else {
558  print '<td>';
559  if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) {
560  // Label generique car entre parentheses. On l'affiche en le traduisant
561  print $langs->trans($reg[1]);
562  } else {
563  print dol_escape_htmltag($objp->label);
564  }
565  print '</td>';
566  }
567  print '</tr>';
568 
569  // Amount
570  print "<tr><td>".$langs->trans("Amount")."</td>";
571  if ($user->rights->banque->modifier) {
572  print '<td>';
573  print '<input name="amount" class="flat maxwidth100" '.($objp->rappro ? ' disabled' : '').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code);
574  print '</td>';
575  } else {
576  print '<td>';
577  print price($objp->amount);
578  print '</td>';
579  }
580  print "</tr>";
581 
582  // Categories
583  if (isModEnabled('categorie') && !empty($user->rights->categorie->lire)) {
584  $langs->load('categories');
585 
586  // Bank line
587  print '<tr><td class="toptd">'.$form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0).'</td><td>';
588  $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1);
589 
590  $arrayselected = array();
591 
592  $c = new Categorie($db);
593  $cats = $c->containing($bankline->id, Categorie::TYPE_BANK_LINE);
594  if (is_array($cats)) {
595  foreach ($cats as $cat) {
596  $arrayselected[] = $cat->id;
597  }
598  }
599  print img_picto('', 'category', 'class="paddingright"').$form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%");
600  print "</td></tr>";
601  }
602 
603  print "</table>";
604 
605  // Code to adjust value date with plus and less picto using an Ajax call instead of a full reload of page
606  /* Not yet ready. We must manage inline replacemet of input date field
607  $urlajax = DOL_URL_ROOT.'/core/ajax/bankconciliate.php?token='.currentToken();
608  print '
609  <script type="text/javascript">
610  $(function() {
611  $("a.ajaxforbankoperationchange").each(function(){
612  var current = $(this);
613  current.click(function()
614  {
615  var url = "'.$urlajax.'&"+current.attr("href").split("?")[1];
616  $.get(url, function(data)
617  {
618  console.log(url)
619  console.log(data)
620  current.parent().prev().replaceWith(data);
621  });
622  return false;
623  });
624  });
625  });
626  </script>
627  ';
628  */
629  print '</div>';
630 
631  print dol_get_fiche_end();
632 
633 
634  print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div><br>';
635 
636  print "</form>";
637 
638 
639 
640  // Releve rappro
641  if ($acct->canBeConciliated() > 0) { // Si compte rapprochable
642  print load_fiche_titre($langs->trans("Reconciliation"), '', 'bank_account');
643  print '<hr>'."\n";
644 
645  print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$objp->rowid.'">';
646  print '<input type="hidden" name="token" value="'.newToken().'">';
647  print '<input type="hidden" name="action" value="setreconcile">';
648  print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
649  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
650 
651  print '<div class="fichecenter">';
652 
653  print '<table class="border centpercent">';
654 
655  print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("AccountStatement"), $langs->trans("InputReceiptNumber"))."</td>";
656  if ($user->rights->banque->consolidate) {
657  print '<td>';
658  if ($objp->rappro) {
659  print '<input name="num_rel_bis" class="flat" value="'.$objp->num_releve.'"'.($objp->rappro ? ' disabled' : '').'>';
660  print '<input name="num_rel" type="hidden" value="'.$objp->num_releve.'">';
661  } else {
662  print '<input name="num_rel" class="flat" value="'.$objp->num_releve.'"'.($objp->rappro ? ' disabled' : '').'>';
663  }
664  if ($objp->num_releve) {
665  print ' &nbsp; (<a href="'.DOL_URL_ROOT.'/compta/bank/releve.php?num='.$objp->num_releve.'&account='.$acct->id.'">'.$langs->trans("AccountStatement").' '.$objp->num_releve.')</a>';
666  }
667  print '</td>';
668  } else {
669  print '<td>'.$objp->num_releve.'</td>';
670  }
671  print '</tr>';
672 
673  print '<tr><td><label for="reconciled">'.$langs->trans("BankLineConciliated").'</label></td>';
674  if ($user->rights->banque->consolidate) {
675  print '<td>';
676  print '<input type="checkbox" id="reconciled" name="reconciled" class="flat" '.(GETPOSTISSET("reconciled") ? (GETPOST("reconciled") ? ' checked="checked"' : '') : ($objp->rappro ? ' checked="checked"' : '')).'">';
677  print '</td>';
678  } else {
679  print '<td>'.yn($objp->rappro).'</td>';
680  }
681  print '</tr>';
682  print '</table>';
683 
684  print '</div>';
685 
686  print '<div class="center">';
687 
688  print '<input type="submit" class="button" value="'.$langs->trans("Update").'">';
689  if ($backtopage) {
690  print ' &nbsp; ';
691  print '<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans("Cancel").'">';
692  }
693  print '</div>';
694 
695  print '</form>';
696  }
697  }
698 
699  $db->free($result);
700 } else {
701  dol_print_error($db);
702 }
703 
704 // End of page
705 llxFooter();
706 $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:1468
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
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
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:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
Categorie
Class to manage categories.
Definition: categorie.class.php:47
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:2046
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
Account\TYPE_CASH
const TYPE_CASH
Cash account.
Definition: account.class.php:346
img_edit_add
img_edit_add($titlealt='default', $other='')
Show logo +.
Definition: functions.lib.php:4353
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
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:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
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:4370
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:4211
AccountLine
Class to manage bank transaction lines.
Definition: account.class.php:1779
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:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
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