From 3ca4ec53236a96cb0421e60bf3064094111a79d0 Mon Sep 17 00:00:00 2001 From: Lyndon Jetten Date: Wed, 26 Jun 2024 12:29:22 +0200 Subject: [PATCH] =?UTF-8?q?Das=20Gruppenbuchungsformular=20hat=20jetzt=20d?= =?UTF-8?q?ie=20Summe=20der=20Ziele=20aller=20ausgew=C3=A4hlten=20Hilfepl?= =?UTF-8?q?=C3=A4ne=20und=20die=20Schnittmenge=20deren=20Leistungen=20und?= =?UTF-8?q?=20Kategorien.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Das Mehrfachbuchungsformular hat ebenfalls die Schnittmenge der Leistungen und Kategorien von den ausgewählten Hilfeplänen. Das Caching ist wieder aktiviert. Und lädt pro Post-Aufruf nur noch einmal 13 MB und danach nur noch 300 kb herunter. Überall konsequent geprüft, ob das Model nicht null ist und falls dem so ist, wird ausgeloggt, damit es zu keinen Fehlern mehr kommt. --- BeWoPlanerMobil/BeWoPlanerMobil.csproj | 10 +- .../Controllers/AbstractBaseController.cs | 1 + .../Controllers/CustomerController.cs | 92 ++- .../Controllers/LoginController.cs | 2 + BeWoPlanerMobil/Controllers/MainController.cs | 725 ++++++++++++------ .../Controllers/ReportController.cs | 21 +- .../Controllers/ReportViewerController.cs | 19 +- .../Controllers/SchedulerController.cs | 42 +- BeWoPlanerMobil/Models/MainModel.cs | 23 +- .../Scripts/ownSoft-Scripts/group-booking.js | 123 --- .../Scripts/ownSoft-Scripts/signature.js | 6 + .../support-concept-statistics.js | 6 + ...ord-security.js => MoKPasswordSecurity.js} | 0 .../ownSoft-Scripts/utils/js-helper.js | 9 + .../ownSoft-Scripts/utils/list-utils.js | 4 +- .../utils/resources-list-utils.js | 4 +- .../ownSoft-Scripts/view-scripts/main.js | 28 +- .../ownSoft-Scripts/view-scripts/scheduler.js | 5 + .../Util/FormCollectionConstants.cs | 1 + .../Util/GroupBookingSelectionObject.cs | 3 +- BeWoPlanerMobil/Views/Login/Index.cshtml | 18 +- .../Category2ServiceDescriptionPartial.cshtml | 47 +- .../Main/GoalRatingPopupContentPartial.cshtml | 51 ++ .../Views/Main/GroupBookingFormPartial.cshtml | 585 +++++++------- .../Views/Main/GroupBookingPartial.cshtml | 42 +- .../Views/Main/GroupBookingScCbRelList.cshtml | 39 +- .../Main/GroupBookingSelectionPartial.cshtml | 82 ++ BeWoPlanerMobil/Views/Main/Main.cshtml | 66 +- .../Views/Main/MultiBookingFormPartial.cshtml | 334 ++++++++ .../Views/Main/MultiBookingPartial.cshtml | 582 +------------- .../Views/Main/MultiBookingScCbRelList.cshtml | 68 ++ .../Main/MultiBookingSelectionPartial.cshtml | 67 ++ .../Main/OneTimeLinkCreationPartial.cshtml | 22 +- .../Main/ServiceRecordListPartial.cshtml | 28 +- .../Views/Main/SingleBookingPartial.cshtml | 19 +- .../Views/Main/TextModulePartial.cshtml | 11 + ...ConfirmationReceiptSignaturePartial.cshtml | 24 +- .../QuittierungsbelegsPreviewPartial.cshtml | 16 +- .../QuittierungsbelegsResultPartial.cshtml | 339 ++++---- BeWoPlanerMobil/Views/Report/Report.cshtml | 12 +- .../DocumentWebViewerPartial.cshtml | 12 + .../Views/ReportViewer/ReportViewer.cshtml | 14 +- .../ReportViewerFormPartial.cshtml | 34 +- .../Scheduler/AppointmentFormPartial.cshtml | 167 ++-- .../AppointmentIntervalFinderPartial.cshtml | 495 ++++++------ ...ointmentIntervalFinderResultPartial.cshtml | 42 +- .../CustomerFilterSelectionPartial.cshtml | 12 + ...ustomerFilteringModalContentPartial.cshtml | 18 +- ...mployeeFilteringModalContentPartial.cshtml | 13 +- .../EmployeeForFilteringPartial.cshtml | 16 +- .../Scheduler/FiveDaySchedulerPartial.cshtml | 106 +-- .../Scheduler/OneDaySchedulerPartial.cshtml | 28 +- .../Views/Scheduler/Scheduler.cshtml | 10 + .../Scheduler/SevenDaySchedulerPartial.cshtml | 140 ++-- BeWoPlanerMobil/Views/Shared/_Layout.cshtml | 449 +++++------ .../OperationsServiceImp.cs | 21 +- 56 files changed, 2944 insertions(+), 2209 deletions(-) delete mode 100644 BeWoPlanerMobil/Scripts/ownSoft-Scripts/group-booking.js rename BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/{password-security.js => MoKPasswordSecurity.js} (100%) create mode 100644 BeWoPlanerMobil/Views/Main/GoalRatingPopupContentPartial.cshtml create mode 100644 BeWoPlanerMobil/Views/Main/GroupBookingSelectionPartial.cshtml create mode 100644 BeWoPlanerMobil/Views/Main/MultiBookingFormPartial.cshtml create mode 100644 BeWoPlanerMobil/Views/Main/MultiBookingScCbRelList.cshtml create mode 100644 BeWoPlanerMobil/Views/Main/MultiBookingSelectionPartial.cshtml diff --git a/BeWoPlanerMobil/BeWoPlanerMobil.csproj b/BeWoPlanerMobil/BeWoPlanerMobil.csproj index d754bd12a..24c41a417 100644 --- a/BeWoPlanerMobil/BeWoPlanerMobil.csproj +++ b/BeWoPlanerMobil/BeWoPlanerMobil.csproj @@ -484,7 +484,6 @@ - @@ -542,7 +541,7 @@ - + @@ -603,6 +602,11 @@ + + + + + @@ -691,7 +695,7 @@ - False + True False 8808 / diff --git a/BeWoPlanerMobil/Controllers/AbstractBaseController.cs b/BeWoPlanerMobil/Controllers/AbstractBaseController.cs index 9beba6d32..117b47549 100644 --- a/BeWoPlanerMobil/Controllers/AbstractBaseController.cs +++ b/BeWoPlanerMobil/Controllers/AbstractBaseController.cs @@ -5,6 +5,7 @@ using System.Web.Security; using BeWo.Service.ServiceContracts; using BeWoPlanerMobil.Models; using BeWoPlanerMobil.Service; +using BeWoPlanerMobil.Util; using BS.Shared; using BS.Shared.Core; using BS.Shared.DataContracts; diff --git a/BeWoPlanerMobil/Controllers/CustomerController.cs b/BeWoPlanerMobil/Controllers/CustomerController.cs index 027625f29..f50d716e9 100644 --- a/BeWoPlanerMobil/Controllers/CustomerController.cs +++ b/BeWoPlanerMobil/Controllers/CustomerController.cs @@ -49,7 +49,7 @@ namespace BeWoPlanerMobil.Controllers { try { - if (!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) + if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) { return Logout(); } @@ -130,6 +130,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -155,6 +156,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -175,7 +177,7 @@ namespace BeWoPlanerMobil.Controllers { if (Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) { - Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; return null; } @@ -211,6 +213,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -318,7 +321,8 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !AbstractModel.IsAllowedToSeeMedikamentenliste) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerReportPartial", Model); } var selectedReportType = (CustomerReportType)reportType; @@ -333,7 +337,8 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !AbstractModel.IsAllowedToSeeMedikamentenliste) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerReportPartial", Model); } Model.SelectedReportType = CustomerReportType.Historie; @@ -348,7 +353,8 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !AbstractModel.IsAllowedToSeeMedikamentenliste) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerMedListPartial", Model); } Model.SelectedReportType = CustomerReportType.Historie; @@ -490,6 +496,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadFormPartial() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerBargeldkassenFormPartial", Model); + } + Model.SelectedBargeldkasse = null; Model.SelectedAuszahlungsintervall = 0; @@ -499,6 +511,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadEditFormPartial(long bargeldkassenOid) { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerBargeldkassenFormPartial", Model); + } + Model.SelectedBargeldkasse = Model.Bargeldkassen.FirstOrDefault(bargeldkasse => bargeldkasse.BargeldkassenOid.HasValue && bargeldkasse.BargeldkassenOid.Value.Equals(bargeldkassenOid)); if(Model.SelectedBargeldkasse != null) @@ -515,6 +533,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null || !long.TryParse(formCollection["bk-to-delete-oid"], out var bargeldkassenOid) || Model.SelectedCustomerOid is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -540,6 +559,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -591,6 +611,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult PrintBargeldkasse(long kassenbuchOid, string reportStartDate, string reportEndDate) { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerReportPartial", Model); + } + var bargeldkasse = Model.Bargeldkassen.FirstOrDefault(f => f.BargeldkassenOid.HasValue && f.BargeldkassenOid.Value.Equals(kassenbuchOid)); var startDate = DateTime.TryParse(reportStartDate, out var parsedStartDate) ? parsedStartDate : DateTime.Today.GetFirstOfMonth(); @@ -630,6 +656,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult DownloadZahlungsbeleg(long transaktionsOid) { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerReportPartial", Model); + } + var kassenbuch = Model.Bargeldkassen.FirstOrDefault(bargeldkasse => bargeldkasse.Bargeldtransaktionen.Any(transaktion => transaktion.BargeldtransaktionOid.Equals(transaktionsOid))); var zahlung = kassenbuch?.Bargeldtransaktionen.FirstOrDefault(bargeldtransaktion => bargeldtransaktion.BargeldtransaktionOid.Equals(transaktionsOid)); @@ -652,6 +684,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadBargeldtransaktionsEditForm(long transaktionsOid) { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerBargeldtransaktionenFormPartial"); + } + var kassenbuch = GetBargeldkasseByTransaktionsOid(transaktionsOid); var zahlung = kassenbuch?.Bargeldtransaktionen.FirstOrDefault(bargeldtransaktion => bargeldtransaktion.BargeldtransaktionOid.Equals(transaktionsOid)); @@ -684,6 +722,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadBargeldtransaktionsForm(long bargeldkassenOid) { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerBargeldtransaktionenFormPartial"); + } + Model.SelectedBargeldtransaktion = null; Model.SelectedTransaktionsart = 0; @@ -695,6 +739,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult CreateOrUpdateBargeldTransaktion2(string rawDate, string rawArt, string rawBetrag, string belegnummer, string notice) { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerBargeldkassen"); + } + var transaktion2Edit = Model.SelectedBargeldtransaktion; var bargeldkasse = Model.SelectedBargeldkasse; @@ -759,7 +809,8 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerBargeldkassen"); } if(bargeldtransaktionsOid is null) @@ -798,7 +849,8 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerBargeldkassen"); } var bargeldkasse = GetBargeldkasseByTransaktionsOid(transaktionsOid); @@ -853,7 +905,8 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerBargeldkassen"); } BargeldkassenDC bargeldkasse = null; @@ -898,11 +951,10 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerBargeldtransaktionshistorienPartial"); } - - var historyEntries = OperationsService.LoadBargeldtransaktionshistoryEntries(transactionOid); Model.BargeldtransaktionshistoryEntries = historyEntries.OrderByDescending(he => he.InsertedOn).ToList(); @@ -931,6 +983,12 @@ namespace BeWoPlanerMobil.Controllers [HttpPost] public ActionResult CreateOrUpdateAbsenceTime(FormCollection formCollection) { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return Logout(); + } + var selectedAbsenceTime = Model.SelectedAbsenceTime; var oid = selectedAbsenceTime?.AbsenceTimeOid; @@ -999,6 +1057,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -1042,6 +1101,11 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadAbsenceTimeToForm() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + } + return PartialView("CustomerAbsenceTimeFormPartial", Model); } @@ -1057,6 +1121,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult DeleteAbsenceTime(long absenceTimeOid) { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("CustomerAbsenceTimePartial"); + } + var absenceTime2Delete = Model.SelectedCustomer.AbsenceTimes.FirstOrDefault(absenceTime => absenceTime.AbsenceTimeOid.HasValue && absenceTime.AbsenceTimeOid.Equals(absenceTimeOid)); if(absenceTime2Delete is null) diff --git a/BeWoPlanerMobil/Controllers/LoginController.cs b/BeWoPlanerMobil/Controllers/LoginController.cs index 6b80a94be..3103008d8 100644 --- a/BeWoPlanerMobil/Controllers/LoginController.cs +++ b/BeWoPlanerMobil/Controllers/LoginController.cs @@ -154,6 +154,8 @@ namespace BeWoPlanerMobil.Controllers ViewData[IsSessionTimedOut] = "Sie wurden automatisch abgemeldet, da Ihre Session abgelaufen ist."; } + var errorMessage = TempData[TempDataConstants.ErrorMessageKey]; + if(tenant is null) { var keks = HttpContext.Request.Cookies.Get(MobileSessionFacade.CookieName); diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index c1883d5fa..535fbdac7 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -63,8 +63,8 @@ namespace BeWoPlanerMobil.Controllers private Dictionary _ParentGoals; - private static readonly List _Zieltypen = new List { ValueListEntryType.SupportConceptGoalCategoryType, ValueListEntryType.SupportConceptIndividualGoalCategoryType }; - private static readonly List _Massnahmentypen = new List { ValueListEntryType.SupportConceptGoalType, ValueListEntryType.SupportConceptIndividualGoalType }; + private static readonly List Zieltypen = new List { ValueListEntryType.SupportConceptGoalCategoryType, ValueListEntryType.SupportConceptIndividualGoalCategoryType }; + private static readonly List Massnahmentypen = new List { ValueListEntryType.SupportConceptGoalType, ValueListEntryType.SupportConceptIndividualGoalType }; private MandatorDC GetMandator() { @@ -81,8 +81,6 @@ namespace BeWoPlanerMobil.Controllers return mandator; } - // ToDo: Am 03.06.2024: Überall prüfen, ob das Model null ist. Wenn ja, dann ausloggen! - [Authorize] public ActionResult Main() { @@ -375,29 +373,40 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - if(!Model.IsInGroupBookingMode) + var rating = Model.GoalRatingTypes.FirstOrDefault(ratingType => ratingType.RatingTypeOid == ratingTypeOid); + + var allGoals = new List(); + + if(Model.IsInGroupBookingMode) { - var rating = Model.GoalRatingTypes.FirstOrDefault(ratingType => ratingType.RatingTypeOid == ratingTypeOid); + var supportConcepts = Model.GroupBookingSelectedSupportConcepts; - var allGoals = GetAllGoalsForSelectedSupportConcept(); - - var goal = allGoals.FirstOrDefault(g => g.ValueListEntryOid?.Equals(goalOid.Value) ?? false); - - if(!(goal is null) && Model.SelectedGoals.Any(a => a.ValueListEntryOid.HasValue && a.ValueListEntryOid.Value == goal.ValueListEntryOid)) - { - goal.RatingTypeOid = ratingTypeOid; - - var selectedGoal = Model.SelectedGoals.FirstOrDefault(a => a.ValueListEntryOid.HasValue && a.ValueListEntryOid.Value == goal.ValueListEntryOid); - if(!(selectedGoal is null)) - { - selectedGoal.RatingTypeOid = ratingTypeOid; - } - } - - return SerializeObject(new GoalRating(rating?.DisplayName ?? string.Empty, goal?.ValueListEntryOid ?? 0)); + supportConcepts.DoForEach(sc => { allGoals.AddRangeIfElementsNotIn(sc.Goals); }); + } + else if(!Model.IsInGroupBookingMode) + { + allGoals = GetAllGoalsForSelectedSupportConcept(); } - return null; + var goal = allGoals.FirstOrDefault(g => g.ValueListEntryOid?.Equals(goalOid.Value) ?? false); + + if(goal != null) + { + if(!Model.SelectedGoals.Any(a => a.ValueListEntryOid.HasValue && a.ValueListEntryOid.Value == goal.ValueListEntryOid)) + { + Model.SelectedGoals.AddIfNotIn(goal); + } + + goal.RatingTypeOid = ratingTypeOid; + + var selectedGoal = Model.SelectedGoals.FirstOrDefault(a => a.ValueListEntryOid.HasValue && a.ValueListEntryOid.Value == goal.ValueListEntryOid); + if(!(selectedGoal is null)) + { + selectedGoal.RatingTypeOid = ratingTypeOid; + } + } + + return SerializeObject(new GoalRating(rating?.DisplayName ?? string.Empty, goal?.ValueListEntryOid ?? 0)); } private List _AllGoals; @@ -440,6 +449,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -461,6 +471,11 @@ namespace BeWoPlanerMobil.Controllers { try { + if(Model is null) + { + return; + } + var selectedGoals = new List(); if(Model.IsInGroupBookingMode) @@ -511,8 +526,8 @@ namespace BeWoPlanerMobil.Controllers private List BuildGoalTree(IReadOnlyCollection goals) { - var ziele = goals.Where(w => _Zieltypen.Contains(w.Type)).OrderBy(s => s.DisplayName).ToList(); - var massnahmen = goals.Where(w => _Massnahmentypen.Contains(w.Type)).OrderBy(s => s.DisplayName).ToList(); + var ziele = goals.Where(w => Zieltypen.Contains(w.Type)).OrderBy(s => s.DisplayName).ToList(); + var massnahmen = goals.Where(w => Massnahmentypen.Contains(w.Type)).OrderBy(s => s.DisplayName).ToList(); var goalTree = new List(); var goalTreeDic = new Dictionary(); var goalsWithRating = Model.SelectedServiceRecord?.Goals.Where(goal => goal.RatingTypeOid.HasValue).ToList() ?? new List(); @@ -898,7 +913,8 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("TextModulePartial"); } Model.TextModules.Clear(); @@ -952,6 +968,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -993,7 +1010,7 @@ namespace BeWoPlanerMobil.Controllers } } - var selectedCostbearerSCRelOid = Model.CostBearer2SupportConceptOid < 1 ? null : Model.CostBearer2SupportConceptOid; + var selectedCostbearerScRelOid = Model.CostBearer2SupportConceptOid < 1 ? null : Model.CostBearer2SupportConceptOid; var datum = Convert.ToDateTime(collection[FormCollectionConstants.DateKey]); var enddatum = datum; @@ -1093,7 +1110,7 @@ namespace BeWoPlanerMobil.Controllers } } - var sc = Model.SupportConcepts.FirstOrDefault(fod => fod.CostBearerRelations.Any(a => a.CostBearer2SupportConceptOid.HasValue && a.CostBearer2SupportConceptOid.Value.Equals(selectedCostbearerSCRelOid))); + var sc = Model.SupportConcepts.FirstOrDefault(fod => fod.CostBearerRelations.Any(a => a.CostBearer2SupportConceptOid.HasValue && a.CostBearer2SupportConceptOid.Value.Equals(selectedCostbearerScRelOid))); if(!(sc is null)) { @@ -1104,7 +1121,7 @@ namespace BeWoPlanerMobil.Controllers Model.NewServiceRecord.Customer = sc.Customer; - var cb2ScRel = sc.CostBearerRelations.First(f => f.CostBearer2SupportConceptOid.HasValue && f.CostBearer2SupportConceptOid.Equals(selectedCostbearerSCRelOid)); + var cb2ScRel = sc.CostBearerRelations.First(f => f.CostBearer2SupportConceptOid.HasValue && f.CostBearer2SupportConceptOid.Equals(selectedCostbearerScRelOid)); Model.NewServiceRecord.CostBearer = cb2ScRel.CostBearer; var intervall = Model.NewServiceRecord.CostBearer.ActualMinuteIntervall; @@ -1118,7 +1135,7 @@ namespace BeWoPlanerMobil.Controllers Model.NewServiceRecord.RoundedDuration = dauer; } - Model.NewServiceRecord.CostBearer2SupportConceptOid = selectedCostbearerSCRelOid; + Model.NewServiceRecord.CostBearer2SupportConceptOid = selectedCostbearerScRelOid; } else { @@ -1267,6 +1284,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] private ActionResult SaveGroupBooking() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return Logout(); + } + var employeeCount = Model.GroupBookingSelectedEmployees.Count; var personCount = Model.GroupBookingSelectedSupportConcepts.Count; @@ -1336,6 +1359,11 @@ namespace BeWoPlanerMobil.Controllers [Authorize] private ActionResult UpdateGroupBooking() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + } + var dc = Model.SelectedServiceRecord; var group = OperationsService.GetServiceRecordGroup(dc.GroupOid.Value); @@ -1416,6 +1444,8 @@ namespace BeWoPlanerMobil.Controllers foreach(var item in group.ServiceRecordList) { + item.Goals = Model.NewServiceRecord.Goals; + item.Notice = Model.NewServiceRecord.Notice?.RemoveUppercaseEsszett(); item.Notice2 = Model.NewServiceRecord.Notice2?.RemoveUppercaseEsszett(); item.Notice3 = Model.NewServiceRecord.Notice3?.RemoveUppercaseEsszett(); @@ -1583,15 +1613,22 @@ namespace BeWoPlanerMobil.Controllers foreach(var sc in Model.GroupBookingSelectedSupportConcepts) { + if(sc?.SupportConceptOid is null) + { + continue; + } + + var costBearerRelation = Model.GroupBookingSelectionObject.SelectedRelations.FirstOrDefault(f => f.SupportConceptOid.HasValue && f.SupportConceptOid.Value.Equals(sc.SupportConceptOid.Value)); + foreach(var emp in Model.GroupBookingSelectedEmployees) { var key = emp.EmployeeOid + "_" + sc.SupportConceptOid; - if(sc.CostBearerRelations != null && sc.CostBearerRelations.Count > 0) + if(costBearerRelation?.CostBearer2SupportConceptOid != null) { var costBearer2SupportConceptOid = sc.CostBearerRelations.ElementAt(0).CostBearer2SupportConceptOid; if(costBearer2SupportConceptOid != null) { - key += "_" + costBearer2SupportConceptOid.Value; + key += "_" + costBearerRelation.CostBearer2SupportConceptOid.Value; } newKeys.Add(key, key); @@ -1683,6 +1720,8 @@ namespace BeWoPlanerMobil.Controllers { if (Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; + TempData[TempDataConstants.ErrorMessageKey] = "Model ist null!"; return Logout(); } @@ -1705,33 +1744,54 @@ namespace BeWoPlanerMobil.Controllers private void LoadServiceCategoriesToModel(long? cb2ScOid) { - if (cb2ScOid is null && Model.IsInGroupBookingMode) + if(Model is null) { - var selectedSupportConcepts = Model.GroupBookingSelectedSupportConcepts; + return; + } + if(Model.Categories2Descriptions is null) + { + Model.Categories2Descriptions = new Dictionary>(); + } + + if(Model.ServiceCategories is null) + { + Model.ServiceCategories = new List(); + } + + Model.ServiceCategories.Clear(); + Model.Categories2Descriptions.Clear(); + Model.SelectedServiceCategory = null; + Model.SelectedServiceCategoryOid = null; + Model.SelectedServiceDescription = null; + Model.SelectedServiceDescriptionOid = null; + + if(cb2ScOid is null && (Model.IsInGroupBookingMode || Model.IsInMultiBookingMode)) + { + var selectedSupportConcepts = Model.IsInGroupBookingMode ? + Model.GroupBookingSelectedSupportConcepts : + Model.IsInMultiBookingMode ? + Model.MultiBookingSelectedSupportConcepts : + new List(); + + // Alle ServiceDescriptions der ausgewählten Hilfepläne laden var nodes = OperationsService.GetSupportConceptTreeNodeDetailInfos(selectedSupportConcepts.Where(sc => sc.SupportConceptOid.HasValue).Select(sc => sc.SupportConceptOid.Value).ToList()); - // Alle Categories und Services der ausgewählten Hilfepläne laden - if(Model.Categories2Descriptions is null) { Model.Categories2Descriptions = new Dictionary>(); } - Model.Categories2Descriptions.Clear(); - Model.Categories2Descriptions = CreateServiceCategory2ServiceDescription(nodes, true); - // ToDo: Ist das hier noch notwendig? - var serviceDescriptionList = new List>(); + if(Model.Categories2Descriptions.Count == 0 && nodes.Any()) + { + var allServiceDescriptions = OperationsService.GetAllServiceDescriptions(); - nodes.AsParallel().ForAll(node => serviceDescriptionList.Add(node.ServiceAccountings.Select(serviceAccounting => serviceAccounting.ServiceDescription).ToList())); + allServiceDescriptions.DoForEach(serviceDescription => Model.Categories2Descriptions.AddOrUpdateValueInDictionary(serviceDescription.Category, serviceDescription)); + } - var serviceDescriptions = serviceDescriptionList.Any() ? serviceDescriptionList.AsParallel().Aggregate>((a, b) => a.Intersect(b)).ToList() : new List(); - - Model.ServiceCategories = serviceDescriptions.Count == 0 - ? CreateServiceCategoryModels(OperationsService.GetAllServiceDescriptions()) - : CreateServiceCategoryModels(serviceDescriptions); + SelectFirstServiceDescription(); return; } @@ -1826,26 +1886,55 @@ namespace BeWoPlanerMobil.Controllers Model.IsCustomerAbsence = false; Model.CustomerAbsenceInfo = null; } + + SelectFirstServiceDescription(); + } + + private void SelectFirstServiceDescription() + { + if(Model?.Categories2Descriptions is null || Model.Categories2Descriptions.Count == 0|| Model.SelectedServiceDescription != null || Model.SelectedServiceCategory != null) + { + return; + } + + var firstServiceCategory2ServiceDescriptions = Model.Categories2Descriptions.OrderBy(c2d => c2d.Key.Position).ThenBy(c2d => c2d.Key.ServiceCategoryOid).FirstOrDefault(c2d => c2d.Value.Any()); + + if(firstServiceCategory2ServiceDescriptions.Key != null) + { + var serviceDescription = firstServiceCategory2ServiceDescriptions.Value.OrderBy(sd => sd.Position).ThenBy(sd => sd.ServiceDescriptionOid).First(); + + Model.SelectedServiceDescription = serviceDescription; + Model.SelectedServiceCategory = serviceDescription.Category; + Model.SelectedServiceDescriptionOid = serviceDescription.ServiceDescriptionOid; + Model.SelectedServiceCategoryOid = serviceDescription.Category.ServiceCategoryOid; + } } private static Dictionary> CreateServiceCategory2ServiceDescription(List nodes, bool isGroupBooking) { var result = new Dictionary>(); - foreach(var node in nodes) + var firstNode = nodes.FirstOrDefault(); + + if(firstNode is null) { - node.ServiceAccountings.DoForEach(sa => + return result; + } + + if(nodes.Count == 1) + { + firstNode.ServiceAccountings.DoForEach(serviceAccounting => result.AddOrUpdateValueInDictionary(serviceAccounting.ServiceDescription.Category, serviceAccounting.ServiceDescription)); + } + + foreach(var serviceAccounting in firstNode.ServiceAccountings) + { + var serviceDescription = serviceAccounting.ServiceDescription; + var serviceCategory = serviceDescription.Category; + + if(nodes.All(node => node.ServiceAccountings.Any(accounting => accounting.ServiceDescription.Equals(serviceDescription)))) { - var serviceDescription = sa.ServiceDescription; - var category = serviceDescription.Category; - - var withSupportConceptCondition = !isGroupBooking && category.OhneHilfeplan.HasValue && (category.OhneHilfeplan == AccountingvisibilityType.Beides || category.OhneHilfeplan == AccountingvisibilityType.NurKlientenbezogen); - - if(withSupportConceptCondition || isGroupBooking) - { - result.AddOrUpdateValueInDictionary(category, serviceDescription); - } - }); + result.AddOrUpdateValueInDictionary(serviceCategory, serviceDescription); + } } return result.OrderBy(kvp => kvp.Key.Position).ToDictionary(category2Descriptions => category2Descriptions.Key, category2Descriptions => category2Descriptions.Value); @@ -1857,6 +1946,7 @@ namespace BeWoPlanerMobil.Controllers { if (Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -1880,6 +1970,20 @@ namespace BeWoPlanerMobil.Controllers return RedirectToActionPermanent("Main"); } + [Authorize] + public ActionResult ReloadGoalRatings() + { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("GoalRatingPopupContentPartial"); + } + + LoadGoalRatings(); + + return PartialView("GoalRatingPopupContentPartial", Model); + } + [Authorize] public string UpdateGoals(string pGoalOids) { @@ -1890,7 +1994,7 @@ namespace BeWoPlanerMobil.Controllers } var sc = Model.SelectedSupportConcept; - if (sc is null) + if (!Model.IsInGroupBookingMode && sc is null) { return LeerzeichenFuerGetMethoden; } @@ -1905,22 +2009,31 @@ namespace BeWoPlanerMobil.Controllers var splitOids = pGoalOids.Trim(';').Split(';'); var selectedGoalOids = splitOids.Select(long.Parse).ToList(); - var allGoals = sc.Goals; + var allGoals = new List(); + + if(Model.IsInGroupBookingMode) + { + var supportConcepts = Model.GroupBookingSelectedSupportConcepts; + + supportConcepts.DoForEach(supportConcept => { allGoals.AddRangeIfElementsNotIn(supportConcept.Goals); }); + } + else if(!Model.IsInGroupBookingMode) + { + allGoals = sc.Goals; + } + var parents = CustomerService.GetSupportConceptGoalParents(allGoals.Where(w => w.ParentOid.HasValue).Select(s => s.ParentOid.Value).ToList()); allGoals.AddRangeIfElementsNotIn(parents); var goals = allGoals.Where(w => w.ValueListEntryOid.HasValue && selectedGoalOids.Contains(w.ValueListEntryOid.Value)).ToList(); - // ToDo: Hier liegt der Bug! // ToDo: vorhandene Bewertungen beachten! var stillSelectedGoals = Model.SelectedGoals.Where(s => goals.Any(a => a.ValueListEntryOid.HasValue && a.ValueListEntryOid.Value == s.ValueListEntryOid)).ToList(); Model.SelectedGoals = stillSelectedGoals; Model.SelectedGoals.AddRangeIfElementsNotIn(goals); - - //Model.SelectedGoals = goals; return LeerzeichenFuerGetMethoden; } @@ -1944,6 +2057,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -2044,6 +2158,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -2068,8 +2183,11 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedServiceRecord = selectedServiceRecord; Model.SelectedGoals = selectedServiceRecord.Goals; - Model.SelectedServiceDescriptionOid = selectedServiceRecord.ServiceDescription.ServiceDescriptionOid; - Model.SelectedServiceCategoryOid = selectedServiceRecord.ServiceDescription.Category.ServiceCategoryOid; + var selectedServiceDescription = selectedServiceRecord.ServiceDescription; + var selectedServiceCategory = selectedServiceDescription.Category; + + Model.SelectedServiceDescriptionOid = selectedServiceDescription.ServiceDescriptionOid; + Model.SelectedServiceCategoryOid = selectedServiceCategory.ServiceCategoryOid; Model.PreviouslySelectedEmployee = Model.SelectedEmployee; Model.SelectedEmployee = selectedServiceRecord.Employee; @@ -2079,7 +2197,8 @@ namespace BeWoPlanerMobil.Controllers Model.PreviouslySelectedSupportConcept = Model.SelectedSupportConcept; Model.PreviouslySelectedCostbearer2SupportConceptOid = Model.CostBearer2SupportConceptOid; - if (selectedServiceRecord.GroupOid.HasValue) + // Gruppenbuchung + if(selectedServiceRecord.GroupOid.HasValue) { Model.IsInGroupBookingMode = true; @@ -2101,6 +2220,15 @@ namespace BeWoPlanerMobil.Controllers selectedSupportConcepts.AddRangeIfElementsNotIn(OperationsService.GetSupportConceptsById(group.ServiceRecordList.Select(s => s.SupportConcept.SupportConceptOid))); Model.GroupBookingSelectedSupportConcepts = selectedSupportConcepts; + + LoadServiceCategoriesToModel(null); + + Model.SelectedServiceDescriptionOid = selectedServiceRecord.ServiceDescription.ServiceDescriptionOid; + Model.SelectedServiceCategoryOid = selectedServiceRecord.ServiceDescription.Category.ServiceCategoryOid; + Model.SelectedServiceDescription = selectedServiceDescription; + Model.SelectedServiceCategory = selectedServiceCategory; + + LoadGoals(); } return RedirectToActionPermanent("Main"); @@ -2152,6 +2280,12 @@ namespace BeWoPlanerMobil.Controllers [HttpPost] public ActionResult ValidateServiceRecord(FormCollection formCollection) { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return Logout(); + } + var inEditMode = Model.IsInEditingMode; var von = formCollection[FormCollectionConstants.DateKey]; @@ -2786,6 +2920,7 @@ namespace BeWoPlanerMobil.Controllers { if (Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -2830,8 +2965,7 @@ namespace BeWoPlanerMobil.Controllers Model.CostBearer2SupportConceptOid = null; Model.SelectedEmployee = null; - Model.ServiceCategories = CreateServiceCategoryModels(OperationsService.GetAllServiceDescriptions()); - + LoadServiceCategoriesToModel(null); Model.GroupBookingSelectedEmployees.AddIfNotIn(MobileSessionFacade.LoggedInCompactEmployee); Model.IsInEditingMode = false; @@ -2851,8 +2985,7 @@ namespace BeWoPlanerMobil.Controllers Model.CostBearer2SupportConceptOid = null; Model.SelectedEmployee = null; - Model.ServiceCategories = CreateServiceCategoryModels(OperationsService.GetAllServiceDescriptions()); - + LoadServiceCategoriesToModel(null); Model.MultiBookingSelectedEmployees.AddIfNotIn(MobileSessionFacade.LoggedInCompactEmployee); Model.IsInEditingMode = false; @@ -2920,6 +3053,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult ResetSingleBookingForm() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return Logout(); + } + ResetBookingMode(BookingMode.SingleBookingMode); return View("Main", Model); @@ -2929,6 +3068,11 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult ResetGroupBookingForm() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + } + ResetBookingMode(BookingMode.GroupBookingMode); return View("Main", Model); @@ -2938,6 +3082,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult ResetMultiBookingForm() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return Logout(); + } + if(Model.PreviouslySelectedSupportConcept != null && Model.SelectedSupportConcept is null) { Model.SelectedSupportConcept = Model.PreviouslySelectedSupportConcept; @@ -2945,7 +3095,6 @@ namespace BeWoPlanerMobil.Controllers } ResetModel(); - //ResetBookingMode(BookingMode.SingleBookingMode); return View("Main", Model); } @@ -2956,6 +3105,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -2970,6 +3120,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -3007,6 +3158,11 @@ namespace BeWoPlanerMobil.Controllers Model.MultiBookingSelectedGroupOfPeopleOids.Clear(); Model.MultiBookingSelectedSupportConcepts.Clear(); + Model.SelectedServiceCategory = null; + Model.SelectedServiceCategoryOid = null; + Model.SelectedServiceDescription = null; + Model.SelectedServiceDescriptionOid = null; + LoadServiceCategoriesToModel(Model.CostBearer2SupportConceptOid); var serviceDescriptions = Model.GetServiceDesctiptions(); @@ -3033,6 +3189,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult AddScCbRelsToGroupBooking(string[] relOids, string[] groupOids) { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("GroupBookingScCbRelList"); + } + var singleRels = new List(); var groupRels = new List(); var groups = new List(); @@ -3120,17 +3282,41 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult RemoveSupportConceptCostbearerRel(string relOid) { - if(!long.TryParse(relOid, out var supportConceptCostBearerRelationOid)) + if(Model is null) { - return PartialView("GroupBookingFormPartial", Model); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("GroupBookingSelectionPartial"); } - var supportConcept = Model.GroupBookingSelectedSupportConcepts.FirstOrDefault(f => f.CostBearerRelations.Any(a => a.CostBearer2SupportConceptOid == supportConceptCostBearerRelationOid)); + if(!long.TryParse(relOid, out var supportConceptCostBearerRelationOid)) + { + return PartialView("GroupBookingSelectionPartial", Model); + } - var relation = Model.SelectedConceptCostBearerRelations.FirstOrDefault(f => f.CostBearer2SupportConceptOid == supportConceptCostBearerRelationOid); + var supportConcept2Remove = Model.GroupBookingSelectedSupportConcepts.FirstOrDefault(f => f.CostBearerRelations.Any(a => a.CostBearer2SupportConceptOid == supportConceptCostBearerRelationOid)); - Model.GroupBookingSelectedSupportConcepts.Remove(supportConcept); - Model.SelectedConceptCostBearerRelations.Remove(relation); + var relation2Remove = Model.SelectedConceptCostBearerRelations.FirstOrDefault(f => f.CostBearer2SupportConceptOid == supportConceptCostBearerRelationOid); + + if(supportConcept2Remove?.SupportConceptOid.HasValue ?? false) + { + var supportConcepts = Model.GroupBookingSelectedSupportConcepts.Where(supportConcept => supportConcept.SupportConceptOid.HasValue && supportConcept.SupportConceptOid.Value.Equals(supportConcept2Remove.SupportConceptOid.Value) == false).ToList(); + + // Ziele, die bei den verbleibenden Hilfeplänen nicht vorhanden sind, werden aus der Auswahl entfernt. + var remainingGoals = new List(); + + foreach(var supportConcept in supportConcepts) + { + foreach(var goal in supportConcept.Goals) + { + remainingGoals.AddIfNotIn(goal); + } + } + + Model.SelectedGoals = Model.SelectedGoals.Where(goal => remainingGoals.Contains(goal)).ToList(); + } + + Model.GroupBookingSelectedSupportConcepts.Remove(supportConcept2Remove); + Model.SelectedConceptCostBearerRelations.Remove(relation2Remove); var selectedGroups = Model.GroupsOfPeople.Where(group => group.GroupOfPeopleOid.HasValue && Model.GroupBookingSelectedGroupOfPeopleOids.Contains(group.GroupOfPeopleOid.Value)).ToList(); @@ -3138,41 +3324,34 @@ namespace BeWoPlanerMobil.Controllers Model.GroupBookingSelectedGroupOfPeopleOids = groups.Where(group => group.GroupOfPeopleOid.HasValue).Select(group => group.GroupOfPeopleOid.Value).ToList(); - return PartialView("GroupBookingFormPartial", Model); + LoadServiceCategoriesToModel(null); + + if(Model.SelectedServiceCategory != null && !Model.Categories2Descriptions.Keys.Contains(Model.SelectedServiceCategory)) + { + var firstCategory2ServiceDescriptions = Model.Categories2Descriptions.FirstOrDefault(); + var firstServiceCategory = firstCategory2ServiceDescriptions.Key; + var firstServiceDescription = firstCategory2ServiceDescriptions.Value?.FirstOrDefault(); + + Model.SelectedServiceCategory = firstServiceCategory; + Model.SelectedServiceDescription = firstServiceDescription; + } + + return PartialView("GroupBookingSelectionPartial", Model); } [Authorize] public ActionResult ReloadGroupBookingForm() - { - return PartialView("GroupBookingFormPartial", Model); - } - - // ToDo: Veraltet und durch RemoveSupportConceptCostbearerRel ersetzt! - [Authorize] - public string RemoveSupportConceptCostBearerRelationFromGroupBooking(string pRelOid) { if(Model is null) { - Logout(); - return LeerzeichenFuerGetMethoden; + TempData[TempDataConstants.DoLogoutKey] = true; + } + else + { + LoadServiceCategoriesToModel(null); } - long.TryParse(pRelOid, out var supportConceptCostBearerRelationOid); - - var supportConcept = Model.GroupBookingSelectedSupportConcepts.FirstOrDefault(f => f.CostBearerRelations.Any(a => a.CostBearer2SupportConceptOid == supportConceptCostBearerRelationOid)); - - var relation = Model.SelectedConceptCostBearerRelations.FirstOrDefault(f => f.CostBearer2SupportConceptOid == supportConceptCostBearerRelationOid); - - Model.GroupBookingSelectedSupportConcepts.Remove(supportConcept); - Model.SelectedConceptCostBearerRelations.Remove(relation); - - var selectedGroups = Model.GroupsOfPeople.Where(group => group.GroupOfPeopleOid.HasValue && Model.GroupBookingSelectedGroupOfPeopleOids.Contains(group.GroupOfPeopleOid.Value)).ToList(); - - var groups = selectedGroups.Where(group => group.SupportConceptList.All(a => Model.GroupBookingSelectedSupportConcepts.Where(w => w.SupportConceptOid.HasValue).Select(s => s.SupportConceptOid.Value).Contains(a.SupportConceptOid))); - - Model.GroupBookingSelectedGroupOfPeopleOids = groups.Where(group => group.GroupOfPeopleOid.HasValue).Select(group => group.GroupOfPeopleOid.Value).ToList(); - - return SerializeObject(Model.GroupBookingSelectionObject); + return PartialView("GroupBookingSelectionPartial", Model); } [Authorize] @@ -3234,6 +3413,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -3255,6 +3435,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -3262,24 +3443,9 @@ namespace BeWoPlanerMobil.Controllers { if(!Model.IsInEditingMode) { - if(Model.SelectedConceptCostBearerRelations.Count == 1) + if(Model.GroupBookingSelectedCostbearerRelOids.Count == 1) { - var cb2ScOids = (from scDc in Model.GroupBookingSelectedSupportConcepts - where scDc.CostBearerRelations != null && scDc.CostBearerRelations.Count > 0 - let costBearer2SupportConceptOid = scDc.CostBearerRelations[0].CostBearer2SupportConceptOid - where costBearer2SupportConceptOid != null - select costBearer2SupportConceptOid.Value).ToList(); - - var cb2ScOidsCount = cb2ScOids.Count; - - if(cb2ScOidsCount == 1) - { - Model.CostBearer2SupportConceptOid = cb2ScOids[0]; - } - else - { - return RedirectToActionPermanent("Main"); - } + Model.CostBearer2SupportConceptOid = Model.GroupBookingSelectedCostbearerRelOids.FirstOrDefault(); } } else @@ -3367,6 +3533,8 @@ namespace BeWoPlanerMobil.Controllers var doku4 = formCollection[FormCollectionConstants.Dokumentation4Key]; var doku5 = formCollection[FormCollectionConstants.Dokumentation5Key]; + // Ziele und Maßnahmen + // Start- und Endstrings werden in DateTime-Objekte konvertiert var zeitenFeld = new DateTime[2]; @@ -3560,6 +3728,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -3751,6 +3920,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -3772,6 +3942,174 @@ namespace BeWoPlanerMobil.Controllers #region Mehrfachbuchung + [Authorize] + public ActionResult ReloadMultiBookingForm() + { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + } + else + { + LoadServiceCategoriesToModel(null); + } + + return PartialView("MultiBookingSelectionPartial", Model); + } + + [Authorize] + public ActionResult AddScCbRelsToMultiBooking(string[] relOids, string[] groupOids) + { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("MultiBookingScCbRelList"); + } + + var singleRels = new List(); + var groupRels = new List(); + var groups = new List(); + + if(groupOids is null) + { + groupOids = Array.Empty(); + } + + if(relOids is null) + { + relOids = Array.Empty(); + } + + relOids.DoForEach(relOid => + { + if(long.TryParse(relOid, out var singleRelOid)) + { + singleRels.AddIfNotIn(singleRelOid); + } + }); + + groupOids.DoForEach(groupOid => + { + if(long.TryParse(groupOid, out var g)) + { + groupRels.AddIfNotIn(g); + } + }); + + Model.MultiBookingSelectedGroupOfPeopleOids.Clear(); + + groupRels.DoForEach(groupOid => + { + var group = Model.GroupsOfPeople.FirstOrDefault(f => f.GroupOfPeopleOid.HasValue && f.GroupOfPeopleOid.Value.Equals(groupOid)); + + if(group is null) + { + return; + } + + groups.AddIfNotIn(group); + group.SupportConceptList.DoForEach(f => singleRels.AddRangeIfElementsNotIn(f.CostBearerRelOids)); + }); + + Model.MultiBookingSelectedSupportConcepts.Clear(); + + Model.MultiBookingSelectedCostbearerRelOids.Clear(); + Model.MultiBookingSelectedCostbearerRelOids.AddRangeIfElementsNotIn(singleRels); + + var selectedSupportConcepts = CustomerService.GetSupportConceptsByCostbearer2SupportConceptRelOids(singleRels); + + var groupCostBearerRelations = CustomerService.GetSupportConceptCostBearerRelationsById(singleRels); + + Model.MultiBookingSelectedConceptCostBearerRelations.Clear(); + Model.MultiBookingSelectedConceptCostBearerRelations.AddRangeIfElementsNotIn(groupCostBearerRelations); + + Model.MultiBookingSelectedSupportConcepts.AddRangeIfElementsNotIn(selectedSupportConcepts); + + foreach(var gruppe in groups.Where(g => g.GroupOfPeopleOid.HasValue)) + { + var groupRelOids = new List(); + gruppe.SupportConceptList.ForEach(f => groupRelOids.AddRange(f.CostBearerRelOids)); + + if(!gruppe.GroupOfPeopleOid.HasValue) + { + continue; + } + + var groupOid = gruppe.GroupOfPeopleOid.Value; + + if(singleRels.ContainsItems(groupRelOids)) + { + Model.MultiBookingSelectedGroupOfPeopleOids.AddIfNotIn(groupOid); + } + else if(Model.MultiBookingSelectedGroupOfPeopleOids.Contains(groupOid)) + { + Model.MultiBookingSelectedGroupOfPeopleOids.Remove(groupOid); + } + } + + return PartialView("MultiBookingScCbRelList", Model); + } + + [Authorize] + public ActionResult RemoveSupportConceptCostbearerRelFromMultiBooking(string relOid) + { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("MultiBookingSelectionPartial"); + } + + if(!long.TryParse(relOid, out var supportConceptCostBearerRelationOid)) + { + return PartialView("MultiBookingSelectionPartial", Model); + } + + var supportConcept2Remove = Model.MultiBookingSelectedSupportConcepts.FirstOrDefault(f => f.CostBearerRelations.Any(a => a.CostBearer2SupportConceptOid == supportConceptCostBearerRelationOid)); + + var relation2Remove = Model.MultiBookingSelectedConceptCostBearerRelations.FirstOrDefault(f => f.CostBearer2SupportConceptOid == supportConceptCostBearerRelationOid); + + if(supportConcept2Remove?.SupportConceptOid.HasValue ?? false) + { + var supportConcepts = Model.MultiBookingSelectedSupportConcepts.Where(supportConcept => supportConcept.SupportConceptOid.HasValue && supportConcept.SupportConceptOid.Value.Equals(supportConcept2Remove.SupportConceptOid.Value) == false).ToList(); + + // Ziele, die bei den verbleibenden Hilfeplänen nicht vorhanden sind, werden aus der Auswahl entfernt. + var remainingGoals = new List(); + + foreach(var supportConcept in supportConcepts) + { + foreach(var goal in supportConcept.Goals) + { + remainingGoals.AddIfNotIn(goal); + } + } + + Model.SelectedGoals = Model.SelectedGoals.Where(goal => remainingGoals.Contains(goal)).ToList(); + } + + Model.MultiBookingSelectedSupportConcepts.Remove(supportConcept2Remove); + Model.MultiBookingSelectedConceptCostBearerRelations.Remove(relation2Remove); + + var selectedGroups = Model.GroupsOfPeople.Where(group => group.GroupOfPeopleOid.HasValue && Model.MultiBookingSelectedGroupOfPeopleOids.Contains(group.GroupOfPeopleOid.Value)).ToList(); + + var groups = selectedGroups.Where(group => group.SupportConceptList.All(a => Model.MultiBookingSelectedSupportConcepts.Where(w => w.SupportConceptOid.HasValue).Select(s => s.SupportConceptOid.Value).Contains(a.SupportConceptOid))); + + Model.MultiBookingSelectedGroupOfPeopleOids = groups.Where(group => group.GroupOfPeopleOid.HasValue).Select(group => group.GroupOfPeopleOid.Value).ToList(); + + LoadServiceCategoriesToModel(null); + + if(Model.SelectedServiceCategory != null && !Model.Categories2Descriptions.Keys.Contains(Model.SelectedServiceCategory)) + { + var firstCategory2ServiceDescriptions = Model.Categories2Descriptions.FirstOrDefault(); + var firstServiceCategory = firstCategory2ServiceDescriptions.Key; + var firstServiceDescription = firstCategory2ServiceDescriptions.Value.FirstOrDefault(); + + Model.SelectedServiceCategory = firstServiceCategory; + Model.SelectedServiceDescription = firstServiceDescription; + } + + return PartialView("MultiBookingSelectionPartial", Model); + } + [Authorize] [HttpPost] public ActionResult SetMultiBookingMode(FormCollection formCollection) @@ -3974,103 +4312,6 @@ namespace BeWoPlanerMobil.Controllers return ResetEditingMode(); } - [Authorize] - public string AddSupportConceptCostBearerRelationsToMultiBooking(string pRelOids, string pGroupOids) - { - if(Model is null) - { - Logout(); - return LeerzeichenFuerGetMethoden; - } - - var rawRelOids = string.IsNullOrEmpty(pRelOids) ? Array.Empty() : pRelOids.Split(','); - var rawGroupOids = string.IsNullOrEmpty(pGroupOids) ? Array.Empty() : pGroupOids.Split(','); - - var relOids = new List(); - var groups = new List(); - - rawRelOids.DoForEach(s => relOids.AddIfNotIn(long.Parse(s))); - - Model.MultiBookingSelectedGroupOfPeopleOids.Clear(); - - rawGroupOids.DoForEach(s => - { - var group = Model.GroupsOfPeople.FirstOrDefault(f => f.GroupOfPeopleOid.HasValue && f.GroupOfPeopleOid.Value.Equals(long.Parse(s))); - if(group is null) - { - return; - } - - groups.AddIfNotIn(group); - group.SupportConceptList.DoForEach(f => relOids.AddRangeIfElementsNotIn(f.CostBearerRelOids)); - }); - - Model.MultiBookingSelectedSupportConcepts.Clear(); - - Model.MultiBookingSelectedCostbearerRelOids.Clear(); - Model.MultiBookingSelectedCostbearerRelOids.AddRangeIfElementsNotIn(relOids); - - var selectedSupportConcepts = Model.SupportConcepts.Where(w => w != null && w.CostBearerRelations.Any(a => a.CostBearer2SupportConceptOid.HasValue && relOids.Contains(a.CostBearer2SupportConceptOid.Value))).ToList(); - - var multiBookingCostBearerRelations = CustomerService.GetSupportConceptCostBearerRelationsById(relOids); - - Model.MultiBookingSelectedConceptCostBearerRelations.Clear(); - Model.MultiBookingSelectedConceptCostBearerRelations.AddRangeIfElementsNotIn(multiBookingCostBearerRelations); - - Model.MultiBookingSelectedSupportConcepts.AddRangeIfElementsNotIn(selectedSupportConcepts); - - foreach(var gruppe in groups.Where(g => g.GroupOfPeopleOid.HasValue)) - { - var groupRelOids = new List(); - gruppe.SupportConceptList.ForEach(f => groupRelOids.AddRange(f.CostBearerRelOids)); - - if(!gruppe.GroupOfPeopleOid.HasValue) - { - continue; - } - - var groupOid = gruppe.GroupOfPeopleOid.Value; - - if(relOids.ContainsItems(groupRelOids)) - { - Model.MultiBookingSelectedGroupOfPeopleOids.AddIfNotIn(groupOid); - } - else if(Model.MultiBookingSelectedGroupOfPeopleOids.Contains(groupOid)) - { - Model.MultiBookingSelectedGroupOfPeopleOids.Remove(groupOid); - } - } - - return SerializeObject(Model.MultiBookingSelectionObject); - } - - [Authorize] - public string RemoveSupportConceptCostBearerRelationFromMultiBooking(string pRelOid) - { - if(Model is null) - { - Logout(); - return LeerzeichenFuerGetMethoden; - } - - long.TryParse(pRelOid, out var supportConceptCostBearerRelationOid); - - var supportConcept = Model.MultiBookingSelectedSupportConcepts.FirstOrDefault(f => f.CostBearerRelations.Any(a => a.CostBearer2SupportConceptOid == supportConceptCostBearerRelationOid)); - - var relation = Model.MultiBookingSelectedConceptCostBearerRelations.FirstOrDefault(f => f.CostBearer2SupportConceptOid == supportConceptCostBearerRelationOid); - - Model.MultiBookingSelectedSupportConcepts.Remove(supportConcept); - Model.MultiBookingSelectedConceptCostBearerRelations.Remove(relation); - - var selectedGroups = Model.GroupsOfPeople.Where(group => group.GroupOfPeopleOid.HasValue && Model.MultiBookingSelectedGroupOfPeopleOids.Contains(group.GroupOfPeopleOid.Value)).ToList(); - - var groups = selectedGroups.Where(group => group.SupportConceptList.All(a => Model.MultiBookingSelectedSupportConcepts.Where(w => w.SupportConceptOid.HasValue).Select(s => s.SupportConceptOid.Value).Contains(a.SupportConceptOid))); - - Model.MultiBookingSelectedGroupOfPeopleOids = groups.Where(group => group.GroupOfPeopleOid.HasValue).Select(group => group.GroupOfPeopleOid.Value).ToList(); - - return SerializeObject(Model.MultiBookingSelectionObject); - } - [Authorize] public string AddEmployeesToMultiBooking(string pEmployeeOids) { @@ -4099,6 +4340,7 @@ namespace BeWoPlanerMobil.Controllers return JsonConvert.SerializeObject(Model.MultiBookingSelectedEmployees.Count); } + // Veraltet [Authorize] public string MultiBookingHasSelectedSupportConcepts() { @@ -4137,6 +4379,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || MobileSessionFacade.LoggedInUserDC.UserVersion is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -4352,28 +4595,60 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult ReloadGoals() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + } + LoadGoals(); return PartialView("GoalTreePartial", Model); } [Authorize] - public ActionResult UpdateServiceCategories() + public ActionResult SetSelectedServiceCategory(string categoryOidStr) { - LoadServiceCategoriesToModel(null); + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("Category2ServiceDescriptionPartial", Model); + } + + if(long.TryParse(categoryOidStr, out var categoryOid)) + { + Model.SelectedServiceCategory = Model.Categories2Descriptions.FirstOrDefault(f => f.Key?.ServiceCategoryOid != null && f.Key.ServiceCategoryOid.Value.Equals(categoryOid)).Key; + Model.SelectedServiceCategoryOid = Model.SelectedServiceCategory?.ServiceCategoryOid; + Model.SelectedServiceDescription = null; + Model.SelectedServiceDescriptionOid = null; + + if(Model.SelectedServiceCategory is null) + { + return PartialView("Category2ServiceDescriptionPartial", Model); + } + + var selectedServiceDescription = Model.Categories2Descriptions[Model.SelectedServiceCategory].OrderBy(sd => sd.Position).ThenBy(sd => sd.ServiceDescriptionOid).FirstOrDefault(); + + Model.SelectedServiceDescription = selectedServiceDescription; + Model.SelectedServiceDescriptionOid = selectedServiceDescription?.ServiceDescriptionOid; + } return PartialView("Category2ServiceDescriptionPartial", Model); } [Authorize] - public ActionResult SetSelectedServiceCategory(string categoryOidStr) + public string CheckSession() { - if(long.TryParse(categoryOidStr, out var categoryOid)) - { - Model.SelectedServiceCategory = Model.Categories2Descriptions.FirstOrDefault(f => f.Key?.ServiceCategoryOid != null && f.Key.ServiceCategoryOid.Value.Equals(categoryOid)).Key; - } + return (Model is null).ToString(); + } - return PartialView("Category2ServiceDescriptionPartial", Model); + [HttpPost] + public ActionResult ZombieLogout() + { +#if DEBUG + TempData[TempDataConstants.ErrorMessageKey] = "Der Browser wurde aus der Versenkung zurückgeholt und das Model ist jetzt null!"; +#endif + + return base.Logout(); } } diff --git a/BeWoPlanerMobil/Controllers/ReportController.cs b/BeWoPlanerMobil/Controllers/ReportController.cs index ddd117bdb..3f52f71ce 100644 --- a/BeWoPlanerMobil/Controllers/ReportController.cs +++ b/BeWoPlanerMobil/Controllers/ReportController.cs @@ -92,6 +92,12 @@ namespace BeWoPlanerMobil.Controllers return RedirectToActionPermanent("Main", "Main"); } + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return Logout(); + } + var month = DateTime.Today.Month; var year = DateTime.Today.Year; var first = new DateTime(year, month, 1).AddMonths(-1); @@ -832,7 +838,8 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("QuittierungsbelegsResultPartial"); } if(Model.SelectedFilterItem is null) @@ -1110,6 +1117,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -1131,6 +1139,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model?.ConfirmationReceiptObject is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -1183,7 +1192,8 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + PartialView("ConfirmationReceiptSignaturePartial"); } if(!Guid.TryParse(identifier, out var resultIdentifier)) @@ -1228,6 +1238,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadReportToModel() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("QuittierungsbelegsPreviewPartial"); + } + var month = Model.SelectedMonth ?? DateTime.Now.AddMonths(-1).Month; var year = Model.SelectedYear ?? DateTime.Now.Year; var customerOid = Model.SelectedCustomerOid; @@ -1261,6 +1277,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } diff --git a/BeWoPlanerMobil/Controllers/ReportViewerController.cs b/BeWoPlanerMobil/Controllers/ReportViewerController.cs index 577600578..845649c11 100644 --- a/BeWoPlanerMobil/Controllers/ReportViewerController.cs +++ b/BeWoPlanerMobil/Controllers/ReportViewerController.cs @@ -42,11 +42,12 @@ namespace BeWoPlanerMobil.Controllers } } - + [Authorize] public ActionResult ReportViewer() { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -107,6 +108,11 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult DocumentWebViewerPartial() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + } + return PartialView("DocumentWebViewerPartial", Model); } @@ -117,7 +123,8 @@ namespace BeWoPlanerMobil.Controllers { if (Model?.Employee?.EmployeeOid is null || reportOid is null) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("DocumentWebViewerPartial"); } var selectedQuery = Model.Queries.FirstOrDefault(query => query.Oid.Equals(reportOid.Value)); @@ -152,7 +159,7 @@ namespace BeWoPlanerMobil.Controllers return PartialView("DocumentWebViewerPartial", Model); } - [Authorize] + //[Authorize] //private string GetQueryReportUrl(QueryDC query) //{ // var url = Request?.Url; @@ -192,7 +199,8 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("ReportViewerFormPartial"); } Model.SelectedReportType = reportType == "0" ? ReportType.Berichte : ReportType.Mitarbeiterstundenkonto; @@ -205,7 +213,8 @@ namespace BeWoPlanerMobil.Controllers { if(Model?.Employee?.EmployeeOid is null) { - return Logout(); + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("DocumentWebViewerPartial"); } if(!string.IsNullOrWhiteSpace(parameters)) diff --git a/BeWoPlanerMobil/Controllers/SchedulerController.cs b/BeWoPlanerMobil/Controllers/SchedulerController.cs index db8e29044..77fb4d358 100644 --- a/BeWoPlanerMobil/Controllers/SchedulerController.cs +++ b/BeWoPlanerMobil/Controllers/SchedulerController.cs @@ -49,7 +49,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult Scheduler() { - if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !AbstractModel.IsAllowedToSeeScheduler) + if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !AbstractModel.IsAllowedToSeeScheduler) { return Logout(); } @@ -267,6 +267,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -393,6 +394,7 @@ namespace BeWoPlanerMobil.Controllers { if (Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -413,6 +415,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -432,6 +435,7 @@ namespace BeWoPlanerMobil.Controllers public ActionResult SelectSchedulerDate(FormCollection formCollection) { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -453,6 +457,10 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; +#if DEBUG + TempData[TempDataConstants.ErrorMessageKey] = "Model war null"; +#endif return Logout(); } @@ -596,7 +604,6 @@ namespace BeWoPlanerMobil.Controllers return JsonConvert.SerializeObject(Model.SelectedCustomers.OrderBy(o => o.LastNameFirstName)); } - // ToDo: AUSFÜHRLICH TESTEN! [Authorize] public string CheckResourcesAvailability(string start, string end, string resourceOids, bool allDay) { @@ -660,6 +667,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -676,6 +684,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -759,6 +768,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -782,6 +792,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } @@ -845,6 +856,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult FetchAppointments() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("OneDaySchedulerPartial"); + } + LoadAppointmentsForDate(); return PartialView("OneDaySchedulerPartial", Model); @@ -905,12 +922,22 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult FetchSelectedEmployeesForPopup() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + } + return PartialView("EmployeeForFilteringPartial", Model); } [Authorize] public ActionResult FetchEmployeeFilteringModalBody() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + } + return PartialView("EmployeeFilteringModalContentPartial", Model); } @@ -963,12 +990,22 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult FetchCustomersForFiltering() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + } + return PartialView("CustomerFilterSelectionPartial", Model); } [Authorize] public ActionResult FetchCustomerFilteringModalBody() { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + } + return PartialView("CustomerFilteringModalContentPartial", Model); } @@ -1138,6 +1175,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { + TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } diff --git a/BeWoPlanerMobil/Models/MainModel.cs b/BeWoPlanerMobil/Models/MainModel.cs index fdc9f29dd..2cfc40c20 100644 --- a/BeWoPlanerMobil/Models/MainModel.cs +++ b/BeWoPlanerMobil/Models/MainModel.cs @@ -775,6 +775,23 @@ namespace BeWoPlanerMobil.Models public ServiceCategoryDC SelectedServiceCategory { get; set; } public ServiceDescriptionDC SelectedServiceDescription { get; set; } + + public ServiceDescriptionDC GetSelectedOrFirstServiceDescription() + { + if(!(SelectedServiceDescription is null) || Categories2Descriptions is null) + { + return SelectedServiceDescription; + } + + var firstServiceCategory2ServiceDescriptions = Categories2Descriptions.OrderBy(c2d => c2d.Key.Position).ThenBy(c2d => c2d.Key.ServiceCategoryOid).FirstOrDefault(c2d => c2d.Value.Any()); + + if(firstServiceCategory2ServiceDescriptions.Key != null && (firstServiceCategory2ServiceDescriptions.Value?.Any() ?? false)) + { + return firstServiceCategory2ServiceDescriptions.Value.OrderBy(sd => sd.Position).ThenBy(sd => sd.ServiceDescriptionOid).First(); + } + + return SelectedServiceDescription; + } } public class CustomSelectListItem @@ -783,13 +800,17 @@ namespace BeWoPlanerMobil.Models public string Text2 { get; } public string Value { get; } public string TextColor { get; } + public long? SupportConceptOid { get; } + public long? CostBearer2SupportConceptOid { get; } - public CustomSelectListItem(string pText1, string pText2, string pValue, string pTextColor) + public CustomSelectListItem(string pText1, string pText2, string pValue, string pTextColor, long? supportConceptOid, long? costBearer2SupportConceptOid) { Text1 = pText1; Text2 = pText2; Value = pValue; TextColor = pTextColor; + SupportConceptOid = supportConceptOid; + CostBearer2SupportConceptOid = costBearer2SupportConceptOid; } } diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/group-booking.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/group-booking.js deleted file mode 100644 index 91c07ed92..000000000 --- a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/group-booking.js +++ /dev/null @@ -1,123 +0,0 @@ -function updateGroupBookingCb2ScList(result) { - try { - var list = $("#selected-cb2sc-list"); - - if(isEmptyOrSpaces(result) || result === "SessionTimeout") { - window.location.href = getRedirectLink(); - return; - } - - var groupBookingSelectionObject = $.parseJSON(result); - - var resultList = groupBookingSelectionObject.SelectedRelations; - - list.empty(); - - $.each(resultList, - function (index, customListItem) { - var html = '
' + customListItem.Text1 + '
' + customListItem.Text2 + '
'; - - list.append(html); - }); - - updateGroupBookingGroupList(groupBookingSelectionObject); - } catch (error) { - if (stringContainsDoctype(result)) { - showErrorPopup(error, result); - } else { - showErrorPopup(error); - } - } -} - -function removeCb2ScRelation(relOid) { - try { - $("#relation-item-" + relOid).remove(); - - if($("#cb2sc-checkbox-" + relOid).length) { - $("#cb2sc-checkbox-" + relOid).prop("checked", false); - } - - if($("#selected-cb2sc-list").find(".list-group-item").length === 0) { - deactivateGroupBookingForm(); - - $("#group-booking-supportconcepts input:checked").each(function () { - $(this).prop("checked", false); - }); - } - - $.get(getRemoveCb2ScRelFromGroupBookingUrl(), {pRelOid: relOid}).done(function (result) { - try { - updateGroupBookingGroupList($.parseJSON(result)); - } catch (error) { - if(stringContainsDoctype(result)) { - showErrorPopup(error, result); - } else { - showErrorPopup(error); - } - } - }); - } catch (error) { - showErrorPopup(error); - } -} - -function updateGroupBookingGroupList(groupBookingSelectionObject) { - var groupOids = groupBookingSelectionObject.GroupOids === undefined ? [] : groupBookingSelectionObject.GroupOids; - var relOids = []; - - if(groupBookingSelectionObject.SelectedRelations !== undefined){ - for(var i = 0; i < groupBookingSelectionObject.SelectedRelations.length; i++) { - var oidStringValue = groupBookingSelectionObject.SelectedRelations[i].Value; - var oidIntValue = parseInt(oidStringValue, 10); - - relOids.push(oidIntValue); - } - } - - $("#group-booking-supportconcepts input").each(function() { - var value = $(this).val(); - - $(this).prop("checked", isInArray(value, relOids)); - }); - - $("#group-booking-groups input").each(function() { - var value = $(this).val(); - - $(this).prop("checked", isInArray(value, groupOids)); - }); - - if(relOids.length === 0 && groupOids.length === 0) { - deactivateGroupBookingForm(); - } else { - activateGroupBookingForm(); - } -} - -function addEmployeeToGroupBooking() { - var url = getAddEmployeesToGroupBookingUrl(); - - var selectedEmployees = []; - - var oidString = ""; - - $("#group-booking-employee-selection-popup input:checked").each(function() { - var oid = $(this).val(); - - selectedEmployees.push(oid); - }); - - for(var i = 0; i < selectedEmployees.length; i++) { - oidString += selectedEmployees[i]; - - if(i < selectedEmployees.length - 1) { - oidString += ","; - } - } - - $.get(url, { pEmployeeOids: oidString }).done(function(numberOfSelectedEmployees) { - $("#selected-employees-count-badge").text(numberOfSelectedEmployees); - - $("#create-button").prop("disabled", numberOfSelectedEmployees === "0" ? true : false); - }); -} \ No newline at end of file diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/signature.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/signature.js index cc7867828..037fc5259 100644 --- a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/signature.js +++ b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/signature.js @@ -77,6 +77,12 @@ function initializeSignature(selectedServiceRecordOid) { return; } + if(false === checkJson(jsonServiceRecord2Monatsunterschrift)) { + logWarning("initializeSignature: Der zurückgegebene Wert ist kein gültiges JSON!"); + hideSpinner(); + return; + } + var serviceRecord2Monatsunterschrift = parseJason(jsonServiceRecord2Monatsunterschrift); var hasMonatsunterschrift = serviceRecord2Monatsunterschrift.HasMonatsunterschrift; diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/support-concept-statistics.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/support-concept-statistics.js index 0e2a3249d..b73f5ba0d 100644 --- a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/support-concept-statistics.js +++ b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/support-concept-statistics.js @@ -18,6 +18,12 @@ function getSupportConceptStatistics(cb2ScRRelOid) { $.get(url, { oid: cb2ScRRelOid }).done(function(jsonObject) { try { + if(false === checkJson(jsonObject)) { + logWarning("getSupportConceptStatistics: Der zurückgegebene Wert ist kein gültiges JSON!"); + hideSpinner(); + return; + } + var scStatistics = parseJason(jsonObject); $("#period-statistics-container").empty(); diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/password-security.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/MoKPasswordSecurity.js similarity index 100% rename from BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/password-security.js rename to BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/MoKPasswordSecurity.js diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/js-helper.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/js-helper.js index ea594d5ca..51e6fa587 100644 --- a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/js-helper.js +++ b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/js-helper.js @@ -67,4 +67,13 @@ function checkArraysForEquality(a1, a2) { } finally { return false; } +} + +function checkJson(jsonToParse) { + try { + $.parseJSON(jsonToParse); + return true; + } catch(parsingError) { + return false; + } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/list-utils.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/list-utils.js index 5072a40d8..c6cb3782a 100644 --- a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/list-utils.js +++ b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/list-utils.js @@ -28,7 +28,9 @@ function changeItemListSelection(url, popupId, listId, itemIdPrefix, isCustomer, // Wird aufgerufen, um die Liste mit den ausgewählten Objekten zu aktualisieren function updateSelectedList(jsonResult, listId, itemIdPrefix, isCustomer, popupId, checkBoxIdSuffix, url, filterAppointmentsUrl, allItemsCheckBoxSuffix, teamMemberOids, allItemsCheckBoxId) { try { - if(isEmptyOrSpaces(jsonResult)) { + if(false === checkJson(jsonResult)) { + logWarning("updateSelectedList: Der zurückgegebene Wert ist kein gültiges JSON!"); + hideSpinner(); return; } diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/resources-list-utils.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/resources-list-utils.js index d3a1e4943..651331013 100644 --- a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/resources-list-utils.js +++ b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/utils/resources-list-utils.js @@ -34,7 +34,9 @@ function updateSelectedResourceList(jsonResult, listId, listItemIdPrefix, popupI list.empty(); - if(isEmptyOrSpaces(jsonResult)) { + if(false === checkJson(jsonResult)) { + logWarning("updateSelectedResourceList: Der zurückgegebene Wert ist kein gültiges JSON!"); + hideSpinner(); return; } diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js index 84a1bc502..20d53f72f 100644 --- a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js +++ b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js @@ -91,11 +91,18 @@ function deleteServiceRecord(serviceRecordOid) { var url = getValidateServiceRecordDeletionUrl(); $.get(url, { serviceRecordOidString: serviceRecordOid }).done(function(result) { - if (result === "Error") { + if(result === "Error") { + hideSpinner(); showAlertMessageBox("Fehler", "Es ist ein Fehler aufgetreten", null, false); return; } + if(false === checkJson(result)) { + logWarning("deleteServiceRecord: Der zurückgegebene Wert ist kein gültiges JSON!"); + hideSpinner(); + return; + } + var form = $("#deletion-form"); if(result.length === 0) { @@ -291,26 +298,7 @@ function hideGoalRatingPopup() { } } -function rateGoal(ratingTypeOid) { - try { - var url = getRateSelectedGoalUrl(); - var goalOid = $("#goal-to-rate-oid").val(); - - $.get(url, { ratingTypeOid: ratingTypeOid, goalOid: goalOid }).done( - function (result) { - var obj = parseJason(result); - - $("#goal-rating-" + goalOid).text(obj.RatingName); - - hideGoalRatingPopup(); - $("#goal-to-rate-oid").val(""); - } - ); - } catch(error) { - showErrorPopup(error); - } -} function checkChildNodes(parentOid) { var rootElement = $("#c-" + parentOid); diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/scheduler.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/scheduler.js index 02aaab2bf..588c528d7 100644 --- a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/scheduler.js +++ b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/scheduler.js @@ -191,6 +191,11 @@ function insertOrUpdateAppointment(formattedStartDate, formattedEndDate, formatt endTimeRaw: formattedEndTime } ).done(function(result) { + if(false === checkJson(result)) { + logWarning("insertOrUpdateAppointment: Der zurückgegebene Wert ist kein gültiges JSON!"); + return; + } + var isOverlapping = parseJason(result); if(isOverlapping === true) { diff --git a/BeWoPlanerMobil/Util/FormCollectionConstants.cs b/BeWoPlanerMobil/Util/FormCollectionConstants.cs index 9140e5781..864b5eb10 100644 --- a/BeWoPlanerMobil/Util/FormCollectionConstants.cs +++ b/BeWoPlanerMobil/Util/FormCollectionConstants.cs @@ -75,5 +75,6 @@ public static string AutoEndOfSessionLogoutMessageKey => "ein_schluessel"; public static string HasWarningMessageKey => "HasWarningMessage"; public static string ErrorMessageKey => "ErrorMessage"; + public static string DoLogoutKey => "DoLogout"; } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Util/GroupBookingSelectionObject.cs b/BeWoPlanerMobil/Util/GroupBookingSelectionObject.cs index 5ba637b52..c1967077b 100644 --- a/BeWoPlanerMobil/Util/GroupBookingSelectionObject.cs +++ b/BeWoPlanerMobil/Util/GroupBookingSelectionObject.cs @@ -8,6 +8,7 @@ namespace BeWoPlanerMobil.Util { public List SelectedRelations { get; set; } = new List(); public IEnumerable GroupOids { get; set; } + public GroupBookingSelectionObject(IEnumerable selectedConceptCostBearerRelations, IEnumerable groupOids) { @@ -26,7 +27,7 @@ namespace BeWoPlanerMobil.Util "text-bewo-expires-in-three-months" : "text-dark"; - var listItem = new CustomSelectListItem(text1, text2, value, textColor); + var listItem = new CustomSelectListItem(text1, text2, value, textColor, rel.SupportConcept?.SupportConceptOid, rel.CostBearer2SupportConceptOid); SelectedRelations.Add(listItem); } diff --git a/BeWoPlanerMobil/Views/Login/Index.cshtml b/BeWoPlanerMobil/Views/Login/Index.cshtml index f4e56f2ff..10b95a04d 100644 --- a/BeWoPlanerMobil/Views/Login/Index.cshtml +++ b/BeWoPlanerMobil/Views/Login/Index.cshtml @@ -80,4 +80,20 @@ $("#login-btn").click(); } }); - \ No newline at end of file + + +@if(Html.IsInDebugMode()) +{ + if(!(TempData[TempDataConstants.ErrorMessageKey] is null)) + { +
+
+
+ +
+
+
+ } +} diff --git a/BeWoPlanerMobil/Views/Main/Category2ServiceDescriptionPartial.cshtml b/BeWoPlanerMobil/Views/Main/Category2ServiceDescriptionPartial.cshtml index d0f999cc0..67d394a65 100644 --- a/BeWoPlanerMobil/Views/Main/Category2ServiceDescriptionPartial.cshtml +++ b/BeWoPlanerMobil/Views/Main/Category2ServiceDescriptionPartial.cshtml @@ -1,4 +1,16 @@ -@model BeWoPlanerMobil.Models.MainModel +@using BeWoPlanerMobil.Util +@model BeWoPlanerMobil.Models.MainModel + +@{ + if(TempData[TempDataConstants.DoLogoutKey] is bool doLogout && doLogout) + { + + + + } +} +@{ + var selectedServiceDescription = Model.GetSelectedOrFirstServiceDescription(); + var selectedCategory = selectedServiceDescription?.Category; +} +
@@ -45,9 +62,14 @@ { var category = serviceCategory2ServiceDescriptions.Key; - var selected = Model.SelectedServiceCategory?.Equals(category) ?? false ? "selected" : string.Empty; + if(category is null) + { + continue; + } - + var selected = selectedCategory != null && selectedCategory.Equals(category) ? " selected" : string.Empty; + + }
@@ -66,16 +88,17 @@
diff --git a/BeWoPlanerMobil/Views/Main/GoalRatingPopupContentPartial.cshtml b/BeWoPlanerMobil/Views/Main/GoalRatingPopupContentPartial.cshtml new file mode 100644 index 000000000..cdb51cf1d --- /dev/null +++ b/BeWoPlanerMobil/Views/Main/GoalRatingPopupContentPartial.cshtml @@ -0,0 +1,51 @@ +@using BeWoPlanerMobil.Models +@using BeWoPlanerMobil.Util +@model BeWoPlanerMobil.Models.MainModel + +@{ + if(TempData[TempDataConstants.DoLogoutKey] is bool doLogout && doLogout) + { + + + + } +} + + + +@if(AbstractModel.HasRightToRateGoals) +{ +
    + @foreach(var ratingType in Model.GoalRatingTypes) + { +
  • @ratingType.DisplayName
  • + } +
+} diff --git a/BeWoPlanerMobil/Views/Main/GroupBookingFormPartial.cshtml b/BeWoPlanerMobil/Views/Main/GroupBookingFormPartial.cshtml index 9b36c62af..c0f4b0fcc 100644 --- a/BeWoPlanerMobil/Views/Main/GroupBookingFormPartial.cshtml +++ b/BeWoPlanerMobil/Views/Main/GroupBookingFormPartial.cshtml @@ -3,22 +3,82 @@ @using BS.Shared @model BeWoPlanerMobil.Models.MainModel +@{ + if(TempData[TempDataConstants.DoLogoutKey] is bool doLogout && doLogout) + { + + + + } +} + + + } +} @using(Html.BeginForm("ResetGroupBookingForm", "Main", FormMethod.Post, new { Id = "reset-group-booking-form-form" })) diff --git a/BeWoPlanerMobil/Views/Main/GroupBookingScCbRelList.cshtml b/BeWoPlanerMobil/Views/Main/GroupBookingScCbRelList.cshtml index fde1dfd8d..d8dd6ddc9 100644 --- a/BeWoPlanerMobil/Views/Main/GroupBookingScCbRelList.cshtml +++ b/BeWoPlanerMobil/Views/Main/GroupBookingScCbRelList.cshtml @@ -1,31 +1,16 @@ -@model BeWoPlanerMobil.Models.MainModel +@using BeWoPlanerMobil.Util +@model BeWoPlanerMobil.Models.MainModel - + } - +}
    @@ -42,7 +27,7 @@