dolibarr  17.0.4
payments.php
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/salary.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
32 if (isModEnabled('accounting')) {
33  require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
34 }
35 
36 // Load translation files required by the page
37 $langs->loadLangs(array("compta", "salaries", "bills", "hrm"));
38 
39 $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
40 $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
41 $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
42 $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
43 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
44 $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
45 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomlist'; // To manage different context of search
46 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
47 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
48 
49 // Load variable for pagination
50 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
51 $sortfield = GETPOST('sortfield', 'aZ09comma');
52 $sortorder = GETPOST('sortorder', 'aZ09comma');
53 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
54 if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // 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_ref_salary = GETPOST('search_ref_salary', 'int');
85 $search_user = GETPOST('search_user', 'alpha');
86 $search_label = GETPOST('search_label', 'alpha');
87 $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
88 $search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
89 $search_dateep_start = dol_mktime(0, 0, 0, GETPOST('search_dateep_startmonth', 'int'), GETPOST('search_dateep_startday', 'int'), GETPOST('search_dateep_startyear', 'int'));
90 $search_dateep_end = dol_mktime(23, 59, 59, GETPOST('search_dateep_endmonth', 'int'), GETPOST('search_dateep_endday', 'int'), GETPOST('search_dateep_endyear', 'int'));
91 $search_amount = GETPOST('search_amount', 'alpha');
92 $search_account = GETPOST('search_account', 'int');
93 $search_fk_bank = GETPOST('search_fk_bank', 'int');
94 $search_chq_number = GETPOST('search_chq_number', 'int');
95 
96 $filtre = GETPOST("filtre", 'restricthtml');
97 
98 if (!GETPOST('search_type_id', 'int')) {
99  $newfiltre = str_replace('filtre=', '', $filtre);
100  $filterarray = explode('-', $newfiltre);
101  foreach ($filterarray as $val) {
102  $part = explode(':', $val);
103  if ($part[0] == 's.fk_typepayment') {
104  $search_type_id = $part[1];
105  }
106  }
107 } else {
108  $search_type_id = GETPOST('search_type_id', 'int');
109 }
110 
111 $childids = $user->getAllChildIds(1);
112 
113 // Initialize array of search criterias
114 $search_all = GETPOST("search_all", 'alpha');
115 $search = array();
116 foreach ($object->fields as $key => $val) {
117  if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
118 }
119 
120 // List of fields to search into when doing a "search in all"
121 $fieldstosearchall = array();
122 foreach ($object->fields as $key => $val) {
123  if (!empty($val['searchall'])) {
124  $fieldstosearchall['t.'.$key] = $val['label'];
125  }
126 }
127 
128 // Definition of array of fields for columns
129 $arrayfields = array();
130 foreach ($object->fields as $key => $val) {
131  // If $val['visible']==0, then we never show the field
132  if (!empty($val['visible'])) {
133  $visible = (int) dol_eval($val['visible'], 1, 1, '1');
134  $arrayfields['t.'.$key] = array(
135  'label'=>$val['label'],
136  'checked'=>(($visible < 0) ? 0 : 1),
137  'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
138  'position'=>$val['position'],
139  'help'=> isset($val['help']) ? $val['help'] : ''
140  );
141  }
142 }
143 
144 $permissiontoread = $user->rights->salaries->read;
145 $permissiontoadd = $user->rights->salaries->write;
146 $permissiontodelete = $user->rights->salaries->delete;
147 
148 // Security check
149 $socid = GETPOST("socid", "int");
150 if ($user->socid > 0) {
151  $socid = $user->socid;
152 }
153 restrictedArea($user, 'salaries', 0, 'salary', '');
154 
155 
156 /*
157  * Actions
158  */
159 
160 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
161 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
162 
163 $parameters = array();
164 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
165 if ($reshook < 0) {
166  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
167 }
168 
169 if (empty($reshook)) {
170  // Selection of new fields
171  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
172 
173  // Purge search criteria
174  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
175  $search_ref = "";
176  $search_ref_salary = "";
177  $search_user = "";
178  $search_label = "";
179  $search_date_start = '';
180  $search_date_end = '';
181  $search_dateep_start = '';
182  $search_dateep_end = '';
183  $search_amount = "";
184  $search_account = '';
185  $search_fk_bank = '';
186  $search_chq_number = '';
187  $search_type_id = "";
188  }
189  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
190  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
191  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
192  }
193 
194  // Mass actions
195  $objectclass = 'PaymentSalary';
196  $objectlabel = 'SalariesPayments';
197  $uploaddir = $conf->salaries->dir_output;
198  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
199 
200  // Validate records
201  if (!$error && $massaction == 'buildsepa' && $permissiontoadd) {
202  $objecttmp = new $objectclass($db);
203 
204  // TODO
205  }
206 }
207 
208 /*
209  * View
210  */
211 
212 $form = new Form($db);
213 $salstatic = new Salary($db);
214 $paymentsalstatic = new PaymentSalary($db);
215 $userstatic = new User($db);
216 $accountstatic = new Account($db);
217 $accountlinestatic = new AccountLine($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('SalariesPayments');
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_user, s.amount, s.salary, sal.rowid as id_salary, sal.label, s.datep as datep, sal.dateep, b.datev as datev, s.fk_typepayment as type, s.num_payment, s.fk_bank,";
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 .= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
230 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as sal ON (sal.rowid = s.fk_salary)";
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 as b ON s.fk_bank = b.rowid";
233 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid,";
234 $sql .= " ".MAIN_DB_PREFIX."user as u";
235 $sql .= " WHERE u.rowid = sal.fk_user";
236 $sql .= " AND s.entity IN (".getEntity('payment_salaries').")";
237 if (empty($user->rights->salaries->readall)) {
238  $sql .= " AND sal.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_ref_salary) {
246  $sql .= " AND sal.rowid=".((int) $search_ref_salary);
247 }
248 if ($search_user) {
249  $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
250 }
251 if ($search_label) {
252  $sql .= natural_search(array('sal.label'), $search_label);
253 }
254 if ($search_date_start) {
255  $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'";
256 }
257 if ($search_date_end) {
258  $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'";
259 }
260 if ($search_dateep_start) {
261  $sql .= " AND sal.dateep >= '".$db->idate($search_dateep_start)."'";
262 }
263 if ($search_dateep_end) {
264  $sql .= " AND sal.dateep <= '".$db->idate($search_dateep_end)."'";
265 }
266 if ($search_amount) {
267  $sql .= natural_search("s.amount", $search_amount, 1);
268 }
269 if ($search_account > 0) {
270  $sql .= " AND b.fk_account=".((int) $search_account);
271 }
272 if ($search_fk_bank) {
273  $sql .= " AND s.fk_bank=".((int) $search_fk_bank);
274 }
275 if ($search_chq_number) {
276  $sql .= natural_search(array('s.num_payment'), $search_chq_number);
277 }
278 
279 if ($search_type_id > 0) {
280  $sql .= " AND s.fk_typepayment=".((int) $search_type_id);
281 }
282 $sql .= $db->order($sortfield, $sortorder);
283 
284 // Count total nb of records
285 $nbtotalofrecords = '';
286 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
287  $resql = $db->query($sql);
288  $nbtotalofrecords = $db->num_rows($resql);
289  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
290  $page = 0;
291  $offset = 0;
292  }
293 }
294 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
295 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
296  $num = $nbtotalofrecords;
297 } else {
298  if ($limit) {
299  $sql .= $db->plimit($limit + 1, $offset);
300  }
301 
302  $resql = $db->query($sql);
303  if (!$resql) {
304  dol_print_error($db);
305  exit;
306  }
307 
308  $num = $db->num_rows($resql);
309 }
310 
311 // Output page
312 // --------------------------------------------------------------------
313 
314 llxHeader('', $title, $help_url);
315 
316 $arrayofselected = is_array($toselect) ? $toselect : array();
317 
318 $param = '';
319 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
320  $param .= '&contextpage='.urlencode($contextpage);
321 }
322 if ($limit > 0 && $limit != $conf->liste_limit) {
323  $param .= '&limit='.urlencode($limit);
324 }
325 if ($search_type_id) {
326  $param .= '&search_type_id='.urlencode($search_type_id);
327 }
328 if ($optioncss != '') {
329  $param .= '&optioncss='.urlencode($optioncss);
330 }
331 if ($search_ref) {
332  $param .= '&search_ref='.urlencode($search_ref);
333 }
334 if ($search_ref_salary) {
335  $param .= '&search_ref_salary='.urlencode($search_ref_salary);
336 }
337 if ($search_user) {
338  $param .= '&search_user='.urlencode($search_user);
339 }
340 if ($search_label) {
341  $param .= '&search_label='.urlencode($search_label);
342 }
343 if ($search_fk_bank) {
344  $param .= '&search_fk_bank='.urlencode($search_fk_bank);
345 }
346 if ($search_chq_number) {
347  $param .= '&search_chq_number='.urlencode($search_chq_number);
348 }
349 if ($search_account) {
350  $param .= '&search_account='.urlencode($search_account);
351 }
352 if ($search_date_start) {
353  $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int'));
354 }
355 if ($search_dateep_start) {
356  $param .= '&search_dateep_startday='.urlencode(GETPOST('search_dateep_startday', 'int')).'&search_dateep_startmonth='.urlencode(GETPOST('search_dateep_startmonth', 'int')).'&search_dateep_startyear='.urlencode(GETPOST('search_dateep_startyear', 'int'));
357 }
358 if ($search_date_end) {
359  $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int'));
360 }
361 if ($search_dateep_end) {
362  $param .= '&search_dateep_endday='.urlencode(GETPOST('search_dateep_endday', 'int')).'&search_dateep_endmonth='.urlencode(GETPOST('search_dateep_endmonth', 'int')).'&search_dateep_endyear='.urlencode(GETPOST('search_dateep_endyear', 'int'));
363 }
364 // Add $param from extra fields
365 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
366 
367 // List of mass actions available
368 $arrayofmassactions = array(
369  //'presend'=>$langs->trans("SendByMail"),
370  //'buildsepa'=>$langs->trans("BuildSepa"), // TODO
371 );
372 //if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
373 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
374  $arrayofmassactions = array();
375 }
376 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
377 
378 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
379 if ($optioncss != '') {
380  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
381 }
382 print '<input type="hidden" name="token" value="'.newToken().'">';
383 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
384 print '<input type="hidden" name="action" value="list">';
385 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
386 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
387 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
388 
389 $url = DOL_URL_ROOT.'/salaries/card.php?action=create';
390 if (!empty($socid)) {
391  $url .= '&socid='.$socid;
392 }
393 $newcardbutton = dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->salaries->write);
394 
395 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
396 
397 $moreforfilter = '';
398 
399 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
400 //$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
401 $selectedfields = '';
402 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
403 
404 print '<div class="div-table-responsive">';
405 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
406 
407 // Fields title search
408 // --------------------------------------------------------------------
409 print '<tr class="liste_titre_filter">';
410 // Ref
411 print '<td class="liste_titre left">';
412 print '<input class="flat" type="text" size="3" name="search_ref" value="'.$db->escape($search_ref).'">';
413 print '</td>';
414 // Salary
415 print '<td class="liste_titre center">';
416 print '<input class="flat" type="text" size="3" name="search_ref_salary" value="'.$db->escape($search_ref_salary).'">';
417 print '</td>';
418 // Label
419 print '<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$db->escape($search_label).'"></td>';
420 // Date end period
421 print '<td class="liste_titre center">';
422 print '<div class="nowrap">';
423 print $form->selectDate($search_dateep_start ? $search_dateep_start : -1, 'search_dateep_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
424 print '</div>';
425 print '<div class="nowrap">';
426 print $form->selectDate($search_dateep_end ? $search_dateep_end : -1, 'search_dateep_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
427 print '</div>';
428 print '</td>';
429 // Date payment
430 print '<td class="liste_titre center">';
431 print '<div class="nowrap">';
432 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
433 print '</div>';
434 print '<div class="nowrap">';
435 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
436 print '</div>';
437 print '</td>';
438 // Date value
439 /*print '<td class="liste_titre center">';
440 print '</td>';*/
441 // Employee
442 print '<td class="liste_titre">';
443 print '<input class="flat" type="text" size="6" name="search_user" value="'.$db->escape($search_user).'">';
444 print '</td>';
445 // Type
446 print '<td class="liste_titre left">';
447 print $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16, 1, '', 1);
448 print '</td>';
449 // Chq number
450 print '<td class="liste_titre right"><input name="search_chq_number" class="flat" type="text" size="8" value="'.$db->escape($search_chq_number).'"></td>';
451 
452 if (isModEnabled("banque")) {
453  // Bank transaction
454  print '<td class="liste_titre center">';
455  print '<input class="flat" type="text" size="3" name="search_fk_bank" value="'.$db->escape($search_fk_bank).'">';
456  print '</td>';
457 
458  // Account
459  print '<td class="liste_titre">';
460  $form->select_comptes($search_account, 'search_account', 0, '', 1);
461  print '</td>';
462 }
463 // Amount
464 print '<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$db->escape($search_amount).'"></td>';
465 
466 // Extra fields
467 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
468 
469 // Fields from hook
470 $parameters = array('arrayfields'=>$arrayfields);
471 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
472 print $hookmanager->resPrint;
473 // Action column
474 print '<td class="liste_titre maxwidthsearch">';
475 $searchpicto = $form->showFilterButtons();
476 print $searchpicto;
477 print '</td>';
478 print '</tr>'."\n";
479 
480 
481 // Fields title label
482 // --------------------------------------------------------------------
483 print '<tr class="liste_titre">';
484 print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder);
485 print_liste_field_titre("Salary", $_SERVER["PHP_SELF"], "sal.rowid", "", $param, '', $sortfield, $sortorder);
486 print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder);
487 print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "sal.dateep", "", $param, '', $sortfield, $sortorder, 'center ');
488 print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
489 //print_liste_field_titre("DateValue", $_SERVER["PHP_SELF"], "b.datev,s.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
490 print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder);
491 print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pst.code", "", $param, 'class="left"', $sortfield, $sortorder);
492 print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "s.num_payment", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber');
493 if (isModEnabled("banque")) {
494  print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "s.fk_bank", "", $param, '', $sortfield, $sortorder);
495  print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
496 }
497 print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
498 // Extra fields
499 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
500 // Hook fields
501 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
502 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
503 print $hookmanager->resPrint;
504 // Action column
505 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
506 print '</tr>'."\n";
507 
508 
509 // Detect if we need a fetch on each output line
510 $needToFetchEachLine = 0;
511 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
512  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
513  if (preg_match('/\$object/', $val)) {
514  $needToFetchEachLine++;
515  }
516  // There is at least one compute field that use $object
517  }
518 }
519 
520 // Loop on record
521 // --------------------------------------------------------------------
522 $i = 0;
523 $total = 0;
524 $totalarray = array();
525 while ($i < ($limit ? min($num, $limit) : $num)) {
526  $obj = $db->fetch_object($resql);
527  if (empty($obj)) {
528  break;
529  }
530  // Should not happen
531 
532  // Store properties in $object
533  $object->setVarsFromFetchObj($obj);
534 
535  // Show here line of result
536  print '<tr class="oddeven">';
537 
538  $userstatic->id = $obj->uid;
539  $userstatic->lastname = $obj->lastname;
540  $userstatic->firstname = $obj->firstname;
541  $userstatic->admin = $obj->admin;
542  $userstatic->login = $obj->login;
543  $userstatic->email = $obj->email;
544  $userstatic->socid = $obj->fk_soc;
545  $userstatic->statut = $obj->status;
546 
547  $salstatic->id = $obj->id_salary;
548  $salstatic->ref = $obj->id_salary;
549 
550  $paymentsalstatic->id = $obj->rowid;
551  $paymentsalstatic->ref = $obj->rowid;
552 
553  // Ref
554  print "<td>".$paymentsalstatic->getNomUrl(1)."</td>\n";
555  if (!$i) {
556  $totalarray['nbfield']++;
557  }
558 
559  // Ref salary
560  print "<td>".$salstatic->getNomUrl(1)."</td>\n";
561  if (!$i) {
562  $totalarray['nbfield']++;
563  }
564 
565  // Label payment
566  print "<td>".dol_trunc($obj->label, 40)."</td>\n";
567  if (!$i) {
568  $totalarray['nbfield']++;
569  }
570 
571  // Date end period
572  print '<td class="center">'.dol_print_date($db->jdate($obj->dateep), 'day')."</td>\n";
573  if (!$i) {
574  $totalarray['nbfield']++;
575  }
576 
577  // Date payment
578  print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
579  if (!$i) {
580  $totalarray['nbfield']++;
581  }
582 
583  // Date value
584  /*print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day')."</td>\n";
585  if (!$i) $totalarray['nbfield']++;*/
586 
587  // Employee
588  print "<td>".$userstatic->getNomUrl(1)."</td>\n";
589  if (!$i) {
590  $totalarray['nbfield']++;
591  }
592 
593  // Type
594  print '<td>';
595  print $langs->trans("PaymentTypeShort".$obj->payment_code);
596  print '</td>';
597  if (!$i) {
598  $totalarray['nbfield']++;
599  }
600 
601  // Chq number
602  print '<td>'.$obj->num_payment.'</td>';
603  if (!$i) {
604  $totalarray['nbfield']++;
605  }
606 
607  // Account
608  if (isModEnabled("banque")) {
609  // Bank transaction
610  print '<td>';
611  $accountlinestatic->id = $obj->fk_bank;
612  print $accountlinestatic->getNomUrl(1);
613  print '</td>';
614  if (!$i) {
615  $totalarray['nbfield']++;
616  }
617 
618  print '<td>';
619  if ($obj->fk_bank > 0) {
620  //$accountstatic->fetch($obj->fk_bank);
621  $accountstatic->id = $obj->bid;
622  $accountstatic->ref = $obj->bref;
623  $accountstatic->number = $obj->bnumber;
624  $accountstatic->iban = $obj->iban;
625  $accountstatic->bic = $obj->bic;
626  $accountstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
627  $accountstatic->clos = $obj->clos;
628 
629  if (isModEnabled('accounting')) {
630  $accountstatic->account_number = $obj->account_number;
631 
632  $accountingjournal = new AccountingJournal($db);
633  $accountingjournal->fetch($obj->fk_accountancy_journal);
634 
635  $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
636  }
637  $accountstatic->label = $obj->blabel;
638  if ($accountstatic->id > 0) {
639  print $accountstatic->getNomUrl(1);
640  }
641  } else {
642  print '&nbsp;';
643  }
644  print '</td>';
645  if (!$i) {
646  $totalarray['nbfield']++;
647  }
648  }
649 
650  // Amount
651  print '<td class="nowrap right"><span class="amount">'.price($obj->amount).'</span></td>';
652  if (!$i) {
653  $totalarray['nbfield']++;
654  }
655  if (!$i) {
656  $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
657  }
658  $totalarray['val']['totalttcfield'] += $obj->amount;
659 
660  // Extra fields
661  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
662  // Fields from hook
663  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
664  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
665  print $hookmanager->resPrint;
666  // Action column
667  print '<td class="nowrap center">';
668  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
669  $selected = 0;
670  if (in_array($object->id, $arrayofselected)) {
671  $selected = 1;
672  }
673  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
674  }
675  print '</td>';
676  if (!$i) {
677  $totalarray['nbfield']++;
678  }
679 
680  print '</tr>'."\n";
681 
682  $i++;
683 }
684 
685 // Show total line
686 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
687 
688 
689 // If no record found
690 if ($num == 0) {
691  /*$colspan = 1;
692  foreach ($arrayfields as $key => $val) {
693  if (!empty($val['checked'])) {
694  $colspan++;
695  }
696  }*/
697  $colspan = 12;
698  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
699 }
700 
701 
702 $db->free($resql);
703 
704 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
705 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
706 print $hookmanager->resPrint;
707 
708 print '</table>'."\n";
709 print '</div>'."\n";
710 
711 print '</form>'."\n";
712 
713 // End of page
714 llxFooter();
715 $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 bank transaction lines.
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_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_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.