From d0b8c437e54d9f4e85ec47397c180192e91d15e2 Mon Sep 17 00:00:00 2001 From: Kojo Date: Wed, 11 Jun 2025 13:22:10 +0200 Subject: [PATCH 01/27] =?UTF-8?q?VacationService:=20Pfingstferien=202025?= =?UTF-8?q?=20f=C3=BCr=20NRW=20korrigiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/Plugins/VacationService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Service/Plugins/VacationService.cs b/Service/Plugins/VacationService.cs index 94e1a950b..1e68ced26 100644 --- a/Service/Plugins/VacationService.cs +++ b/Service/Plugins/VacationService.cs @@ -222,7 +222,7 @@ namespace BeWo.Service.Plugins list.Add(new FerienDC() { Name = "Weihnachtsferien 2024", Start = new DateTime(2024, 12, 23), Ende = new DateTime(2025, 1, 6) }); list.Add(new FerienDC() { Name = "Osterferien 2025", Start = new DateTime(2025, 4, 14), Ende = new DateTime(2025, 4, 26) }); - list.Add(new FerienDC() { Name = "Pfingstferien 2025", Start = new DateTime(2025, 6, 10), Ende = new DateTime(2024, 6, 10) }); + list.Add(new FerienDC() { Name = "Pfingstferien 2025", Start = new DateTime(2025, 6, 10), Ende = new DateTime(2025, 6, 10) }); list.Add(new FerienDC() { Name = "Sommerferien 2025", Start = new DateTime(2025, 7, 14), Ende = new DateTime(2025, 8, 26) }); list.Add(new FerienDC() { Name = "Herbstferien 2025", Start = new DateTime(2025, 10, 13), Ende = new DateTime(2025, 10, 25) }); list.Add(new FerienDC() { Name = "Weihnachtsferien 2025", Start = new DateTime(2025, 12, 22), Ende = new DateTime(2026, 1, 6) }); From 27631533c8a2dd5c86bbb9e2279a676373f5f165 Mon Sep 17 00:00:00 2001 From: HirschleM Date: Wed, 11 Jun 2025 14:30:21 +0200 Subject: [PATCH 02/27] =?UTF-8?q?MH:=20Drogenhilfe=20PUR=20Hilfepl=C3=A4ne?= =?UTF-8?q?=20Listendruck=20gefixt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReportImp/PURReports/PSBServicesOverview.cs | 2 ++ ReportImp/PURReports/Properties/licenses.licx | 1 + 2 files changed, 3 insertions(+) diff --git a/ReportImp/PURReports/PSBServicesOverview.cs b/ReportImp/PURReports/PSBServicesOverview.cs index a90c3ff2a..0ce4fdd26 100644 --- a/ReportImp/PURReports/PSBServicesOverview.cs +++ b/ReportImp/PURReports/PSBServicesOverview.cs @@ -8,9 +8,11 @@ using BeWo.Data.Access; using BeWo.Data.Entities; using BeWo.Report; using BeWo.Report.ReportObjects; +using BS.Shared.Core; namespace PURReports { + [IDSpecificClass(Identifier = "PSBServicesOverview")] public partial class PSBServicesOverview : DevExpress.XtraReports.UI.XtraReport, IBeWoReport { private DevExpress.XtraReports.UI.TopMarginBand topMarginBand1; diff --git a/ReportImp/PURReports/Properties/licenses.licx b/ReportImp/PURReports/Properties/licenses.licx index e69de29bb..d59547a61 100644 --- a/ReportImp/PURReports/Properties/licenses.licx +++ b/ReportImp/PURReports/Properties/licenses.licx @@ -0,0 +1 @@ +DevExpress.XtraReports.UI.XtraReport, DevExpress.XtraReports.v23.2, Version=23.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a From cc0e41202de5a73bacfa02f6139c70cd2654aa41 Mon Sep 17 00:00:00 2001 From: HirschleM Date: Wed, 11 Jun 2025 15:16:19 +0200 Subject: [PATCH 03/27] MH: Assistenza FLSReport Leistung --- .../FLSGroupReport.Designer.cs | 340 ++++++++++-------- 1 file changed, 187 insertions(+), 153 deletions(-) diff --git a/ReportImp/AssistenzaReports/FLSGroupReport.Designer.cs b/ReportImp/AssistenzaReports/FLSGroupReport.Designer.cs index 026c1816e..84123c49c 100644 --- a/ReportImp/AssistenzaReports/FLSGroupReport.Designer.cs +++ b/ReportImp/AssistenzaReports/FLSGroupReport.Designer.cs @@ -36,6 +36,14 @@ namespace BeWo.AssistenzaReports this.xrTableRow1 = new DevExpress.XtraReports.UI.XRTableRow(); this.xrTable1 = new DevExpress.XtraReports.UI.XRTable(); this.Detail1 = new DevExpress.XtraReports.UI.DetailBand(); + this.xrLabel20 = new DevExpress.XtraReports.UI.XRLabel(); + this.xrLabel21 = new DevExpress.XtraReports.UI.XRLabel(); + this.xrLabel22 = new DevExpress.XtraReports.UI.XRLabel(); + this.xrLabel19 = new DevExpress.XtraReports.UI.XRLabel(); + this.xrLabel15 = new DevExpress.XtraReports.UI.XRLabel(); + this.xrLabel16 = new DevExpress.XtraReports.UI.XRLabel(); + this.xrLabel17 = new DevExpress.XtraReports.UI.XRLabel(); + this.xrLabel18 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel13 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel12 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel11 = new DevExpress.XtraReports.UI.XRLabel(); @@ -43,6 +51,10 @@ namespace BeWo.AssistenzaReports this.DetailReport = new DevExpress.XtraReports.UI.DetailReportBand(); this.DetailReport1 = new DevExpress.XtraReports.UI.DetailReportBand(); this.Detail2 = new DevExpress.XtraReports.UI.DetailBand(); + this.xrLabel24 = new DevExpress.XtraReports.UI.XRLabel(); + this.TextFLS = new DevExpress.XtraReports.UI.FormattingRule(); + this.xrLabel23 = new DevExpress.XtraReports.UI.XRLabel(); + this.TextStunden = new DevExpress.XtraReports.UI.FormattingRule(); this.xrLabel14 = new DevExpress.XtraReports.UI.XRLabel(); this.lblAufteilungLeistungen = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel8 = new DevExpress.XtraReports.UI.XRLabel(); @@ -85,18 +97,8 @@ namespace BeWo.AssistenzaReports this.fieldGroupFLS = new DevExpress.XtraReports.UI.CalculatedField(); this.topMarginBand1 = new DevExpress.XtraReports.UI.TopMarginBand(); this.bottomMarginBand1 = new DevExpress.XtraReports.UI.BottomMarginBand(); - this.xrLabel15 = new DevExpress.XtraReports.UI.XRLabel(); - this.xrLabel16 = new DevExpress.XtraReports.UI.XRLabel(); - this.xrLabel17 = new DevExpress.XtraReports.UI.XRLabel(); - this.xrLabel18 = new DevExpress.XtraReports.UI.XRLabel(); - this.xrLabel19 = new DevExpress.XtraReports.UI.XRLabel(); - this.xrLabel20 = new DevExpress.XtraReports.UI.XRLabel(); - this.xrLabel21 = new DevExpress.XtraReports.UI.XRLabel(); - this.xrLabel22 = new DevExpress.XtraReports.UI.XRLabel(); - this.TextStunden = new DevExpress.XtraReports.UI.FormattingRule(); - this.xrLabel23 = new DevExpress.XtraReports.UI.XRLabel(); - this.xrLabel24 = new DevExpress.XtraReports.UI.XRLabel(); - this.TextFLS = new DevExpress.XtraReports.UI.FormattingRule(); + this.xrTableCell11 = new DevExpress.XtraReports.UI.XRTableCell(); + this.xrTableCell12 = new DevExpress.XtraReports.UI.XRTableCell(); this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); ((System.ComponentModel.ISupportInitialize)(this.xrTable1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable3)).BeginInit(); @@ -166,6 +168,104 @@ namespace BeWo.AssistenzaReports this.Detail1.Name = "Detail1"; this.Detail1.StylePriority.UseFont = false; // + // xrLabel20 + // + this.xrLabel20.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { + new DevExpress.XtraReports.UI.XRBinding("Text", null, "FLSReportGroups.CustomValue3", "{0:0.##}")}); + this.xrLabel20.Font = new DevExpress.Drawing.DXFont("Arial", 10F); + this.xrLabel20.LocationFloat = new DevExpress.Utils.PointFloat(160F, 97.58164F); + this.xrLabel20.Name = "xrLabel20"; + this.xrLabel20.SizeF = new System.Drawing.SizeF(50F, 19.79166F); + this.xrLabel20.StylePriority.UseFont = false; + this.xrLabel20.StylePriority.UsePadding = false; + this.xrLabel20.StylePriority.UseTextAlignment = false; + this.xrLabel20.Text = "xrLabel13"; + this.xrLabel20.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft; + // + // xrLabel21 + // + this.xrLabel21.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { + new DevExpress.XtraReports.UI.XRBinding("Text", null, "FLSReportGroups.CustomValue4")}); + this.xrLabel21.Font = new DevExpress.Drawing.DXFont("Arial", 10F); + this.xrLabel21.LocationFloat = new DevExpress.Utils.PointFloat(280F, 97.58164F); + this.xrLabel21.Name = "xrLabel21"; + this.xrLabel21.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel21.SizeF = new System.Drawing.SizeF(203F, 19.79166F); + this.xrLabel21.StylePriority.UseFont = false; + this.xrLabel21.Text = "xrLabel11"; + this.xrLabel21.TextFormatString = "{0:0} Stunden"; + // + // xrLabel22 + // + this.xrLabel22.Font = new DevExpress.Drawing.DXFont("Arial", 10F); + this.xrLabel22.LocationFloat = new DevExpress.Utils.PointFloat(210F, 97.58164F); + this.xrLabel22.Name = "xrLabel22"; + this.xrLabel22.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel22.SizeF = new System.Drawing.SizeF(70F, 19.79166F); + this.xrLabel22.StylePriority.UseFont = false; + this.xrLabel22.StylePriority.UseTextAlignment = false; + this.xrLabel22.Text = "entspricht"; + this.xrLabel22.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; + // + // xrLabel19 + // + this.xrLabel19.Font = new DevExpress.Drawing.DXFont("Arial", 10F); + this.xrLabel19.LocationFloat = new DevExpress.Utils.PointFloat(0F, 97.58167F); + this.xrLabel19.Name = "xrLabel19"; + this.xrLabel19.SizeF = new System.Drawing.SizeF(140.8333F, 19.79166F); + this.xrLabel19.StylePriority.UseFont = false; + this.xrLabel19.StylePriority.UsePadding = false; + this.xrLabel19.Text = "davon indirekt:"; + // + // xrLabel15 + // + this.xrLabel15.Font = new DevExpress.Drawing.DXFont("Arial", 10F); + this.xrLabel15.LocationFloat = new DevExpress.Utils.PointFloat(210F, 77.78998F); + this.xrLabel15.Name = "xrLabel15"; + this.xrLabel15.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel15.SizeF = new System.Drawing.SizeF(70F, 19.79166F); + this.xrLabel15.StylePriority.UseFont = false; + this.xrLabel15.StylePriority.UseTextAlignment = false; + this.xrLabel15.Text = "entspricht"; + this.xrLabel15.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; + // + // xrLabel16 + // + this.xrLabel16.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { + new DevExpress.XtraReports.UI.XRBinding("Text", null, "FLSReportGroups.CustomValue2")}); + this.xrLabel16.Font = new DevExpress.Drawing.DXFont("Arial", 10F); + this.xrLabel16.LocationFloat = new DevExpress.Utils.PointFloat(280F, 77.78998F); + this.xrLabel16.Name = "xrLabel16"; + this.xrLabel16.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel16.SizeF = new System.Drawing.SizeF(203F, 19.79166F); + this.xrLabel16.StylePriority.UseFont = false; + this.xrLabel16.Text = "xrLabel11"; + this.xrLabel16.TextFormatString = "{0:0} FLS"; + // + // xrLabel17 + // + this.xrLabel17.Font = new DevExpress.Drawing.DXFont("Arial", 10F); + this.xrLabel17.LocationFloat = new DevExpress.Utils.PointFloat(0F, 77.79001F); + this.xrLabel17.Name = "xrLabel17"; + this.xrLabel17.SizeF = new System.Drawing.SizeF(140.8333F, 19.79166F); + this.xrLabel17.StylePriority.UseFont = false; + this.xrLabel17.StylePriority.UsePadding = false; + this.xrLabel17.Text = "davon abrechenbar:"; + // + // xrLabel18 + // + this.xrLabel18.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { + new DevExpress.XtraReports.UI.XRBinding("Text", null, "FLSReportGroups.CustomValue1", "{0:0.##}")}); + this.xrLabel18.Font = new DevExpress.Drawing.DXFont("Arial", 10F); + this.xrLabel18.LocationFloat = new DevExpress.Utils.PointFloat(160F, 77.78998F); + this.xrLabel18.Name = "xrLabel18"; + this.xrLabel18.SizeF = new System.Drawing.SizeF(50F, 19.79166F); + this.xrLabel18.StylePriority.UseFont = false; + this.xrLabel18.StylePriority.UsePadding = false; + this.xrLabel18.StylePriority.UseTextAlignment = false; + this.xrLabel18.Text = "xrLabel13"; + this.xrLabel18.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft; + // // xrLabel13 // this.xrLabel13.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { @@ -253,18 +353,59 @@ namespace BeWo.AssistenzaReports this.Detail2.KeepTogetherWithDetailReports = true; this.Detail2.Name = "Detail2"; // + // xrLabel24 + // + this.xrLabel24.Font = new DevExpress.Drawing.DXFont("Arial", 10F); + this.xrLabel24.FormattingRules.Add(this.TextFLS); + this.xrLabel24.LocationFloat = new DevExpress.Utils.PointFloat(320F, 50F); + this.xrLabel24.Name = "xrLabel24"; + this.xrLabel24.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel24.SizeF = new System.Drawing.SizeF(70.70834F, 25F); + this.xrLabel24.StylePriority.UseFont = false; + this.xrLabel24.Text = "FLS"; + this.xrLabel24.Visible = false; + // + // TextFLS + // + this.TextFLS.Condition = "[Name] != \'Indirekte Leistungen\'"; + this.TextFLS.DataMember = "FLSReportGroups.FLSReportDetails"; + this.TextFLS.Formatting.Visible = DevExpress.Utils.DefaultBoolean.True; + this.TextFLS.Name = "TextFLS"; + // + // xrLabel23 + // + this.xrLabel23.Font = new DevExpress.Drawing.DXFont("Arial", 10F); + this.xrLabel23.FormattingRules.Add(this.TextStunden); + this.xrLabel23.LocationFloat = new DevExpress.Utils.PointFloat(320F, 50F); + this.xrLabel23.Name = "xrLabel23"; + this.xrLabel23.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel23.SizeF = new System.Drawing.SizeF(107.75F, 25F); + this.xrLabel23.StylePriority.UseFont = false; + this.xrLabel23.Text = "Stunden"; + this.xrLabel23.Visible = false; + // + // TextStunden + // + this.TextStunden.Condition = "[Name] == \'Indirekte Leistungen\'"; + this.TextStunden.DataMember = "FLSReportGroups.FLSReportDetails"; + this.TextStunden.Formatting.Visible = DevExpress.Utils.DefaultBoolean.True; + this.TextStunden.Name = "TextStunden"; + // // xrLabel14 // this.xrLabel14.CanShrink = true; this.xrLabel14.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "FLSReportGroups.FLSReportDetails.CustomValue2")}); this.xrLabel14.Font = new DevExpress.Drawing.DXFont("Arial", 10F); - this.xrLabel14.LocationFloat = new DevExpress.Utils.PointFloat(160F, 75F); + this.xrLabel14.LocationFloat = new DevExpress.Utils.PointFloat(210F, 76.3333F); this.xrLabel14.Multiline = true; this.xrLabel14.Name = "xrLabel14"; - this.xrLabel14.SizeF = new System.Drawing.SizeF(160F, 25F); + this.xrLabel14.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 100F); + this.xrLabel14.SizeF = new System.Drawing.SizeF(70.00003F, 25F); this.xrLabel14.StylePriority.UseFont = false; this.xrLabel14.StylePriority.UsePadding = false; + this.xrLabel14.StylePriority.UseTextAlignment = false; + this.xrLabel14.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; // // lblAufteilungLeistungen // @@ -275,7 +416,7 @@ namespace BeWo.AssistenzaReports this.lblAufteilungLeistungen.LocationFloat = new DevExpress.Utils.PointFloat(0F, 75F); this.lblAufteilungLeistungen.Multiline = true; this.lblAufteilungLeistungen.Name = "lblAufteilungLeistungen"; - this.lblAufteilungLeistungen.SizeF = new System.Drawing.SizeF(160F, 25F); + this.lblAufteilungLeistungen.SizeF = new System.Drawing.SizeF(210F, 25F); this.lblAufteilungLeistungen.StylePriority.UseFont = false; this.lblAufteilungLeistungen.StylePriority.UsePadding = false; // @@ -384,7 +525,7 @@ namespace BeWo.AssistenzaReports this.xrTable4.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); this.xrTable4.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.xrTableRow4}); - this.xrTable4.SizeF = new System.Drawing.SizeF(645.2084F, 25F); + this.xrTable4.SizeF = new System.Drawing.SizeF(677F, 25F); this.xrTable4.StylePriority.UseBorders = false; this.xrTable4.StylePriority.UsePadding = false; // @@ -394,6 +535,7 @@ namespace BeWo.AssistenzaReports this.xrTableCell3, this.xrTableCell4, this.xrTableCell9, + this.xrTableCell12, this.xrTableCell10}); this.xrTableRow4.Name = "xrTableRow4"; this.xrTableRow4.Weight = 1D; @@ -416,7 +558,7 @@ namespace BeWo.AssistenzaReports this.xrTableCell4.Name = "xrTableCell4"; this.xrTableCell4.StylePriority.UseFont = false; this.xrTableCell4.Text = "xrTableCell4"; - this.xrTableCell4.Weight = 1.5351406935500007D; + this.xrTableCell4.Weight = 1.2011096977378757D; // // xrTableCell9 // @@ -430,7 +572,7 @@ namespace BeWo.AssistenzaReports this.xrTableCell9.StylePriority.UseTextAlignment = false; this.xrTableCell9.Text = "xrTableCell9"; this.xrTableCell9.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; - this.xrTableCell9.Weight = 1.2281126927809249D; + this.xrTableCell9.Weight = 0.80974157332799979D; // // xrTableCell10 // @@ -459,7 +601,7 @@ namespace BeWo.AssistenzaReports this.xrTable2.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 0, 0, 0, 100F); this.xrTable2.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { this.xrTableRow2}); - this.xrTable2.SizeF = new System.Drawing.SizeF(645.2084F, 25F); + this.xrTable2.SizeF = new System.Drawing.SizeF(677F, 25F); this.xrTable2.StylePriority.UseBorders = false; this.xrTable2.StylePriority.UseFont = false; this.xrTable2.StylePriority.UsePadding = false; @@ -470,6 +612,7 @@ namespace BeWo.AssistenzaReports this.xrTableCell5, this.xrTableCell6, this.xrTableCell7, + this.xrTableCell11, this.xrTableCell8}); this.xrTableRow2.Name = "xrTableRow2"; this.xrTableRow2.Weight = 1D; @@ -484,7 +627,7 @@ namespace BeWo.AssistenzaReports // this.xrTableCell6.Name = "xrTableCell6"; this.xrTableCell6.Text = "Uhrzeit"; - this.xrTableCell6.Weight = 2.5482014884439645D; + this.xrTableCell6.Weight = 1.9937381428350172D; // // xrTableCell7 // @@ -494,7 +637,7 @@ namespace BeWo.AssistenzaReports this.xrTableCell7.StylePriority.UseTextAlignment = false; this.xrTableCell7.Text = "Minuten"; this.xrTableCell7.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; - this.xrTableCell7.Weight = 2.0385611475733261D; + this.xrTableCell7.Weight = 1.3441004785659614D; // // xrTableCell8 // @@ -673,141 +816,30 @@ namespace BeWo.AssistenzaReports this.bottomMarginBand1.HeightF = 50F; this.bottomMarginBand1.Name = "bottomMarginBand1"; // - // xrLabel15 + // xrTableCell11 // - this.xrLabel15.Font = new DevExpress.Drawing.DXFont("Arial", 10F); - this.xrLabel15.LocationFloat = new DevExpress.Utils.PointFloat(210F, 77.78998F); - this.xrLabel15.Name = "xrLabel15"; - this.xrLabel15.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel15.SizeF = new System.Drawing.SizeF(70F, 19.79166F); - this.xrLabel15.StylePriority.UseFont = false; - this.xrLabel15.StylePriority.UseTextAlignment = false; - this.xrLabel15.Text = "entspricht"; - this.xrLabel15.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; + this.xrTableCell11.Multiline = true; + this.xrTableCell11.Name = "xrTableCell11"; + this.xrTableCell11.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 100F); + this.xrTableCell11.StylePriority.UsePadding = false; + this.xrTableCell11.StylePriority.UseTextAlignment = false; + this.xrTableCell11.Text = "Leistung"; + this.xrTableCell11.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft; + this.xrTableCell11.Weight = 3.2874851621896379D; // - // xrLabel16 + // xrTableCell12 // - this.xrLabel16.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { - new DevExpress.XtraReports.UI.XRBinding("Text", null, "FLSReportGroups.CustomValue2")}); - this.xrLabel16.Font = new DevExpress.Drawing.DXFont("Arial", 10F); - this.xrLabel16.LocationFloat = new DevExpress.Utils.PointFloat(280F, 77.78998F); - this.xrLabel16.Name = "xrLabel16"; - this.xrLabel16.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel16.SizeF = new System.Drawing.SizeF(203F, 19.79166F); - this.xrLabel16.StylePriority.UseFont = false; - this.xrLabel16.Text = "xrLabel11"; - this.xrLabel16.TextFormatString = "{0:0} FLS"; - // - // xrLabel17 - // - this.xrLabel17.Font = new DevExpress.Drawing.DXFont("Arial", 10F); - this.xrLabel17.LocationFloat = new DevExpress.Utils.PointFloat(0F, 77.79001F); - this.xrLabel17.Name = "xrLabel17"; - this.xrLabel17.SizeF = new System.Drawing.SizeF(140.8333F, 19.79166F); - this.xrLabel17.StylePriority.UseFont = false; - this.xrLabel17.StylePriority.UsePadding = false; - this.xrLabel17.Text = "davon abrechenbar:"; - // - // xrLabel18 - // - this.xrLabel18.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { - new DevExpress.XtraReports.UI.XRBinding("Text", null, "FLSReportGroups.CustomValue1", "{0:0.##}")}); - this.xrLabel18.Font = new DevExpress.Drawing.DXFont("Arial", 10F); - this.xrLabel18.LocationFloat = new DevExpress.Utils.PointFloat(160F, 77.78998F); - this.xrLabel18.Name = "xrLabel18"; - this.xrLabel18.SizeF = new System.Drawing.SizeF(50F, 19.79166F); - this.xrLabel18.StylePriority.UseFont = false; - this.xrLabel18.StylePriority.UsePadding = false; - this.xrLabel18.StylePriority.UseTextAlignment = false; - this.xrLabel18.Text = "xrLabel13"; - this.xrLabel18.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft; - // - // xrLabel19 - // - this.xrLabel19.Font = new DevExpress.Drawing.DXFont("Arial", 10F); - this.xrLabel19.LocationFloat = new DevExpress.Utils.PointFloat(0F, 97.58167F); - this.xrLabel19.Name = "xrLabel19"; - this.xrLabel19.SizeF = new System.Drawing.SizeF(140.8333F, 19.79166F); - this.xrLabel19.StylePriority.UseFont = false; - this.xrLabel19.StylePriority.UsePadding = false; - this.xrLabel19.Text = "davon indirekt:"; - // - // xrLabel20 - // - this.xrLabel20.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { - new DevExpress.XtraReports.UI.XRBinding("Text", null, "FLSReportGroups.CustomValue3", "{0:0.##}")}); - this.xrLabel20.Font = new DevExpress.Drawing.DXFont("Arial", 10F); - this.xrLabel20.LocationFloat = new DevExpress.Utils.PointFloat(160F, 97.58164F); - this.xrLabel20.Name = "xrLabel20"; - this.xrLabel20.SizeF = new System.Drawing.SizeF(50F, 19.79166F); - this.xrLabel20.StylePriority.UseFont = false; - this.xrLabel20.StylePriority.UsePadding = false; - this.xrLabel20.StylePriority.UseTextAlignment = false; - this.xrLabel20.Text = "xrLabel13"; - this.xrLabel20.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft; - // - // xrLabel21 - // - this.xrLabel21.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { - new DevExpress.XtraReports.UI.XRBinding("Text", null, "FLSReportGroups.CustomValue4")}); - this.xrLabel21.Font = new DevExpress.Drawing.DXFont("Arial", 10F); - this.xrLabel21.LocationFloat = new DevExpress.Utils.PointFloat(280F, 97.58164F); - this.xrLabel21.Name = "xrLabel21"; - this.xrLabel21.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel21.SizeF = new System.Drawing.SizeF(203F, 19.79166F); - this.xrLabel21.StylePriority.UseFont = false; - this.xrLabel21.Text = "xrLabel11"; - this.xrLabel21.TextFormatString = "{0:0} Stunden"; - // - // xrLabel22 - // - this.xrLabel22.Font = new DevExpress.Drawing.DXFont("Arial", 10F); - this.xrLabel22.LocationFloat = new DevExpress.Utils.PointFloat(210F, 97.58164F); - this.xrLabel22.Name = "xrLabel22"; - this.xrLabel22.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel22.SizeF = new System.Drawing.SizeF(70F, 19.79166F); - this.xrLabel22.StylePriority.UseFont = false; - this.xrLabel22.StylePriority.UseTextAlignment = false; - this.xrLabel22.Text = "entspricht"; - this.xrLabel22.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight; - // - // TextStunden - // - this.TextStunden.Condition = "[Name] == \'Indirekte Leistungen\'"; - this.TextStunden.DataMember = "FLSReportGroups.FLSReportDetails"; - this.TextStunden.Formatting.Visible = DevExpress.Utils.DefaultBoolean.True; - this.TextStunden.Name = "TextStunden"; - // - // xrLabel23 - // - this.xrLabel23.Font = new DevExpress.Drawing.DXFont("Arial", 10F); - this.xrLabel23.FormattingRules.Add(this.TextStunden); - this.xrLabel23.LocationFloat = new DevExpress.Utils.PointFloat(320F, 50F); - this.xrLabel23.Name = "xrLabel23"; - this.xrLabel23.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel23.SizeF = new System.Drawing.SizeF(107.75F, 25F); - this.xrLabel23.StylePriority.UseFont = false; - this.xrLabel23.Text = "Stunden"; - this.xrLabel23.Visible = false; - // - // xrLabel24 - // - this.xrLabel24.Font = new DevExpress.Drawing.DXFont("Arial", 10F); - this.xrLabel24.FormattingRules.Add(this.TextFLS); - this.xrLabel24.LocationFloat = new DevExpress.Utils.PointFloat(320F, 50F); - this.xrLabel24.Name = "xrLabel24"; - this.xrLabel24.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel24.SizeF = new System.Drawing.SizeF(70.70834F, 25F); - this.xrLabel24.StylePriority.UseFont = false; - this.xrLabel24.Text = "FLS"; - this.xrLabel24.Visible = false; - // - // TextFLS - // - this.TextFLS.Condition = "[Name] != \'Indirekte Leistungen\'"; - this.TextFLS.DataMember = "FLSReportGroups.FLSReportDetails"; - this.TextFLS.Formatting.Visible = DevExpress.Utils.DefaultBoolean.True; - this.TextFLS.Name = "TextFLS"; + this.xrTableCell12.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { + new DevExpress.XtraReports.UI.XRBinding("Text", null, "FLSReportGroups.FLSReportDetails.ServiceRecords.ServiceDescription")}); + this.xrTableCell12.Font = new DevExpress.Drawing.DXFont("Arial", 9.75F); + this.xrTableCell12.Multiline = true; + this.xrTableCell12.Name = "xrTableCell12"; + this.xrTableCell12.Padding = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 100F); + this.xrTableCell12.StylePriority.UseFont = false; + this.xrTableCell12.StylePriority.UsePadding = false; + this.xrTableCell12.StylePriority.UseTextAlignment = false; + this.xrTableCell12.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft; + this.xrTableCell12.Weight = 1.9805148080459751D; // // bindingSource1 // @@ -919,5 +951,7 @@ namespace BeWo.AssistenzaReports private DevExpress.XtraReports.UI.XRLabel xrLabel23; private DevExpress.XtraReports.UI.XRLabel xrLabel24; private DevExpress.XtraReports.UI.FormattingRule TextFLS; + private DevExpress.XtraReports.UI.XRTableCell xrTableCell12; + private DevExpress.XtraReports.UI.XRTableCell xrTableCell11; } } From 1861b33f8c5e2dc0cfafee389e5ab873b523102d Mon Sep 17 00:00:00 2001 From: HirschleM Date: Wed, 11 Jun 2025 15:50:51 +0200 Subject: [PATCH 04/27] MH: MuenchenerAidsHilfeEV Abrechnung --- .../Invoicing/CustomInvoiceCreation.cs | 39 ++- .../MuenchenerAidsHilfeEV.csproj | 2 + .../ServiceInvoiceReport.Designer.cs | 259 +++++++++--------- 3 files changed, 165 insertions(+), 135 deletions(-) diff --git a/ReportImp/MuenchenerAidsHilfeEV/Invoicing/CustomInvoiceCreation.cs b/ReportImp/MuenchenerAidsHilfeEV/Invoicing/CustomInvoiceCreation.cs index 6a1f4b617..d6e78121c 100644 --- a/ReportImp/MuenchenerAidsHilfeEV/Invoicing/CustomInvoiceCreation.cs +++ b/ReportImp/MuenchenerAidsHilfeEV/Invoicing/CustomInvoiceCreation.cs @@ -72,33 +72,52 @@ namespace MuenchenerAidsHilfeEV.Invoicing { laengerAls31 = customer.AbsenceTimes .Where(at => at.Start.HasValue && at.End.HasValue && ((at.End - at.Start).Value.TotalDays + 1 > 31)).ToList(); + + // Abwesenheit künstlich um 1 tag verkürzen, da der letzte Abwesenheitstag wieder als anwesend gilt + //foreach (var item in laengerAls31) + // item.End = item.End.Value.AddDays(-1); } Dictionary tagessatz2unitCount = new Dictionary(); + // Zum Debuggen Liste mit allen Tagen, die abgerechnet werden, damit man sehen kann, welcher zu viel/zu wenig ist + List debug = new List(); + var start = startDate; while (start <= endDate) { + if (start.Day == 30 && start.Month == 5) + { + + } + // Wenn eine Abwesenheit den aktuellen Tag enthält prüfen, ob er schon > 31 ist und wenn nein, ob es eine pauschale Bewilligung gibt var abs = laengerAls31.FirstOrDefault(l => l.AbsenceSpan.ContainsDate(start)); bool abrechenbar = true; - bool abwesend = false; + bool alsAbwesendAbrechnen = false; if (abs != null) { - abwesend = true; - - // Abwesenheit künstlich um 1 tag verkürzen, da der letzte Abwesenheitstag wieder als anwesend gilt - abs.End = abs.End.Value.AddDays(-1); - var absStart = new DateTime(abs.Start.Value.Year, abs.Start.Value.Month, abs.Start.Value.Day); int tage = 1; while (absStart < abs.End) { + if (absStart.Day == 30 && absStart.Month == 5) + { + + } + // Wenn der abzurechnende Tag nach dem 31. einer Abwesenheit liegt prüfen, ob er abgerechnet werden soll oder nicht if (absStart.Date == start.Date && tage > 31 || scap.ApprovedFixedAmount != null) { - // Wenn ein Betrag > 0 zurückkommt existiert eine Bewilligung mit Tagessatz speziell für die Abwesenheit, sonst nicht abrechnen - if (GetTagespauschale(scap, start, abwesend) == 0) + alsAbwesendAbrechnen = true; + // Wenn eine Bewilligung mit Tagessatz speziell für die Abwesenheit existiert, prüfen ob der Betrag > 0 ist + if (scap.ApprovedFixedAmount != null) + { + if (GetTagespauschale(scap, start, true) == 0) + abrechenbar = false; + } + // Gibt es keine spezielle Bewilligung mit einem Betrag, darf nicht abgerechnet werden + else abrechenbar = false; break; } @@ -109,7 +128,9 @@ namespace MuenchenerAidsHilfeEV.Invoicing } if (abrechenbar) { - var pauschale = GetTagespauschale(scap, start, abwesend); + debug.Add(start); + // alsAbwesendAbrechnen ist nur true, wenn es für den Zeitraum eine Bewilligung mit Pauschalbetrag gibt + var pauschale = GetTagespauschale(scap, start, alsAbwesendAbrechnen); if (!tagessatz2unitCount.ContainsKey(pauschale)) tagessatz2unitCount.Add(pauschale, 1); diff --git a/ReportImp/MuenchenerAidsHilfeEV/MuenchenerAidsHilfeEV.csproj b/ReportImp/MuenchenerAidsHilfeEV/MuenchenerAidsHilfeEV.csproj index 5819a412a..f37efa919 100644 --- a/ReportImp/MuenchenerAidsHilfeEV/MuenchenerAidsHilfeEV.csproj +++ b/ReportImp/MuenchenerAidsHilfeEV/MuenchenerAidsHilfeEV.csproj @@ -31,6 +31,7 @@ 4 + @@ -42,6 +43,7 @@ + diff --git a/ReportImp/MuenchenerAidsHilfeEV/ServiceInvoiceReport.Designer.cs b/ReportImp/MuenchenerAidsHilfeEV/ServiceInvoiceReport.Designer.cs index c31787f26..4b2fa6587 100644 --- a/ReportImp/MuenchenerAidsHilfeEV/ServiceInvoiceReport.Designer.cs +++ b/ReportImp/MuenchenerAidsHilfeEV/ServiceInvoiceReport.Designer.cs @@ -44,6 +44,13 @@ namespace MuenchenerAidsHilfeEV this.xrRichText1 = new DevExpress.XtraReports.UI.XRRichText(); this.xrLabel8 = new DevExpress.XtraReports.UI.XRLabel(); this.Page1 = new DevExpress.XtraReports.UI.GroupHeaderBand(); + this.xrTable5 = new DevExpress.XtraReports.UI.XRTable(); + this.xrTableRow23 = new DevExpress.XtraReports.UI.XRTableRow(); + this.xrTableCell32 = new DevExpress.XtraReports.UI.XRTableCell(); + this.xrTableCell37 = new DevExpress.XtraReports.UI.XRTableCell(); + this.xrTableCell33 = new DevExpress.XtraReports.UI.XRTableCell(); + this.xrTableCell36 = new DevExpress.XtraReports.UI.XRTableCell(); + this.xrTableCell34 = new DevExpress.XtraReports.UI.XRTableCell(); this.lblEinrichtungsnummer = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel7 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel2 = new DevExpress.XtraReports.UI.XRLabel(); @@ -75,7 +82,6 @@ namespace MuenchenerAidsHilfeEV this.xrTableCell8 = new DevExpress.XtraReports.UI.XRTableCell(); this.xrTableRow1 = new DevExpress.XtraReports.UI.XRTableRow(); this.xrTableCell1 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrLabel15 = new DevExpress.XtraReports.UI.XRLabel(); this.DetailReport = new DevExpress.XtraReports.UI.DetailReportBand(); this.Detail1 = new DevExpress.XtraReports.UI.DetailBand(); this.DetailReport2 = new DevExpress.XtraReports.UI.DetailReportBand(); @@ -88,23 +94,18 @@ namespace MuenchenerAidsHilfeEV this.xrTableCell45 = new DevExpress.XtraReports.UI.XRTableCell(); this.xrTableCell47 = new DevExpress.XtraReports.UI.XRTableCell(); this.GroupFooter1 = new DevExpress.XtraReports.UI.GroupFooterBand(); + this.ReportFooter2 = new DevExpress.XtraReports.UI.ReportFooterBand(); this.xrLabel1 = new DevExpress.XtraReports.UI.XRLabel(); - this.xrTable5 = new DevExpress.XtraReports.UI.XRTable(); - this.xrTableRow23 = new DevExpress.XtraReports.UI.XRTableRow(); - this.xrTableCell32 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableCell37 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableCell33 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableCell36 = new DevExpress.XtraReports.UI.XRTableCell(); - this.xrTableCell34 = new DevExpress.XtraReports.UI.XRTableCell(); + this.xrLabel15 = new DevExpress.XtraReports.UI.XRLabel(); this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); ((System.ComponentModel.ISupportInitialize)(this.xrRichText4)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrRichText3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrRichText2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrRichText1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.xrTable5)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable6)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.xrTable5)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this)).BeginInit(); // @@ -231,6 +232,105 @@ namespace MuenchenerAidsHilfeEV this.Page1.Name = "Page1"; this.Page1.StylePriority.UseFont = false; // + // xrTable5 + // + this.xrTable5.LocationFloat = new DevExpress.Utils.PointFloat(0F, 435.7917F); + this.xrTable5.Name = "xrTable5"; + this.xrTable5.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { + this.xrTableRow23}); + this.xrTable5.SizeF = new System.Drawing.SizeF(677F, 25F); + // + // xrTableRow23 + // + this.xrTableRow23.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] { + this.xrTableCell32, + this.xrTableCell37, + this.xrTableCell33, + this.xrTableCell36, + this.xrTableCell34}); + this.xrTableRow23.Name = "xrTableRow23"; + this.xrTableRow23.Weight = 1D; + // + // xrTableCell32 + // + this.xrTableCell32.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) + | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.xrTableCell32.Name = "xrTableCell32"; + this.xrTableCell32.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F); + this.xrTableCell32.StylePriority.UseBackColor = false; + this.xrTableCell32.StylePriority.UseBorderColor = false; + this.xrTableCell32.StylePriority.UseBorders = false; + this.xrTableCell32.StylePriority.UsePadding = false; + this.xrTableCell32.StylePriority.UseTextAlignment = false; + this.xrTableCell32.Text = "Zeitraum"; + this.xrTableCell32.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft; + this.xrTableCell32.Weight = 0.75332349160221157D; + // + // xrTableCell37 + // + this.xrTableCell37.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) + | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.xrTableCell37.Name = "xrTableCell37"; + this.xrTableCell37.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F); + this.xrTableCell37.StylePriority.UseBackColor = false; + this.xrTableCell37.StylePriority.UseBorderColor = false; + this.xrTableCell37.StylePriority.UseBorders = false; + this.xrTableCell37.StylePriority.UsePadding = false; + this.xrTableCell37.StylePriority.UseTextAlignment = false; + this.xrTableCell37.Text = "Betreuungsschlüssel "; + this.xrTableCell37.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; + this.xrTableCell37.Weight = 0.7221196454948301D; + // + // xrTableCell33 + // + this.xrTableCell33.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) + | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.xrTableCell33.Name = "xrTableCell33"; + this.xrTableCell33.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F); + this.xrTableCell33.StylePriority.UseBackColor = false; + this.xrTableCell33.StylePriority.UseBorderColor = false; + this.xrTableCell33.StylePriority.UseBorders = false; + this.xrTableCell33.StylePriority.UsePadding = false; + this.xrTableCell33.StylePriority.UseTextAlignment = false; + this.xrTableCell33.Text = "Tage"; + this.xrTableCell33.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight; + this.xrTableCell33.Weight = 0.4431314566991178D; + // + // xrTableCell36 + // + this.xrTableCell36.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) + | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.xrTableCell36.Name = "xrTableCell36"; + this.xrTableCell36.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F); + this.xrTableCell36.StylePriority.UseBackColor = false; + this.xrTableCell36.StylePriority.UseBorderColor = false; + this.xrTableCell36.StylePriority.UseBorders = false; + this.xrTableCell36.StylePriority.UsePadding = false; + this.xrTableCell36.StylePriority.UseTextAlignment = false; + this.xrTableCell36.Text = "Satz"; + this.xrTableCell36.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight; + this.xrTableCell36.Weight = 0.44313146796853364D; + // + // xrTableCell34 + // + this.xrTableCell34.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) + | DevExpress.XtraPrinting.BorderSide.Right) + | DevExpress.XtraPrinting.BorderSide.Bottom))); + this.xrTableCell34.Name = "xrTableCell34"; + this.xrTableCell34.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F); + this.xrTableCell34.StylePriority.UseBackColor = false; + this.xrTableCell34.StylePriority.UseBorderColor = false; + this.xrTableCell34.StylePriority.UseBorders = false; + this.xrTableCell34.StylePriority.UsePadding = false; + this.xrTableCell34.StylePriority.UseTextAlignment = false; + this.xrTableCell34.Text = "Gesamt"; + this.xrTableCell34.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight; + this.xrTableCell34.Weight = 0.63829393823530678D; + // // lblEinrichtungsnummer // this.lblEinrichtungsnummer.BackColor = System.Drawing.Color.Transparent; @@ -571,17 +671,6 @@ namespace MuenchenerAidsHilfeEV this.xrTableCell1.StylePriority.UseTextAlignment = false; this.xrTableCell1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft; this.xrTableCell1.Weight = 1D; - // - // xrLabel15 - // - this.xrLabel15.LocationFloat = new DevExpress.Utils.PointFloat(0F, 67.08334F); - this.xrLabel15.Multiline = true; - this.xrLabel15.Name = "xrLabel15"; - this.xrLabel15.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel15.SizeF = new System.Drawing.SizeF(666.9999F, 59.50002F); - this.xrLabel15.StylePriority.UseFont = false; - this.xrLabel15.Text = "Zahlung sofort nach Rechnungserhalt ohne Abzug.\r\n\r\nDiese Rechnung wurde maschinel" + - "l erstellt und ist ohne Unterschrift gültig."; // // DetailReport // @@ -607,7 +696,6 @@ namespace MuenchenerAidsHilfeEV this.DetailReport2.DataSource = this.bindingSource1; this.DetailReport2.Level = 0; this.DetailReport2.Name = "DetailReport2"; - this.DetailReport2.PageBreak = DevExpress.XtraReports.UI.PageBreak.AfterBand; // // Detail3 // @@ -714,11 +802,16 @@ namespace MuenchenerAidsHilfeEV // // GroupFooter1 // - this.GroupFooter1.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { + this.GroupFooter1.HeightF = 0F; + this.GroupFooter1.Name = "GroupFooter1"; + // + // ReportFooter2 + // + this.ReportFooter2.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { this.xrLabel1, this.xrLabel15}); - this.GroupFooter1.HeightF = 126.5834F; - this.GroupFooter1.Name = "GroupFooter1"; + this.ReportFooter2.HeightF = 111.4583F; + this.ReportFooter2.Name = "ReportFooter2"; // // xrLabel1 // @@ -726,7 +819,7 @@ namespace MuenchenerAidsHilfeEV new DevExpress.XtraReports.UI.XRBinding("Text", null, "GrossClaim", "Gesamtsumme: {0}")}); this.xrLabel1.Font = new DevExpress.Drawing.DXFont("Arial", 10F, DevExpress.Drawing.DXFontStyle.Bold, DevExpress.Drawing.DXGraphicsUnit.Point, new DevExpress.Drawing.DXFontAdditionalProperty[] { new DevExpress.Drawing.DXFontAdditionalProperty("GdiCharSet", ((byte)(0)))}); - this.xrLabel1.LocationFloat = new DevExpress.Utils.PointFloat(420.9999F, 0F); + this.xrLabel1.LocationFloat = new DevExpress.Utils.PointFloat(420.9967F, 0F); this.xrLabel1.Name = "xrLabel1"; this.xrLabel1.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 5, 0, 0, 100F); this.xrLabel1.SizeF = new System.Drawing.SizeF(255.8333F, 25F); @@ -736,104 +829,16 @@ namespace MuenchenerAidsHilfeEV this.xrLabel1.Text = "xrLabel1"; this.xrLabel1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight; // - // xrTable5 + // xrLabel15 // - this.xrTable5.LocationFloat = new DevExpress.Utils.PointFloat(0F, 435.7917F); - this.xrTable5.Name = "xrTable5"; - this.xrTable5.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] { - this.xrTableRow23}); - this.xrTable5.SizeF = new System.Drawing.SizeF(677F, 25F); - // - // xrTableRow23 - // - this.xrTableRow23.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] { - this.xrTableCell32, - this.xrTableCell37, - this.xrTableCell33, - this.xrTableCell36, - this.xrTableCell34}); - this.xrTableRow23.Name = "xrTableRow23"; - this.xrTableRow23.Weight = 1D; - // - // xrTableCell32 - // - this.xrTableCell32.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) - | DevExpress.XtraPrinting.BorderSide.Right) - | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell32.Name = "xrTableCell32"; - this.xrTableCell32.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F); - this.xrTableCell32.StylePriority.UseBackColor = false; - this.xrTableCell32.StylePriority.UseBorderColor = false; - this.xrTableCell32.StylePriority.UseBorders = false; - this.xrTableCell32.StylePriority.UsePadding = false; - this.xrTableCell32.StylePriority.UseTextAlignment = false; - this.xrTableCell32.Text = "Zeitraum"; - this.xrTableCell32.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft; - this.xrTableCell32.Weight = 0.75332349160221157D; - // - // xrTableCell37 - // - this.xrTableCell37.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) - | DevExpress.XtraPrinting.BorderSide.Right) - | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell37.Name = "xrTableCell37"; - this.xrTableCell37.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F); - this.xrTableCell37.StylePriority.UseBackColor = false; - this.xrTableCell37.StylePriority.UseBorderColor = false; - this.xrTableCell37.StylePriority.UseBorders = false; - this.xrTableCell37.StylePriority.UsePadding = false; - this.xrTableCell37.StylePriority.UseTextAlignment = false; - this.xrTableCell37.Text = "Betreuungsschlüssel "; - this.xrTableCell37.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; - this.xrTableCell37.Weight = 0.7221196454948301D; - // - // xrTableCell33 - // - this.xrTableCell33.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) - | DevExpress.XtraPrinting.BorderSide.Right) - | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell33.Name = "xrTableCell33"; - this.xrTableCell33.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F); - this.xrTableCell33.StylePriority.UseBackColor = false; - this.xrTableCell33.StylePriority.UseBorderColor = false; - this.xrTableCell33.StylePriority.UseBorders = false; - this.xrTableCell33.StylePriority.UsePadding = false; - this.xrTableCell33.StylePriority.UseTextAlignment = false; - this.xrTableCell33.Text = "Tage"; - this.xrTableCell33.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight; - this.xrTableCell33.Weight = 0.4431314566991178D; - // - // xrTableCell36 - // - this.xrTableCell36.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) - | DevExpress.XtraPrinting.BorderSide.Right) - | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell36.Name = "xrTableCell36"; - this.xrTableCell36.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F); - this.xrTableCell36.StylePriority.UseBackColor = false; - this.xrTableCell36.StylePriority.UseBorderColor = false; - this.xrTableCell36.StylePriority.UseBorders = false; - this.xrTableCell36.StylePriority.UsePadding = false; - this.xrTableCell36.StylePriority.UseTextAlignment = false; - this.xrTableCell36.Text = "Satz"; - this.xrTableCell36.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight; - this.xrTableCell36.Weight = 0.44313146796853364D; - // - // xrTableCell34 - // - this.xrTableCell34.Borders = ((DevExpress.XtraPrinting.BorderSide)((((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Top) - | DevExpress.XtraPrinting.BorderSide.Right) - | DevExpress.XtraPrinting.BorderSide.Bottom))); - this.xrTableCell34.Name = "xrTableCell34"; - this.xrTableCell34.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 2, 2, 100F); - this.xrTableCell34.StylePriority.UseBackColor = false; - this.xrTableCell34.StylePriority.UseBorderColor = false; - this.xrTableCell34.StylePriority.UseBorders = false; - this.xrTableCell34.StylePriority.UsePadding = false; - this.xrTableCell34.StylePriority.UseTextAlignment = false; - this.xrTableCell34.Text = "Gesamt"; - this.xrTableCell34.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight; - this.xrTableCell34.Weight = 0.63829393823530678D; + this.xrLabel15.LocationFloat = new DevExpress.Utils.PointFloat(0F, 51.95827F); + this.xrLabel15.Multiline = true; + this.xrLabel15.Name = "xrLabel15"; + this.xrLabel15.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel15.SizeF = new System.Drawing.SizeF(666.9999F, 59.50002F); + this.xrLabel15.StylePriority.UseFont = false; + this.xrLabel15.Text = "Zahlung sofort nach Rechnungserhalt ohne Abzug.\r\n\r\nDiese Rechnung wurde maschinel" + + "l erstellt und ist ohne Unterschrift gültig."; // // bindingSource1 // @@ -847,7 +852,8 @@ namespace MuenchenerAidsHilfeEV this.topMarginBand1, this.bottomMarginBand1, this.Page1, - this.DetailReport}); + this.DetailReport, + this.ReportFooter2}); this.DataSource = this.bindingSource1; this.ExportOptions.PrintPreview.DefaultFileName = "Spitzabrechnung"; this.Font = new DevExpress.Drawing.DXFont("Arial", 10F, DevExpress.Drawing.DXFontStyle.Regular, DevExpress.Drawing.DXGraphicsUnit.Point, new DevExpress.Drawing.DXFontAdditionalProperty[] { @@ -865,10 +871,10 @@ namespace MuenchenerAidsHilfeEV ((System.ComponentModel.ISupportInitialize)(this.xrRichText3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.xrRichText2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.xrRichText1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.xrTable5)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTable6)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.xrTable5)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this)).EndInit(); @@ -889,7 +895,6 @@ namespace MuenchenerAidsHilfeEV private DevExpress.XtraReports.UI.XRTable xrTable2; private DevExpress.XtraReports.UI.XRTableRow xrTableRow4; private DevExpress.XtraReports.UI.XRTableCell xrTableCell11; - private DevExpress.XtraReports.UI.XRLabel xrLabel15; private DevExpress.XtraReports.UI.DetailReportBand DetailReport; private DevExpress.XtraReports.UI.DetailBand Detail1; private DevExpress.XtraReports.UI.DetailReportBand DetailReport2; @@ -903,7 +908,6 @@ namespace MuenchenerAidsHilfeEV private DevExpress.XtraReports.UI.XRTableCell xrTableCell47; private DevExpress.XtraReports.UI.XRLabel lblAdresse; private DevExpress.XtraReports.UI.GroupFooterBand GroupFooter1; - private DevExpress.XtraReports.UI.XRLabel xrLabel1; private DevExpress.XtraReports.UI.XRPictureBox xrPictureBox1; private DevExpress.XtraReports.UI.XRLabel xrLabel6; private DevExpress.XtraReports.UI.XRLabel xrLabel10; @@ -941,5 +945,8 @@ namespace MuenchenerAidsHilfeEV private DevExpress.XtraReports.UI.XRTableCell xrTableCell33; private DevExpress.XtraReports.UI.XRTableCell xrTableCell36; private DevExpress.XtraReports.UI.XRTableCell xrTableCell34; + private DevExpress.XtraReports.UI.ReportFooterBand ReportFooter2; + private DevExpress.XtraReports.UI.XRLabel xrLabel1; + private DevExpress.XtraReports.UI.XRLabel xrLabel15; } } From c95dad72bf79a0b1f6d773ce33605bc35bdd7899 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 11 Jun 2025 22:56:25 +0200 Subject: [PATCH 05/27] =?UTF-8?q?=C3=9Cberarbeitung=20Mok=20Session=20Hand?= =?UTF-8?q?ling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BeWo/BeWo.csproj | 4 +- BeWo/BeWoApp.xaml.cs | 1 + BeWo/Services/BeWoWindowService.cs | 16 +- .../BeWoDatabaseTerminator/App.config | 34 +- .../BeWoDatabaseTerminator.csproj | 33 +- .../MySql/MySqlHelper.cs | 3 +- .../BeWoDatabaseTerminator/Program.cs | 5 +- .../BeWoDatabaseTerminator/packages.config | 10 + BeWoPlanerMobil/BeWoPlanerMobil.csproj | 10 + BeWoPlanerMobil/BeWoPlanerMobil.csproj.user | 2 +- .../Controllers/AbstractBaseController.cs | 85 +- .../Controllers/CustomerController.cs | 191 +-- .../Controllers/DebuggingToolsController.cs | 21 +- .../DevExpressSchedulerController.cs | 22 +- .../ExternalSignatureController.cs | 18 +- .../Controllers/LoginController.cs | 24 +- BeWoPlanerMobil/Controllers/MainController.cs | 1036 ++++++++++------- .../Controllers/ReportController.cs | 308 +++-- .../Controllers/ReportViewerController.cs | 131 ++- .../Controllers/SchedulerController.cs | 403 ++++--- BeWoPlanerMobil/Models/AbstractModel.cs | 161 +-- BeWoPlanerMobil/Models/CustomerModel.cs | 50 +- .../Models/CustomerSessionModel.cs | 51 + BeWoPlanerMobil/Models/ISessionModel.cs | 9 + BeWoPlanerMobil/Models/MainModel.cs | 218 ++-- BeWoPlanerMobil/Models/MainSessionModel.cs | 88 ++ BeWoPlanerMobil/Models/ReportModel.cs | 73 +- BeWoPlanerMobil/Models/ReportSessionModel .cs | 54 + BeWoPlanerMobil/Models/ReportViewerModel.cs | 37 +- .../Models/ReportViewerSessionModel.cs | 37 + BeWoPlanerMobil/Models/SchedulerModel.cs | 135 +-- .../Models/SchedulerSessionModel.cs | 61 + .../Service/ASPHibernateSessionManager.cs | 14 +- .../Service/MobileSessionFacade.cs | 74 +- BeWoPlanerMobil/TestWebService.asmx.cs | 4 +- BeWoPlanerMobil/Util/AppointmentListItem.cs | 17 +- BeWoPlanerMobil/Util/DcToMokMapper.cs | 23 + .../Util/FormCollectionConstants.cs | 24 +- BeWoPlanerMobil/Util/MokMandator.cs | 37 + BeWoPlanerMobil/Util/MokSettings.cs | 13 + BeWoPlanerMobil/Util/NullableDateTimeSpan.cs | 1 + .../QuittierungsbelegsReportSettings.cs | 20 + .../Views/Customer/Customer.cshtml | 25 +- .../CustomerAbsenceTimeFormPartial.cshtml | 6 +- .../Customer/CustomerBargeldkassen.cshtml | 2 +- BeWoPlanerMobil/Views/Login/Index.cshtml | 4 +- .../Main/GoalRatingPopupContentPartial.cshtml | 2 +- .../Views/Main/GoalTreePartial.cshtml | 4 +- .../Views/Main/GroupBookingFormPartial.cshtml | 28 +- .../Views/Main/GroupBookingScCbRelList.cshtml | 4 +- BeWoPlanerMobil/Views/Main/Main.cshtml | 12 +- .../Views/Main/MultiBookingFormPartial.cshtml | 6 +- .../Main/ServiceRecordListPartial.cshtml | 8 +- .../Views/Main/SingleBookingPartial.cshtml | 21 +- ...ConfirmationReceiptSignaturePartial.cshtml | 6 +- .../QuittierungsbelegsPreviewPartial.cshtml | 4 +- .../QuittierungsbelegsResultPartial.cshtml | 12 +- BeWoPlanerMobil/Views/Report/Report.cshtml | 14 +- .../ReportViewerFormPartial.cshtml | 8 +- .../Scheduler/AppointmentFormPartial.cshtml | 18 +- .../AppointmentIntervalFinderPartial.cshtml | 22 +- .../CustomerFilterSelectionPartial.cshtml | 4 +- ...mployeeFilteringModalContentPartial.cshtml | 2 +- .../EmployeeForFilteringPartial.cshtml | 5 +- .../EmployeeSelectionPopupPartial.cshtml | 2 +- .../Views/Scheduler/Scheduler.cshtml | 22 +- BeWoPlanerMobil/Views/Shared/_Layout.cshtml | 10 +- Data/ASPHibernateSessionManager.cs | 129 +- Data/Access/AdoDAO.cs | 4 +- Data/Security/UserRightHelper.cs | 9 +- Data/SessionFacade.cs | 34 +- Host/GkvAbrechnungClient.aspx.cs | 1 - Host/Host.csproj | 22 +- Host/ResetPassword.aspx.cs | 2 - Host/ServiceRecordEditPage.aspx | 114 -- Host/ServiceRecordEditPage.aspx.cs | 298 ----- Host/ServiceRecordEditPage.aspx.designer.cs | 195 ---- Host/ServiceRecordPage.aspx | 1 - Host/ServiceRecordPage.aspx.cs | 489 -------- Host/ServiceRecordPage.aspx.designer.cs | 15 - Lib/MySql.Data.dll | Bin 1730048 -> 1188424 bytes Model/Changes_alle_fuer_neue_db.txt | 26 + .../Reports/LeistungsnachweisAmbDienst.cs | 5 +- Service/Service.csproj | 4 - .../ServiceImplementations/UserServiceImp.cs | 5 +- Shared/DataContracts/ClientPartials/UserDC.cs | 20 + 86 files changed, 2629 insertions(+), 2553 deletions(-) create mode 100644 BeWoPlanerMobil/Models/CustomerSessionModel.cs create mode 100644 BeWoPlanerMobil/Models/ISessionModel.cs create mode 100644 BeWoPlanerMobil/Models/MainSessionModel.cs create mode 100644 BeWoPlanerMobil/Models/ReportSessionModel .cs create mode 100644 BeWoPlanerMobil/Models/ReportViewerSessionModel.cs create mode 100644 BeWoPlanerMobil/Models/SchedulerSessionModel.cs create mode 100644 BeWoPlanerMobil/Util/DcToMokMapper.cs create mode 100644 BeWoPlanerMobil/Util/MokMandator.cs create mode 100644 BeWoPlanerMobil/Util/MokSettings.cs create mode 100644 BeWoPlanerMobil/Util/ReportUtils/QuittierungsbelegsReportSettings.cs delete mode 100644 Host/ServiceRecordEditPage.aspx delete mode 100644 Host/ServiceRecordEditPage.aspx.cs delete mode 100644 Host/ServiceRecordEditPage.aspx.designer.cs delete mode 100644 Host/ServiceRecordPage.aspx delete mode 100644 Host/ServiceRecordPage.aspx.cs delete mode 100644 Host/ServiceRecordPage.aspx.designer.cs diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index 63ce2457b..62aaffa88 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -43,12 +43,12 @@ de-DE BeWoPlaner ownSoft GmbH - 2.0.1.265 + 2.0.1.266 true publish.htm false true - 266 + 267 2.0.1.%2a false true diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs index e85dc7e0d..a4873b144 100644 --- a/BeWo/BeWoApp.xaml.cs +++ b/BeWo/BeWoApp.xaml.cs @@ -635,6 +635,7 @@ namespace BeWo //IsInDeveloperMode = false; AppSettings.ModuleAiEnabled = true; AppSettings.ModuleAiSettingsEnabled = false; + AppSettings.IsSchedulerAllowed = true; #endif AppSettings.ShowDatevFields = showDatevFields; diff --git a/BeWo/Services/BeWoWindowService.cs b/BeWo/Services/BeWoWindowService.cs index ecf66a07a..60baef259 100644 --- a/BeWo/Services/BeWoWindowService.cs +++ b/BeWo/Services/BeWoWindowService.cs @@ -24,10 +24,10 @@ namespace BeWo.Services public void ShowAiConversationWindow(UIContext uIContext, Dictionary bewoObjects, long? reference_oid = null) { -#if !DEBUG - BeWoApp.ShowInfoMessage("Diese Funktion befindet sich in der Testphase."); - return; -#endif +//#if !DEBUG +// BeWoApp.ShowInfoMessage("Diese Funktion befindet sich in der Testphase."); +// return; +//#endif ShowWindowDialog( cf => cf.GetAiConversationControl(uIContext, bewoObjects, reference_oid), @@ -35,10 +35,10 @@ namespace BeWo.Services } public void ShowAiConversationModalViewWindow(UIContext uIContext, Dictionary bewoObjects, long? reference_oid = null) { -#if !DEBUG - BeWoApp.ShowInfoMessage("Diese Funktion befindet sich in der Testphase."); - return; -#endif +//#if !DEBUG +// BeWoApp.ShowInfoMessage("Diese Funktion befindet sich in der Testphase."); +// return; +//#endif ShowModalViewWindow(cf => cf.GetAiConversationControl(uIContext, bewoObjects, reference_oid), (wf, ctrl) => wf.GetAiModalViewWindow(uIContext, ctrl)); diff --git a/BeWoDatabaseTerminator/BeWoDatabaseTerminator/App.config b/BeWoDatabaseTerminator/BeWoDatabaseTerminator/App.config index d1d139af0..c99ec9310 100644 --- a/BeWoDatabaseTerminator/BeWoDatabaseTerminator/App.config +++ b/BeWoDatabaseTerminator/BeWoDatabaseTerminator/App.config @@ -1,19 +1,27 @@ - + - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/BeWoDatabaseTerminator/BeWoDatabaseTerminator/BeWoDatabaseTerminator.csproj b/BeWoDatabaseTerminator/BeWoDatabaseTerminator/BeWoDatabaseTerminator.csproj index 706261a46..df4b91303 100644 --- a/BeWoDatabaseTerminator/BeWoDatabaseTerminator/BeWoDatabaseTerminator.csproj +++ b/BeWoDatabaseTerminator/BeWoDatabaseTerminator/BeWoDatabaseTerminator.csproj @@ -37,16 +37,45 @@ bdt.ico - - ..\..\Lib\MySql.Data.dll + + ..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\MySqlConnector.2.4.0\lib\net471\MySqlConnector.dll ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + diff --git a/BeWoDatabaseTerminator/BeWoDatabaseTerminator/MySql/MySqlHelper.cs b/BeWoDatabaseTerminator/BeWoDatabaseTerminator/MySql/MySqlHelper.cs index 1e93c8717..7f09a5531 100644 --- a/BeWoDatabaseTerminator/BeWoDatabaseTerminator/MySql/MySqlHelper.cs +++ b/BeWoDatabaseTerminator/BeWoDatabaseTerminator/MySql/MySqlHelper.cs @@ -4,7 +4,7 @@ using System.Data; using System.IO; using BeWoDatabaseTerminator.Security; using BeWoDatabaseTerminator.Utils; -using MySql.Data.MySqlClient; +using MySqlConnector; namespace BeWoDatabaseTerminator.MySql { @@ -118,6 +118,7 @@ namespace BeWoDatabaseTerminator.MySql { try { + return; _Connection.Open(); var command = new MySqlCommand($"DROP SCHEMA IF EXISTS `{schemaName}`;", _Connection); diff --git a/BeWoDatabaseTerminator/BeWoDatabaseTerminator/Program.cs b/BeWoDatabaseTerminator/BeWoDatabaseTerminator/Program.cs index 587d60dc1..94377747e 100644 --- a/BeWoDatabaseTerminator/BeWoDatabaseTerminator/Program.cs +++ b/BeWoDatabaseTerminator/BeWoDatabaseTerminator/Program.cs @@ -96,6 +96,7 @@ namespace BeWoDatabaseTerminator private static async Task Main(string[] args) { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; PinCertificate(); @@ -281,9 +282,9 @@ namespace BeWoDatabaseTerminator private static async Task ActivateDatabase(string tenant, ContractStatus contractStatus) { var connectionString = $"Server={_ConnectionStringServer};Password={_ConnectionStringPassword};User ID={_ConnectionStringUserID};Port={_ConnectionStringPort}"; - + //connectionString += ";Charset=utf8mb4"; var isExisting = new MySqlHelper(connectionString).CheckForDatabase(tenant); - + var configFilePath = Path.Combine(_MultitenancyPath, $"{tenant}.config"); // Config-Datei existiert bereits diff --git a/BeWoDatabaseTerminator/BeWoDatabaseTerminator/packages.config b/BeWoDatabaseTerminator/BeWoDatabaseTerminator/packages.config index 2c2f63591..52fa96d34 100644 --- a/BeWoDatabaseTerminator/BeWoDatabaseTerminator/packages.config +++ b/BeWoDatabaseTerminator/BeWoDatabaseTerminator/packages.config @@ -1,4 +1,14 @@  + + + + + + + + + + \ No newline at end of file diff --git a/BeWoPlanerMobil/BeWoPlanerMobil.csproj b/BeWoPlanerMobil/BeWoPlanerMobil.csproj index 6a7d40ba9..fab648643 100644 --- a/BeWoPlanerMobil/BeWoPlanerMobil.csproj +++ b/BeWoPlanerMobil/BeWoPlanerMobil.csproj @@ -310,13 +310,22 @@ + + + + + + + + + @@ -357,6 +366,7 @@ + diff --git a/BeWoPlanerMobil/BeWoPlanerMobil.csproj.user b/BeWoPlanerMobil/BeWoPlanerMobil.csproj.user index 033eb78ef..197827697 100644 --- a/BeWoPlanerMobil/BeWoPlanerMobil.csproj.user +++ b/BeWoPlanerMobil/BeWoPlanerMobil.csproj.user @@ -9,7 +9,7 @@ Release|Any CPU - ShowAllFiles + ProjectFiles 600 MvcControllerEmptyScaffolder root/Common/MVC/Controller diff --git a/BeWoPlanerMobil/Controllers/AbstractBaseController.cs b/BeWoPlanerMobil/Controllers/AbstractBaseController.cs index c00149d73..7d2b72977 100644 --- a/BeWoPlanerMobil/Controllers/AbstractBaseController.cs +++ b/BeWoPlanerMobil/Controllers/AbstractBaseController.cs @@ -2,9 +2,13 @@ using System.Diagnostics; using System.Web.Mvc; using System.Web.Security; +using BeWo.Data.Access; +using BeWo.Data.Entities; +using BeWo.Service.DCEntityMapper; using BeWo.Service.ServiceContracts; using BeWoPlanerMobil.Models; using BeWoPlanerMobil.Service; +using BeWoPlanerMobil.Util; using BS.Shared; using BS.Shared.Core; using BS.Shared.DataContracts; @@ -30,6 +34,8 @@ namespace BeWoPlanerMobil.Controllers public static readonly string IsSessionTimedOut = "isSessionTimedOut"; + private UserDC loggedInUserDc = null; + private EmployeeDC loggedInEmployeeDC = null; protected ActionResult Logout() { @@ -45,9 +51,60 @@ namespace BeWoPlanerMobil.Controllers return RedirectToActionPermanent("Index", "Login", new {tenant = MobileSessionFacade.Tenant}); } - protected UserDC GetUser() + protected virtual void InitModel(AbstractModel model) { - return UserService.LoadUser(MobileSessionFacade.LoggedInUser.Oid.Value); + model.LoggedInUser = LoggedInUser; + model.LoggedInEmployee = LoggedInEmployee; + model.Mandator = Mandator; + + if (model.SessionModel != null) + { + String sessionkey = model.GetType().Name; + + if (Session[sessionkey] is null) + { + Session[sessionkey] = model.SessionModel; + } + else + { + model.SessionModel = (ISessionModel)Session[sessionkey]; + } + } + } + + protected UserDC LoggedInUser + { + get + { + if (loggedInUserDc == null) + { + var user = DAOFactory.GenericDAO.LoadByID(MobileSessionFacade.LoggedInUserOid.Value); + loggedInUserDc = MapperFactory.UserDC_User.MapToNewDC(user); + loggedInEmployeeDC = MapperFactory.EmployeeDC_Employee.MapToNewDC(user.Employee); + } + return loggedInUserDc; + } + + } + + protected EmployeeDC LoggedInEmployee + { + get + { + if (loggedInEmployeeDC == null) + { + var tmp = LoggedInUser; //Sets employee + } + return loggedInEmployeeDC; + } + } + + protected MokMandator Mandator + { + get + { + return MobileSessionFacade.Mandator; + } } protected override void OnActionExecuting(ActionExecutingContext filterContext) @@ -62,12 +119,13 @@ namespace BeWoPlanerMobil.Controllers { get { - var timeUntilUILock = BS.Shared.Settings.ApplicationSettings.TimeUntilUILock; + //var timeUntilUILock = BS.Shared.Settings.ApplicationSettings.TimeUntilUILock; - if(timeUntilUILock > 0 && System.Web.HttpContext.Current.Session.Timeout > timeUntilUILock) - { - return timeUntilUILock; - } + //if(timeUntilUILock > 0 && System.Web.HttpContext.Current.Session.Timeout > timeUntilUILock) + //{ + // return timeUntilUILock; + //} + //var mokSessionTimeout = UserSettingsUtils.GetSettingValueAsInteger(Mandator.Settings, SettingsKeys.MoKSessionTimeout, 20); return System.Web.HttpContext.Current.Session.Timeout; } @@ -76,15 +134,14 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult UpdateApplicationSettings(string pKey, string pValue) { - var userSettings = GetUser().Settings; + + var userSettings = LoggedInUser.Settings; UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, pKey, pValue, userSettings); - var loggedInUser = GetUser(); - - if(loggedInUser?.UserOid.HasValue ?? false) + if(LoggedInUser?.UserOid.HasValue ?? false) { - UserService.UpdateUserSettings(loggedInUser.UserOid.Value, userSettings); + UserService.UpdateUserSettings(LoggedInUser.UserOid.Value, userSettings); } return RedirectToAction("Main"); @@ -93,11 +150,11 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public void UpdateUserSettingsWithoutReload(string key, string value) { - var userSettings = GetUser().Settings; + var userSettings = LoggedInUser.Settings; UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, key, value, userSettings); - var loggedInUser = GetUser(); + var loggedInUser = LoggedInUser; if(loggedInUser?.UserOid.HasValue ?? false) { diff --git a/BeWoPlanerMobil/Controllers/CustomerController.cs b/BeWoPlanerMobil/Controllers/CustomerController.cs index fdbb4e658..a8618b619 100644 --- a/BeWoPlanerMobil/Controllers/CustomerController.cs +++ b/BeWoPlanerMobil/Controllers/CustomerController.cs @@ -20,6 +20,10 @@ namespace BeWoPlanerMobil.Controllers { public class CustomerController : ReportBaseController { + public CustomerController() + { + + } private CustomerModel _Model; public CustomerModel Model { @@ -31,20 +35,33 @@ namespace BeWoPlanerMobil.Controllers return null; } - if (((CustomerModel) Session[ModelSessionConstants.CustomerModelKey])?.Employee is null) + if (_Model == null) { - _Model = new CustomerModel{Employee = MobileSessionFacade.LoggedInEmployee}; - Session[ModelSessionConstants.CustomerModelKey] = _Model; - } - else - { - _Model = (CustomerModel)Session[ModelSessionConstants.CustomerModelKey]; + _Model = new CustomerModel(); + + InitModel(_Model); + InitViewModel(); + } + //if (((CustomerModel) Session[ModelSessionConstants.CustomerModelKey])?.LoggedInEmployee is null) + //{ + // _Model = new CustomerModel(); + + // InitModel(_Model); + + // Session[ModelSessionConstants.CustomerModelKey] = _Model; + //} + //else + //{ + // _Model = (CustomerModel)Session[ModelSessionConstants.CustomerModelKey]; + //} + return _Model; } } + [Authorize] public ActionResult Customer(long? id) { @@ -55,12 +72,6 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } - var customerFilter = MobileUserSettingsUtils.GetSettingValueAsEnum(AbstractModel.UserSettings, SettingsKeys.CustomerFilterCustomers, CustomerFilterEnum.MyCustomer); - - Model.SelectedCustomerFilter = customerFilter; - - InitViewModel(); - if(id.HasValue) { LoadCustomerToModel(id); @@ -82,27 +93,70 @@ namespace BeWoPlanerMobil.Controllers private void InitViewModel() { - if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) + if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) { Logout(); return; } - if(Model.Employee?.EmployeeOid.HasValue ?? false) + + + if (Model.LoggedInEmployee?.EmployeeOid.HasValue ?? false) { - Model.Customers = EmployeeService.GetActiveCustomersForEmployee(Model.Employee.EmployeeOid.Value, Model.SelectedCustomerFilter).OrderBy(customer => customer.LastName).ToList(); + Model.Customers = EmployeeService.GetActiveCustomersForEmployee(Model.LoggedInEmployee.EmployeeOid.Value, Model.SelectedCustomerFilter).OrderBy(customer => customer.LastName).ToList(); } else { Model.Customers = new List(); } - if(AbstractModel.IsAllowedToSeeMedikamentenliste) + if (Model.CustomerSessionModel.SelectedCustomerOid.HasValue) + { + Model.SelectedCustomer = CustomerService.LoadCustomer(Model.CustomerSessionModel.SelectedCustomerOid.Value); + } + + if (Model.IsAllowedToSeeMedikamentenliste) { Model.ReportTypes = new List { CustomerReportType.Medikamentenliste, CustomerReportType.Bedarfsmedikation, CustomerReportType.Historie }; } - Model.AllAbsenceReasons = AbstractModel.HasRightToViewCustomerAbsenceTimes ? CustomerService.GetAllAbsenceReasons() : new List(); + Model.AllAbsenceReasons = Model.HasRightToViewCustomerAbsenceTimes ? CustomerService.GetAllAbsenceReasons() : new List(); + + + + if (Model.CustomerSessionModel.SelectedAbsenceTimeOid.HasValue && Model.SelectedCustomer != null) + { + Model.SelectedAbsenceTime = Model.SelectedCustomer.AbsenceTimes.FirstOrDefault(absenceTime => absenceTime.AbsenceTimeOid.HasValue && absenceTime.AbsenceTimeOid.Value.Equals(Model.CustomerSessionModel.SelectedAbsenceTimeOid.Value)); + } + + ReloadBargeldkassen(); + + + if (Model.CustomerSessionModel.SelectedBargeldkasseOid.HasValue && Model.Bargeldkassen != null) + { + Model.SelectedBargeldkasse = Model.Bargeldkassen.FirstOrDefault(bargeldkasse => bargeldkasse.BargeldkassenOid.HasValue && bargeldkasse.BargeldkassenOid.Value.Equals(Model.CustomerSessionModel.SelectedBargeldkasseOid.Value)); + } + + if (Model.CustomerSessionModel.SelectedBargeldtransaktionOid.HasValue) + { + var kassenbuch = GetBargeldkasseByTransaktionsOid(Model.CustomerSessionModel.SelectedBargeldtransaktionOid.Value); + + var zahlung = kassenbuch?.Bargeldtransaktionen.FirstOrDefault(bargeldtransaktion => bargeldtransaktion.BargeldtransaktionOid.Equals(Model.CustomerSessionModel.SelectedBargeldtransaktionOid.Value)); + + Model.SelectedBargeldtransaktion = zahlung; + } + + + if (Model.SelectedCustomer != null) + { + Model.FolderTree = OperationsService.GetFolderTree(TableID.Customer, Model.SelectedCustomer.CustomerOid.Value); + Model.ICD10Diagnosen = OperationsService.GetDiagiosisStringsForICD10Codes(Model.SelectedCustomer.ICD10DiagnosisCodes); + } + + + var customerFilter = MobileUserSettingsUtils.GetSettingValueAsEnum(Model.UserSettings, SettingsKeys.CustomerFilterCustomers, CustomerFilterEnum.MyCustomer); + + Model.SelectedCustomerFilter = customerFilter; } private void LoadCustomerToModel(long? customerOid) @@ -112,31 +166,30 @@ namespace BeWoPlanerMobil.Controllers return; } - if(customerOid == -1) + + + if (customerOid == -1) { - Model.SelectedCustomer = null; - Model.SelectedCustomerOid = null; - Model.FolderTree = null; - Model.ICD10Diagnosen = null; - Model.Bargeldkassen = new List(); - Model.BargeldtransaktionshistoryEntries = new List(); - Model.TransaktionsOid2HasHistoryEntries = new Dictionary(); - Model.SelectedBargeldtransaktion = null; + + Model.CustomerSessionModel.ResetValues(); + //Model.SelectedCustomer = null; + //Model.SelectedCustomerOid = null; + //Model.SelectedAbsenceTimeOid = null; + //Model.SelectedAbsenceReason = null; + //Model.FolderTree = null; + //Model.ICD10Diagnosen = null; + //Model.Bargeldkassen = new List(); + //Model.BargeldtransaktionshistoryEntries = new List(); + //Model.TransaktionsOid2HasHistoryEntries = new Dictionary(); + //Model.SelectedBargeldtransaktion = null; } else { - Model.FolderTree = OperationsService.GetFolderTree(TableID.Customer, customerOid.Value); - Model.SelectedCustomerOid = customerOid; - var customer = CustomerService.LoadCustomer(customerOid.Value); - - if(!(customer is null)) + if (Model.SelectedCustomerOid.HasValue && Model.SelectedCustomerOid != customerOid) { - Model.ICD10Diagnosen = OperationsService.GetDiagiosisStringsForICD10Codes(customer.ICD10DiagnosisCodes); + Model.CustomerSessionModel.ResetValues(); } - - Model.SelectedCustomer = customer; - - ReloadBargeldkassen(); + Model.SelectedCustomerOid = customerOid; } } @@ -146,7 +199,7 @@ namespace BeWoPlanerMobil.Controllers { try { - if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) + if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) { TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); @@ -295,7 +348,7 @@ namespace BeWoPlanerMobil.Controllers ObjectOid = Model.SelectedCustomerOid, BinaryData = fileData, FileAttachmentType = FileAttachmentType.NotSpecified, - InsertedBy = $"{Model.Employee.FirstName} {Model.Employee.LastName}", + InsertedBy = $"{Model.LoggedInEmployee.FirstName} {Model.LoggedInEmployee.LastName}", InsertedOn = DateTime.Now }; @@ -409,7 +462,7 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - var isAllowedToEdit = MobileSessionFacade.LoggedInUser.CheckForAtLeastOneRight(new List { UserRightType.CustomerView_Edit, UserRightType.EditAll }); + var isAllowedToEdit = LoggedInUser.CheckForAtLeastOneRight(new List { UserRightType.CustomerView_Edit, UserRightType.EditAll }); if(isAllowedToEdit && Model.SelectedCustomer != null) { @@ -557,7 +610,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult ShowMedList(int reportType) { - if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !AbstractModel.IsAllowedToSeeMedikamentenliste) + if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !Model.IsAllowedToSeeMedikamentenliste) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("BeWoReportPartial", Model); @@ -573,7 +626,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult ShowHistoricalMedList(long medListOid) { - if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !AbstractModel.IsAllowedToSeeMedikamentenliste) + if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !Model.IsAllowedToSeeMedikamentenliste) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("BeWoReportPartial", Model); @@ -589,7 +642,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult DeleteHistoricalMedList(long medListOid) { - if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !AbstractModel.IsAllowedToSeeMedikamentenliste) + if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !Model.IsAllowedToSeeMedikamentenliste) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("CustomerMedListPartial", Model); @@ -702,9 +755,10 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - var selectedBargeldkasse = Model.Bargeldkassen.FirstOrDefault(bargeldkasse => bargeldkasse.BargeldkassenOid.HasValue && bargeldkasse.BargeldkassenOid.Value.Equals(oid)); + //var selectedBargeldkasse = Model.Bargeldkassen.FirstOrDefault(bargeldkasse => bargeldkasse.BargeldkassenOid.HasValue && bargeldkasse.BargeldkassenOid.Value.Equals(oid)); - Model.SelectedBargeldkasse = selectedBargeldkasse; + //Model.SelectedBargeldkasse = selectedBargeldkasse; + Model.SelectedBargeldkasseOid = oid; return LeerzeichenFuerGetMethoden; } @@ -718,7 +772,8 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - Model.SelectedBargeldkasse = null; + //Model.SelectedBargeldkasse = null; + Model.SelectedBargeldkasseOid = null; return LeerzeichenFuerGetMethoden; } @@ -732,7 +787,7 @@ namespace BeWoPlanerMobil.Controllers return PartialView("CustomerBargeldkassenFormPartial", Model); } - Model.SelectedBargeldkasse = null; + Model.SelectedBargeldkasseOid = null; Model.SelectedAuszahlungsintervall = 0; return PartialView("CustomerBargeldkassenFormPartial", Model); @@ -747,6 +802,7 @@ namespace BeWoPlanerMobil.Controllers return PartialView("CustomerBargeldkassenFormPartial", Model); } + Model.SelectedBargeldkasseOid = bargeldkassenOid; Model.SelectedBargeldkasse = Model.Bargeldkassen.FirstOrDefault(bargeldkasse => bargeldkasse.BargeldkassenOid.HasValue && bargeldkasse.BargeldkassenOid.Value.Equals(bargeldkassenOid)); if(Model.SelectedBargeldkasse != null) @@ -778,7 +834,7 @@ namespace BeWoPlanerMobil.Controllers OperationsService.DeactivateBargeldkasse(bargeldkassenOid, bargeldkassenVersion); - ReloadBargeldkassen(); + //ReloadBargeldkassen(); return RedirectToActionPermanent("Customer"); } @@ -796,7 +852,7 @@ namespace BeWoPlanerMobil.Controllers var name = formCollection["bargeldkassenname"]; var rawAnfangsbestand = formCollection["bargeldkassenanfangsbestand"]; - decimal.TryParse(rawAnfangsbestand, out var anfangsbestand); + decimal.TryParse(rawAnfangsbestand.Replace(".", ","), out var anfangsbestand); var auszahlungsintervall = (Auszahlungsintervall) Model.SelectedAuszahlungsintervall; @@ -813,7 +869,7 @@ namespace BeWoPlanerMobil.Controllers OperationsService.InsertNewBargeldkasse(newBargeldkasse); - LoadCustomerToModel(Model.SelectedCustomerOid); + //LoadCustomerToModel(Model.SelectedCustomerOid); } else { @@ -830,10 +886,11 @@ namespace BeWoPlanerMobil.Controllers OperationsService.UpdateBargeldkasse(bargeldkasse); - LoadCustomerToModel(Model.SelectedCustomerOid); + //LoadCustomerToModel(Model.SelectedCustomerOid); } - Model.SelectedBargeldkasse = null; + //Model.SelectedBargeldkasse = null; + Model.SelectedBargeldkasseOid = null; return RedirectToActionPermanent("Customer"); } @@ -930,8 +987,9 @@ namespace BeWoPlanerMobil.Controllers { Model.SelectedTransaktionsart = (int) zahlung.Zahlungstyp; } - - Model.SelectedBargeldkasse = kassenbuch; + + //Model.SelectedBargeldkasse = kassenbuch; + Model.SelectedBargeldkasseOid = kassenbuch.BargeldkassenOid; return PartialView("CustomerBargeldtransaktionenFormPartial", Model); } @@ -961,7 +1019,8 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedBargeldtransaktion = null; Model.SelectedTransaktionsart = 0; - Model.SelectedBargeldkasse = Model.Bargeldkassen.FirstOrDefault(bk => bk.BargeldkassenOid.HasValue && bk.BargeldkassenOid.Equals(bargeldkassenOid)); + Model.SelectedBargeldkasseOid = bargeldkassenOid; + //Model.SelectedBargeldkasse = Model.Bargeldkassen.FirstOrDefault(bk => bk.BargeldkassenOid.HasValue && bk.BargeldkassenOid.Equals(bargeldkassenOid)); return PartialView("CustomerBargeldtransaktionenFormPartial", Model); } @@ -1027,7 +1086,7 @@ namespace BeWoPlanerMobil.Controllers OperationsService.UpdateBargeldkasse(bargeldkasse); - Model.SelectedBargeldkasse = null; + Model.SelectedBargeldkasseOid = null; ReloadBargeldkassen(); @@ -1069,7 +1128,7 @@ namespace BeWoPlanerMobil.Controllers return PartialView("CustomerBargeldkassen", Model); } - ReloadBargeldkassen(); +// ReloadBargeldkassen(); return PartialView("CustomerBargeldkassen", Model); } @@ -1125,7 +1184,7 @@ namespace BeWoPlanerMobil.Controllers OperationsService.UpdateBargeldkasse(bargeldkasse); } - ReloadBargeldkassen(); + //ReloadBargeldkassen(); return PartialView("CustomerBargeldkassen", Model); } @@ -1170,7 +1229,7 @@ namespace BeWoPlanerMobil.Controllers OperationsService.DeleteBargeldtransaktionSignature(signatureOid.Value); OperationsService.UpdateBargeldkasse(bargeldkasse); - ReloadBargeldkassen(); + //ReloadBargeldkassen(); } return PartialView("CustomerBargeldkassen", Model); @@ -1276,7 +1335,7 @@ namespace BeWoPlanerMobil.Controllers LoadCustomerToModel(customer.CustomerOid); Model.SelectedAbsenceTime = null; - Model.SelectedAbsenceReason = -1; + Model.SelectedAbsenceReasonOid = -1; return RedirectToActionPermanent("Customer", new { id = customer.CustomerOid }); } @@ -1305,8 +1364,8 @@ namespace BeWoPlanerMobil.Controllers //return "Es ist ein Fehler bei der Auswahl der zu bearbeitenden Abwesenheit aufgetreten.
Bitte wenden Sie sich an Ihren Systemadministrator."; } - Model.SelectedAbsenceTime = selectedAbsenceTime; - Model.SelectedAbsenceReason = selectedAbsenceTime.Reason.AbsenceReasonOid; + Model.SelectedAbsenceTimeOid = absenceTimeOid; + Model.SelectedAbsenceReasonOid = selectedAbsenceTime.Reason.AbsenceReasonOid; //return LeerzeichenFuerGetMethoden; return RedirectToActionPermanent("Customer", Model); @@ -1322,8 +1381,8 @@ namespace BeWoPlanerMobil.Controllers return "Es ist ein Fehler bei der Auswahl der zu bearbeitenden Abwesenheit aufgetreten.
Bitte wenden Sie sich an Ihren Systemadministrator."; } - Model.SelectedAbsenceTime = selectedAbsenceTime; - Model.SelectedAbsenceReason = selectedAbsenceTime.Reason.AbsenceReasonOid; + Model.SelectedAbsenceTimeOid = absenceTimeOid; + Model.SelectedAbsenceReasonOid = selectedAbsenceTime.Reason.AbsenceReasonOid; return LeerzeichenFuerGetMethoden; } @@ -1342,8 +1401,8 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public string DeselectAbsenceTime() { - Model.SelectedAbsenceTime = null; - Model.SelectedAbsenceReason = -1; + Model.SelectedAbsenceTimeOid = null; + Model.SelectedAbsenceReasonOid = -1; return LeerzeichenFuerGetMethoden; } diff --git a/BeWoPlanerMobil/Controllers/DebuggingToolsController.cs b/BeWoPlanerMobil/Controllers/DebuggingToolsController.cs index 1a129abda..281325174 100644 --- a/BeWoPlanerMobil/Controllers/DebuggingToolsController.cs +++ b/BeWoPlanerMobil/Controllers/DebuggingToolsController.cs @@ -18,16 +18,23 @@ namespace BeWoPlanerMobil.Controllers return null; } - if(((DebuggingToolsModel)Session[ModelSessionConstants.DebuggingToolsModelKey])?.Employee == null) + if (_Model == null) { - _Model = new DebuggingToolsModel { Employee = MobileSessionFacade.LoggedInEmployee }; - Session[ModelSessionConstants.DebuggingToolsModelKey] = _Model; - } - else - { - _Model = (DebuggingToolsModel) Session[ModelSessionConstants.DebuggingToolsModelKey]; + _Model = new DebuggingToolsModel(); + InitModel(_Model); } + //if (((DebuggingToolsModel)Session[ModelSessionConstants.DebuggingToolsModelKey])?.LoggedInEmployee is null) + //{ + // _Model = new DebuggingToolsModel(); + // InitModel(_Model); + // Session[ModelSessionConstants.DebuggingToolsModelKey] = _Model; + //} + //else + //{ + // _Model = (DebuggingToolsModel) Session[ModelSessionConstants.DebuggingToolsModelKey]; + //} + return _Model; } } diff --git a/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs b/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs index 81a744b45..3d19afac8 100644 --- a/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs +++ b/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs @@ -22,15 +22,21 @@ namespace BeWoPlanerMobil.Controllers return null; } - if (((DevExpressSchedulerModel)Session["DevExpressSchedulerModel"])?.Employee == null) + if (_Model == null) { - _Model = new DevExpressSchedulerModel { Employee = MobileSessionFacade.LoggedInEmployee }; - Session["DevExpressSchedulerModel"] = _Model; - } - else - { - _Model = (DevExpressSchedulerModel)Session["DevExpressSchedulerModel"]; + _Model = new DevExpressSchedulerModel(); + InitModel(_Model); } + //if (((DevExpressSchedulerModel)Session["DevExpressSchedulerModel"])?.LoggedInEmployee is null) + //{ + // _Model = new DevExpressSchedulerModel(); + // InitModel(_Model); + // Session["DevExpressSchedulerModel"] = _Model; + //} + //else + //{ + // _Model = (DevExpressSchedulerModel)Session["DevExpressSchedulerModel"]; + //} return _Model; } @@ -46,7 +52,7 @@ namespace BeWoPlanerMobil.Controllers var appointments = KalenderService.LoadFilteredAppointments( true, - Model?.Employee?.EmployeeOid ?? 1, + Model?.LoggedInEmployee?.EmployeeOid ?? 1, DateTime.Today.AddDays(-60), DateTime.Today.AddDays(60), new List(), diff --git a/BeWoPlanerMobil/Controllers/ExternalSignatureController.cs b/BeWoPlanerMobil/Controllers/ExternalSignatureController.cs index 03fa9e151..d4e2d08ac 100644 --- a/BeWoPlanerMobil/Controllers/ExternalSignatureController.cs +++ b/BeWoPlanerMobil/Controllers/ExternalSignatureController.cs @@ -31,16 +31,22 @@ namespace BeWoPlanerMobil.Controllers { get { - if((ExternalSignatureModel) Session["ExternalSignatureModel"] is null) + if (_Model == null) { _Model = new ExternalSignatureModel(); - Session["ExternalSignatureModel"] = _Model; - } - else - { - _Model = (ExternalSignatureModel) Session["ExternalSignatureModel"]; } + + //if((ExternalSignatureModel) Session["ExternalSignatureModel"] is null) + //{ + // _Model = new ExternalSignatureModel(); + // Session["ExternalSignatureModel"] = _Model; + //} + //else + //{ + // _Model = (ExternalSignatureModel) Session["ExternalSignatureModel"]; + //} + return _Model ?? new ExternalSignatureModel(); } } diff --git a/BeWoPlanerMobil/Controllers/LoginController.cs b/BeWoPlanerMobil/Controllers/LoginController.cs index 984fe8b4e..2e1953189 100644 --- a/BeWoPlanerMobil/Controllers/LoginController.cs +++ b/BeWoPlanerMobil/Controllers/LoginController.cs @@ -52,16 +52,16 @@ namespace BeWoPlanerMobil.Controllers } } - Log.Info($"LoginController.Index(): Loggedin User: {MobileSessionFacade.LoggedInUser.LoginName}"); + var user = LoggedInUser; + + Log.Info($"LoginController.Index(): Loggedin User: {user.LoginName}"); - MobileSessionFacade.Mandator = OperationsService.GetMandator(); + MobileSessionFacade.Mandator = DcToMokMapper.CreateMandator(OperationsService.GetMandator()); - var viewServiceRecords = AbstractModel.HasRightToSeeServiceRecords;//AbstractModel.CheckRight(UserRightType.ServiceRecordView_View); - var viewAll = AbstractModel.CheckRight(UserRightType.ViewAll); - - var user = UserService.LoadUser(MobileSessionFacade.LoggedInUser.Oid.Value); - var userGroups = user.UserGroups; + var viewServiceRecords = user.HasRight(UserRightType.ServiceRecordView_View) && user.HasRight(UserRightType.ServiceRecordView_Create); + var viewAll = user.HasRight(UserRightType.ViewAll); + //if(!MobileSessionFacade.LoggedInUser.UserGroups.Any(a => a.Rights.Any(f => f.RightType.Equals(UserRightType.ServiceRecordView_View))) && // !MobileSessionFacade.LoggedInUser.UserGroups.Any(a => a.Rights.Any(f => f.RightType.Equals(UserRightType.ViewAll)))) if(!viewServiceRecords && !viewAll) @@ -72,7 +72,7 @@ namespace BeWoPlanerMobil.Controllers return View("Index"); } - FormsAuthentication.SetAuthCookie(MobileSessionFacade.LoggedInUser.LoginName, true); + FormsAuthentication.SetAuthCookie(LoggedInUser.LoginName, true); ViewData[LoginErrorIndex] = string.Empty; var keks = new HttpCookie(MobileSessionFacade.CookieName) { Value = MobileSessionFacade.Tenant, Expires = DateTime.Now.AddDays(1) }; @@ -124,11 +124,11 @@ namespace BeWoPlanerMobil.Controllers Log.Info($"LoginController.Index(): Login failed! Tenant = {MobileSessionFacade.Tenant}"); - //ViewData[LoginErrorIndex] = Request.Browser.Browser.Equals("InternetExplorer") ? - // "Dieser Browser ist nicht mit dem mobilen BeWoPlaner kompatibel. Bitte benutzen Sie einen anderen Browser als den Internet Explorer." : - // "Die Anmeldung ist fehlgeschlagen. Bitte überprüfen Sie Benutzername und Passwort."; + ViewData[LoginErrorIndex] = Request.Browser.Browser.Equals("InternetExplorer") ? + "Dieser Browser ist nicht mit dem mobilen BeWoPlaner kompatibel. Bitte benutzen Sie einen anderen Browser als den Internet Explorer." : + "Die Anmeldung ist fehlgeschlagen. Bitte überprüfen Sie Benutzername und Passwort."; - return View("Index"); + return View("Index"); } catch(Exception e) { diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index 87b7f9a59..017c38f88 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -31,6 +31,9 @@ using FormCollection = System.Web.Mvc.FormCollection; using GoalRating = BeWoPlanerMobil.Util.GoalRating; using Image = System.Drawing.Image; using ServiceRecordDC = BS.Shared.DataContracts.ServiceRecordDC; +using BeWo.Data.Access; +using BeWo.Service.DCEntityMapper; +using BeWo.Data.Entities; /* * ToDo: Bug, wenn man auf "bearbeiten" bei einem Eintrag klickt, wird die Leistung nicht geladen @@ -52,16 +55,24 @@ namespace BeWoPlanerMobil.Controllers return null; } - if(((MainModel) Session[ModelSessionConstants.MainModelKey])?.Employee is null) + if (_Model == null) { - _Model = new MainModel { Employee = MobileSessionFacade.LoggedInEmployee }; - Session[ModelSessionConstants.MainModelKey] = _Model; - } - else - { - _Model = (MainModel) Session[ModelSessionConstants.MainModelKey]; + _Model = new MainModel(); + InitModel(_Model); + InitViewModel(); } + //if(((MainModel) Session[ModelSessionConstants.MainModelKey])?.LoggedInEmployee is null) + //{ + // _Model = new MainModel(); + // InitModel(_Model); + // Session[ModelSessionConstants.MainModelKey] = _Model; + //} + //else + //{ + // _Model = (MainModel) Session[ModelSessionConstants.MainModelKey]; + //} + return _Model; } } @@ -71,6 +82,286 @@ namespace BeWoPlanerMobil.Controllers private static readonly List _GoalTypes = new List { ValueListEntryType.SupportConceptGoalCategoryType, ValueListEntryType.SupportConceptIndividualGoalCategoryType }; private static readonly List _MeasureTypes = new List { ValueListEntryType.SupportConceptGoalType, ValueListEntryType.SupportConceptIndividualGoalType }; + public void InitViewModel() + { + InitSettings(); + + //Load SupportConcepts + if (Model.LoggedInEmployee?.EmployeeOid.HasValue ?? false) + { + Model.SupportConcepts = EmployeeService.GetActiveSupportConceptsForEmployee(Model.LoggedInEmployee.EmployeeOid, Model.SelectedSupportConceptFilter); + } + else + { + Model.SupportConcepts = new List(); + } + + if (Model.ShowExpiredSupportConcepts == false) + { + Model.SupportConcepts = Model.SupportConcepts.Where(supportConcept => + { + var endDate = MainModel.GetEndDateOfSupportConcept(supportConcept); + + return endDate is null || endDate.Value >= DateTime.Now.Date; + }).ToList(); + } + + + + Model.GroupsOfPeople = EmployeeService.GetAllGroups(LoggedInEmployee.EmployeeOid).OrderBy(gop => gop.Name).ToList(); + + Model.Dokutypes = ValueListService.GetAllValueListEntrysByType(ValueListEntryType.DocumentType); + if (Model.Dokutypes != null) + { + Model.Dokutypes = Model.Dokutypes.OrderBy(s => s.ValueListEntryOid).ToArray(); + } + + //Load Employees + if (Model.AllEmployees is null) + { + Model.AllEmployees = EmployeeService.GetAllActiveEmployeesCompact().OrderBy(e => e.LastName).ToList(); + } + + if (Model.EmployeesForGroupAndMultiBooking is null) + { + Model.EmployeesForGroupAndMultiBooking = EmployeeService.GetAllCompactEmployees().Where(e => e.ActivationType == ActivationTypeId.Active).OrderBy(e => e.LastName).ToList(); + } + + if (LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowCreationForOtherEmployees)) + { + Model.Employees = Model.AllEmployees; + } + else if (LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowCreationForOtherTeamMember) && Model.LoggedInEmployee.EmployeeOid != null) + { + Model.Employees = EmployeeService.GetAllTeamMember(LoggedInUser.Employee).Where(e => e.ActivationType == ActivationTypeId.Active).ToList(); + } + else + { + Model.Employees = new List { LoggedInUser.Employee }; + } + + Model.Employees = Model.Employees.OrderBy(e => e.LastName).ThenBy(e => e.FirstName).ToList(); + + + Model.SelectedConceptCostBearerRelations = new List(); + Model.MultiBookingSelectedConceptCostBearerRelations = new List(); + + Model.GoalRatingTypes = OperationsService.GetAllRatingTypes().OrderBy(o => o.Position).ToList(); + + SetSelectedObjects(); + } + + private void SetSelectedObjects() + { + if (Model.SelectedEmployeeOid.HasValue) + { + Model.SelectedEmployee = Model.AllEmployees.First(f => f.EmployeeOid.Equals(Model.SelectedEmployeeOid.Value)); + } + else + { + Model.SelectedEmployee = LoggedInUser.Employee; + } + + var isInList = Model.SelectedCostBearerSupportConceptOid.HasValue && Model.SupportConceptListObjects.Exists(s => s.CostBearer2SupportConceptOid == Model.SelectedCostBearerSupportConceptOid); + + if (!Model.SelectedCostBearerSupportConceptOid.HasValue || !isInList) + { + if (Model.SelectedCostBearerSupportConceptOid.HasValue && !isInList) + { + Log.Info($"Model.SelectedCostBearerSupportConceptOid = {Model.SelectedCostBearerSupportConceptOid} is not in list !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + + var sb = new StringBuilder(); + foreach (var o in Model.SupportConceptListObjects) + { + if (sb.Length > 0) + { + sb.Append(", "); + } + + sb.Append(o.CostBearer2SupportConceptOid); + } + + Log.Info($"Model.SupportConceptListObjects Oids = {sb}"); + } + + Model.SelectedCostBearer2SupportConceptRelListObject = Model.SupportConceptListObjects.FirstOrDefault(f => f.CostBearer2SupportConceptOid == -1) ?? Model.SupportConceptListObjects.First(); + Model.SelectedCostBearerSupportConceptOid = -1; + + Model.HasAnyRatingTypes = Model.HasRightToRateGoals && OperationsService.GetAllRatingTypes().Any(); + } + else + { + Model.SelectedCostBearer2SupportConceptRelListObject = Model.SupportConceptListObjects.FirstOrDefault(f => f.CostBearer2SupportConceptOid == Model.SelectedCostBearerSupportConceptOid) ?? Model.SupportConceptListObjects.First(); + } + + if (Model.SelectedSupportConceptOid.HasValue) + { + + } + + if (Model.SelectedConceptCostBearerRelationOids.Count > 0) + { + Model.SelectedConceptCostBearerRelations = CustomerService.GetSupportConceptCostBearerRelationsById(Model.SelectedConceptCostBearerRelationOids); + } + + + Model.GroupBookingSelectedEmployees = Model.AllEmployees.Where(employee => Model.GroupBookingSelectedEmployeeOids.Contains(employee.EmployeeOid)).ToList(); + Model.GroupBookingSelectedSupportConcepts = Model.SupportConcepts.Where(s => Model.GroupBookingSelectedSupportConceptOids.Contains(s.SupportConceptOid.Value)).ToList(); + //Model.Group = Model.SupportConceptListObjectsForGroupBooking.Where(s => Model.GroupBookingSelectedSupportConceptOids.Contains(s.SupportConceptOid.Value)).ToList(); + + if (Model.SelectedCostBearerSupportConceptOid.HasValue && Model.SelectedCostBearerSupportConceptOid != -1) + { + LoadSupportConceptThings(Model.SelectedCostBearerSupportConceptOid); + LoadPaginatedServiceRecordsToModel(Model.CurrentPage); + } + + if (Model.AllGoals != null) + { + Model.SelectedGoals = Model.AllGoals.Where(g => Model.SelectedGoalOids.Contains(g.ValueListEntryOid.Value)).ToList(); + } + + + } + + private void LoadSupportConceptThings(long? cb2ScOid) + { + LoadServiceCategoriesToModel(cb2ScOid); + + LoadGoals(); + + LoadTextModules(); + } + + private void InitSettings() + { + //Mandator Settings + Model.ShowBetrag = UserSettingsUtils.GetSettingValueAsBool(Model.Mandator.Settings, SettingsKeys.ShowBetrag); + Model.ShowMarker = UserSettingsUtils.GetSettingValueAsBool(Model.Mandator.Settings, SettingsKeys.ShowMarker); + Model.EinheitZeiterfassung = UserSettingsUtils.GetSettingValueAsInteger(Model.Mandator.Settings, SettingsKeys.EinheitZeiterfassung); + + /* + * Minuten: 0 + * Stunden: 1 + * Min & Std: 2 + */ + if (Model.EinheitZeiterfassung == 1) + { + Model.IsShowingDurationInHours = true; + } + + Model.FilterGroupServiceCategories = UserSettingsUtils.GetSettingValueAsBool(Model.Mandator.Settings, SettingsKeys.FilterGroupServiceCategories); + Model.SetStartTimeToEndTimeAfterSave = UserSettingsUtils.GetSettingValueAsBool(Model.Mandator.Settings, SettingsKeys.SetStartTimeToEndTimeAfterSave); + + Model.MokSettings = new MokSettings(); + + Model.MokSettings.SupportConceptExpirationLimitInMonths = UserSettingsUtils.GetSettingValueAsInteger(Model.Mandator.Settings, SettingsKeys.HilfeplanAuslaufAuswahl, 3); + Model.MokSettings.AnzTageZeiterfassErfolgt = UserSettingsUtils.GetSettingValueAsInteger(Model.Mandator.Settings, SettingsKeys.AnzTageZeiterfassErfolgt); + Model.MokSettings.MaxDaysEditServiceRecordsAllowed = UserSettingsUtils.GetSettingValueAsInteger(Model.Mandator.Settings, SettingsKeys.MaxDaysEditServiceRecordsAllowed); + Model.MokSettings.TimeUntilUILock = UserSettingsUtils.GetSettingValueAsInteger(Model.Mandator.Settings, SettingsKeys.TimeUntilUILock); + Model.MokSettings.ServiceRecordAllowChangeHours = UserSettingsUtils.GetSettingValueAsInteger(Model.Mandator.Settings, SettingsKeys.ServiceRecordAllowChangeHours); + + Model.ShowServiceRecordInsertedOn = !UserSettingsUtils.GetSettingValueAsBool(Model.Mandator.Settings, SettingsKeys.HideServiceRecordInsertedByAndInsertedOn); + + Model.ShowSignature = UserSettingsUtils.GetSettingValueAsBool(Model.Mandator.Settings, SettingsKeys.ShowSignature) && Model.HasRightToProvideSingleSignature; + + Model.ShowDistanceField = UserSettingsUtils.GetSettingValueAsBool(Model.Mandator.Settings, SettingsKeys.ShowDistanceFields); + + var settingsValue = GetSettingValue(Model.Mandator.Settings, SettingsKeys.IsServiceRecordNoticeMandatory); + + Model.IsServiceRecordNoticeMandatory = settingsValue is null || !settingsValue.Equals("0"); + + //User Settings + var user = LoggedInUser; + var userSettings = user?.Settings.FirstOrDefault(f => f.Type.Equals(SettingsType.ApplicationSettings))?.Value; + + Model.ShowExpiredSupportConcepts = UserSettingsUtils.GetSettingValueAsBool(userSettings, SettingsKeys.ShowExpiredSupportConcepts); + Model.ShowOnlyOwnSupportConcepts = UserSettingsUtils.GetSettingValueAsBool(userSettings, SettingsKeys.ShowOnlyMySupportConcepts); + Model.IsOnlyYearMonthVisible = UserSettingsUtils.GetSettingValueAsBool(userSettings, SettingsKeys.IsOnlyYearMonthVisible); + + Model.LastSelectedServiceRecordMonth = UserSettingsUtils.GetSettingValueAsDateTime(userSettings, SettingsKeys.LastSelectedServiceRecordMonth) ?? DateTime.Today; + + //int zeitraum; + var serviceRecordTimeInterval = UserSettingsUtils.GetSettingValueAsEnum(userSettings, SettingsKeys.LastSelectedServiceRecordTimeInterval, ServiceRecordTimeInterval.LastWeek); + + Model.ServiceRecordTimeInterval = serviceRecordTimeInterval; + + if (serviceRecordTimeInterval == ServiceRecordTimeInterval.ZeitraumWaehlen && (Model.SelectedZeitraum?.StartDate is null || Model.SelectedZeitraum.EndDate is null)) + { + var today = DateTime.Today; + Model.SelectedZeitraum = new NullableDateTimeSpan(today.GetFirstOfMonth(), today); + } + + Model.LastSelectedServiceRecordTimeIntervalDays = UserSettingsUtils.GetSettingValueAsInteger(userSettings, SettingsKeys.LastSelectedServiceRecordTimeIntervalDays); + + if (Model.ServiceRecordTimeInterval == ServiceRecordTimeInterval.Monatsauswahl) + { + Model.SelectedZeitraum = new NullableDateTimeSpan(Model.LastSelectedServiceRecordMonth.Date.GetFirstOfMonth(), Model.LastSelectedServiceRecordMonth.Date.GetLastOfMonth()); + } + + CalculateSelectedDayCount(Model.LastSelectedServiceRecordTimeIntervalDays, Model.LastSelectedServiceRecordMonth, Model.SelectedZeitraum?.StartDate, Model.SelectedZeitraum?.EndDate, null); + + var customerFilter = MobileUserSettingsUtils.GetSettingValueAsEnum(userSettings, SettingsKeys.CustomerFilterInZeiterfassung, CustomerFilterEnum.MyCustomer); + + if (customerFilter != CustomerFilterEnum.MyCustomer && !Model.IsAllowedToSeeSupportConceptFilter) + { + customerFilter = CustomerFilterEnum.MyCustomer; + } + + //if (Model.SelectedSupportConceptFilter == null) + + Model.SelectedSupportConceptFilter = customerFilter; + + Model.IsEndDateVisible = UserSettingsUtils.GetSettingValueAsBool(Model.Mandator.Settings, SettingsKeys.IsEndDateVisible); + + if (Model.IsZeiterfassungInStdMin) + { + var letzteZeiterfassungsdauer = UserSettingsUtils.GetSettingValueAsInteger(userSettings, SettingsKeys.LetzteZeiterfassungsDauer); + Model.IsShowingDurationInHours = letzteZeiterfassungsdauer == 1; + } + } + + public void LoadTextModules() + { + Model.TextModules.Clear(); + + if (Model.SelectedServiceCategoryOid.HasValue && (Model.LoggedInEmployee?.EmployeeOid.HasValue ?? false)) + { + var allTextModules = OperationsService.GetTextModules(Model.HasRightToSeeGlobalTextModules, Model.LoggedInEmployee.EmployeeOid.Value, Model.HasRightToSeeGlobalTextModules, false); + + foreach (var tm in allTextModules.Where(textModule => textModule.IsParent == false)) + { + if (string.IsNullOrWhiteSpace(tm.Text)) + { + tm.Text = tm.Name; + } + } + + Model.AllTextModules = allTextModules.Where(tb => tb.TextModuleOid.HasValue).Select(tb => new TextbausteinDisplayItem(tb.Name, tb.Text, tb.Parent?.TextModuleOid, tb.TextModuleOid.Value, tb.IsExpanded)).ToList(); + + var x = allTextModules.Where( + w => (w.ServiceCategory is null || w.ServiceCategory.ServiceCategoryOid == Model.SelectedServiceCategoryOid.Value) + && !string.IsNullOrEmpty(w.Text) + && (w.IsOnlyForEmployee && w.Employee.EmployeeOid.Equals(Model.LoggedInEmployee.EmployeeOid) || !w.IsOnlyForEmployee)).OrderBy(t => t.Text).ToList(); + + x.AddRangeIfElementsNotIn(BS.Shared.Core.Utils.GetParentTextModules(x)); + + var textModuleDisplayItems = x.Where(tb => tb.TextModuleOid.HasValue).Select(tb => new TextbausteinDisplayItem(tb.Name, tb.Text, tb.Parent?.TextModuleOid, tb.TextModuleOid.Value, tb.IsExpanded)).ToList(); + + foreach (var item in textModuleDisplayItems) + { + if (item.ParentOid is null) + { + continue; + } + + var parent = textModuleDisplayItems.FirstOrDefault(p => p.Oid == item.ParentOid); + + parent?.Children.AddIfNotIn(item); + } + + Model.TextModules = textModuleDisplayItems.Where(item => item.ParentOid is null).OrderBy(item => item.Name).ToList(); + } + } [Authorize] public ActionResult Main() @@ -89,10 +380,9 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } - if(Model.Mandator is null) + if (!Model.SessionInitialized) { - Model.Mandator = MobileSessionFacade.Mandator; - + Model.SessionInitialized = true; var mokSessionTimeout = UserSettingsUtils.GetSettingValueAsInteger(Model.Mandator.Settings, SettingsKeys.MoKSessionTimeout, 20); Session.Timeout = mokSessionTimeout; @@ -119,170 +409,9 @@ namespace BeWoPlanerMobil.Controllers } } - AbstractModel.ShowBetrag = UserSettingsUtils.GetSettingValueAsBool(Model.Mandator.Settings, SettingsKeys.ShowBetrag); - - Model.ShowMarker = UserSettingsUtils.GetSettingValueAsBool(Model.Mandator.Settings, SettingsKeys.ShowMarker); + } - var mandatorSettings = Model.Mandator.Settings; - - Model.EinheitZeiterfassung = UserSettingsUtils.GetSettingValueAsInteger(mandatorSettings, SettingsKeys.EinheitZeiterfassung); - - /* - * Minuten: 0 - * Stunden: 1 - * Min & Std: 2 - */ - if(Model.EinheitZeiterfassung == 1) - { - Model.IsShowingDurationInHours = true; - } - - Model.FilterGroupServiceCategories = UserSettingsUtils.GetSettingValueAsBool(mandatorSettings, SettingsKeys.FilterGroupServiceCategories); - - Model.SetStartTimeToEndTimeAfterSave = UserSettingsUtils.GetSettingValueAsBool(mandatorSettings, SettingsKeys.SetStartTimeToEndTimeAfterSave); - - var user = GetUser(); - var userSettings = user?.Settings.FirstOrDefault(f => f.Type.Equals(SettingsType.ApplicationSettings))?.Value; - - Model.ShowExpiredSupportConcepts = UserSettingsUtils.GetSettingValueAsBool(userSettings, SettingsKeys.ShowExpiredSupportConcepts); - Model.ShowOnlyOwnSupportConcepts = UserSettingsUtils.GetSettingValueAsBool(userSettings, SettingsKeys.ShowOnlyMySupportConcepts); - Model.IsOnlyYearMonthVisible = UserSettingsUtils.GetSettingValueAsBool(userSettings, SettingsKeys.IsOnlyYearMonthVisible); - - InitializeInterval(userSettings); - - var customerFilter = MobileUserSettingsUtils.GetSettingValueAsEnum(userSettings, SettingsKeys.CustomerFilterInZeiterfassung, CustomerFilterEnum.MyCustomer); - - if(customerFilter != CustomerFilterEnum.MyCustomer && !AbstractModel.IsAllowedToSeeSupportConceptFilter) - { - customerFilter = CustomerFilterEnum.MyCustomer; - } - - Model.SelectedSupportConceptFilter = customerFilter; - - BS.Shared.Settings.ApplicationSettings.SupportConceptExpirationLimitInMonths = UserSettingsUtils.GetSettingValueAsInteger(mandatorSettings, SettingsKeys.HilfeplanAuslaufAuswahl, 3); - BS.Shared.Settings.ApplicationSettings.AnzTageZeiterfassErfolgt = UserSettingsUtils.GetSettingValueAsInteger(mandatorSettings, SettingsKeys.AnzTageZeiterfassErfolgt); - BS.Shared.Settings.ApplicationSettings.MaxDaysEditServiceRecordsAllowed = UserSettingsUtils.GetSettingValueAsInteger(mandatorSettings, SettingsKeys.MaxDaysEditServiceRecordsAllowed); - BS.Shared.Settings.ApplicationSettings.TimeUntilUILock = UserSettingsUtils.GetSettingValueAsInteger(mandatorSettings, SettingsKeys.TimeUntilUILock); - BS.Shared.Settings.ApplicationSettings.ServiceRecordAllowChangeHours = UserSettingsUtils.GetSettingValueAsInteger(mandatorSettings, SettingsKeys.ServiceRecordAllowChangeHours); - - AbstractModel.ShowServiceRecordInsertedOn = !UserSettingsUtils.GetSettingValueAsBool(mandatorSettings, SettingsKeys.HideServiceRecordInsertedByAndInsertedOn); - - Model.ShowSignature = UserSettingsUtils.GetSettingValueAsBool(mandatorSettings, SettingsKeys.ShowSignature) && AbstractModel.HasRightToProvideSingleSignature; - - Model.GroupsOfPeople = EmployeeService.GetAllGroups(GetUser().Employee.EmployeeOid).OrderBy(gop => gop.Name).ToList(); - - AbstractModel.ShowDistanceField = UserSettingsUtils.GetSettingValueAsBool(mandatorSettings, SettingsKeys.ShowDistanceFields); - - Model.Dokutypes = ValueListService.GetAllValueListEntrysByType(ValueListEntryType.DocumentType); - if(Model.Dokutypes != null) - { - Model.Dokutypes = Model.Dokutypes.OrderBy(s => s.ValueListEntryOid).ToArray(); - } - - if(Model.AllEmployees is null) - { - Model.AllEmployees = EmployeeService.GetAllActiveEmployeesCompact().OrderBy(e => e.LastName).ToList(); - } - - if(Model.EmployeesForGroupAndMultiBooking is null) - { - Model.EmployeesForGroupAndMultiBooking = EmployeeService.GetAllCompactEmployees().Where(e => e.ActivationType == ActivationTypeId.Active).OrderBy(e => e.LastName).ToList(); - } - - if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreationForOtherEmployees)) - { - Model.Employees = EmployeeService.GetAllActiveEmployeesCompact(); - } - else if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreationForOtherTeamMember) && Model.Employee?.EmployeeOid != null) - { - Model.Employees = EmployeeService.GetAllTeamMember(MobileSessionFacade.LoggedInCompactEmployee).Where(e => e.ActivationType == ActivationTypeId.Active).ToList(); - } - else - { - Model.Employees = new List { MobileSessionFacade.LoggedInCompactEmployee }; - } - - Model.Employees = Model.Employees.OrderBy(e => e.LastName).ThenBy(e => e.FirstName).ToList(); - - if(Model.Employee?.EmployeeOid.HasValue ?? false) - { - Model.SupportConcepts = EmployeeService.GetActiveSupportConceptsForEmployee(Model.Employee.EmployeeOid, Model.SelectedSupportConceptFilter); - } - else - { - Model.SupportConcepts = new List(); - } - - if(Model.ShowExpiredSupportConcepts == false) - { - Model.SupportConcepts = Model.SupportConcepts.Where(supportConcept => - { - var endDate = MainModel.GetEndDateOfSupportConcept(supportConcept); - - return endDate is null || endDate.Value >= DateTime.Now.Date; - }).ToList(); - } - - if(Model.SelectedConceptCostBearerRelations is null) - { - Model.SelectedConceptCostBearerRelations = new List(); - } - - if(Model.MultiBookingSelectedConceptCostBearerRelations is null) - { - Model.MultiBookingSelectedConceptCostBearerRelations = new List(); - } - - if(Model.SelectedEmployee is null) - { - Model.SelectedEmployee = MobileSessionFacade.LoggedInCompactEmployee; - } - - var settingsValue = GetSettingValue(mandatorSettings, SettingsKeys.IsServiceRecordNoticeMandatory); - - Model.IsServiceRecordNoticeMandatory = settingsValue is null || !settingsValue.Equals("0"); - - var isInList = !(Model.SelectedCostBearer2SupportConceptRelListObject is null) && Model.SupportConceptListObjects.Contains(Model.SelectedCostBearer2SupportConceptRelListObject); - - if(Model.SelectedCostBearer2SupportConceptRelListObject is null || !isInList) - { - if(Model.SelectedCostBearer2SupportConceptRelListObject != null && !isInList) - { - Log.Info($"Model.SelectedSupportConceptListObject.Oid = {Model.SelectedCostBearer2SupportConceptRelListObject.CostBearer2SupportConceptOid} is not in list !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - - var sb = new StringBuilder(); - foreach(var o in Model.SupportConceptListObjects) - { - if (sb.Length > 0) - { - sb.Append(", "); - } - - sb.Append(o.CostBearer2SupportConceptOid); - } - - Log.Info($"Model.SupportConceptListObjects Oids = {sb}"); - } - - Model.SelectedCostBearer2SupportConceptRelListObject = Model.SupportConceptListObjects.FirstOrDefault(f => f.CostBearer2SupportConceptOid == "-1") ?? Model.SupportConceptListObjects.First(); - Model.CostBearer2SupportConceptOid = -1; - - Model.HasAnyRatingTypes = AbstractModel.HasRightToRateGoals && OperationsService.GetAllRatingTypes().Any(); - } - - if(!(Model.CostBearer2SupportConceptOid is null) && Model.CostBearer2SupportConceptOid != -1) - { - LoadPaginatedServiceRecordsToModel(Model.CurrentPage); - } - - Model.IsEndDateVisible = UserSettingsUtils.GetSettingValueAsBool(mandatorSettings, SettingsKeys.IsEndDateVisible); - - if(Model.IsZeiterfassungInStdMin) - { - var letzteZeiterfassungsdauer = UserSettingsUtils.GetSettingValueAsInteger(userSettings, SettingsKeys.LetzteZeiterfassungsDauer); - Model.IsShowingDurationInHours = letzteZeiterfassungsdauer == 1; - } } catch(Exception e) { @@ -292,31 +421,8 @@ namespace BeWoPlanerMobil.Controllers return View(Model); } - [Authorize] - private void InitializeInterval(string userSettings) - { - Model.LastSelectedServiceRecordMonth = UserSettingsUtils.GetSettingValueAsDateTime(userSettings, SettingsKeys.LastSelectedServiceRecordMonth) ?? DateTime.Today; - //int zeitraum; - var serviceRecordTimeInterval = UserSettingsUtils.GetSettingValueAsEnum(userSettings, SettingsKeys.LastSelectedServiceRecordTimeInterval, ServiceRecordTimeInterval.LastWeek); - - Model.ServiceRecordTimeInterval = serviceRecordTimeInterval; - - if(serviceRecordTimeInterval == ServiceRecordTimeInterval.ZeitraumWaehlen && (Model.SelectedZeitraum?.StartDate is null || Model.SelectedZeitraum.EndDate is null)) - { - var today = DateTime.Today; - Model.SelectedZeitraum = new NullableDateTimeSpan(today.GetFirstOfMonth(), today); - } - - Model.LastSelectedServiceRecordTimeIntervalDays = UserSettingsUtils.GetSettingValueAsInteger(userSettings, SettingsKeys.LastSelectedServiceRecordTimeIntervalDays); - - if(Model.ServiceRecordTimeInterval == ServiceRecordTimeInterval.Monatsauswahl) - { - Model.SelectedZeitraum = new NullableDateTimeSpan(Model.LastSelectedServiceRecordMonth.Date.GetFirstOfMonth(), Model.LastSelectedServiceRecordMonth.Date.GetLastOfMonth()); - } - - CalculateSelectedDayCount(Model.LastSelectedServiceRecordTimeIntervalDays, Model.LastSelectedServiceRecordMonth, Model.SelectedZeitraum?.StartDate, Model.SelectedZeitraum?.EndDate, null); - } + [Authorize] private void UpdateSettings(string key, string value) @@ -326,7 +432,7 @@ namespace BeWoPlanerMobil.Controllers return; } - var loggedInUser = GetUser(); + var loggedInUser = LoggedInUser; if(loggedInUser?.UserOid is null) { @@ -363,22 +469,11 @@ namespace BeWoPlanerMobil.Controllers return base.Logout(); } - #region Ziele und Maßnahmen - [Authorize] - public void LoadGoalRatings() - { - if(Model is null || !AbstractModel.HasRightToRateGoals) - { - return; - } - - Model.GoalRatingTypes = OperationsService.GetAllRatingTypes().OrderBy(o => o.Position).ToList(); - } [Authorize] public string RateSelectedGoal(long? ratingTypeOid, long? goalOid) { - if(Model is null || ratingTypeOid is null || goalOid is null || !AbstractModel.HasRightToRateGoals) + if(Model is null || ratingTypeOid is null || goalOid is null || !Model.HasRightToRateGoals) { return LeerzeichenFuerGetMethoden; } @@ -453,8 +548,8 @@ namespace BeWoPlanerMobil.Controllers } } - [Authorize] - public void LoadGoals() + + private void LoadGoals() { try { @@ -473,16 +568,16 @@ namespace BeWoPlanerMobil.Controllers } else { - if(Model.CostBearer2SupportConceptOid is null) + if(Model.SelectedCostBearerSupportConceptOid is null) { return; } - var supportConcept = Model.SupportConcepts.FirstOrDefault(sc => sc.CostBearerRelations.Any(sc2Cb => sc2Cb.CostBearer2SupportConceptOid.HasValue && sc2Cb.CostBearer2SupportConceptOid.Value.Equals(Model.CostBearer2SupportConceptOid.Value))); + var supportConcept = Model.SupportConcepts.FirstOrDefault(sc => sc.CostBearerRelations.Any(sc2Cb => sc2Cb.CostBearer2SupportConceptOid.HasValue && sc2Cb.CostBearer2SupportConceptOid.Value.Equals(Model.SelectedCostBearerSupportConceptOid.Value))); if(supportConcept is null) { - Log.Info($"Hilfeplan von Bewilligung mit Oid {Model.CostBearer2SupportConceptOid} nicht gefunden beim Laden der Ziele (LoadGoals)."); + Log.Info($"Hilfeplan von Bewilligung mit Oid {Model.SelectedCostBearerSupportConceptOid} nicht gefunden beim Laden der Ziele (LoadGoals)."); return; } @@ -503,7 +598,7 @@ namespace BeWoPlanerMobil.Controllers } var allGoals = selectedGoals.Union(_ParentGoals.Values).ToList(); - + Model.AllGoals = allGoals; Model.GoalTree = BuildGoalTree(allGoals); } catch(Exception exception) @@ -636,7 +731,7 @@ namespace BeWoPlanerMobil.Controllers break; } } - #endregion + [Authorize] public string LoadStatistics(long oid) @@ -908,46 +1003,47 @@ namespace BeWoPlanerMobil.Controllers TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("TextModulePartial"); } + //Wird alles im InitViewModel gemacht: - Model.TextModules.Clear(); + //Model.TextModules.Clear(); - if(Model.SelectedServiceCategoryOid.HasValue && (Model.Employee?.EmployeeOid.HasValue ?? false)) - { - var allTextModules = OperationsService.GetTextModules(AbstractModel.HasRightToSeeGlobalTextModules, Model.Employee.EmployeeOid.Value, AbstractModel.HasRightToSeeGlobalTextModules, false); + //if(Model.SelectedServiceCategoryOid.HasValue && (Model.LoggedInEmployee?.EmployeeOid.HasValue ?? false)) + //{ + // var allTextModules = OperationsService.GetTextModules(Model.HasRightToSeeGlobalTextModules, Model.LoggedInEmployee.EmployeeOid.Value, Model.HasRightToSeeGlobalTextModules, false); - foreach(var tm in allTextModules.Where(textModule => textModule.IsParent == false)) - { - if(string.IsNullOrWhiteSpace(tm.Text)) - { - tm.Text = tm.Name; - } - } + // foreach(var tm in allTextModules.Where(textModule => textModule.IsParent == false)) + // { + // if(string.IsNullOrWhiteSpace(tm.Text)) + // { + // tm.Text = tm.Name; + // } + // } - Model.AllTextModules = allTextModules.Where(tb => tb.TextModuleOid.HasValue).Select(tb => new TextbausteinDisplayItem(tb.Name, tb.Text, tb.Parent?.TextModuleOid, tb.TextModuleOid.Value, tb.IsExpanded)).ToList(); + // Model.AllTextModules = allTextModules.Where(tb => tb.TextModuleOid.HasValue).Select(tb => new TextbausteinDisplayItem(tb.Name, tb.Text, tb.Parent?.TextModuleOid, tb.TextModuleOid.Value, tb.IsExpanded)).ToList(); - var x = allTextModules.Where( - w => (w.ServiceCategory is null || w.ServiceCategory.ServiceCategoryOid == Model.SelectedServiceCategoryOid.Value) - && !string.IsNullOrEmpty(w.Text) - && (w.IsOnlyForEmployee && w.Employee.EmployeeOid.Equals(Model.Employee.EmployeeOid) || !w.IsOnlyForEmployee)).OrderBy(t => t.Text).ToList(); + // var x = allTextModules.Where( + // w => (w.ServiceCategory is null || w.ServiceCategory.ServiceCategoryOid == Model.SelectedServiceCategoryOid.Value) + // && !string.IsNullOrEmpty(w.Text) + // && (w.IsOnlyForEmployee && w.Employee.EmployeeOid.Equals(Model.LoggedInEmployee.EmployeeOid) || !w.IsOnlyForEmployee)).OrderBy(t => t.Text).ToList(); - x.AddRangeIfElementsNotIn(Utils.GetParentTextModules(x)); + // x.AddRangeIfElementsNotIn(BS.Shared.Core.Utils.GetParentTextModules(x)); - var textModuleDisplayItems = x.Where(tb => tb.TextModuleOid.HasValue).Select(tb => new TextbausteinDisplayItem(tb.Name, tb.Text, tb.Parent?.TextModuleOid, tb.TextModuleOid.Value, tb.IsExpanded)).ToList(); + // var textModuleDisplayItems = x.Where(tb => tb.TextModuleOid.HasValue).Select(tb => new TextbausteinDisplayItem(tb.Name, tb.Text, tb.Parent?.TextModuleOid, tb.TextModuleOid.Value, tb.IsExpanded)).ToList(); - foreach(var item in textModuleDisplayItems) - { - if(item.ParentOid is null) - { - continue; - } + // foreach(var item in textModuleDisplayItems) + // { + // if(item.ParentOid is null) + // { + // continue; + // } - var parent = textModuleDisplayItems.FirstOrDefault(p => p.Oid == item.ParentOid); + // var parent = textModuleDisplayItems.FirstOrDefault(p => p.Oid == item.ParentOid); - parent?.Children.AddIfNotIn(item); - } + // parent?.Children.AddIfNotIn(item); + // } - Model.TextModules = textModuleDisplayItems.Where(item => item.ParentOid is null).OrderBy(item => item.Name).ToList(); - } + // Model.TextModules = textModuleDisplayItems.Where(item => item.ParentOid is null).OrderBy(item => item.Name).ToList(); + //} return PartialView("TextModulePartial", Model); } @@ -960,17 +1056,18 @@ namespace BeWoPlanerMobil.Controllers { if(Model is null) { - Log.Info($"Model ist null bei CreateOrUpdateServiceRecord; User: {MobileSessionFacade.LoggedInUser.Oid} {MobileSessionFacade.LoggedInUser.LoginName} ({MobileSessionFacade.LoggedInUser.Employee})"); + Log.Info($"Model ist null bei CreateOrUpdateServiceRecord; User: {LoggedInUser.UserOid} {LoggedInUser.LoginName} ({LoggedInUser.Employee})"); TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); } // Falls ein Termin in die Zeiterfassung übernommen werden soll - AppointmentListItem appointmentListItemPrototype = null; + SchedulerAppointmentDC appointmentPrototype = null; - if(TempData[TempDataConstants.AppointmentListItemKey] is AppointmentListItem appointmentListItem && Model.Employee.EmployeeOid.HasValue) + if(TempData[TempDataConstants.AppointmentOidKey] != null && Int64.TryParse(TempData[TempDataConstants.AppointmentOidKey].ToString(), out var appOid) && Model.LoggedInEmployee.EmployeeOid.HasValue) { - appointmentListItemPrototype = appointmentListItem; + var app = DAOFactory.GenericDAO.LoadByID(appOid); + appointmentPrototype = MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDC(app); } var marker = "on" == collection[FormCollectionConstants.MarkerKey]; @@ -1011,7 +1108,7 @@ namespace BeWoPlanerMobil.Controllers } } - var selectedCostbearerScRelOid = Model.CostBearer2SupportConceptOid < 1 ? null : Model.CostBearer2SupportConceptOid; + var selectedCostbearerScRelOid = Model.SelectedCostBearerSupportConceptOid < 1 ? null : Model.SelectedCostBearerSupportConceptOid; var datum = Convert.ToDateTime(collection[FormCollectionConstants.DateKey]); var enddatum = datum; @@ -1098,11 +1195,11 @@ namespace BeWoPlanerMobil.Controllers Model.NewServiceRecord.DistanceInMeter = null; Model.NewServiceRecord.DistanceInMeterDecimal = distanceInMeters; - if(Model.Employee.EmployeeOid.HasValue) + if(Model.LoggedInEmployee.EmployeeOid.HasValue) { if(!Model.IsInEditingMode) { - Model.NewServiceRecord.Employee = Model.SelectedEmployee ?? MobileSessionFacade.LoggedInCompactEmployee; + Model.NewServiceRecord.Employee = Model.SelectedEmployee ?? LoggedInUser.Employee; } else { @@ -1118,7 +1215,7 @@ namespace BeWoPlanerMobil.Controllers { if(sc.SupportConceptOid.HasValue) { - Model.NewServiceRecord.SupportConcept = CustomerService.LoadCompactSupportConceptDC(sc.SupportConceptOid.Value, Model.Employee.EmployeeOid); + Model.NewServiceRecord.SupportConcept = CustomerService.LoadCompactSupportConceptDC(sc.SupportConceptOid.Value, Model.LoggedInEmployee.EmployeeOid); } Model.NewServiceRecord.Customer = sc.Customer; @@ -1184,7 +1281,7 @@ namespace BeWoPlanerMobil.Controllers Model.NewServiceRecord.IP = Request.UserHostAddress; Model.NewServiceRecord.InsertedOn = DateTime.Now; - Model.NewServiceRecord.InsUser = $"{MobileSessionFacade.LoggedInEmployee.FirstName} {MobileSessionFacade.LoggedInEmployee.LastName}"; + Model.NewServiceRecord.InsUser = MobileSessionFacade.EmployeeFullname; Model.NewServiceRecord.IsCreatedInMobileClient = true; if(Model.IsInGroupBookingMode && Model.GroupBookingSelectedSupportConcepts.Count > 1) @@ -1196,58 +1293,56 @@ namespace BeWoPlanerMobil.Controllers { var oidList = OperationsService.InsertNewServiceRecords(new List { Model.NewServiceRecord }); - Model.ServiceRecordOid = oidList[0]; + Model.LastCreatedServiceRecordOid = oidList[0]; if(Model.NewServiceRecord.CostBearer != null && Model.ShowSignature) { TempData[TempDataConstants.ShowSignatureSuggestionPopup] = true; } - if(!(appointmentListItemPrototype is null)) + if(!(appointmentPrototype is null)) { - var appointment = appointmentListItemPrototype.SchedulerAppointment; + var isRecurring = !(appointmentPrototype.RecurrenceInfo is null); - var isRecurring = !(appointment.RecurrenceInfo is null); - - if(isRecurring && appointment.Type != (int) AppointmentType.ChangedOccurrence) + if(isRecurring && appointmentPrototype.Type != (int) AppointmentType.ChangedOccurrence) { - var id = appointment.RecurrenceIdReference; + var id = appointmentPrototype.RecurrenceIdReference; var recurrenceInfo = new RecurrenceInfo(); - recurrenceInfo.FromXml(appointment.RecurrenceInfo); + recurrenceInfo.FromXml(appointmentPrototype.RecurrenceInfo); var occurrenceCalculator = OccurrenceCalculator.CreateInstance(recurrenceInfo); var pattern = StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern); - pattern.RecurrenceInfo.FromXml(appointment.RecurrenceInfo); + pattern.RecurrenceInfo.FromXml(appointmentPrototype.RecurrenceInfo); pattern.Start = pattern.RecurrenceInfo.Start; pattern.End = pattern.RecurrenceInfo.End; - var occurrence = occurrenceCalculator.CalcOccurrences(new TimeInterval(appointment.StartDate.Value, appointment.EndDate.Value), pattern).FirstOrDefault(); + var occurrence = occurrenceCalculator.CalcOccurrences(new TimeInterval(appointmentPrototype.StartDate.Value, appointmentPrototype.EndDate.Value), pattern).FirstOrDefault(); if(!(occurrence is null)) { var index = occurrence.RecurrenceIndex; - appointment = SchedulerController.CloneAppointment(appointment, $"", (int)AppointmentType.ChangedOccurrence); + appointmentPrototype = SchedulerController.CloneAppointment(appointmentPrototype, $"", (int)AppointmentType.ChangedOccurrence); } else { - appointment = null; + appointmentPrototype = null; } } - if(!(appointment is null)) + if(!(appointmentPrototype is null)) { - var serviceRecord = OperationsService.GetServiceRecordById(Model.ServiceRecordOid); + var serviceRecord = OperationsService.GetServiceRecordById(Model.LastCreatedServiceRecordOid); - appointment.ServiceRecordList.AddIfNotIn(serviceRecord); + appointmentPrototype.ServiceRecordList.AddIfNotIn(serviceRecord); - if(appointment.SchedulerAppointmentOid.HasValue) + if(appointmentPrototype.SchedulerAppointmentOid.HasValue) { - KalenderService.UpdateSchedulerAppointments(new List { appointment }); + KalenderService.UpdateSchedulerAppointments(new List { appointmentPrototype }); } else { - KalenderService.InsertSchedulerAppointments(new List { appointment }); + KalenderService.InsertSchedulerAppointments(new List { appointmentPrototype }); } } } @@ -1344,9 +1439,10 @@ namespace BeWoPlanerMobil.Controllers var serviceRecords = groupDC.ServiceRecordList; - if(TempData[TempDataConstants.AppointmentListItemKey] is AppointmentListItem appointmentListItem && Model.Employee.EmployeeOid.HasValue) + if (TempData[TempDataConstants.AppointmentOidKey] != null && Int64.TryParse(TempData[TempDataConstants.AppointmentOidKey].ToString(), out var appOid) && Model.LoggedInEmployee.EmployeeOid.HasValue) { - var appointment = appointmentListItem.SchedulerAppointment; + var app = DAOFactory.GenericDAO.LoadByID(appOid); + var appointment = MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDC(app); appointment.ServiceRecordList.AddRange(serviceRecords); @@ -1484,6 +1580,7 @@ namespace BeWoPlanerMobil.Controllers Model.NewServiceRecord = null; Model.SelectedServiceRecord = null; + Model.SelectedServiceRecordOid = null; Model.GroupBookingSelectedSupportConcepts = new List(); Model.GroupBookingSelectedEmployees = new List(); @@ -1496,7 +1593,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] private IEnumerable CalculateGroupBookingDuration(int pEmployeeCount, int pCustomerCount, ICollection cb2ScOids) { - var compactSupportConcepts = CustomerServiceImp.GetCompactSupportConcepts((from sc in Model.GroupBookingSelectedSupportConcepts where sc.SupportConceptOid != null select sc.SupportConceptOid.Value).ToList(), GetUser().Employee.EmployeeOid); + var compactSupportConcepts = CustomerServiceImp.GetCompactSupportConcepts((from sc in Model.GroupBookingSelectedSupportConcepts where sc.SupportConceptOid != null select sc.SupportConceptOid.Value).ToList(), LoggedInUser.Employee.EmployeeOid); var nodes = (from supportConcept in Model.GroupBookingSelectedSupportConcepts let cb = supportConcept.CostBearerRelations.FirstOrDefault(f => cb2ScOids.Contains(f.CostBearer2SupportConceptOid.Value)) let sc = compactSupportConcepts.FirstOrDefault(f => f.SupportConceptOid == supportConcept.SupportConceptOid) where cb != null && sc != null select SupportConceptService.CreateFlatSupportConceptItem(sc, CustomerService.LoadOrganisationCompact(cb.CostBearer.OrganisationOid))).ToList(); @@ -1722,7 +1819,7 @@ namespace BeWoPlanerMobil.Controllers { try { - if(Model is null) + if (Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); @@ -1730,9 +1827,7 @@ namespace BeWoPlanerMobil.Controllers long? cb2ScOid = Convert.ToInt64(formCollection[FormCollectionConstants.CostBearer2SupportConceptOidKey]); - Model.SelectedCostBearerSupportConceptRelOid = cb2ScOid; - - LoadSupportConceptThings(cb2ScOid); + Model.SelectedCostBearerSupportConceptOid = cb2ScOid; return RedirectToActionPermanent("Main");//ResetEditingMode(); } @@ -1746,22 +1841,19 @@ namespace BeWoPlanerMobil.Controllers private void LoadServiceCategoriesToModel(long? cb2ScOid) { - if(Model is null) - { - Log.Info($"Model ist null in Methode LoadServiceCategoriesToModel({cb2ScOid})"); - return; - } - + if(Model.Categories2Descriptions is null) { Model.Categories2Descriptions = new Dictionary>(); } Model.Categories2Descriptions.Clear(); - Model.SelectedServiceCategory = null; - Model.SelectedServiceDescription = null; + //Model.SelectedServiceCategory = null; + //Model.SelectedServiceCategoryOid = null; + //Model.SelectedServiceDescription = null; + //Model.SelectedServiceDescriptionOid = null; - if(cb2ScOid is null && (Model.IsInGroupBookingMode || Model.IsInMultiBookingMode)) + if (cb2ScOid is null && (Model.IsInGroupBookingMode || Model.IsInMultiBookingMode)) { Log.Info("Oid der Bewilligung ist null und der MoK befindet sich im Gruppen- oder Mehrfachbuchungsmodus"); @@ -1781,20 +1873,20 @@ namespace BeWoPlanerMobil.Controllers return; } - Model.CostBearer2SupportConceptOid = cb2ScOid; + Model.SelectedCostBearerSupportConceptOid = cb2ScOid; Model.SelectedSupportConcept = Model.SupportConcepts.FirstOrDefault( supportConcept => supportConcept.CostBearerRelations.Any( supportConceptCostBearerRel => supportConceptCostBearerRel.CostBearer2SupportConceptOid.HasValue && - supportConceptCostBearerRel.CostBearer2SupportConceptOid.Value.Equals(Model.CostBearer2SupportConceptOid))); + supportConceptCostBearerRel.CostBearer2SupportConceptOid.Value.Equals(Model.SelectedCostBearerSupportConceptOid))); if(Model.SelectedSupportConcept != null) { - Model.SelectedCostBearer2SupportConceptRelListObject = Model.SupportConceptListObjects.First(f => long.Parse(f.CostBearer2SupportConceptOid) == cb2ScOid); + Model.SelectedCostBearer2SupportConceptRelListObject = Model.SupportConceptListObjects.First(f => f.CostBearer2SupportConceptOid == cb2ScOid); - var node = OperationsService.GetSupportConceptTreeNodeDetailInfo(Model.SelectedSupportConcept.Customer.CustomerOid, Model.SelectedSupportConcept.SupportConceptOid, Model.CostBearer2SupportConceptOid); + var node = OperationsService.GetSupportConceptTreeNodeDetailInfo(Model.SelectedSupportConcept.Customer.CustomerOid, Model.SelectedSupportConcept.SupportConceptOid, Model.SelectedCostBearerSupportConceptOid); Model.Categories2Descriptions = CreateServiceCategory2ServiceDescription(new List { node }, false); } @@ -1802,7 +1894,7 @@ namespace BeWoPlanerMobil.Controllers { var allServiceDescriptions = OperationsService.GetAllServiceDescriptions(); - Model.SelectedCostBearer2SupportConceptRelListObject = Model.SupportConceptListObjects.First(f => f.CostBearer2SupportConceptOid.Equals(cb2ScOid.ToString())); + Model.SelectedCostBearer2SupportConceptRelListObject = Model.SupportConceptListObjects.First(f => f.CostBearer2SupportConceptOid == cb2ScOid); if(Model.Categories2Descriptions is null) { @@ -1863,24 +1955,56 @@ namespace BeWoPlanerMobil.Controllers private void SelectFirstServiceDescription() { - if(Model?.Categories2Descriptions is null || Model.Categories2Descriptions.Count == 0|| Model.SelectedServiceDescription != null || Model.SelectedServiceCategory != null) + if (Model?.Categories2Descriptions is null || Model.Categories2Descriptions.Count == 0) { + UpdateSelectedServiceCategorieAndDescription(null, null); return; } + //Nur, wenn Kategorie und Leistung null sind oder nicht in der Liste alle Kategorien enthalten sind, soll weiter unten die erste Leistung in der Liste gesetzt werden + if (Model.SelectedServiceCategoryOid.HasValue && Model.SelectedServiceDescriptionOid.HasValue) + { + var cat = Model.Categories2Descriptions.Keys.Where(c => c.ServiceCategoryOid == Model.SelectedServiceCategoryOid).FirstOrDefault(); + if (cat != null) + { + var desc = Model.Categories2Descriptions[cat].Where(d => d.ServiceDescriptionOid == Model.SelectedServiceDescriptionOid).FirstOrDefault(); + + if (desc != null) + { + //Setzte Objekte im Model, sonst wird unten die erste Leistung gesetzt + Model.SelectedServiceCategory = cat; + Model.SelectedServiceDescription = desc; + + return; + } + } + } + + + var firstServiceCategory2ServiceDescriptions = Model.Categories2Descriptions.OrderBy(c2d => c2d.Key.Position).ThenBy(c2d => c2d.Key.ServiceCategoryOid).FirstOrDefault(c2d => c2d.Value.Any()); if(firstServiceCategory2ServiceDescriptions.Key is null) { + UpdateSelectedServiceCategorieAndDescription(null, null); return; } var serviceDescription = firstServiceCategory2ServiceDescriptions.Value.OrderBy(sd => sd.Position).ThenBy(sd => sd.ServiceDescriptionOid).First(); - Model.SelectedServiceDescription = serviceDescription; - Model.SelectedServiceCategory = serviceDescription.Category; + UpdateSelectedServiceCategorieAndDescription(serviceDescription.Category, serviceDescription); } + private void UpdateSelectedServiceCategorieAndDescription(ServiceCategoryDC cat, ServiceDescriptionDC desc) + { + Model.SelectedServiceCategory = cat; + Model.SelectedServiceDescription = desc; + + Model.SelectedServiceCategoryOid = Model.SelectedServiceCategory?.ServiceCategoryOid; + Model.SelectedServiceDescriptionOid = Model.SelectedServiceDescription?.ServiceDescriptionOid; + } + + private Dictionary> CreateServiceCategory2ServiceDescription(List nodes, bool isGroupBooking) { var result = new Dictionary>(); @@ -1933,7 +2057,7 @@ namespace BeWoPlanerMobil.Controllers Model.ServiceRecordOidToDelete = long.Parse(formCollection[FormCollectionConstants.ServiceRecordOidHolderKey]); - if(Model.ServiceRecordOidToDelete != null && Model.ServiceRecordOidToDelete > 0 && MobileSessionFacade.LoggedInUser.UserGroups.Any(a => a.Rights.Any(f => f.RightType.Equals(UserRightType.ServiceRecordView_Delete)))) + if(Model.ServiceRecordOidToDelete != null && Model.ServiceRecordOidToDelete > 0 && LoggedInUser.UserGroups.Any(a => a.Rights.Any(f => f.Equals(UserRightType.ServiceRecordView_Delete)))) { var serviceRecordDC = Model.ServiceRecords.FirstOrDefault(f => f.ServiceRecordOid != null && f.ServiceRecordOid.Value.Equals(Model.ServiceRecordOidToDelete)); var version = serviceRecordDC?.ServiceRecordVersion; @@ -1949,19 +2073,18 @@ namespace BeWoPlanerMobil.Controllers return ResetEditingMode(); } - [Authorize] - public ActionResult ReloadGoalRatings() - { - if(Model is null) - { - TempData[TempDataConstants.DoLogoutKey] = true; - return PartialView("GoalRatingPopupContentPartial"); - } + //[Authorize] + //public ActionResult ReloadGoalRatings() + //{ + // if(Model is null) + // { + // TempData[TempDataConstants.DoLogoutKey] = true; + // return PartialView("GoalRatingPopupContentPartial"); + // } - LoadGoalRatings(); - return PartialView("GoalRatingPopupContentPartial", Model); - } + // return PartialView("GoalRatingPopupContentPartial", Model); + //} [Authorize] public string UpdateGoals(string pGoalOids) @@ -2011,6 +2134,7 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedGoals = stillSelectedGoals; Model.SelectedGoals.AddRangeIfElementsNotIn(goals); + Model.SelectedGoalOids = Model.SelectedGoals.Select(g => g.ValueListEntryOid.Value).ToList(); return Model.SelectedGoals?.Count.ToString() ?? "0"; } @@ -2027,6 +2151,7 @@ namespace BeWoPlanerMobil.Controllers var serviceDescription = OperationsService.GetServiceDescription(pServiceDescriptionOid); Model.SelectedServiceDescription = serviceDescription; + Model.SelectedServiceDescriptionOid = pServiceDescriptionOid; return LeerzeichenFuerGetMethoden; } @@ -2118,7 +2243,7 @@ namespace BeWoPlanerMobil.Controllers CalculateSelectedDayCount(dayCountNumber, lastSelectedServiceRecordMonth, parsedStart, parsedEnd, serviceRecordTimeInterval); - if(Model.CostBearer2SupportConceptOid.HasValue && Model.CostBearer2SupportConceptOid != -1) + if(Model.SelectedCostBearerSupportConceptOid.HasValue && Model.SelectedCostBearerSupportConceptOid != -1) { LoadPaginatedServiceRecordsToModel(Model.CurrentPage); } @@ -2210,52 +2335,54 @@ namespace BeWoPlanerMobil.Controllers } Model.SelectedServiceRecord = selectedServiceRecord; + Model.SelectedServiceRecordOid = Model.SelectedServiceRecord?.ServiceRecordOid; + Model.SelectedGoals = selectedServiceRecord.Goals; var selectedServiceDescription = selectedServiceRecord.ServiceDescription; var selectedServiceCategory = selectedServiceDescription.Category; - Model.SelectedServiceDescription = selectedServiceDescription; - Model.SelectedServiceCategory = selectedServiceCategory; + Model.SelectedServiceDescriptionOid = selectedServiceDescription?.ServiceDescriptionOid; + Model.SelectedServiceCategoryOid = selectedServiceCategory?.ServiceCategoryOid; - Model.PreviouslySelectedEmployee = Model.SelectedEmployee; - Model.SelectedEmployee = selectedServiceRecord.Employee; + Model.PreviouslySelectedEmployeeOid = Model.SelectedEmployee?.EmployeeOid; + Model.SelectedEmployeeOid = selectedServiceRecord.Employee?.EmployeeOid; Model.IsInEditingMode = true; - Model.PreviouslySelectedSupportConcept = Model.SelectedSupportConcept; - Model.PreviouslySelectedCostbearer2SupportConceptOid = Model.CostBearer2SupportConceptOid; + Model.PreviouslySelectedSupportConceptOid = Model.SelectedSupportConcept?.SupportConceptOid; + Model.PreviouslySelectedCostbearer2SupportConceptOid = Model.SelectedCostBearerSupportConceptOid; // Gruppenbuchung if(selectedServiceRecord.GroupOid.HasValue) { Model.IsInGroupBookingMode = true; - Model.SelectedSupportConcept = null; - Model.SelectedEmployee = null; + Model.SelectedSupportConceptOid = null; + Model.SelectedEmployeeOid = null; var group = OperationsService.GetServiceRecordGroup(selectedServiceRecord.GroupOid.Value); var employees = group.ServiceRecordList.Select(serviceRecord => serviceRecord.Employee).Distinct().ToList(); - Model.GroupBookingSelectedEmployees = employees; + Model.GroupBookingSelectedEmployeeOids = employees.Select(e => e.EmployeeOid).ToList(); var cb2ScOids = group.ServiceRecordList.Where(w => w.CostBearer2SupportConceptOid.HasValue).Select(s => s.CostBearer2SupportConceptOid.Value).ToList(); - Model.SelectedConceptCostBearerRelations.AddRangeIfElementsNotIn(OperationsService.GetSupportConceptCostBearerRelDCsByOids(cb2ScOids)); + //Model.SelectedConceptCostBearerRelations.AddRangeIfElementsNotIn(OperationsService.GetSupportConceptCostBearerRelDCsByOids(cb2ScOids)); + Model.SelectedConceptCostBearerRelationOids = cb2ScOids; - var selectedSupportConcepts = new List(); - selectedSupportConcepts.AddRangeIfElementsNotIn(OperationsService.GetSupportConceptsById(group.ServiceRecordList.Select(s => s.SupportConcept.SupportConceptOid))); + //var selectedSupportConcepts = new List(); + //selectedSupportConcepts.AddRangeIfElementsNotIn(OperationsService.GetSupportConceptsById(group.ServiceRecordList.Select(s => s.SupportConcept.SupportConceptOid))); + //Model.GroupBookingSelectedSupportConcepts = selectedSupportConcepts; - Model.GroupBookingSelectedSupportConcepts = selectedSupportConcepts; + Model.GroupBookingSelectedSupportConceptOids = group.ServiceRecordList.Select(s => s.SupportConcept.SupportConceptOid).ToList(); - LoadServiceCategoriesToModel(null); + Model.SelectedServiceDescriptionOid = selectedServiceDescription?.ServiceDescriptionOid; + Model.SelectedServiceCategoryOid = selectedServiceCategory?.ServiceCategoryOid; - Model.SelectedServiceDescription = selectedServiceDescription; - Model.SelectedServiceCategory = selectedServiceCategory; - - LoadGoals(); } + return RedirectToActionPermanent("Main"); } @@ -2393,22 +2520,22 @@ namespace BeWoPlanerMobil.Controllers checkServiceRecord.ServiceDescription = OperationsService.GetServiceDescription(Model.SelectedServiceDescriptionOid.Value); - checkServiceRecord.Employee = Model.SelectedEmployee ?? MobileSessionFacade.LoggedInCompactEmployee; + checkServiceRecord.Employee = Model.SelectedEmployee ?? LoggedInUser.Employee; // Mitarbeiter ausgewählt und Einzelbuchung if(Model.SelectedEmployee != null && !Model.IsInGroupBookingMode && !Model.IsInMultiBookingMode) { - var supportConcept = Model.SupportConcepts.FirstOrDefault(fod => fod.CostBearerRelations.Any(a => a.CostBearer2SupportConceptOid.HasValue && a.CostBearer2SupportConceptOid.Value.Equals(Model.CostBearer2SupportConceptOid))); + var supportConcept = Model.SupportConcepts.FirstOrDefault(fod => fod.CostBearerRelations.Any(a => a.CostBearer2SupportConceptOid.HasValue && a.CostBearer2SupportConceptOid.Value.Equals(Model.SelectedCostBearerSupportConceptOid))); if(supportConcept != null) { if(supportConcept.SupportConceptOid != null) { - checkServiceRecord.SupportConcept = CustomerService.LoadCompactSupportConceptDC(supportConcept.SupportConceptOid.Value, Model.Employee.EmployeeOid); + checkServiceRecord.SupportConcept = CustomerService.LoadCompactSupportConceptDC(supportConcept.SupportConceptOid.Value, Model.LoggedInEmployee.EmployeeOid); } checkServiceRecord.Customer = supportConcept.Customer; - var cb2ScRel = supportConcept.CostBearerRelations.First(f => f.CostBearer2SupportConceptOid.HasValue && f.CostBearer2SupportConceptOid.Equals(Model.CostBearer2SupportConceptOid)); + var cb2ScRel = supportConcept.CostBearerRelations.First(f => f.CostBearer2SupportConceptOid.HasValue && f.CostBearer2SupportConceptOid.Equals(Model.SelectedCostBearerSupportConceptOid)); checkServiceRecord.CostBearer = cb2ScRel.CostBearer; var intervall = checkServiceRecord.CostBearer.ActualMinuteIntervall; @@ -2417,7 +2544,7 @@ namespace BeWoPlanerMobil.Controllers checkServiceRecord.RoundedDuration = dauer % intervall != 0 ? dauer + (intervall - dauer % intervall) : dauer; } - checkServiceRecord.CostBearer2SupportConceptOid = Model.CostBearer2SupportConceptOid; + checkServiceRecord.CostBearer2SupportConceptOid = Model.SelectedCostBearerSupportConceptOid; } } @@ -2436,16 +2563,16 @@ namespace BeWoPlanerMobil.Controllers limitFuerZeiterfassung = 0; } - if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth)) + if(LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth)) { maxDaysEditSRsAllowed = -1; } SupportConceptStatisticsDC stats = null; - if(Model.CostBearer2SupportConceptOid != null && Model.CostBearer2SupportConceptOid > 0) + if(Model.SelectedCostBearerSupportConceptOid != null && Model.SelectedCostBearerSupportConceptOid > 0) { - stats = OperationsService.CreateSupportConceptStatistics(Model.CostBearer2SupportConceptOid.Value, DateTime.Now); + stats = OperationsService.CreateSupportConceptStatistics(Model.SelectedCostBearerSupportConceptOid.Value, DateTime.Now); } var employeeOids = new List { checkServiceRecord.Employee.EmployeeOid }; @@ -2561,16 +2688,17 @@ namespace BeWoPlanerMobil.Controllers } } - var allowOverlappingFls = MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreateOverlappingFLS); - var allowOverlappingFlsForEmployee = MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreateOverlappingFLSForEmployee); - var allowMoreFlsThanApproved = MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreateMoreFLSThanApproved); - var bookAfterSettlementInvoice = MobileSessionFacade.CheckForUserRight(UserRightType.BookServiceRecordAfterSettlementInvoice); - var bookServiceRecordOutOfSupportConcept = MobileSessionFacade.CheckForUserRight(UserRightType.BookServiceRecordOutOfSupportConcept); - var allowCreateAfterEmployeeSignature = MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreateAfterEmployeeSignature); - var allowEditAfterEmployeeSignature = MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowEditAfterEmployeeSignature); + var user = LoggedInUser; + var allowOverlappingFls = user.HasRight(UserRightType.ServiceRecord_AllowCreateOverlappingFLS); + var allowOverlappingFlsForEmployee = user.HasRight(UserRightType.ServiceRecord_AllowCreateOverlappingFLSForEmployee); + var allowMoreFlsThanApproved = user.HasRight(UserRightType.ServiceRecord_AllowCreateMoreFLSThanApproved); + var bookAfterSettlementInvoice = user.HasRight(UserRightType.BookServiceRecordAfterSettlementInvoice); + var bookServiceRecordOutOfSupportConcept = user.HasRight(UserRightType.BookServiceRecordOutOfSupportConcept); + var allowCreateAfterEmployeeSignature = user.HasRight(UserRightType.ServiceRecord_AllowCreateAfterEmployeeSignature); + var allowEditAfterEmployeeSignature = user.HasRight(UserRightType.ServiceRecord_AllowEditAfterEmployeeSignature); - var allowCreateAll = MobileSessionFacade.CheckForUserRight(UserRightType.CreateAll); - var allowEditAll = MobileSessionFacade.CheckForUserRight(UserRightType.CreateAll); + var allowCreateAll = user.HasRight(UserRightType.CreateAll); + var allowEditAll = user.HasRight(UserRightType.CreateAll); var newResult = new ValidationResult(); var exitLoop = false; @@ -2672,7 +2800,7 @@ namespace BeWoPlanerMobil.Controllers intervall = "" + limitFuerZeiterfassung + " Tagen"; } - if(!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecordAllowEditAfterMindays)) + if(!LoggedInUser.HasRight(UserRightType.ServiceRecordAllowEditAfterMindays)) { if(limitFuerZeiterfassung == 1) { @@ -2770,6 +2898,8 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedServiceRecord.RoundedDuration = Model.SelectedDurationUnit == "Stunden" || Model.EinheitZeiterfassung == 1 ? duration * 60 : duration; } + Model.SelectedServiceRecordOid = Model.SelectedServiceRecord?.ServiceRecordOid; + TempData[TempDataConstants.AfterValidationStateKey] = true; return View("Main", Model); @@ -2800,7 +2930,7 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - var validationResultList = OperationsService.ValidateServiceRecordDeletion(serviceRecord, Model.Employee.EmployeeOid.Value); + var validationResultList = OperationsService.ValidateServiceRecordDeletion(serviceRecord, Model.LoggedInEmployee.EmployeeOid.Value); if(validationResultList.Count > 0) { @@ -2863,6 +2993,8 @@ namespace BeWoPlanerMobil.Controllers } Model.SelectedEmployee = Model.AllEmployees.First(f => f.EmployeeOid.Equals(employeeOid)); + Model.SelectedEmployeeOid = Model.SelectedEmployee?.EmployeeOid; + return Model.SelectedEmployee?.DetailDescription ?? LeerzeichenFuerGetMethoden; } catch(Exception e) @@ -2923,12 +3055,12 @@ namespace BeWoPlanerMobil.Controllers return RedirectToActionPermanent("Customer", "Customer", new { id = Model.SelectedSupportConcept.Customer.Oid }); } - if(Model?.SelectedSupportConcept is null && (CustomerModel)Session[ModelSessionConstants.CustomerModelKey] != null) - { - var customerModel = (CustomerModel) Session[ModelSessionConstants.CustomerModelKey]; - customerModel.SelectedCustomerOid = null; - customerModel.SelectedCustomer = null; - } + //if(Model?.SelectedSupportConcept is null && (CustomerModel)Session[ModelSessionConstants.CustomerModelKey] != null) + //{ + // var customerModel = (CustomerModel) Session[ModelSessionConstants.CustomerModelKey]; + // customerModel.SelectedCustomerOid = null; + // customerModel.SelectedCustomer = null; + //} return RedirectToActionPermanent("Customer", "Customer"); } @@ -2936,7 +3068,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult RedirectToReportView() { - return AbstractModel.HasRightToViewQuittierungsbelege ? RedirectToActionPermanent("InitReports", "Report") : RedirectToMain(); + return Model.HasRightToViewQuittierungsbelege ? RedirectToAction("InitReports", "Report") : RedirectToMain(); } [Authorize] @@ -2982,7 +3114,7 @@ namespace BeWoPlanerMobil.Controllers } TempData[TempDataConstants.IsInTransferModeKey] = null; - TempData[TempDataConstants.AppointmentListItemKey] = null; + TempData[TempDataConstants.AppointmentOidKey] = null; var bookingMode = "true,false" == pFormCollection[FormCollectionConstants.IsInGroupBookingModeKey] ? BookingMode.GroupBookingMode : BookingMode.SingleBookingMode; @@ -3014,72 +3146,74 @@ namespace BeWoPlanerMobil.Controllers { ResetMultiBookingMode(); - Model.PreviouslySelectedEmployee = Model.SelectedEmployee; - Model.PreviouslySelectedSupportConcept = Model.SelectedSupportConcept; - Model.PreviouslySelectedCostbearer2SupportConceptOid = Model.CostBearer2SupportConceptOid; + Model.PreviouslySelectedEmployeeOid = Model.SelectedEmployeeOid; + Model.PreviouslySelectedSupportConceptOid = Model.SelectedSupportConceptOid; + Model.PreviouslySelectedCostbearer2SupportConceptOid = Model.SelectedCostBearerSupportConceptOid; - Model.SelectedSupportConcept = null; - Model.CostBearer2SupportConceptOid = null; - Model.SelectedEmployee = null; + Model.SelectedSupportConceptOid = null; + Model.SelectedCostBearerSupportConceptOid = null; + Model.SelectedEmployeeOid = null; - LoadServiceCategoriesToModel(null); - Model.GroupBookingSelectedEmployees.AddIfNotIn(MobileSessionFacade.LoggedInCompactEmployee); + Model.GroupBookingSelectedEmployeeOids.AddIfNotIn(LoggedInUser.Employee.EmployeeOid); Model.IsInEditingMode = false; - Model.SelectedServiceRecord = null; + Model.SelectedServiceRecordOid = null; } if(bookingMode == BookingMode.MultiBookingMode) { ResetGroupBookingMode(); - Model.PreviouslySelectedEmployee = Model.SelectedEmployee; - Model.PreviouslySelectedSupportConcept = Model.SelectedSupportConcept; - Model.PreviouslySelectedCostbearer2SupportConceptOid = Model.CostBearer2SupportConceptOid; + Model.PreviouslySelectedEmployeeOid = Model.SelectedEmployeeOid; + Model.PreviouslySelectedSupportConceptOid = Model.SelectedSupportConceptOid; + Model.PreviouslySelectedCostbearer2SupportConceptOid = Model.SelectedCostBearerSupportConceptOid; - Model.SelectedSupportConcept = null; - Model.CostBearer2SupportConceptOid = null; - Model.SelectedEmployee = null; + Model.SelectedSupportConceptOid = null; + Model.SelectedCostBearerSupportConceptOid = null; + Model.SelectedEmployeeOid = null; - LoadServiceCategoriesToModel(null); - Model.MultiBookingSelectedEmployees.AddIfNotIn(MobileSessionFacade.LoggedInCompactEmployee); + + Model.MultiBookingSelectedEmployeeOids.AddIfNotIn(LoggedInUser.Employee.EmployeeOid); Model.IsInEditingMode = false; - Model.SelectedServiceRecord = null; - - Model.GroupBookingSelectedCostbearerRelOids.Clear(); - Model.GroupBookingSelectedEmployees.Clear(); - Model.GroupBookingSelectedSupportConcepts.Clear(); - Model.SelectedConceptCostBearerRelations.Clear(); + Model.SelectedServiceRecordOid = null; } if(bookingMode == BookingMode.SingleBookingMode) { ResetMultiBookingMode(); - Model.SelectedEmployee = Model.PreviouslySelectedEmployee ?? MobileSessionFacade.LoggedInCompactEmployee; + Model.SelectedEmployeeOid = Model.PreviouslySelectedEmployeeOid ?? LoggedInUser.Employee.EmployeeOid; - if(Model.PreviouslySelectedSupportConcept is object) + if (Model.PreviouslySelectedSupportConceptOid.HasValue) { - Model.SelectedSupportConcept = Model.PreviouslySelectedSupportConcept; - Model.CostBearer2SupportConceptOid = Model.PreviouslySelectedCostbearer2SupportConceptOid; + Model.SelectedSupportConceptOid = Model.PreviouslySelectedSupportConceptOid; } - + if (Model.PreviouslySelectedCostbearer2SupportConceptOid.HasValue) + { + Model.SelectedCostBearerSupportConceptOid = Model.PreviouslySelectedCostbearer2SupportConceptOid; + } + + ResetGroupBookingMode(); } - LoadSupportConceptThings(Model.CostBearer2SupportConceptOid); + Model.SelectedSupportConceptOid = Model.SelectedSupportConcept?.SupportConceptOid; + Model.SelectedEmployeeOid = Model.SelectedEmployee?.EmployeeOid; + Model.SelectedServiceRecordOid = Model.SelectedServiceRecord?.ServiceRecordOid; + } private void ResetMultiBookingMode() { Model.Categories2Descriptions.Clear(); + Model.MultiBookingSelectedConceptCostBearerRelations.Clear(); - Model.MultiBookingSelectedEmployees.Clear(); + Model.MultiBookingSelectedEmployeeOids.Clear(); Model.MultiBookingSelectedGroupOfPeopleOids.Clear(); Model.MultiBookingSelectedCostbearerRelOids.Clear(); - Model.MultiBookingSelectedSupportConcepts.Clear(); + Model.MultiBookingSelectedSupportConceptOids.Clear(); Model.MultiBookingSupportConceptListObjects.Clear(); } @@ -3087,9 +3221,9 @@ namespace BeWoPlanerMobil.Controllers { Model.Categories2Descriptions.Clear(); Model.GroupBookingSelectedCostbearerRelOids.Clear(); - Model.GroupBookingSelectedEmployees.Clear(); - Model.GroupBookingSelectedSupportConcepts.Clear(); - Model.SelectedConceptCostBearerRelations.Clear(); + Model.GroupBookingSelectedEmployeeOids.Clear(); + Model.GroupBookingSelectedSupportConceptOids.Clear(); + Model.SelectedConceptCostBearerRelationOids.Clear(); } [HttpPost] @@ -3104,7 +3238,7 @@ namespace BeWoPlanerMobil.Controllers ResetBookingMode(BookingMode.SingleBookingMode); - LoadServiceCategoriesToModel(Model.SelectedCostBearerSupportConceptRelOid); + //LoadServiceCategoriesToModel(Model.SelectedCostBearerSupportConceptOid); return View("Main", Model); } @@ -3133,10 +3267,10 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } - if(Model.PreviouslySelectedSupportConcept != null && Model.SelectedSupportConcept is null) + if(Model.PreviouslySelectedSupportConceptOid != null && Model.SelectedSupportConceptOid is null) { - Model.SelectedSupportConcept = Model.PreviouslySelectedSupportConcept; - Model.CostBearer2SupportConceptOid = Model.PreviouslySelectedCostbearer2SupportConceptOid; + Model.SelectedSupportConceptOid = Model.PreviouslySelectedSupportConceptOid; + Model.SelectedCostBearerSupportConceptOid = Model.PreviouslySelectedCostbearer2SupportConceptOid; } ResetModel(); @@ -3182,32 +3316,34 @@ namespace BeWoPlanerMobil.Controllers return; } - TempData[TempDataConstants.AppointmentListItemKey] = null; + TempData[TempDataConstants.AppointmentOidKey] = null; TempData[TempDataConstants.IsInTransferModeKey] = null; TempData[TempDataConstants.AfterValidationStateKey] = null; - Model.NewServiceRecord = new ServiceRecordDC(); - Model.SelectedServiceRecord = null; + Model.NewServiceRecord = new ServiceRecordDC(); + Model.SelectedServiceRecordOid = null; Model.IsInEditingMode = false; - Model.GroupBookingSelectedSupportConcepts.Clear(); - Model.SelectedConceptCostBearerRelations.Clear(); + Model.SelectedEmployeeOid = LoggedInUser.Employee.EmployeeOid; + Model.SelectedConceptCostBearerRelationOids.Clear(); + Model.GroupBookingSelectedSupportConceptOids.Clear(); Model.GroupBookingSelectedCostbearerRelOids.Clear(); Model.GroupBookingSelectedGroupOfPeopleOids.Clear(); - Model.GroupBookingSelectedEmployees = new List { MobileSessionFacade.LoggedInCompactEmployee }; - Model.SelectedEmployee = MobileSessionFacade.LoggedInCompactEmployee; + Model.GroupBookingSelectedEmployeeOids = new List { LoggedInUser.Employee.EmployeeOid }; + + Model.IsInMultiBookingMode = false; Model.MultiBookingSelectedCostbearerRelOids.Clear(); - Model.MultiBookingSelectedEmployees.Clear(); - Model.MultiBookingSelectedConceptCostBearerRelations.Clear(); - Model.MultiBookingSelectedEmployees = new List { MobileSessionFacade.LoggedInCompactEmployee }; + Model.MultiBookingSelectedEmployeeOids = new List { LoggedInUser.Employee.EmployeeOid }; Model.MultiBookingSelectedGroupOfPeopleOids.Clear(); - Model.MultiBookingSelectedSupportConcepts.Clear(); - Model.SelectedGoals.Clear(); + Model.MultiBookingSelectedSupportConceptOids.Clear(); + Model.SelectedGoalOids.Clear(); - Model.SelectedServiceCategory = null; - Model.SelectedServiceDescription = null; + Model.SelectedServiceCategoryOid = null; + Model.SelectedServiceDescriptionOid = null; - LoadServiceCategoriesToModel(Model.CostBearer2SupportConceptOid); + //LoadServiceCategoriesToModel(Model.SelectedCostBearerSupportConceptOid); + + //Model.MainSessionModel.ResetValues(); } [Authorize] @@ -3265,6 +3401,7 @@ namespace BeWoPlanerMobil.Controllers }); Model.GroupBookingSelectedSupportConcepts.Clear(); + Model.GroupBookingSelectedCostbearerRelOids.Clear(); Model.GroupBookingSelectedCostbearerRelOids.AddRangeIfElementsNotIn(singleRels); @@ -3300,6 +3437,9 @@ namespace BeWoPlanerMobil.Controllers } } + Model.SelectedConceptCostBearerRelationOids = Model.SelectedConceptCostBearerRelations.Select(s => s.CostBearer2SupportConceptOid.Value).ToList(); + Model.GroupBookingSelectedSupportConceptOids = Model.GroupBookingSelectedSupportConcepts.Select(s => s.SupportConceptOid.Value).ToList(); + return PartialView("GroupBookingScCbRelList", Model); } @@ -3360,6 +3500,13 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedServiceDescription = firstServiceDescription; } + + Model.SelectedGoalOids = Model.SelectedGoals.Select(g => g.ValueListEntryOid.Value).ToList(); + Model.GroupBookingSelectedSupportConceptOids = Model.GroupBookingSelectedSupportConcepts.Select(g => g.SupportConceptOid.Value).ToList(); + Model.SelectedConceptCostBearerRelationOids = Model.SelectedConceptCostBearerRelations.Select(g => g.CostBearer2SupportConceptOid.Value).ToList(); + Model.SelectedServiceCategoryOid = Model.SelectedServiceCategory?.ServiceCategoryOid; + Model.SelectedServiceDescriptionOid = Model.SelectedServiceDescription?.ServiceDescriptionOid; + return PartialView("GroupBookingSelectionPartial", Model); } @@ -3390,6 +3537,7 @@ namespace BeWoPlanerMobil.Controllers if(string.IsNullOrEmpty(pEmployeeOids)) { Model.GroupBookingSelectedEmployees.Clear(); + Model.GroupBookingSelectedEmployeeOids.Clear(); return JsonConvert.SerializeObject(Model.GroupBookingSelectedEmployees.Count); } @@ -3402,8 +3550,10 @@ namespace BeWoPlanerMobil.Controllers Model.GroupBookingSelectedEmployees.Clear(); Model.GroupBookingSelectedEmployees.AddRangeIfElementsNotIn(employees); + Model.GroupBookingSelectedEmployeeOids = Model.GroupBookingSelectedEmployees.Select(e => e.EmployeeOid).ToList(); return JsonConvert.SerializeObject(Model.GroupBookingSelectedEmployees.Count); + } [Authorize] @@ -3469,7 +3619,7 @@ namespace BeWoPlanerMobil.Controllers { if(Model.GroupBookingSelectedCostbearerRelOids.Count == 1) { - Model.CostBearer2SupportConceptOid = Model.GroupBookingSelectedCostbearerRelOids.FirstOrDefault(); + Model.SelectedCostBearerSupportConceptOid = Model.GroupBookingSelectedCostbearerRelOids.FirstOrDefault(); } } else @@ -3518,7 +3668,7 @@ namespace BeWoPlanerMobil.Controllers } // Kostenträger-Hilfeplan-Relation - var selectedCostbearer2SupportConceptRelOid = Model.CostBearer2SupportConceptOid < 1 ? null : Model.CostBearer2SupportConceptOid; + var selectedCostbearer2SupportConceptRelOid = Model.SelectedCostBearerSupportConceptOid < 1 ? null : Model.SelectedCostBearerSupportConceptOid; // Datumsteil des Startdatums var datum = Convert.ToDateTime(formCollection[FormCollectionConstants.DateKey]); @@ -3610,7 +3760,7 @@ namespace BeWoPlanerMobil.Controllers Model.NewServiceRecord.DistanceInMeterDecimal = distanceInMeters; - if(Model.Employee.EmployeeOid.HasValue) + if(Model.LoggedInEmployee.EmployeeOid.HasValue) { if(Model.SelectedEmployee != null) @@ -3624,7 +3774,7 @@ namespace BeWoPlanerMobil.Controllers { if(supportConcept.SupportConceptOid.HasValue) { - Model.NewServiceRecord.SupportConcept = CustomerService.LoadCompactSupportConceptDC(supportConcept.SupportConceptOid.Value, Model.Employee.EmployeeOid); + Model.NewServiceRecord.SupportConcept = CustomerService.LoadCompactSupportConceptDC(supportConcept.SupportConceptOid.Value, Model.LoggedInEmployee.EmployeeOid); } Model.NewServiceRecord.Customer = supportConcept.Customer; @@ -3688,7 +3838,7 @@ namespace BeWoPlanerMobil.Controllers } Model.NewServiceRecord.InsertedOn = DateTime.Now; - Model.NewServiceRecord.InsUser = $"{MobileSessionFacade.LoggedInEmployee.FirstName} {MobileSessionFacade.LoggedInEmployee.LastName}"; + Model.NewServiceRecord.InsUser = MobileSessionFacade.EmployeeFullname; Model.NewServiceRecord.IsCreatedInMobileClient = true; @@ -3735,21 +3885,7 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - [Authorize] - public void LoadSupportConceptThings(long? cb2ScOid) - { - if(Model is null) - { - Logout(); - return; - } - - LoadServiceCategoriesToModel(cb2ScOid); - - LoadGoalRatings(); - - LoadGoals(); - } + /// /// Bereitet die Übernahme eines Termins in die Zeiterfassung vor. Wird im SchedulerController aufgerufen. @@ -3764,11 +3900,13 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } - if(TempData[TempDataConstants.AppointmentListItemKey] is AppointmentListItem appointmentListItem && Model.Employee.EmployeeOid.HasValue) + if (TempData[TempDataConstants.AppointmentOidKey] != null && Int64.TryParse(TempData[TempDataConstants.AppointmentOidKey].ToString(), out var appOid) && Model.LoggedInEmployee.EmployeeOid.HasValue) { TempData[TempDataConstants.IsInTransferModeKey] = true; - var appointment = appointmentListItem.SchedulerAppointment; + var app = DAOFactory.GenericDAO.LoadByID(appOid); + + var appointment = MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDC(app); var start = appointment.StartDate; var end = appointment.EndDate; @@ -3783,13 +3921,13 @@ namespace BeWoPlanerMobil.Controllers if(employeeOids.Count == 0) { - employeeOids.Add(Model.Employee.EmployeeOid.Value); + employeeOids.Add(Model.LoggedInEmployee.EmployeeOid.Value); } var notice = appointment.Description; var customerService = PluginLoader.FindClass(); - var supportConcepts = customerService.GetAllActiveSupportConceptCostbearer(false, true, Model.Employee.EmployeeOid.Value); + var supportConcepts = customerService.GetAllActiveSupportConceptCostbearer(false, true, Model.LoggedInEmployee.EmployeeOid.Value); supportConcepts = supportConcepts.Where(sc => customerOids.Contains(sc.Customer.CustomerOid) && sc.StartDate.HasValue && sc.EndDate.HasValue && start.Value.AreInBetweenDates(end.Value, sc.StartDate.Value, sc.EndDate.Value)).ToList(); var supportConceptList = new List(); @@ -3811,7 +3949,7 @@ namespace BeWoPlanerMobil.Controllers { ResetBookingMode(BookingMode.SingleBookingMode); - Model.SelectedEmployee = Model.AllEmployees.FirstOrDefault(e => e.EmployeeOid.Equals(Model.Employee.EmployeeOid.Value)); + Model.SelectedEmployee = Model.AllEmployees.FirstOrDefault(e => e.EmployeeOid.Equals(Model.LoggedInEmployee.EmployeeOid.Value)); LoadSupportConceptThings(-2); @@ -3829,10 +3967,7 @@ namespace BeWoPlanerMobil.Controllers var availableRelOids = new List(); Model.SupportConceptListObjects.DoForEach(sclo => { - if(long.TryParse(sclo.CostBearer2SupportConceptOid, out var costBearer2SupportConceptRelOid)) - { - availableRelOids.AddIfNotIn(costBearer2SupportConceptRelOid); - } + availableRelOids.AddIfNotIn(sclo.CostBearer2SupportConceptOid); }); if(supportConceptList.Count == 1 && employeeOids.Count == 1) @@ -3907,7 +4042,9 @@ namespace BeWoPlanerMobil.Controllers } } - TempData[TempDataConstants.AppointmentListItemKey] = appointmentListItem; + Model.SelectedServiceRecordOid = Model.SelectedServiceRecord?.ServiceRecordOid; + + TempData[TempDataConstants.AppointmentOidKey] = appointment?.SchedulerAppointmentOid; } return View("Main", Model); @@ -4162,7 +4299,7 @@ namespace BeWoPlanerMobil.Controllers } TempData[TempDataConstants.IsInTransferModeKey] = null; - TempData[TempDataConstants.AppointmentListItemKey] = null; + TempData[TempDataConstants.AppointmentOidKey] = null; try { @@ -4228,7 +4365,7 @@ namespace BeWoPlanerMobil.Controllers } } - var selectedCostbearer2SupportConceptRelOid = Model.CostBearer2SupportConceptOid < 1 ? null : Model.CostBearer2SupportConceptOid; + var selectedCostbearer2SupportConceptRelOid = Model.SelectedCostBearerSupportConceptOid < 1 ? null : Model.SelectedCostBearerSupportConceptOid; var datum = Convert.ToDateTime(formCollection[FormCollectionConstants.DateKey]); var enddatum = datum; @@ -4329,7 +4466,7 @@ namespace BeWoPlanerMobil.Controllers Notice4 = doku4 ?? string.Empty, Notice5 = doku5 ?? string.Empty, InsertedOn = DateTime.Now, - InsUser = $"{MobileSessionFacade.LoggedInEmployee.FirstName} {MobileSessionFacade.LoggedInEmployee.LastName}", + InsUser = MobileSessionFacade.EmployeeFullname, IsCreatedInMobileClient = true, Employee = employee, ServiceRecordFormat = ServiceRecordFormate.OriginaleZeiterfassung, @@ -4427,7 +4564,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult ChangePassword(FormCollection formCollection) { - if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || MobileSessionFacade.LoggedInUserDC.UserVersion is null) + if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || LoggedInUser.UserVersion is null) { TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); @@ -4446,7 +4583,7 @@ namespace BeWoPlanerMobil.Controllers var passwordUtils = new PasswordUtils(); if(passwordUtils.EvaluatePasswordStrength(newPassword) < 2) { - var checkResult = UserService.CheckPassword(MobileSessionFacade.LoggedInUser.Oid.Value, oldPassword, newPassword); + var checkResult = UserService.CheckPassword(LoggedInUser.UserOid.Value, oldPassword, newPassword); if(!(checkResult is null)) { @@ -4455,8 +4592,8 @@ namespace BeWoPlanerMobil.Controllers } } - var userName = MobileSessionFacade.LoggedInUserDC.LoginName; - var userVersion = MobileSessionFacade.LoggedInUserDC.UserVersion.Value; + var userName = LoggedInUser.LoginName; + var userVersion = LoggedInUser.UserVersion.Value; UserService.ChangePassword(userName, userVersion, oldPassword, newPassword); @@ -4494,10 +4631,10 @@ namespace BeWoPlanerMobil.Controllers int totalServiceRecords; var firstResult = (selectedPage - 1) * Model.MaxResults; - var selectedEmployeeOid = Model.SelectedEmployee?.EmployeeOid ?? Model.Employee.EmployeeOid.Value; + var selectedEmployeeOid = Model.SelectedEmployee?.EmployeeOid ?? Model.LoggedInEmployee.EmployeeOid.Value; // Ohne Hilfeplan - if(Model.CostBearer2SupportConceptOid is null || Model.CostBearer2SupportConceptOid < 1) + if(Model.SelectedCostBearerSupportConceptOid is null || Model.SelectedCostBearerSupportConceptOid < 1) { records = Model.ServiceRecordTimeInterval == ServiceRecordTimeInterval.ZeitraumWaehlen || Model.ServiceRecordTimeInterval == ServiceRecordTimeInterval.Monatsauswahl ? //Zeitraum oder Monat gewählt @@ -4511,12 +4648,12 @@ namespace BeWoPlanerMobil.Controllers OperationsService .GetCustomerServiceRecordsWithStartEndDatePaginated( Model.SelectedSupportConcept.Customer.CustomerOid, - Model.CostBearer2SupportConceptOid.Value, + Model.SelectedCostBearerSupportConceptOid.Value, Model.SelectedZeitraum.StartDate.Value, Model.SelectedZeitraum.EndDate.Value, firstResult, Model.MaxResults, out totalServiceRecords) : - OperationsService.FindServiceRecordsForLastDaysPaginated(Model.CostBearer2SupportConceptOid, Model.SelectedDayCount, Model.Employee?.EmployeeOid, firstResult, Model.MaxResults, out totalServiceRecords).ToList(); + OperationsService.FindServiceRecordsForLastDaysPaginated(Model.SelectedCostBearerSupportConceptOid, Model.SelectedDayCount, Model.LoggedInEmployee?.EmployeeOid, firstResult, Model.MaxResults, out totalServiceRecords).ToList(); } var pages = Math.DivRem(totalServiceRecords, Model.MaxResults, out var remainder); @@ -4712,6 +4849,9 @@ namespace BeWoPlanerMobil.Controllers var selectedServiceDescription = Model.Categories2Descriptions[Model.SelectedServiceCategory].OrderBy(sd => sd.Position).ThenBy(sd => sd.ServiceDescriptionOid).FirstOrDefault(); Model.SelectedServiceDescription = selectedServiceDescription; + + Model.SelectedServiceCategoryOid = Model.SelectedServiceCategory?.ServiceCategoryOid; + Model.SelectedServiceDescriptionOid = Model.SelectedServiceDescription?.ServiceDescriptionOid; } return PartialView("Category2ServiceDescriptionPartial", Model); diff --git a/BeWoPlanerMobil/Controllers/ReportController.cs b/BeWoPlanerMobil/Controllers/ReportController.cs index ee5aee98e..c46a186c3 100644 --- a/BeWoPlanerMobil/Controllers/ReportController.cs +++ b/BeWoPlanerMobil/Controllers/ReportController.cs @@ -14,6 +14,7 @@ using System.Linq; using System.Text; using System.Web.Mvc; using BeWo.Service.Plugins; +using DevExpress.XtraReports.UI; // Controller des Quittierungsbelegsmoduls @@ -33,20 +34,83 @@ namespace BeWoPlanerMobil.Controllers return null; } - if(((ReportModel) Session[ModelSessionConstants.ReportModelKey])?.Employee is null) + if (_Model == null) { - _Model = new ReportModel {Employee = MobileSessionFacade.LoggedInEmployee, ReportCreator = GetReportCreator()}; - Session[ModelSessionConstants.ReportModelKey] = _Model; - } - else - { - _Model = (ReportModel) Session[ModelSessionConstants.ReportModelKey]; + _Model = new ReportModel { ReportCreator = GetReportCreator() }; + InitModel(_Model); + InitViewModel(); } + //if (((ReportModel) Session[ModelSessionConstants.ReportModelKey])?.LoggedInEmployee is null) + //{ + // _Model = new ReportModel {ReportCreator = GetReportCreator()}; + // InitModel(_Model); + // Session[ModelSessionConstants.ReportModelKey] = _Model; + //} + //else + //{ + // _Model = (ReportModel) Session[ModelSessionConstants.ReportModelKey]; + //} return _Model; } } + private void InitViewModel() + { + var month = DateTime.Today.Month; + var year = DateTime.Today.Year; + var first = new DateTime(year, month, 1).AddMonths(-1); + var last = first.AddMonths(1).AddDays(-1); + + Model.SelectedYear = Model.SelectedYear ?? first.Year; + Model.SelectedMonth = Model.SelectedMonth ?? first.Month; + Model.SelectedStartDay = Model.SelectedStartDay ?? first.Day; + Model.SelectedEndDay = Model.SelectedEndDay ?? last.Day; + + InitFilterCombo(); + + Model.Customers.Clear(); + + Model.Customers = CustomerService.GetAllActiveCustomersForEmployee(); + + Model.Employees = EmployeeService.GetActiveCompactEmployeesForEmployee(LoggedInEmployee.EmployeeOid.Value); + + Model.ServiceCategories = OperationsService.GetAllServiceCategories(); + + Model.Organisations = CustomerService.GetAllCostBearerCompact(); + Model.Organisations.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.CurrentCulture)); + + Model.AllTeams = EmployeeService.GetAllActiveCompactTeamsForEmployee(LoggedInEmployee.EmployeeOid.Value); + + Model.Dokutypes = ValueListService.GetAllValueListEntrysByType(ValueListEntryType.DocumentType); + if (Model.Dokutypes != null) + { + Model.Dokutypes = Model.Dokutypes.OrderBy(s => s.ValueListEntryOid).ToArray(); + } + + if (Model.SelectedCustomerOid.HasValue) + { + Model.SelectedCustomer = Model.Customers.FirstOrDefault(customer => customer.CustomerOid == Model.SelectedCustomerOid.Value); + } + + if (Model.SelectedEmployeeOid.HasValue) + { + Model.SelectedEmployee = Model.Employees.FirstOrDefault(employee => employee.EmployeeOid.Equals(Model.SelectedEmployeeOid.Value)); + } + if (Model.SelectedTeamOid.HasValue) + { + Model.SelectedTeam = Model.AllTeams.FirstOrDefault(team => team.TeamOid == Model.SelectedTeamOid.Value); + } + if (Model.SelectedOrganisationOid.HasValue) + { + Model.SelectedOrganisation= Model.Organisations.FirstOrDefault(organisation => organisation.OrganisationOid.Equals(Model.SelectedOrganisationOid.Value)); + } + if (Model.SelectedServiceCategoryOid.HasValue) + { + Model.SelectedServiceCategory = Model.ServiceCategories.FirstOrDefault(serviceCategory => serviceCategory.ServiceCategoryOid == Model.SelectedServiceCategoryOid.Value); + } + } + private static AbstractReportCreator GetReportCreator() { var creator = PluginLoader.FindClass(); @@ -68,7 +132,7 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } - if(!AbstractModel.HasRightToViewQuittierungsbelege) + if(!_Model.HasRightToViewQuittierungsbelege) { return RedirectToActionPermanent("Main", "Main"); } @@ -82,12 +146,12 @@ namespace BeWoPlanerMobil.Controllers { try { - if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || Model?.Employee?.EmployeeOid is null) + if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || Model?.LoggedInEmployee?.EmployeeOid is null) { return Logout(); } - if(!AbstractModel.HasRightToViewQuittierungsbelege) + if(!Model.HasRightToViewQuittierungsbelege) { return RedirectToActionPermanent("Main", "Main"); } @@ -98,36 +162,7 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } - var month = DateTime.Today.Month; - var year = DateTime.Today.Year; - var first = new DateTime(year, month, 1).AddMonths(-1); - var last = first.AddMonths(1).AddDays(-1); - - Model.SelectedYear = Model.SelectedYear ?? first.Year; - Model.SelectedMonth = Model.SelectedMonth ?? first.Month; - Model.SelectedStartDay = Model.SelectedStartDay ?? first.Day; - Model.SelectedEndDay = Model.SelectedEndDay ?? last.Day; - - InitFilterCombo(); - - Model.Customers.Clear(); - - Model.Customers = CustomerService.GetAllActiveCustomersForEmployee(); - - Model.Employees = EmployeeService.GetActiveCompactEmployeesForEmployee(MobileSessionFacade.LoggedInCompactEmployee.EmployeeOid); - - Model.ServiceCategories = OperationsService.GetAllServiceCategories(); - - Model.Organisations = CustomerService.GetAllCostBearerCompact(); - Model.Organisations.Sort((x, y) => string.Compare(x.Name, y.Name, StringComparison.CurrentCulture)); - - Model.AllTeams = EmployeeService.GetAllActiveCompactTeamsForEmployee(MobileSessionFacade.LoggedInEmployee.EmployeeOid); - - Model.Dokutypes = ValueListService.GetAllValueListEntrysByType(ValueListEntryType.DocumentType); - if(Model.Dokutypes != null) - { - Model.Dokutypes = Model.Dokutypes.OrderBy(s => s.ValueListEntryOid).ToArray(); - } + } catch(Exception e) { @@ -143,9 +178,9 @@ namespace BeWoPlanerMobil.Controllers var filterList = new List(); - var hasRightToViewCustomers = AbstractModel.CheckForAtLeastOneRight(new[] { UserRightType.CustomerView_View, UserRightType.ViewAll }); + var hasRightToViewCustomers = Model.CheckForAtLeastOneRight(new[] { UserRightType.CustomerView_View, UserRightType.ViewAll }); - var hasRightToViewMyTeams = AbstractModel.CheckForAtLeastOneRight(new[] { UserRightType.Customer_ViewMyTeams, UserRightType.ViewAll }); + var hasRightToViewMyTeams = Model.CheckForAtLeastOneRight(new[] { UserRightType.Customer_ViewMyTeams, UserRightType.ViewAll }); if(hasRightToViewCustomers) { @@ -160,14 +195,14 @@ namespace BeWoPlanerMobil.Controllers filterList.Add(new QbFilterItem(QBFilterEnum.MeineKlienten)); filterList.Add(new QbFilterItem(QBFilterEnum.KlientenAuswahl)); - if(AbstractModel.CheckRight(UserRightType.TeamView_ViewMyTeams) && false == AbstractModel.CheckRight(UserRightType.TeamView_ViewAll)) + if(Model.CheckRight(UserRightType.TeamView_ViewMyTeams) && false == Model.CheckRight(UserRightType.TeamView_ViewAll)) { if(hasRightToViewMyTeams) { filterList.Add(new QbFilterItem(QBFilterEnum.TeamAuswahl)); } } - else if(AbstractModel.CheckRight(UserRightType.TeamView_ViewAll)) + else if(Model.CheckRight(UserRightType.TeamView_ViewAll)) { if(hasRightToViewCustomers) { @@ -286,9 +321,9 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - if(Model.SelectedEmployee is null && (Model.Employee?.EmployeeOid.HasValue ?? false)) + if(Model.SelectedEmployee is null && (Model.LoggedInEmployee?.EmployeeOid.HasValue ?? false)) { - return $"{Model.Employee.LastNameFirstName}_{Model.Employee.EmployeeOid.Value}"; + return $"{Model.LoggedInEmployee.LastNameFirstName}_{Model.LoggedInEmployee.EmployeeOid.Value}"; } return $"{Model.SelectedEmployee.DetailDescription}_{Model.SelectedEmployee.EmployeeOid}"; @@ -303,6 +338,7 @@ namespace BeWoPlanerMobil.Controllers } Model.SelectedCustomer = Model.Customers.FirstOrDefault(customer => customer.CustomerOid == customerOid); + Model.SelectedCustomerOid = customerOid; return Model.SelectedCustomer?.DetailDescription ?? LeerzeichenFuerGetMethoden; } @@ -316,7 +352,7 @@ namespace BeWoPlanerMobil.Controllers } Model.SelectedTeam = Model.AllTeams.FirstOrDefault(team => team.TeamOid == teamOid); - + Model.SelectedTeamOid = teamOid; return Model.SelectedTeam?.DetailDescription ?? string.Empty; } @@ -386,12 +422,24 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - var isParsingSuccessful2 = long.TryParse(organisationOidStr, out var organisationOid); - var isParsingSuccessful3 = long.TryParse(categoryOidStr, out var categoryOid); + Model.SelectedOrganisationOid = null; + Model.SelectedServiceCategoryOid = null; - Model.SelectedOrganisation = isParsingSuccessful2 ? Model.Organisations.FirstOrDefault(organisation => organisation.OrganisationOid.Equals(organisationOid)) : null; + if (long.TryParse(organisationOidStr, out var organisationOid)) + { + Model.SelectedOrganisationOid = organisationOid; + } + + if (long.TryParse(categoryOidStr, out var categoryOid)) + { + Model.SelectedServiceCategoryOid = categoryOid; + } + - Model.SelectedServiceCategory = isParsingSuccessful3 ? OperationsService.LoadServiceCategory(categoryOid) : null; + //Model.SelectedOrganisation = isParsingSuccessful2 ? Model.Organisations.FirstOrDefault(organisation => organisation.OrganisationOid.Equals(organisationOid)) : null; + + //Model.SelectedServiceCategory = isParsingSuccessful3 ? OperationsService.LoadServiceCategory(categoryOid) : null; + return LeerzeichenFuerGetMethoden; } @@ -407,6 +455,7 @@ namespace BeWoPlanerMobil.Controllers Model.IsForSelectedEmployeesOnly = isForSelectedEmployeeOnly ?? false; Model.SelectedEmployee = employeeOid.HasValue ? Model.Employees.FirstOrDefault(employee => employee.EmployeeOid.Equals(employeeOid.Value)) : null; + Model.SelectedEmployeeOid = employeeOid; return LeerzeichenFuerGetMethoden; } @@ -421,6 +470,7 @@ namespace BeWoPlanerMobil.Controllers } Model.SelectedEmployee = employeeOid.HasValue ? Model.Employees.FirstOrDefault(employee => employee.EmployeeOid.Equals(employeeOid)) : null; + Model.SelectedEmployeeOid = employeeOid; return Model.SelectedEmployee?.DetailDescription ?? LeerzeichenFuerGetMethoden; } @@ -438,6 +488,7 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedOrganisation = organisationOid.HasValue && Model.IsForSelectedCostbearersOnly ? Model.Organisations.FirstOrDefault(organisation => organisation.OrganisationOid.Equals(organisationOid)) : null; + Model.SelectedOrganisationOid = organisationOid; return LeerzeichenFuerGetMethoden; } @@ -452,6 +503,7 @@ namespace BeWoPlanerMobil.Controllers } Model.SelectedOrganisation = organisationOid.HasValue ? Model.Organisations.FirstOrDefault(organisation => organisation.OrganisationOid.Equals(organisationOid)) : null; + Model.SelectedOrganisationOid = organisationOid; return Model.SelectedOrganisation?.DetailDescription ?? LeerzeichenFuerGetMethoden; } @@ -468,6 +520,7 @@ namespace BeWoPlanerMobil.Controllers Model.IsForSelectedCategoryOnly = isForSelectedServiceCategoryOnly ?? false; Model.SelectedServiceCategory = serviceCategoryOid.HasValue && Model.IsForSelectedCategoryOnly ? Model.ServiceCategories.FirstOrDefault(serviceCategory => serviceCategory.ServiceCategoryOid == serviceCategoryOid) : null; + Model.SelectedServiceCategoryOid = serviceCategoryOid; return LeerzeichenFuerGetMethoden; } @@ -485,6 +538,7 @@ namespace BeWoPlanerMobil.Controllers { Model.SelectedServiceCategory = Model.ServiceCategories.FirstOrDefault(serviceCategory => serviceCategory.ServiceCategoryOid == serviceCategoryOid); } + Model.SelectedServiceCategoryOid = serviceCategoryOid; return LeerzeichenFuerGetMethoden; } @@ -512,7 +566,7 @@ namespace BeWoPlanerMobil.Controllers var selectedFilterEnum = (QBFilterEnum) filterEnumValue; - Model.SelectedFilterItem = new QbFilterItem(selectedFilterEnum); + Model.SelectedFilterItemId = selectedFilterEnum; if(selectedFilterEnum != QBFilterEnum.KlientenAuswahl || Model.SelectedCustomer != null) { @@ -523,7 +577,7 @@ namespace BeWoPlanerMobil.Controllers if(!(customer is null)) { - Model.SelectedCustomer = customer; + Model.SelectedCustomerOid = customer.CustomerOid; } return LeerzeichenFuerGetMethoden; @@ -582,9 +636,9 @@ namespace BeWoPlanerMobil.Controllers { var temp = csr.ServiceRecords.Where(sr => sr.ServiceRecordOid.HasValue && !serviceRecordOidsWithSignature.Contains(sr.ServiceRecordOid.Value)); - if(!AbstractModel.HasRightToProvideEmployeeSignatureForOthers) + if(!Model.HasRightToProvideEmployeeSignatureForOthers) { - temp = temp.Where(sr => sr.Employee.Equals(MobileSessionFacade.LoggedInCompactEmployee)); + temp = temp.Where(sr => sr.Employee.Equals(LoggedInUser.Employee)); } csr.ServiceRecords.Clear(); @@ -613,9 +667,9 @@ namespace BeWoPlanerMobil.Controllers var filteredServiceRecords = new List(); - if(!isCustomerSig && !AbstractModel.HasRightToProvideEmployeeSignatureForOthers) + if(!isCustomerSig && !Model.HasRightToProvideEmployeeSignatureForOthers) { - filteredServiceRecords = serviceRecords.Where(sr => sr.Employee.Equals(MobileSessionFacade.LoggedInCompactEmployee)).ToList(); + filteredServiceRecords = serviceRecords.Where(sr => sr.Employee.Equals(LoggedInUser.Employee)).ToList(); } else { @@ -626,7 +680,7 @@ namespace BeWoPlanerMobil.Controllers { ServiceRecords = filteredServiceRecords, CustomerOid = isCustomerSig ? (long?) customerOid : null, - Employee = isCustomerSig ? null : MobileSessionFacade.LoggedInCompactEmployee, + Employee = isCustomerSig ? null : LoggedInUser.Employee, SignatureImage = base64SignatureString, SignatureType = signatureType, TimeSpanString = timeSpanString @@ -751,14 +805,14 @@ namespace BeWoPlanerMobil.Controllers var info = formCollection["deleteCustomerSignaturesInfo"]; - if(AbstractModel.HasRightToDeleteReceiptSignatures) + if(Model.HasRightToDeleteReceiptSignatures) { DeleteSignatures(info, true); } LoadPaginatedQbEntries(Model.CurrentQbEntryPage); - return RedirectToActionPermanent("InitReports"); + return RedirectToAction("InitReports"); } [Authorize] @@ -773,20 +827,20 @@ namespace BeWoPlanerMobil.Controllers var info = formCollection["deleteEmployeeSignatureInfo"]; - if(AbstractModel.HasRightToDeleteReceiptSignatures) + if(Model.HasRightToDeleteReceiptSignatures) { DeleteSignatures(info, false); } LoadPaginatedQbEntries(Model.CurrentQbEntryPage); - return RedirectToActionPermanent("InitReports"); + return RedirectToAction("InitReports"); } [Authorize] private void DeleteSignatures(string guid, bool isCustomerSignature) { - if(Model is null || !AbstractModel.HasRightToDeleteReceiptSignatures) + if(Model is null || !Model.HasRightToDeleteReceiptSignatures) { return; } @@ -843,13 +897,13 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedConfirmationReceiptSignatures = ConvertSignatureDCsToSignatureObjects(signatures); var customerName = obj.CustomerName; - var employeeName = MobileSessionFacade.LoggedInCompactEmployee.SimpleDescription; + var employeeName = LoggedInUser.Employee.SimpleDescription; var serviceRecordCount = 0; if(isEmployee) { - serviceRecordCount = AbstractModel.HasRightToProvideEmployeeSignatureForOthers ? obj.Items.Count : obj.Items.Count(x => x.EmployeeOid.Equals(Model.Employee.EmployeeOid)); + serviceRecordCount = Model.HasRightToProvideEmployeeSignatureForOthers ? obj.Items.Count : obj.Items.Count(x => x.EmployeeOid.Equals(LoggedInEmployee.EmployeeOid)); } else { @@ -863,38 +917,39 @@ namespace BeWoPlanerMobil.Controllers return PartialView("ConfirmationReceiptSignaturePartial", Model); } - [Authorize] - public ActionResult LoadReportToModel() - { - if(Model is null) - { - TempData[TempDataConstants.DoLogoutKey] = true; - return PartialView("QuittierungsbelegsPreviewPartial"); - } + //[Authorize] + //public ActionResult LoadReportToModel() + //{ + // if(Model is null) + // { + // TempData[TempDataConstants.DoLogoutKey] = true; + // return PartialView("QuittierungsbelegsPreviewPartial"); + // } - var month = Model.SelectedMonth ?? DateTime.Now.AddMonths(-1).Month; - var year = Model.SelectedYear ?? DateTime.Now.Year; - var customerOid = Model.SelectedCustomerOid; - var teamOid = Model.SelectedTeamOid; - var employeeOid = Model.SelectedEmployeeOid; - var organisationOid = Model.SelectedOrganisationOid; - var serviceCategoryOid = Model.SelectedServiceCategoryOid; - var startDate = Model.SelectedStartDay ?? 1; + // var month = Model.SelectedMonth ?? DateTime.Now.AddMonths(-1).Month; + // var year = Model.SelectedYear ?? DateTime.Now.Year; + // var customerOid = Model.SelectedCustomerOid; + // var teamOid = Model.SelectedTeamOid; + // var employeeOid = Model.SelectedEmployeeOid; + // var organisationOid = Model.SelectedOrganisationOid; + // var serviceCategoryOid = Model.SelectedServiceCategoryOid; + // var startDate = Model.SelectedStartDay ?? 1; - var date = new DateTime(year, month, startDate); + // var date = new DateTime(year, month, startDate); - var endDate = Model.SelectedEndDay ?? date.GetLastOfMonth().Day; - var filterType = Model.SelectedFilterItem; + // 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); + // Model.QuittierungsbelegsReportObject = Model.ReportCreator.CreateServiceOverviewReportNew(month, year, filterType.FilterEnum, customerOid, teamOid, employeeOid, organisationOid, serviceCategoryOid, startDate, endDate, false); - return PartialView("QuittierungsbelegsPreviewPartial", Model); - } + // return PartialView("QuittierungsbelegsPreviewPartial", Model); + //} [Authorize] public string ResetQuittierungsbeleg() { - Model.QuittierungsbelegsReportObject = null; + Model.QuittierungsbelegsReportSettings = null; + Model.QuittierungsbelegsReport = null; return LeerzeichenFuerGetMethoden; } @@ -909,28 +964,61 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } - var month = Model.SelectedMonth ?? DateTime.Now.AddMonths(-1).Month; - var year = Model.SelectedYear ?? DateTime.Now.Year; - var customerOid = Model.SelectedCustomerOid; - var teamOid = Model.SelectedTeamOid; - var employeeOid = Model.SelectedEmployeeOid; - var organisationOid = Model.SelectedOrganisationOid; - var serviceCategoryOid = Model.SelectedServiceCategoryOid; - var startDate = Model.SelectedStartDay ?? 1; + var reportSettings = new QuittierungsbelegsReportSettings(); - var date = new DateTime(year, month, startDate); + reportSettings.Month = Model.SelectedMonth ?? DateTime.Now.AddMonths(-1).Month; + reportSettings.Year = Model.SelectedYear ?? DateTime.Now.Year; + reportSettings.CustomerOid = Model.SelectedCustomerOid; + reportSettings.TeamOid = Model.SelectedTeamOid; + reportSettings.EmployeeOid = Model.SelectedEmployeeOid; + reportSettings.OrganisationOid = Model.SelectedOrganisationOid; + reportSettings.ServiceCategoryOid = Model.SelectedServiceCategoryOid; + reportSettings.StartDay = Model.SelectedStartDay ?? 1; - var endDate = Model.SelectedEndDay ?? date.GetLastOfMonth().Day; - var filterType = Model.SelectedFilterItem; + var date = new DateTime(reportSettings.Year, reportSettings.Month, reportSettings.StartDay); - var report = Model.ReportCreator.CreateServiceOverviewReportNew(month, year, filterType.FilterEnum, customerOid, teamOid, employeeOid, organisationOid, serviceCategoryOid, startDate, endDate, false); + reportSettings.EndDay = Model.SelectedEndDay ?? date.GetLastOfMonth().Day; + reportSettings.FilterEnum = Model.SelectedFilterItem.FilterEnum; + + + Model.QuittierungsbelegsReportSettings = reportSettings; + + //var report = Model.ReportCreator.CreateServiceOverviewReportNew(month, year, filterType.FilterEnum, customerOid, teamOid, employeeOid, organisationOid, serviceCategoryOid, startDate, endDate, false); + + //report.ExportOptions.PrintPreview.DefaultFileName = CreateFileName(); + //report.DisplayName = CreateFileName(); + + + return RedirectToAction("InitReports"); + } + + [Authorize] + public ActionResult CreateQuittierungsbelegsReport() + { + if (Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return PartialView("QuittierungsbelegsPreviewPartial"); + } + Model.QuittierungsbelegsReport = CreateQuittierungsbelegsReportFromSettings(); + + return PartialView("QuittierungsbelegsPreviewPartial", Model); + } + + private XtraReport CreateQuittierungsbelegsReportFromSettings() + { + if (Model.QuittierungsbelegsReportSettings == null) + { + return null; + } + var s = Model.QuittierungsbelegsReportSettings; + + var report = Model.ReportCreator.CreateServiceOverviewReportNew(s.Month, s.Year, s.FilterEnum, s.CustomerOid, s.TeamOid, s.EmployeeOid, s.OrganisationOid, s.ServiceCategoryOid, s.StartDay, s.EndDay, false); report.ExportOptions.PrintPreview.DefaultFileName = CreateFileName(); report.DisplayName = CreateFileName(); - Model.QuittierungsbelegsReportObject = report; - - return RedirectToActionPermanent("InitReports"); + return report; } private string CreateFileName() @@ -1040,6 +1128,7 @@ namespace BeWoPlanerMobil.Controllers else { Model.SelectedCustomer = null; + Model.SelectedCustomerOid = null; } if(Model.SelectedFilterItem.FilterEnum == QBFilterEnum.TeamAuswahl) @@ -1058,6 +1147,7 @@ namespace BeWoPlanerMobil.Controllers else { Model.SelectedTeam = null; + Model.SelectedTeamOid = null; } var reportTimeFrame = GetReportTimeFrame(); @@ -1154,15 +1244,15 @@ namespace BeWoPlanerMobil.Controllers employeeSignatureState = SignatureState.All; } - if(!AbstractModel.HasRightToProvideEmployeeSignatureForOthers) + if(!Model.HasRightToProvideEmployeeSignatureForOthers) { // Prüfen, ob alle eigenen ServiceRecords unterschrieben sind var ownServiceRecordOids = new List(); - reportObjects.DoForEach(reportObject => ownServiceRecordOids.AddRangeIfElementsNotIn(reportObject.Services.Where(serviceDetail => serviceDetail.EmployeeOid.Equals(Model.Employee.EmployeeOid)).Select(serviceDetail => serviceDetail.ServiceRecordOid))); + reportObjects.DoForEach(reportObject => ownServiceRecordOids.AddRangeIfElementsNotIn(reportObject.Services.Where(serviceDetail => serviceDetail.EmployeeOid.Equals(LoggedInEmployee.EmployeeOid)).Select(serviceDetail => serviceDetail.ServiceRecordOid))); // Prüfen, ob Einträge von anderen Mitarbeitern existieren var serviceRecordOidsFromOtherEmployees = new List(); - reportObjects.DoForEach(reportObject => serviceRecordOidsFromOtherEmployees.AddRangeIfElementsNotIn(reportObject.Services.Where(serviceDetail => !serviceDetail.EmployeeOid.Equals(Model.Employee.EmployeeOid)).Select(serviceDetail => serviceDetail.ServiceRecordOid))); + reportObjects.DoForEach(reportObject => serviceRecordOidsFromOtherEmployees.AddRangeIfElementsNotIn(reportObject.Services.Where(serviceDetail => !serviceDetail.EmployeeOid.Equals(LoggedInEmployee.EmployeeOid)).Select(serviceDetail => serviceDetail.ServiceRecordOid))); var areAllForeignEntriesSigned = serviceRecordOidsFromOtherEmployees.All(srOid => serviceRecordOidsWithSignature.ContainsValueAtKey(SignatureType.Employee, srOid)); var areAllOwnEntriesSigned = ownServiceRecordOids.All(srOid => serviceRecordOidsWithSignature.ContainsValueAtKey(SignatureType.Employee, srOid)); @@ -1253,10 +1343,10 @@ namespace BeWoPlanerMobil.Controllers employeeOids.AddIfNotIn(serviceDetail.EmployeeOid); } - if(!AbstractModel.HasRightToProvideEmployeeSignatureForOthers) + if(!Model.HasRightToProvideEmployeeSignatureForOthers) { - var serviceRecordOidsFromOtherEmployees = reportObject.Services.Where(serviceDetail => !serviceDetail.EmployeeOid.Equals(Model.Employee.EmployeeOid)).Select(serviceDetail => serviceDetail.ServiceRecordOid).ToList(); - var ownServiceRecordOids = reportObject.Services.Where(serviceDetail => serviceDetail.EmployeeOid.Equals(Model.Employee.EmployeeOid)).Select(serviceDetail => serviceDetail.ServiceRecordOid).ToList(); + var serviceRecordOidsFromOtherEmployees = reportObject.Services.Where(serviceDetail => !serviceDetail.EmployeeOid.Equals(LoggedInEmployee.EmployeeOid)).Select(serviceDetail => serviceDetail.ServiceRecordOid).ToList(); + var ownServiceRecordOids = reportObject.Services.Where(serviceDetail => serviceDetail.EmployeeOid.Equals(LoggedInEmployee.EmployeeOid)).Select(serviceDetail => serviceDetail.ServiceRecordOid).ToList(); var areAllForeignEntriesSigned = serviceRecordOidsFromOtherEmployees.All(srOid => serviceRecordOidsWithSignature.ContainsValueAtKey(SignatureType.Employee, srOid)); var areAllOwnEntriesSigned = ownServiceRecordOids.All(srOid => serviceRecordOidsWithSignature.ContainsValueAtKey(SignatureType.Employee, srOid)); diff --git a/BeWoPlanerMobil/Controllers/ReportViewerController.cs b/BeWoPlanerMobil/Controllers/ReportViewerController.cs index 837e9775b..a3682d914 100644 --- a/BeWoPlanerMobil/Controllers/ReportViewerController.cs +++ b/BeWoPlanerMobil/Controllers/ReportViewerController.cs @@ -33,29 +33,30 @@ namespace BeWoPlanerMobil.Controllers return null; } - if(((ReportViewerModel)Session[ModelSessionConstants.ReportViewerModelKey])?.Employee is null) + + if (_Model == null) { - _Model = new ReportViewerModel { Employee = MobileSessionFacade.LoggedInEmployee, ReportCreator = GetReportCreator() }; - Session[ModelSessionConstants.ReportViewerModelKey] = _Model; - } - else - { - _Model = (ReportViewerModel)Session[ModelSessionConstants.ReportViewerModelKey]; + _Model = new ReportViewerModel { ReportCreator = GetReportCreator() }; + InitModel(_Model); + InitViewModel(); } + //if (((ReportViewerModel)Session[ModelSessionConstants.ReportViewerModelKey])?.LoggedInEmployee is null) + //{ + // _Model = new ReportViewerModel { ReportCreator = GetReportCreator() }; + // Session[ModelSessionConstants.ReportViewerModelKey] = _Model; + //} + //else + //{ + // _Model = (ReportViewerModel)Session[ModelSessionConstants.ReportViewerModelKey]; + //} + return _Model; } } - [Authorize] - public ActionResult ReportViewer() + private void InitViewModel() { - if(Model is null) - { - TempData[TempDataConstants.DoLogoutKey] = true; - return Logout(); - } - Model.Report = null; var month = DateTime.Today.Month; @@ -67,27 +68,39 @@ namespace BeWoPlanerMobil.Controllers - Model.AllEmployees = AbstractModel.HasRightMitarbeiterstundenkontoViewAll - ? EmployeeService.GetAllActiveEmployeesCompact() - : new List { MobileSessionFacade.LoggedInCompactEmployee }; + Model.AllEmployees = Model.HasRightMitarbeiterstundenkontoViewAll + ? EmployeeService.GetAllActiveEmployeesCompact() + : new List { LoggedInUser.Employee }; // Alle Teams darf man nur sehen, wenn man das Recht "HasRightMitarbeiterstundenkontoViewAll" hat. // Hat man weder das Recht "HasRightMitarbeiterstundenkontoViewAll" noch "HasRightMitarbeiterstundenkontoViewTeams", sieht man die Teams gar nicht. // Hat man das Recht "HasRightMitarbeiterstundenkontoViewTeams", aber nicht das Recht "HasRightMitarbeiterstundenkontoViewAll", sieht man nur die Teams, deren Teamleiter man ist. - Model.AllTeams = AbstractModel.HasRightMitarbeiterstundenkontoViewAll - ? EmployeeService.GetAllActiveCompactTeamsForEmployee(MobileSessionFacade.LoggedInEmployee.EmployeeOid) - : EmployeeService.FindLeadingCompactTeamsOfEmployee(MobileSessionFacade.LoggedInCompactEmployee.EmployeeOid); + Model.AllTeams = Model.HasRightMitarbeiterstundenkontoViewAll + ? EmployeeService.GetAllActiveCompactTeamsForEmployee(LoggedInEmployee.EmployeeOid) + : EmployeeService.FindLeadingCompactTeamsOfEmployee(LoggedInUser.Employee.EmployeeOid); - if(false == AbstractModel.HasRightMitarbeiterstundenkontoViewAll || Model.SelectedEmployee is null) + if (false == Model.HasRightMitarbeiterstundenkontoViewAll || Model.SelectedEmployeeOid is null) { - Model.SelectedEmployee = MobileSessionFacade.LoggedInCompactEmployee; + Model.SelectedEmployeeOid = LoggedInUser.Employee.EmployeeOid; } + if (Model.SelectedEmployeeOid.HasValue) + { + Model.SelectedEmployee = Model.AllEmployees.FirstOrDefault(employee => employee.EmployeeOid.Equals(Model.SelectedEmployeeOid.Value)); + } + + if (Model.SelectedTeamOid.HasValue) + { + Model.SelectedTeam = Model.AllTeams.FirstOrDefault(team => team.TeamOid.Equals(Model.SelectedTeamOid.Value)); + } + + + Model.ReportTypes = new List(); #if DEBUG - if(AbstractModel.HasRightToViewReports) + if (Model.HasRightToViewReports) { Model.ReportTypes.Add(new SelectListItem { @@ -100,15 +113,20 @@ namespace BeWoPlanerMobil.Controllers Model.Queries = QueryService.GetAllQueriesOfType(QueryType.Public); + if (Model.SelectedQueryOid.HasValue) + { + Model.SelectedQuery = Model.Queries.FirstOrDefault(q => q.Oid.Equals(Model.SelectedQueryOid.Value)); + } + var names2ValueListEntryTypes = new Dictionary(); - foreach(var query in Model.Queries.Where(q => q.Parameter?.Any() ?? false)) + foreach (var query in Model.Queries.Where(q => q.Parameter?.Any() ?? false)) { - foreach(var parameter in query.Parameter.Where(p => p.ParamType == QueryParameterType.ValueListEntryType)) + foreach (var parameter in query.Parameter.Where(p => p.ParamType == QueryParameterType.ValueListEntryType)) { var parameterName = parameter.Name; - if(!(parameterName?.Contains("_") ?? false)) + if (!(parameterName?.Contains("_") ?? false)) { continue; } @@ -118,12 +136,12 @@ namespace BeWoPlanerMobil.Controllers var name = name2Type[0]; var type = name2Type[1]; - if(!int.TryParse(type, out var typeEnumInt)) + if (!int.TryParse(type, out var typeEnumInt)) { continue; } - var valueListEntryType = (ValueListEntryType) typeEnumInt; + var valueListEntryType = (ValueListEntryType)typeEnumInt; names2ValueListEntryTypes.AddIfNotIn(new KeyValuePair(name, valueListEntryType)); } } @@ -135,9 +153,9 @@ namespace BeWoPlanerMobil.Controllers Model.ValueListEntryTypes2ValueListEntries.AddOrUpdateValueInDictionary(valueListEntry.Type, valueListEntry); }); - if(Model.Employee?.EmployeeOid.HasValue ?? false) + if (Model.LoggedInEmployee?.EmployeeOid.HasValue ?? false) { - Model.SupportConcepts = EmployeeService.GetActiveSupportConceptsForEmployee(Model.Employee.EmployeeOid, CustomerFilterEnum.All); + Model.SupportConcepts = EmployeeService.GetActiveSupportConceptsForEmployee(Model.LoggedInEmployee.EmployeeOid, CustomerFilterEnum.All); } else { @@ -146,9 +164,9 @@ namespace BeWoPlanerMobil.Controllers Model.SupportConcepts.DoForEach(sc => Model.CostBearer2SupportConceptRels.AddRangeIfElementsNotIn(sc.CostBearerRelations)); - if(Model.SelectedCostBearer2SupportConceptRelListObject is null) + if (Model.SelectedCostBearer2SupportConceptRelListObject is null) { - Model.SelectedCostBearer2SupportConceptRelListObject = Model.CostBearer2SupportConceptRelListObjects.FirstOrDefault(f => f.CostBearer2SupportConceptOid == "-1") ?? Model.CostBearer2SupportConceptRelListObjects.First(); + Model.SelectedCostBearer2SupportConceptRelListObject = Model.CostBearer2SupportConceptRelListObjects.FirstOrDefault(f => f.CostBearer2SupportConceptOid == -1) ?? Model.CostBearer2SupportConceptRelListObjects.First(); } Model.AllOrganisationForQuery = CustomerService.GetAllActiveOrganisationsCompact(); @@ -156,12 +174,12 @@ namespace BeWoPlanerMobil.Controllers Model.AllServiceCategoriesForQueries = OperationsService.GetAllServiceCategories(); - + } - + #endif - if(AbstractModel.HasRightToViewMitarbeiterstundenkonto) + if (Model.HasRightToViewMitarbeiterstundenkonto) { Model.ReportTypes.Add(new SelectListItem { @@ -178,6 +196,18 @@ namespace BeWoPlanerMobil.Controllers #if DEBUG //Model.SelectedReportType = ReportType.Berichte; #endif + } + + [Authorize] + public ActionResult ReportViewer() + { + if(Model is null) + { + TempData[TempDataConstants.DoLogoutKey] = true; + return Logout(); + } + + return View(Model); } @@ -198,7 +228,7 @@ namespace BeWoPlanerMobil.Controllers { try { - if(Model?.Employee?.EmployeeOid is null || reportOid is null) + if(Model?.LoggedInEmployee?.EmployeeOid is null || reportOid is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("BeWoReportPartial"); @@ -216,7 +246,7 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedQuery = selectedQuery; - var dcid = $"{MobileSessionFacade.Tenant}queryeoid{Model.Employee.EmployeeOid.Value}"; + var dcid = $"{MobileSessionFacade.Tenant}queryeoid{Model.LoggedInEmployee.EmployeeOid.Value}"; var queryResult = QueryService.ExecuteQuery(selectedQuery.Oid, null); @@ -249,7 +279,7 @@ namespace BeWoPlanerMobil.Controllers { try { - if(Model?.Employee?.EmployeeOid is null || reportOid is null) + if(Model?.LoggedInEmployee?.EmployeeOid is null || reportOid is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("BerichteFormPartialView"); @@ -318,7 +348,7 @@ namespace BeWoPlanerMobil.Controllers private string GetSiteOfOrigin() { - if(Model?.Employee?.EmployeeOid is null) + if(Model?.LoggedInEmployee?.EmployeeOid is null) { return null; } @@ -361,6 +391,7 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } + Model.SelectedEmployeeOid = employeeOid; Model.SelectedEmployee = Model.AllEmployees.FirstOrDefault(employee => employee.EmployeeOid.Equals(employeeOid.Value)); return Model.SelectedEmployee?.DetailDescription ?? LeerzeichenFuerGetMethoden; @@ -381,6 +412,7 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } + Model.SelectedTeamOid = teamOid; Model.SelectedTeam = Model.AllTeams.FirstOrDefault(team => team.TeamOid.Equals(teamOid.Value)); return Model.SelectedTeam?.DetailDescription ?? LeerzeichenFuerGetMethoden; @@ -389,7 +421,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadMitarbeiterstundenkonto(int ansicht, int month, int year, bool all, bool isEmployee) { - if(Model?.Employee?.EmployeeOid is null) + if(Model?.LoggedInEmployee?.EmployeeOid is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("BeWoReportPartial"); @@ -397,13 +429,14 @@ namespace BeWoPlanerMobil.Controllers var teamOids = new List(); var employeeOid = Model.SelectedEmployeeOid; - var oid = isEmployee ? employeeOid ?? Model.Employee.EmployeeOid.Value : Model.SelectedTeamOid; + var oid = isEmployee ? employeeOid ?? Model.LoggedInEmployee.EmployeeOid.Value : Model.SelectedTeamOid; if(isEmployee) { + teamOids = null; employeeOid = oid; - if(all || false == AbstractModel.HasRightMitarbeiterstundenkontoViewAll) + if(all || false == Model.HasRightMitarbeiterstundenkontoViewAll) { employeeOid = null; } @@ -413,16 +446,18 @@ namespace BeWoPlanerMobil.Controllers employeeOid = oid; } - if(false == AbstractModel.HasRightMitarbeiterstundenkontoViewAll) + if(false == Model.HasRightMitarbeiterstundenkontoViewAll) { - employeeOid = Model.Employee.EmployeeOid; + employeeOid = Model.LoggedInEmployee.EmployeeOid; } } else { + employeeOid = null; + var teamOid = oid; - if(all || (!AbstractModel.HasRightMitarbeiterstundenkontoViewAll && !AbstractModel.HasRightMitarbeiterstundenkontoViewTeams)) + if(all || (!Model.HasRightMitarbeiterstundenkontoViewAll && !Model.HasRightMitarbeiterstundenkontoViewTeams)) { teamOid = null; } @@ -723,7 +758,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult ExecuteQuery() { - if(Model?.Employee?.EmployeeOid is null) + if(Model?.LoggedInEmployee?.EmployeeOid is null) { TempData[TempDataConstants.DoLogoutKey] = true; @@ -748,7 +783,7 @@ namespace BeWoPlanerMobil.Controllers } } - var dcid = $"{MobileSessionFacade.Tenant}queryeoid{Model.Employee.EmployeeOid.Value}"; + var dcid = $"{MobileSessionFacade.Tenant}queryeoid{Model.LoggedInEmployee.EmployeeOid.Value}"; var queryResult = QueryService.ExecuteQuery(query.Oid, paramList); diff --git a/BeWoPlanerMobil/Controllers/SchedulerController.cs b/BeWoPlanerMobil/Controllers/SchedulerController.cs index 8ec847df3..735d9dd9c 100644 --- a/BeWoPlanerMobil/Controllers/SchedulerController.cs +++ b/BeWoPlanerMobil/Controllers/SchedulerController.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Security.Cryptography; +using System.Text; using System.Web.Mvc; using BeWoPlanerMobil.Models; @@ -32,35 +34,37 @@ namespace BeWoPlanerMobil.Controllers return null; } - if (((SchedulerModel) Session[ModelSessionConstants.SchedulerModelKey])?.Employee is null) + if (_Model == null) { - _Model = new SchedulerModel { Employee = MobileSessionFacade.LoggedInEmployee }; - Session[ModelSessionConstants.SchedulerModelKey] = _Model; - } - else - { - _Model = (SchedulerModel) Session[ModelSessionConstants.SchedulerModelKey]; + _Model = new SchedulerModel(); + InitModel(_Model); + InitViewModel(); } + //if (((SchedulerModel) Session[ModelSessionConstants.SchedulerModelKey])?.LoggedInEmployee is null) + //{ + // _Model = new SchedulerModel(); + // InitModel(_Model); + // Session[ModelSessionConstants.SchedulerModelKey] = _Model; + //} + //else + //{ + // _Model = (SchedulerModel) Session[ModelSessionConstants.SchedulerModelKey]; + //} + return _Model; } } - [Authorize] - public ActionResult Scheduler() + private void InitViewModel() { - if(Model is null || !MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !AbstractModel.IsAllowedToSeeScheduler) - { - return Logout(); - } - - if(AbstractModel.HasRightToInsertRessourceAppointments || AbstractModel.HasRightToViewAllResourceAppointments) + if (Model.HasRightToInsertRessourceAppointments || Model.HasRightToViewAllResourceAppointments) { var allResources = KalenderService.GetAllResources().OrderBy(r => r.Name).ToList(); var categories2Resources = new Dictionary>(); - foreach(var category in allResources.Select(resource => resource.ResourceCategory)) + foreach (var category in allResources.Select(resource => resource.ResourceCategory)) { categories2Resources.AddOrUpdateValueInDictionary(category, allResources.Where(resource => resource.ResourceCategory.Equals(category)).OrderBy(r => r.Name).ToList()); } @@ -68,35 +72,107 @@ namespace BeWoPlanerMobil.Controllers Model.ResourceCategories2Resources = categories2Resources.OrderBy(kvp => kvp.Key.DisplayName).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); } - if(Model?.Employee?.EmployeeOid.HasValue ?? false) + if (Model?.LoggedInEmployee?.EmployeeOid.HasValue ?? false) { - var compactEmployee = EmployeeService.GetActiveCompactEmployeeWithOid(Model.Employee.EmployeeOid.Value); + var compactEmployee = EmployeeService.GetActiveCompactEmployeeWithOid(Model.LoggedInEmployee.EmployeeOid.Value); Model.MyTeamEmployees = EmployeeService.GetAllTeamMember(compactEmployee).OrderBy(employee => employee.LastName).ToList(); } - else if(!(Model is null)) + else if (!(Model is null)) { Model.MyTeamEmployees = new List(); } - if(AbstractModel.HasRightToViewTeams && (Model?.Employee?.EmployeeOid.HasValue ?? false)) + if (Model.HasRightToViewTeams && (Model?.LoggedInEmployee?.EmployeeOid.HasValue ?? false)) { - Model.MyTeams = EmployeeService.GetAllActiveCompactTeamsForEmployee(Model.Employee.EmployeeOid.Value).OrderBy(team => team.Name).ToList(); + Model.MyTeams = EmployeeService.GetAllActiveCompactTeamsForEmployee(Model.LoggedInEmployee.EmployeeOid.Value).OrderBy(team => team.Name).ToList(); } - if(!(Model is null)) + if (!(Model is null)) { - Model.TeamMemberCustomerOids = EmployeeService.LoadTeamsRelatedCustomerOids(MobileSessionFacade.LoggedInCompactEmployee.EmployeeOid); + Model.TeamMemberCustomerOids = EmployeeService.LoadTeamsRelatedCustomerOids(LoggedInUser.Employee.EmployeeOid); + } + + if (Model.HasRightToViewCustomerSelectionInScheduler) + { + Model.AllCustomers = CustomerService.GetAllActiveCompactCustomers().OrderBy(customer => customer.LastName).ToList(); + } + + if (Model.HasRightToViewEmployeeAppointments) + { + Model.AllEmployees = EmployeeService.GetAllActiveEmployeesCompact().OrderBy(employee => employee.LastName).ToList(); + } + + //LoadAppointmentsForDate(); + + if (Model.SelectedAppointmentOid.HasValue) + { + if (Model.Appointments == null) + { + LoadAppointmentsForDate(); + } + Model.SelectedAppointment = Model.Appointments.FirstOrDefault(app => app.SchedulerAppointmentOid.HasValue && app.SchedulerAppointmentOid.Value == Model.SelectedAppointmentOid.Value); + } + SetHasResourcesEmployeesOrCustomers(); + UpdateSelectedObjects(); + + + } + + private void UpdateSelectedObjects() + { + //mache aus dem Ressourcenkategorien Dictionary eine flache Liste: + var list = new List(); + Model.ResourceCategories2Resources.Values.DoForEach(l => l.DoForEach(s => list.AddIfNotIn(s))); + + Model.SelectedEmployees = Model.AllEmployees.Where(employee => Model.SelectedEmployeeOids.Contains(employee.EmployeeOid)).ToList(); + Model.SelectedCustomers = Model.AllCustomers.Where(customer => Model.SelectedCustomerOids.Contains(customer.CustomerOid)).ToList(); + Model.SelectedResources = list.Where(resource => resource.ResourceOid.HasValue && Model.SelectedResourceOids.Contains(resource.ResourceOid.Value)).ToList(); + + Model.SelectedEmployeesForFiltering = Model.AllEmployees.Where(employee => Model.SelectedEmployeeOidsForFiltering.Contains(employee.EmployeeOid)).ToList(); + Model.SelectedCustomersForFiltering = Model.AllCustomers.Where(customer => Model.SelectedCustomerOidsForFiltering.Contains(customer.CustomerOid)).ToList(); + Model.SelectedResourcesForFiltering = list.Where(resource => resource.ResourceOid.HasValue && Model.SelectedResourceOidsForFiltering.Contains(resource.ResourceOid.Value)).ToList(); + + Model.SelectedEmployeesForIntervalFinder = Model.AllEmployees.Where(employee => Model.SelectedEmployeeOidsForIntervalFinder.Contains(employee.EmployeeOid)).ToList(); + Model.SelectedCustomersForIntervalFinder = Model.AllCustomers.Where(customer => Model.SelectedCustomerOidsForIntervalFinder.Contains(customer.CustomerOid)).ToList(); + Model.SelectedResourcesForIntervalFinder = list.Where(resource => resource.ResourceOid.HasValue && Model.SelectedResourceOidsForIntervalFinder.Contains(resource.ResourceOid.Value)).ToList(); + } + + // ToDo: Überarbeiten? Es kam das Ansehen hinzu + private void SetHasResourcesEmployeesOrCustomers() + { + var isOwnAppointment = !Model.IsInEditMode || Model.SelectedAppointment?.Originator.EmployeeOid == LoggedInEmployee.EmployeeOid; + + var v1 = Model.HasRightToInsertEmployeeAppointments || Model.IsInEditMode && Model.HasRightToEditEmployeeAppointments; + + var v2 = Model.HasRightToInsertRessourceAppointments || Model.IsInEditMode && Model.HasRightToEditResourceAppointments; + + if (Model.IsInEditMode && !isOwnAppointment) + { + v2 = Model.HasRightToEditOthersResourceAppointments; + } + + var v3 = Model.HasRightToInsertCustomerAppointments || Model.IsInEditMode && Model.HasRightToEditCustomerAppointments; + + Model.HasResourcesEmployeesOrCustomers = v1 || v2 || v3; + + } + + [Authorize] + public ActionResult Scheduler() + { + if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || !Model.IsAllowedToSeeScheduler) + { + return Logout(); } - LoadAppointmentsForDate(); return View(Model); } private void LoadAppointmentsForDate() { - if(Model?.Employee.EmployeeOid is null) + if(Model?.LoggedInEmployee.EmployeeOid is null) { return; } @@ -119,16 +195,16 @@ namespace BeWoPlanerMobil.Controllers end = sunday; } - var selectedCustomers = Model.SelectedCustomersForFiltering?.Select(s => s.CustomerOid).ToList() ?? new List(); - var selectedEmployees = Model.SelectedEmployeesForFiltering?.Select(s => s.EmployeeOid).ToList() ?? new List(); - var selectedResources = Model.SelectedResourcesForFiltering?.Where(w => w.ResourceOid.HasValue).Select(s => s.ResourceOid.Value).ToList() ?? new List(); + var selectedCustomers = Model.SelectedCustomerOidsForFiltering; + var selectedEmployees = Model.SelectedEmployeeOidsForFiltering.Clone(); //Wird soinst im KalenderService geändert + var selectedResources = Model.SelectedResourceOidsForFiltering; - var appointments = KalenderService.LoadFilteredAppointmentsMitAufgaben(AbstractModel.HasRightToViewEmployeeAppointments, Model.Employee.EmployeeOid.Value, start.Date, end, selectedEmployees, selectedCustomers, selectedResources, false, false, false, false, true, true).ToList(); + var appointments = KalenderService.LoadFilteredAppointmentsMitAufgaben(Model.HasRightToViewEmployeeAppointments, Model.LoggedInEmployee.EmployeeOid.Value, start.Date, end, selectedEmployees, selectedCustomers, selectedResources, false, false, false, false, true, true).ToList(); // Private Termine foreach(var appointment in appointments.Where(a => a.IsPrivate)) { - if(appointment.Originator.Equals(MobileSessionFacade.LoggedInCompactEmployee) || appointment.EmployeeList.Any(e2a => e2a.Employee.Equals(MobileSessionFacade.LoggedInCompactEmployee))) + if(appointment.Originator.Equals(LoggedInUser.Employee) || appointment.EmployeeList.Any(e2a => e2a.Employee.Equals(LoggedInUser.Employee))) { continue; } @@ -142,17 +218,17 @@ namespace BeWoPlanerMobil.Controllers var tasks = appointments.Where(w => w.IsTask && w.CompletedDate is null).ToList(); // Nur eigene Kliententermine ansehen - if(!AbstractModel.HasRightToViewCustomerAppointments) + if(!Model.HasRightToViewCustomerAppointments) { - appointments = appointments.Where(a => a.CustomerList.All(c => MobileSessionFacade.LoggedInEmployee.RelatedCustomers.Any(rc => rc.Customer.Equals(c)))).ToList(); + appointments = appointments.Where(a => a.CustomerList.All(c => LoggedInEmployee.RelatedCustomers.Any(rc => rc.Customer.Equals(c)))).ToList(); } - if(!AbstractModel.HasRightToViewAllResourceAppointments) + if(!Model.HasRightToViewAllResourceAppointments) { appointments = appointments.Where(a => a.ResourceList.Count == 0).ToList(); } - if(!AbstractModel.IsAllowedToSeeCustomers) + if(!Model.IsAllowedToSeeCustomers) { appointments = appointments.Where(a => a.CustomerList.Count == 0).ToList(); } @@ -189,19 +265,31 @@ namespace BeWoPlanerMobil.Controllers holySweetFlyingFuck.OrderByDescending(appointment => appointment.IsTask).ThenBy(appointment => appointment.StartDate).ToList() : holySweetFlyingFuck.Where(w => w.IsTask is false).OrderBy(appointment => appointment.StartDate).ToList(); - Model.WeekViewObject = new WeekViewObject(Model.Appointments, Model.SelectedDate.GetInSameCalendarWeek(DayOfWeek.Monday), Model.Employee); + UpdateAppointmentListItems(); - if(AbstractModel.HasRightToViewCustomerSelectionInScheduler) + Model.WeekViewObject = new WeekViewObject(Model.Appointments, Model.SelectedDate.GetInSameCalendarWeek(DayOfWeek.Monday), Model.LoggedInEmployee); + + + } + private void UpdateAppointmentListItems() + { + var md5 = new MD5CryptoServiceProvider(); + + + var list = new List(); + + foreach (var appointment in Model.Appointments) { - //Model.AllCustomers = EmployeeService.GetActiveCompactCustomersForEmployee(Model.Employee.EmployeeOid).OrderBy(o => o.DetailDescription).ToList(); - Model.AllCustomers = CustomerService.GetAllActiveCompactCustomers().OrderBy(customer => customer.LastName).ToList(); + String key = String.Format("{0}_{1}", appointment.SchedulerAppointmentOid, appointment.RecurrenceInfo); + String id = BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(key))).Replace("-", "").ToLower(); + var listItem = new AppointmentListItem(id, appointment); + + + + list.Add(listItem); } - if(AbstractModel.HasRightToViewEmployeeAppointments) - { - //Model.AllEmployees = EmployeeService.GetActiveCompactEmployeesForEmployee(Model.Employee.EmployeeOid.Value).OrderBy(o => o.DetailDescription).ToList(); - Model.AllEmployees = EmployeeService.GetAllActiveEmployeesCompact().OrderBy(employee => employee.LastName).ToList(); - } + Model.AppointmentListItems = list; } private static IEnumerable CalculateRecurrences(IEnumerable appointments, DateTime start, DateTime end, IReadOnlyCollection changedOccurrences, IReadOnlyCollection deletedOccurrences) @@ -341,7 +429,7 @@ namespace BeWoPlanerMobil.Controllers appointmentToInsert.StartDate = startDate; appointmentToInsert.Subject = subject; appointmentToInsert.Description = notice; - appointmentToInsert.Originator = MobileSessionFacade.LoggedInCompactEmployee; + appointmentToInsert.Originator = LoggedInUser.Employee; appointmentToInsert.Location = location; appointmentToInsert.ActivationType = ActivationTypeId.Active; appointmentToInsert.IsPrivate = isPrivate; @@ -376,10 +464,10 @@ namespace BeWoPlanerMobil.Controllers if(Model != null) { Model.IsAllDay = false; - Model.SelectedAppointment = null; - Model.SelectedResources?.Clear(); - Model.SelectedCustomers?.Clear(); - Model.SelectedEmployees?.Clear(); + Model.SelectedAppointmentOid = null; + Model.SelectedResourceOids?.Clear(); + Model.SelectedCustomerOids?.Clear(); + Model.SelectedEmployeeOids?.Clear(); } } @@ -400,7 +488,7 @@ namespace BeWoPlanerMobil.Controllers if(Model != null) { - Model.SelectedAppointment = null; + Model.SelectedAppointmentOid = null; //Model.SelectedResources.Clear(); } @@ -421,7 +509,7 @@ namespace BeWoPlanerMobil.Controllers if(!(Model is null)) { - Model.SelectedAppointment = null; + Model.SelectedAppointmentOid = null; //Model.SelectedResources.Clear(); } @@ -443,9 +531,9 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedDate = schedulerDate; - Model.SelectedAppointment = null; - Model.SelectedResources.Clear(); - + Model.SelectedAppointmentOid = null; + Model.SelectedResourceOids.Clear(); + return RedirectToActionPermanent("Scheduler"); } @@ -471,9 +559,12 @@ namespace BeWoPlanerMobil.Controllers return RedirectToActionPermanent("Scheduler"); } - Model.SelectedAppointment = Model.Appointments.FirstOrDefault(app => app.SchedulerAppointmentOid.HasValue && app.SchedulerAppointmentOid.Value == appointmentOid); + LoadAppointmentsForDate(); - if(Model.SelectedAppointment != null) + Model.SelectedAppointmentOid = appointmentOid; + Model.SelectedAppointment = Model.Appointments.FirstOrDefault(app => app.SchedulerAppointmentOid.HasValue && app.SchedulerAppointmentOid.Value == appointmentOid); + + if (Model.SelectedAppointment != null) { if(Model.SelectedAppointment.AllDay && Model.SelectedAppointment.EndDate.HasValue) { @@ -482,9 +573,9 @@ namespace BeWoPlanerMobil.Controllers Model.IsAllDay = Model.SelectedAppointment.AllDay; Model.IsPrivate = Model.SelectedAppointment.IsPrivate; - Model.SelectedResources = Model.SelectedAppointment?.ResourceList ?? new List(); - Model.SelectedEmployees = Model.SelectedAppointment?.EmployeeList.Select(e2a => e2a.Employee).ToList() ?? new List(); - Model.SelectedCustomers = Model.SelectedAppointment?.CustomerList ?? new List(); + Model.SelectedResourceOids = Model.SelectedAppointment?.ResourceList.Select(r => r.ResourceOid.Value).ToList() ?? new List(); + Model.SelectedEmployeeOids = Model.SelectedAppointment?.EmployeeList.Select(e2a => e2a.Employee.EmployeeOid).ToList() ?? new List(); + Model.SelectedCustomerOids = Model.SelectedAppointment?.CustomerList.Select(c => c.CustomerOid).ToList() ?? new List(); } return RedirectToActionPermanent("Scheduler"); @@ -495,14 +586,16 @@ namespace BeWoPlanerMobil.Controllers { if(Model != null) { - Model.SelectedAppointment = null; - Model.SelectedResources.Clear(); - Model.SelectedEmployees.Clear(); - Model.SelectedCustomers.Clear(); + Model.SelectedAppointmentOid = null; + Model.SelectedResourceOids.Clear(); + Model.SelectedEmployeeOids.Clear(); + Model.SelectedCustomerOids.Clear(); Model.IsAllDay = false; Model.IsPrivate = false; } + UpdateSelectedObjects(); + return Json(null, JsonRequestBehavior.AllowGet); } @@ -516,7 +609,7 @@ namespace BeWoPlanerMobil.Controllers } var isOverlapping = false; - var oid = Model.SelectedAppointment?.SchedulerAppointmentOid; + var oid = Model.SelectedAppointmentOid; var isSuccessfulStartDate = DateTime.TryParseExact(startDateRaw, "dd.MM.yyyy", null, DateTimeStyles.None, out var startDate); var isSuccessfulStartTime = DateTime.TryParseExact(startTimeRaw, "HH:mm", null, DateTimeStyles.None, out var startTime); @@ -532,7 +625,7 @@ namespace BeWoPlanerMobil.Controllers var employeeOidList = Model.SelectedAppointment?.EmployeeList?.Select(employee2Appointment => employee2Appointment.Employee.EmployeeOid).ToList() ?? new List(); var resourceOidList = Model.SelectedResources.Where(resource => resource.ResourceOid.HasValue).Select(resource => resource.ResourceOid.Value).ToList() ?? new List(); - var originator = Model.SelectedAppointment?.Originator ?? MobileSessionFacade.LoggedInCompactEmployee; + var originator = Model.SelectedAppointment?.Originator ?? LoggedInUser.Employee; var recurrenceId = Model.SelectedAppointment?.RecurrenceId ?? string.Empty; var recurrenceIndex = Model.SelectedAppointment?.RecurrenceIndex ?? 0; @@ -560,7 +653,7 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - if(!AbstractModel.HasRightToInsertRessourceAppointments) + if(!Model.HasRightToInsertRessourceAppointments) { return "Fehler! Sie haben nicht das Recht, Termine mit Ressourcen anzulegen!"; } @@ -582,7 +675,7 @@ namespace BeWoPlanerMobil.Controllers dateTimes.EndDate = dateTimes.EndDate.AddDays(1); } - var info = KalenderService.CheckResourceAvailabilityWithEmployeeInformation(dateTimes.StartDate, dateTimes.EndDate, oidList, Model.SelectedAppointment?.SchedulerAppointmentOid, null); + var info = KalenderService.CheckResourceAvailabilityWithEmployeeInformation(dateTimes.StartDate, dateTimes.EndDate, oidList, Model.SelectedAppointmentOid, null); var result = string.Empty; @@ -606,7 +699,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public string HasSelectedAppointment() { - return JsonConvert.SerializeObject(Model?.SelectedAppointment != null); + return JsonConvert.SerializeObject(Model?.SelectedAppointmentOid.HasValue); } [Authorize] @@ -642,13 +735,13 @@ namespace BeWoPlanerMobil.Controllers var intervalEndDateString = formCollection["IntervalEnd"].Substring(0, 10); var intervalEndTimeString = formCollection["IntervalEndTime"]; - if(int.TryParse(durationString, out var intervalDuration) && DateTime.TryParse($"{intervalStartDateString} {intervalStartTimeString}", out var intervalStart) && DateTime.TryParse($"{intervalEndDateString} {intervalEndTimeString}", out var intervalEnd) && Model.Employee.EmployeeOid.HasValue) + if(int.TryParse(durationString, out var intervalDuration) && DateTime.TryParse($"{intervalStartDateString} {intervalStartTimeString}", out var intervalStart) && DateTime.TryParse($"{intervalEndDateString} {intervalEndTimeString}", out var intervalEnd) && Model.LoggedInEmployee.EmployeeOid.HasValue) { - var customerOids = Model.SelectedCustomersForIntervalFinder.Select(customer => customer.CustomerOid).ToList(); - var employeeOids = Model.SelectedEmployeesForIntervalFinder.Select(employee => employee.EmployeeOid).ToList(); - var resourceOids = Model.SelectedResourcesForIntervalFinder.Where(resource => resource.ResourceOid.HasValue).Select(r => r.ResourceOid.Value).ToList(); + var customerOids = Model.SelectedCustomerOidsForIntervalFinder.Clone(); + var employeeOids = Model.SelectedEmployeeOidsForIntervalFinder.Clone(); + var resourceOids = Model.SelectedResourceOidsForIntervalFinder.Clone(); - Model.FreeIntervals = KalenderService.FindAppointmentsInRangeForIntervalFinder(intervalDuration, intervalStart, intervalEnd, resourceOids, customerOids, employeeOids, Model.Employee.EmployeeOid.Value); + Model.FreeIntervals = KalenderService.FindAppointmentsInRangeForIntervalFinder(intervalDuration, intervalStart, intervalEnd, resourceOids, customerOids, employeeOids, Model.LoggedInEmployee.EmployeeOid.Value); Model.IntervalStartDate = intervalStart; Model.IntervalEndDate = intervalEnd; @@ -667,9 +760,9 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - var employeeOids = ConvertOidStringToList(oidString); - - Model.SelectedEmployeesForIntervalFinder = Model.AllEmployees.Where(employee => employeeOids.Contains(employee.EmployeeOid)).ToList(); + + Model.SelectedEmployeeOidsForIntervalFinder = ConvertOidStringToList(oidString); + UpdateSelectedObjects(); return JsonConvert.SerializeObject(Model.SelectedEmployeesForIntervalFinder.OrderBy(o => o.DetailDescription)); } @@ -683,9 +776,8 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - var customerOids = ConvertOidStringToList(oidString); - - Model.SelectedCustomersForIntervalFinder = Model.AllCustomers.Where(customer => customerOids.Contains(customer.CustomerOid)).ToList(); + Model.SelectedCustomerOidsForIntervalFinder = ConvertOidStringToList(oidString); + UpdateSelectedObjects(); return JsonConvert.SerializeObject(Model.SelectedCustomersForIntervalFinder.OrderBy(o => o.LastNameFirstName)); } @@ -699,13 +791,9 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - var resourceOidList = ConvertOidStringToList(resourceOids); - - var list = new List(); - - Model.ResourceCategories2Resources.Values.DoForEach(l => l.DoForEach(s => list.AddIfNotIn(s))); - - Model.SelectedResourcesForIntervalFinder = list.Where(resource => resource.ResourceOid.HasValue && resourceOidList.Contains(resource.ResourceOid.Value)).ToList(); + + Model.SelectedResourceOidsForIntervalFinder = ConvertOidStringToList(resourceOids); + UpdateSelectedObjects(); return JsonConvert.SerializeObject(Model.SelectedResourcesForIntervalFinder); } @@ -726,9 +814,9 @@ namespace BeWoPlanerMobil.Controllers if(!newValue) { - Model.SelectedEmployeesForIntervalFinder.Clear(); - Model.SelectedCustomersForIntervalFinder.Clear(); - Model.SelectedResourcesForIntervalFinder.Clear(); + Model.SelectedEmployeeOidsForIntervalFinder.Clear(); + Model.SelectedCustomerOidsForIntervalFinder.Clear(); + Model.SelectedResourceOidsForIntervalFinder.Clear(); } return RedirectToActionPermanent("Scheduler"); @@ -766,18 +854,18 @@ namespace BeWoPlanerMobil.Controllers ActivationType = ActivationTypeId.Active, IsTask = false, IsPrivate = false, - Originator = MobileSessionFacade.LoggedInCompactEmployee, + Originator = LoggedInUser.Employee, StartDate = startDate, EndDate = endDate }; - Model.SelectedCustomers = Model.SelectedCustomersForIntervalFinder.Clone(); - Model.SelectedEmployees = Model.SelectedEmployeesForIntervalFinder.Clone(); - Model.SelectedResources = Model.SelectedResourcesForIntervalFinder.Clone(); + Model.SelectedCustomerOids = Model.SelectedCustomerOidsForIntervalFinder.Clone(); + Model.SelectedEmployeeOids = Model.SelectedEmployeeOidsForIntervalFinder.Clone(); + Model.SelectedResourceOids = Model.SelectedResourceOidsForIntervalFinder.Clone(); - Model.SelectedCustomersForIntervalFinder.Clear(); - Model.SelectedEmployeesForIntervalFinder.Clear(); - Model.SelectedResourcesForIntervalFinder.Clear(); + Model.SelectedCustomerOidsForIntervalFinder.Clear(); + Model.SelectedEmployeeOidsForIntervalFinder.Clear(); + Model.SelectedResourceOidsForIntervalFinder.Clear(); Model.IntervalStartDate = null; Model.IntervalEndDate = null; @@ -794,6 +882,10 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } + Model.SelectedCustomerOidsForIntervalFinder.Clear(); + Model.SelectedEmployeeOidsForIntervalFinder.Clear(); + Model.SelectedResourceOidsForIntervalFinder.Clear(); + Model.SelectedCustomersForIntervalFinder.Clear(); Model.SelectedEmployeesForIntervalFinder.Clear(); Model.SelectedResourcesForIntervalFinder.Clear(); @@ -831,7 +923,7 @@ namespace BeWoPlanerMobil.Controllers Model.ResourceCategories2Resources.Values.DoForEach(l => l.DoForEach(s => list.AddIfNotIn(s))); Model.SelectedResourcesForFiltering = list.Where(resource => resource.ResourceOid.HasValue && oidList.Contains(resource.ResourceOid.Value)).ToList(); - + Model.SelectedResourceOidsForFiltering = oidList; return JsonConvert.SerializeObject(Model.SelectedResourcesForFiltering); } @@ -844,11 +936,9 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - var oidList = ConvertOidStringToList(oidString); + Model.SelectedEmployeeOidsForFiltering = ConvertOidStringToList(oidString); - Model.SelectedEmployeesForFiltering = Model.AllEmployees.Where(employee => oidList.Contains(employee.EmployeeOid)).ToList(); - - return Model.SelectedEmployeesForFiltering.Count.ToString(); + return Model.SelectedEmployeeOidsForFiltering.Count.ToString(); } [Authorize] @@ -860,17 +950,15 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - var oidList = ConvertOidStringToList(oidString); + Model.SelectedCustomerOidsForFiltering = ConvertOidStringToList(oidString); - Model.SelectedCustomersForFiltering = Model.AllCustomers.Where(customer => oidList.Contains(customer.CustomerOid)).ToList(); - - return Model.SelectedCustomersForFiltering.Count.ToString(); + return Model.SelectedCustomerOidsForFiltering.Count.ToString(); } [Authorize] public ActionResult FetchSelectedEmployeesForPopup() { - if(Model is null) + if (Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; } @@ -881,7 +969,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult FetchEmployeeFilteringModalBody() { - if(Model is null) + if (Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; } @@ -892,7 +980,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public string SelectTeamForFiltering(string teamOidString) { - if(Model?.Employee?.EmployeeOid is null) + if(Model?.LoggedInEmployee?.EmployeeOid is null) { Logout(); return LeerzeichenFuerGetMethoden; @@ -900,14 +988,14 @@ namespace BeWoPlanerMobil.Controllers if(long.TryParse(teamOidString, out var teamOid)) { - var team = EmployeeService.FindTeamByOid(teamOid, Model.Employee.EmployeeOid.Value); + var team = EmployeeService.FindTeamByOid(teamOid, Model.LoggedInEmployee.EmployeeOid.Value); if(!(team is null)) { - Model.SelectedEmployeesForFiltering.AddRangeIfElementsNotIn(team.Member); + Model.SelectedEmployeeOidsForFiltering.AddRangeIfElementsNotIn(team.Member.Select(m => m.EmployeeOid)); } } - + UpdateSelectedObjects(); return LeerzeichenFuerGetMethoden; } @@ -918,7 +1006,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public string SelectTeamForAppointment(string teamOidString) { - if(Model?.Employee?.EmployeeOid is null) + if(Model?.LoggedInEmployee?.EmployeeOid is null) { TempData[TempDataConstants.DoLogoutKey] = true; return LeerzeichenFuerGetMethoden; @@ -931,15 +1019,16 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - var team = EmployeeService.FindTeamByOid(teamOid, Model.Employee.EmployeeOid.Value); + var team = EmployeeService.FindTeamByOid(teamOid, Model.LoggedInEmployee.EmployeeOid.Value); if(team is null) { return LeerzeichenFuerGetMethoden; } - Model.SelectedEmployees.AddRangeIfElementsNotIn(team.Member); - teamMemberOids.AddRangeIfElementsNotIn(team.Member.Select(member => member.EmployeeOid)); + Model.SelectedEmployeeOids.AddRangeIfElementsNotIn(team.Member.Select(m => m.EmployeeOid)); + + UpdateSelectedObjects(); return LeerzeichenFuerGetMethoden; } @@ -954,9 +1043,9 @@ namespace BeWoPlanerMobil.Controllers return PartialView("SchedulerEmployeeSelectionPartial"); } - var oidList = ConvertOidStringToList(oidString); - - Model.SelectedEmployees = Model.AllEmployees.Where(employee => oidList.Contains(employee.EmployeeOid)).ToList(); + + Model.SelectedEmployeeOids = ConvertOidStringToList(oidString); + UpdateSelectedObjects(); return PartialView("SchedulerEmployeeSelectionPartial", Model); } @@ -969,8 +1058,10 @@ namespace BeWoPlanerMobil.Controllers TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("EmployeeSelectionPopupListPartial"); } + + Model.SelectedEmployeeOids = isChecked ? Model.AllEmployees.Select(r => r.EmployeeOid).ToList() : new List(); - Model.SelectedEmployees = isChecked ? Model.AllEmployees : new List(); + UpdateSelectedObjects(); return PartialView("EmployeeSelectionPopupListPartial", Model); } @@ -978,7 +1069,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadUpdatedEmployees() { - if(Model is null) + if (Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("SchedulerEmployeeSelectionPartial"); @@ -990,7 +1081,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadUpdatedEmployeePopupList() { - if(Model is null) + if (Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("EmployeeSelectionPopupListPartial"); @@ -1012,8 +1103,9 @@ namespace BeWoPlanerMobil.Controllers Logout(); return PartialView("CustomerSelectionPopupListPartial"); } - - Model.SelectedCustomers = isChecked ? Model.AllCustomers : new List(); + + Model.SelectedCustomerOids = isChecked ? Model.AllCustomers.Select(r => r.CustomerOid).ToList() : new List(); + UpdateSelectedObjects(); return PartialView("CustomerSelectionPopupListPartial", Model); } @@ -1021,7 +1113,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadUpdatedCustomers() { - if(Model is null) + if (Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("SchedulerCustomerSelectionPartial"); @@ -1033,7 +1125,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadUpdatedCustomerPopupList() { - if(Model is null) + if (Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("CustomerSelectionPopupListPartial"); @@ -1052,9 +1144,10 @@ namespace BeWoPlanerMobil.Controllers return PartialView("SchedulerCustomerSelectionPartial"); } - var oidList = ConvertOidStringToList(oidString); + + Model.SelectedCustomerOids = ConvertOidStringToList(oidString); - Model.SelectedCustomers = Model.AllCustomers.Where(customer => oidList.Contains(customer.CustomerOid)).ToList(); + UpdateSelectedObjects(); return PartialView("SchedulerCustomerSelectionPartial", Model); } @@ -1072,7 +1165,7 @@ namespace BeWoPlanerMobil.Controllers return PartialView("SchedulerResourceSelectionPartial"); } - var oidList = ConvertOidStringToList(oidString); + //var list = new List(); @@ -1080,7 +1173,9 @@ namespace BeWoPlanerMobil.Controllers //Model.SelectedResources = list.Where(resource => resource.ResourceOid.HasValue && oidList.Contains(resource.ResourceOid.Value)).ToList(); - Model.SelectedResources = Model.AllResources.Where(resource => resource.ResourceOid.HasValue && oidList.Contains(resource.ResourceOid.Value)).ToList(); + Model.SelectedResourceOids = ConvertOidStringToList(oidString); + + UpdateSelectedObjects(); return PartialView("SchedulerResourceSelectionPartial", Model); } @@ -1094,7 +1189,9 @@ namespace BeWoPlanerMobil.Controllers return PartialView("ResourceSelectionPopupListPartial"); } - Model.SelectedResources = isChecked ? Model.AllResources : new List(); + Model.SelectedResourceOids = isChecked ? Model.AllResources.Select(r => r.ResourceOid.Value).ToList() : new List(); + + UpdateSelectedObjects(); return PartialView("ResourceSelectionPopupListPartial", Model); } @@ -1102,7 +1199,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadUpdatedResourcePopupList() { - if(Model is null) + if (Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("ResourceSelectionPopupListPartial"); @@ -1114,7 +1211,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult LoadUpdatedResources() { - if(Model is null) + if (Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("SchedulerResourceSelectionPartial"); @@ -1129,7 +1226,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult FetchCustomersForFiltering() { - if(Model is null) + if (Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; } @@ -1140,7 +1237,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult FetchCustomerFilteringModalBody() { - if(Model is null) + if (Model is null) { TempData[TempDataConstants.DoLogoutKey] = true; } @@ -1174,18 +1271,17 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public string DeleteAppointment(string appointmentIdentifier, bool deleteSeries) { - if(Model?.Employee?.EmployeeOid is null) + + if(Model?.LoggedInEmployee?.EmployeeOid is null) { Logout(); return LeerzeichenFuerGetMethoden; } - if(!Guid.TryParse(appointmentIdentifier, out var identifier)) - { - return LeerzeichenFuerGetMethoden; - } - var schedulerAppointment = Model.AppointmentListItems.FirstOrDefault(app => app.Identifier.Equals(identifier))?.SchedulerAppointment; + LoadAppointmentsForDate(); + + var schedulerAppointment = Model.AppointmentListItems.FirstOrDefault(app => app.Identifier.Equals(appointmentIdentifier))?.SchedulerAppointment; if(schedulerAppointment is null) { @@ -1216,14 +1312,14 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - var teamMemberCustomerOids = EmployeeService.LoadTeamsRelatedCustomerOids(Model.Employee.EmployeeOid.Value); + var teamMemberCustomerOids = EmployeeService.LoadTeamsRelatedCustomerOids(Model.LoggedInEmployee.EmployeeOid.Value); var customerList = schedulerAppointment.CustomerList; var employeeList = schedulerAppointment.EmployeeList; var resourceList = schedulerAppointment.ResourceList; var originator = schedulerAppointment.Originator; var isNew = schedulerAppointment.SchedulerAppointmentOid is null; - var loggedOnUser = MobileSessionFacade.LoggedInUserDC; + var loggedOnUser = LoggedInUser; var isAllowedToDelete = BS.Shared.Core.Utils.CheckSchedulerRights(customerList, resourceList, employeeList, originator, isNew, SchedulerRightsCheckType.Edit, loggedOnUser, teamMemberCustomerOids); @@ -1287,7 +1383,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public string SelectTeamForIntervalFinder(string teamOidString) { - if(Model?.Employee?.EmployeeOid is null) + if(Model?.LoggedInEmployee?.EmployeeOid is null) { Logout(); return LeerzeichenFuerGetMethoden; @@ -1295,12 +1391,12 @@ namespace BeWoPlanerMobil.Controllers if(long.TryParse(teamOidString, out var teamOid)) { - var team = EmployeeService.FindTeamByOid(teamOid, Model.Employee.EmployeeOid.Value); + var team = EmployeeService.FindTeamByOid(teamOid, Model.LoggedInEmployee.EmployeeOid.Value); if(!(team is null)) { var memberOids = team.Member.Select(member => member.EmployeeOid).ToList(); - + Model.SelectedEmployeeOidsForIntervalFinder.AddRangeIfElementsNotIn(memberOids); return JsonConvert.SerializeObject(memberOids); } } @@ -1318,11 +1414,12 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } - if(!Guid.TryParse(formCollection[FormCollectionConstants.AppointmentIdInputKey], out var identifier)) + var identifier = formCollection[FormCollectionConstants.AppointmentIdInputKey]; + + if (Model.AppointmentListItems == null) { - return RedirectToActionPermanent("PrepareServiceRecordInsert", "Main"); + LoadAppointmentsForDate(); } - var appointmentListItem = Model.AppointmentListItems.FirstOrDefault(f => f.Identifier.Equals(identifier)); if(appointmentListItem is null) @@ -1332,13 +1429,13 @@ namespace BeWoPlanerMobil.Controllers var appointment = appointmentListItem.SchedulerAppointment; - var employeeOids = appointment.EmployeeList.Select(employee2Appointment => employee2Appointment.Employee.EmployeeOid).ToList(); - if(employeeOids.Count == 0) - { - employeeOids.Add(appointment.Originator.EmployeeOid); - } + //var employeeOids = appointment.EmployeeList.Select(employee2Appointment => employee2Appointment.Employee.EmployeeOid).ToList(); + //if(employeeOids.Count == 0) + //{ + // employeeOids.Add(appointment.Originator.EmployeeOid); + //} - TempData[TempDataConstants.AppointmentListItemKey] = appointmentListItem; + TempData[TempDataConstants.AppointmentOidKey] = appointmentListItem.SchedulerAppointment?.SchedulerAppointmentOid; return RedirectToActionPermanent("PrepareServiceRecordInsert", "Main"); } diff --git a/BeWoPlanerMobil/Models/AbstractModel.cs b/BeWoPlanerMobil/Models/AbstractModel.cs index 70b9ef2ac..6907ee331 100644 --- a/BeWoPlanerMobil/Models/AbstractModel.cs +++ b/BeWoPlanerMobil/Models/AbstractModel.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using BeWoPlanerMobil.Service; using BeWoPlanerMobil.Util; @@ -12,43 +13,52 @@ namespace BeWoPlanerMobil.Models { public class AbstractModel { - public static bool IsDeleteBtnVisible => CheckRight(UserRightType.ServiceRecordView_Delete); + public bool IsDeleteBtnVisible => CheckRight(UserRightType.ServiceRecordView_Delete); - public static bool IsAllowedToSeeScheduler => MobileSessionFacade.LoggedInUser != null && CheckRight(UserRightType.KalenderAnsehen) || CheckRight(UserRightType.ViewAll); + public bool IsAllowedToSeeScheduler => LoggedInUser != null && CheckRight(UserRightType.KalenderAnsehen) || CheckRight(UserRightType.ViewAll); - public static bool IsAllowedToSeeCustomers => CheckRight(UserRightType.ViewAll) || CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers); + public bool IsAllowedToSeeCustomers => CheckRight(UserRightType.ViewAll) || CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers); - public static bool IsEmployeeSelectionVisible => CheckRight(UserRightType.ServiceRecord_AllowCreationForOtherEmployees) || CheckRight(UserRightType.ServiceRecord_AllowCreationForOtherTeamMember); + public bool IsEmployeeSelectionVisible => CheckRight(UserRightType.ServiceRecord_AllowCreationForOtherEmployees) || CheckRight(UserRightType.ServiceRecord_AllowCreationForOtherTeamMember); - public static bool HasRightForGroupBookings => CheckRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking); + public bool HasRightForGroupBookings => CheckRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking); - public static bool HasRightToViewCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAlleAnsehen) || CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers) || CheckRight(UserRightType.Customer_ViewMyTeams); - public static bool HasRightToViewEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAnsehen) || CheckRight(UserRightType.ViewAll); - public static bool HasRightToViewAllResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAnsehen) || CheckRight(UserRightType.ViewAll); + public bool HasRightToViewCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAlleAnsehen) || CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers) || CheckRight(UserRightType.Customer_ViewMyTeams); + public bool HasRightToViewEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAnsehen) || CheckRight(UserRightType.ViewAll); + public bool HasRightToViewAllResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAnsehen) || CheckRight(UserRightType.ViewAll); - public EmployeeDC Employee { get; set; } + public ISessionModel SessionModel { get; internal set; } - public string LoggedInEmplyeeFirstNameLastName => Employee != null ? $"{Employee.FirstName} {Employee.LastName}" : "BeWoPlaner"; + public UserDC LoggedInUser { get; set; } - public static bool HasRightToSeeAllSupportConcepts => CheckRight(UserRightType.SupportConcept_ViewAllSupportConcepts) || CheckRight(UserRightType.ViewAll); + public MokMandator Mandator { get; set; } - public static bool HasRightToSeeTextModules => CheckRight(UserRightType.TextbausteineNurEigeneAnsehen) || CheckRight(UserRightType.TextbausteineAlleAnsehen); - public static bool HasRightToSeeOwnTextModules => CheckRight(UserRightType.TextbausteineNurEigeneAnsehen); - public static bool HasRightToSeeGlobalTextModules => CheckRight(UserRightType.TextbausteineAlleAnsehen); + public EmployeeDC LoggedInEmployee { get; set; } - public static bool HasRightToSeeServiceRecords => CheckRight(UserRightType.ServiceRecordView_View) && CheckRight(UserRightType.ServiceRecordView_Create); + public string LoggedInEmplyeeFirstNameLastName => LoggedInEmployee != null ? $"{LoggedInEmployee.FirstName} {LoggedInEmployee.LastName}" : "BeWoPlaner"; - public static string TimeOfLastAction { get; set; } + public bool HasRightToSeeAllSupportConcepts => CheckRight(UserRightType.SupportConcept_ViewAllSupportConcepts) || CheckRight(UserRightType.ViewAll); - public static bool HasRightToInsertRessourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAnlegen) || CheckRight(UserRightType.CreateAll); + public bool HasRightToSeeTextModules => CheckRight(UserRightType.TextbausteineNurEigeneAnsehen) || CheckRight(UserRightType.TextbausteineAlleAnsehen); + public bool HasRightToSeeOwnTextModules => CheckRight(UserRightType.TextbausteineNurEigeneAnsehen); + public bool HasRightToSeeGlobalTextModules => CheckRight(UserRightType.TextbausteineAlleAnsehen); - public static bool HasRightToViewQuittierungsbelege + public bool HasRightToSeeServiceRecords => CheckRight(UserRightType.ServiceRecordView_View) && CheckRight(UserRightType.ServiceRecordView_Create); + + public static string TimeOfLastAction + { + get { return MobileSessionFacade.TimeOfLastAction; } + set { MobileSessionFacade.TimeOfLastAction = value; } + } + + public bool HasRightToInsertRessourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAnlegen) || CheckRight(UserRightType.CreateAll); + + public bool HasRightToViewQuittierungsbelege { get { - var mandator = MobileSessionFacade.Mandator; - - var showEmployeeSignatureSetting = MobileUtils.GetSettingValue(mandator.Settings, SettingsKeys.ShowSignature); + + var showEmployeeSignatureSetting = MobileUtils.GetSettingValue(Mandator.Settings, SettingsKeys.ShowSignature); #if DEBUG showEmployeeSignatureSetting = "1"; #endif @@ -58,40 +68,45 @@ namespace BeWoPlanerMobil.Models - public static bool IsAllowedToSeeSupportConceptFilter + public bool IsAllowedToSeeSupportConceptFilter { get { - var user = MobileSessionFacade.LoggedInUser; + var user = LoggedInUser; if(user != null) { return user.CheckForAtLeastOneRight(new List { UserRightType.ViewAll, UserRightType.SupportConcept_ViewAllSupportConcepts }) || - user.CheckForRight(UserRightType.SupportConcept_ViewMyTeams); + user.HasRight(UserRightType.SupportConcept_ViewMyTeams); } return false; } } - public static string UserSettings + public string UserSettings { get { - var user = MobileSessionFacade.LoggedInUser; + var user = LoggedInUser; - return user?.SettingList.FirstOrDefault(f => f.Type.Equals(SettingsType.ApplicationSettings))?.Value; + return user?.Settings.FirstOrDefault(f => f.Type.Equals(SettingsType.ApplicationSettings))?.Value; } } - public static bool IsAllowedToSeeCustomerFilter => MobileSessionFacade.LoggedInUser?.CheckForAtLeastOneRight(new List { UserRightType.ViewAll, UserRightType.CustomerView_View, UserRightType.Customer_ViewMyTeams }) ?? false; + public MokSettings MokSettings { get; set; } + + public bool IsAllowedToSeeCustomerFilter => LoggedInUser?.CheckForAtLeastOneRight(new List { UserRightType.ViewAll, UserRightType.CustomerView_View, UserRightType.Customer_ViewMyTeams }) ?? false; - public static bool IsAllowedToSeeMedikamentenliste + public bool IsAllowedToSeeMedikamentenliste { get { - var mandator = MobileSessionFacade.Mandator; +#if DEBUG + return true; +#endif + var mandator = Mandator; var hasSetting = MobileUtils.GetSettingValue(mandator.Settings, SettingsKeys.ShowMedication) == "1"; @@ -101,55 +116,55 @@ namespace BeWoPlanerMobil.Models } } - public static bool CheckRight(UserRightType userRightType) + public bool CheckRight(UserRightType userRightType) { - return MobileSessionFacade.CheckForUserRight(userRightType); + return LoggedInUser.HasRight(userRightType); } - public static bool CheckRights(List userRightTypes) + public bool CheckRights(List userRightTypes) { - return userRightTypes.All(MobileSessionFacade.CheckForUserRight); + return userRightTypes.All(LoggedInUser.HasRight); } - public static bool CheckForAtLeastOneRight(UserRightType[] rights) + public bool CheckForAtLeastOneRight(UserRightType[] rights) { - return rights.Any(MobileSessionFacade.CheckForUserRight); + return rights.Any(LoggedInUser.HasRight); } - public static bool HasRightToInsertEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAnlegen) || + public bool HasRightToInsertEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAnlegen) || CheckRight(UserRightType.CreateAll); - public static bool HasRightToEditEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAendern) || CheckRight(UserRightType.EditAll); + public bool HasRightToEditEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAendern) || CheckRight(UserRightType.EditAll); - public static bool HasRightToEditResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAendern) || CheckRight(UserRightType.EditAll); - public static bool HasRightToEditOthersResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAndererAendern) || CheckRight(UserRightType.EditAll); + public bool HasRightToEditResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAendern) || CheckRight(UserRightType.EditAll); + public bool HasRightToEditOthersResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAndererAendern) || CheckRight(UserRightType.EditAll); - public static bool HasRightToInsertCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAnlegen) && + public bool HasRightToInsertCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAnlegen) && (CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers) || CheckRight(UserRightType.Customer_ViewMyTeams)) || CheckRight(UserRightType.CreateAll); - public static bool HasRightToEditCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAendern) || CheckRight(UserRightType.EditAll); + public bool HasRightToEditCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAendern) || CheckRight(UserRightType.EditAll); - public static bool ShowServiceRecordInsertedOn { get; set; } + public bool ShowServiceRecordInsertedOn { get; set; } - public static bool HasRightToViewCustomerSelectionInScheduler => CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers) || CheckRight(UserRightType.Customer_ViewMyTeams); + public bool HasRightToViewCustomerSelectionInScheduler => CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers) || CheckRight(UserRightType.Customer_ViewMyTeams); - public static bool HasRightToViewTeams => CheckRight(UserRightType.TeamView_ViewMyTeams) || CheckRight(UserRightType.TeamView_ViewAll); + public bool HasRightToViewTeams => CheckRight(UserRightType.TeamView_ViewMyTeams) || CheckRight(UserRightType.TeamView_ViewAll); - public static bool HasRightForMultiBooking => CheckRight(UserRightType.ServiceRecord_AllowCreatingMultiBooking); + public bool HasRightForMultiBooking => CheckRight(UserRightType.ServiceRecord_AllowCreatingMultiBooking); - public static bool HasRightToDeleteReceiptSignatures => CheckRight(UserRightType.ConfirmationReceiptSignatures_Delete); + public bool HasRightToDeleteReceiptSignatures => CheckRight(UserRightType.ConfirmationReceiptSignatures_Delete); - public static bool HasRightToRateGoals => CheckRight(UserRightType.BewertenInZeiterfassung); + public bool HasRightToRateGoals => CheckRight(UserRightType.BewertenInZeiterfassung); - public static bool HasRightToEditCustomers => CheckRight(UserRightType.CustomerView_Edit); + public bool HasRightToEditCustomers => CheckRight(UserRightType.CustomerView_Edit); - public static bool HasRightMitarbeiterstundenkontoViewAll => CheckRight(UserRightType.Mitarbeiterstundenkonto_ViewAll); - public static bool HasRightMitarbeiterstundenkontoViewTeams => CheckRight(UserRightType.Mitarbeiterstundenkonto_ViewTeams); - public static bool HasRightMitarbeiterstundenkontoViewSelf => CheckRight(UserRightType.Mitarbeiterstundenkonto_ViewSelf); + public bool HasRightMitarbeiterstundenkontoViewAll => CheckRight(UserRightType.Mitarbeiterstundenkonto_ViewAll); + public bool HasRightMitarbeiterstundenkontoViewTeams => CheckRight(UserRightType.Mitarbeiterstundenkonto_ViewTeams); + public bool HasRightMitarbeiterstundenkontoViewSelf => CheckRight(UserRightType.Mitarbeiterstundenkonto_ViewSelf); - public static bool HasRightToViewReports => CheckForAtLeastOneRight(new UserRightType[] + public bool HasRightToViewReports => CheckForAtLeastOneRight(new UserRightType[] { UserRightType.ViewAll, UserRightType.QueryView_View, @@ -172,7 +187,7 @@ namespace BeWoPlanerMobil.Models UserRightType.Auswertungen_HilfeplanuebersichtAnsehen }); - public static bool HasRightToViewMitarbeiterstundenkonto + public bool HasRightToViewMitarbeiterstundenkonto { get { @@ -180,34 +195,34 @@ namespace BeWoPlanerMobil.Models } } - public static bool HasRightToViewDiagnosen => CheckRight(UserRightType.Customer_ViewDiagnosis); + public bool HasRightToViewDiagnosen => CheckRight(UserRightType.Customer_ViewDiagnosis); - public static bool HasRightToProvideSingleSignature => CheckRight(UserRightType.Signature_ProvideSingleSignature); + public bool HasRightToProvideSingleSignature => CheckRight(UserRightType.Signature_ProvideSingleSignature); - public static bool HasRightToViewOwnCustomersBargeldkassen => CheckRight(UserRightType.BargeldverwaltungNurEigeneAnsehen); + public bool HasRightToViewOwnCustomersBargeldkassen => CheckRight(UserRightType.BargeldverwaltungNurEigeneAnsehen); - public static bool HasRightToViewAllCustomersBargeldkassen => CheckRight(UserRightType.BargeldverwaltungAnsehen); + public bool HasRightToViewAllCustomersBargeldkassen => CheckRight(UserRightType.BargeldverwaltungAnsehen); - public static bool HasRightToDeleteCustomerBargeldkassen => CheckRight(UserRightType.BargeldverwaltungLoeschen); + public bool HasRightToDeleteCustomerBargeldkassen => CheckRight(UserRightType.BargeldverwaltungLoeschen); - public static bool HasRightToCreateCustomerBargeldkassen => CheckRight(UserRightType.BargeldverwaltungAnlegen); + public bool HasRightToCreateCustomerBargeldkassen => CheckRight(UserRightType.BargeldverwaltungAnlegen); - public static bool HasRightToEditCustomerBargeldkassen => CheckRight(UserRightType.BargeldverwaltungBearbeiten); + public bool HasRightToEditCustomerBargeldkassen => CheckRight(UserRightType.BargeldverwaltungBearbeiten); - public static bool HasRightToViewCustomerAbsenceTimes => CheckRight(UserRightType.Customer_ViewAbsenceTimes); + public bool HasRightToViewCustomerAbsenceTimes => CheckRight(UserRightType.Customer_ViewAbsenceTimes); - public static bool HasRightToProvideEmployeeSignatureForOthers => CheckRight(UserRightType.Signature_ProvideMonthlySignatureByProxy); + public bool HasRightToProvideEmployeeSignatureForOthers => CheckRight(UserRightType.Signature_ProvideMonthlySignatureByProxy); - public static bool HasRightToViewBetreuung => CheckRight(UserRightType.Customer_ViewBetreuung); + public bool HasRightToViewBetreuung => CheckRight(UserRightType.Customer_ViewBetreuung); - public static bool HasRightToViewCustomerDocuments => CheckForAtLeastOneRight(new[] { UserRightType.ViewAll, UserRightType.DokumenteKlienten }); + public bool HasRightToViewCustomerDocuments => CheckForAtLeastOneRight(new[] { UserRightType.ViewAll, UserRightType.DokumenteKlienten }); - public static string UserMessage { get; set; } + //public string UserMessage { get; set; } public XtraReport Report { get; set; } public string ReportName { get; set; } - protected static string GetIsNotApproved(SupportConceptCostBearerRelDC rel) + protected string GetIsNotApproved(SupportConceptCostBearerRelDC rel) { var result = string.Empty; @@ -239,20 +254,20 @@ namespace BeWoPlanerMobil.Models public Dictionary Collapsibles2IsShown { get; set; } = new Dictionary(); - public static bool ShowDifferentQBInterval + public bool ShowDifferentQBInterval { get { - var settingsValue = MobileUtils.GetSettingValue(MobileSessionFacade.Mandator.Settings, SettingsKeys.ShowServicesOverviewHalfOrWholeMonth); + var settingsValue = MobileUtils.GetSettingValue(Mandator.Settings, SettingsKeys.ShowServicesOverviewHalfOrWholeMonth); return "1" == settingsValue; } } - public static bool ShowDistanceField { get; set; } + public bool ShowDistanceField { get; set; } - public static bool ShowBetrag { get; set; } + public bool ShowBetrag { get; set; } - public static string LocalStorageKey => MobileSessionFacade.LoggedInUser is object ? $"bwp_{MobileSessionFacade.Tenant}_{MobileSessionFacade.LoggedInUser.Oid}" : null; + } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Models/CustomerModel.cs b/BeWoPlanerMobil/Models/CustomerModel.cs index 56e636a05..fb03a2b60 100644 --- a/BeWoPlanerMobil/Models/CustomerModel.cs +++ b/BeWoPlanerMobil/Models/CustomerModel.cs @@ -15,13 +15,25 @@ namespace BeWoPlanerMobil.Models { public class CustomerModel : AbstractModel { + + public CustomerModel() + { + SessionModel = new CustomerSessionModel(); + } + + public CustomerSessionModel CustomerSessionModel + { + get + { + return SessionModel as CustomerSessionModel; + } + } + [Display(Name = "Klient")] - public long? SelectedCustomerOid { get; set; } + public long? SelectedCustomerOid { get { return CustomerSessionModel.SelectedCustomerOid; } set { CustomerSessionModel.SelectedCustomerOid = value; } } public CustomerDC SelectedCustomer { get; set; } - public List Customers { get; set; } - public IEnumerable CustomerListItems { get @@ -38,7 +50,7 @@ namespace BeWoPlanerMobil.Models public JsonCustomer SelectedJsonCustomer => SelectedCustomer != null ? new JsonCustomer(SelectedCustomer, FolderTree, ICD10Diagnosen) : null; [Display(Name = "Filter")] - public CustomerFilterEnum SelectedCustomerFilter { get; set; } + public CustomerFilterEnum SelectedCustomerFilter { get { return CustomerSessionModel.SelectedCustomerFilter; } set { CustomerSessionModel.SelectedCustomerFilter = value; } } public List CustomerFilter { @@ -46,7 +58,7 @@ namespace BeWoPlanerMobil.Models { var result = new List(); - var user = MobileSessionFacade.LoggedInUser; + var user = LoggedInUser; const string allCustomers = "Alle Klienten anzeigen"; const string myCustomersOnly = "Nur meine Klienten anzeigen"; @@ -63,12 +75,12 @@ namespace BeWoPlanerMobil.Models result.Add(new SelectListItem { Text = allCustomers, Value = allCustomersValue }); result.Add(new SelectListItem { Text = myCustomersOnly, Value = myCustomersValue }); - if(user.CheckForRight(UserRightType.Customer_ViewMyTeams)) + if(user.HasRight(UserRightType.Customer_ViewMyTeams)) { result.Add(new SelectListItem {Text = myTeamsCustomersOnly, Value = myTeamsCustomersValue }); } } - else if(user.CheckForRight(UserRightType.Customer_ViewMyTeams)) + else if(user.HasRight(UserRightType.Customer_ViewMyTeams)) { result.Add(new SelectListItem { Text = myCustomersOnly, Value = myCustomersValue }); result.Add(new SelectListItem { Text = myTeamsCustomersOnly, Value = myTeamsCustomersValue }); @@ -84,7 +96,7 @@ namespace BeWoPlanerMobil.Models public List ReportTypes { get; set; } [Display(Name = "Bericht")] - public CustomerReportType SelectedReportType { get; set; } + public CustomerReportType SelectedReportType { get { return CustomerSessionModel.SelectedReportType; } set { CustomerSessionModel.SelectedReportType = value; } } public List ReportTypeItems { @@ -108,7 +120,7 @@ namespace BeWoPlanerMobil.Models public List Bargeldkassen { get; set; } = new List(); [Display(Name = "Kategorie")] - public long? SelectedAbsenceReason { get; set; } + public long? SelectedAbsenceReasonOid { get { return CustomerSessionModel.SelectedAbsenceReasonOid; } set { CustomerSessionModel.SelectedAbsenceReasonOid = value; } } public List AllAbsenceReasons { get; set; } @@ -136,12 +148,24 @@ namespace BeWoPlanerMobil.Models } } + public long? SelectedAbsenceTimeOid { get { return CustomerSessionModel.SelectedAbsenceTimeOid; } set { CustomerSessionModel.SelectedAbsenceTimeOid = value; } } + public AbsenceTimeDC SelectedAbsenceTime { get; set; } + //{ + // get { return selectedAbsenceTime; } + // set + // { + // selectedAbsenceTime = value; + // SelectedAbsenceTimeOid = selectedAbsenceTime != null ? selectedAbsenceTime.AbsenceTimeOid : null; + // } + //} + + public long? SelectedBargeldkasseOid { get { return CustomerSessionModel.SelectedBargeldkasseOid; } set { CustomerSessionModel.SelectedBargeldkasseOid = value; } } public BargeldkassenDC SelectedBargeldkasse { get; set; } [Display(Name="Auszahlunsintervall")] - public int SelectedAuszahlungsintervall { get; set; } + public int SelectedAuszahlungsintervall { get { return CustomerSessionModel.SelectedAuszahlungsintervall; } set { CustomerSessionModel.SelectedAuszahlungsintervall = value; } } public List Auszahlungsintervalle => new List { @@ -155,11 +179,13 @@ namespace BeWoPlanerMobil.Models public string BargeldkassenReportName { get; set; } public XtraReport ZahlungsbelegsReportObject { get; set; } - + + public long? SelectedBargeldtransaktionOid { get { return CustomerSessionModel.SelectedBargeldtransaktionOid; } set { CustomerSessionModel.SelectedBargeldtransaktionOid = value; } } + public BargeldtransaktionDC SelectedBargeldtransaktion { get; set; } [Display(Name = "Art")] - public int SelectedTransaktionsart { get; set; } + public int SelectedTransaktionsart { get { return CustomerSessionModel.SelectedTransaktionsart; } set { CustomerSessionModel.SelectedTransaktionsart = value; } } public List Transaktionsarten => new List { diff --git a/BeWoPlanerMobil/Models/CustomerSessionModel.cs b/BeWoPlanerMobil/Models/CustomerSessionModel.cs new file mode 100644 index 000000000..ae8e2e361 --- /dev/null +++ b/BeWoPlanerMobil/Models/CustomerSessionModel.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Web.Mvc; +using BeWo.View.Navigation.Filter; +using BeWoPlanerMobil.Controllers; +using BeWoPlanerMobil.Service; +using BeWoPlanerMobil.Util; +using BS.Shared; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using DevExpress.XtraReports.UI; + +namespace BeWoPlanerMobil.Models +{ + [Serializable] + public class CustomerSessionModel : ISessionModel + { + public long? SelectedCustomerOid { get; set; } + + public CustomerFilterEnum SelectedCustomerFilter { get; set; } + + public CustomerReportType SelectedReportType { get; set; } + + public long? SelectedAbsenceReasonOid { get; set; } + + public long? SelectedAbsenceTimeOid { get; set; } + + public long? SelectedBargeldkasseOid { get; set; } + + public int SelectedAuszahlungsintervall { get; set; } + + public long? SelectedBargeldtransaktionOid { get; set; } + + public int SelectedTransaktionsart { get; set; } + + public void ResetValues() + { + SelectedCustomerOid = null; + //SelectedCustomerFilter = CustomerFilterEnum.All; + //SelectedReportType = CustomerReportType.Medikamentenliste; + SelectedAbsenceReasonOid = null; + SelectedAbsenceTimeOid = null; + SelectedBargeldkasseOid = null; + //SelectedAuszahlungsintervall = 0; + SelectedBargeldtransaktionOid = null; + //SelectedTransaktionsart = 0; + } + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Models/ISessionModel.cs b/BeWoPlanerMobil/Models/ISessionModel.cs new file mode 100644 index 000000000..ec84e0c65 --- /dev/null +++ b/BeWoPlanerMobil/Models/ISessionModel.cs @@ -0,0 +1,9 @@ +using BeWoPlanerMobil.Service; + +namespace BeWoPlanerMobil.Models +{ + public interface ISessionModel + { + void ResetValues(); + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Models/MainModel.cs b/BeWoPlanerMobil/Models/MainModel.cs index bb41e75d4..ee0fbb059 100644 --- a/BeWoPlanerMobil/Models/MainModel.cs +++ b/BeWoPlanerMobil/Models/MainModel.cs @@ -19,17 +19,33 @@ namespace BeWoPlanerMobil.Models { protected static readonly log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public MainModel() + { + SessionModel = new MainSessionModel(); + SessionModel.ResetValues(); + NewServiceRecord = new ServiceRecordDC(); + ShowOnlyOwnSupportConcepts = true; + ErrorWert = 1; + } + + public MainSessionModel MainSessionModel + { + get + { + return SessionModel as MainSessionModel; + } + } - public long? SelectedCostBearerSupportConceptRelOid { get; set; } + public bool SessionInitialized { get { return MainSessionModel.SessionInitialized; } set { MainSessionModel.SessionInitialized = value; } } [Display(Name = "Nur meine Klienten anzeigen")] - public bool ShowOnlyOwnSupportConcepts { get; set; } + public bool ShowOnlyOwnSupportConcepts { get { return MainSessionModel.ShowOnlyOwnSupportConcepts; } set { MainSessionModel.ShowOnlyOwnSupportConcepts = value; } } [Display(Name = "Nur Klienten meiner Teams anzeigen")] - public bool ShowOnlyMyTeamsSupportConcepts { get; set; } - - public CustomerFilterEnum SelectedSupportConceptFilter { get; set; } + public bool ShowOnlyMyTeamsSupportConcepts { get { return MainSessionModel.ShowOnlyMyTeamsSupportConcepts; } set { MainSessionModel.ShowOnlyMyTeamsSupportConcepts = value; } } + + public CustomerFilterEnum SelectedSupportConceptFilter { get { return MainSessionModel.SelectedSupportConceptFilter; } set { MainSessionModel.SelectedSupportConceptFilter = value; } } public List SupportConceptFilter { @@ -55,7 +71,7 @@ namespace BeWoPlanerMobil.Models var result = new List(); - var user = MobileSessionFacade.LoggedInUser; + var user = LoggedInUser; var alle = new CustomerFilterItem(CustomerFilterEnum.All); var nurMeine = new CustomerFilterItem(CustomerFilterEnum.MyCustomer); @@ -73,7 +89,7 @@ namespace BeWoPlanerMobil.Models { if(user.CheckForAtLeastOneRight(new List { UserRightType.ViewAll, UserRightType.SupportConcept_ViewAllSupportConcepts })) { - if(user.CheckForRight(UserRightType.SupportConcept_ViewMyTeams)) + if(user.HasRight(UserRightType.SupportConcept_ViewMyTeams)) { result.Add(new SelectListItem { Text = allSupportConcepts, Value = allSupportConceptsValue }); result.Add(new SelectListItem { Text = myTeamsSupportConceptsOnly, Value = myTeamsSupportConceptsOnlyValue }); @@ -85,7 +101,7 @@ namespace BeWoPlanerMobil.Models result.Add(new SelectListItem { Text = mySupportConceptsOnly, Value = mySupportConceptsValue }); } } - else if(user.CheckForRight(UserRightType.SupportConcept_ViewMyTeams)) + else if(user.HasRight(UserRightType.SupportConcept_ViewMyTeams)) { result.Add(new SelectListItem { Text = myTeamsSupportConceptsOnly, Value = myTeamsSupportConceptsOnlyValue }); result.Add(new SelectListItem { Text = mySupportConceptsOnly, Value = mySupportConceptsValue }); @@ -97,37 +113,25 @@ namespace BeWoPlanerMobil.Models } [Display(Name = "Abgelaufene Hilfepläne anzeigen")] - public bool ShowExpiredSupportConcepts { get; set; } - - private long? _CostBearer2SupportConceptOid; - + public bool ShowExpiredSupportConcepts { get { return MainSessionModel.ShowExpiredSupportConcepts; } set { MainSessionModel.ShowExpiredSupportConcepts = value; } } + [Display(Name = "Hilfeplan")] - public long? CostBearer2SupportConceptOid - { - get => _CostBearer2SupportConceptOid; + public long? SelectedCostBearerSupportConceptOid { get { return MainSessionModel.SelectedCostBearerSupportConceptOid; } set { MainSessionModel.SelectedCostBearerSupportConceptOid = value; } } + + public long? SelectedServiceCategoryOid { get { return MainSessionModel.SelectedServiceCategoryOid; } set { MainSessionModel.SelectedServiceCategoryOid = value; } } - set - { - Log.Info($"CostBearer2SupportConceptOid ausgewählt: {value}. Vorher: {_CostBearer2SupportConceptOid}; Benutzer: {MobileSessionFacade.LoggedInUser.LoginName} UserOid: {MobileSessionFacade.LoggedInUser.Oid}"); - _CostBearer2SupportConceptOid = value; - } - } - - public long? SelectedServiceCategoryOid => SelectedServiceCategory?.ServiceCategoryOid; - - public long? SelectedServiceDescriptionOid => SelectedServiceDescription?.ServiceDescriptionOid; - - public long? SelectedServiceRecordOid { get; set; } + public long? SelectedServiceDescriptionOid { get { return MainSessionModel.SelectedServiceDescriptionOid; } set { MainSessionModel.SelectedServiceDescriptionOid = value; } } + public bool IsAllowedToDeleteServiceRecord(ServiceRecordDC serviceRecord) { var allowed = false; - if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecordView_Delete)) + if(LoggedInUser.HasRight(UserRightType.ServiceRecordView_Delete)) { allowed = true; } - else if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowChangeWithin24Hours)) + else if(LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowChangeWithin24Hours)) { if(serviceRecord.InsertedOn.HasValue) { @@ -140,7 +144,7 @@ namespace BeWoPlanerMobil.Models if(allowed && ApplicationSettings.MaxDaysEditServiceRecordsAllowed > 0) { - if(!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth)) + if(!LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth)) { if(serviceRecord.Start.HasValue) { @@ -158,7 +162,7 @@ namespace BeWoPlanerMobil.Models if (allowed && ApplicationSettings.AnzTageZeiterfassErfolgt > 0) { - if (!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecordAllowEditAfterMindays)) + if (!LoggedInUser.HasRight(UserRightType.ServiceRecordAllowEditAfterMindays)) { if (serviceRecord.Start != null) { @@ -172,9 +176,9 @@ namespace BeWoPlanerMobil.Models } } - if(allowed && !MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowEditForOtherEmployees)) + if(allowed && !LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowEditForOtherEmployees)) { - if(MobileSessionFacade.LoggedInEmployee.EmployeeOid != serviceRecord.Employee.EmployeeOid) + if(LoggedInUser.Employee.EmployeeOid != serviceRecord.Employee.EmployeeOid) { allowed = false; } @@ -182,7 +186,7 @@ namespace BeWoPlanerMobil.Models if(allowed && serviceRecord.GroupOid.HasValue) { - if(!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking)) + if(!LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking)) { allowed = false; } @@ -191,33 +195,23 @@ namespace BeWoPlanerMobil.Models return allowed; } + public long? SelectedServiceRecordOid { get { return MainSessionModel.SelectedServiceRecordOid; } set { MainSessionModel.SelectedServiceRecordOid = value; } } + public ServiceRecordDC SelectedServiceRecord { get; set; } - private SupportConceptDC _SelectedSupportConcept; - - public SupportConceptDC SelectedSupportConcept - { - get => _SelectedSupportConcept; - - set - { - var stackTrace = new StackTrace(); - var callingMethodsName = stackTrace.GetFrame(1).GetMethod().Name; - Log.Info($"SC mit Oid {value?.SupportConceptOid} ausgewählt. Vorheriger SC: {_SelectedSupportConcept?.SupportConceptOid}. Aufrufende Methode: {callingMethodsName}"); - - _SelectedSupportConcept = value; - } - } + public long? SelectedSupportConceptOid { get { return MainSessionModel.SelectedSupportConceptOid; } set { MainSessionModel.SelectedSupportConceptOid = value; } } + public SupportConceptDC SelectedSupportConcept { get; set; } + public int Zeitraum { get; set; } public int ErrorWert { get; set; } public bool ShowSignature { get; set; } - public long ServiceRecordOid { get; set; } + public long LastCreatedServiceRecordOid { get { return MainSessionModel.LastCreatedServiceRecordOid; } set { MainSessionModel.LastCreatedServiceRecordOid = value; } } - public List SupportConcepts { get; set; } + public List SupportConcepts { get; set; } public List Textbausteine { get; set; } = new List(); @@ -239,6 +233,8 @@ namespace BeWoPlanerMobil.Models set => _ServiceRecords = value; } + public List SelectedGoalOids { get { return MainSessionModel.SelectedGoalOids; } set { MainSessionModel.SelectedGoalOids = value; } } + private List _SelectedGoals; public List SelectedGoals @@ -259,25 +255,21 @@ namespace BeWoPlanerMobil.Models public long? ServiceRecordOidToDelete { get; set; } - public MainModel() - { - NewServiceRecord = new ServiceRecordDC(); - ShowOnlyOwnSupportConcepts = true; - ErrorWert = 1; - } + public IEnumerable SupportConceptListObjects { get { - var allCostBearerRelations = new List {new CostBearer2SupportConceptRelListObject("Hilfeplan auswählen", "", "-1", false, false), new CostBearer2SupportConceptRelListObject("Ohne Hilfeplan", "", "-2", false, false) }; - foreach(var sc in SupportConcepts.OrderBy(sc => sc.Customer.LastName)) + var allCostBearerRelations = new List {new CostBearer2SupportConceptRelListObject("Hilfeplan auswählen", "", -1, false, false), new CostBearer2SupportConceptRelListObject("Ohne Hilfeplan", "", -2, false, false) }; + BS.Shared.Settings.ApplicationSettings.SupportConceptExpirationLimitInMonths = MokSettings.SupportConceptExpirationLimitInMonths; + foreach (var sc in SupportConcepts.OrderBy(sc => sc.Customer.LastName)) { allCostBearerRelations.AddRange(sc.CostBearerRelations.Where(w => ShowExpiredSupportConcepts || w.EndDate is null || w.EndDate.Value >= DateTime.Now.Date).Select( cb => new CostBearer2SupportConceptRelListObject( $"{sc.Customer.SimpleDescription} {(sc.Customer.DateOfBirth.HasValue ? "*" + sc.Customer.DateOfBirth.Value.ToString("dd.MM.yyyy") : string.Empty)}", $"{cb.AuswahlBezeichnung} {cb.StartDate?.ToShortDateString().Remove(6, 2) ?? string.Empty}-{cb.EndDate?.ToShortDateString().Remove(6, 2) ?? string.Empty} {cb.CostBearer.Name}{GetIsNotApproved(cb)}", - cb.CostBearer2SupportConceptOid.ToString(), + cb.CostBearer2SupportConceptOid.Value, cb.SupportConcept.IsAboutToExpire, cb.SupportConcept.ExpiresIn3MonthOrLess)) ); @@ -288,6 +280,8 @@ namespace BeWoPlanerMobil.Models public CostBearer2SupportConceptRelListObject SelectedCostBearer2SupportConceptRelListObject { get; set; } + public List SelectedConceptCostBearerRelationOids { get { return MainSessionModel.SelectedConceptCostBearerRelations; } set { MainSessionModel.SelectedConceptCostBearerRelations = value; } } + public List SelectedConceptCostBearerRelations { get; set; } public GroupBookingSelectionObject GroupBookingSelectionObject => new GroupBookingSelectionObject(SelectedConceptCostBearerRelations, GroupBookingSelectedGroupOfPeopleOids); @@ -304,7 +298,7 @@ namespace BeWoPlanerMobil.Models cb => new CostBearer2SupportConceptRelListObject( $"{sc.Customer.SimpleDescription} {(sc.Customer.DateOfBirth.HasValue ? "*" + sc.Customer.DateOfBirth.Value.ToString("dd.MM.yyyy") : string.Empty)}", $"{cb.AuswahlBezeichnung} {cb.StartDate?.ToShortDateString().Remove(6, 2) ?? string.Empty}-{cb.EndDate?.ToShortDateString().Remove(6, 2) ?? string.Empty} {cb.CostBearer.Name}", - cb.CostBearer2SupportConceptOid.ToString(), + cb.CostBearer2SupportConceptOid.Value, cb.SupportConcept.IsAboutToExpire, cb.SupportConcept.ExpiresIn3MonthOrLess)) ); @@ -322,16 +316,14 @@ namespace BeWoPlanerMobil.Models } } - public List Employees { get; set; } - public List EmployeesForGroupAndMultiBooking { get; set; } public List AllEmployees { get; set; } [Display(Name = "Mitarbeiter")] - public long? SelectedEmployeeOid => SelectedEmployee?.EmployeeOid; + public long? SelectedEmployeeOid { get { return MainSessionModel.SelectedEmployeeOid; } set { MainSessionModel.SelectedEmployeeOid = value; } } - public CompactEmployeeDC SelectedEmployee { get; set; } + public CompactEmployeeDC SelectedEmployee { get; set; } public List GroupsOfPeople { get; set; } = new List(); @@ -342,7 +334,7 @@ namespace BeWoPlanerMobil.Models get { var result = new List(); - result.AddRange(Employees.Select(item => new SelectListItem {Value = item.EmployeeOid.ToString(), Text = $"{item.LastName}, {item.FirstName}", Selected = item.Equals(MobileSessionFacade.LoggedInCompactEmployee)}).OrderBy(s => s.Text).ToList()); + result.AddRange(Employees.Select(item => new SelectListItem {Value = item.EmployeeOid.ToString(), Text = $"{item.LastName}, {item.FirstName}", Selected = item.Equals(LoggedInUser.Employee)}).OrderBy(s => s.Text).ToList()); return result; } @@ -369,36 +361,37 @@ namespace BeWoPlanerMobil.Models return maxDate; } - public List GroupBookingSelectedSupportConcepts { get; set; } = new List(); + public List GroupBookingSelectedSupportConceptOids { get { return MainSessionModel.GroupBookingSelectedSupportConceptOids; } set { MainSessionModel.GroupBookingSelectedSupportConceptOids = value; } } + public List GroupBookingSelectedSupportConcepts { get; set; } = new List(); - public List GroupBookingSelectedCostbearerRelOids { get; set; } = new List(); + public List GroupBookingSelectedCostbearerRelOids { get { return MainSessionModel.GroupBookingSelectedCostbearerRelOids; } set { MainSessionModel.GroupBookingSelectedCostbearerRelOids = value; } } - public List GroupBookingSelectedEmployees { get; set; } = new List(); + public List GroupBookingSelectedEmployeeOids { get { return MainSessionModel.GroupBookingSelectedEmployeeOids; } set { MainSessionModel.GroupBookingSelectedEmployeeOids = value; } } + public List GroupBookingSelectedEmployees { get; set; } = new List(); [Display(Name = "Gruppenbuchung")] public bool IsInGroupBookingMode { - get => _IsInGroupBookingMode; + get => MainSessionModel.IsInGroupBookingMode; set { - _IsInGroupBookingMode = value; + MainSessionModel.IsInGroupBookingMode = value; - if(!_IsInGroupBookingMode) + if(!MainSessionModel.IsInGroupBookingMode) { GroupBookingSelectedSupportConcepts?.Clear(); GroupBookingSelectedEmployees?.Clear(); - } + GroupBookingSelectedSupportConceptOids?.Clear(); + GroupBookingSelectedEmployeeOids?.Clear(); + } } } - private bool _IsInGroupBookingMode; - + public bool IsInEditingMode { get { return MainSessionModel.IsInEditingMode; } set { MainSessionModel.IsInEditingMode = value; } } - public bool IsInEditingMode { get; set; } - - public List GetServiceDesctiptions() + public List GetServiceDesctiptions() { var result = new List(); @@ -412,23 +405,27 @@ namespace BeWoPlanerMobil.Models public bool IsServiceRecordNoticeMandatory { get; set; } = true; - public CompactEmployeeDC PreviouslySelectedEmployee { get; set; } - public SupportConceptDC PreviouslySelectedSupportConcept { get; set; } - private long? _PreviouslySelectedCostbearer2SupportConceptOid; + public long? PreviouslySelectedEmployeeOid { get { return MainSessionModel.PreviouslySelectedEmployeeOid; } set { MainSessionModel.PreviouslySelectedEmployeeOid = value; } } + public CompactEmployeeDC PreviouslySelectedEmployee { get; set; } + + public long? PreviouslySelectedSupportConceptOid { get { return MainSessionModel.PreviouslySelectedSupportConceptOid; } set { MainSessionModel.PreviouslySelectedSupportConceptOid = value; } } + public SupportConceptDC PreviouslySelectedSupportConcept { get; set; } + + public long? PreviouslySelectedCostbearer2SupportConceptOid { - get => _PreviouslySelectedCostbearer2SupportConceptOid; + get => MainSessionModel.PreviouslySelectedCostbearer2SupportConceptOid; set { var stackTrace = new StackTrace(); var callingMethodsName = stackTrace.GetFrame(1).GetMethod().Name; - var alt = _PreviouslySelectedCostbearer2SupportConceptOid; + var alt = MainSessionModel.PreviouslySelectedCostbearer2SupportConceptOid; Log.Info($"PreviouslySelectedCostbearer2SupportConceptOid-Set von {alt} zu {value} von Methode: {callingMethodsName}"); - _PreviouslySelectedCostbearer2SupportConceptOid = value; + MainSessionModel.PreviouslySelectedCostbearer2SupportConceptOid = value; } } public bool IsEndDateVisible { get; set; } @@ -479,11 +476,11 @@ namespace BeWoPlanerMobil.Models { var allowed = false; - if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecordView_Edit)) + if(LoggedInUser.HasRight(UserRightType.ServiceRecordView_Edit)) { allowed = true; } - else if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowChangeWithin24Hours)) + else if(LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowChangeWithin24Hours)) { if(serviceRecord.InsertedOn != null) { @@ -496,7 +493,7 @@ namespace BeWoPlanerMobil.Models if(allowed && ApplicationSettings.MaxDaysEditServiceRecordsAllowed > 0) { - if(!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth)) + if(!LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth)) { if(serviceRecord.Start != null) { @@ -512,9 +509,9 @@ namespace BeWoPlanerMobil.Models } } - if(allowed && !MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowEditForOtherEmployees)) + if(allowed && !LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowEditForOtherEmployees)) { - if(MobileSessionFacade.LoggedInEmployee.EmployeeOid != serviceRecord.Employee.EmployeeOid) + if(LoggedInUser.Employee.EmployeeOid != serviceRecord.Employee.EmployeeOid) { allowed = false; } @@ -522,7 +519,7 @@ namespace BeWoPlanerMobil.Models if(allowed && serviceRecord.GroupOid.HasValue) { - if(!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking)) + if(!LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking)) { allowed = false; } @@ -530,7 +527,7 @@ namespace BeWoPlanerMobil.Models if(allowed && ApplicationSettings.AnzTageZeiterfassErfolgt > 0) { - if(!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecordAllowEditAfterMindays)) + if(!LoggedInUser.HasRight(UserRightType.ServiceRecordAllowEditAfterMindays)) { if(serviceRecord.Start != null) { @@ -690,39 +687,29 @@ namespace BeWoPlanerMobil.Models /// public ServiceRecordTimeInterval ServiceRecordTimeInterval { get; set; } public int SelectedDayCount { get; set; } - public NullableDateTimeSpan SelectedZeitraum { get; set; } + public NullableDateTimeSpan SelectedZeitraum { get { return MainSessionModel.SelectedZeitraum; } set { MainSessionModel.SelectedZeitraum = value; } } public bool IsOnlyYearMonthVisible { get; set; } #region Mehrfachbuchung - private bool _IsInMultiBookingMode; [Display(Name = "Mehrfachbuchung")] - public bool IsInMultiBookingMode - { - get => _IsInMultiBookingMode; + public bool IsInMultiBookingMode { get { return MainSessionModel.IsInMultiBookingMode; } set { MainSessionModel.IsInMultiBookingMode = value; } } - set - { - _IsInMultiBookingMode = value; - - if(!_IsInMultiBookingMode) - { - - } - } - } + public List MultiBookingSelectedSupportConceptOids { get { return MainSessionModel.MultiBookingSelectedSupportConceptOids; } set { MainSessionModel.MultiBookingSelectedSupportConceptOids = value; } } public List MultiBookingSelectedSupportConcepts { get; set; } = new List(); - public List MultiBookingSelectedGroupOfPeopleOids { get; set; } = new List(); + public List MultiBookingSelectedGroupOfPeopleOids { get { return MainSessionModel.MultiBookingSelectedGroupOfPeopleOids; } set { MainSessionModel.MultiBookingSelectedGroupOfPeopleOids = value; } } public List MultiBookingSelectedConceptCostBearerRelations { get; set; } public GroupBookingSelectionObject MultiBookingSelectionObject => new GroupBookingSelectionObject(MultiBookingSelectedConceptCostBearerRelations, MultiBookingSelectedGroupOfPeopleOids); - public List MultiBookingSelectedCostbearerRelOids { get; set; } = new List(); + public List MultiBookingSelectedCostbearerRelOids { get { return MainSessionModel.MultiBookingSelectedCostbearerRelOids; } set { MainSessionModel.MultiBookingSelectedCostbearerRelOids = value; } } + + public List MultiBookingSelectedEmployeeOids { get { return MainSessionModel.MultiBookingSelectedEmployeeOids; } set { MainSessionModel.MultiBookingSelectedEmployeeOids = value; } } public List MultiBookingSelectedEmployees { get; set; } = new List(); public List MultiBookingSupportConceptListObjects @@ -737,7 +724,7 @@ namespace BeWoPlanerMobil.Models cb => new CostBearer2SupportConceptRelListObject( $"{sc.Customer.SimpleDescription} {(sc.Customer.DateOfBirth.HasValue ? "*" + sc.Customer.DateOfBirth.Value.ToString("dd.MM.yyyy") : string.Empty)}", $"{cb.AuswahlBezeichnung} {cb.StartDate?.ToShortDateString().Remove(6, 2) ?? string.Empty}-{cb.EndDate?.ToShortDateString().Remove(6, 2) ?? string.Empty} {cb.CostBearer.Name}", - cb.CostBearer2SupportConceptOid.ToString(), + cb.CostBearer2SupportConceptOid.Value, cb.SupportConcept.IsAboutToExpire, cb.SupportConcept.ExpiresIn3MonthOrLess)) ); @@ -749,8 +736,6 @@ namespace BeWoPlanerMobil.Models #endregion - public MandatorDC Mandator { get; set; } - public bool IsPasswordSecurityEnabled { get; set; } public bool ShowMarker { get; set; } @@ -758,7 +743,7 @@ namespace BeWoPlanerMobil.Models #region ServiceRecord-Pagination public int ServiceRecordCount { get; set; } - public int CurrentPage { get; set; } + public int CurrentPage { get { return MainSessionModel.CurrentPage; } set { MainSessionModel.CurrentPage = value; } } public int MaxResults { get; set; } = 10; @@ -783,6 +768,7 @@ namespace BeWoPlanerMobil.Models public ServiceCategoryDC SelectedServiceCategory { get; set; } public ServiceDescriptionDC SelectedServiceDescription { get; set; } + public List AllGoals { get; internal set; } public ServiceDescriptionDC GetSelectedOrFirstServiceDescription() { @@ -830,7 +816,7 @@ namespace BeWoPlanerMobil.Models public string SupportConceptTimeSpan { get; } - public string CostBearer2SupportConceptOid { get; } + public long CostBearer2SupportConceptOid { get; } public string CostBearer2SupportConceptOidName { get; } @@ -838,13 +824,13 @@ namespace BeWoPlanerMobil.Models public bool ExpiresInThreeMonthsOrLess { get; } - public CostBearer2SupportConceptRelListObject(string pNameAndDateOfBirth, string pSupportConceptTimeSpan, string pCostBearer2SupportConceptOid, bool isAboutToExpire, bool expiresIn3MonthOrLess) + public CostBearer2SupportConceptRelListObject(string pNameAndDateOfBirth, string pSupportConceptTimeSpan, long pCostBearer2SupportConceptOid, bool isAboutToExpire, bool expiresIn3MonthOrLess) { NameAndDateOfBirth = pNameAndDateOfBirth; SupportConceptTimeSpan = pSupportConceptTimeSpan; CostBearer2SupportConceptOid = pCostBearer2SupportConceptOid; - CostBearer2SupportConceptOidName = "OidHolder_" + CostBearer2SupportConceptOid; + CostBearer2SupportConceptOidName = String.Format("OidHolder_{0}", CostBearer2SupportConceptOid); IsAboutToExpire = isAboutToExpire; ExpiresInThreeMonthsOrLess = expiresIn3MonthOrLess; @@ -873,7 +859,7 @@ namespace BeWoPlanerMobil.Models hash = (hash * hashingMultiplier) ^ (NameAndDateOfBirth?.GetHashCode() ?? 0); hash = (hash * hashingMultiplier) ^ (SupportConceptTimeSpan?.GetHashCode() ?? 0); - hash = (hash * hashingMultiplier) ^ (CostBearer2SupportConceptOid?.GetHashCode() ?? 0); + hash = (hash * hashingMultiplier) ^ (CostBearer2SupportConceptOid.GetHashCode()); hash = (hash * hashingMultiplier) ^ IsAboutToExpire.GetHashCode(); hash = (hash * hashingMultiplier) ^ ExpiresInThreeMonthsOrLess.GetHashCode(); diff --git a/BeWoPlanerMobil/Models/MainSessionModel.cs b/BeWoPlanerMobil/Models/MainSessionModel.cs new file mode 100644 index 000000000..79697ee9e --- /dev/null +++ b/BeWoPlanerMobil/Models/MainSessionModel.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Web.Mvc; +using BeWo.View.Navigation.Filter; +using BeWoPlanerMobil.Controllers; +using BeWoPlanerMobil.Service; +using BeWoPlanerMobil.Util; +using BS.Shared; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using DevExpress.XtraReports.UI; + +namespace BeWoPlanerMobil.Models +{ + [Serializable] + public class MainSessionModel : ISessionModel + { + public bool SessionInitialized { get; internal set; } + public long? SelectedSupportConceptOid { get; internal set; } + public long? SelectedCostBearerSupportConceptOid { get; internal set; } + public bool ShowOnlyOwnSupportConcepts { get; internal set; } + public bool ShowOnlyMyTeamsSupportConcepts { get; internal set; } + public CustomerFilterEnum SelectedSupportConceptFilter { get; internal set; } + public bool ShowExpiredSupportConcepts { get; internal set; } + public long? SelectedServiceCategoryOid { get; internal set; } + public long? SelectedServiceDescriptionOid { get; internal set; } + public long? SelectedServiceRecordOid { get; internal set; } + public long? SelectedEmployeeOid { get; internal set; } + public NullableDateTimeSpan SelectedZeitraum { get; internal set; } + public List SelectedConceptCostBearerRelations { get; internal set; } + public List GroupBookingSelectedSupportConceptOids { get; internal set; } + public List GroupBookingSelectedEmployeeOids { get; internal set; } + public List GroupBookingSelectedCostbearerRelOids { get; internal set; } + public bool IsInGroupBookingMode { get; internal set; } + public bool IsInEditingMode { get; internal set; } + public long? PreviouslySelectedEmployeeOid { get; internal set; } + public long? PreviouslySelectedSupportConceptOid { get; internal set; } + public long? PreviouslySelectedCostbearer2SupportConceptOid { get; internal set; } + public bool IsInMultiBookingMode { get; internal set; } + public List MultiBookingSelectedSupportConceptOids { get; internal set; } + public List MultiBookingSelectedGroupOfPeopleOids { get; internal set; } + public List MultiBookingSelectedCostbearerRelOids { get; internal set; } + public List MultiBookingSelectedEmployeeOids { get; internal set; } + public int CurrentPage { get; internal set; } + public List SelectedGoalOids { get; internal set; } + public long LastCreatedServiceRecordOid { get; internal set; } + + public void ResetValues() + { + SessionInitialized = false; + SelectedSupportConceptOid = null; + SelectedCostBearerSupportConceptOid = null; + ShowOnlyOwnSupportConcepts = false; + ShowOnlyMyTeamsSupportConcepts = false; + SelectedSupportConceptFilter = CustomerFilterEnum.All; + ShowExpiredSupportConcepts = false; + SelectedServiceCategoryOid = null; + SelectedServiceDescriptionOid = null; + SelectedServiceRecordOid = null; + SelectedEmployeeOid = null; + SelectedZeitraum = null; + + SelectedConceptCostBearerRelations = new List(); + GroupBookingSelectedSupportConceptOids = new List(); + GroupBookingSelectedEmployeeOids = new List(); + GroupBookingSelectedCostbearerRelOids = new List(); + MultiBookingSelectedSupportConceptOids = new List(); + MultiBookingSelectedGroupOfPeopleOids = new List(); + MultiBookingSelectedCostbearerRelOids = new List(); + MultiBookingSelectedEmployeeOids = new List(); + + SelectedGoalOids = new List(); + + PreviouslySelectedEmployeeOid = null; + PreviouslySelectedSupportConceptOid = null; + PreviouslySelectedCostbearer2SupportConceptOid = null; + + IsInGroupBookingMode = false; + IsInEditingMode = false; + IsInMultiBookingMode = false; + + CurrentPage = 0; + LastCreatedServiceRecordOid = 0; + } + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Models/ReportModel.cs b/BeWoPlanerMobil/Models/ReportModel.cs index 57e9bbf5a..f4469d90d 100644 --- a/BeWoPlanerMobil/Models/ReportModel.cs +++ b/BeWoPlanerMobil/Models/ReportModel.cs @@ -17,6 +17,19 @@ namespace BeWoPlanerMobil.Models { public class ReportModel : AbstractModel { + public ReportModel() + { + SessionModel = new ReportSessionModel(); + } + + public ReportSessionModel ReportSessionModel + { + get + { + return SessionModel as ReportSessionModel; + } + } + public QbSignatureIntervalSelection SelectedIntervalSelection { get; set; } public List IntervalSelections => new List @@ -41,16 +54,16 @@ namespace BeWoPlanerMobil.Models } }; - [Display(Name = "Klient")] - public long? SelectedCustomerOid => SelectedCustomer?.CustomerOid; + [Display(Name = "Klient")] + public long? SelectedCustomerOid { get { return ReportSessionModel.SelectedCustomerOid; } set { ReportSessionModel.SelectedCustomerOid = value; } } public CompactCustomerDC SelectedCustomer { get; set; } [Display(Name = "Monat")] - public int? SelectedMonth { get; set; } + public int? SelectedMonth { get { return ReportSessionModel.SelectedMonth; } set { ReportSessionModel.SelectedMonth = value; } } [Display(Name = "Jahr")] - public int? SelectedYear { get; set; } + public int? SelectedYear { get { return ReportSessionModel.SelectedYear; } set { ReportSessionModel.SelectedYear = value; } } public List Months { @@ -115,27 +128,27 @@ namespace BeWoPlanerMobil.Models } [Display(Name = "Vom")] - public int? SelectedStartDay { get; set; } + public int? SelectedStartDay { get { return ReportSessionModel.SelectedStartDay; } set { ReportSessionModel.SelectedStartDay = value; } } [Display(Name = "Bis")] - public int? SelectedEndDay { get; set; } + public int? SelectedEndDay { get { return ReportSessionModel.SelectedEndDay; } set { ReportSessionModel.SelectedEndDay = value; } } public ConfirmationReceiptObject ConfirmationReceiptObject { get; set; } [Display(Name = "Mitarbeiter")] - public long? SelectedEmployeeOid => SelectedEmployee?.EmployeeOid; + public long? SelectedEmployeeOid { get { return ReportSessionModel.SelectedEmployeeOid; } set { ReportSessionModel.SelectedEmployeeOid = value; } } public CompactEmployeeDC SelectedEmployee { get; set; } [Display(Name="Kostenträger")] - public long? SelectedOrganisationOid => SelectedOrganisation?.OrganisationOid; + public long? SelectedOrganisationOid { get { return ReportSessionModel.SelectedOrganisationOid; } set { ReportSessionModel.SelectedOrganisationOid = value; } } public CompactOrganisationDC SelectedOrganisation { get; set; } public List Organisations { get; set; } = new List(); [Display(Name="Leistungskategorie")] - public long? SelectedServiceCategoryOid => SelectedServiceCategory?.ServiceCategoryOid; + public long? SelectedServiceCategoryOid { get { return ReportSessionModel.SelectedServiceCategoryOid; } set { ReportSessionModel.SelectedServiceCategoryOid = value; } } public ServiceCategoryDC SelectedServiceCategory { get; set; } @@ -166,21 +179,33 @@ namespace BeWoPlanerMobil.Models } [Display(Name="Filter")] - public QbFilterItem SelectedFilterItem { get; set; } - public int? SelectedFilterItemId - { - get - { - if(SelectedFilterItem is null) + + public QbFilterItem SelectedFilterItem + { + get + { + if (QbFilters == null || !SelectedFilterItemId.HasValue) { return null; } - - return (int)SelectedFilterItem.FilterEnum; - } + return QbFilters.FirstOrDefault(f => f.FilterEnum == SelectedFilterItemId.Value); + } } + public QBFilterEnum? SelectedFilterItemId { get { return ReportSessionModel.SelectedFilterItemId; } set { ReportSessionModel.SelectedFilterItemId = value; } } + //{ + // get + // { + // if(SelectedFilterItem is null) + // { + // return null; + // } + + // return (int)SelectedFilterItem.FilterEnum; + // } + //} + public List QbFilters { get; set; } = new List(); public List QbFilterItems @@ -203,7 +228,7 @@ namespace BeWoPlanerMobil.Models } [Display(Name = "Team")] - public long? SelectedTeamOid => SelectedTeam?.TeamOid; + public long? SelectedTeamOid { get { return ReportSessionModel.SelectedTeamOid; } set { ReportSessionModel.SelectedTeamOid = value; } } public CompactTeamDC SelectedTeam { get; set; } @@ -244,9 +269,9 @@ namespace BeWoPlanerMobil.Models ConfirmationReceiptSignatures.Where(crs => crs.ConfirmationReceiptSignatureOid != null && confirmationReceiptSignatureOids.Contains(crs.ConfirmationReceiptSignatureOid.Value)).ToList(); } - public bool IsForSelectedEmployeesOnly { get; set; } - public bool IsForSelectedCostbearersOnly { get; set; } - public bool IsForSelectedCategoryOnly { get; set; } + public bool IsForSelectedEmployeesOnly { get { return ReportSessionModel.IsForSelectedEmployeesOnly; } set { ReportSessionModel.IsForSelectedEmployeesOnly = value; } } + public bool IsForSelectedCostbearersOnly { get { return ReportSessionModel.IsForSelectedCostbearersOnly; } set { ReportSessionModel.IsForSelectedCostbearersOnly = value; } } + public bool IsForSelectedCategoryOnly { get { return ReportSessionModel.IsForSelectedCategoryOnly; } set { ReportSessionModel.IsForSelectedCategoryOnly = value; } } public List SelectedConfirmationReceiptSignatures { get; set; } @@ -254,7 +279,9 @@ namespace BeWoPlanerMobil.Models public AbstractReportCreator ReportCreator { get; set; } - public XtraReport QuittierungsbelegsReportObject { get; set; } + public QuittierungsbelegsReportSettings QuittierungsbelegsReportSettings { get { return ReportSessionModel.QuittierungsbelegsReportSettings; } set { ReportSessionModel.QuittierungsbelegsReportSettings = value; } } + + public XtraReport QuittierungsbelegsReport { get; set; } public int QbEntryCount { get; set; } public int MaxResults { get; set; } = 10; diff --git a/BeWoPlanerMobil/Models/ReportSessionModel .cs b/BeWoPlanerMobil/Models/ReportSessionModel .cs new file mode 100644 index 000000000..f923ca2ed --- /dev/null +++ b/BeWoPlanerMobil/Models/ReportSessionModel .cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Web.Mvc; +using BeWo.View.Navigation.Filter; +using BeWoPlanerMobil.Controllers; +using BeWoPlanerMobil.Service; +using BeWoPlanerMobil.Util; +using BeWoPlanerMobil.Util.ReportUtils; +using BS.Shared; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using DevExpress.XtraReports.UI; + +namespace BeWoPlanerMobil.Models +{ + [Serializable] + public class ReportSessionModel : ISessionModel + { + public long? SelectedCustomerOid { get; set; } + public long? SelectedEmployeeOid { get; set; } + public long? SelectedTeamOid { get; set; } + public long? SelectedOrganisationOid { get; set; } + public long? SelectedServiceCategoryOid { get; set; } + public int? SelectedMonth { get; internal set; } + public int? SelectedYear { get; internal set; } + public int? SelectedStartDay { get; internal set; } + public int? SelectedEndDay { get; internal set; } + public QBFilterEnum? SelectedFilterItemId { get; internal set; } + public bool IsForSelectedEmployeesOnly { get; internal set; } + public bool IsForSelectedCostbearersOnly { get; internal set; } + public bool IsForSelectedCategoryOnly { get; internal set; } + public QuittierungsbelegsReportSettings QuittierungsbelegsReportSettings { get; internal set; } + + public void ResetValues() + { + SelectedCustomerOid = null; + SelectedEmployeeOid = null; + SelectedTeamOid = null; + SelectedOrganisationOid = null; + SelectedServiceCategoryOid = null; + SelectedMonth = null; + SelectedYear = null; + SelectedStartDay = null; + SelectedEndDay = null; + SelectedFilterItemId = null; + IsForSelectedEmployeesOnly = false; + IsForSelectedCostbearersOnly = false; + IsForSelectedCategoryOnly = false; + QuittierungsbelegsReportSettings = null; + } + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Models/ReportViewerModel.cs b/BeWoPlanerMobil/Models/ReportViewerModel.cs index 723d428af..1fce6f018 100644 --- a/BeWoPlanerMobil/Models/ReportViewerModel.cs +++ b/BeWoPlanerMobil/Models/ReportViewerModel.cs @@ -12,13 +12,26 @@ namespace BeWoPlanerMobil.Models { public class ReportViewerModel : AbstractModel { + public ReportViewerModel() + { + SessionModel = new ReportViewerSessionModel(); + } + + public ReportViewerSessionModel ReportViewerSessionModel + { + get + { + return SessionModel as ReportViewerSessionModel; + } + } + public List AllEmployees { get; set; } public List AllTeams { get; set; } public List Queries { get; set; } public AbstractReportCreator ReportCreator { get; set; } [Display(Name = "Monat")] - public int? SelectedMonth { get; set; } + public int? SelectedMonth { get { return ReportViewerSessionModel.SelectedMonth; } set { ReportViewerSessionModel.SelectedMonth = value; } } public List Months { get @@ -40,7 +53,7 @@ namespace BeWoPlanerMobil.Models [Display(Name = "Jahr")] - public int? SelectedYear { get; set; } + public int? SelectedYear { get { return ReportViewerSessionModel.SelectedYear; } set { ReportViewerSessionModel.SelectedYear = value; } } public List Years { get @@ -62,7 +75,7 @@ namespace BeWoPlanerMobil.Models [Display(Name="Bericht")] - public ReportType SelectedReportType { get; set; } + public ReportType SelectedReportType { get { return ReportViewerSessionModel.SelectedReportType; } set { ReportViewerSessionModel.SelectedReportType = value; } } public List ReportTypes { get; set; } @@ -94,7 +107,7 @@ namespace BeWoPlanerMobil.Models [Display(Name = "Mitarbeiter")] - public long? SelectedEmployeeOid => SelectedEmployee?.EmployeeOid; + public long? SelectedEmployeeOid { get { return ReportViewerSessionModel.SelectedEmployeeOid; } set { ReportViewerSessionModel.SelectedEmployeeOid = value; } } public CompactEmployeeDC SelectedEmployee { get; set; } public List Employees { @@ -109,7 +122,7 @@ namespace BeWoPlanerMobil.Models if(HasRightMitarbeiterstundenkontoViewSelf && !HasRightMitarbeiterstundenkontoViewAll) { - result.Add(new SelectListItem{ Text = Employee.LastNameFirstName, Value = Employee.EmployeeOid.ToString()}); + result.Add(new SelectListItem{ Text = LoggedInEmployee.LastNameFirstName, Value = LoggedInEmployee.EmployeeOid.ToString()}); return result; } @@ -126,7 +139,7 @@ namespace BeWoPlanerMobil.Models [Display(Name = "Team")] - public long? SelectedTeamOid => SelectedTeam?.TeamOid; + public long? SelectedTeamOid { get { return ReportViewerSessionModel.SelectedTeamOid; } set { ReportViewerSessionModel.SelectedTeamOid = value; } } public CompactTeamDC SelectedTeam { get; set; } public List Teams { @@ -151,11 +164,14 @@ namespace BeWoPlanerMobil.Models } - public List SelectedEmployees { get; set; } - public List SelectedTeams { get; set; } + //public List SelectedEmployees { get; set; } + //public List SelectedTeams { get; set; } + + public long? SelectedQueryOid { get { return ReportViewerSessionModel.SelectedQueryOid; } set { ReportViewerSessionModel.SelectedQueryOid = value; } } public QueryDC SelectedQuery { get; set; } + public List SupportConcepts { get; set; } public CostBearer2SupportConceptRelListObject SelectedCostBearer2SupportConceptRelListObject { get; set; } @@ -164,14 +180,14 @@ namespace BeWoPlanerMobil.Models { get { - var allCostBearerRelations = new List { new CostBearer2SupportConceptRelListObject("Hilfeplan auswählen", "", "0", false, false) }; + var allCostBearerRelations = new List { new CostBearer2SupportConceptRelListObject("Hilfeplan auswählen", "", 0, false, false) }; foreach(var sc in SupportConcepts.OrderBy(sc => sc.Customer.LastName)) { allCostBearerRelations.AddRange(sc.CostBearerRelations.Select( cb => new CostBearer2SupportConceptRelListObject( $"{sc.Customer.SimpleDescription} {(sc.Customer.DateOfBirth.HasValue ? "*" + sc.Customer.DateOfBirth.Value.ToString("dd.MM.yyyy") : string.Empty)}", $"{cb.AuswahlBezeichnung} {cb.StartDate?.ToShortDateString().Remove(6, 2) ?? string.Empty}-{cb.EndDate?.ToShortDateString().Remove(6, 2) ?? string.Empty} {cb.CostBearer.Name}{GetIsNotApproved(cb)}", - cb.CostBearer2SupportConceptOid.ToString(), + cb.CostBearer2SupportConceptOid.Value, cb.SupportConcept.IsAboutToExpire, cb.SupportConcept.ExpiresIn3MonthOrLess)) ); @@ -231,6 +247,7 @@ namespace BeWoPlanerMobil.Models } } + [Serializable] public class ReportSelectListItem : SelectListItem { public long? QueryOid { get; set; } diff --git a/BeWoPlanerMobil/Models/ReportViewerSessionModel.cs b/BeWoPlanerMobil/Models/ReportViewerSessionModel.cs new file mode 100644 index 000000000..2db225d3d --- /dev/null +++ b/BeWoPlanerMobil/Models/ReportViewerSessionModel.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Web.Mvc; +using BeWo.View.Navigation.Filter; +using BeWoPlanerMobil.Controllers; +using BeWoPlanerMobil.Service; +using BeWoPlanerMobil.Util; +using BS.Shared; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using DevExpress.XtraReports.UI; + +namespace BeWoPlanerMobil.Models +{ + [Serializable] + public class ReportViewerSessionModel : ISessionModel + { + public long? SelectedEmployeeOid { get; set; } + public long? SelectedTeamOid { get; set; } + public int? SelectedMonth { get; internal set; } + public int? SelectedYear { get; internal set; } + public ReportType SelectedReportType { get; internal set; } + public long? SelectedQueryOid { get; internal set; } + + public void ResetValues() + { + SelectedEmployeeOid = null; + SelectedTeamOid = null; + SelectedMonth = null; + SelectedYear = null; + SelectedReportType = ReportType.Berichte; + SelectedQueryOid = null; + } + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Models/SchedulerModel.cs b/BeWoPlanerMobil/Models/SchedulerModel.cs index bbaa5d4ad..f92078704 100644 --- a/BeWoPlanerMobil/Models/SchedulerModel.cs +++ b/BeWoPlanerMobil/Models/SchedulerModel.cs @@ -15,49 +15,38 @@ namespace BeWoPlanerMobil.Models { public class SchedulerModel : AbstractModel { - public List TeamMemberCustomerOids { get; set; } - - public DateTime SelectedDate { get; set; } = DateTime.Today; - - public SchedulerAppointmentDC SelectedAppointment { get; set; } - - private List _Appointments; - - public List Appointments + public SchedulerModel() { - get => _Appointments ?? (_Appointments = new List()); + SessionModel = new SchedulerSessionModel(); + SessionModel.ResetValues(); + } - set + public SchedulerSessionModel SchedulerSessionModel + { + get { - var oldAppointments = AppointmentListItems.Select(li => li.SchedulerAppointment).ToList(); - - _Appointments = value ?? new List(); - - if(_Appointments.AreListEqual(oldAppointments)) - { - return; - } - - _AppointmentListItems = new List(); - - foreach(var appointment in _Appointments) - { - var listItem = new AppointmentListItem(appointment); - listItem.GenerateIdentifier(_AppointmentListItems.Select(a => a.Identifier).ToList()); - - _AppointmentListItems.Add(listItem); - } + return SessionModel as SchedulerSessionModel; } } - - private List _AppointmentListItems; - public List AppointmentListItems => _AppointmentListItems ?? (_AppointmentListItems = new List()); - public bool HasRightToEditAppointment(Guid identifier) + public List TeamMemberCustomerOids { get; set; } + + public DateTime SelectedDate { get { return SchedulerSessionModel.SelectedDate; } set { SchedulerSessionModel.SelectedDate = value; } } + + public long? SelectedAppointmentOid { get { return SchedulerSessionModel.SelectedAppointmentOid; } set { SchedulerSessionModel.SelectedAppointmentOid = value; } } + + public SchedulerAppointmentDC SelectedAppointment { get; set; } + + + public List Appointments { get; set; } + + public List AppointmentListItems { get; set; } + + public bool HasRightToEditAppointment(String identifier) { var appointment = AppointmentListItems.FirstOrDefault(app => app.Identifier.Equals(identifier))?.SchedulerAppointment; //Appointments.FirstOrDefault(app => app.SchedulerAppointmentOid.HasValue && app.SchedulerAppointmentOid.Value == appointmentOid); - return appointment != null && Utils.CheckSchedulerRights(appointment.CustomerList, appointment.ResourceList, appointment.EmployeeList, appointment.Originator, appointment.SchedulerAppointmentOid is null, SchedulerRightsCheckType.Edit, MobileSessionFacade.LoggedInUserDC, TeamMemberCustomerOids ?? new List()); + return appointment != null && BS.Shared.Core.Utils.CheckSchedulerRights(appointment.CustomerList, appointment.ResourceList, appointment.EmployeeList, appointment.Originator, appointment.SchedulerAppointmentOid is null, SchedulerRightsCheckType.Edit, LoggedInUser, TeamMemberCustomerOids ?? new List()); } public string DescriptionToEdit => SelectedAppointment?.Description ?? string.Empty; @@ -85,7 +74,9 @@ namespace BeWoPlanerMobil.Models } } - public List SelectedResources { get; set; } = new List(); + public List SelectedResourceOids { get { return SchedulerSessionModel.SelectedResourceOids; } set { SchedulerSessionModel.SelectedResourceOids = value; } } + + public List SelectedResources { get; set; } public Dictionary> ResourceCategories2Resources { get; set; } = new Dictionary>(); @@ -112,42 +103,30 @@ namespace BeWoPlanerMobil.Models public List AllEmployees { get; set; } = new List(); - public List SelectedEmployees { get; set; } = new List(); + public List SelectedEmployeeOids { get { return SchedulerSessionModel.SelectedEmployeeOids; } set { SchedulerSessionModel.SelectedEmployeeOids = value; } } + + public List SelectedEmployees { get; set; } public List AllCustomers { get; set; } = new List(); + public List SelectedCustomerOids { get { return SchedulerSessionModel.SelectedCustomerOids; } set { SchedulerSessionModel.SelectedCustomerOids = value; } } + public List SelectedCustomers { get; set; } = new List(); - public bool IsInEditMode => SelectedAppointment != null; + public bool IsInEditMode => SelectedAppointmentOid.HasValue; // ToDo: Überarbeiten? Es kam das Ansehen hinzu - public bool HasResourcesEmployeesOrCustomers - { - get - { - var isOwnAppointment = !IsInEditMode || SelectedAppointment.Originator.EmployeeOid == Employee.EmployeeOid; - - var v1 = HasRightToInsertEmployeeAppointments || IsInEditMode && HasRightToEditEmployeeAppointments; - - var v2 = HasRightToInsertRessourceAppointments || IsInEditMode && HasRightToEditResourceAppointments; - - if (IsInEditMode && !isOwnAppointment) - { - v2 = HasRightToEditOthersResourceAppointments; - } - - var v3 = HasRightToInsertCustomerAppointments || IsInEditMode && HasRightToEditCustomerAppointments; - - return v1 || v2 || v3; - } - } - + public bool HasResourcesEmployeesOrCustomers { get; set; } + public bool ShowEmployeeButton => IsInEditMode ? HasRightToInsertEmployeeAppointments : HasRightToEditEmployeeAppointments; public bool ShowCustomerButton => IsInEditMode ? HasRightToInsertCustomerAppointments : HasRightToEditCustomerAppointments; //IntervalFinder + public List SelectedEmployeeOidsForIntervalFinder { get { return SchedulerSessionModel.SelectedEmployeeOidsForIntervalFinder; } set { SchedulerSessionModel.SelectedEmployeeOidsForIntervalFinder = value; } } public List SelectedEmployeesForIntervalFinder { get; set; } = new List(); + public List SelectedCustomerOidsForIntervalFinder { get { return SchedulerSessionModel.SelectedCustomerOidsForIntervalFinder; } set { SchedulerSessionModel.SelectedCustomerOidsForIntervalFinder = value; } } public List SelectedCustomersForIntervalFinder { get; set; } = new List(); + public List SelectedResourceOidsForIntervalFinder { get { return SchedulerSessionModel.SelectedResourceOidsForIntervalFinder; } set { SchedulerSessionModel.SelectedResourceOidsForIntervalFinder = value; } } public List SelectedResourcesForIntervalFinder { get; set; } = new List(); public Dictionary> FreeIntervals { get; set; } = new Dictionary>(); @@ -170,34 +149,38 @@ namespace BeWoPlanerMobil.Models } } - public bool IsInIntervalFinderMode { get; set; } - public DateTime? IntervalStartDate { get; set; } - public DateTime? IntervalEndDate { get; set; } + public bool IsInIntervalFinderMode { get { return SchedulerSessionModel.IsInIntervalFinderMode; } set { SchedulerSessionModel.IsInIntervalFinderMode = value; } } + public DateTime? IntervalStartDate { get { return SchedulerSessionModel.IntervalStartDate; } set { SchedulerSessionModel.IntervalStartDate = value; } } + public DateTime? IntervalEndDate { get { return SchedulerSessionModel.IntervalEndDate; } set { SchedulerSessionModel.IntervalEndDate = value; } } public string IntervalStartDateStr => IntervalStartDate.HasValue ? IntervalStartDate.Value.ToString("yyyy-MM-ddTHH:mm") : string.Empty; public string IntervalEndDateStr => IntervalEndDate.HasValue ? IntervalEndDate.Value.ToString("yyyy-MM-ddTHH:mm") : string.Empty; public string IntervalStartTimeStr => IntervalStartDate.HasValue ? $"{IntervalStartDate:HH:mm}" : string.Empty; public string IntervalEndTimeStr => IntervalEndDate.HasValue ? $"{IntervalEndDate:HH:mm}" : string.Empty; - public int? IntervalDuration { get; set; } + public int? IntervalDuration { get { return SchedulerSessionModel.IntervalDuration; } set { SchedulerSessionModel.IntervalDuration = value; } } public string IntervalDurationStr => IntervalDuration.HasValue ? $"{IntervalDuration}" : string.Empty; [Display(Name = "Ganztägig")] - public bool IsAllDay { get; set; } - + public bool IsAllDay { get { return SchedulerSessionModel.IsAllDay; } set { SchedulerSessionModel.IsAllDay = value; } } + [Display(Name = "Privat")] - public bool IsPrivate { get; set; } + public bool IsPrivate { get { return SchedulerSessionModel.IsPrivate; } set { SchedulerSessionModel.IsPrivate = value; } } + public List MyTeamEmployees { get; set; } - public List SelectedResourcesForFiltering { get; set; } = new List(); - public List SelectedEmployeesForFiltering { get; set; } = new List(); - public List SelectedCustomersForFiltering { get; set; } = new List(); + public List SelectedResourceOidsForFiltering { get { return SchedulerSessionModel.SelectedResourceOidsForFiltering; } set { SchedulerSessionModel.SelectedResourceOidsForFiltering = value; } } + public List SelectedResourcesForFiltering { get; set; } + public List SelectedEmployeeOidsForFiltering { get { return SchedulerSessionModel.SelectedEmployeeOidsForFiltering; } set { SchedulerSessionModel.SelectedEmployeeOidsForFiltering = value; } } + public List SelectedEmployeesForFiltering { get; set; } + public List SelectedCustomerOidsForFiltering { get { return SchedulerSessionModel.SelectedCustomerOidsForFiltering; } set { SchedulerSessionModel.SelectedCustomerOidsForFiltering = value; } } + public List SelectedCustomersForFiltering { get; set; } public List MyTeams { get; set; } = new List(); - public bool ShouldLoadTasks { get; set; } + public bool ShouldLoadTasks { get { return SchedulerSessionModel.ShouldLoadTasks; } set { SchedulerSessionModel.ShouldLoadTasks = value; } } } public class WeekViewObject @@ -240,13 +223,13 @@ namespace BeWoPlanerMobil.Models SaturdayAppointments = new KeyValuePair>(saturday, new List()); SundayAppointments = new KeyValuePair>(last, new List()); - mondays.DoForEach(app => MondayAppointments.Value.Add(new AppointmentListItem(app))); - tuesdays.DoForEach(app => TuesdayAppointments.Value.Add(new AppointmentListItem(app))); - wednesdays.DoForEach(app => WednesdayAppointments.Value.Add(new AppointmentListItem(app))); - thursdays.DoForEach(app => ThursdayAppointments.Value.Add(new AppointmentListItem(app))); - fridays.DoForEach(app => FridayAppointments.Value.Add(new AppointmentListItem(app))); - saturdays.DoForEach(app => SaturdayAppointments.Value.Add(new AppointmentListItem(app))); - sundays.DoForEach(app => SundayAppointments.Value.Add(new AppointmentListItem(app))); + mondays.DoForEach(app => MondayAppointments.Value.Add(new AppointmentListItem("", app))); + tuesdays.DoForEach(app => TuesdayAppointments.Value.Add(new AppointmentListItem("", app))); + wednesdays.DoForEach(app => WednesdayAppointments.Value.Add(new AppointmentListItem("", app))); + thursdays.DoForEach(app => ThursdayAppointments.Value.Add(new AppointmentListItem("", app))); + fridays.DoForEach(app => FridayAppointments.Value.Add(new AppointmentListItem("", app))); + saturdays.DoForEach(app => SaturdayAppointments.Value.Add(new AppointmentListItem("", app))); + sundays.DoForEach(app => SundayAppointments.Value.Add(new AppointmentListItem("", app))); } } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Models/SchedulerSessionModel.cs b/BeWoPlanerMobil/Models/SchedulerSessionModel.cs new file mode 100644 index 000000000..8ccea54fa --- /dev/null +++ b/BeWoPlanerMobil/Models/SchedulerSessionModel.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Web.Mvc; +using BeWo.View.Navigation.Filter; +using BeWoPlanerMobil.Controllers; +using BeWoPlanerMobil.Service; +using BeWoPlanerMobil.Util; +using BS.Shared; +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using DevExpress.XtraReports.UI; + +namespace BeWoPlanerMobil.Models +{ + [Serializable] + public class SchedulerSessionModel : ISessionModel + { + public DateTime SelectedDate { get; set; } + public long? SelectedAppointmentOid { get; internal set; } + public List SelectedResourceOids { get; internal set; } + public List SelectedEmployeeOids { get; internal set; } + public List SelectedCustomerOids { get; internal set; } + public List SelectedEmployeeOidsForIntervalFinder { get; internal set; } + public List SelectedCustomerOidsForIntervalFinder { get; internal set; } + public List SelectedResourceOidsForIntervalFinder { get; internal set; } + public bool IsAllDay { get; set; } + public bool IsPrivate { get; set; } + public List SelectedEmployeeOidsForFiltering { get; internal set; } + public List SelectedCustomerOidsForFiltering { get; internal set; } + public List SelectedResourceOidsForFiltering { get; internal set; } + public bool ShouldLoadTasks { get; internal set; } + public bool IsInIntervalFinderMode { get; internal set; } + public DateTime? IntervalStartDate { get; internal set; } + public DateTime? IntervalEndDate { get; internal set; } + public int? IntervalDuration { get; internal set; } + + public void ResetValues() + { + SelectedDate = DateTime.Today; + SelectedAppointmentOid = null; + SelectedResourceOids = new List(); + SelectedEmployeeOids = new List(); + SelectedCustomerOids = new List(); + SelectedEmployeeOidsForIntervalFinder = new List(); + SelectedCustomerOidsForIntervalFinder = new List(); + SelectedResourceOidsForIntervalFinder = new List(); + SelectedEmployeeOidsForFiltering = new List(); + SelectedCustomerOidsForFiltering = new List(); + SelectedResourceOidsForFiltering = new List(); + IsAllDay = false; + IsPrivate = false; + ShouldLoadTasks = false; + IsInIntervalFinderMode = false; + IntervalStartDate = null; + IntervalEndDate = null; + IntervalDuration = null; + } + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Service/ASPHibernateSessionManager.cs b/BeWoPlanerMobil/Service/ASPHibernateSessionManager.cs index 5068ce9fb..8ec1a34f5 100644 --- a/BeWoPlanerMobil/Service/ASPHibernateSessionManager.cs +++ b/BeWoPlanerMobil/Service/ASPHibernateSessionManager.cs @@ -10,6 +10,7 @@ using System.Web; using BeWo.Data.Access; using BeWo.Data.Entities; +using BeWo.Service.DCEntityMapper; using BeWo.Service.ServiceImplementations; using BeWoPlanerMobil.Util; using BS.Shared; @@ -110,10 +111,10 @@ namespace BeWoPlanerMobil.Service var userLoaded = TryAuthenticateWithLoginForm(context); - if(!userLoaded && MobileSessionFacade.LoggedInUser != null && MobileSessionFacade.LoggedInUser.Oid.HasValue) - { - MobileSessionFacade.LoggedInUser = DAOFactory.GenericDAO.LoadByID(MobileSessionFacade.LoggedInUser.Oid.Value); - } + //if(!userLoaded && MobileSessionFacade.LoggedInUser != null && MobileSessionFacade.LoggedInUser.UserOid.HasValue) + //{ + // MobileSessionFacade.LoggedInUser = MapperFactory.UserDC_User.MapToNewDC(DAOFactory.GenericDAO.LoadByID(MobileSessionFacade.LoggedInUser.UserOid.Value)); + //} } }; @@ -203,7 +204,10 @@ namespace BeWoPlanerMobil.Service } MobileSessionFacade.PasswordStrength = new PasswordUtils().EvaluatePasswordStrength(password); - MobileSessionFacade.LoggedInUser = user; + + MobileSessionFacade.LoggedInUserOid = user.Oid; + MobileSessionFacade.EmployeeFullname = user.Employee.Person.FirstNameLastName; + //MobileSessionFacade.LoggedInEmployee = MapperFactory.EmployeeDC_Employee.MapToNewDC(user.Employee); } return true; diff --git a/BeWoPlanerMobil/Service/MobileSessionFacade.cs b/BeWoPlanerMobil/Service/MobileSessionFacade.cs index d355558d9..7f2dd3e81 100644 --- a/BeWoPlanerMobil/Service/MobileSessionFacade.cs +++ b/BeWoPlanerMobil/Service/MobileSessionFacade.cs @@ -6,8 +6,7 @@ using BeWo.Data.Entities; using BeWo.Service.DCEntityMapper; using BeWo.Service.ServiceContracts; using BeWo.Service.ServiceImplementations; - - +using BeWoPlanerMobil.Util; using BS.Shared; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; @@ -43,52 +42,85 @@ namespace BeWoPlanerMobil.Service public IReportService ReportService { get; } public IQueryService QueryService { get; } - public static ApplicationUser LoggedInUser + public static long? LoggedInUserOid { - get => HttpContext.Current.Session["apuser"] as ApplicationUser; + get => HttpContext.Current.Session["LoggedInUserOid"] as long?; - set => HttpContext.Current.Session["apuser"] = value; + set => HttpContext.Current.Session["LoggedInUserOid"] = value; } - public static string EmployeeFullname => LoggedInUser != null ? LoggedInUser.Employee.Person.FirstNameLastName : string.Empty; + //public static UserDC LoggedInUser + //{ + // get => HttpContext.Current.Session["apuser"] as UserDC; - public static EmployeeDC LoggedInEmployee => LoggedInUser == null ? null : MapperFactory.EmployeeDC_Employee.MapToNewDC(LoggedInUser.Employee); + // set => HttpContext.Current.Session["apuser"] = value; + //} - public static CompactEmployeeDC LoggedInCompactEmployee => LoggedInUser == null ? null : MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(LoggedInUser.Employee); + //public static EmployeeDC LoggedInEmployee + //{ + // get => HttpContext.Current.Session["LoggedInEmployee"] as EmployeeDC; - public static UserDC LoggedInUserDC => LoggedInUser == null ? null : MapperFactory.UserDC_User.MapToNewDC(LoggedInUser); + // set => HttpContext.Current.Session["LoggedInEmployee"] = value; + //} - public static List UserSettings => LoggedInUserDC.Settings; + //public static string EmployeeFullname => LoggedInUser != null ? LoggedInUser.Employee.FirstNameLastName : string.Empty; - public static string Tenant + // public static CompactEmployeeDC LoggedInCompactEmployee => LoggedInUser == null ? null : LoggedInUser.Employee; + + + // public static List UserSettings => LoggedInUser.Settings; + public static string LocalStorageKey => LoggedInUserOid.HasValue ? $"bwp_{MobileSessionFacade.Tenant}_{LoggedInUserOid}" : null; + + public static string EmployeeFullname + { + get => HttpContext.Current.Session["EmployeeFullname"] as string; + + set => HttpContext.Current.Session["EmployeeFullname"] = value; + } + + public static string Tenant { get => HttpContext.Current.Session["tenant"] as string; set => HttpContext.Current.Session["tenant"] = value; } - public static MandatorDC Mandator + public static string TimeOfLastAction { - get => HttpContext.Current.Session["mandator"] as MandatorDC; + get => HttpContext.Current.Session["TimeOfLastAction"] as string; - set => HttpContext.Current.Session["mandator"] = value; + set => HttpContext.Current.Session["TimeOfLastAction"] = value; } - public static bool IsUserLoggedIn() + //public long? MandatorOid + //{ + // get => HttpContext.Current.Session["MandatorOid"] as long?; + + // set => HttpContext.Current.Session["MandatorOid"] = value; + //} + + public static MokMandator Mandator + { + get => HttpContext.Current.Session["mandator"] as MokMandator; + + set => HttpContext.Current.Session["mandator"] = value; + } + + public static bool IsUserLoggedIn() { - return LoggedInUser != null; + return LoggedInUserOid.HasValue; } public static void LogUserOut() { - HttpContext.Current.Session["apuser"] = null; + HttpContext.Current.Session["LoggedInUserOid"] = null; HttpContext.Current.Session.Abandon(); } - public static bool CheckForUserRight(UserRightType userRightType) - { - return LoggedInUser != null && LoggedInUser.UserGroups.Any(ug => ug.Rights.Any(rr => rr.RightType.Equals(userRightType))); - } + //public static bool CheckForUserRight(UserRightType userRightType) + //{ + // return LoggedInUser != null && LoggedInUser.UserGroups.Any(ug => ug.Rights.Any(rr => rr.Equals(userRightType))); + //} public static string CookieName => "tenantKeks"; diff --git a/BeWoPlanerMobil/TestWebService.asmx.cs b/BeWoPlanerMobil/TestWebService.asmx.cs index a525c42a9..59ab24675 100644 --- a/BeWoPlanerMobil/TestWebService.asmx.cs +++ b/BeWoPlanerMobil/TestWebService.asmx.cs @@ -7,6 +7,7 @@ using System.Xml; using System.Xml.Serialization; using BeWo.Data; using BeWo.Data.Access; +using BeWo.Service.DCEntityMapper; using BeWo.Service.ServiceContracts; using BeWo.Service.ServiceImplementations; using BeWoPlanerMobil.Service; @@ -50,7 +51,8 @@ namespace BeWoPlanerMobil } else { - MobileSessionFacade.LoggedInUser = user; + MobileSessionFacade.LoggedInUserOid = user.Oid; + MobileSessionFacade.EmployeeFullname = user.Employee.Person.FirstNameLastName; result = true; } diff --git a/BeWoPlanerMobil/Util/AppointmentListItem.cs b/BeWoPlanerMobil/Util/AppointmentListItem.cs index 13e83b48d..25e33d4ac 100644 --- a/BeWoPlanerMobil/Util/AppointmentListItem.cs +++ b/BeWoPlanerMobil/Util/AppointmentListItem.cs @@ -11,7 +11,7 @@ namespace BeWoPlanerMobil.Util { public class AppointmentListItem { - public Guid Identifier { get; private set; } + public String Identifier { get; } public long? Oid { get; } @@ -71,20 +71,9 @@ namespace BeWoPlanerMobil.Util public SchedulerAppointmentDC SchedulerAppointment { get; } - public void GenerateIdentifier(List existingIdentifiers) + public AppointmentListItem(String id, SchedulerAppointmentDC schedulerAppointment) { - var identifier = Guid.NewGuid(); - while(existingIdentifiers.Contains(identifier)) - { - identifier = Guid.NewGuid(); - } - - Identifier = identifier; - } - - public AppointmentListItem(SchedulerAppointmentDC schedulerAppointment) - { - Identifier = Guid.NewGuid(); + Identifier = id; Subject = schedulerAppointment.Subject; diff --git a/BeWoPlanerMobil/Util/DcToMokMapper.cs b/BeWoPlanerMobil/Util/DcToMokMapper.cs new file mode 100644 index 000000000..a4a98b8d9 --- /dev/null +++ b/BeWoPlanerMobil/Util/DcToMokMapper.cs @@ -0,0 +1,23 @@ +using BS.Shared.DataContracts; +using BS.Shared.DataContracts.Compact; +using BS.Shared.DataContracts.Invoicing; +using System; +using System.Runtime.Serialization; +using System.Windows.Media; + +namespace BeWoPlanerMobil.Util +{ + + public class DcToMokMapper + { + public static MokMandator CreateMandator(MandatorDC dc) + { + return new MokMandator + { + Settings = dc.Settings + }; + + } + + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Util/FormCollectionConstants.cs b/BeWoPlanerMobil/Util/FormCollectionConstants.cs index 75a22d8fe..105aa8286 100644 --- a/BeWoPlanerMobil/Util/FormCollectionConstants.cs +++ b/BeWoPlanerMobil/Util/FormCollectionConstants.cs @@ -56,22 +56,22 @@ public static string ServiceRecordOidForSignature => "ServiceRecordOidForSignature"; } - public class ModelSessionConstants - { - public static string ReportModelKey => "ReportModel"; - public static string CustomerModelKey => "CustomerModelModel"; - public static string SchedulerModelKey => "SchedulerModel"; - public static string MainModelKey => "MainModel"; - public static string DevelopmentModelKey => "DevelopmentModel"; - public static string DevExpressReportModelKey => "DevExpressReportModel"; - public static string ReportViewerModelKey => "ReportViewerModel"; - public static string DebuggingToolsModelKey => "DebuggingToolsModel"; - } + //public class ModelSessionConstants + //{ + // public static string ReportModelKey => "ReportModel"; + // public static string CustomerModelKey => "CustomerModelModel"; + // public static string SchedulerModelKey => "SchedulerModel"; + // public static string MainModelKey => "MainModel"; + // public static string DevelopmentModelKey => "DevelopmentModel"; + // public static string DevExpressReportModelKey => "DevExpressReportModel"; + // public static string ReportViewerModelKey => "ReportViewerModel"; + // public static string DebuggingToolsModelKey => "DebuggingToolsModel"; + //} public class TempDataConstants { public static string ShowSignatureSuggestionPopup => "ShowSignatureSuggestionPopup"; - public static string AppointmentListItemKey => "AppointmentListItem"; + public static string AppointmentOidKey => "AppointmentOid"; public static string IsInTransferModeKey => "IsInTransferMode"; public static string AfterValidationStateKey => "AfterValidation"; public static string PwChErrKey => "passwd-change-error"; diff --git a/BeWoPlanerMobil/Util/MokMandator.cs b/BeWoPlanerMobil/Util/MokMandator.cs new file mode 100644 index 000000000..4c83b614e --- /dev/null +++ b/BeWoPlanerMobil/Util/MokMandator.cs @@ -0,0 +1,37 @@ +using BS.Shared.DataContracts.Compact; +using BS.Shared.DataContracts.Invoicing; +using System; +using System.Runtime.Serialization; +using System.Windows.Media; + +namespace BeWoPlanerMobil.Util +{ + [Serializable] + public class MokMandator + { + //public long BeWoClientType { get; set; } + //public string ClientId { get; set; } + //public string Country { get; set; } + //public long? MandatorOid { get; set; } + //public long? MandatorVersion { get; set; } + //public string Name { get; set; } + //public string Website { get; set; } + //public string PostalCode { get; set; } + public string Settings { get; set; } + //public string State { get; set; } + //public string Street { get; set; } + //public string Town { get; set; } + //public string RssFeedUrl { get; set; } + //public string SupportToolUrl { get; set; } + //public bool IsSchedulerAllowed { get; set; } + //public bool IsMedicationAllowed { get; set; } + //public bool AllowSbd { get; set; } + //public string Apikey { get; set; } + //public string IKLeistungserbringer { get; set; } + //public bool CanEditIKLeistungserbringer { get; set; } + //public string ColorWaitTooLong { get; set; } + //public string ColorSendUrbelege { get; set; } + //public bool ShowGkvBzEinzel { get; set; } + //public bool ShowGkvBzUrbelege { get; set; } + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Util/MokSettings.cs b/BeWoPlanerMobil/Util/MokSettings.cs new file mode 100644 index 000000000..6170e837b --- /dev/null +++ b/BeWoPlanerMobil/Util/MokSettings.cs @@ -0,0 +1,13 @@ +using BS.Shared.Core; + +namespace BeWoPlanerMobil.Util +{ + public class MokSettings + { + public int SupportConceptExpirationLimitInMonths { get; set; } + public int AnzTageZeiterfassErfolgt { get; set; } + public int MaxDaysEditServiceRecordsAllowed { get; set; } + public int ServiceRecordAllowChangeHours { get; set; } + public int TimeUntilUILock { get; set; } + } +} diff --git a/BeWoPlanerMobil/Util/NullableDateTimeSpan.cs b/BeWoPlanerMobil/Util/NullableDateTimeSpan.cs index 2accc5f16..9a0446537 100644 --- a/BeWoPlanerMobil/Util/NullableDateTimeSpan.cs +++ b/BeWoPlanerMobil/Util/NullableDateTimeSpan.cs @@ -4,6 +4,7 @@ using System.Diagnostics; namespace BeWoPlanerMobil.Util { [DebuggerDisplay("{StartDate} - {EndDate}")] + [Serializable] public class NullableDateTimeSpan { public DateTime? StartDate { get; set; } diff --git a/BeWoPlanerMobil/Util/ReportUtils/QuittierungsbelegsReportSettings.cs b/BeWoPlanerMobil/Util/ReportUtils/QuittierungsbelegsReportSettings.cs new file mode 100644 index 000000000..dc64e829f --- /dev/null +++ b/BeWoPlanerMobil/Util/ReportUtils/QuittierungsbelegsReportSettings.cs @@ -0,0 +1,20 @@ +using BS.Shared; +using System; + +namespace BeWoPlanerMobil.Util.ReportUtils +{ + [Serializable] + public class QuittierungsbelegsReportSettings + { + public int Year { get; set; } + public int Month { get; set; } + public int StartDay { get; set; } + public int EndDay { get; set; } + public long? CustomerOid { get; internal set; } + public long? TeamOid { get; internal set; } + public long? EmployeeOid { get; internal set; } + public long? OrganisationOid { get; internal set; } + public long? ServiceCategoryOid { get; internal set; } + public QBFilterEnum FilterEnum { get; internal set; } + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Views/Customer/Customer.cshtml b/BeWoPlanerMobil/Views/Customer/Customer.cshtml index 69d9b24fd..a5c000378 100644 --- a/BeWoPlanerMobil/Views/Customer/Customer.cshtml +++ b/BeWoPlanerMobil/Views/Customer/Customer.cshtml @@ -145,7 +145,7 @@
- @if(AbstractModel.IsAllowedToSeeCustomerFilter) + @if(Model.IsAllowedToSeeCustomerFilter) {
@using(Html.BeginForm("SetCustomerFilter", "Customer", FormMethod.Post)) @@ -188,7 +188,7 @@
@using(Html.BeginForm("UpdateCustomer", "Customer", FormMethod.Post, new { id = "stammdaten-form", @class = "needs-validation", novalidate = "novalidate" })) { - var inputDisabled = !AbstractModel.HasRightToEditCustomers ? "disabled" : string.Empty; + var inputDisabled = !Model.HasRightToEditCustomers ? "disabled" : string.Empty;
@@ -519,7 +519,7 @@
- @if(AbstractModel.HasRightToEditCustomers) + @if(Model.HasRightToEditCustomers) {
@@ -808,7 +808,7 @@ } @* ----- Dokumente ----- *@ - if(AbstractModel.HasRightToViewCustomerDocuments) + if(Model.HasRightToViewCustomerDocuments) {
@@ -832,11 +832,10 @@
} - @* ----- Medikamentenliste ----- *@ - if(AbstractModel.IsAllowedToSeeMedikamentenliste) - { + if (Model.IsAllowedToSeeMedikamentenliste && Model.SelectedCustomer.Medikamentenverordnungslisten.Any()) + {
@@ -859,7 +858,7 @@ } @* ----- Diagnosen ----- *@ - if(AbstractModel.HasRightToViewDiagnosen && (Model.SelectedJsonCustomer.HasDiagnosen || Model.SelectedJsonCustomer.HasDisabilities || Model.SelectedJsonCustomer.HasSchwebi)) + if(Model.HasRightToViewDiagnosen && (Model.SelectedJsonCustomer.HasDiagnosen || Model.SelectedJsonCustomer.HasDisabilities || Model.SelectedJsonCustomer.HasSchwebi)) {
@@ -989,9 +988,9 @@ } - var isRelatedCustomer = Model.SelectedCustomerOid.HasValue && Model.Employee.RelatedCustomers.Any(cer => cer.Customer.CustomerOid.Equals(Model.SelectedCustomerOid.Value)); + var isRelatedCustomer = Model.SelectedCustomerOid.HasValue && Model.LoggedInEmployee.RelatedCustomers.Any(cer => cer.Customer.CustomerOid.Equals(Model.SelectedCustomerOid.Value)); - var isAllowedToViewBargeldkassen = AbstractModel.HasRightToViewAllCustomersBargeldkassen || (isRelatedCustomer && AbstractModel.HasRightToViewOwnCustomersBargeldkassen); + var isAllowedToViewBargeldkassen = Model.HasRightToViewAllCustomersBargeldkassen || (isRelatedCustomer && Model.HasRightToViewOwnCustomersBargeldkassen); @* ----- Bargeldverwaltung ----- *@ @@ -1021,7 +1020,7 @@ } @* ----- Abwesenheiten ----- *@ - if(AbstractModel.HasRightToViewCustomerAbsenceTimes) + if(Model.HasRightToViewCustomerAbsenceTimes) {
@@ -1054,7 +1053,7 @@ var hasRelatedEmployees = Model.SelectedCustomer?.RelatedEmployees.Any() ?? false; var hasRelatedTeams = Model.SelectedCustomer?.RelatedTeams.Any() ?? false; - if(AbstractModel.HasRightToViewBetreuung && (hasRelatedEmployees || hasRelatedTeams)) + if(Model.HasRightToViewBetreuung && (hasRelatedEmployees || hasRelatedTeams)) {
@@ -1081,7 +1080,7 @@ }
-@if(AbstractModel.HasRightToViewCustomerAbsenceTimes) +@if(Model.HasRightToViewCustomerAbsenceTimes) { - @Html.DropDownListFor(m => m.SelectedAbsenceReason, Model.AbsenceReasonItems, new { @class = "custom-select", Id = "absence-reason-select", Name = "customer-absence-time-category" }) + @Html.DropDownListFor(m => m.SelectedAbsenceReasonOid, Model.AbsenceReasonItems, new { @class = "custom-select", Id = "absence-reason-select", Name = "customer-absence-time-category" })
diff --git a/BeWoPlanerMobil/Views/Customer/CustomerBargeldkassen.cshtml b/BeWoPlanerMobil/Views/Customer/CustomerBargeldkassen.cshtml index 22e524b70..0f51657a3 100644 --- a/BeWoPlanerMobil/Views/Customer/CustomerBargeldkassen.cshtml +++ b/BeWoPlanerMobil/Views/Customer/CustomerBargeldkassen.cshtml @@ -666,7 +666,7 @@ } -@if(AbstractModel.HasRightToCreateCustomerBargeldkassen || AbstractModel.HasRightToEditCustomerBargeldkassen) +@if(Model.HasRightToCreateCustomerBargeldkassen || Model.HasRightToEditCustomerBargeldkassen) {