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