dolibarr  7.0.0-beta
demandes.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
5  * Copyright (C) 2011-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.'/core/modules/modPrelevement.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
32 
33 $langs->load("banks");
34 $langs->load("categories");
35 $langs->load("withdrawals");
36 $langs->load("companies");
37 
38 // Security check
39 $socid = GETPOST('socid','int');
40 if ($user->societe_id) $socid=$user->societe_id;
41 $result = restrictedArea($user, 'prelevement','','','bons');
42 
43 // Get supervariables
44 $page = GETPOST('page','int');
45 $sortorder = GETPOST('sortorder','alpha');
46 $sortfield = GETPOST('sortfield','alpha');
47 
48 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
49 $sortfield = GETPOST("sortfield",'alpha');
50 $sortorder = GETPOST("sortorder",'alpha');
51 $page = GETPOST("page",'int');
52 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
53 $offset = $limit * $page;
54 $pageprev = $page - 1;
55 $pagenext = $page + 1;
56 if (! $sortorder) $sortorder="DESC";
57 if (! $sortfield) $sortfield="f.facnumber";
58 
59 
60 /*
61  * View
62  */
63 
64 llxHeader();
65 
66 $thirdpartystatic=new Societe($db);
67 $invoicestatic=new Facture($db);
68 
69 // List of requests
70 
71 $sql= "SELECT f.facnumber, f.rowid, f.total_ttc,";
72 $sql.= " s.nom as name, s.rowid as socid,";
73 $sql.= " pfd.date_demande as date_demande,";
74 $sql.= " pfd.fk_user_demande";
75 $sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
76 $sql.= " ".MAIN_DB_PREFIX."societe as s,";
77 $sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
78 if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
79 $sql.= " WHERE s.rowid = f.fk_soc";
80 $sql.= " AND f.entity = ".$conf->entity;
81 if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
82 if ($socid) $sql.= " AND f.fk_soc = ".$socid;
83 if (!$statut) $sql.= " AND pfd.traite = 0";
84 if ($statut) $sql.= " AND pfd.traite = ".$statut;
85 $sql.= " AND pfd.fk_facture = f.rowid";
86 if (dol_strlen(trim(GETPOST('search_societe','alpha'))))
87 {
88  $sql.= natural_search("s.nom", 'search_societe');
89 }
90 $sql.= " ORDER BY $sortfield $sortorder ";
91 $sql.= $db->plimit($limit+1, $offset);
92 
93 $resql=$db->query($sql);
94 if ($resql)
95 {
96  $num = $db->num_rows($resql);
97  $i = 0;
98 
99  if (!$statut)
100  {
101  print_barre_liste($langs->trans("RequestStandingOrderToTreat"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num);
102  }
103  else
104  {
105  print_barre_liste($langs->trans("RequestStandingOrderTreated"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num);
106  }
107 
108  print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">';
109 
110  print '<table class="liste" width="100%">';
111 
112  print '<tr class="liste_titre">';
113  print_liste_field_titre("Bill", $_SERVER["PHP_SELF"]);
114  print_liste_field_titre("Company", $_SERVER["PHP_SELF"]);
115  print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"');
116  print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, 'align="center"');
118  print '</tr>';
119 
120  print '<tr class="liste_titre">';
121  print '<td class="liste_titre"><input type="text" class="flat" name="search_facture" size="12" value="'.dol_escape_htmltag(GETPOST('search_facture','alpha')).'"></td>';
122  print '<td class="liste_titre"><input type="text" class="flat" name="search_societe" size="18" value="'.dol_escape_htmltag(GETPOST('search_societe','alpha')).'"></td>';
123  print '<td class="liste_titre"></td>';
124  print '<td class="liste_titre"></td>';
125  // Action column
126  print '<td class="liste_titre" align="middle">';
127  $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
128  print $searchpicto;
129  print '</td>';
130  print '</tr>';
131 
132  $var = True;
133 
134  $users = array();
135 
136  while ($i < min($num,$limit))
137  {
138  $obj = $db->fetch_object($resql);
139 
140  print '<tr class="oddeven">';
141 
142  // Ref facture
143  print '<td>';
144  $invoicestatic->id=$obj->rowid;
145  $invoicestatic->ref=$obj->facnumber;
146  print $invoicestatic->getNomUrl(1,'withdraw');
147  print '</td>';
148 
149  print '<td>';
150  $thirdpartystatic->id=$obj->socid;
151  $thirdpartystatic->name=$obj->name;
152  print $thirdpartystatic->getNomUrl(1,'customer');
153  print '</td>';
154 
155  print '<td align="right">'.price($obj->total_ttc).'</td>';
156 
157  print '<td align="center">'.dol_print_date($db->jdate($obj->date_demande),'day').'</td>';
158 
159  print '<td align="right"></td>';
160 
161  print '</tr>';
162  $i++;
163  }
164 
165  print "</table><br>";
166 
167  print '</form>';
168 }
169 else
170 {
171  dol_print_error($db);
172 }
173 
174 llxFooter();
175 $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.
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 third parties objects (customers, suppliers, prospects...)
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
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.
Class to manage invoices.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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.