dolibarr 25.0.0-alpha
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2016-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// Add hook to complete $arrayfield
118$parameters = array('arrayfields' => &$arrayfields);
119$reshook = $hookmanager->executeHooks('completeArrayFields', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
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) > (int) $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="'.dolBuildUrl($_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, $conf->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 ($conf->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, '', 'maxwidth125', 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, 'maxwidth125', 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, 'maxwidth125');
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 (!$conf->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 ($conf->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 (!$conf->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 // Values read from the database are strings, so they are converted with jdate() and not idate(), the same way
665 // ChargeSociales::fetch() does it. The properties are timestamps, used as such by getNomUrl() and getKanbanView().
666 $chargesociale_static->date_ech = $db->jdate($obj->date_ech); // Date of contribution
667 $chargesociale_static->period = $db->jdate($obj->period); // End date of period
668 $chargesociale_static->type_accountancy_code = $obj->type_accountancy_code;
669 $chargesociale_static->note_private = $obj->note_private;
670 $chargesociale_static->note_public = $obj->note_public;
671
672 if (isModEnabled('project')) {
673 $projectstatic->id = $obj->project_id;
674 $projectstatic->ref = $obj->project_ref;
675 $projectstatic->title = $obj->project_label;
676 }
677
678 if ($mode == 'kanban') {
679 if ($i == 0) {
680 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
681 print '<div class="box-flex-container kanban">';
682 }
683 // Output Kanban
684 print $chargesociale_static->getKanbanView('', array('project' => $projectstatic, 'selected' => in_array($chargesociale_static->id, $arrayofselected)));
685 if ($i == ($imaxinloop - 1)) {
686 print '</div>';
687 print '</td></tr>';
688 }
689 } else {
690 print '<tr class="oddeven row-with-select">';
691
692
693 // Action column
694 if ($conf->main_checkbox_left_column) {
695 print '<td class="center">';
696 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
697 $selected = 0;
698 if (in_array($chargesociale_static->id, $arrayofselected)) {
699 $selected = 1;
700 }
701 print '<input id="cb'.$chargesociale_static->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$chargesociale_static->id.'"'.($selected ? ' checked="checked"' : '').'>';
702 }
703 print '</td>';
704 if (!$i) {
705 $totalarray['nbfield']++;
706 }
707 }
708
709 // Line number
710 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
711 print '<td>'.(($offset * $limit) + $i).'</td>';
712 if (!$i) {
713 $totalarray['nbfield']++;
714 }
715 }
716
717 // Ref
718 if (!empty($arrayfields['cs.rowid']['checked'])) {
719 print '<td class="tdoverflowmax125">';
720 print $chargesociale_static->getNomUrl(1, '', 0, 0, -1, 1);
721 print '</td>';
722 if (!$i) {
723 $totalarray['nbfield']++;
724 }
725 }
726
727 // Label
728 if (!empty($arrayfields['cs.libelle']['checked'])) {
729 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).'">'.dol_escape_htmltag($obj->label).'</td>';
730 if (!$i) {
731 $totalarray['nbfield']++;
732 }
733 }
734
735 // Type
736 if (!empty($arrayfields['cs.fk_type']['checked'])) {
737 $typelabeltoshow = $obj->type_label;
738 $typelabelpopup = $obj->type_label;
739 if (isModEnabled('accounting')) {
740 $typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code;
741 }
742 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($typelabelpopup).'">'.dol_escape_htmltag($typelabeltoshow).'</td>';
743 if (!$i) {
744 $totalarray['nbfield']++;
745 }
746 }
747
748 // Date
749 if (!empty($arrayfields['cs.date_ech']['checked'])) {
750 print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
751 if (!$i) {
752 $totalarray['nbfield']++;
753 }
754 }
755
756 // Date end period
757 if (!empty($arrayfields['cs.periode']['checked'])) {
758 print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->period), 'day').'</td>';
759 if (!$i) {
760 $totalarray['nbfield']++;
761 }
762 }
763
764 // Project ref
765 if (!empty($arrayfields['p.ref']['checked'])) {
766 print '<td class="nowraponall">';
767 if ($obj->project_id > 0) {
768 print $projectstatic->getNomUrl(1);
769 }
770 print '</td>';
771 if (!$i) {
772 $totalarray['nbfield']++;
773 }
774 }
775
776 if (!empty($arrayfields['cs.fk_user']['checked'])) {
777 // Employee
778 print '<td class="tdoverflowmax150">';
779 if (!empty($obj->fk_user)) {
780 if (!empty($TLoadedUsers[$obj->fk_user])) {
781 $ustatic = $TLoadedUsers[$obj->fk_user];
782 } else {
783 $ustatic = new User($db);
784 $ustatic->fetch($obj->fk_user);
785 $TLoadedUsers[$obj->fk_user] = $ustatic;
786 }
787 print $ustatic->getNomUrl(-1);
788 }
789 print "</td>\n";
790 if (!$i) {
791 $totalarray['nbfield']++;
792 }
793 }
794
795 // Type
796 if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
797 print '<td class="tdoverflowmax150" title="'.dolPrintHTMLForAttribute($langs->trans("PaymentTypeShort".$obj->payment_code)).'">';
798 if (!empty($obj->payment_code)) {
799 print $langs->trans("PaymentTypeShort".$obj->payment_code);
800 }
801 print '</td>';
802 if (!$i) {
803 $totalarray['nbfield']++;
804 }
805 }
806
807 // Account
808 if (!empty($arrayfields['cs.fk_account']['checked'])) {
809 print '<td class="toverflowmax150">';
810 if ($obj->fk_account > 0) {
811 $bankstatic->id = $obj->fk_account;
812 $bankstatic->ref = $obj->bref;
813 $bankstatic->number = $obj->bnumber;
814 $bankstatic->iban = $obj->iban;
815 $bankstatic->bic = $obj->bic;
816 $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
817 $bankstatic->account_number = $obj->account_number;
818 $bankstatic->status = $obj->status;
819 $bankstatic->label = $obj->blabel;
820
821 //$accountingjournal->fetch($obj->fk_accountancy_journal);
822 //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
823
824 print $bankstatic->getNomUrl(1);
825 }
826 print '</td>';
827 if (!$i) {
828 $totalarray['nbfield']++;
829 }
830 }
831
832 // Amount
833 if (!empty($arrayfields['cs.amount']['checked'])) {
834 print '<td class="nowraponall amount right">'.price($obj->amount).'</td>';
835 if (!$i) {
836 $totalarray['nbfield']++;
837 $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
838 }
839 $totalarray['val']['totalttcfield'] += $obj->amount;
840 }
841
842 // Status
843 if (!empty($arrayfields['cs.paye']['checked'])) {
844 print '<td class="nowraponall right">'.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>';
845 if (!$i) {
846 $totalarray['nbfield']++;
847 }
848 }
849
850 // Action column
851 if (!$conf->main_checkbox_left_column) {
852 print '<td class="center">';
853 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
854 $selected = 0;
855 if (in_array($chargesociale_static->id, $arrayofselected)) {
856 $selected = 1;
857 }
858 print '<input id="cb'.$chargesociale_static->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$chargesociale_static->id.'"'.($selected ? ' checked="checked"' : '').'>';
859 }
860 print '</td>';
861 if (!$i) {
862 $totalarray['nbfield']++;
863 }
864 }
865
866 print '</tr>'."\n";
867 }
868 $i++;
869}
870
871// Show total line
872include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
873
874// If no record found
875if ($num == 0) {
876 $colspan = 1;
877 foreach ($arrayfields as $key => $val) {
878 if (!empty($val['checked'])) {
879 $colspan++;
880 }
881 }
882 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
883}
884
885$db->free($resql);
886
887$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
888$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
889print $hookmanager->resPrint;
890
891print '</table>'."\n";
892print '</div>'."\n";
893
894print '</form>'."\n";
895
896// End of page
897llxFooter();
898$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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
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...
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:183
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.