dolibarr 25.0.0-alpha
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2011-2016 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
7 * Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
8 * Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2026 Jose Martinez <jose.martinez@pichinov.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
32// Load Dolibarr environment
33require '../../../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
35require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
36require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
37require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
38
47// Load translation files required by the page
48$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'compta'));
49
50$id = GETPOSTINT('id');
51$ref = GETPOST('ref', 'alpha');
52$action = GETPOST('action', 'aZ09');
53$confirm = GETPOST('confirm', 'alpha');
54
55$type = GETPOST('type');
56if (empty($type)) {
57 $type = 'CHQ';
58}
59
60$object = new RemiseCheque($db);
61
62$sortfield = GETPOST('sortfield', 'aZ09comma');
63$sortorder = GETPOST('sortorder', 'aZ09comma');
64$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
65if (!$sortorder) {
66 $sortorder = "ASC";
67}
68if (!$sortfield) {
69 $sortfield = "b.dateo,b.rowid";
70}
71if (empty($page) || $page == -1) {
72 $page = 0;
73}
74$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
75$offset = $limit * $page;
76
77$upload_dir = $conf->bank->multidir_output[$object->entity ? $object->entity : $conf->entity]."/checkdeposits";
78
79// filter by dates from / to
80$search_date_start_day = GETPOSTINT('search_date_start_day');
81$search_date_start_month = GETPOSTINT('search_date_start_month');
82$search_date_start_year = GETPOSTINT('search_date_start_year');
83$search_date_end_day = GETPOSTINT('search_date_end_day');
84$search_date_end_month = GETPOSTINT('search_date_end_month');
85$search_date_end_year = GETPOSTINT('search_date_end_year');
86$search_date_start = dol_mktime(0, 0, 0, $search_date_start_month, $search_date_start_day, $search_date_start_year);
87$search_date_end = dol_mktime(23, 59, 59, $search_date_end_month, $search_date_end_day, $search_date_end_year);
88$filteraccountid = GETPOSTINT('accountid');
89
90// Security check
91$fieldname = (!empty($ref) ? 'ref' : 'rowid');
92if ($user->socid) {
93 $socid = $user->socid;
94}
95$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque', '', 'fk_user_author', $fieldname);
96
97$usercanread = $user->hasRight('banque', 'cheque');
98$usercancreate = $user->hasRight('banque', 'cheque');
99$usercandelete = $user->hasRight('banque', 'cheque');
100
101$permissiontodelete = $user->hasRight('banque', 'cheque');
102
103// List of payment mode to support
104// Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA'
105$arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ'));
106
107
108/*
109 * Actions
110 */
111
112if ($action == 'setdate' && $user->hasRight('banque', 'cheque')) {
113 $result = $object->fetch(GETPOSTINT('id'));
114 if ($result > 0) {
115 $date = dol_mktime(0, 0, 0, GETPOSTINT('datecreate_month'), GETPOSTINT('datecreate_day'), GETPOSTINT('datecreate_year'));
116
117 $result = $object->set_date($user, $date);
118 if ($result < 0) {
119 setEventMessages($object->error, $object->errors, 'errors');
120 }
121 } else {
122 setEventMessages($object->error, $object->errors, 'errors');
123 }
124}
125
126if ($action == 'setrefext' && $user->hasRight('banque', 'cheque')) {
127 $result = $object->fetch(GETPOSTINT('id'));
128 if ($result > 0) {
129 $ref_ext = GETPOST('ref_ext');
130
131 $result = $object->setValueFrom('ref_ext', $ref_ext, '', null, 'text', '', $user, 'CHECKDEPOSIT_MODIFY');
132 if ($result < 0) {
133 setEventMessages($object->error, $object->errors, 'errors');
134 }
135 } else {
136 setEventMessages($object->error, $object->errors, 'errors');
137 }
138}
139
140if ($action == 'setref' && $user->hasRight('banque', 'cheque')) {
141 $result = $object->fetch(GETPOSTINT('id'));
142 if ($result > 0) {
143 $ref = GETPOST('ref');
144
145 $result = $object->set_number($user, $ref);
146 if ($result < 0) {
147 setEventMessages($object->error, $object->errors, 'errors');
148 }
149 } else {
150 setEventMessages($object->error, $object->errors, 'errors');
151 }
152}
153
154if ($action == 'create' && GETPOSTINT("accountid") > 0 && $user->hasRight('banque', 'cheque')) {
155 if (GETPOSTISARRAY('toRemise')) {
156 $object->type = $type;
157 $object->date_bordereau = dol_now();
158 $arrayofid = GETPOST('toRemise', 'array:int');
159
160 $result = $object->create($user, GETPOSTINT("accountid"), 0, $arrayofid);
161 if ($result > 0) {
162 if ($object->statut == 1) { // If statut is validated, we build doc
163 $object->fetch($object->id); // To force to reload all properties in correct property name
164 // Define output language
165 $outputlangs = $langs;
166 $newlang = '';
167 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
168 $newlang = GETPOST('lang_id', 'aZ09');
169 }
170 //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->client->default_lang;
171 if (!empty($newlang)) {
172 $outputlangs = new Translate("", $conf);
173 $outputlangs->setDefaultLang($newlang);
174 }
175 $result = $object->generatePdf(GETPOST("model"), $outputlangs);
176 }
177
178 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
179 exit;
180 } else {
181 setEventMessages($object->error, $object->errors, 'errors');
182 $action = 'create2';
183 }
184 } else {
185 setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'mesgs');
186 $action = 'create2';
187 }
188}
189
190if ($action == 'remove' && $id > 0 && GETPOSTINT("lineid") > 0 && $user->hasRight('banque', 'cheque')) {
191 $object->id = $id;
192 $result = $object->removeCheck(GETPOSTINT("lineid"));
193 if ($result === 0) {
194 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
195 exit;
196 } else {
197 setEventMessages($object->error, $object->errors, 'errors');
198 }
199}
200
201if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) {
202 $object->id = $id;
203 $result = $object->delete($user);
204 if ($result == 0) {
205 header("Location: index.php");
206 exit;
207 } else {
208 setEventMessages($object->error, $object->errors, 'errors');
209 }
210}
211
212if ($action == 'confirm_validate' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) {
213 $result = $object->fetch($id);
214 $result = $object->validate($user);
215 if ($result >= 0) {
216 // Define output language
217 $outputlangs = $langs;
218 $newlang = '';
219 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
220 $newlang = GETPOST('lang_id', 'aZ09');
221 }
222 //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->client->default_lang;
223 if (!empty($newlang)) {
224 $outputlangs = new Translate("", $conf);
225 $outputlangs->setDefaultLang($newlang);
226 }
227 $result = $object->generatePdf(GETPOST('model'), $outputlangs);
228
229 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
230 exit;
231 } else {
232 setEventMessages($object->error, $object->errors, 'errors');
233 }
234}
235
236if ($action == 'confirm_reject_check' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) {
237 $reject_date = dol_mktime(0, 0, 0, GETPOSTINT('rejectdate_month'), GETPOSTINT('rejectdate_day'), GETPOSTINT('rejectdate_year'));
238 $rejected_check = GETPOSTINT('bankid');
239
240 $object->fetch($id);
241 $paiement_id = $object->rejectCheck($rejected_check, $reject_date);
242 if ($paiement_id > 0) {
243 setEventMessages($langs->trans("CheckRejectedAndInvoicesReopened"), null, 'mesgs');
244 //header("Location: ".DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id);
245 //exit;
246 $action = '';
247 } else {
248 setEventMessages($object->error, $object->errors, 'errors');
249 $action = '';
250 }
251}
252
253if ($action == 'builddoc' && $user->hasRight('banque', 'cheque')) {
254 $result = $object->fetch($id);
255
256 // Save last template used to generate document
257 //if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
258
259 $outputlangs = $langs;
260 $newlang = '';
261 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
262 $newlang = GETPOST('lang_id', 'aZ09');
263 }
264 //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->client->default_lang;
265 if (!empty($newlang)) {
266 $outputlangs = new Translate("", $conf);
267 $outputlangs->setDefaultLang($newlang);
268 }
269 $result = $object->generatePdf(GETPOST("model"), $outputlangs);
270 if ($result <= 0) {
271 dol_print_error($db, $object->error);
272 exit;
273 } else {
274 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(!getDolGlobalString('MAIN_JUMP_TAG') ? '' : '#builddoc'));
275 exit;
276 }
277} elseif ($action == 'remove_file' && $user->hasRight('banque', 'cheque')) {
278 // Remove file in doc form
279 if ($object->fetch($id) > 0) {
280 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
281
282 $langs->load("other");
283
284 $filetodelete = GETPOST('file', 'alpha');
285 $file = $upload_dir.'/'.$filetodelete;
286
287 $ret = dol_delete_file($file, 1, 0, 0, $object);
288 if ($ret) {
289 setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
290 } else {
291 setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
292 }
293 }
294}
295
296
297/*
298 * View
299 */
300
301if (GETPOST('removefilter')) {
302 // filter by dates from / to
303 $search_date_start_day = '';
304 $search_date_start_month = '';
305 $search_date_start_year = '';
306 $search_date_end_day = '';
307 $search_date_end_month = '';
308 $search_date_end_year = '';
309 $search_date_start = '';
310 $search_date_end = '';
311 $filteraccountid = 0;
312}
313
314if ($action == 'create2') {
315 $title = $langs->trans("NewChequeDeposit");
316} else {
317 if ($type == 'CHQ') {
318 $title = $langs->trans("Cheques");
319 } else {
320 $title = ($langs->trans("PaymentType".$type) != "PaymentType".$type ? $langs->trans("PaymentType".$type) : $langs->trans("PaymentMode").' '.$type);
321 }
322}
323
324$helpurl = "";
325llxHeader("", $title, $helpurl);
326
327$form = new Form($db);
328$formfile = new FormFile($db);
329
330
331if ($action == 'create2') {
332 $head = array();
333 $h = 0;
334 $head[$h][0] = $_SERVER["PHP_SELF"].'?action=new';
335 $head[$h][1] = $langs->trans("MenuChequeDeposits");
336 $hselected = (string) $h;
337 $h++;
338
339 print load_fiche_titre($title, '', 'bank_account');
340} else {
341 $result = $object->fetch($id, $ref);
342 if ($result < 0) {
343 recordNotFound('', 0);
344 }
345
346 $h = 0;
347 $head = array();
348 $head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$object->id;
349 $head[$h][1] = $langs->trans("CheckReceipt");
350 $hselected = (string) $h;
351 $h++;
352 // $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/info.php?id='.$object->id;
353 // $head[$h][1] = $langs->trans("Info");
354 // $h++;
355
356 print dol_get_fiche_head($head, $hselected, $langs->trans("Cheques"), -1, 'payment');
357
358 /*
359 * Confirmation of slip's delete
360 */
361 if ($action == 'delete') {
362 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("DeleteCheckReceipt"), $langs->trans("ConfirmDeleteCheckReceipt"), 'confirm_delete', '', '', 1);
363 }
364
365 /*
366 * Confirmation of slip's validation
367 */
368 if ($action == 'valide') {
369 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_validate', '', '', 1);
370 }
371
372 /*
373 * Confirm check rejection
374 */
375 if ($action == 'reject_check') {
376 $formquestion = array(
377 array('type' => 'hidden', 'name' => 'bankid', 'value' => GETPOSTINT('lineid')),
378 array('type' => 'date', 'name' => 'rejectdate_', 'label' => $langs->trans("RejectCheckDate"), 'value' => dol_now())
379 );
380 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("RejectCheck"), $langs->trans("ConfirmRejectCheck"), 'confirm_reject_check', $formquestion, '', 1);
381 }
382}
383
384$accounts = array();
385
386if ($action == 'create2') {
387 $paymentstatic = new Paiement($db);
388 $accountlinestatic = new AccountLine($db);
389
390 $lines = array();
391
392 $now = dol_now();
393
394 $labeltype = ($langs->trans("PaymentType".$type) != "PaymentType".$type ? $langs->trans("PaymentType".$type) : $type);
395 if ($type == 'CHQ') {
396 print '<span class="opacitymedium">'.$langs->trans("SelectChequeTransactionAndGenerate").'</span><br><br>'."\n";
397 } else {
398 print '<span class="opacitymedium">'.$langs->trans("SelectPaymentTransactionAndGenerate", $labeltype).'</span><br><br>'."\n";
399 }
400
401 print '<form class="nocellnopadd" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
402 print '<input type="hidden" name="token" value="'.newToken().'">';
403 print '<input type="hidden" name="action" value="create2">';
404
405 print dol_get_fiche_head();
406
407 print '<table class="border centpercent">';
408
409 if (count($arrayofpaymentmodetomanage) > 1) {
410 $arrayoflabels = array();
411 foreach ($arrayofpaymentmodetomanage as $key => $val) {
412 $labelval = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val);
413 $arrayoflabels[$key] = $labelval;
414 }
415 // Type
416 print '<tr><td>';
417 print $langs->trans("Type");
418 print '</td><td>';
419 print $form->selectarray('type', $arrayoflabels, $type);
420 print '</td></tr>';
421 }
422 // Date
423 print '<tr><td class="titlefieldcreate">';
424 if ($type == 'CHQ') {
425 print $langs->trans("DateChequeReceived");
426 } else {
427 print $langs->trans("DatePaymentReceived");
428 }
429 print '</td><td>';
430 // filter by dates from / to
431 print '<div class="nowrapfordate">';
432 print $form->selectDate($search_date_start, 'search_date_start_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('From'));
433 print '</div>';
434 print '<div class="nowrapfordate marginleftonly">';
435 print $form->selectDate($search_date_end, 'search_date_end_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('to'));
436 print '</div>';
437 print '</td></tr>';
438 print '<tr><td>'.$langs->trans("BankAccount").'</td><td>';
439 print img_picto('', 'account', 'class="pictofixedwidth"');
440 // Filter must use the Universal Search Filter syntax, select_comptes() runs it through
441 // forgeSQLFromUniversalSearchCriteria(). != is mapped to <>, so cash registers stay excluded.
442 $form->select_comptes($filteraccountid, 'accountid', 0, '(courant:!=:2)', 1);
443 print '</td></tr>';
444 print '</table>';
445
446 print dol_get_fiche_end();
447
448 print '<div class="center">';
449 print '<input type="submit" class="button small" name="filter" value="'.dol_escape_htmltag($langs->trans("ToFilter")).'">';
450 if ($search_date_start || $search_date_end || $filteraccountid > 0) {
451 print ' &nbsp; ';
452 print '<input type="submit" class="button" name="removefilter small" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
453 }
454 print '</div>';
455 print '</form>';
456 print '<br><br>';
457 print '<br>';
458
459 $sql = "SELECT ba.rowid as bid, ba.label,";
460 $sql .= " b.rowid as transactionid, b.label as transactionlabel, b.datec as datec, b.dateo as date, ";
461 $sql .= " b.amount, b.emetteur, b.num_chq, b.banque,";
462 $sql .= " p.rowid as paymentid, p.ref as paymentref";
463 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
464 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
465 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)";
466 $sql .= " WHERE b.fk_type = '".$db->escape($type)."'";
467 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
468 $sql .= " AND b.fk_bordereau = 0";
469 $sql .= " AND b.amount > 0";
470 if ($search_date_start) {
471 $sql .= " AND b.dateo >= '".$db->idate($search_date_start)."'";
472 }
473 if ($search_date_end) {
474 $sql .= " AND b.dateo <= '".$db->idate($search_date_end)."'";
475 }
476 if ($filteraccountid > 0) {
477 $sql .= " AND ba.rowid = ".((int) $filteraccountid);
478 }
479 $sql .= $db->order("b.dateo,b.rowid", "ASC");
480
481 $resql = $db->query($sql);
482 if ($resql) {
483 $i = 0;
484 while ($obj = $db->fetch_object($resql)) {
485 $accounts[$obj->bid] = $obj->label;
486 $lines[$obj->bid][$i]["date"] = $db->jdate($obj->datec);
487 $lines[$obj->bid][$i]["amount"] = $obj->amount;
488 $lines[$obj->bid][$i]["emetteur"] = $obj->emetteur;
489 $lines[$obj->bid][$i]["numero"] = $obj->num_chq;
490 $lines[$obj->bid][$i]["banque"] = $obj->banque;
491 $lines[$obj->bid][$i]["id"] = $obj->transactionid;
492 $lines[$obj->bid][$i]["ref"] = $obj->transactionid;
493 $lines[$obj->bid][$i]["label"] = $obj->transactionlabel;
494 $lines[$obj->bid][$i]["paymentid"] = $obj->paymentid;
495 $lines[$obj->bid][$i]["paymentref"] = $obj->paymentref;
496 $lines[$obj->bid][$i]["paymentdate"] = $db->jdate($obj->date);
497 $i++;
498 }
499
500 if ($i == 0) {
501 if ($type == 'CHQ') {
502 print '<div class="opacitymedium">'.$langs->trans("NoWaitingChecks").'</div><br>';
503 } else {
504 print '<div class="opacitymedium">'.$langs->trans("NoWaitingPaymentForDeposit", $labeltype).'</div><br>';
505 }
506 }
507 }
508
509 foreach ($accounts as $bid => $account_label) {
510 print '
511 <script type="text/javascript">
512 jQuery(document).ready(function()
513 {
514 jQuery("#checkall_'.$bid.'").click(function()
515 {
516 jQuery(".checkforremise_'.$bid.'").prop(\'checked\', true);
517 });
518 jQuery("#checknone_'.$bid.'").click(function()
519 {
520 jQuery(".checkforremise_'.$bid.'").prop(\'checked\', false);
521 });
522 });
523 </script>
524 ';
525
526 $num = $db->num_rows($resql);
527
528 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
529 print '<input type="hidden" name="token" value="'.newToken().'">';
530 print '<input type="hidden" name="action" value="create">';
531 print '<input type="hidden" name="type" value="'.$type.'">';
532 print '<input type="hidden" name="accountid" value="'.$bid.'">';
533
534 print load_fiche_titre($account_label, '', '');
535
536 $moreforfilter = '';
537 print '<div class="div-table-responsive-no-min">';
538 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
539
540 print '<tr class="liste_titre">';
541 if ($conf->main_checkbox_left_column) {
542 print '<td class="center">'.$langs->trans("Select")."<br>";
543 if ($conf->use_javascript_ajax) {
544 print '<a href="#" id="checkall_'.$bid.'">'.$langs->trans("All").'</a> / <a href="#" id="checknone_'.$bid.'">'.$langs->trans("None").'</a>';
545 }
546 print '</td>';
547 }
548 print '<td>';
549 if ($type == 'CHQ') {
550 print $langs->trans("DateChequeReceived");
551 } else {
552 print $langs->trans("DatePaymentForDepositReceived", $type);
553 }
554 print '</td>'."\n";
555 print '<td>'.$langs->trans("ChequeNumber")."</td>\n";
556 print '<td>'.$langs->trans("CheckTransmitter")."</td>\n";
557 print '<td>'.$langs->trans("Bank")."</td>\n";
558 print '<td class="right">'.$langs->trans("Amount")."</td>\n";
559 print '<td class="center">'.$langs->trans("Payment")."</td>\n";
560 print '<td class="center">'.$langs->trans("LineRecord")."</td>\n";
561 if (empty($conf->main_checkbox_left_column)) {
562 print '<td class="center">'.$langs->trans("Select")."<br>";
563 if ($conf->use_javascript_ajax) {
564 print '<a href="#" id="checkall_'.$bid.'">'.$langs->trans("All").'</a> / <a href="#" id="checknone_'.$bid.'">'.$langs->trans("None").'</a>';
565 }
566 print '</td>';
567 }
568 print "</tr>\n";
569
570 if (count($lines[$bid])) {
571 foreach ($lines[$bid] as $lid => $value) {
572 print '<tr class="oddeven">';
573 if ($conf->main_checkbox_left_column) {
574 print '<td class="center">';
575 print '<input id="'.$value["id"].'" class="flat checkforremise_'.$bid.'" checked type="checkbox" name="toRemise[]" value="'.$value["id"].'">';
576 print '</td>';
577 }
578 print '<td>'.dol_print_date($value["paymentdate"], 'day').'</td>';
579 print '<td>'.dolPrintHTML($value["numero"])."</td>\n";
580 print '<td class="tdoverflowmax125" title="'.dolPrintHTML($value["emetteur"]).'">'.dolPrintHTML($value["emetteur"])."</td>\n";
581 print '<td>'.dolPrintHTML($value["banque"])."</td>\n";
582 print '<td class="right nowraponall"><span class="amount">'.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).'</span></td>';
583
584 // Link to payment
585 print '<td class="center nowraponall">';
586 $paymentstatic->id = $value["paymentid"];
587 $paymentstatic->ref = $value["paymentref"];
588 $paymentstatic->date = $value["paymentdate"];
589 if ($paymentstatic->id) {
590 print $paymentstatic->getNomUrl(1);
591 }
592 print '</td>';
593 // Link to bank transaction
594 print '<td class="center nowraponall">';
595 $accountlinestatic->id = $value["id"];
596 $accountlinestatic->ref = $value["ref"];
597 if ($accountlinestatic->id > 0) {
598 print $accountlinestatic->getNomUrl(1);
599 }
600 print '</td>';
601 if (empty($conf->main_checkbox_left_column)) {
602 print '<td class="center">';
603 print '<input id="'.$value["id"].'" class="flat checkforremise_'.$bid.'" checked type="checkbox" name="toRemise[]" value="'.$value["id"].'">';
604 print '</td>';
605 }
606 print '</tr>';
607 }
608 }
609 print "</table>";
610 print '</div>';
611
612 print '<div class="tabsAction">';
613 if ($user->hasRight('banque', 'cheque')) {
614 print '<input type="submit" class="button" value="'.$langs->trans('NewCheckDepositOn').'">';
615 } else {
616 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('NewCheckDepositOn').'</a>';
617 }
618 print '</div><br>';
619 print '</form>';
620 }
621} else {
622 $paymentstatic = new Paiement($db);
623 $accountlinestatic = new AccountLine($db);
624 $accountstatic = new Account($db);
625 $accountstatic->fetch($object->account_id);
626
627 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/paiement/cheque/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
628
629 $morehtmlref = '';
630 $morehtmlleft = '';
631 $moreghtmlright = '';
632
633 $labelval = ($langs->trans("PaymentType".$object->type) != "PaymentType".$object->type ? $langs->trans("PaymentType".$object->type) : $object->type);
634 $morehtmlref = '<br><div class="refidno">'.$langs->trans("Type").' : '.$labelval.'</div>';
635
636 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, $morehtmlleft, '', 0, $moreghtmlright);
637
638
639 print '<div class="fichecenter">';
640 print '<div class="underbanner clearboth"></div>';
641
642 print '<table class="border centpercent">';
643
644 print '<tr><td class="titlefield">';
645
646 print '<table class="nobordernopadding centpercent"><tr><td>';
647 print $langs->trans('Date');
648 print '</td>';
649 if ($action != 'editdate') {
650 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>';
651 }
652 print '</tr></table>';
653
654 print '</td><td>';
655 if ($action == 'editdate') {
656 print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
657 print '<input type="hidden" name="token" value="'.newToken().'">';
658 print '<input type="hidden" name="action" value="setdate">';
659 print $form->selectDate($object->date_bordereau, 'datecreate_', 0, 0, 0, "setdate");
660 print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
661 print '</form>';
662 } else {
663 print $object->date_bordereau ? dol_print_date($object->date_bordereau, 'day') : '&nbsp;';
664 }
665
666 print '</td>';
667 print '</tr>';
668
669 // External ref - Ext ref are not visible field on standard usage
670 if (getDolGlobalString('MAIN_SHOW_EXTREF')) {
671 print '<tr><td>';
672 print '<table class="nobordernopadding" width="100%"><tr><td>';
673 print $langs->trans('RefExt');
674 print '</td>';
675 if ($action != 'editrefext') {
676 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editrefext&token='.newToken().'&id='.((int) $object->id).'">'.img_edit($langs->trans('SetRefExt'), 1).'</a></td>';
677 }
678 print '</tr></table>';
679 print '</td><td>';
680 if ($action == 'editrefext') {
681 print '<form name="setrefext" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
682 print '<input type="hidden" name="token" value="'.newToken().'">';
683 print '<input type="hidden" name="action" value="setrefext">';
684 print '<input type="text" name="ref_ext" value="'.$object->ref_ext.'">';
685 print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
686 print '</form>';
687 } else {
688 print $object->ref_ext;
689 }
690 print '</td></tr>';
691 }
692
693 print '<tr><td>'.$langs->trans('Account').'</td><td>';
694 print $accountstatic->getNomUrl(1);
695 print '</td></tr>';
696
697 // Number of bank checks
698 print '<tr><td>'.$langs->trans('NbOfCheques').'</td><td>';
699 print $object->nbcheque;
700 print '</td></tr>';
701
702 print '<tr><td>'.$langs->trans('Total').'</td><td>';
703 print '<span class="amount">'.price($object->amount).'</span>';
704 print '</td></tr>';
705
706 print '</table><br>';
707
708 print '</div>';
709
710
711 // List of bank checks
712 $sql = "SELECT b.rowid, b.rowid as ref, b.label, b.amount, b.num_chq, b.emetteur,";
713 $sql .= " b.dateo as date, b.datec as datec, b.banque,";
714 $sql .= " p.rowid as pid, p.ref as pref, ba.rowid as bid, p.statut";
715 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
716 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)";
717 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
718 $sql .= " WHERE ba.entity IN (".getEntity('bank_account').")";
719 $sql .= " AND b.fk_type= '".$db->escape($object->type)."'";
720 $sql .= " AND b.fk_bordereau = ".((int) $object->id);
721 $sql .= $db->order($sortfield, $sortorder);
722
723 $resql = $db->query($sql);
724 if ($resql) {
725 $num = $db->num_rows($resql);
726
727 print '<div class="div-table-responsive">';
728 print '<table class="noborder centpercent">';
729
730 $param = "&amp;id=".$object->id;
731
732 print '<tr class="liste_titre">';
733 print_liste_field_titre("Cheques", '', '', '', '', 'width="30"');
734 print_liste_field_titre("DateChequeReceived", $_SERVER["PHP_SELF"], "b.dateo,b.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
735 print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "b.num_chq", "", $param, 'align="center"', $sortfield, $sortorder);
736 print_liste_field_titre("CheckTransmitter", $_SERVER["PHP_SELF"], "b.emetteur", "", $param, "", $sortfield, $sortorder);
737 print_liste_field_titre("Bank", $_SERVER["PHP_SELF"], "b.banque", "", $param, "", $sortfield, $sortorder);
738 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "b.amount", "", $param, 'class="right"', $sortfield, $sortorder);
739 print_liste_field_titre("Payment", $_SERVER["PHP_SELF"], "p.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
740 print_liste_field_titre("LineRecord", $_SERVER["PHP_SELF"], "b.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
742 print "</tr>\n";
743
744 $i = 1;
745 if ($num > 0) {
746 while ($objp = $db->fetch_object($resql)) {
747 $paymentstatic->id = $objp->pid;
748 $paymentstatic->ref = $objp->pref;
749
750 $accountlinestatic->id = $objp->rowid;
751 $accountlinestatic->ref = $objp->ref;
752
753 print '<tr class="oddeven">';
754 print '<td class="center">'.$i.'</td>';
755 print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>'; // Operation date
756 print '<td class="center">'.($objp->num_chq ? $objp->num_chq : '&nbsp;').'</td>';
757 print '<td>'.dol_trunc($objp->emetteur, 24).'</td>';
758 print '<td>'.dol_trunc($objp->banque, 24).'</td>';
759 print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
760 // Link to payment
761 print '<td class="center">';
762 if ($paymentstatic->id) {
763 print $paymentstatic->getNomUrl(1);
764 } else {
765 print '&nbsp;';
766 }
767 print '</td>';
768 // Link to bank transaction
769 print '<td class="center">';
770 if ($accountlinestatic->id > 0) {
771 print $accountlinestatic->getNomUrl(1);
772 } else {
773 print '&nbsp;';
774 }
775 print '</td>';
776 // Action button
777 print '<td class="right">';
778 if ($object->statut == 0) {
779 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=remove&token='.newToken().'&lineid='.$objp->rowid.'">'.img_delete().'</a>';
780 }
781 if ($object->statut == 1 && $objp->statut != 2) {
782 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reject_check&token='.newToken().'&lineid='.$objp->rowid.'">'.img_picto($langs->trans("RejectCheck"), 'fa-ban').'</a>';
783 }
784 if ($objp->statut == 2) {
785 print ' &nbsp; '.img_picto($langs->trans('CheckRejected'), 'statut8').'</a>';
786 }
787 print '</td>';
788 print '</tr>';
789
790 $i++;
791 }
792 } else {
793 print '<td colspan="9"><span class="opacitymedium">';
794 print $langs->trans("None");
795 print '</span></td>';
796 }
797
798 print "</table>";
799
800 // Cheque denormalized data nbcheque is similar to real number of bank check
801 if ($num > 0 && $i < ($object->nbcheque + 1)) {
802 // Show warning that some records were removed.
803 $langs->load("errors");
804 print info_admin($langs->trans("WarningSomeBankTransactionByChequeWereRemovedAfter"), 0, 0, 'warning');
805 // TODO Fix data ->nbcheque and ->amount
806 }
807
808 print "</div>";
809 } else {
810 dol_print_error($db);
811 }
812
813 print dol_get_fiche_end();
814}
815
816
817
818
819/*
820 * Actions Buttons
821 */
822
823print '<div class="tabsAction">';
824
825if ($user->socid == 0 && !empty($object->id) && $object->statut == 0 && $user->hasRight('banque', 'cheque')) {
826 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valide&token='.newToken().'&sortfield='.$sortfield.'&sortorder='.$sortorder.'">'.$langs->trans('Validate').'</a>';
827}
828
829if ($user->socid == 0 && !empty($object->id) && $user->hasRight('banque', 'cheque')) {
830 print dolGetButtonAction($langs->trans("Delete"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete, array('attr' => array('class' => 'reposition')))."\n";
831}
832print '</div>';
833
834
835
836if ($action != 'create2') {
837 if ($object->status == 1) {
838 // Documents
839 $objref = dol_sanitizeFileName($object->ref);
840 $filedir = $upload_dir.'/'.$objref;
841 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
842 $genallowed = $usercancreate;
843 $delallowed = $usercandelete;
844 print $formfile->showdocuments('remisecheque', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
845
846 print '<br>';
847 }
848}
849
850// End of page
851llxFooter();
852$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage bank accounts.
Class to manage bank transaction lines.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage payments of customer invoices.
Class to manage cheque delivery receipts.
Class to manage translations.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_now($mode='gmt')
Return date for now.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
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...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:540
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:738
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.