dolibarr  9.0.0
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2010-2018 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/prelevement/class/ligneprelevement.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
31 
32 // Load translation files required by the page
33 $langs->loadLangs(array('banks', 'withdrawals', 'companies', 'categories'));
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 
41 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
42 $sortfield = GETPOST('sortfield','alpha');
43 $sortorder = GETPOST('sortorder','alpha');
44 $page = GETPOST('page','int');
45 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
46 $offset = $limit * $page;
47 $pageprev = $page - 1;
48 $pagenext = $page + 1;
49 if (! $sortorder) $sortorder="DESC";
50 if (! $sortfield) $sortfield="p.datec";
51 
52 $search_line = GETPOST('search_line','alpha');
53 $search_bon = GETPOST('search_bon','alpha');
54 $search_code = GETPOST('search_code','alpha');
55 $search_company = GETPOST('search_company','alpha');
56 $statut = GETPOST('statut','int');
57 
58 $bon=new BonPrelevement($db,"");
59 $ligne=new LignePrelevement($db,$user);
60 
61 
62 /*
63  * Actions
64  */
65 
66 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
67 {
68  $search_line="";
69  $search_bon="";
70  $search_code="";
71  $search_company="";
72  $statut="";
73 }
74 
75 
76 /*
77  * View
78  */
79 
80 $form=new Form($db);
81 
82 llxHeader('',$langs->trans("WithdrawalsLines"));
83 
84 $sql = "SELECT p.rowid, p.ref, p.statut, p.datec";
85 $sql.= " ,f.rowid as facid, f.facnumber, f.total_ttc";
86 $sql.= " , s.rowid as socid, s.nom as name, s.code_client";
87 $sql.= " , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne";
88 $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
89 $sql.= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl";
90 $sql.= " , ".MAIN_DB_PREFIX."prelevement_facture as pf";
91 $sql.= " , ".MAIN_DB_PREFIX."facture as f";
92 $sql.= " , ".MAIN_DB_PREFIX."societe as s";
93 $sql.= " WHERE pl.fk_prelevement_bons = p.rowid";
94 $sql.= " AND pf.fk_prelevement_lignes = pl.rowid";
95 $sql.= " AND pf.fk_facture = f.rowid";
96 $sql.= " AND f.fk_soc = s.rowid";
97 $sql.= " AND f.entity = ".$conf->entity;
98 if ($socid) $sql.= " AND s.rowid = ".$socid;
99 if ($search_line) $sql.= " AND pl.rowid = '".$db->escape($search_line)."'";
100 if ($search_bon) $sql.= natural_search("p.ref", $search_bon);
101 if ($search_code) $sql.= natural_search("s.code_client", $search_code);
102 if ($search_company) $sql.= natural_search("s.nom", $search_company);
103 
104 $sql.= $db->order($sortfield,$sortorder);
105 
106 // Count total nb of records
107 $nbtotalofrecords = '';
108 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
109 {
110  $result = $db->query($sql);
111  $nbtotalofrecords = $db->num_rows($result);
112  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
113  {
114  $page = 0;
115  $offset = 0;
116  }
117 }
118 
119 $sql.= $db->plimit($limit + 1,$offset);
120 
121 $result = $db->query($sql);
122 if ($result)
123 {
124  $num = $db->num_rows($result);
125  $i = 0;
126 
127  $urladd = "&amp;statut=".$statut;
128  $urladd .= "&amp;search_bon=".$search_bon;
129  if ($limit > 0 && $limit != $conf->liste_limit) $urladd.='&limit='.urlencode($limit);
130 
131  print"\n<!-- debut table -->\n";
132  print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">';
133 
134  print_barre_liste($langs->trans("WithdrawalsLines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit);
135 
136  $moreforfilter='';
137 
138  print '<div class="div-table-responsive">';
139  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
140 
141  print '<tr class="liste_titre">';
142  print '<td class="liste_titre"><input type="text" class="flat" name="search_line" value="'. dol_escape_htmltag($search_line).'" size="6"></td>';
143  print '<td class="liste_titre"><input type="text" class="flat" name="search_bon" value="'. dol_escape_htmltag($search_bon).'" size="6"></td>';
144  print '<td class="liste_titre">&nbsp;</td>';
145  print '<td class="liste_titre"><input type="text" class="flat" name="search_company" value="'. dol_escape_htmltag($search_company).'" size="6"></td>';
146  print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_code" value="'. dol_escape_htmltag($search_code).'" size="6"></td>';
147  print '<td class="liste_titre">&nbsp;</td>';
148  print '<td class="liste_titre">&nbsp;</td>';
149  print '<td class="liste_titre" align="right">';
150  $searchpicto=$form->showFilterButtons();
151  print $searchpicto;
152  print '</td>';
153  print '</tr>';
154 
155  print '<tr class="liste_titre">';
156  print_liste_field_titre("Line",$_SERVER["PHP_SELF"]);
157  print_liste_field_titre("WithdrawalsReceipts",$_SERVER["PHP_SELF"],"p.ref");
158  print_liste_field_titre("Bill",$_SERVER["PHP_SELF"],"f.facnumber",'',$urladd);
159  print_liste_field_titre("Company",$_SERVER["PHP_SELF"],"s.nom");
160  print_liste_field_titre("CustomerCode",$_SERVER["PHP_SELF"],"s.code_client",'','','align="center"');
161  print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"p.datec","","",'align="center"');
162  print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"pl.amount","","",'align="right"');
164  print "</tr>\n";
165 
166  while ($i < min($num,$limit))
167  {
168  $obj = $db->fetch_object($result);
169 
170  print '<tr class="oddeven"><td>';
171 
172  print $ligne->LibStatut($obj->statut_ligne,2);
173  print "&nbsp;";
174 
175  print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/ligne.php?id='.$obj->rowid_ligne.'">';
176  print substr('000000'.$obj->rowid_ligne, -6);
177  print '</a></td>';
178 
179  print '<td>';
180 
181  print $bon->LibStatut($obj->statut,2);
182  print "&nbsp;";
183 
184  print '<a href="card.php?id='.$obj->rowid.'">'.$obj->ref."</a></td>\n";
185 
186  print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$obj->facid.'">';
187  print img_object($langs->trans("ShowBill"),"bill");
188  print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$obj->facid.'">'.$obj->facnumber."</a></td>\n";
189  print '</a></td>';
190 
191  print '<td><a href="card.php?id='.$obj->rowid.'">'.$obj->name."</a></td>\n";
192 
193  print '<td align="center"><a href="card.php?id='.$obj->rowid.'">'.$obj->code_client."</a></td>\n";
194 
195  print '<td align="center">'.dol_print_date($db->jdate($obj->datec),'day')."</td>\n";
196 
197  print '<td align="right">'.price($obj->amount)."</td>\n";
198 
199  print '<td>&nbsp;</td>';
200 
201  print "</tr>\n";
202  $i++;
203  }
204  print "</table>";
205  print '</div>';
206 
207  print '</form>';
208 
209  $db->free($result);
210 }
211 else
212 {
213  dol_print_error($db);
214 }
215 
216 // End of page
217 llxFooter();
218 $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...
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.
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Class to manage withdrawals.