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