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