dolibarr  13.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-2020 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 require '../../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'compta'));
38 
39 $id = GETPOST('id', 'int');
40 $ref = GETPOST('ref', 'alpha');
41 $action = GETPOST('action', 'aZ09');
42 $confirm = GETPOST('confirm', 'alpha');
43 
44 // Security check
45 $fieldname = (!empty($ref) ? 'ref' : 'rowid');
46 if ($user->socid) $socid = $user->socid;
47 $result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque', '', 'fk_user_author', $fieldname);
48 
49 $sortfield = GETPOST('sortfield', 'aZ09comma');
50 $sortorder = GETPOST('sortorder', 'aZ09comma');
51 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
52 if (!$sortorder) $sortorder = "ASC";
53 if (!$sortfield) $sortfield = "b.dateo,b.rowid";
54 if (empty($page) || $page == -1) { $page = 0; }
55 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
56 $offset = $limit * $page;
57 
58 $dir = $conf->bank->dir_output.'/checkdeposits/';
59 $filterdate = dol_mktime(0, 0, 0, GETPOST('fdmonth'), GETPOST('fdday'), GETPOST('fdyear'));
60 $filteraccountid = GETPOST('accountid', 'int');
61 
62 $object = new RemiseCheque($db);
63 
64 
65 /*
66  * Actions
67  */
68 
69 if ($action == 'setdate' && $user->rights->banque->cheque)
70 {
71  $result = $object->fetch(GETPOST('id', 'int'));
72  if ($result > 0)
73  {
74  //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
75  $date = dol_mktime(0, 0, 0, $_POST['datecreate_month'], $_POST['datecreate_day'], $_POST['datecreate_year']);
76 
77  $result = $object->set_date($user, $date);
78  if ($result < 0)
79  {
80  setEventMessages($object->error, $object->errors, 'errors');
81  }
82  } else {
83  setEventMessages($object->error, $object->errors, 'errors');
84  }
85 }
86 
87 if ($action == 'setrefext' && $user->rights->banque->cheque)
88 {
89  $result = $object->fetch(GETPOST('id', 'int'));
90  if ($result > 0)
91  {
92  $ref_ext = GETPOST('ref_ext');
93 
94  $result = $object->setValueFrom('ref_ext', $ref_ext, '', null, 'text', '', $user, 'CHECKDEPOSIT_MODIFY');
95  if ($result < 0)
96  {
97  setEventMessages($object->error, $object->errors, 'errors');
98  }
99  } else {
100  setEventMessages($object->error, $object->errors, 'errors');
101  }
102 }
103 
104 if ($action == 'setref' && $user->rights->banque->cheque)
105 {
106  $result = $object->fetch(GETPOST('id', 'int'));
107  if ($result > 0)
108  {
109  $ref = GETPOST('ref');
110 
111  $result = $object->set_number($user, $ref);
112  if ($result < 0)
113  {
114  setEventMessages($object->error, $object->errors, 'errors');
115  }
116  } else {
117  setEventMessages($object->error, $object->errors, 'errors');
118  }
119 }
120 
121 if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->cheque)
122 {
123  if (is_array($_POST['toRemise']))
124  {
125  $result = $object->create($user, $_POST["accountid"], 0, $_POST['toRemise']);
126  if ($result > 0)
127  {
128  if ($object->statut == 1) // If statut is validated, we build doc
129  {
130  $object->fetch($object->id); // To force to reload all properties in correct property name
131  // Define output language
132  $outputlangs = $langs;
133  $newlang = '';
134  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id'];
135  //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
136  if (!empty($newlang))
137  {
138  $outputlangs = new Translate("", $conf);
139  $outputlangs->setDefaultLang($newlang);
140  }
141  $result = $object->generatePdf($_POST["model"], $outputlangs);
142  }
143 
144  header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
145  exit;
146  } else {
147  setEventMessages($object->error, $object->errors, 'errors');
148  }
149  } else {
150  setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'mesgs');
151  $action = 'new';
152  }
153 }
154 
155 if ($action == 'remove' && $id > 0 && GETPOST("lineid", 'int') > 0 && $user->rights->banque->cheque)
156 {
157  $object->id = $id;
158  $result = $object->removeCheck(GETPOST("lineid", "int"));
159  if ($result === 0)
160  {
161  header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
162  exit;
163  } else {
164  setEventMessages($object->error, $object->errors, 'errors');
165  }
166 }
167 
168 if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->cheque)
169 {
170  $object->id = $id;
171  $result = $object->delete();
172  if ($result == 0)
173  {
174  header("Location: index.php");
175  exit;
176  } else {
177  setEventMessages($paiement->error, $paiement->errors, 'errors');
178  }
179 }
180 
181 if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->banque->cheque)
182 {
183  $result = $object->fetch($id);
184  $result = $object->validate($user);
185  if ($result >= 0)
186  {
187  // Define output language
188  $outputlangs = $langs;
189  $newlang = '';
190  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id'];
191  //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
192  if (!empty($newlang))
193  {
194  $outputlangs = new Translate("", $conf);
195  $outputlangs->setDefaultLang($newlang);
196  }
197  $result = $object->generatePdf(GETPOST('model'), $outputlangs);
198 
199  header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
200  exit;
201  } else {
202  setEventMessages($object->error, $object->errors, 'errors');
203  }
204 }
205 
206 if ($action == 'confirm_reject_check' && $confirm == 'yes' && $user->rights->banque->cheque)
207 {
208  $reject_date = dol_mktime(0, 0, 0, GETPOST('rejectdate_month'), GETPOST('rejectdate_day'), GETPOST('rejectdate_year'));
209  $rejected_check = GETPOST('bankid', 'int');
210 
211  $object->fetch($id);
212  $paiement_id = $object->rejectCheck($rejected_check, $reject_date);
213  if ($paiement_id > 0)
214  {
215  setEventMessages($langs->trans("CheckRejectedAndInvoicesReopened"), null, 'mesgs');
216  //header("Location: ".DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id);
217  //exit;
218  $action = '';
219  } else {
220  setEventMessages($object->error, $object->errors, 'errors');
221  $action = '';
222  }
223 }
224 
225 if ($action == 'builddoc' && $user->rights->banque->cheque)
226 {
227  $result = $object->fetch($id);
228 
229  // Save last template used to generate document
230  //if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
231 
232  $outputlangs = $langs;
233  $newlang = '';
234  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id'];
235  //if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
236  if (!empty($newlang))
237  {
238  $outputlangs = new Translate("", $conf);
239  $outputlangs->setDefaultLang($newlang);
240  }
241  $result = $object->generatePdf($_POST["model"], $outputlangs);
242  if ($result <= 0)
243  {
244  dol_print_error($db, $object->error);
245  exit;
246  } else {
247  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc'));
248  exit;
249  }
250 } // Remove file in doc form
251 elseif ($action == 'remove_file' && $user->rights->banque->cheque)
252 {
253  if ($object->fetch($id) > 0)
254  {
255  include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
256 
257  $langs->load("other");
258 
259  $file = $dir.get_exdir($object->ref, 0, 1, 0, $object, 'cheque').GETPOST('file');
260  $ret = dol_delete_file($file, 0, 0, 0, $object);
261  if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
262  else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
263  }
264 }
265 
266 
267 /*
268  * View
269  */
270 
271 if (GETPOST('removefilter'))
272 {
273  $filterdate = '';
274  $filteraccountid = 0;
275 }
276 
277 $title = $langs->trans("Cheques")." - ".$langs->trans("Card");
278 $helpurl = "";
279 llxHeader("", $title, $helpurl);
280 
281 $form = new Form($db);
282 $formfile = new FormFile($db);
283 
284 
285 if ($action == 'new')
286 {
287  $head = array();
288  $h = 0;
289  $head[$h][0] = $_SERVER["PHP_SELF"].'?action=new';
290  $head[$h][1] = $langs->trans("MenuChequeDeposits");
291  $hselected = $h;
292  $h++;
293 
294  print load_fiche_titre($langs->trans("Cheques"), '', 'bank_account');
295 } else {
296  $result = $object->fetch($id, $ref);
297  if ($result < 0)
298  {
299  dol_print_error($db, $object->error);
300  exit;
301  }
302 
303  $h = 0;
304  $head[$h][0] = $_SERVER["PHP_SELF"].'?id='.$object->id;
305  $head[$h][1] = $langs->trans("CheckReceipt");
306  $hselected = $h;
307  $h++;
308  // $head[$h][0] = DOL_URL_ROOT.'/compta/paiement/cheque/info.php?id='.$object->id;
309  // $head[$h][1] = $langs->trans("Info");
310  // $h++;
311 
312  print dol_get_fiche_head($head, $hselected, $langs->trans("Cheques"), -1, 'payment');
313 
314  /*
315  * Confirmation of slip's delete
316  */
317  if ($action == 'delete')
318  {
319  print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("DeleteCheckReceipt"), $langs->trans("ConfirmDeleteCheckReceipt"), 'confirm_delete', '', '', 1);
320  }
321 
322  /*
323  * Confirmation of slip's validation
324  */
325  if ($action == 'valide')
326  {
327  print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_validate', '', '', 1);
328  }
329 
330  /*
331  * Confirm check rejection
332  */
333  if ($action == 'reject_check')
334  {
335  $formquestion = array(
336  array('type' => 'hidden', 'name' => 'bankid', 'value' => GETPOST('lineid', 'int')),
337  array('type' => 'date', 'name' => 'rejectdate_', 'label' => $langs->trans("RejectCheckDate"), 'value' => dol_now())
338  );
339  print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("RejectCheck"), $langs->trans("ConfirmRejectCheck"), 'confirm_reject_check', $formquestion, '', 1);
340  }
341 }
342 
343 $accounts = array();
344 
345 if ($action == 'new')
346 {
347  $paymentstatic = new Paiement($db);
348  $accountlinestatic = new AccountLine($db);
349 
350  $lines = array();
351 
352  $now = dol_now();
353 
354  print '<span class="opacitymedium">'.$langs->trans("SelectChequeTransactionAndGenerate").'</span><br><br>'."\n";
355 
356  print '<form class="nocellnopadd" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
357  print '<input type="hidden" name="token" value="'.newToken().'">';
358  print '<input type="hidden" name="action" value="new">';
359 
361 
362  print '<table class="border centpercent">';
363  //print '<tr><td width="30%">'.$langs->trans('Date').'</td><td width="70%">'.dol_print_date($now,'day').'</td></tr>';
364  // Filter
365  print '<tr><td class="titlefieldcreate">'.$langs->trans("DateChequeReceived").'</td><td>';
366  print $form->selectDate($filterdate, 'fd', 0, 0, 1, '', 1, 1);
367  print '</td></tr>';
368  print '<tr><td>'.$langs->trans("BankAccount").'</td><td>';
369  $form->select_comptes($filteraccountid, 'accountid', 0, 'courant <> 2', 1);
370  print '</td></tr>';
371  print '</table>';
372 
374 
375  print '<div class="center">';
376  print '<input type="submit" class="button" name="filter" value="'.dol_escape_htmltag($langs->trans("ToFilter")).'">';
377  if ($filterdate || $filteraccountid > 0)
378  {
379  print ' &nbsp; ';
380  print '<input type="submit" class="button" name="removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
381  }
382  print '</div>';
383  print '</form>';
384  print '<br>';
385 
386  $sql = "SELECT ba.rowid as bid, ba.label,";
387  $sql .= " b.rowid as transactionid, b.label as transactionlabel, b.datec as datec, b.dateo as date, ";
388  $sql .= " b.amount, b.emetteur, b.num_chq, b.banque,";
389  $sql .= " p.rowid as paymentid, p.ref as paymentref";
390  $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
391  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
392  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)";
393  $sql .= " WHERE b.fk_type = 'CHQ'";
394  $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
395  $sql .= " AND b.fk_bordereau = 0";
396  $sql .= " AND b.amount > 0";
397  if ($filterdate) $sql .= " AND b.dateo = '".$db->idate($filterdate)."'";
398  if ($filteraccountid > 0) $sql .= " AND ba.rowid = ".((int) $filteraccountid);
399  $sql .= $db->order("b.dateo,b.rowid", "ASC");
400 
401  $resql = $db->query($sql);
402  if ($resql)
403  {
404  $i = 0;
405  while ($obj = $db->fetch_object($resql))
406  {
407  $accounts[$obj->bid] = $obj->label;
408  $lines[$obj->bid][$i]["date"] = $db->jdate($obj->date);
409  $lines[$obj->bid][$i]["amount"] = $obj->amount;
410  $lines[$obj->bid][$i]["emetteur"] = $obj->emetteur;
411  $lines[$obj->bid][$i]["numero"] = $obj->num_chq;
412  $lines[$obj->bid][$i]["banque"] = $obj->banque;
413  $lines[$obj->bid][$i]["id"] = $obj->transactionid;
414  $lines[$obj->bid][$i]["ref"] = $obj->transactionid;
415  $lines[$obj->bid][$i]["label"] = $obj->transactionlabel;
416  $lines[$obj->bid][$i]["paymentid"] = $obj->paymentid;
417  $lines[$obj->bid][$i]["paymentref"] = $obj->paymentref;
418  $i++;
419  }
420 
421  if ($i == 0)
422  {
423  print '<div class="opacitymedium">'.$langs->trans("NoWaitingChecks").'</div><br>';
424  }
425  }
426 
427  foreach ($accounts as $bid => $account_label)
428  {
429  print '
430  <script language="javascript" type="text/javascript">
431  jQuery(document).ready(function()
432  {
433  jQuery("#checkall_'.$bid.'").click(function()
434  {
435  jQuery(".checkforremise_'.$bid.'").prop(\'checked\', true);
436  });
437  jQuery("#checknone_'.$bid.'").click(function()
438  {
439  jQuery(".checkforremise_'.$bid.'").prop(\'checked\', false);
440  });
441  });
442  </script>
443  ';
444 
445  $num = $db->num_rows($resql);
446  print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
447  print '<input type="hidden" name="token" value="'.newToken().'">';
448  print '<input type="hidden" name="action" value="create">';
449  print '<input type="hidden" name="accountid" value="'.$bid.'">';
450 
451  $moreforfilter = '';
452  print '<div class="div-table-responsive-no-min">';
453  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
454 
455  print '<tr class="liste_titre">';
456  print '<td>'.$langs->trans("DateChequeReceived").'</td>'."\n";
457  print '<td>'.$langs->trans("ChequeNumber")."</td>\n";
458  print '<td>'.$langs->trans("CheckTransmitter")."</td>\n";
459  print '<td>'.$langs->trans("Bank")."</td>\n";
460  print '<td>'.$langs->trans("Amount")."</td>\n";
461  print '<td class="center">'.$langs->trans("Payment")."</td>\n";
462  print '<td class="center">'.$langs->trans("LineRecord")."</td>\n";
463  print '<td class="center">'.$langs->trans("Select")."<br>";
464  if ($conf->use_javascript_ajax) print '<a href="#" id="checkall_'.$bid.'">'.$langs->trans("All").'</a> / <a href="#" id="checknone_'.$bid.'">'.$langs->trans("None").'</a>';
465  print '</td>';
466  print "</tr>\n";
467 
468  if (count($lines[$bid]))
469  {
470  foreach ($lines[$bid] as $lid => $value)
471  {
472  //$account_id = $bid; FIXME not used
473 
474  // FIXME $accounts[$bid] is a label !
475  /*if (! isset($accounts[$bid]))
476  $accounts[$bid]=0;
477  $accounts[$bid] += 1;*/
478 
479  print '<tr class="oddeven">';
480  print '<td>'.dol_print_date($value["date"], 'day').'</td>';
481  print '<td>'.$value["numero"]."</td>\n";
482  print '<td>'.$value["emetteur"]."</td>\n";
483  print '<td>'.$value["banque"]."</td>\n";
484  print '<td class="right">'.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).'</td>';
485 
486  // Link to payment
487  print '<td class="center">';
488  $paymentstatic->id = $value["paymentid"];
489  $paymentstatic->ref = $value["paymentref"];
490  if ($paymentstatic->id)
491  {
492  print $paymentstatic->getNomUrl(1);
493  } else {
494  print '&nbsp;';
495  }
496  print '</td>';
497  // Link to bank transaction
498  print '<td class="center">';
499  $accountlinestatic->id = $value["id"];
500  $accountlinestatic->ref = $value["ref"];
501  if ($accountlinestatic->id > 0) {
502  print $accountlinestatic->getNomUrl(1);
503  } else {
504  print '&nbsp;';
505  }
506  print '</td>';
507 
508  print '<td class="center">';
509  print '<input id="'.$value["id"].'" class="flat checkforremise_'.$bid.'" checked type="checkbox" name="toRemise[]" value="'.$value["id"].'">';
510  print '</td>';
511  print '</tr>';
512 
513  $i++;
514  }
515  }
516  print "</table>";
517  print '</div>';
518 
519  print '<div class="tabsAction">';
520  if ($user->rights->banque->cheque)
521  {
522  print '<input type="submit" class="button" value="'.$langs->trans('NewCheckDepositOn', $account_label).'">';
523  } else {
524  print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('NewCheckDepositOn', $account_label).'</a>';
525  }
526  print '</div><br>';
527  print '</form>';
528  }
529 } else {
530  $paymentstatic = new Paiement($db);
531  $accountlinestatic = new AccountLine($db);
532  $accountstatic = new Account($db);
533  $accountstatic->fetch($object->account_id);
534 
535  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/paiement/cheque/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
536 
537  $morehtmlref = '';
538  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
539 
540 
541  print '<div class="fichecenter">';
542  print '<div class="underbanner clearboth"></div>';
543 
544 
545  print '<table class="border centpercent">';
546 
547  print '<tr><td class="titlefield">';
548 
549  print '<table class="nobordernopadding" width="100%"><tr><td>';
550  print $langs->trans('Date');
551  print '</td>';
552  if ($action != 'editdate') print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>';
553  print '</tr></table>';
554  print '</td><td colspan="2">';
555  if ($action == 'editdate')
556  {
557  print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
558  print '<input type="hidden" name="token" value="'.newToken().'">';
559  print '<input type="hidden" name="action" value="setdate">';
560  print $form->selectDate($object->date_bordereau, 'datecreate_', '', '', '', "setdate");
561  print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
562  print '</form>';
563  } else {
564  print $object->date_bordereau ? dol_print_date($object->date_bordereau, 'day') : '&nbsp;';
565  }
566 
567  print '</td>';
568  print '</tr>';
569 
570  // External ref
571  /* Ext ref are not visible field on standard usage
572  print '<tr><td>';
573 
574  print '<table class="nobordernopadding" width="100%"><tr><td>';
575  print $langs->trans('RefExt');
576  print '</td>';
577  if ($action != 'editrefext') print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editrefext&amp;id='.$object->id.'">'.img_edit($langs->trans('SetRefExt'),1).'</a></td>';
578  print '</tr></table>';
579  print '</td><td colspan="2">';
580  if ($action == 'editrefext')
581  {
582  print '<form name="setrefext" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
583  print '<input type="hidden" name="token" value="'.newToken().'">';
584  print '<input type="hidden" name="action" value="setrefext">';
585  print '<input type="text" name="ref_ext" value="'.$object->ref_ext.'">';
586  print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
587  print '</form>';
588  }
589  else
590  {
591  print $object->ref_ext;
592  }
593 
594  print '</td>';
595  print '</tr>';
596  */
597 
598  print '<tr><td>'.$langs->trans('Account').'</td><td colspan="2">';
599  print $accountstatic->getNomUrl(1);
600  print '</td></tr>';
601 
602  // Number of bank checks
603  print '<tr><td>'.$langs->trans('NbOfCheques').'</td><td colspan="2">';
604  print $object->nbcheque;
605  print '</td></tr>';
606 
607  print '<tr><td>'.$langs->trans('Total').'</td><td colspan="2">';
608  print price($object->amount);
609  print '</td></tr>';
610 
611  /*print '<tr><td>'.$langs->trans('Status').'</td><td colspan="2">';
612  print $object->getLibStatut(4);
613  print '</td></tr>';*/
614 
615  print '</table><br>';
616 
617  print '</div>';
618 
619 
620  // List of bank checks
621  $sql = "SELECT b.rowid, b.rowid as ref, b.label, b.amount, b.num_chq, b.emetteur,";
622  $sql .= " b.dateo as date, b.datec as datec, b.banque,";
623  $sql .= " p.rowid as pid, p.ref as pref, ba.rowid as bid, p.statut";
624  $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
625  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)";
626  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
627  $sql .= " WHERE ba.entity IN (".getEntity('bank_account').")";
628  $sql .= " AND b.fk_type= 'CHQ'";
629  $sql .= " AND b.fk_bordereau = ".$object->id;
630  $sql .= $db->order($sortfield, $sortorder);
631 
632  $resql = $db->query($sql);
633  if ($resql)
634  {
635  $num = $db->num_rows($resql);
636 
637  print '<div class="div-table-responsive">';
638  print '<table class="noborder centpercent">';
639 
640  $param = "&amp;id=".$object->id;
641 
642  print '<tr class="liste_titre">';
643  print_liste_field_titre("Cheques", '', '', '', '', 'width="30"');
644  print_liste_field_titre("DateChequeReceived", $_SERVER["PHP_SELF"], "b.dateo,b.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
645  print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "b.num_chq", "", $param, 'align="center"', $sortfield, $sortorder);
646  print_liste_field_titre("CheckTransmitter", $_SERVER["PHP_SELF"], "b.emetteur", "", $param, "", $sortfield, $sortorder);
647  print_liste_field_titre("Bank", $_SERVER["PHP_SELF"], "b.banque", "", $param, "", $sortfield, $sortorder);
648  print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "b.amount", "", $param, 'class="right"', $sortfield, $sortorder);
649  print_liste_field_titre("Payment", $_SERVER["PHP_SELF"], "p.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
650  print_liste_field_titre("LineRecord", $_SERVER["PHP_SELF"], "b.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
652  print "</tr>\n";
653 
654  $i = 1;
655  if ($num > 0)
656  {
657  while ($objp = $db->fetch_object($resql))
658  {
659  print '<tr class="oddeven">';
660  print '<td class="center">'.$i.'</td>';
661  print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>'; // Operation date
662  print '<td class="center">'.($objp->num_chq ? $objp->num_chq : '&nbsp;').'</td>';
663  print '<td>'.dol_trunc($objp->emetteur, 24).'</td>';
664  print '<td>'.dol_trunc($objp->banque, 24).'</td>';
665  print '<td class="right">'.price($objp->amount).'</td>';
666  // Link to payment
667  print '<td class="center">';
668  $paymentstatic->id = $objp->pid;
669  $paymentstatic->ref = $objp->pref;
670  if ($paymentstatic->id) {
671  print $paymentstatic->getNomUrl(1);
672  } else {
673  print '&nbsp;';
674  }
675  print '</td>';
676  // Link to bank transaction
677  print '<td class="center">';
678  $accountlinestatic->id = $objp->rowid;
679  $accountlinestatic->ref = $objp->ref;
680  if ($accountlinestatic->id > 0) {
681  print $accountlinestatic->getNomUrl(1);
682  } else {
683  print '&nbsp;';
684  }
685  print '</td>';
686  // Action button
687  print '<td class="right">';
688  if ($object->statut == 0)
689  {
690  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=remove&amp;lineid='.$objp->rowid.'">'.img_delete().'</a>';
691  }
692  if ($object->statut == 1 && $objp->statut != 2)
693  {
694  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reject_check&amp;lineid='.$objp->rowid.'">'.img_picto($langs->trans("RejectCheck"), 'disable').'</a>';
695  }
696  if ($objp->statut == 2)
697  {
698  print ' &nbsp; '.img_picto($langs->trans('CheckRejected'), 'statut8').'</a>';
699  }
700  print '</td>';
701  print '</tr>';
702 
703  $i++;
704  }
705  } else {
706  print '<td colspan="8" class="opacitymedium">';
707  print $langs->trans("None");
708  print '</td>';
709  }
710 
711  print "</table>";
712 
713  // Cheque denormalized data nbcheque is similar to real number of bank check
714  if ($num > 0 && $i < ($object->nbcheque + 1)) {
715  // Show warning that some records were removed.
716  $langs->load("errors");
717  print info_admin($langs->trans("WarningSomeBankTransactionByChequeWereRemovedAfter"), 0, 0, 'warning');
718  // TODO Fix data ->nbcheque and ->amount
719  }
720 
721  print "</div>";
722  } else {
723  dol_print_error($db);
724  }
725 
726  print dol_get_fiche_end();
727 }
728 
729 
730 
731 
732 /*
733  * Actions Buttons
734  */
735 
736 print '<div class="tabsAction">';
737 
738 if ($user->socid == 0 && !empty($object->id) && $object->statut == 0 && $user->rights->banque->cheque)
739 {
740  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=valide&amp;token='.newToken().'&amp;sortfield='.$sortfield.'&amp;sortorder='.$sortorder.'">'.$langs->trans('Validate').'</a>';
741 }
742 
743 if ($user->socid == 0 && !empty($object->id) && $user->rights->banque->cheque)
744 {
745  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'&amp;sortfield='.$sortfield.'&amp;sortorder='.$sortorder.'">'.$langs->trans('Delete').'</a>';
746 }
747 print '</div>';
748 
749 
750 
751 if ($action != 'new')
752 {
753  if ($object->statut == 1)
754  {
755  $filename = dol_sanitizeFileName($object->ref);
756  $filedir = $dir.get_exdir($object->ref, 0, 1, 0, $object, 'checkdeposits');
757  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
758 
759  print $formfile->showdocuments('remisecheque', $filename, $filedir, $urlsource, 1, 1);
760 
761  print '<br>';
762  }
763 }
764 
765 // End of page
766 llxFooter();
767 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_now($mode= 'auto')
Return date for now.
Class to manage bank transaction lines.
Class to manage bank accounts.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
Class to manage payments of customer invoices.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
Definition: files.lib.php:1144
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class to offer components to list and upload files.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
Class to manage cheque delivery receipts.