From a42653c045fedf3f8d3a98be54d8f67b5ee91fc8 Mon Sep 17 00:00:00 2001 From: Lyndon Jetten Date: Wed, 6 Dec 2023 18:14:34 +0100 Subject: [PATCH 01/21] Quittierungsbeleg von Prof. Dr. Eggers Stiftung angepasst. --- BeWo/Scheduler/View/NewSchedulerView.xaml.cs | 222 ++++++++++-------- BeWo/View/Detail/DebugMessageLogView.xaml.cs | 4 +- BeWoPlanerMobil/BeWoPlanerMobil.csproj.user | 4 +- .../Controllers/CustomerController.cs | 47 ++-- BeWoPlanerMobil/Controllers/MainController.cs | 6 + .../Controllers/ReportController.cs | 71 +++++- .../Views/Customer/Customer.cshtml | 29 ++- BeWoPlanerMobil/Views/Main/Main.cshtml | 26 ++ .../Views/Main/SingleBookingPartial.cshtml | 4 +- .../QuittierungsbelegsPreviewPartial.cshtml | 14 ++ .../QuittierungsbelegsResultPartial.cshtml | 98 ++++---- BeWoPlanerMobil/Views/Report/Report.cshtml | 7 + BeWoPlanerMobil/Views/Shared/_Layout.cshtml | 11 +- Data/Access/SearchDAO.cs | 4 + Data/Utils/IntervalFinderHelper.cs | 13 +- .../ServicesOverviewReport.Designer.cs | 51 +++- Service/Plugins/PluginLoader.cs | 13 +- 17 files changed, 420 insertions(+), 204 deletions(-) diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs index 0116fe234..d02c35187 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs @@ -248,22 +248,22 @@ namespace BeWo.Scheduler.View private bool CheckCats2ResourcesForEqualitiy(Dictionary> dic2) { - if(_Category2ResourcesDictionary == null && dic2 != null || dic2 == null && _Category2ResourcesDictionary != null) + if(_Category2ResourcesDictionary is null && dic2 != null || dic2 is null && _Category2ResourcesDictionary != null) { return false; } - return _Category2ResourcesDictionary == null && dic2 == null || _Category2ResourcesDictionary != null && dic2 != null && _Category2ResourcesDictionary.Count == dic2.Count && _Category2ResourcesDictionary.Except(dic2).Any(); + return _Category2ResourcesDictionary is null && dic2 is null || _Category2ResourcesDictionary != null && dic2 != null && _Category2ResourcesDictionary.Count == dic2.Count && _Category2ResourcesDictionary.Except(dic2).Any(); } private static bool ListEquals(IReadOnlyCollection list1, ICollection list2) { - if(list1 == null && list2 == null) + if(list1 is null && list2 is null) { return true; } - if(list1 == null && list2 != null || list1 != null && list2 == null) + if(list1 is null && list2 != null || list1 != null && list2 is null) { return false; } @@ -636,20 +636,20 @@ namespace BeWo.Scheduler.View var ausnahmen = item.GetExceptions(); foreach(var exc in ausnahmen) { - var b = exc.GetSourceObject(Scheduler.GetCoreStorage()) as IBeWoAppointment; - if(b?.CustomFields == null) + var beWoAppointment = exc.GetSourceObject(Scheduler.GetCoreStorage()) as IBeWoAppointment; + if(beWoAppointment?.CustomFields is null) { continue; } - foreach(var field in b.CustomFields) + foreach(var field in beWoAppointment.CustomFields) { exc.CustomFields[field.Key] = field.Value; } } } - if(bapp?.CustomFields == null) + if(bapp?.CustomFields is null) { continue; } @@ -1313,14 +1313,14 @@ namespace BeWo.Scheduler.View if(_IsNew) { - var n = new ObservableCollection(SelectedEmployees.Select(item => new Employee2SchedulerAppointmentDC {Employee = item, ParticipationAnswer = ParticipationAnswer.Offen}).ToList()); - e.Appointment.CF_EmployeeList(n); + var employees2Appointments = new ObservableCollection(SelectedEmployees.Select(item => new Employee2SchedulerAppointmentDC {Employee = item, ParticipationAnswer = ParticipationAnswer.Offen}).ToList()); + e.Appointment.CF_EmployeeList(employees2Appointments); e.Appointment.CF_CustomerList(new List(SelectedCustomers)); e.Appointment.CF_ResourceList(new List(SelectedResources)); } var form = ViewModel.GetEditAppointmentForm(control, e.Appointment); - if(form == null) + if(form is null) { if(_IsNew) { @@ -1955,14 +1955,14 @@ namespace BeWo.Scheduler.View private void MeinTB_OnChecked(object sender, RoutedEventArgs e) { - var tb = (ToggleButton) sender; + var toggleButton = (ToggleButton) sender; - if(tb?.IsChecked == null) + if(toggleButton?.IsChecked is null) { return; } - if(!tb.IsChecked.Value) + if(!toggleButton.IsChecked.Value) { MitarbeiterSuchGrid.Visibility = Visibility.Collapsed; MitarbeiterSuchTextBox.Clear(); @@ -1976,14 +1976,14 @@ namespace BeWo.Scheduler.View private void MeinTB2_OnChecked(object sender, RoutedEventArgs e) { - var tb = (ToggleButton) sender; + var toggleButton = (ToggleButton) sender; - if(tb?.IsChecked == null) + if(toggleButton?.IsChecked is null) { return; } - if(!tb.IsChecked.Value) + if(!toggleButton.IsChecked.Value) { KlientenSuchGrid.Visibility = Visibility.Collapsed; KlientenSuchTextBox.Clear(); @@ -2021,12 +2021,21 @@ namespace BeWo.Scheduler.View _ReloadingViewModel = true; - if(ViewModel == null) + if(ViewModel is null) { _ReloadingViewModel = false; return; } + var stopwatch = new Stopwatch(); + stopwatch.Start(); +#if DEBUG + var stackTrace = new StackTrace(); + var callingMethodName = stackTrace.GetFrame(1).GetMethod().Name; + + BeWoApp.LogMessage(callingMethodName + "->ReloadVM"); +#endif + var range = Scheduler.ActiveView.GetVisibleIntervals(); var start = range.Start; var end = range.End; @@ -2051,10 +2060,11 @@ namespace BeWo.Scheduler.View _LastFetchedInterval = FetchingInterval; - ReloadAppointmentViewModel(start, end, selectedEmployeeOids, selectedCustomerOids, selectedResourceOids, employeesOnly, customersOnly, resourcesOnly, onlyPrivateAppointments, showOnlyMyAppointments, showAbsenceTimes); + ReloadAppointmentViewModel(start, end, selectedEmployeeOids, selectedCustomerOids, selectedResourceOids, employeesOnly, customersOnly, resourcesOnly, onlyPrivateAppointments, showOnlyMyAppointments, showAbsenceTimes, + delegate { this.Dispatch(() => { stopwatch.Stop(); BeWoApp.LogMessage($"Das Laden der Termine und Abwesenheiten dauerte {stopwatch.ElapsedMilliseconds}ms."); }); }); } - public void ReloadAppointmentViewModel(DateTime pIntervalStart, DateTime pIntervalEnd, List pSelectedEmployees, List pSelectedCustomer, List pSelectedResources, bool pEmployeesOnly, bool pCustomersOnly, bool pResourcesOnly, bool pPrivateAppointmentsOnly, bool pOnlyMyAppointments, bool pShouldShowAbsenceTimes) + public void ReloadAppointmentViewModel(DateTime pIntervalStart, DateTime pIntervalEnd, List pSelectedEmployees, List pSelectedCustomer, List pSelectedResources, bool pEmployeesOnly, bool pCustomersOnly, bool pResourcesOnly, bool pPrivateAppointmentsOnly, bool pOnlyMyAppointments, bool pShouldShowAbsenceTimes, Action callback = null) { ResetDeletionMode(); @@ -2086,7 +2096,7 @@ namespace BeWo.Scheduler.View { var prefilteredAppointments = appointments.Where(w => (w.EmployeeList.Count == 0 && w.Originator.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid) || w.EmployeeList.Count > 0 && w.EmployeeList.Any(a => a.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid)) || - BeWoUtils.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen)) && (!w.EmployeeList.TrueForAll(e2a => e2a.ParticipationAnswer == ParticipationAnswer.Absage) || w.EmployeeList == null || w.EmployeeList.Count == 0)).ToList(); + BeWoUtils.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen)) && (!w.EmployeeList.TrueForAll(e2a => e2a.ParticipationAnswer == ParticipationAnswer.Absage) || w.EmployeeList is null || w.EmployeeList.Count == 0)).ToList(); var anonymizedAppointments = appointments.Where(w => w.CanBeEdited == false && w.IsTask == false).ToList(); @@ -2121,9 +2131,9 @@ namespace BeWo.Scheduler.View SelectedCustomers = AllCustomers.Where(w => SelectedCustomers.Any(a => a.CustomerOid.Equals(w.CustomerOid))).ToList(); SelectedResources = AllResources.Where(w => SelectedResources.Any(a => a.ResourceOid.Equals(w.ResourceOid))).ToList(); - var items = SelectedItems; + //var items = SelectedItems; - var testtesttest = ViewModel.ActiveAppointmentViewModel; + //var testtesttest = ViewModel.ActiveAppointmentViewModel; _ReloadingViewModel = false; @@ -2165,6 +2175,8 @@ namespace BeWo.Scheduler.View _IsComingFromHomeDragPanel = false; } + + callback?.Invoke(); }); }); }); @@ -2183,7 +2195,9 @@ namespace BeWo.Scheduler.View var dialog = new SaveFileDialog {Filter = "iCalendar files (*.ics)|*.ics", FilterIndex = 1}; if(dialog.ShowDialog() != true) + { return; + } using(var stream = dialog.OpenFile()) { @@ -2193,11 +2207,14 @@ namespace BeWo.Scheduler.View private void ExportAppointmentsAs_iCal(Stream stream) { - if(stream == null) + if(stream is null) + { return; + } + try { - var productIdentifier = string.Format("-//{0}//DXScheduler iCalendarExchange Example//DE", BeWoApp.Mandator); + var productIdentifier = $"-//{BeWoApp.Mandator}//DXScheduler iCalendarExchange Example//DE"; var exporter = new iCalendarExporter(Scheduler.GetCoreStorage()) {ProductIdentifier = productIdentifier}; exporter.AppointmentExporting += OnAppointmentExporting; @@ -2205,7 +2222,7 @@ namespace BeWo.Scheduler.View } catch(Exception e) { - MessageBox.Show(string.Format("Der Kalender konnte leider nicht exportiert werden.\n{0}", e.Message), "Fehler beim Export", MessageBoxButton.OK, MessageBoxImage.Error); + MessageBox.Show($"Der Kalender konnte leider nicht exportiert werden.\n{e.Message}", "Fehler beim Export", MessageBoxButton.OK, MessageBoxImage.Error); } } @@ -2308,7 +2325,7 @@ namespace BeWo.Scheduler.View var neu = new List(); - foreach (var app in kollektionOhneAusnahmen.Where(w => !ausnahmen.Select(s => s.RecurrenceIndex).Contains(w.RecurrenceIndex))) + foreach(var app in kollektionOhneAusnahmen.Where(w => !ausnahmen.Select(s => s.RecurrenceIndex).Contains(w.RecurrenceIndex))) { var recurrenceId = app.RecurrenceInfo.Id.ToString(); @@ -2320,7 +2337,7 @@ namespace BeWo.Scheduler.View neu.AddIfNotIn(app); } - if (ausnahmen.Count > 0) + if(ausnahmen.Count > 0) { kollektionOhneAusnahmen = kollektionOhneAusnahmen.Where(w => !ausnahmen.Select(s => s.RecurrenceIndex).Contains(w.RecurrenceIndex)).ToList(); } @@ -2330,7 +2347,7 @@ namespace BeWo.Scheduler.View var recurrenceId = appointment.RecurrenceInfo.Id.ToString(); var recurrenceIndex = appointment.RecurrenceIndex; - if (!(appointment.IsOccurrence && deletedOccurrences.Any(a => a.RecurrenceIdReference == recurrenceId && a.RecurrenceIndexReference == recurrenceIndex))) + if(!(appointment.IsOccurrence && deletedOccurrences.Any(a => a.RecurrenceIdReference == recurrenceId && a.RecurrenceIndexReference == recurrenceIndex))) { serienTermine.AddIfNotIn(new SchedulerAppointmentDC { @@ -2400,14 +2417,16 @@ namespace BeWo.Scheduler.View public void PreselectCustomer(long pCustomerOid) { - if(AllCustomers.Any(c => c.CustomerOid.Equals(pCustomerOid))) + if(!AllCustomers.Any(c => c.CustomerOid.Equals(pCustomerOid))) { - SelectedCustomers = new List {AllCustomers.Find(f => f.CustomerOid.Equals(pCustomerOid))}; - - OnPropertyChanged(nameof(SelectedCustomers)); - OnPropertyChanged(nameof(SelectedItems)); - OnPropertyChanged(nameof(GefilterteKlienten)); + return; } + + SelectedCustomers = new List {AllCustomers.Find(f => f.CustomerOid.Equals(pCustomerOid))}; + + OnPropertyChanged(nameof(SelectedCustomers)); + OnPropertyChanged(nameof(SelectedItems)); + OnPropertyChanged(nameof(GefilterteKlienten)); } private void DateNavigator_OnSelectedDatesChanged(object sender, EventArgs e) @@ -2419,6 +2438,7 @@ namespace BeWo.Scheduler.View var selectedDates = navigator.SelectedDates; var isSelectedDateFetched = _LastFetchedInterval.ContainsEveryDateFromList(selectedDates); + if(!isSelectedDateFetched && !(_LastFetchedInterval.Start.Equals(new DateTime(1, 1, 1, 0, 0, 0)) && _LastFetchedInterval.End.Equals(new DateTime(1, 1, 1, 0, 30, 0)))) { ReloadVM(); @@ -2467,26 +2487,28 @@ namespace BeWo.Scheduler.View private void NurMeineTermineEinAusCheckBox_OnChecked(object sender, RoutedEventArgs e) { - var cb = (CheckBox) sender; + var checkBox = (CheckBox) sender; - if(CheckBoxConverter != null && BeWoApp.CompactLoggedOnEmployee != null) + if(CheckBoxConverter is null || BeWoApp.CompactLoggedOnEmployee is null) { - if(cb.IsChecked != null && cb.IsChecked.Value) - { - SelectedEmployees = new List {BeWoApp.CompactLoggedOnEmployee}; - CheckBoxConverter.AktuellerMitarbeiter = BeWoApp.CompactLoggedOnEmployee; - } - else if(cb.IsChecked != null && !cb.IsChecked.Value && SelectedEmployees.Count == 1) - { - SelectedEmployees.Remove(BeWoApp.CompactLoggedOnEmployee); - CheckBoxConverter.AktuellerMitarbeiter = null; - } - - OnPropertyChanged(nameof(SelectedEmployees)); - OnPropertyChanged(nameof(SelectedItems)); - - ReloadVM(true); + return; } + + if(checkBox.IsChecked != null && checkBox.IsChecked.Value) + { + SelectedEmployees = new List {BeWoApp.CompactLoggedOnEmployee}; + CheckBoxConverter.AktuellerMitarbeiter = BeWoApp.CompactLoggedOnEmployee; + } + else if(checkBox.IsChecked != null && !checkBox.IsChecked.Value && SelectedEmployees.Count == 1) + { + SelectedEmployees.Remove(BeWoApp.CompactLoggedOnEmployee); + CheckBoxConverter.AktuellerMitarbeiter = null; + } + + OnPropertyChanged(nameof(SelectedEmployees)); + OnPropertyChanged(nameof(SelectedItems)); + + ReloadVM(true); } private void AbwesenheitenEinAusCheckBox_OnChecked(object sender, RoutedEventArgs e) @@ -2529,15 +2551,17 @@ namespace BeWo.Scheduler.View private void Scheduler_OnInplaceEditorShowing(object sender, InplaceEditorEventArgs e) { - if(_IsNew) + if(!_IsNew) { - var n = new ObservableCollection(SelectedEmployees.Select(item => new Employee2SchedulerAppointmentDC {Employee = item, ParticipationAnswer = ParticipationAnswer.Offen}).ToList()); - e.Appointment.CF_EmployeeList(n); - e.Appointment.CF_CustomerList(new List(SelectedCustomers)); - e.Appointment.CF_ResourceList(new List(SelectedResources)); - - _IsNew = false; + return; } + + var n = new ObservableCollection(SelectedEmployees.Select(item => new Employee2SchedulerAppointmentDC {Employee = item, ParticipationAnswer = ParticipationAnswer.Offen}).ToList()); + e.Appointment.CF_EmployeeList(n); + e.Appointment.CF_CustomerList(new List(SelectedCustomers)); + e.Appointment.CF_ResourceList(new List(SelectedResources)); + + _IsNew = false; } private void ButtonDeleteAppointmentsInInterval_Click(object sender, RoutedEventArgs e) @@ -2633,14 +2657,14 @@ namespace BeWo.Scheduler.View var appointmentDC = appointmentVM?.CommitToDataContract(); - if(appointmentDC?.SchedulerAppointmentOid == null || appointmentDC.NewSchedulerAppointmentVersion == null || appointmentToRestore.Type != AppointmentType.ChangedOccurrence) + if(appointmentDC?.SchedulerAppointmentOid is null || appointmentDC.NewSchedulerAppointmentVersion is null || appointmentToRestore.Type != AppointmentType.ChangedOccurrence) { return; } ServiceFacade.DoResourceServiceAsync(s => s.GetSchedulerAppointmentByid(appointmentDC.SchedulerAppointmentOid.Value), appointment => { - if(appointment.SchedulerAppointmentOid == null || appointment.NewSchedulerAppointmentVersion == null) + if(appointment.SchedulerAppointmentOid is null || appointment.NewSchedulerAppointmentVersion is null) { return; } @@ -2671,8 +2695,8 @@ namespace BeWo.Scheduler.View private void ShowTasksCheckBox_OnClick(object sender, RoutedEventArgs e) { - var cb = (CheckBox) sender; - IsTasksVisible = cb.IsChecked ?? false; + var checkBox = (CheckBox) sender; + IsTasksVisible = checkBox.IsChecked ?? false; ReloadVM(true); } @@ -2712,15 +2736,15 @@ namespace BeWo.Scheduler.View { var storageAppointments = Scheduler.Storage.AppointmentStorage.Items.ToList(); - var sb = new StringBuilder(); - sb.Append("AppointmentStorage-Inhalt:\n"); + var stringBuilder = new StringBuilder(); + stringBuilder.Append("AppointmentStorage-Inhalt:\n"); foreach(var app in storageAppointments) { - sb.Append($"{app.Subject} {app.Start:dd.MM.yyyy HH:mm}-{app.End:dd.MM.yyyy HH:mm}\n"); + stringBuilder.Append($"{app.Subject} {app.Start:dd.MM.yyyy HH:mm}-{app.End:dd.MM.yyyy HH:mm}\n"); } - WriteToDebug(sb.ToString()); + WriteToDebug(stringBuilder.ToString()); } private void Scheduler_OnAppointmentDrop(object sender, AppointmentDragEventArgs e) @@ -2833,9 +2857,9 @@ namespace BeWo.Scheduler.View public static class ViewTypeConvert { - public static AppointmentViewType ToAppointmentViewType(SchedulerViewType svt) + public static AppointmentViewType ToAppointmentViewType(SchedulerViewType schedulerViewType) { - switch(svt) + switch(schedulerViewType) { case SchedulerViewType.Day: return AppointmentViewType.Day; @@ -2893,7 +2917,7 @@ namespace BeWo.Scheduler.View { var customFieldStorage = (CustomFieldStorage)customFields[nameof(CustomFieldStorage)]; - if (customFieldStorage != null && parameter != null && parameter.Equals("AlleRessourcen")) + if(customFieldStorage != null && parameter != null && parameter.Equals("AlleRessourcen")) { return customFieldStorage.ResourceList; } @@ -3155,7 +3179,7 @@ namespace BeWo.Scheduler.View { var customFields = (CustomFieldCollection) value; - if(customFields == null) + if(customFields is null) { return new SolidColorBrush(Color.FromRgb(192, 255, 208)); } @@ -3185,32 +3209,32 @@ namespace BeWo.Scheduler.View { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if(value is Employee2SchedulerAppointmentDC employee2SchedulerAppointment) + if(!(value is Employee2SchedulerAppointmentDC employee2SchedulerAppointment)) { - if (parameter != null && parameter.Equals("GibName")) - { - return employee2SchedulerAppointment.Employee.DetailDescription; - } - - var color = Color.FromRgb(255, 255, 255); - - switch (employee2SchedulerAppointment.ParticipationAnswer) - { - case ParticipationAnswer.Vorbehalt: - color = Color.FromRgb(185, 39, 217); - break; - case ParticipationAnswer.Zusage: - color = Color.FromRgb(72, 212, 78); - break; - case ParticipationAnswer.Absage: - color = Color.FromRgb(171, 0, 48); - break; - } - - return new SolidColorBrush(color); + return null; } - return null; + if(parameter != null && parameter.Equals("GibName")) + { + return employee2SchedulerAppointment.Employee.DetailDescription; + } + + var color = Color.FromRgb(255, 255, 255); + + switch(employee2SchedulerAppointment.ParticipationAnswer) + { + case ParticipationAnswer.Vorbehalt: + color = Color.FromRgb(185, 39, 217); + break; + case ParticipationAnswer.Zusage: + color = Color.FromRgb(72, 212, 78); + break; + case ParticipationAnswer.Absage: + color = Color.FromRgb(171, 0, 48); + break; + } + + return new SolidColorBrush(color); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) @@ -3223,19 +3247,13 @@ namespace BeWo.Scheduler.View { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (BeWoApp.AppSettings.ShowInfoButtonInCalender == true) - { - return Visibility.Visible; - } - else - return Visibility.Collapsed; + return BeWoApp.AppSettings.ShowInfoButtonInCalender ? Visibility.Visible : Visibility.Collapsed; } + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } - - #endregion } diff --git a/BeWo/View/Detail/DebugMessageLogView.xaml.cs b/BeWo/View/Detail/DebugMessageLogView.xaml.cs index 3b7fc7a6d..dd543e050 100644 --- a/BeWo/View/Detail/DebugMessageLogView.xaml.cs +++ b/BeWo/View/Detail/DebugMessageLogView.xaml.cs @@ -70,13 +70,13 @@ namespace BeWo.View.Detail public DebugWindowMessage(string messageText) { - MessageText = $"{DateTime.Now:dd.MM.yyyy HH:mm:ss}: {messageText}"; + MessageText = $"{DateTime.Now:dd.MM.yyyy HH:mm:ss.fff}: {messageText}"; CustomColor = Colors.Black; } public DebugWindowMessage(string messageText, Color customColor) { - MessageText = $"{DateTime.Now:dd.MM.yyyy HH:mm:ss}: {messageText}"; + MessageText = $"{DateTime.Now:dd.MM.yyyy HH:mm:ss.fff}: {messageText}"; CustomColor = customColor; } } diff --git a/BeWoPlanerMobil/BeWoPlanerMobil.csproj.user b/BeWoPlanerMobil/BeWoPlanerMobil.csproj.user index 6a59e7939..2763ebb1b 100644 --- a/BeWoPlanerMobil/BeWoPlanerMobil.csproj.user +++ b/BeWoPlanerMobil/BeWoPlanerMobil.csproj.user @@ -8,7 +8,7 @@ - Release|Any CPU + Debug|Any CPU ShowAllFiles 600 MvcControllerEmptyScaffolder @@ -28,7 +28,7 @@ - Views/Login/Index.cshtml + http://localhost/BeWoPlanerMobil/ CurrentPage True False diff --git a/BeWoPlanerMobil/Controllers/CustomerController.cs b/BeWoPlanerMobil/Controllers/CustomerController.cs index 5120670c5..914474f64 100644 --- a/BeWoPlanerMobil/Controllers/CustomerController.cs +++ b/BeWoPlanerMobil/Controllers/CustomerController.cs @@ -62,8 +62,6 @@ namespace BeWoPlanerMobil.Controllers { LoadCustomerToModel(id); } - - } catch (Exception e) { @@ -218,13 +216,16 @@ namespace BeWoPlanerMobil.Controllers Model.Report = null; - if(int.TryParse(formCollection["report-type-input"], out var selectedReportTypeInt)) + if(!int.TryParse(formCollection["report-type-input"], out var selectedReportTypeInt)) { - var selectedReportType = (CustomerReportType) selectedReportTypeInt; - - SelectReport(selectedReportType); + return RedirectToActionPermanent("Customer"); } + var selectedReportType = (CustomerReportType) selectedReportTypeInt; + + SelectReport(selectedReportType); + + //return RedirectToActionPermanent("Customer", Model); return RedirectToActionPermanent("Customer"); } @@ -235,6 +236,18 @@ namespace BeWoPlanerMobil.Controllers GenerateMobileMedListForSelectedCustomer(); } + public string SelectReportType(int reportType) + { + if(Model is null) + { + return "Die Auswahl des Berichts ist fehlgeschlagen. Bitte wenden Sie sich an den Administrator."; + } + + Model.SelectedReportType = (CustomerReportType) reportType; + + return LeerzeichenFuerGetMethoden; + } + public void GenerateMobileMedListForSelectedCustomer(long? selectedMedListOid = null) { if(Model.SelectedCustomerOid is null) @@ -373,6 +386,8 @@ namespace BeWoPlanerMobil.Controllers CustomerService.UpdateCustomer(customer); + LoadCustomerToModel(customer.CustomerOid); + return RedirectToActionPermanent("Customer", new { id = customer.CustomerOid }); } @@ -380,13 +395,15 @@ namespace BeWoPlanerMobil.Controllers [HttpPost] public ActionResult ViewMedListFromHistoryList(FormCollection formCollection) { - if(long.TryParse(formCollection["med-list-oid"], out var medListOid)) + if(!long.TryParse(formCollection["med-list-oid"], out var medListOid)) { - Model.SelectedReportType = CustomerReportType.Historie; - - GenerateMobileMedListForSelectedCustomer(medListOid); + return RedirectToActionPermanent("Customer"); } + Model.SelectedReportType = CustomerReportType.Historie; + + GenerateMobileMedListForSelectedCustomer(medListOid); + return RedirectToActionPermanent("Customer"); } @@ -394,13 +411,15 @@ namespace BeWoPlanerMobil.Controllers [HttpPost] public ActionResult DeleteMedListFromHistoryList(FormCollection formCollection) { - if(long.TryParse(formCollection["med-list-oid"], out var medListOid)) + if(!long.TryParse(formCollection["med-list-oid"], out var medListOid)) { - Model.SelectedReportType = CustomerReportType.Historie; - - CustomerService.DeleteMedikamentenverordnungsliste(medListOid); + return RedirectToActionPermanent("Customer"); } + Model.SelectedReportType = CustomerReportType.Historie; + + CustomerService.DeleteMedikamentenverordnungsliste(medListOid); + return RedirectToActionPermanent("Customer"); } diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index 3f4b3b344..8c1d3da42 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -3950,6 +3950,12 @@ namespace BeWoPlanerMobil.Controllers return RedirectToActionPermanent("Main"); } + + [Authorize] + public string ProvokeJsonError() + { + return "\r\n\r\n \r\n \r\n \r\n \r\n HTML 5 Boilerplate\r\n \r\n \r\n \r\n\t\r\n \r\n"; + } } public class ServiceRecord2Monatsunterschrift diff --git a/BeWoPlanerMobil/Controllers/ReportController.cs b/BeWoPlanerMobil/Controllers/ReportController.cs index 2d5b6019e..8b694313c 100644 --- a/BeWoPlanerMobil/Controllers/ReportController.cs +++ b/BeWoPlanerMobil/Controllers/ReportController.cs @@ -14,6 +14,8 @@ using System.Linq; using System.Text; using System.Web.Mvc; using BeWo.Service.Plugins; +using DevExpress.Mvvm.Native; +using NHibernate.Util; namespace BeWoPlanerMobil.Controllers { @@ -1266,15 +1268,76 @@ namespace BeWoPlanerMobil.Controllers var endDate = Model.SelectedEndDay ?? date.GetLastOfMonth().Day; var filterType = Model.SelectedFilterItem; - Model.QuittierungsbelegsReportObject = Model.ReportCreator.CreateServiceOverviewReportNew(month, year, filterType.FilterEnum, customerOid, teamOid, employeeOid, organisationOid, serviceCategoryOid, startDate, endDate, false); + var report = Model.ReportCreator.CreateServiceOverviewReportNew(month, year, filterType.FilterEnum, customerOid, teamOid, employeeOid, organisationOid, serviceCategoryOid, startDate, endDate, false); - //var employeeOid = Model.Employee.EmployeeOid; - //var report = Model.ReportCreator.CreateEmployeeHourReport(employeeOid, null, new DateTime(2023, 10, 1), new DateTime(2023, 10, 31), 0); + report.ExportOptions.PrintPreview.DefaultFileName = CreateFileName(); + report.DisplayName = CreateFileName(); - //Model.QuittierungsbelegsReportObject = report; + Model.QuittierungsbelegsReportObject = report; return RedirectToActionPermanent("InitReports"); } + + private string CreateFileName() + { + // Quittierungsbeleg_AlleKlienten_Jetten-Lyndon_LWL_Oktober-01-15-2023.pdf + var fileName = "Quittierungsbeleg_"; + + var selectedFilter = Model.SelectedFilterItem.FilterEnum; + var filterText = string.Empty; + switch(selectedFilter) + { + case QBFilterEnum.AlleKlienten: + filterText = "AlleKlienten"; + break; + case QBFilterEnum.NurKlientenMeinesTeams: + filterText = "KlientenMeinerTeams"; + break; + case QBFilterEnum.MeineKlienten: + filterText = "MeineKlienten"; + break; + case QBFilterEnum.KlientenAuswahl: + filterText = "KlientenAuswahl"; + break; + case QBFilterEnum.TeamAuswahl: + filterText = "TeamAuswahl"; + break; + } + + fileName += $"{filterText}_"; + + if(Model.IsForSelectedEmployeesOnly) + { + var selectedEmployee = Model.SelectedEmployee; + var employeeName = $"{selectedEmployee.LastName}-{selectedEmployee.FirstName}_"; + + fileName += $"{employeeName}_"; + } + + if(Model.IsForSelectedCostbearersOnly) + { + var selectedCostbearer = Model.SelectedOrganisation; + fileName += $"{selectedCostbearer.Name}_"; + } + + if(Model.IsForSelectedCategoryOnly) + { + var selectedServiceCategory = Model.SelectedServiceCategory; + fileName += $"{selectedServiceCategory.Name}_"; + } + + if(!Model.SelectedMonth.HasValue || !Model.SelectedYear.HasValue || !Model.SelectedStartDay.HasValue || !Model.SelectedEndDay.HasValue) + { + return fileName; + } + + var start = new DateTime(Model.SelectedYear.Value, Model.SelectedMonth.Value, Model.SelectedStartDay.Value); + var end = new DateTime(Model.SelectedYear.Value, Model.SelectedMonth.Value, Model.SelectedEndDay.Value); + + fileName += $"{start:MMMM}-{start:dd}-{end:dd}-{start:yyyy}"; + + return fileName; + } } public class ConfirmationReceiptSignatureObject diff --git a/BeWoPlanerMobil/Views/Customer/Customer.cshtml b/BeWoPlanerMobil/Views/Customer/Customer.cshtml index ece606f63..57ae27d73 100644 --- a/BeWoPlanerMobil/Views/Customer/Customer.cshtml +++ b/BeWoPlanerMobil/Views/Customer/Customer.cshtml @@ -1,4 +1,5 @@ -@using BeWoPlanerMobil.Models; +@using BeWoPlanerMobil.Controllers +@using BeWoPlanerMobil.Models; @using BeWoPlanerMobil.Util @using BS.Shared @@ -105,6 +106,11 @@ var historyList = $("#med-list-history-list"); $("#show-med-list-btn").prop("disabled", selectedReportType === "2"); + $.get("@Url.Action("SelectReportType")", {reportType: selectedReportType}).success(function(result) { + if(result.length > 1) { + showErrorMessagePopup(result); + } + }); if (selectedReportType !== "2") { historyList.hide(); @@ -175,7 +181,7 @@ var inputDisabled = !AbstractModel.HasRightToEditCustomers ? "disabled" : string.Empty;
-
+
@@ -255,7 +261,7 @@
-
+
@@ -312,7 +318,7 @@
-
+
@@ -369,7 +375,7 @@
-
+
@@ -432,7 +438,7 @@
@@ -772,12 +778,17 @@ @Html.DropDownListFor(m => m.SelectedReportType, Model.ReportTypeItems, new { @class = "custom-select", id = "report-type-select", onchange = "changeReportTypeSelection()" })
- + @{ + var showReportBtnDisabledValue = Model.SelectedReportType == CustomerReportType.Historie ? "disabled" : string.Empty; + } +
@if(!(Model.SelectedCustomer is null)) { - + var displayValue = Model.SelectedReportType == CustomerReportType.Historie ? string.Empty : "d-none"; + +
@@ -1046,7 +1057,7 @@ @if(!(Model?.Report is null) && Html.IsInDebugMode()) {