diff --git a/module/execution/control.php b/module/execution/control.php
index 62de145e05..06c63487db 100644
--- a/module/execution/control.php
+++ b/module/execution/control.php
@@ -1705,7 +1705,7 @@ class execution extends control
foreach($branches[$productIndex] as $branchID => $branch)
{
$linkedBranches[$productIndex][$branchID] = $branchID;
- $productPlans[$productIndex][$branchID] = isset($plans[$productIndex][$branchID]) ? $plans[$productIndex][$branchID] : array();
+ $productPlans[$productIndex] = isset($plans[$productIndex][$branchID]) ? $plans[$productIndex][$branchID] : array();
}
}
@@ -1740,7 +1740,7 @@ class execution extends control
foreach($branches[$productIndex] as $branchID => $branch)
{
$linkedBranches[$productIndex][$branchID] = $branchID;
- $productPlans[$productIndex][$branchID] = isset($plans[$productIndex][$branchID]) ? $plans[$productIndex][$branchID] : array();
+ $productPlans[$productIndex] = isset($plans[$productIndex][$branchID]) ? $plans[$productIndex][$branchID] : array();
}
}
@@ -2033,8 +2033,8 @@ class execution extends control
{
$linkedBranchList[$branchID] = $branchID;
$linkedBranches[$productID][$branchID] = $branchID;
- $productPlans[$productID][$branchID] = isset($plans[$productID][$branchID]) ? $plans[$productID][$branchID] : array();
- if($branchID != BRANCH_MAIN and isset($plans[$productID][BRANCH_MAIN])) $productPlans[$productID][$branchID] += $plans[$productID][BRANCH_MAIN];
+ $productPlans[$productID] = isset($plans[$productID][$branchID]) ? $plans[$productID][$branchID] : array();
+ if($branchID != BRANCH_MAIN and isset($plans[$productID][BRANCH_MAIN])) $productPlans[$productID] += $plans[$productID][BRANCH_MAIN];
if(!empty($executionStories[$productID][$branchID]))
{
array_push($unmodifiableProducts, $productID);
diff --git a/module/execution/css/create.css b/module/execution/css/create.css
index 839355f188..b3ef4c9ba2 100644
--- a/module/execution/css/create.css
+++ b/module/execution/css/create.css
@@ -21,9 +21,9 @@
.chosen-container.chosen-highlight-selected .disabled-result.result-selected {background: none;}
-#productsBox .row .col-sm-4 {padding-right: 13px;}
-#plansBox .row {display: inline-table; width: 102%;}
-#plansBox .row .col-sm-4 {display: inline-block; float: none; padding-right: 13px;}
+.productsBox .row .col-sm-4 {padding-right: 13px;}
+.plansBox .row {display: inline-table; width: 102%;}
+.plansBox .row .col-sm-4 {display: inline-block; float: none; padding-right: 13px;}
#dateRange {vertical-align: top; padding-top: 13px;}
#dateRangeOption {vertical-align: top; padding-top: 13px;}
@@ -32,3 +32,9 @@
#copyProjectModal .projectSelect {display: inline-block; margin-left: 10px; width: 20%;}
#copyProjectModal .titleBox{position: relative; bottom: 3px; display: inline-block;}
a.chosen-single > div > b {top: -4px !important;}
+
+.productsBox a {border-radius: 2px !important;}
+.productsBox .required:after {right: -9.5px !important;}
+.productsBox .input-group-addon > div {display: inline-block !important;}
+.productsBox .required + .text-danger.help-text {position: relative; left: 10px;}
+.productsBox > #productNameLabel {padding-top: 8px;}
diff --git a/module/execution/js/common.js b/module/execution/js/common.js
index 19d68b6372..b7a2eb2964 100644
--- a/module/execution/js/common.js
+++ b/module/execution/js/common.js
@@ -113,6 +113,15 @@ function computeEndDate(delta)
computeWorkDays();
}
+/* Auto compute the work days. */
+$(function()
+{
+ $(".date").bind('dateSelected', function()
+ {
+ computeWorkDays(this.id);
+ })
+});
+
/**
* Load branches.
*
@@ -122,118 +131,127 @@ function computeEndDate(delta)
*/
function loadBranches(product)
{
- if($('#productsBox .input-group:last select:first').val() != 0)
+ /* When selecting a product, delete a plan that is empty by default. */
+ $("#planDefault").remove();
+
+ $(".productsBox select[name^='products']").each(function()
{
- if(model !== 'waterfall')
+ var $product = $(product);
+ var productID = $(this).val();
+ if($product.val() != 0 && $product.val() == $(this).val() && $product.attr('id') != $(this).attr('id') && !multiBranchProducts[$product.val()])
{
- var length = $('#productsBox .input-group').size();
- $('#productsBox .row').append('
' + $('#productsBox .col-sm-4:last').html().replace('required', '') + '
');
- if($('#productsBox .input-group:last select').size() >= 2) $('#productsBox .input-group:last select:last').remove();
- $('#productsBox .input-group:last .chosen-container').remove();
- $('#productsBox .input-group:last select:first').attr('name', 'products[' + length + ']').attr('id', 'products' + length);
- $('#productsBox .input-group:last .chosen').chosen();
+ bootbox.alert(errorSameProducts);
+ $product.val(0);
+ $product.trigger("chosen:updated");
+ return false;
}
- adjustProductBoxMargin();
+ });
+
+ var $tableRow = $(product).closest('.table-row');
+ var index = $tableRow.find('select:first').attr('id').replace('products' , '');
+ var oldBranch = $(product).attr('data-branch') !== undefined ? $(product).attr('data-branch') : 0;
+ if($(product).val() != 0)
+ {
+ $(product).closest('tr').find('.newProduct').addClass('hidden')
+ }
+ else
+ {
+ $(product).closest('tr').find('.newProduct').removeClass('hidden')
}
- var $inputgroup = $(product).closest('.input-group');
- 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();
+ if(!multiBranchProducts[$(product).val()])
+ {
+ $tableRow.find('.table-col:last select').val('').trigger('chosen:updated');
+ $tableRow.find('.table-col:last').addClass('hidden');
+ }
- var projectID = $('#project').val();
- if(typeof(projectID) == 'undefined') projectID = 0;
-
- var index = $inputgroup.find('select:first').attr('id').replace('products' , '');
- $.get(createLink('branch', 'ajaxGetBranches', "productID=" + $(product).val() + "&oldBranch=0¶m=active&projectID=" + projectID + "&withMainBranch=true"), function(data)
+ $.get(createLink('branch', 'ajaxGetBranches', "productID=" + $(product).val() + "&oldBranch=" + oldBranch + "¶m=active&projectID=" + projectID + "&withMainBranch=true"), function(data)
{
if(data)
{
- $inputgroup.addClass('has-branch').append(data);
- $inputgroup.find('select:last').attr('name', 'branch[' + index + ']').attr('id', 'branch' + index).attr('onchange', "loadPlans('#products" + index + "', this.value)").chosen();
+ $tableRow.find("select[name^='branch']").replaceWith(data);
+ $tableRow.find('.table-col:last .chosen-container').remove();
+ $tableRow.find('.table-col:last').removeClass('hidden');
+ $tableRow.find("select[name^='branch']").attr('multiple', '').attr('name', 'branch[' + index + '][]').attr('id', 'branch' + index).attr('onchange', "loadPlans('#products" + index + "', this)").chosen();
- $inputgroup.find('select:last').each(disableSelectedBranch);
disableSelectedProduct();
}
- var branchID = $('#branch' + index).val();
- loadPlans(product, branchID);
+ var branch = $('#branch' + index);
+ loadPlans(product, branch);
});
-
- if(!multiBranchProducts[$(product).val()]) disableSelectedProduct();
}
/**
- * Load plans by product id.
+ * Load plans.
*
- * @param int $product
- * @param int $branchID
+ * @param obj $product
+ * @param obj $branchID
* @access public
* @return void
*/
-function loadPlans(product, branchID)
+function loadPlans(product, branch)
{
- if($('#plansBox').size() == 0) return false;
-
var productID = $(product).val();
- var branchID = typeof(branchID) == 'undefined' ? 0 : branchID;
+ var branchID = $(branch).val() == null ? 0 : '0,' + $(branch).val();
+ var planID = $(product).attr('data-plan') !== undefined ? $(product).attr('data-plan') : 0;
var index = $(product).attr('id').replace('products', '');
- $.get(createLink('product', 'ajaxGetPlans', "productID=" + productID + '&branch=0,' + branchID + '&planID=0&fieldID&needCreate=&expired=noclosed,unexpired¶m=skipParent,multiple'), function(data)
+ $.get(createLink('product', 'ajaxGetPlans', "productID=" + productID + '&branch=' + branchID + '&planID=' + planID + '&fieldID&needCreate=&expired=unexpired,noclosed¶m=skipParent,multiple'), function(data)
{
if(data)
{
- if($("div#plan" + index).size() == 0) $("#plansBox .row").append('');
- $("div#plan" + index).html(data).find('select').attr('name', 'plans[' + productID + '][' + branchID + '][]').attr('id', 'plans' + productID).chosen();
-
- adjustPlanBoxMargin();
+ $("div#plan" + index).find("select[name^='plans']").replaceWith(data);
+ $("div#plan" + index).find('.chosen-container').remove();
+ $("div#plan" + index).find('select').attr('name', 'plans[' + productID + ']' + '[]').attr('id', 'plans' + productID).chosen();
}
});
}
/**
- * Adjust product box margin.
- *
+ * Add new line for link product.
+ *
+ * @param obj $obj
* @access public
* @return void
*/
-function adjustProductBoxMargin()
+function addNewLine(obj)
{
- var productRows = Math.ceil($('#productsBox > .row > .col-sm-4').length / 3);
- if(productRows > 1)
+ var newLine = $(obj).closest('tr').clone();
+ var index = 0;
+ $(".productsBox select[name^='products']").each(function()
{
- for(i = 1; i <= productRows - 1; i++)
- {
- $('#productsBox .col-sm-4:lt(' + (i * 3) + ')').css('margin-bottom', '10px');
- }
- }
-}
+ var id = $(this).attr('id').replace('products' , '');
-/**
- * Adjust plan box margin.
- *
- * @access public
- * @return void
- */
-function adjustPlanBoxMargin()
-{
- var planRows = Math.ceil($('#plansBox > .row > .col-sm-4').length / 3);
- if(planRows > 1)
- {
- for(j = 1; j <= planRows - 1; j++)
- {
- $('#plansBox .col-sm-4:lt(' + (j * 3) + ')').css('margin-bottom', '10px');
- }
- }
-}
+ id = parseInt(id);
+ id ++;
-/* Auto compute the work days. */
-$(function()
-{
- $(".date").bind('dateSelected', function()
- {
- computeWorkDays(this.id);
+ index = id > index ? id : index;
})
-});
+
+ newLine.find('.newProduct').remove();
+ newLine.find('.addProduct').remove();
+ newLine.addClass('newLine');
+ newLine.find('th').html('');
+ newLine.find('.removeLine').css('visibility', 'visible');
+ newLine.find('.chosen-container').remove();
+ newLine.find('.productsBox .table-col:last').addClass('hidden');
+ newLine.find("select[name^='products']").attr('name', 'products[' + index + ']').attr('id', 'products' + index).val('').chosen();
+ newLine.find("select[name^='plans']").attr('name', 'plans[' + index + '][' + 0 + '][]').chosen();
+ newLine.find("div[id^='plan']").attr('id', 'plan' + index);
+
+ $(obj).closest('tr').after(newLine);
+ var product = newLine.find("select[name^='products']");
+ var branch = newLine.find("select[name^='branch']");
+ loadPlans(product, branch);
+ disableSelectedProduct();
+}
+
+function removeLine(obj)
+{
+ $(obj).closest('tr').remove();
+ disableSelectedProduct();
+}
$(function()
{
@@ -247,9 +265,6 @@ $(function()
e.stopPropagation();
e.preventDefault();
});
-
- adjustProductBoxMargin();
- adjustPlanBoxMargin();
});
/**
diff --git a/module/execution/model.php b/module/execution/model.php
index 8aecc43b56..cc2033499b 100755
--- a/module/execution/model.php
+++ b/module/execution/model.php
@@ -2370,23 +2370,28 @@ class executionModel extends model
$oldPlan = 0;
$branch = isset($branches[$i]) ? $branches[$i] : 0;
- if(isset($existedProducts[$productID][$branch])) continue;
+ if(!is_array($branch)) $branch = array($branch);
- if(isset($oldProducts[$productID][$branch]))
+ foreach($branch as $branchID)
{
- $oldProduct = $oldProducts[$productID][$branch];
- if($this->app->rawMethod != 'edit') $oldPlan = $oldProduct->plan;
- }
+ if(isset($existedProducts[$productID][$branchID])) continue;
- $data = new stdclass();
- $data->project = $executionID;
- $data->product = $productID;
- $data->branch = $branch;
- $data->plan = isset($plans[$productID][$branch]) ? implode(',', $plans[$productID][$branch]) : $oldPlan;
- $data->plan = trim($data->plan, ',');
- $data->plan = empty($data->plan) ? 0 : ",$data->plan,";
- $this->dao->insert(TABLE_PROJECTPRODUCT)->data($data)->exec();
- $existedProducts[$productID][$branch] = true;
+ if(isset($oldProducts[$productID][$branchID]))
+ {
+ $oldProduct = $oldProducts[$productID][$branchID];
+ if($this->app->rawMethod != 'edit') $oldPlan = $oldProduct->plan;
+ }
+
+ $data = new stdclass();
+ $data->project = $executionID;
+ $data->product = $productID;
+ $data->branch = $branchID;
+ $data->plan = isset($plans[$productID]) ? implode(',', $plans[$productID]) : $oldPlan;
+ $data->plan = trim($data->plan, ',');
+ $data->plan = empty($data->plan) ? 0 : ",$data->plan,";
+ $this->dao->insert(TABLE_PROJECTPRODUCT)->data($data)->exec();
+ $existedProducts[$productID][$branchID] = true;
+ }
}
$oldProductKeys = array_keys($oldProducts);
diff --git a/module/execution/view/create.html.php b/module/execution/view/create.html.php
index 8868df5b4d..9fa8689fa2 100644
--- a/module/execution/view/create.html.php
+++ b/module/execution/view/create.html.php
@@ -130,61 +130,81 @@
printExtendFields('', 'table', 'columns=3');?>
hasProduct)) $hidden = ''?>
+
+
+
- | execution->manageProducts;?> |
-
+ | project->manageProductPlan;?> |
+
-
-
-
- type != 'normal' and isset($branchGroups[$product->id]));?>
- id] as $branchID => $branch):?>
- |
- model) and $project->model == 'scrum') $hidden = '';?>
-
- | execution->linkPlan;?> |
-
+
+
+
+ |
+ | project->manageProductPlan;?> |
+
- begin)):?>
- product}][{$plan->branch}][]", $productPlan, $plan->id, "class='form-control chosen' multiple");?>
- id)?>
-
-
-
- id] as $branchID => $branch):?>
- id][$branchID]) ? $productPlans[$product->id][$branchID] : array();?>
- id}][$branchID][]", $plans, $branches[$product->id][$branchID]->plan, "class='form-control chosen' multiple");?>
-
-
-
-
-
-
-
+
+
+
+
+ product->common;?>
+
+
+
+
+
+ product->branchName['branch'];?>
+
+
+
+
+
+
|
+
| execution->teamname;?> |
|
diff --git a/module/execution/view/edit.html.php b/module/execution/view/edit.html.php
index 0f6507834d..5ef11f6ee6 100644
--- a/module/execution/view/edit.html.php
+++ b/module/execution/view/edit.html.php
@@ -141,56 +141,45 @@
attribute, array('request', 'design', 'review'))): ?>
hasProduct)) $hidden = ''?>
+
+
- | execution->manageProducts;?> |
-
- grade == 2 or $execution->type == 'stage') ? "disabled" : '';?>
+ | project->manageProductPlan;?> |
+
-
-
- type != 'normal' and isset($branchGroups[$product->id]);?>
- id] as $branchID => $branch):?>
- |
-
- model) and $project->model == 'scrum') $hidden = '';?>
-
- | execution->linkPlan;?> |
-
-
-
-
-
-
-
- id] as $branchID => $branch):?>
- id][$branchID]) ? $productPlans[$product->id][$branchID] : array();?>
- id}][{$branchID}][]", $plans, $branches[$product->id][$branchID]->plan, "class='form-control chosen' multiple");?>
-
-
-
-
|
+
+
@@ -232,5 +221,6 @@
execution->confirmSync);?>
+project);?>
project->unLinkProductTip);?>
diff --git a/module/project/css/create.css b/module/project/css/create.css
index 21c3fceddd..9d2c6d922c 100755
--- a/module/project/css/create.css
+++ b/module/project/css/create.css
@@ -16,15 +16,13 @@
#budgetUnit {border-left: 0px;}
#projectName {display: inline-block; width: 32%;}
.productsBox a {border-radius: 2px !important;}
-.productsBox .col-sm-4 {padding-right: 5px;}
.productsBox .required:after {right: -9.5px !important;}
.productsBox .addProduct {padding-left: 0px !important;}
.productsBox .addProduct.required:after {right: -1px !important;}
.productsBox .input-group-addon > div {display: inline-block !important;}
.productsBox .required + .text-danger.help-text {position: relative; left: 10px;}
.productsBox > #productNameLabel {padding-top: 8px;}
-#plansBox .col-sm-4 {float: none; display: inline-block; padding-right: 5px;}
.futureBox {vertical-align: top !important; padding-top: 13px !important;}
#projectType {padding-top: 7px !important;}
.division .icon-help {margin-left: 15px}
-.has-info {border-color: #0c64eb!important;}
\ No newline at end of file
+.has-info {border-color: #0c64eb!important;}
diff --git a/module/project/js/create.js b/module/project/js/create.js
index c4224e113b..ff42309610 100644
--- a/module/project/js/create.js
+++ b/module/project/js/create.js
@@ -397,7 +397,7 @@ function addNewLine(obj)
newLine.find('.removeLine').css('visibility', 'visible');
newLine.find('.chosen-container').remove();
newLine.find('.productsBox .table-col:last').addClass('hidden');
- newLine.find("select[name^='products']").attr('name', 'products[' + index + ']').attr('id', 'products' + index).chosen();
+ newLine.find("select[name^='products']").attr('name', 'products[' + index + ']').attr('id', 'products' + index).val('').chosen();
newLine.find("select[name^='plans']").attr('name', 'plans[' + index + '][' + 0 + '][]').chosen();
newLine.find("div[id^='plan']").attr('id', 'plan' + index);
diff --git a/module/project/view/create.html.php b/module/project/view/create.html.php
index 1b8cb9b15f..168d65b784 100755
--- a/module/project/view/create.html.php
+++ b/module/project/view/create.html.php
@@ -228,64 +228,6 @@
-
| project->division;?> |