137 lines
6.5 KiB
Plaintext
137 lines
6.5 KiB
Plaintext
@using EnVisage.Code
|
|
@using EnVisage.Code.HtmlHelpers
|
|
@using EnVisage.Models
|
|
@model EnVisage.Models.HolidayModel
|
|
@{
|
|
ViewBag.Title = Model != null ? "Edit " + Model.Name + " Holiday" : "Add Holiday";
|
|
}
|
|
|
|
@section Scripts
|
|
{
|
|
<script type="text/javascript">
|
|
emulateNavUrl = "/Calendar";
|
|
</script>
|
|
@if (Model != null)
|
|
{
|
|
<script type="text/javascript">
|
|
init.push(function() {
|
|
StartEdit('Holiday', '@Model.Id', null, '#btnsave', 'erorMsgPlaceholder');
|
|
$("#@Html.ClientIdFor(t => t.OccurrenceType)").change(onTypeChange);
|
|
$("#@Html.ClientIdFor(t => t.OccurrenceMonth)").change(onMonthChange);
|
|
$("#@Html.ClientIdFor(t => t.NonWorkingWeek)").change(onNonWorkingChange);
|
|
|
|
$('#btnsave').click(function () {
|
|
if ($(this).parents('form').valid())
|
|
blockUI();
|
|
});
|
|
});
|
|
|
|
function onTypeChange() {
|
|
var value = $("#@Html.ClientIdFor(t => t.OccurrenceType)").val();
|
|
if (value == '@HolidayModel.HolidayOccurrence.OnlyOnce.ToString()' ||
|
|
value == '@HolidayModel.HolidayOccurrence.SameDayEveryYear.ToString()' ||
|
|
value == '@HolidayModel.HolidayOccurrence.VariesEveryYear.ToString()') {
|
|
$("#divWeekDay").hide();
|
|
$("#divMonthDay").show();
|
|
} else {
|
|
$("#divWeekDay").show();
|
|
$("#divMonthDay").hide();
|
|
}
|
|
$("@Html.ClientIdFor(t => t.OccurrenceMonth)").change();
|
|
}
|
|
function onMonthChange() {
|
|
var value = $("#@Html.ClientIdFor(t => t.OccurrenceMonth)").val();
|
|
var curDayValue = $("#@Html.ClientIdFor(t => t.OccurrenceMonthDay)").val();
|
|
var numDays = 31;
|
|
if (value == '2')
|
|
numDays = 28;
|
|
else if (value == '4' || value == '6' || value == '9' || value == '11')
|
|
numDays = 30;
|
|
var items = "";
|
|
for (var i = 1; i <= numDays; i++)
|
|
{
|
|
items += "<option value=\"" + i + "\" " + ((i == parseInt (curDayValue)) ? "selected" : "") + ">" + i + "</option>";
|
|
};
|
|
$("#@Html.ClientIdFor(t => t.OccurrenceMonthDay)").html(items);
|
|
}
|
|
function onNonWorkingChange(value, data, context) {
|
|
if (document.getElementById('@Html.ClientIdFor(t => t.NonWorkingWeek)').checked) {
|
|
document.getElementById('@Html.ClientIdFor(t => t.WorkingDay)').checked = false;
|
|
$("#@Html.ClientIdFor(t => t.WorkingDay)").prop('disabled', true);
|
|
} else {
|
|
$("#@Html.ClientIdFor(t => t.WorkingDay)").prop('disabled', false);
|
|
}
|
|
}
|
|
</script>
|
|
}
|
|
}
|
|
<div id="erorMsgPlaceholder"></div>
|
|
|
|
@if (Model != null)
|
|
{
|
|
<div class="alert alert-danger" id="danger" hidden="hidden">
|
|
<strong>Oh snap!</strong>
|
|
<span id="erormsg">Change a few things up and try submitting again.</span>
|
|
<span style="float: right"><a href="@Url.Action("HolidayDetails", "Calendar")">Back to Details</a></span>
|
|
</div>
|
|
}
|
|
|
|
@using (Html.BeginForm("EditHoliday", "Calendar", FormMethod.Post, new { @class = "panel form-horizontal" }))
|
|
{
|
|
@Html.HiddenFor(t=>t.Id)
|
|
@Html.AntiForgeryToken()
|
|
<div class="panel-body">
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.Name, new { @class = "col-sm-2 control-label" })
|
|
<div class="col-sm-10">
|
|
@Html.TextBoxFor(model => model.Name, new { @class = "form-control" })
|
|
@Html.ValidationMessageFor(model => model.Name)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.OccurrenceType, new { @class = "col-sm-2 control-label" })
|
|
<div class="col-sm-2">
|
|
@Html.DropDownListFor(t => t.OccurrenceType, Utils.GetOccurrenceTypes(), new { @class = "form-control" })
|
|
@Html.ValidationMessageFor(model => model.OccurrenceType)
|
|
</div>
|
|
@*@Html.LabelFor(model => model.OccurrenceWeekDay, new { @class = "col-sm-2 control-label" })*@
|
|
<div class="col-sm-2" id="divWeekDay" style="display: @(Model.ShowWeekDayDdl ? "block" : "none")">
|
|
@Html.DropDownListFor(model => model.OccurrenceWeekDay, Utils.GetWeekDays(), new { @class = "form-control" })
|
|
@Html.ValidationMessageFor(model => model.OccurrenceWeekDay)
|
|
</div>
|
|
<div class="col-sm-2" id="divMonthDay" style="display: @(!Model.ShowWeekDayDdl ? "block" : "none")">
|
|
@Html.DropDownListFor(model => model.OccurrenceMonthDay, Utils.GetMonthDays(Model.OccurrenceMonth ?? 1), new { @class = "form-control" })
|
|
@Html.ValidationMessageFor(model => model.OccurrenceMonthDay)
|
|
</div>
|
|
<div style="margin-top: 5px;float: left;">of</div>
|
|
@* @Html.LabelFor(model => model.OccurrenceMonth, new { @class = "col-sm-1 control-label" })*@
|
|
<div class="col-sm-2">
|
|
@Html.DropDownListFor(model => model.OccurrenceMonth, Utils.GetMonths(), new { @class = "form-control" })
|
|
@Html.ValidationMessageFor(model => model.OccurrenceMonth)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.WorkingDay, new { @class = "col-sm-2 control-label" })
|
|
<div class="col-sm-10">
|
|
@Html.EditorFor(model => model.WorkingDay, new { @class = "form-control" })
|
|
@Html.ValidationMessageFor(model => model.WorkingDay)
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
@Html.LabelFor(model => model.NonWorkingWeek, new { @class = "col-sm-2 control-label" })
|
|
<div class="col-sm-10">
|
|
@Html.EditorFor(model => model.NonWorkingWeek, new { @class = "form-control" })
|
|
@Html.ValidationMessageFor(model => model.NonWorkingWeek)
|
|
</div>
|
|
</div>
|
|
|
|
@Html.ValidationSummary(false, "The holiday 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">
|
|
<a class="btn btn-primary" href="@Url.Action("Index", "Calendar")"><i class="fa fa-backward"></i> Back to list</a>
|
|
<button type="submit" class="btn btn-success" id="btnsave"><i class="fa fa-save"></i> Save</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|