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