diff --git a/module/admin/control.php b/module/admin/control.php index 2a38dac0ef..97238f0cfe 100755 --- a/module/admin/control.php +++ b/module/admin/control.php @@ -53,23 +53,52 @@ class admin extends control $this->loadModel('misc'); - $hasInternet = $this->admin->checkInternet(); - $clientLang = $this->app->getClientLang(); - $langNotCN = common::checkNotCN(); - $dateUsed = $this->admin->genDateUsed(); + $clientLang = $this->app->getClientLang(); + $langNotCN = common::checkNotCN(); + $dateUsed = $this->admin->genDateUsed(); + + $zentaoData = $this->admin->getZentaoData(); + $hasInternet = $zentaoData->hasData; $this->view->title = $this->lang->admin->common; $this->view->position[] = $this->lang->admin->index; - $this->view->plugins = $this->admin->getExtensionsByAPI('plugin', $langNotCN ? 5 : 6, $hasInternet); - $this->view->patches = $this->admin->getExtensionsByAPI('patch', 5, $hasInternet); + $this->view->plugins = $zentaoData->plugins; + $this->view->patches = $zentaoData->patches; $this->view->dateUsed = $dateUsed; $this->view->hasInternet = $hasInternet; - $this->view->dynamics = ($hasInternet and !$langNotCN) ? $this->admin->getDynamicsByAPI(3) : array(); - $this->view->publicClass = ($hasInternet and !$langNotCN) ? $this->admin->getPublicClassByAPI(3) : array(); + $this->view->dynamics = $zentaoData->news; + $this->view->publicClass = $zentaoData->publicclass; $this->view->langNotCN = $langNotCN; $this->display(); } + /** + * Get zentao.net data by api. + * + * @access public + * @return void + */ + public function ajaxSetZentaoData() + { + $hasInternet = $this->admin->checkInternet(); + + if($hasInternet) + { + $nextWeek = date('Y-m-d', strtotime('-7 days')); + $zentaoData = $this->loadModel('block')->getZentaoData($nextWeek); + + if(empty($zentaoData)) + { + $this->admin->setExtensionsByAPI('plugin', 6); + $this->admin->setExtensionsByAPI('patch', 5); + $this->admin->setDynamicsByAPI(3); + $this->admin->setPublicClassByAPI(3); + } + } + + return $this->send(array('result' => 'success')); + } + /** * Ignore notice of register and bind. * diff --git a/module/admin/css/index.css b/module/admin/css/index.css index e3770ac26c..d457164dbc 100755 --- a/module/admin/css/index.css +++ b/module/admin/css/index.css @@ -85,6 +85,7 @@ /* css for without internet */ .main.without-internet {display: flex; flex-wrap: wrap;} .main.without-internet > .plug.panel {flex: 1 1 60%; margin-bottom: unset; margin-right: 16px;} +.main.without-internet > .bottom {flex: 1 1 30%;} .main.without-internet > .bottom > .official.panel {margin-right: unset;} .main.without-internet > .bottom > .official.panel > .main-panel {flex-direction: row-reverse;} diff --git a/module/admin/js/index.js b/module/admin/js/index.js index f97411945c..fed2be7c68 100644 --- a/module/admin/js/index.js +++ b/module/admin/js/index.js @@ -10,4 +10,6 @@ $(function() { window.open($(this).data('link')); }); + + if(!hasInternet) $.get(createLink('admin', 'ajaxSetZentaoData')); }); diff --git a/module/admin/model.php b/module/admin/model.php index 1802914b76..e2b8302278 100755 --- a/module/admin/model.php +++ b/module/admin/model.php @@ -507,7 +507,7 @@ class adminModel extends model } /** - * Get extensions from zentao.net. + * Set extensions from zentao.net. * * @param string $type plugin|patch * @param int $limit @@ -515,44 +515,22 @@ class adminModel extends model * @access public * @return array */ - public function getExtensionsByAPI($type = 'plugin', $limit = 6, $hasInternet = true) + public function setExtensionsByAPI($type = 'plugin', $limit = 5) { - if($hasInternet) + $searchType = $type == 'plugin' ? 'byModule,offcial' : 'byModule'; + $param = $type == 'plugin' ? '' : 'MTIxOA=='; + $extensions = $this->loadModel('extension')->getExtensionsByAPI($searchType, $param, 0, $limit); + $extensions = isset($extensions->extensions) ? (array)$extensions->extensions : array(); + $plugins = array(); + foreach($extensions as $extension) { - $searchType = $type == 'plugin' ? 'byModule,offcial' : 'byModule'; - $param = $type == 'plugin' ? '' : 'MTIxOA=='; - $extensions = $this->loadModel('extension')->getExtensionsByAPI($searchType, $param, 0, $limit); - $extensions = isset($extensions->extensions) ? (array)$extensions->extensions : array(); - $plugins = array(); - foreach($extensions as $extension) - { - if($type == 'patch' and !isset($extension->compatibleRelease)) continue; + if($type == 'patch' and !isset($extension->compatibleRelease)) continue; - $extension->viewLink = str_replace(array('info', 'client'), '', $extension->viewLink); - $plugins[] = $extension; - } - } - else - { - if($this->config->edition == 'open') - { - $plugins = array( - $this->config->admin->plugins[27], - $this->config->admin->plugins[26], - $this->config->admin->plugins[30] - ); - } - else - { - $plugins = array( - $this->config->admin->plugins[198], - $this->config->admin->plugins[194], - $this->config->admin->plugins[203] - ); - } + $extension->viewLink = str_replace(array('info', 'client'), '', $extension->viewLink); + $plugins[] = $extension; } - return $plugins; + return $this->loadModel('block')->setZentaoData($type, $plugins); } /** @@ -576,13 +554,13 @@ class adminModel extends model } /** - * Get public class from zentao.net. + * Set public class from zentao.net. * * @param int $limit * @access public - * @return array + * @return void */ - public function getPublicClassByAPI($limit = 2) + public function setPublicClassByAPI($limit = 3) { $apiURL = $this->config->admin->videoAPIURL; $data = $this->fetchAPI($apiURL); @@ -600,24 +578,25 @@ class adminModel extends model $publicClass[$index]->viewLink = $this->config->admin->apiRoot . '/publicclass/' . ($course->alias ? "{$course->alias}-" : '') . "{$course->id}.html"; $index ++; } - return $publicClass; + + return $this->loadModel('block')->setZentaoData('publicclass', $publicClass); } /** - * Get dynamics by API. + * Set dynamics by API. * * @param int $limit * @access public - * @return array + * @return void */ - public function getDynamicsByAPI($limit = 2) + public function setDynamicsByAPI($limit = 2) { $apiURL = $this->config->admin->downloadAPIURL; $data = $this->fetchAPI($apiURL); $articles = $data->articles; - $index = 1; - $downloads = array(); + $index = 1; + $news = array(); foreach($articles as $article) { if($index > $limit) break; @@ -626,14 +605,15 @@ class adminModel extends model if(!isset($this->lang->admin->$tagKey)) break; if(!preg_match("/{$this->lang->admin->$tagKey}\d/", $article->title)) continue; - $downloads[$index] = new stdClass(); - $downloads[$index]->id = $article->id; - $downloads[$index]->title = $article->title; - $downloads[$index]->addedDate = $article->addedDate; - $downloads[$index]->link = $this->config->admin->apiRoot . "/download/{$article->alias}-{$article->id}.html"; + $news[$index] = new stdClass(); + $news[$index]->id = $article->id; + $news[$index]->title = $article->title; + $news[$index]->addedDate = $article->addedDate; + $news[$index]->link = $this->config->admin->apiRoot . "/download/{$article->alias}-{$article->id}.html"; $index ++; } - return $downloads; + + return $this->loadModel('block')->setZentaoData('news', $news); } /** @@ -644,11 +624,11 @@ class adminModel extends model */ public function checkInternet() { - $timeoutMS = 400; - $curl = curl_init(); + $timeout = 3; + $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $this->config->admin->apiSite); - curl_setopt($curl, CURLOPT_TIMEOUT_MS, $timeoutMS); - curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, $timeoutMS); + curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); + curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); @@ -675,4 +655,58 @@ class adminModel extends model return helper::getDateInterval($firstUseDate); } + + /** + * Get zentao.net data. + * + * @access public + * @return object + */ + public function getZentaoData() + { + $zentaoData = $this->loadModel('block')->getZentaoData(); + + $data = new stdclass(); + $data->hasData = true; + + $news = array(); + $publicclass = array(); + $plugins = array(); + $patches = array(); + if(empty($zentaoData)) + { + $data->hasData = false; + if($this->config->edition == 'open') + { + $plugins = array( + $this->config->admin->plugins[27], + $this->config->admin->plugins[26], + $this->config->admin->plugins[30] + ); + } + else + { + $plugins = array( + $this->config->admin->plugins[198], + $this->config->admin->plugins[194], + $this->config->admin->plugins[203] + ); + } + } + else + { + $news = json_decode($zentaoData['news']); + $publicclass = json_decode($zentaoData['publicclass']); + $plugins = json_decode($zentaoData['plugin']); + $patches = json_decode($zentaoData['patch']); + if(common::checkNotCN()) array_pop($plugins); + } + + $data->news = $news; + $data->publicclass = $publicclass; + $data->plugins = $plugins; + $data->patches = $patches; + + return $data; + } } diff --git a/module/admin/view/index.html.php b/module/admin/view/index.html.php index 594c0b0270..cc7e7ec861 100755 --- a/module/admin/view/index.html.php +++ b/module/admin/view/index.html.php @@ -26,7 +26,7 @@ - admin->helpURL[$menuKey], " ", '_blank', 'class="text-muted setting-help"');?> + admin->helpURL[$menuKey], " ", '_blank', 'class="text-muted setting-help"');?>

diff --git a/module/block/model.php b/module/block/model.php index 383315585e..fcb3d99bab 100644 --- a/module/block/model.php +++ b/module/block/model.php @@ -1072,4 +1072,43 @@ class blockModel extends model { return $this->dao->select('count(estimate) as estimate')->from(TABLE_STORY)->where('id')->in($storyID)->fetch('estimate'); } + + /** + * Get zentao.net data. + * + * @param string $minTime + * @access public + * @return array + */ + public function getZentaoData($minTime = '') + { + return $this->dao->select('type,params')->from(TABLE_BLOCK) + ->where('account')->eq('system') + ->andWhere('vision')->eq('rnd') + ->andWhere('module')->eq('zentao') + ->beginIF($minTime)->andWhere('source')->ge($minTime)->fi() + ->andWhere('type')->in('plugin,patch,publicclass,news') + ->fetchPairs('type'); + } + + /** + * Set zentao data. + * + * @param string $type + * @param string $params + * @access public + * @return void + */ + public function setZentaoData($type = 'patch', $params = '') + { + $data = new stdclass(); + $data->account = 'system'; + $data->vision = 'rnd'; + $data->module = 'zentao'; + $data->type = $type; + $data->source = date('Y-m-d'); + $data->params = json_encode($params); + + $this->dao->replace(TABLE_BLOCK)->data($data)->exec(); + } } diff --git a/module/bug/config.php b/module/bug/config.php old mode 100644 new mode 100755 index 060992e9ab..d9c707e2f2 --- a/module/bug/config.php +++ b/module/bug/config.php @@ -223,7 +223,7 @@ $config->bug->datatable->fieldList['execution']['title'] = 'execution'; $config->bug->datatable->fieldList['execution']['fixed'] = 'no'; $config->bug->datatable->fieldList['execution']['width'] = '120'; $config->bug->datatable->fieldList['execution']['required'] = 'no'; -$config->bug->datatable->fieldList['execution']['dataSource'] = array('module' => 'product', 'method' =>'getAllExecutionPairsByProduct', 'params' => '$productID&$branch'); +$config->bug->datatable->fieldList['execution']['dataSource'] = array('module' => 'product', 'method' =>'getAllExecutionPairsByProduct', 'params' => '$productID&$branch&0&stagefilter'); $config->bug->datatable->fieldList['plan']['title'] = 'plan'; $config->bug->datatable->fieldList['plan']['fixed'] = 'no'; diff --git a/module/bug/control.php b/module/bug/control.php index f9727a0d45..de0279b862 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -859,7 +859,7 @@ class bug extends control $this->view->users = $this->user->getPairs('devfirst|noclosed'); $this->view->projects = array('' => '') + $this->product->getProjectPairsByProduct($productID, $branch ? "0,$branch" : 0, 'id_desc', $projectID); $this->view->projectID = $projectID; - $this->view->executions = array('' => '') + $this->product->getExecutionPairsByProduct($productID, $branch ? "0,$branch" : 0, 'id_desc', $projectID, 'multiple'); + $this->view->executions = array('' => '') + $this->product->getExecutionPairsByProduct($productID, $branch ? "0,$branch" : 0, 'id_desc', $projectID, 'multiple,stagefilter'); $this->view->executionID = $executionID; $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0, $branch === 'all' ? 0 : $branch); $this->view->moduleID = $moduleID; @@ -1398,7 +1398,7 @@ class bug extends control } /* Set users. */ - $users = $this->user->getPairs('devfirst', '', $this->config->maxCount); + $users = $this->user->getPairs('devfirst'); $users = array('' => '', 'ditto' => $this->lang->bug->ditto) + $users; /* Assign. */ diff --git a/module/bug/js/common.js b/module/bug/js/common.js index 8c1fb0a745..e50f5bf3ed 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -369,7 +369,7 @@ function loadProductExecutions(productID, projectID = 0) var execution = $('#execution').val(); } - link = createLink('product', 'ajaxGetExecutions', 'productID=' + productID + '&projectID=' + projectID + '&branch=' + branch + '&number=&executionID=' + execution); + link = createLink('product', 'ajaxGetExecutions', 'productID=' + productID + '&projectID=' + projectID + '&branch=' + branch + '&number=&executionID=' + execution + '&from=&mode=stagefilter'); $('#executionIdBox').load(link, function() { $(this).find('select').chosen(); diff --git a/module/bug/view/batchedit.html.php b/module/bug/view/batchedit.html.php index c3ed89d702..95cf0ba72d 100644 --- a/module/bug/view/batchedit.html.php +++ b/module/bug/view/batchedit.html.php @@ -74,9 +74,6 @@ $bug):?> - config->user->moreLink)) $this->config->moreLinks["assignedTos[$bugID]"] = $this->config->user->moreLink; - ?> >type, 'class=form-control');?> diff --git a/module/execution/control.php b/module/execution/control.php index 153deec30c..0c473b3597 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2634,30 +2634,19 @@ class execution extends control $this->session->set('storyList', $this->app->getURI(true), 'execution'); $this->session->set('rdSearchValue', ''); - $features = $this->execution->getExecutionFeatures($execution); - $kanbanData = $this->loadModel('kanban')->getRDKanban($executionID, $browseType, $orderBy, 0, $groupBy); - - /* Set lane type. */ - if(!$features['story'] and !$features['qa']) $browseType = 'task'; - $this->session->set('execLaneType', $browseType); - - /* Remove lanes if no feature. */ - foreach($kanbanData as $regionID => $region) - { - foreach($region->groups as $groupID => $group) - { - if(!$features['story'] and $group->lanes[0]->type == 'story') unset($kanbanData[$regionID]->groups[$groupID]); - if(!$features['qa'] and $group->lanes[0]->type == 'bug') unset($kanbanData[$regionID]->groups[$groupID]); - } - $kanbanData[$regionID]->groups = array_values($kanbanData[$regionID]->groups); - } - + $features = $this->execution->getExecutionFeatures($execution); + $kanbanData = $this->loadModel('kanban')->getRDKanban($executionID, $browseType, $orderBy, 0, $groupBy); $executionActions = array(); foreach($this->config->execution->statusActions as $action) { if($this->execution->isClickable($execution, $action)) $executionActions[] = $action; } + /* Set lane type. */ + if(!$features['story'] and !$features['qa']) $browseType = 'task'; + if(!$features['story']) unset($this->lang->kanban->group->task['story']); + $this->session->set('execLaneType', $browseType); + $userList = array(); $users = $this->loadModel('user')->getPairs('noletter|nodeleted'); $avatarPairs = $this->user->getAvatarPairs('all'); diff --git a/module/execution/js/kanban.js b/module/execution/js/kanban.js index 87ac799f21..13228c26c6 100644 --- a/module/execution/js/kanban.js +++ b/module/execution/js/kanban.js @@ -215,7 +215,7 @@ $('.c-group').change(function() { $('.c-group').show(); - var type = $('#type').val(); + var type = $('#type').val() ? $('#type').val() : browseType; var group = $('#group').val(); var link = createLink('execution', 'kanban', 'executionID=' + executionID + '&type=' + type + '&orderBy=id_asc' + '&groupBy=' + group); location.href = link; diff --git a/module/execution/lang/de.php b/module/execution/lang/de.php index faffb7fa8d..993b5092e6 100644 --- a/module/execution/lang/de.php +++ b/module/execution/lang/de.php @@ -282,7 +282,7 @@ $lang->execution->treeViewTask = 'Tree View Task'; $lang->execution->treeViewStory = 'Tree View Story'; $lang->execution->storyKanban = 'Story Kanban'; $lang->execution->storySort = 'Story sortieren'; -$lang->execution->importPlanStory = $lang->executionCommon . ' is created!\nDo you want to import stories that have been linked to the plan? The stories in the draft will be automatically filtered out when imported.'; +$lang->execution->importPlanStory = $lang->executionCommon . ' is created!\nDo you want to import stories that have been linked to the plan? Only active ' . $lang->SRCommon . ' can be imported.'; $lang->execution->importEditPlanStory = $lang->executionCommon . ' is edited!\nDo you want to import stories that have been linked to the plan? The stories in the draft will be automatically filtered out when imported.'; $lang->execution->importBranchPlanStory = $lang->executionCommon . ' is created!\nDo you want to import stories that have been linked to the plan? Only the activation stories of the branch associated with this ' .$lang->executionCommon. ' will be associated with the import'; $lang->execution->importBranchEditPlanStory = $lang->executionCommon . ' is edited!\nDo you want to import stories that have been linked to the plan? Only the activation stories of the branch associated with this ' .$lang->executionCommon. ' will be associated with the import'; diff --git a/module/execution/lang/en.php b/module/execution/lang/en.php index 29cc89a90f..4a54020911 100644 --- a/module/execution/lang/en.php +++ b/module/execution/lang/en.php @@ -282,7 +282,7 @@ $lang->execution->treeViewTask = 'Tree View Task'; $lang->execution->treeViewStory = 'Tree View Story'; $lang->execution->storyKanban = 'Story Kanban'; $lang->execution->storySort = 'Rank Story'; -$lang->execution->importPlanStory = $lang->executionCommon . ' is created!\nDo you want to import stories that have been linked to the plan? The stories in the draft will be automatically filtered out when imported.'; +$lang->execution->importPlanStory = $lang->executionCommon . ' is created!\nDo you want to import stories that have been linked to the plan? Only active ' . $lang->SRCommon . ' can be imported.'; $lang->execution->importEditPlanStory = $lang->executionCommon . ' is edited!\nDo you want to import stories that have been linked to the plan? The stories in the draft will be automatically filtered out when imported.'; $lang->execution->importBranchPlanStory = $lang->executionCommon . ' is created!\nDo you want to import stories that have been linked to the plan? Only the activation stories of the branch associated with this ' .$lang->executionCommon. ' will be associated with the import'; $lang->execution->importBranchEditPlanStory = $lang->executionCommon . ' is edited!\nDo you want to import stories that have been linked to the plan? Only the activation stories of the branch associated with this ' .$lang->executionCommon. ' will be associated with the import'; diff --git a/module/execution/lang/fr.php b/module/execution/lang/fr.php index 45a067d107..edb6d956ed 100644 --- a/module/execution/lang/fr.php +++ b/module/execution/lang/fr.php @@ -282,7 +282,7 @@ $lang->execution->treeViewTask = 'Tree View Task'; $lang->execution->treeViewStory = 'Tree View Story'; $lang->execution->storyKanban = 'Story Kanban'; $lang->execution->storySort = 'Rank Story'; -$lang->execution->importPlanStory = $lang->executionCommon . ' is created!\nDo you want to import stories that have been linked to the plan? The stories in the draft will be automatically filtered out when imported.'; +$lang->execution->importPlanStory = $lang->executionCommon . ' is created!\nDo you want to import stories that have been linked to the plan? Only active ' . $lang->SRCommon . ' can be imported.'; $lang->execution->importEditPlanStory = $lang->executionCommon . ' is edited!\nDo you want to import stories that have been linked to the plan? The stories in the draft will be automatically filtered out when imported.'; $lang->execution->importBranchPlanStory = $lang->executionCommon . ' is created!\nDo you want to import stories that have been linked to the plan? Only the activation stories of the branch associated with this ' .$lang->executionCommon. ' will be associated with the import'; $lang->execution->importBranchEditPlanStory = $lang->executionCommon . ' is edited!\nDo you want to import stories that have been linked to the plan? Only the activation stories of the branch associated with this ' .$lang->executionCommon. ' will be associated with the import'; diff --git a/module/execution/lang/zh-cn.php b/module/execution/lang/zh-cn.php index af29250198..ed2fcaab23 100644 --- a/module/execution/lang/zh-cn.php +++ b/module/execution/lang/zh-cn.php @@ -282,7 +282,7 @@ $lang->execution->treeViewTask = '树状图查看任务'; $lang->execution->treeViewStory = "树状图查看{$lang->SRCommon}"; $lang->execution->storyKanban = "{$lang->SRCommon}看板"; $lang->execution->storySort = "{$lang->SRCommon}排序"; -$lang->execution->importPlanStory = '创建' . $lang->executionCommon . '成功!\n是否导入计划关联的相关' . $lang->SRCommon . '?导入时将自动过滤掉草稿状态的' . $lang->SRCommon . '。'; +$lang->execution->importPlanStory = '创建' . $lang->executionCommon . '成功!\n是否导入计划关联的相关' . $lang->SRCommon . '?导入时只能导入激活状态的' . $lang->SRCommon . '。'; $lang->execution->importEditPlanStory = '编辑' . $lang->executionCommon . '成功!\n是否导入计划关联的相关' . $lang->SRCommon . '?导入时将自动过滤掉草稿状态的' . $lang->SRCommon . '。'; $lang->execution->importBranchPlanStory = '创建' . $lang->executionCommon . '成功!\n是否导入计划关联的相关' . $lang->SRCommon . '?导入时将只关联本' . $lang->executionCommon . '所关联分支的激活需求。'; $lang->execution->importBranchEditPlanStory = '编辑' . $lang->executionCommon . '成功!\n是否导入计划关联的相关' . $lang->SRCommon . '?导入时将只关联本' . $lang->executionCommon . '所关联分支的激活需求。'; diff --git a/module/execution/model.php b/module/execution/model.php index 4a4e430561..01eed079a3 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1458,32 +1458,34 @@ class executionModel extends model } /* The total workload of the first stage should not exceed 100%. */ - if($type == 'create' or (!empty($oldExecution) and $oldExecution->grade == 1)) + if($type == 'create' or (!empty($oldExecution) and $oldExecution->grade == 1 and isset($this->lang->execution->typeList[$oldExecution->type]))) { $oldPercentTotal = $this->dao->select('SUM(t2.percent) as total')->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.project=t2.id') ->where('t1.product')->eq($this->post->products[0]) + ->beginIF(!empty($_POST['branch'][0]))->andWhere('t1.branch')->eq(current($this->post->branch[0]))->fi() ->andWhere('t2.type')->eq('stage') ->andWhere('t2.grade')->eq(1) ->andWhere('t2.deleted')->eq(0) - ->andWhere('t2.parent')->eq($oldExecution->parent) + ->beginIF($type == 'create')->andWhere('t2.parent')->eq($oldExecution->id)->fi() + ->beginIF(!empty($oldExecution) and isset($this->lang->execution->typeList[$oldExecution->type]))->andWhere('t2.parent')->eq($oldExecution->parent)->fi() ->fetch('total'); if(!$oldPercentTotal) $oldPercentTotal = 0; if($type == 'create') $percentTotal = $percent + $oldPercentTotal; - if(!empty($oldExecution) and $oldExecution->grade == 1) $percentTotal = $oldPercentTotal - $oldExecution->percent + $this->post->percent; + if(!empty($oldExecution) and isset($this->lang->execution->typeList[$oldExecution->type])) $percentTotal = $oldPercentTotal - $oldExecution->percent + $percent; if($percentTotal > 100) { - dao::$errors['percent'] = sprintf($this->lang->execution->workloadTotal, '%', $oldPercentTotal . '%'); + $printPercent = $type == 'create' ? $oldPercentTotal : $percentTotal; + dao::$errors['percent'] = sprintf($this->lang->execution->workloadTotal, '%', $printPercent . '%'); return false; } } if($type == 'update' and $oldExecution->grade > 1) { - $parentPlan = $this->loadModel('programPlan')->getByID($oldExecution->parent); - $childrenTotalPercent = $this->dao->select('SUM(percent) as total')->from(TABLE_EXECUTION)->where('parent')->eq($oldExecution->parent)->andWhere('deleted')->eq(0)->fetch('total'); + $childrenTotalPercent = $this->dao->select('SUM(percent) as total')->from(TABLE_EXECUTION)->where('parent')->eq($oldExecution->parent)->andWhere('project')->eq($oldExecution->project)->andWhere('deleted')->eq(0)->fetch('total'); $childrenTotalPercent = $childrenTotalPercent - $oldExecution->percent + $this->post->percent; if($childrenTotalPercent > 100) @@ -5162,7 +5164,7 @@ class executionModel extends model } else { - $path = str_replace(",$execution->project", '', $execution->path); + $path = str_replace(",$execution->project,", ',', $execution->path); $trClass = 'table-nest-hide'; $trAttrs = "data-id={$execution->id} data-parent={$execution->parent} data-status={$execution->status}"; $trAttrs .= " data-nest-parent='$execution->parent' data-order='$execution->order' data-nest-path='$path'"; diff --git a/module/execution/view/kanban.html.php b/module/execution/view/kanban.html.php index 58293d2cde..5b88da0f03 100644 --- a/module/execution/view/kanban.html.php +++ b/module/execution/view/kanban.html.php @@ -199,7 +199,7 @@ js::set('priv',