* Modify code logic.
This commit is contained in:
+52
-44
@@ -353,26 +353,28 @@ class project extends control
|
||||
$this->loadModel('action')->create('project', $projectID, 'opened');
|
||||
|
||||
/* Link the plan stories. */
|
||||
$newPlans = $this->dao->select('plan')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->andWhere('plan')->ne(0)->fetchPairs('plan');
|
||||
if(!empty($newPlans))
|
||||
if(!empty($_POST['plans']))
|
||||
{
|
||||
foreach($newPlans as $planID)
|
||||
foreach($_POST['plans'] as $plans)
|
||||
{
|
||||
$planStories = $planProducts = array();
|
||||
$planStory = $this->loadModel('story')->getPlanStories($planID);
|
||||
if(!empty($planStory))
|
||||
foreach($plans as $planID)
|
||||
{
|
||||
foreach($planStory as $id => $story)
|
||||
$planStories = $planProducts = array();
|
||||
$planStory = $this->loadModel('story')->getPlanStories($planID);
|
||||
if(!empty($planStory))
|
||||
{
|
||||
if($story->status == 'draft')
|
||||
foreach($planStory as $id => $story)
|
||||
{
|
||||
unset($planStory[$id]);
|
||||
continue;
|
||||
if($story->status == 'draft')
|
||||
{
|
||||
unset($planStory[$id]);
|
||||
continue;
|
||||
}
|
||||
$planProducts[$story->id] = $story->product;
|
||||
}
|
||||
$planProducts[$story->id] = $story->product;
|
||||
$planStories = array_keys($planStory);
|
||||
$this->execution->linkStory($projectID, $planStories, $planProducts);
|
||||
}
|
||||
$planStories = array_keys($planStory);
|
||||
$this->execution->linkStory($projectID, $planStories, $planProducts);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -442,29 +444,29 @@ class project extends control
|
||||
$this->view->title = $this->lang->project->create;
|
||||
$this->view->position[] = $this->lang->project->create;
|
||||
|
||||
$this->view->gobackLink = (isset($output['from']) and $output['from'] == 'global') ? $this->createLink('project', 'browse') : '';
|
||||
$this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst');
|
||||
$this->view->users = $this->user->getPairs('noclosed|nodeleted');
|
||||
$this->view->copyProjects = $this->project->getPairsByModel();
|
||||
$this->view->products = $products;
|
||||
$this->view->allProducts = array('0' => '') + $this->program->getProductPairs($programID, 'assign', 'noclosed');
|
||||
$this->view->productPlans = array('0' => '') + $productPlans;
|
||||
$this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), 'noclosed');
|
||||
$this->view->programID = $programID;
|
||||
$this->view->abnormalProducts = $this->loadModel('product')->getAbnormalProductPairs($programID);
|
||||
$this->view->model = $model;
|
||||
$this->view->name = $name;
|
||||
$this->view->code = $code;
|
||||
$this->view->team = $team;
|
||||
$this->view->acl = $acl;
|
||||
$this->view->auth = $auth;
|
||||
$this->view->whitelist = $whitelist;
|
||||
$this->view->copyProjectID = $copyProjectID;
|
||||
$this->view->programList = $this->program->getParentPairs();
|
||||
$this->view->parentProgram = $parentProgram;
|
||||
$this->view->URSRPairs = $this->loadModel('custom')->getURSRPairs();
|
||||
$this->view->availableBudget = $this->program->getBudgetLeft($parentProgram);
|
||||
$this->view->budgetUnitList = $this->program->getBudgetUnitList();
|
||||
$this->view->gobackLink = (isset($output['from']) and $output['from'] == 'global') ? $this->createLink('project', 'browse') : '';
|
||||
$this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst');
|
||||
$this->view->users = $this->user->getPairs('noclosed|nodeleted');
|
||||
$this->view->copyProjects = $this->project->getPairsByModel();
|
||||
$this->view->products = $products;
|
||||
$this->view->allProducts = array('0' => '') + $this->program->getProductPairs($programID, 'assign', 'noclosed');
|
||||
$this->view->productPlans = array('0' => '') + $productPlans;
|
||||
$this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), 'noclosed');
|
||||
$this->view->programID = $programID;
|
||||
$this->view->multiBranchProducts = $this->loadModel('product')->getMultiBranchPairs($programID);
|
||||
$this->view->model = $model;
|
||||
$this->view->name = $name;
|
||||
$this->view->code = $code;
|
||||
$this->view->team = $team;
|
||||
$this->view->acl = $acl;
|
||||
$this->view->auth = $auth;
|
||||
$this->view->whitelist = $whitelist;
|
||||
$this->view->copyProjectID = $copyProjectID;
|
||||
$this->view->programList = $this->program->getParentPairs();
|
||||
$this->view->parentProgram = $parentProgram;
|
||||
$this->view->URSRPairs = $this->loadModel('custom')->getURSRPairs();
|
||||
$this->view->availableBudget = $this->program->getBudgetLeft($parentProgram);
|
||||
$this->view->budgetUnitList = $this->program->getBudgetUnitList();
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -504,7 +506,12 @@ class project extends control
|
||||
}
|
||||
|
||||
/* Link the plan stories. */
|
||||
$newPlans = $this->dao->select('plan')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->andWhere('plan')->ne(0)->fetchPairs('plan');
|
||||
$newPlans = array();
|
||||
foreach($_POST['plans'] as $plans)
|
||||
{
|
||||
foreach($plans as $planID) $newPlans[$planID] = $planID;
|
||||
}
|
||||
|
||||
$diffResult = array_diff($oldPlans, $newPlans);
|
||||
if(!empty($newPlans) and !empty($diffResult))
|
||||
{
|
||||
@@ -523,20 +530,21 @@ class project extends control
|
||||
$linkedProducts = $this->project->getProducts($projectID);
|
||||
$parentProject = $this->program->getByID($project->parent);
|
||||
$branches = $this->project->getBranchesByProject($projectID);
|
||||
$plans = $this->productplan->getGroupByProduct(array_keys($linkedProducts));
|
||||
$projectStories = $this->project->getStoriesByProject($projectID);
|
||||
|
||||
/* If the story of the product which linked the project, you don't allow to remove the product. */
|
||||
$unmodifiableProducts = array();
|
||||
$unmodifiableBranches = array();
|
||||
foreach($linkedProducts as $productID => $linkedProduct)
|
||||
{
|
||||
if(!isset($allProducts[$productID])) $allProducts[$product->id] = $product->name;
|
||||
if(!isset($allProducts[$productID])) $allProducts[$productID] = $product->name;
|
||||
foreach($branches[$productID] as $branchID => $branch)
|
||||
{
|
||||
$linkedBranches[$productID][$branchID] = $branchID;
|
||||
$productPlans[$productID][$branchID] = $this->productplan->getPairs($productID, $branchID);
|
||||
$productPlans[$productID][$branchID] = isset($plans[$productID][$branchID]) ? $plans[$productID][$branchID] : array();
|
||||
|
||||
$projectStories = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->andWhere('product')->eq($productID)->andWhere('branch')->eq($branchID)->fetchAll('story');
|
||||
if(!empty($projectStories))
|
||||
if(!empty($projectStories[$productID][$branchID]))
|
||||
{
|
||||
array_push($unmodifiableProducts, $productID);
|
||||
array_push($unmodifiableBranches, $branchID);
|
||||
@@ -554,7 +562,7 @@ class project extends control
|
||||
$this->view->program = $this->program->getByID($project->parent);
|
||||
$this->view->projectID = $projectID;
|
||||
$this->view->allProducts = array('0' => '') + $allProducts;
|
||||
$this->view->abnormalProducts = $this->loadModel('product')->getAbnormalProductPairs();
|
||||
$this->view->multiBranchProducts = $this->loadModel('product')->getMultiBranchPairs();
|
||||
$this->view->productPlans = array_filter($productPlans);
|
||||
$this->view->linkedProducts = $linkedProducts;
|
||||
$this->view->linkedBranches = $linkedBranches;
|
||||
@@ -1697,6 +1705,7 @@ class project extends control
|
||||
$allProducts = $this->program->getProductPairs($project->parent, 'assign', 'noclosed');
|
||||
$linkedProducts = $this->product->getProducts($projectID);
|
||||
$branches = $this->project->getBranchesByProject($projectID);
|
||||
$projectStories = $this->project->getStoriesByProject($projectID);
|
||||
|
||||
/* If the story of the product which linked the project, you don't allow to remove the product. */
|
||||
$unmodifiableProducts = array();
|
||||
@@ -1708,8 +1717,7 @@ class project extends control
|
||||
foreach($branches[$productID] as $branchID => $branch)
|
||||
{
|
||||
$linkedBranches[$productID][$branchID] = $branchID;
|
||||
$projectStories = $this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->andWhere('product')->eq($productID)->andWhere('branch')->eq($branchID)->fetchAll('story');
|
||||
if(!empty($projectStories))
|
||||
if(!empty($projectStories[$productID][$branchID]))
|
||||
{
|
||||
array_push($unmodifiableProducts, $productID);
|
||||
array_push($unmodifiableBranches, $branchID);
|
||||
|
||||
Reference in New Issue
Block a user