From 4e9ff5df54030652dfbe230f33bded38f33c64bc Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 23 Jul 2025 18:34:48 +0200 Subject: [PATCH] - Mok Bugfixing - Ferientage im QB von LH Bad Kreuznach FUD entfernt --- BeWoPlanerMobil/Controllers/MainController.cs | 189 ++++++++++++++---- .../Service/ASPHibernateSessionManager.cs | 5 +- .../Views/Main/SingleBookingPartial.cshtml | 2 +- Data/Access/SearchDAO.cs | 3 - .../Reports/LeistungsnachweisAmbDienst.cs | 2 +- 5 files changed, 155 insertions(+), 46 deletions(-) diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index 935236d14..5c31c4c14 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -47,6 +47,9 @@ namespace BeWoPlanerMobil.Controllers private MainModel _Model; public bool SkipModelInitialization { get; set; } + + public bool SkipServiceRecordInitialization { get; set; } + public MainModel Model { get @@ -139,9 +142,8 @@ namespace BeWoPlanerMobil.Controllers { if(Model.LoggedInEmployee?.EmployeeOid.HasValue ?? false) { - //Model.SupportConcepts = new List(); - - var test = OperationsService.GetAllActiveSupportConceptCostbearer(false, true, Model.LoggedInEmployee.EmployeeOid.Value); + var customerService = PluginLoader.FindClass(); + var test = customerService.GetAllActiveSupportConceptCostbearer(false, true, Model.LoggedInEmployee.EmployeeOid.Value); Model.SupportConcepts = test; } @@ -155,7 +157,16 @@ namespace BeWoPlanerMobil.Controllers Model.SupportConcepts = Model.SupportConcepts.Where(sc => sc.EndDate is null || sc.EndDate.Value >= DateTime.Now.Date).ToList(); } - foreach(var supportConcept in Model.SupportConcepts) + if (Model.SelectedSupportConceptFilter == CustomerFilterEnum.MyCustomer) + { + Model.SupportConcepts = Model.SupportConcepts.Where(sc => sc.IsRelatedToEmployee).ToList(); + } + else if (Model.SelectedSupportConceptFilter == CustomerFilterEnum.TeamCustomer) + { + Model.SupportConcepts = Model.SupportConcepts.Where(sc => sc.Customer.IsRelatedToTeam).ToList(); + } + + foreach (var supportConcept in Model.SupportConcepts) { if(supportConcept.Goals is null) { @@ -256,8 +267,11 @@ namespace BeWoPlanerMobil.Controllers if(Model.SelectedCostBearerSupportConceptOid.HasValue && Model.SelectedCostBearerSupportConceptOid != -1) { - LoadSupportConceptThings(Model.SelectedCostBearerSupportConceptOid, true); - LoadPaginatedServiceRecordsToModel(Model.CurrentPage); + LoadSupportConceptThings(Model.SelectedCostBearerSupportConceptOid, true); + if (!SkipServiceRecordInitialization) + { + LoadPaginatedServiceRecordsToModel(Model.CurrentPage); + } } else if(Model.IsInGroupBookingMode || Model.IsInMultiBookingMode) { @@ -644,17 +658,23 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult SetShowExpiredSupportConcepts(FormCollection pCollection) { - if(Model is null) + if(!IsUserLoggedIn()) { TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); + } + SkipModelInitialization = true; var newValue = "true,false" == pCollection[FormCollectionConstants.ShowExpiredSupportConceptsKey]; + UpdateApplicationSettings(SettingsKeys.ShowExpiredSupportConcepts, newValue ? "1" : "0"); Model.ShowExpiredSupportConcepts = newValue; + - return UpdateApplicationSettings(SettingsKeys.ShowExpiredSupportConcepts, newValue ? "1" : "0"); + Model.SupportConceptListObjects.Clear(); // Erzwingt das neu laden + + return RedirectToAction("Main"); } [HttpPost] @@ -2186,35 +2206,109 @@ namespace BeWoPlanerMobil.Controllers return result; } - if(nodes.Count == 1) + if (nodes.Count == 1) { firstNode.ServiceAccountings.DoForEach(serviceAccounting => result.AddOrUpdateValueInDictionary(serviceAccounting.ServiceDescription.Category, serviceAccounting.ServiceDescription)); } - - foreach(var serviceAccounting in firstNode.ServiceAccountings) + else if (Model.FilterGroupServiceCategories) { - var serviceDescription = serviceAccounting.ServiceDescription; - var serviceCategory = serviceDescription.Category; + var schnittmenge = ErstelleServiceCategorySchnittmenge(nodes); - if(nodes.All(node => node.ServiceAccountings.Any(accounting => accounting.ServiceDescription.Equals(serviceDescription)))) + foreach (var serviceAccounting in schnittmenge) { + var serviceDescription = serviceAccounting.ServiceDescription; + var serviceCategory = serviceDescription.Category; + result.AddOrUpdateValueInDictionary(serviceCategory, serviceDescription); } } - - if(firstNode.ServiceAccountings.Count == 0 || result.Count == 0) + + if (result.Count == 0) { - var allServiceDescriptions = OperationsService.GetAllServiceDescriptions().Where(sd => sd.Category.ActivationType == ActivationTypeId.Active && sd.ActivationType == ActivationTypeId.Active && sd.Category.OhneHilfeplan != AccountingvisibilityType.NichtKlientenbezogen).ToList(); - - foreach(var serviceDescription in allServiceDescriptions) - { - result.AddOrUpdateValueInDictionary(serviceDescription.Category, serviceDescription); - } + result = GetAllServiceCategory2ServiceDescriptionDict(); } return result.OrderBy(kvp => kvp.Key.Position).ToDictionary(category2Descriptions => category2Descriptions.Key, category2Descriptions => category2Descriptions.Value.OrderBy(serviceDescription => serviceDescription.Position).ToList()); } + + private Dictionary> GetAllServiceCategory2ServiceDescriptionDict() + { + var result = new Dictionary>(); + + var allServiceDescriptions = OperationsService.GetAllServiceDescriptions().Where(sd => sd.Category.ActivationType == ActivationTypeId.Active && sd.ActivationType == ActivationTypeId.Active && sd.Category.OhneHilfeplan != AccountingvisibilityType.NichtKlientenbezogen).ToList(); + + foreach (var serviceDescription in allServiceDescriptions) + { + result.AddOrUpdateValueInDictionary(serviceDescription.Category, serviceDescription); + } + + return result; + } + + private List ErstelleServiceCategorySchnittmenge(List allInfos) + { + + if (allInfos.Count == 0) + { + return null; + } + else if (allInfos.Count == 1) + { + return allInfos[0].ServiceAccountings; + } + + var schnittmenge = new List(); + + Dictionary> allDict = null; + foreach (var info in allInfos) + { + if (info.ServiceAccountings != null && info.ServiceAccountings.Count == 0) + { + if (allDict == null) + { + allDict = GetAllServiceCategory2ServiceDescriptionDict(); + } + + foreach (var cat in allDict.Keys) + { + if (!cat.OhneHilfeplan.HasValue || (cat.OhneHilfeplan.Value != AccountingvisibilityType.NichtKlientenbezogen && cat.OhneHilfeplan.Value != AccountingvisibilityType.Never)) + { + var descList = allDict[cat]; + foreach (var desc in descList) + { + info.ServiceAccountings.Add(new ServiceAccountingDC { ServiceDescription = desc }); + } + } + } + } + } + + var erster = allInfos[0]; + + foreach (var sa in erster.ServiceAccountings) + { + //Prüfe für jeden des ersten ob er auch in allen anderen enthalten ist + bool istDrin = true; + for (int i = 1; i < allInfos.Count; i++) + { + var info2 = allInfos[i]; + + if (!info2.ServiceAccountings.Exists(sa2 => sa2.ServiceDescription.ServiceDescriptionOid == sa.ServiceDescription.ServiceDescriptionOid)) + { + istDrin = false; + } + + } + if (istDrin) + { + schnittmenge.Add(sa); + } + } + return schnittmenge; + + } + [HttpPost] [Authorize] public ActionResult DeleteServiceRecord(FormCollection formCollection) @@ -2377,12 +2471,14 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadServiceRecordsNonPost(int dayCountNumber, string start, string end, int month, int year, int recordsKey) { - if(Model is null) + if(!IsUserLoggedIn()) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("ServiceRecordListPartial"); } + SkipServiceRecordInitialization = true; + var lastSelectedServiceRecordMonth = new DateTime(year, month, 1); var isValidStart = DateTime.TryParse(start, out var parsedStart); @@ -2537,7 +2633,7 @@ namespace BeWoPlanerMobil.Controllers var employees = group.ServiceRecordList.Select(serviceRecord => serviceRecord.Employee).Distinct().ToList(); Model.GroupBookingSelectedEmployeeOids = employees.Select(e => e.EmployeeOid).ToList(); - var cb2ScOids = group.ServiceRecordList.Where(w => w.CostBearer2SupportConceptOid.HasValue).Select(s => s.CostBearer2SupportConceptOid.Value).ToList(); + var cb2ScOids = group.ServiceRecordList.Where(w => w.CostBearer2SupportConceptOid.HasValue).Select(s => s.CostBearer2SupportConceptOid.Value).Distinct().ToList(); //Model.SelectedConceptCostBearerRelations.AddRangeIfElementsNotIn(OperationsService.GetSupportConceptCostBearerRelDCsByOids(cb2ScOids)); Model.GroupBookingSelectedCostBearerSupportConceptOids = cb2ScOids; @@ -3737,11 +3833,13 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult SetSupportConceptFilter(FormCollection formCollection) { - if(Model is null) + if(!IsUserLoggedIn()) { TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); + } + SkipModelInitialization = true; var selectedSupportConceptFilter = formCollection[nameof(Model.SelectedSupportConceptFilter)]; @@ -3752,6 +3850,8 @@ namespace BeWoPlanerMobil.Controllers UpdateApplicationSettings(SettingsKeys.CustomerFilterInZeiterfassung, customerFilter.ToString()); + Model.SupportConceptListObjects.Clear(); // Erzwingt das neu laden + return RedirectToActionPermanent("Main"); } @@ -4020,7 +4120,7 @@ namespace BeWoPlanerMobil.Controllers CompactSupportConceptDC sc = null; if (Model.SupportConcepts != null) { - //sc = Model.SupportConcepts.FirstOrDefault(s => s.SupportConceptOid == supportConceptOid); + sc = Model.SupportConcepts.FirstOrDefault(s => s.SupportConceptOid == supportConceptOid); } if (sc == null) { @@ -4055,12 +4155,14 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult PrepareServiceRecordInsert() { - if(Model is null) + if(!IsUserLoggedIn()) { TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } + SkipModelInitialization = true; + Model.TransferringAppointmentOid = TempData[TempDataConstants.AppointmentOidKey] as long?; if(Model.TransferringAppointmentOid.HasValue && Model.LoggedInEmployee.EmployeeOid.HasValue) @@ -4087,9 +4189,10 @@ namespace BeWoPlanerMobil.Controllers var notice = appointment.Description; - var customerService = PluginLoader.FindClass(); - var supportConcepts = customerService.GetAllActiveSupportConceptCostbearer(false, true, Model.LoggedInEmployee.EmployeeOid.Value); - supportConcepts = supportConcepts.Where(sc => customerOids.Contains(sc.Customer.CustomerOid) && sc.StartDate.HasValue && sc.EndDate.HasValue && start.Value.AreInBetweenDates(end.Value, sc.StartDate.Value, sc.EndDate.Value)).ToList(); + Model.SupportConceptListObjects.Clear(); //Macht, dass beim Init die SupportConcepts neu geladen werden + InitViewModel(); + + var supportConcepts = Model.SupportConcepts.Where(sc => customerOids.Contains(sc.Customer.CustomerOid) && sc.StartDate.HasValue && sc.EndDate.HasValue && start.Value.AreInBetweenDates(end.Value, sc.StartDate.Value, sc.EndDate.Value)).ToList(); var supportConceptList = new List(); @@ -4138,15 +4241,13 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedEmployee = Model.AllEmployees.FirstOrDefault(e => e.EmployeeOid.Equals(employeeOids.FirstOrDefault())); var compactSupportConcept = supportConceptList.First(); - var supportConcept = Model.SupportConcepts.FirstOrDefault(f => f.SupportConceptOid.Equals(compactSupportConcept.SupportConceptOid)); + var scListObject = Model.SupportConceptListObjects.FirstOrDefault(f => f.SupportConceptOid.Equals(compactSupportConcept.SupportConceptOid)); - var serviceRecord = CreateServiceRecordFromScratch(start.Value, end.Value, supportConcept?.Customer, Model.SelectedEmployee, notice); + var serviceRecord = CreateServiceRecordFromScratch(start.Value, end.Value, compactSupportConcept?.Customer, Model.SelectedEmployee, notice); - var costBearer = supportConcept?.CostBearerList.FirstOrDefault(); + var costBearer = compactSupportConcept?.CostBearerList.FirstOrDefault(); - var cb2ScOid = supportConcept?.CostBearerRelOids.FirstOrDefault(cbOid => availableRelOids.Contains(cbOid)); - - LoadSupportConceptThings(cb2ScOid ?? -2, false); + var cb2ScOid = compactSupportConcept?.CostBearerRelOids.FirstOrDefault(cbOid => availableRelOids.Contains(cbOid)); serviceRecord.CostBearer = costBearer?.Organisation; serviceRecord.CostBearer2SupportConceptOid = cb2ScOid; @@ -4156,6 +4257,7 @@ namespace BeWoPlanerMobil.Controllers { Model.SelectedServiceRecord = serviceRecord; } + Model.SelectedCostBearerSupportConceptOid = cb2ScOid; } else // Gruppenbuchung { @@ -4174,11 +4276,9 @@ namespace BeWoPlanerMobil.Controllers ServiceDescription = Model.GetSelectedOrFirstServiceDescription() }; - var supportConceptsForGroupBooking = Model.SupportConcepts.Where(sc => supportConceptList.Any(csc => csc.SupportConceptOid.Equals(sc.SupportConceptOid))).ToList(); - var costBearer2SupportConceptOids = new List(); - foreach(var supportConcept in supportConceptsForGroupBooking) + foreach(var supportConcept in supportConceptList) { var cb2ScOid = supportConcept?.CostBearerRelOids.FirstOrDefault(cbOid => availableRelOids.Contains(cbOid)); @@ -4196,13 +4296,15 @@ namespace BeWoPlanerMobil.Controllers //Model.SelectedConceptCostBearerRelations = costBearer2SupportConcepts; //Model.GroupBookingSelectedSupportConcepts = supportConceptsForGroupBooking; } + Model.GroupBookingSelectedEmployeeOids = employeeOids; - LoadSupportConceptThings(null, false); } } Model.SelectedServiceRecordOid = Model.SelectedServiceRecord?.ServiceRecordOid; + SetSelectedObjects(); + Model.TransferringAppointmentOid = appointment.SchedulerAppointmentOid; Model.IsInTransferMode = true; } @@ -4703,6 +4805,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadServiceRecordPage(int selectedPage) { + SkipServiceRecordInitialization = true; if(Model.SelectedZeitraum?.StartDate is null || Model.SelectedZeitraum.EndDate is null) { Model.SelectedZeitraum = new NullableDateTimeSpan(DateTime.Today.GetFirstOfMonth(), DateTime.Today); @@ -4761,6 +4864,7 @@ namespace BeWoPlanerMobil.Controllers pages++; } + Model.ServiceRecordCount = totalServiceRecords; Model.ServiceRecordPageCount = pages; @@ -4814,6 +4918,11 @@ namespace BeWoPlanerMobil.Controllers Model.ServiceRecordOids2GoalHeader = GetServiceRecordOids2GoalHeaders(serviceRecords, goalCategories); Model.ServiceRecords = serviceRecords; + + if (selectedPage > 1 && Model.ServiceRecordPageCount < selectedPage) + { + LoadPaginatedServiceRecordsToModel(1); + } } [Authorize] diff --git a/BeWoPlanerMobil/Service/ASPHibernateSessionManager.cs b/BeWoPlanerMobil/Service/ASPHibernateSessionManager.cs index 29c551d02..102139bd2 100644 --- a/BeWoPlanerMobil/Service/ASPHibernateSessionManager.cs +++ b/BeWoPlanerMobil/Service/ASPHibernateSessionManager.cs @@ -110,7 +110,10 @@ namespace BeWoPlanerMobil.Service } var userLoaded = TryAuthenticateWithLoginForm(context); - + //if (!userLoaded && MobileSessionFacade.IsUserLoggedIn()) + //{ + // MobileSessionFacade.LogUserOut(); + //} //if(!userLoaded && MobileSessionFacade.LoggedInUser != null && MobileSessionFacade.LoggedInUser.UserOid.HasValue) //{ // MobileSessionFacade.LoggedInUser = MapperFactory.UserDC_User.MapToNewDC(DAOFactory.GenericDAO.LoadByID(MobileSessionFacade.LoggedInUser.UserOid.Value)); diff --git a/BeWoPlanerMobil/Views/Main/SingleBookingPartial.cshtml b/BeWoPlanerMobil/Views/Main/SingleBookingPartial.cshtml index 5be159062..bfefa2426 100644 --- a/BeWoPlanerMobil/Views/Main/SingleBookingPartial.cshtml +++ b/BeWoPlanerMobil/Views/Main/SingleBookingPartial.cshtml @@ -627,7 +627,7 @@ Bis - + diff --git a/Data/Access/SearchDAO.cs b/Data/Access/SearchDAO.cs index fa0785464..380dda2f1 100644 --- a/Data/Access/SearchDAO.cs +++ b/Data/Access/SearchDAO.cs @@ -6019,11 +6019,8 @@ WHERE sc.Billable = 1 and sr.StartDate >= '{0:yyyy-MM-dd}' and sr.StartDate < '{ rowCount = rowCountCirteria.SetProjection(Projections.RowCount()).FutureValue().Value; var result = criteria - .CreateAlias(nameof(ServiceRecord.ValueList), "vl", JoinType.LeftOuterJoin) .CreateAlias(nameof(ServiceRecord.ServiceDescription), "sd", JoinType.InnerJoin) .CreateAlias($"sd.{nameof(ServiceDescription.ServiceCategory)}", "sc", JoinType.InnerJoin) - //.CreateAlias(ServiceRecord.PropertyName_Employee, "e", JoinType.InnerJoin) - //.CreateCriteria("e." + Employee.PropertyName_Person, JoinType.InnerJoin) .SetFirstResult(firstResult) .SetMaxResults(maxResults) .Future(); diff --git a/ReportImp/LebenshilfeBadKreuznachFUD/Reporting/Reports/LeistungsnachweisAmbDienst.cs b/ReportImp/LebenshilfeBadKreuznachFUD/Reporting/Reports/LeistungsnachweisAmbDienst.cs index 7a048f713..e93d8469d 100644 --- a/ReportImp/LebenshilfeBadKreuznachFUD/Reporting/Reports/LeistungsnachweisAmbDienst.cs +++ b/ReportImp/LebenshilfeBadKreuznachFUD/Reporting/Reports/LeistungsnachweisAmbDienst.cs @@ -46,7 +46,7 @@ namespace LebenshilfeBadKreuznachFUD.Reporting.Reports if (ferien != null) { - item.Notice = ferien.Name; + //item.Notice = ferien.Name; } }