dolibarr  19.0.0-dev
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 $mode = GETPOST('mode', 'alpha'); // mode view for result
49 
50 
51 // Load variable for pagination
52 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
53 $sortfield = GETPOST('sortfield', 'aZ09comma');
54 $sortorder = GETPOST('sortorder', 'aZ09comma');
55 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
56 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
57 $offset = $limit * $page;
58 $pageprev = $page - 1;
59 $pagenext = $page + 1;
60 if (!$sortfield) {
61  $sortfield = "s.datep,s.rowid";
62 }
63 if (!$sortorder) {
64  $sortorder = "DESC,DESC";
65 }
66 
67 // Initialize technical objects
68 $object = new PaymentSalary($db);
69 $extrafields = new ExtraFields($db);
70 $diroutputmassaction = $conf->user->dir_output.'/temp/massgeneration/'.$user->id;
71 $hookmanager->initHooks(array('salarieslist')); // Note that conf->hooks_modules contains array
72 
73 // Fetch optionals attributes and labels
74 $extrafields->fetch_name_optionals_label($object->table_element);
75 
76 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
77 
78 if (!$sortfield) {
79  $sortfield = "s.datep,s.rowid";
80 }
81 if (!$sortorder) {
82  $sortorder = "DESC,DESC";
83 }
84 
85 $search_ref = GETPOST('search_ref', 'int');
86 $search_ref_salary = GETPOST('search_ref_salary', 'int');
87 $search_user = GETPOST('search_user', 'alpha');
88 $search_label = GETPOST('search_label', 'alpha');
89 $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
90 $search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
91 $search_dateep_start = dol_mktime(0, 0, 0, GETPOST('search_dateep_startmonth', 'int'), GETPOST('search_dateep_startday', 'int'), GETPOST('search_dateep_startyear', 'int'));
92 $search_dateep_end = dol_mktime(23, 59, 59, GETPOST('search_dateep_endmonth', 'int'), GETPOST('search_dateep_endday', 'int'), GETPOST('search_dateep_endyear', 'int'));
93 $search_amount = GETPOST('search_amount', 'alpha');
94 $search_account = GETPOST('search_account', 'int');
95 $search_fk_bank = GETPOST('search_fk_bank', 'int');
96 $search_chq_number = GETPOST('search_chq_number', 'int');
97 
98 $filtre = GETPOST("filtre", 'restricthtml');
99 
100 $search_type_id = '';
101 if (!GETPOST('search_type_id', 'int')) {
102  $newfiltre = str_replace('filtre=', '', $filtre);
103  $filterarray = explode('-', $newfiltre);
104  foreach ($filterarray as $val) {
105  $part = explode(':', $val);
106  if ($part[0] == 's.fk_typepayment') {
107  $search_type_id = $part[1];
108  }
109  }
110 } else {
111  $search_type_id = GETPOST('search_type_id', 'int');
112 }
113 
114 $childids = $user->getAllChildIds(1);
115 
116 // Initialize array of search criterias
117 $search_all = GETPOST("search_all", 'alpha');
118 $search = array();
119 foreach ($object->fields as $key => $val) {
120  if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
121 }
122 
123 // List of fields to search into when doing a "search in all"
124 $fieldstosearchall = array();
125 foreach ($object->fields as $key => $val) {
126  if (!empty($val['searchall'])) {
127  $fieldstosearchall['t.'.$key] = $val['label'];
128  }
129 }
130 
131 // Definition of array of fields for columns
132 $arrayfields = array();
133 foreach ($object->fields as $key => $val) {
134  // If $val['visible']==0, then we never show the field
135  if (!empty($val['visible'])) {
136  $visible = (int) dol_eval($val['visible'], 1, 1, '1');
137  $arrayfields['t.'.$key] = array(
138  'label'=>$val['label'],
139  'checked'=>(($visible < 0) ? 0 : 1),
140  'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')),
141  'position'=>$val['position'],
142  'help'=> isset($val['help']) ? $val['help'] : ''
143  );
144  }
145 }
146 
147 $permissiontoread = $user->rights->salaries->read;
148 $permissiontoadd = $user->rights->salaries->write;
149 $permissiontodelete = $user->rights->salaries->delete;
150 
151 // Security check
152 $socid = GETPOST("socid", "int");
153 if ($user->socid > 0) {
154  $socid = $user->socid;
155 }
156 restrictedArea($user, 'salaries', 0, 'salary', '');
157 
158 
159 /*
160  * Actions
161  */
162 
163 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
164 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
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_ref_salary = "";
180  $search_user = "";
181  $search_label = "";
182  $search_date_start = '';
183  $search_date_end = '';
184  $search_dateep_start = '';
185  $search_dateep_end = '';
186  $search_amount = "";
187  $search_account = '';
188  $search_fk_bank = '';
189  $search_chq_number = '';
190  $search_type_id = "";
191  }
192  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
193  || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
194  $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
195  }
196 
197  // Mass actions
198  $objectclass = 'PaymentSalary';
199  $objectlabel = 'SalariesPayments';
200  $uploaddir = $conf->salaries->dir_output;
201  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
202 
203  // Validate records
204  if (!$error && $massaction == 'buildsepa' && $permissiontoadd) {
205  $objecttmp = new $objectclass($db);
206 
207  // TODO
208  }
209 }
210 
211 /*
212  * View
213  */
214 
215 $form = new Form($db);
216 $salstatic = new Salary($db);
217 $paymentsalstatic = new PaymentSalary($db);
218 $userstatic = new User($db);
219 $accountstatic = new Account($db);
220 $accountlinestatic = new AccountLine($db);
221 
222 $now = dol_now();
223 
224 //$help_url="EN:Module_BillOfMaterials|FR:Module_BillOfMaterials_FR|ES:Módulo_BillOfMaterials";
225 $help_url = '';
226 $title = $langs->trans('SalariesPayments');
227 
228 $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,";
229 $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,";
230 $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,";
231 $sql .= " pst.code as payment_code";
232 $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
233 $sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as sal ON (sal.rowid = s.fk_salary)";
234 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id";
235 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
236 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid,";
237 $sql .= " ".MAIN_DB_PREFIX."user as u";
238 $sql .= " WHERE u.rowid = sal.fk_user";
239 $sql .= " AND s.entity IN (".getEntity('payment_salaries').")";
240 if (empty($user->rights->salaries->readall)) {
241  $sql .= " AND sal.fk_user IN (".$db->sanitize(join(',', $childids)).")";
242 }
243 
244 // Search criteria
245 if ($search_ref) {
246  $sql .= " AND s.rowid=".((int) $search_ref);
247 }
248 if ($search_ref_salary) {
249  $sql .= " AND sal.rowid=".((int) $search_ref_salary);
250 }
251 if ($search_user) {
252  $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
253 }
254 if ($search_label) {
255  $sql .= natural_search(array('sal.label'), $search_label);
256 }
257 if ($search_date_start) {
258  $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'";
259 }
260 if ($search_date_end) {
261  $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'";
262 }
263 if ($search_dateep_start) {
264  $sql .= " AND sal.dateep >= '".$db->idate($search_dateep_start)."'";
265 }
266 if ($search_dateep_end) {
267  $sql .= " AND sal.dateep <= '".$db->idate($search_dateep_end)."'";
268 }
269 if ($search_amount) {
270  $sql .= natural_search("s.amount", $search_amount, 1);
271 }
272 if ($search_account > 0) {
273  $sql .= " AND b.fk_account=".((int) $search_account);
274 }
275 if ($search_fk_bank) {
276  $sql .= " AND s.fk_bank=".((int) $search_fk_bank);
277 }
278 if ($search_chq_number) {
279  $sql .= natural_search(array('s.num_payment'), $search_chq_number);
280 }
281 
282 if ($search_type_id > 0) {
283  $sql .= " AND s.fk_typepayment=".((int) $search_type_id);
284 }
285 $sql .= $db->order($sortfield, $sortorder);
286 
287 // Count total nb of records
288 $nbtotalofrecords = '';
289 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
290  $resql = $db->query($sql);
291  $nbtotalofrecords = $db->num_rows($resql);
292  if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
293  $page = 0;
294  $offset = 0;
295  }
296 }
297 // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
298 if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
299  $num = $nbtotalofrecords;
300 } else {
301  if ($limit) {
302  $sql .= $db->plimit($limit + 1, $offset);
303  }
304 
305  $resql = $db->query($sql);
306  if (!$resql) {
307  dol_print_error($db);
308  exit;
309  }
310 
311  $num = $db->num_rows($resql);
312 }
313 
314 // Output page
315 // --------------------------------------------------------------------
316 
317 llxHeader('', $title, $help_url);
318 
319 $arrayofselected = is_array($toselect) ? $toselect : array();
320 
321 $param = '';
322 if (!empty($mode)) {
323  $param .= '&mode='.urlencode($mode);
324 }
325 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
326  $param .= '&contextpage='.urlencode($contextpage);
327 }
328 if ($limit > 0 && $limit != $conf->liste_limit) {
329  $param .= '&limit='.((int) $limit);
330 }
331 if ($search_type_id) {
332  $param .= '&search_type_id='.urlencode($search_type_id);
333 }
334 if ($optioncss != '') {
335  $param .= '&optioncss='.urlencode($optioncss);
336 }
337 if ($search_ref) {
338  $param .= '&search_ref='.urlencode($search_ref);
339 }
340 if ($search_ref_salary) {
341  $param .= '&search_ref_salary='.urlencode($search_ref_salary);
342 }
343 if ($search_user) {
344  $param .= '&search_user='.urlencode($search_user);
345 }
346 if ($search_label) {
347  $param .= '&search_label='.urlencode($search_label);
348 }
349 if ($search_fk_bank) {
350  $param .= '&search_fk_bank='.urlencode($search_fk_bank);
351 }
352 if ($search_chq_number) {
353  $param .= '&search_chq_number='.urlencode($search_chq_number);
354 }
355 if ($search_account) {
356  $param .= '&search_account='.urlencode($search_account);
357 }
358 if ($search_date_start) {
359  $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'));
360 }
361 if ($search_dateep_start) {
362  $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'));
363 }
364 if ($search_date_end) {
365  $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'));
366 }
367 if ($search_dateep_end) {
368  $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'));
369 }
370 // Add $param from extra fields
371 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
372 
373 // List of mass actions available
374 $arrayofmassactions = array(
375  //'presend'=>$langs->trans("SendByMail"),
376  //'buildsepa'=>$langs->trans("BuildSepa"), // TODO
377 );
378 //if ($permissiontodelete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
379 if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
380  $arrayofmassactions = array();
381 }
382 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
383 
384 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
385 if ($optioncss != '') {
386  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
387 }
388 print '<input type="hidden" name="token" value="'.newToken().'">';
389 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
390 print '<input type="hidden" name="action" value="list">';
391 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
392 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
393 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
394 print '<input type="hidden" name="mode" value="'.$mode.'">';
395 
396 
397 $url = DOL_URL_ROOT.'/salaries/card.php?action=create';
398 if (!empty($socid)) {
399  $url .= '&socid='.$socid;
400 }
401 $newcardbutton = '';
402 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
403 $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
404 $newcardbutton = dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->salaries->write);
405 
406 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
407 
408 $moreforfilter = '';
409 
410 $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
411 //$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
412 $selectedfields = '';
413 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
414 
415 print '<div class="div-table-responsive">';
416 print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
417 
418 // Fields title search
419 // --------------------------------------------------------------------
420 print '<tr class="liste_titre_filter">';
421 // Ref
422 print '<td class="liste_titre left">';
423 print '<input class="flat" type="text" size="3" name="search_ref" value="'.$db->escape($search_ref).'">';
424 print '</td>';
425 // Salary
426 print '<td class="liste_titre center">';
427 print '<input class="flat" type="text" size="3" name="search_ref_salary" value="'.$db->escape($search_ref_salary).'">';
428 print '</td>';
429 // Label
430 print '<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$db->escape($search_label).'"></td>';
431 // Date end period
432 print '<td class="liste_titre center">';
433 print '<div class="nowrap">';
434 print $form->selectDate($search_dateep_start ? $search_dateep_start : -1, 'search_dateep_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
435 print '</div>';
436 print '<div class="nowrap">';
437 print $form->selectDate($search_dateep_end ? $search_dateep_end : -1, 'search_dateep_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
438 print '</div>';
439 print '</td>';
440 // Date payment
441 print '<td class="liste_titre center">';
442 print '<div class="nowrap">';
443 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
444 print '</div>';
445 print '<div class="nowrap">';
446 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
447 print '</div>';
448 print '</td>';
449 // Date value
450 /*print '<td class="liste_titre center">';
451 print '</td>';*/
452 // Employee
453 print '<td class="liste_titre">';
454 print '<input class="flat" type="text" size="6" name="search_user" value="'.$db->escape($search_user).'">';
455 print '</td>';
456 // Type
457 print '<td class="liste_titre left">';
458 print $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16, 1, '', 1);
459 print '</td>';
460 // Chq number
461 print '<td class="liste_titre right"><input name="search_chq_number" class="flat" type="text" size="8" value="'.$db->escape($search_chq_number).'"></td>';
462 
463 if (isModEnabled("banque")) {
464  // Bank transaction
465  print '<td class="liste_titre center">';
466  print '<input class="flat" type="text" size="3" name="search_fk_bank" value="'.$db->escape($search_fk_bank).'">';
467  print '</td>';
468 
469  // Account
470  print '<td class="liste_titre">';
471  $form->select_comptes($search_account, 'search_account', 0, '', 1);
472  print '</td>';
473 }
474 // Amount
475 print '<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$db->escape($search_amount).'"></td>';
476 
477 // Extra fields
478 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
479 
480 // Fields from hook
481 $parameters = array('arrayfields'=>$arrayfields);
482 $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
483 print $hookmanager->resPrint;
484 // Action column
485 print '<td class="liste_titre maxwidthsearch">';
486 $searchpicto = $form->showFilterButtons();
487 print $searchpicto;
488 print '</td>';
489 print '</tr>'."\n";
490 
491 $totalarray = array();
492 $totalarray['nbfield'] = 0;
493 
494 // Fields title label
495 // --------------------------------------------------------------------
496 print '<tr class="liste_titre">';
497 // Action column
498 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
499  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
500  $totalarray['nbfield']++;
501 }
502 print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder);
503 $totalarray['nbfield']++;
504 print_liste_field_titre("Salary", $_SERVER["PHP_SELF"], "sal.rowid", "", $param, '', $sortfield, $sortorder);
505 $totalarray['nbfield']++;
506 print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder);
507 $totalarray['nbfield']++;
508 print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "sal.dateep", "", $param, '', $sortfield, $sortorder, 'center ');
509 $totalarray['nbfield']++;
510 print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
511 $totalarray['nbfield']++;
512 print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder);
513 $totalarray['nbfield']++;
514 print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pst.code", "", $param, 'class="left"', $sortfield, $sortorder);
515 $totalarray['nbfield']++;
516 print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "s.num_payment", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber');
517 $totalarray['nbfield']++;
518 if (isModEnabled("banque")) {
519  print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "s.fk_bank", "", $param, '', $sortfield, $sortorder);
520  $totalarray['nbfield']++;
521  print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
522  $totalarray['nbfield']++;
523 }
524 print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
525 $totalarray['nbfield']++;
526 // Extra fields
527 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
528 // Hook fields
529 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
530 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
531 print $hookmanager->resPrint;
532 // Action column
533 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
534  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
535  $totalarray['nbfield']++;
536 }
537 print '</tr>'."\n";
538 
539 
540 // Detect if we need a fetch on each output line
541 $needToFetchEachLine = 0;
542 if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
543  foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
544  if (!is_null($val) && preg_match('/\$object/', $val)) {
545  $needToFetchEachLine++;
546  }
547  // There is at least one compute field that use $object
548  }
549 }
550 
551 // Loop on record
552 // --------------------------------------------------------------------
553 $i = 0;
554 $savnbfield = $totalarray['nbfield'];
555 $totalarray = array();
556 $totalarray['nbfield'] = 0;
557 $imaxinloop = ($limit ? min($num, $limit) : $num);
558 while ($i < $imaxinloop) {
559  $obj = $db->fetch_object($resql);
560  if (empty($obj)) {
561  break;
562  }
563  // Should not happen
564 
565  // Store properties in $object
566  $object->setVarsFromFetchObj($obj);
567 
568  $userstatic->id = $obj->uid;
569  $userstatic->lastname = $obj->lastname;
570  $userstatic->firstname = $obj->firstname;
571  $userstatic->admin = $obj->admin;
572  $userstatic->login = $obj->login;
573  $userstatic->email = $obj->email;
574  $userstatic->socid = $obj->fk_soc;
575  $userstatic->statut = $obj->status;
576 
577  $salstatic->id = $obj->id_salary;
578  $salstatic->ref = $obj->id_salary;
579 
580  $paymentsalstatic->id = $obj->rowid;
581  $paymentsalstatic->ref = $obj->rowid;
582  $paymentsalstatic->amount = $obj->amount;
583  $paymentsalstatic->fk_typepayment = $obj->payment_code;
584  $paymentsalstatic->datec = $obj->dateep;
585  $paymentsalstatic->datep = $obj->datep;
586 
587  $accountlinestatic->id = $obj->fk_bank;
588  $accountlinestatic->ref = $obj->fk_bank;
589  $paymentsalstatic->fk_bank = $accountlinestatic->getNomUrl(1);
590  $paymentsalstatic->fk_user_author = $userstatic->getNomUrl(1);
591 
592  if ($mode == 'kanban') {
593  if ($i == 0) {
594  print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
595  print '<div class="box-flex-container kanban">';
596  }
597  // Output Kanban
598  print $paymentsalstatic->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
599  if ($i == ($imaxinloop - 1)) {
600  print '</div>';
601  print '</td></tr>';
602  }
603  } else {
604  // Show here line of result
605  print '<tr class="oddeven">';
606  // Ref
607  print "<td>".$paymentsalstatic->getNomUrl(1)."</td>\n";
608  if (!$i) {
609  $totalarray['nbfield']++;
610  }
611 
612  // Date payment
613  print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'dayhour', 'tzuserrel')."</td>\n";
614  if (!$i) {
615  $totalarray['nbfield']++;
616  }
617 
618  // Ref salary
619  print "<td>".$salstatic->getNomUrl(1)."</td>\n";
620  if (!$i) {
621  $totalarray['nbfield']++;
622  }
623 
624  // Label payment
625  print "<td>".dol_trunc($obj->label, 40)."</td>\n";
626  if (!$i) {
627  $totalarray['nbfield']++;
628  }
629 
630  // Date end period
631  print '<td class="center">'.dol_print_date($db->jdate($obj->dateep), 'day')."</td>\n";
632  if (!$i) {
633  $totalarray['nbfield']++;
634  }
635 
636  // Date payment
637  print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
638  if (!$i) {
639  $totalarray['nbfield']++;
640  }
641 
642  // Date value
643  /*print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day')."</td>\n";
644  if (!$i) $totalarray['nbfield']++;*/
645 
646  // Employee
647  print "<td>".$userstatic->getNomUrl(1)."</td>\n";
648  if (!$i) {
649  $totalarray['nbfield']++;
650  }
651 
652  // Type
653  print '<td>';
654  print $langs->trans("PaymentTypeShort".$obj->payment_code);
655  print '</td>';
656  if (!$i) {
657  $totalarray['nbfield']++;
658  }
659 
660  // Chq number
661  print '<td>'.$obj->num_payment.'</td>';
662  if (!$i) {
663  $totalarray['nbfield']++;
664  }
665 
666  // Account
667  if (isModEnabled("banque")) {
668  // Bank transaction
669  print '<td>';
670  $accountlinestatic->id = $obj->fk_bank;
671  print $accountlinestatic->getNomUrl(1);
672  print '</td>';
673  if (!$i) {
674  $totalarray['nbfield']++;
675  }
676 
677  print '<td>';
678  if ($obj->fk_bank > 0) {
679  //$accountstatic->fetch($obj->fk_bank);
680  $accountstatic->id = $obj->bid;
681  $accountstatic->ref = $obj->bref;
682  $accountstatic->number = $obj->bnumber;
683  $accountstatic->iban = $obj->iban;
684  $accountstatic->bic = $obj->bic;
685  $accountstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
686  $accountstatic->clos = $obj->clos;
687 
688  if (isModEnabled('accounting')) {
689  $accountstatic->account_number = $obj->account_number;
690 
691  $accountingjournal = new AccountingJournal($db);
692  $accountingjournal->fetch($obj->fk_accountancy_journal);
693 
694  $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
695  }
696  $accountstatic->label = $obj->blabel;
697  if ($accountstatic->id > 0) {
698  print $accountstatic->getNomUrl(1);
699  }
700  } else {
701  print '&nbsp;';
702  }
703  print '</td>';
704  if (!$i) {
705  $totalarray['nbfield']++;
706  }
707  }
708 
709  // Amount
710  print '<td class="nowrap right"><span class="amount">'.price($obj->amount).'</span></td>';
711  if (!$i) {
712  $totalarray['nbfield']++;
713  }
714  if (!$i) {
715  $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
716  }
717  if (!$i) {
718  $totalarray['val']['totalttcfield'] = $obj->amount;
719  } else {
720  $totalarray['val']['totalttcfield'] += $obj->amount;
721  }
722 
723 
724  // Extra fields
725  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
726  // Fields from hook
727  $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
728  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
729  print $hookmanager->resPrint;
730  // Action column
731  print '<td class="nowrap center">';
732  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
733  $selected = 0;
734  if (in_array($object->id, $arrayofselected)) {
735  $selected = 1;
736  }
737  print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
738  }
739  print '</td>';
740  if (!$i) {
741  $totalarray['nbfield']++;
742  }
743 
744  print '</tr>'."\n";
745  }
746  $i++;
747 }
748 
749 // Show total line
750 include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
751 
752 
753 // If no record found
754 if ($num == 0) {
755  /*$colspan = 1;
756  foreach ($arrayfields as $key => $val) {
757  if (!empty($val['checked'])) {
758  $colspan++;
759  }
760  }*/
761  $colspan = 12;
762  print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
763 }
764 
765 
766 $db->free($resql);
767 
768 $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
769 $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
770 print $hookmanager->resPrint;
771 
772 print '</table>'."\n";
773 print '</div>'."\n";
774 
775 print '</form>'."\n";
776 
777 // End of page
778 llxFooter();
779 $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 journals.
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:48
if(isModEnabled('facture') && $user->hasRight('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') && $user->hasRight('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)) $sql
Social contributions to pay.
Definition: index.php:746
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...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.