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