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