dolibarr 18.0.6
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
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
30require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
31require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
32if (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');
56if (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;
60if (!$sortfield) {
61 $sortfield = "s.datep,s.rowid";
62}
63if (!$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
78if (!$sortfield) {
79 $sortfield = "s.datep,s.rowid";
80}
81if (!$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 = '';
101if (!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();
119foreach ($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();
125foreach ($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();
133foreach ($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");
153if ($user->socid > 0) {
154 $socid = $user->socid;
155}
156restrictedArea($user, 'salaries', 0, 'salary', '');
157
158
159/*
160 * Actions
161 */
162
163if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
164if (!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
168if ($reshook < 0) {
169 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
170}
171
172if (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').")";
240if (empty($user->rights->salaries->readall)) {
241 $sql .= " AND sal.fk_user IN (".$db->sanitize(join(',', $childids)).")";
242}
243
244// Search criteria
245if ($search_ref) {
246 $sql .= " AND s.rowid=".((int) $search_ref);
247}
248if ($search_ref_salary) {
249 $sql .= " AND sal.rowid=".((int) $search_ref_salary);
250}
251if ($search_user) {
252 $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
253}
254if ($search_label) {
255 $sql .= natural_search(array('sal.label'), $search_label);
256}
257if ($search_date_start) {
258 $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'";
259}
260if ($search_date_end) {
261 $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'";
262}
263if ($search_dateep_start) {
264 $sql .= " AND sal.dateep >= '".$db->idate($search_dateep_start)."'";
265}
266if ($search_dateep_end) {
267 $sql .= " AND sal.dateep <= '".$db->idate($search_dateep_end)."'";
268}
269if ($search_amount) {
270 $sql .= natural_search("s.amount", $search_amount, 1);
271}
272if ($search_account > 0) {
273 $sql .= " AND b.fk_account=".((int) $search_account);
274}
275if ($search_fk_bank) {
276 $sql .= " AND s.fk_bank=".((int) $search_fk_bank);
277}
278if ($search_chq_number) {
279 $sql .= natural_search(array('s.num_payment'), $search_chq_number);
280}
281
282if ($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 = '';
289if (!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.
298if (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
317llxHeader('', $title, $help_url);
318
319$arrayofselected = is_array($toselect) ? $toselect : array();
320
321$param = '';
322if (!empty($mode)) {
323 $param .= '&mode='.urlencode($mode);
324}
325if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
326 $param .= '&contextpage='.urlencode($contextpage);
327}
328if ($limit > 0 && $limit != $conf->liste_limit) {
329 $param .= '&limit='.((int) $limit);
330}
331if ($search_type_id) {
332 $param .= '&search_type_id='.urlencode($search_type_id);
333}
334if ($optioncss != '') {
335 $param .= '&optioncss='.urlencode($optioncss);
336}
337if ($search_ref) {
338 $param .= '&search_ref='.urlencode($search_ref);
339}
340if ($search_ref_salary) {
341 $param .= '&search_ref_salary='.urlencode($search_ref_salary);
342}
343if ($search_user) {
344 $param .= '&search_user='.urlencode($search_user);
345}
346if ($search_label) {
347 $param .= '&search_label='.urlencode($search_label);
348}
349if ($search_fk_bank) {
350 $param .= '&search_fk_bank='.urlencode($search_fk_bank);
351}
352if ($search_chq_number) {
353 $param .= '&search_chq_number='.urlencode($search_chq_number);
354}
355if ($search_account) {
356 $param .= '&search_account='.urlencode($search_account);
357}
358if ($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}
361if ($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}
364if ($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}
367if ($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
371include 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");
379if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
380 $arrayofmassactions = array();
381}
382$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
383
384print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
385if ($optioncss != '') {
386 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
387}
388print '<input type="hidden" name="token" value="'.newToken().'">';
389print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
390print '<input type="hidden" name="action" value="list">';
391print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
392print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
393print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
394print '<input type="hidden" name="mode" value="'.$mode.'">';
395
396
397$url = DOL_URL_ROOT.'/salaries/card.php?action=create';
398if (!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
406print_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
415print '<div class="div-table-responsive">';
416print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
417
418// Fields title search
419// --------------------------------------------------------------------
420print '<tr class="liste_titre_filter">';
421// Action column
422if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
423 print '<td class="liste_titre maxwidthsearch">';
424 $searchpicto = $form->showFilterButtons();
425 print $searchpicto;
426 print '</td>';
427}
428// Ref
429print '<td class="liste_titre left">';
430print '<input class="flat" type="text" size="3" name="search_ref" value="'.$db->escape($search_ref).'">';
431print '</td>';
432// Salary
433print '<td class="liste_titre center">';
434print '<input class="flat" type="text" size="3" name="search_ref_salary" value="'.$db->escape($search_ref_salary).'">';
435print '</td>';
436// Label
437print '<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$db->escape($search_label).'"></td>';
438// Date end period
439print '<td class="liste_titre center">';
440print '<div class="nowrap">';
441print $form->selectDate($search_dateep_start ? $search_dateep_start : -1, 'search_dateep_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
442print '</div>';
443print '<div class="nowrap">';
444print $form->selectDate($search_dateep_end ? $search_dateep_end : -1, 'search_dateep_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
445print '</div>';
446print '</td>';
447// Date payment
448print '<td class="liste_titre center">';
449print '<div class="nowrap">';
450print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
451print '</div>';
452print '<div class="nowrap">';
453print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
454print '</div>';
455print '</td>';
456// Date value
457/*print '<td class="liste_titre center">';
458print '</td>';*/
459// Employee
460print '<td class="liste_titre">';
461print '<input class="flat" type="text" size="6" name="search_user" value="'.$db->escape($search_user).'">';
462print '</td>';
463// Type
464print '<td class="liste_titre">';
465print $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16, 1, '', 1);
466print '</td>';
467// Chq number
468print '<td class="liste_titre"><input name="search_chq_number" class="flat width50" type="text" value="'.$db->escape($search_chq_number).'"></td>';
469
470if (isModEnabled("banque")) {
471 // Bank transaction
472 print '<td class="liste_titre">';
473 print '<input class="flat width50" type="text" name="search_fk_bank" value="'.$db->escape($search_fk_bank).'">';
474 print '</td>';
475
476 // Account
477 print '<td class="liste_titre">';
478 $form->select_comptes($search_account, 'search_account', 0, '', 1);
479 print '</td>';
480}
481// Amount
482print '<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$db->escape($search_amount).'"></td>';
483
484// Extra fields
485include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
486
487// Fields from hook
488$parameters = array('arrayfields'=>$arrayfields);
489$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
490print $hookmanager->resPrint;
491// Action column
492if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
493 print '<td class="liste_titre maxwidthsearch">';
494 $searchpicto = $form->showFilterButtons();
495 print $searchpicto;
496 print '</td>';
497}
498print '</tr>'."\n";
499
500$totalarray = array();
501$totalarray['nbfield'] = 0;
502
503// Fields title label
504// --------------------------------------------------------------------
505print '<tr class="liste_titre">';
506// Action column
507if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
508 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
509 $totalarray['nbfield']++;
510}
511print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder);
512$totalarray['nbfield']++;
513print_liste_field_titre("Salary", $_SERVER["PHP_SELF"], "sal.rowid", "", $param, '', $sortfield, $sortorder);
514$totalarray['nbfield']++;
515print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, '', $sortfield, $sortorder);
516$totalarray['nbfield']++;
517print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "sal.dateep", "", $param, '', $sortfield, $sortorder, 'center ');
518$totalarray['nbfield']++;
519print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
520$totalarray['nbfield']++;
521print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder);
522$totalarray['nbfield']++;
523print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pst.code", "", $param, '', $sortfield, $sortorder);
524$totalarray['nbfield']++;
525print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "s.num_payment", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber');
526$totalarray['nbfield']++;
527if (isModEnabled("banque")) {
528 print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "s.fk_bank", "", $param, '', $sortfield, $sortorder);
529 $totalarray['nbfield']++;
530 print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
531 $totalarray['nbfield']++;
532}
533print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder);
534$totalarray['nbfield']++;
535// Extra fields
536include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
537// Hook fields
538$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
539$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
540print $hookmanager->resPrint;
541// Action column
542if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
543 print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
544 $totalarray['nbfield']++;
545}
546print '</tr>'."\n";
547
548
549// Detect if we need a fetch on each output line
550$needToFetchEachLine = 0;
551if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
552 foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
553 if (!is_null($val) && preg_match('/\$object/', $val)) {
554 $needToFetchEachLine++;
555 }
556 // There is at least one compute field that use $object
557 }
558}
559
560// Loop on record
561// --------------------------------------------------------------------
562$i = 0;
563$savnbfield = $totalarray['nbfield'];
564$totalarray = array();
565$totalarray['nbfield'] = 0;
566$imaxinloop = ($limit ? min($num, $limit) : $num);
567while ($i < $imaxinloop) {
568 $obj = $db->fetch_object($resql);
569 if (empty($obj)) {
570 break;
571 }
572 // Should not happen
573
574 // Store properties in $object
575 $object->setVarsFromFetchObj($obj);
576
577 $userstatic->id = $obj->uid;
578 $userstatic->lastname = $obj->lastname;
579 $userstatic->firstname = $obj->firstname;
580 $userstatic->admin = $obj->admin;
581 $userstatic->login = $obj->login;
582 $userstatic->email = $obj->email;
583 $userstatic->socid = $obj->fk_soc;
584 $userstatic->statut = $obj->status;
585 $userstatic->status = $obj->status;
586
587 $salstatic->id = $obj->id_salary;
588 $salstatic->ref = $obj->id_salary;
589
590 $paymentsalstatic->id = $obj->rowid;
591 $paymentsalstatic->ref = $obj->rowid;
592 $paymentsalstatic->amount = $obj->amount;
593 $paymentsalstatic->fk_typepayment = $obj->payment_code;
594 $paymentsalstatic->datec = $obj->dateep;
595 $paymentsalstatic->datep = $obj->datep;
596
597 $accountlinestatic->id = $obj->fk_bank;
598 $accountlinestatic->ref = $obj->fk_bank;
599 $paymentsalstatic->fk_bank = $accountlinestatic->getNomUrl(1);
600 $paymentsalstatic->fk_user_author = $userstatic->getNomUrl(1);
601
602 if ($mode == 'kanban') {
603 if ($i == 0) {
604 print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
605 print '<div class="box-flex-container kanban">';
606 }
607 // Output Kanban
608 print $paymentsalstatic->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected)));
609 if ($i == ($imaxinloop - 1)) {
610 print '</div>';
611 print '</td></tr>';
612 }
613 } else {
614 // Show here line of result
615 print '<tr class="oddeven">';
616
617 // Action column
618 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
619 print '<td class="nowrap center">';
620 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
621 $selected = 0;
622 if (in_array($object->id, $arrayofselected)) {
623 $selected = 1;
624 }
625 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
626 }
627 print '</td>';
628 if (!$i) {
629 $totalarray['nbfield']++;
630 }
631 }
632
633 // Ref
634 print "<td>".$paymentsalstatic->getNomUrl(1)."</td>\n";
635 if (!$i) {
636 $totalarray['nbfield']++;
637 }
638
639 // Ref salary
640 print "<td>".$salstatic->getNomUrl(1)."</td>\n";
641 if (!$i) {
642 $totalarray['nbfield']++;
643 }
644
645 // Label payment
646 print "<td>".dol_trunc($obj->label, 40)."</td>\n";
647 if (!$i) {
648 $totalarray['nbfield']++;
649 }
650
651 // Date end period
652 print '<td class="center">'.dol_print_date($db->jdate($obj->dateep), 'day')."</td>\n";
653 if (!$i) {
654 $totalarray['nbfield']++;
655 }
656
657 // Date payment
658 print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
659 if (!$i) {
660 $totalarray['nbfield']++;
661 }
662
663 // Date value
664 /*print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day')."</td>\n";
665 if (!$i) $totalarray['nbfield']++;*/
666
667 // Employee
668 print "<td>".$userstatic->getNomUrl(1)."</td>\n";
669 if (!$i) {
670 $totalarray['nbfield']++;
671 }
672
673 // Type
674 print '<td>';
675 print $langs->trans("PaymentTypeShort".$obj->payment_code);
676 print '</td>';
677 if (!$i) {
678 $totalarray['nbfield']++;
679 }
680
681 // Chq number
682 print '<td>'.$obj->num_payment.'</td>';
683 if (!$i) {
684 $totalarray['nbfield']++;
685 }
686
687 // Account
688 if (isModEnabled("banque")) {
689 // Bank transaction
690 print '<td>';
691 $accountlinestatic->id = $obj->fk_bank;
692 print $accountlinestatic->getNomUrl(1);
693 print '</td>';
694 if (!$i) {
695 $totalarray['nbfield']++;
696 }
697
698 print '<td>';
699 if ($obj->fk_bank > 0) {
700 //$accountstatic->fetch($obj->fk_bank);
701 $accountstatic->id = $obj->bid;
702 $accountstatic->ref = $obj->bref;
703 $accountstatic->number = $obj->bnumber;
704 $accountstatic->iban = $obj->iban;
705 $accountstatic->bic = $obj->bic;
706 $accountstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
707 $accountstatic->clos = $obj->clos;
708
709 if (isModEnabled('accounting')) {
710 $accountstatic->account_number = $obj->account_number;
711
712 $accountingjournal = new AccountingJournal($db);
713 $accountingjournal->fetch($obj->fk_accountancy_journal);
714
715 $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
716 }
717 $accountstatic->label = $obj->blabel;
718 if ($accountstatic->id > 0) {
719 print $accountstatic->getNomUrl(1);
720 }
721 } else {
722 print '&nbsp;';
723 }
724 print '</td>';
725 if (!$i) {
726 $totalarray['nbfield']++;
727 }
728 }
729
730 // Amount
731 print '<td class="nowrap right"><span class="amount">'.price($obj->amount).'</span></td>';
732 if (!$i) {
733 $totalarray['nbfield']++;
734 }
735 if (!$i) {
736 $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
737 }
738 if (!$i) {
739 $totalarray['val']['totalttcfield'] = $obj->amount;
740 } else {
741 $totalarray['val']['totalttcfield'] += $obj->amount;
742 }
743
744
745 // Extra fields
746 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
747 // Fields from hook
748 $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
749 $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
750 print $hookmanager->resPrint;
751
752 // Action column
753 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
754 print '<td class="nowrap center">';
755 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
756 $selected = 0;
757 if (in_array($object->id, $arrayofselected)) {
758 $selected = 1;
759 }
760 print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
761 }
762 print '</td>';
763 if (!$i) {
764 $totalarray['nbfield']++;
765 }
766 }
767
768 print '</tr>'."\n";
769 }
770 $i++;
771}
772
773// Show total line
774include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
775
776
777// If no record found
778if ($num == 0) {
779 /*$colspan = 1;
780 foreach ($arrayfields as $key => $val) {
781 if (!empty($val['checked'])) {
782 $colspan++;
783 }
784 }*/
785 $colspan = 12;
786 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
787}
788
789
790$db->free($resql);
791
792$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
793$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
794print $hookmanager->resPrint;
795
796print '</table>'."\n";
797print '</div>'."\n";
798
799print '</form>'."\n";
800
801// End of page
802llxFooter();
803$db->close();
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.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.