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