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