diff --git a/db/update17.6.sql b/db/update17.6.sql
index 1d60b73fd5..9d9d37cf92 100644
--- a/db/update17.6.sql
+++ b/db/update17.6.sql
@@ -13,3 +13,4 @@ CREATE TABLE `zt_taskteam` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `zt_taskestimate` ADD `order` tinyint unsigned NULL DEFAULT '0';
ALTER TABLE `zt_effort` ADD `order` tinyint unsigned NOT NULL DEFAULT '0' AFTER `end`;
+ALTER TABLE `zt_block` CHANGE `block` `block` varchar(30) COLLATE 'utf8_general_ci' NOT NULL AFTER `source`;
diff --git a/db/zentao.sql b/db/zentao.sql
index 8ed0a0d092..9cc580a01d 100755
--- a/db/zentao.sql
+++ b/db/zentao.sql
@@ -218,7 +218,7 @@ CREATE TABLE IF NOT EXISTS `zt_block` (
`type` char(30) NOT NULL,
`title` varchar(100) NOT NULL,
`source` varchar(20) NOT NULL,
- `block` varchar(20) NOT NULL,
+ `block` varchar(30) NOT NULL,
`params` text NOT NULL,
`order` tinyint(3) unsigned NOT NULL DEFAULT '0',
`grid` tinyint(3) unsigned NOT NULL DEFAULT '0',
diff --git a/module/block/control.php b/module/block/control.php
index c078c7a1bc..94d29d0eb6 100755
--- a/module/block/control.php
+++ b/module/block/control.php
@@ -935,8 +935,9 @@ class block extends control
$current = zget($weeks, $monday, '');
$current = substr($current, 0, -11) . substr($current, -6);
- $project->pv = $this->weekly->getPV($projectID, $today);
- $project->ev = $this->weekly->getEV($projectID, $today);
+ $PVEV = $this->weekly->getPVEV($projectID, $today);
+ $project->pv = $PVEV['PV'];
+ $project->ev = $PVEV['EV'];
$project->ac = $this->weekly->getAC($projectID, $today);
$project->sv = $this->weekly->getSV($project->ev, $project->pv);
$project->cv = $this->weekly->getCV($project->ev, $project->ac);
@@ -1200,8 +1201,9 @@ class block extends control
$this->weekly->save($this->session->project, $date);
- $this->view->pv = (float)$this->weekly->getPV($this->session->project, $today);
- $this->view->ev = (float)$this->weekly->getEV($this->session->project, $today);
+ $PVEV = $this->weekly->getPVEV($this->session->project, $today);
+ $this->view->pv = (float)$PVEV['PV'];
+ $this->view->ev = (float)$PVEV['EV'];
$this->view->ac = (float)$this->weekly->getAC($this->session->project, $today);
$this->view->sv = $this->weekly->getSV($this->view->ev, $this->view->pv);
$this->view->cv = $this->weekly->getCV($this->view->ev, $this->view->ac);
@@ -1210,6 +1212,28 @@ class block extends control
$this->view->progress = !empty($this->view->pv) ? floor($this->view->ac / $this->view->pv * 1000) / 1000 * 100 : 0;
}
+ /**
+ * Print waterfall general report block.
+ *
+ * @access public
+ * @return void
+ */
+ public function printWaterfallGeneralReportBlock()
+ {
+ $this->loadModel('programplan');
+ $this->loadModel('project');
+ $this->loadModel('weekly');
+
+ $PVEV = $this->project->getWaterfallPVEV($this->session->project);
+ $this->view->pv = (float)$PVEV['PV'];
+ $this->view->ev = (float)$PVEV['EV'];
+ $this->view->ac = (float)$this->project->getWaterfallAC($this->session->project);
+ $this->view->sv = $this->weekly->getSV($this->view->ev, $this->view->pv);
+ $this->view->cv = $this->weekly->getCV($this->view->ev, $this->view->ac);
+
+ $this->view->progress = !empty($this->view->pv) ? floor($this->view->ac / $this->view->pv * 1000) / 1000 * 100 : 0;
+ }
+
/**
* Print waterfall gantt block.
*
diff --git a/module/block/model.php b/module/block/model.php
index 3086c24bfb..97d52b15b3 100644
--- a/module/block/model.php
+++ b/module/block/model.php
@@ -656,18 +656,29 @@ class blockModel extends model
* Get waterfall project report pararms.
*
* @access public
- * @return string
+ * @return bool
*/
public function getWaterfallReportParams()
{
return false;
}
+ /**
+ * Get waterfall general report params.
+ *
+ * @access public
+ * @return bool
+ */
+ public function getWaterfallGeneralReportParams()
+ {
+ return false;
+ }
+
/**
* Get project estimate pararms.
*
* @access public
- * @return string
+ * @return bool
*/
public function getWaterfallEstimateParams()
{
diff --git a/module/block/view/waterfallgeneralreportblock.html.php b/module/block/view/waterfallgeneralreportblock.html.php
new file mode 100644
index 0000000000..4989d3373f
--- /dev/null
+++ b/module/block/view/waterfallgeneralreportblock.html.php
@@ -0,0 +1,54 @@
+
+
+
+
+
+
project->progress;?>
+
+
+
+
+
+
+
programplan->end . ')';?>
+
+
+
+
programplan->realEnd . ')';?>
+
+
+
+
programplan->ac . ')';?>
+
+
+
+
programplan->sv . ')';?>
+
+
+
+
programplan->cv . ')';?>
+
+
+
+
+
+
diff --git a/module/project/model.php b/module/project/model.php
index 33ff71ccf4..733c154410 100644
--- a/module/project/model.php
+++ b/module/project/model.php
@@ -415,6 +415,55 @@ class projectModel extends model
return is_numeric($projectIDList) ? (empty($progressList) ? 0 : $progressList[$projectIDList]) : $progressList;
}
+ /**
+ * Get waterfall general PV and EV.
+ *
+ * @param int $projectID
+ * @access public
+ * @return array
+ */
+ public function getWaterfallPVEV($projectID)
+ {
+ $executions = $this->dao->select('id,begin,end,realEnd,status')->from(TABLE_EXECUTION)->where('deleted')->eq(0)->andWhere('vision')->eq($this->config->vision)->andWhere('project')->eq($projectID)->fetchAll('id');
+ $stmt = $this->dao->select('id,status,estimate,consumed,`left`,closedReason')->from(TABLE_TASK)->where('execution')->in(array_keys($executions))->andWhere("parent")->ge(0)->andWhere("deleted")->eq(0)->query();
+
+ $PV = 0;
+ $EV = 0;
+ while($task = $stmt->fetch())
+ {
+ $PV += $task->estimate;
+ if($task->status == 'done' or $task->closedReason == 'done')
+ {
+ $EV += $this->estimate;
+ }
+ else
+ {
+ $task->progress = round($task->consumed / ($task->consumed + $task->left), 2) * 100;
+ $EV += round($task->estimate * $task->progress / 100, 2);
+ }
+ }
+
+ return array('PV' => sprintf("%.2f", $PV), 'EV' => sprintf("%.2f", $EV));
+ }
+
+ /**
+ * Get waterfall general AC
+ *
+ * @param int $projectID
+ * @access public
+ * @return string
+ */
+ public function getWaterfallAC($projectID)
+ {
+ $executions = $this->dao->select('id,begin,end,realEnd,status')->from(TABLE_EXECUTION)->where('deleted')->eq(0)->andWhere('vision')->eq($this->config->vision)->andWhere('project')->eq($projectID)->fetchAll('id');
+ $taskIdList = $this->dao->select('id')->from(TABLE_TASK)->where('execution')->in(array_keys($executions))->andWhere("parent")->ge(0)->andWhere("deleted")->eq(0)->fetchPairs('id', 'id');
+
+ $AC = $this->dao->select('sum(consumed) as consumed')->from(TABLE_EFFORT)->where('objectType')->eq('task')->andWhere('objectID')->in($taskIdList)->andWhere('deleted')->eq('0')->fetch('consumed');
+ if(is_null($AC)) $AC = 0;
+
+ return sprintf("%.2f", $AC);
+ }
+
/**
* Get project workhour info.
*
diff --git a/module/weekly/control.php b/module/weekly/control.php
index 9407cece01..1222aaf804 100755
--- a/module/weekly/control.php
+++ b/module/weekly/control.php
@@ -54,8 +54,9 @@ class weekly extends control
$this->view->title = $this->lang->weekly->common;
- $this->view->pv = $this->weekly->getPV($projectID, $date);
- $this->view->ev = $this->weekly->getEV($projectID, $date);
+ $PVEV = $this->weekly->getPVEV($projectID, $date);
+ $this->view->pv = $PVEV['PV'];
+ $this->view->ev = $PVEV['EV'];
$this->view->ac = $this->weekly->getAC($projectID, $date);
$this->view->sv = $this->weekly->getSV($this->view->ev, $this->view->pv);
$this->view->cv = $this->weekly->getCV($this->view->ev, $this->view->ac);
diff --git a/module/weekly/model.php b/module/weekly/model.php
index 4610cdb712..3eeb0de923 100755
--- a/module/weekly/model.php
+++ b/module/weekly/model.php
@@ -121,8 +121,9 @@ class weeklyModel extends model
->exec();
$report = new stdclass;
- $report->pv = $this->getPV($project, $date);
- $report->ev = $this->getEV($project, $date);
+ $PVEV = $this->getPVEV($project, $date);
+ $report->pv = $PVEV['PV'];
+ $report->ev = $PVEV['EV'];
$report->ac = $this->getAC($project, $date);
$report->sv = $this->getSV($report->ev, $report->pv);
$report->cv = $this->getCV($report->ev, $report->ac);
@@ -369,17 +370,17 @@ class weeklyModel extends model
}
/**
- * GetPV
+ * Get PV and EV
*
* @param int $project
* @param string $date
* @access public
- * @return int
+ * @return array
*/
- public function getPV($projectID, $date = '')
+ public function getPVEV($projectID, $date = '')
{
$report = $this->getFromDB($projectID, $date);
- if(!empty($report)) return $report->pv;
+ if(!empty($report)) return array('PV' => $report->pv, 'EV' => $report->ev);
if(!$date) $date = date('Y-m-d');
$monday = $this->getThisMonday($date);
@@ -397,6 +398,8 @@ class weeklyModel extends model
->fetchAll('id');
$PV = 0;
+ $EV = 0;
+ $this->loadModel('holiday');
foreach($tasks as $task)
{
if(helper::isZeroDate($task->estStarted)) $task->estStarted = date('Y-m-d', strtotime($task->openedDate));
@@ -407,74 +410,36 @@ class weeklyModel extends model
if(helper::isZeroDate($task->finishedDate)) $task->deadline = date('Y-m-d', strtotime($task->finishedDate));
}
- $fullDays = $this->loadModel('holiday')->getActualWorkingDays($task->estStarted, $task->deadline);
+ $fullDays = $this->holiday->getActualWorkingDays($task->estStarted, $task->deadline);
if($task->estStarted < $monday and $task->deadline >= $nextMonday)
{
$weekActualDays = $workdays;
}
elseif($task->estStarted >= $monday and $task->estStarted < $nextMonday)
{
- $weekActualDays = $this->loadModel('holiday')->getActualWorkingDays($task->estStarted, $task->deadline >= $nextMonday ? $sunday : $task->deadline);
+ $weekActualDays = $this->holiday->getActualWorkingDays($task->estStarted, $task->deadline >= $nextMonday ? $sunday : $task->deadline);
}
elseif($task->deadline >= $monday and $task->deadline < $nextMonday)
{
- $weekActualDays = $this->loadModel('holiday')->getActualWorkingDays($monday, $task->deadline);
+ $weekActualDays = $this->holiday->getActualWorkingDays($monday, $task->deadline);
}
if(empty($fullDays) or empty($weekActualDays) or empty($task->estimate)) continue;
- $PV += round(count($weekActualDays) / count($fullDays) * $task->estimate, 2);
- }
+ $thisPV = round(count($weekActualDays) / count($fullDays) * $task->estimate, 2);
- return sprintf("%.2f",$PV);
- }
-
- /**
- * Get EV data.
- *
- * @param int $projectID
- * @param string $date
- * @access public
- * @return int
- */
- public function getEV($projectID, $date = '')
- {
- $report = $this->getFromDB($projectID, $date);
- if(!empty($report)) return $report->ev;
-
- $executions = $this->loadModel('execution')->getList($projectID);
- $executionIdList = array_keys($executions);
-
- if(!$date) $date = date('Y-m-d');
- $monday = $this->getThisMonday($date);
- $sunday = $this->getThisSunday($date);
- $lastDay = $this->getLastDay($date);
- $nextMonday = date('Y-m-d', strtotime($sunday) + 24 * 3600);
-
- $tasks = $this->dao->select('*')
- ->from(TABLE_TASK)
- ->where('execution')->in($executionIdList)
- ->andWhere('consumed')->gt(0)
- ->andWhere("((estStarted >= '$monday' AND estStarted < '$nextMonday') OR (deadline >= '$monday' AND deadline < '$nextMonday') OR (estStarted < '$monday' AND deadline > '$nextMonday'))")
- ->andWhere("parent")->ge(0)
- ->andWhere("deleted")->eq(0)
- ->andWhere('status')->ne('cancel')
- ->query();
-
- $EV = 0;
- foreach($tasks as $task)
- {
if($task->status == 'done' or $task->closedReason == 'done')
{
- $EV += $task->estimate;
+ $EV += $thisPV;
}
else
{
$task->progress = round($task->consumed / ($task->consumed + $task->left), 2) * 100;
- $EV += $task->estimate * $task->progress / 100;
+ $EV += round($thisPV * $task->progress / 100, 2);
}
+ $PV += $thisPV;
}
- return sprintf("%.2f", $EV);
+ return array('PV' => sprintf("%.2f", $PV), 'EV' => sprintf("%.2f", $EV));
}
/**
@@ -492,15 +457,10 @@ class weeklyModel extends model
if(!$date) $date = date('Y-m-d');
- $monday = $this->getThisMonday($date);
- $nextMonday = date('Y-m-d', strtotime($monday) + (7 * 24 * 3600));
- $executions = $this->dao->select('id,begin,end,realEnd,status')->from(TABLE_EXECUTION)->where('deleted')->eq(0)->andWhere('vision')->eq($this->config->vision)->andWhere('project')->eq($project)->fetchAll('id');
- $executionIdList = array_keys($executions);
- $taskIdList = $this->dao->select('id')->from(TABLE_TASK)
- ->where('execution')->in($executionIdList)
- ->andWhere("parent")->ge(0)
- ->andWhere("deleted")->eq(0)
- ->fetchPairs();
+ $monday = $this->getThisMonday($date);
+ $nextMonday = date('Y-m-d', strtotime($monday) + (7 * 24 * 3600));
+ $executions = $this->dao->select('id,begin,end,realEnd,status')->from(TABLE_EXECUTION)->where('deleted')->eq(0)->andWhere('vision')->eq($this->config->vision)->andWhere('project')->eq($project)->fetchAll('id');
+ $taskIdList = $this->dao->select('id')->from(TABLE_TASK)->where('execution')->in(array_keys($executions))->andWhere("parent")->ge(0)->andWhere("deleted")->eq(0)->fetchPairs();
$AC = $this->dao->select('sum(consumed) as consumed')
->from(TABLE_EFFORT)