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