* finish task #68203.

This commit is contained in:
wangyidong
2022-09-07 11:08:48 +08:00
parent 72dad72c13
commit a8a703bf16
4 changed files with 47 additions and 42 deletions
+2 -1
View File
@@ -68,7 +68,7 @@ class storiesEntry extends entry
if(!$productID and isset($this->requestBody->product)) $productID = $this->requestBody->product;
if(!$productID) return $this->sendError(400, 'Need product id.');
$fields = 'title,spec,verify,reviewer,type,parent,plan,module,moduleOptionMenu,source,sourceNote,category,pri,estimate,mailto,keywords,notifyemail,uid,URS';
$fields = 'title,spec,verify,reviewer,type,parent,plan,module,moduleOptionMenu,source,sourceNote,category,pri,estimate,mailto,keywords,notifyemail,uid,URS,status';
$this->batchSetPost($fields);
/* If reviewer is not post, set needNotReview. */
@@ -76,6 +76,7 @@ class storiesEntry extends entry
if(empty($reviewer)) $this->setPost('needNotReview', 1);
$this->setPost('product', $productID);
$this->setPost('type', $this->param('type', 'story'));
$this->setPost('status', $this->param('status', 'draft'));
$control = $this->loadController('story', 'create');
$this->requireFields('title,spec,pri,category');
-8
View File
@@ -1198,14 +1198,6 @@ class block extends control
$weeks = $this->loadModel('weekly')->getWeekPairs($begin);
$current = zget($weeks, $date, '');
$task = $this->dao->select("
sum(consumed) as totalConsumed,
sum(if(status != 'cancel' and status != 'closed', `left`, 0)) as totalLeft")
->from(TABLE_TASK)->where('project')->eq($this->session->project)
->andWhere('deleted')->eq(0)
->andWhere('parent')->lt(1)
->fetch();
$this->weekly->save($this->session->project, $date);
$this->view->pv = (float)$this->weekly->getPV($this->session->project, $today);
+1 -1
View File
@@ -2911,7 +2911,7 @@ EOD;
$this->loadModel('action')->create('user', $user->id, 'login');
$this->loadModel('score')->create('user', 'login');
if($isFreepasswd) return print(js::locate($this->config->webRoot));
if($isFreepasswd) die(js::locate($this->config->webRoot));
$this->session->set('ENTRY_CODE', $this->get->code);
$this->session->set('VALID_ENTRY', md5(md5($this->get->code) . helper::getRemoteIp()));
+44 -32
View File
@@ -155,10 +155,12 @@ class weeklyModel extends model
*/
public function getThisMonday($date)
{
$day = date('w', strtotime($date));
$timestamp = strtotime($date);
$day = date('w', $timestamp);
if($day == 0) $day = 7;
$days = $day - 1;
return date('Y-m-d', strtotime("$date - $days days"));
return date('Y-m-d', $timestamp - (($day - 1) * 24 * 3600));
}
/**
@@ -171,7 +173,7 @@ class weeklyModel extends model
public function getThisSunday($date)
{
$monday = $this->getThisMonday($date);
return date('Y-m-d', strtotime("$monday +6 days"));
return date('Y-m-d', strtotime($monday) + (6 * 24 * 3600));
}
/**
@@ -237,7 +239,7 @@ class weeklyModel extends model
$tasks = $this->dao->select('*')
->from(TABLE_TASK)
->where('execution')->in($executionIdList)
->andWhere("(status='done' or closedReason= 'done')")
->andWhere("(status = 'done' or closedReason = 'done')")
->andWhere('finishedDate')->ge($monday)
->andWhere('finishedDate')->le($sunday)
->andWhere('deleted')->eq(0)
@@ -258,7 +260,7 @@ class weeklyModel extends model
if(!$date) $date = date('Y-m-d');
$monday = $this->getThisMonday($date);
$sunday = $this->getThisSunday($date);
$nextMonday = date('Y-m-d', strtotime("$sunday +1 days"));
$nextMonday = date('Y-m-d', strtotime($sunday) + 24 * 3600);
$executions = $this->loadModel('execution')->getList($project, 'all', $status = 'all', $limit = 0, $productID = 0, $branch = 0);
$executionIdList = array_keys($executions);
@@ -296,8 +298,9 @@ class weeklyModel extends model
{
if(!$date) $date = date('Y-m-d');
$sunday = $this->getThisSunday($date);
$nextMonday = date('Y-m-d', strtotime("$sunday +1 days"));
$sencondMondy = date('Y-m-d', strtotime("$sunday +8 days"));
$timestamp = strtotime($sunday);
$nextMonday = date('Y-m-d', $timestamp + 24 * 3600);
$sencondMondy = date('Y-m-d', $timestamp + (8 * 24 * 3600));
$executions = $this->loadModel('execution')->getList($project, 'all', $status = 'all', $limit = 0, $productID = 0, $branch = 0);
$executionIdList = array_keys($executions);
@@ -305,7 +308,7 @@ class weeklyModel extends model
$tasks = $this->dao->select('*')
->from(TABLE_TASK)
->where('execution')->in($executionIdList)
->andWhere("((deadline > '$nextMonday' and deadline < '$sencondMondy') or (estStarted > '$nextMonday' and estStarted < '$sencondMondy'))")
->andWhere("((deadline >= '$nextMonday' and deadline < '$sencondMondy') or (estStarted >= '$nextMonday' and estStarted < '$sencondMondy') or (estStarted < '$nextMonday' and deadline > '$sencondMondy'))")
->andWhere('deleted')->eq(0)
->fetchAll('id');
@@ -325,8 +328,9 @@ class weeklyModel extends model
if(!$date) $date = date('Y-m-d');
$sunday = $this->getThisSunday($date);
$nextMonday = date('Y-m-d', strtotime("$sunday +1 days"));
$sencondMondy = date('Y-m-d', strtotime("$sunday +8 days"));
$timestamp = strtotime($sunday);
$nextMonday = date('Y-m-d', $timestamp + 24 * 3600);
$sencondMondy = date('Y-m-d', $timestamp + (8 * 24 * 3600));
$executions = $this->loadModel('execution')->getList($project, 'all', $status = 'all', $limit = 0, $productID = 0, $branch = 0);
$executionIdList = array_keys($executions);
@@ -351,7 +355,7 @@ class weeklyModel extends model
{
if(!$date) $date = date('Y-m-d');
$monday = $this->getThisMonday($date);
$nextMonday = date('Y-m-d', strtotime("$monday +7 days"));
$nextMonday = date('Y-m-d', strtotime($monday) + (7 * 24 * 3600));
$executions = $this->loadModel('execution')->getList($project);
$executionIdList = array_keys($executions);
@@ -381,14 +385,12 @@ class weeklyModel extends model
$monday = $this->getThisMonday($date);
$sunday = $this->getThisSunday($date);
$lastDay = $this->getLastDay($date);
$nextMonday = date('Y-m-d', strtotime("$sunday +1 days"));
$nextMonday = date('Y-m-d', strtotime($sunday) + 24 * 3600);
$workdays = $this->loadModel('holiday')->getActualWorkingDays($monday, $sunday);
$executions = $this->loadModel('execution')->getList($projectID);
$executionIdList = array_keys($executions);
$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');
$tasks = $this->dao->select('*')->from(TABLE_TASK)
->where('execution')->in($executionIdList)
->where('execution')->in(array_keys($executions))
->andWhere("parent")->ge(0)
->andWhere("deleted")->eq(0)
->andWhere("((estStarted >= '$monday' AND estStarted < '$nextMonday') OR (deadline >= '$monday' AND deadline < '$nextMonday') OR (estStarted < '$monday' AND deadline > '$nextMonday'))")
@@ -397,18 +399,30 @@ class weeklyModel extends model
$PV = 0;
foreach($tasks as $task)
{
if($task->estStarted == '0000-00-00') $task->estStarted = date('Y-m-d', strtotime($task->openedDate));
if($task->deadline < $nextMonday)
if(helper::isZeroDate($task->estStarted)) $task->estStarted = date('Y-m-d', strtotime($task->openedDate));
if(helper::isZeroDate($task->deadline))
{
$PV += $task->estimate;
continue;
$execution = $executions[$task->execution];
$task->deadline = helper::isZeroDate($execution->realEnd) ? $execution->end : $execution->realEnd;
if(helper::isZeroDate($task->finishedDate)) $task->deadline = date('Y-m-d', strtotime($task->finishedDate));
}
$fullDays = $this->loadModel('holiday')->getActualWorkingDays($task->estStarted, $task->deadline);
$passedDays = $this->loadModel('holiday')->getActualWorkingDays($task->estStarted, $sunday);
$fullDays = $this->loadModel('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);
}
elseif($task->deadline >= $monday and $task->deadline < $nextMonday)
{
$weekActualDays = $this->loadModel('holiday')->getActualWorkingDays($monday, $task->deadline);
}
if(empty($fullDays) or empty($passedDays) or empty($task->estimate)) continue;
$PV += count($passedDays) * $task->estimate / count($fullDays);
if(empty($fullDays) or empty($weekActualDays) or empty($task->estimate)) continue;
$PV += round(count($weekActualDays) / count($fullDays) * $task->estimate, 2);
}
return sprintf("%.2f",$PV);
@@ -434,18 +448,17 @@ class weeklyModel extends model
$monday = $this->getThisMonday($date);
$sunday = $this->getThisSunday($date);
$lastDay = $this->getLastDay($date);
$nextMonday = date('Y-m-d', strtotime("$sunday +1 days"));
$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")->ge($monday)
->andWhere("estStarted")->lt($nextMonday)
->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')
->fetchAll('id');
->query();
$EV = 0;
foreach($tasks as $task)
@@ -480,8 +493,8 @@ class weeklyModel extends model
if(!$date) $date = date('Y-m-d');
$monday = $this->getThisMonday($date);
$nextMonday = date('Y-m-d', strtotime("$monday +7 days"));
$executions = $this->loadModel('execution')->getList($project, 'all', 'all', 0, 0, 0);
$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($projectID)->fetchAll('id');
$executionIdList = array_keys($executions);
$taskIdList = $this->dao->select('id')->from(TABLE_TASK)
->where('execution')->in($executionIdList)
@@ -493,7 +506,6 @@ class weeklyModel extends model
->from(TABLE_EFFORT)
->where('objectType')->eq('task')
->andWhere('objectID')->in($taskIdList)
->andWhere('execution')->in($executionIdList)
->andWhere('date')->ge($monday)
->andWhere('date')->lt($nextMonday)
->andWhere('deleted')->eq('0')