dolibarr  13.0.2
orders_list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.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 <https://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/bank/class/account.class.php';
30 
31 // Load translation files required by the page
32 $langs->loadLangs(array('banks', 'categories', 'widthdrawals'));
33 
34 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'directdebitcredittransferlist'; // To manage different context of search
35 
36 // Security check
37 $socid = GETPOST('socid', 'int');
38 if ($user->socid) $socid = $user->socid;
39 $result = restrictedArea($user, 'prelevement', '', '', 'bons');
40 
41 $type = GETPOST('type', 'aZ09');
42 
43 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
44 $sortfield = GETPOST('sortfield', 'aZ09comma');
45 $sortorder = GETPOST('sortorder', 'aZ09comma');
46 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : 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 // Get supervariables
55 $statut = GETPOST('statut', 'int');
56 $search_ref = GETPOST('search_ref', 'alpha');
57 $search_amount = GETPOST('search_amount', 'alpha');
58 
59 $bon = new BonPrelevement($db);
60 $hookmanager->initHooks(array('withdrawalsreceiptslist'));
61 
62 $usercancreate = $user->rights->prelevement->bons->creer;
63 if ($type == 'bank-transfer') {
64  $usercancreate = $user->rights->paymentbybanktransfer->create;
65 }
66 
67 
68 /*
69  * Actions
70  */
71 
72 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
73 {
74  $search_ref = "";
75  $search_amount = "";
76 }
77 
78 
79 /*
80  * View
81  */
82 
83 llxHeader('', $langs->trans("WithdrawalsReceipts"));
84 
85 $sql = "SELECT p.rowid, p.ref, p.amount, p.statut, p.datec";
86 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
87 $sql .= " WHERE p.entity IN (".getEntity('invoice').")";
88 if ($type == 'bank-transfer') {
89  $sql .= " AND p.type = 'bank-transfer'";
90 } else {
91  $sql .= " AND p.type = 'debit-order'";
92 }
93 if ($search_ref) $sql .= natural_search("p.ref", $search_ref);
94 if ($search_amount) $sql .= natural_search("p.amount", $search_amount, 1);
95 
96 $sql .= $db->order($sortfield, $sortorder);
97 
98 // Count total nb of records
99 $nbtotalofrecords = '';
100 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
101 {
102  $result = $db->query($sql);
103  $nbtotalofrecords = $db->num_rows($result);
104  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
105  {
106  $page = 0;
107  $offset = 0;
108  }
109 }
110 
111 $sql .= $db->plimit($limit + 1, $offset);
112 
113 $result = $db->query($sql);
114 if ($result)
115 {
116  $num = $db->num_rows($result);
117  $i = 0;
118 
119  $param = '';
120  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
121  if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
122  $param .= "&statut=".urlencode($statut);
123 
124  $selectedfields = '';
125 
126  $newcardbutton = '';
127  if ($usercancreate)
128  {
129  $newcardbutton .= dolGetButtonTitle($langs->trans('NewStandingOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php');
130  }
131 
132  // Lines of title fields
133  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
134  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
135  print '<input type="hidden" name="token" value="'.newToken().'">';
136  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
137  print '<input type="hidden" name="action" value="list">';
138  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
139  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
140  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
141 
142  $titlekey = "WithdrawalsReceipts";
143  $title = $langs->trans("WithdrawalsReceipts");
144  if ($type == 'bank-transfer') {
145  $titlekey = "BankTransferReceipts";
146  $title = $langs->trans("BankTransferReceipts");
147  }
148 
149  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit, 0, 0, 1);
150 
151  $moreforfilter = '';
152 
153  print '<div class="div-table-responsive">';
154  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
155 
156  print '<tr class="liste_titre">';
157  print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
158  print '<td class="liste_titre">&nbsp;</td>';
159  print '<td class="liste_titre right"><input type="text" class="flat maxwidth100" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
160  print '<td class="liste_titre">&nbsp;</td>';
161  print '<td class="liste_titre maxwidthsearch">';
162  $searchpicto = $form->showFilterButtons();
163  print $searchpicto;
164  print '</td>';
165  print '</tr>';
166 
167  print '<tr class="liste_titre">';
168  print_liste_field_titre($titlekey, $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
169  print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center ');
170  print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "p.amount", "", $param, '', $sortfield, $sortorder, 'right ');
171  print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
172  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center ')."\n";
173  print "</tr>\n";
174 
175  $directdebitorder = new BonPrelevement($db);
176 
177  if ($num) {
178  while ($i < min($num, $limit))
179  {
180  $obj = $db->fetch_object($result);
181 
182  $directdebitorder->id = $obj->rowid;
183  $directdebitorder->ref = $obj->ref;
184  $directdebitorder->datec = $obj->datec;
185  $directdebitorder->amount = $obj->amount;
186  $directdebitorder->statut = $obj->statut;
187 
188  print '<tr class="oddeven">';
189 
190  print '<td>';
191  print $directdebitorder->getNomUrl(1);
192  print "</td>\n";
193 
194  print '<td class="center">'.dol_print_date($db->jdate($obj->datec), 'day')."</td>\n";
195 
196  print '<td class="right">'.price($obj->amount)."</td>\n";
197 
198  print '<td class="right">';
199  print $bon->LibStatut($obj->statut, 3);
200  print '</td>';
201 
202  print '<td class="right"></td>'."\n";
203 
204  print "</tr>\n";
205  $i++;
206  }
207  } else {
208  print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>';
209  }
210 
211  print "</table>";
212  print '</div>';
213 
214  print '</form>';
215 
216  $db->free($result);
217 } else {
218  dol_print_error($db);
219 }
220 
221 // End of page
222 llxFooter();
223 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
llxHeader()
Empty header.
Definition: wrapper.php:45
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Class to manage withdrawal receipts.
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.
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 $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
Definition: index.php:89
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
llxFooter()
Empty footer.
Definition: wrapper.php:59