From 3a8564cbcb20c1c1ede3a4e6f2d6fca5376d3538 Mon Sep 17 00:00:00 2001 From: chencongzhi520 Date: Tue, 22 Jun 2010 05:56:24 +0000 Subject: [PATCH] * change onCaseOf/endCase into beginIF/endIF --- module/action/model.php | 2 +- module/bug/model.php | 2 +- module/dept/model.php | 4 +- module/product/model.php | 2 +- module/project/model.php | 4 +- module/story/model.php | 16 +- module/task/model.php | 518 +++++++++++++++++++------------------- module/testcase/model.php | 2 +- module/todo/model.php | 4 +- module/tree/model.php | 2 +- module/user/model.php | 4 +- 11 files changed, 280 insertions(+), 280 deletions(-) diff --git a/module/action/model.php b/module/action/model.php index 7a1435c63b..2d9cff9120 100644 --- a/module/action/model.php +++ b/module/action/model.php @@ -167,7 +167,7 @@ class actionModel extends model public function getDynamic($objectType = 'all', $count = 30) { $actions = $this->dao->select('*')->from(TABLE_ACTION) - ->onCaseOf($objectType != 'all')->where('objectType')->eq($objectType)->endCase() + ->beginIF($objectType != 'all')->where('objectType')->eq($objectType)->endIF() ->orderBy('id desc')->limit($count)->fetchAll(); if(!$actions) return array(); foreach($actions as $action) diff --git a/module/bug/model.php b/module/bug/model.php index 02ceff5b3d..6e4eb75307 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -66,7 +66,7 @@ class bugModel extends model { return $this->dao->select('*')->from(TABLE_BUG) ->where('product')->eq((int)$productID) - ->onCaseOf(!empty($moduleIds))->andWhere('module')->in($moduleIds)->endCase() + ->beginIF(!empty($moduleIds))->andWhere('module')->in($moduleIds)->endIF() ->andWhere('deleted')->eq(0) ->orderBy($orderBy)->page($pager)->fetchAll(); } diff --git a/module/dept/model.php b/module/dept/model.php index f13d746437..d9c194dd15 100644 --- a/module/dept/model.php +++ b/module/dept/model.php @@ -37,7 +37,7 @@ class deptModel extends model $rootDept = $this->getByID($rootDeptID); if(!$rootDept) $rootDept->path = ''; return $this->dao->select('*')->from(TABLE_DEPT) - ->onCaseOf($rootDeptID > 0)->where('path')->like($rootDept->path . '%')->endCase() + ->beginIF($rootDeptID > 0)->where('path')->like($rootDept->path . '%')->endIF() ->orderBy('grade desc, `order`') ->get(); } @@ -221,7 +221,7 @@ class deptModel extends model { return $this->dao->select('*')->from(TABLE_USER) ->where('deleted')->eq(0) - ->onCaseOf($deptID)->andWhere('dept')->in($deptID)->endCase() + ->beginIF($deptID)->andWhere('dept')->in($deptID)->endIF() ->orderBy('id') ->fetchAll(); } diff --git a/module/product/model.php b/module/product/model.php index df7b2b9867..8986808933 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -63,7 +63,7 @@ class productModel extends model return $this->dao->select('id,name') ->from(TABLE_PRODUCT) ->where('deleted')->eq(0) - ->onCaseOf($mode == 'noclosed')->andWhere('status')->ne('closed')->endCase() + ->beginIF($mode == 'noclosed')->andWhere('status')->ne('closed')->endIF() ->fetchPairs(); } diff --git a/module/project/model.php b/module/project/model.php index ff7d95e64b..1055c063da 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -139,7 +139,7 @@ class projectModel extends model $projects = $this->dao->select('*')->from(TABLE_PROJECT) ->where('iscat')->eq(0) ->andWhere('deleted')->eq(0) - ->onCaseOf($mode == 'noclosed')->andWhere('status')->ne('done')->endCase() + ->beginIF($mode == 'noclosed')->andWhere('status')->ne('done')->endIF() ->orderBy('status, end desc')->fetchAll(); $pairs = array(); foreach($projects as $project) @@ -153,7 +153,7 @@ class projectModel extends model public function getList($status = 'all') { return $this->dao->select('*')->from(TABLE_PROJECT)->where('iscat')->eq(0) - ->onCaseOf($status != 'all')->andWhere('status')->in($status)->endcase() + ->beginIF($status != 'all')->andWhere('status')->in($status)->endIF() ->andWhere('deleted')->eq(0) ->orderBy('status, end DESC') ->fetchAll(); diff --git a/module/story/model.php b/module/story/model.php index 42c5f5a1a7..19892bb0e7 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -380,8 +380,8 @@ class storyModel extends model ->from(TABLE_STORY)->alias('t1') ->leftJoin(TABLE_PRODUCTPLAN)->alias('t2')->on('t1.plan = t2.id') ->where('t1.product')->in($productID) - ->onCaseOf(!empty($moduleIds))->andWhere('module')->in($moduleIds)->endCase() - ->onCaseOf($status != 'all')->andWhere('status')->in($status)->endCase() + ->beginIF(!empty($moduleIds))->andWhere('module')->in($moduleIds)->endIF() + ->beginIF($status != 'all')->andWhere('status')->in($status)->endIF() ->andWhere('t1.deleted')->eq(0) ->orderBy($orderBy)->page($pager)->fetchAll(); } @@ -392,9 +392,9 @@ class storyModel extends model $stories = $this->dao->select('t1.id, t1.title, t1.module, t2.name AS product') ->from(TABLE_STORY)->alias('t1')->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id') ->where('1=1') - ->onCaseOf($productID)->andWhere('t1.product')->in($productID)->endCase() - ->onCaseOf($moduleIds)->andWhere('t1.module')->in($moduleIds)->endCase() - ->onCaseOf($status != 'all')->andWhere('status')->in($status)->endCase() + ->beginIF($productID)->andWhere('t1.product')->in($productID)->endIF() + ->beginIF($moduleIds)->andWhere('t1.module')->in($moduleIds)->endIF() + ->beginIF($status != 'all')->andWhere('status')->in($status)->endIF() ->andWhere('t1.deleted')->eq(0) ->orderBy($order) ->fetchAll(); @@ -447,7 +447,7 @@ class storyModel extends model ->on('t1.product = t3.id') ->where('t1.project')->eq((int)$projectID) ->andWhere('t2.deleted')->eq(0) - ->onCaseOf($productID)->andWhere('t1.product')->eq((int)$productID)->endCase() + ->beginIF($productID)->andWhere('t1.product')->eq((int)$productID)->endIF() ->fetchAll(); if(!$stories) return array(); return $this->formatStories($stories); @@ -458,7 +458,7 @@ class storyModel extends model { return $this->dao->select('*')->from(TABLE_STORY) ->where('plan')->eq((int)$planID) - ->onCaseOf($status != 'all')->andWhere('status')->in($status)->endCase() + ->beginIF($status != 'all')->andWhere('status')->in($status)->endIF() ->andWhere('deleted')->eq(0) ->orderBy($orderBy)->page($pager)->fetchAll('id'); } @@ -468,7 +468,7 @@ class storyModel extends model { return $this->dao->select('*')->from(TABLE_STORY) ->where('plan')->eq($planID) - ->onCaseOf($status != 'all')->andWhere('status')->in($status)->endCase() + ->beginIF($status != 'all')->andWhere('status')->in($status)->endIF() ->andWhere('deleted')->eq(0) ->fetchAll(); } diff --git a/module/task/model.php b/module/task/model.php index 8b6c86b92b..094eeeac0c 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -1,259 +1,259 @@ -. - * - * @copyright Copyright 2009-2010 青岛易软天创网络科技有限公司(www.cnezsoft.com) - * @author Chunsheng Wang - * @package task - * @version $Id$ - * @link http://www.zentaoms.com - */ -?> -striptags('name') - ->specialChars('desc') - ->add('project', (int)$projectID) - ->setDefault('estimate, left, story', 0) - ->setDefault('deadline', '0000-00-00') - ->setIF($this->post->estimate != false, 'left', $this->post->estimate) - ->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story)) - ->setDefault('statusCustom', strpos(self::CUSTOM_STATUS_ORDER, $this->post->status) + 1) - ->remove('after,files,labels') - ->get(); - - $this->dao->insert(TABLE_TASK)->data($task) - ->autoCheck() - ->batchCheck($this->config->task->create->requiredFields, 'notempty') - ->checkIF($task->estimate != '', 'estimate', 'float') - ->exec(); - if(!dao::isError()) - { - $taskID = $this->dao->lastInsertID(); - if($this->post->story) $this->loadModel('story')->setStage($this->post->story); - $this->loadModel('file')->saveUpload('task', $taskID); - return $taskID; - } - return false; - } - - /* 更新一个任务。*/ - public function update($taskID) - { - $oldTask = $this->getById($taskID); - $task = fixer::input('post') - ->striptags('name') - ->specialChars('desc') - ->setDefault('story, estimate, left, consumed', 0) - ->setIF($this->post->story != false and $this->post->story != $oldTask->story, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story)) - ->setIF($this->post->status == 'done', 'left', 0) - ->setIF($this->post->consumed > 0 and $this->post->left > 0 and $this->post->status == 'wait', 'status', 'doing') - ->remove('comment,fiels,labels') - ->get(); - $task->statusCustom = strpos(self::CUSTOM_STATUS_ORDER, $task->status) + 1; - - $this->dao->update(TABLE_TASK)->data($task) - ->autoCheck() - ->batchCheckIF($task->status != 'cancel', $this->config->task->edit->requiredFields, 'notempty') - ->checkIF($task->estimate != false, 'estimate', 'float') - ->checkIF($task->left != false, 'left', 'float') - ->checkIF($task->consumed != false, 'consumed', 'float') - ->checkIF($task->status == 'done', 'consumed', 'notempty') - ->checkIF($task->left == 0 and $task->status != 'cancel', 'status', 'equal', 'done') - ->where('id')->eq((int)$taskID)->exec(); - if($this->post->story != false) $this->loadModel('story')->setStage($this->post->story); - if(!dao::isError()) return common::createChanges($oldTask, $task); - } - - /* 通过id获取一个任务信息。*/ - public function getById($taskID) - { - $task = $this->dao->select('t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS ownerRealName') - ->from(TABLE_TASK)->alias('t1') - ->leftJoin(TABLE_STORY)->alias('t2') - ->on('t1.story = t2.id') - ->leftJoin(TABLE_USER)->alias('t3') - ->on('t1.owner = t3.account') - ->where('t1.id')->eq((int)$taskID) - ->fetch(); - if(!$task) return false; - if($task->mailto) - { - $task->mailto = ltrim(trim($task->mailto), ','); // 去掉开始的,。 - $task->mailto = str_replace(' ', '', $task->mailto); - $task->mailto = rtrim($task->mailto, ',') . ','; - $task->mailto = str_replace(',', ', ', $task->mailto); - } - $task->files = $this->loadModel('file')->getByObject('task', $taskID); - return $this->processTask($task); - } - - /* 获得某一个项目的任务列表。*/ - public function getProjectTasks($projectID, $status = 'all', $orderBy = 'status_asc, id_desc', $pager = null) - { - $orderBy = str_replace('status', 'statusCustom', $orderBy); - $tasks = $this->dao->select('t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS ownerRealName') - ->from(TABLE_TASK)->alias('t1') - ->leftJoin(TABLE_STORY)->alias('t2') - ->on('t1.story = t2.id') - ->leftJoin(TABLE_USER)->alias('t3') - ->on('t1.owner = t3.account') - ->where('t1.project')->eq((int)$projectID) - ->andWhere('t1.deleted')->eq(0) - ->onCaseOf($status == 'needConfirm')->andWhere('t2.version > t1.storyVersion')->andWhere("t2.status = 'active'")->endCase() - ->onCaseOf($status != 'all' and $status != 'needConfirm')->andWhere('t1.status')->in($status)->endCase() - ->orderBy($orderBy) - ->page($pager) - ->fetchAll(); - if($tasks) return $this->processTasks($tasks); - return false; - } - - /* 获得某一个项目的任务id=>name列表。*/ - public function getProjectTaskPairs($projectID, $status = 'all', $orderBy = 'id_desc') - { - $tasks = array('' => ''); - $stmt = $this->dao->select('t1.id, t1.name, t2.realname AS ownerRealName') - ->from(TABLE_TASK)->alias('t1') - ->leftJoin(TABLE_USER)->alias('t2') - ->on('t1.owner = t2.account') - ->where('t1.project')->eq((int)$projectID) - ->andWhere('t1.deleted')->eq(0) - ->onCaseOf($status != 'all')->andWhere('t1.status')->in($status)->endCase() - ->orderBy($orderBy) - ->query(); - while($task = $stmt->fetch()) $tasks[$task->id] = "$task->id:$task->ownerRealName:$task->name"; - return $tasks; - } - - /* 获得用户的任务列表。*/ - public function getUserTasks($account, $status = 'all') - { - $tasks = $this->dao->select('t1.*, t2.id as projectID, t2.name as projectName, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion') - ->from(TABLE_TASK)->alias('t1') - ->leftjoin(TABLE_PROJECT)->alias('t2') - ->on('t1.project = t2.id') - ->leftjoin(TABLE_STORY)->alias('t3') - ->on('t1.story = t3.id') - ->where('t1.owner')->eq($account) - ->andWhere('t1.deleted')->eq(0) - ->onCaseOf($status != 'all')->andWhere('t1.status')->in($status)->endCase() - ->fetchAll(); - if($tasks) return $this->processTasks($tasks); - return array(); - } - - /* 获得用户的任务id=>name列表。*/ - public function getUserTaskPairs($account, $status = 'all') - { - $tasks = array(); - $sql = $this->dao->select('t1.id, t1.name, t2.name as project') - ->from(TABLE_TASK)->alias('t1') - ->leftjoin(TABLE_PROJECT)->alias('t2') - ->on('t1.project = t2.id') - ->where('t1.owner')->eq($account) - ->andWhere('t1.deleted')->eq(0); - if($status != 'all') $sql->andwhere('t1.status')->in($status); - $stmt = $sql->query(); - while($task = $stmt->fetch()) - { - $tasks[$task->id] = $task->project . ' / ' . $task->name; - } - return $tasks; - } - - /* 获得story对应的task id=>name列表。*/ - public function getStoryTaskPairs($storyID, $projectID = 0) - { - return $this->dao->select('id, name') - ->from(TABLE_TASK) - ->where('story')->eq((int)$storyID) - ->andWhere('deleted')->eq(0) - ->onCaseOf($projectID)->andWhere('project')->eq($projectID)->endCase() - ->fetchPairs(); - } - - /* 获得story对应的task数量。*/ - public function getStoryTaskCounts($stories, $projectID = 0) - { - $taskCounts = $this->dao->select('story, COUNT(*) AS tasks') - ->from(TABLE_TASK) - ->where('story')->in($stories) - ->andWhere('deleted')->eq(0) - ->onCaseOf($projectID)->andWhere('project')->eq($projectID)->endCase() - ->groupBy('story') - ->fetchPairs(); - foreach($stories as $storyID) if(!isset($taskCounts[$storyID])) $taskCounts[$storyID] = 0; - return $taskCounts; - } - - /* 计算一组任务的相关状态。*/ - private function processTasks($tasks) - { - $today = helper::today(); - foreach($tasks as $task) - { - /* 计算是否延期。*/ - if($task->status !== 'done' and $task->status !== 'cancel') - { - if($task->deadline != '0000-00-00') - { - $delay = helper::diffDate($today, $task->deadline); - if($delay > 0) $task->delay = $delay; - } - } - - /* 判断需求是否变更。*/ - $task->needConfirm = false; - if($task->storyStatus == 'active' and $task->latestStoryVersion > $task->storyVersion) - { - $task->needConfirm = true; - } - } - return $tasks; - } - - /* 计算一个任务的相关状态。*/ - private function processTask($task) - { - $today = helper::today(); - - /* 计算是否延期。*/ - if($task->status !== 'done' and $task->status !== 'cancel') - { - if($task->deadline != '0000-00-00') - { - $delay = helper::diffDate($today, $task->deadline); - if($delay > 0) $task->delay = $delay; - } - } - - /* 判断需求是否变更。*/ - $task->needConfirm = false; - if($task->storyStatus == 'active' and $task->latestStoryVersion > $task->storyVersion) - { - $task->needConfirm = true; - } - return $task; - } -} +. + * + * @copyright Copyright 2009-2010 青岛易软天创网络科技有限公司(www.cnezsoft.com) + * @author Chunsheng Wang + * @package task + * @version $Id$ + * @link http://www.zentaoms.com + */ +?> +striptags('name') + ->specialChars('desc') + ->add('project', (int)$projectID) + ->setDefault('estimate, left, story', 0) + ->setDefault('deadline', '0000-00-00') + ->setIF($this->post->estimate != false, 'left', $this->post->estimate) + ->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story)) + ->setDefault('statusCustom', strpos(self::CUSTOM_STATUS_ORDER, $this->post->status) + 1) + ->remove('after,files,labels') + ->get(); + + $this->dao->insert(TABLE_TASK)->data($task) + ->autoCheck() + ->batchCheck($this->config->task->create->requiredFields, 'notempty') + ->checkIF($task->estimate != '', 'estimate', 'float') + ->exec(); + if(!dao::isError()) + { + $taskID = $this->dao->lastInsertID(); + if($this->post->story) $this->loadModel('story')->setStage($this->post->story); + $this->loadModel('file')->saveUpload('task', $taskID); + return $taskID; + } + return false; + } + + /* 更新一个任务。*/ + public function update($taskID) + { + $oldTask = $this->getById($taskID); + $task = fixer::input('post') + ->striptags('name') + ->specialChars('desc') + ->setDefault('story, estimate, left, consumed', 0) + ->setIF($this->post->story != false and $this->post->story != $oldTask->story, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story)) + ->setIF($this->post->status == 'done', 'left', 0) + ->setIF($this->post->consumed > 0 and $this->post->left > 0 and $this->post->status == 'wait', 'status', 'doing') + ->remove('comment,fiels,labels') + ->get(); + $task->statusCustom = strpos(self::CUSTOM_STATUS_ORDER, $task->status) + 1; + + $this->dao->update(TABLE_TASK)->data($task) + ->autoCheck() + ->batchCheckIF($task->status != 'cancel', $this->config->task->edit->requiredFields, 'notempty') + ->checkIF($task->estimate != false, 'estimate', 'float') + ->checkIF($task->left != false, 'left', 'float') + ->checkIF($task->consumed != false, 'consumed', 'float') + ->checkIF($task->status == 'done', 'consumed', 'notempty') + ->checkIF($task->left == 0 and $task->status != 'cancel', 'status', 'equal', 'done') + ->where('id')->eq((int)$taskID)->exec(); + if($this->post->story != false) $this->loadModel('story')->setStage($this->post->story); + if(!dao::isError()) return common::createChanges($oldTask, $task); + } + + /* 通过id获取一个任务信息。*/ + public function getById($taskID) + { + $task = $this->dao->select('t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS ownerRealName') + ->from(TABLE_TASK)->alias('t1') + ->leftJoin(TABLE_STORY)->alias('t2') + ->on('t1.story = t2.id') + ->leftJoin(TABLE_USER)->alias('t3') + ->on('t1.owner = t3.account') + ->where('t1.id')->eq((int)$taskID) + ->fetch(); + if(!$task) return false; + if($task->mailto) + { + $task->mailto = ltrim(trim($task->mailto), ','); // 去掉开始的,。 + $task->mailto = str_replace(' ', '', $task->mailto); + $task->mailto = rtrim($task->mailto, ',') . ','; + $task->mailto = str_replace(',', ', ', $task->mailto); + } + $task->files = $this->loadModel('file')->getByObject('task', $taskID); + return $this->processTask($task); + } + + /* 获得某一个项目的任务列表。*/ + public function getProjectTasks($projectID, $status = 'all', $orderBy = 'status_asc, id_desc', $pager = null) + { + $orderBy = str_replace('status', 'statusCustom', $orderBy); + $tasks = $this->dao->select('t1.*, t2.id AS storyID, t2.title AS storyTitle, t2.version AS latestStoryVersion, t2.status AS storyStatus, t3.realname AS ownerRealName') + ->from(TABLE_TASK)->alias('t1') + ->leftJoin(TABLE_STORY)->alias('t2') + ->on('t1.story = t2.id') + ->leftJoin(TABLE_USER)->alias('t3') + ->on('t1.owner = t3.account') + ->where('t1.project')->eq((int)$projectID) + ->andWhere('t1.deleted')->eq(0) + ->beginIF($status == 'needConfirm')->andWhere('t2.version > t1.storyVersion')->andWhere("t2.status = 'active'")->endIF() + ->beginIF($status != 'all' and $status != 'needConfirm')->andWhere('t1.status')->in($status)->endIF() + ->orderBy($orderBy) + ->page($pager) + ->fetchAll(); + if($tasks) return $this->processTasks($tasks); + return false; + } + + /* 获得某一个项目的任务id=>name列表。*/ + public function getProjectTaskPairs($projectID, $status = 'all', $orderBy = 'id_desc') + { + $tasks = array('' => ''); + $stmt = $this->dao->select('t1.id, t1.name, t2.realname AS ownerRealName') + ->from(TABLE_TASK)->alias('t1') + ->leftJoin(TABLE_USER)->alias('t2') + ->on('t1.owner = t2.account') + ->where('t1.project')->eq((int)$projectID) + ->andWhere('t1.deleted')->eq(0) + ->beginIF($status != 'all')->andWhere('t1.status')->in($status)->endIF() + ->orderBy($orderBy) + ->query(); + while($task = $stmt->fetch()) $tasks[$task->id] = "$task->id:$task->ownerRealName:$task->name"; + return $tasks; + } + + /* 获得用户的任务列表。*/ + public function getUserTasks($account, $status = 'all') + { + $tasks = $this->dao->select('t1.*, t2.id as projectID, t2.name as projectName, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion') + ->from(TABLE_TASK)->alias('t1') + ->leftjoin(TABLE_PROJECT)->alias('t2') + ->on('t1.project = t2.id') + ->leftjoin(TABLE_STORY)->alias('t3') + ->on('t1.story = t3.id') + ->where('t1.owner')->eq($account) + ->andWhere('t1.deleted')->eq(0) + ->beginIF($status != 'all')->andWhere('t1.status')->in($status)->endIF() + ->fetchAll(); + if($tasks) return $this->processTasks($tasks); + return array(); + } + + /* 获得用户的任务id=>name列表。*/ + public function getUserTaskPairs($account, $status = 'all') + { + $tasks = array(); + $sql = $this->dao->select('t1.id, t1.name, t2.name as project') + ->from(TABLE_TASK)->alias('t1') + ->leftjoin(TABLE_PROJECT)->alias('t2') + ->on('t1.project = t2.id') + ->where('t1.owner')->eq($account) + ->andWhere('t1.deleted')->eq(0); + if($status != 'all') $sql->andwhere('t1.status')->in($status); + $stmt = $sql->query(); + while($task = $stmt->fetch()) + { + $tasks[$task->id] = $task->project . ' / ' . $task->name; + } + return $tasks; + } + + /* 获得story对应的task id=>name列表。*/ + public function getStoryTaskPairs($storyID, $projectID = 0) + { + return $this->dao->select('id, name') + ->from(TABLE_TASK) + ->where('story')->eq((int)$storyID) + ->andWhere('deleted')->eq(0) + ->beginIF($projectID)->andWhere('project')->eq($projectID)->endIF() + ->fetchPairs(); + } + + /* 获得story对应的task数量。*/ + public function getStoryTaskCounts($stories, $projectID = 0) + { + $taskCounts = $this->dao->select('story, COUNT(*) AS tasks') + ->from(TABLE_TASK) + ->where('story')->in($stories) + ->andWhere('deleted')->eq(0) + ->beginIF($projectID)->andWhere('project')->eq($projectID)->endIF() + ->groupBy('story') + ->fetchPairs(); + foreach($stories as $storyID) if(!isset($taskCounts[$storyID])) $taskCounts[$storyID] = 0; + return $taskCounts; + } + + /* 计算一组任务的相关状态。*/ + private function processTasks($tasks) + { + $today = helper::today(); + foreach($tasks as $task) + { + /* 计算是否延期。*/ + if($task->status !== 'done' and $task->status !== 'cancel') + { + if($task->deadline != '0000-00-00') + { + $delay = helper::diffDate($today, $task->deadline); + if($delay > 0) $task->delay = $delay; + } + } + + /* 判断需求是否变更。*/ + $task->needConfirm = false; + if($task->storyStatus == 'active' and $task->latestStoryVersion > $task->storyVersion) + { + $task->needConfirm = true; + } + } + return $tasks; + } + + /* 计算一个任务的相关状态。*/ + private function processTask($task) + { + $today = helper::today(); + + /* 计算是否延期。*/ + if($task->status !== 'done' and $task->status !== 'cancel') + { + if($task->deadline != '0000-00-00') + { + $delay = helper::diffDate($today, $task->deadline); + if($delay > 0) $task->delay = $delay; + } + } + + /* 判断需求是否变更。*/ + $task->needConfirm = false; + if($task->storyStatus == 'active' and $task->latestStoryVersion > $task->storyVersion) + { + $task->needConfirm = true; + } + return $task; + } +} diff --git a/module/testcase/model.php b/module/testcase/model.php index 9d8f4388a5..83f7bd0c38 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -72,7 +72,7 @@ class testcaseModel extends model { return $this->dao->select('*')->from(TABLE_CASE) ->where('product')->eq((int)$productID) - ->onCaseOf($moduleIds)->andWhere('module')->in($moduleIds)->endCase() + ->beginIF($moduleIds)->andWhere('module')->in($moduleIds)->endIF() ->andWhere('deleted')->eq('0') ->orderBy($orderBy)->page($pager)->fetchAll(); } diff --git a/module/todo/model.php b/module/todo/model.php index f484998d62..74637ca865 100644 --- a/module/todo/model.php +++ b/module/todo/model.php @@ -129,8 +129,8 @@ class todoModel extends model ->where('account')->eq($account) ->andWhere("date >= '$begin'") ->andWhere("date <= '$end'") - ->onCaseOf($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->endCase() - ->onCaseOf($status == 'undone')->andWhere('status')->ne('done')->endCase() + ->beginIF($status != 'all' and $status != 'undone')->andWhere('status')->in($status)->endIF() + ->beginIF($status == 'undone')->andWhere('status')->ne('done')->endIF() ->orderBy('date, status, begin') ->query(); while($todo = $stmt->fetch()) diff --git a/module/tree/model.php b/module/tree/model.php index 9a59347113..51196edd98 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -45,7 +45,7 @@ class treeModel extends model return $this->dao->select('*')->from(TABLE_MODULE) ->where('product')->eq((int)$productID) ->andWhere('view')->eq($viewType) - ->onCaseOf($rootModulePath)->andWhere('path')->like($rootModulePath)->endCase() + ->beginIF($rootModulePath)->andWhere('path')->like($rootModulePath)->endIF() ->orderBy('grade desc, `order`') ->get(); } diff --git a/module/user/model.php b/module/user/model.php index 8d89804b4d..dc376e2ce7 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -72,8 +72,8 @@ class userModel extends model public function getById($userID) { $user = $this->dao->select('*')->from(TABLE_USER) - ->onCaseOf(is_numeric($userID))->where('id')->eq((int)$userID)->endCase() - ->onCaseOf(!is_numeric($userID))->where('account')->eq($userID)->endCase() + ->beginIF(is_numeric($userID))->where('id')->eq((int)$userID)->endIF() + ->beginIF(!is_numeric($userID))->where('account')->eq($userID)->endIF() ->fetch(); if(!$user) return false; $user->last = date(DT_DATETIME1, $user->last);