From e230d72cea2e185e62fbefaa5cfcd4f80169c96b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 18 May 2015 19:41:23 +0200 Subject: [PATCH] Increase default date range to current month instead of current day --- htdocs/admin/tools/listevents.php | 21 ++++++++++++++------- htdocs/core/lib/functions.lib.php | 17 ++--------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index e894bd94f5853..72280ec722034 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -1,7 +1,7 @@ - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2015 Bahfir Abbes +/* Copyright (C) 2004-2015 Laurent Destailleur + * 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 @@ -25,6 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; if (! $user->admin) accessforbidden(); @@ -64,7 +65,10 @@ $date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); // checks:if date_start>date_end then date_end=date_start + 24 hours -if($date_start>$date_end) $date_end=$date_start+86400; +if ($date_start > $date_end) $date_end=$date_start+86400; + +$now = dol_now(); +$nowarray = dol_getdate($now); $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"]; @@ -74,10 +78,13 @@ $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 +if (empty($date_start)) // We define date_start and date_end +{ + $date_start=dol_get_first_day($nowarray['year'],$nowarray['mon'],false); +} +if (empty($date_end)) { - $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())); + $date_end=dol_mktime(23,59,59,$nowarray['mon'],$nowarray['mday'],$nowarray['year']); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f067dcaf4171b..194a6b3c3bb3f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1127,19 +1127,6 @@ function dol_getdate($timestamp,$fast=false) else { $arrayinfo=getdate($timestamp); - - /*$startday=isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1; - if($startday==1) - { - if ($arrayinfo["wday"]==0) - { - $arrayinfo["wday"]=6; - } - else - { - $arrayinfo["wday"]=$arrayinfo["wday"]-1; - } - }*/ } return $arrayinfo; @@ -2886,14 +2873,14 @@ function print_fleche_navigation($page,$file,$options='',$nextpage=0,$betweenarr print '