dolibarr  7.0.0-beta
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@capnetworks.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 $langs->load("banks");
35 $langs->load("categories");
36 $langs->load("bills");
37 
38 // Security check
39 if ($user->societe_id) $socid=$user->societe_id;
40 $result = restrictedArea($user, 'banque', '','');
41 
42 $search_ref = GETPOST('search_ref','alpha');
43 $search_account = GETPOST('search_account','int');
44 $search_amount = GETPOST('search_amount','alpha');
45 
46 $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
47 $sortfield = GETPOST("sortfield",'alpha');
48 $sortorder = GETPOST("sortorder",'alpha');
49 $page = GETPOST("page",'int');
50 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
51 $offset = $limit * $page;
52 $pageprev = $page - 1;
53 $pagenext = $page + 1;
54 if (! $sortorder) $sortorder="DESC";
55 if (! $sortfield) $sortfield="dp";
56 
57 $year=GETPOST("year");
58 $month=GETPOST("month");
59 
60 $form=new Form($db);
61 $formother = new FormOther($db);
62 $checkdepositstatic=new RemiseCheque($db);
63 $accountstatic=new Account($db);
64 
65 
66 /*
67  * Actions
68  */
69 
70 // If click on purge search criteria ?
71 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
72 {
73  $search_ref='';
74  $search_amount='';
75  $search_account='';
76  $year='';
77  $month='';
78 }
79 
80 
81 
82 /*
83  * View
84  */
85 
86 llxHeader('',$langs->trans("ChequesReceipts"));
87 
88 $sql = "SELECT bc.rowid, bc.ref as ref, bc.date_bordereau as dp,";
89 $sql.= " bc.nbcheque, bc.amount, bc.statut,";
90 $sql.= " ba.rowid as bid, ba.label";
91 $sql.= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc,";
92 $sql.= " ".MAIN_DB_PREFIX."bank_account as ba";
93 $sql.= " WHERE bc.fk_bank_account = ba.rowid";
94 $sql.= " AND bc.entity = ".$conf->entity;
95 
96 // Search criteria
97 if ($search_ref) $sql.=natural_search("bc.ref",$search_ref);
98 if ($search_account > 0) $sql.=" AND bc.fk_bank_account=".$search_account;
99 if ($search_amount) $sql.=natural_search("bc.amount", price2num($search_amount));
100 if ($month > 0)
101 {
102  if ($year > 0 && empty($day))
103  $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))."'";
104  else if ($year > 0 && ! empty($day))
105  $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))."'";
106  else
107  $sql.= " AND date_format(bc.date_bordereau, '%m') = '".$month."'";
108 }
109 else if ($year > 0)
110 {
111  $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))."'";
112 }
113 $sql.= $db->order($sortfield,$sortorder);
114 
115 $nbtotalofrecords = '';
116 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
117 {
118  $result = $db->query($sql);
119  $nbtotalofrecords = $db->num_rows($result);
120 }
121 
122 $sql.= $db->plimit($limit+1, $offset);
123 //print "$sql";
124 
125 $resql = $db->query($sql);
126 if ($resql)
127 {
128  $num = $db->num_rows($resql);
129  $i = 0;
130  $param='';
131  if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
132  if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
133 
134  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
135  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
136  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
137  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
138  print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">';
139  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
140  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
141  print '<input type="hidden" name="page" value="'.$page.'">';
142 
143  print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_bank.png', '', '', $limit);
144 
145  $moreforfilter='';
146 
147  print '<div class="div-table-responsive">';
148  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
149 
150  // Lignes des champs de filtre
151  print '<tr class="liste_titre">';
152  print '<td class="liste_titre" align="left">';
153  print '<input class="flat" type="text" size="4" name="search_ref" value="'.$search_ref.'">';
154  print '</td>';
155  print '<td class="liste_titre" align="center">';
156  if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
157  print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
158  $formother->select_year($year?$year:-1,'year',1, 20, 5);
159  print '</td>';
160  print '<td class="liste_titre">';
161  $form->select_comptes($search_account,'search_account',0,'',1);
162  print '</td>';
163  print '<td class="liste_titre">&nbsp;</td>';
164  print '<td class="liste_titre" align="right">';
165  print '<input class="flat maxwidth50" type="text" name="search_amount" value="'.$search_amount.'">';
166  print '</td>';
167  print '<td class="liste_titre"></td>';
168  print '<td class="liste_titre" align="right">';
169  $searchpicto=$form->showFilterAndCheckAddButtons(0);
170  print $searchpicto;
171  print '</td>';
172  print "</tr>\n";
173 
174  print '<tr class="liste_titre">';
175  print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"bc.ref","",$param,"",$sortfield,$sortorder);
176  print_liste_field_titre("DateCreation",$_SERVER["PHP_SELF"],"dp","",$param,'align="center"',$sortfield,$sortorder);
177  print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
178  print_liste_field_titre("NbOfCheques",$_SERVER["PHP_SELF"],"bc.nbcheque","",$param,'align="right"',$sortfield,$sortorder);
179  print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"bc.amount","",$param,'align="right"',$sortfield,$sortorder);
180  print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"bc.statut","",$param,'align="right"',$sortfield,$sortorder);
182  print "</tr>\n";
183 
184  if ($num > 0)
185  {
186  $var=true;
187  while ($i < min($num,$limit))
188  {
189  $objp = $db->fetch_object($resql);
190 
191  print '<tr class="oddeven">';
192 
193  // Num ref cheque
194  print '<td>';
195  $checkdepositstatic->id=$objp->rowid;
196  $checkdepositstatic->ref=($objp->ref?$objp->ref:$objp->rowid);
197  $checkdepositstatic->statut=$objp->statut;
198  print $checkdepositstatic->getNomUrl(1);
199  print '</td>';
200 
201  // Date
202  print '<td align="center">'.dol_print_date($db->jdate($objp->dp),'day').'</td>'; // TODO Use date hour
203 
204  // Bank
205  print '<td>';
206  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>';
207  else print '&nbsp;';
208  print '</td>';
209 
210  // Number of cheques
211  print '<td align="right">'.$objp->nbcheque.'</td>';
212 
213  // Amount
214  print '<td align="right">'.price($objp->amount).'</td>';
215 
216  // Statut
217  print '<td align="right">';
218  print $checkdepositstatic->LibStatut($objp->statut,5);
219  print '</td>';
220 
221  print '<td></td>';
222 
223  print "</tr>\n";
224  $i++;
225  }
226  }
227  else
228  {
229  print '<tr class="oddeven">';
230  print '<td colspan="7" class="opacitymedium">'.$langs->trans("None")."</td>";
231  print '</tr>';
232  }
233  print "</table>";
234  print "</div>";
235  print "</form>\n";
236 }
237 else
238 {
239  dol_print_error($db);
240 }
241 
242 
243 llxFooter();
244 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
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:445
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.
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:46
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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:459
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
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 '...
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.