This commit is contained in:
hufangzhou
2021-01-18 14:21:55 +08:00
6 changed files with 48 additions and 42 deletions

View File

@@ -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();
}

View File

@@ -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;
}
}

View File

@@ -66,7 +66,7 @@
<th><?php echo $lang->program->PGMBudget;?></th>
<td>
<div class='input-group'>
<?php $placeholder = $parentProgram and $parentProgram->budget != 0 ? 'placeholder=' . $lang->program->PGMParentBudget . $remainBudget : '';?>
<?php $placeholder = ($parentProgram and $parentProgram->budget != 0) ? 'placeholder=' . $lang->program->PGMParentBudget . $remainBudget : '';?>
<?php echo html::input('budget', '', "class='form-control' " . (strpos($requiredFields, 'budget') !== false ? 'required ' : '') . $placeholder);?>
<?php if($parentProgram):?>
<span class='input-group-addon fix-border'><?php echo zget($budgetUnitList, $parentProgram->budgetUnit);?></span>

View File

@@ -44,7 +44,7 @@
<th><?php echo $lang->program->PGMBudget;?></th>
<td>
<div class='input-group'>
<?php $placeholder = $parentProgram and $parentProgram->budget != 0 ? 'placeholder=' . $lang->program->PGMParentBudget . $remainBudget : '';?>
<?php $placeholder = ($parentProgram and $parentProgram->budget != 0) ? 'placeholder=' . $lang->program->PGMParentBudget . $remainBudget : '';?>
<?php echo html::input('budget', $program->budget != 0 ? $program->budget : '', "class='form-control' " . (strpos($requiredFields, 'budget') !== false ? 'required ' : '') . ($program->budget == 0 ? 'disabled ' : '') . $placeholder);?>
<?php if($parentProgram):?>
<span class='input-group-addon'><?php echo zget($budgetUnitList, $program->budgetUnit);?></span>

View File

@@ -51,9 +51,14 @@
<th><?php echo $lang->program->PRJBudget;?></th>
<td>
<div class='input-group'>
<?php echo html::input('budget', '', "class='form-control' " . (strpos($requiredFields, 'budget') !== false ? ' required' : ''));?>
<?php $placeholder = ($parentProgram and $parentProgram->budget != 0) ? 'placeholder=' . $lang->program->PGMParentBudget . $remainBudget : '';?>
<?php echo html::input('budget', '', "class='form-control' " . (strpos($requiredFields, 'budget') !== false ? 'required ' : '') . $placeholder);?>
<?php if($parentProgram):?>
<span class='input-group-addon'><?php echo zget($budgetUnitList, $parentProgram->budgetUnit);?></span>
<?php else:?>
<span class='input-group-addon'></span>
<?php echo html::select('budgetUnit', $lang->program->unitList, empty($parentProgram->budgetUnit) ? 'wanyuan' : $parentProgram->budgetUnit, "class='form-control'");?>
<?php echo html::select('budgetUnit', $budgetUnitList, $config->program->mainCurrency, "class='form-control'");?>
<?php endif;?>
</div>
</td>
<td>

View File

@@ -53,9 +53,14 @@
<th><?php echo $lang->program->PRJBudget;?></th>
<td>
<div class='input-group'>
<?php echo html::input('budget', $project->budget != 0 ? $project->budget : '', "class='form-control' " . (strpos($requiredFields, 'budget') !== false ? ' required' : '') . ($project->budget == 0 ? 'disabled' : ''));?>
<?php $placeholder = ($parentProgram and $parentProgram->budget != 0) ? 'placeholder=' . $lang->program->PGMParentBudget . $remainBudget : '';?>
<?php echo html::input('budget', $project->budget != 0 ? $project->budget : '', "class='form-control' " . (strpos($requiredFields, 'budget') !== false ? 'required ' : '') . ($project->budget == 0 ? 'disabled ' : '') . $placeholder);?>
<?php if($parentProgram):?>
<span class='input-group-addon'><?php echo zget($budgetUnitList, $project->budgetUnit);?></span>
<?php else:?>
<span class='input-group-addon'></span>
<?php echo html::select('budgetUnit', $lang->program->unitList, $project->budgetUnit, "class='form-control'");?>
<?php echo html::select('budgetUnit', $budgetUnitList, $project->budgetUnit, "class='form-control'");?>
<?php endif;?>
</div>
</td>
<td>