* Doing task #73985.
This commit is contained in:
@@ -127,6 +127,7 @@ class programModel extends model
|
||||
->beginIF($mode == 'assign')->andWhere('t1.program')->eq($programID)->fi()
|
||||
->beginIF(strpos($status, 'noclosed') !== false)->andWhere('t1.status')->ne('closed')->fi()
|
||||
->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($views)->fi()
|
||||
->orderBy('t1.program, t1.order_asc')
|
||||
->fetchGroup('program');
|
||||
|
||||
/* Put products of current program first.*/
|
||||
|
||||
@@ -281,6 +281,13 @@ class project extends control
|
||||
$data['selectedProgramPath'] = explode(',', $selectedProgram->path);
|
||||
}
|
||||
|
||||
if($objectType == 'program')
|
||||
{
|
||||
$allProducts = array(0 => '') + $this->program->getProductPairsWithProgram($selectedProgramID, 'all', 'noclosed');
|
||||
$data['allProducts'] = html::select("products[]", $allProducts, '', "class='form-control chosen' onchange='loadBranches(this)'");
|
||||
$data['plans'] = html::select('plans[][][]', '', '', 'class=\'form-control chosen\' multiple');
|
||||
}
|
||||
|
||||
/* Finish task #64882.Get the path of the last selected program. */
|
||||
if(!empty($objectID)) $data['objectPath'] = explode(',', $object->path);
|
||||
if(isset($availableBudget)) $data['availableBudget'] = $availableBudget;
|
||||
|
||||
@@ -143,10 +143,35 @@ function setParentProgram(parentProgram)
|
||||
$.get(createLink('project', 'ajaxGetObjectInfo', 'objectType=program&objectID=' + lastSelectedID + "&selectedProgramID=" + parentProgram), function(data)
|
||||
{
|
||||
var data = JSON.parse(data);
|
||||
selectedParent = parentProgram != 0 ? data.selectedProgramPath[1] : 0;
|
||||
selectedParent = parentProgram != 0 ? data.selectedProgramPath[1] : 0;
|
||||
lastSelectedParent = lastSelectedID != 0 ? data.objectPath[1] : 0;
|
||||
|
||||
if(selectedParent != lastSelectedParent) $('#budget').val('');
|
||||
if(selectedParent != lastSelectedParent)
|
||||
{
|
||||
$('#budget').val('');
|
||||
|
||||
var select = data.allProducts;
|
||||
var planSelect = data.plans;
|
||||
|
||||
var index = 0;
|
||||
$('#productsBox .row .col-sm-4 .input-group').each(function()
|
||||
{
|
||||
var selectedProduct = $(this).find('[name^=products]').val();
|
||||
var selectedBranch = $(this).find('[name^=branch]').val();
|
||||
|
||||
$(this).html(select);
|
||||
$(this).find('[name^=products]').attr('name', 'products[' + index + ']').attr('id', 'products' + index).attr('data-branch', selectedBranch);
|
||||
$(this).find('[name^=products]').val(selectedProduct).chosen().change();
|
||||
|
||||
index ++;
|
||||
});
|
||||
|
||||
/* Hide product and plan dropdown controls. */
|
||||
$('#plansBox .col-sm-4:not(:last)').remove();
|
||||
$('#plansBox .col-sm-4').children().remove();
|
||||
$('#plansBox .col-sm-4').prepend(planSelect);
|
||||
$('#plansBox .col-sm-4 select').chosen();
|
||||
}
|
||||
|
||||
if(parentProgram != 0)
|
||||
{
|
||||
@@ -289,8 +314,9 @@ function loadBranches(product)
|
||||
if($inputgroup.find('select').size() >= 2) $inputgroup.removeClass('has-branch').find('select:last').remove();
|
||||
if($inputgroup.find('.chosen-container').size() >= 2) $inputgroup.find('.chosen-container:last').remove();
|
||||
|
||||
var index = $inputgroup.find('select:first').attr('id').replace('products' , '');
|
||||
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + $(product).val() + "&oldBranch=0¶m=active"), function(data)
|
||||
var index = $inputgroup.find('select:first').attr('id').replace('products' , '');
|
||||
var oldBranch = $(product).attr('data-branch') !== undefined ? $(product).attr('data-branch') : 0;
|
||||
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + $(product).val() + "&oldBranch=" + oldBranch + "¶m=active"), function(data)
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user