diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 1051fca8ba3..d64d85813e6 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -28,46 +28,143 @@ 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') + +$search_id = GETPOST('search_id', 'alpha'); +$year=GETPOST('year'); +if (empty($year)) +{ + $tmpdate=dol_getdate(dol_now()); + $year=$tmpdate['year']; +} + +// Load variable for pagination +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); +if (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 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +//if (! $sortfield) $sortfield="p.date_fin"; +//if (! $sortorder) $sortorder="DESC"; + + // Protection if external user if ($user->societe_id > 0) accessforbidden(); // Si l'utilisateur n'a pas le droit de lire cette page if(!$user->rights->holiday->read_all) accessforbidden(); -$year=GETPOST('year'); -if (empty($year)) -{ - $tmpdate=dol_getdate(dol_now()); - $year=$tmpdate['year']; -} - // Load translation files required by the page $langs->load('users'); +// Initialize technical objects +$object = new Holiday($db); +$extrafields = new ExtraFields($db); +//$diroutputmassaction = $conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('leavemovementlist')); // Note that conf->hooks_modules contains array + +$arrayfields=array(); +$arrayofmassactions=array(); + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_id=''; + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + /*$objectclass='MyObject'; + $objectlabel='MyObject'; + $permtoread = $user->rights->mymodule->read; + $permtodelete = $user->rights->mymodule->delete; + $uploaddir = $conf->mymodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + */ +} + + /* * View */ -$cp = new Holiday($db); +$form = new Form($db); -$alltypeleaves=$cp->getTypes(1, -1); // To have labels +$alltypeleaves=$object->getTypes(1, -1); // To have labels llxHeader('', $langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year.')'); -// Recent changes are more important than old changes -$log_holiday = $cp->fetchLog('ORDER BY cpl.rowid DESC', " AND date_action BETWEEN '".$db->idate(dol_get_first_day($year, 1, 1))."' AND '".$db->idate(dol_get_last_day($year, 12, 1))."'"); // Load $cp->logs -$pagination=''; + +$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); + +$sqlorder = 'ORDER BY cpl.rowid DESC'; + +// Recent changes are more important than old changes +$log_holiday = $object->fetchLog($sqlorder, $sqlwhere); // Load $object->logs + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); +if ($search_id) $param='&search_id='.urlencode($search_id); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$pagination=''; print load_fiche_titre($langs->trans('LogCP'), $pagination, 'title_hrm.png'); print '
'.$langs->trans('LastUpdateCP').': '."\n"; -$lastUpdate = $cp->getConfCP('lastUpdate'); +$lastUpdate = $object->getConfCP('lastUpdate'); if ($lastUpdate) { $monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; $yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3]; - print ''.dol_print_date($db->jdate($cp->getConfCP('lastUpdate')), 'dayhour', 'tzuser').''; + print ''.dol_print_date($db->jdate($object->getConfCP('lastUpdate')), 'dayhour', 'tzuser').''; print '
'.$langs->trans("MonthOfLastMonthlyUpdate").': '.$yearLastUpdate.'-'.$monthLastUpdate.''."\n"; } else print $langs->trans('None'); @@ -75,12 +172,18 @@ 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=''; + print '
'; print ''."\n"; print ''; print ''; +print ''; print ''; print ''; print ''; @@ -89,6 +192,11 @@ print ''; print ''; print ''; print ''; +// Action column +print ''; print ''; print ''; @@ -99,11 +207,13 @@ print_liste_field_titre('UserUpdateCP'); print_liste_field_titre('Description'); print_liste_field_titre('Type'); print_liste_field_titre('PrevSoldeCP', $_SERVER["PHP_SELF"], '', '', '', 'align="right"'); +print_liste_field_titre('Variation', $_SERVER["PHP_SELF"], '', '', '', 'align="right"'); print_liste_field_titre('NewSoldeCP', $_SERVER["PHP_SELF"], '', '', '', 'align="right"'); +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ')."\n"; print ''; -foreach($cp->logs as $logs_CP) +foreach($object->logs as $logs_CP) { $user_action = new User($db); $user_action->fetch($logs_CP['fk_user_action']); @@ -111,6 +221,9 @@ foreach($cp->logs as $logs_CP) $user_update = new User($db); $user_update->fetch($logs_CP['fk_user_update']); + $delta = price2num($logs_CP['new_solde'] - $logs_CP['prev_solde'], 5); + $detasign = ($delta > 0 ? '+' : '-'); + print ''; print ''; print ''; @@ -122,14 +235,16 @@ foreach($cp->logs as $logs_CP) print $label?$label:$logs_CP['fk_type']; print ''; print ''; + print ''; print ''; + print ''; print ''."\n"; } if ($log_holiday == '2') { - print ''; - print ''; + print ''; + print ''; print ''; } @@ -137,6 +252,8 @@ print ''."\n"; print '
'; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
'.$logs_CP['rowid'].''.$logs_CP['date_action'].''.price2num($logs_CP['prev_solde'], 5).' '.$langs->trans('days').''.$detasign.$delta.''.price2num($logs_CP['new_solde'], 5).' '.$langs->trans('days').'
'.$langs->trans('NoRecordFound').'
'.$langs->trans('NoRecordFound').'
'."\n"; print '
'; +print '
'; + // End of page llxFooter(); $db->close();