From 57b1e3d93a88310f87a684363c4e6b92ee45a440 Mon Sep 17 00:00:00 2001 From: Lyndon Jetten Date: Tue, 4 Aug 2020 12:45:46 +0200 Subject: [PATCH] . --- BeWo/Core/BeWoUtils.cs | 58 +++++-- BeWo/Scheduler/Utils/AppointmentExtensions.cs | 9 ++ BeWo/Scheduler/View/NewSchedulerView.xaml | 74 ++++----- BeWo/Scheduler/View/NewSchedulerView.xaml.cs | 107 ++++++++----- .../Scheduler/ViewModel/CustomFieldStorage.cs | 6 + .../ViewModel/SchedulerAppointmentListVM.cs | 103 ++++++++++-- .../ViewModel/SchedulerAppointmentVM.cs | 110 +++++++------ BeWo/ownChat/ChatDokumentationsView.xaml.cs | 147 ++++++++---------- BeWoPlanerMobil/Controllers/MainController.cs | 62 ++++++-- BeWoPlanerMobil/Scripts/group-booking.js | 8 +- BeWoPlanerMobil/Views/Main/Main.cshtml | 31 +++- BeWoPlanerMobil/Views/Shared/_Layout.cshtml | 20 ++- Data/Access/SearchDAO.cs | 2 +- Data/Entities/SchedulerAppointment.cs | 14 ++ Data/Mappings/SchedulerAppointment.hbm.xml | 21 +-- ...anges_2020_07_24_HasServiceRecordEntry.txt | 1 + ...dulerAppointmentDC_SchedulerAppointment.cs | 6 +- .../OperationsServiceImp.cs | 1 + .../DataContracts/SchedulerAppointmentDC.cs | 6 +- Shared/Extensions/DateTimeExtensions.cs | 18 +-- 20 files changed, 522 insertions(+), 282 deletions(-) create mode 100644 Model/Changes_2020_07_24_HasServiceRecordEntry.txt diff --git a/BeWo/Core/BeWoUtils.cs b/BeWo/Core/BeWoUtils.cs index ca937f5a7..25194354e 100644 --- a/BeWo/Core/BeWoUtils.cs +++ b/BeWo/Core/BeWoUtils.cs @@ -2070,40 +2070,66 @@ namespace BeWo.Core } } - public static void CreateZeiterfassung(DateTime start, DateTime end, List customer, List employees, String notice) + public static void CreateZeiterfassung(DateTime start, DateTime end, List customer, List employees, String notice, Appointment appointment, Action schedulerCallback) { + ChatDokumentationsView newView; + if (customer.Count == 0) { - - //Normale Buchung - ChatDokumentationsView newView = new ChatDokumentationsView(notice, null, start, end); - - newView.ShowDialog(); + // Normale Buchung + newView = new ChatDokumentationsView(notice, null, start, end, schedulerCallback, appointment); } else if (customer.Count == 1 && employees.Count == 0) { var compactKlient = ServiceFacade.DoCustomerServiceSync(s => s.GetCompactCustomerDC(customer[0].CustomerOid)); - //Normale Buchung - ChatDokumentationsView newView = new ChatDokumentationsView(notice, compactKlient, start, end); - - newView.ShowDialog(); + // Normale Buchung + newView = new ChatDokumentationsView(notice, compactKlient, start, end, schedulerCallback, appointment); } else { - if (employees.Count == 0) { employees.Add(BeWoApp.CompactLoggedOnEmployee); } - //gruppenbuchungen - ChatDokumentationsView newView = new ChatDokumentationsView(notice, start, end, customer, employees); - - newView.ShowDialog(); + // Gruppenbuchungen + newView = new ChatDokumentationsView(notice, start, end, customer, employees, schedulerCallback, appointment); } + + newView.ShowDialog(); } - + + public static void CreateZeiterfassung(DateTime start, DateTime end, List customer, List employees, String notice) + { + ChatDokumentationsView newView; + + if(customer.Count == 0) + { + // Normale Buchung + newView = new ChatDokumentationsView(notice, null, start, end); + } + else if(customer.Count == 1 && employees.Count == 0) + { + var compactKlient = ServiceFacade.DoCustomerServiceSync(s => s.GetCompactCustomerDC(customer[0].CustomerOid)); + + // Normale Buchung + newView = new ChatDokumentationsView(notice, compactKlient, start, end); + } + else + { + if(employees.Count == 0) + { + employees.Add(BeWoApp.CompactLoggedOnEmployee); + } + + // Gruppenbuchungen + newView = new ChatDokumentationsView(notice, start, end, customer, employees); + } + + newView.ShowDialog(); + } + public static void OwnChatSynchronisationVeranlassen() { if (!BeWoApp.Mandator.Apikey.IsNullOrEmpty()) diff --git a/BeWo/Scheduler/Utils/AppointmentExtensions.cs b/BeWo/Scheduler/Utils/AppointmentExtensions.cs index af5f2c007..890ae78d8 100644 --- a/BeWo/Scheduler/Utils/AppointmentExtensions.cs +++ b/BeWo/Scheduler/Utils/AppointmentExtensions.cs @@ -90,6 +90,10 @@ namespace BeWo.Scheduler.Utils return appointment.GetCustomFieldStorage()?.SchedulerAppointmentOid; } + public static bool CF_HasServiceRecordEntry(this Appointment appointment) + { + return appointment.GetCustomFieldStorage()?.HasServiceRecordEntry ?? false; + } @@ -164,5 +168,10 @@ namespace BeWo.Scheduler.Utils { appointment.GetCustomFieldStorage().TaskDescription = pTaskDescription; } + + public static void CF_HasServiceRecordEntry(this Appointment appointment, bool hasServiceRecordEntry) + { + appointment.GetCustomFieldStorage().HasServiceRecordEntry = hasServiceRecordEntry; + } } } diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml b/BeWo/Scheduler/View/NewSchedulerView.xaml index 74a9bdca4..2bad46b14 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml @@ -29,11 +29,11 @@ - - - - - + + + + + @@ -72,33 +72,33 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -129,28 +129,30 @@ - + + - - + + - + + - + diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs index 7a029d5e3..4f2a2f274 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs @@ -7,7 +7,6 @@ using System.Globalization; using System.IO; using System.Linq; using System.Text; -using System.Threading; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; @@ -37,7 +36,7 @@ using DevExpress.Xpf.Editors; using DevExpress.Xpf.Scheduler; using DevExpress.Xpf.Scheduler.Reporting; using DevExpress.XtraScheduler; - +using DevExpress.XtraScheduler.Compatibility; using Appointment = DevExpress.XtraScheduler.Appointment; using AppointmentViewInfoCustomizingEventArgs = DevExpress.Xpf.Scheduler.AppointmentViewInfoCustomizingEventArgs; using ColorConverter = System.Windows.Media.ColorConverter; @@ -974,14 +973,14 @@ namespace BeWo.Scheduler.View private void NewSchedulerStorage_AppointmentsChanged(object sender, PersistentObjectsEventArgs e) { - if (IgnoreChangeEvents) + if (IgnoreChangeEvents || IgnoreManualAppointmentCreation) { return; } - WriteToDebug("AppointmentsChanged, bitch"); + Debug.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NewSchedulerStorage_AppointmentsChanged"); - var appList = e.Objects.Cast().ToList(); + var appList = e.Objects.Cast().ToList(); if (appList.Any(f => f.CF_IsPrivate())) { @@ -1051,6 +1050,11 @@ namespace BeWo.Scheduler.View private void NewSchedulerStorage_AppointmentsInserted(object sender, PersistentObjectsEventArgs e) { + if(IgnoreManualAppointmentCreation) + { + return; + } + var appList = e.Objects.Cast().ToList(); if(appList.Any(f => f.CF_IsPrivate())) @@ -1058,7 +1062,7 @@ namespace BeWo.Scheduler.View ShowPrivateAppointmentsCheckBox.IsChecked = true; } - ViewModel.ActiveAppointmentViewModel.InsertAppointments(Scheduler, appList); + ViewModel.ActiveAppointmentViewModel.InsertAppointments(Scheduler, appList); UpdateRequestString(); ReloadVM(true); } @@ -1550,53 +1554,77 @@ namespace BeWo.Scheduler.View return; } - var app = Scheduler.SelectedAppointments[0]; + var appointment = Scheduler.SelectedAppointments.FirstOrDefault(); - var e2aList = app.CF_EmployeeList(); - var customerList = app.CF_CustomerList(); + if(appointment == null) + { + return; + } + + var employee2SchedulerAppointmentList = appointment.CF_EmployeeList(); + var customerList = appointment.CF_CustomerList(); - var empList = e2aList.Select(e2a => e2a.Employee).ToList(); + var employeeList = employee2SchedulerAppointmentList.Select(employee2SchedulerAppointment => employee2SchedulerAppointment.Employee).ToList(); + BeWoUtils.CreateZeiterfassung(appointment.Start, appointment.End, customerList, employeeList, appointment.Subject, appointment, () => + { + try + { + IgnoreManualAppointmentCreation = true; + IgnoreChangeEvents = true; - BeWoUtils.CreateZeiterfassung(app.Start, app.End, customerList, empList, app.Subject); - //var employ = SelectedMitarbeiter.Items; - //var y = SelectedKlient.Items; + var schedulerAppointment = (SchedulerAppointmentVM) appointment.GetSourceObject(Scheduler.GetCoreStorage()); + var appointmentOid = schedulerAppointment?.CommitToDataContract().SchedulerAppointmentOid; - //if (y.Count == 0) - //{ - // MessageBox.Show("Bitte wählen Sie mindestens einen Klienten aus!"); - //} - //else - //{ - // var startDate = StartDate.DateTime; - // var startTime = DateTime.Parse(StartTime.Text); + if(appointmentOid.HasValue) + { + appointment.CF_HasServiceRecordEntry(true); - // var endDate = EndDate.DateTime; - // var endTime = DateTime.Parse(EndTime.Text); + ViewModel.ActiveAppointmentViewModel.SaveAppointments(Scheduler, new List {appointment}); - // DateTime start = new DateTime(startDate.Year, startDate.Month, startDate.Day, startTime.Hour, startTime.Minute, startTime.Second); - // DateTime end = new DateTime(endDate.Year, endDate.Month, endDate.Day, endTime.Hour, endTime.Minute, endTime.Second); + ReloadVM(true); + } + else + { + // Serientermin! + var recurrenceInfo = appointment.RecurrenceInfo; - // List customerlist = new List(); - // List employeelist = new List(); + var pattern = StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern); + pattern.RecurrenceInfo.FromXml(recurrenceInfo.ToXml()); - // foreach (var employee in employ) - // { - // var xy = (Employee2SchedulerAppointmentDC)employee; - // employeelist.Add(xy.Employee); - // } + var apt = appointment.RecurrencePattern.CreateException(AppointmentType.ChangedOccurrence, appointment.RecurrenceIndex); - // foreach (var klient in y) - // { - // var s = (CompactCustomerDC)klient; - // customerlist.Add(s); - // } + apt.Duration = appointment.Duration; + apt.End = apt.Start.Add(appointment.Duration); - // BeWoUtils.CreateZeiterfassung(start, end, customerlist, employeelist, Notice.Text); - //} + apt.Subject = appointment.Subject; + apt.Location = appointment.Location; + apt.Description = appointment.Description; + + Scheduler.Storage.AppointmentStorage.CreateCustomFields(apt); + + apt.CustomFields[nameof(CustomFieldStorage)] = appointment.CustomFields[nameof(CustomFieldStorage)]; + + apt.CF_HasServiceRecordEntry(true); + + ViewModel.ActiveAppointmentViewModel.InsertAppointments(Scheduler, new List {apt}); + + IgnoreChangeEvents = true; + + ReloadVM(true); + } + } + finally + { + IgnoreManualAppointmentCreation = false; + IgnoreChangeEvents = false; + } + }); } + private bool IgnoreManualAppointmentCreation { get; set; } + private void MeinTB_OnChecked(object sender, RoutedEventArgs e) { var tb = (ToggleButton) sender; @@ -2349,7 +2377,6 @@ namespace BeWo.Scheduler.View } } - private static void WriteToDebug(string pText) { Debug.WriteLine($"-----------------------> {pText}"); diff --git a/BeWo/Scheduler/ViewModel/CustomFieldStorage.cs b/BeWo/Scheduler/ViewModel/CustomFieldStorage.cs index 67e297d83..3e6043711 100644 --- a/BeWo/Scheduler/ViewModel/CustomFieldStorage.cs +++ b/BeWo/Scheduler/ViewModel/CustomFieldStorage.cs @@ -103,6 +103,8 @@ namespace BeWo.Scheduler.ViewModel _AbsenceTimeStart = pAppointment.AbsenceTimeStart; _AbsenceTimeEnd = pAppointment.AbsenceTimeEnd; + + HasServiceRecordEntry = pAppointment.HasServiceRecordEntry; } public CustomFieldStorage(SchedulerAppointmentDC pAppointment) @@ -129,6 +131,8 @@ namespace BeWo.Scheduler.ViewModel RecurrenceId = pAppointment.RecurrenceId; RecurrenceIndex = pAppointment.RecurrenceIndex; + + HasServiceRecordEntry = pAppointment.HasServiceRecordEntry; } public CustomFieldStorage(ObservableCollection pEmployees, List pCustomers, List pResources, CompactEmployeeDC pOriginator, bool pIsPrivate, bool pIsTask, string pTaskDescription, DateTime? pDueDate, DateTime? pCompletedDate, string pCompletedNotice, List pSupportConcepts, string pSubject, bool pIsAllDay) @@ -162,5 +166,7 @@ namespace BeWo.Scheduler.ViewModel public Visibility ToolTipTrennstrichVisibility => EmployeeList?.Count > 0 || CustomerList?.Count > 0 || ResourceList?.Count > 0 ? Visibility.Visible : Visibility.Collapsed; public Visibility ToolTipZusageVisibility => IsTask ? Visibility.Collapsed : Visibility.Visible; + + public bool HasServiceRecordEntry { get; set; } } } diff --git a/BeWo/Scheduler/ViewModel/SchedulerAppointmentListVM.cs b/BeWo/Scheduler/ViewModel/SchedulerAppointmentListVM.cs index 9687474cf..d394c3857 100644 --- a/BeWo/Scheduler/ViewModel/SchedulerAppointmentListVM.cs +++ b/BeWo/Scheduler/ViewModel/SchedulerAppointmentListVM.cs @@ -137,20 +137,27 @@ namespace BeWo.Scheduler.ViewModel } public void SaveAppointments(SchedulerControl control, IEnumerable list) - { + { var areEqual = false; var dcList = new List(); foreach (var item in list) - { - var vm = item.GetSourceObject(control.GetCoreStorage()) as SchedulerAppointmentVM; - if (vm == null) + { + if (!(item.GetSourceObject(control.GetCoreStorage()) is SchedulerAppointmentVM vm)) { - continue; + continue; } UpdateSchedulerAppointment(item, vm); + if(vm.ResourceList.Any()) + { + if(!CheckForUnavailableResources(vm)) + { + return; + } + } + if (!ShouldLockOverlappingAppointmentCheck && vm.EventType != 3 && !vm.IsTask) { var isOverlapping = false; @@ -167,7 +174,7 @@ namespace BeWo.Scheduler.ViewModel if (isOverlapping) { - var erg = MessageBox.Show("Dieser Termin überschneidet sich mit einem anderen bereits existierenden Termin.\n Möchten Sie ihn wirklich speichern?", "Überschneidung", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); + var erg = MessageBox.Show("Dieser Termin überschneidet sich mit einem anderen bereits existierenden Termin.\nMöchten Sie ihn wirklich speichern?", "Überschneidung", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (erg.Equals(MessageBoxResult.No)) { @@ -202,17 +209,55 @@ namespace BeWo.Scheduler.ViewModel public void InsertAppointments(SchedulerControl control, IEnumerable list) { - var dcList = new List(); + var dcList = new List(); foreach (var item in list) - { - var vm = item.GetSourceObject(control.GetCoreStorage()) as SchedulerAppointmentVM; - if (vm == null) + { + if (!(item.GetSourceObject(control.GetCoreStorage()) is SchedulerAppointmentVM vm)) { - continue; + if(item.IsException && item.CF_HasServiceRecordEntry()) + { + var dc = new SchedulerAppointmentDC + { + IsPrivate = item.CF_IsPrivate(), + Subject = item.Subject, + Description = item.Description, + StartDate = item.Start, + EndDate = item.End, + Originator = item.CF_Originator(), + LabelId = item.LabelId, + AllDay = item.AllDay, + Status = item.StatusId, + Type = (int) item.Type, + Location = item.Location, + RecurrenceInfo = item.RecurrenceInfo.ToXml(), + ReminderInfo = item.Reminder?.ToXml(), + CustomerList = item.CF_CustomerList(), + EmployeeList = item.CF_EmployeeList().ToList(), + ResourceList = item.CF_ResourceList(), + SupportConceptList = item.CF_SupportConceptList(), + RecurrenceIndex = item.RecurrenceIndex, + RecurrenceId = item.RecurrenceInfo.Id.ToString(), + HasServiceRecordEntry = item.CF_HasServiceRecordEntry() + }; + + vm = new SchedulerAppointmentVM(dc); + } + else + { + continue; + } } UpdateSchedulerAppointment(item, vm); + if(vm.ResourceList.Any()) + { + if(!CheckForUnavailableResources(vm)) + { + return; + } + } + if (!ShouldLockOverlappingAppointmentCheck && !vm.IsTask) { var isOverlapping = false; @@ -228,7 +273,7 @@ namespace BeWo.Scheduler.ViewModel if (isOverlapping) { - var erg = MessageBox.Show("Dieser Termin überschneidet sich mit einem anderen bereits existierenden Termin.\n Möchten Sie ihn wirklich speichern?", "Überschneidung", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); + var erg = MessageBox.Show("Dieser Termin überschneidet sich mit einem anderen bereits existierenden Termin.\nMöchten Sie ihn wirklich speichern?", "Überschneidung", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); if (erg.Equals(MessageBoxResult.No)) { @@ -266,6 +311,7 @@ namespace BeWo.Scheduler.ViewModel vm.CompletedNotice = app.CF_CompletedNotice(); vm.TaskDescription = app.CF_TaskDescription(); vm.SupportConceptList = app.CF_SupportConceptList(); + vm.HasServiceRecordEntry = app.CF_HasServiceRecordEntry(); if(vm.IsTask) { @@ -594,6 +640,39 @@ namespace BeWo.Scheduler.ViewModel return areEqual; } + + private static bool CheckForUnavailableResources(SchedulerAppointmentVM vm) + { + var unavailableResources = new List(); + + ServiceFacade.DoResourceServiceSync(s => unavailableResources = s.CheckResourceAvailability(vm.Start, vm.End, vm.ResourceList.Select(resource => resource.ResourceOid.Value).ToList(), null)); + + if(unavailableResources.Any()) + { + var names = string.Empty; + + unavailableResources.DoForEach(resource => names += resource.Name + ", "); + + names = names.TrimEnd(' ').TrimEnd(','); + + var resourceCount = vm.ResourceList.Count; + + var warningMessage = unavailableResources.Count > 1 ? + $"Ein{(resourceCount > 1 ? "ige" : "e")} der ausgewählten Ressourcen ({names}) sind" : + $"{(resourceCount > 1 ? "Eine der" : "Die")} ausgewählte{(resourceCount > 1 ? "n" : string.Empty)} Ressource{(resourceCount > 1 ? "n" : string.Empty)} ({names}) ist"; + + warningMessage += $" zum gewählten Zeitpunkt ({vm.Start.GetIntervalDescription(vm.End).TrimStart(' ')}) nicht verfügbar.\n\nMöchten Sie trotzdem speichern?"; + + var erg = MessageBox.Show(warningMessage, "Überschneidung", MessageBoxButton.YesNo); + + if(erg.Equals(MessageBoxResult.No)) + { + return false; + } + } + + return true; + } } } diff --git a/BeWo/Scheduler/ViewModel/SchedulerAppointmentVM.cs b/BeWo/Scheduler/ViewModel/SchedulerAppointmentVM.cs index 260243a9f..95f5175b2 100644 --- a/BeWo/Scheduler/ViewModel/SchedulerAppointmentVM.cs +++ b/BeWo/Scheduler/ViewModel/SchedulerAppointmentVM.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.ComponentModel; using System.Linq; using BeWo.ViewModel; @@ -58,7 +57,25 @@ namespace BeWo.Scheduler.ViewModel private DateTime? _CompletedDate; private DateTime? _DueDate; private DateTime? _DueTime; - public DateTime? AbsenceTimeStart { get; set; } + private bool _HasServiceRecordEntry; + + + public bool HasServiceRecordEntry + { + get => _HasServiceRecordEntry; + set + { + if(AreDifferent(_HasServiceRecordEntry, value)) + { + _HasServiceRecordEntry = value; + + StoreDirtyInformation(AreDifferent(DataContract.HasServiceRecordEntry, value), nameof(HasServiceRecordEntry)); + FirePropertyChanged(nameof(HasServiceRecordEntry)); + } + } + } + + public DateTime? AbsenceTimeStart { get; set; } public DateTime? AbsenceTimeEnd { get; set; } public object Id { get; set; } @@ -545,27 +562,29 @@ namespace BeWo.Scheduler.ViewModel protected override void InitByDataContract(SchedulerAppointmentDC pDataContract) { - _AllDay = pDataContract.AllDay; - _Description = pDataContract.Description; - _End = pDataContract.EndDate ?? DateTime.Now; - _Location = pDataContract.Location; - _RecurrenceInfo = pDataContract.RecurrenceInfo; - _Start = pDataContract.StartDate ?? DateTime.Now; - _Status = pDataContract.Status; - _Subject = pDataContract.Subject; - _Type = pDataContract.Type; - _IsPrivate = pDataContract.IsPrivate; - _Originator = pDataContract.Originator; - _CustomerList = pDataContract.CustomerList ?? new List(); - _EmployeeList = new ObservableCollection(pDataContract.EmployeeList ?? new List()); - _ResourceList = pDataContract.ResourceList ?? new List(); - _IsTask = pDataContract.IsTask; - _TaskDescription = pDataContract.TaskDescription; - _CompletedNotice = pDataContract.CompletedNotice; - _CompletedDate = pDataContract.CompletedDate; - _SupportConceptList = pDataContract.SupportConceptList ?? new List(); - - if(pDataContract.DueDate.HasValue) + _AllDay = pDataContract.AllDay; + _Description = pDataContract.Description; + _End = pDataContract.EndDate ?? DateTime.Now; + _Location = pDataContract.Location; + _RecurrenceInfo = pDataContract.RecurrenceInfo; + _Start = pDataContract.StartDate ?? DateTime.Now; + _Status = pDataContract.Status; + _Subject = pDataContract.Subject; + _Type = pDataContract.Type; + _IsPrivate = pDataContract.IsPrivate; + _Originator = pDataContract.Originator; + _CustomerList = pDataContract.CustomerList ?? new List(); + _EmployeeList = new ObservableCollection(pDataContract.EmployeeList ?? new List()); + _ResourceList = pDataContract.ResourceList ?? new List(); + _IsTask = pDataContract.IsTask; + _TaskDescription = pDataContract.TaskDescription; + _CompletedNotice = pDataContract.CompletedNotice; + _CompletedDate = pDataContract.CompletedDate; + _SupportConceptList = pDataContract.SupportConceptList ?? new List(); + _HasServiceRecordEntry = pDataContract.HasServiceRecordEntry; + + + if(pDataContract.DueDate.HasValue) { _DueDate = pDataContract.DueDate; _DueTime = pDataContract.DueDate; @@ -574,27 +593,29 @@ namespace BeWo.Scheduler.ViewModel protected override SchedulerAppointmentDC MapToDataContract(SchedulerAppointmentDC pDataContract, bool doCommit) { - pDataContract.AllDay = _AllDay; - pDataContract.Description = _Description; - pDataContract.EndDate = _End; - pDataContract.Location = _Location; - pDataContract.RecurrenceInfo = _RecurrenceInfo; - pDataContract.StartDate = _Start; - pDataContract.Status = _Status; - pDataContract.Subject = _Subject; - pDataContract.Type = _Type; - pDataContract.IsPrivate = _IsPrivate; - pDataContract.Originator = _Originator; - pDataContract.CustomerList = _CustomerList; - pDataContract.EmployeeList = _EmployeeList.ToList(); - pDataContract.ResourceList = _ResourceList; - pDataContract.IsTask = _IsTask; - pDataContract.TaskDescription = _TaskDescription; - pDataContract.CompletedNotice = _CompletedNotice; - pDataContract.CompletedDate = _CompletedDate; - pDataContract.SupportConceptList = _SupportConceptList; + pDataContract.AllDay = _AllDay; + pDataContract.Description = _Description; + pDataContract.EndDate = _End; + pDataContract.Location = _Location; + pDataContract.RecurrenceInfo = _RecurrenceInfo; + pDataContract.StartDate = _Start; + pDataContract.Status = _Status; + pDataContract.Subject = _Subject; + pDataContract.Type = _Type; + pDataContract.IsPrivate = _IsPrivate; + pDataContract.Originator = _Originator; + pDataContract.CustomerList = _CustomerList; + pDataContract.EmployeeList = _EmployeeList.ToList(); + pDataContract.ResourceList = _ResourceList; + pDataContract.IsTask = _IsTask; + pDataContract.TaskDescription = _TaskDescription; + pDataContract.CompletedNotice = _CompletedNotice; + pDataContract.CompletedDate = _CompletedDate; + pDataContract.SupportConceptList = _SupportConceptList; + pDataContract.HasServiceRecordEntry = _HasServiceRecordEntry; - if(_DueDate.HasValue && _DueTime.HasValue) + + if(_DueDate.HasValue && _DueTime.HasValue) { pDataContract.DueDate = new DateTime(_DueDate.Value.Year, _DueDate.Value.Month, _DueDate.Value.Day, _DueTime.Value.Hour, _DueTime.Value.Minute, 0); } @@ -657,7 +678,8 @@ namespace BeWo.Scheduler.ViewModel Equals(EndTime, obj.EndTime) && Equals(Location, obj.Location) && ResourceList.AreEqual(obj.ResourceList) && - Equals(RecurrenceInfo, obj.RecurrenceInfo); + Equals(RecurrenceInfo, obj.RecurrenceInfo) && + HasServiceRecordEntry == obj.HasServiceRecordEntry; return areEqual; } diff --git a/BeWo/ownChat/ChatDokumentationsView.xaml.cs b/BeWo/ownChat/ChatDokumentationsView.xaml.cs index aeff8c63a..c74581104 100644 --- a/BeWo/ownChat/ChatDokumentationsView.xaml.cs +++ b/BeWo/ownChat/ChatDokumentationsView.xaml.cs @@ -7,9 +7,6 @@ using BS.Shared.Extensions; using System.Windows.Controls; using System.Windows.Threading; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; using BeWo.Core.Service; using BeWo.View; using BeWo.View.Detail; @@ -17,14 +14,14 @@ using BeWo.ViewModel.ListViewModel; using BS.Shared; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; -using BS.Shared.Translation; using ChatController.ChatKlassen; +using DevExpress.XtraScheduler; namespace BeWo.ownChat { public partial class ChatDokumentationsView { - private ServiceRecordVM serviceRecord; + private ServiceRecordVM _ServiceRecord; public ChatDokumentationsView() {} @@ -32,14 +29,14 @@ namespace BeWo.ownChat { InitializeComponent(); - this.serviceRecord = serviceRecord; + _ServiceRecord = serviceRecord; var newView = new ServiceRecordEditView(); newView.InitView(list, serviceRecord, false); newView.SetSearchText(serviceRecord.Customer != null ? serviceRecord.Customer.LastName : ""); - CommandBindingsCloseSave(newView); + CommandBindingsCloseSave(newView, null); Popup_Content(newView); } @@ -105,11 +102,11 @@ namespace BeWo.ownChat //} //Konstruktor für Kalender - public ChatDokumentationsView(string notice, CompactCustomerDC _compactCustomer, DateTime firstTime, DateTime lastTime) + public ChatDokumentationsView(string notice, CompactCustomerDC _compactCustomer, DateTime firstTime, DateTime lastTime, Action schedulerCallback = null, Appointment appointment = null) { InitializeComponent(); - CompactCustomerDC customerCompact = _compactCustomer; + var customerCompact = _compactCustomer; Cache.GetInstance().GetActiveSupportConceptCostbearer(scList => VMFactory.CreateServiceRecordVMAsync( @@ -117,7 +114,7 @@ namespace BeWo.ownChat vm => this.Dispatch( delegate { - ServiceRecordEditView newView = new ServiceRecordEditView(); + var serviceRecordEditView = new ServiceRecordEditView(); vm.DispatcherObject = this; @@ -131,101 +128,92 @@ namespace BeWo.ownChat dc.ServiceDescription = vm.PrototypeVM.Category2Services[cat1][0]; } - serviceRecord = new ServiceRecordVM(dc, vm.PrototypeVM.Category2Services, vm.PrototypeVM.AllGoalCategories, vm.PrototypeVM.AllGoals); - serviceRecord.Notice = notice; - bool hideCustomerCombo = serviceRecord.SupportConcept == null; - newView.InitView(vm, serviceRecord, hideCustomerCombo); - if(customerCompact != null) - { - newView.SetSearchText(customerCompact.LastName); - } - else - { - newView.SetSearchText(""); - } + _ServiceRecord = new ServiceRecordVM(dc, vm.PrototypeVM.Category2Services, vm.PrototypeVM.AllGoalCategories, vm.PrototypeVM.AllGoals) {Notice = notice}; + var hideCustomerCombo = _ServiceRecord.SupportConcept == null; + serviceRecordEditView.InitView(vm, _ServiceRecord, hideCustomerCombo); - CommandBindingsCloseSave(newView); + serviceRecordEditView.SetSearchText(customerCompact != null ? customerCompact.LastName : ""); - Popup_Content(newView); + CommandBindingsCloseSave(serviceRecordEditView, schedulerCallback); + + Popup_Content(serviceRecordEditView); }))); } //GruppenBuchung Konstruktor für Kalender - public ChatDokumentationsView(string notice, DateTime firstTime,DateTime lastTime ,List _compactCustomer, List _compactEmployee) + public ChatDokumentationsView(string notice, DateTime firstTime, DateTime lastTime, List _compactCustomer, List _compactEmployee, Action schedulerCallback = null, Appointment appointment = null) { InitializeComponent(); - var customerCompact = _compactCustomer[0]; - Cache.GetInstance().GetActiveSupportConceptCostbearer(scList => VMFactory.CreateServiceRecordVMAsync( BeWoApp.LoggedOnUser.Employee.EmployeeOid, vm => this.Dispatch( delegate { - ServiceRecordGroupEditView newView = new ServiceRecordGroupEditView(); + var newView = new ServiceRecordGroupEditView(); vm.DispatcherObject = this; - - var group = new ServiceRecordGroupDC(); - - group.StartDate = firstTime; - group.EndDate = lastTime; - group.CustomerCount = _compactCustomer.Count; - group.EmployeeCount = _compactEmployee.Count; - group.Notice = notice; - - List ServiceListRecordDC = new List(); - + var serviceRecordGroup = new ServiceRecordGroupDC + { + StartDate = firstTime, + EndDate = lastTime, + CustomerCount = _compactCustomer.Count, + EmployeeCount = _compactEmployee.Count, + Notice = notice + }; + + var serviceRecordList = new List(); foreach (var emp in _compactEmployee) { foreach (var cus in _compactCustomer) { - var sc = SupportConceptService.HoleHilfeplanAusListe(scList, cus, firstTime, lastTime); - if (sc != null) + var supportConcept = SupportConceptService.HoleHilfeplanAusListe(scList, cus, firstTime, lastTime); + + if (supportConcept != null) { - var dcs = new ServiceRecordDC(); - dcs.Start = firstTime; - dcs.End = lastTime; - dcs.Employee = emp; - dcs.Customer = cus; - dcs.SupportConcept = SupportConceptService.HoleHilfeplanAusListe(scList, cus, firstTime, lastTime); - dcs.GroupEmployeeCount = _compactEmployee.Count; - dcs.GroupPersonCount = _compactCustomer.Count; + var serviceRecord = new ServiceRecordDC + { + Start = firstTime, + End = lastTime, + Employee = emp, + Customer = cus, + SupportConcept = SupportConceptService.HoleHilfeplanAusListe(scList, cus, firstTime, lastTime), + GroupEmployeeCount = _compactEmployee.Count, + GroupPersonCount = _compactCustomer.Count + }; if (BeWoApp.AppSettings.IsEndDateVisible) { - dcs.ServiceRecordFormat = ServiceRecordFormate.ZeiterfassungMitEndDatum; + serviceRecord.ServiceRecordFormat = ServiceRecordFormate.ZeiterfassungMitEndDatum; } else if (BeWoApp.AppSettings.IsOnlyYearMonthVisible) { - dcs.ServiceRecordFormat = + serviceRecord.ServiceRecordFormat = ServiceRecordFormate.ZeiterfassungMitMonatJahr; } else { - dcs.ServiceRecordFormat = ServiceRecordFormate.OriginaleZeiterfassung; + serviceRecord.ServiceRecordFormat = ServiceRecordFormate.OriginaleZeiterfassung; } - dcs.DurationInStunden = ZeiterfassungsDauer.Minuten; + serviceRecord.DurationInStunden = ZeiterfassungsDauer.Minuten; - - if (dcs.SupportConcept.CostBearerList != null && - dcs.SupportConcept.CostBearerList.Count > 0) + if (serviceRecord.SupportConcept.CostBearerList != null && serviceRecord.SupportConcept.CostBearerList.Count > 0) { - dcs.CostBearer = dcs.SupportConcept.CostBearerList[0].Organisation; + serviceRecord.CostBearer = serviceRecord.SupportConcept.CostBearerList[0].Organisation; } - ServiceListRecordDC.Add(dcs); + serviceRecordList.Add(serviceRecord); } } } - if (ServiceListRecordDC.Count == 0) + if (serviceRecordList.Count == 0) { MessageBox.Show( "Es wurden keine laufenden Hilfepläne für die ausgewählten Klienten gefunden. Die Übernahme in die Zeiterfassung ist nicht möglich.", @@ -233,22 +221,19 @@ namespace BeWo.ownChat Close(); return; } - group.ServiceRecordList = ServiceListRecordDC; - + + serviceRecordGroup.ServiceRecordList = serviceRecordList; if (vm.PrototypeVM.SortedCategories != null && vm.PrototypeVM.SortedCategories.Count > 0) { var cat1 = vm.PrototypeVM.SortedCategories[0]; - ServiceListRecordDC[0].ServiceDescription = vm.PrototypeVM.Category2Services[cat1][0]; + serviceRecordList[0].ServiceDescription = vm.PrototypeVM.Category2Services[cat1][0]; } - - serviceRecord = new ServiceRecordVM(ServiceListRecordDC[0], vm.PrototypeVM.Category2Services, vm.PrototypeVM.AllGoalCategories, vm.PrototypeVM.AllGoals); - serviceRecord.Notice = notice; + _ServiceRecord = new ServiceRecordVM(serviceRecordList[0], vm.PrototypeVM.Category2Services, vm.PrototypeVM.AllGoalCategories, vm.PrototypeVM.AllGoals) {Notice = notice}; - newView.InitView(vm, serviceRecord, group); - + newView.InitView(vm, _ServiceRecord, serviceRecordGroup); if (newView.CommandBindings.Count == 0) { @@ -269,7 +254,7 @@ namespace BeWo.ownChat ApplicationCommands.Save, (s, e) => { - bool save = newView.IsValid(); + var save = newView.IsValid(); if (!save) { @@ -277,20 +262,18 @@ namespace BeWo.ownChat } newView.SaveData(); + schedulerCallback?.Invoke(); Close(); - })); } - popup_contentChat.Child = newView; popup_contentChat.Visibility = Visibility.Visible; - }))); } - private void CommandBindingsCloseSave(ServiceRecordEditView newView) + private void CommandBindingsCloseSave(ServiceRecordEditView newView, Action schedulerCallback) { if (newView.CommandBindings.Count == 0) { @@ -311,32 +294,33 @@ namespace BeWo.ownChat ApplicationCommands.Save, (s, e) => { - bool save = newView.IsValid(); + var isValid = newView.IsValid(); - if (!save) + if (!isValid) { return; } - newView.SaveData(); + // TODO: Callback einbauen, das den Termin verändert (vom Kalender übergeben) + if(newView.SaveData()) + { + schedulerCallback?.Invoke(); + } + Close(); - })); } } - - - private void Popup_Content( ServiceRecordEditView newView) + private void Popup_Content(UIElement serviceRecordEditView) { - popup_contentChat.Child = newView; + popup_contentChat.Child = serviceRecordEditView; popup_contentChat.Visibility = Visibility.Visible; } - private void RootGroupBox_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { try @@ -348,7 +332,6 @@ namespace BeWo.ownChat } } - private DateTime ConvertToDateTimeStart(string startTime) { diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index 3790e3983..d3e17eefd 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Web.Mvc; @@ -61,6 +62,19 @@ namespace BeWoPlanerMobil.Controllers 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() + { + var mandator = (MandatorDC)HttpContext.Session["mandator"]; + + if(mandator == null) + { + mandator = OperationsService.GetMandator(); + HttpContext.Session["mandator"] = mandator; + } + + return mandator; + } + [Authorize] public ActionResult Main() { @@ -81,7 +95,8 @@ namespace BeWoPlanerMobil.Controllers Model.ShowExpiredSupportConcepts = GetUserSettingValue("ShowExpiredSupportConcepts") == "1"; Model.ShowOnlyOwnSupportConcepts = GetUserSettingValue("ShowOnlyMySupportConcepts") == "1"; - var mandator = OperationsService.GetMandator(); + var mandator = GetMandator(); + var supportConceptExpirationLimitInMonths = GetSettingValue(mandator.Settings, "HilfeplanAuslaufAuswahl"); var anzTageZeiterfassErfolgt = GetSettingValue(mandator.Settings, "AnzTageZeiterfassErfolgt"); var maxDaysEditServiceRecordsAllowed = GetSettingValue(mandator.Settings, "MaxDaysEditServiceRecordsAllowed"); @@ -359,7 +374,7 @@ namespace BeWoPlanerMobil.Controllers return SerializeObject(goalTree); } - private static List BuildGoalTree(List goals) + private static List BuildGoalTree(IReadOnlyCollection goals) { var ziele = goals.Where(w => _Zieltypen.Contains(w.Type)).OrderBy(s => s.TypeDescription).ToList(); var massnahmen = goals.Where(w => _Massnahmentypen.Contains(w.Type)).OrderBy(s => s.TypeDescription).ToList(); @@ -859,7 +874,7 @@ namespace BeWoPlanerMobil.Controllers if(Model.Dokutypes != null && Model.Dokutypes.Length > 1) { - doku1 = collection["Dokumentation"]; + doku1 = collection["Dokumentation1"]; } else { @@ -1489,6 +1504,13 @@ namespace BeWoPlanerMobil.Controllers private void LoadServiceCategoriesToModel(long? cb2ScOid) { + if(cb2ScOid == null && Model.IsInGroupBookingMode) + { + Model.ServiceCategories = CreateServiceCategoryModels(OperationsService.GetAllServiceDescriptions()); + + return; + } + Model.CostBearer2SupportConceptOid = cb2ScOid; Model.SelectedSupportConcept = Model.SupportConcepts.FirstOrDefault( @@ -1644,7 +1666,13 @@ namespace BeWoPlanerMobil.Controllers recordsOhneDuplikate.Add(r); } - Model.ServiceRecords = recordsOhneDuplikate; + Model.ServiceRecords = recordsOhneDuplikate.Where(serviceRecord => serviceRecord.Start.HasValue && serviceRecord.End.HasValue) + .OrderBy(serviceRecord => serviceRecord.Start.Value.Date) + .ThenBy(serviceRecord => serviceRecord.Start.Value.Hour) + .ThenBy(serviceRecord => serviceRecord.Start.Value.Minute) + .ThenBy(serviceRecord => serviceRecord.End.Value.Date) + .ThenBy(serviceRecord => serviceRecord.End.Value.Hour) + .ThenBy(serviceRecord => serviceRecord.End.Value.Minute).ToList(); } [HttpPost] @@ -1810,7 +1838,7 @@ namespace BeWoPlanerMobil.Controllers } } - var mandator = OperationsService.GetMandator(); + var mandator = GetMandator(); var maxDaysEditSRsAllowedString = GetSettingValue(mandator.Settings, "MaxDaysEditServiceRecordsAllowed"); var limitFuerZeiterfassungString = GetSettingValue(mandator.Settings, "AnzTageZeiterfassErfolgt"); @@ -2115,6 +2143,12 @@ namespace BeWoPlanerMobil.Controllers return RedirectToAction("Main"); } + /// + /// Setzt die getroffenen Auswahlen zurück + /// + /// + /// Wenn true, wird davon ausgegangen, dass man von der Einzelbuchung in eine Gruppenbuchung wechselt und es wird sich der vorher ausgewählte Mitarbeiter und Hilfeplan gemerkt. + /// Bei false wird davon ausgegangen, dass man von der Gruppenbuchung in eine Einzelbuchung wechselt und der vorher ausgewählte Mitarbeiter und Hilfeplan wird automatisch ausgewählt. private void ResetGroupBookingMode(bool pIsInGroupBookingMode) { if (Model == null) @@ -2182,8 +2216,7 @@ namespace BeWoPlanerMobil.Controllers Model.NewServiceRecord = new ServiceRecordDC(); Model.SelectedServiceRecord = null; - Model.SelectedSupportConcepts.Clear(); - Model.SelectedEmployees.Clear(); + //Model.SelectedEmployees.Clear(); Model.IsInEditingMode = false; Model.SelectedSupportConcepts.Clear(); Model.SelectedConceptCostBearerRelations.Clear(); @@ -2191,7 +2224,10 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedGroupOfPeopleOids.Clear(); Model.SelectedEmployees = new List { MobileSessionFacade.LoggedInCompactEmployee }; Model.SelectedEmployee = MobileSessionFacade.LoggedInCompactEmployee; - LoadServiceCategoriesToModel(Model.CostBearer2SupportConceptOid); + + Model.ServiceCategories = CreateServiceCategoryModels(OperationsService.GetAllServiceDescriptions()); + + //LoadServiceCategoriesToModel(Model.CostBearer2SupportConceptOid); var serviceDescriptions = Model.GetServiceDesctiptions(); @@ -2315,7 +2351,7 @@ namespace BeWoPlanerMobil.Controllers if(string.IsNullOrEmpty(pEmployeeOids)) { Model.SelectedEmployees.Clear(); - return _LeerzeichenFuerGetMethoden; + return JsonConvert.SerializeObject(Model.SelectedEmployees.Count); } var rawEmployeeOids = pEmployeeOids.Split(','); @@ -2327,8 +2363,8 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedEmployees.Clear(); Model.SelectedEmployees.AddRangeIfElementsNotIn(employees); - - return _LeerzeichenFuerGetMethoden; + + return JsonConvert.SerializeObject(Model.SelectedEmployees.Count); } [HttpPost] @@ -2576,6 +2612,8 @@ namespace BeWoPlanerMobil.Controllers if(Model.IsInGroupBookingMode && Model.SelectedSupportConcepts.Count > 1) { + ResetGroupBookingMode(true); + return SaveGroupBooking(); } @@ -2590,7 +2628,7 @@ namespace BeWoPlanerMobil.Controllers Log.Error(e.Message, e); } - return RedirectToActionPermanent("Main"); + return ResetEditingMode(null); } [HttpPost] diff --git a/BeWoPlanerMobil/Scripts/group-booking.js b/BeWoPlanerMobil/Scripts/group-booking.js index 9ba599067..fc21f4529 100644 --- a/BeWoPlanerMobil/Scripts/group-booking.js +++ b/BeWoPlanerMobil/Scripts/group-booking.js @@ -30,7 +30,7 @@ groupOidString += ","; } } - //TODO: Formular deaktivieren oder aktivieren, je nach dem, ob Gruppen oder Hilfepläne ausgewählt sind. + $.get(url, {pRelOids: scOidString, pGroupOids: groupOidString}).done(updateGroupBookingCb2ScList); } @@ -126,5 +126,9 @@ function addEmployeeToGroupBooking() { } } - $.get(url, { pEmployeeOids: 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/Views/Main/Main.cshtml b/BeWoPlanerMobil/Views/Main/Main.cshtml index 26c8b12c5..951cbc41e 100644 --- a/BeWoPlanerMobil/Views/Main/Main.cshtml +++ b/BeWoPlanerMobil/Views/Main/Main.cshtml @@ -44,14 +44,14 @@ $(document).ready(function () { var supportConceptOid = parseInt($("#CostBearer2SupportConceptOid").val()); - + var isSupportConceptSelected = supportConceptOid !== -1; $("#employeesDropDown, #category-select, #leistung-select, #start-date, #end-date, #start-time, #end-time, #duration, #distance, #textbausteine-button, #goals-button, textarea, #reset-button, #create-button, #statistics-button, #timeFrameSelect, #hours-minutes-dropdown-btn").prop("disabled", (isSupportConceptSelected ? false : true)); if(getIsInGroupBookingMode()) { var hasSelectedSupportConcepts = "@Model.SelectedConceptCostBearerRelations.Any()".toLowerCase() === "true"; - + $("#employees-button, #category-select, #leistung-select, #start-date, #end-date, #start-time, #end-time, #duration, #distance, textarea, #reset-button, #create-button, #textbausteine-button, #hours-minutes-dropdown-btn").prop("disabled", (hasSelectedSupportConcepts ? false : true)); } @@ -98,6 +98,13 @@ } setInputFilter(); + + @if(Model.IsInGroupBookingMode) + { + + $("#create-button").prop("disabled", @Model.SelectedEmployees.Count === 0 ? true : false); + + } }); function setInputFilter() { @@ -138,7 +145,7 @@ if($("#sketch-pad").length !== 0) { var rowWidth = $("#canvas-row").innerWidth(); var canvasWidth = $("#sketch-pad").innerWidth(); - + var newWidth = rowWidth; if (newWidth !== canvasWidth) { @@ -539,7 +546,7 @@ var textareaName = i + 1 < 1 ? "Dokumentation" : "Dokumentation" + (i + 1);
- +
} @@ -896,7 +903,9 @@
- +
@@ -1140,7 +1149,9 @@
- +
@@ -1438,9 +1449,15 @@