Merge branch '230' into 'sprint/zentaopms230'
* Code for weekly. See merge request easycorp/zentaopms!4980
This commit is contained in:
Regular → Executable
+8
-12
@@ -1204,6 +1204,8 @@ class block extends control
|
||||
->andWhere('parent')->lt(1)
|
||||
->fetch();
|
||||
|
||||
$this->weekly->save($this->session->project, $date);
|
||||
|
||||
$this->view->pv = $this->weekly->getPV($this->session->project, $today);
|
||||
$this->view->ev = $this->weekly->getEV($this->session->project, $today);
|
||||
$this->view->ac = $this->weekly->getAC($this->session->project, $today);
|
||||
@@ -1299,23 +1301,17 @@ class block extends control
|
||||
$projectID = $this->session->project;
|
||||
$project = $this->loadModel('project')->getByID($projectID);
|
||||
|
||||
$begin = $project->begin;
|
||||
$today = helper::today();
|
||||
$end = date('Y-m-d', strtotime($today));
|
||||
$projectWeekly = $this->dao->select('*')->from(TABLE_WEEKLYREPORT)->where('project')->eq($projectID)->orderBy('weekStart_asc')->fetchAll('weekStart');
|
||||
|
||||
$charts['PV'] = '[';
|
||||
$charts['EV'] = '[';
|
||||
$charts['AC'] = '[';
|
||||
$i = 1;
|
||||
while($begin < $end)
|
||||
foreach($projectWeekly as $weekStart => $data)
|
||||
{
|
||||
$charts['labels'][] = $this->lang->block->time . $i . $this->lang->block->month;
|
||||
$charts['PV'] .= $this->weekly->getPV($projectID, $begin) . ',';
|
||||
$charts['EV'] .= $this->weekly->getEV($projectID, $begin) . ',';
|
||||
$charts['AC'] .= $this->weekly->getAC($projectID, $begin) . ',';
|
||||
$stageEnd = $this->weekly->getThisSunday($begin);
|
||||
$begin = date('Y-m-d', strtotime("$stageEnd + 30 day"));
|
||||
$i ++;
|
||||
$charts['labels'][] = $weekStart;
|
||||
$charts['PV'] .= $data->pv . ',';
|
||||
$charts['EV'] .= $data->ev . ',';
|
||||
$charts['AC'] .= $data->ac . ',';
|
||||
}
|
||||
|
||||
$charts['PV'] .= ']';
|
||||
|
||||
Regular → Executable
+2
-1
@@ -50,6 +50,8 @@ class weekly extends control
|
||||
if(!$date) $date = helper::today();
|
||||
$date = date('Y-m-d', strtotime($date));
|
||||
|
||||
$this->weekly->save($projectID, $date);
|
||||
|
||||
$this->view->title = $this->lang->weekly->common;
|
||||
|
||||
$this->view->pv = $this->weekly->getPV($projectID, $date);
|
||||
@@ -67,7 +69,6 @@ class weekly extends control
|
||||
$this->view->postponed = $this->weekly->getPostponed($projectID, $date);
|
||||
$this->view->nextWeek = $this->weekly->getTasksOfNextWeek($projectID, $date);
|
||||
$this->view->workload = $this->weekly->getWorkloadByType($projectID, $date);
|
||||
$this->weekly->save($projectID, $date);
|
||||
|
||||
$this->lang->modulePageNav = $this->weekly->getPageNav($this->view->project, $date);
|
||||
$this->display();
|
||||
|
||||
+16
-7
@@ -114,7 +114,11 @@ class weeklyModel extends model
|
||||
*/
|
||||
public function save($project, $date)
|
||||
{
|
||||
$this->dao->delete()->from(TABLE_WEEKLYREPORT)->where('project')->eq($project)->exec();
|
||||
$weekStart = $this->getThisMonday($date);
|
||||
$this->dao->delete()->from(TABLE_WEEKLYREPORT)
|
||||
->where('project')->eq($project)
|
||||
->andWhere('weekStart')->eq($weekStart)
|
||||
->exec();
|
||||
|
||||
$report = new stdclass;
|
||||
$report->pv = $this->getPV($project, $date);
|
||||
@@ -123,7 +127,7 @@ class weeklyModel extends model
|
||||
$report->sv = $this->getSV($report->ev, $report->pv);
|
||||
$report->cv = $this->getCV($report->ev, $report->ac);
|
||||
$report->project = $project;
|
||||
$report->weekStart = $this->getThisMonday($date);
|
||||
$report->weekStart = $weekStart;
|
||||
$report->staff = $this->getStaff($project);
|
||||
$report->workload = json_encode($this->getWorkloadByType($project, $date));
|
||||
$this->dao->replace(TABLE_WEEKLYREPORT)->data($report)->exec();
|
||||
@@ -378,9 +382,10 @@ class weeklyModel extends model
|
||||
|
||||
$tasks = $this->dao->select('*')->from(TABLE_TASK)
|
||||
->where('execution')->in($executionIdList)
|
||||
->andWhere("(estStarted < '$nextMonday' or estStarted='0000-00-00')")
|
||||
->andWhere("parent")->ge(0)
|
||||
->andWhere("deleted")->eq(0)
|
||||
->andWhere("estStarted")->ge($monday)
|
||||
->andWhere("estStarted")->lt($nextMonday)
|
||||
->fetchAll('id');
|
||||
|
||||
$PV = 0;
|
||||
@@ -400,7 +405,7 @@ class weeklyModel extends model
|
||||
$PV += count($passedDays) * $task->estimate / count($fullDays);
|
||||
}
|
||||
|
||||
return round($PV, 2);
|
||||
return sprintf("%.2f",$PV);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -429,7 +434,8 @@ class weeklyModel extends model
|
||||
->from(TABLE_TASK)
|
||||
->where('execution')->in($executionIdList)
|
||||
->andWhere('consumed')->gt(0)
|
||||
->andWhere("(estStarted < '$nextMonday' or estStarted='0000-00-00')")
|
||||
->andWhere("estStarted")->ge($monday)
|
||||
->andWhere("estStarted")->lt($nextMonday)
|
||||
->andWhere("parent")->ge(0)
|
||||
->andWhere("deleted")->eq(0)
|
||||
->andWhere('status')->ne('cancel')
|
||||
@@ -448,7 +454,8 @@ class weeklyModel extends model
|
||||
$EV += $task->estimate * $task->progress / 100;
|
||||
}
|
||||
}
|
||||
return round($EV, 2);
|
||||
|
||||
return sprintf("%.2f", $EV);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -483,6 +490,7 @@ class weeklyModel extends model
|
||||
->where('objectType')->eq('task')
|
||||
->andWhere('objectID')->in($taskIdList)
|
||||
->andWhere('execution')->in($executionIdList)
|
||||
->andWhere('date')->ge($monday)
|
||||
->andWhere('date')->lt($nextMonday)
|
||||
->fetch('consumed');
|
||||
}
|
||||
@@ -491,11 +499,12 @@ class weeklyModel extends model
|
||||
$AC = $this->dao->select('sum(consumed) as consumed')
|
||||
->from(TABLE_TASKESTIMATE)
|
||||
->where('task')->in($taskIdList)
|
||||
->andWhere('date')->ge($monday)
|
||||
->andWhere('date')->lt($nextMonday)
|
||||
->fetch('consumed');
|
||||
}
|
||||
|
||||
return round($AC, 2);
|
||||
return sprintf("%.2f", $AC);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user