| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- <?php
- /**
- * The zen file of my module of ZenTaoPMS.
- *
- * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
- * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
- * @author Mengyi Liu <liumengyi@easycorp.ltd>
- * @package my
- * @link https://www.zentao.net
- */
- class myZen extends my
- {
- /**
- * 构造任务数据。
- * Build task data.
- *
- * @param array $tasks
- * @access protected
- * @return array
- */
- protected function buildTaskData($tasks)
- {
- $parents = array();
- foreach($tasks as $task)
- {
- if(isset($tasks[$task->parent]) || $task->parent <= 0 || isset($parents[$task->parent])) continue;
- $parents[$task->parent] = $task->parent;
- }
- $parentPairs = $this->loadModel('task')->getPairsByIdList($parents);
- foreach($tasks as $task)
- {
- $task->estimateLabel = $task->estimate . $this->lang->execution->workHourUnit;
- $task->consumedLabel = $task->consumed . $this->lang->execution->workHourUnit;
- $task->leftLabel = $task->left . $this->lang->execution->workHourUnit;
- $task->status = !empty($task->storyStatus) && $task->storyStatus == 'active' && $task->latestStoryVersion > $task->storyVersion && !in_array($task->status, array('cancel', 'closed')) ? 'changed' : $task->status;
- $task->canBeChanged = common::canBeChanged('task', $task);
- $task->isChild = false;
- $task->parentName = '';
- if($task->status == 'changed') $task->rawStatus = 'changed';
- if($task->parent > 0)
- {
- if(isset($tasks[$task->parent]))
- {
- $tasks[$task->parent]->hasChild = true;
- }
- else
- {
- $task->name = zget($parentPairs, $task->parent, '') . ' / ' . $task->name;
- $task->isChild = true;
- $task->parent = 0;
- }
- }
- }
- return $tasks;
- }
- /**
- * 构造用例数据。
- * Build case data.
- *
- * @param array $cases
- * @param string $type assigntome|openedbyme
- * @access protected
- * @return array
- */
- protected function buildCaseData($cases, $type)
- {
- $cases = $this->loadModel('story')->checkNeedConfirm($cases);
- $cases = $this->loadModel('testcase')->appendData($cases, $type == 'assigntome' ? 'run' : 'case');
- $failCount = 0;
- foreach($cases as $case)
- {
- if($case->lastRunResult && $case->lastRunResult != 'pass') $failCount ++;
- if($case->needconfirm)
- {
- $case->status = $this->lang->story->changed;
- }
- else if(isset($case->fromCaseVersion) and $case->fromCaseVersion > $case->version and !$case->needconfirm)
- {
- $case->status = $this->lang->testcase->changed;
- }
- if(!$case->lastRunResult) $case->lastRunResult = $this->lang->testcase->unexecuted;
- }
- $this->view->failCount = $failCount;
- return $cases;
- }
- /**
- * 构造反馈关联的数据。
- * Build related data.
- *
- * @param array $feedbacks
- * @access protected
- * @return void
- */
- protected function assignRelatedData($feedbacks)
- {
- $storyIdList = $bugIdList = $todoIdList = $taskIdList = $ticketIdList = array();
- foreach($feedbacks as $feedback)
- {
- if($feedback->solution == 'tobug') $bugIdList[] = $feedback->result;
- if($feedback->solution == 'tostory') $storyIdList[] = $feedback->result;
- if($feedback->solution == 'totodo') $todoIdList[] = $feedback->result;
- if($feedback->solution == 'totask') $taskIdList[] = $feedback->result;
- if($feedback->solution == 'ticket') $ticketIdList[] = $feedback->result;
- }
- $bugs = $bugIdList ? $this->loadModel('bug')->getByIdList($bugIdList) : array();
- $stories = $storyIdList ? $this->loadModel('story')->getByList($storyIdList) : array();
- $todos = $todoIdList ? $this->loadModel('todo')->getByList($todoIdList) : array();
- $tasks = $taskIdList ? $this->loadModel('task')->getByIdList($taskIdList) : array();
- $tickets = $ticketIdList ? $this->loadModel('ticket')->getByList($ticketIdList) : array();
- $this->view->bugs = $bugs;
- $this->view->todos = $todos;
- $this->view->stories = $stories;
- $this->view->tasks = $tasks;
- $this->view->tickets = $tickets;
- }
- /**
- * 构造反馈的搜索表单。
- * Build search form for feedback.
- *
- * @param int $queryID
- * @param string $orderBy
- * @access protected
- * @return void
- */
- protected function buildSearchFormForFeedback($queryID, $orderBy)
- {
- $rawMethod = $this->app->rawMethod;
- $this->config->feedback->search['module'] = $rawMethod . 'Feedback';
- $this->config->feedback->search['actionURL'] = inlink($rawMethod, "mode=feedback&browseType=bysearch¶m=myQueryID&orderBy={$orderBy}");
- $this->config->feedback->search['queryID'] = $queryID;
- $this->config->feedback->search['params']['product']['values'] = $this->loadModel('product')->getPairs();
- $this->config->feedback->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu(0, 'feedback', 0);
- $this->config->feedback->search['params']['processedBy']['values'] = $this->loadModel('feedback')->getFeedbackPairs('admin');
- if($rawMethod == 'work')
- {
- unset($this->config->feedback->search['fields']['assignedTo']);
- unset($this->config->feedback->search['fields']['closedBy']);
- unset($this->config->feedback->search['fields']['closedDate']);
- unset($this->config->feedback->search['fields']['closedReason']);
- unset($this->config->feedback->search['fields']['processedBy']);
- unset($this->config->feedback->search['fields']['processedDate']);
- unset($this->config->feedback->search['fields']['solution']);
- }
- $this->loadModel('search')->setSearchParams($this->config->feedback->search);
- }
- /**
- * 展示待处理的数量。
- * Show to-do work count.
- *
- * @param int $recTotal
- * @param int $recPerPage
- * @param int $pageID
- * @access public
- * @return array
- */
- public function showWorkCount($recTotal = 0, $recPerPage = 20, $pageID = 1)
- {
- /* Load pager. */
- $this->app->loadClass('pager', true);
- if($this->app->getViewType() == 'mhtml') $recPerPage = 10;
- $pager = pager::init($recTotal, $recPerPage, $pageID);
- $count = array('task' => 0, 'aitask' => 0, 'story' => 0, 'bug' => 0, 'case' => 0, 'testtask' => 0, 'requirement' => 0, 'issue' => 0, 'risk' => 0, 'qa' => 0, 'meeting' => 0, 'ticket' => 0, 'feedback' => 0);
- /* Get the number of tasks assigned to me. */
- $this->loadModel('task')->getUserTasks($this->app->user->account, 'assignedTo', 0, $pager);
- $count['task'] = $pager->recTotal;
- /* Get the number of stories assigned to me. */
- $pager->recTotal = 0;
- $this->loadModel('story')->getUserStories($this->app->user->account, 'assignedTo', 'id_desc', $pager, 'story', false, 'all');
- $assignedToStoryCount = $pager->recTotal;
- $pager->recTotal = 0;
- $this->story->getUserStories($this->app->user->account, 'reviewBy', 'id_desc', $pager, 'story', false, 'all');
- $reviewByStoryCount = $pager->recTotal;
- $count['story'] = $assignedToStoryCount + $reviewByStoryCount;
- $isOpenedURAndSR = $this->config->URAndSR ? 1 : 0;
- if($isOpenedURAndSR)
- {
- /* Get the number of requirements assigned to me. */
- $pager->recTotal = 0;
- $this->story->getUserStories($this->app->user->account, 'assignedTo', 'id_desc', $pager, 'requirement', false, 'all');
- $assignedRequirementCount = $pager->recTotal;
- $pager->recTotal = 0;
- $this->story->getUserStories($this->app->user->account, 'reviewBy', 'id_desc', $pager, 'requirement', false, 'all');
- $reviewByRequirementCount = $pager->recTotal;
- $count['requirement'] = $assignedRequirementCount + $reviewByRequirementCount;
- }
- if($this->config->enableER)
- {
- $pager->recTotal = 0;
- $this->story->getUserStories($this->app->user->account, 'assignedTo', 'id_desc', $pager, 'epic', false, 'all');
- $assignedEpicCount = $pager->recTotal;
- $pager->recTotal = 0;
- $this->story->getUserStories($this->app->user->account, 'reviewBy', 'id_desc', $pager, 'epic', false, 'all');
- $reviewByEpicCount = $pager->recTotal;
- $count['epic'] = $assignedEpicCount + $reviewByEpicCount;
- }
- /* Get the number of bugs assigned to me. */
- $pager->recTotal = 0;
- $this->loadModel('bug')->getUserBugs($this->app->user->account, 'assignedTo', 'id_desc', 0, $pager);
- $count['bug'] = $pager->recTotal;
- /* Get the number of testcases assigned to me. */
- $pager->recTotal = 0;
- $this->loadModel('testcase')->getByAssignedTo($this->app->user->account, 'skip', 'id_desc', $pager);
- $count['case'] = $pager->recTotal;
- /* Get the number of testtasks assigned to me. */
- $pager->recTotal = 0;
- $this->loadModel('testtask')->getByUser($this->app->user->account, $pager, 'id_desc', 'wait');
- $count['testtask'] = $pager->recTotal;
- $pager->recTotal = 0;
- $count = $this->showWorkCountNotInOpen($count, $pager);
- $this->view->todoCount = $count;
- $this->view->isOpenedURAndSR = $isOpenedURAndSR;
- return $count;
- }
- /**
- * 展示非开源版的待处理的数量。
- * Show to-do work count that not in open edition.
- *
- * @param array $count
- * @param object $pager
- * @access public
- * @return array
- */
- protected function showWorkCountNotInOpen($count, $pager)
- {
- $isBiz = $this->config->edition == 'biz' ? 1 : 0;
- $isMax = $this->config->edition == 'max' ? 1 : 0;
- $isIPD = $this->config->edition == 'ipd' ? 1 : 0;
- if($this->config->edition != 'open')
- {
- if(!empty($this->config->enableAITeammate))
- {
- $this->loadModel('aitask')->getList(0, 'done', 'id_desc', $pager, $this->app->user->account);
- $count['aitask'] = $pager->recTotal;
- }
- $pager->recTotal = 0;
- $this->loadModel('feedback')->getList('assigntome', 'id_desc', $pager);
- $count['feedback'] = $pager->recTotal;
- $pager->recTotal = 0;
- $this->session->set('ticketBrowseType', 'assignedtome', 'feedback');
- $this->loadModel('ticket')->getList('assignedtome', 'id_desc', $pager);
- $count['ticket'] = $pager->recTotal;
- }
- if($isMax || $isIPD)
- {
- if($this->config->vision != 'or')
- {
- /* Get the number of issues assigned to me. */
- $pager->recTotal = 0;
- $this->loadModel('issue')->getUserIssues('assignedTo', 0, $this->app->user->account, 'id_desc', $pager);
- $count['issue'] = $pager->recTotal;
- /* Get the number of risks assigned to me. */
- $pager->recTotal = 0;
- $this->loadModel('risk')->getUserRisks('assignedTo', $this->app->user->account, 'id_desc', $pager);
- $count['risk'] = $pager->recTotal;
- /* Get the number of reviewissues assigned to me. */
- $pager->recTotal = 0;
- $this->loadModel('reviewissue')->getUserReviewissues('assignedTo', $this->app->user->account, 'id_desc', $pager);
- $count['reviewissue'] = $pager->recTotal;
- /* Get the number of nc assigned to me. */
- $pager->recTotal = 0;
- $this->my->getNcList('assignedToMe', 'id_desc', $pager, 'active');
- $ncCount = $pager->recTotal;
- /* Get the number of nc assigned to me. */
- $pager->recTotal = 0;
- $this->loadModel('auditplan')->getList(0, 'myChecking', '', 'id_desc', $pager);
- $auditplanCount = $pager->recTotal;
- $count['qa'] = $ncCount + $auditplanCount;
- /* Get the number of meetings assigned to me. */
- $pager->recTotal = 0;
- $this->loadModel('meeting')->getListByUser('futureMeeting', 'id_desc', 0, $pager);
- $count['meeting'] = $pager->recTotal;
- }
- if($isIPD && $this->config->vision == 'or')
- {
- /* Get the number of demands assigned to me. */
- $pager->recTotal = 0;
- $this->loadModel('demand')->getUserDemands($this->app->user->account, 'assignedTo', 'id_desc', $pager);
- $assignedToDemandCount = $pager->recTotal;
- /* Get the number of demands review by me. */
- $pager->recTotal = 0;
- $this->loadModel('demand')->getUserDemands($this->app->user->account, 'reviewBy', 'id_desc', $pager);
- $reviewByDemandCount = $pager->recTotal;
- $count['demand'] = $assignedToDemandCount + $reviewByDemandCount;
- }
- }
- $this->view->isBiz = $isBiz;
- $this->view->isMax = $isMax;
- $this->view->isIPD = $isIPD;
- return $count;
- }
- }
|