@using EnVisage.Code @using EnVisage.Models @using System.Linq @using EnVisage.Code.Extensions @model NonProjectTimeModel @{ string userId = User.Identity.GetID(); var allocCats = string.Empty; foreach (var item in Utils.GetNonProjectTimeCategories()) { if (!string.IsNullOrEmpty(allocCats)) { allocCats += ","; } allocCats += "{ id: '" + item.Value + "', text: '" + item.Text + "'}"; } var distribution = string.Empty; if (Model != null && Model.NonProjectTimeAllocations != null) { var distributionModel = Model.NonProjectTimeAllocations .ToDictionary(x => Utils.ConvertToUnixDate(x.WeekEndingDate), x => new { x.HoursOff, StartDate = Utils.ConvertToUnixDate(x.WeekStartDate), EndDate = Utils.ConvertToUnixDate(x.WeekEndingDate) }); distribution = Newtonsoft.Json.JsonConvert.SerializeObject(distributionModel); } // Get teams list for display in assignment picker var teamOptsForSelect2 = Utils.GetTeams(userId, true); // Get resources list for display in assignment picker DateTime dp = Model.Id.Equals(Guid.Empty) ? DateTime.UtcNow.Date : Model.NonProjectTimeStartDate.ToUniversalTime().Date; List teamsToBrowse = teamOptsForSelect2.Where(x => !String.IsNullOrEmpty(x.Value) && (x.IsAccessible || x.Value == Model.TeamId.ToString())).Select(x => new Guid(x.Value)).ToList(); // Format SelectAll option for teams list var selectAllOption = teamOptsForSelect2.FirstOrDefault(x => String.IsNullOrEmpty(x.Value)); if (selectAllOption != null) { selectAllOption.Value = Guid.Empty.ToString(); selectAllOption.Text = "Select All"; selectAllOption.IsAccessible = true; } var resourceOptsForSelect2 = Utils.GetResourcesByTeams(teamsToBrowse, dp, Model.TeamId); if (!SecurityManager.CheckSecurityObjectPermission(Areas.AccessToOtherResources, AccessLevel.Read)) { resourceOptsForSelect2 = from optGroup in resourceOptsForSelect2 where optGroup.children.Any(x => Guid.Equals(new Guid(x.id), ViewBag.CurrentResourceId)) let children = optGroup.children.Where(x => Guid.Equals(new Guid(x.id), ViewBag.CurrentResourceId)).ToList() select new Utils.Select2DataOptionGroup { id = optGroup.id, text = optGroup.text, children = children }; } } @using (Ajax.BeginForm("ScheduleNonProjectTime", "PeopleResource", null, new AjaxOptions { HttpMethod = "Post", OnBegin = "blockUI", OnSuccess = "onSuccess", OnFailure = "onFailure(xhr)", OnComplete = "unblockUI" }, new { id = "npTimeForm" })) { @Html.AntiForgeryToken() @Html.HiddenFor(model => model.Id) @Html.HiddenFor(t => t.NonProjectTimeCategoryName) @Html.HiddenFor(t => t.TeamId) @Html.HiddenFor(x => x.NonProjectTimeStartDateOld) @Html.HiddenFor(x => x.PermanentOld) }