428 lines
22 KiB
Plaintext
428 lines
22 KiB
Plaintext
@using EnVisage.Code
|
|
@using EnVisage.Code.HtmlHelpers
|
|
@using EnVisage.Models
|
|
@model ScenarioModel
|
|
@{
|
|
ViewBag.Title = Model.Id != Guid.Empty ? "Edit " + Model.Name : "Add New Scenario";
|
|
}
|
|
@section Scripts
|
|
{
|
|
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
|
|
<script type="text/javascript">
|
|
emulateNavUrl = "/Scenarios";
|
|
init.push(function() {
|
|
|
|
$(".datepicker").datepicker({
|
|
autoclose: true
|
|
});
|
|
@if (Model.Id == Guid.Empty || ScenarioStatus.Draft.Equals(Model.Status))
|
|
{
|
|
<text>
|
|
$("input[name='@Html.ClientIdFor(x => x.StartDate)']").change(dateChanged).on('changeDate', dateChanged);
|
|
</text>
|
|
}
|
|
function dateChanged(dateUpdated) {
|
|
$("input[name='MilestoneStartDate']").val($(this).val());
|
|
$("input[name='MilestoneStartDate']").datepicker({
|
|
autoclose: true
|
|
});
|
|
$("input[name='MilestoneStartDate']").datepicker('changeDate');
|
|
if ($('#EndDate').val() == "")
|
|
$('#EndDate').val($(this).val());
|
|
}
|
|
|
|
$('.input-color').minicolors({
|
|
control: 'hue',
|
|
position: 'bottom left',
|
|
theme: 'bootstrap'
|
|
});
|
|
|
|
@*$('#@Html.ClientIdFor(model => model.LaborSplitPercentage)_container').slider({
|
|
'range': 'min',
|
|
'min': 0,
|
|
'max': 100,
|
|
'value': $('#@Html.ClientIdFor(model => model.LaborSplitPercentage)_container .sliderValue').val(),
|
|
change: onDependentChange,
|
|
slide: onDependentSlide
|
|
});*@
|
|
@if (Model.Id != Guid.Empty)
|
|
{
|
|
@:StartEdit('Scenario', '@Model.Id', "#btnDelete", "#btnsave", "erorMsgPlaceholder");
|
|
}
|
|
$("#@Html.ClientIdFor(t => t.Type)").change(function() {
|
|
if ($(this).val() == '@ScenarioType.Scheduling.ToString()') {
|
|
$("#fsFin").hide();
|
|
} else {
|
|
$("#fsFin").show();
|
|
}
|
|
});
|
|
$("input[name=UseLMMargin]").click(function() {
|
|
if ($(this).val() == "False") {
|
|
$("#@Html.ClientIdFor(t => t.GrossMargin)").attr('disabled', false);
|
|
$("#@Html.ClientIdFor(t => t.LMMargin)").attr('disabled', true);
|
|
$("#@Html.ClientIdFor(t => t.LMMargin)").val("");
|
|
} else {
|
|
$("#@Html.ClientIdFor(t => t.GrossMargin)").attr('disabled', true);
|
|
$("#@Html.ClientIdFor(t => t.LMMargin)").attr('disabled', false);
|
|
$("#@Html.ClientIdFor(t => t.GrossMargin)").val("");
|
|
}
|
|
});
|
|
@if (Model.Id != Guid.Empty && !ScenarioStatus.Draft.Equals(Model.Status))
|
|
{
|
|
<text>
|
|
$("#@Html.ClientIdFor(t => t.AllowAdjustment)").change(function () {
|
|
if ($(this).prop("checked") == true) {
|
|
$("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").prop("disabled", true);
|
|
$("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").datepicker("disable");
|
|
$("#@Html.ClientIdFor(t => t.StartDate)").prop("disabled", false);
|
|
$("#@Html.ClientIdFor(t => t.StartDate)").datepicker('enable');
|
|
} else {
|
|
$("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").prop("disabled", false);
|
|
$("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").datepicker('enable');
|
|
$("#@Html.ClientIdFor(t => t.StartDate)").prop("disabled", true);
|
|
$("#@Html.ClientIdFor(t => t.StartDate)").datepicker("disable");
|
|
}
|
|
});
|
|
</text>
|
|
}
|
|
$("#@Html.ClientIdFor(t => t.GrowthScenario)").change(function() {
|
|
if ($(this).prop("checked") == true) {
|
|
$("#@Html.ClientIdFor(t => t.UseActuals)").prop("disabled", true);
|
|
$("#@Html.ClientIdFor(t => t.UseActuals)").prop("checked", false);
|
|
$("#lblActualsCantBeChecked").show();
|
|
} else {
|
|
$("#@Html.ClientIdFor(t => t.UseActuals)").prop("disabled", false);
|
|
//$("#@Html.ClientIdFor(t => t.UseActuals)").prop("checked", true);
|
|
$("#lblActualsCantBeChecked").hide();
|
|
}
|
|
});
|
|
|
|
$("#@Html.ClientIdFor(t => t.UseActuals)").change(function () {
|
|
if ($(this).prop("checked") == true) {
|
|
if ($("#@Html.ClientIdFor(t => t.GrowthScenario)").prop("checked") == true)
|
|
$(this).prop("checked", false);
|
|
}
|
|
//else
|
|
@*{
|
|
$("#@Html.ClientIdFor(t => t.GrowthScenario)").prop("checked", true);
|
|
}*@
|
|
});
|
|
|
|
$("#@Html.ClientIdFor(t => t.TemplateId)").change(loadExpenditures);
|
|
|
|
var options2 = {
|
|
orientation: $('body').hasClass('right-to-left') ? "auto right" : 'auto auto'
|
|
};
|
|
$('#bs-datepicker-range').datepicker(options2);
|
|
$('#bs-datepicker-range span.input-group-addon').hide();
|
|
@* $('#@Html.ClientIdFor(t => t.StartDate)').addClass('form-control');
|
|
$('#@Html.ClientIdFor(t => t.EndDate)').addClass('form-control');
|
|
$('#@Html.ClientIdFor(t => t.StartDate)').removeClass('text-box');
|
|
$('#@Html.ClientIdFor(t => t.EndDate)').removeClass('text-box');
|
|
$('#@Html.ClientIdFor(t => t.StartDate)').removeClass('single-line');
|
|
$('#@Html.ClientIdFor(t => t.EndDate)').removeClass('single-line');*@
|
|
});
|
|
|
|
function RecalcExpense(el)
|
|
{
|
|
var expense = $("#@Html.ClientIdFor(x => x.TDDirectCosts)");
|
|
var revenue = 0;
|
|
var margin = 0;
|
|
var useLMMargin = $("#@Html.ClientIdFor(x => x.UseLMMargin)")[0].checked;
|
|
if (el.id == '@Html.ClientIdFor(x => x.ProjectedRevenue)') {
|
|
revenue = parseFloat($(el).val());
|
|
margin = useLMMargin ? parseFloat($('#@Html.ClientIdFor(x => x.GrossMargin)').val()) :
|
|
0; //parseFloat($('#@Html.ClientIdFor(x => x.LMMargin)').val());
|
|
} else if (el.id == '@Html.ClientIdFor(x => x.GrossMargin)') {
|
|
margin = parseFloat($(el).val());
|
|
revenue = parseFloat($('#@Html.ClientIdFor(x => x.ProjectedRevenue)').val());
|
|
} else if (el.id == '@Html.ClientIdFor(x => x.LMMargin)') {
|
|
margin = parseFloat($(el).val());
|
|
revenue = parseFloat($('#@Html.ClientIdFor(x => x.ProjectedRevenue)').val());
|
|
}
|
|
if (!isNaN(revenue) && !isNaN(margin))
|
|
{
|
|
var buDirectCosts = $("#@Html.ClientIdFor(x => x.BUDirectCosts)");
|
|
expense.val(revenue - parseFloat(buDirectCosts.val()) * margin / 100);
|
|
}
|
|
}
|
|
|
|
function onDependentSlide(event, ui) {
|
|
var value = ui.value;
|
|
$(this).children(".sliderValue").val(value);
|
|
$(this).children(".sliderTitle").html(value + '%');
|
|
}
|
|
|
|
function onDependentChange(event, ui) {
|
|
var value = ui.value;
|
|
$(this).children(".sliderValue").val(value);
|
|
$(this).children(".sliderTitle").html(value + '%');
|
|
}
|
|
|
|
function loadExpenditures() {
|
|
$('#expendituresContainer').load("@Url.Action("LoadExpenditures", "Scenarios")/" + $("#@Html.ClientIdFor(t => t.TemplateId)").val());
|
|
}
|
|
function onSave(val) {
|
|
$('#@Html.ClientIdFor(t=>t.AsDraft)').val(val);
|
|
if ($('#frmEditScenario').valid())
|
|
blockUI();
|
|
return true;
|
|
}
|
|
</script>
|
|
}
|
|
|
|
<div id="erorMsgPlaceholder"></div>
|
|
|
|
@using (Html.BeginForm("Edit", "Scenarios", FormMethod.Post, new { @class = "panel form-horizontal", @id = "frmEditScenario" }))
|
|
{
|
|
@Html.AntiForgeryToken()
|
|
@Html.HiddenFor(t => t.Id)
|
|
@Html.HiddenFor(t => t.ParentId)
|
|
@Html.HiddenFor(t => t.BUDirectCosts)
|
|
@Html.HiddenFor(t => t.IsRevenueGenerating)
|
|
@Html.HiddenFor(t => t.StartDateDisabled)
|
|
@Html.HiddenFor(t => t.BackUrl)
|
|
@Html.HiddenFor(t => t.BackName)
|
|
@Html.HiddenFor(t => t.AsDraft)
|
|
@Html.HiddenFor(t => t.Status)
|
|
<div class="panel-body">
|
|
<fieldset id="fsBasic">
|
|
<legend class="text-bold">Scenario Information</legend>
|
|
<div class="form-group">
|
|
<label class="col-sm-3 control-label" for="Name">Project Name</label>
|
|
<div class="col-sm-9">
|
|
<input id="ProjectName" class="form-control" disabled="disabled" type="text" value="@Html.GetProjectName(Model.ParentId)">
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.Name, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
@Html.TextBoxFor(model => model.Name, new { @class = "form-control" })
|
|
@Html.ValidationMessageFor(model => model.Name)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.Color, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
@Html.TextBoxFor(model => model.Color, new { @class = "form-control input-color" })
|
|
@Html.ValidationMessageFor(model => model.Color)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.Type, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
@Html.DropDownListFor(model => model.Type, Utils.GetScenarioTypes4Wizard(), new { @class = "form-control" })
|
|
@Html.ValidationMessageFor(model => model.Type)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.TemplateId, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
@if (Model.Id == Guid.Empty || ScenarioStatus.Draft.Equals(Model.Status))
|
|
{
|
|
@Html.DropDownListFor(model => model.TemplateId, Utils.GetScenarioTemplates(ScenarioStatus.Draft.Equals(Model.Status)), new { @class = "form-control" })
|
|
}
|
|
else
|
|
{
|
|
@Html.DropDownListFor(model => model.TemplateId, Utils.GetScenarioTemplates(ScenarioStatus.Draft.Equals(Model.Status)), new { @class = "form-control", @disabled = "disabled" })
|
|
}
|
|
@Html.ValidationMessageFor(model => model.TemplateId)
|
|
</div>
|
|
</div>
|
|
@if (Model.Id == Guid.Empty || ScenarioStatus.Draft.Equals(Model.Status))
|
|
{
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.IsActiveScenario, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
<div class="checkbox">
|
|
@Html.CheckBoxFor(model => model.IsActiveScenario)
|
|
</div>
|
|
@Html.ValidationMessageFor(model => model.IsActiveScenario)
|
|
</div>
|
|
</div>
|
|
}
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.UseActuals, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
<div class="checkbox">
|
|
@if (!Model.GrowthScenario)
|
|
{
|
|
@Html.CheckBoxFor(model => model.UseActuals)
|
|
<i id="lblActualsCantBeChecked" style="display:none;">(Actuals cannot be used in Growth Scenarios)</i>
|
|
}
|
|
else
|
|
{
|
|
@Html.CheckBoxFor(model => model.UseActuals, new { @disabled = "disabled" })
|
|
<i id="lblActualsCantBeChecked">(Actuals cannot be used in Growth Scenarios)</i>
|
|
}
|
|
</div>
|
|
@Html.ValidationMessageFor(model => model.UseActuals)
|
|
</div>
|
|
</div>
|
|
@if (Model.Id != Guid.Empty && !ScenarioStatus.Draft.Equals(Model.Status))
|
|
{
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.AllowAdjustment, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
<div class="checkbox">
|
|
@Html.CheckBoxFor(model => model.AllowAdjustment)
|
|
</div>
|
|
@Html.ValidationMessageFor(model => model.AllowAdjustment)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.PriorWeekCutOff, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
@Html.EditorFor(t => t.PriorWeekCutOff)
|
|
@Html.ValidationMessageFor(model => model.PriorWeekCutOff)
|
|
</div>
|
|
</div>
|
|
}
|
|
<div class="form-group">
|
|
<label class="col-sm-3 control-label">Scenario Start/End Dates</label>
|
|
<div class="col-sm-3">
|
|
<div class="input-daterange input-group" id="bs-datepicker-range">
|
|
@Html.EditorFor(t => t.StartDate, new { @class = "form-control" })
|
|
<div class="input-group-addon">to</div>
|
|
@Html.EditorFor(model => model.EndDate, new { @class = "form-control" })
|
|
</div>
|
|
@Html.ValidationMessageFor(model => model.StartDate)
|
|
@Html.ValidationMessageFor(model => model.EndDate)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.MilestoneStartDate, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
@Html.EditorFor(t => t.MilestoneStartDate)
|
|
@Html.ValidationMessageFor(model => model.MilestoneStartDate)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.GrowthScenario, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
<div class="checkbox">
|
|
@Html.CheckBoxFor(model => model.GrowthScenario)
|
|
</div>
|
|
@Html.ValidationMessageFor(model => model.GrowthScenario)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.TotalMilestones, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
@Html.TextBoxFor(model => model.TotalMilestones, new { @class = "form-control", @style = "width:178px;" })
|
|
@Html.ValidationMessageFor(model => model.TotalMilestones)
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
<fieldset id="fsFin">
|
|
<legend class="text-bold">Financial Information</legend>
|
|
@if (!Model.IsRevenueGenerating)
|
|
{
|
|
<div class="form-group">
|
|
<label class="col-sm-3 control-label">Projected Expense</label>
|
|
<div class="col-sm-9">
|
|
<div class="input-group">
|
|
<span class="input-group-addon">$</span>
|
|
@Html.TextBoxFor(model => model.TDDirectCosts, new { @class = "form-control", @style = "width:138px;" }, Model.IsRevenueGenerating)
|
|
</div>
|
|
@Html.ValidationMessageFor(model => model.TDDirectCosts)
|
|
</div>
|
|
</div>
|
|
}
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.ProjectedRevenue, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
<div class="input-group">
|
|
<span class="input-group-addon">$</span>
|
|
@Html.TextBoxFor(model => model.ProjectedRevenue, new { @class = "form-control", @onchange = "RecalcExpense(this);", @style = "width:138px;" }, !Model.IsRevenueGenerating)
|
|
</div>
|
|
@Html.ValidationMessageFor(model => model.ProjectedRevenue)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.GrossMargin, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
<div class="input-group" style="width:178px;">
|
|
<span class="input-group-addon">
|
|
<label class="px-single">@Html.RadioButtonFor(t => t.UseLMMargin, false, new { @class = "px", @onclick = "RecalcExpense($('#" + @Html.ClientIdFor(x => x.ProjectedRevenue) + "')[0]);" }, !Model.IsRevenueGenerating)<span class="lbl"></span></label>
|
|
</span>
|
|
@Html.TextBoxFor(model => model.GrossMargin, new { @class = "form-control", @onchange = "RecalcExpense(this);" }, Model.UseLMMargin || !Model.IsRevenueGenerating)
|
|
<span class="input-group-addon">%</span>
|
|
</div>
|
|
@Html.ValidationMessageFor(model => model.GrossMargin)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.LMMargin, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
<div class="input-group" style="width: 178px;">
|
|
<span class="input-group-addon">
|
|
<label class="px-single">@Html.RadioButtonFor(t => t.UseLMMargin, true, new { @class = "px", @onclick = "RecalcExpense($('#" + @Html.ClientIdFor(x => x.ProjectedRevenue) + "')[0]);" }, !Model.IsRevenueGenerating)<span class="lbl"></span></label>
|
|
</span>
|
|
@Html.TextBoxFor(model => model.LMMargin, new { @class = "form-control", @onchange = "RecalcExpense(this);" }, !Model.UseLMMargin || !Model.IsRevenueGenerating)
|
|
<span class="input-group-addon">%</span>
|
|
</div>
|
|
@Html.ValidationMessageFor(model => model.LMMargin)
|
|
</div>
|
|
</div>
|
|
@if (Model.Id != Guid.Empty && !ScenarioStatus.Draft.Equals(Model.Status))
|
|
{
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.FreezeResource, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
<div class="radio">
|
|
<label>@Html.RadioButtonFor(t => t.FreezeResource, false, new { @class = "px" })<span class="lbl">No, adjust resource to match margins</span></label>
|
|
</div>
|
|
<div class="radio">
|
|
<label>@Html.RadioButtonFor(t => t.FreezeResource, true, new { @class = "px" })<span class="lbl">Yes, keep current resource totals</span></label>
|
|
</div>
|
|
@Html.ValidationMessageFor(model => model.FreezeResource)
|
|
</div>
|
|
</div>
|
|
}
|
|
@*<div class="form-group">
|
|
@Html.LabelFor(model => model.LaborSplitPercentage, new { @class = "col-sm-3 control-label" })
|
|
<div class="col-sm-9">
|
|
@Html.EditorFor(model => model.LaborSplitPercentage)
|
|
@Html.ValidationMessageFor(model => model.LaborSplitPercentage)
|
|
</div>
|
|
</div>*@
|
|
</fieldset>
|
|
<fieldset id="fsExpenditures">
|
|
<legend class="text-bold">Expenditure Categories</legend>
|
|
<div class="table-light table-responsive" style="overflow-y: auto;height: 300px;" id="expendituresContainer">
|
|
@Html.Partial("_expenditures", Model.Expenditures)
|
|
</div>
|
|
</fieldset>
|
|
@Html.ValidationSummary(false, "The Scenario could not be saved due to the following errors:")
|
|
<div class="form-group" style="margin-bottom: 0;">
|
|
<div class="col-sm-offset-2 col-sm-10">
|
|
@if (Model.Id != Guid.Empty)
|
|
{
|
|
<a id="aDet_@Model.Id" onclick="return CheckLock(this.id, 'Scenario', '@Model.Id')" class="btn btn-primary popover-warning popover-dark" href="@Url.Action("Details", "Scenarios", new { @id = Model.Id, @BackUrl = Model.BackUrl, @BackName = Model.BackName })"><i class="fa fa-backward"></i> Back to scenario</a>
|
|
}
|
|
else
|
|
{
|
|
<a class="btn btn-primary" href="@Url.Action("Index", "Project")"><i class="fa fa-backward"></i> Back to projects</a>
|
|
}
|
|
<button type="submit" class="btn btn-success" id="btnsave" onclick="return onSave(false);"><i class="fa fa-save"></i> Save</button>
|
|
@if (Guid.Empty.Equals(Model.Id))
|
|
{
|
|
<button type="submit" class="btn btn-success" id="btnSaveAsDraft" onclick="return onSave(true);"><i class="fa fa-save"></i> Save as Draft</button>
|
|
}
|
|
@if (Model.Id != Guid.Empty)
|
|
{
|
|
if (Model.ChildScenarios > 0)
|
|
{
|
|
<a id="btnDelete" class="btn btn-danger disabled" href="javascript:void(0);"><i class="fa fa-trash-o"></i> Delete</a>
|
|
}
|
|
else
|
|
{
|
|
<a id="btnDelete" class="btn btn-danger" href="@Url.Action("Delete", "Scenarios", new { @id = Model.Id })"><i class="fa fa-trash-o"></i> Delete</a>
|
|
}
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|