forked from extern/egroupware
"fixed postgres problem reported by Mary Muir <mmuir(at)sjgeophysics.com> on the user list"
This commit is contained in:
parent
7eab124b15
commit
cdcf216712
@ -7,7 +7,7 @@
|
|||||||
* @package timesheet
|
* @package timesheet
|
||||||
* @copyright (c) 2005/6 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
* @copyright (c) 2005/6 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
|
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
|
||||||
@ -26,7 +26,7 @@ class botimesheet extends so_sql
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Timesheets config data
|
* Timesheets config data
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $config = array();
|
var $config = array();
|
||||||
@ -46,34 +46,34 @@ class botimesheet extends so_sql
|
|||||||
var $quantity_sum=false;
|
var $quantity_sum=false;
|
||||||
/**
|
/**
|
||||||
* Timestaps that need to be adjusted to user-time on reading or saving
|
* Timestaps that need to be adjusted to user-time on reading or saving
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $timestamps = array(
|
var $timestamps = array(
|
||||||
'ts_start','ts_modified'
|
'ts_start','ts_modified'
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* Offset in secconds between user and server-time, it need to be add to a server-time to get the user-time
|
* Offset in secconds between user and server-time, it need to be add to a server-time to get the user-time
|
||||||
* or substracted from a user-time to get the server-time
|
* or substracted from a user-time to get the server-time
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
var $tz_offset_s;
|
var $tz_offset_s;
|
||||||
/**
|
/**
|
||||||
* Current time as timestamp in user-time
|
* Current time as timestamp in user-time
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
var $now;
|
var $now;
|
||||||
/**
|
/**
|
||||||
* Start of today in user-time
|
* Start of today in user-time
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
var $today;
|
var $today;
|
||||||
/**
|
/**
|
||||||
* Filter for search limiting the date-range
|
* Filter for search limiting the date-range
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $date_filters = array( // Start: year,month,day,week, End: year,month,day,week
|
var $date_filters = array( // Start: year,month,day,week, End: year,month,day,week
|
||||||
@ -91,31 +91,31 @@ class botimesheet extends so_sql
|
|||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* Reference to the (bo)link class instanciated at $GLOBALS['egw']->link
|
* Reference to the (bo)link class instanciated at $GLOBALS['egw']->link
|
||||||
*
|
*
|
||||||
* @var bolink
|
* @var bolink
|
||||||
*/
|
*/
|
||||||
var $link;
|
var $link;
|
||||||
/**
|
/**
|
||||||
* Grants: $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
|
* Grants: $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $grants;
|
var $grants;
|
||||||
/**
|
/**
|
||||||
* Sums of the last search in keys duration and price
|
* Sums of the last search in keys duration and price
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $summary;
|
var $summary;
|
||||||
/**
|
/**
|
||||||
* Array with boolean values in keys 'day', 'week' or 'month', for the sums to return in the search
|
* Array with boolean values in keys 'day', 'week' or 'month', for the sums to return in the search
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $show_sums;
|
var $show_sums;
|
||||||
|
|
||||||
var $customfields=array();
|
var $customfields=array();
|
||||||
|
|
||||||
function botimesheet()
|
function botimesheet()
|
||||||
{
|
{
|
||||||
$this->so_sql(TIMESHEET_APP,'egw_timesheet');
|
$this->so_sql(TIMESHEET_APP,'egw_timesheet');
|
||||||
@ -149,10 +149,10 @@ class botimesheet extends so_sql
|
|||||||
$GLOBALS['egw']->link =& CreateObject('phpgwapi.bolink');
|
$GLOBALS['egw']->link =& CreateObject('phpgwapi.bolink');
|
||||||
}
|
}
|
||||||
$this->link =& $GLOBALS['egw']->link;
|
$this->link =& $GLOBALS['egw']->link;
|
||||||
|
|
||||||
$this->grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
|
$this->grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get list of specified grants as uid => Username pairs
|
* get list of specified grants as uid => Username pairs
|
||||||
*
|
*
|
||||||
@ -173,7 +173,7 @@ class botimesheet extends so_sql
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if the user has enough rights for a certain operation
|
* checks if the user has enough rights for a certain operation
|
||||||
*
|
*
|
||||||
@ -194,14 +194,14 @@ class botimesheet extends so_sql
|
|||||||
$save_data = $this->data;
|
$save_data = $this->data;
|
||||||
$data = $this->read($data,true);
|
$data = $this->read($data,true);
|
||||||
$this->data = $save_data;
|
$this->data = $save_data;
|
||||||
|
|
||||||
if (!$data) return null; // entry not found
|
if (!$data) return null; // entry not found
|
||||||
}
|
}
|
||||||
$rights = $this->grants[$data['ts_owner']];
|
$rights = $this->grants[$data['ts_owner']];
|
||||||
|
|
||||||
return $data && !!($rights & $required);
|
return $data && !!($rights & $required);
|
||||||
}
|
}
|
||||||
|
|
||||||
function date_filter($name,&$start,&$end_param)
|
function date_filter($name,&$start,&$end_param)
|
||||||
{
|
{
|
||||||
$end = $end_param;
|
$end = $end_param;
|
||||||
@ -226,9 +226,9 @@ class botimesheet extends so_sql
|
|||||||
$year = (int) date('Y',$this->today);
|
$year = (int) date('Y',$this->today);
|
||||||
$month = (int) date('m',$this->today);
|
$month = (int) date('m',$this->today);
|
||||||
$day = (int) date('d',$this->today);
|
$day = (int) date('d',$this->today);
|
||||||
|
|
||||||
list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $this->date_filters[$name];
|
list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $this->date_filters[$name];
|
||||||
|
|
||||||
if ($syear || $eyear)
|
if ($syear || $eyear)
|
||||||
{
|
{
|
||||||
$start = mktime(0,0,0,1,1,$syear+$year);
|
$start = mktime(0,0,0,1,1,$syear+$year);
|
||||||
@ -265,7 +265,7 @@ class botimesheet extends so_sql
|
|||||||
}
|
}
|
||||||
$end_param = $end - 24*60*60;
|
$end_param = $end - 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";
|
//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 for the filter
|
// convert start + end from user to servertime for the filter
|
||||||
return '('.($start-$this->tz_offset_s).' <= ts_start AND ts_start < '.($end-$this->tz_offset_s).')';
|
return '('.($start-$this->tz_offset_s).' <= ts_start AND ts_start < '.($end-$this->tz_offset_s).')';
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ class botimesheet extends so_sql
|
|||||||
* @param string $op='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
|
* @param string $op='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
|
||||||
* @param mixed $start=false if != false, return only maxmatch rows begining with start, or array($start,$num)
|
* @param mixed $start=false if != false, return only maxmatch rows begining with start, or array($start,$num)
|
||||||
* @param array $filter=null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
|
* @param array $filter=null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
|
||||||
* @param string $join='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or
|
* @param string $join='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or
|
||||||
* "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join!
|
* "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join!
|
||||||
* @param boolean $need_full_no_count=false If true an unlimited query is run to determine the total number of rows, default false
|
* @param boolean $need_full_no_count=false If true an unlimited query is run to determine the total number of rows, default false
|
||||||
* @param boolean $only_summary=false If true only return the sums as array with keys duration and price, default false
|
* @param boolean $only_summary=false If true only return the sums as array with keys duration and price, default false
|
||||||
@ -308,7 +308,7 @@ class botimesheet extends so_sql
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']);
|
if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']);
|
||||||
|
|
||||||
foreach($filter['ts_owner'] as $key => $owner)
|
foreach($filter['ts_owner'] as $key => $owner)
|
||||||
{
|
{
|
||||||
if (!isset($this->grants[$owner]))
|
if (!isset($this->grants[$owner]))
|
||||||
@ -327,7 +327,7 @@ class botimesheet extends so_sql
|
|||||||
($this->quantity_sum ? ",SUM(ts_quantity) AS quantity" : ''),
|
($this->quantity_sum ? ",SUM(ts_quantity) AS quantity" : ''),
|
||||||
'','',$wildcard,$empty,$op,false,$filter,$join);
|
'','',$wildcard,$empty,$op,false,$filter,$join);
|
||||||
$this->summary = $this->summary[0];
|
$this->summary = $this->summary[0];
|
||||||
|
|
||||||
if ($only_summary) return $this->summary;
|
if ($only_summary) return $this->summary;
|
||||||
|
|
||||||
if ($this->show_sums && strpos($order_by,'ts_start') !== false && // sums only make sense if ordered by ts_start
|
if ($this->show_sums && strpos($order_by,'ts_start') !== false && // sums only make sense if ordered by ts_start
|
||||||
@ -348,7 +348,7 @@ class botimesheet extends so_sql
|
|||||||
}
|
}
|
||||||
// regular entries
|
// regular entries
|
||||||
parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count);
|
parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count);
|
||||||
|
|
||||||
$sort = substr($order_by,8);
|
$sort = substr($order_by,8);
|
||||||
$union_order = array();
|
$union_order = array();
|
||||||
$sum_ts_id = array('year' => -3,'month' => -2,'week' => -1,'day' => 0);
|
$sum_ts_id = array('year' => -3,'month' => -2,'week' => -1,'day' => 0);
|
||||||
@ -411,7 +411,7 @@ class botimesheet extends so_sql
|
|||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* saves a timesheet entry
|
* saves a timesheet entry
|
||||||
*
|
*
|
||||||
@ -425,7 +425,7 @@ class botimesheet extends so_sql
|
|||||||
function save($keys=null,$touch_modified=true,$ignore_acl=false)
|
function save($keys=null,$touch_modified=true,$ignore_acl=false)
|
||||||
{
|
{
|
||||||
if ($keys) $this->data_merge($keys);
|
if ($keys) $this->data_merge($keys);
|
||||||
|
|
||||||
if (!$ignore_acl && $this->data['ts_id'] && !$this->check_acl(EGW_ACL_EDIT))
|
if (!$ignore_acl && $this->data['ts_id'] && !$this->check_acl(EGW_ACL_EDIT))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -481,7 +481,7 @@ class botimesheet extends so_sql
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deletes a timesheet entry identified by $keys or the loaded one, reimplemented to notify the link class (unlink)
|
* deletes a timesheet entry identified by $keys or the loaded one, reimplemented to notify the link class (unlink)
|
||||||
*
|
*
|
||||||
@ -496,7 +496,7 @@ class botimesheet extends so_sql
|
|||||||
$keys = array('ts_id' => (int) $keys);
|
$keys = array('ts_id' => (int) $keys);
|
||||||
}
|
}
|
||||||
$ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id'];
|
$ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id'];
|
||||||
|
|
||||||
if (!$this->check_acl(EGW_ACL_DELETE,$ts_id))
|
if (!$this->check_acl(EGW_ACL_DELETE,$ts_id))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -575,7 +575,7 @@ class botimesheet extends so_sql
|
|||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the time- and pricesum for the given timesheet entries
|
* Get the time- and pricesum for the given timesheet entries
|
||||||
*
|
*
|
||||||
@ -586,10 +586,10 @@ class botimesheet extends so_sql
|
|||||||
{
|
{
|
||||||
return $this->search(array('ts_id'=>$ids),true,'','','',false,'AND',false,null,'',false,true);
|
return $this->search(array('ts_id'=>$ids),true,'','','',false,'AND',false,null,'',false,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get title for an timesheet entry identified by $entry
|
* get title for an timesheet entry identified by $entry
|
||||||
*
|
*
|
||||||
* Is called as hook to participate in the linking
|
* Is called as hook to participate in the linking
|
||||||
*
|
*
|
||||||
* @param int/array $entry int ts_id or array with timesheet entry
|
* @param int/array $entry int ts_id or array with timesheet entry
|
||||||
@ -651,19 +651,19 @@ class botimesheet extends so_sql
|
|||||||
'menuaction' => TIMESHEET_APP.'.uitimesheet.view',
|
'menuaction' => TIMESHEET_APP.'.uitimesheet.view',
|
||||||
),
|
),
|
||||||
'view_id' => 'ts_id',
|
'view_id' => 'ts_id',
|
||||||
'view_popup' => '600x400',
|
'view_popup' => '600x400',
|
||||||
'add' => array(
|
'add' => array(
|
||||||
'menuaction' => TIMESHEET_APP.'.uitimesheet.edit',
|
'menuaction' => TIMESHEET_APP.'.uitimesheet.edit',
|
||||||
),
|
),
|
||||||
'add_app' => 'link_app',
|
'add_app' => 'link_app',
|
||||||
'add_id' => 'link_id',
|
'add_id' => 'link_id',
|
||||||
'add_popup' => '600x400',
|
'add_popup' => '600x400',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the timesheets linked with given project(s) AND with entries of other apps, which are also linked to the same project
|
* Return the timesheets linked with given project(s) AND with entries of other apps, which are also linked to the same project
|
||||||
*
|
*
|
||||||
* Projectmanager will cumulate them in the other apps entries.
|
* Projectmanager will cumulate them in the other apps entries.
|
||||||
*
|
*
|
||||||
* @param array $param int/array $param['pm_id'] project-id(s)
|
* @param array $param int/array $param['pm_id'] project-id(s)
|
||||||
@ -672,7 +672,7 @@ class botimesheet extends so_sql
|
|||||||
function cumulate($param)
|
function cumulate($param)
|
||||||
{
|
{
|
||||||
$links = $this->link->get_3links(TIMESHEET_APP,'projectmanager',$param['pm_id']);
|
$links = $this->link->get_3links(TIMESHEET_APP,'projectmanager',$param['pm_id']);
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach($links as $link)
|
foreach($links as $link)
|
||||||
{
|
{
|
||||||
@ -716,31 +716,31 @@ class botimesheet extends so_sql
|
|||||||
*
|
*
|
||||||
* @param int $pm_id ID of selected project
|
* @param int $pm_id ID of selected project
|
||||||
* @return array containing link_id and ts_id
|
* @return array containing link_id and ts_id
|
||||||
*/
|
*/
|
||||||
function get_ts_links($pm_id=0) {
|
function get_ts_links($pm_id=0) {
|
||||||
$tslist = array();
|
$tslist = array();
|
||||||
if(strlen($pm_id) > 0) {
|
if(strlen($pm_id) > 0) {
|
||||||
if(isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) {
|
if(isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) {
|
||||||
$bo_pm = CreateObject('projectmanager.boprojectmanager');
|
$bo_pm = CreateObject('projectmanager.boprojectmanager');
|
||||||
$childs = $bo_pm->children($pm_id);
|
$childs = $bo_pm->children($pm_id);
|
||||||
$childs[] = $pm_id;
|
$childs[] = $pm_id;
|
||||||
$pmChilds = implode(",",$childs);
|
$pmChilds = "'".implode("','",$childs)."'";
|
||||||
$this->db->select( 'egw_links','link_id, link_id1',$query,
|
$this->db->select( 'egw_links','link_id, link_id1',$query,
|
||||||
__LINE__,__FILE__,False,
|
__LINE__,__FILE__,False,
|
||||||
'',False,0,
|
'',False,0,
|
||||||
'JOIN egw_pm_projects ON (pm_id = link_id2)
|
'JOIN egw_pm_projects ON (pm_id = link_id2)
|
||||||
WHERE
|
WHERE
|
||||||
link_app1 = \'timesheet\' AND
|
link_app1 = \'timesheet\' AND
|
||||||
link_app2 = \'projectmanager\' AND
|
link_app2 = \'projectmanager\' AND
|
||||||
link_id2 IN ('.$pmChilds.')');
|
link_id2 IN ('.$pmChilds.')');
|
||||||
|
|
||||||
while($row = $this->db->row(true)) {
|
while($row = $this->db->row(true)) {
|
||||||
$tslist[$row['link_id']] = $row['link_id1'];
|
$tslist[$row['link_id']] = $row['link_id1'];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return $tslist;
|
return $tslist;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user