diff --git a/module/upgrade/control.php b/module/upgrade/control.php index f65055394f..57ca5c038b 100644 --- a/module/upgrade/control.php +++ b/module/upgrade/control.php @@ -341,7 +341,7 @@ class upgrade extends control /* When upgrading historical data as a project, handle products that are not linked with the project. */ if(!empty($singleProducts)) $this->upgrade->computeProductAcl($singleProducts, $programID); } - elseif($type == 'sprint') + elseif($type == 'sprint' or $type == 'noProject') { $linkedSprints = $this->post->sprints; @@ -453,6 +453,7 @@ class upgrade extends control $this->view->lineGroups = $lineGroups; $this->view->productGroups = $productGroups; } + /* Get projects group by product. */ if($type == 'product') { @@ -486,7 +487,6 @@ class upgrade extends control if(empty($noMergedProducts)) $this->locate($this->createLink('upgrade', 'mergeProgram', "type=sprint&programID=0&projectType=$projectType")); - /* Group project by product. */ $productGroups = array(); foreach($noMergedSprints as $sprint) @@ -501,6 +501,7 @@ class upgrade extends control $this->view->noMergedProducts = $noMergedProducts; $this->view->productGroups = $productGroups; } + /* Get no merged projects than is not linked product. */ if($type == 'sprint') { @@ -508,10 +509,26 @@ class upgrade extends control $projectProducts = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('project')->in(array_keys($noMergedSprints))->fetchGroup('project', 'product'); foreach($projectProducts as $sprintID => $products) unset($noMergedSprints[$sprintID]); - if(empty($noMergedSprints)) $this->locate($this->createLink('upgrade', 'mergeProgram', "type=moreLink")); + if(empty($noMergedSprints)) $this->locate($this->createLink('upgrade', 'mergeProgram', "type=noProject")); $this->view->noMergedSprints = $noMergedSprints; } + + /* Get one no merged sprint that link more then two products and no project in the system. */ + if($type == 'noProject') + { + $project = $this->dao->select('*')->from(TABLE_PROJECT)->where('type')->eq('project')->fetch(); + if($project) $this->locate($this->createLink('upgrade', 'mergeProgram', 'type=moreLink')); + $noMergedSprints = $this->dao->select('*')->from(TABLE_PROJECT)->where('parent')->eq(0)->andWhere('path')->eq('')->orderBy('id_desc')->limit(1)->fetchAll('id'); + + $productPrograms = $this->dao->select('t3.id as id, t3.name as name')->from(TABLE_PROJECTPRODUCT)->alias('t1') + ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id') + ->leftJoin(TABLE_PROGRAM)->alias('t3')->on('t2.program=t3.id') + ->where('t1.project')->eq(key($noMergedSprints)) + ->fetchPairs(); + $this->view->noMergedSprints = $noMergedSprints; + } + /* Get no merged projects that link more then two products. */ if($type == 'moreLink') { @@ -549,7 +566,7 @@ class upgrade extends control $currentProgramID = $programID ? $programID : key($programs); $this->view->title = $this->lang->upgrade->mergeProgram; - $this->view->programs = $programs; + $this->view->programs = $type == 'noProject' ? $productPrograms : $programs; $this->view->programID = $programID; $this->view->projects = array('' => '') + $this->upgrade->getProjectPairsByProgram($currentProgramID); $this->view->lines = $currentProgramID ? array('' => '') + $this->loadModel('product')->getLinePairs($currentProgramID) : array('' => ''); diff --git a/module/upgrade/view/createprogram.html.php b/module/upgrade/view/createprogram.html.php index 3824f3e72d..3ece464deb 100644 --- a/module/upgrade/view/createprogram.html.php +++ b/module/upgrade/view/createprogram.html.php @@ -13,7 +13,9 @@