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