forked from extern/egroupware
usebility improvment:
- filter by custom date-range - app-header with user and date-range
This commit is contained in:
parent
fc5c2baa45
commit
c706a3f043
@ -162,54 +162,67 @@ class botimesheet extends so_sql
|
||||
return $data && !!($rights & $required);
|
||||
}
|
||||
|
||||
function date_filter($name)
|
||||
function date_filter($name,$start=0,$end=0)
|
||||
{
|
||||
if (!isset($this->date_filters[$name]))
|
||||
if ($name == 'custom' && $start)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$year = (int) date('Y',$this->today);
|
||||
$month = (int) date('m',$this->today);
|
||||
$day = (int) date('d',$this->today);
|
||||
|
||||
list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $this->date_filters[$name];
|
||||
|
||||
if ($syear || $eyear)
|
||||
{
|
||||
$start = mktime(0,0,0,1,1,$syear+$year);
|
||||
$end = mktime(0,0,0,1,1,$eyear+$year);
|
||||
}
|
||||
elseif ($smonth || $emonth)
|
||||
{
|
||||
$start = mktime(0,0,0,$smonth+$month,1,$year);
|
||||
$end = mktime(0,0,0,$emonth+$month,1,$year);
|
||||
}
|
||||
elseif ($sday || $eday)
|
||||
{
|
||||
$start = mktime(0,0,0,$month,$sday+$day,$year);
|
||||
$end = mktime(0,0,0,$month,$eday+$day,$year);
|
||||
}
|
||||
elseif ($sweek || $eweek)
|
||||
{
|
||||
$wday = (int) date('w',$this->today); // 0=sun, ..., 6=sat
|
||||
switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
|
||||
if ($end)
|
||||
{
|
||||
case 'Sunday':
|
||||
$weekstart = $this->today - $wday * 24*60*60;
|
||||
break;
|
||||
case 'Saturday':
|
||||
$weekstart = $this->today - (6-$wday) * 24*60*60;
|
||||
break;
|
||||
case 'Moday':
|
||||
default:
|
||||
$weekstart = $this->today - ($wday ? $wday-1 : 6) * 24*60*60;
|
||||
break;
|
||||
$end += 24*60*60;
|
||||
}
|
||||
else
|
||||
{
|
||||
$end = $start + 8*24*60*60;
|
||||
}
|
||||
$start = $weekstart + $sweek*7*24*60*60;
|
||||
$end = $weekstart + $eweek*7*24*60*60;
|
||||
// todo
|
||||
}
|
||||
//echo "<p align='right'>date_filter($name) today=".date('l, Y-m-d H:i',$this->today)." ==> ".date('l, Y-m-d H:i:s',$start)." <= date < ".date('l, Y-m-d H:i:s',$end)."</p>\n";
|
||||
else
|
||||
{
|
||||
if (!isset($this->date_filters[$name]))
|
||||
{
|
||||
return '1=1';
|
||||
}
|
||||
$year = (int) date('Y',$this->today);
|
||||
$month = (int) date('m',$this->today);
|
||||
$day = (int) date('d',$this->today);
|
||||
|
||||
list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $this->date_filters[$name];
|
||||
|
||||
if ($syear || $eyear)
|
||||
{
|
||||
$start = mktime(0,0,0,1,1,$syear+$year);
|
||||
$end = mktime(0,0,0,1,1,$eyear+$year);
|
||||
}
|
||||
elseif ($smonth || $emonth)
|
||||
{
|
||||
$start = mktime(0,0,0,$smonth+$month,1,$year);
|
||||
$end = mktime(0,0,0,$emonth+$month,1,$year);
|
||||
}
|
||||
elseif ($sday || $eday)
|
||||
{
|
||||
$start = mktime(0,0,0,$month,$sday+$day,$year);
|
||||
$end = mktime(0,0,0,$month,$eday+$day,$year);
|
||||
}
|
||||
elseif ($sweek || $eweek)
|
||||
{
|
||||
$wday = (int) date('w',$this->today); // 0=sun, ..., 6=sat
|
||||
switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
|
||||
{
|
||||
case 'Sunday':
|
||||
$weekstart = $this->today - $wday * 24*60*60;
|
||||
break;
|
||||
case 'Saturday':
|
||||
$weekstart = $this->today - (6-$wday) * 24*60*60;
|
||||
break;
|
||||
case 'Moday':
|
||||
default:
|
||||
$weekstart = $this->today - ($wday ? $wday-1 : 6) * 24*60*60;
|
||||
break;
|
||||
}
|
||||
$start = $weekstart + $sweek*7*24*60*60;
|
||||
$end = $weekstart + $eweek*7*24*60*60;
|
||||
}
|
||||
}
|
||||
//echo "<p align='right'>date_filter($name,$start,$end) today=".date('l, Y-m-d H:i',$this->today)." ==> ".date('l, Y-m-d H:i:s',$start)." <= date < ".date('l, Y-m-d H:i:s',$end)."</p>\n";
|
||||
// convert start + end from user to servertime
|
||||
$start -= $this->tz_offset_s;
|
||||
$end -= $this->tz_offset_s;
|
||||
|
@ -270,12 +270,39 @@ class uitimesheet extends botimesheet
|
||||
$cats = $GLOBALS['egw']->categories->return_all_children((int)$query['cat_id']);
|
||||
$query['col_filter']['cat_id'] = count($cats) > 1 ? $cats : $query['cat_id'];
|
||||
}
|
||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('timesheet');
|
||||
if ($query['col_filter']['ts_owner'])
|
||||
{
|
||||
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$GLOBALS['egw']->common->grab_owner_name($query['col_filter']['ts_owner']);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($query['col_filter']['ts_owner']);
|
||||
}
|
||||
if ($query['filter'])
|
||||
{
|
||||
$query['col_filter'][0] = $this->date_filter($query['filter']);
|
||||
}
|
||||
if (!$query['col_filter']['ts_owner']) unset($query['col_filter']['ts_owner']);
|
||||
$query['col_filter'][0] = $this->date_filter($query['filter'],$query['startdate'],$query['enddate']);
|
||||
|
||||
if ($query['filter'] == 'custom') // show the custome dates
|
||||
{
|
||||
if (!is_object($GLOBALS['egw']->js))
|
||||
{
|
||||
$GLOBALS['egw']->js = CreateObject('phpgwapi.javascript');
|
||||
}
|
||||
$GLOBALS['egw']->js->set_onload("set_style_by_class('*','custom_hide','visibility','visible');");
|
||||
|
||||
if ($query['startdate'])
|
||||
{
|
||||
$df = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
|
||||
$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . $GLOBALS['egw']->common->show_date($query['startdate']+12*60*60,$df,false).
|
||||
' - '.$GLOBALS['egw']->common->show_date(($query['enddate'] ? $query['enddate'] : $query['startdate']+7*24*60*60)+12*60*60,$df,false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang($query['filter']);
|
||||
}
|
||||
}
|
||||
$total = parent::get_rows($query,$rows,$readonlys);
|
||||
|
||||
unset($query['col_filter'][0]);
|
||||
@ -355,12 +382,16 @@ class uitimesheet extends botimesheet
|
||||
{
|
||||
$date_filters[$name] = $name;
|
||||
}
|
||||
$date_filters['custom'] = 'custom';
|
||||
|
||||
$content['nm'] = array(
|
||||
'get_rows' => TIMESHEET_APP.'.uitimesheet.get_rows',
|
||||
'options-filter' => $date_filters,
|
||||
'options-filter2' => array('No details','Details'),
|
||||
'order' => 'ts_start',// IO name of the column to sort after (optional for the sortheaders)
|
||||
'sort' => 'DESC',// IO direction of the sort: 'ASC' or 'DESC'
|
||||
'header_right' => 'timesheet.index.dates',
|
||||
'filter_onchange' => "set_style_by_class('*','custom_hide','visibility',this.value == 'custom' ? 'visible' : 'hidden'); if (this.value != 'custom') this.form.submit();",
|
||||
);
|
||||
}
|
||||
$read_grants = $this->grant_list(EGW_ACL_READ);
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// eTemplates for Application 'timesheet', generated by soetemplate::dump4setup() 2006-03-21 14:49
|
||||
// eTemplates for Application 'timesheet', generated by soetemplate::dump4setup() 2006-03-21 23:16
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
@ -21,5 +21,9 @@ $templ_data[] = array('name' => 'timesheet.edit.notes','template' => '','lang' =
|
||||
|
||||
$templ_data[] = array('name' => 'timesheet.index','template' => '','lang' => '','group' => '0','version' => '0.1.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:1:{s:2:"h1";s:6:",!@msg";}i:1;a:1:{s:1:"A";a:5:{s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:5:"align";s:6:"center";}}i:2;a:1:{s:1:"A";a:3:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:20:"timesheet.index.rows";}}i:3;a:1:{s:1:"A";a:4:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:4:"name";s:3:"add";s:7:"onclick";s:163:"window.open(egw::link(\'/index.php\',\'menuaction=timesheet.uitimesheet.edit\'),\'_blank\',\'dependent=yes,width=600,height=400,scrollbars=yes,status=yes\'); return false;";}}}s:4:"rows";i:3;s:4:"cols";i:1;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '','modified' => '1134799202',);
|
||||
|
||||
$templ_data[] = array('name' => 'timesheet.index','template' => '','lang' => '','group' => '0','version' => '1.2.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:5:{i:0;a:2:{s:2:"h1";s:6:",!@msg";s:2:"h2";s:2:",1";}i:1;a:1:{s:1:"A";a:5:{s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";s:7:"no_lang";s:1:"1";s:4:"name";s:3:"msg";s:5:"align";s:6:"center";}}i:2;a:1:{s:1:"A";a:3:{s:4:"type";s:8:"template";s:5:"align";s:5:"right";s:4:"name";s:5:"dates";}}i:3;a:1:{s:1:"A";a:3:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:20:"timesheet.index.rows";}}i:4;a:1:{s:1:"A";a:4:{s:4:"type";s:6:"button";s:5:"label";s:3:"Add";s:4:"name";s:3:"add";s:7:"onclick";s:163:"window.open(egw::link(\'/index.php\',\'menuaction=timesheet.uitimesheet.edit\'),\'_blank\',\'dependent=yes,width=600,height=400,scrollbars=yes,status=yes\'); return false;";}}}s:4:"rows";i:4;s:4:"cols";i:1;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '','modified' => '1142977673',);
|
||||
|
||||
$templ_data[] = array('name' => 'timesheet.index.dates','template' => '','lang' => '','group' => '0','version' => '1.2.001','data' => 'a:1:{i:0;a:10:{s:4:"type";s:4:"hbox";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:1:"4";i:1;a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Start";}i:2;a:3:{s:4:"type";s:4:"date";s:4:"name";s:9:"startdate";s:6:"needed";s:1:"1";}i:3;a:2:{s:4:"type";s:5:"label";s:5:"label";s:3:"End";}i:4;a:3:{s:4:"type";s:4:"date";s:4:"name";s:7:"enddate";s:4:"help";s:30:"Leave it empty for a full week";}s:4:"span";s:12:",custom_hide";}}','size' => '','style' => '.custom_hide { visibility: hidden; }','modified' => '1142973260',);
|
||||
|
||||
$templ_data[] = array('name' => 'timesheet.index.rows','template' => '','lang' => '','group' => '0','version' => '0.1.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:5:{s:2:"c1";s:2:"th";s:2:"c2";s:3:"row";s:1:"A";s:3:"15%";s:1:"G";s:14:",@no_owner_col";s:1:"B";s:3:"50%";}i:1;a:8:{s:1:"A";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"Date";s:4:"name";s:8:"ts_start";}s:1:"B";a:5:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";s:7:"no_lang";s:1:"1";i:1;a:4:{s:4:"type";s:22:"nextmatch-filterheader";s:4:"size";s:7:"Project";s:4:"name";s:10:"ts_project";s:7:"no_lang";s:1:"1";}i:2;a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:5:"Title";s:4:"name";s:8:"ts_title";}}s:1:"C";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Duration";s:4:"name";s:11:"ts_duration";}i:2;a:4:{s:4:"type";s:13:"date-duration";s:4:"name";s:8:"duration";s:4:"size";s:6:",h,,,1";s:8:"readonly";s:1:"1";}}s:1:"D";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:8:"Quantity";s:4:"name";s:11:"ts_quantity";}s:1:"E";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:5:"Price";s:4:"name";s:12:"ts_unitprice";}s:1:"F";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:5:"Total";s:4:"name";s:8:"ts_total";}i:2;a:3:{s:4:"type";s:5:"float";s:4:"name";s:5:"price";s:8:"readonly";s:1:"1";}}s:1:"G";a:4:{s:4:"type";s:22:"nextmatch-filterheader";s:4:"name";s:8:"ts_owner";s:4:"size";s:4:"User";s:7:"no_lang";s:1:"1";}s:1:"H";a:2:{s:4:"type";s:5:"label";s:5:"label";s:7:"Actions";}}i:2;a:8:{s:1:"A";a:4:{s:4:"type";s:9:"date-time";s:4:"name";s:16:"${row}[ts_start]";s:8:"readonly";s:1:"1";s:4:"size";s:2:",8";}s:1:"B";a:5:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:4:"link";s:4:"name";s:15:"${row}[ts_link]";s:7:"no_lang";s:1:"1";}i:2;a:4:{s:4:"type";s:5:"label";s:4:"name";s:16:"${row}[ts_title]";s:7:"no_lang";s:1:"1";s:4:"size";s:1:"b";}i:3;a:3:{s:4:"type";s:5:"label";s:4:"name";s:22:"${row}[ts_description]";s:7:"no_lang";s:1:"1";}}s:1:"C";a:4:{s:4:"type";s:13:"date-duration";s:4:"name";s:19:"${row}[ts_duration]";s:8:"readonly";s:1:"1";s:4:"size";s:5:",,,,1";}s:1:"D";a:3:{s:4:"type";s:5:"label";s:4:"name";s:19:"${row}[ts_quantity]";s:7:"no_lang";s:1:"1";}s:1:"E";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:20:"${row}[ts_unitprice]";}s:1:"F";a:3:{s:4:"type";s:5:"label";s:7:"no_lang";s:1:"1";s:4:"name";s:16:"${row}[ts_total]";}s:1:"G";a:3:{s:4:"type";s:14:"select-account";s:4:"name";s:16:"${row}[ts_owner]";s:8:"readonly";s:1:"1";}s:1:"H";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:6:{s:4:"type";s:6:"button";s:4:"size";s:4:"view";s:5:"label";s:4:"View";s:4:"name";s:22:"view[$row_cont[ts_id]]";s:7:"onclick";s:186:"window.open(egw::link(\'/index.php\',\'menuaction=timesheet.uitimesheet.view&ts_id=$row_cont[ts_id]\'),\'_blank\',\'dependent=yes,width=600,height=400,scrollbars=yes,status=yes\'); return false;";s:4:"help";s:15:"View this entry";}i:2;a:6:{s:4:"type";s:6:"button";s:4:"size";s:4:"edit";s:5:"label";s:4:"Edit";s:4:"name";s:22:"edit[$row_cont[ts_id]]";s:4:"help";s:15:"Edit this entry";s:7:"onclick";s:186:"window.open(egw::link(\'/index.php\',\'menuaction=timesheet.uitimesheet.edit&ts_id=$row_cont[ts_id]\'),\'_blank\',\'dependent=yes,width=600,height=400,scrollbars=yes,status=yes\'); return false;";}i:3;a:6:{s:4:"type";s:6:"button";s:4:"size";s:6:"delete";s:5:"label";s:6:"Delete";s:4:"name";s:24:"delete[$row_cont[ts_id]]";s:4:"help";s:17:"Delete this entry";s:7:"onclick";s:36:"return confirm(\'Delete this entry\');";}}}}s:4:"rows";i:2;s:4:"cols";i:8;s:4:"size";s:4:"100%";s:7:"options";a:1:{i:0;s:4:"100%";}}}','size' => '100%','style' => '','modified' => '1134799629',);
|
||||
|
||||
|
@ -17,6 +17,7 @@ last modified timesheet de Zuletzt ge
|
||||
last month timesheet de Letzten Monat
|
||||
last week timesheet de Letzte Woche
|
||||
last year timesheet de Letztes Jahr
|
||||
leave it empty for a full week timesheet de Leer lassen für eine volle Woche
|
||||
links timesheet de Verknüpfungen
|
||||
no details timesheet de Keine Details
|
||||
permission denied!!! timesheet de Zugriff verweigert!!!
|
||||
|
@ -17,6 +17,7 @@ last modified timesheet en Last modified
|
||||
last month timesheet en Last month
|
||||
last week timesheet en Last week
|
||||
last year timesheet en Last year
|
||||
leave it empty for a full week timesheet en Leave it empty for a full week
|
||||
links timesheet en Links
|
||||
no details timesheet en no details
|
||||
permission denied!!! timesheet en Permission denied!!!
|
||||
|
@ -1,6 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- $Id$ -->
|
||||
<overlay>
|
||||
<template id="timesheet.index.dates" template="" lang="" group="0" version="1.2.001">
|
||||
<hbox data="" rows="1" cols="1" class="custom_hide">
|
||||
<description value="Start"/>
|
||||
<date id="startdate" needed="1"/>
|
||||
<description value="End"/>
|
||||
<date id="enddate" statustext="Leave it empty for a full week"/>
|
||||
</hbox>
|
||||
<styles>
|
||||
.custom_hide { visibility: hidden; }
|
||||
</styles>
|
||||
</template>
|
||||
<template id="timesheet.index.rows" template="" lang="" group="0" version="0.1.001">
|
||||
<grid width="100%">
|
||||
<columns>
|
||||
@ -56,7 +67,7 @@
|
||||
</rows>
|
||||
</grid>
|
||||
</template>
|
||||
<template id="timesheet.index" template="" lang="" group="0" version="0.1.001">
|
||||
<template id="timesheet.index" template="" lang="" group="0" version="1.2.001">
|
||||
<grid width="100%">
|
||||
<columns>
|
||||
<column/>
|
||||
@ -65,6 +76,9 @@
|
||||
<row disabled="!@msg">
|
||||
<description span="all" class="redItalic" no_lang="1" id="msg" align="center"/>
|
||||
</row>
|
||||
<row disabled="1">
|
||||
<template align="right" id="timesheet.index.dates"/>
|
||||
</row>
|
||||
<row>
|
||||
<nextmatch id="nm" options="timesheet.index.rows"/>
|
||||
</row>
|
||||
|
Loading…
Reference in New Issue
Block a user