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