dolibarr  17.0.4
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2016 Frédéric France <frederic.france@free.fr>
6  * Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
7  * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
8  * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
9  * Copyright (C) 2021-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <https://www.gnu.org/licenses/>.
23  */
24 
31 // Load Dolibarr environment
32 require '../../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
38 if (isModEnabled('project')) {
39  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
40 }
41 
42 // Load translation files required by the page
43 $langs->loadLangs(array('compta', 'banks', 'bills', 'hrm', 'projects'));
44 
45 $action = GETPOST('action', 'aZ09');
46 $massaction = GETPOST('massaction', 'alpha');
47 $confirm = GETPOST('confirm', 'alpha');
48 $optioncss = GETPOST('optioncss', 'alpha');
49 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist';
50 
51 $search_ref = GETPOST('search_ref', 'int');
52 $search_label = GETPOST('search_label', 'alpha');
53 $search_typeid = GETPOST('search_typeid', 'int');
54 $search_amount = GETPOST('search_amount', 'alpha');
55 $search_status = GETPOST('search_status', 'int');
56 $search_date_startday = GETPOST('search_date_startday', 'int');
57 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
58 $search_date_startyear = GETPOST('search_date_startyear', 'int');
59 $search_date_endday = GETPOST('search_date_endday', 'int');
60 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
61 $search_date_endyear = GETPOST('search_date_endyear', 'int');
62 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
63 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
64 $search_date_limit_startday = GETPOST('search_date_limit_startday', 'int');
65 $search_date_limit_startmonth = GETPOST('search_date_limit_startmonth', 'int');
66 $search_date_limit_startyear = GETPOST('search_date_limit_startyear', 'int');
67 $search_date_limit_endday = GETPOST('search_date_limit_endday', 'int');
68 $search_date_limit_endmonth = GETPOST('search_date_limit_endmonth', 'int');
69 $search_date_limit_endyear = GETPOST('search_date_limit_endyear', 'int');
70 $search_date_limit_start = dol_mktime(0, 0, 0, $search_date_limit_startmonth, $search_date_limit_startday, $search_date_limit_startyear);
71 $search_date_limit_end = dol_mktime(23, 59, 59, $search_date_limit_endmonth, $search_date_limit_endday, $search_date_limit_endyear);
72 $search_project_ref = GETPOST('search_project_ref', 'alpha');
73 $search_users = GETPOST('search_users');
74 $search_type = GETPOST('search_type', 'int');
75 $search_account = GETPOST('search_account', 'int');
76 
77 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
78 $sortfield = GETPOST('sortfield', 'aZ09comma');
79 $sortorder = GETPOST("sortorder", 'aZ09comma');
80 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
81 
82 if (empty($page) || $page == -1) {
83  $page = 0; // If $page is not defined, or '' or -1
84 }
85 $offset = $limit * $page;
86 $pageprev = $page - 1;
87 $pagenext = $page + 1;
88 
89 if (!$sortfield) {
90  $sortfield = "cs.date_ech";
91 }
92 if (!$sortorder) {
93  $sortorder = "DESC";
94 }
95 
96 $filtre = GETPOST("filtre", 'int');
97 
98 $arrayfields = array(
99  'cs.rowid' =>array('label'=>"Ref", 'checked'=>1, 'position'=>10),
100  'cs.libelle' =>array('label'=>"Label", 'checked'=>1, 'position'=>20),
101  'cs.fk_type' =>array('label'=>"Type", 'checked'=>1, 'position'=>30),
102  'cs.date_ech' =>array('label'=>"Date", 'checked'=>1, 'position'=>40),
103  'cs.periode' =>array('label'=>"PeriodEndDate", 'checked'=>1, 'position'=>50),
104  'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled('project'))),
105  'cs.fk_user' =>array('label'=>"Employee", 'checked'=>1, 'position'=>70),
106  'cs.fk_mode_reglement' =>array('checked'=>-1, 'position'=>80, 'label'=>"DefaultPaymentMode"),
107  'cs.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>100),
108  'cs.paye' =>array('label'=>"Status", 'checked'=>1, 'position'=>110),
109 );
110 
111 if (isModEnabled("banque")) {
112  $arrayfields['cs.fk_account'] = array('checked'=>-1, 'position'=>90, 'label'=>"DefaultBankAccount");
113 }
114 
115 $arrayfields = dol_sort_array($arrayfields, 'position');
116 
117 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
118 $hookmanager->initHooks(array('sclist'));
119 $object = new ChargeSociales($db);
120 
121 // Security check
122 $socid = GETPOST("socid", 'int');
123 if ($user->socid) {
124  $socid = $user->socid;
125 }
126 $result = restrictedArea($user, 'tax', '', 'chargesociales', 'charges');
127 
128 
129 /*
130  * Actions
131  */
132 
133 $parameters = array('socid'=>$socid);
134 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
135 if ($reshook < 0) {
136  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
137 }
138 
139 
140 if (empty($reshook)) {
141  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
142 
143  // All tests are required to be compatible with all browsers
144  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
145  $search_ref = '';
146  $search_label = '';
147  $search_amount = '';
148  $search_status = '';
149  $search_typeid = '';
150  $search_date_startday = '';
151  $search_date_startmonth = '';
152  $search_date_startyear = '';
153  $search_date_endday = '';
154  $search_date_endmonth = '';
155  $search_date_endyear = '';
156  $search_date_start = '';
157  $search_date_end = '';
158  $search_date_limit_startday = '';
159  $search_date_limit_startmonth = '';
160  $search_date_limit_startyear = '';
161  $search_date_limit_endday = '';
162  $search_date_limit_endmonth = '';
163  $search_date_limit_endyear = '';
164  $search_date_limit_start = '';
165  $search_date_limit_end = '';
166  $search_project_ref = '';
167  $search_users = '';
168  $search_type = '';
169  $search_account = '';
170  $search_array_options = array();
171  }
172 }
173 
174 /*
175  * View
176  */
177 
178 $form = new Form($db);
179 $formother = new FormOther($db);
180 $bankstatic = new Account($db);
181 $formsocialcontrib = new FormSocialContrib($db);
182 $chargesociale_static = new ChargeSociales($db);
183 if (isModEnabled('project')) {
184  $projectstatic = new Project($db);
185 }
186 
187 llxHeader('', $langs->trans("SocialContributions"));
188 
189 $sql = "SELECT cs.rowid, cs.fk_type as type, cs.fk_user,";
190 $sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode, cs.fk_account,";
191 if (isModEnabled('project')) {
192  $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
193 }
194 $sql .= " c.libelle as type_label, c.accountancy_code as type_accountancy_code,";
195 $sql .= " ba.label as blabel, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos,";
196 $sql .= " SUM(pc.amount) as alreadypayed, pay.code as payment_code";
197 
198 $sqlfields = $sql; // $sql fields to remove for count total
199 
200 $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
201 $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs";
202 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (cs.fk_account = ba.rowid)";
203 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pay ON (cs.fk_mode_reglement = pay.id)';
204 if (isModEnabled('project')) {
205  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cs.fk_projet";
206 }
207 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
208 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON (cs.fk_user = u.rowid)";
209 $sql .= " WHERE cs.fk_type = c.id";
210 $sql .= " AND cs.entity = ".((int) $conf->entity);
211 // Search criteria
212 if ($search_ref) {
213  $sql .= " AND cs.ref = '".$db->escape($search_ref)."'";
214 }
215 if ($search_label) {
216  $sql .= natural_search("cs.libelle", $search_label);
217 }
218 if (isModEnabled('project')) {
219  if ($search_project_ref != '') {
220  $sql .= natural_search("p.ref", $search_project_ref);
221  }
222 }
223 if (!empty($search_users)) {
224  $sql .= ' AND cs.fk_user IN ('.$db->sanitize(implode(', ', $search_users)).')';
225 }
226 if (!empty($search_type) && $search_type > 0) {
227  $sql .= ' AND cs.fk_mode_reglement='.((int) $search_type);
228 }
229 if (!empty($search_account) && $search_account > 0) {
230  $sql .= ' AND cs.fk_account='.((int) $search_account);
231 }
232 if ($search_amount) {
233  $sql .= natural_search("cs.amount", $search_amount, 1);
234 }
235 if ($search_status != '' && $search_status >= 0) {
236  $sql .= " AND cs.paye = ".((int) $search_status);
237 }
238 if ($search_date_start) {
239  $sql .= " AND cs.date_ech >= '".$db->idate($search_date_start)."'";
240 }
241 if ($search_date_end) {
242  $sql .= " AND cs.date_ech <= '".$db->idate($search_date_end)."'";
243 }
244 if ($search_date_limit_start) {
245  $sql .= " AND cs.periode >= '".$db->idate($search_date_limit_start)."'";
246 }
247 if ($search_date_limit_end) {
248  $sql .= " AND cs.periode <= '".$db->idate($search_date_limit_end)."'";
249 }
250 if ($search_typeid > 0) {
251  $sql .= " AND cs.fk_type = ".((int) $search_typeid);
252 }
253 $sql .= " GROUP BY cs.rowid, cs.fk_type, cs.fk_user, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, cs.fk_account, c.libelle, c.accountancy_code, ba.label, ba.ref, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos, pay.code, u.lastname";
254 if (isModEnabled('project')) {
255  $sql .= ", p.rowid, p.ref, p.title";
256 }
257 
258 // Count total nb of records
259 $nbtotalofrecords = '';
260 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
261  /* The fast and low memory method to get and count full list converts the sql into a sql count */
262  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
263  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
264  $resql = $db->query($sqlforcount);
265  if ($resql) {
266  $objforcount = $db->fetch_object($resql);
267  $nbtotalofrecords = $objforcount->nbtotalofrecords;
268  } else {
269  dol_print_error($db);
270  }
271 
272  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
273  $page = 0;
274  $offset = 0;
275  }
276  $db->free($resql);
277 }
278 
279 // Complete request and execute it with limit
280 $sql .= $db->order($sortfield, $sortorder);
281 if ($limit) {
282  $sql .= $db->plimit($limit + 1, $offset);
283 }
284 
285 $resql = $db->query($sql);
286 if (!$resql) {
287  dol_print_error($db);
288  llxFooter();
289  $db->close();
290  exit;
291 }
292 
293 $num = $db->num_rows($resql);
294 $i = 0;
295 
296 $param = '';
297 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
298  $param .= '&contextpage='.urlencode($contextpage);
299 }
300 if ($limit > 0 && $limit != $conf->liste_limit) {
301  $param .= '&limit='.urlencode($limit);
302 }
303 if ($search_ref) {
304  $param .= '&search_ref='.urlencode($search_ref);
305 }
306 if ($search_label) {
307  $param .= '&search_label='.urlencode($search_label);
308 }
309 if ($search_project_ref >= 0) {
310  $param .= "&search_project_ref=".urlencode($search_project_ref);
311 }
312 if ($search_amount) {
313  $param .= '&search_amount='.urlencode($search_amount);
314 }
315 if ($search_typeid) {
316  $param .= '&search_typeid='.urlencode($search_typeid);
317 }
318 if ($search_users) {
319  foreach ($search_users as $id_user) {
320  $param .= '&search_users[]='.urlencode($id_user);
321  }
322 }
323 if ($search_type) {
324  $param .= '&search_type='.urlencode($search_type);
325 }
326 if ($search_account) {
327  $param .= '&search_account='.$search_account;
328 }
329 if ($search_status != '' && $search_status != '-1') {
330  $param .= '&search_status='.urlencode($search_status);
331 }
332 if ($search_date_startday) {
333  $param .= '&search_date_startday='.urlencode($search_date_startday);
334 }
335 if ($search_date_startmonth) {
336  $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
337 }
338 if ($search_date_startyear) {
339  $param .= '&search_date_startyear='.urlencode($search_date_startyear);
340 }
341 if ($search_date_endday) {
342  $param .= '&search_date_endday='.urlencode($search_date_endday);
343 }
344 if ($search_date_endmonth) {
345  $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
346 }
347 if ($search_date_endyear) {
348  $param .= '&search_date_endyear='.urlencode($search_date_endyear);
349 }
350 if ($search_date_limit_startday) {
351  $param .= '&search_date_limit_startday='.urlencode($search_date_limit_startday);
352 }
353 if ($search_date_limit_startmonth) {
354  $param .= '&search_date_limit_startmonth='.urlencode($search_date_limit_startmonth);
355 }
356 if ($search_date_limit_startyear) {
357  $param .= '&search_date_limit_startyear='.urlencode($search_date_limit_startyear);
358 }
359 if ($search_date_limit_endday) {
360  $param .= '&search_date_limit_endday='.urlencode($search_date_limit_endday);
361 }
362 if ($search_date_limit_endmonth) {
363  $param .= '&search_date_limit_endmonth='.urlencode($search_date_limit_endmonth);
364 }
365 if ($search_date_limit_endyear) {
366  $param .= '&search_date_limit_endyear='.urlencode($search_date_limit_endyear);
367 }
368 
369 $newcardbutton = '';
370 if ($user->rights->tax->charges->creer) {
371  $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create');
372 }
373 
374 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
375 if ($optioncss != '') {
376  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
377 }
378 print '<input type="hidden" name="token" value="'.newToken().'">';
379 print '<input type="hidden" name="action" value="list">';
380 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
381 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
382 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
383 print '<input type="hidden" name="search_status" value="'.$search_status.'">';
384 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
385 
386 $center = '';
387 
388 print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1);
389 
390 if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
391  print '<div class="error">';
392  $langs->load("errors");
393  $countrynotdefined = $langs->trans("ErrorSetACountryFirst");
394  print $countrynotdefined;
395  print '</div>';
396 
397  print '</form>';
398  llxFooter();
399  $db->close();
400 }
401 
402 $moreforfilter = '';
403 $massactionbutton = '';
404 
405 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
406 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
407 if ($massactionbutton) {
408  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
409 }
410 
411 print '<div class="div-table-responsive">';
412 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">'."\n";
413 
414 print '<tr class="liste_titre_filter">';
415 
416 // Filters: Line number (placeholder)
417 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
418  print '<td class="liste_titre">';
419  print '</td>';
420 }
421 
422 // Filter: Ref
423 if (!empty($arrayfields['cs.rowid']['checked'])) {
424  print '<td class="liste_titre">';
425  print '<input class="flat maxwidth75" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
426  print '</td>';
427 }
428 
429 // Filter: Label
430 if (!empty($arrayfields['cs.rowid']['checked'])) {
431  print '<td class="liste_titre">';
432  print '<input type="text" class="flat maxwidth100" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
433  print '</td>';
434 }
435 
436 // Filter: Type
437 if (!empty($arrayfields['cs.fk_type']['checked'])) {
438  print '<td class="liste_titre">';
439  $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth150', 1);
440  print '</td>';
441 }
442 
443 // Filter: Date (placeholder)
444 if (!empty($arrayfields['cs.date_ech']['checked'])) {
445  print '<td class="liste_titre center">';
446  print '<div class="nowrap">';
447  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
448  print '</div>';
449  print '<div class="nowrap">';
450  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
451  print '</div>';
452  print '</td>';
453 }
454 
455 // Filter: Period end date
456 if (!empty($arrayfields['cs.periode']['checked'])) {
457  print '<td class="liste_titre center">';
458  print '<div class="nowrap">';
459  print $form->selectDate($search_date_limit_start ? $search_date_limit_start : -1, 'search_date_limit_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
460  print '</div>';
461  print '<div class="nowrap">';
462  print $form->selectDate($search_date_limit_end ? $search_date_limit_end : -1, 'search_date_limit_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
463  print '</div>';
464  print '</td>';
465 }
466 
467 // Filter: Project ref
468 if (!empty($arrayfields['p.ref']['checked'])) {
469  print '<td class="liste_titre">';
470  print '<input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'">';
471  print '</td>';
472 }
473 
474 if (!empty($arrayfields['cs.fk_user']['checked'])) {
475  // Employee
476  print '<td class="liste_titre">';
477  print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth150', 0, 0, true);
478  print '</td>';
479 }
480 
481 // Filter: Type
482 if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
483  print '<td class="liste_titre">';
484  print $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 0, 1, 'maxwidth150', 1);
485  print '</td>';
486 }
487 
488 // Filter: Bank Account
489 if (!empty($arrayfields['cs.fk_account']['checked'])) {
490  print '<td class="liste_titre">';
491  $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth150');
492  print '</td>';
493 }
494 
495 // Filter: Amount
496 if (!empty($arrayfields['cs.amount']['checked'])) {
497  print '<td class="liste_titre right">';
498  print '<input class="flat maxwidth75" type="text" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
499  print '</td>';
500 }
501 
502 // Filter: Status
503 if (!empty($arrayfields['cs.paye']['checked'])) {
504  print '<td class="liste_titre maxwidthonsmartphone right">';
505  $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid"));
506  print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 onrightofpage', 1);
507  print '</td>';
508 }
509 
510 // Fields from hook
511 $parameters = array('arrayfields'=>$arrayfields);
512 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
513 print $hookmanager->resPrint;
514 
515 // Filter: Buttons
516 print '<td class="liste_titre maxwidthsearch">';
517 print $form->showFilterAndCheckAddButtons(0);
518 print '</td>';
519 
520 print '</tr>';
521 
522 print '<tr class="liste_titre">';
523 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
524  print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
525 }
526 if (!empty($arrayfields['cs.rowid']['checked'])) {
527  print_liste_field_titre($arrayfields['cs.rowid']['label'], $_SERVER["PHP_SELF"], "cs.rowid", '', $param, '', $sortfield, $sortorder);
528 }
529 if (!empty($arrayfields['cs.libelle']['checked'])) {
530  print_liste_field_titre($arrayfields['cs.libelle']['label'], $_SERVER["PHP_SELF"], "cs.libelle,cs.periode", '', $param, '', $sortfield, $sortorder);
531 }
532 if (!empty($arrayfields['cs.fk_type']['checked'])) {
533  print_liste_field_titre($arrayfields['cs.fk_type']['label'], $_SERVER["PHP_SELF"], "cs.fk_type,cs.periode", '', $param, '', $sortfield, $sortorder);
534 }
535 if (!empty($arrayfields['cs.date_ech']['checked'])) {
536  print_liste_field_titre($arrayfields['cs.date_ech']['label'], $_SERVER["PHP_SELF"], "cs.date_ech,cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
537 }
538 if (!empty($arrayfields['cs.periode']['checked'])) {
539  print_liste_field_titre($arrayfields['cs.periode']['label'], $_SERVER["PHP_SELF"], "cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
540 }
541 if (!empty($arrayfields['p.ref']['checked'])) {
542  print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
543 }
544 if (!empty($arrayfields['cs.fk_user']['checked'])) {
545  print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname,cs.periode", "", $param, 'class="left"', $sortfield, $sortorder);
546 }
547 if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
548  print_liste_field_titre($arrayfields['cs.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "cs.fk_mode_reglement,cs.periode", '', $param, '', $sortfield, $sortorder);
549 }
550 if (!empty($arrayfields['cs.fk_account']['checked'])) {
551  print_liste_field_titre($arrayfields['cs.fk_account']['label'], $_SERVER["PHP_SELF"], "cs.fk_account,cs.periode", '', $param, '', $sortfield, $sortorder);
552 }
553 if (!empty($arrayfields['cs.amount']['checked'])) {
554  print_liste_field_titre($arrayfields['cs.amount']['label'], $_SERVER["PHP_SELF"], "cs.amount,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
555 }
556 if (!empty($arrayfields['cs.paye']['checked'])) {
557  print_liste_field_titre($arrayfields['cs.paye']['label'], $_SERVER["PHP_SELF"], "cs.paye,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
558 }
559 
560 // Hook fields
561 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
562 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
563 print $hookmanager->resPrint;
564 
565 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
566 print '</tr>';
567 
568 $i = 0;
569 $totalarray = $TLoadedUsers = array();
570 $totalarray['nbfield'] = 0;
571 $totalarray['val']['totalttcfield'] = 0;
572 while ($i < min($num, $limit)) {
573  $obj = $db->fetch_object($resql);
574 
575  $chargesociale_static->id = $obj->rowid;
576  $chargesociale_static->ref = $obj->rowid;
577  $chargesociale_static->label = $obj->label;
578  $chargesociale_static->type_label = $obj->type_label;
579 
580  if (isModEnabled('project')) {
581  $projectstatic->id = $obj->project_id;
582  $projectstatic->ref = $obj->project_ref;
583  $projectstatic->title = $obj->project_label;
584  }
585 
586  print '<tr class="oddeven">';
587 
588  // Line number
589  if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
590  print '<td>'.(($offset * $limit) + $i).'</td>';
591  if (!$i) {
592  $totalarray['nbfield']++;
593  }
594  }
595 
596  // Ref
597  if (!empty($arrayfields['cs.rowid']['checked'])) {
598  print '<td>'.$chargesociale_static->getNomUrl(1, '20').'</td>';
599  if (!$i) {
600  $totalarray['nbfield']++;
601  }
602  }
603 
604  // Label
605  if (!empty($arrayfields['cs.libelle']['checked'])) {
606  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).'">'.dol_escape_htmltag($obj->label).'</td>';
607  if (!$i) {
608  $totalarray['nbfield']++;
609  }
610  }
611 
612  // Type
613  if (!empty($arrayfields['cs.fk_type']['checked'])) {
614  $typelabeltoshow = $obj->type_label;
615  $typelabelpopup = $obj->type_label;
616  if (isModEnabled('accounting')) {
617  $typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code;
618  }
619  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($typelabelpopup).'">'.dol_escape_htmltag($typelabeltoshow).'</td>';
620  if (!$i) {
621  $totalarray['nbfield']++;
622  }
623  }
624 
625  // Date
626  if (!empty($arrayfields['cs.date_ech']['checked'])) {
627  print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
628  if (!$i) {
629  $totalarray['nbfield']++;
630  }
631  }
632 
633  // Date end period
634  if (!empty($arrayfields['cs.periode']['checked'])) {
635  print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->periode), 'day').'</td>';
636  if (!$i) {
637  $totalarray['nbfield']++;
638  }
639  }
640 
641  // Project ref
642  if (!empty($arrayfields['p.ref']['checked'])) {
643  print '<td class="nowraponall">';
644  if ($obj->project_id > 0) {
645  print $projectstatic->getNomUrl(1);
646  }
647  print '</td>';
648  if (!$i) {
649  $totalarray['nbfield']++;
650  }
651  }
652 
653  if (!empty($arrayfields['cs.fk_user']['checked'])) {
654  // Employee
655  print '<td class="tdoverflowmax150">';
656  if (!empty($obj->fk_user)) {
657  if (!empty($TLoadedUsers[$obj->fk_user])) {
658  $ustatic = $TLoadedUsers[$obj->fk_user];
659  } else {
660  $ustatic = new User($db);
661  $ustatic->fetch($obj->fk_user);
662  $TLoadedUsers[$obj->fk_user] = $ustatic;
663  }
664  print $ustatic->getNomUrl(-1);
665  }
666  print "</td>\n";
667  if (!$i) {
668  $totalarray['nbfield']++;
669  }
670  }
671 
672  // Type
673  if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
674  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans("PaymentTypeShort".$obj->payment_code)).'">';
675  if (!empty($obj->payment_code)) {
676  print $langs->trans("PaymentTypeShort".$obj->payment_code);
677  }
678  print '</td>';
679  if (!$i) {
680  $totalarray['nbfield']++;
681  }
682  }
683 
684  // Account
685  if (!empty($arrayfields['cs.fk_account']['checked'])) {
686  print '<td class="toverflowmax150">';
687  if ($obj->fk_account > 0) {
688  $bankstatic->id = $obj->fk_account;
689  $bankstatic->ref = $obj->bref;
690  $bankstatic->number = $obj->bnumber;
691  $bankstatic->iban = $obj->iban;
692  $bankstatic->bic = $obj->bic;
693  $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
694  $bankstatic->account_number = $obj->account_number;
695  $bankstatic->clos = $obj->clos;
696 
697  //$accountingjournal->fetch($obj->fk_accountancy_journal);
698  //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
699 
700  $bankstatic->label = $obj->blabel;
701  print $bankstatic->getNomUrl(1);
702  }
703  print '</td>';
704  if (!$i) $totalarray['nbfield']++;
705  }
706 
707  // Amount
708  if (!empty($arrayfields['cs.amount']['checked'])) {
709  print '<td class="nowraponall amount right">'.price($obj->amount).'</td>';
710  if (!$i) {
711  $totalarray['nbfield']++;
712  }
713  if (!$i) {
714  $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
715  }
716  $totalarray['val']['totalttcfield'] += $obj->amount;
717  }
718 
719  // Status
720  if (!empty($arrayfields['cs.paye']['checked'])) {
721  print '<td class="nowraponall right">'.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>';
722  if (!$i) {
723  $totalarray['nbfield']++;
724  }
725  }
726 
727  // Buttons
728  print '<td></td>';
729  if (!$i) {
730  $totalarray['nbfield']++;
731  }
732 
733  print '</tr>'."\n";
734 
735  $i++;
736 }
737 
738 // Show total line
739 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
740 
741 // If no record found
742 if ($num == 0) {
743  $colspan = 1;
744  foreach ($arrayfields as $key => $val) {
745  if (!empty($val['checked'])) {
746  $colspan++;
747  }
748  }
749  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
750 }
751 
752 $db->free($resql);
753 
754 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
755 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
756 print $hookmanager->resPrint;
757 
758 print '</table>'."\n";
759 print '</div>'."\n";
760 
761 print '</form>'."\n";
762 
763 // End of page
764 llxFooter();
765 $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.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
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 generation of HTML components for social contributions management.
Class to manage projects.
Class to manage Dolibarr users.
Definition: user.class.php:47
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)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
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.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
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.