dolibarr  19.0.0-dev
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 (!getDolGlobalInt('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  $savnbfield = 8;
244 
245  $imaxinloop = ($limit ? min($num, $limit) : $num);
246  while ($i < $imaxinloop) {
247  $objp = $db->fetch_object($resql);
248 
249  $checkdepositstatic->id = $objp->rowid;
250  $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid);
251  $checkdepositstatic->statut = $objp->statut;
252  $checkdepositstatic->nbcheque = $objp->nbcheque;
253  $checkdepositstatic->amount = $objp->amount;
254  $checkdepositstatic->date_bordereau = $objp->date_bordereau;
255  $checkdepositstatic->type = $objp->type;
256 
257  $account = new Account($db);
258  $account->fetch($objp->bid);
259  $checkdepositstatic->account_id = $account->getNomUrl(1);
260 
261  if ($mode == 'kanban') {
262  if ($i == 0) {
263  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
264  print '<div class="box-flex-container kanban">';
265  }
266  // Output Kanban
267  print $checkdepositstatic->getKanbanView('', array('selected' => in_array($checkdepositstatic->id, $arrayofselected)));
268  if ($i == ($imaxinloop - 1)) {
269  print '</div>';
270  print '</td></tr>';
271  }
272  } else {
273  print '<tr class="oddeven">';
274 
275  // Num ref cheque
276  print '<td>';
277  print $checkdepositstatic->getNomUrl(1);
278  print '</td>';
279 
280  // Type
281  $labelpaymentmode = ($langs->transnoentitiesnoconv("PaymentType".$checkdepositstatic->type) != "PaymentType".$checkdepositstatic->type ? $langs->transnoentitiesnoconv("PaymentType".$checkdepositstatic->type) : $checkdepositstatic->type);
282  print '<td>'.dol_escape_htmltag($labelpaymentmode).'</td>';
283 
284  // Date
285  print '<td class="center">'.dol_print_date($db->jdate($objp->date_bordereau), 'dayhour', 'tzuser').'</td>';
286 
287  // Bank
288  print '<td>';
289  if ($objp->bid) {
290  print '<a href="'.DOL_URL_ROOT.'/compta/bank/bankentries_list.php?account='.$objp->bid.'">'.img_object($langs->trans("ShowAccount"), 'account').' '.$objp->label.'</a>';
291  } else {
292  print '&nbsp;';
293  }
294  print '</td>';
295 
296  // Number of cheques
297  print '<td class="right">'.$objp->nbcheque.'</td>';
298 
299  // Amount
300  print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
301 
302  // Statut
303  print '<td class="right">';
304  print $checkdepositstatic->LibStatut($objp->statut, 5);
305  print '</td>';
306 
307  print '<td></td>';
308 
309  print "</tr>\n";
310  }
311  $i++;
312  }
313  } else {
314  print '<tr class="oddeven">';
315  print '<td colspan="7" class="opacitymedium">'.$langs->trans("None")."</td>";
316  print '</tr>';
317  }
318  print "</table>";
319  print "</div>";
320  print "</form>\n";
321 } else {
322  dol_print_error($db);
323 }
324 
325 // End of page
326 llxFooter();
327 $db->close();
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
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage bank accounts.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation de composants html autre Only common components are here.
Class to manage cheque delivery receipts.
if(isModEnabled('facture') && $user->hasRight('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') && $user->hasRight('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:746
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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...
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $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='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 from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.