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