From ccb1a37a950bddb0e5070dbc8f4a4f919d43e127 Mon Sep 17 00:00:00 2001 From: Lyndon Date: Fri, 27 Mar 2026 15:14:20 +0100 Subject: [PATCH] =?UTF-8?q?Das=20=C3=9Cbertragen=20eines=20Kalendertermins?= =?UTF-8?q?=20in=20die=20Zeiterfassung=20funktioniert=20jetzt=20wieder=20b?= =?UTF-8?q?ei=20Serienterminen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModel/NewSchedulerViewModel.cs | 2 +- BeWo/ownChat/ChatDokumentationsView.xaml.cs | 7 +- .../DevExpressSchedulerController.cs | 78 +++++- BeWoPlanerMobil/Controllers/MainController.cs | 260 ++++++++++-------- .../Controllers/SchedulerController.cs | 14 +- .../Util/FormCollectionConstants.cs | 6 + .../AptFltCustomersPartial.cshtml | 10 +- .../AptFltEmployeesPartial.cshtml | 14 +- .../AptFltResourcesPartial.cshtml | 17 +- .../DevExpressScheduler.cshtml | 225 ++++++++------- .../Scheduler/OneDaySchedulerPartial.cshtml | 8 +- Data/Access/SearchDAO.cs | 10 +- Service/ServiceContracts/IEmployeeService.cs | 4 + .../ServiceContracts/IOperationsService.cs | 4 + .../EmployeeServiceImp.cs | 16 +- .../OperationsServiceImp.cs | 7 + .../DataContracts/SchedulerAppointmentDC.cs | 8 +- 17 files changed, 435 insertions(+), 255 deletions(-) diff --git a/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs b/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs index 33c7bc663..f1574b9b0 100644 --- a/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs +++ b/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs @@ -76,7 +76,7 @@ namespace BeWo.Scheduler.ViewModel ServiceFacade.DoEmployeeServiceSync(s => originator = s.FindCompactEmployeeByFullname(abwesenheit.InsUser)); } - if(!(dc is null)) + if(false == dc is null) { subject += $" ({dc.SimpleDescription})"; } diff --git a/BeWo/ownChat/ChatDokumentationsView.xaml.cs b/BeWo/ownChat/ChatDokumentationsView.xaml.cs index 68031b05a..de4d021bc 100644 --- a/BeWo/ownChat/ChatDokumentationsView.xaml.cs +++ b/BeWo/ownChat/ChatDokumentationsView.xaml.cs @@ -162,12 +162,12 @@ namespace BeWo.ownChat var goalCategoryDict = vm.AllGoalCategories.ToDictionary(goalCat => goalCat.ValueListEntryOid.Value); - foreach (var goal in infoDC.SupportConceptGoals) + foreach(var goal in infoDC.SupportConceptGoals) { - if (goal.ParentOid != null && goalCategoryDict.ContainsKey(goal.ParentOid.Value)) + if(goal.ParentOid != null && goalCategoryDict.ContainsKey(goal.ParentOid.Value)) { var path = ServiceRecordListVM.GetAllParentGoalCategoies(goalCategoryDict, goal); - foreach (var goalCat in path) + foreach(var goalCat in path) { goalCats.Add(goalCat); goalCategoryDict.Remove(goalCat.ValueListEntryOid.Value); @@ -214,7 +214,6 @@ namespace BeWo.ownChat { vm.FetchStatistics(cb2ScOid.Value); } - serviceRecordEditView.InitView(vm, _ServiceRecord, hideCustomerCombo); diff --git a/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs b/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs index e767001bf..e9d48c8d9 100644 --- a/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs +++ b/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs @@ -22,7 +22,6 @@ namespace BeWoPlanerMobil.Controllers /* * ToDo: * 1. Filterung einbauen (Mitarbeiter, Klienten, Ressourcen, Privat, Aufgaben, Abwesenheiten) - * Das Filtern muss über den CustomCallback geschehen, damit die Termin-Liste aktualisiert wird. * 2. "In die Zeiterfassung übertragen" und "Verfügbare Mitarbeiter prüfen" einbauen * 3. Rechte implementieren! * 4. Übersetzungen @@ -94,12 +93,14 @@ namespace BeWoPlanerMobil.Controllers private void InitViewModel() { - if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || Model?.LoggedInEmployee?.EmployeeOid is null) + if(false == MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || Model?.LoggedInEmployee?.EmployeeOid is null) { Logout(); return; } + var x = Model.SelectedEmployeeOidsForFiltering; + Model.PossibleEmployees = EmployeeService.GetAllAuthorizedCompactEmployees(); Model.PossibleCustomers = CustomerService.GetAllAuthorizedCompactCustomers(); Model.PossibleResources = KalenderService.GetAllResources(); @@ -263,7 +264,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult DevExpressScheduler() { - if(!MobileSessionFacade.IsUserLoggedIn() || Model is null) + if(false == MobileSessionFacade.IsUserLoggedIn() || Model is null) { return RedirectToActionPermanent("Index", "Login"); } @@ -515,7 +516,16 @@ namespace BeWoPlanerMobil.Controllers return PartialView("AptFltEmployeePopupListPartial"); } - Model.SelectedEmployeeOidsForFiltering = Model.PossibleEmployees.Select(employee => employee.EmployeeOid).ToList(); + if(isChecked) + { + Model.SelectedEmployeesForFiltering = Model.PossibleEmployees; + Model.SelectedEmployeeOidsForFiltering = Model.PossibleEmployees.Select(employee => employee.EmployeeOid).ToList(); + } + else + { + Model.SelectedEmployeesForFiltering?.Clear(); + Model.SelectedEmployeeOidsForFiltering?.Clear(); + } return PartialView("AptFltEmployeePopupListPartial", Model); } @@ -529,7 +539,16 @@ namespace BeWoPlanerMobil.Controllers return PartialView("AptFltCustomerPopupListPartial"); } - Model.SelectedCustomerOidsForFiltering = Model.PossibleCustomers.Select(customer => customer.CustomerOid).ToList(); + if(isChecked) + { + Model.SelectedCustomerOidsForFiltering = Model.PossibleCustomers.Select(customer => customer.CustomerOid).ToList(); + Model.SelectedCustomersForFiltering = Model.PossibleCustomers; + } + else + { + Model.SelectedCustomerOidsForFiltering?.Clear(); + Model.SelectedCustomersForFiltering?.Clear(); + } return PartialView("AptFltCustomerPopupListPartial", Model); } @@ -543,9 +562,18 @@ namespace BeWoPlanerMobil.Controllers return PartialView("AptFltResourcePopupListPartial"); } - Model.SelectedResourceOidsForFiltering = Model.PossibleResources.Where(resource => resource.ResourceOid.HasValue).Select(resource => resource.ResourceOid.Value).ToList(); + if(isChecked) + { + Model.SelectedResourceOidsForFiltering = Model.PossibleResources.Where(resource => resource.ResourceOid.HasValue).Select(resource => resource.ResourceOid.Value).ToList(); + Model.SelectedResourcesForFiltering = Model.PossibleResources; + } + else + { + Model.SelectedResourceOidsForFiltering?.Clear(); + Model.SelectedResourcesForFiltering?.Clear(); + } - return PartialView("AptFltResourcePopupListPartial"); + return PartialView("AptFltResourcePopupListPartial", Model); } [Authorize] @@ -561,14 +589,17 @@ namespace BeWoPlanerMobil.Controllers if(selectedTeam is null) { - return PartialView("AptFltEmployeePopupListPartial"); + return PartialView("AptFltEmployeePopupListPartial", Model); } var fullTeamObj = EmployeeService.LoadTeam(teamOid); - Model.SelectedEmployeeOids.AddRangeIfElementsNotIn(fullTeamObj.Member.Select(member => member.EmployeeOid)); + var teamMembers = fullTeamObj?.Member ?? new List(); - return PartialView("AptFltEmployeePopupListPartial"); + Model.SelectedEmployeesForFiltering.AddRangeIfElementsNotIn(teamMembers); + Model.SelectedEmployeeOids.AddRangeIfElementsNotIn(teamMembers.Select(member => member.EmployeeOid)); + + return PartialView("AptFltEmployeePopupListPartial", Model); } [Authorize] @@ -582,6 +613,7 @@ namespace BeWoPlanerMobil.Controllers var selectedEmployees = Model.PossibleEmployees.Where(possibleEmployee => selectedEmployeeOids.Contains(possibleEmployee.EmployeeOid)).ToList(); + Model.SelectedEmployeesForFiltering = selectedEmployees; Model.SelectedEmployeeOidsForFiltering = selectedEmployees.Select(employee => employee.EmployeeOid).ToList(); return PartialView("AptFltEmployeePopupListPartial", Model); @@ -598,6 +630,9 @@ namespace BeWoPlanerMobil.Controllers var selectedCustomers = Model.PossibleCustomers.Where(possibleCustomer => selectedCustomerOids.Contains(possibleCustomer.CustomerOid)).ToList(); + Model.SelectedCustomersForFiltering = selectedCustomers; + Model.SelectedCustomerOidsForFiltering = selectedCustomers.Select(customer => customer.CustomerOid).ToList(); + return PartialView("AptFltCustomerPopupListPartial", Model); } @@ -610,7 +645,30 @@ namespace BeWoPlanerMobil.Controllers return PartialView("AptFltResourcePopupListPartial"); } + var selectedResources = Model.PossibleResources.Where(possibleResource => possibleResource.ResourceOid.HasValue && selectedResourceOids.Contains(possibleResource.ResourceOid.Value)).ToList(); + + Model.SelectedResourcesForFiltering = selectedResources; + Model.SelectedResourceOidsForFiltering = selectedResources.Where(resource => resource.ResourceOid.HasValue).Select(resource => resource.ResourceOid.Value).ToList(); + return PartialView("AptFltResourcePopupListPartial", Model); } + + [Authorize] + public string GetSelectedEmployeesForAptFlt() + { + return JsonConvert.SerializeObject(Model.SelectedEmployeeOidsForFiltering.Count); + } + + [Authorize] + public string GetSelectedCustomersForAptFlt() + { + return JsonConvert.SerializeObject(Model.SelectedCustomerOidsForFiltering.Count); + } + + [Authorize] + public string GetSelectedResourcesForAptFlt() + { + return JsonConvert.SerializeObject(Model.SelectedResourceOidsForFiltering.Count); + } } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index 0494f2dfe..cf624ac4e 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -25,7 +25,6 @@ using System.Net.Sockets; using System.Text; using System.Web.Mvc; using System.Windows.Forms; -using DevExpress.XtraRichEdit.Commands.Internal; using static BeWoPlanerMobil.Util.MobileUtils; using static BS.Shared.ServiceRecordValidationResult; using FormCollection = System.Web.Mvc.FormCollection; @@ -618,7 +617,7 @@ namespace BeWoPlanerMobil.Controllers { try { - if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) + if(false == MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) { var isNewSession = Session.IsNewSession; @@ -630,7 +629,7 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } - if(!Model.SessionInitialized) + if(false == Model.SessionInitialized) { Model.SessionInitialized = true; var mokSessionTimeout = UserSettingsUtils.GetSettingValueAsInteger(Model.Mandator.Settings, SettingsKeys.MoKSessionTimeout, 20); @@ -653,12 +652,17 @@ namespace BeWoPlanerMobil.Controllers break; } - if(!string.IsNullOrEmpty(tempDataValue)) + if(false == string.IsNullOrEmpty(tempDataValue)) { TempData[TempDataConstants.ShowPwChPopupKey] = tempDataValue; } } } + + if(TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] is SchedulerAppointmentDC occurrenceToInsert) + { + TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] = occurrenceToInsert; + } } catch(Exception e) { @@ -1293,6 +1297,10 @@ namespace BeWoPlanerMobil.Controllers var app = DAOFactory.GenericDAO.LoadByID(Model.TransferringAppointmentOid.Value); appointmentPrototype = MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDC(app); } + else if(TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] is SchedulerAppointmentDC occurrenceToInsert) + { + appointmentPrototype = occurrenceToInsert; + } var marker = "on" == collection[FormCollectionConstants.MarkerKey]; @@ -1318,7 +1326,7 @@ namespace BeWoPlanerMobil.Controllers var distanz = collection[FormCollectionConstants.DistanceKey]; decimal? distanceInMeters = null; - if(!string.IsNullOrEmpty(distanz)) + if(false == string.IsNullOrEmpty(distanz)) { if(decimal.TryParse(distanz, out var parsedDistance)) { @@ -1350,7 +1358,7 @@ namespace BeWoPlanerMobil.Controllers durationAsString = durationAsString?.Replace('.', ','); - if(!string.IsNullOrEmpty(durationAsString)) + if(false == string.IsNullOrEmpty(durationAsString)) { decimal.TryParse(durationAsString, out dauer); } @@ -1417,23 +1425,23 @@ namespace BeWoPlanerMobil.Controllers if(Model.LoggedInEmployee.EmployeeOid.HasValue) { - if(!Model.IsInEditingMode) + if(false == Model.IsInEditingMode) { Model.NewServiceRecord.Employee = Model.SelectedEmployee ?? LoggedInUser.Employee; } else { - if(!(Model.SelectedEmployee is null)) + if(Model.SelectedEmployee != null) { Model.NewServiceRecord.Employee = Model.SelectedEmployee; } } - var sclo = Model.SupportConceptListObjects.FirstOrDefault(a => a.CostBearer2SupportConceptOid.Equals(selectedCostbearerScRelOid)); + var mokSupportConceptListObject = Model.SupportConceptListObjects.FirstOrDefault(a => a.CostBearer2SupportConceptOid.Equals(selectedCostbearerScRelOid)); - if(!(sclo is null)) + if(mokSupportConceptListObject != null) { - var sc = GetCompactSupportConcept(sclo.SupportConceptOid, selectedCostbearerScRelOid); + var sc = GetCompactSupportConcept(mokSupportConceptListObject.SupportConceptOid, selectedCostbearerScRelOid); Model.NewServiceRecord.SupportConcept = sc; @@ -1479,7 +1487,7 @@ namespace BeWoPlanerMobil.Controllers var serviceDescOid = 0L; - if(!string.IsNullOrEmpty(collection[FormCollectionConstants.ServiceDescriptionKey])) + if(false == string.IsNullOrEmpty(collection[FormCollectionConstants.ServiceDescriptionKey])) { serviceDescOid = Convert.ToInt64(collection[FormCollectionConstants.ServiceDescriptionKey]); } @@ -1508,7 +1516,7 @@ namespace BeWoPlanerMobil.Controllers return Model.NewServiceRecord.ServiceRecordOid.HasValue ? SaveGroupBooking() : UpdateGroupBooking(); } - if(!Model.IsInEditingMode) + if(false == Model.IsInEditingMode) { var oidList = OperationsService.InsertNewServiceRecords(new List { Model.NewServiceRecord }); @@ -1516,57 +1524,32 @@ namespace BeWoPlanerMobil.Controllers TempData[TempDataConstants.AfterInsertKey] = true; - if (Model.IsAllowedToCreateSignature(Model.NewServiceRecord)) + if(Model.IsAllowedToCreateSignature(Model.NewServiceRecord)) { - if (Model.NewServiceRecord.CostBearer != null && Model.ShowSignature && (Model.NewServiceRecord.ServiceDescription.Category.IsBillable || Model.NewServiceRecord.ServiceDescription.Category.BillableAmount > 0m || Model.NewServiceRecord.ServiceDescription.BillableAmount > 0m)) + if(Model.NewServiceRecord.CostBearer != null && Model.ShowSignature && (Model.NewServiceRecord.ServiceDescription.Category.IsBillable || Model.NewServiceRecord.ServiceDescription.Category.BillableAmount > 0m || Model.NewServiceRecord.ServiceDescription.BillableAmount > 0m)) { TempData[TempDataConstants.ShowSignatureSuggestionPopup] = true; } } - if(appointmentPrototype is object) + + if(false == appointmentPrototype is null) { - var isRecurring = !(appointmentPrototype.RecurrenceInfo is null); + var serviceRecord = OperationsService.GetServiceRecordById(Model.LastCreatedServiceRecordOid); - if(isRecurring && appointmentPrototype.Type != (int) AppointmentType.ChangedOccurrence) + if(appointmentPrototype.ServiceRecordList is null) { - var id = appointmentPrototype.RecurrenceIdReference; - - var recurrenceInfo = new RecurrenceInfo(); - recurrenceInfo.FromXml(appointmentPrototype.RecurrenceInfo); - var occurrenceCalculator = OccurrenceCalculator.CreateInstance(recurrenceInfo); - - var pattern = StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern); - pattern.RecurrenceInfo.FromXml(appointmentPrototype.RecurrenceInfo); - pattern.Start = pattern.RecurrenceInfo.Start; - pattern.End = pattern.RecurrenceInfo.End; - - var occurrence = occurrenceCalculator.CalcOccurrences(new TimeInterval(appointmentPrototype.StartDate.Value, appointmentPrototype.EndDate.Value), pattern).FirstOrDefault(); - - if(!(occurrence is null)) - { - var index = occurrence.RecurrenceIndex; - appointmentPrototype = SchedulerController.CloneAppointment(appointmentPrototype, $"", (int)AppointmentType.ChangedOccurrence); - } - else - { - appointmentPrototype = null; - } + appointmentPrototype.ServiceRecordList = new List(); } - if(appointmentPrototype is object) + appointmentPrototype.ServiceRecordList.AddIfNotIn(serviceRecord); + + if(appointmentPrototype.SchedulerAppointmentOid.HasValue) { - var serviceRecord = OperationsService.GetServiceRecordById(Model.LastCreatedServiceRecordOid); - - appointmentPrototype.ServiceRecordList.AddIfNotIn(serviceRecord); - - if(appointmentPrototype.SchedulerAppointmentOid.HasValue) - { - KalenderService.UpdateSchedulerAppointments(new List { appointmentPrototype }); - } - else - { - KalenderService.InsertSchedulerAppointments(new List { appointmentPrototype }); - } + KalenderService.UpdateSchedulerAppointments(new List { appointmentPrototype }); + } + else + { + KalenderService.InsertSchedulerAppointments(new List { appointmentPrototype }); } } } @@ -1580,7 +1563,7 @@ namespace BeWoPlanerMobil.Controllers var previousStartDate = Model.IsInEditingMode ? Model.SelectedServiceRecord?.Start : Model.NewServiceRecord?.Start; var previousEndDate = Model.IsInEditingMode ? Model.SelectedServiceRecord?.End : Model.NewServiceRecord?.End; - if(!(previousStartDate is null) && !(previousEndDate is null)) + if(previousStartDate.HasValue && previousEndDate.HasValue) { var duration = (previousEndDate - previousStartDate).Value.TotalMinutes; @@ -1595,7 +1578,7 @@ namespace BeWoPlanerMobil.Controllers { Log.Error(e.Message, e); } - if (!Model.IsInGroupBookingMode && !Model.IsInMultiBookingMode) + if (false == Model.IsInGroupBookingMode && !Model.IsInMultiBookingMode) { //Setze den zuletzt ausgewählten HP zurück, sonst springt die Anzeige dorthin Model.PreviouslySelectedCostbearer2SupportConceptOid = null; @@ -1605,7 +1588,7 @@ namespace BeWoPlanerMobil.Controllers long? oldCatOid = null; long? oldDescOid = null; - if(!Model.IsInEditingMode) + if(false == Model.IsInEditingMode) { oldCatOid = Model.SelectedServiceCategoryOid; oldDescOid = Model.SelectedServiceDescriptionOid; @@ -1674,6 +1657,12 @@ namespace BeWoPlanerMobil.Controllers if(newDCList.Count == 1) { OperationsService.InsertNewServiceRecords(newDCList); + + if(TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] is SchedulerAppointmentDC occurrenceToInsert) + { + KalenderService.InsertSchedulerAppointment(occurrenceToInsert); + } + TempData[TempDataConstants.AfterInsertKey] = true; } else @@ -1703,13 +1692,28 @@ namespace BeWoPlanerMobil.Controllers TempData[TempDataConstants.AfterInsertKey] = true; - if(Model.TransferringAppointmentOid.HasValue && Model.LoggedInEmployee.EmployeeOid.HasValue) + if((Model.TransferringAppointmentOid is null && TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] is null) || Model.LoggedInEmployee?.EmployeeOid is null) { - var app = DAOFactory.GenericDAO.LoadByID(Model.TransferringAppointmentOid.Value); - var appointment = MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDC(app); + return ResetEditingMode(); + } - appointment.ServiceRecordList.AddRange(serviceRecords); + var appointment = Model.TransferringAppointmentOid is null ? + (SchedulerAppointmentDC) TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] : + MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDC(DAOFactory.GenericDAO.LoadByID(Model.TransferringAppointmentOid.Value)); + if(appointment.ServiceRecordList is null) + { + appointment.ServiceRecordList = new List(); + } + + appointment.ServiceRecordList.AddRange(serviceRecords); + // ToDo: Ist immer noch nicht mit den ServiceRecords verbunden! + if(appointment.SchedulerAppointmentOid is null) + { + KalenderService.InsertSchedulerAppointments(new List { appointment }); + } + else + { KalenderService.UpdateSchedulerAppointments(new List { appointment }); } } @@ -2712,6 +2716,11 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } + if(TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] is SchedulerAppointmentDC occurrenceToInsert) + { + TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] = occurrenceToInsert; + } + var inEditMode = Model.IsInEditingMode; var von = formCollection[FormCollectionConstants.DateKey]; @@ -2740,12 +2749,12 @@ namespace BeWoPlanerMobil.Controllers var startHoursDt = ConvertTimeStringToDateTime(start); var endHoursDt = ConvertTimeStringToDateTime(end); - if(!DateTime.TryParse(von, out var startDate)) + if(false == DateTime.TryParse(von, out var startDate)) { startDate = DateTime.Now.Date; } - if(!DateTime.TryParse(bis, out var endDate)) + if(false == DateTime.TryParse(bis, out var endDate)) { endDate = DateTime.Now.Date; } @@ -2803,10 +2812,7 @@ namespace BeWoPlanerMobil.Controllers if(supportConcept != null) { - if(supportConcept.SupportConceptOid != null) - { - checkServiceRecord.SupportConcept = GetCompactSupportConcept(supportConcept.SupportConceptOid, Model.SelectedCostBearerSupportConceptOid); - } + checkServiceRecord.SupportConcept = GetCompactSupportConcept(supportConcept.SupportConceptOid, Model.SelectedCostBearerSupportConceptOid); checkServiceRecord.Customer = supportConcept.Customer; var costbearer = supportConcept.CostBearerList.FirstOrDefault(); @@ -3950,7 +3956,7 @@ namespace BeWoPlanerMobil.Controllers try { - if(!Model.IsInEditingMode) + if(false == Model.IsInEditingMode) { if(Model.GroupBookingSelectedCostBearerSupportConceptOids.Count == 1) { @@ -4235,8 +4241,6 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - - /// /// Bereitet die Übernahme eines Termins in die Zeiterfassung vor. Wird im SchedulerController aufgerufen. @@ -4245,7 +4249,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult PrepareServiceRecordInsert() { - if(!IsUserLoggedIn()) + if(false == IsUserLoggedIn()) { TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); @@ -4269,19 +4273,11 @@ namespace BeWoPlanerMobil.Controllers var startRaw = TempData[TempDataConstants.AppointmentStartKey]?.ToString(); var endRaw = TempData[TempDataConstants.AppointmentEndKey]?.ToString(); var subject = TempData[TempDataConstants.AppointmentSubjectKey]?.ToString(); - var isAllDay = false; - - if(TempData[TempDataConstants.AppointmentIsAllDayKey] is bool isAllDayRaw && isAllDayRaw) - { - isAllDay = true; - } - else if(appointment != null) - { - isAllDay = appointment.AllDay; - } + var isAllDay = TempData[TempDataConstants.AppointmentIsAllDayKey] is true; var customerOids = new List(); var employeeOids = new List(); + var resourceOids = new List(); if(TempData[TempDataConstants.AppointmentEmployeeOidsKey] is string employeeOidsRaw && employeeOidsRaw.Length > 0) { @@ -4293,22 +4289,24 @@ namespace BeWoPlanerMobil.Controllers customerOids = Utils.ConvertCharSeparatedValuesToLongList(customerOidsRaw, ','); } - var isStartParsingSuccessful = DateTime.TryParse(startRaw, out var parsedStart); - var isEndParsingSuccessful = DateTime.TryParse(endRaw, out var parsedEnd); + if(TempData[TempDataConstants.AppointmentResourceOidsKey] is string resourceOidsRaw && resourceOidsRaw.Length > 0) + { + resourceOids = Utils.ConvertCharSeparatedValuesToLongList(resourceOidsRaw, ','); + } - var start = appointment is null ? parsedStart : appointment.StartDate; - var end = appointment is null ? parsedEnd : appointment.EndDate; + DateTime.TryParse(startRaw, out var start); + DateTime.TryParse(endRaw, out var end); if(appointment is object) { customerOids = appointment.CustomerList.Select(customer => customer.CustomerOid).ToList(); employeeOids = appointment.EmployeeList.Select(e2a => e2a.Employee.EmployeeOid).ToList(); } - - if(isAllDay && start.HasValue && end.HasValue) + + if(isAllDay) { - start = start.Value.MergeDateWithHoursMinutesSeconds(0, 0, 1); - end = end.Value.MergeDateWithHoursMinutesSeconds(0, 0, 1); + start = start.MergeDateWithHoursMinutesSeconds(0, 0, 1); + end = end.MergeDateWithHoursMinutesSeconds(0, 0, 1); } if(employeeOids.Count == 0) @@ -4317,11 +4315,16 @@ namespace BeWoPlanerMobil.Controllers } var notice = appointment?.Description ?? TempData[TempDataConstants.AppointmentSubjectKey]?.ToString(); + if(appointment is null) + { + notice = TempData[TempDataConstants.AppointmentDescriptionKey]?.ToString() ?? + TempData[TempDataConstants.AppointmentSubjectKey]?.ToString(); + } Model.SupportConceptListObjects.Clear(); //Macht, dass beim Init die SupportConcepts neu geladen werden InitViewModel(true); - 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 supportConcepts = Model.SupportConcepts.Where(sc => customerOids.Contains(sc.Customer.CustomerOid)).ToList(); var supportConceptList = new List(); @@ -4337,6 +4340,49 @@ namespace BeWoPlanerMobil.Controllers supportConceptList.AddIfNotIn(supportConcept); } + // Falls es sich um einen Serientermin handelt, Ausnahme erstellen und speichern, nachdem der Eintrag in der Datenbank gespeichert wurde. + if(isSerientermin && appointment is null) + { + var customers = CustomerService.GetCompactCustomersById(customerOids); + var employees = EmployeeService.GetActiveCompactEmployeesByOids(employeeOids); + var resources = OperationsService.GetResourcesByOids(resourceOids); + + appointment = new SchedulerAppointmentDC + { + StartDate = start, + EndDate = end, + ActivationType = ActivationTypeId.Active, + AllDay = isAllDay, + CustomerList = customers, + ResourceList = resources, + EmployeeList = new List(), + Location = TempData[TempDataConstants.AppointmentLocationKey]?.ToString(), + IsPrivate = TempData[TempDataConstants.AppointmentIsPrivateKey] is true, + Subject = subject, + SupportConceptList = supportConceptList, + Type = (int) AppointmentType.ChangedOccurrence, + Originator = Model.LoggedInUser.Employee + }; + + foreach(var employee in employees) + { + appointment.EmployeeList.Add(new Employee2SchedulerAppointmentDC { Employee = employee }); + } + + var recurrenceInfo = TempData[TempDataConstants.AppointmentRecurrenceInfoKey].ToString(); + + var pattern = StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern); + pattern.RecurrenceInfo.FromXml(recurrenceInfo); + pattern.Start = pattern.RecurrenceInfo.Start; + pattern.End = pattern.RecurrenceInfo.End; + + var apt = pattern.CreateException(AppointmentType.ChangedOccurrence, recurrenceIndex.Value); + + appointment = SchedulerAppointmentDC.RecurringExceptionFromDevExpressAppointment(apt, appointment, recurrenceIndex.Value, pattern.RecurrenceInfo.Id.ToString()); + + TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] = appointment; + } + // Ohne Hilfeplan if(supportConceptList.Count == 0) { @@ -4349,7 +4395,7 @@ namespace BeWoPlanerMobil.Controllers if(Model.SelectedServiceDescription != null) { Model.SelectedServiceCategory = Model.SelectedServiceDescription.Category; - var serviceRecord = CreateServiceRecordFromScratch(start.Value, end.Value, null, Model.SelectedEmployee, notice); + var serviceRecord = CreateServiceRecordFromScratch(start, end, null, Model.SelectedEmployee, notice); serviceRecord.ServiceDescription = Model.SelectedServiceDescription; Model.SelectedServiceRecord = serviceRecord; } @@ -4377,7 +4423,7 @@ namespace BeWoPlanerMobil.Controllers LoadSupportConceptThings(scListObject.CostBearer2SupportConceptOid, true); } - var serviceRecord = CreateServiceRecordFromScratch(start.Value, end.Value, compactSupportConcept?.Customer, Model.SelectedEmployee, notice); + var serviceRecord = CreateServiceRecordFromScratch(start, end, compactSupportConcept?.Customer, Model.SelectedEmployee, notice); var costBearer = compactSupportConcept?.CostBearerList.FirstOrDefault(); @@ -4391,6 +4437,7 @@ namespace BeWoPlanerMobil.Controllers { Model.SelectedServiceRecord = serviceRecord; } + Model.SelectedCostBearerSupportConceptOid = cb2ScOid; } else // Gruppenbuchung @@ -4399,9 +4446,9 @@ namespace BeWoPlanerMobil.Controllers Model.GroupBookingSelectedEmployees = Model.AllEmployees.Where(w => employeeOids.Contains(w.EmployeeOid)).ToList(); - var roundedDuration = (int) ((end - start)?.TotalMinutes ?? 0); + var roundedDuration = (int) (end - start).TotalMinutes; - Model.SelectedServiceRecord = new ServiceRecordDC() + Model.SelectedServiceRecord = new ServiceRecordDC { Start = start, End = end, @@ -4427,29 +4474,12 @@ namespace BeWoPlanerMobil.Controllers if(costBearer2SupportConceptOids.Any()) { Model.GroupBookingSelectedCostBearerSupportConceptOids = costBearer2SupportConceptOids; - //Model.SelectedConceptCostBearerRelations = costBearer2SupportConcepts; - //Model.GroupBookingSelectedSupportConcepts = supportConceptsForGroupBooking; } + Model.GroupBookingSelectedEmployeeOids = employeeOids; - } } - // ToDo: Falls es sich um einen Serientermin handelt, Ausnahme erstellen und speichern, nachdem der Eintrag in der Datenbank gespeichert wurde. - if(isSerientermin) - { - var recurrenceInfo = appointment.RecurrenceInfo; - - var pattern = StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern); - pattern.RecurrenceInfo.FromXml(recurrenceInfo); - - var apt = pattern.CreateException(AppointmentType.ChangedOccurrence, recurrenceIndex.Value); - - var changedOccurrence = SchedulerAppointmentDC.RecurringExceptionFromDevExpressAppointment(apt, appointment); - - var x = apt.RecurrenceIndex; - } - Model.SelectedServiceRecordOid = Model.SelectedServiceRecord?.ServiceRecordOid; SetSelectedObjects(); @@ -4529,7 +4559,6 @@ namespace BeWoPlanerMobil.Controllers return RedirectToActionPermanent("Main"); } - #region Mehrfachbuchung [Authorize] @@ -4547,8 +4576,6 @@ namespace BeWoPlanerMobil.Controllers return PartialView("MultiBookingSelectionPartial", Model); } - - [Authorize] public ActionResult RemoveSupportConceptCostbearerRelFromMultiBooking(string relOid) { @@ -4838,6 +4865,11 @@ namespace BeWoPlanerMobil.Controllers OperationsService.InsertNewServiceRecords(serviceRecordsToInsert); + if(TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] is SchedulerAppointmentDC occurrenceToInsert) + { + KalenderService.InsertSchedulerAppointment(occurrenceToInsert); + } + TempData[TempDataConstants.AfterInsertKey] = true; } } diff --git a/BeWoPlanerMobil/Controllers/SchedulerController.cs b/BeWoPlanerMobil/Controllers/SchedulerController.cs index c936d9544..56bc75df4 100644 --- a/BeWoPlanerMobil/Controllers/SchedulerController.cs +++ b/BeWoPlanerMobil/Controllers/SchedulerController.cs @@ -1433,21 +1433,27 @@ namespace BeWoPlanerMobil.Controllers if(appointment?.RecurrenceInfo != null) { - TempData[TempDataConstants.AppointmentRecurrenceIndexKey] = appointment?.RecurrenceIndex; + TempData[TempDataConstants.AppointmentRecurrenceInfoKey] = appointment.RecurrenceInfo; + TempData[TempDataConstants.AppointmentRecurrenceIndexKey] = appointment.RecurrenceIndex; } + TempData[TempDataConstants.AppointmentLocationKey] = appointment?.Location; + TempData[TempDataConstants.AppointmentIsPrivateKey] = appointment?.IsPrivate ?? false; + TempData[TempDataConstants.AppointmentDescriptionKey] = appointment?.Description; + TempData[TempDataConstants.AppointmentStartKey] = appointment?.StartDate; TempData[TempDataConstants.AppointmentEndKey] = appointment?.EndDate; TempData[TempDataConstants.AppointmentSubjectKey] = appointment?.Subject; TempData[TempDataConstants.AppointmentIsAllDayKey] = appointment?.AllDay ?? false; - TempData[TempDataConstants.AppointmentCustomerOidsKey] = string.Join(",", appointment?.CustomerList.Select(s => s.CustomerOid) ?? new List()); + TempData[TempDataConstants.AppointmentCustomerOidsKey] = string.Join(",", appointment?.CustomerList.Select(customer => customer.CustomerOid) ?? new List()); - TempData[TempDataConstants.AppointmentEmployeeOidsKey] = string.Join(",", appointment?.EmployeeList.Select(s => s.Employee.EmployeeOid) ?? new List()); + TempData[TempDataConstants.AppointmentEmployeeOidsKey] = string.Join(",", appointment?.EmployeeList.Select(employee2Appointment => employee2Appointment.Employee.EmployeeOid) ?? new List()); + + TempData[TempDataConstants.AppointmentResourceOidsKey] = string.Join(",", appointment?.ResourceList.Where(resource => resource.ResourceOid.HasValue).Select(resource => resource.ResourceOid.Value) ?? new List()); TempData[TempDataConstants.AppointmentIsSerienterminKey] = appointment != null && appointment.SchedulerAppointmentOid is null && appointment.RecurrenceInfo is string; - return RedirectToActionPermanent("PrepareServiceRecordInsert", "Main"); } diff --git a/BeWoPlanerMobil/Util/FormCollectionConstants.cs b/BeWoPlanerMobil/Util/FormCollectionConstants.cs index efce2ea10..8ff79a53b 100644 --- a/BeWoPlanerMobil/Util/FormCollectionConstants.cs +++ b/BeWoPlanerMobil/Util/FormCollectionConstants.cs @@ -109,5 +109,11 @@ public static string IsGroupTabActiveKey => "IsGroupTabActive"; public static string AfterInsertKey => "AfterInsert"; public static string AppointmentRecurrenceIndexKey => "AppointmentRecurrenceIndex"; + public static string AppointmentRecurrenceInfoKey => "AppointmentRecurrenceInfo"; + public static string AppointmentResourceOidsKey => "AppointmentResourceOids"; + public static string AppointmentLocationKey => "Location"; + public static string AppointmentIsPrivateKey => "IsPrivate"; + public static string AppointmentDescriptionKey => "Description"; + public static string AppointmentOccurrenceToInsertKey => "AppointmentOccurrenceToInsert"; } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltCustomersPartial.cshtml b/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltCustomersPartial.cshtml index 2f43c6437..53cb5859a 100644 --- a/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltCustomersPartial.cshtml +++ b/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltCustomersPartial.cshtml @@ -50,7 +50,15 @@ $("#all-customers-checkbox").prop("checked", (allCustomersCount === selectedCustomersCount)); - $("#customer-input-container").load("@Url.Action("UpdateCustomerSelection")", { selectedCustomerOids: selectedCustomerOids }, () => { scheduler.Refresh(); }); + showSpinner(); + $("#customer-input-container").load( + "@Url.Action("UpdateCustomerSelection")", + { selectedCustomerOids: selectedCustomerOids }, + () => { + scheduler.Refresh(); + hideSpinner(); + } + ); } diff --git a/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltEmployeesPartial.cshtml b/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltEmployeesPartial.cshtml index 994357cd0..8acfca795 100644 --- a/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltEmployeesPartial.cshtml +++ b/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltEmployeesPartial.cshtml @@ -54,10 +54,20 @@ const selectedEmployeeOids = $("#employee-input-container input:checked").map(function() { return $(this).attr("id").split("-")[1]; }).get(); const allEmployeesCount = $("#employee-input-container input[type=checkbox]").map(function () { return $(this).attr("id").split("-")[1]; }).get().length; const selectedEmployeesCount = selectedEmployeeOids.length; - console.log(selectedEmployeeOids); + $("#all-employees-checkbox").prop("checked", (allEmployeesCount === selectedEmployeesCount)); - $("#employee-input-container").load("@Url.Action("UpdateEmployeeSelection", "DevExpressScheduler")", {selectedEmployeeOids: selectedEmployeeOids }, () => { scheduler.Refresh(); }); + showSpinner(); + + $("#employee-input-container").load( + "@Url.Action("UpdateEmployeeSelection", "DevExpressScheduler")", + { + selectedEmployeeOids: selectedEmployeeOids + }, + () => { + scheduler.Refresh(); + hideSpinner(); + }); } diff --git a/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltResourcesPartial.cshtml b/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltResourcesPartial.cshtml index 2a7e96c41..4dce81421 100644 --- a/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltResourcesPartial.cshtml +++ b/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltResourcesPartial.cshtml @@ -1,5 +1,4 @@ -@using BeWoPlanerMobil.Util -@using BS.Shared.Extensions +@using BS.Shared.Extensions @model BeWoPlanerMobil.Models.DevExpressSchedulerModel diff --git a/BeWoPlanerMobil/Views/DevExpressScheduler/DevExpressScheduler.cshtml b/BeWoPlanerMobil/Views/DevExpressScheduler/DevExpressScheduler.cshtml index 6569b1a64..2d5b36566 100644 --- a/BeWoPlanerMobil/Views/DevExpressScheduler/DevExpressScheduler.cshtml +++ b/BeWoPlanerMobil/Views/DevExpressScheduler/DevExpressScheduler.cshtml @@ -1,140 +1,157 @@ -@using BeWoPlanerMobil.Util.Constants -@using BeWoPlanerMobil.Util.SchedulerUtils -@using BS.Shared.DataContracts.Compact -@model BeWoPlanerMobil.Models.DevExpressSchedulerModel +@model BeWoPlanerMobil.Models.DevExpressSchedulerModel @{ ViewBag.Title = "DevExpressScheduler"; } diff --git a/BeWoPlanerMobil/Views/Scheduler/OneDaySchedulerPartial.cshtml b/BeWoPlanerMobil/Views/Scheduler/OneDaySchedulerPartial.cshtml index 014309b5d..900d3c3c1 100644 --- a/BeWoPlanerMobil/Views/Scheduler/OneDaySchedulerPartial.cshtml +++ b/BeWoPlanerMobil/Views/Scheduler/OneDaySchedulerPartial.cshtml @@ -266,7 +266,7 @@
} - @if(Model.HasRightToEditAppointment(appointment.Identifier) && !appointment.IsTask && appointment.CanBeEdited) + @if(Model.HasRightToEditAppointment(appointment.Identifier) && false == appointment.IsTask && appointment.CanBeEdited) {
@if(appointment.Oid.HasValue) @@ -283,9 +283,9 @@ }
- +