dolibarr  16.0.5
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@open-dsi.fr>
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 <https://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->socid) {
39  $socid = $user->socid;
40 }
41 $result = restrictedArea($user, 'banque', '', '');
42 
43 $search_ref = GETPOST('search_ref', 'alpha');
44 $search_account = GETPOST('search_account', 'int');
45 $search_amount = GETPOST('search_amount', 'alpha');
46 
47 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
48 $sortfield = GETPOST('sortfield', 'aZ09comma');
49 $sortorder = GETPOST('sortorder', 'aZ09comma');
50 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
51 if (empty($page) || $page == -1) {
52  $page = 0;
53 } // If $page is not defined, or '' or -1
54 $offset = $limit * $page;
55 $pageprev = $page - 1;
56 $pagenext = $page + 1;
57 if (!$sortorder) {
58  $sortorder = "DESC";
59 }
60 if (!$sortfield) {
61  $sortfield = "dp";
62 }
63 
64 $year = GETPOST("year");
65 $month = GETPOST("month");
66 
67 $form = new Form($db);
68 $formother = new FormOther($db);
69 $checkdepositstatic = new RemiseCheque($db);
70 $accountstatic = new Account($db);
71 
72 
73 /*
74  * Actions
75  */
76 
77 // If click on purge search criteria ?
78 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
79  $search_ref = '';
80  $search_amount = '';
81  $search_account = '';
82  $year = '';
83  $month = '';
84 }
85 
86 
87 
88 /*
89  * View
90  */
91 
92 llxHeader('', $langs->trans("ChequesReceipts"));
93 
94 $sql = "SELECT bc.rowid, bc.ref as ref, bc.date_bordereau as dp,";
95 $sql .= " bc.nbcheque, bc.amount, bc.statut,";
96 $sql .= " ba.rowid as bid, ba.label";
97 $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc,";
98 $sql .= " ".MAIN_DB_PREFIX."bank_account as ba";
99 $sql .= " WHERE bc.fk_bank_account = ba.rowid";
100 $sql .= " AND bc.entity = ".$conf->entity;
101 
102 // Search criteria
103 if ($search_ref) {
104  $sql .= natural_search("bc.ref", $search_ref);
105 }
106 if ($search_account > 0) {
107  $sql .= " AND bc.fk_bank_account = ".((int) $search_account);
108 }
109 if ($search_amount) {
110  $sql .= natural_search("bc.amount", price2num($search_amount));
111 }
112 $sql .= dolSqlDateFilter('bc.date_bordereau', 0, $month, $year);
113 
114 $sql .= $db->order($sortfield, $sortorder);
115 
116 $nbtotalofrecords = '';
117 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
118  $result = $db->query($sql);
119  $nbtotalofrecords = $db->num_rows($result);
120  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
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  $num = $db->num_rows($resql);
132  $i = 0;
133  $param = '';
134  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
135  $param .= '&contextpage='.$contextpage;
136  }
137  if ($limit > 0 && $limit != $conf->liste_limit) {
138  $param .= '&limit='.$limit;
139  }
140 
141  $url = DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new';
142  if (!empty($socid)) {
143  $url .= '&socid='.$socid;
144  }
145  $newcardbutton = dolGetButtonTitle($langs->trans('NewCheckDeposit'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->cheque);
146 
147  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
148  if ($optioncss != '') {
149  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
150  }
151  print '<input type="hidden" name="token" value="'.newToken().'">';
152  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
153  print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">';
154  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
155  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
156  print '<input type="hidden" name="page" value="'.$page.'">';
157 
158  print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit);
159 
160  $moreforfilter = '';
161 
162  print '<div class="div-table-responsive">';
163  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
164 
165  // Fields title search
166  print '<tr class="liste_titre">';
167  print '<td class="liste_titre" align="left">';
168  print '<input class="flat" type="text" size="4" name="search_ref" value="'.$search_ref.'">';
169  print '</td>';
170  print '<td class="liste_titre" align="center">';
171  if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
172  print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
173  }
174  print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
175  print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 5);
176  print '</td>';
177  print '<td class="liste_titre">';
178  $form->select_comptes($search_account, 'search_account', 0, '', 1);
179  print '</td>';
180  print '<td class="liste_titre">&nbsp;</td>';
181  print '<td class="liste_titre right">';
182  print '<input class="flat maxwidth50" type="text" name="search_amount" value="'.$search_amount.'">';
183  print '</td>';
184  print '<td class="liste_titre"></td>';
185  print '<td class="liste_titre maxwidthsearch">';
186  $searchpicto = $form->showFilterAndCheckAddButtons(0);
187  print $searchpicto;
188  print '</td>';
189  print "</tr>\n";
190 
191  print '<tr class="liste_titre">';
192  print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "bc.ref", "", $param, "", $sortfield, $sortorder);
193  print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "dp", "", $param, 'align="center"', $sortfield, $sortorder);
194  print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
195  print_liste_field_titre("NbOfCheques", $_SERVER["PHP_SELF"], "bc.nbcheque", "", $param, 'class="right"', $sortfield, $sortorder);
196  print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "bc.amount", "", $param, 'class="right"', $sortfield, $sortorder);
197  print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "bc.statut", "", $param, 'class="right"', $sortfield, $sortorder);
199  print "</tr>\n";
200 
201  if ($num > 0) {
202  while ($i < min($num, $limit)) {
203  $objp = $db->fetch_object($resql);
204 
205  print '<tr class="oddeven">';
206 
207  // Num ref cheque
208  print '<td>';
209  $checkdepositstatic->id = $objp->rowid;
210  $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
211  $checkdepositstatic->statut = $objp->statut;
212  print $checkdepositstatic->getNomUrl(1);
213  print '</td>';
214 
215  // Date
216  print '<td class="center">'.dol_print_date($db->jdate($objp->dp), 'day').'</td>'; // TODO Use date hour
217 
218  // Bank
219  print '<td>';
220  if ($objp->bid) {
221  print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"), 'account').' '.$objp->label.'</a>';
222  } else {
223  print '&nbsp;';
224  }
225  print '</td>';
226 
227  // Number of cheques
228  print '<td class="right">'.$objp->nbcheque.'</td>';
229 
230  // Amount
231  print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
232 
233  // Statut
234  print '<td class="right">';
235  print $checkdepositstatic->LibStatut($objp->statut, 5);
236  print '</td>';
237 
238  print '<td></td>';
239 
240  print "</tr>\n";
241  $i++;
242  }
243  } else {
244  print '<tr class="oddeven">';
245  print '<td colspan="7" class="opacitymedium">'.$langs->trans("None")."</td>";
246  print '</tr>';
247  }
248  print "</table>";
249  print "</div>";
250  print "</form>\n";
251 } else {
252  dol_print_error($db);
253 }
254 
255 // End of page
256 llxFooter();
257 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
print_barre_liste
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
Definition: functions.lib.php:5257
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
natural_search
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...
Definition: functions.lib.php:9420
RemiseCheque
Class to manage cheque delivery receipts.
Definition: remisecheque.class.php:34
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4211
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
dolSqlDateFilter
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
Definition: date.lib.php:334
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
Account
Class to manage bank accounts.
Definition: account.class.php:38