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