dolibarr  18.0.0-alpha
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2014 Alexandre Spangaro <aspangaro@open-dsi.fr>
6  * Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 // Load Dolibarr environment
29 require '../../../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34 
35 // Load translation files required by the page
36 $langs->loadLangs(array('banks', 'categories', 'bills'));
37 
38 // Security check
39 if ($user->socid) {
40  $socid = $user->socid;
41 }
42 $result = restrictedArea($user, 'banque', '', '');
43 
44 $search_ref = GETPOST('search_ref', 'alpha');
45 $search_account = GETPOST('search_account', 'int');
46 $search_amount = GETPOST('search_amount', 'alpha');
47 $mode = GETPOST('mode', 'alpha');
48 
49 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
50 $sortfield = GETPOST('sortfield', 'aZ09comma');
51 $sortorder = GETPOST('sortorder', 'aZ09comma');
52 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
53 if (empty($page) || $page == -1) {
54  $page = 0;
55 } // If $page is not defined, or '' or -1
56 $offset = $limit * $page;
57 $pageprev = $page - 1;
58 $pagenext = $page + 1;
59 if (!$sortorder) {
60  $sortorder = "DESC";
61 }
62 if (!$sortfield) {
63  $sortfield = "bc.date_bordereau";
64 }
65 
66 $year = GETPOST("year");
67 $month = GETPOST("month");
68 $optioncss = GETPOST('optioncss', 'alpha');
69 $view = GETPOST("view", 'alpha');
70 
71 $form = new Form($db);
72 $formother = new FormOther($db);
73 $checkdepositstatic = new RemiseCheque($db);
74 $accountstatic = new Account($db);
75 
76 // List of payment mode to support
77 // Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA'
78 $arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ'));
79 
80 $arrayoflabels = array();
81 foreach ($arrayofpaymentmodetomanage as $key => $val) {
82  $labelval = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val);
83  $arrayoflabels[$key] = $labelval;
84 }
85 
86 
87 /*
88  * Actions
89  */
90 
91 // If click on purge search criteria ?
92 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
93  $search_ref = '';
94  $search_amount = '';
95  $search_account = '';
96  $year = '';
97  $month = '';
98 }
99 
100 
101 
102 /*
103  * View
104  */
105 
106 llxHeader('', $langs->trans("ChequeDeposits"));
107 
108 $sql = "SELECT bc.rowid, bc.ref, bc.date_bordereau,";
109 $sql .= " bc.nbcheque, bc.amount, bc.statut, bc.type,";
110 $sql .= " ba.rowid as bid, ba.label";
111 
112 $sqlfields = $sql; // $sql fields to remove for count total
113 
114 $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc,";
115 $sql .= " ".MAIN_DB_PREFIX."bank_account as ba";
116 $sql .= " WHERE bc.fk_bank_account = ba.rowid";
117 $sql .= " AND bc.entity = ".((int) $conf->entity);
118 
119 // Search criteria
120 if ($search_ref) {
121  $sql .= natural_search("bc.ref", $search_ref);
122 }
123 if ($search_account > 0) {
124  $sql .= " AND bc.fk_bank_account = ".((int) $search_account);
125 }
126 if ($search_amount) {
127  $sql .= natural_search("bc.amount", price2num($search_amount));
128 }
129 $sql .= dolSqlDateFilter('bc.date_bordereau', 0, $month, $year);
130 
131 // Count total nb of records
132 $nbtotalofrecords = '';
133 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
134  /* The fast and low memory method to get and count full list converts the sql into a sql count */
135  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
136  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
137  $resql = $db->query($sqlforcount);
138  if ($resql) {
139  $objforcount = $db->fetch_object($resql);
140  $nbtotalofrecords = $objforcount->nbtotalofrecords;
141  } else {
142  dol_print_error($db);
143  }
144 
145  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
146  $page = 0;
147  $offset = 0;
148  }
149  $db->free($resql);
150 }
151 
152 $sql .= $db->order($sortfield, $sortorder);
153 if ($limit) {
154  $sql .= $db->plimit($limit + 1, $offset);
155 }
156 //print "$sql";
157 
158 $resql = $db->query($sql);
159 if ($resql) {
160  $num = $db->num_rows($resql);
161  $i = 0;
162  $param = '';
163  if (!empty($mode)) {
164  $param .= '&mode='.urlencode($mode);
165  }
166  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
167  $param .= '&contextpage='.$contextpage;
168  }
169  if ($limit > 0 && $limit != $conf->liste_limit) {
170  $param .= '&limit='.$limit;
171  }
172 
173  $url = DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new';
174  if (!empty($socid)) {
175  $url .= '&socid='.$socid;
176  }
177  $newcardbutton = '';
178  $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
179  $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
180  $newcardbutton .= dolGetButtonTitle($langs->trans('NewCheckDeposit'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->cheque);
181 
182  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
183  if ($optioncss != '') {
184  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
185  }
186  print '<input type="hidden" name="token" value="'.newToken().'">';
187  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
188  print '<input type="hidden" name="view" value="'.dol_escape_htmltag($view).'">';
189  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
190  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
191  print '<input type="hidden" name="page" value="'.$page.'">';
192  print '<input type="hidden" name="mode" value="'.$mode.'">';
193 
194 
195  print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit);
196 
197  $moreforfilter = '';
198 
199  print '<div class="div-table-responsive">';
200  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
201 
202  // Fields title search
203  print '<tr class="liste_titre">';
204  print '<td class="liste_titre">';
205  print '<input class="flat" type="text" size="4" name="search_ref" value="'.$search_ref.'">';
206  print '</td>';
207  // Type
208  print '<td class="liste_titre">';
209  print '</td>';
210  print '<td class="liste_titre center">';
211  if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
212  print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
213  }
214  print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
215  print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 5);
216  print '</td>';
217  print '<td class="liste_titre">';
218  $form->select_comptes($search_account, 'search_account', 0, '', 1);
219  print '</td>';
220  print '<td class="liste_titre">&nbsp;</td>';
221  print '<td class="liste_titre right">';
222  print '<input class="flat maxwidth50" type="text" name="search_amount" value="'.$search_amount.'">';
223  print '</td>';
224  print '<td class="liste_titre"></td>';
225  print '<td class="liste_titre maxwidthsearch">';
226  $searchpicto = $form->showFilterAndCheckAddButtons(0);
227  print $searchpicto;
228  print '</td>';
229  print "</tr>\n";
230 
231  print '<tr class="liste_titre">';
232  print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "bc.ref", "", $param, "", $sortfield, $sortorder);
233  print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "bc.type", "", $param, "", $sortfield, $sortorder);
234  print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "bc.date_bordereau", "", $param, 'align="center"', $sortfield, $sortorder);
235  print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
236  print_liste_field_titre("NbOfCheques", $_SERVER["PHP_SELF"], "bc.nbcheque", "", $param, 'class="right"', $sortfield, $sortorder);
237  print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "bc.amount", "", $param, 'class="right"', $sortfield, $sortorder);
238  print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "bc.statut", "", $param, 'class="right"', $sortfield, $sortorder);
240  print "</tr>\n";
241 
242  if ($num > 0) {
243  $imaxinloop = ($limit ? min($num, $limit) : $num);
244  while ($i < $imaxinloop) {
245  $objp = $db->fetch_object($resql);
246 
247  $checkdepositstatic->id = $objp->rowid;
248  $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
249  $checkdepositstatic->statut = $objp->statut;
250  $checkdepositstatic->nbcheque = $objp->nbcheque;
251  $checkdepositstatic->amount = $objp->amount;
252  $checkdepositstatic->date_bordereau = $objp->date_bordereau;
253  $checkdepositstatic->type = $objp->type;
254 
255  $account = new Account($db);
256  $account->fetch($objp->bid);
257  $checkdepositstatic->account_id = $account->getNomUrl(1);
258 
259  if ($mode == 'kanban') {
260  if ($i == 0) {
261  print '<tr><td colspan="12">';
262  print '<div class="box-flex-container kanban">';
263  }
264  // Output Kanban
265  print $checkdepositstatic->getKanbanView('');
266  if ($i == ($imaxinloop - 1)) {
267  print '</div>';
268  print '</td></tr>';
269  }
270  } else {
271  print '<tr class="oddeven">';
272 
273  // Num ref cheque
274  print '<td>';
275  print $checkdepositstatic->getNomUrl(1);
276  print '</td>';
277 
278  // Type
279  $labelpaymentmode = ($langs->transnoentitiesnoconv("PaymentType".$checkdepositstatic->type) != "PaymentType".$checkdepositstatic->type ? $langs->transnoentitiesnoconv("PaymentType".$checkdepositstatic->type) : $checkdepositstatic->type);
280  print '<td>'.dol_escape_htmltag($labelpaymentmode).'</td>';
281 
282  // Date
283  print '<td class="center">'.dol_print_date($db->jdate($objp->date_bordereau), 'dayhour', 'tzuser').'</td>';
284 
285  // Bank
286  print '<td>';
287  if ($objp->bid) {
288  print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"), 'account').' '.$objp->label.'</a>';
289  } else {
290  print '&nbsp;';
291  }
292  print '</td>';
293 
294  // Number of cheques
295  print '<td class="right">'.$objp->nbcheque.'</td>';
296 
297  // Amount
298  print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
299 
300  // Statut
301  print '<td class="right">';
302  print $checkdepositstatic->LibStatut($objp->statut, 5);
303  print '</td>';
304 
305  print '<td></td>';
306 
307  print "</tr>\n";
308  }
309  $i++;
310  }
311  } else {
312  print '<tr class="oddeven">';
313  print '<td colspan="7" class="opacitymedium">'.$langs->trans("None")."</td>";
314  print '</tr>';
315  }
316  print "</table>";
317  print "</div>";
318  print "</form>\n";
319 } else {
320  dol_print_error($db);
321 }
322 
323 // End of page
324 llxFooter();
325 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
$sql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:745
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:551
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:5031
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5876
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
dolGetButtonTitle
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.
Definition: functions.lib.php:11112
print_barre_liste
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.
Definition: functions.lib.php:5453
restrictedArea
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:349
getDolGlobalString
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:101
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:451
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5218
natural_search
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...
Definition: functions.lib.php:9872
RemiseCheque
Class to manage cheque delivery receipts.
Definition: remisecheque.class.php:34
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4398
dolSqlDateFilter
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
Definition: date.lib.php:359
$nbtotalofrecords
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
Account
Class to manage bank accounts.
Definition: account.class.php:40