dolibarr  19.0.0-dev
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 // Load Dolibarr environment
34 require '../../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
39 
40 // Load translation files required by the page
41 $langs->loadLangs(array('banks', 'categories', 'compta', 'bills', 'other'));
42 if (isModEnabled('adherent')) {
43  $langs->load("members");
44 }
45 if (isModEnabled('don')) {
46  $langs->load("donations");
47 }
48 if (isModEnabled('loan')) {
49  $langs->load("loan");
50 }
51 if (isModEnabled('salaries')) {
52  $langs->load("salaries");
53 }
54 
55 
56 $id = GETPOST('rowid', 'int');
57 $rowid = GETPOST("rowid", 'int');
58 $accountoldid = GETPOST('account', 'int'); // GETPOST('account') is old account id
59 $accountid = GETPOST('accountid', 'int'); // GETPOST('accountid') is new account id
60 $ref = GETPOST('ref', 'alpha');
61 $action = GETPOST('action', 'aZ09');
62 $confirm = GETPOST('confirm', 'alpha');
63 $orig_account = GETPOST("orig_account");
64 $backtopage = GETPOST('backtopage', 'alpha');
65 $cancel = GETPOST('cancel', 'alpha');
66 
67 // Security check
68 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
69 $fieldtype = (!empty($ref) ? 'ref' : 'rowid');
70 $socid = 0;
71 if ($user->socid) {
72  $socid = $user->socid;
73 }
74 
75 $result = restrictedArea($user, 'banque', $accountoldid, 'bank_account');
76 if (empty($user->rights->banque->lire) && empty($user->rights->banque->consolidate)) {
78 }
79 
80 $hookmanager->initHooks(array('bankline'));
81 $object = new AccountLine($db);
82 $extrafields = new ExtraFields($db);
83 $extrafields->fetch_name_optionals_label($object->element);
84 
85 /*
86  * Actions
87  */
88 
89 $parameters = array('socid' => $socid);
90 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
91 if ($reshook < 0) {
92  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
93 }
94 if ($cancel) {
95  if ($backtopage) {
96  header("Location: ".$backtopage);
97  exit;
98  }
99 }
100 
101 
102 if ($user->rights->banque->consolidate && $action == 'donext') {
103  $al = new AccountLine($db);
104  $al->dateo_next(GETPOST("rowid", 'int'));
105 } elseif ($user->rights->banque->consolidate && $action == 'doprev') {
106  $al = new AccountLine($db);
107  $al->dateo_previous(GETPOST("rowid", 'int'));
108 } elseif ($user->rights->banque->consolidate && $action == 'dvnext') {
109  $al = new AccountLine($db);
110  $al->datev_next(GETPOST("rowid", 'int'));
111 } elseif ($user->rights->banque->consolidate && $action == 'dvprev') {
112  $al = new AccountLine($db);
113  $al->datev_previous(GETPOST("rowid", 'int'));
114 }
115 
116 if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->banque->modifier) {
117  $cat1 = GETPOST("cat1", 'int');
118  if (!empty($rowid) && !empty($cat1)) {
119  $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".((int) $rowid)." AND fk_categ = ".((int) $cat1);
120  if (!$db->query($sql)) {
121  dol_print_error($db);
122  }
123  } else {
124  setEventMessages($langs->trans("MissingIds"), null, 'errors');
125  }
126 }
127 
128 if ($user->rights->banque->modifier && $action == "update") {
129  $error = 0;
130 
131  $result = $object->fetch($rowid);
132  if ($result <= 0) {
133  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.
134  $object->id = $rowid;
135  }
136 
137  $acsource = new Account($db);
138  $acsource->fetch($accountoldid);
139 
140  $actarget = new Account($db);
141  if (GETPOST('accountid', 'int') > 0 && !$object->rappro && !$object->getVentilExportCompta()) { // We ask to change bank account
142  $actarget->fetch(GETPOST('accountid', 'int'));
143  } else {
144  $actarget->fetch($accountoldid);
145  }
146 
147  if (!($actarget->id > 0)) {
148  setEventMessages($langs->trans("ErrorFailedToLoadBankAccount"), null, 'errors');
149  $error++;
150  }
151  if ($actarget->courant == Account::TYPE_CASH && GETPOST('value', 'alpha') != 'LIQ') {
152  setEventMessages($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), null, 'errors');
153  $error++;
154  }
155 
156  if (!$error) {
157  $db->begin();
158 
159  $amount = price2num(GETPOST('amount'));
160  $dateop = dol_mktime(12, 0, 0, GETPOST("dateomonth"), GETPOST("dateoday"), GETPOST("dateoyear"));
161  $dateval = dol_mktime(12, 0, 0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear"));
162  $sql = "UPDATE ".MAIN_DB_PREFIX."bank";
163  $sql .= " SET ";
164  // Always opened
165  if (GETPOSTISSET('value')) {
166  $sql .= " fk_type='".$db->escape(GETPOST('value'))."',";
167  }
168  if (GETPOSTISSET('num_chq')) {
169  $sql .= " num_chq='".$db->escape(GETPOST("num_chq"))."',";
170  }
171  if (GETPOSTISSET('banque')) {
172  $sql .= " banque='".$db->escape(GETPOST("banque"))."',";
173  }
174  if (GETPOSTISSET('emetteur')) {
175  $sql .= " emetteur='".$db->escape(GETPOST("emetteur"))."',";
176  }
177  // Blocked when conciliated
178  if (!$object->rappro) {
179  if (GETPOSTISSET('label')) {
180  $sql .= " label = '".$db->escape(GETPOST("label"))."',";
181  }
182  if (GETPOSTISSET('amount')) {
183  $sql .= " amount= '".$db->escape($amount)."',";
184  }
185  if (GETPOSTISSET('dateomonth')) {
186  $sql .= " dateo = '".$db->idate($dateop)."',";
187  }
188  if (GETPOSTISSET('datevmonth')) {
189  $sql .= " datev = '".$db->idate($dateval)."',";
190  }
191  }
192  $sql .= " fk_account = ".((int) $actarget->id);
193  $sql .= " WHERE rowid = ".((int) $object->id);
194 
195  $result = $db->query($sql);
196  if (!$result) {
197  $error++;
198  }
199 
200  if (!$error) {
201  $arrayofcategs = GETPOST('custcats', 'array');
202  $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid = ".((int) $rowid);
203  if (!$db->query($sql)) {
204  $error++;
205  dol_print_error($db);
206  }
207  if (count($arrayofcategs)) {
208  foreach ($arrayofcategs as $val) {
209  $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES (".((int) $rowid).", ".((int) $val).")";
210  if (!$db->query($sql)) {
211  $error++;
212  dol_print_error($db);
213  }
214  }
215  // $arrayselected will be loaded after in page output
216  }
217  }
218 
219  if (!$error) {
220  $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
221  $object->insertExtraFields();
222  }
223 
224  if (!$error) {
225  setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
226  $db->commit();
227  } else {
228  $db->rollback();
229  dol_print_error($db);
230  }
231  }
232 }
233 
234 // Reconcile
235 if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == 'setreconcile')) {
236  $num_rel = trim(GETPOST("num_rel"));
237  $rappro = GETPOST('reconciled') ? 1 : 0;
238 
239  // Check parameters
240  if ($rappro && empty($num_rel)) {
241  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountStatement")), null, 'errors');
242  $error++;
243  }
244 
245  if (!$error) {
246  $db->begin();
247 
248  $sql = "UPDATE ".MAIN_DB_PREFIX."bank";
249  $sql .= " SET num_releve = ".($num_rel ? "'".$db->escape($num_rel)."'" : "null");
250  if (empty($num_rel)) {
251  $sql .= ", rappro = 0";
252  } else {
253  $sql .= ", rappro = ".((int) $rappro);
254  }
255  $sql .= " WHERE rowid = ".((int) $rowid);
256 
257  dol_syslog("line.php", LOG_DEBUG);
258  $result = $db->query($sql);
259  if ($result) {
260  setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
261  $db->commit();
262  } else {
263  $db->rollback();
264  dol_print_error($db);
265  }
266  }
267 }
268 
269 
270 
271 /*
272  * View
273  */
274 
275 $form = new Form($db);
276 
277 llxHeader('', $langs->trans("BankTransaction"));
278 
279 $arrayselected = array();
280 
281 $c = new Categorie($db);
282 $cats = $c->containing($rowid, Categorie::TYPE_BANK_LINE);
283 if (is_array($cats)) {
284  foreach ($cats as $cat) {
285  $arrayselected[] = $cat->id;
286  }
287 }
288 
289 $head = bankline_prepare_head($rowid);
290 
291 
292 $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro,";
293 $sql .= " b.num_releve, b.fk_user_author, b.num_chq, b.fk_type, b.fk_account, b.fk_bordereau as receiptid,";
294 $sql .= " b.emetteur,b.banque";
295 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
296 $sql .= " WHERE rowid=".((int) $rowid);
297 $sql .= " ORDER BY dateo ASC";
298 $result = $db->query($sql);
299 if ($result) {
300  $i = 0;
301  $total = 0;
302  if ($db->num_rows($result)) {
303  $objp = $db->fetch_object($result);
304 
305  $total = $total + $objp->amount;
306 
307  $acct = new Account($db);
308  $acct->fetch($objp->fk_account);
309  $account = $acct->id;
310 
311  $bankline = new AccountLine($db);
312  $bankline->fetch($rowid, $ref);
313 
314  $links = $acct->get_url($rowid);
315  $bankline->load_previous_next_ref('', 'rowid');
316 
317  // Confirmations
318  if ($action == 'delete_categ') {
319  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);
320  }
321 
322  print '<form name="update" method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$rowid.'">';
323  print '<input type="hidden" name="token" value="'.newToken().'">';
324  print '<input type="hidden" name="action" value="update">';
325  print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
326  print '<input type="hidden" name="account" value="'.$acct->id.'">';
327 
328  print dol_get_fiche_head($head, 'bankline', $langs->trans('LineRecord'), 0, 'accountline', 0);
329 
330  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?restore_lastsearch_values=1'.(GETPOST('account', 'int', 1) ? '&id='.GETPOST('account', 'int', 1) : '').'">'.$langs->trans("BackToList").'</a>';
331 
332 
333  dol_banner_tab($bankline, 'rowid', $linkback);
334 
335  print '<div class="fichecenter2">';
336 
337  print '<div class="underbanner clearboth"></div>';
338  print '<table class="border centpercent tableforfield">';
339 
340  $i++;
341 
342  // Bank account
343  print '<tr><td class="titlefieldcreate">'.$langs->trans("Account").'</td>';
344  print '<td>';
345  // $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.
346  if (($objp->rappro || $bankline->getVentilExportCompta()) && $objp->fk_account > 0) {
347  print $acct->getNomUrl(1, 'transactions', 'reflabel');
348  } else {
349  print img_picto('', 'bank_account', 'class="paddingright"');
350  print $form->select_comptes($acct->id, 'accountid', 0, '', ($acct->id > 0 ? $acct->id : 1), '', 0, '', 1);
351  }
352  print '</td>';
353  print '</tr>';
354 
355  // Show links of bank transactions
356  if (count($links)) {
357  print '<tr><td class="tdtop">'.$langs->trans("Links").'</td>';
358  print '<td>';
359  foreach ($links as $key => $val) {
360  if ($key) {
361  print '<br>';
362  }
363  if ($links[$key]['type'] == 'payment') {
364  require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
365  $paymenttmp = new Paiement($db);
366  $paymenttmp->fetch($links[$key]['url_id']);
367  $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref;
368  /*print '<a href="'.DOL_URL_ROOT.'/compta/paiement/card.php?id='.$links[$key]['url_id'].'">';
369  print img_object($langs->trans('Payment'),'payment').' ';
370  print $langs->trans("Payment");
371  print '</a>';*/
372  print $paymenttmp->getNomUrl(1);
373  } elseif ($links[$key]['type'] == 'payment_supplier') {
374  require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
375  $paymenttmp = new PaiementFourn($db);
376  $paymenttmp->fetch($links[$key]['url_id']);
377  $paymenttmp->ref = $langs->trans("Payment").' '.$paymenttmp->ref;
378  /*print '<a href="'.DOL_URL_ROOT.'/fourn/paiement/card.php?id='.$links[$key]['url_id'].'">';
379  print img_object($langs->trans('Payment'),'payment').' ';
380  print $langs->trans("Payment");
381  print '</a>';*/
382  print $paymenttmp->getNomUrl(1);
383  } elseif ($links[$key]['type'] == 'company') {
384  $societe = new Societe($db);
385  $societe->fetch($links[$key]['url_id']);
386  print $societe->getNomUrl(1);
387  } elseif ($links[$key]['type'] == 'sc') {
388  print '<a href="'.DOL_URL_ROOT.'/compta/sociales/card.php?id='.$links[$key]['url_id'].'">';
389  print img_object($langs->trans('SocialContribution'), 'bill').' ';
390  print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : '');
391  print '</a>';
392  } elseif ($links[$key]['type'] == 'vat') {
393  print '<a href="'.DOL_URL_ROOT.'/compta/tva/card.php?id='.$links[$key]['url_id'].'">';
394  print img_object($langs->trans('VATDeclaration'), 'bill').' ';
395  print $langs->trans("VATDeclaration").($links[$key]['label'] ? '&nbsp;'.$links[$key]['label'] : '');
396  print '</a>';
397  } elseif ($links[$key]['type'] == 'salary') {
398  print '<a href="'.DOL_URL_ROOT.'/salaries/card.php?id='.$links[$key]['url_id'].'">';
399  print img_object($langs->trans('Salary'), 'bill').' ';
400  print $langs->trans("Salary").($links[$key]['label'] ? ' - '.$links[$key]['label'] : '');
401  print '</a>';
402  } elseif ($links[$key]['type'] == 'payment_sc') {
403  print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">';
404  print img_object($langs->trans('Payment'), 'payment').' ';
405  print $langs->trans("SocialContributionPayment");
406  print '</a>';
407  } elseif ($links[$key]['type'] == 'payment_vat') {
408  print '<a href="'.DOL_URL_ROOT.'/compta/payment_vat/card.php?id='.$links[$key]['url_id'].'">';
409  print img_object($langs->trans('VATPayment'), 'payment').' ';
410  print $langs->trans("VATPayment");
411  print '</a>';
412  } elseif ($links[$key]['type'] == 'payment_salary') {
413  print '<a href="'.DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='.$links[$key]['url_id'].'">';
414  print img_object($langs->trans('PaymentSalary'), 'payment').' ';
415  print $langs->trans("SalaryPayment");
416  print '</a>';
417  } elseif ($links[$key]['type'] == 'payment_loan') {
418  print '<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$links[$key]['url_id'].'">';
419  print img_object($langs->trans('LoanPayment'), 'payment').' ';
420  print $langs->trans("PaymentLoan");
421  print '</a>';
422  } elseif ($links[$key]['type'] == 'loan') {
423  print '<a href="'.DOL_URL_ROOT.'/loan/card.php?id='.$links[$key]['url_id'].'">';
424  print img_object($langs->trans('Loan'), 'bill').' ';
425  print $langs->trans("Loan");
426  print '</a>';
427  } elseif ($links[$key]['type'] == 'member') {
428  print '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$links[$key]['url_id'].'">';
429  print img_object($langs->trans('Member'), 'user').' ';
430  print $links[$key]['label'];
431  print '</a>';
432  } elseif ($links[$key]['type'] == 'payment_donation') {
433  print '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$links[$key]['url_id'].'">';
434  print img_object($langs->trans('Donation'), 'payment').' ';
435  print $langs->trans("DonationPayment");
436  print '</a>';
437  } elseif ($links[$key]['type'] == 'banktransfert') {
438  print '<a href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$links[$key]['url_id'].'">';
439  print img_object($langs->trans('Transaction'), 'payment').' ';
440  print $langs->trans("TransactionOnTheOtherAccount");
441  print '</a>';
442  } elseif ($links[$key]['type'] == 'user') {
443  print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$links[$key]['url_id'].'">';
444  print img_object($langs->trans('User'), 'user').' ';
445  print $langs->trans("User");
446  print '</a>';
447  } elseif ($links[$key]['type'] == 'payment_various') {
448  print '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/card.php?id='.$links[$key]['url_id'].'">';
449  print img_object($langs->trans('VariousPayment'), 'payment').' ';
450  print $langs->trans("VariousPayment");
451  print '</a>';
452  } else {
453  print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
454  print img_object('', 'generic').' ';
455  print $links[$key]['label'];
456  print '</a>';
457  }
458  }
459  print '</td></tr>';
460  }
461 
462  //$user->rights->banque->modifier=false;
463  //$user->rights->banque->consolidate=true;
464 
465  // Type of payment / Number
466  print "<tr><td>".$langs->trans("Type")." / ".$langs->trans("Numero");
467  print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
468  print "</td>";
469  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
470  print '<td>';
471  $form->select_types_paiements($objp->fk_type, "value", '', 2);
472  print '<input type="text" class="flat" name="num_chq" value="'.(empty($objp->num_chq) ? '' : $objp->num_chq).'">';
473  if ($objp->receiptid) {
474  include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
475  $receipt = new RemiseCheque($db);
476  $receipt->fetch($objp->receiptid);
477  print ' &nbsp; &nbsp; '.$langs->trans("CheckReceipt").': '.$receipt->getNomUrl(2);
478  }
479  print '</td>';
480  } else {
481  print '<td>'.$objp->fk_type.' '.dol_escape_htmltag($objp->num_chq).'</td>';
482  }
483  print "</tr>";
484 
485  // Transmitter
486  print "<tr><td>".$langs->trans("CheckTransmitter");
487  print ' <em>('.$langs->trans("ChequeMaker").')</em>';
488  print "</td>";
489  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
490  print '<td>';
491  print '<input type="text" class="flat minwidth200" name="emetteur" value="'.(empty($objp->emetteur) ? '' : dol_escape_htmltag($objp->emetteur)).'">';
492  print '</td>';
493  } else {
494  print '<td>'.$objp->emetteur.'</td>';
495  }
496  print "</tr>";
497 
498  // Bank of cheque
499  print "<tr><td>".$langs->trans("Bank");
500  print ' <em>('.$langs->trans("ChequeBank").')</em>';
501  print "</td>";
502  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
503  print '<td>';
504  print '<input type="text" class="flat minwidth200" name="banque" value="'.(empty($objp->banque) ? '' : dol_escape_htmltag($objp->banque)).'">';
505  print '</td>';
506  } else {
507  print '<td>'.dol_escape_htmltag($objp->banque).'</td>';
508  }
509  print "</tr>";
510 
511  // Date ope
512  print '<tr><td>'.$langs->trans("DateOperation").'</td>';
513  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
514  print '<td>';
515  print $form->selectDate($db->jdate($objp->do), 'dateo', '', '', '', 'update', 1, 0, $objp->rappro);
516  if (!$objp->rappro) {
517  print ' &nbsp; ';
518  print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=doprev&id='.$objp->fk_account.'&rowid='.$objp->rowid.'&token='.newToken().'">';
519  print img_edit_remove()."</a> ";
520  print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=donext&id='.$objp->fk_account.'&rowid='.$objp->rowid.'&token='.newToken().'">';
521  print img_edit_add()."</a>";
522  }
523  print '</td>';
524  } else {
525  print '<td>';
526  print dol_print_date($db->jdate($objp->do), "day");
527  print '</td>';
528  }
529  print '</tr>';
530 
531  // Value date
532  print "<tr><td>".$langs->trans("DateValue")."</td>";
533  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
534  print '<td>';
535  print $form->selectDate($db->jdate($objp->dv), 'datev', '', '', '', 'update', 1, 0, $objp->rappro);
536  if (!$objp->rappro) {
537  print ' &nbsp; ';
538  print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvprev&id='.$objp->fk_account.'&rowid='.$objp->rowid.'&token='.newToken().'">';
539  print img_edit_remove()."</a> ";
540  print '<a class="ajaxforbankoperationchange" href="'.$_SERVER['PHP_SELF'].'?action=dvnext&id='.$objp->fk_account.'&rowid='.$objp->rowid.'&token='.newToken().'">';
541  print img_edit_add()."</a>";
542  }
543  print '</td>';
544  } else {
545  print '<td>';
546  print dol_print_date($db->jdate($objp->dv), "day");
547  print '</td>';
548  }
549  print "</tr>";
550 
551  // Description
552  $reg = array();
553  print "<tr><td>".$langs->trans("Label")."</td>";
554  if ($user->rights->banque->modifier || $user->rights->banque->consolidate) {
555  print '<td>';
556  print '<input name="label" class="flat minwidth300" '.($objp->rappro ? ' disabled' : '').' value="';
557  if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) {
558  // Label generique car entre parentheses. On l'affiche en le traduisant
559  print $langs->trans($reg[1]);
560  } else {
561  print dol_escape_htmltag($objp->label);
562  }
563  print '">';
564  print '</td>';
565  } else {
566  print '<td>';
567  if (preg_match('/^\((.*)\)$/i', $objp->label, $reg)) {
568  // Label generique car entre parentheses. On l'affiche en le traduisant
569  print $langs->trans($reg[1]);
570  } else {
571  print dol_escape_htmltag($objp->label);
572  }
573  print '</td>';
574  }
575  print '</tr>';
576 
577  // Amount
578  print "<tr><td>".$langs->trans("Amount")."</td>";
579  if ($user->rights->banque->modifier) {
580  print '<td>';
581  print '<input name="amount" class="flat maxwidth100" '.($objp->rappro ? ' disabled' : '').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code);
582  print '</td>';
583  } else {
584  print '<td>';
585  print price($objp->amount);
586  print '</td>';
587  }
588  print "</tr>";
589 
590  // Categories
591  if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) {
592  $langs->load('categories');
593 
594  // Bank line
595  print '<tr><td class="toptd">'.$form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0).'</td><td>';
596  $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1);
597 
598  $arrayselected = array();
599 
600  $c = new Categorie($db);
601  $cats = $c->containing($bankline->id, Categorie::TYPE_BANK_LINE);
602  if (is_array($cats)) {
603  foreach ($cats as $cat) {
604  $arrayselected[] = $cat->id;
605  }
606  }
607  print img_picto('', 'category', 'class="paddingright"').$form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%");
608  print "</td></tr>";
609  }
610 
611  // Other attributes
612  $parameters = array();
613  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $bankline, $action); // Note that $action and $object may have been modified by hook
614  print $hookmanager->resPrint;
615  if (empty($reshook)) {
616  print $bankline->showOptionals($extrafields, ($objp->rappro ? 'view' : 'create'), $parameters);
617  }
618  print "</table>";
619 
620  // Code to adjust value date with plus and less picto using an Ajax call instead of a full reload of page
621  /* Not yet ready. We must manage inline replacemet of input date field
622  $urlajax = DOL_URL_ROOT.'/core/ajax/bankconciliate.php?token='.currentToken();
623  print '
624  <script type="text/javascript">
625  $(function() {
626  $("a.ajaxforbankoperationchange").each(function(){
627  var current = $(this);
628  current.click(function()
629  {
630  var url = "'.$urlajax.'&"+current.attr("href").split("?")[1];
631  $.get(url, function(data)
632  {
633  console.log(url)
634  console.log(data)
635  current.parent().prev().replaceWith(data);
636  });
637  return false;
638  });
639  });
640  });
641  </script>
642  ';
643  */
644  print '</div>';
645 
646  print dol_get_fiche_end();
647 
648 
649  print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div><br>';
650 
651  print "</form>";
652 
653 
654 
655  // Releve rappro
656  if ($acct->canBeConciliated() > 0) { // Si compte rapprochable
657  print load_fiche_titre($langs->trans("Reconciliation"), '', 'bank_account');
658  print '<hr>'."\n";
659 
660  print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?rowid='.$objp->rowid.'">';
661  print '<input type="hidden" name="token" value="'.newToken().'">';
662  print '<input type="hidden" name="action" value="setreconcile">';
663  print '<input type="hidden" name="orig_account" value="'.$orig_account.'">';
664  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
665 
666  print '<div class="fichecenter">';
667 
668  print '<table class="border centpercent">';
669 
670  print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("AccountStatement"), $langs->trans("InputReceiptNumber"))."</td>";
671  if ($user->rights->banque->consolidate) {
672  print '<td>';
673  if ($objp->rappro) {
674  print '<input name="num_rel_bis" id="num_rel_bis" class="flat" type="text" value="'.$objp->num_releve.'"'.($objp->rappro ? ' disabled' : '').'>';
675  print '<input name="num_rel" id="num_rel" class="flat" type="hidden" value="'.$objp->num_releve.'">';
676  } else {
677  print '<input name="num_rel" id="num_rel" class="flat" value="'.$objp->num_releve.'"'.($objp->rappro ? ' disabled' : '').'>';
678  }
679  if ($objp->num_releve) {
680  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>';
681  }
682  print '</td>';
683  } else {
684  print '<td>'.$objp->num_releve.'</td>';
685  }
686  print '</tr>';
687 
688  print '<tr><td><label for="reconciled">'.$langs->trans("BankLineConciliated").'</label></td>';
689  if ($user->rights->banque->consolidate) {
690  print '<td>';
691  print '<input type="checkbox" id="reconciled" name="reconciled" class="flat" '.(GETPOSTISSET("reconciled") ? (GETPOST("reconciled") ? ' checked="checked"' : '') : ($objp->rappro ? ' checked="checked"' : '')).'">';
692 
693  print '
694  <script type="text/javascript">
695  jQuery(document).ready(function() {
696  $("#reconciled").click(function(){
697  console.log("We click on checkbox reconciled "+$("#reconciled").prop("checked"));
698  if ($("#reconciled").prop("checked") == false) {
699  console.log("we remove disabled");
700  jQuery("#num_rel_bis").removeAttr("disabled");
701  jQuery("#num_rel").removeAttr("disabled");
702  jQuery("#num_rel_bis").attr("type", "hidden");
703  jQuery("#num_rel").attr("type", "text");
704  jQuery("#num_rel_bis").hide();
705  jQuery("#num_rel").show();
706  } else {
707 
708  }
709  });
710  });
711  </script>
712  ';
713 
714  print '</td>';
715  } else {
716  print '<td>'.yn($objp->rappro).'</td>';
717  }
718  print '</tr>';
719  print '</table>';
720 
721  print '</div>';
722 
723  print '<div class="center">';
724 
725  print '<input type="submit" class="button" value="'.$langs->trans("Update").'">';
726  if ($backtopage) {
727  print ' &nbsp; ';
728  print '<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans("Cancel").'">';
729  }
730  print '</div>';
731 
732  print '</form>';
733  }
734  }
735 
736  $db->free($result);
737 } else {
738  dol_print_error($db);
739 }
740 
741 // End of page
742 llxFooter();
743 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:51
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
dol_escape_htmltag
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...
Definition: functions.lib.php:1600
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5477
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:609
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:5107
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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:2205
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5955
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:2675
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:4135
Account\TYPE_CASH
const TYPE_CASH
Cash account.
Definition: account.class.php:355
llxHeader
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
img_edit_add
img_edit_add($titlealt='default', $other='')
Show logo +.
Definition: functions.lib.php:4616
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1741
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
Definition: functions.lib.php:8673
$sql
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
restrictedArea
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.
Definition: security.lib.php:353
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:11654
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2177
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:207
dol_get_fiche_head
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.
Definition: functions.lib.php:1979
PaiementFourn
Class to manage payments for supplier invoices.
Definition: paiementfourn.class.php:39
img_edit_remove
img_edit_remove($titlealt='default', $other='')
Show logo -.
Definition: functions.lib.php:4633
Paiement
Class to manage payments of customer invoices.
Definition: paiement.class.php:43
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:509
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
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:53
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:4473
AccountLine
Class to manage bank transaction lines.
Definition: account.class.php:1874
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:5829
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1169
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:2968
Account
Class to manage bank accounts.
Definition: account.class.php:40