From 4a4ed45d98211cae85403fb3e9ce0919aa1cbc63 Mon Sep 17 00:00:00 2001 From: Lyndon Jetten Date: Mon, 26 Nov 2018 13:27:16 -0400 Subject: [PATCH] Gruppenbuchung --- BeWoPlanerMobil/BeWoPlanerMobil.csproj | 1 - BeWoPlanerMobil/Controllers/MainController.cs | 63 ++++--------- BeWoPlanerMobil/Models/MainModel.cs | 88 ++++++++++--------- BeWoPlanerMobil/Scripts/gruppenbuchung.js | 2 +- BeWoPlanerMobil/Scripts/initialization.js | 5 +- BeWoPlanerMobil/Scripts/mainView.js | 9 +- BeWoPlanerMobil/Util/MobileUtils.cs | 39 +++++++- BeWoPlanerMobil/Views/Main/Main.cshtml | 83 ++++++++--------- 8 files changed, 148 insertions(+), 142 deletions(-) diff --git a/BeWoPlanerMobil/BeWoPlanerMobil.csproj b/BeWoPlanerMobil/BeWoPlanerMobil.csproj index 61c5612e8..51b5e31b4 100644 --- a/BeWoPlanerMobil/BeWoPlanerMobil.csproj +++ b/BeWoPlanerMobil/BeWoPlanerMobil.csproj @@ -178,7 +178,6 @@ - diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index 9fa7afd2c..6af60cc9a 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -4,10 +4,13 @@ using System.Diagnostics; using System.Linq; using System.Text; using System.Web.Mvc; + using BeWo.Service.ServiceImplementations; + using BeWoPlanerMobil.Models; using BeWoPlanerMobil.Service; using BeWoPlanerMobil.Util; + using static BeWoPlanerMobil.Util.MobileUtils; using BS.Shared; @@ -959,9 +962,9 @@ namespace BeWoPlanerMobil.Controllers var employeeCount = Model.SelectedEmployees.Count; var personCount = Model.SelectedSupportConcepts.Count; - var cb2scOids = (from scDc in Model.SelectedSupportConcepts where scDc.CostBearerRelations != null && scDc.CostBearerRelations.Count > 0 let costBearer2SupportConceptOid = scDc.CostBearerRelations[0].CostBearer2SupportConceptOid where costBearer2SupportConceptOid != null select costBearer2SupportConceptOid.Value).ToList(); + var cb2SCOids = (from scDc in Model.SelectedSupportConcepts where scDc.CostBearerRelations != null && scDc.CostBearerRelations.Count > 0 let costBearer2SupportConceptOid = scDc.CostBearerRelations[0].CostBearer2SupportConceptOid where costBearer2SupportConceptOid != null select costBearer2SupportConceptOid.Value).ToList(); - var list = CalculateGroupBookingDuration(employeeCount, personCount, cb2scOids); + var list = CalculateGroupBookingDuration(employeeCount, personCount, cb2SCOids); var newDCList = new List(); @@ -1183,7 +1186,7 @@ namespace BeWoPlanerMobil.Controllers string calcdId = null; var lastMinuteInterval = -1; - if(MobileUtils.IsBillable(Model.SelectedServiceDescriptionOid.Value, Model.GetServiceDesctiptions())) + if(Model.SelectedServiceDescriptionOid.HasValue && IsBillable(Model.SelectedServiceDescriptionOid.Value, Model.GetServiceDesctiptions())) { roundDuration = true; @@ -1239,11 +1242,11 @@ namespace BeWoPlanerMobil.Controllers return list; } - private void UpdateServiceRecordGroup(ServiceRecordGroupDC groupDC) + private void UpdateServiceRecordGroup(ServiceRecordGroupDC pGroupDC) { var newCount = 0; - foreach(var serviceRecord in groupDC.ServiceRecordList) + foreach(var serviceRecord in pGroupDC.ServiceRecordList) { if(!serviceRecord.ServiceRecordOid.HasValue) { @@ -1251,7 +1254,7 @@ namespace BeWoPlanerMobil.Controllers } } - if(newCount == groupDC.ServiceRecordList.Count) + if(newCount == pGroupDC.ServiceRecordList.Count) { return; } @@ -1279,7 +1282,7 @@ namespace BeWoPlanerMobil.Controllers } } - foreach(var item in groupDC.ServiceRecordList) + foreach(var item in pGroupDC.ServiceRecordList) { var key = item.Employee.EmployeeOid + "_" + item.SupportConcept.SupportConceptOid; if(item.CostBearer2SupportConceptOid.HasValue) @@ -1336,7 +1339,7 @@ namespace BeWoPlanerMobil.Controllers else { newServiceRecord = CloneServiceRecordForGroupBooking(Model.NewServiceRecord); - groupDC.ServiceRecordList.Add(newServiceRecord); + pGroupDC.ServiceRecordList.Add(newServiceRecord); } newServiceRecord.Employee = emp; @@ -1350,7 +1353,7 @@ namespace BeWoPlanerMobil.Controllers foreach(var item in dcsToChange) { - groupDC.ServiceRecordList.Remove(item); + pGroupDC.ServiceRecordList.Remove(item); } } } @@ -1615,43 +1618,6 @@ namespace BeWoPlanerMobil.Controllers return RedirectToActionPermanent("Main"); } - - private static List CreateServiceCategoryModels(IEnumerable serviceDescriptions) - { - var catOid2ModelDict = new Dictionary(); - foreach (var sd in serviceDescriptions) - { - if (!catOid2ModelDict.ContainsKey(sd.Category.ServiceCategoryOid.Value)) - { - catOid2ModelDict[sd.Category.ServiceCategoryOid.Value] = new ServiceCategoryModel - { - Name = sd.Category.Name, - IsDefault = sd.Category.IsDefault, - Percentage = sd.Category.Percentage, - Position = sd.Category.Position, - OhneHilfeplan = sd.Category.OhneHilfeplan, - ServiceCategoryOid = sd.Category.ServiceCategoryOid, - ServiceDescriptions = new List() - }; - } - - catOid2ModelDict[sd.Category.ServiceCategoryOid.Value].ServiceDescriptions.Add(sd); - } - - var list = catOid2ModelDict.Values.ToList(); - - list.Sort((s1, s2) => - { - if (s1.IsDefault) - { - return 1; - } - - return s1.Position != s2.Position ? s1.Position.CompareTo(s2.Position) : s1.ServiceCategoryOid.Value.CompareTo(s2.ServiceCategoryOid.Value); - }); - - return list; - } [HttpPost] [Authorize] @@ -1821,8 +1787,10 @@ namespace BeWoPlanerMobil.Controllers var employees = new List(); Model.SelectedServiceRecord = serviceRecord; + Model.SelectedSupportConcepts.Clear(); + Model.SelectedEmployees.Clear(); - if(serviceRecord?.GroupOid != null) + if (serviceRecord?.GroupOid != null) { var serviceRecordGroup = OperationsService.GetServiceRecordGroup(serviceRecord.GroupOid.Value); @@ -1850,6 +1818,7 @@ namespace BeWoPlanerMobil.Controllers // TODO: Wie bei SetGroupBooking //LoadServiceCategoriesForGroupBooking(); + Model.ServiceCategories = CreateServiceCategoryModels(OperationsService.GetAllServiceDescriptions()); return RedirectToActionPermanent("Main"); } diff --git a/BeWoPlanerMobil/Models/MainModel.cs b/BeWoPlanerMobil/Models/MainModel.cs index 0f6b5dc85..29c2ee8fc 100644 --- a/BeWoPlanerMobil/Models/MainModel.cs +++ b/BeWoPlanerMobil/Models/MainModel.cs @@ -150,29 +150,30 @@ namespace BeWoPlanerMobil.Models } } - public IEnumerable SelectedSupportConceptListItemsForGroupBooking - { - get - { - var selectedSCs = new List(); + // TODO: KGW? + //public IEnumerable SelectedSupportConceptListItemsForGroupBooking + //{ + // get + // { + // var selectedSCs = new List(); - if(SelectedSupportConcepts != null) - { - foreach(var sc in SelectedSupportConcepts.OrderBy(sc => sc.Customer.LastName)) - { - selectedSCs.AddRange(sc.CostBearerRelations.Where(w => ShowExpiredSupportConcepts || w.EndDate == null || w.EndDate.Value >= DateTime.Now).Select(cb => new SelectListItem - { - Value = cb.CostBearer2SupportConceptOid.ToString(), - Text = $"{sc.Customer.LastNameFirstName} | {cb.StartDate?.ToShortDateString().Remove(6, 2) ?? string.Empty}-{cb.EndDate?.ToShortDateString().Remove(6, 2) ?? string.Empty} {cb.CostBearer.Name}" - })); - } - } + // if(SelectedSupportConcepts != null) + // { + // foreach(var sc in SelectedSupportConcepts.OrderBy(sc => sc.Customer.LastName)) + // { + // selectedSCs.AddRange(sc.CostBearerRelations.Where(w => ShowExpiredSupportConcepts || w.EndDate == null || w.EndDate.Value >= DateTime.Now).Select(cb => new SelectListItem + // { + // Value = cb.CostBearer2SupportConceptOid.ToString(), + // Text = $"{sc.Customer.LastNameFirstName} | {cb.StartDate?.ToShortDateString().Remove(6, 2) ?? string.Empty}-{cb.EndDate?.ToShortDateString().Remove(6, 2) ?? string.Empty} {cb.CostBearer.Name}" + // })); + // } + // } - return selectedSCs; - } - } - - public IEnumerable ServiceCategoryListItems + // return selectedSCs; + // } + //} + + public IEnumerable ServiceCategoryListItems { get { @@ -197,26 +198,28 @@ namespace BeWoPlanerMobil.Models return result; } } - - [Display(Name = "Textbaustein")] - public long? SelectedTextbausteinOid { get; set; } - public IEnumerable TextbausteinListItems - { - get - { - var result = new List(); + // TODO: KGW? + // [Display(Name = "Textbaustein")] + // public long? SelectedTextbausteinOid { get; set; } - if (Textbausteine != null) - { - result.AddRange(Textbausteine.Select(item => new SelectListItem { Value = item.TextModuleOid.Value.ToString(), Text = item.Name }).ToList()); - } + // TODO: KGW? + //public IEnumerable TextbausteinListItems + //{ + // get + // { + // var result = new List(); - return result; - } - } + // if (Textbausteine != null) + // { + // result.AddRange(Textbausteine.Select(item => new SelectListItem { Value = item.TextModuleOid.Value.ToString(), Text = item.Name }).ToList()); + // } - public List Customers { get; set; } + // return result; + // } + //} + + public List Customers { get; set; } public List Employees { get; set; } @@ -249,8 +252,9 @@ namespace BeWoPlanerMobil.Models public List SelectedGroupOfPeopleOids { get; set; } = new List(); - [Display(Name = "Gruppen")] - public string SelectedGroupInfo { get; set; } + // TODO: KGW + //[Display(Name = "Gruppen")] + //public string SelectedGroupInfo { get; set; } public IEnumerable EmployeeListItems { @@ -288,12 +292,14 @@ namespace BeWoPlanerMobil.Models public List SelectedEmployees { get; set; } = new List(); - public List SelectedCostbearer2SupportConceptOids { get; set; } = new List(); + // TODO: KGW + //public List SelectedCostbearer2SupportConceptOids { get; set; } = new List(); [Display(Name = "Gruppenbuchung")] public bool IsInGroupBookingMode { - get => _IsInGroupBookingMode; + //get => _IsInGroupBookingMode; + get => false; set { diff --git a/BeWoPlanerMobil/Scripts/gruppenbuchung.js b/BeWoPlanerMobil/Scripts/gruppenbuchung.js index f4571be1a..888003ea8 100644 --- a/BeWoPlanerMobil/Scripts/gruppenbuchung.js +++ b/BeWoPlanerMobil/Scripts/gruppenbuchung.js @@ -170,6 +170,6 @@ function addEmployees() { showSanduhr(); - $("groupBookingEmployeeSelectionForm").submit(); + $("#groupBookingEmployeeSelectionForm").submit(); } /* ------------------------------- */ \ No newline at end of file diff --git a/BeWoPlanerMobil/Scripts/initialization.js b/BeWoPlanerMobil/Scripts/initialization.js index c02cbb37c..aa5a3ca85 100644 --- a/BeWoPlanerMobil/Scripts/initialization.js +++ b/BeWoPlanerMobil/Scripts/initialization.js @@ -167,7 +167,10 @@ function initBeWoMobile(actionPath) { var employeesTableHasEntries = $("#rightContent input:checked").length; if (isInGroupBookingMode()) { - $("#anlegenEditierenBtn").prop("disabled", (supportConceptTableHasEntries === 0 || employeesTableHasEntries === 0)); + var value = (supportConceptTableHasEntries === 0 || employeesTableHasEntries === 0) ? false : true; + + $("#anlegenEditierenBtn").prop("disabled", value); + hideElement($("#selectSCForm")); } else { showElement($("#selectSCForm")); diff --git a/BeWoPlanerMobil/Scripts/mainView.js b/BeWoPlanerMobil/Scripts/mainView.js index c7eb934a0..b1f22a37c 100644 --- a/BeWoPlanerMobil/Scripts/mainView.js +++ b/BeWoPlanerMobil/Scripts/mainView.js @@ -372,8 +372,6 @@ function activateForm(actionPath) { loadGoals(actionPath); - console.log("actionPath: " + actionPath); - $("#kategorien_select").val($("#kategorien_select option").eq(0).val()); loadServiceDescriptions(); @@ -399,13 +397,12 @@ function resetRecordForm() { $("#kategorien_select").val($("#kategorien_select option").eq(0).val()); for(var i = 0; i < numberOfDocumentationTypes; i++) { - $('#notiz_textbox' + (i + 1)).val(""); + $("#notiz_textbox" + (i + 1)).val(""); } var selectedCategory = $("#kategorien_select").find(":selected").val(); if(isInEditingMode()) { - console.log('making ajax call to reset the editing mode'); makeAjaxCall("POST", resetEditingModeUrl, function(response) { window.location.reload(); }, { pFormCollection: null }, null); } @@ -466,7 +463,7 @@ function validateTimeField(id) { var zeitStr = id === "#start_textbox" ? "Start" : "End"; if (timeStr !== "" && !zeitRegEx.test(timeStr)) { - showZeiterfassungsError('Bitte geben Sie eine ' + + 'xxx-Zeit in einem gültigen Format (HH:MM oder HHMM) an.'); + showZeiterfassungsError("Bitte geben Sie eine " + zeitStr + "-Zeit in einem gültigen Format (HH:MM oder HHMM) an."); return false; } else { clearZED(); @@ -689,7 +686,7 @@ function validateServiceRecordBeforeSubmit() { } function ErfolgteSpx() { - if (document.getElementById("SaveSignature").value == "True") { + if (document.getElementById("SaveSignature").value === "True") { toggleSuccessPopup("Eintrag wurde gespeichert." + "\n" + "Möchte Sie diesen unterschreiben lassen?", 4); document.getElementById("SaveSignature").value = "False"; diff --git a/BeWoPlanerMobil/Util/MobileUtils.cs b/BeWoPlanerMobil/Util/MobileUtils.cs index b63601963..94dba949c 100644 --- a/BeWoPlanerMobil/Util/MobileUtils.cs +++ b/BeWoPlanerMobil/Util/MobileUtils.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; - +using BeWoPlanerMobil.Models; using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.Extensions; @@ -224,5 +224,42 @@ namespace BeWoPlanerMobil.Util { return new JSONCustomer(pCustomer); } + + public static List CreateServiceCategoryModels(IEnumerable serviceDescriptions) + { + var catOid2ModelDict = new Dictionary(); + foreach (var sd in serviceDescriptions) + { + if (!catOid2ModelDict.ContainsKey(sd.Category.ServiceCategoryOid.Value)) + { + catOid2ModelDict[sd.Category.ServiceCategoryOid.Value] = new ServiceCategoryModel + { + Name = sd.Category.Name, + IsDefault = sd.Category.IsDefault, + Percentage = sd.Category.Percentage, + Position = sd.Category.Position, + OhneHilfeplan = sd.Category.OhneHilfeplan, + ServiceCategoryOid = sd.Category.ServiceCategoryOid, + ServiceDescriptions = new List() + }; + } + + catOid2ModelDict[sd.Category.ServiceCategoryOid.Value].ServiceDescriptions.Add(sd); + } + + var list = catOid2ModelDict.Values.ToList(); + + list.Sort((s1, s2) => + { + if (s1.IsDefault) + { + return 1; + } + + return s1.Position != s2.Position ? s1.Position.CompareTo(s2.Position) : s1.ServiceCategoryOid.Value.CompareTo(s2.ServiceCategoryOid.Value); + }); + + return list; + } } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Views/Main/Main.cshtml b/BeWoPlanerMobil/Views/Main/Main.cshtml index f167f98dc..3adffe582 100644 --- a/BeWoPlanerMobil/Views/Main/Main.cshtml +++ b/BeWoPlanerMobil/Views/Main/Main.cshtml @@ -1,6 +1,5 @@ @using BeWoPlanerMobil.Models; @using BeWoPlanerMobil.Util -@using DevExpress.Mvvm.Native @model MainModel @{ @@ -581,52 +580,52 @@ - @using (Html.BeginForm("AddSupportConceptsToGroupBooking", "Main", FormMethod.Post, new {id = "groupBookingSupportConceptSelectionForm"})) - { - var i = 0; - var j = 0; -
- - @foreach (var hp in Model.SupporConceptListItemsForGroupBooking) - { - - - - - i++; - } - -
- - - @hp.Text -
-
-
- - @foreach (var gruppe in Model.GroupOfPeopleListItems) - { + @using (Html.BeginForm("AddSupportConceptsToGroupBooking", "Main", FormMethod.Post, new {id = "groupBookingSupportConceptSelectionForm"})) + { + var i = 0; + var j = 0; +
+
+ @foreach (var hp in Model.SupporConceptListItemsForGroupBooking) + { - j++; - } -
- - @gruppe.Text + @hp.Text
-
- } + i++; + } + + + +
+ + @foreach (var gruppe in Model.GroupOfPeopleListItems) + { + + + + + j++; + } +
+ + + @gruppe.Text +
+
+ } @@ -1017,15 +1016,11 @@ SetSaveSignatureUrl = '@Url.Action("SetSaveSignature")'; loadTextbausteineForCategoryUrl = '@Url.Action("LoadTextbausteineForServiceCategory")'; loadCompleteTextbausteinByOidUrl = '@Url.Action("LoadCompleteTextbausteinByOid")'; - @*addSupportConceptForGruppenbuchungUrl = '@Url.Action("AddSupportConceptToGruppenbuchung")'; - addEmployeeForGruppenbuchungUrl = '@Url.Action("AddEmployeeToGruppenbuchung")'; - removeSupportConceptFromGruppenbuchungUrl = '@Url.Action("RemoveSupportConceptFromGruppenbuchung")'; - removeEmployeeFromGruppenbuchungUrl = '@Url.Action("RemoveEmployeeFromGruppenbuchung")';*@ setGroupbookinModeUrl = '@Url.Action("SetGroupBookingMode")'; setSelectedGroupServiceRecordUrl = '@Url.Action("SetSelectedGroupServiceRecord")'; resetEditingModeUrl = '@Url.Action("ResetEditingMode")'; - loadCategoryAndDescriptionUrl = '@Url.Action("LoadCategoryAndDescription")'; - addEmployeesToGroupBookingUrl = '@Url.Action("AddEmployeesToGroupBooking")'; + loadCategoryAndDescriptionUrl = '@Url.Action("LoadCategoryAndDescription")'; + addEmployeesToGroupBookingUrl = '@Url.Action("AddEmployeesToGroupBooking")';