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