[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gforge-commits] gforge/common/reporting Report.class, NONE, 1.1 ReportP
From: |
tperdue |
Subject: |
[Gforge-commits] gforge/common/reporting Report.class, NONE, 1.1 ReportProjectAct.class, NONE, 1.1 ReportProjectTime.class, NONE, 1.1 ReportSetup.class, NONE, 1.1 ReportSiteAct.class, NONE, 1.1 ReportSiteTime.class, NONE, 1.1 ReportTrackerAct.class, NONE, 1.1 ReportUserAct.class, NONE, 1.1 ReportUserAdded.class, NONE, 1.1 ReportUserCum.class, NONE, 1.1 ReportUserTime.class, NONE, 1.1 report_utils.php, NONE, 1.1 |
Date: |
Wed, 28 Jul 2004 12:31:29 -0500 |
Update of /cvsroot/gforge/gforge/common/reporting
In directory db.perdue.net:/home/tperdue/share/dev.gforge.org/common/reporting
Added Files:
Report.class ReportProjectAct.class ReportProjectTime.class
ReportSetup.class ReportSiteAct.class ReportSiteTime.class
ReportTrackerAct.class ReportUserAct.class
ReportUserAdded.class ReportUserCum.class ReportUserTime.class
report_utils.php
Log Message:
Release of Reporting Module
--- NEW FILE: Report.class ---
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: Report.class,v 1.1 2004/07/28 17:31:26 tperdue Exp $
* @author Tim Perdue address@hidden
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
DEFINE('REPORT_DAY_SPAN',24*60*60);
DEFINE('REPORT_WEEK_SPAN',7*24*60*60);
DEFINE('REPORT_MONTH_SPAN',30*24*60*60);
DEFINE('REPORT_TYPE_DAILY',1);
DEFINE('REPORT_TYPE_WEEKLY',2);
DEFINE('REPORT_TYPE_MONTHLY',3);
DEFINE('REPORT_TYPE_OA',4);
class Report extends Error {
//var $adjust_days=array('Sun'=>0, 'Sat'=>6, 'Fri'=>5, 'Thu'=>4, 'Wed'=>3,
'Tue'=>2, 'Mon'=>1);
var $adjust_days=array('Sun'=>'0.0', 'Sat'=>1, 'Fri'=>2, 'Thu'=>3, 'Wed'=>4,
'Tue'=>5, 'Mon'=>6);
var $month_start_arr=array();
var $week_start_arr=array();
var $site_start_date;
var $data;
var $labels;
var $span;
var $start_date;
var $end_date;
var $span_name=array(1=>'Daily',2=>'Weekly',3=>'Monthly',4=>'OverAll');
var $graph_interval=array(1=>7,2=>1,3=>1,4=>1);
function Report() {
$this->Error();
//
// All reporting action will be done in GMT timezone
//
putenv('TZ=GMT');
}
/**
* get the unix time that this install was setup.
*/
function getMinDate() {
if (!$this->site_start_date) {
$res=db_query("select min(add_date) AS start_date from users
where add_date > 0;");
$this->site_start_date=db_result($res,0,'start_date');
}
return $this->site_start_date;
}
function &getMonthStartArr() {
if (count($this->month_start_arr) < 1) {
$min_date=$this->getMinDate();
for ($i=0; $i<24; $i++) {
$this->month_start_arr[]=mktime(0,0,0,date('m')+1-$i,1,date('Y'));
if ($this->month_start_arr[$i] < $min_date) {
break;
}
}
}
return $this->month_start_arr;
}
function &getWeekStartArr() {
if (count($this->week_start_arr) < 1) {
$min_date=$this->getMinDate();
$start=mktime(0,0,0,date('m'),(date('d')+$this->adjust_days[date('D')]),date('Y'));
for ($i=0; $i<104; $i++) {
$this->week_start_arr[]=($start-REPORT_WEEK_SPAN*$i);
if ($this->week_start_arr[$i] < $min_date) {
break;
}
}
}
return $this->week_start_arr;
}
function setSpan($span) {
$this->span=$span;
}
function getSpanName() {
return $this->span_name[$this->span];
}
function setData($result,$column) {
$this->data =& util_result_column_to_array($result,$column);
}
function setDates($result,$column) {
$arr =& util_result_column_to_array($result,$column);
for ($i=0; $i<count($arr); $i++) {
$this->labels[$i] = date('M d',$arr[$i]);
}
}
function getGraphInterval() {
return $this->graph_interval[$this->span];
}
function &getData() {
return $this->data;
}
function &getDates() {
return $this->labels;
}
function getStartDate() {
return $this->start_date;
}
function getEndDate() {
return $this->end_date;
}
}
?>
--- NEW FILE: ReportProjectAct.class ---
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: ReportProjectAct.class,v 1.1 2004/07/28 17:31:26 tperdue Exp
$
* @author Tim Perdue address@hidden
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once('common/reporting/Report.class');
class ReportProjectAct extends Report {
var $res;
function ReportProjectAct($span,$group_id,$start=0,$end=0) {
$this->Report();
if (!$start) {
$start=mktime(0,0,0,date('m'),1,date('Y'));;
}
if (!$end) {
$end=time();
} else {
$end--;
}
if (!$group_id) {
$this->setError('No group_id');
return false;
}
if (!$span || $span == REPORT_TYPE_MONTHLY) {
$res=db_query("SELECT * FROM rep_group_act_monthly
WHERE group_id='$group_id' AND month BETWEEN '$start'
AND '$end' ORDER BY month");
} elseif ($span == REPORT_TYPE_WEEKLY) {
$res=db_query("SELECT * FROM rep_group_act_weekly
WHERE group_id='$group_id' AND week BETWEEN '$start'
AND '$end' ORDER BY week");
} elseif ($span == REPORT_TYPE_DAILY) {
$res=db_query("SELECT * FROM rep_group_act_daily
WHERE group_id='$group_id' AND day BETWEEN '$start' AND
'$end' ORDER BY day ASC");
}
$this->start_date=$start;
$this->end_date=$end;
if (!$res || db_error()) {
$this->setError('ReportProjectAct:: '.db_error());
return false;
}
$this->setSpan($span);
$this->setDates($res,1);
$this->res=$res;
return true;
}
function &getTrackerOpened() {
return util_result_column_to_array($this->res,2);
}
function &getTrackerClosed() {
return util_result_column_to_array($this->res,3);
}
function &getForum() {
return util_result_column_to_array($this->res,4);
}
function &getDocs() {
return util_result_column_to_array($this->res,5);
}
function &getDownloads() {
return util_result_column_to_array($this->res,6);
}
function &getCVSCommits() {
return util_result_column_to_array($this->res,7);
}
function &getTaskOpened() {
return util_result_column_to_array($this->res,8);
}
function &getTaskClosed() {
return util_result_column_to_array($this->res,9);
}
}
?>
--- NEW FILE: ReportProjectTime.class ---
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: ReportProjectTime.class,v 1.1 2004/07/28 17:31:26 tperdue
Exp $
* @author Tim Perdue address@hidden
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once('common/reporting/Report.class');
class ReportProjectTime extends Report {
function ReportProjectTime($group_id,$type,$start=0,$end=0) {
$this->Report();
if (!$start) {
$start=mktime(0,0,0,date('m'),1,date('Y'));;
}
if (!$end) {
$end=time();
} else {
$end--;
}
if (!$group_id) {
$this->setError('No User_id');
return false;
}
//
// Task report
//
if (!$type || $type=='tasks') {
$res=db_query("SELECT pt.summary,sum(rtt.hours) AS hours
FROM rep_time_tracking rtt, project_task pt,
project_group_list pgl
WHERE pgl.group_project_id=pt.group_project_id
AND pgl.group_id='$group_id'
AND rtt.report_date BETWEEN '$start' AND '$end'
AND rtt.project_task_id=pt.project_task_id
GROUP BY pt.summary
ORDER BY hours DESC");
//
// Category report
//
} elseif ($type=='category') {
$res=db_query("SELECT rtc.category_name, sum(rtt.hours) AS
hours
FROM rep_time_tracking rtt, rep_time_category rtc,
project_task pt, project_group_list pgl
WHERE pgl.group_id='$group_id'
AND pgl.group_project_id=pt.group_project_id
AND rtt.project_task_id=pt.project_task_id
AND rtt.report_date BETWEEN '$start' AND '$end'
AND rtt.time_code=rtc.time_code
GROUP BY rtc.category_name
ORDER BY hours DESC");
//
// Percentage this user spent on a specific subproject
//
} elseif ($type=='subproject') {
$res=db_query("SELECT pgl.project_name, sum(rtt.hours) AS hours
FROM rep_time_tracking rtt, project_task pt,
project_group_list pgl
WHERE pgl.group_id='$group_id'
AND rtt.report_date BETWEEN '$start' AND '$end'
AND rtt.project_task_id=pt.project_task_id
AND pt.group_project_id=pgl.group_project_id
GROUP BY pgl.project_name
ORDER BY hours DESC");
} else {
//
// Biggest Users
//
$res=db_query("SELECT u.realname, sum(rtt.hours) AS hours
FROM users u, rep_time_tracking rtt, project_task pt,
project_group_list pgl
WHERE pgl.group_id='$group_id'
AND rtt.report_date BETWEEN '$start' AND '$end'
AND rtt.project_task_id=pt.project_task_id
AND pt.group_project_id=pgl.group_project_id
AND u.user_id=rtt.user_id
GROUP BY u.realname
ORDER BY hours DESC");
}
$this->start_date=$start;
$this->end_date=$end;
if (!$res || db_error()) {
$this->setError('ReportUserAct:: '.db_error());
return false;
}
$this->labels = util_result_column_to_array($res,0);
$this->setData($res,1);
return true;
}
}
?>
--- NEW FILE: ReportSetup.class ---
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: ReportSetup.class,v 1.1 2004/07/28 17:31:26 tperdue Exp $
* @author Tim Perdue address@hidden
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
[...999 lines suppressed...]
* @param string The category name.
* @return boolean Success.
*/
function addTimeCode($category_name) {
return db_query("INSERT INTO rep_time_category (category_name) VALUES
('$category_name')");
}
/**
* Update the rep_time_category table.
*
* @param string The category name.
* @return boolean Success.
*/
function updateTimeCode($time_code, $category_name) {
return db_query("UPDATE rep_time_category SET
category_name='$category_name' WHERE time_code='$time_code'");
}
}
?>
--- NEW FILE: ReportSiteAct.class ---
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: ReportSiteAct.class,v 1.1 2004/07/28 17:31:26 tperdue Exp $
* @author Tim Perdue address@hidden
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once('common/reporting/Report.class');
class ReportSiteAct extends Report {
var $res;
function ReportSiteAct($span,$start=0,$end=0) {
$this->Report();
if (!$start) {
$start=mktime(0,0,0,date('m'),1,date('Y'));;
}
if (!$end) {
$end=time();
} else {
$end--;
}
if (!$span || $span == REPORT_TYPE_MONTHLY) {
$res=db_query("SELECT * FROM rep_site_act_monthly_vw
WHERE month BETWEEN '$start' AND '$end' ORDER BY
month");
} elseif ($span == REPORT_TYPE_WEEKLY) {
$res=db_query("SELECT * FROM rep_site_act_weekly_vw
WHERE week BETWEEN '$start' AND '$end' ORDER BY week");
} elseif ($span == REPORT_TYPE_DAILY) {
$res=db_query("SELECT * FROM rep_site_act_daily_vw
WHERE day BETWEEN '$start' AND '$end' ORDER BY day
ASC");
}
$this->start_date=$start;
$this->end_date=$end;
if (!$res || db_error()) {
$this->setError('ReportProjectAct:: '.db_error());
return false;
}
$this->setSpan($span);
$this->setDates($res,0);
$this->res=$res;
return true;
}
function &getTrackerOpened() {
return util_result_column_to_array($this->res,1);
}
function &getTrackerClosed() {
return util_result_column_to_array($this->res,2);
}
function &getForum() {
return util_result_column_to_array($this->res,3);
}
function &getDocs() {
return util_result_column_to_array($this->res,4);
}
function &getDownloads() {
return util_result_column_to_array($this->res,5);
}
function &getCVSCommits() {
return util_result_column_to_array($this->res,6);
}
function &getTaskOpened() {
return util_result_column_to_array($this->res,7);
}
function &getTaskClosed() {
return util_result_column_to_array($this->res,8);
}
}
?>
--- NEW FILE: ReportSiteTime.class ---
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: ReportSiteTime.class,v 1.1 2004/07/28 17:31:26 tperdue Exp $
* @author Tim Perdue address@hidden
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once('common/reporting/Report.class');
class ReportSiteTime extends Report {
function ReportSiteTime($type,$start=0,$end=0) {
$this->Report();
if (!$start) {
$start=mktime(0,0,0,date('m'),1,date('Y'));;
}
if (!$end) {
$end=time();
} else {
$end--;
}
//
// Task report
//
if (!$type || $type=='tasks') {
$res=db_query("SELECT pt.summary,sum(rtt.hours) AS hours
FROM rep_time_tracking rtt, project_task pt,
project_group_list pgl
WHERE pgl.group_project_id=pt.group_project_id
AND rtt.report_date BETWEEN '$start' AND '$end'
AND rtt.project_task_id=pt.project_task_id
GROUP BY pt.summary
ORDER BY hours DESC");
//
// Category report
//
} elseif ($type=='category') {
$res=db_query("SELECT rtc.category_name, sum(rtt.hours) AS
hours
FROM rep_time_tracking rtt, rep_time_category rtc
WHERE rtt.report_date BETWEEN '$start' AND '$end'
AND rtt.time_code=rtc.time_code
GROUP BY rtc.category_name
ORDER BY hours DESC");
//
// Percentage this user spent on a specific subproject
//
} elseif ($type=='subproject') {
$res=db_query("SELECT pgl.project_name, sum(rtt.hours) AS hours
FROM rep_time_tracking rtt, project_task pt,
project_group_list pgl
WHERE rtt.report_date BETWEEN '$start' AND '$end'
AND rtt.project_task_id=pt.project_task_id
AND pt.group_project_id=pgl.group_project_id
GROUP BY pgl.project_name
ORDER BY hours DESC");
} else {
$res=db_query("SELECT u.realname, sum(rtt.hours) AS hours
FROM users u, rep_time_tracking rtt, project_task pt,
project_group_list pgl
WHERE rtt.report_date BETWEEN '$start' AND '$end'
AND u.user_id=rtt.user_id
GROUP BY u.realname
ORDER BY hours DESC");
}
$this->start_date=$start;
$this->end_date=$end;
if (!$res || db_error()) {
$this->setError('ReportUserAct:: '.db_error());
return false;
}
$this->labels = util_result_column_to_array($res,0);
$this->setData($res,1);
return true;
}
}
?>
--- NEW FILE: ReportTrackerAct.class ---
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: ReportTrackerAct.class,v 1.1 2004/07/28 17:31:26 tperdue Exp
$
* @author Tim Perdue address@hidden
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once('common/reporting/Report.class');
class ReportTrackerAct extends Report {
var $res;
var $avgtime;
var $opencount;
var $stillopencount;
function ReportTrackerAct($span,$group_id,$atid,$start=0,$end=0) {
$this->Report();
if (!$start) {
$start=mktime(0,0,0,date('m'),1,date('Y')-1);
}
if (!$end) {
$end=time();
} else {
$end--;
}
if (!$group_id) {
$this->setError('No group_id');
return false;
}
if (!$span || $span == REPORT_TYPE_MONTHLY) {
$arr =& $this->getMonthStartArr();
for ($i=1; $i<count($arr); $i++) {
if ($arr[$i]<$start || $arr[$i]>$end) {
//skip this month as it's not in the range
} else {
$this->labels[]=date('M d',$arr[$i]).' <->
'.date('M d',($arr[$i-1]-1));
$this->avgtime[]=$this->getAverageTime($atid,$arr[$i],($arr[$i-1]-1));
$this->opencount[]=$this->getOpenCount($atid,$arr[$i],($arr[$i-1]-1));
$this->stillopencount[]=$this->getStillOpenCount($atid,$arr[$i],($arr[$i-1]-1));
}
}
} elseif ($span == REPORT_TYPE_WEEKLY) {
$arr =& $this->getWeekStartArr();
for ($i=1; $i<count($arr); $i++) {
if ($arr[$i]<$start || $arr[$i]>$end) {
//skip this month as it's not in the range
} else {
$this->labels[]=date('M d',$arr[$i]).' <->
'.date('M d',($arr[$i-1]-1));
$this->avgtime[]=$this->getAverageTime($atid,$arr[$i],($arr[$i-1]-1));
$this->opencount[]=$this->getOpenCount($atid,$arr[$i],($arr[$i-1]-1));
$this->stillopencount[]=$this->getStillOpenCount($atid,$arr[$i],($arr[$i-1]-1));
}
}
}
$this->start_date=$start;
$this->end_date=$end;
$this->setSpan($span);
$this->setDates($res,1);
$this->res=$res;
return true;
}
function getAverageTime($atid,$start,$end) {
$sql="SELECT avg((close_date-open_date)/(24*60*60)) AS avgtime
FROM artifact
WHERE group_artifact_id='$atid'
AND close_date > 0
AND (open_date >= '$start' AND open_date <= '$end')";
$res=db_query($sql);
echo db_error();
return db_result($res,0,0);
}
function getOpenCount($atid,$start,$end) {
$sql="SELECT count(*)
FROM artifact
WHERE
group_artifact_id='$atid'
AND open_date >= '$start'
AND open_date <= '$end'";
$res=db_query($sql);
echo db_error();
return db_result($res,0,0);
}
function getStillOpenCount($atid,$start,$end) {
$sql="SELECT count(*)
FROM artifact
WHERE
group_artifact_id='$atid'
AND open_date <= '$end'
AND (close_date >= '$end' OR close_date < 1 OR close_date is
null)";
$res=db_query($sql);
echo db_error();
return db_result($res,0,0);
}
function &getAverageTimeData() {
return $this->avgtime;
}
function &getOpenCountData() {
return $this->opencount;
}
function &getStillOpenCountData() {
return $this->stillopencount;
}
}
?>
--- NEW FILE: ReportUserAct.class ---
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: ReportUserAct.class,v 1.1 2004/07/28 17:31:26 tperdue Exp $
* @author Tim Perdue address@hidden
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once('common/reporting/Report.class');
class ReportUserAct extends Report {
var $res;
function ReportUserAct($span,$user_id,$start=0,$end=0) {
$this->Report();
if (!$start) {
$start=mktime(0,0,0,date('m'),1,date('Y'));;
}
if (!$end) {
$end=time();
} else {
$end--;
}
if (!$user_id) {
$this->setError('No User_id');
return false;
}
if (!$span || $span == REPORT_TYPE_MONTHLY) {
$res=db_query("SELECT * FROM rep_user_act_monthly
WHERE user_id='$user_id' AND month BETWEEN '$start' AND
'$end' ORDER BY month");
} elseif ($span == REPORT_TYPE_WEEKLY) {
$res=db_query("SELECT * FROM rep_user_act_weekly
WHERE user_id='$user_id' AND week BETWEEN '$start' AND
'$end' ORDER BY week");
} elseif ($span == REPORT_TYPE_DAILY) {
$res=db_query("SELECT * FROM rep_user_act_daily
WHERE user_id='$user_id' AND day BETWEEN '$start' AND
'$end' ORDER BY day ASC");
}
$this->start_date=$start;
$this->end_date=$end;
if (!$res || db_error()) {
$this->setError('ReportUserAct:: '.db_error());
return false;
}
$this->setSpan($span);
$this->setDates($res,1);
$this->res=$res;
return true;
}
function &getTrackerOpened() {
return util_result_column_to_array($this->res,2);
}
function &getTrackerClosed() {
return util_result_column_to_array($this->res,3);
}
function &getForum() {
return util_result_column_to_array($this->res,4);
}
function &getDocs() {
return util_result_column_to_array($this->res,5);
}
function &getCVSCommits() {
return util_result_column_to_array($this->res,6);
}
function &getTaskOpened() {
return util_result_column_to_array($this->res,7);
}
function &getTaskClosed() {
return util_result_column_to_array($this->res,8);
}
}
?>
--- NEW FILE: ReportUserAdded.class ---
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: ReportUserAdded.class,v 1.1 2004/07/28 17:31:26 tperdue Exp $
* @author Tim Perdue address@hidden
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once('common/reporting/Report.class');
class ReportUserAdded extends Report {
function ReportUserAdded($span,$start=0,$end=0) {
$this->Report();
if (!$start) {
$start=mktime(0,0,0,date('m'),1,date('Y'));;
}
if (!$end) {
$end=time();
} else {
$end--;
}
if (!$span || $span == REPORT_TYPE_MONTHLY) {
$res=db_query("SELECT * FROM rep_users_added_monthly
WHERE month BETWEEN '$start' AND '$end' ORDER BY
month");
} elseif ($span == REPORT_TYPE_WEEKLY) {
$res=db_query("SELECT * FROM rep_users_added_weekly
WHERE week BETWEEN '$start' AND '$end' ORDER BY week");
} elseif ($span == REPORT_TYPE_DAILY) {
$res=db_query("SELECT * FROM rep_users_added_daily
WHERE day BETWEEN '$start' AND '$end' ORDER BY day
ASC");
}
$this->start_date=$start;
$this->end_date=$end;
if (!$res || db_error()) {
$this->setError('ReportUserAdded:: '.db_error());
return false;
}
$this->setSpan($span);
$this->setDates($res,0);
$this->setData($res,1);
return true;
}
}
?>
--- NEW FILE: ReportUserCum.class ---
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: ReportUserCum.class,v 1.1 2004/07/28 17:31:26 tperdue Exp $
* @author Tim Perdue address@hidden
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once('common/reporting/Report.class');
class ReportUserCum extends Report {
function ReportUserCum($span,$start=0,$end=0) {
$this->Report();
if (!$start) {
$start=mktime(0,0,0,date('m'),1,date('Y'));;
}
if (!$end) {
$end=time();
} else {
$end--;
}
if (!$span || $span == REPORT_TYPE_MONTHLY) {
$res=db_query("SELECT * FROM rep_users_cum_monthly
WHERE month BETWEEN '$start' AND '$end' ORDER BY
month");
} elseif ($span == REPORT_TYPE_WEEKLY) {
$res=db_query("SELECT * FROM rep_users_cum_weekly
WHERE week BETWEEN '$start' AND '$end' ORDER BY week");
} elseif ($span == REPORT_TYPE_DAILY) {
$res=db_query("SELECT * FROM rep_users_cum_daily
WHERE day BETWEEN '$start' AND '$end' ORDER BY day
ASC");
}
$this->start_date=$start;
$this->end_date=$end;
if (!$res || db_error()) {
$this->setError('ReportUserAdded:: '.db_error());
return false;
}
$this->setSpan($span);
$this->setDates($res,0);
$this->setData($res,1);
return true;
}
}
?>
--- NEW FILE: ReportUserTime.class ---
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: ReportUserTime.class,v 1.1 2004/07/28 17:31:26 tperdue Exp $
* @author Tim Perdue address@hidden
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once('common/reporting/Report.class');
class ReportUserTime extends Report {
function ReportUserTime($user_id,$type,$start=0,$end=0) {
$this->Report();
if (!$start) {
$start=mktime(0,0,0,date('m'),1,date('Y'));;
}
if (!$end) {
$end=time();
} else {
$end--;
}
if (!$user_id) {
$this->setError('No User_id');
return false;
}
//
// Task report
//
if (!$type || $type=='tasks') {
$res=db_query("SELECT pt.summary,sum(rtt.hours) AS hours
FROM rep_time_tracking rtt, project_task pt
WHERE rtt.user_id='$user_id'
AND rtt.report_date BETWEEN '$start' AND '$end'
AND rtt.project_task_id=pt.project_task_id
GROUP BY pt.summary
ORDER BY hours DESC");
//
// Category report
//
} elseif ($type=='category') {
$res=db_query("SELECT rtc.category_name, sum(rtt.hours) AS
hours
FROM rep_time_tracking rtt, rep_time_category rtc
WHERE rtt.user_id='$user_id'
AND rtt.report_date BETWEEN '$start' AND '$end'
AND rtt.time_code=rtc.time_code
GROUP BY rtc.category_name
ORDER BY hours DESC");
//
// Percentage this user spent on a specific subproject
//
} elseif ($type=='subproject') {
$res=db_query("SELECT pgl.project_name, sum(rtt.hours) AS hours
FROM rep_time_tracking rtt, project_task pt,
project_group_list pgl
WHERE rtt.user_id='$user_id'
AND rtt.report_date BETWEEN '$start' AND '$end'
AND rtt.project_task_id=pt.project_task_id
AND pt.group_project_id=pgl.group_project_id
GROUP BY pgl.project_name
ORDER BY hours DESC");
}
$this->start_date=$start;
$this->end_date=$end;
if (!$res || db_error()) {
$this->setError('ReportUserAct:: '.db_error());
return false;
}
$this->labels = util_result_column_to_array($res,0);
$this->setData($res,1);
return true;
}
}
?>
--- NEW FILE: report_utils.php ---
<?php
/**
* Reporting System
*
* Copyright 2004 (c) GForge LLC
*
* @version $Id: report_utils.php,v 1.1 2004/07/28 17:31:26 tperdue Exp $
* @author Tim Perdue address@hidden
* @date 2003-03-16
*
* This file is part of GForge.
*
* GForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
function report_header($title) {
global $HTML,$report_company_name,$sys_name;
echo $HTML->header(array('title'=>" Reporting: " . $title));
echo html_feedback_top($GLOBALS['feedback']);
echo "<h2>$report_company_name Reporting</h2><p>";
}
function report_footer() {
global $HTML;
echo html_feedback_bottom($GLOBALS['feedback']);
echo $HTML->footer(array());
}
function report_span_box($name='SPAN', $selected='1', $suppress_daily=false) {
if ($suppress_daily) {
$vals=array(2,3);
$titles=array('Weekly','Monthly');
} else {
$vals=array(1,2,3);
$titles=array('Daily','Weekly','Monthly');
}
return html_build_select_box_from_arrays
($vals,$titles,$name,$selected,false);
}
function report_weeks_box($Report, $name='week', $selected=false) {
global $sys_datefmt;
$arr =& $Report->getWeekStartArr();
$arr2=array();
for ($i=0; $i<count($arr); $i++) {
$arr2[$i]=date('Y-m-d',$arr[$i]) .' to '.
date('Y-m-d',($arr[$i]+6*24*60*60));
}
return html_build_select_box_from_arrays
($arr,$arr2,$name,$selected,false);
}
function report_day_adjust_box($Report, $name='days_adjust', $selected=false) {
$days[]='0.0';
$days[]='1';
$days[]='2';
$days[]='3';
$days[]='4';
$days[]='5';
$days[]='6';
$names[]='Sunday';
$names[]='Monday';
$names[]='Tuesday';
$names[]='Wednesday';
$names[]='Thursday';
$names[]='Friday';
$names[]='Saturday';
return html_build_select_box_from_arrays
($days,$names,$name,$selected,false);
// return html_build_select_box_from_arrays
(array_reverse(array_values($Report->adjust_days)),array_reverse(array_keys($Report->adjust_days)),$name,$selected,false);
}
function report_months_box($Report, $name='month', $selected=false) {
global $sys_datefmt;
$arr =& $Report->getMonthStartArr();
$arr2=array();
for ($i=0; $i<count($arr); $i++) {
$arr2[$i]=date('Y-m',$arr[$i]);
}
return html_build_select_box_from_arrays
($arr,$arr2,$name,$selected,false);
}
function report_useract_box($name='dev_id', $selected='1', $start_with='') {
if ($start_with) {
$sql2=" AND realname ILIKE '$start_with%' ";
}
$res=db_query("SELECT user_id,realname
FROM users
WHERE status='A' $sql2
AND (exists (SELECT user_id FROM rep_user_act_daily WHERE
user_id=users.user_id)) ORDER BY realname");
return html_build_select_box($res, $name, $selected, false);
}
function report_usertime_box($name='dev_id', $selected='1', $start_with='') {
if ($start_with) {
$sql2=" AND realname ILIKE '$start_with%' ";
}
$res=db_query("SELECT user_id,realname
FROM users
WHERE status='A' $sql2
AND (exists (SELECT user_id FROM rep_time_tracking WHERE
user_id=users.user_id)) ORDER BY realname");
return html_build_select_box($res, $name, $selected, false);
}
function report_group_box($name='g_id', $selected='1') {
$res=db_query("SELECT group_id,group_name FROM groups WHERE status='A'
ORDER BY group_name");
return html_build_select_box($res, $name, $selected, false);
}
function report_area_box($name='area', $selected='1') {
$arr[]='tracker';
$arr[]='forum';
$arr[]='docman';
$arr[]='taskman';
$arr[]='downloads';
$arr2[]='Tracker';
$arr2[]='Forum';
$arr2[]='Docman';
$arr2[]='Taskman';
$arr2[]='Downloads';
return html_build_select_box_from_arrays
($arr,$arr2,$name,$selected,false);
}
function report_tracker_box($name='datatype', $selected='1') {
$arr[]='Bugs';
$arr[]='Support';
$arr[]='Patches';
$arr[]='Feature Requests';
$arr[]='Other Trackers';
$arr[]='Forum Messages';
$arr[]='Tasks';
$arr[]='Downloads';
$arr2[]='1';
$arr2[]='2';
$arr2[]='3';
$arr2[]='4';
$arr2[]='0';
$arr2[]='5';
$arr2[]='6';
$arr2[]='7';
return html_build_select_box_from_arrays
($arr2,$arr,$name,$selected,false);
}
function report_time_category_box($name='category',$selected=false) {
global $report_time_category_res;
if (!$report_time_category_res) {
$report_time_category_res=db_query("SELECT * FROM
rep_time_category");
}
return
html_build_select_box($report_time_category_res,$name,$selected,false);
}
//
// Takes an array of labels and an array values and removes vals < 2% and
sets up an "other"
//
function report_pie_arr($labels, $vals) {
global $pie_labels,$pie_vals;
//first get sum of all values
for ($i=0; $i<count($vals); $i++) {
$total += $vals[$i];
}
//now prune out vals where < 2%
for ($i=0; $i<count($vals); $i++) {
if (($vals[$i]/$total) < .02) {
$rem += $vals[$i];
} else {
$pie_labels[]=util_unconvert_htmlspecialchars($labels[$i])." (".
number_format($vals[$i],1) .") ";
$pie_vals[]=number_format($vals[$i],1);
}
}
if ($rem > 0) {
$pie_labels[]='Other'." (". number_format($rem,1) .") ";
$pie_vals[]=number_format($rem,1);
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gforge-commits] gforge/common/reporting Report.class, NONE, 1.1 ReportProjectAct.class, NONE, 1.1 ReportProjectTime.class, NONE, 1.1 ReportSetup.class, NONE, 1.1 ReportSiteAct.class, NONE, 1.1 ReportSiteTime.class, NONE, 1.1 ReportTrackerAct.class, NONE, 1.1 ReportUserAct.class, NONE, 1.1 ReportUserAdded.class, NONE, 1.1 ReportUserCum.class, NONE, 1.1 ReportUserTime.class, NONE, 1.1 report_utils.php, NONE, 1.1,
tperdue <=
- Prev by Date:
[Gforge-commits] gforge/www/project/stats index.php, 1.4, 1.5 project_stats_utils.php, 1.5, NONE stats_graph.php, 1.5, NONE
- Next by Date:
[Gforge-commits] gforge/www/pm mod_task.php,1.13,1.14
- Previous by thread:
[Gforge-commits] gforge/www/project/stats index.php, 1.4, 1.5 project_stats_utils.php, 1.5, NONE stats_graph.php, 1.5, NONE
- Next by thread:
[Gforge-commits] gforge/www/pm mod_task.php,1.13,1.14
- Index(es):