dolibarr  16.0.5
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 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
30 if (isModEnabled('accounting')) {
31  require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
32 }
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array("compta", "salaries", "bills", "hrm"));
36 
37 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
38 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
39 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
40 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
41 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
42 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
43 $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search
44 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
45 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
46 
47 // Load variable for pagination
48 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
49 $sortfield = GETPOST('sortfield', 'aZ09comma');
50 $sortorder = GETPOST('sortorder', 'aZ09comma');
51 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
52 if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
53  $page = 0;
54 } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
55 $offset = $limit * $page;
56 $pageprev = $page - 1;
57 $pagenext = $page + 1;
58 if (!$sortfield) {
59  $sortfield = "s.datep,s.rowid";
60 }
61 if (!$sortorder) {
62  $sortorder = "DESC,DESC";
63 }
64 
65 // Initialize technical objects
66 $object = new PaymentSalary($db);
67 $extrafields = new ExtraFields($db);
68 $diroutputmassaction = $conf->user->dir_output.'/temp/massgeneration/'.$user->id;
69 $hookmanager->initHooks(array('salarieslist')); // Note that conf->hooks_modules contains array
70 
71 // Fetch optionals attributes and labels
72 $extrafields->fetch_name_optionals_label($object->table_element);
73 
74 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
75 
76 if (!$sortfield) {
77  $sortfield = "s.datep,s.rowid";
78 }
79 if (!$sortorder) {
80  $sortorder = "DESC,DESC";
81 }
82 
83 $search_ref = GETPOST('search_ref', 'int');
84 $search_user = GETPOST('search_user', 'alpha');
85 $search_label = GETPOST('search_label', 'alpha');
86 $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'));
87 $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'));
88 $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'));
89 $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'));
90 $search_amount = GETPOST('search_amount', 'alpha');
91 $search_account = GETPOST('search_account', 'int');
92 $search_status = GETPOST('search_status', 'int');
93 $search_type_id = GETPOST('search_type_id', 'int');
94 
95 $filtre = GETPOST("filtre", 'restricthtml');
96 
97 $childids = $user->getAllChildIds(1);
98 
99 // Initialize array of search criterias
100 $search_all = GETPOST("search_all", 'alpha');
101 $search = array();
102 foreach ($object->fields as $key => $val) {
103  if (GETPOST('search_'.$key, 'alpha') !== '') {
104  $search[$key] = GETPOST('search_'.$key, 'alpha');
105  }
106  if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
107  $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
108  $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
109  }
110 }
111 
112 // List of fields to search into when doing a "search in all"
113 $fieldstosearchall = array();
114 foreach ($object->fields as $key => $val) {
115  if (!empty($val['searchall'])) {
116  $fieldstosearchall['t.'.$key] = $val['label'];
117  }
118 }
119 
120 // Definition of array of fields for columns
121 $arrayfields = array();
122 foreach ($object->fields as $key => $val) {
123  // If $val['visible']==0, then we never show the field
124  if (!empty($val['visible'])) {
125  $visible = (int) dol_eval($val['visible'], 1, 1, '1');
126  $arrayfields['t.'.$key] = array(
127  'label'=>$val['label'],
128  'checked'=>(($visible < 0) ? 0 : 1),
129  'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
130  'position'=>$val['position'],
131  'help'=> isset($val['help']) ? $val['help'] : ''
132  );
133  }
134 }
135 // Extra fields
136 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
137 
138 $object->fields = dol_sort_array($object->fields, 'position');
139 $arrayfields = dol_sort_array($arrayfields, 'position');
140 
141 $permissiontoread = $user->rights->salaries->read;
142 $permissiontoadd = $user->rights->salaries->write;
143 $permissiontodelete = $user->rights->salaries->delete;
144 
145 // Security check
146 $socid = GETPOST("socid", "int");
147 if ($user->socid) {
148  $socid = $user->socid;
149 }
150 restrictedArea($user, 'salaries', '', 'salary', '');
151 
152 
153 /*
154  * Actions
155  */
156 
157 if (GETPOST('cancel', 'alpha')) {
158  $action = 'list';
159  $massaction = '';
160 }
161 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
162  $massaction = '';
163 }
164 
165 $parameters = array();
166 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
167 if ($reshook < 0) {
168  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
169 }
170 
171 if (empty($reshook)) {
172  // Selection of new fields
173  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
174 
175  // Purge search criteria
176  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
177  $search_ref = "";
178  $search_user = "";
179  $search_label = "";
180  $search_date_start_from = '';
181  $search_date_start_to = '';
182  $search_date_end_from = '';
183  $search_date_end_to = '';
184  $search_date_end = '';
185  $search_amount = "";
186  $search_account = '';
187  $search_status = '';
188  $search_type_id = "";
189  }
190  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
191  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
192  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
193  }
194 
195  // Mass actions
196  $objectclass = 'PaymentSalary';
197  $objectlabel = 'SalariesPayments';
198  $uploaddir = $conf->salaries->dir_output;
199  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
200 
201  // Validate records
202  if (!$error && $massaction == 'buildsepa' && $permissiontoadd) {
203  $objecttmp = new $objectclass($db);
204 
205  // TODO
206  }
207 }
208 
209 /*
210  * View
211  */
212 
213 $form = new Form($db);
214 $salstatic = new Salary($db);
215 $userstatic = new User($db);
216 $accountstatic = new Account($db);
217 
218 $now = dol_now();
219 
220 //$help_url="EN:Module_BillOfMaterials|FR:Module_BillOfMaterials_FR|ES:Módulo_BillOfMaterials";
221 $help_url = '';
222 $title = $langs->trans('Salaries');
223 
224 $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc, u.statut as status,";
225 $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, ";
226 $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,";
227 $sql .= " pst.code as payment_code,";
228 $sql .= " SUM(ps.amount) as alreadypayed";
229 $sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
230 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as ps ON (ps.fk_salary = s.rowid) ";
231 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON (s.fk_typepayment = pst.id) ";
232 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account ba ON (ba.rowid = s.fk_account), ";
233 //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as ps ON ps.fk_salary = s.rowid, ";
234 $sql .= " ".MAIN_DB_PREFIX."user as u";
235 $sql .= " WHERE u.rowid = s.fk_user";
236 $sql .= " AND s.entity IN (".getEntity('payment_salaries').")";
237 if (empty($user->rights->salaries->readall)) {
238  $sql .= " AND s.fk_user IN (".$db->sanitize(join(',', $childids)).")";
239 }
240 
241 // Search criteria
242 if ($search_ref) {
243  $sql .= " AND s.rowid=".((int) $search_ref);
244 }
245 if ($search_user) {
246  $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
247 }
248 if ($search_label) {
249  $sql .= natural_search(array('s.label'), $search_label);
250 }
251 if (!empty($search_date_start_from)) {
252  $sql .= " AND s.datesp >= '".$db->idate($search_date_start_from)."'";
253 }
254 if (!empty($search_date_end_from)) {
255  $sql .= " AND s.dateep >= '".$db->idate($search_date_end_from)."'";
256 }
257 if (!empty($search_date_start_to)) {
258  $sql .= " AND s.datesp <= '".$db->idate($search_date_start_to)."'";
259 }
260 if (!empty($search_date_end_to)) {
261  $sql .= " AND s.dateep <= '".$db->idate($search_date_end_to)."'";
262 }
263 
264 if ($search_amount) {
265  $sql .= natural_search("s.amount", $search_amount, 1);
266 }
267 if ($search_account > 0) {
268  $sql .= " AND s.fk_account=".((int) $search_account);
269 }
270 if ($search_status != '' && $search_status >= 0) {
271  $sql .= " AND s.paye = ".((int) $search_status);
272 }
273 if ($search_type_id) {
274  $sql .= " AND s.fk_typepayment=".((int) $search_type_id);
275 }
276 $sql .= " GROUP BY u.rowid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary, u.fk_soc, u.statut,";
277 $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,";
278 $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,";
279 $sql .= " pst.code";
280 $sql .= $db->order($sortfield, $sortorder);
281 
282 // Count total nb of records
283 $nbtotalofrecords = '';
284 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
285  $resql = $db->query($sql);
286  $nbtotalofrecords = $db->num_rows($resql);
287  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
288  $page = 0;
289  $offset = 0;
290  }
291 }
292 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
293 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
294  $num = $nbtotalofrecords;
295 } else {
296  if ($limit) {
297  $sql .= $db->plimit($limit + 1, $offset);
298  }
299 
300  $resql = $db->query($sql);
301  if (!$resql) {
302  dol_print_error($db);
303  exit;
304  }
305 
306  $num = $db->num_rows($resql);
307 }
308 
309 // Output page
310 // --------------------------------------------------------------------
311 
312 llxHeader('', $title, $help_url);
313 
314 $arrayofselected = is_array($toselect) ? $toselect : array();
315 
316 $param = '';
317 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
318  $param .= '&contextpage='.urlencode($contextpage);
319 }
320 if ($limit > 0 && $limit != $conf->liste_limit) {
321  $param .= '&limit='.urlencode($limit);
322 }
323 if ($search_type_id) {
324  $param .= '&search_type_id='.urlencode($search_type_id);
325 }
326 if ($optioncss != '') {
327  $param .= '&optioncss='.urlencode($optioncss);
328 }
329 if ($search_ref) {
330  $param .= '&search_ref='.urlencode($search_ref);
331 }
332 if ($search_user > 0) {
333  $param .= '&search_user='.urlencode($search_user);
334 }
335 if ($search_label) {
336  $param .= '&search_label='.urlencode($search_label);
337 }
338 if ($search_account) {
339  $param .= '&search_account='.urlencode($search_account);
340 }
341 if ($search_status != '' && $search_status != '-1') {
342  $param .= '&search_status='.urlencode($search_status);
343 }
344 if (!empty($search_date_start_from)) {
345  $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'));
346 }
347 if (!empty($search_date_start_to)) {
348  $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'));
349 }
350 if (!empty($search_date_end_from)) {
351  $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'));
352 }
353 if (!empty($search_date_end_to)) {
354  $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'));
355 }
356 
357 // Add $param from extra fields
358 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
359 
360 // List of mass actions available
361 $arrayofmassactions = array(
362  //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
363  //'buildsepa'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("BuildSepa"), // TODO
364 );
365 //if ($permissiontodelete) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
366 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
367  $arrayofmassactions = array();
368 }
369 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
370 
371 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
372 if ($optioncss != '') {
373  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
374 }
375 print '<input type="hidden" name="token" value="'.newToken().'">';
376 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
377 print '<input type="hidden" name="action" value="list">';
378 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
379 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
380 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
381 
382 $url = DOL_URL_ROOT.'/salaries/card.php?action=create';
383 if (!empty($socid)) {
384  $url .= '&socid='.$socid;
385 }
386 $newcardbutton = dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->salaries->write);
387 
388 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'salary', 0, $newcardbutton, '', $limit, 0, 0, 1);
389 
390 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
391 //$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
392 $selectedfields = '';
393 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
394 
395 $moreforfilter = '';
396 
397 print '<div class="div-table-responsive">';
398 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
399 
400 // Fields title search
401 // --------------------------------------------------------------------
402 print '<tr class="liste_titre_filter">';
403 // Ref
404 print '<td class="liste_titre left">';
405 print '<input class="flat" type="text" size="3" name="search_ref" value="'.$db->escape($search_ref).'">';
406 print '</td>';
407 // Label
408 print '<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$db->escape($search_label).'"></td>';
409 
410 // Date start
411 print '<td class="liste_titre center">';
412 print '<div class="nowrap">';
413 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'));
414 print '</div>';
415 print '<div class="nowrap">';
416 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'));
417 print '</div>';
418 print '</td>';
419 
420 // Date End
421 print '<td class="liste_titre center">';
422 print '<div class="nowrap">';
423 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'));
424 print '</div>';
425 print '<div class="nowrap">';
426 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'));
427 print '</div>';
428 print '</td>';
429 
430 // Employee
431 print '<td class="liste_titre">';
432 print '<input class="flat" type="text" size="6" name="search_user" value="'.$db->escape($search_user).'">';
433 print '</td>';
434 
435 // Type
436 print '<td class="liste_titre left">';
437 $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16);
438 print '</td>';
439 
440 // Bank account
441 if (isModEnabled('banque')) {
442  print '<td class="liste_titre">';
443  $form->select_comptes($search_account, 'search_account', 0, '', 1);
444  print '</td>';
445 }
446 
447 // Amount
448 print '<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$db->escape($search_amount).'"></td>';
449 
450 print '<td class="liste_titre maxwidthonsmartphone right">';
451 $liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid"));
452 print $form->selectarray('search_status', $liststatus, $search_status, 1);
453 print '</td>';
454 
455 // Extra fields
456 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
457 
458 // Fields from hook
459 $parameters = array('arrayfields'=>$arrayfields);
460 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
461 print $hookmanager->resPrint;
462 // Action column
463 print '<td class="liste_titre maxwidthsearch">';
464 $searchpicto = $form->showFilterButtons();
465 print $searchpicto;
466 print '</td>';
467 print '</tr>'."\n";
468 
469 
470 // Fields title label
471 // --------------------------------------------------------------------
472 print '<tr class="liste_titre">';
473 print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder);
474 print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder);
475 print_liste_field_titre("DateStart", $_SERVER["PHP_SELF"], "s.datesp,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
476 print_liste_field_titre("DateEnd", $_SERVER["PHP_SELF"], "s.dateep,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
477 print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname", "", $param, "", $sortfield, $sortorder);
478 print_liste_field_titre("DefaultPaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder);
479 if (isModEnabled('banque')) {
480  print_liste_field_titre("DefaultBankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
481 }
482 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
483 print_liste_field_titre('Status', $_SERVER["PHP_SELF"], "s.paye", '', $param, 'class="right"', $sortfield, $sortorder);
484 // Extra fields
485 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
486 // Hook fields
487 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
488 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
489 print $hookmanager->resPrint;
490 // Action column
491 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
492 print '</tr>'."\n";
493 
494 
495 // Detect if we need a fetch on each output line
496 $needToFetchEachLine = 0;
497 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
498  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
499  if (preg_match('/\$object/', $val)) {
500  $needToFetchEachLine++; // There is at least one compute field that use $object
501  }
502  }
503 }
504 
505 // Loop on record
506 // --------------------------------------------------------------------
507 $i = 0;
508 $total = 0;
509 $totalarray = array();
510 $totalarray['nbfield'] = 0;
511 $totalarray['val'] = array();
512 $totalarray['val']['totalttcfield'] = 0;
513 while ($i < ($limit ? min($num, $limit) : $num)) {
514  $obj = $db->fetch_object($resql);
515  if (empty($obj)) {
516  break; // Should not happen
517  }
518 
519  // Store properties in $object
520  $object->setVarsFromFetchObj($obj);
521 
522  $userstatic->id = $obj->uid;
523  $userstatic->lastname = $obj->lastname;
524  $userstatic->firstname = $obj->firstname;
525  $userstatic->admin = $obj->admin;
526  $userstatic->login = $obj->login;
527  $userstatic->email = $obj->email;
528  $userstatic->socid = $obj->fk_soc;
529  $userstatic->statut = $obj->status;
530 
531  $salstatic->id = $obj->rowid;
532  $salstatic->ref = $obj->rowid;
533  $salstatic->label = $obj->label;
534  $salstatic->paye = $obj->paye;
535  $salstatic->datesp = $db->jdate($obj->datesp);
536  $salstatic->dateep = $db->jdate($obj->dateep);
537 
538  // Show here line of result
539  print '<tr class="oddeven">';
540 
541  // Ref
542  print "<td>".$salstatic->getNomUrl(1)."</td>\n";
543  if (!$i) {
544  $totalarray['nbfield']++;
545  }
546 
547  // Label payment
548  print "<td>".dol_trunc($obj->label, 40)."</td>\n";
549  if (!$i) {
550  $totalarray['nbfield']++;
551  }
552 
553  // Date Start
554  print '<td class="center">'.dol_print_date($db->jdate($obj->datesp), 'day')."</td>\n";
555  if (!$i) {
556  $totalarray['nbfield']++;
557  }
558 
559  // Date End
560  print '<td class="center">'.dol_print_date($db->jdate($obj->dateep), 'day')."</td>\n";
561  if (!$i) {
562  $totalarray['nbfield']++;
563  }
564 
565  // Employee
566  print "<td>".$userstatic->getNomUrl(1)."</td>\n";
567  if (!$i) {
568  $totalarray['nbfield']++;
569  }
570 
571  // Type
572  print '<td>';
573  if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code);
574  print '</td>';
575  if (!$i) {
576  $totalarray['nbfield']++;
577  }
578 
579  // Account
580  if (isModEnabled('banque')) {
581  print '<td>';
582  if ($obj->fk_account > 0) {
583  //$accountstatic->fetch($obj->fk_bank);
584  $accountstatic->id = $obj->bid;
585  $accountstatic->ref = $obj->bref;
586  $accountstatic->label = $obj->blabel;
587  $accountstatic->number = $obj->bnumber;
588  $accountstatic->iban = $obj->iban;
589  $accountstatic->bic = $obj->bic;
590  $accountstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
591  $accountstatic->account_number = $obj->account_number;
592  $accountstatic->clos = $obj->clos;
593 
594  if (isModEnabled('accounting')) {
595  $accountstatic->account_number = $obj->account_number;
596 
597  $accountingjournal = new AccountingJournal($db);
598  $accountingjournal->fetch($obj->fk_accountancy_journal);
599 
600  $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
601  }
602  //$accountstatic->label = $obj->blabel;
603  print $accountstatic->getNomUrl(1);
604  } else {
605  print '&nbsp;';
606  }
607  print '</td>';
608  if (!$i) {
609  $totalarray['nbfield']++;
610  }
611  }
612 
613  // if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
614 
615  // Amount
616  print '<td class="nowrap right"><span class="amount">'.price($obj->amount).'</span></td>';
617  if (!$i) {
618  $totalarray['nbfield']++;
619  }
620  if (!$i) {
621  $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
622  }
623  $totalarray['val']['totalttcfield'] += $obj->amount;
624 
625  print '<td class="nowrap right">'.$salstatic->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>';
626  if (!$i) $totalarray['nbfield']++;
627 
628  // Extra fields
629  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
630  // Fields from hook
631  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
632  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
633  print $hookmanager->resPrint;
634  // Action column
635  print '<td class="nowrap center">';
636  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
637  $selected = 0;
638  if (in_array($object->id, $arrayofselected)) {
639  $selected = 1;
640  }
641  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
642  }
643  print '</td>';
644  if (!$i) {
645  $totalarray['nbfield']++;
646  }
647 
648  print '</tr>'."\n";
649 
650  $i++;
651 }
652 
653 // Show total line
654 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
655 
656 
657 // If no record found
658 if ($num == 0) {
659  /*$colspan = 1;
660  foreach ($arrayfields as $key => $val) {
661  if (!empty($val['checked'])) {
662  $colspan++;
663  }
664  }*/
665  $colspan = 9;
666  if (isModEnabled('banque')) { $colspan++; }
667  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
668 }
669 
670 
671 $db->free($resql);
672 
673 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
674 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
675 print $hookmanager->resPrint;
676 
677 print '</table>'."\n";
678 print '</div>'."\n";
679 
680 print '</form>'."\n";
681 
682 
683 // End of page
684 llxFooter();
685 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
getTitleFieldOfList
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
Definition: functions.lib.php:5049
PaymentSalary
Class to manage payments of salaries.
Definition: paymentsalary.class.php:34
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
dol_sort_array
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...
Definition: functions.lib.php:8385
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
AccountingJournal
Class to manage accounting accounts.
Definition: accountingjournal.class.php:27
dolGetButtonTitle
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.
Definition: functions.lib.php:10605
print_barre_liste
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.
Definition: functions.lib.php:5257
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
User
Class to manage Dolibarr users.
Definition: user.class.php:44
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
print_liste_field_titre
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
Definition: functions.lib.php:5026
natural_search
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...
Definition: functions.lib.php:9420
dol_eval
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
Definition: functions.lib.php:8611
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
Salary
Class to manage salary payments.
Definition: salary.class.php:33
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
dol_mktime
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...
Definition: functions.lib.php:2757
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
Account
Class to manage bank accounts.
Definition: account.class.php:38