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