dolibarr 19.0.3
list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2011-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
3 * Copyright (C) 2015-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
5 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
6 * Copyright (C) 2024 Nick Fragoulis
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
31require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
32if (isModEnabled('accounting')) {
33 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
34}
35
36// Load translation files required by the page
37$langs->loadLangs(array("compta", "salaries", "bills", "hrm"));
38
39$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
40$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
41$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
42$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
43$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
44$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
45$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
46$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
47$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
48$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
49
50
51// Load variable for pagination
52$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
53$sortfield = GETPOST('sortfield', 'aZ09comma');
54$sortorder = GETPOST('sortorder', 'aZ09comma');
55$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
56if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
57 // If $page is not defined, or '' or -1 or if we click on clear filters
58 $page = 0;
59}
60$offset = $limit * $page;
61$pageprev = $page - 1;
62$pagenext = $page + 1;
63if (!$sortfield) {
64 $sortfield = "s.datep,s.rowid";
65}
66if (!$sortorder) {
67 $sortorder = "DESC,DESC";
68}
69
70// Initialize technical objects
71$object = new Salary($db);
72$extrafields = new ExtraFields($db);
73$diroutputmassaction = $conf->user->dir_output.'/temp/massgeneration/'.$user->id;
74$hookmanager->initHooks(array('salarieslist')); // Note that conf->hooks_modules contains array
75
76// Fetch optionals attributes and labels
77$extrafields->fetch_name_optionals_label($object->table_element);
78
79$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
80
81if (!$sortfield) {
82 $sortfield = "s.datep,s.rowid";
83}
84if (!$sortorder) {
85 $sortorder = "DESC,DESC";
86}
87
88$search_ref = GETPOST('search_ref', 'int');
89$search_user = GETPOST('search_user', 'alpha');
90$search_label = GETPOST('search_label', 'alpha');
91$search_date_start_from = dol_mktime(0, 0, 0, GETPOST('search_date_start_frommonth', 'int'), GETPOST('search_date_start_fromday', 'int'), GETPOST('search_date_start_fromyear', 'int'));
92$search_date_start_to = dol_mktime(23, 59, 59, GETPOST('search_date_start_tomonth', 'int'), GETPOST('search_date_start_today', 'int'), GETPOST('search_date_start_toyear', 'int'));
93$search_date_end_from = dol_mktime(0, 0, 0, GETPOST('search_date_end_frommonth', 'int'), GETPOST('search_date_end_fromday', 'int'), GETPOST('search_date_end_fromyear', 'int'));
94$search_date_end_to = dol_mktime(23, 59, 59, GETPOST('search_date_end_tomonth', 'int'), GETPOST('search_date_end_today', 'int'), GETPOST('search_date_end_toyear', 'int'));
95$search_amount = GETPOST('search_amount', 'alpha');
96$search_account = GETPOST('search_account', 'int');
97$search_status = GETPOST('search_status', 'int');
98$search_type_id = GETPOST('search_type_id', 'int');
99
100$filtre = GETPOST("filtre", 'restricthtml');
101
102$childids = $user->getAllChildIds(1);
103
104// Initialize array of search criterias
105$search_all = GETPOST("search_all", 'alpha');
106$search = array();
107foreach ($object->fields as $key => $val) {
108 if (GETPOST('search_'.$key, 'alpha') !== '') {
109 $search[$key] = GETPOST('search_'.$key, 'alpha');
110 }
111 if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
112 $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
113 $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
114 }
115}
116
117// List of fields to search into when doing a "search in all"
118$fieldstosearchall = array();
119foreach ($object->fields as $key => $val) {
120 if (!empty($val['searchall'])) {
121 $fieldstosearchall['t.'.$key] = $val['label'];
122 }
123}
124
125// Definition of array of fields for columns
126$arrayfields = array();
127foreach ($object->fields as $key => $val) {
128 // If $val['visible']==0, then we never show the field
129 if (!empty($val['visible'])) {
130 $visible = (int) dol_eval($val['visible'], 1);
131 $arrayfields['t.'.$key] = array(
132 'label'=>$val['label'],
133 'checked'=>(($visible < 0) ? 0 : 1),
134 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)),
135 'position'=>$val['position'],
136 'help'=> isset($val['help']) ? $val['help'] : ''
137 );
138 }
139}
140// Extra fields
141include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
142
143$object->fields = dol_sort_array($object->fields, 'position');
144$arrayfields = dol_sort_array($arrayfields, 'position');
145
146$permissiontoread = $user->rights->salaries->read;
147$permissiontoadd = $user->rights->salaries->write;
148$permissiontodelete = $user->rights->salaries->delete;
149
150// Security check
151$socid = GETPOST("socid", "int");
152if ($user->socid) {
153 $socid = $user->socid;
154}
155restrictedArea($user, 'salaries', '', 'salary', '');
156
157
158/*
159 * Actions
160 */
161
162if (GETPOST('cancel', 'alpha')) {
163 $action = 'list';
164 $massaction = '';
165}
166if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
167 $massaction = '';
168}
169
170$parameters = array();
171$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
172if ($reshook < 0) {
173 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
174}
175
176if (empty($reshook)) {
177 // Selection of new fields
178 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
179
180 // Purge search criteria
181 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
182 $search_ref = "";
183 $search_user = "";
184 $search_label = "";
185 $search_date_start_from = '';
186 $search_date_start_to = '';
187 $search_date_end_from = '';
188 $search_date_end_to = '';
189 $search_date_end = '';
190 $search_amount = "";
191 $search_account = '';
192 $search_status = '';
193 $search_type_id = "";
194 }
195 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
196 || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
197 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
198 }
199
200 // Mass actions
201 $objectclass = 'Salary';
202 $objectlabel = 'Salaries';
203 $uploaddir = $conf->salaries->dir_output;
204 include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
205
206 // Validate records
207 if (!$error && $massaction == 'buildsepa' && $permissiontoadd) {
208 $objecttmp = new $objectclass($db);
209
210 // TODO
211 }
212}
213
214/*
215 * View
216 */
217
218$form = new Form($db);
219$salstatic = new Salary($db);
220$userstatic = new User($db);
221$accountstatic = new Account($db);
222
223$now = dol_now();
224
225$title = $langs->trans('Salaries');
226//$help_url="EN:Module_BillOfMaterials|FR:Module_BillOfMaterials_FR|ES:Módulo_BillOfMaterials";
227$help_url = '';
228$morejs = array();
229$morecss = array();
230
231// Build and execute select
232// --------------------------------------------------------------------
233$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.photo, u.salary as current_salary, u.fk_soc as fk_soc, u.statut as status,";
234$sql .= " s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp, s.dateep, s.fk_typepayment as paymenttype, ";
235$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos,";
236$sql .= " pst.code as payment_code,";
237$sql .= " SUM(ps.amount) as alreadypayed";
238// Add fields from extrafields
239if (!empty($extrafields->attributes[$object->table_element]['label'])) {
240 foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
241 $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
242 }
243}
244// Add fields from hooks
245$parameters = array();
246$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
247$sql .= $hookmanager->resPrint;
248$sql = preg_replace('/,\s*$/', '', $sql);
249//$sql .= ", COUNT(rc.rowid) as anotherfield";
250
251$sqlfields = $sql; // $sql fields to remove for count total
252
253$sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
254if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
255 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (s.rowid = ef.fk_object)";
256}
257$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as ps ON (ps.fk_salary = s.rowid) ";
258$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON (s.fk_typepayment = pst.id) ";
259$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account ba ON (ba.rowid = s.fk_account), ";
260//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as ps ON ps.fk_salary = s.rowid, ";
261$sql .= " ".MAIN_DB_PREFIX."user as u";
262$sql .= " WHERE u.rowid = s.fk_user";
263$sql .= " AND s.entity IN (".getEntity('salaries').")";
264if (!$user->hasRight('salaries', 'readall')) {
265 $sql .= " AND s.fk_user IN (".$db->sanitize(join(',', $childids)).")";
266}
267//print $sql;
268
269// Search criteria
270if ($search_ref) {
271 $sql .= " AND s.rowid=".((int) $search_ref);
272}
273if ($search_user) {
274 $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
275}
276if ($search_label) {
277 $sql .= natural_search(array('s.label'), $search_label);
278}
279if (!empty($search_date_start_from)) {
280 $sql .= " AND s.datesp >= '".$db->idate($search_date_start_from)."'";
281}
282if (!empty($search_date_end_from)) {
283 $sql .= " AND s.dateep >= '".$db->idate($search_date_end_from)."'";
284}
285if (!empty($search_date_start_to)) {
286 $sql .= " AND s.datesp <= '".$db->idate($search_date_start_to)."'";
287}
288if (!empty($search_date_end_to)) {
289 $sql .= " AND s.dateep <= '".$db->idate($search_date_end_to)."'";
290}
291
292if ($search_amount) {
293 $sql .= natural_search("s.amount", $search_amount, 1);
294}
295if ($search_account > 0) {
296 $sql .= " AND s.fk_account=".((int) $search_account);
297}
298if ($search_status != '' && $search_status >= 0) {
299 $sql .= " AND s.paye = ".((int) $search_status);
300}
301if ($search_type_id) {
302 $sql .= " AND s.fk_typepayment=".((int) $search_type_id);
303}
304// Add where from extra fields
305include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
306$sql .= " GROUP BY u.rowid, u.lastname, u.firstname, u.login, u.email, u.admin, u.photo, u.salary, u.fk_soc, u.statut,";
307$sql .= " s.rowid, s.fk_account, s.paye, s.fk_user, s.amount, s.salary, s.label, s.datesp, s.dateep, s.fk_typepayment, s.fk_bank,";
308$sql .= " ba.rowid, ba.ref, ba.number, ba.account_number, ba.fk_accountancy_journal, ba.label, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos,";
309$sql .= " pst.code";
310
311// Count total nb of records
312$nbtotalofrecords = '';
313if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
314 /* The fast and low memory method to get and count full list converts the sql into a sql count */
315 $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
316 $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
317 $resql = $db->query($sqlforcount);
318 if ($resql) {
319 $objforcount = $db->fetch_object($resql);
320 $nbtotalofrecords = $objforcount->nbtotalofrecords;
321 } else {
322 dol_print_error($db);
323 }
324
325 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller than the paging size (filtering), goto and load page 0
326 $page = 0;
327 $offset = 0;
328 }
329 $db->free($resql);
330}
331
332// Complete request and execute it with limit
333$sql .= $db->order($sortfield, $sortorder);
334if ($limit) {
335 $sql .= $db->plimit($limit + 1, $offset);
336}
337
338$resql = $db->query($sql);
339if (!$resql) {
340 dol_print_error($db);
341 exit;
342}
343
344$num = $db->num_rows($resql);
345
346
347// Direct jump if only one record found
348if ($num == 1 && getDolGlobalString('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
349 $obj = $db->fetch_object($resql);
350 $id = $obj->rowid;
351 header("Location: ".DOL_URL_ROOT.'/salaries/card.php?id='.$id);
352 exit;
353}
354
355
356// Output page
357// --------------------------------------------------------------------
358
359llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); // Can use also classforhorizontalscrolloftabs instead of bodyforlist for no horizontal scroll
360
361$arrayofselected = is_array($toselect) ? $toselect : array();
362
363$param = '';
364if (!empty($mode)) {
365 $param .= '&mode='.urlencode($mode);
366}
367if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
368 $param .= '&contextpage='.urlencode($contextpage);
369}
370if ($limit > 0 && $limit != $conf->liste_limit) {
371 $param .= '&limit='.((int) $limit);
372}
373if ($search_type_id) {
374 $param .= '&search_type_id='.urlencode($search_type_id);
375}
376if ($optioncss != '') {
377 $param .= '&optioncss='.urlencode($optioncss);
378}
379if ($search_ref) {
380 $param .= '&search_ref='.urlencode($search_ref);
381}
382if ($search_user > 0) {
383 $param .= '&search_user='.urlencode($search_user);
384}
385if ($search_label) {
386 $param .= '&search_label='.urlencode($search_label);
387}
388if ($search_account) {
389 $param .= '&search_account='.urlencode($search_account);
390}
391if ($search_status != '' && $search_status != '-1') {
392 $param .= '&search_status='.urlencode($search_status);
393}
394if (!empty($search_date_start_from)) {
395 $param .= '&search_date_start_fromday='.urlencode(GETPOST('search_date_start_fromday')).'&search_date_start_frommonth='.urlencode(GETPOST('search_date_start_frommonth')).'&search_date_start_fromyear='.urlencode(GETPOST('search_date_start_fromyear'));
396}
397if (!empty($search_date_start_to)) {
398 $param .= "&search_date_start_today=".urlencode(GETPOST('search_date_start_today'))."&search_date_start_tomonth=".urlencode(GETPOST('search_date_start_tomonth'))."&search_date_start_toyear=".urlencode(GETPOST('search_date_start_toyear'));
399}
400if (!empty($search_date_end_from)) {
401 $param .= '&search_date_end_fromday='.urlencode(GETPOST('search_date_end_fromday')).'&search_date_end_frommonth='.urlencode(GETPOST('search_date_end_frommonth')).'&search_date_end_fromyear='.urlencode(GETPOST('search_date_end_fromyear'));
402}
403if (!empty($search_date_end_to)) {
404 $param .= "&search_date_end_today=".urlencode(GETPOST('search_date_end_today'))."&search_date_end_tomonth=".urlencode(GETPOST('search_date_end_tomonth'))."&search_date_end_toyear=".urlencode(GETPOST('search_date_end_toyear'));
405}
406
407// Add $param from extra fields
408include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
409// Add $param from hooks
410$parameters = array('param' => &$param);
411$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
412$param .= $hookmanager->resPrint;
413
414// List of mass actions available
415$arrayofmassactions = array(
416 //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
417 //'buildsepa'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("BuildSepa"), // TODO
418);
419if (!empty($permissiontodelete)) {
420 $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
421}
422if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
423 $arrayofmassactions = array();
424}
425$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
426
427print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
428if ($optioncss != '') {
429 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
430}
431print '<input type="hidden" name="token" value="'.newToken().'">';
432print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
433print '<input type="hidden" name="action" value="list">';
434print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
435print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
436print '<input type="hidden" name="page" value="'.$page.'">';
437print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
438print '<input type="hidden" name="page_y" value="">';
439print '<input type="hidden" name="mode" value="'.$mode.'">';
440
441
442$url = DOL_URL_ROOT.'/salaries/card.php?action=create';
443if (!empty($socid)) {
444 $url .= '&socid='.$socid;
445}
446
447$newcardbutton = '';
448$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'));
449$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'));
450$newcardbutton .= dolGetButtonTitleSeparator();
451$newcardbutton .= dolGetButtonTitle($langs->trans('NewSalary'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
452
453print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
454
455// Add code for pre mass action (confirmation or email presend form)
456$topicmail = "SendSalaryRef";
457$modelmail = "salary";
458$objecttmp = new Salary($db);
459$trackid = 'sal'.$object->id;
460include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
461
462$moreforfilter = '';
463
464$parameters = array();
465$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
466if (empty($reshook)) {
467 $moreforfilter .= $hookmanager->resPrint;
468} else {
469 $moreforfilter = $hookmanager->resPrint;
470}
471
472if (!empty($moreforfilter)) {
473 print '<div class="liste_titre liste_titre_bydiv centpercent">';
474 print $moreforfilter;
475 $parameters = array();
476 $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
477 print $hookmanager->resPrint;
478 print '</div>';
479}
480
481$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
482$selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
483$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
484
485print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
486print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
487
488// Fields title search
489// --------------------------------------------------------------------
490print '<tr class="liste_titre_filter">';
491// Action column
492if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
493 print '<td class="liste_titre center maxwidthsearch">';
494 $searchpicto = $form->showFilterButtons('left');
495 print $searchpicto;
496 print '</td>';
497}
498// Ref
499print '<td class="liste_titre left">';
500print '<input class="flat width50" type="text" name="search_ref" value="'.$db->escape($search_ref).'">';
501print '</td>';
502// Label
503print '<td class="liste_titre"><input type="text" class="flat width100" name="search_label" value="'.$db->escape($search_label).'"></td>';
504
505// Date start
506print '<td class="liste_titre center">';
507print '<div class="nowrapfordate">';
508 print $form->selectDate($search_date_start_from ? $search_date_start_from : -1, 'search_date_start_from', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
509print '</div>';
510print '<div class="nowrapfordate">';
511 print $form->selectDate($search_date_start_to ? $search_date_start_to : -1, 'search_date_start_to', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
512print '</div>';
513print '</td>';
514
515// Date End
516print '<td class="liste_titre center">';
517print '<div class="nowrapfordate">';
518 print $form->selectDate($search_date_end_from ? $search_date_end_from : -1, 'search_date_end_from', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
519print '</div>';
520print '<div class="nowrapfordate">';
521 print $form->selectDate($search_date_end_to ? $search_date_end_to : -1, 'search_date_end_to', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
522print '</div>';
523print '</td>';
524
525// Employee
526print '<td class="liste_titre">';
527print '<input class="flat" type="text" size="6" name="search_user" value="'.$db->escape($search_user).'">';
528print '</td>';
529
530// Type
531print '<td class="liste_titre left">';
532print $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16, 1, 'maxwidth125', 1);
533print '</td>';
534
535// Bank account
536if (isModEnabled("banque")) {
537 print '<td class="liste_titre">';
538 print $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth125', 1);
539 print '</td>';
540}
541
542// Extra fields
543include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
544
545// Amount
546print '<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$db->escape($search_amount).'"></td>';
547
548// Status
549print '<td class="liste_titre right parentonrightofpage">';
550$liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid"));
551print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage');
552print '</td>';
553
554// Fields from hook
555$parameters = array('arrayfields'=>$arrayfields);
556$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
557print $hookmanager->resPrint;
558// Action column
559if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
560 print '<td class="liste_titre center maxwidthsearch">';
561 $searchpicto = $form->showFilterButtons();
562 print $searchpicto;
563 print '</td>';
564}
565print '</tr>'."\n";
566
567$totalarray = array();
568$totalarray['nbfield'] = 0;
569
570// Fields title label
571// --------------------------------------------------------------------
572print '<tr class="liste_titre">';
573// Action column
574if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
575 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
576 $totalarray['nbfield']++;
577}
578print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder);
579$totalarray['nbfield']++;
580print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder);
581$totalarray['nbfield']++;
582print_liste_field_titre("DateStart", $_SERVER["PHP_SELF"], "s.datesp,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
583$totalarray['nbfield']++;
584print_liste_field_titre("DateEnd", $_SERVER["PHP_SELF"], "s.dateep,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
585$totalarray['nbfield']++;
586print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname", "", $param, "", $sortfield, $sortorder);
587$totalarray['nbfield']++;
588print_liste_field_titre("DefaultPaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder);
589$totalarray['nbfield']++;
590if (isModEnabled("banque")) {
591 print_liste_field_titre("DefaultBankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
592 $totalarray['nbfield']++;
593}
594
595// Extra fields
596include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
597
598print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
599$totalarray['nbfield']++;
600print_liste_field_titre('Status', $_SERVER["PHP_SELF"], "s.paye", '', $param, 'class="right"', $sortfield, $sortorder);
601$totalarray['nbfield']++;
602
603// Hook fields
604$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
605$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
606print $hookmanager->resPrint;
607// Action column
608if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
609 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
610 $totalarray['nbfield']++;
611}
612print '</tr>'."\n";
613
614
615// Detect if we need a fetch on each output line
616$needToFetchEachLine = 0;
617if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
618 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
619 if (!is_null($val) && preg_match('/\$object/', $val)) {
620 $needToFetchEachLine++; // There is at least one compute field that use $object
621 }
622 }
623}
624
625// Loop on record
626// --------------------------------------------------------------------
627$i = 0;
628$savnbfield = $totalarray['nbfield'];
629$totalarray = array();
630$totalarray['nbfield'] = 0;
631$totalarray['val'] = array();
632$totalarray['val']['totalttcfield'] = 0;
633$imaxinloop = ($limit ? min($num, $limit) : $num);
634while ($i < $imaxinloop) {
635 $obj = $db->fetch_object($resql);
636 if (empty($obj)) {
637 break; // Should not happen
638 }
639
640 // Store properties in $object
641 $object->setVarsFromFetchObj($obj);
642
643 $userstatic->id = $obj->uid;
644 $userstatic->lastname = $obj->lastname;
645 $userstatic->firstname = $obj->firstname;
646 $userstatic->admin = $obj->admin;
647 $userstatic->login = $obj->login;
648 $userstatic->email = $obj->email;
649 $userstatic->socid = $obj->fk_soc;
650 $userstatic->statut = $obj->status; // deprecated
651 $userstatic->status = $obj->status;
652 $userstatic->photo = $obj->photo;
653
654 $salstatic->id = $obj->rowid;
655 $salstatic->ref = $obj->rowid;
656 $salstatic->label = $obj->label;
657 $salstatic->paye = $obj->paye;
658 $salstatic->status = $obj->paye;
659 $salstatic->alreadypaid = $obj->alreadypayed;
660 $salstatic->datesp = $obj->datesp;
661 $salstatic->dateep = $obj->dateep;
662 $salstatic->amount = $obj->amount;
663 $salstatic->type_payment = $obj->payment_code;
664
665 if ($mode == 'kanban') {
666 if ($i == 0) {
667 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
668 print '<div class="box-flex-container kanban">';
669 }
670 // Output Kanban
671 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
672 $selected = 0;
673 if (in_array($object->id, $arrayofselected)) {
674 $selected = 1;
675 }
676 }
677 print $salstatic->getKanbanView('', array('user' => $userstatic, 'selected' => $selected));
678 if ($i == ($imaxinloop - 1)) {
679 print '</div>';
680 print '</td></tr>';
681 }
682 } else {
683 // Show here line of result
684 $j = 0;
685 print '<tr data-rowid="'.$object->id.'" class="oddeven">';
686 // Action column
687 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
688 print '<td class="nowrap center">';
689 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
690 $selected = 0;
691 if (in_array($object->id, $arrayofselected)) {
692 $selected = 1;
693 }
694 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
695 }
696 print '</td>';
697 if (!$i) {
698 $totalarray['nbfield']++;
699 }
700 }
701
702 // Ref
703 print "<td>".$salstatic->getNomUrl(1)."</td>\n";
704 if (!$i) {
705 $totalarray['nbfield']++;
706 }
707
708 // Label payment
709 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->label).'">'.dol_escape_htmltag($obj->label)."</td>\n";
710 if (!$i) {
711 $totalarray['nbfield']++;
712 }
713
714 // Date Start
715 print '<td class="center">'.dol_print_date($db->jdate($obj->datesp), 'day')."</td>\n";
716 if (!$i) {
717 $totalarray['nbfield']++;
718 }
719
720 // Date End
721 print '<td class="center">'.dol_print_date($db->jdate($obj->dateep), 'day')."</td>\n";
722 if (!$i) {
723 $totalarray['nbfield']++;
724 }
725
726 // Employee
727 print '<td class="tdoverflowmax150">'.$userstatic->getNomUrl(-1)."</td>\n";
728 if (!$i) {
729 $totalarray['nbfield']++;
730 }
731
732 // Payment mode
733 print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans("PaymentTypeShort".$obj->payment_code)).'">';
734 if (!empty($obj->payment_code)) {
735 print $langs->trans("PaymentTypeShort".$obj->payment_code);
736 }
737 print '</td>';
738 if (!$i) {
739 $totalarray['nbfield']++;
740 }
741
742 // Account
743 if (isModEnabled("banque")) {
744 print '<td>';
745 if ($obj->fk_account > 0) {
746 //$accountstatic->fetch($obj->fk_bank);
747 $accountstatic->id = $obj->bid;
748 $accountstatic->ref = $obj->bref;
749 $accountstatic->label = $obj->blabel;
750 $accountstatic->number = $obj->bnumber;
751 $accountstatic->iban = $obj->iban;
752 $accountstatic->bic = $obj->bic;
753 $accountstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
754 $accountstatic->account_number = $obj->account_number;
755 $accountstatic->clos = $obj->clos;
756
757 if (isModEnabled('accounting')) {
758 $accountstatic->account_number = $obj->account_number;
759
760 $accountingjournal = new AccountingJournal($db);
761 $accountingjournal->fetch($obj->fk_accountancy_journal);
762
763 $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
764 }
765 //$accountstatic->label = $obj->blabel;
766 print $accountstatic->getNomUrl(1);
767 } else {
768 print '&nbsp;';
769 }
770 print '</td>';
771 if (!$i) {
772 $totalarray['nbfield']++;
773 }
774 }
775
776 // if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
777
778 // Extra fields
779 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
780
781 // Amount
782 print '<td class="nowraponall right"><span class="amount">'.price($obj->amount).'</span></td>';
783 if (!$i) {
784 $totalarray['nbfield']++;
785 }
786 if (!$i) {
787 $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
788 }
789 $totalarray['val']['totalttcfield'] += $obj->amount;
790
791 print '<td class="nowraponall right">'.$salstatic->getLibStatut(5, $obj->alreadypayed).'</td>';
792 if (!$i) {
793 $totalarray['nbfield']++;
794 }
795
796 // Fields from hook
797 $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
798 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
799 print $hookmanager->resPrint;
800 // Action column
801 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
802 print '<td class="nowrap center">';
803 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
804 $selected = 0;
805 if (in_array($object->id, $arrayofselected)) {
806 $selected = 1;
807 }
808 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
809 }
810 print '</td>';
811 if (!$i) {
812 $totalarray['nbfield']++;
813 }
814 }
815 print '</tr>'."\n";
816 }
817 $i++;
818}
819
820// Show total line
821include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
822
823
824// If no record found
825if ($num == 0) {
826 /*$colspan = 1;
827 foreach ($arrayfields as $key => $val) {
828 if (!empty($val['checked'])) {
829 $colspan++;
830 }
831 }*/
832 $colspan = 9;
833 if (isModEnabled("banque")) {
834 $colspan++;
835 }
836 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
837}
838
839
840$db->free($resql);
841
842$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
843$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
844print $hookmanager->resPrint;
845
846print '</table>'."\n";
847print '</div>'."\n";
848
849print '</form>'."\n";
850
851
852// End of page
853llxFooter();
854$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.
Class to manage accounting journals.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class to manage salary payments.
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...
dol_now($mode='auto')
Return date for now.
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...
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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.