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