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