diff --git a/module/program/control.php b/module/program/control.php index 27f6f139be..b98d158cdf 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -887,31 +887,34 @@ class program extends control } } - $allProducts = $this->program->getPGMProductPairs($programID); + $allProducts = $this->program->getPGMProductPairs($programID); + $parentProgram = $this->program->getPGMByID($programID); $this->view->title = $this->lang->program->PRJCreate; $this->view->position[] = $this->lang->program->PRJCreate; - $this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst'); - $this->view->users = $this->user->getPairs('noclosed|nodeleted'); - $this->view->copyProjects = $this->program->getPRJPairsByModel(); - $this->view->products = $products; - $this->view->allProducts = array('0' => '') + $allProducts; - $this->view->productPlans = array('0' => '') + $productPlans; - $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products)); - $this->view->programID = $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->from = $from; - $this->view->programList = $this->program->getParentPairs(); - $this->view->parentProgram = $this->program->getPGMByID($programID); - $this->view->URSRPairs = $this->loadModel('custom')->getURSRPairs(); + $this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst'); + $this->view->users = $this->user->getPairs('noclosed|nodeleted'); + $this->view->copyProjects = $this->program->getPRJPairsByModel(); + $this->view->products = $products; + $this->view->allProducts = array('0' => '') + $allProducts; + $this->view->productPlans = array('0' => '') + $productPlans; + $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products)); + $this->view->programID = $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->from = $from; + $this->view->programList = $this->program->getParentPairs(); + $this->view->parentProgram = $parentProgram; + $this->view->URSRPairs = $this->loadModel('custom')->getURSRPairs(); + $this->view->remainBudget = $this->program->getParentRemainBudget($parentProgram); + $this->view->budgetUnitList = $this->program->getBudgetUnitList(); $this->display(); } @@ -963,6 +966,7 @@ class program extends control $productPlans = array(0 => ''); $allProducts = $programID != $project->parent ? $this->program->getPGMProductPairs($programID) : $this->program->getPGMProductPairs($project->parent, 'assign', 'noclosed'); $linkedProducts = $programID != $project->parent ? array() : $this->project->getProducts($projectID); + $parentProgram = $this->program->getPGMByID($programID); foreach($linkedProducts as $product) { @@ -989,6 +993,9 @@ class program extends control $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($linkedProducts), '', $linkedBranches); $this->view->URSRPairs = $this->loadModel('custom')->getURSRPairs(); $this->view->from = $from; + $this->view->parentProgram = $parentProgram; + $this->view->remainBudget = $this->program->getParentRemainBudget($parentProgram); + $this->view->budgetUnitList = $this->program->getBudgetUnitList(); $this->display(); } diff --git a/module/program/model.php b/module/program/model.php index 1c35f65580..43bb2b8e0b 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1389,13 +1389,8 @@ class programModel extends model /* The budget of a child project cannot beyond the remaining budget of the parent program. */ if(isset($project->budget) and $parentProgram->budget != 0) { - $childGrade = $parentProgram->grade + 1; - $childSumBudget = $this->dao->select("sum(budget) as sumBudget")->from(TABLE_PROJECT) - ->where('path')->like("%{$project->parent}%") - ->andWhere('grade')->eq($childGrade) - ->fetch('sumBudget'); - - if($project->budget > $parentProgram->budget - $childSumBudget) dao::$errors['budget'] = $this->lang->program->beyondParentBudget; + $parentRemainBudget = $this->getParentRemainBudget($parentProgram); + if($project->budget > $parentRemainBudget) dao::$errors['budget'] = $this->lang->program->beyondParentBudget; } /* Judge products not empty. */ @@ -1573,14 +1568,8 @@ class programModel extends model /* The budget of a child project cannot beyond the remaining budget of the parent program. */ if($project->budget != 0 and $parentProgram->budget != 0) { - $childGrade = $parentProgram->grade + 1; - $childSumBudget = $this->dao->select("sum(budget) as sumBudget")->from(TABLE_PROJECT) - ->where('path')->like("%{$project->parent}%") - ->andWhere('grade')->eq($childGrade) - ->andWhere('id')->ne($projectID) - ->fetch('sumBudget'); - - if($project->budget > $parentProgram->budget - $childSumBudget) dao::$errors['budget'] = $this->lang->program->beyondParentBudget; + $parentRemainBudget = $this->getParentRemainBudget($parentProgram); + if($project->budget > $parentRemainBudget + $project->budget) dao::$errors['budget'] = $this->lang->program->beyondParentBudget; } } diff --git a/module/program/view/pgmcreate.html.php b/module/program/view/pgmcreate.html.php index ec61909b52..f113fc616d 100644 --- a/module/program/view/pgmcreate.html.php +++ b/module/program/view/pgmcreate.html.php @@ -66,7 +66,7 @@ program->PGMBudget;?>
- budget != 0 ? 'placeholder=' . $lang->program->PGMParentBudget . $remainBudget : '';?> + budget != 0) ? 'placeholder=' . $lang->program->PGMParentBudget . $remainBudget : '';?> budgetUnit);?> diff --git a/module/program/view/pgmedit.html.php b/module/program/view/pgmedit.html.php index 915dc13a86..0dfee337fc 100644 --- a/module/program/view/pgmedit.html.php +++ b/module/program/view/pgmedit.html.php @@ -44,7 +44,7 @@ program->PGMBudget;?>
- budget != 0 ? 'placeholder=' . $lang->program->PGMParentBudget . $remainBudget : '';?> + budget != 0) ? 'placeholder=' . $lang->program->PGMParentBudget . $remainBudget : '';?> budget != 0 ? $program->budget : '', "class='form-control' " . (strpos($requiredFields, 'budget') !== false ? 'required ' : '') . ($program->budget == 0 ? 'disabled ' : '') . $placeholder);?> budgetUnit);?> diff --git a/module/program/view/prjcreate.html.php b/module/program/view/prjcreate.html.php index e4ae72680c..4f00282792 100644 --- a/module/program/view/prjcreate.html.php +++ b/module/program/view/prjcreate.html.php @@ -51,9 +51,14 @@ program->PRJBudget;?>
- + budget != 0) ? 'placeholder=' . $lang->program->PGMParentBudget . $remainBudget : '';?> + + + budgetUnit);?> + - program->unitList, empty($parentProgram->budgetUnit) ? 'wanyuan' : $parentProgram->budgetUnit, "class='form-control'");?> + program->mainCurrency, "class='form-control'");?> +
diff --git a/module/program/view/prjedit.html.php b/module/program/view/prjedit.html.php index 1d0416da0c..9b88da6aaf 100644 --- a/module/program/view/prjedit.html.php +++ b/module/program/view/prjedit.html.php @@ -53,9 +53,14 @@ program->PRJBudget;?>
- budget != 0 ? $project->budget : '', "class='form-control' " . (strpos($requiredFields, 'budget') !== false ? ' required' : '') . ($project->budget == 0 ? 'disabled' : ''));?> + budget != 0) ? 'placeholder=' . $lang->program->PGMParentBudget . $remainBudget : '';?> + budget != 0 ? $project->budget : '', "class='form-control' " . (strpos($requiredFields, 'budget') !== false ? 'required ' : '') . ($project->budget == 0 ? 'disabled ' : '') . $placeholder);?> + + budgetUnit);?> + - program->unitList, $project->budgetUnit, "class='form-control'");?> + budgetUnit, "class='form-control'");?> +