dolibarr  9.0.0
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
6  * Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
28 require '../../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array('banks', 'categories', 'bills'));
36 
37 // Security check
38 if ($user->societe_id) $socid=$user->societe_id;
39 $result = restrictedArea($user, 'banque', '','');
40 
41 $search_ref = GETPOST('search_ref','alpha');
42 $search_account = GETPOST('search_account','int');
43 $search_amount = GETPOST('search_amount','alpha');
44 
45 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
46 $sortfield = GETPOST("sortfield",'alpha');
47 $sortorder = GETPOST("sortorder",'alpha');
48 $page = GETPOST("page",'int');
49 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
50 $offset = $limit * $page;
51 $pageprev = $page - 1;
52 $pagenext = $page + 1;
53 if (! $sortorder) $sortorder="DESC";
54 if (! $sortfield) $sortfield="dp";
55 
56 $year=GETPOST("year");
57 $month=GETPOST("month");
58 
59 $form=new Form($db);
60 $formother = new FormOther($db);
61 $checkdepositstatic=new RemiseCheque($db);
62 $accountstatic=new Account($db);
63 
64 
65 /*
66  * Actions
67  */
68 
69 // If click on purge search criteria ?
70 if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
71 {
72  $search_ref='';
73  $search_amount='';
74  $search_account='';
75  $year='';
76  $month='';
77 }
78 
79 
80 
81 /*
82  * View
83  */
84 
85 llxHeader('',$langs->trans("ChequesReceipts"));
86 
87 $sql = "SELECT bc.rowid, bc.ref as ref, bc.date_bordereau as dp,";
88 $sql.= " bc.nbcheque, bc.amount, bc.statut,";
89 $sql.= " ba.rowid as bid, ba.label";
90 $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc,";
91 $sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
92 $sql.= " WHERE bc.fk_bank_account = ba.rowid";
93 $sql.= " AND bc.entity = ".$conf->entity;
94 
95 // Search criteria
96 if ($search_ref) $sql.=natural_search("bc.ref",$search_ref);
97 if ($search_account > 0) $sql.=" AND bc.fk_bank_account=".$search_account;
98 if ($search_amount) $sql.=natural_search("bc.amount", price2num($search_amount));
99 if ($month > 0)
100 {
101  if ($year > 0 && empty($day))
102  $sql.= " AND bc.date_bordereau BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
103  else if ($year > 0 && ! empty($day))
104  $sql.= " AND bc.date_bordereau BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
105  else
106  $sql.= " AND date_format(bc.date_bordereau, '%m') = '".$month."'";
107 }
108 else if ($year > 0)
109 {
110  $sql.= " AND bc.date_bordereau BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
111 }
112 $sql.= $db->order($sortfield,$sortorder);
113 
114 $nbtotalofrecords = '';
115 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
116 {
117  $result = $db->query($sql);
118  $nbtotalofrecords = $db->num_rows($result);
119  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
120  {
121  $page = 0;
122  $offset = 0;
123  }
124 }
125 
126 $sql.= $db->plimit($limit+1, $offset);
127 //print "$sql";
128 
129 $resql = $db->query($sql);
130 if ($resql)
131 {
132  $num = $db->num_rows($resql);
133  $i = 0;
134  $param='';
135  if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
136  if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
137 
138  $newcardbutton='';
139  if ($user->rights->banque->cheque)
140  {
141  $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new"><span class="valignmiddle">'.$langs->trans('NewCheckDeposit').'</span>';
142  $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
143  $newcardbutton.= '</a>';
144  }
145 
146  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
147  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
148  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
149  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
150  print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">';
151  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
152  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
153  print '<input type="hidden" name="page" value="'.$page.'">';
154 
155  print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_bank.png', 0, $newcardbutton, '', $limit);
156 
157  $moreforfilter='';
158 
159  print '<div class="div-table-responsive">';
160  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
161 
162  // Lignes des champs de filtre
163  print '<tr class="liste_titre">';
164  print '<td class="liste_titre" align="left">';
165  print '<input class="flat" type="text" size="4" name="search_ref" value="'.$search_ref.'">';
166  print '</td>';
167  print '<td class="liste_titre" align="center">';
168  if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
169  print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
170  $formother->select_year($year?$year:-1,'year',1, 20, 5);
171  print '</td>';
172  print '<td class="liste_titre">';
173  $form->select_comptes($search_account,'search_account',0,'',1);
174  print '</td>';
175  print '<td class="liste_titre">&nbsp;</td>';
176  print '<td class="liste_titre" align="right">';
177  print '<input class="flat maxwidth50" type="text" name="search_amount" value="'.$search_amount.'">';
178  print '</td>';
179  print '<td class="liste_titre"></td>';
180  print '<td class="liste_titre" align="right">';
181  $searchpicto=$form->showFilterAndCheckAddButtons(0);
182  print $searchpicto;
183  print '</td>';
184  print "</tr>\n";
185 
186  print '<tr class="liste_titre">';
187  print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"bc.ref","",$param,"",$sortfield,$sortorder);
188  print_liste_field_titre("DateCreation",$_SERVER["PHP_SELF"],"dp","",$param,'align="center"',$sortfield,$sortorder);
189  print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
190  print_liste_field_titre("NbOfCheques",$_SERVER["PHP_SELF"],"bc.nbcheque","",$param,'align="right"',$sortfield,$sortorder);
191  print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"bc.amount","",$param,'align="right"',$sortfield,$sortorder);
192  print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"bc.statut","",$param,'align="right"',$sortfield,$sortorder);
194  print "</tr>\n";
195 
196  if ($num > 0)
197  {
198  while ($i < min($num,$limit))
199  {
200  $objp = $db->fetch_object($resql);
201 
202  print '<tr class="oddeven">';
203 
204  // Num ref cheque
205  print '<td>';
206  $checkdepositstatic->id=$objp->rowid;
207  $checkdepositstatic->ref=($objp->ref?$objp->ref:$objp->rowid);
208  $checkdepositstatic->statut=$objp->statut;
209  print $checkdepositstatic->getNomUrl(1);
210  print '</td>';
211 
212  // Date
213  print '<td align="center">'.dol_print_date($db->jdate($objp->dp),'day').'</td>'; // TODO Use date hour
214 
215  // Bank
216  print '<td>';
217  if ($objp->bid) print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.'</a>';
218  else print '&nbsp;';
219  print '</td>';
220 
221  // Number of cheques
222  print '<td align="right">'.$objp->nbcheque.'</td>';
223 
224  // Amount
225  print '<td align="right">'.price($objp->amount).'</td>';
226 
227  // Statut
228  print '<td align="right">';
229  print $checkdepositstatic->LibStatut($objp->statut,5);
230  print '</td>';
231 
232  print '<td></td>';
233 
234  print "</tr>\n";
235  $i++;
236  }
237  }
238  else
239  {
240  print '<tr class="oddeven">';
241  print '<td colspan="7" class="opacitymedium">'.$langs->trans("None")."</td>";
242  print '</tr>';
243  }
244  print "</table>";
245  print "</div>";
246  print "</form>\n";
247 }
248 else
249 {
250  dol_print_error($db);
251 }
252 
253 // End of page
254 llxFooter();
255 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
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
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...
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:453
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.
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
Classe permettant la generation de composants html autre Only common components are here...
llxHeader()
Empty header.
Definition: wrapper.php:44
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:467
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.
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
Class to manage cheque delivery receipts.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)