dolibarr 20.0.0
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 $arrayofid = GETPOST('toRemise', 'array:int');
148
149 $result = $object->create($user, GETPOSTINT("accountid"), 0, $arrayofid);
150 if ($result > 0) {
151 if ($object->statut == 1) { // If statut is validated, we build doc
152 $object->fetch($object->id); // To force to reload all properties in correct property name
153 // Define output language
154 $outputlangs = $langs;
155 $newlang = '';
156 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
157 $newlang = GETPOST('lang_id', 'aZ09');
158 }
159 //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->client->default_lang;
160 if (!empty($newlang)) {
161 $outputlangs = new Translate("", $conf);
162 $outputlangs->setDefaultLang($newlang);
163 }
164 $result = $object->generatePdf(GETPOST("model"), $outputlangs);
165 }
166
167 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
168 exit;
169 } else {
170 setEventMessages($object->error, $object->errors, 'errors');
171 }
172 } else {
173 setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'mesgs');
174 $action = 'new';
175 }
176}
177
178if ($action == 'remove' && $id > 0 && GETPOSTINT("lineid") > 0 && $user->hasRight('banque', 'cheque')) {
179 $object->id = $id;
180 $result = $object->removeCheck(GETPOSTINT("lineid"));
181 if ($result === 0) {
182 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
183 exit;
184 } else {
185 setEventMessages($object->error, $object->errors, 'errors');
186 }
187}
188
189if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) {
190 $object->id = $id;
191 $result = $object->delete($user);
192 if ($result == 0) {
193 header("Location: index.php");
194 exit;
195 } else {
196 setEventMessages($paiement->error, $paiement->errors, 'errors');
197 }
198}
199
200if ($action == 'confirm_validate' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) {
201 $result = $object->fetch($id);
202 $result = $object->validate($user);
203 if ($result >= 0) {
204 // Define output language
205 $outputlangs = $langs;
206 $newlang = '';
207 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
208 $newlang = GETPOST('lang_id', 'aZ09');
209 }
210 //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->client->default_lang;
211 if (!empty($newlang)) {
212 $outputlangs = new Translate("", $conf);
213 $outputlangs->setDefaultLang($newlang);
214 }
215 $result = $object->generatePdf(GETPOST('model'), $outputlangs);
216
217 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
218 exit;
219 } else {
220 setEventMessages($object->error, $object->errors, 'errors');
221 }
222}
223
224if ($action == 'confirm_reject_check' && $confirm == 'yes' && $user->hasRight('banque', 'cheque')) {
225 $reject_date = dol_mktime(0, 0, 0, GETPOST('rejectdate_month'), GETPOST('rejectdate_day'), GETPOST('rejectdate_year'));
226 $rejected_check = GETPOSTINT('bankid');
227
228 $object->fetch($id);
229 $paiement_id = $object->rejectCheck($rejected_check, $reject_date);
230 if ($paiement_id > 0) {
231 setEventMessages($langs->trans("CheckRejectedAndInvoicesReopened"), null, 'mesgs');
232 //header("Location: ".DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id);
233 //exit;
234 $action = '';
235 } else {
236 setEventMessages($object->error, $object->errors, 'errors');
237 $action = '';
238 }
239}
240
241if ($action == 'builddoc' && $user->hasRight('banque', 'cheque')) {
242 $result = $object->fetch($id);
243
244 // Save last template used to generate document
245 //if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
246
247 $outputlangs = $langs;
248 $newlang = '';
249 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
250 $newlang = GETPOST('lang_id', 'aZ09');
251 }
252 //if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) $newlang=$object->client->default_lang;
253 if (!empty($newlang)) {
254 $outputlangs = new Translate("", $conf);
255 $outputlangs->setDefaultLang($newlang);
256 }
257 $result = $object->generatePdf(GETPOST("model"), $outputlangs);
258 if ($result <= 0) {
259 dol_print_error($db, $object->error);
260 exit;
261 } else {
262 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(!getDolGlobalString('MAIN_JUMP_TAG') ? '' : '#builddoc'));
263 exit;
264 }
265} elseif ($action == 'remove_file' && $user->hasRight('banque', 'cheque')) {
266 // Remove file in doc form
267 if ($object->fetch($id) > 0) {
268 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
269
270 $langs->load("other");
271
272 $filetodelete = GETPOST('file', 'alpha');
273 $file = $upload_dir.'/'.$filetodelete;
274
275 $ret = dol_delete_file($file, 0, 0, 0, $object);
276 if ($ret) {
277 setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
278 } else {
279 setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
280 }
281 }
282}
283
284
285/*
286 * View
287 */
288
289if (GETPOST('removefilter')) {
290 // filter by dates from / to
291 $search_date_start_day = '';
292 $search_date_start_month = '';
293 $search_date_start_year = '';
294 $search_date_end_day = '';
295 $search_date_end_month = '';
296 $search_date_end_year = '';
297 $search_date_start = '';
298 $search_date_end = '';
299 $filteraccountid = 0;
300}
301
302if ($action == 'new') {
303 $title = $langs->trans("NewChequeDeposit");
304} else {
305 if ($type == 'CHQ') {
306 $title = $langs->trans("Cheques");
307 } else {
308 $title = ($langs->trans("PaymentType".$type) != "PaymentType".$type ? $langs->trans("PaymentType".$type) : $langs->trans("PaymentMode").' '.$type);
309 }
310}
311
312$helpurl = "";
313llxHeader("", $title, $helpurl);
314
315$form = new Form($db);
316$formfile = new FormFile($db);
317
318
319if ($action == 'new') {
320 $head = array();
321 $h = 0;
322 $head[$h][0] = $_SERVER["PHP_SELF"].'?action=new';
323 $head[$h][1] = $langs->trans("MenuChequeDeposits");
324 $hselected = $h;
325 $h++;
326
327 print load_fiche_titre($title, '', 'bank_account');
328} else {
329 $result = $object->fetch($id, $ref);
330 if ($result < 0) {
331 dol_print_error($db, $object->error);
332 exit;
333 }
334
335 $h = 0;
336 $head = array();
337 $head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$object->id;
338 $head[$h][1] = $langs->trans("CheckReceipt");
339 $hselected = $h;
340 $h++;
341 // $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/info.php?id='.$object->id;
342 // $head[$h][1] = $langs->trans("Info");
343 // $h++;
344
345 print dol_get_fiche_head($head, $hselected, $langs->trans("Cheques"), -1, 'payment');
346
347 /*
348 * Confirmation of slip's delete
349 */
350 if ($action == 'delete') {
351 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("DeleteCheckReceipt"), $langs->trans("ConfirmDeleteCheckReceipt"), 'confirm_delete', '', '', 1);
352 }
353
354 /*
355 * Confirmation of slip's validation
356 */
357 if ($action == 'valide') {
358 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_validate', '', '', 1);
359 }
360
361 /*
362 * Confirm check rejection
363 */
364 if ($action == 'reject_check') {
365 $formquestion = array(
366 array('type' => 'hidden', 'name' => 'bankid', 'value' => GETPOSTINT('lineid')),
367 array('type' => 'date', 'name' => 'rejectdate_', 'label' => $langs->trans("RejectCheckDate"), 'value' => dol_now())
368 );
369 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("RejectCheck"), $langs->trans("ConfirmRejectCheck"), 'confirm_reject_check', $formquestion, '', 1);
370 }
371}
372
373$accounts = array();
374
375if ($action == 'new') {
376 $paymentstatic = new Paiement($db);
377 $accountlinestatic = new AccountLine($db);
378
379 $lines = array();
380
381 $now = dol_now();
382
383 $labeltype = ($langs->trans("PaymentType".$type) != "PaymentType".$type ? $langs->trans("PaymentType".$type) : $type);
384 if ($type == 'CHQ') {
385 print '<span class="opacitymedium">'.$langs->trans("SelectChequeTransactionAndGenerate").'</span><br><br>'."\n";
386 } else {
387 print '<span class="opacitymedium">'.$langs->trans("SelectPaymentTransactionAndGenerate", $labeltype).'</span><br><br>'."\n";
388 }
389
390 print '<form class="nocellnopadd" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
391 print '<input type="hidden" name="token" value="'.newToken().'">';
392 print '<input type="hidden" name="action" value="new">';
393
394 print dol_get_fiche_head();
395
396 print '<table class="border centpercent">';
397
398 if (count($arrayofpaymentmodetomanage) > 1) {
399 $arrayoflabels = array();
400 foreach ($arrayofpaymentmodetomanage as $key => $val) {
401 $labelval = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val);
402 $arrayoflabels[$key] = $labelval;
403 }
404 // Type
405 print '<tr><td>';
406 print $langs->trans("Type");
407 print '</td><td>';
408 print $form->selectarray('type', $arrayoflabels, $type);
409 print '</td></tr>';
410 }
411 // Date
412 print '<tr><td class="titlefieldcreate">';
413 if ($type == 'CHQ') {
414 print $langs->trans("DateChequeReceived");
415 } else {
416 print $langs->trans("DatePaymentReceived");
417 }
418 print '</td><td>';
419 // filter by dates from / to
420 print '<div class="nowrapfordate">';
421 print $form->selectDate($search_date_start, 'search_date_start_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('From'));
422 print '</div>';
423 print '<div class="nowrapfordate">';
424 print $form->selectDate($search_date_end, 'search_date_end_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('to'));
425 print '</div>';
426 print '</td></tr>';
427 print '<tr><td>'.$langs->trans("BankAccount").'</td><td>';
428 $form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1);
429 print '</td></tr>';
430 print '</table>';
431
432 print dol_get_fiche_end();
433
434 print '<div class="center">';
435 print '<input type="submit" class="button small" name="filter" value="'.dol_escape_htmltag($langs->trans("ToFilter")).'">';
436 if ($search_date_start || $search_date_end || $filteraccountid > 0) {
437 print ' &nbsp; ';
438 print '<input type="submit" class="button" name="removefilter small" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
439 }
440 print '</div>';
441 print '</form>';
442 print '<br>';
443 print '<br>';
444
445 $sql = "SELECT ba.rowid as bid, ba.label,";
446 $sql .= " b.rowid as transactionid, b.label as transactionlabel, b.datec as datec, b.dateo as date, ";
447 $sql .= " b.amount, b.emetteur, b.num_chq, b.banque,";
448 $sql .= " p.rowid as paymentid, p.ref as paymentref";
449 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
450 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
451 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)";
452 $sql .= " WHERE b.fk_type = '".$db->escape($type)."'";
453 $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
454 $sql .= " AND b.fk_bordereau = 0";
455 $sql .= " AND b.amount > 0";
456 if ($search_date_start) {
457 $sql .= " AND b.dateo >= '".$db->idate($search_date_start)."'";
458 }
459 if ($search_date_end) {
460 $sql .= " AND b.dateo <= '".$db->idate($search_date_end)."'";
461 }
462 if ($filteraccountid > 0) {
463 $sql .= " AND ba.rowid = ".((int) $filteraccountid);
464 }
465 $sql .= $db->order("b.dateo,b.rowid", "ASC");
466
467 $resql = $db->query($sql);
468 if ($resql) {
469 $i = 0;
470 while ($obj = $db->fetch_object($resql)) {
471 $accounts[$obj->bid] = $obj->label;
472 $lines[$obj->bid][$i]["date"] = $db->jdate($obj->datec);
473 $lines[$obj->bid][$i]["amount"] = $obj->amount;
474 $lines[$obj->bid][$i]["emetteur"] = $obj->emetteur;
475 $lines[$obj->bid][$i]["numero"] = $obj->num_chq;
476 $lines[$obj->bid][$i]["banque"] = $obj->banque;
477 $lines[$obj->bid][$i]["id"] = $obj->transactionid;
478 $lines[$obj->bid][$i]["ref"] = $obj->transactionid;
479 $lines[$obj->bid][$i]["label"] = $obj->transactionlabel;
480 $lines[$obj->bid][$i]["paymentid"] = $obj->paymentid;
481 $lines[$obj->bid][$i]["paymentref"] = $obj->paymentref;
482 $lines[$obj->bid][$i]["paymentdate"] = $db->jdate($obj->date);
483 $i++;
484 }
485
486 if ($i == 0) {
487 if ($type == 'CHQ') {
488 print '<div class="opacitymedium">'.$langs->trans("NoWaitingChecks").'</div><br>';
489 } else {
490 print '<div class="opacitymedium">'.$langs->trans("NoWaitingPaymentForDeposit", $labeltype).'</div><br>';
491 }
492 }
493 }
494
495 foreach ($accounts as $bid => $account_label) {
496 print '
497 <script type="text/javascript">
498 jQuery(document).ready(function()
499 {
500 jQuery("#checkall_'.$bid.'").click(function()
501 {
502 jQuery(".checkforremise_'.$bid.'").prop(\'checked\', true);
503 });
504 jQuery("#checknone_'.$bid.'").click(function()
505 {
506 jQuery(".checkforremise_'.$bid.'").prop(\'checked\', false);
507 });
508 });
509 </script>
510 ';
511
512 $num = $db->num_rows($resql);
513
514 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
515 print '<input type="hidden" name="token" value="'.newToken().'">';
516 print '<input type="hidden" name="action" value="create">';
517 print '<input type="hidden" name="type" value="'.$type.'">';
518 print '<input type="hidden" name="accountid" value="'.$bid.'">';
519
520 $moreforfilter = '';
521 print '<div class="div-table-responsive-no-min">';
522 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
523
524 print '<tr class="liste_titre">';
525 print '<td>';
526 if ($type == 'CHQ') {
527 print $langs->trans("DateChequeReceived");
528 } else {
529 print $langs->trans("DatePaymentForDepositReceived", $type);
530 }
531 print '</td>'."\n";
532 print '<td>'.$langs->trans("ChequeNumber")."</td>\n";
533 print '<td>'.$langs->trans("CheckTransmitter")."</td>\n";
534 print '<td>'.$langs->trans("Bank")."</td>\n";
535 print '<td class="right">'.$langs->trans("Amount")."</td>\n";
536 print '<td class="center">'.$langs->trans("Payment")."</td>\n";
537 print '<td class="center">'.$langs->trans("LineRecord")."</td>\n";
538 print '<td class="center">'.$langs->trans("Select")."<br>";
539 if ($conf->use_javascript_ajax) {
540 print '<a href="#" id="checkall_'.$bid.'">'.$langs->trans("All").'</a> / <a href="#" id="checknone_'.$bid.'">'.$langs->trans("None").'</a>';
541 }
542 print '</td>';
543 print "</tr>\n";
544
545 if (count($lines[$bid])) {
546 foreach ($lines[$bid] as $lid => $value) {
547 print '<tr class="oddeven">';
548 print '<td>'.dol_print_date($value["date"], 'day').'</td>';
549 print '<td>'.$value["numero"]."</td>\n";
550 print '<td>'.$value["emetteur"]."</td>\n";
551 print '<td>'.$value["banque"]."</td>\n";
552 print '<td class="right"><span class="amount">'.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).'</span></td>';
553
554 // Link to payment
555 print '<td class="center">';
556 $paymentstatic->id = $value["paymentid"];
557 $paymentstatic->ref = $value["paymentref"];
558 $paymentstatic->date = $value["paymentdate"];
559 if ($paymentstatic->id) {
560 print $paymentstatic->getNomUrl(1);
561 } else {
562 print '&nbsp;';
563 }
564 print '</td>';
565 // Link to bank transaction
566 print '<td class="center">';
567 $accountlinestatic->id = $value["id"];
568 $accountlinestatic->ref = $value["ref"];
569 if ($accountlinestatic->id > 0) {
570 print $accountlinestatic->getNomUrl(1);
571 } else {
572 print '&nbsp;';
573 }
574 print '</td>';
575
576 print '<td class="center">';
577 print '<input id="'.$value["id"].'" class="flat checkforremise_'.$bid.'" checked type="checkbox" name="toRemise[]" value="'.$value["id"].'">';
578 print '</td>';
579 print '</tr>';
580 }
581 }
582 print "</table>";
583 print '</div>';
584
585 print '<div class="tabsAction">';
586 if ($user->hasRight('banque', 'cheque')) {
587 print '<input type="submit" class="button" value="'.$langs->trans('NewCheckDepositOn', $account_label).'">';
588 } else {
589 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('NewCheckDepositOn', $account_label).'</a>';
590 }
591 print '</div><br>';
592 print '</form>';
593 }
594} else {
595 $paymentstatic = new Paiement($db);
596 $accountlinestatic = new AccountLine($db);
597 $accountstatic = new Account($db);
598 $accountstatic->fetch($object->account_id);
599
600 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/paiement/cheque/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
601
602 $morehtmlref = '';
603 $morehtmlleft = '';
604 $moreghtmlright = '';
605
606 $labelval = ($langs->trans("PaymentType".$object->type) != "PaymentType".$object->type ? $langs->trans("PaymentType".$object->type) : $object->type);
607 $morehtmlref = '<br><div class="refidno">'.$langs->trans("Type").' : '.$labelval.'</div>';
608
609 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, $morehtmlleft, '', 0, $moreghtmlright);
610
611
612 print '<div class="fichecenter">';
613 print '<div class="underbanner clearboth"></div>';
614
615 print '<table class="border centpercent">';
616
617 print '<tr><td class="titlefield">';
618
619 print '<table class="nobordernopadding centpercent"><tr><td>';
620 print $langs->trans('Date');
621 print '</td>';
622 if ($action != 'editdate') {
623 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>';
624 }
625 print '</tr></table>';
626
627 print '</td><td>';
628 if ($action == 'editdate') {
629 print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
630 print '<input type="hidden" name="token" value="'.newToken().'">';
631 print '<input type="hidden" name="action" value="setdate">';
632 print $form->selectDate($object->date_bordereau, 'datecreate_', 0, 0, 0, "setdate");
633 print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
634 print '</form>';
635 } else {
636 print $object->date_bordereau ? dol_print_date($object->date_bordereau, 'day') : '&nbsp;';
637 }
638
639 print '</td>';
640 print '</tr>';
641
642 // External ref - Ext ref are not visible field on standard usage
643 if (getDolGlobalString('MAIN_SHOW_EXTREF')) {
644 print '<tr><td>';
645 print '<table class="nobordernopadding" width="100%"><tr><td>';
646 print $langs->trans('RefExt');
647 print '</td>';
648 if ($action != 'editrefext') {
649 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>';
650 }
651 print '</tr></table>';
652 print '</td><td>';
653 if ($action == 'editrefext') {
654 print '<form name="setrefext" 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="setrefext">';
657 print '<input type="text" name="ref_ext" value="'.$object->ref_ext.'">';
658 print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
659 print '</form>';
660 } else {
661 print $object->ref_ext;
662 }
663 print '</td></tr>';
664 }
665
666 print '<tr><td>'.$langs->trans('Account').'</td><td>';
667 print $accountstatic->getNomUrl(1);
668 print '</td></tr>';
669
670 // Number of bank checks
671 print '<tr><td>'.$langs->trans('NbOfCheques').'</td><td>';
672 print $object->nbcheque;
673 print '</td></tr>';
674
675 print '<tr><td>'.$langs->trans('Total').'</td><td>';
676 print '<span class="amount">'.price($object->amount).'</span>';
677 print '</td></tr>';
678
679 print '</table><br>';
680
681 print '</div>';
682
683
684 // List of bank checks
685 $sql = "SELECT b.rowid, b.rowid as ref, b.label, b.amount, b.num_chq, b.emetteur,";
686 $sql .= " b.dateo as date, b.datec as datec, b.banque,";
687 $sql .= " p.rowid as pid, p.ref as pref, ba.rowid as bid, p.statut";
688 $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
689 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)";
690 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
691 $sql .= " WHERE ba.entity IN (".getEntity('bank_account').")";
692 $sql .= " AND b.fk_type= '".$db->escape($object->type)."'";
693 $sql .= " AND b.fk_bordereau = ".((int) $object->id);
694 $sql .= $db->order($sortfield, $sortorder);
695
696 $resql = $db->query($sql);
697 if ($resql) {
698 $num = $db->num_rows($resql);
699
700 print '<div class="div-table-responsive">';
701 print '<table class="noborder centpercent">';
702
703 $param = "&amp;id=".$object->id;
704
705 print '<tr class="liste_titre">';
706 print_liste_field_titre("Cheques", '', '', '', '', 'width="30"');
707 print_liste_field_titre("DateChequeReceived", $_SERVER["PHP_SELF"], "b.dateo,b.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
708 print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "b.num_chq", "", $param, 'align="center"', $sortfield, $sortorder);
709 print_liste_field_titre("CheckTransmitter", $_SERVER["PHP_SELF"], "b.emetteur", "", $param, "", $sortfield, $sortorder);
710 print_liste_field_titre("Bank", $_SERVER["PHP_SELF"], "b.banque", "", $param, "", $sortfield, $sortorder);
711 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "b.amount", "", $param, 'class="right"', $sortfield, $sortorder);
712 print_liste_field_titre("Payment", $_SERVER["PHP_SELF"], "p.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
713 print_liste_field_titre("LineRecord", $_SERVER["PHP_SELF"], "b.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
715 print "</tr>\n";
716
717 $i = 1;
718 if ($num > 0) {
719 while ($objp = $db->fetch_object($resql)) {
720 $paymentstatic->id = $objp->pid;
721 $paymentstatic->ref = $objp->pref;
722
723 $accountlinestatic->id = $objp->rowid;
724 $accountlinestatic->ref = $objp->ref;
725
726 print '<tr class="oddeven">';
727 print '<td class="center">'.$i.'</td>';
728 print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>'; // Operation date
729 print '<td class="center">'.($objp->num_chq ? $objp->num_chq : '&nbsp;').'</td>';
730 print '<td>'.dol_trunc($objp->emetteur, 24).'</td>';
731 print '<td>'.dol_trunc($objp->banque, 24).'</td>';
732 print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
733 // Link to payment
734 print '<td class="center">';
735 if ($paymentstatic->id) {
736 print $paymentstatic->getNomUrl(1);
737 } else {
738 print '&nbsp;';
739 }
740 print '</td>';
741 // Link to bank transaction
742 print '<td class="center">';
743 if ($accountlinestatic->id > 0) {
744 print $accountlinestatic->getNomUrl(1);
745 } else {
746 print '&nbsp;';
747 }
748 print '</td>';
749 // Action button
750 print '<td class="right">';
751 if ($object->statut == 0) {
752 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=remove&token='.newToken().'&lineid='.$objp->rowid.'">'.img_delete().'</a>';
753 }
754 if ($object->statut == 1 && $objp->statut != 2) {
755 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reject_check&token='.newToken().'&lineid='.$objp->rowid.'">'.img_picto($langs->trans("RejectCheck"), 'disable').'</a>';
756 }
757 if ($objp->statut == 2) {
758 print ' &nbsp; '.img_picto($langs->trans('CheckRejected'), 'statut8').'</a>';
759 }
760 print '</td>';
761 print '</tr>';
762
763 $i++;
764 }
765 } else {
766 print '<td colspan="9"><span class="opacitymedium">';
767 print $langs->trans("None");
768 print '</span></td>';
769 }
770
771 print "</table>";
772
773 // Cheque denormalized data nbcheque is similar to real number of bank check
774 if ($num > 0 && $i < ($object->nbcheque + 1)) {
775 // Show warning that some records were removed.
776 $langs->load("errors");
777 print info_admin($langs->trans("WarningSomeBankTransactionByChequeWereRemovedAfter"), 0, 0, 'warning');
778 // TODO Fix data ->nbcheque and ->amount
779 }
780
781 print "</div>";
782 } else {
783 dol_print_error($db);
784 }
785
786 print dol_get_fiche_end();
787}
788
789
790
791
792/*
793 * Actions Buttons
794 */
795
796print '<div class="tabsAction">';
797
798if ($user->socid == 0 && !empty($object->id) && $object->statut == 0 && $user->hasRight('banque', 'cheque')) {
799 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valide&token='.newToken().'&sortfield='.$sortfield.'&sortorder='.$sortorder.'">'.$langs->trans('Validate').'</a>';
800}
801
802if ($user->socid == 0 && !empty($object->id) && $user->hasRight('banque', 'cheque')) {
803 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
804}
805print '</div>';
806
807
808
809if ($action != 'new') {
810 if ($object->statut == 1) {
811 // Documents
812 $objref = dol_sanitizeFileName($object->ref);
813 $filedir = $upload_dir.'/'.$objref;
814 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
815 $genallowed = $usercancreate;
816 $delallowed = $usercandelete;
817 print $formfile->showdocuments('remisecheque', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
818
819 print '<br>';
820 }
821}
822
823// End of page
824llxFooter();
825$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.