From 5191bffb1c4cafd19aeeef934bf48c37bf1a4bf8 Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Wed, 13 May 2015 18:56:13 +0100 Subject: [PATCH 1/3] improve events list view provide a finer grained view for this list and fix bug related to sorting control which wipes off other parameters --- htdocs/admin/tools/listevents.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 373b46c6062..fff66571517 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015 Bahfir Abbes * * 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 @@ -59,6 +60,22 @@ $search_user = GETPOST("search_user"); $search_desc = GETPOST("search_desc"); $search_ua = GETPOST("search_ua"); +$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); +$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); +$params = "&search_code=$search_code&search_ip=$search_ip&search_user=$search_user&search_desc=$search_desc&search_ua=$search_ua"; +$params.= "&date_startmonth=".$_REQUEST["date_startmonth"]; +$params.= "&date_startday=".$_REQUEST["date_startday"]; +$params.= "&date_startyear=".$_REQUEST["date_startyear"]; +$params.= "&date_endmonth=".$_REQUEST["date_endmonth"]; +$params.= "&date_endday=".$_REQUEST["date_endday"]; +$params.= "&date_endyear=".$_REQUEST["date_endyear"]; + +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $date_start=mktime(0,0,0,strftime("%m",time()),strftime("%d",time()),strftime("%Y",time())); + $date_end=mktime(23,59,59,strftime("%m",time()),strftime("%d",time()),strftime("%Y",time())); +} + /* * Actions @@ -124,6 +141,7 @@ $sql.= " u.login"; $sql.= " FROM ".MAIN_DB_PREFIX."events as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user"; $sql.= " WHERE e.entity IN (".getEntity('actioncomm', 1).")"; +$sql.= " AND e.dateevent >= '".$db->idate($date_start)."' AND e.dateevent <= '".$db->idate($date_end)."'"; if ($search_code) { $usefilter++; $sql.=" AND e.type LIKE '%".$db->escape($search_code)."%'"; } if ($search_ip) { $usefilter++; $sql.=" AND e.ip LIKE '%".$db->escape($search_ip)."%'"; } if ($search_user) { $usefilter++; $sql.=" AND u.login LIKE '%".$db->escape($search_user)."%'"; } @@ -145,7 +163,8 @@ if ($result) if ($search_desc) $param.='&search_desc='.$search_desc; if ($search_ua) $param.='&search_ua='.$search_ua; - print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, 0, 'setup'); + $langs->load('withdrawals'); + print_barre_liste($langs->trans("ListOfSecurityEvents").' : '.$num.' '.strtolower($langs->trans("Lines")), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, 0, 'setup'); if ($action == 'purge') { @@ -168,7 +187,7 @@ if ($result) print '
'; print ''; - print ' '; + print ''.$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).$form->select_date($date_end,'date_end',0,0,0,'',1,0,1).''; print ''; print ''; From ffc5284a7875041d97d1618d2f06eeda0ebdbc6a Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Thu, 14 May 2015 20:17:52 +0100 Subject: [PATCH 2/3] Update listevents.php --- htdocs/admin/tools/listevents.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index fff66571517..33fba65cecc 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -62,6 +62,11 @@ $search_ua = GETPOST("search_ua"); $date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); $date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); + +// checks: if date_start<0 then date_start=01/01/1970 and if date_start>date_end then date_end=date_start + 24 hours +if($date_start<0) $date_start=0; +if($date_start>$date_end) $date_end=$date_start+86400; + $params = "&search_code=$search_code&search_ip=$search_ip&search_user=$search_user&search_desc=$search_desc&search_ua=$search_ua"; $params.= "&date_startmonth=".$_REQUEST["date_startmonth"]; $params.= "&date_startday=".$_REQUEST["date_startday"]; @@ -72,8 +77,8 @@ $params.= "&date_endyear=".$_REQUEST["date_endyear"]; if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $date_start=mktime(0,0,0,strftime("%m",time()),strftime("%d",time()),strftime("%Y",time())); - $date_end=mktime(23,59,59,strftime("%m",time()),strftime("%d",time()),strftime("%Y",time())); + $date_start=dol_mktime(0,0,0,strftime("%m",time()),strftime("%d",time()),strftime("%Y",time())); + $date_end=dol_mktime(23,59,59,strftime("%m",time()),strftime("%d",time()),strftime("%Y",time())); } From 1ba2240553e1403cb7204fafd1ff30c775a5e129 Mon Sep 17 00:00:00 2001 From: Bahfir Abbes Date: Sun, 17 May 2015 16:13:50 +0100 Subject: [PATCH 3/3] fix add to listevents.php use of dol_mktime + check dates order --- htdocs/admin/tools/listevents.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 33fba65cecc..e894bd94f58 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -63,8 +63,7 @@ $search_ua = GETPOST("search_ua"); $date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); $date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); -// checks: if date_start<0 then date_start=01/01/1970 and if date_start>date_end then date_end=date_start + 24 hours -if($date_start<0) $date_start=0; +// checks:if date_start>date_end then date_end=date_start + 24 hours if($date_start>$date_end) $date_end=$date_start+86400; $params = "&search_code=$search_code&search_ip=$search_ip&search_user=$search_user&search_desc=$search_desc&search_ua=$search_ua";