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