dolibarr 21.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 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 a technical object to manage hooks of page. Note that conf->hooks_modules contains an 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
198$title = $langs->trans("SocialContributions");
199
200llxHeader('', $title, '', '', 0, 0, '', '', '', 'bodyforlist');
201
202$arrayofselected = is_array($toselect) ? $toselect : array();
203
204$sql = "SELECT cs.rowid, cs.fk_type as type, cs.fk_user,";
205$sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode, cs.fk_account,";
206if (isModEnabled('project')) {
207 $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
208}
209$sql .= " c.libelle as type_label, c.accountancy_code as type_accountancy_code,";
210$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,";
211$sql .= " pay.code as payment_code";
212$sqlfields = $sql; // $sql fields to remove for count total
213
214$sql .= ", SUM(pc.amount) as alreadypayed";
215
216$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
217$sql .= " ".MAIN_DB_PREFIX."chargesociales as cs";
218$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (cs.fk_account = ba.rowid)";
219$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pay ON (cs.fk_mode_reglement = pay.id)';
220if (isModEnabled('project')) {
221 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cs.fk_projet";
222}
223$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
224$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON (cs.fk_user = u.rowid)";
225$sql .= " WHERE cs.fk_type = c.id";
226$sql .= " AND cs.entity = ".((int) $conf->entity);
227// Search criteria
228if ($search_ref) {
229 $sql .= " AND cs.ref = '".$db->escape($search_ref)."'";
230}
231if ($search_label) {
232 $sql .= natural_search("cs.libelle", $search_label);
233}
234if (isModEnabled('project')) {
235 if ($search_project_ref != '') {
236 $sql .= natural_search("p.ref", $search_project_ref);
237 }
238}
239if (!empty($search_users)) {
240 $sql .= ' AND cs.fk_user IN ('.$db->sanitize(implode(', ', $search_users)).')';
241}
242if (!empty($search_type) && $search_type > 0) {
243 $sql .= ' AND cs.fk_mode_reglement='.((int) $search_type);
244}
245if (!empty($search_account) && $search_account > 0) {
246 $sql .= ' AND cs.fk_account='.((int) $search_account);
247}
248if ($search_amount) {
249 $sql .= natural_search("cs.amount", $search_amount, 1);
250}
251if ($search_status != '' && $search_status >= 0) {
252 $sql .= " AND cs.paye = ".((int) $search_status);
253}
254if ($search_date_start) {
255 $sql .= " AND cs.date_ech >= '".$db->idate($search_date_start)."'";
256}
257if ($search_date_end) {
258 $sql .= " AND cs.date_ech <= '".$db->idate($search_date_end)."'";
259}
260if ($search_date_limit_start) {
261 $sql .= " AND cs.periode >= '".$db->idate($search_date_limit_start)."'";
262}
263if ($search_date_limit_end) {
264 $sql .= " AND cs.periode <= '".$db->idate($search_date_limit_end)."'";
265}
266if ($search_typeid > 0) {
267 $sql .= " AND cs.fk_type = ".((int) $search_typeid);
268}
269$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";
270if (isModEnabled('project')) {
271 $sql .= ", p.rowid, p.ref, p.title";
272}
273
274// Count total nb of records
275$nbtotalofrecords = '';
276if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
277 /* The fast and low memory method to get and count full list converts the sql into a sql count */
278 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT cs.rowid) as nbtotalofrecords', $sql);
279 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
280 $resql = $db->query($sqlforcount);
281 if ($resql) {
282 $objforcount = $db->fetch_object($resql);
283 $nbtotalofrecords = $objforcount->nbtotalofrecords;
284 } else {
285 dol_print_error($db);
286 }
287
288 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
289 $page = 0;
290 $offset = 0;
291 }
292 $db->free($resql);
293}
294
295// Complete request and execute it with limit
296$sql .= $db->order($sortfield, $sortorder);
297if ($limit) {
298 $sql .= $db->plimit($limit + 1, $offset);
299}
300
301$resql = $db->query($sql);
302if (!$resql) {
303 dol_print_error($db);
304 llxFooter();
305 $db->close();
306 exit;
307}
308
309$num = $db->num_rows($resql);
310$i = 0;
311
312$param = '';
313if (!empty($mode)) {
314 $param .= '&mode='.urlencode($mode);
315}
316if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
317 $param .= '&contextpage='.urlencode($contextpage);
318}
319if ($limit > 0 && $limit != $conf->liste_limit) {
320 $param .= '&limit='.((int) $limit);
321}
322if ($search_ref) {
323 $param .= '&search_ref='.urlencode($search_ref);
324}
325if ($search_label) {
326 $param .= '&search_label='.urlencode($search_label);
327}
328if ($search_project_ref >= 0) {
329 $param .= "&search_project_ref=".urlencode($search_project_ref);
330}
331if ($search_amount) {
332 $param .= '&search_amount='.urlencode($search_amount);
333}
334if ($search_typeid) {
335 $param .= '&search_typeid='.urlencode((string) ($search_typeid));
336}
337if ($search_users) {
338 foreach ($search_users as $id_user) {
339 $param .= '&search_users[]='.urlencode($id_user);
340 }
341}
342if ($search_type) {
343 $param .= '&search_type='.urlencode((string) ($search_type));
344}
345if ($search_account) {
346 $param .= '&search_account='.$search_account;
347}
348if ($search_status != '' && $search_status != '-1') {
349 $param .= '&search_status='.urlencode($search_status);
350}
351if ($search_date_startday) {
352 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
353}
354if ($search_date_startmonth) {
355 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
356}
357if ($search_date_startyear) {
358 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
359}
360if ($search_date_endday) {
361 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
362}
363if ($search_date_endmonth) {
364 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
365}
366if ($search_date_endyear) {
367 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
368}
369if ($search_date_limit_startday) {
370 $param .= '&search_date_limit_startday='.urlencode((string) ($search_date_limit_startday));
371}
372if ($search_date_limit_startmonth) {
373 $param .= '&search_date_limit_startmonth='.urlencode((string) ($search_date_limit_startmonth));
374}
375if ($search_date_limit_startyear) {
376 $param .= '&search_date_limit_startyear='.urlencode((string) ($search_date_limit_startyear));
377}
378if ($search_date_limit_endday) {
379 $param .= '&search_date_limit_endday='.urlencode((string) ($search_date_limit_endday));
380}
381if ($search_date_limit_endmonth) {
382 $param .= '&search_date_limit_endmonth='.urlencode((string) ($search_date_limit_endmonth));
383}
384if ($search_date_limit_endyear) {
385 $param .= '&search_date_limit_endyear='.urlencode((string) ($search_date_limit_endyear));
386}
387
388$url = DOL_URL_ROOT.'/compta/sociales/card.php?action=create';
389
390$newcardbutton = '';
391$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'));
392$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'));
393$newcardbutton .= dolGetButtonTitleSeparator();
394$newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
395
396// List of mass actions available
397$arrayofmassactions = array();
398if (!empty($permissiontodelete)) {
399 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
400}
401$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
402$moreforfilter = '';
403
404print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
405if ($optioncss != '') {
406 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
407}
408print '<input type="hidden" name="token" value="'.newToken().'">';
409print '<input type="hidden" name="action" value="list">';
410print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
411print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
412print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
413print '<input type="hidden" name="search_status" value="'.$search_status.'">';
414print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
415print '<input type="hidden" name="mode" value="'.$mode.'">';
416
417
418// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
419print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1);
420
421if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
422 print '<div class="error">';
423 $langs->load("errors");
424 $countrynotdefined = $langs->trans("ErrorSetACountryFirst");
425 print $countrynotdefined;
426 print '</div>';
427
428 print '</form>';
429 llxFooter();
430 $db->close();
431}
432
433
434$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
435$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
436if ($massactionbutton) {
437 $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
438}
439
440$objecttmp = new ChargeSociales($db);
441$trackid = 'sc'.$object->id;
442include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
443
444print '<div class="div-table-responsive">';
445print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">'."\n";
446
447print '<tr class="liste_titre_filter">';
448
449// Filter: Buttons
450if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
451 print '<td class="liste_titre maxwidthsearch">';
452 print $form->showFilterAndCheckAddButtons(0);
453 print '</td>';
454}
455
456// Filters: Line number (placeholder)
457if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
458 print '<td class="liste_titre">';
459 print '</td>';
460}
461
462// Filter: Ref
463if (!empty($arrayfields['cs.rowid']['checked'])) {
464 print '<td class="liste_titre">';
465 print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
466 print '</td>';
467}
468
469// Filter: Label
470if (!empty($arrayfields['cs.rowid']['checked'])) {
471 print '<td class="liste_titre">';
472 print '<input type="text" class="flat maxwidth100" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
473 print '</td>';
474}
475
476// Filter: Type
477if (!empty($arrayfields['cs.fk_type']['checked'])) {
478 print '<td class="liste_titre">';
479 $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth150', 1);
480 print '</td>';
481}
482
483// Filter: Date (placeholder)
484if (!empty($arrayfields['cs.date_ech']['checked'])) {
485 print '<td class="liste_titre center">';
486 print '<div class="nowrapfordate">';
487 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
488 print '</div>';
489 print '<div class="nowrapfordate">';
490 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
491 print '</div>';
492 print '</td>';
493}
494
495// Filter: Period end date
496if (!empty($arrayfields['cs.periode']['checked'])) {
497 print '<td class="liste_titre center">';
498 print '<div class="nowrapfordate">';
499 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'));
500 print '</div>';
501 print '<div class="nowrapfordate">';
502 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'));
503 print '</div>';
504 print '</td>';
505}
506
507// Filter: Project ref
508if (!empty($arrayfields['p.ref']['checked'])) {
509 print '<td class="liste_titre">';
510 print '<input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'">';
511 print '</td>';
512}
513
514if (!empty($arrayfields['cs.fk_user']['checked'])) {
515 // Employee
516 print '<td class="liste_titre">';
517 print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth150', 0, 0, true);
518 print '</td>';
519}
520
521// Filter: Type
522if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
523 print '<td class="liste_titre">';
524 print $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 0, 1, 'maxwidth150', 1);
525 print '</td>';
526}
527
528// Filter: Bank Account
529if (!empty($arrayfields['cs.fk_account']['checked'])) {
530 print '<td class="liste_titre">';
531 $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth150');
532 print '</td>';
533}
534
535// Filter: Amount
536if (!empty($arrayfields['cs.amount']['checked'])) {
537 print '<td class="liste_titre right">';
538 print '<input class="flat maxwidth75" type="text" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
539 print '</td>';
540}
541
542// Filter: Status
543if (!empty($arrayfields['cs.paye']['checked'])) {
544 print '<td class="liste_titre right parentonrightofpage">';
545 $liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid"));
546 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
547 print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1);
548 print '</td>';
549}
550
551// Fields from hook
552$parameters = array('arrayfields' => $arrayfields);
553$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
554print $hookmanager->resPrint;
555
556// Filter: Buttons
557if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
558 print '<td class="liste_titre maxwidthsearch">';
559 print $form->showFilterAndCheckAddButtons(0);
560 print '</td>';
561}
562
563print '</tr>';
564
565$totalarray = array();
566$totalarray['nbfield'] = 0;
567
568// Fields title label
569// --------------------------------------------------------------------
570print '<tr class="liste_titre">';
571
572if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
573 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
574 $totalarray['nbfield']++;
575}
576
577if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
578 print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
579 $totalarray['nbfield']++;
580}
581if (!empty($arrayfields['cs.rowid']['checked'])) {
582 // False positive @phan-suppress-next-line PhanTypeInvalidDimOffset
583 print_liste_field_titre($arrayfields['cs.rowid']['label'], $_SERVER["PHP_SELF"], "cs.rowid", '', $param, '', $sortfield, $sortorder);
584 $totalarray['nbfield']++;
585}
586if (!empty($arrayfields['cs.libelle']['checked'])) {
587 print_liste_field_titre($arrayfields['cs.libelle']['label'], $_SERVER["PHP_SELF"], "cs.libelle,cs.periode", '', $param, '', $sortfield, $sortorder);
588 $totalarray['nbfield']++;
589}
590if (!empty($arrayfields['cs.fk_type']['checked'])) {
591 print_liste_field_titre($arrayfields['cs.fk_type']['label'], $_SERVER["PHP_SELF"], "cs.fk_type,cs.periode", '', $param, '', $sortfield, $sortorder);
592 $totalarray['nbfield']++;
593}
594if (!empty($arrayfields['cs.date_ech']['checked'])) {
595 print_liste_field_titre($arrayfields['cs.date_ech']['label'], $_SERVER["PHP_SELF"], "cs.date_ech,cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
596 $totalarray['nbfield']++;
597}
598if (!empty($arrayfields['cs.periode']['checked'])) {
599 print_liste_field_titre($arrayfields['cs.periode']['label'], $_SERVER["PHP_SELF"], "cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
600 $totalarray['nbfield']++;
601}
602if (!empty($arrayfields['p.ref']['checked'])) {
603 print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
604 $totalarray['nbfield']++;
605}
606if (!empty($arrayfields['cs.fk_user']['checked'])) {
607 print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname,cs.periode", "", $param, 'class="left"', $sortfield, $sortorder);
608 $totalarray['nbfield']++;
609}
610if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
611 print_liste_field_titre($arrayfields['cs.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "cs.fk_mode_reglement,cs.periode", '', $param, '', $sortfield, $sortorder);
612 $totalarray['nbfield']++;
613}
614if (!empty($arrayfields['cs.fk_account']['checked'])) {
615 print_liste_field_titre($arrayfields['cs.fk_account']['label'], $_SERVER["PHP_SELF"], "cs.fk_account,cs.periode", '', $param, '', $sortfield, $sortorder);
616 $totalarray['nbfield']++;
617}
618if (!empty($arrayfields['cs.amount']['checked'])) {
619 print_liste_field_titre($arrayfields['cs.amount']['label'], $_SERVER["PHP_SELF"], "cs.amount,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
620 $totalarray['nbfield']++;
621}
622if (!empty($arrayfields['cs.paye']['checked'])) {
623 print_liste_field_titre($arrayfields['cs.paye']['label'], $_SERVER["PHP_SELF"], "cs.paye,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
624 $totalarray['nbfield']++;
625}
626
627// Hook fields
628$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
629$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
630print $hookmanager->resPrint;
631
632if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
633 print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
634 $totalarray['nbfield']++;
635}
636print '</tr>';
637
638// Loop on record
639// --------------------------------------------------------------------
640$i = 0;
641$savnbfield = $totalarray['nbfield'];
642$totalarray = array();
643$totalarray['nbfield'] = 0;
644$totalarray['val'] = array('totalttcfield' => 0);
645$imaxinloop = ($limit ? min($num, $limit) : $num);
646if (!isset($TLoadedUsers) || !is_array($TLoadedUsers)) {
647 // Ensure array is initialised
648 $TLoadedUsers = array();
649}
650while ($i < $imaxinloop) {
651 $obj = $db->fetch_object($resql);
652
653 $chargesociale_static->id = $obj->rowid;
654 $chargesociale_static->ref = $obj->rowid;
655 $chargesociale_static->label = $obj->label;
656 $chargesociale_static->type_label = $obj->type_label;
657 $chargesociale_static->amount = $obj->amount;
658 $chargesociale_static->paye = $obj->paye;
659 $chargesociale_static->date_ech = $obj->date_ech;
660
661 if (isModEnabled('project')) {
662 $projectstatic->id = $obj->project_id;
663 $projectstatic->ref = $obj->project_ref;
664 $projectstatic->title = $obj->project_label;
665 }
666
667 if ($mode == 'kanban') {
668 if ($i == 0) {
669 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
670 print '<div class="box-flex-container kanban">';
671 }
672 // Output Kanban
673 print $chargesociale_static->getKanbanView('', array('project' => $projectstatic, 'selected' => in_array($chargesociale_static->id, $arrayofselected)));
674 if ($i == ($imaxinloop - 1)) {
675 print '</div>';
676 print '</td></tr>';
677 }
678 } else {
679 print '<tr class="oddeven">';
680
681
682 // Action column
683 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
684 print '<td class="center">';
685 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
686 $selected = 0;
687 if (in_array($chargesociale_static->id, $arrayofselected)) {
688 $selected = 1;
689 }
690 print '<input id="cb'.$chargesociale_static->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$chargesociale_static->id.'"'.($selected ? ' checked="checked"' : '').'>';
691 }
692 print '</td>';
693 if (!$i) {
694 $totalarray['nbfield']++;
695 }
696 }
697
698 // Line number
699 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
700 print '<td>'.(($offset * $limit) + $i).'</td>';
701 if (!$i) {
702 $totalarray['nbfield']++;
703 }
704 }
705
706 // Ref
707 if (!empty($arrayfields['cs.rowid']['checked'])) {
708 print '<td>'.$chargesociale_static->getNomUrl(1, '20').'</td>';
709 if (!$i) {
710 $totalarray['nbfield']++;
711 }
712 }
713
714 // Label
715 if (!empty($arrayfields['cs.libelle']['checked'])) {
716 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).'">'.dol_escape_htmltag($obj->label).'</td>';
717 if (!$i) {
718 $totalarray['nbfield']++;
719 }
720 }
721
722 // Type
723 if (!empty($arrayfields['cs.fk_type']['checked'])) {
724 $typelabeltoshow = $obj->type_label;
725 $typelabelpopup = $obj->type_label;
726 if (isModEnabled('accounting')) {
727 $typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code;
728 }
729 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($typelabelpopup).'">'.dol_escape_htmltag($typelabeltoshow).'</td>';
730 if (!$i) {
731 $totalarray['nbfield']++;
732 }
733 }
734
735 // Date
736 if (!empty($arrayfields['cs.date_ech']['checked'])) {
737 print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
738 if (!$i) {
739 $totalarray['nbfield']++;
740 }
741 }
742
743 // Date end period
744 if (!empty($arrayfields['cs.periode']['checked'])) {
745 print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->periode), 'day').'</td>';
746 if (!$i) {
747 $totalarray['nbfield']++;
748 }
749 }
750
751 // Project ref
752 if (!empty($arrayfields['p.ref']['checked'])) {
753 print '<td class="nowraponall">';
754 if ($obj->project_id > 0) {
755 print $projectstatic->getNomUrl(1);
756 }
757 print '</td>';
758 if (!$i) {
759 $totalarray['nbfield']++;
760 }
761 }
762
763 if (!empty($arrayfields['cs.fk_user']['checked'])) {
764 // Employee
765 print '<td class="tdoverflowmax150">';
766 if (!empty($obj->fk_user)) {
767 if (!empty($TLoadedUsers[$obj->fk_user])) {
768 $ustatic = $TLoadedUsers[$obj->fk_user];
769 } else {
770 $ustatic = new User($db);
771 $ustatic->fetch($obj->fk_user);
772 $TLoadedUsers[$obj->fk_user] = $ustatic;
773 }
774 print $ustatic->getNomUrl(-1);
775 }
776 print "</td>\n";
777 if (!$i) {
778 $totalarray['nbfield']++;
779 }
780 }
781
782 // Type
783 if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
784 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans("PaymentTypeShort".$obj->payment_code)).'">';
785 if (!empty($obj->payment_code)) {
786 print $langs->trans("PaymentTypeShort".$obj->payment_code);
787 }
788 print '</td>';
789 if (!$i) {
790 $totalarray['nbfield']++;
791 }
792 }
793
794 // Account
795 if (!empty($arrayfields['cs.fk_account']['checked'])) {
796 print '<td class="toverflowmax150">';
797 if ($obj->fk_account > 0) {
798 $bankstatic->id = $obj->fk_account;
799 $bankstatic->ref = $obj->bref;
800 $bankstatic->number = $obj->bnumber;
801 $bankstatic->iban = $obj->iban;
802 $bankstatic->bic = $obj->bic;
803 $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
804 $bankstatic->account_number = $obj->account_number;
805 $bankstatic->clos = $obj->clos;
806
807 //$accountingjournal->fetch($obj->fk_accountancy_journal);
808 //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
809
810 $bankstatic->label = $obj->blabel;
811 print $bankstatic->getNomUrl(1);
812 }
813 print '</td>';
814 if (!$i) {
815 $totalarray['nbfield']++;
816 }
817 }
818
819 // Amount
820 if (!empty($arrayfields['cs.amount']['checked'])) {
821 print '<td class="nowraponall amount right">'.price($obj->amount).'</td>';
822 if (!$i) {
823 $totalarray['nbfield']++;
824 $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
825 }
826 $totalarray['val']['totalttcfield'] += $obj->amount;
827 }
828
829 // Status
830 if (!empty($arrayfields['cs.paye']['checked'])) {
831 print '<td class="nowraponall right">'.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>';
832 if (!$i) {
833 $totalarray['nbfield']++;
834 }
835 }
836
837 // Action column
838 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
839 print '<td class="center">';
840 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
841 $selected = 0;
842 if (in_array($chargesociale_static->id, $arrayofselected)) {
843 $selected = 1;
844 }
845 print '<input id="cb'.$chargesociale_static->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$chargesociale_static->id.'"'.($selected ? ' checked="checked"' : '').'>';
846 }
847 print '</td>';
848 if (!$i) {
849 $totalarray['nbfield']++;
850 }
851 }
852
853 print '</tr>'."\n";
854 }
855 $i++;
856}
857
858// Show total line
859include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
860
861// If no record found
862if ($num == 0) {
863 $colspan = 1;
864 foreach ($arrayfields as $key => $val) {
865 if (!empty($val['checked'])) {
866 $colspan++;
867 }
868 }
869 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
870}
871
872$db->free($resql);
873
874$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
875$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
876print $hookmanager->resPrint;
877
878print '</table>'."\n";
879print '</div>'."\n";
880
881print '</form>'."\n";
882
883// End of page
884llxFooter();
885$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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
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.
llxFooter()
Footer empty.
Definition document.php:107
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)
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...
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.