From 83dbebc5b8a509df6e94b515d9b1f52ac2c2addc Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Wed, 28 Sep 2022 11:16:33 +0800 Subject: [PATCH 01/12] * Task#70759 Add relation productID for copyProject. --- module/program/model.php | 5 +++-- module/project/control.php | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/module/program/model.php b/module/program/model.php index 5c3c36218c..90c0ddf67f 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -66,10 +66,11 @@ class programModel extends model * @param string $mode all|assign * @param string $status all|noclosed * @param string|array $append + * @param string|int $shadow all | 0 | 1 * @access public * @return array */ - public function getProductPairs($programID = 0, $mode = 'assign', $status = 'all', $append = '') + public function getProductPairs($programID = 0, $mode = 'assign', $status = 'all', $append = '', $shadow = 0) { /* Get the top programID. */ if($programID) @@ -86,8 +87,8 @@ class programModel extends model $views = empty($append) ? $this->app->user->view->products : $this->app->user->view->products . ",$append"; $products = $this->dao->select('*')->from(TABLE_PRODUCT) ->where('deleted')->eq(0) - ->andWhere('shadow')->eq(0) ->andWhere('vision')->eq($this->config->vision) + ->beginIF($shadow !== 'all')->andWhere('shadow')->eq((int)$shadow)->fi() ->beginIF($mode == 'assign')->andWhere('program')->eq($programID)->fi() ->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi() ->beginIF(!$this->app->user->admin)->andWhere('id')->in($views)->fi() diff --git a/module/project/control.php b/module/project/control.php index df020ebd52..4881cd6b68 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -529,6 +529,7 @@ class project extends control $products = array(); $productPlans = array(); + $shadow = 0; $parentProgram = $this->loadModel('program')->getByID($programID); if($copyProjectID) @@ -543,8 +544,9 @@ class project extends control $programID = $copyProject->parent; $model = $copyProject->model; $hasProduct = $copyProject->hasProduct; + $products = $this->product->getProducts($copyProjectID); - $products = $this->product->getProducts($copyProjectID); + if(!$copyProject->hasProduct) $shadow = 1; foreach($products as $product) { foreach($product->branches as $branch) @@ -573,7 +575,7 @@ class project extends control $this->view->users = $this->user->getPairs('noclosed|nodeleted'); $this->view->copyProjects = $this->project->getPairsByModel($model); $this->view->products = $products; - $this->view->allProducts = array('0' => '') + $this->program->getProductPairs($programID, 'assign', 'noclosed'); + $this->view->allProducts = array('0' => '') + $this->program->getProductPairs($programID, 'assign', 'noclosed', '', $shadow); $this->view->productPlans = array('0' => '') + $productPlans; $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), 'noclosed'); $this->view->programID = $programID; From 8d3ec9efdb5fd49bb6414d6fc8d7f4c772329d22 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Wed, 28 Sep 2022 13:55:41 +0800 Subject: [PATCH 02/12] * Finish task #70757. --- module/group/model.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/module/group/model.php b/module/group/model.php index f6affcba9e..0489768256 100644 --- a/module/group/model.php +++ b/module/group/model.php @@ -469,6 +469,23 @@ class groupModel extends model { $actions = $this->post->actions; $oldGroup = $this->getByID($groupID); + $projects = isset($actions['projects']) ? $actions['projects'] : array(); + $sprints = isset($actions['sprints']) ? $actions['sprints'] : array(); + + /* Add shadow productID when select noProduct project or execution. */ + if($projects or $sprints) + { + /* Get all noProduct projects and executions . */ + $noProductList = $this->loadModel('project')->getNoProductList(); + $shadowProductIDList = $this->dao->select('id')->from(TABLE_PRODUCT)->where('shadow')->eq(1)->fetchPairs(); + $noProductObjects = array_merge($projects, $sprints); + + foreach($noProductObjects as $objectID) + { + if(isset($noProductList[$objectID])) $actions['products'][] = $noProductList[$objectID]->product; + } + } + if(isset($_POST['allchecker']))$actions['views'] = array(); if(!isset($actions['actions']))$actions['actions'] = array(); From 537fd26d8fb624fbad79cfc6afb00fe4e17696ed Mon Sep 17 00:00:00 2001 From: liugang Date: Wed, 28 Sep 2022 16:12:26 +0800 Subject: [PATCH 03/12] * Create view to save the normal products. --- db/update17.6.1.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/update17.6.1.sql b/db/update17.6.1.sql index 7fed81278f..1475570e6d 100644 --- a/db/update17.6.1.sql +++ b/db/update17.6.1.sql @@ -1,4 +1,4 @@ ALTER TABLE `zt_product` ADD `shadow` tinyint(1) unsigned NOT NULL AFTER `code`; ALTER TABLE `zt_project` ADD `hasProduct` tinyint(1) unsigned NOT NULL DEFAULT 1 AFTER `code`; -ALTER TABLE `zt_product` MODIFY `name` varchar(110) NOT NULL; \ No newline at end of file +CREATE VIEW `ztv_normalproduct` AS SELECT * FROM `zt_product` WHERE `shadow` = 0; From 6c2a324e400f25c6a675ea7bc5bf68525fb17cbf Mon Sep 17 00:00:00 2001 From: liugang Date: Wed, 28 Sep 2022 16:30:28 +0800 Subject: [PATCH 04/12] * Create view to filter the shadow products. --- db/update17.6.1.sql | 2 +- db/updateproinstall.sql | 1 + db/zentao.sql | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/db/update17.6.1.sql b/db/update17.6.1.sql index 1475570e6d..82cf22c4cf 100644 --- a/db/update17.6.1.sql +++ b/db/update17.6.1.sql @@ -1,4 +1,4 @@ ALTER TABLE `zt_product` ADD `shadow` tinyint(1) unsigned NOT NULL AFTER `code`; ALTER TABLE `zt_project` ADD `hasProduct` tinyint(1) unsigned NOT NULL DEFAULT 1 AFTER `code`; -CREATE VIEW `ztv_normalproduct` AS SELECT * FROM `zt_product` WHERE `shadow` = 0; +CREATE OR REPLACE VIEW `ztv_normalproduct` AS SELECT * FROM `zt_product` WHERE `shadow` = 0; diff --git a/db/updateproinstall.sql b/db/updateproinstall.sql index d393bed109..45f00324cf 100644 --- a/db/updateproinstall.sql +++ b/db/updateproinstall.sql @@ -487,6 +487,7 @@ CREATE OR REPLACE VIEW `ztv_daytaskfinish` AS select count(*) AS `taskfinish`,le CREATE OR REPLACE VIEW `ztv_daybugopen` AS select count(*) AS `bugopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'bug') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10); CREATE OR REPLACE VIEW `ztv_daybugresolve` AS select count(*) AS `bugresolve`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'bug') and (`zt_action`.`action` = 'resolved')) group by left(`zt_action`.`date`,10); CREATE OR REPLACE VIEW `ztv_dayactions` AS select count(*) AS `actions`,left(`zt_action`.`date`,10) AS `day` from `zt_action` group by left(`zt_action`.`date`,10); +CREATE OR REPLACE VIEW `ztv_normalproduct` AS SELECT * FROM `zt_product` WHERE `shadow` = 0; REPLACE INTO `zt_report` (`code`, `name`, `module`, `sql`, `vars`, `langs`, `params`, `step`, `desc`, `addedBy`, `addedDate`) VALUES ('product-invest', '{\"zh-cn\":\"\\u4ea7\\u54c1\\u6295\\u5165\\u8868\",\"zh-tw\":\"\\u7522\\u54c1\\u6295\\u5165\\u8868\",\"en\":\"Product Investment\"}', ',product', 'select t1.id,t1.name,1 as projects, round(t3.consumed,2) as consumed from TABLE_PRODUCT as t1\r\n left join TABLE_PROJECTPRODUCT as t2 on t1.id=t2.product\r\n left join ztv_projectsummary as t3 on t2.project=t3.project\r\n left join TABLE_PROJECT as t4 on t2.project=t4.id\r\n left join TABLE_PROGRAM as t5 on t1.program=t5.id\r\n where t1.deleted=\'0\' and t4.deleted=\'0\' and t4.type=\'project\'\r\norder by t5.`order` asc, t1.line desc, t1.`order` asc', '', '{\"projects\":{\"zh-cn\":\"\\u9879\\u76ee\\u6570\",\"zh-tw\":\"\\u9879\\u76ee\\u6570\",\"en\":\"Projects\"},\"consumed\":{\"zh-cn\":\"\\u5df2\\u6d88\\u8017\\u5de5\\u65f6\",\"zh-tw\":\"\\u5df2\\u6d88\\u8017\\u5de5\\u65f6\",\"en\":\"Cost(h)\"}}', '{\"group1\":\"name\",\"group2\":\"\",\"reportField\":[\"projects\",\"consumed\"],\"reportType\":[\"sum\",\"sum\"],\"sumAppend\":[\"projects\",\"consumed\"]}', 2, '{\"zh-cn\":\"\\u5217\\u51fa\\u6bcf\\u4e2a\\u4ea7\\u54c1\\u7684\\u9879\\u76ee\\u603b\\u6570\\uff0c\\u5df2\\u7ecf\\u6d88\\u8017\\u7684\\u5de5\\u65f6\\u3002\",\"zh-tw\":\"\\u5217\\u51fa\\u6bcf\\u500b\\u7522\\u54c1\\u7684\\u9805\\u76ee\\u7e3d\\u6578\\uff0c\\u5df2\\u7d93\\u6d88\\u8017\\u7684\\u5de5\\u6642\\u3002\",\"en\":\"Number of projects and consumed hours.\"}', 'admin', '2015-07-20 14:21:30'), diff --git a/db/zentao.sql b/db/zentao.sql index e92a6e2223..11043c5dec 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -7007,6 +7007,7 @@ CREATE OR REPLACE VIEW `ztv_daytaskfinish` AS select count(*) AS `taskfinish`,le CREATE OR REPLACE VIEW `ztv_daybugopen` AS select count(*) AS `bugopen`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'bug') and (`zt_action`.`action` = 'opened')) group by left(`zt_action`.`date`,10); CREATE OR REPLACE VIEW `ztv_daybugresolve` AS select count(*) AS `bugresolve`,left(`zt_action`.`date`,10) AS `day` from `zt_action` where ((`zt_action`.`objectType` = 'bug') and (`zt_action`.`action` = 'resolved')) group by left(`zt_action`.`date`,10); CREATE OR REPLACE VIEW `ztv_dayactions` AS select count(*) AS `actions`,left(`zt_action`.`date`,10) AS `day` from `zt_action` group by left(`zt_action`.`date`,10); +CREATE OR REPLACE VIEW `ztv_normalproduct` AS SELECT * FROM `zt_product` WHERE `shadow` = 0; REPLACE INTO `zt_report` (`code`, `name`, `module`, `sql`, `vars`, `langs`, `params`, `step`, `desc`, `addedBy`, `addedDate`) VALUES ('product-progress', '{\"zh-cn\":\"\\u4ea7\\u54c1\\u5b8c\\u6210\\u5ea6\\u7edf\\u8ba1\\u8868\",\"zh-tw\":\"\\u7522\\u54c1\\u5b8c\\u6210\\u5ea6\\u7d71\\u8a08\\u8868\",\"en\":\"Product Progress\"}', ',product', 'select t1.*,t2.name, (case when t1.status = \'closed\' or t1.stage = \'released\' then 1 else 0 end) as done, 1 as count from TABLE_STORY as t1 \r\nleft join TABLE_PRODUCT as t2 on t1.product=t2.id \r\nleft join TABLE_PROGRAM as t3 on t2.program=t3.id \r\nwhere t1.deleted=\'0\' and t2.deleted=\'0\'\r\norder by t3.`order` asc, t2.line desc, t2.`order` asc', '', '{\"count\":{\"zh-cn\":\"\\u9700\\u6c42\\u6570\",\"zh-tw\":\"\\u9700\\u6c42\\u6570\",\"en\":\"Stories\"},\"done\":{\"zh-cn\":\"\\u5b8c\\u6210\\u6570\",\"zh-tw\":\"\\u5b8c\\u6210\\u6570\",\"en\":\"Done\"}}', '{\"group1\":\"name\",\"group2\":\"\",\"reportField\":[\"count\",\"done\"],\"reportType\":[\"sum\",\"sum\"],\"sumAppend\":[\"count\",\"done\"],\"percent\":{\"1\":\"1\"},\"contrast\":{\"1\":\"count\"},\"showAlone\":{\"1\":\"1\"}}', 2, '{\"zh-cn\":\"\\u6309\\u7167\\u4ea7\\u54c1\\u5217\\u51fa\\u9700\\u6c42\\u603b\\u6570\\uff0c\\u5b8c\\u6210\\u7684\\u603b\\u6570(\\u72b6\\u6001\\u662f\\u5173\\u95ed\\uff0c\\u6216\\u8005\\u7814\\u53d1\\u9636\\u6bb5\\u662f\\u53d1\\u5e03)\\uff0c\\u5b8c\\u6210\\u7684\\u767e\\u5206\\u6bd4\\u3002\",\"zh-tw\":\"\\u6309\\u7167\\u7522\\u54c1\\u5217\\u51fa\\u9700\\u6c42\\u7e3d\\u6578\\uff0c\\u5b8c\\u6210\\u7684\\u7e3d\\u6578(\\u72c0\\u614b\\u662f\\u95dc\\u9589\\uff0c\\u6216\\u8005\\u7814\\u767c\\u968e\\u6bb5\\u662f\\u767c\\u5e03)\\uff0c\\u5b8c\\u6210\\u7684\\u767e\\u5206\\u6bd4\\u3002\",\"en\":\"Number of total stories,done stories(state is closed, or stage is released), percent of completion.\"}', 'admin', '2015-07-21 15:07:48'), From 1f663ed48c410cb039a24788b7c4a1c30c302d53 Mon Sep 17 00:00:00 2001 From: sunguangming Date: Thu, 29 Sep 2022 09:02:09 +0800 Subject: [PATCH 05/12] * Finish task #70744. --- module/kanban/control.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/module/kanban/control.php b/module/kanban/control.php index ceefd81560..2f28ee92ab 100644 --- a/module/kanban/control.php +++ b/module/kanban/control.php @@ -1195,9 +1195,22 @@ class kanban extends control $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); - $productPairs = $this->product->getPairs(); + $productPairs = $this->product->getPairs('', 0, '', 'all'); $selectedProductID = empty($selectedProductID) ? key($productPairs) : $selectedProductID; + /* Waterfall project has no plan. */ + $waterfallProducts = $this->dao->select('t1.product')->from(TABLE_PROJECTPRODUCT)->alias('t1') + ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') + ->where('t2.type')->eq('project') + ->andWhere('t2.model')->eq('waterfall') + ->andWhere('t2.hasProduct')->eq('0') + ->fetchPairs(); + + foreach($productPairs as $id => $name) + { + if(isset($waterfallProducts[$id])) unset($productPairs[$id]); + } + $this->view->products = $productPairs; $this->view->selectedProductID = $selectedProductID; $this->view->lanePairs = $this->kanban->getLanePairsByGroup($groupID); @@ -1247,7 +1260,7 @@ class kanban extends control $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); - $this->view->products = array($this->lang->kanban->allProducts) + $this->product->getPairs(); + $this->view->products = array($this->lang->kanban->allProducts) + $this->product->getPairs('', 0, '', 'all'); $this->view->selectedProductID = $selectedProductID; $this->view->lanePairs = $this->kanban->getLanePairsByGroup($groupID); $this->view->releases2Imported = $this->release->getList($selectedProductID, 'all', 'all', 't1.date_desc', $pager); From 010f148222f05947c42c48add7506e195aa26494 Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 29 Sep 2022 09:20:37 +0800 Subject: [PATCH 06/12] * Set the team name as same as the execution's name. --- module/execution/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/execution/model.php b/module/execution/model.php index 27cf2f9a4f..1c8c2d4dbf 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -347,7 +347,7 @@ class executionModel extends model ->setDefault('openedVersion', $this->config->version) ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', helper::now()) - ->setDefault('team', substr($this->post->name, 0, 30)) + ->setDefault('team', $this->post->name) ->setIF($this->post->heightType == 'auto', 'displayCards', 0) ->setIF(!isset($_POST['whitelist']), 'whitelist', '') ->setIF($this->config->systemMode == 'new', 'parent', $this->post->project) From 1941a6936ce75d9900e91cda75cb9b70bec02d71 Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 29 Sep 2022 10:38:14 +0800 Subject: [PATCH 07/12] * Fix bug #28091,28092. --- module/project/model.php | 17 +++++++++++++++++ module/story/control.php | 17 ++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/module/project/model.php b/module/project/model.php index 078b6989ab..10f8fd2a70 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -173,6 +173,23 @@ class projectModel extends model return $project; } + /** + * Get a project by its shadow product. + * + * @param int $product + * @access public + * @return object + */ + public function getByShadowProduct($product) + { + return $this->dao->select('t2.*')->from(TABLE_PROJECTPRODUCT)->alias('t1') + ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id') + ->where('t1.product')->eq($product) + ->andWhere('t2.type')->eq('project') + ->limit(1) + ->fetch(); + } + /** * Get project info. * diff --git a/module/story/control.php b/module/story/control.php index 73b27b5193..9d3f7f9975 100755 --- a/module/story/control.php +++ b/module/story/control.php @@ -864,19 +864,14 @@ class story extends control $this->view->hiddenURS = false; $this->view->teamUsers = array(); - if($this->app->tab === 'project' || $this->app->tab === 'execution') + if($product->shadow) { - $project = $this->dao->findById((int)$objectID)->from(TABLE_PROJECT)->fetch(); - if(!empty($project->project)) $project = $this->dao->findById((int)$project->project)->from(TABLE_PROJECT)->fetch(); + $project = $this->project->getByShadowProduct($product->id); + $this->view->teamUsers = $this->project->getTeamMemberPairs($project->id); + $this->view->hiddenProduct = true; - if(empty($project->hasProduct)) - { - $this->view->teamUsers = $this->project->getTeamMemberPairs($project->id); - $this->view->hiddenProduct = true; - - if($project->model !== 'scrum') $this->view->hiddenPlan = true; - if($project->model === 'kanban') $this->view->hiddenURS = true; - } + if($project->model !== 'scrum') $this->view->hiddenPlan = true; + if($project->model === 'kanban') $this->view->hiddenURS = true; } /* Display status of branch. */ From 595b5f8f83987e0a980cfab6441a2c53f69a3caa Mon Sep 17 00:00:00 2001 From: sunguangming Date: Thu, 29 Sep 2022 11:36:18 +0800 Subject: [PATCH 08/12] * Code for task #71167. --- module/execution/control.php | 1 + module/execution/css/testtask.css | 2 +- module/execution/view/testtask.html.php | 12 ++++++++---- module/project/css/testtask.css | 2 +- module/project/view/testtask.html.php | 11 +++++++---- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 60c0aef0dc..cd6e647819 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1318,6 +1318,7 @@ class execution extends control $this->view->position[] = html::a($this->createLink('execution', 'testtask', "executionID=$executionID"), $this->executions[$executionID]); $this->view->position[] = $this->lang->testtask->common; $this->view->execution = $execution; + $this->view->project = $this->loadModel('project')->getByID($execution->project); $this->view->executionID = $executionID; $this->view->executionName = $this->executions[$executionID]; $this->view->pager = $pager; diff --git a/module/execution/css/testtask.css b/module/execution/css/testtask.css index 7d167eb581..36c6fbf838 100644 --- a/module/execution/css/testtask.css +++ b/module/execution/css/testtask.css @@ -1,7 +1,7 @@ .table-group-btns {width: 200px;} .table-footer, .table-grouped {box-shadow: none !important;} -.table-footer {margin-left: 205px; margin-top: 10px;} +.table-footer {margin-top: 10px;} .table-grouped > thead>tr>th.c-id, .table-grouped > tbody>tr>td.c-id {padding-left: 15px;} .table-grouped > tbody>tr>td {overflow: hidden; text-overflow: ellipsis; white-space: nowrap;} diff --git a/module/execution/view/testtask.html.php b/module/execution/view/testtask.html.php index 66cc3b0dbc..91b1c7ca1d 100644 --- a/module/execution/view/testtask.html.php +++ b/module/execution/view/testtask.html.php @@ -12,9 +12,13 @@ ?> testtask->confirmDelete)?> +hasProduct) and $project->hasProduct == '0');?> + + +