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