From 987bb95ce8cb7c25120ac02e5161f17c10dcfe86 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Mon, 14 Feb 2022 09:04:01 +0800 Subject: [PATCH] * finish task #49091. --- extension/lite/user/ext/model/lite.php | 106 ++++++++++++++++++ .../lite/user/ext/view/execution.html.php | 63 +++++++++++ 2 files changed, 169 insertions(+) create mode 100644 extension/lite/user/ext/model/lite.php create mode 100644 extension/lite/user/ext/view/execution.html.php diff --git a/extension/lite/user/ext/model/lite.php b/extension/lite/user/ext/model/lite.php new file mode 100644 index 0000000000..8f74ddca58 --- /dev/null +++ b/extension/lite/user/ext/model/lite.php @@ -0,0 +1,106 @@ +dao->select('t1.*,t2.*')->from(TABLE_TEAM)->alias('t1') + ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.root = t2.id') + ->where('t1.type')->eq($type) + ->andWhere('t2.type')->in($objectType) + ->beginIF(strpos('doing|wait|suspended|closed', $status) !== false)->andWhere('status')->eq($status)->fi() + ->beginIF($status == 'done')->andWhere('status')->in('done,closed')->fi() + ->beginIF($status == 'undone')->andWhere('status')->notin('done,closed')->fi() + ->beginIF($status == 'openedbyme')->andWhere('openedBy')->eq($account)->fi() + ->beginIF($type == 'execution' and !$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->sprints)->fi() + ->beginIF($type == 'project' and !$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->projects)->fi() + ->andWhere('t1.account')->eq($account) + ->andWhere('t2.deleted')->eq(0) + ->andWhere('t2.vision')->eq($this->config->vision) + ->orderBy("t2.$orderBy") + ->page($pager) + ->fetchAll('root'); + + $objectIdList = array(); + $projectIdList = array(); + foreach($myObjectsList as $object) + { + $objectIdList[] = $object->id; + $projectIdList[] = $object->project; + } + + /* Get all tasks and compute totalConsumed, totalLeft, totalWait, progress according to them. */ + $hours = array(); + $emptyHour = array('totalConsumed' => 0, 'totalLeft' => 0, 'progress' => 0, 'waitTasks' => 0, 'assignedToMeTasks' => 0, 'doneTasks' => 0, 'taskTotal' => 0); + $searchField = $type == 'project' ? 'project' : 'execution'; + $tasks = $this->dao->select('id, project, execution, consumed, `left`, status, assignedTo,finishedBy') + ->from(TABLE_TASK) + ->where('parent')->lt(1) + ->andWhere($searchField)->in($objectIdList)->fi() + ->andWhere('deleted')->eq(0) + ->fetchGroup($searchField, 'id'); + + /* Compute totalEstimate, totalConsumed, totalLeft. */ + foreach($tasks as $objectID => $objectTasks) + { + $hour = (object)$emptyHour; + $hour->taskTotal = count($objectTasks); + foreach($objectTasks as $task) + { + if($task->status == 'wait') $hour->waitTasks += 1; + if($task->finishedBy != '') $hour->doneTasks += 1; + if($task->status != 'cancel') $hour->totalConsumed += $task->consumed; + if($task->status != 'cancel' and $task->status != 'closed') $hour->totalLeft += $task->left; + if($task->assignedTo == $account) $hour->assignedToMeTasks += 1; + } + $hours[$objectID] = $hour; + } + + /* Compute totalReal and progress. */ + foreach($hours as $hour) + { + $hour->totalConsumed = round($hour->totalConsumed, 1); + $hour->totalLeft = round($hour->totalLeft, 1); + $hour->totalReal = $hour->totalConsumed + $hour->totalLeft; + $hour->progress = $hour->totalReal ? round($hour->totalConsumed / $hour->totalReal, 2) * 100 : 0; + } + + $myObjects = array(); + $projectList = $this->loadModel('project')->getByIdList($projectIdList); + foreach($myObjectsList as $object) + { + /* Judge whether the project or execution is delayed. */ + if($object->status != 'done' and $object->status != 'closed' and $object->status != 'suspended') + { + $delay = helper::diffDate(helper::today(), $object->end); + if($delay > 0) $object->delay = $delay; + } + + /* Process the hours. */ + $object->progress = isset($hours[$object->id]) ? $hours[$object->id]->progress : 0; + $object->waitTasks = isset($hours[$object->id]) ? $hours[$object->id]->waitTasks : 0; + $object->doneTasks = isset($hours[$object->id]) ? $hours[$object->id]->doneTasks : 0; + $object->taskTotal = isset($hours[$object->id]) ? $hours[$object->id]->taskTotal : 0; + $object->totalConsumed = isset($hours[$object->id]) ? $hours[$object->id]->totalConsumed : 0; + $object->assignedToMeTasks = isset($hours[$object->id]) ? $hours[$object->id]->assignedToMeTasks : 0; + + if($object->project) + { + $parentProject = zget($projectList, $object->project, ''); + $object->projectName = $parentProject ? $parentProject->name : ''; + } + $myObjects[$object->id] = $object; + } + + return $myObjects; +} + diff --git a/extension/lite/user/ext/view/execution.html.php b/extension/lite/user/ext/view/execution.html.php new file mode 100644 index 0000000000..6b6c8d08f8 --- /dev/null +++ b/extension/lite/user/ext/view/execution.html.php @@ -0,0 +1,63 @@ + + * @package dashboard + * @version $Id: project.html.php 4129 2013-01-18 01:58:14Z wwccss $ + * @link http://www.zentao.net + */ +?> +app->getModuleRoot() . 'common/view/header.html.php';?> +app->getModuleRoot() . 'common/view/tablesorter.html.php';?> +app->getModuleRoot() . 'user/view/featurebar.html.php';?> +
+
+ + id}&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}"; ?> + + + + + + + + + + + + + + + createLink('execution', 'view', "executionID=$execution->id");?> + config->vision == 'lite') $executionLink = $this->createLink('execution', 'kanban', "kanbanID=$execution->id");?> + + + + delay)):?> + + + + + + + + + + + + +
idAB);?>user->name);?> statusAB);?> team->role;?> execution->begin);?> execution->end);?> team->join;?> team->hours;?>
id);?> + maxVersion)):?> + user->executionTypeList, $execution->type);?> + + name);?> + execution->delayed;?>processStatus('execution', $execution);?>role;?>begin;?>end;?>join;?>hours;?>
+ + + +
+
+app->getModuleRoot() . 'common/view/footer.html.php';?>