dolibarr  9.0.0
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@inodbox.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 // Load translation files required by the page
32 $langs->loadLangs(array('banks', 'categories', 'widthdrawals'));
33 
34 // Security check
35 $socid = GETPOST('socid','int');
36 if ($user->societe_id) $socid=$user->societe_id;
37 $result = restrictedArea($user, 'prelevement','','','bons');
38 
39 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
40 $sortfield = GETPOST('sortfield','alpha');
41 $sortorder = GETPOST('sortorder','alpha');
42 $page = GETPOST('page','int');
43 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
44 $offset = $limit * $page;
45 $pageprev = $page - 1;
46 $pagenext = $page + 1;
47 if (! $sortorder) $sortorder="DESC";
48 if (! $sortfield) $sortfield="p.datec";
49 
50 // Get supervariables
51 $statut = GETPOST('statut','int');
52 $search_ref = GETPOST('search_ref','alpha');
53 $search_amount = GETPOST('search_amount','alpha');
54 
55 $bon=new BonPrelevement($db,"");
56 
57 
58 /*
59  * Actions
60  */
61 
62 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
63 {
64  $search_ref="";
65  $search_amount="";
66 }
67 
68 
69 /*
70  * View
71  */
72 
73 llxHeader('',$langs->trans("WithdrawalsReceipts"));
74 
75 $sql = "SELECT p.rowid, p.ref, p.amount, p.statut, p.datec";
76 $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
77 $sql.= " WHERE p.entity IN (".getEntity('facture').")";
78 if ($search_ref) $sql.=natural_search("p.ref", $search_ref);
79 if ($search_amount) $sql.=natural_search("p.amount", $search_amount, 1);
80 
81 $sql.= $db->order($sortfield,$sortorder);
82 
83 // Count total nb of records
84 $nbtotalofrecords = '';
85 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
86 {
87  $result = $db->query($sql);
88  $nbtotalofrecords = $db->num_rows($result);
89  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
90  {
91  $page = 0;
92  $offset = 0;
93  }
94 }
95 
96 $sql.= $db->plimit($limit + 1,$offset);
97 
98 $result = $db->query($sql);
99 if ($result)
100 {
101  $num = $db->num_rows($result);
102  $i = 0;
103 
104  $urladd= "&amp;statut=".$statut;
105 
106  $selectedfields='';
107 
108  $newcardbutton='';
109  if ($user->rights->prelevement->bons->creer)
110  {
111  $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/compta/prelevement/create.php"><span class="valignmiddle">'.$langs->trans('NewStandingOrder').'</span>';
112  $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
113  $newcardbutton.= '</a>';
114  }
115 
116  // Lines of title fields
117  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
118  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
119  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
120  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
121  print '<input type="hidden" name="action" value="list">';
122  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
123  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
124  print '<input type="hidden" name="page" value="'.$page.'">';
125  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
126 
127  print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, $newcardbutton, '', $limit);
128 
129  $moreforfilter='';
130 
131  print '<div class="div-table-responsive">';
132  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
133 
134  print '<tr class="liste_titre">';
135  print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'. dol_escape_htmltag($search_ref).'"></td>';
136  print '<td class="liste_titre">&nbsp;</td>';
137  print '<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'. dol_escape_htmltag($search_amount).'"></td>';
138  print '<td class="liste_titre">&nbsp;</td>';
139  print '<td class="liste_titre" align="right">';
140  $searchpicto=$form->showFilterButtons();
141  print $searchpicto;
142  print '</td>';
143  print '</tr>';
144 
145  print '<tr class="liste_titre">';
146  print_liste_field_titre("WithdrawalsReceipts",$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"',$sortfield,$sortorder);
147  print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"',$sortfield,$sortorder);
148  print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"p.amount","","",'align="right"',$sortfield,$sortorder);
149  print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"","","",'align="right"',$sortfield,$sortorder);
150  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
151  print "</tr>\n";
152 
153  while ($i < min($num,$limit))
154  {
155  $obj = $db->fetch_object($result);
156 
157  print '<tr class="oddeven"><td>';
158 
159  print '<a href="card.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
160 
161  print '<td align="center">'.dol_print_date($db->jdate($obj->datec),'day')."</td>\n";
162 
163  print '<td align="right">'.price($obj->amount)."</td>\n";
164 
165  print '<td align="right">';
166  print $bon->LibStatut($obj->statut, 3);
167  print '</td>';
168 
169  print '<td align="right"></td>'."\n";
170 
171  print "</tr>\n";
172  $i++;
173  }
174  print "</table>";
175  print '</div>';
176 
177  print '</form>';
178 
179  $db->free($result);
180 }
181 else
182 {
183  dol_print_error($db);
184 }
185 
186 // End of page
187 llxFooter();
188 $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
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
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...
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: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...
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.