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