diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 0d987844924..adbdd83de65 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -1,6 +1,7 @@ * Copyright (C) 2011 Dimitri Mouillard + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -28,18 +29,20 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$search_id = GETPOST('search_id', 'alpha'); -$year = GETPOST('year'); +$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'); if (empty($year)) { $tmpdate = dol_getdate(dol_now()); @@ -47,7 +50,7 @@ if (empty($year)) } // Load variable for pagination -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -55,8 +58,8 @@ if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST( $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -//if (! $sortfield) $sortfield="p.date_fin"; -//if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) $sortfield="cpl.rowid"; +if (! $sortorder) $sortorder="DESC"; // 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 @@ -132,10 +147,12 @@ llxHeader('', $langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year. $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))."'"; -if ($search_id != '') $sqlwhere .= natural_search('rowid', $search_id, 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_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 $log_holiday = $object->fetchLog($sqlorder, $sqlwhere); // Load $object->logs @@ -172,9 +189,9 @@ print "
\n"; $moreforfilter = ''; $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=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; print ''."\n"; @@ -182,15 +199,15 @@ print '
'; print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +if (!empty($arrayfields['cpl.rowid']['checked'])) print ''; +if (!empty($arrayfields['cpl.date_action']['checked'])) print ''; +if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print ''; +if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print ''; +if (!empty($arrayfields['cpl.type_action']['checked'])) print ''; +if (!empty($arrayfields['cpl.fk_type']['checked'])) print ''; +if (!empty($arrayfields['cpl.prev_solde']['checked'])) print ''; +if (!empty($arrayfields['variation']['checked'])) print ''; +if (!empty($arrayfields['cpl.new_solde']['checked'])) print ''; // Action column print ''; print ''; print ''; -print_liste_field_titre('ID'); -print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'center '); -print_liste_field_titre('ActionByCP'); -print_liste_field_titre('UserUpdateCP'); -print_liste_field_titre('Description'); -print_liste_field_titre('Type'); -print_liste_field_titre('PrevSoldeCP', $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'right '); -print_liste_field_titre('Variation', $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'right '); -print_liste_field_titre('NewSoldeCP', $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'right '); +if (!empty($arrayfields['cpl.rowid']['checked'])) print_liste_field_titre($arrayfields['cpl.rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cpl.date_action']['checked'])) print_liste_field_titre($arrayfields['cpl.date_action']['label'], $_SERVER["PHP_SELF"], 'date_action', '', '', '', $sortfield, $sortorder, 'center '); +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); +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); +if (!empty($arrayfields['cpl.type_action']['checked'])) print_liste_field_titre($arrayfields['cpl.type_action']['label'], $_SERVER["PHP_SELF"], 'type_action', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cpl.fk_type']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_type']['label'], $_SERVER["PHP_SELF"], 'fk_type', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cpl.prev_solde']['checked'])) print_liste_field_titre($arrayfields['cpl.prev_solde']['label'], $_SERVER["PHP_SELF"], 'prev_solde', '', '', '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['variation']['checked'])) print_liste_field_titre($arrayfields['variation']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, '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 ''; @@ -221,21 +238,25 @@ foreach ($object->logs as $logs_CP) $user_update->fetch($logs_CP['fk_user_update']); $delta = price2num($logs_CP['new_solde'] - $logs_CP['prev_solde'], 5); - $detasign = ($delta > 0 ? '+' : '-'); + $detasign = ($delta > 0 ? '+' : ''); print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if (!empty($arrayfields['cpl.rowid']['checked'])) print ''; + if (!empty($arrayfields['cpl.date_action']['checked'])) print ''; + if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print ''; + if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print ''; + if (!empty($arrayfields['cpl.type_action']['checked'])) print ''; + if (!empty($arrayfields['cpl.fk_type']['checked'])) + { + print ''; + } + + if (!empty($arrayfields['cpl.prev_solde']['checked'])) print ''; + if (!empty($arrayfields['variation']['checked'])) print ''; + if (!empty($arrayfields['cpl.new_solde']['checked'])) print ''; print ''; print ''."\n"; }
'; $searchpicto = $form->showFilterButtons(); @@ -199,15 +216,15 @@ print '
'.$logs_CP['rowid'].''.$logs_CP['date_action'].''.$user_action->getNomUrl(-1).''.$user_update->getNomUrl(-1).''.$logs_CP['type_action'].''; - $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 ''.price2num($logs_CP['prev_solde'], 5).' '.$langs->trans('days').''.$detasign.$delta.''.price2num($logs_CP['new_solde'], 5).' '.$langs->trans('days').''.$logs_CP['rowid'].''.$logs_CP['date_action'].''.$user_action->getNomUrl(-1).''.$user_update->getNomUrl(-1).''.$logs_CP['type_action'].''; + $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 ''.price2num($logs_CP['prev_solde'], 5).' '.$langs->trans('days').''.$detasign.$delta.''.price2num($logs_CP['new_solde'], 5).' '.$langs->trans('days').'