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