dolibarr  9.0.0
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@inodbox.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 // Load translation files required by the page
34 $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies'));
35 
36 // Security check
37 $socid = GETPOST('socid','int');
38 if ($user->societe_id) $socid=$user->societe_id;
39 $result = restrictedArea($user, 'prelevement','','','bons');
40 
41 // Get supervariables
42 $page = GETPOST('page','int');
43 $sortorder = GETPOST('sortorder','alpha');
44 $sortfield = GETPOST('sortfield','alpha');
45 
46 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
47 $sortfield = GETPOST("sortfield",'alpha');
48 $sortorder = GETPOST("sortorder",'alpha');
49 $page = GETPOST("page",'int');
50 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
51 $offset = $limit * $page;
52 $pageprev = $page - 1;
53 $pagenext = $page + 1;
54 if (! $sortorder) $sortorder="DESC";
55 if (! $sortfield) $sortfield="f.facnumber";
56 
57 
58 /*
59  * View
60  */
61 
62 llxHeader();
63 
64 $thirdpartystatic=new Societe($db);
65 $invoicestatic=new Facture($db);
66 
67 // List of requests
68 
69 $sql= "SELECT f.facnumber, f.rowid, f.total_ttc,";
70 $sql.= " s.nom as name, s.rowid as socid,";
71 $sql.= " pfd.date_demande as date_demande,";
72 $sql.= " pfd.fk_user_demande";
73 $sql.= " FROM ".MAIN_DB_PREFIX."facture as f,";
74 $sql.= " ".MAIN_DB_PREFIX."societe as s,";
75 $sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
76 if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
77 $sql.= " WHERE s.rowid = f.fk_soc";
78 $sql.= " AND f.entity = ".$conf->entity;
79 if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
80 if ($socid) $sql.= " AND f.fk_soc = ".$socid;
81 if (!$statut) $sql.= " AND pfd.traite = 0";
82 if ($statut) $sql.= " AND pfd.traite = ".$statut;
83 $sql.= " AND pfd.fk_facture = f.rowid";
84 if (dol_strlen(trim(GETPOST('search_societe','alpha'))))
85 {
86  $sql.= natural_search("s.nom", 'search_societe');
87 }
88 $sql.= " ORDER BY $sortfield $sortorder ";
89 $sql.= $db->plimit($limit+1, $offset);
90 
91 $resql=$db->query($sql);
92 if ($resql)
93 {
94  $num = $db->num_rows($resql);
95  $i = 0;
96 
97  if (!$statut)
98  {
99  print_barre_liste($langs->trans("RequestStandingOrderToTreat"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num);
100  }
101  else
102  {
103  print_barre_liste($langs->trans("RequestStandingOrderTreated"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num);
104  }
105 
106  print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">';
107 
108  print '<table class="liste" width="100%">';
109 
110  print '<tr class="liste_titre">';
111  print_liste_field_titre("Bill", $_SERVER["PHP_SELF"]);
112  print_liste_field_titre("Company", $_SERVER["PHP_SELF"]);
113  print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"');
114  print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, 'align="center"');
116  print '</tr>';
117 
118  print '<tr class="liste_titre">';
119  print '<td class="liste_titre"><input type="text" class="flat" name="search_facture" size="12" value="'.dol_escape_htmltag(GETPOST('search_facture','alpha')).'"></td>';
120  print '<td class="liste_titre"><input type="text" class="flat" name="search_societe" size="18" value="'.dol_escape_htmltag(GETPOST('search_societe','alpha')).'"></td>';
121  print '<td class="liste_titre"></td>';
122  print '<td class="liste_titre"></td>';
123  // Action column
124  print '<td class="liste_titre" align="middle">';
125  $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
126  print $searchpicto;
127  print '</td>';
128  print '</tr>';
129 
130  $users = array();
131 
132  while ($i < min($num,$limit))
133  {
134  $obj = $db->fetch_object($resql);
135 
136  print '<tr class="oddeven">';
137 
138  // Ref facture
139  print '<td>';
140  $invoicestatic->id=$obj->rowid;
141  $invoicestatic->ref=$obj->facnumber;
142  print $invoicestatic->getNomUrl(1,'withdraw');
143  print '</td>';
144 
145  print '<td>';
146  $thirdpartystatic->id=$obj->socid;
147  $thirdpartystatic->name=$obj->name;
148  print $thirdpartystatic->getNomUrl(1,'customer');
149  print '</td>';
150 
151  print '<td align="right">'.price($obj->total_ttc).'</td>';
152 
153  print '<td align="center">'.dol_print_date($db->jdate($obj->date_demande),'day').'</td>';
154 
155  print '<td align="right"></td>';
156 
157  print '</tr>';
158  $i++;
159  }
160 
161  print "</table><br>";
162 
163  print '</form>';
164 }
165 else
166 {
167  dol_print_error($db);
168 }
169 
170 // End of page
171 llxFooter();
172 $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
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:1053
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
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: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.
Class to manage invoices.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.