mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +01:00
Add labeled week & month filters for list view
This commit is contained in:
parent
b034eeac92
commit
422ecd25a9
@ -41,6 +41,8 @@ class calendar_uilist extends calendar_ui
|
|||||||
var $date_filters = array(
|
var $date_filters = array(
|
||||||
'after' => 'After current date',
|
'after' => 'After current date',
|
||||||
'before' => 'Before current date',
|
'before' => 'Before current date',
|
||||||
|
'week' => 'Week',
|
||||||
|
'month' => 'Month',
|
||||||
'all' => 'All events',
|
'all' => 'All events',
|
||||||
'custom' => 'Selected range',
|
'custom' => 'Selected range',
|
||||||
);
|
);
|
||||||
@ -252,10 +254,6 @@ class calendar_uilist extends calendar_ui
|
|||||||
function get_rows(&$params,&$rows,&$readonlys)
|
function get_rows(&$params,&$rows,&$readonlys)
|
||||||
{
|
{
|
||||||
//echo "uilist::get_rows() params="; _debug_array($params);
|
//echo "uilist::get_rows() params="; _debug_array($params);
|
||||||
if (isset($_GET['listview_days']) && is_numeric($_GET['listview_days']))
|
|
||||||
{
|
|
||||||
$params['filter'] = 'fixed';
|
|
||||||
}
|
|
||||||
if ($params['filter'] == 'custom')
|
if ($params['filter'] == 'custom')
|
||||||
{
|
{
|
||||||
if (!$params['startdate'] && !$params['enddate'])
|
if (!$params['startdate'] && !$params['enddate'])
|
||||||
@ -317,43 +315,41 @@ class calendar_uilist extends calendar_ui
|
|||||||
case 'all':
|
case 'all':
|
||||||
break;
|
break;
|
||||||
case 'before':
|
case 'before':
|
||||||
$search_params['end'] = $this->date;
|
$search_params['end'] = $params['date'] ? egw_time::to($params['date'],'ts') : $this->date;
|
||||||
$label = lang('Before %1',$this->bo->long_date($this->date));
|
$label = lang('Before %1',$this->bo->long_date($search_params['end']));
|
||||||
break;
|
break;
|
||||||
case 'custom':
|
case 'custom':
|
||||||
$this->first = $search_params['start'] = egw_time::to($params['startdate'],'ts');
|
$this->first = $search_params['start'] = egw_time::to($params['startdate'],'ts');
|
||||||
$this->last = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate']))-1;
|
$this->last = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate']))-1;
|
||||||
$label = $this->bo->long_date($this->first,$this->last);
|
$label = $this->bo->long_date($this->first,$this->last);
|
||||||
break;
|
break;
|
||||||
case 'fixed':
|
case 'week':
|
||||||
if ($this->listview_days == 5 || $this->listview_days == 7) // weekview
|
$start = $this->bo->date2array($params['date'] ? $params['date'] : $this->date);
|
||||||
{
|
$this->first = $this->datetime->get_weekday_start($start['year'],$start['month'],$start['day']);
|
||||||
$this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
|
$this->last = $this->bo->date2array($this->first);
|
||||||
$this->last = $this->bo->date2array($this->first);
|
$this->last['day'] += ($params['weekend'] == 'true' ? 7 : 5) - 1;
|
||||||
$this->last['day'] += (int) $this->listview_days - 1;
|
$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
|
||||||
$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
|
unset($this->last['raw']);
|
||||||
unset($this->last['raw']);
|
$this->last = $this->bo->date2ts($this->last);
|
||||||
$this->last = $this->bo->date2ts($this->last);
|
$this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W',$this->first).': '.$this->bo->long_date($this->first,$this->last);
|
||||||
$this->date_filters['fixed'] = $label = lang('Week').' '.adodb_date('W',$this->first).': '.$this->bo->long_date($this->first,$this->last);
|
$params['startdate'] = $search_params['start'] = $this->first;
|
||||||
$params['startdate'] = $search_params['start'] = $this->first;
|
$params['enddate'] = $search_params['end'] = $this->last;
|
||||||
$params['enddate'] = $search_params['end'] = $this->last;
|
break;
|
||||||
break;
|
|
||||||
}
|
case 'month':
|
||||||
elseif ((string)$this->listview_days === '0') // monthview
|
$this->first = $this->bo->date2array($params['date'] ? $params['date'] : $this->date);
|
||||||
{
|
$this->first['day'] = 1;
|
||||||
$this->first = $this->bo->date2array($this->date);
|
unset($this->first['raw']);
|
||||||
$this->first['day'] = 1;
|
$this->last = $this->first;
|
||||||
unset($this->first['raw']);
|
$this->last['month'] += 1;
|
||||||
$this->last = $this->first;
|
$this->date_filters['month'] = $label = lang(adodb_date('F',$this->bo->date2ts($params['date']))).' '.$this->first['year'];
|
||||||
$this->last['month'] += 1;
|
$this->first = $this->bo->date2ts($this->first);
|
||||||
$this->first = $this->bo->date2ts($this->first);
|
$this->last = $this->bo->date2ts($this->last);
|
||||||
$this->last = $this->bo->date2ts($this->last);
|
$this->last--;
|
||||||
$this->last--;
|
$params['startdate'] = $search_params['start'] = $this->first;
|
||||||
$this->date_filters['fixed'] = $label = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year;
|
$params['enddate'] = $search_params['end'] = $this->last;
|
||||||
$params['startdate'] = $search_params['start'] = $this->first;
|
break;
|
||||||
$params['enddate'] = $search_params['end'] = $this->last;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// fall through to after given date
|
// fall through to after given date
|
||||||
case 'after':
|
case 'after':
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user