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