dolibarr  18.0.6
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-2023 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 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
39 
40 // Load translation files required by the page
41 $langs->loadLangs(array('compta', 'banks', 'bills', 'hrm', 'projects'));
42 
43 $action = GETPOST('action', 'aZ09');
44 $massaction = GETPOST('massaction', 'alpha');
45 $confirm = GETPOST('confirm', 'alpha');
46 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
47 $optioncss = GETPOST('optioncss', 'alpha');
48 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist';
49 $mode = GETPOST('mode', 'alpha');
50 
51 
52 $search_ref = GETPOST('search_ref', 'int');
53 $search_label = GETPOST('search_label', 'alpha');
54 $search_typeid = GETPOST('search_typeid', 'int');
55 $search_amount = GETPOST('search_amount', 'alpha');
56 $search_status = GETPOST('search_status', 'int');
57 $search_date_startday = GETPOST('search_date_startday', 'int');
58 $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
59 $search_date_startyear = GETPOST('search_date_startyear', 'int');
60 $search_date_endday = GETPOST('search_date_endday', 'int');
61 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
62 $search_date_endyear = GETPOST('search_date_endyear', 'int');
63 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
64 $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
65 $search_date_limit_startday = GETPOST('search_date_limit_startday', 'int');
66 $search_date_limit_startmonth = GETPOST('search_date_limit_startmonth', 'int');
67 $search_date_limit_startyear = GETPOST('search_date_limit_startyear', 'int');
68 $search_date_limit_endday = GETPOST('search_date_limit_endday', 'int');
69 $search_date_limit_endmonth = GETPOST('search_date_limit_endmonth', 'int');
70 $search_date_limit_endyear = GETPOST('search_date_limit_endyear', 'int');
71 $search_date_limit_start = dol_mktime(0, 0, 0, $search_date_limit_startmonth, $search_date_limit_startday, $search_date_limit_startyear);
72 $search_date_limit_end = dol_mktime(23, 59, 59, $search_date_limit_endmonth, $search_date_limit_endday, $search_date_limit_endyear);
73 $search_project_ref = GETPOST('search_project_ref', 'alpha');
74 $search_users = GETPOST('search_users');
75 $search_type = GETPOST('search_type', 'int');
76 $search_account = GETPOST('search_account', 'int');
77 
78 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
79 $sortfield = GETPOST('sortfield', 'aZ09comma');
80 $sortorder = GETPOST("sortorder", 'aZ09comma');
81 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
82 
83 if (empty($page) || $page == -1) {
84  $page = 0; // If $page is not defined, or '' or -1
85 }
86 $offset = $limit * $page;
87 $pageprev = $page - 1;
88 $pagenext = $page + 1;
89 
90 if (!$sortfield) {
91  $sortfield = "cs.date_ech";
92 }
93 if (!$sortorder) {
94  $sortorder = "DESC";
95 }
96 
97 $filtre = GETPOST("filtre", 'int');
98 
99 $arrayfields = array(
100  'cs.rowid' =>array('label'=>"Ref", 'checked'=>1, 'position'=>10),
101  'cs.libelle' =>array('label'=>"Label", 'checked'=>1, 'position'=>20),
102  'cs.fk_type' =>array('label'=>"Type", 'checked'=>1, 'position'=>30),
103  'cs.date_ech' =>array('label'=>"Date", 'checked'=>1, 'position'=>40),
104  'cs.periode' =>array('label'=>"PeriodEndDate", 'checked'=>1, 'position'=>50),
105  'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>60, 'enabled'=>(isModEnabled('project'))),
106  'cs.fk_user' =>array('label'=>"Employee", 'checked'=>1, 'position'=>70),
107  'cs.fk_mode_reglement' =>array('checked'=>-1, 'position'=>80, 'label'=>"DefaultPaymentMode"),
108  'cs.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>100),
109  'cs.paye' =>array('label'=>"Status", 'checked'=>1, 'position'=>110),
110 );
111 
112 if (isModEnabled("banque")) {
113  $arrayfields['cs.fk_account'] = array('checked'=>-1, 'position'=>90, 'label'=>"DefaultBankAccount");
114 }
115 
116 $arrayfields = dol_sort_array($arrayfields, 'position');
117 
118 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
119 $hookmanager->initHooks(array('sclist'));
120 $object = new ChargeSociales($db);
121 
122 // Security check
123 $socid = GETPOST("socid", 'int');
124 if ($user->socid) {
125  $socid = $user->socid;
126 }
127 $result = restrictedArea($user, 'tax', '', 'chargesociales', 'charges');
128 $permissiontodelete = $user->rights->tax->charges->supprimer;
129 
130 
131 /*
132  * Actions
133  */
134 
135 $parameters = array('socid'=>$socid);
136 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
137 if ($reshook < 0) {
138  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
139 }
140 
141 
142 if (empty($reshook)) {
143  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
144 
145  // All tests are required to be compatible with all browsers
146  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
147  $search_ref = '';
148  $search_label = '';
149  $search_amount = '';
150  $search_status = '';
151  $search_typeid = '';
152  $search_date_startday = '';
153  $search_date_startmonth = '';
154  $search_date_startyear = '';
155  $search_date_endday = '';
156  $search_date_endmonth = '';
157  $search_date_endyear = '';
158  $search_date_start = '';
159  $search_date_end = '';
160  $search_date_limit_startday = '';
161  $search_date_limit_startmonth = '';
162  $search_date_limit_startyear = '';
163  $search_date_limit_endday = '';
164  $search_date_limit_endmonth = '';
165  $search_date_limit_endyear = '';
166  $search_date_limit_start = '';
167  $search_date_limit_end = '';
168  $search_project_ref = '';
169  $search_users = '';
170  $search_type = '';
171  $search_account = '';
172  $search_array_options = array();
173  $toselect = array();
174  }
175 
176  // Mass actions
177  $objectclass = 'ChargeSociales';
178  $objectlabel = 'ChargeSociales';
179  $uploaddir = $conf->tax->dir_output;
180  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
181 }
182 
183 /*
184  * View
185  */
186 
187 $form = new Form($db);
188 $formother = new FormOther($db);
189 $bankstatic = new Account($db);
190 $formsocialcontrib = new FormSocialContrib($db);
191 $chargesociale_static = new ChargeSociales($db);
192 $projectstatic = new Project($db);
193 
194 llxHeader('', $langs->trans("SocialContributions"));
195 
196 $arrayofselected = is_array($toselect) ? $toselect : array();
197 
198 $sql = "SELECT cs.rowid, cs.fk_type as type, cs.fk_user,";
199 $sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode, cs.fk_account,";
200 if (isModEnabled('project')) {
201  $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
202 }
203 $sql .= " c.libelle as type_label, c.accountancy_code as type_accountancy_code,";
204 $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,";
205 $sql .= " pay.code as payment_code";
206 $sqlfields = $sql; // $sql fields to remove for count total
207 
208 $sql .= ", SUM(pc.amount) as alreadypayed";
209 
210 $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
211 $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs";
212 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (cs.fk_account = ba.rowid)";
213 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pay ON (cs.fk_mode_reglement = pay.id)';
214 if (isModEnabled('project')) {
215  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cs.fk_projet";
216 }
217 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
218 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON (cs.fk_user = u.rowid)";
219 $sql .= " WHERE cs.fk_type = c.id";
220 $sql .= " AND cs.entity = ".((int) $conf->entity);
221 // Search criteria
222 if ($search_ref) {
223  $sql .= " AND cs.ref = '".$db->escape($search_ref)."'";
224 }
225 if ($search_label) {
226  $sql .= natural_search("cs.libelle", $search_label);
227 }
228 if (isModEnabled('project')) {
229  if ($search_project_ref != '') {
230  $sql .= natural_search("p.ref", $search_project_ref);
231  }
232 }
233 if (!empty($search_users)) {
234  $sql .= ' AND cs.fk_user IN ('.$db->sanitize(implode(', ', $search_users)).')';
235 }
236 if (!empty($search_type) && $search_type > 0) {
237  $sql .= ' AND cs.fk_mode_reglement='.((int) $search_type);
238 }
239 if (!empty($search_account) && $search_account > 0) {
240  $sql .= ' AND cs.fk_account='.((int) $search_account);
241 }
242 if ($search_amount) {
243  $sql .= natural_search("cs.amount", $search_amount, 1);
244 }
245 if ($search_status != '' && $search_status >= 0) {
246  $sql .= " AND cs.paye = ".((int) $search_status);
247 }
248 if ($search_date_start) {
249  $sql .= " AND cs.date_ech >= '".$db->idate($search_date_start)."'";
250 }
251 if ($search_date_end) {
252  $sql .= " AND cs.date_ech <= '".$db->idate($search_date_end)."'";
253 }
254 if ($search_date_limit_start) {
255  $sql .= " AND cs.periode >= '".$db->idate($search_date_limit_start)."'";
256 }
257 if ($search_date_limit_end) {
258  $sql .= " AND cs.periode <= '".$db->idate($search_date_limit_end)."'";
259 }
260 if ($search_typeid > 0) {
261  $sql .= " AND cs.fk_type = ".((int) $search_typeid);
262 }
263 $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";
264 if (isModEnabled('project')) {
265  $sql .= ", p.rowid, p.ref, p.title";
266 }
267 
268 // Count total nb of records
269 $nbtotalofrecords = '';
270 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
271  /* The fast and low memory method to get and count full list converts the sql into a sql count */
272  $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT cs.rowid) as nbtotalofrecords', $sql);
273  $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
274  $resql = $db->query($sqlforcount);
275  if ($resql) {
276  $objforcount = $db->fetch_object($resql);
277  $nbtotalofrecords = $objforcount->nbtotalofrecords;
278  } else {
279  dol_print_error($db);
280  }
281 
282  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
283  $page = 0;
284  $offset = 0;
285  }
286  $db->free($resql);
287 }
288 
289 // Complete request and execute it with limit
290 $sql .= $db->order($sortfield, $sortorder);
291 if ($limit) {
292  $sql .= $db->plimit($limit + 1, $offset);
293 }
294 
295 $resql = $db->query($sql);
296 if (!$resql) {
297  dol_print_error($db);
298  llxFooter();
299  $db->close();
300  exit;
301 }
302 
303 $num = $db->num_rows($resql);
304 $i = 0;
305 
306 $param = '';
307 if (!empty($mode)) {
308  $param .= '&mode='.urlencode($mode);
309 }
310 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
311  $param .= '&contextpage='.urlencode($contextpage);
312 }
313 if ($limit > 0 && $limit != $conf->liste_limit) {
314  $param .= '&limit='.((int) $limit);
315 }
316 if ($search_ref) {
317  $param .= '&search_ref='.urlencode($search_ref);
318 }
319 if ($search_label) {
320  $param .= '&search_label='.urlencode($search_label);
321 }
322 if ($search_project_ref >= 0) {
323  $param .= "&search_project_ref=".urlencode($search_project_ref);
324 }
325 if ($search_amount) {
326  $param .= '&search_amount='.urlencode($search_amount);
327 }
328 if ($search_typeid) {
329  $param .= '&search_typeid='.urlencode($search_typeid);
330 }
331 if ($search_users) {
332  foreach ($search_users as $id_user) {
333  $param .= '&search_users[]='.urlencode($id_user);
334  }
335 }
336 if ($search_type) {
337  $param .= '&search_type='.urlencode($search_type);
338 }
339 if ($search_account) {
340  $param .= '&search_account='.$search_account;
341 }
342 if ($search_status != '' && $search_status != '-1') {
343  $param .= '&search_status='.urlencode($search_status);
344 }
345 if ($search_date_startday) {
346  $param .= '&search_date_startday='.urlencode($search_date_startday);
347 }
348 if ($search_date_startmonth) {
349  $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
350 }
351 if ($search_date_startyear) {
352  $param .= '&search_date_startyear='.urlencode($search_date_startyear);
353 }
354 if ($search_date_endday) {
355  $param .= '&search_date_endday='.urlencode($search_date_endday);
356 }
357 if ($search_date_endmonth) {
358  $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
359 }
360 if ($search_date_endyear) {
361  $param .= '&search_date_endyear='.urlencode($search_date_endyear);
362 }
363 if ($search_date_limit_startday) {
364  $param .= '&search_date_limit_startday='.urlencode($search_date_limit_startday);
365 }
366 if ($search_date_limit_startmonth) {
367  $param .= '&search_date_limit_startmonth='.urlencode($search_date_limit_startmonth);
368 }
369 if ($search_date_limit_startyear) {
370  $param .= '&search_date_limit_startyear='.urlencode($search_date_limit_startyear);
371 }
372 if ($search_date_limit_endday) {
373  $param .= '&search_date_limit_endday='.urlencode($search_date_limit_endday);
374 }
375 if ($search_date_limit_endmonth) {
376  $param .= '&search_date_limit_endmonth='.urlencode($search_date_limit_endmonth);
377 }
378 if ($search_date_limit_endyear) {
379  $param .= '&search_date_limit_endyear='.urlencode($search_date_limit_endyear);
380 }
381 
382 $newcardbutton = '';
383 $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'));
384 $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'));
385 if ($user->rights->tax->charges->creer) {
386  $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create');
387 }
388 
389 
390 // List of mass actions available
391 $arrayofmassactions = array();
392 if (!empty($permissiontodelete)) {
393  $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
394 }
395 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
396 $moreforfilter = '';
397 
398 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
399 if ($optioncss != '') {
400  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
401 }
402 print '<input type="hidden" name="token" value="'.newToken().'">';
403 print '<input type="hidden" name="action" value="list">';
404 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
405 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
406 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
407 print '<input type="hidden" name="search_status" value="'.$search_status.'">';
408 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
409 print '<input type="hidden" name="mode" value="'.$mode.'">';
410 
411 
412 print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1);
413 
414 if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
415  print '<div class="error">';
416  $langs->load("errors");
417  $countrynotdefined = $langs->trans("ErrorSetACountryFirst");
418  print $countrynotdefined;
419  print '</div>';
420 
421  print '</form>';
422  llxFooter();
423  $db->close();
424 }
425 
426 
427 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
428 $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
429 if ($massactionbutton) {
430  $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
431 }
432 
433 $objecttmp = new ChargeSociales($db);
434 $trackid = 'sc'.$object->id;
435 include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
436 
437 print '<div class="div-table-responsive">';
438 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">'."\n";
439 
440 print '<tr class="liste_titre_filter">';
441 
442 // Filter: Buttons
443 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
444  print '<td class="liste_titre maxwidthsearch">';
445  print $form->showFilterAndCheckAddButtons(0);
446  print '</td>';
447 }
448 
449 // Filters: Line number (placeholder)
450 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
451  print '<td class="liste_titre">';
452  print '</td>';
453 }
454 
455 // Filter: Ref
456 if (!empty($arrayfields['cs.rowid']['checked'])) {
457  print '<td class="liste_titre">';
458  print '<input class="flat maxwidth75" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
459  print '</td>';
460 }
461 
462 // Filter: Label
463 if (!empty($arrayfields['cs.rowid']['checked'])) {
464  print '<td class="liste_titre">';
465  print '<input type="text" class="flat maxwidth100" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
466  print '</td>';
467 }
468 
469 // Filter: Type
470 if (!empty($arrayfields['cs.fk_type']['checked'])) {
471  print '<td class="liste_titre">';
472  $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth150', 1);
473  print '</td>';
474 }
475 
476 // Filter: Date (placeholder)
477 if (!empty($arrayfields['cs.date_ech']['checked'])) {
478  print '<td class="liste_titre center">';
479  print '<div class="nowrap">';
480  print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
481  print '</div>';
482  print '<div class="nowrap">';
483  print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
484  print '</div>';
485  print '</td>';
486 }
487 
488 // Filter: Period end date
489 if (!empty($arrayfields['cs.periode']['checked'])) {
490  print '<td class="liste_titre center">';
491  print '<div class="nowrap">';
492  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'));
493  print '</div>';
494  print '<div class="nowrap">';
495  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'));
496  print '</div>';
497  print '</td>';
498 }
499 
500 // Filter: Project ref
501 if (!empty($arrayfields['p.ref']['checked'])) {
502  print '<td class="liste_titre">';
503  print '<input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'">';
504  print '</td>';
505 }
506 
507 if (!empty($arrayfields['cs.fk_user']['checked'])) {
508  // Employee
509  print '<td class="liste_titre">';
510  print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth150', 0, 0, true);
511  print '</td>';
512 }
513 
514 // Filter: Type
515 if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
516  print '<td class="liste_titre">';
517  print $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 0, 1, 'maxwidth150', 1);
518  print '</td>';
519 }
520 
521 // Filter: Bank Account
522 if (!empty($arrayfields['cs.fk_account']['checked'])) {
523  print '<td class="liste_titre">';
524  $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth150');
525  print '</td>';
526 }
527 
528 // Filter: Amount
529 if (!empty($arrayfields['cs.amount']['checked'])) {
530  print '<td class="liste_titre right">';
531  print '<input class="flat maxwidth75" type="text" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
532  print '</td>';
533 }
534 
535 // Filter: Status
536 if (!empty($arrayfields['cs.paye']['checked'])) {
537  print '<td class="liste_titre right parentonrightofpage">';
538  $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid"));
539  print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1);
540  print '</td>';
541 }
542 
543 // Fields from hook
544 $parameters = array('arrayfields'=>$arrayfields);
545 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
546 print $hookmanager->resPrint;
547 
548 // Filter: Buttons
549 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
550  print '<td class="liste_titre maxwidthsearch">';
551  print $form->showFilterAndCheckAddButtons(0);
552  print '</td>';
553 }
554 
555 print '</tr>';
556 
557 $totalarray = array();
558 $totalarray['nbfield'] = 0;
559 
560 // Fields title label
561 // --------------------------------------------------------------------
562 print '<tr class="liste_titre">';
563 
564 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
565  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
566  $totalarray['nbfield']++;
567 }
568 
569 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
570  print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
571  $totalarray['nbfield']++;
572 }
573 if (!empty($arrayfields['cs.rowid']['checked'])) {
574  print_liste_field_titre($arrayfields['cs.rowid']['label'], $_SERVER["PHP_SELF"], "cs.rowid", '', $param, '', $sortfield, $sortorder);
575  $totalarray['nbfield']++;
576 }
577 if (!empty($arrayfields['cs.libelle']['checked'])) {
578  print_liste_field_titre($arrayfields['cs.libelle']['label'], $_SERVER["PHP_SELF"], "cs.libelle,cs.periode", '', $param, '', $sortfield, $sortorder);
579  $totalarray['nbfield']++;
580 }
581 if (!empty($arrayfields['cs.fk_type']['checked'])) {
582  print_liste_field_titre($arrayfields['cs.fk_type']['label'], $_SERVER["PHP_SELF"], "cs.fk_type,cs.periode", '', $param, '', $sortfield, $sortorder);
583  $totalarray['nbfield']++;
584 }
585 if (!empty($arrayfields['cs.date_ech']['checked'])) {
586  print_liste_field_titre($arrayfields['cs.date_ech']['label'], $_SERVER["PHP_SELF"], "cs.date_ech,cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
587  $totalarray['nbfield']++;
588 }
589 if (!empty($arrayfields['cs.periode']['checked'])) {
590  print_liste_field_titre($arrayfields['cs.periode']['label'], $_SERVER["PHP_SELF"], "cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
591  $totalarray['nbfield']++;
592 }
593 if (!empty($arrayfields['p.ref']['checked'])) {
594  print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
595  $totalarray['nbfield']++;
596 }
597 if (!empty($arrayfields['cs.fk_user']['checked'])) {
598  print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname,cs.periode", "", $param, 'class="left"', $sortfield, $sortorder);
599  $totalarray['nbfield']++;
600 }
601 if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
602  print_liste_field_titre($arrayfields['cs.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "cs.fk_mode_reglement,cs.periode", '', $param, '', $sortfield, $sortorder);
603  $totalarray['nbfield']++;
604 }
605 if (!empty($arrayfields['cs.fk_account']['checked'])) {
606  print_liste_field_titre($arrayfields['cs.fk_account']['label'], $_SERVER["PHP_SELF"], "cs.fk_account,cs.periode", '', $param, '', $sortfield, $sortorder);
607  $totalarray['nbfield']++;
608 }
609 if (!empty($arrayfields['cs.amount']['checked'])) {
610  print_liste_field_titre($arrayfields['cs.amount']['label'], $_SERVER["PHP_SELF"], "cs.amount,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
611  $totalarray['nbfield']++;
612 }
613 if (!empty($arrayfields['cs.paye']['checked'])) {
614  print_liste_field_titre($arrayfields['cs.paye']['label'], $_SERVER["PHP_SELF"], "cs.paye,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
615  $totalarray['nbfield']++;
616 }
617 
618 // Hook fields
619 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
620 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
621 print $hookmanager->resPrint;
622 
623 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
624  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
625  $totalarray['nbfield']++;
626 }
627 print '</tr>';
628 
629 // Loop on record
630 // --------------------------------------------------------------------
631 $i = 0;
632 $savnbfield = $totalarray['nbfield'];
633 $totalarray = array();
634 $totalarray['nbfield'] = 0;
635 $totalarray['val'] = array();
636 $imaxinloop = ($limit ? min($num, $limit) : $num);
637 while ($i < $imaxinloop) {
638  $obj = $db->fetch_object($resql);
639 
640  $chargesociale_static->id = $obj->rowid;
641  $chargesociale_static->ref = $obj->rowid;
642  $chargesociale_static->label = $obj->label;
643  $chargesociale_static->type_label = $obj->type_label;
644  $chargesociale_static->amount = $obj->amount;
645  $chargesociale_static->paye = $obj->paye;
646  $chargesociale_static->date_ech = $obj->date_ech;
647 
648  if (isModEnabled('project')) {
649  $projectstatic->id = $obj->project_id;
650  $projectstatic->ref = $obj->project_ref;
651  $projectstatic->title = $obj->project_label;
652  }
653 
654  if ($mode == 'kanban') {
655  if ($i == 0) {
656  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
657  print '<div class="box-flex-container kanban">';
658  }
659  // Output Kanban
660  print $chargesociale_static->getKanbanView('', array('project'=> $projectstatic, 'selected' => in_array($chargesociale_static->id, $arrayofselected)));
661  if ($i == ($imaxinloop - 1)) {
662  print '</div>';
663  print '</td></tr>';
664  }
665  } else {
666  print '<tr class="oddeven">';
667 
668 
669  // Action column
670  if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
671  print '<td class="center">';
672  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
673  $selected = 0;
674  if (in_array($chargesociale_static->id, $arrayofselected)) {
675  $selected = 1;
676  }
677  print '<input id="cb'.$chargesociale_static->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$chargesociale_static->id.'"'.($selected ? ' checked="checked"' : '').'>';
678  }
679  print '</td>';
680  if (!$i) {
681  $totalarray['nbfield']++;
682  }
683  }
684 
685  // Line number
686  if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
687  print '<td>'.(($offset * $limit) + $i).'</td>';
688  if (!$i) {
689  $totalarray['nbfield']++;
690  }
691  }
692 
693  // Ref
694  if (!empty($arrayfields['cs.rowid']['checked'])) {
695  print '<td>'.$chargesociale_static->getNomUrl(1, '20').'</td>';
696  if (!$i) {
697  $totalarray['nbfield']++;
698  }
699  }
700 
701  // Label
702  if (!empty($arrayfields['cs.libelle']['checked'])) {
703  print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).'">'.dol_escape_htmltag($obj->label).'</td>';
704  if (!$i) {
705  $totalarray['nbfield']++;
706  }
707  }
708 
709  // Type
710  if (!empty($arrayfields['cs.fk_type']['checked'])) {
711  $typelabeltoshow = $obj->type_label;
712  $typelabelpopup = $obj->type_label;
713  if (isModEnabled('accounting')) {
714  $typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code;
715  }
716  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($typelabelpopup).'">'.dol_escape_htmltag($typelabeltoshow).'</td>';
717  if (!$i) {
718  $totalarray['nbfield']++;
719  }
720  }
721 
722  // Date
723  if (!empty($arrayfields['cs.date_ech']['checked'])) {
724  print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
725  if (!$i) {
726  $totalarray['nbfield']++;
727  }
728  }
729 
730  // Date end period
731  if (!empty($arrayfields['cs.periode']['checked'])) {
732  print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->periode), 'day').'</td>';
733  if (!$i) {
734  $totalarray['nbfield']++;
735  }
736  }
737 
738  // Project ref
739  if (!empty($arrayfields['p.ref']['checked'])) {
740  print '<td class="nowraponall">';
741  if ($obj->project_id > 0) {
742  print $projectstatic->getNomUrl(1);
743  }
744  print '</td>';
745  if (!$i) {
746  $totalarray['nbfield']++;
747  }
748  }
749 
750  if (!empty($arrayfields['cs.fk_user']['checked'])) {
751  // Employee
752  print '<td class="tdoverflowmax150">';
753  if (!empty($obj->fk_user)) {
754  if (!empty($TLoadedUsers[$obj->fk_user])) {
755  $ustatic = $TLoadedUsers[$obj->fk_user];
756  } else {
757  $ustatic = new User($db);
758  $ustatic->fetch($obj->fk_user);
759  $TLoadedUsers[$obj->fk_user] = $ustatic;
760  }
761  print $ustatic->getNomUrl(-1);
762  }
763  print "</td>\n";
764  if (!$i) {
765  $totalarray['nbfield']++;
766  }
767  }
768 
769  // Type
770  if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
771  print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans("PaymentTypeShort".$obj->payment_code)).'">';
772  if (!empty($obj->payment_code)) {
773  print $langs->trans("PaymentTypeShort".$obj->payment_code);
774  }
775  print '</td>';
776  if (!$i) {
777  $totalarray['nbfield']++;
778  }
779  }
780 
781  // Account
782  if (!empty($arrayfields['cs.fk_account']['checked'])) {
783  print '<td class="toverflowmax150">';
784  if ($obj->fk_account > 0) {
785  $bankstatic->id = $obj->fk_account;
786  $bankstatic->ref = $obj->bref;
787  $bankstatic->number = $obj->bnumber;
788  $bankstatic->iban = $obj->iban;
789  $bankstatic->bic = $obj->bic;
790  $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
791  $bankstatic->account_number = $obj->account_number;
792  $bankstatic->clos = $obj->clos;
793 
794  //$accountingjournal->fetch($obj->fk_accountancy_journal);
795  //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
796 
797  $bankstatic->label = $obj->blabel;
798  print $bankstatic->getNomUrl(1);
799  }
800  print '</td>';
801  if (!$i) $totalarray['nbfield']++;
802  }
803 
804  // Amount
805  if (!empty($arrayfields['cs.amount']['checked'])) {
806  print '<td class="nowraponall amount right">'.price($obj->amount).'</td>';
807  if (!$i) {
808  $totalarray['nbfield']++;
809  }
810  if (!$i) {
811  $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
812  }
813  $totalarray['val']['totalttcfield'] += $obj->amount;
814  }
815 
816  // Status
817  if (!empty($arrayfields['cs.paye']['checked'])) {
818  print '<td class="nowraponall right">'.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>';
819  if (!$i) {
820  $totalarray['nbfield']++;
821  }
822  }
823 
824  // Action column
825  if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
826  print '<td class="center">';
827  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
828  $selected = 0;
829  if (in_array($chargesociale_static->id, $arrayofselected)) {
830  $selected = 1;
831  }
832  print '<input id="cb'.$chargesociale_static->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$chargesociale_static->id.'"'.($selected ? ' checked="checked"' : '').'>';
833  }
834  print '</td>';
835  if (!$i) {
836  $totalarray['nbfield']++;
837  }
838  }
839 
840  print '</tr>'."\n";
841  }
842  $i++;
843 }
844 
845 // Show total line
846 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
847 
848 // If no record found
849 if ($num == 0) {
850  $colspan = 1;
851  foreach ($arrayfields as $key => $val) {
852  if (!empty($val['checked'])) {
853  $colspan++;
854  }
855  }
856  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
857 }
858 
859 $db->free($resql);
860 
861 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
862 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
863 print $hookmanager->resPrint;
864 
865 print '</table>'."\n";
866 print '</div>'."\n";
867 
868 print '</form>'."\n";
869 
870 // End of page
871 llxFooter();
872 $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:48
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
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_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...
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.