Add search, sort, select for leave log view
This commit is contained in:
parent
33a6b37e81
commit
22f708b95a
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
|
* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
|
||||||
|
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -39,6 +40,8 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
|||||||
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||||
|
|
||||||
$search_id = GETPOST('search_id', 'alpha');
|
$search_id = GETPOST('search_id', 'alpha');
|
||||||
|
$search_prev_solde = GETPOST('search_prev_solde', 'alpha');
|
||||||
|
$search_new_solde = GETPOST('search_new_solde', 'alpha');
|
||||||
$year=GETPOST('year');
|
$year=GETPOST('year');
|
||||||
if (empty($year))
|
if (empty($year))
|
||||||
{
|
{
|
||||||
@ -55,8 +58,8 @@ if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST(
|
|||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
//if (! $sortfield) $sortfield="p.date_fin";
|
if (! $sortfield) $sortfield="cpl.rowid";
|
||||||
//if (! $sortorder) $sortorder="DESC";
|
if (! $sortorder) $sortorder="DESC";
|
||||||
|
|
||||||
|
|
||||||
// Protection if external user
|
// Protection if external user
|
||||||
@ -118,6 +121,18 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Definition of fields for lists
|
||||||
|
$arrayfields = array(
|
||||||
|
'cpl.rowid'=>array('label'=>$langs->trans("ID"), 'checked'=>1),
|
||||||
|
'cpl.date_action'=>array('label'=>$langs->trans("Date"), 'checked'=>1),
|
||||||
|
'cpl.fk_user_action'=>array('label'=>$langs->trans("ActionByCP"), 'checked'=>1),
|
||||||
|
'cpl.fk_user_update'=>array('label'=>$langs->trans("UserUpdateCP"), 'checked'=>1),
|
||||||
|
'cpl.type_action'=>array('label'=>$langs->trans("Description"), 'checked'=>1),
|
||||||
|
'cpl.fk_type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
|
||||||
|
'cpl.prev_solde'=>array('label'=>$langs->trans("PrevSoldeCP"), 'checked'=>1),
|
||||||
|
'variation'=>array('label'=>$langs->trans("Variation"), 'checked'=>1),
|
||||||
|
'cpl.new_solde'=>array('label'=>$langs->trans("NewSoldeCP"), 'checked'=>1),
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
@ -134,8 +149,10 @@ llxHeader('', $langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year.
|
|||||||
$sqlwhere = '';
|
$sqlwhere = '';
|
||||||
$sqlwhere.= " AND date_action BETWEEN '".$db->idate(dol_get_first_day($year, 1, 1))."' AND '".$db->idate(dol_get_last_day($year, 12, 1))."'";
|
$sqlwhere.= " AND date_action BETWEEN '".$db->idate(dol_get_first_day($year, 1, 1))."' AND '".$db->idate(dol_get_last_day($year, 12, 1))."'";
|
||||||
if ($search_id != '') $sqlwhere.= natural_search('rowid', $search_id, 1);
|
if ($search_id != '') $sqlwhere.= natural_search('rowid', $search_id, 1);
|
||||||
|
if ($search_prev_solde != '') $sqlwhere.= natural_search('prev_solde', $search_prev_solde, 1);
|
||||||
|
if ($search_new_solde != '') $sqlwhere.= natural_search('new_solde', $search_new_solde, 1);
|
||||||
|
|
||||||
$sqlorder = 'ORDER BY cpl.rowid DESC';
|
$sqlorder = $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
// Recent changes are more important than old changes
|
// Recent changes are more important than old changes
|
||||||
$log_holiday = $object->fetchLog($sqlorder, $sqlwhere); // Load $object->logs
|
$log_holiday = $object->fetchLog($sqlorder, $sqlwhere); // Load $object->logs
|
||||||
@ -172,9 +189,9 @@ print "</div><br>\n";
|
|||||||
$moreforfilter = '';
|
$moreforfilter = '';
|
||||||
|
|
||||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||||
//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
|
||||||
//$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
|
|
||||||
$selectedfields = '';
|
$selectedfields = '';
|
||||||
|
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||||
|
$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
|
||||||
|
|
||||||
print '<div class="div-table-responsive">';
|
print '<div class="div-table-responsive">';
|
||||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n";
|
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n";
|
||||||
@ -182,15 +199,15 @@ print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" :
|
|||||||
print '<tbody>';
|
print '<tbody>';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
|
if (!empty($arrayfields['cpl.rowid']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
|
||||||
print '<td class="liste_titre"></td>';
|
if (!empty($arrayfields['cpl.date_action']['checked'])) print '<td class="liste_titre"></td>';
|
||||||
print '<td class="liste_titre"></td>';
|
if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print '<td class="liste_titre"></td>';
|
||||||
print '<td class="liste_titre"></td>';
|
if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print '<td class="liste_titre"></td>';
|
||||||
print '<td class="liste_titre"></td>';
|
if (!empty($arrayfields['cpl.type_action']['checked'])) print '<td class="liste_titre"></td>';
|
||||||
print '<td class="liste_titre"></td>';
|
if (!empty($arrayfields['cpl.fk_type']['checked'])) print '<td class="liste_titre"></td>';
|
||||||
print '<td class="liste_titre"></td>';
|
if (!empty($arrayfields['cpl.prev_solde']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_prev_solde" value="'.$search_prev_solde.'"></td>';
|
||||||
print '<td class="liste_titre"></td>';
|
if (!empty($arrayfields['variation']['checked'])) print '<td class="liste_titre"></td>';
|
||||||
print '<td class="liste_titre"></td>';
|
if (!empty($arrayfields['cpl.new_solde']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_new_solde" value="'.$search_new_solde.'"></td>';
|
||||||
// Action column
|
// Action column
|
||||||
print '<td class="liste_titre maxwidthsearch">';
|
print '<td class="liste_titre maxwidthsearch">';
|
||||||
$searchpicto = $form->showFilterButtons();
|
$searchpicto = $form->showFilterButtons();
|
||||||
@ -199,15 +216,15 @@ print '</td>';
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print_liste_field_titre('ID');
|
if (!empty($arrayfields['cpl.rowid']['checked'])) print_liste_field_titre($arrayfields['cpl.rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', '', '', $sortfield, $sortorder);
|
||||||
print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'center ');
|
if (!empty($arrayfields['cpl.date_action']['checked'])) print_liste_field_titre($arrayfields['cpl.date_action']['label'], $_SERVER["PHP_SELF"], 'date_action', '', '', '', $sortfield, $sortorder, 'center ');
|
||||||
print_liste_field_titre('ActionByCP');
|
if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_user_action']['label'], $_SERVER["PHP_SELF"], 'fk_user_action', '', '', '', $sortfield, $sortorder);
|
||||||
print_liste_field_titre('UserUpdateCP');
|
if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_user_update']['label'], $_SERVER["PHP_SELF"], 'fk_user_update', '', '', '', $sortfield, $sortorder);
|
||||||
print_liste_field_titre('Description');
|
if (!empty($arrayfields['cpl.type_action']['checked'])) print_liste_field_titre($arrayfields['cpl.type_action']['label'], $_SERVER["PHP_SELF"], 'type_action', '', '', '', $sortfield, $sortorder);
|
||||||
print_liste_field_titre('Type');
|
if (!empty($arrayfields['cpl.fk_type']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_type']['label'], $_SERVER["PHP_SELF"], 'fk_type', '', '', '', $sortfield, $sortorder);
|
||||||
print_liste_field_titre('PrevSoldeCP', $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'right ');
|
if (!empty($arrayfields['cpl.prev_solde']['checked'])) print_liste_field_titre($arrayfields['cpl.prev_solde']['label'], $_SERVER["PHP_SELF"], 'prev_solde', '', '', '', $sortfield, $sortorder, 'right ');
|
||||||
print_liste_field_titre('Variation', $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'right ');
|
if (!empty($arrayfields['variation']['checked'])) print_liste_field_titre($arrayfields['variation']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'right ');
|
||||||
print_liste_field_titre('NewSoldeCP', $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'right ');
|
if (!empty($arrayfields['cpl.new_solde']['checked'])) print_liste_field_titre($arrayfields['cpl.new_solde']['label'], $_SERVER["PHP_SELF"], 'new_solde', '', '', '', $sortfield, $sortorder, 'right ');
|
||||||
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
|
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
@ -221,21 +238,25 @@ foreach ($object->logs as $logs_CP)
|
|||||||
$user_update->fetch($logs_CP['fk_user_update']);
|
$user_update->fetch($logs_CP['fk_user_update']);
|
||||||
|
|
||||||
$delta = price2num($logs_CP['new_solde'] - $logs_CP['prev_solde'], 5);
|
$delta = price2num($logs_CP['new_solde'] - $logs_CP['prev_solde'], 5);
|
||||||
$detasign = ($delta > 0 ? '+' : '-');
|
$detasign = ($delta > 0 ? '+' : '');
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td>'.$logs_CP['rowid'].'</td>';
|
if (!empty($arrayfields['cpl.rowid']['checked'])) print '<td>'.$logs_CP['rowid'].'</td>';
|
||||||
print '<td style="text-align: center;">'.$logs_CP['date_action'].'</td>';
|
if (!empty($arrayfields['cpl.date_action']['checked'])) print '<td style="text-align: center;">'.$logs_CP['date_action'].'</td>';
|
||||||
print '<td>'.$user_action->getNomUrl(-1).'</td>';
|
if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print '<td>'.$user_action->getNomUrl(-1).'</td>';
|
||||||
print '<td>'.$user_update->getNomUrl(-1).'</td>';
|
if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print '<td>'.$user_update->getNomUrl(-1).'</td>';
|
||||||
print '<td>'.$logs_CP['type_action'].'</td>';
|
if (!empty($arrayfields['cpl.type_action']['checked'])) print '<td>'.$logs_CP['type_action'].'</td>';
|
||||||
|
if (!empty($arrayfields['cpl.fk_type']['checked']))
|
||||||
|
{
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$label = (($alltypeleaves[$logs_CP['fk_type']]['code'] && $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code']) != $alltypeleaves[$logs_CP['fk_type']]['code']) ? $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code']) : $alltypeleaves[$logs_CP['fk_type']]['label']);
|
$label = (($alltypeleaves[$logs_CP['fk_type']]['code'] && $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code']) != $alltypeleaves[$logs_CP['fk_type']]['code']) ? $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code']) : $alltypeleaves[$logs_CP['fk_type']]['label']);
|
||||||
print $label ? $label : $logs_CP['fk_type'];
|
print $label ? $label : $logs_CP['fk_type'];
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td style="text-align: right;">'.price2num($logs_CP['prev_solde'], 5).' '.$langs->trans('days').'</td>';
|
}
|
||||||
print '<td style="text-align: right;">'.$detasign.$delta.'</td>';
|
|
||||||
print '<td style="text-align: right;">'.price2num($logs_CP['new_solde'], 5).' '.$langs->trans('days').'</td>';
|
if (!empty($arrayfields['cpl.prev_solde']['checked'])) print '<td style="text-align: right;">'.price2num($logs_CP['prev_solde'], 5).' '.$langs->trans('days').'</td>';
|
||||||
|
if (!empty($arrayfields['variation']['checked'])) print '<td style="text-align: right;">'.$detasign.$delta.'</td>';
|
||||||
|
if (!empty($arrayfields['cpl.new_solde']['checked'])) print '<td style="text-align: right;">'.price2num($logs_CP['new_solde'], 5).' '.$langs->trans('days').'</td>';
|
||||||
print '<td></td>';
|
print '<td></td>';
|
||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user