dolibarr 24.0.0-beta
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 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
34require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
35require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
36require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
37
46// Load translation files required by the page
47$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'compta'));
48
49$id = GETPOSTINT('id');
50$ref = GETPOST('ref', 'alpha');
51$action = GETPOST('action', 'aZ09');
52$confirm = GETPOST('confirm', 'alpha');
53
54$type = GETPOST('type');
55if (empty($type)) {
56 $type = 'CHQ';
57}
58
60
61$sortfield = GETPOST('sortfield', 'aZ09comma');
62$sortorder = GETPOST('sortorder', 'aZ09comma');
63$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
64if (!$sortorder) {
65 $sortorder = "ASC";
66}
67if (!$sortfield) {
68 $sortfield = "b.dateo,b.rowid";
69}
70if (empty($page) || $page == -1) {
71 $page = 0;
72}
73$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
74$offset = $limit * $page;
75
76$upload_dir = $conf->bank->multidir_output[$object->entity ? $object->entity : $conf->entity]."/checkdeposits";
77
78// filter by dates from / to
79$search_date_start_day = GETPOSTINT('search_date_start_day');
80$search_date_start_month = GETPOSTINT('search_date_start_month');
81$search_date_start_year = GETPOSTINT('search_date_start_year');
82$search_date_end_day = GETPOSTINT('search_date_end_day');
83$search_date_end_month = GETPOSTINT('search_date_end_month');
84$search_date_end_year = GETPOSTINT('search_date_end_year');
85$search_date_start = dol_mktime(0, 0, 0, $search_date_start_month, $search_date_start_day, $search_date_start_year);
86$search_date_end = dol_mktime(23, 59, 59, $search_date_end_month, $search_date_end_day, $search_date_end_year);
87$filteraccountid = GETPOSTINT('accountid');
88
89// Security check
90$fieldname = (!empty($ref) ? 'ref' : 'rowid');
91if ($user->socid) {
92 $socid = $user->socid;
93}
94$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque', '', 'fk_user_author', $fieldname);
95
96$usercanread = $user->hasRight('banque', 'cheque');
97$usercancreate = $user->hasRight('banque', 'cheque');
98$usercandelete = $user->hasRight('banque', 'cheque');
99
100$permissiontodelete = $user->hasRight('banque', 'cheque');
101
102// List of payment mode to support
103// Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA'
104$arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ'));
105
106
107/*
108 * Actions
109 */
110
111if ($action == 'setdate' && $user->hasRight('banque', 'cheque')) {
112 $result = $object->fetch(GETPOSTINT('id'));
113 if ($result > 0) {
114 $date = dol_mktime(0, 0, 0, GETPOSTINT('datecreate_month'), GETPOSTINT('datecreate_day'), GETPOSTINT('datecreate_year'));
115
116 $result = $object->set_date($user, $date);
117 if ($result < 0) {
118 setEventMessages($object->error, $object->errors, 'errors');
119 }
120 } else {
121 setEventMessages($object->error, $object->errors, 'errors');
122 }
123}
124
125if ($action == 'setrefext' && $user->hasRight('banque', 'cheque')) {
126 $result = $object->fetch(GETPOSTINT('id'));
127 if ($result > 0) {
128 $ref_ext = GETPOST('ref_ext');
129
130 $result = $object->setValueFrom('ref_ext', $ref_ext, '', null, 'text', '', $user, 'CHECKDEPOSIT_MODIFY');
131 if ($result < 0) {
132 setEventMessages($object->error, $object->errors, 'errors');
133 }
134 } else {
135 setEventMessages($object->error, $object->errors, 'errors');
136 }
137}
138
139if ($action == 'setref' && $user->hasRight('banque', 'cheque')) {
140 $result = $object->fetch(GETPOSTINT('id'));
141 if ($result > 0) {
142 $ref = GETPOST('ref');
143
144 $result = $object->set_number($user, $ref);
145 if ($result < 0) {
146 setEventMessages($object->error, $object->errors, 'errors');
147 }
148 } else {
149 setEventMessages($object->error, $object->errors, 'errors');
150 }
151}
152
153if ($action == 'create' && GETPOSTINT("accountid") > 0 && $user->hasRight('banque', 'cheque')) {
154 if (GETPOSTISARRAY('toRemise')) {
155 $object->type = $type;
156 $object->date_bordereau = dol_now();
157 $arrayofid = GETPOST('toRemise', 'array:int');
158
159 $result = $object->create($user, GETPOSTINT("accountid"), 0, $arrayofid);
160 if ($result > 0) {
161 if ($object->statut == 1) { // If statut is validated, we build doc
162 $object->fetch($object->id); // To force to reload all properties in correct property name
163 // Define output language
164 $outputlangs = $langs;
165 $newlang = '';
166 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
167 $newlang = GETPOST('lang_id', 'aZ09');
168 }
169 //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->client->default_lang;
170 if (!empty($newlang)) {
171 $outputlangs = new Translate("", $conf);
172 $outputlangs->setDefaultLang($newlang);
173 }
174 $result = $object->generatePdf(GETPOST("model"), $outputlangs);
175 }
176
177 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
178 exit;
179 } else {
180 setEventMessages($object->error, $object->errors, 'errors');
181 $action = 'new';
182 }
183 } else {
184 setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'mesgs');
185 $action = 'new';
186 }
187}
188
189if ($action == 'remove' && $id > 0 && GETPOSTINT("lineid") > 0 && $user->hasRight('banque', 'cheque')) {
190 $object->id = $id;
191 $result = $object->removeCheck(GETPOSTINT("lineid"));
192 if ($result === 0) {
193 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
194 exit;
195 } else {
196 setEventMessages($object->error, $object->errors, 'errors');
197 }
198}
199
200if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) {
201 $object->id = $id;
202 $result = $object->delete($user);
203 if ($result == 0) {
204 header("Location: index.php");
205 exit;
206 } else {
207 setEventMessages($object->error, $object->errors, 'errors');
208 }
209}
210
211if ($action == 'confirm_validate' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) {
212 $result = $object->fetch($id);
213 $result = $object->validate($user);
214 if ($result >= 0) {
215 // Define output language
216 $outputlangs = $langs;
217 $newlang = '';
218 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
219 $newlang = GETPOST('lang_id', 'aZ09');
220 }
221 //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->client->default_lang;
222 if (!empty($newlang)) {
223 $outputlangs = new Translate("", $conf);
224 $outputlangs->setDefaultLang($newlang);
225 }
226 $result = $object->generatePdf(GETPOST('model'), $outputlangs);
227
228 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
229 exit;
230 } else {
231 setEventMessages($object->error, $object->errors, 'errors');
232 }
233}
234
235if ($action == 'confirm_reject_check' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) {
236 $reject_date = dol_mktime(0, 0, 0, GETPOSTINT('rejectdate_month'), GETPOSTINT('rejectdate_day'), GETPOSTINT('rejectdate_year'));
237 $rejected_check = GETPOSTINT('bankid');
238
239 $object->fetch($id);
240 $paiement_id = $object->rejectCheck($rejected_check, $reject_date);
241 if ($paiement_id > 0) {
242 setEventMessages($langs->trans("CheckRejectedAndInvoicesReopened"), null, 'mesgs');
243 //header("Location: ".DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id);
244 //exit;
245 $action = '';
246 } else {
247 setEventMessages($object->error, $object->errors, 'errors');
248 $action = '';
249 }
250}
251
252if ($action == 'builddoc' && $user->hasRight('banque', 'cheque')) {
253 $result = $object->fetch($id);
254
255 // Save last template used to generate document
256 //if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
257
258 $outputlangs = $langs;
259 $newlang = '';
260 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
261 $newlang = GETPOST('lang_id', 'aZ09');
262 }
263 //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->client->default_lang;
264 if (!empty($newlang)) {
265 $outputlangs = new Translate("", $conf);
266 $outputlangs->setDefaultLang($newlang);
267 }
268 $result = $object->generatePdf(GETPOST("model"), $outputlangs);
269 if ($result <= 0) {
270 dol_print_error($db, $object->error);
271 exit;
272 } else {
273 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(!getDolGlobalString('MAIN_JUMP_TAG') ? '' : '#builddoc'));
274 exit;
275 }
276} elseif ($action == 'remove_file' && $user->hasRight('banque', 'cheque')) {
277 // Remove file in doc form
278 if ($object->fetch($id) > 0) {
279 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
280
281 $langs->load("other");
282
283 $filetodelete = GETPOST('file', 'alpha');
284 $file = $upload_dir.'/'.$filetodelete;
285
286 $ret = dol_delete_file($file, 0, 0, 0, $object);
287 if ($ret) {
288 setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
289 } else {
290 setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
291 }
292 }
293}
294
295
296/*
297 * View
298 */
299
300if (GETPOST('removefilter')) {
301 // filter by dates from / to
302 $search_date_start_day = '';
303 $search_date_start_month = '';
304 $search_date_start_year = '';
305 $search_date_end_day = '';
306 $search_date_end_month = '';
307 $search_date_end_year = '';
308 $search_date_start = '';
309 $search_date_end = '';
310 $filteraccountid = 0;
311}
312
313if ($action == 'new') {
314 $title = $langs->trans("NewChequeDeposit");
315} else {
316 if ($type == 'CHQ') {
317 $title = $langs->trans("Cheques");
318 } else {
319 $title = ($langs->trans("PaymentType".$type) != "PaymentType".$type ? $langs->trans("PaymentType".$type) : $langs->trans("PaymentMode").' '.$type);
320 }
321}
322
323$helpurl = "";
324llxHeader("", $title, $helpurl);
325
326$form = new Form($db);
327$formfile = new FormFile($db);
328
329
330if ($action == 'new') {
331 $head = array();
332 $h = 0;
333 $head[$h][0] = $_SERVER["PHP_SELF"].'?action=new';
334 $head[$h][1] = $langs->trans("MenuChequeDeposits");
335 $hselected = (string) $h;
336 $h++;
337
338 print load_fiche_titre($title, '', 'bank_account');
339} else {
340 $result = $object->fetch($id, $ref);
341 if ($result < 0) {
342 dol_print_error($db, $object->error);
343 exit;
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 == 'new') {
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="new">';
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 $form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1);
441 print '</td></tr>';
442 print '</table>';
443
444 print dol_get_fiche_end();
445
446 print '<div class="center">';
447 print '<input type="submit" class="button small" name="filter" value="'.dol_escape_htmltag($langs->trans("ToFilter")).'">';
448 if ($search_date_start || $search_date_end || $filteraccountid > 0) {
449 print ' &nbsp; ';
450 print '<input type="submit" class="button" name="removefilter small" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
451 }
452 print '</div>';
453 print '</form>';
454 print '<br><br>';
455 print '<br>';
456
457 $sql = "SELECT ba.rowid as bid, ba.label,";
458 $sql .= " b.rowid as transactionid, b.label as transactionlabel, b.datec as datec, b.dateo as date, ";
459 $sql .= " b.amount, b.emetteur, b.num_chq, b.banque,";
460 $sql .= " p.rowid as paymentid, p.ref as paymentref";
461 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
462 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
463 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)";
464 $sql .= " WHERE b.fk_type = '".$db->escape($type)."'";
465 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
466 $sql .= " AND b.fk_bordereau = 0";
467 $sql .= " AND b.amount > 0";
468 if ($search_date_start) {
469 $sql .= " AND b.dateo >= '".$db->idate($search_date_start)."'";
470 }
471 if ($search_date_end) {
472 $sql .= " AND b.dateo <= '".$db->idate($search_date_end)."'";
473 }
474 if ($filteraccountid > 0) {
475 $sql .= " AND ba.rowid = ".((int) $filteraccountid);
476 }
477 $sql .= $db->order("b.dateo,b.rowid", "ASC");
478
479 $resql = $db->query($sql);
480 if ($resql) {
481 $i = 0;
482 while ($obj = $db->fetch_object($resql)) {
483 $accounts[$obj->bid] = $obj->label;
484 $lines[$obj->bid][$i]["date"] = $db->jdate($obj->datec);
485 $lines[$obj->bid][$i]["amount"] = $obj->amount;
486 $lines[$obj->bid][$i]["emetteur"] = $obj->emetteur;
487 $lines[$obj->bid][$i]["numero"] = $obj->num_chq;
488 $lines[$obj->bid][$i]["banque"] = $obj->banque;
489 $lines[$obj->bid][$i]["id"] = $obj->transactionid;
490 $lines[$obj->bid][$i]["ref"] = $obj->transactionid;
491 $lines[$obj->bid][$i]["label"] = $obj->transactionlabel;
492 $lines[$obj->bid][$i]["paymentid"] = $obj->paymentid;
493 $lines[$obj->bid][$i]["paymentref"] = $obj->paymentref;
494 $lines[$obj->bid][$i]["paymentdate"] = $db->jdate($obj->date);
495 $i++;
496 }
497
498 if ($i == 0) {
499 if ($type == 'CHQ') {
500 print '<div class="opacitymedium">'.$langs->trans("NoWaitingChecks").'</div><br>';
501 } else {
502 print '<div class="opacitymedium">'.$langs->trans("NoWaitingPaymentForDeposit", $labeltype).'</div><br>';
503 }
504 }
505 }
506
507 foreach ($accounts as $bid => $account_label) {
508 print '
509 <script type="text/javascript">
510 jQuery(document).ready(function()
511 {
512 jQuery("#checkall_'.$bid.'").click(function()
513 {
514 jQuery(".checkforremise_'.$bid.'").prop(\'checked\', true);
515 });
516 jQuery("#checknone_'.$bid.'").click(function()
517 {
518 jQuery(".checkforremise_'.$bid.'").prop(\'checked\', false);
519 });
520 });
521 </script>
522 ';
523
524 $num = $db->num_rows($resql);
525
526 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
527 print '<input type="hidden" name="token" value="'.newToken().'">';
528 print '<input type="hidden" name="action" value="create">';
529 print '<input type="hidden" name="type" value="'.$type.'">';
530 print '<input type="hidden" name="accountid" value="'.$bid.'">';
531
532 print load_fiche_titre($account_label, '', '');
533
534 $moreforfilter = '';
535 print '<div class="div-table-responsive-no-min">';
536 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
537
538 print '<tr class="liste_titre">';
539 if ($conf->main_checkbox_left_column) {
540 print '<td class="center">'.$langs->trans("Select")."<br>";
541 if ($conf->use_javascript_ajax) {
542 print '<a href="#" id="checkall_'.$bid.'">'.$langs->trans("All").'</a> / <a href="#" id="checknone_'.$bid.'">'.$langs->trans("None").'</a>';
543 }
544 print '</td>';
545 }
546 print '<td>';
547 if ($type == 'CHQ') {
548 print $langs->trans("DateChequeReceived");
549 } else {
550 print $langs->trans("DatePaymentForDepositReceived", $type);
551 }
552 print '</td>'."\n";
553 print '<td>'.$langs->trans("ChequeNumber")."</td>\n";
554 print '<td>'.$langs->trans("CheckTransmitter")."</td>\n";
555 print '<td>'.$langs->trans("Bank")."</td>\n";
556 print '<td class="right">'.$langs->trans("Amount")."</td>\n";
557 print '<td class="center">'.$langs->trans("Payment")."</td>\n";
558 print '<td class="center">'.$langs->trans("LineRecord")."</td>\n";
559 if (empty($conf->main_checkbox_left_column)) {
560 print '<td class="center">'.$langs->trans("Select")."<br>";
561 if ($conf->use_javascript_ajax) {
562 print '<a href="#" id="checkall_'.$bid.'">'.$langs->trans("All").'</a> / <a href="#" id="checknone_'.$bid.'">'.$langs->trans("None").'</a>';
563 }
564 print '</td>';
565 }
566 print "</tr>\n";
567
568 if (count($lines[$bid])) {
569 foreach ($lines[$bid] as $lid => $value) {
570 print '<tr class="oddeven">';
571 if ($conf->main_checkbox_left_column) {
572 print '<td class="center">';
573 print '<input id="'.$value["id"].'" class="flat checkforremise_'.$bid.'" checked type="checkbox" name="toRemise[]" value="'.$value["id"].'">';
574 print '</td>';
575 }
576 print '<td>'.dol_print_date($value["paymentdate"], 'day').'</td>';
577 print '<td>'.dolPrintHTML($value["numero"])."</td>\n";
578 print '<td class="tdoverflowmax125" title="'.dolPrintHTML($value["emetteur"]).'">'.dolPrintHTML($value["emetteur"])."</td>\n";
579 print '<td>'.dolPrintHTML($value["banque"])."</td>\n";
580 print '<td class="right nowraponall"><span class="amount">'.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).'</span></td>';
581
582 // Link to payment
583 print '<td class="center nowraponall">';
584 $paymentstatic->id = $value["paymentid"];
585 $paymentstatic->ref = $value["paymentref"];
586 $paymentstatic->date = $value["paymentdate"];
587 if ($paymentstatic->id) {
588 print $paymentstatic->getNomUrl(1);
589 }
590 print '</td>';
591 // Link to bank transaction
592 print '<td class="center nowraponall">';
593 $accountlinestatic->id = $value["id"];
594 $accountlinestatic->ref = $value["ref"];
595 if ($accountlinestatic->id > 0) {
596 print $accountlinestatic->getNomUrl(1);
597 }
598 print '</td>';
599 if (empty($conf->main_checkbox_left_column)) {
600 print '<td class="center">';
601 print '<input id="'.$value["id"].'" class="flat checkforremise_'.$bid.'" checked type="checkbox" name="toRemise[]" value="'.$value["id"].'">';
602 print '</td>';
603 }
604 print '</tr>';
605 }
606 }
607 print "</table>";
608 print '</div>';
609
610 print '<div class="tabsAction">';
611 if ($user->hasRight('banque', 'cheque')) {
612 print '<input type="submit" class="button" value="'.$langs->trans('NewCheckDepositOn').'">';
613 } else {
614 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('NewCheckDepositOn').'</a>';
615 }
616 print '</div><br>';
617 print '</form>';
618 }
619} else {
620 $paymentstatic = new Paiement($db);
621 $accountlinestatic = new AccountLine($db);
622 $accountstatic = new Account($db);
623 $accountstatic->fetch($object->account_id);
624
625 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/paiement/cheque/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
626
627 $morehtmlref = '';
628 $morehtmlleft = '';
629 $moreghtmlright = '';
630
631 $labelval = ($langs->trans("PaymentType".$object->type) != "PaymentType".$object->type ? $langs->trans("PaymentType".$object->type) : $object->type);
632 $morehtmlref = '<br><div class="refidno">'.$langs->trans("Type").' : '.$labelval.'</div>';
633
634 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, $morehtmlleft, '', 0, $moreghtmlright);
635
636
637 print '<div class="fichecenter">';
638 print '<div class="underbanner clearboth"></div>';
639
640 print '<table class="border centpercent">';
641
642 print '<tr><td class="titlefield">';
643
644 print '<table class="nobordernopadding centpercent"><tr><td>';
645 print $langs->trans('Date');
646 print '</td>';
647 if ($action != 'editdate') {
648 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>';
649 }
650 print '</tr></table>';
651
652 print '</td><td>';
653 if ($action == 'editdate') {
654 print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
655 print '<input type="hidden" name="token" value="'.newToken().'">';
656 print '<input type="hidden" name="action" value="setdate">';
657 print $form->selectDate($object->date_bordereau, 'datecreate_', 0, 0, 0, "setdate");
658 print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
659 print '</form>';
660 } else {
661 print $object->date_bordereau ? dol_print_date($object->date_bordereau, 'day') : '&nbsp;';
662 }
663
664 print '</td>';
665 print '</tr>';
666
667 // External ref - Ext ref are not visible field on standard usage
668 if (getDolGlobalString('MAIN_SHOW_EXTREF')) {
669 print '<tr><td>';
670 print '<table class="nobordernopadding" width="100%"><tr><td>';
671 print $langs->trans('RefExt');
672 print '</td>';
673 if ($action != 'editrefext') {
674 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>';
675 }
676 print '</tr></table>';
677 print '</td><td>';
678 if ($action == 'editrefext') {
679 print '<form name="setrefext" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
680 print '<input type="hidden" name="token" value="'.newToken().'">';
681 print '<input type="hidden" name="action" value="setrefext">';
682 print '<input type="text" name="ref_ext" value="'.$object->ref_ext.'">';
683 print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
684 print '</form>';
685 } else {
686 print $object->ref_ext;
687 }
688 print '</td></tr>';
689 }
690
691 print '<tr><td>'.$langs->trans('Account').'</td><td>';
692 print $accountstatic->getNomUrl(1);
693 print '</td></tr>';
694
695 // Number of bank checks
696 print '<tr><td>'.$langs->trans('NbOfCheques').'</td><td>';
697 print $object->nbcheque;
698 print '</td></tr>';
699
700 print '<tr><td>'.$langs->trans('Total').'</td><td>';
701 print '<span class="amount">'.price($object->amount).'</span>';
702 print '</td></tr>';
703
704 print '</table><br>';
705
706 print '</div>';
707
708
709 // List of bank checks
710 $sql = "SELECT b.rowid, b.rowid as ref, b.label, b.amount, b.num_chq, b.emetteur,";
711 $sql .= " b.dateo as date, b.datec as datec, b.banque,";
712 $sql .= " p.rowid as pid, p.ref as pref, ba.rowid as bid, p.statut";
713 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
714 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)";
715 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
716 $sql .= " WHERE ba.entity IN (".getEntity('bank_account').")";
717 $sql .= " AND b.fk_type= '".$db->escape($object->type)."'";
718 $sql .= " AND b.fk_bordereau = ".((int) $object->id);
719 $sql .= $db->order($sortfield, $sortorder);
720
721 $resql = $db->query($sql);
722 if ($resql) {
723 $num = $db->num_rows($resql);
724
725 print '<div class="div-table-responsive">';
726 print '<table class="noborder centpercent">';
727
728 $param = "&amp;id=".$object->id;
729
730 print '<tr class="liste_titre">';
731 print_liste_field_titre("Cheques", '', '', '', '', 'width="30"');
732 print_liste_field_titre("DateChequeReceived", $_SERVER["PHP_SELF"], "b.dateo,b.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
733 print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "b.num_chq", "", $param, 'align="center"', $sortfield, $sortorder);
734 print_liste_field_titre("CheckTransmitter", $_SERVER["PHP_SELF"], "b.emetteur", "", $param, "", $sortfield, $sortorder);
735 print_liste_field_titre("Bank", $_SERVER["PHP_SELF"], "b.banque", "", $param, "", $sortfield, $sortorder);
736 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "b.amount", "", $param, 'class="right"', $sortfield, $sortorder);
737 print_liste_field_titre("Payment", $_SERVER["PHP_SELF"], "p.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
738 print_liste_field_titre("LineRecord", $_SERVER["PHP_SELF"], "b.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
740 print "</tr>\n";
741
742 $i = 1;
743 if ($num > 0) {
744 while ($objp = $db->fetch_object($resql)) {
745 $paymentstatic->id = $objp->pid;
746 $paymentstatic->ref = $objp->pref;
747
748 $accountlinestatic->id = $objp->rowid;
749 $accountlinestatic->ref = $objp->ref;
750
751 print '<tr class="oddeven">';
752 print '<td class="center">'.$i.'</td>';
753 print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>'; // Operation date
754 print '<td class="center">'.($objp->num_chq ? $objp->num_chq : '&nbsp;').'</td>';
755 print '<td>'.dol_trunc($objp->emetteur, 24).'</td>';
756 print '<td>'.dol_trunc($objp->banque, 24).'</td>';
757 print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
758 // Link to payment
759 print '<td class="center">';
760 if ($paymentstatic->id) {
761 print $paymentstatic->getNomUrl(1);
762 } else {
763 print '&nbsp;';
764 }
765 print '</td>';
766 // Link to bank transaction
767 print '<td class="center">';
768 if ($accountlinestatic->id > 0) {
769 print $accountlinestatic->getNomUrl(1);
770 } else {
771 print '&nbsp;';
772 }
773 print '</td>';
774 // Action button
775 print '<td class="right">';
776 if ($object->statut == 0) {
777 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=remove&token='.newToken().'&lineid='.$objp->rowid.'">'.img_delete().'</a>';
778 }
779 if ($object->statut == 1 && $objp->statut != 2) {
780 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reject_check&token='.newToken().'&lineid='.$objp->rowid.'">'.img_picto($langs->trans("RejectCheck"), 'disable').'</a>';
781 }
782 if ($objp->statut == 2) {
783 print ' &nbsp; '.img_picto($langs->trans('CheckRejected'), 'statut8').'</a>';
784 }
785 print '</td>';
786 print '</tr>';
787
788 $i++;
789 }
790 } else {
791 print '<td colspan="9"><span class="opacitymedium">';
792 print $langs->trans("None");
793 print '</span></td>';
794 }
795
796 print "</table>";
797
798 // Cheque denormalized data nbcheque is similar to real number of bank check
799 if ($num > 0 && $i < ($object->nbcheque + 1)) {
800 // Show warning that some records were removed.
801 $langs->load("errors");
802 print info_admin($langs->trans("WarningSomeBankTransactionByChequeWereRemovedAfter"), 0, 0, 'warning');
803 // TODO Fix data ->nbcheque and ->amount
804 }
805
806 print "</div>";
807 } else {
809 }
810
811 print dol_get_fiche_end();
812}
813
814
815
816
817/*
818 * Actions Buttons
819 */
820
821print '<div class="tabsAction">';
822
823if ($user->socid == 0 && !empty($object->id) && $object->statut == 0 && $user->hasRight('banque', 'cheque')) {
824 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valide&token='.newToken().'&sortfield='.$sortfield.'&sortorder='.$sortorder.'">'.$langs->trans('Validate').'</a>';
825}
826
827if ($user->socid == 0 && !empty($object->id) && $user->hasRight('banque', 'cheque')) {
828 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
829}
830print '</div>';
831
832
833
834if ($action != 'new') {
835 if ($object->statut == 1) {
836 // Documents
837 $objref = dol_sanitizeFileName($object->ref);
838 $filedir = $upload_dir.'/'.$objref;
839 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
840 $genallowed = $usercancreate;
841 $delallowed = $usercandelete;
842 print $formfile->showdocuments('remisecheque', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
843
844 print '<br>';
845 }
846}
847
848// End of page
849llxFooter();
850$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:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.