dolibarr  7.0.0-beta
bons.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
5  * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
27 require('../../main.inc.php');
28 require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
30 
31 $langs->load("banks");
32 $langs->load("categories");
33 $langs->load("widthdrawals");
34 
35 // Security check
36 $socid = GETPOST('socid','int');
37 if ($user->societe_id) $socid=$user->societe_id;
38 $result = restrictedArea($user, 'prelevement','','','bons');
39 
40 $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
41 $sortfield = GETPOST('sortfield','alpha');
42 $sortorder = GETPOST('sortorder','alpha');
43 $page = GETPOST('page','int');
44 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
45 $offset = $limit * $page;
46 $pageprev = $page - 1;
47 $pagenext = $page + 1;
48 if (! $sortorder) $sortorder="DESC";
49 if (! $sortfield) $sortfield="p.datec";
50 
51 // Get supervariables
52 $statut = GETPOST('statut','int');
53 $search_ref = GETPOST('search_ref','alpha');
54 $search_amount = GETPOST('search_amount','alpha');
55 
56 $bon=new BonPrelevement($db,"");
57 
58 
59 /*
60  * Actions
61  */
62 
63 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
64 {
65  $search_ref="";
66  $search_amount="";
67 }
68 
69 
70 /*
71  * View
72  */
73 
74 llxHeader('',$langs->trans("WithdrawalsReceipts"));
75 
76 $sql = "SELECT p.rowid, p.ref, p.amount, p.statut";
77 $sql.= ", p.datec";
78 $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
79 $sql.= " WHERE p.entity = ".$conf->entity;
80 if ($search_ref) $sql.=natural_search("p.ref", $search_ref);
81 if ($search_amount) $sql.=natural_search("p.amount", $search_amount, 1);
82 
83 $sql.= $db->order($sortfield,$sortorder);
84 
85 // Count total nb of records
86 $nbtotalofrecords = '';
87 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
88 {
89  $result = $db->query($sql);
90  $nbtotalofrecords = $db->num_rows($result);
91 }
92 
93 $sql.= $db->plimit($limit + 1,$offset);
94 
95 $result = $db->query($sql);
96 if ($result)
97 {
98  $num = $db->num_rows($result);
99  $i = 0;
100 
101  $urladd= "&amp;statut=".$statut;
102 
103  $selectedfields='';
104 
105  // Lines of title fields
106  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
107  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
108  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
109  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
110  print '<input type="hidden" name="action" value="list">';
111  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
112  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
113  print '<input type="hidden" name="page" value="'.$page.'">';
114  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
115 
116  print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit);
117 
118  $moreforfilter='';
119 
120  print '<div class="div-table-responsive">';
121  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
122 
123  print '<tr class="liste_titre">';
124  print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'. dol_escape_htmltag($search_ref).'"></td>';
125  print '<td class="liste_titre">&nbsp;</td>';
126  print '<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'. dol_escape_htmltag($search_amount).'"></td>';
127  print '<td class="liste_titre">&nbsp;</td>';
128  print '<td class="liste_titre" align="right">';
129  $searchpicto=$form->showFilterButtons();
130  print $searchpicto;
131  print '</td>';
132  print '</tr>';
133 
134  print '<tr class="liste_titre">';
135  print_liste_field_titre("WithdrawalsReceipts",$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"',$sortfield,$sortorder);
136  print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"',$sortfield,$sortorder);
137  print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"p.amount","","",'align="right"',$sortfield,$sortorder);
138  print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder);
139  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
140  print "</tr>\n";
141 
142  while ($i < min($num,$limit))
143  {
144  $obj = $db->fetch_object($result);
145 
146  print '<tr class="oddeven"><td>';
147 
148  print '<a href="card.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
149 
150  print '<td align="center">'.dol_print_date($db->jdate($obj->datec),'day')."</td>\n";
151 
152  print '<td align="right">'.price($obj->amount)."</td>\n";
153 
154  print '<td align="right">';
155  print $bon->LibStatut($obj->statut, 3);
156  print '</td>';
157 
158  print '<td align="right"></td>'."\n";
159 
160  print "</tr>\n";
161  $i++;
162  }
163  print "</table>";
164  print '</div>';
165 
166  print '</form>';
167 
168  $db->free($result);
169 }
170 else
171 {
172  dol_print_error($db);
173 }
174 
175 
176 llxFooter();
177 
178 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
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
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='')
Get title line of an array.
Class to manage withdrawal receipts.
llxHeader()
Empty header.
Definition: wrapper.php:46
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...
print
Draft customers invoices.
Definition: index.php:91
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
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.