diff --git a/ReportImp/LebenshilfeBadKreuznachFUD/Statistics/CustomServiceRecordStatisticFactory.cs b/ReportImp/LebenshilfeBadKreuznachFUD/Statistics/CustomServiceRecordStatisticFactory.cs index bd3b07c4b..b251bae69 100644 --- a/ReportImp/LebenshilfeBadKreuznachFUD/Statistics/CustomServiceRecordStatisticFactory.cs +++ b/ReportImp/LebenshilfeBadKreuznachFUD/Statistics/CustomServiceRecordStatisticFactory.cs @@ -38,6 +38,15 @@ namespace LebenshilfeBadKreuznachFUD.Statistics } public override ServiceRecordStatisticsInfoDC GetServiceRecordStatisticInfo(long costBearer2SupportConceptOid, DateTime statisticsDate) { + var appSettings = BeWo.Service.Configuration.AppSettings.GetUserAppSettings(); + + if (appSettings.LastSelectedServiceRecordTimeInterval == ServiceRecordTimeInterval.Monatsauswahl) + { + var selectedMonth = appSettings.LastSelectedServiceRecordMonth; + statisticsDate = selectedMonth.AddMonths(1).AddDays(-1); + } + + var stats = CreateSupportConceptStatisticsImpl(costBearer2SupportConceptOid, statisticsDate); int rowCount = 4; diff --git a/Service/Configuration/AppSettings.cs b/Service/Configuration/AppSettings.cs index e331291a3..038ebbb7e 100644 --- a/Service/Configuration/AppSettings.cs +++ b/Service/Configuration/AppSettings.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using BeWo.Data.Access; using BeWo.Data.Entities; +using BeWo.Data.Security; +using BeWo.Service.DCEntityMapper; using BS.Shared; using BS.Shared.Core; @@ -76,6 +78,11 @@ namespace BeWo.Service.Configuration public DateTime? StartStundenkonto { get; set; } + public ServiceRecordTimeInterval LastSelectedServiceRecordTimeInterval { get; set; } = ServiceRecordTimeInterval.All; + public int LastSelectedServiceRecordTimeIntervalDays { get; set; } = 7; + public DateTime LastSelectedServiceRecordMonth { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); + + public static AppSettings CreateSettings() { @@ -313,11 +320,43 @@ namespace BeWo.Service.Configuration settings.ShowAdditionalService = showAdditionalService; settings.ShowRoundedDurationInEmployeeAnalysis = showRoundedDurationInEmployeeAnalysis; settings.SortServiceDescriptionAlphabetically = sortServiceDescriptionAlphabetically; - + return settings; } - public static Mandator GetMandatorEntity() + public static AppSettings GetUserAppSettings() + { + AppSettings settings = new AppSettings(); + var user = UserRightHelper.GetLoggedInUser(); + if (user != null) + { + var settingsList = MapperFactory.SettingsDC_Settings.MapToNewDCs(user.SettingList); + + var val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, SettingsKeys.LastSelectedServiceRecordTimeInterval, settingsList); + if (int.TryParse(val, out var result)) + { + settings.LastSelectedServiceRecordTimeInterval = (ServiceRecordTimeInterval)result; + } + + + val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, SettingsKeys.LastSelectedServiceRecordTimeIntervalDays, settingsList); + if (val != null) + { + settings.LastSelectedServiceRecordTimeIntervalDays = Convert.ToInt32(UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, SettingsKeys.LastSelectedServiceRecordTimeIntervalDays, settingsList)); + } + + val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, SettingsKeys.LastSelectedServiceRecordMonth, settingsList); + if (val != null) + { + settings.LastSelectedServiceRecordMonth = Convert.ToDateTime(UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, SettingsKeys.LastSelectedServiceRecordMonth, settingsList)); + } + } + + return settings; + + } + + public static Mandator GetMandatorEntity() { var manList = DAOFactory.GenericDAO.GetAll(); Mandator man; diff --git a/Shared/Core/SettingsKeys.cs b/Shared/Core/SettingsKeys.cs index 1af09092f..33d1df25d 100644 --- a/Shared/Core/SettingsKeys.cs +++ b/Shared/Core/SettingsKeys.cs @@ -42,6 +42,7 @@ namespace BS.Shared.Core public static string ShowServiceRecordGridControl => "ShowServiceRecordGridControl"; public static string StartupPanelMaximized => "StartupPanelMaximized"; public static string HideServiceRecordInsertedByAndInsertedOn => "HideServiceRecordInsertedByAndInsertedOn"; + public static string ShowAlwaysHoursInEmployeeView => "ShowAlwaysHoursInEmployeeView"; public static string DocumentationFontSize => "DocumentationFontSize"; public static string ZeigeNurMeineTermine => "ZeigeNurMeineTermine"; public static string LastSelectedServiceRecordTimeIntervalDays => "LastSelectedServiceRecordTimeIntervalDays";