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