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