* Reconstruction method.
This commit is contained in:
@@ -704,49 +704,6 @@ class program extends control
|
||||
echo $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get budget left.
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetBudgetLeft($programID)
|
||||
{
|
||||
$program = $this->program->getByID($programID);
|
||||
$budgetLeft = $this->program->getBudgetLeft($program);
|
||||
echo number_format($budgetLeft, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get available budget.
|
||||
*
|
||||
* @param int $programID
|
||||
* @param int $selectedProgramID
|
||||
* @param int $budget
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetAvailableBudget($programID, $selectedProgramID, $budget)
|
||||
{
|
||||
if(!empty($programID))
|
||||
{
|
||||
$program = $this->program->getByID($programID);
|
||||
$selectedProgram = $this->program->getByID($selectedProgramID);
|
||||
$budgetLeft = $this->program->getBudgetLeft($selectedProgram);
|
||||
$availableBudget = $program->parent == $selectedProgramID ? $budgetLeft + $program->budget : $budgetLeft;
|
||||
}
|
||||
else
|
||||
{
|
||||
$selectedProgram = $this->program->getByID($selectedProgramID);
|
||||
$availableBudget = $this->program->getBudgetLeft($selectedProgram);
|
||||
}
|
||||
|
||||
$tips = '';
|
||||
if($budget != 0 && $budget !== null && $budget > $availableBudget) $tips = "<span id='beyondBudgetTip' class='text-remind'>" . $this->lang->program->budgetOverrun . zget($this->lang->project->currencySymbol, $selectedProgram->budgetUnit) . $availableBudget . "</span>";
|
||||
echo json_encode($tips);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update program order.
|
||||
*
|
||||
|
||||
@@ -294,15 +294,19 @@ $(function()
|
||||
*/
|
||||
function setBudgetTipsAndAclList(parentID)
|
||||
{
|
||||
var selectedProgramID = $('#parent').val();
|
||||
var budget = $('#budget').val();
|
||||
|
||||
if(parentID != 0)
|
||||
{
|
||||
$.get(createLink('program', 'ajaxGetBudgetLeft', "ProgramID=" + parentID), function(budgetLeft)
|
||||
$.get(createLink('project', 'ajaxGetProgramInformation', "objectType=program&objectID=" + parentID + "&selectedProgramID=" + selectedProgramID + "&budget=" + budget), function(data)
|
||||
{
|
||||
var data = JSON.parse(data);
|
||||
parentProgram = programList[parentID];
|
||||
programBudget = parentProgram.budget;
|
||||
PGMBudgetUnit = currencySymbol[parentProgram.budgetUnit];
|
||||
|
||||
budgetNotes = programBudget != 0 ? (PGMParentBudget + PGMBudgetUnit + budgetLeft) : '';
|
||||
budgetNotes = programBudget != 0 ? (PGMParentBudget + PGMBudgetUnit + data.availableBudget) : '';
|
||||
$('#budget').attr('placeholder', budgetNotes);
|
||||
});
|
||||
$('.aclBox').html($('#subPGMAcl').html());
|
||||
@@ -334,11 +338,13 @@ function budgetOverrunTips()
|
||||
}
|
||||
|
||||
if(typeof(programID) == 'undefined') programID = 0;
|
||||
$.get(createLink('program', 'ajaxGetAvailableBudget', 'programID=' + programID + "&selectedProgramID=" + selectedProgramID + "&budget=" + budget), function(data)
|
||||
$.get(createLink('project', 'ajaxGetProgramInformation', 'objectType=program&objectID=' + programID + "&selectedProgramID=" + selectedProgramID + "&budget=" + budget), function(data)
|
||||
{
|
||||
var data = JSON.parse(data);
|
||||
|
||||
var tip = "";
|
||||
if(budget !=0 && budget !== null && budget > data.availableBudget) var tip = "<span id='beyondBudgetTip' class='text-remind'>" + budgetOverrun + currencySymbol[data.budgetUnit] + data.availableBudget + "</span>"
|
||||
if($('#beyondBudgetTip').length > 0) $('#beyondBudgetTip').remove();
|
||||
$('#budgetBox').after(data);
|
||||
$('#budgetBox').after(tip);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
<?php js::set('PGMParentBudget', $lang->program->parentBudget);?>
|
||||
<?php js::set('future', $lang->project->future);?>
|
||||
<?php js::set('programList', $programList);?>
|
||||
<?php js::set('budgetOverrun', $lang->project->budgetOverrun);?>
|
||||
<?php js::set('currencySymbol', $lang->project->currencySymbol)?>
|
||||
<?php js::set('parentBudget', $lang->program->parentBudget);?>
|
||||
<?php $aclList = $parentProgram ? $lang->program->subAclList : $lang->program->aclList;?>
|
||||
<?php $requiredFields = $config->program->create->requiredFields;?>
|
||||
<div id='mainContent' class='main-content'>
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
<?php js::set('exRateNum', sprintf($lang->error->float, $lang->program->exchangeRate));?>
|
||||
<?php js::set('exRateNotNegative', $lang->program->exRateNotNegative);?>
|
||||
<?php js::set('programID', $program->id);?>
|
||||
<?php js::set('budgetOverrun', $lang->project->budgetOverrun);?>
|
||||
<?php js::set('currencySymbol', $lang->project->currencySymbol)?>
|
||||
<?php js::set('parentBudget', $lang->program->parentBudget);?>
|
||||
<?php $aclList = $program->parent ? $lang->program->subAclList : $lang->program->aclList;?>
|
||||
<?php $requiredFields = $config->program->edit->requiredFields;?>
|
||||
<div id='mainContent' class='main-content'>
|
||||
|
||||
Reference in New Issue
Block a user