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