291 lines
12 KiB
Plaintext
291 lines
12 KiB
Plaintext
@using EnVisage.Code
|
||
@using EnVisage.Code.HtmlHelpers
|
||
|
||
@model EnVisage.Models.PeopleResourceModel
|
||
|
||
@{
|
||
ViewBag.Title = Model.Id != Guid.Empty ? "Edit People Resource" : "Add New People Resource";
|
||
}
|
||
|
||
@{
|
||
var projects = EnVisage.Code.Utils.GetResourceProjects(Model.Id, User.Identity.Name);
|
||
}
|
||
|
||
@section Scripts
|
||
{
|
||
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
|
||
<script src="@Url.Content("~/Scripts/URIjs.min.js")" type="text/javascript"></script>
|
||
<script type="text/javascript">
|
||
var datePickerOptions = {
|
||
format: 'm/d/yyyy',
|
||
autoclose: true,
|
||
startDate: '@(Constants.MIN_SELECTABLE_DATE)', // SA. ENV-1235
|
||
endDate: '@(Constants.MAX_SELECTABLE_DATE)' // SA. ENV-1235
|
||
};
|
||
|
||
init.push(function () {
|
||
$('input#@Html.ClientIdFor(x => x.IsActiveEmployee)').switcher({
|
||
on_state_content: 'Active',
|
||
off_state_content: 'Inactive'
|
||
});
|
||
$('input#@Html.ClientIdFor(x => x.ReassignOnDeactivation)').switcher({
|
||
on_state_content: 'Reassign',
|
||
off_state_content: 'Unassign'
|
||
});
|
||
$('input#@Html.ClientIdFor(x => x.IsActiveEmployee)').parent().css("width", "80px");
|
||
$('input#@Html.ClientIdFor(x => x.ReassignOnDeactivation)').parent().css("width", "80px");
|
||
$('.datepicker').datepicker(datePickerOptions);
|
||
@if (Model.Id != Guid.Empty)
|
||
{
|
||
<text>
|
||
StartEdit('PeopleResource', '@Model.Id', null, "#btnsave", "erorMsgPlaceholder");
|
||
$("#@Html.ClientIdFor(t => t.ChangeCapacity)").prop("disabled", true);
|
||
</text>
|
||
}
|
||
if ($("#@Html.ClientIdFor(t => t.PermanentResource)").prop("checked") == true)
|
||
$("#enddaterow").hide();
|
||
});
|
||
$("#@Html.ClientIdFor(t => t.IsActiveEmployee)").change(function () {
|
||
if ($(this).prop("checked") == true) {
|
||
if ($("#@Html.ClientIdFor(t => t.Id)").val() == '00000000-0000-0000-0000-000000000000') {
|
||
$("#@Html.ClientIdFor(t => t.ChangeCapacity)").prop("checked", true);
|
||
$("#@Html.ClientIdFor(t => t.ChangeCapacity)").prop("disabled", false);
|
||
}
|
||
else {
|
||
$("#@Html.ClientIdFor(t => t.ChangeCapacity)").prop("disabled", false);
|
||
$("#@Html.ClientIdFor(t => t.ChangeCapacity)").prop("checked", true);
|
||
}
|
||
}
|
||
else {
|
||
if ($("#@Html.ClientIdFor(t => t.Id)").val() == '00000000-0000-0000-0000-000000000000') {
|
||
$("#@Html.ClientIdFor(t => t.ChangeCapacity)").prop("checked", false);
|
||
$("#@Html.ClientIdFor(t => t.ChangeCapacity)").prop("disabled", true);
|
||
}
|
||
else {
|
||
$("#@Html.ClientIdFor(t => t.ChangeCapacity)").prop("disabled", false);
|
||
$("#@Html.ClientIdFor(t => t.ChangeCapacity)").prop("checked", true);
|
||
}
|
||
}
|
||
});
|
||
|
||
function activatePlannedCapacityChange() {
|
||
if ($("#@Html.ClientIdFor(t => t.Id)").val() != '00000000-0000-0000-0000-000000000000' && $("#@Html.ClientIdFor(t => t.IsActiveEmployee)").prop("checked") == true) {
|
||
$("#@Html.ClientIdFor(t => t.ChangeCapacity)").prop("disabled", false);
|
||
$("#@Html.ClientIdFor(t => t.ChangeCapacity)").prop("checked", "checked");
|
||
}
|
||
}
|
||
$("#@Html.ClientIdFor(t => t.ExpenditureCategoryId)").change(activatePlannedCapacityChange);
|
||
$("#@Html.ClientIdFor(t => t.TeamId)").change(activatePlannedCapacityChange);
|
||
$("#@Html.ClientIdFor(t => t.StartDate)").change(activatePlannedCapacityChange);
|
||
$("#@Html.ClientIdFor(t => t.EndDate)").change(activatePlannedCapacityChange);
|
||
$("#@Html.ClientIdFor(t => t.PermanentResource)").change(function () {
|
||
activatePlannedCapacityChange();
|
||
if ($(this).prop("checked") == true)
|
||
$("#enddaterow").hide();
|
||
else
|
||
$("#enddaterow").show();
|
||
});
|
||
|
||
</script>
|
||
|
||
<script type="text/javascript">
|
||
//fix modal force focus
|
||
$.fn.modal.Constructor.prototype.enforceFocus = function () {
|
||
var that = this;
|
||
$(document).on('focusin.modal', function (e) {
|
||
if ($(e.target).hasClass('select2-input')) {
|
||
return true;
|
||
}
|
||
|
||
if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
|
||
that.$element.focus();
|
||
}
|
||
});
|
||
};
|
||
|
||
init.push(function () {
|
||
$(".forselect2").each(function (i, e) {
|
||
$(e).select2({
|
||
allowClear: true,
|
||
placeholder: "Select resource",
|
||
});
|
||
});
|
||
});
|
||
function submitReassign() {
|
||
blockUI();
|
||
var form = $('#frmReassign');
|
||
var form1 = $('#frmEdit');
|
||
$.ajax({
|
||
cache: false,
|
||
async: true,
|
||
type: "POST",
|
||
url: form.attr('action'),
|
||
data: form.serialize(),
|
||
success: function (data) {
|
||
form1.submit();
|
||
}
|
||
});
|
||
}
|
||
|
||
$('#btnsave').click(function () {
|
||
if ($(this).parents('form').valid()) {
|
||
if (!$("#@Html.ClientIdFor(t => t.IsActiveEmployee)").prop("checked") && '@projects.Count()' != '0' && $("#@Html.ClientIdFor(t => t.ReassignOnDeactivation)").prop("checked")) {
|
||
$('#modalProjectAssign').modal();
|
||
}
|
||
else
|
||
{
|
||
blockUI();
|
||
$('#frmEdit').submit();
|
||
}
|
||
}
|
||
});
|
||
</script>
|
||
}
|
||
|
||
<div id="erorMsgPlaceholder"></div>
|
||
|
||
@using (Html.BeginForm("Edit", "PeopleResource", FormMethod.Post, new { @class = "panel form-horizontal", id = "frmEdit", teamId = Request.QueryString["teamId"] }))
|
||
{
|
||
@Html.AntiForgeryToken()
|
||
@Html.HiddenFor(model => model.Id)
|
||
<div class="panel-body">
|
||
<div class="form-group">
|
||
@Html.LabelFor(model => model.FirstName, new { @class = "col-sm-3 control-label" })
|
||
<div class="col-sm-9">
|
||
@Html.TextBoxFor(model => model.FirstName, new { @class = "form-control" })
|
||
@Html.ValidationMessageFor(model => model.FirstName)
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
@Html.LabelFor(model => model.LastName, new { @class = "col-sm-3 control-label" })
|
||
<div class="col-sm-9">
|
||
@Html.TextBoxFor(model => model.LastName, new { @class = "form-control" })
|
||
@Html.ValidationMessageFor(model => model.LastName)
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-3 control-label" for="Number">Expenditure Category</label>
|
||
<div class="col-sm-9">
|
||
@Html.DropDownListFor(model => model.ExpenditureCategoryId, (IEnumerable<SelectListItem>)ViewBag.ExpendituresList, new { @class = "form-control" })
|
||
@Html.ValidationMessageFor(model => model.ExpenditureCategoryId)
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-3 control-label" for="Number">Team</label>
|
||
<div class="col-sm-9">
|
||
@Html.DropDownListFor(model => model.TeamId, (IEnumerable<SelectListItem>)ViewBag.TeamsList, new { @class = "form-control" })
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
@Html.LabelFor(model => model.IsActiveEmployee, new { @class = "col-sm-3 control-label" })
|
||
<div class="col-sm-9">
|
||
@Html.CheckBoxFor(model => model.IsActiveEmployee, new { @class = "switcher" })
|
||
@Html.ValidationMessageFor(model => model.IsActiveEmployee)
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
@Html.LabelFor(model => model.ReassignOnDeactivation, new { @class = "col-sm-3 control-label" })
|
||
<div class="col-sm-9">
|
||
@Html.CheckBoxFor(model => model.ReassignOnDeactivation, new { @class = "switcher" })
|
||
@Html.ValidationMessageFor(model => model.ReassignOnDeactivation)
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class = "col-sm-3 control-label">Change planned capacity</label>
|
||
<div class="col-sm-9">
|
||
<div class="checkbox">
|
||
@Html.CheckBoxFor(model => model.ChangeCapacity)
|
||
<i>(allows to keep planned capacity up to date after changes; when category or team changed, changes planned capacity for both categories/teams)</i>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-group">
|
||
<label class = "col-sm-3 control-label">Permanent</label>
|
||
<div class="col-sm-9">
|
||
<div class="checkbox">
|
||
@Html.CheckBoxFor(model => model.PermanentResource)
|
||
</div>
|
||
</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(model => model.StartDate, new { @class = "form-control" })
|
||
@Html.ValidationMessageFor(model => model.StartDate)
|
||
</div>
|
||
</div>
|
||
<div class="form-group" id="enddaterow">
|
||
@Html.LabelFor(model => model.EndDate, new { @class = "col-sm-3 control-label" })
|
||
<div class="col-sm-9">
|
||
@Html.EditorFor(model => model.EndDate, new { @class = "form-control" })
|
||
@Html.ValidationMessageFor(model => model.EndDate)
|
||
</div>
|
||
</div>
|
||
@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-3 col-sm-9">
|
||
<a class="btn btn-primary" href="@Url.Action("Board", "Team", new {teamId = Request.QueryString["teamId"] })"><i class="fa fa-backward"></i> Back to people resources</a>
|
||
@if (Model.Id != Guid.Empty)
|
||
{
|
||
<a class="btn btn-primary" href="@Url.Action("Details", "PeopleResource", new { resourceId = Model.Id, teamId = Request.QueryString["teamId"] })"><i class="fa fa-backward"></i> Back to people resource details</a>
|
||
}
|
||
<button type="button" class="btn btn-success" id="btnsave"><i class="fa fa-save"></i> Save</button>
|
||
@if (Model.Id == Guid.Empty)
|
||
{
|
||
<div style="display: inline-block; margin-left: 10px; vertical-align: middle;">
|
||
@Html.CheckBoxFor(model => model.AddMore)
|
||
<label for="@Html.ClientIdFor(model => model.AddMore)" style="vertical-align: top;">@Html.DisplayNameFor(model => model.AddMore)</label>
|
||
</div>
|
||
}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
@using (Html.BeginForm("Reassign", "PeopleResource", FormMethod.Post, new {id = "frmReassign" }))
|
||
{
|
||
<div id="modalProjectAssign" class="modal fade" tabindex="-1" role="dialog" style="display: none;" data-backdrop="static">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
@Html.AntiForgeryToken()
|
||
@Html.HiddenFor(model => model.Id)
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
<h4 class="modal-title">Assign Resources</h4>
|
||
</div>
|
||
<div class="modal-body" style="padding: 0 15px;">
|
||
<div class="panel-body form-horizontal">
|
||
<p>
|
||
This people resource is assigned to one or more projects.
|
||
Inactive resources cannot be assigned to projects, please reassign the following projects to other resources.
|
||
Please note that you can only choose resources from teams that project is already assigned to.
|
||
</p>
|
||
@foreach (var project in projects)
|
||
{
|
||
|
||
<div class="form-group">
|
||
<label class = "col-sm-5 control-label">@project.Name</label>
|
||
<div class="col-sm-7">
|
||
@Html.DropDownList(project.Id.ToString(), EnVisage.Code.Utils.GetSubstituteResources(User.Identity.Name, Model.Id, Model.ExpenditureCategoryId, project.Id), new { @class = "form-control forselect2", @id = project.Id.ToString() })
|
||
@Html.ValidationMessageFor(model => model.SubstituteResources)
|
||
</div>
|
||
</div>
|
||
}
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-primary" onclick="submitReassign()" >Ok</button>
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||
</div>
|
||
</div>
|
||
<!-- / .modal-content -->
|
||
</div>
|
||
<!-- / .modal-dialog -->
|
||
</div>
|
||
} |