247 lines
12 KiB
Plaintext
247 lines
12 KiB
Plaintext
@using EnVisage.Code
|
||
@using EnVisage.Code.HtmlHelpers
|
||
|
||
@model EnVisage.Models.UpdateScenarioModel
|
||
|
||
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
|
||
<script type="text/javascript">
|
||
|
||
@if(Model.Id != Guid.Empty)
|
||
{
|
||
<text>
|
||
$("#@Html.ClientIdFor(t => t.AllowAdjustment)").change(function () {
|
||
ToggeleDates();
|
||
return;
|
||
|
||
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('update');
|
||
//$("#@Html.ClientIdFor(t => t.StartDate)").parent().prop("disabled", false);
|
||
//$("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").parent().prop("disabled", true);
|
||
//$("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").datepicker({enable : false});
|
||
//$("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").datepicker({ enable: false });
|
||
//input - group - addon
|
||
|
||
} 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");
|
||
//$("#@Html.ClientIdFor(t => t.StartDate)").parent().prop("disabled", true);
|
||
//$("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").parent().children()[1].disabled = false;
|
||
//$($("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").parent().children()[1]).removeAttr("disabled", "disabled");
|
||
//$("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").datepicker({ enable: true });
|
||
}
|
||
});
|
||
|
||
$('#adjustMarginForm .expenditueCb').ready(function () {
|
||
$('#adjustMarginForm .expenditueCb').on('change', function (e) {
|
||
var elId = e.currentTarget.id;
|
||
var value = $('#adjustMarginForm #' + elId).prop('checked');
|
||
$('#adjustMarginForm #' + elId.replace('expCatCheckedId_', 'expCatChecked_')).val(value);
|
||
});
|
||
|
||
// SA. ENV-698. Fixed display bug. Begin
|
||
useLMMargin = $("#@Html.ClientIdFor(x=>x.UseLMMargin)")[0].checked;
|
||
|
||
if ($("#adjustMarginForm #@Html.ClientIdFor(x=>x.UseLMMargin)").length > 1) {
|
||
$("#adjustMarginForm #@Html.ClientIdFor(x=>x.UseLMMargin)")[0].checked = !useLMMargin;
|
||
$("#adjustMarginForm #@Html.ClientIdFor(x=>x.UseLMMargin)")[1].checked = useLMMargin;
|
||
}
|
||
|
||
$('#adjustMarginForm #@Html.ClientIdFor(x=>x.GrossMargin)').prop('disabled', useLMMargin);
|
||
$('#adjustMarginForm #@Html.ClientIdFor(x=>x.LMMargin)').prop('disabled', !useLMMargin);
|
||
// SA. ENV-698. End
|
||
});
|
||
|
||
$('#adjustMarginForm').ready(ToggeleDates);
|
||
|
||
function ToggeleDates () {
|
||
if ($("#@Html.ClientIdFor(t => t.AllowAdjustment)").prop("checked") == true) {
|
||
$("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").prop("disabled", true);
|
||
//$("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").parent().children()[1])('date');
|
||
$($("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").parent().children()[1]).css({ 'cursor': 'default' });
|
||
$("#@Html.ClientIdFor(t => t.StartDate)").prop("disabled", false);
|
||
//$("#@Html.ClientIdFor(t => t.StartDate)").parent().addClass('date');
|
||
$($("#@Html.ClientIdFor(t => t.StartDate)").parent().children()[1]).css({ 'cursor': '' });
|
||
|
||
} else {
|
||
$("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").prop("disabled", false);
|
||
$($("#@Html.ClientIdFor(t => t.PriorWeekCutOff)").parent().children()[1]).css({ 'cursor': '' });
|
||
$("#@Html.ClientIdFor(t => t.StartDate)").prop("disabled", true);
|
||
//$("#@Html.ClientIdFor(t => t.StartDate)").parent().removeClass('date');
|
||
$($("#@Html.ClientIdFor(t => t.StartDate)").parent().children()[1]).css({ 'cursor': 'default' });
|
||
}
|
||
}
|
||
</text>
|
||
}
|
||
|
||
function RecalcExpense(el) {
|
||
var expense = $("#adjustMarginForm #@Html.ClientIdFor(x=>x.TDDirectCosts)");
|
||
var revenue = 0;
|
||
var margin = 0;
|
||
var useLMMargin = $("#@Html.ClientIdFor(x=>x.UseLMMargin)")[0].checked;
|
||
|
||
if ($("#adjustMarginForm #@Html.ClientIdFor(x=>x.UseLMMargin)")[0].checked) {
|
||
$('#adjustMarginForm #@Html.ClientIdFor(x=>x.GrossMargin)').prop('disabled', false);
|
||
$('#adjustMarginForm #@Html.ClientIdFor(x=>x.LMMargin)').prop('disabled', true);
|
||
// SA. ENV-698. Following line was commented to fix the bug
|
||
@* $('#adjustMarginForm #@Html.ClientIdFor(x=>x.LMMargin)').val(""); *@
|
||
|
||
}
|
||
else {
|
||
$('#adjustMarginForm #@Html.ClientIdFor(x=>x.LMMargin)').prop('disabled', false);
|
||
$('#adjustMarginForm #@Html.ClientIdFor(x=>x.GrossMargin)').prop('disabled', true);
|
||
// SA. ENV-698. Following line was commented to fix the bug
|
||
@* $('#adjustMarginForm #@Html.ClientIdFor(x=>x.GrossMargin)').val(""); *@
|
||
}
|
||
|
||
if (el.id == '@Html.ClientIdFor(x=>x.ProjectedRevenue)') {
|
||
revenue = parseFloat($(el).val());
|
||
margin = useLMMargin ? parseFloat($('#@Html.ClientIdFor(x=>x.GrossMargin)').val()) :
|
||
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);
|
||
}
|
||
}
|
||
|
||
</script>
|
||
|
||
<div class="modal-content">
|
||
<form id="adjustMarginForm" class="innerForm">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
<h4 class="modal-title">Adjust to Desired Margin</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
@Html.HiddenFor(m => m.Id)
|
||
@Html.HiddenFor(t => t.BUDirectCosts)
|
||
|
||
<div class="row col-sm-6" style="padding-right: 10px;">
|
||
<fieldset id="fsFin" style="">
|
||
<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.Raw(Html.TextBoxFor(model => model.TDDirectCosts, new { @class = "form-control", @style = "width:138px;", @disabled = "disabled" }).ToString().Replace("disabled=\"disabled\"", (Model.IsRevenueGenerating ? "disabled=\"disabled\"" : string.Empty)))
|
||
</div>
|
||
@Html.ValidationMessageFor(model => model.TDDirectCosts)
|
||
</div>
|
||
</div>
|
||
}
|
||
else
|
||
{
|
||
@Html.HiddenFor(t=>t.TDDirectCosts)
|
||
<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.Raw(Html.TextBoxFor(model => model.ProjectedRevenue, new { @class = "form-control", @onchange = "RecalcExpense(this);", @style = "width:138px;", @disabled = "disabled" }).ToString().Replace("disabled=\"disabled\"", (Model.IsRevenueGenerating ? string.Empty : "disabled=\"disabled\"")))
|
||
</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.Raw(Html.RadioButtonFor(t => t.UseLMMargin, false, new { @class = "px", @onclick = "RecalcExpense($('#" + @Html.ClientIdFor(x => x.ProjectedRevenue) + "')[0]);", @disabled = "disabled" }).ToString().Replace("disabled=\"disabled\"", (!Model.IsRevenueGenerating ? "disabled=\"disabled\"" : string.Empty)))<span class="lbl"></span></label>
|
||
</span>
|
||
@Html.Raw(Html.TextBoxFor(model => model.GrossMargin, new { @class = "form-control", @onchange = "RecalcExpense(this);", @disabled = "disabled" }).ToString().Replace("disabled=\"disabled\"", ((Model.UseLMMargin && Model.Id == Guid.Empty) || !Model.IsRevenueGenerating ? "disabled=\"disabled\"" : string.Empty)))
|
||
<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.Raw(@Html.RadioButtonFor(t => t.UseLMMargin, true, new { @class = "px", @onclick = "RecalcExpense($('#" + @Html.ClientIdFor(x => x.ProjectedRevenue) + "')[0]);", @disabled = "disabled" }).ToString().Replace("disabled=\"disabled\"", (!Model.IsRevenueGenerating ? "disabled=\"disabled\"" : string.Empty)))<span class="lbl"></span></label>
|
||
</span>
|
||
@Html.Raw(Html.TextBoxFor(model => model.LMMargin, new { @class = "form-control", @onchange = "RecalcExpense(this);", @disabled = "disabled" }).ToString().Replace("disabled=\"disabled\"", ((!Model.UseLMMargin && Model.Id == Guid.Empty) || !Model.IsRevenueGenerating ? "disabled=\"disabled\"" : string.Empty)))
|
||
<span class="input-group-addon">%</span>
|
||
</div>
|
||
@Html.ValidationMessageFor(model => model.LMMargin)
|
||
</div>
|
||
</div>
|
||
}
|
||
</fieldset>
|
||
|
||
<fieldset id="fsBasic" style="">
|
||
<legend class="text-bold">Scenario Information</legend>
|
||
@if (Model.Id != Guid.Empty)
|
||
{
|
||
<div class="form-group">
|
||
@Html.LabelFor(model => model.AllowAdjustment, new { @class = "col-sm-9 control-label" })
|
||
<div class="col-sm-3">
|
||
<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">
|
||
@Html.LabelFor(model => model.StartDate, new { @class = "col-sm-3 control-label" })
|
||
<div class="col-sm-9">
|
||
@Html.EditorFor(t => t.StartDate)
|
||
@Html.ValidationMessageFor(model => model.StartDate)
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
@Html.LabelFor(model => model.EndDate, new { @class = "col-sm-3 control-label" })
|
||
<div class="col-sm-9">
|
||
@Html.EditorFor(t => t.EndDate)
|
||
@Html.ValidationMessageFor(model => model.EndDate)
|
||
</div>
|
||
</div>
|
||
</fieldset>
|
||
</div>
|
||
|
||
<div class="row col-sm-6">
|
||
<fieldset id="fsExpenditures" style="">
|
||
<legend class="text-bold">Expenditure Categories</legend>
|
||
<div class="table-light table-responsive" style="overflow-y: auto;height: 455px;" id="expendituresContainer">
|
||
@Html.Partial("_expenditures", Model.Expenditures)
|
||
</div>
|
||
</fieldset>
|
||
</div>
|
||
|
||
<div class="modal-footer" style="margin-bottom: 0;">
|
||
<div class="col-sm-10">
|
||
@Html.ValidationMessage("errors", new { @style = "text-align: left" })
|
||
</div>
|
||
<div class="col-sm-offset-2 col-sm-10">
|
||
@*<a class="btn btn-primary" href="javascript:void(0)" onclick="LoadRates();"><i class="fa fa-backward"></i>Back to list</a>*@
|
||
<label style="display:none;" id="saveLoader"><span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> Saving...</label>
|
||
<a class="btn btn-success lockable" id="saveButton" href="javascript:void(0)" onclick="saveMarginConfirmed();"><i class="fa fa-save"></i> Save</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div> |