dolibarr  7.0.0-beta
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
5  * Copyright (C) 2013 C├ędric Salvador <csalvador@gpcsolutions.fr>
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.'/don/class/don.class.php';
29 if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
30 
31 $langs->load("companies");
32 $langs->load("donations");
33 
34 $sortfield = GETPOST("sortfield",'alpha');
35 $sortorder = GETPOST("sortorder",'alpha');
36 $page = GETPOST("page",'int');
37 $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
38 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
39 $offset = $limit * $page;
40 $pageprev = $page - 1;
41 $pagenext = $page + 1;
42 if (! $sortorder) $sortorder="DESC";
43 if (! $sortfield) $sortfield="d.datedon";
44 
45 $statut=(GETPOST("statut",'intcomma')!='')?GETPOST("statut",'intcomma'):"-1";
46 $search_all=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml'));
47 $search_ref=GETPOST('search_ref','alpha');
48 $search_company=GETPOST('search_company','alpha');
49 $search_name=GETPOST('search_name','alpha');
50 $search_amount = GETPOST('search_amount','alpha');
51 $optioncss = GETPOST('optioncss','alpha');
52 
53 if (!$user->rights->don->lire) accessforbidden();
54 
55 if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers
56 {
57  $search_all="";
58  $search_ref="";
59  $search_company="";
60  $search_name="";
61  $search_amount="";
62 }
63 
64 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
65 $hookmanager->initHooks(array('orderlist'));
66 
67 
68 // List of fields to search into when doing a "search in all"
69 $fieldstosearchall = array(
70  'd.rowid'=>'Id',
71  'd.ref'=>'Ref',
72  'd.lastname'=>'Lastname',
73  'd.firstname'=>'Firstname',
74 );
75 
76 /*
77  * View
78  */
79 
80 $form=new Form($db);
81 if (! empty($conf->projet->enabled)) $projectstatic=new Project($db);
82 
83 llxHeader('',$langs->trans("Donations"),'EN:Module_Donations|FR:Module_Dons|ES:M&oacute;dulo_Donaciones');
84 
85 $donationstatic=new Don($db);
86 
87 // Genere requete de liste des dons
88 $sql = "SELECT d.rowid, d.datedon, d.firstname, d.lastname, d.societe,";
89 $sql.= " d.amount, d.fk_statut as statut, ";
90 $sql.= " p.rowid as pid, p.ref, p.title, p.public";
91 $sql.= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p";
92 $sql.= " ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity('donation').")";
93 if ($statut != '' && $statut != '-1')
94 {
95  $sql .= " AND d.fk_statut IN (".$db->escape($statut).")";
96 }
97 if (trim($search_ref) != '')
98 {
99  $sql.= natural_search('d.ref', $search_ref);
100 }
101 if (trim($search_all) != '')
102 {
103  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
104 }
105 if (trim($search_company) != '')
106 {
107  $sql .= natural_search('d.societe', $search_company);
108 }
109 if (trim($search_name) != '')
110 {
111  $sql .= natural_search(array('d.lastname', 'd.firstname'), $search_name);
112 }
113 if ($search_amount) $sql.= natural_search('d.amount', $search_amount, 1);
114 
115 $sql.= $db->order($sortfield,$sortorder);
116 $nbtotalofrecords = '';
117 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
118 {
119  $result = $db->query($sql);
120  $nbtotalofrecords = $db->num_rows($result);
121 }
122 $sql.= $db->plimit($limit+1, $offset);
123 
124 $resql = $db->query($sql);
125 if ($resql)
126 {
127  $num = $db->num_rows($resql);
128  $i = 0;
129 
130  $param = '&statut='.$statut;
131  //if ($page > 0) $param.= '&page='.$page;
132  if ($optioncss != '') $param.='&optioncss='.$optioncss;
133 
134  print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num,$nbtotalofrecords);
135 
136  print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">'."\n";
137  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
138  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
139  print '<input type="hidden" name="action" value="list">';
140  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
141  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
142  print '<input type="hidden" name="page" value="'.$page.'">';
143  print '<input type="hidden" name="type" value="'.$type.'">';
144 
145  if ($search_all)
146  {
147  foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
148  print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall);
149  }
150 
151  print '<div class="div-table-responsive">';
152  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
153 
154  // Filters lines
155  print '<tr class="liste_titre_filter">';
156  print '<td class="liste_titre">';
157  print '<input class="flat" size="10" type="text" name="search_ref" value="'.$search_ref.'">';
158  print '</td>';
159  print '<td class="liste_titre">';
160  print '<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.'">';
161  print '</td>';
162  print '<td class="liste_titre">';
163  print '<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.'">';
164  print '</td>';
165  print '<td class="liste_titre" align="left">';
166  print '&nbsp;';
167  print '</td>';
168  if (! empty($conf->projet->enabled))
169  {
170  print '<td class="liste_titre" align="right">';
171  print '&nbsp;';
172  print '</td>';
173  }
174  print '<td class="liste_titre" align="right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'"></td>';
175  print '<td class="liste_titre" align="right"></td>';
176  print '<td class="liste_titre" align="right">';
177  $searchpicto=$form->showFilterAndCheckAddButtons(0);
178  print $searchpicto;
179  print '</td>';
180  print "</tr>\n";
181 
182  print '<tr class="liste_titre">';
183  print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"d.rowid","", $param,"",$sortfield,$sortorder);
184  print_liste_field_titre("Company",$_SERVER["PHP_SELF"],"d.societe","", $param,"",$sortfield,$sortorder);
185  print_liste_field_titre("Name",$_SERVER["PHP_SELF"],"d.lastname","", $param,"",$sortfield,$sortorder);
186  print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"d.datedon","", $param,'align="center"',$sortfield,$sortorder);
187  if (! empty($conf->projet->enabled))
188  {
189  $langs->load("projects");
190  print_liste_field_titre("Project",$_SERVER["PHP_SELF"],"fk_projet","", $param,"",$sortfield,$sortorder);
191  }
192  print_liste_field_titre("Amount",$_SERVER["PHP_SELF"],"d.amount","", $param,'align="right"',$sortfield,$sortorder);
193  print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"d.fk_statut","", $param,'align="right"',$sortfield,$sortorder);
195  print "</tr>\n";
196 
197  while ($i < min($num,$limit))
198  {
199  $objp = $db->fetch_object($resql);
200 
201  print '<tr class="oddeven">';
202  $donationstatic->id=$objp->rowid;
203  $donationstatic->ref=$objp->rowid;
204  $donationstatic->lastname=$objp->lastname;
205  $donationstatic->firstname=$objp->firstname;
206  print "<td>".$donationstatic->getNomUrl(1)."</td>\n";
207  print "<td>".$objp->societe."</td>\n";
208  print "<td>".$donationstatic->getFullName($langs)."</td>\n";
209  print '<td align="center">'.dol_print_date($db->jdate($objp->datedon),'day').'</td>';
210  if (! empty($conf->projet->enabled))
211  {
212  print "<td>";
213  if ($objp->pid)
214  {
215  $projectstatic->id=$objp->pid;
216  $projectstatic->ref=$objp->ref;
217  $projectstatic->id=$objp->pid;
218  $projectstatic->public=$objp->public;
219  $projectstatic->title=$objp->title;
220  print $projectstatic->getNomUrl(1);
221  }
222  else print '&nbsp;';
223  print "</td>\n";
224  }
225  print '<td align="right">'.price($objp->amount).'</td>';
226  print '<td align="right">'.$donationstatic->LibStatut($objp->statut,5).'</td>';
227  print '<td></td>';
228  print "</tr>";
229  $i++;
230  }
231  print "</table>";
232  print '</div>';
233  print "</form>\n";
234  $db->free($resql);
235 }
236 else
237 {
238  dol_print_error($db);
239 }
240 
241 llxFooter();
242 $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
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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 projects.
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
Class to manage donations.
Definition: don.class.php:35
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.