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