From ca367fe894c6f9bf1b531417cb53f564cb80f29f Mon Sep 17 00:00:00 2001 From: HirschleM Date: Fri, 31 Jul 2026 13:18:04 +0200 Subject: [PATCH] =?UTF-8?q?MH:=20JusinaJugendhilfe=20T=C3=A4tigkeitsnachwe?= =?UTF-8?q?is=20verbessertt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reporting/CustomReportCreator.cs | 154 ++++++++++++++---- .../Reporting/Taetigkeitsnachweis.Designer.cs | 125 +++++++++----- .../Reporting/Taetigkeitsnachweis.cs | 36 ++++ 3 files changed, 242 insertions(+), 73 deletions(-) diff --git a/ReportImp/JusinaJugendhilfe/Reporting/CustomReportCreator.cs b/ReportImp/JusinaJugendhilfe/Reporting/CustomReportCreator.cs index c759a8edf..6cdffbdb6 100644 --- a/ReportImp/JusinaJugendhilfe/Reporting/CustomReportCreator.cs +++ b/ReportImp/JusinaJugendhilfe/Reporting/CustomReportCreator.cs @@ -23,20 +23,14 @@ namespace JusinaJugendhilfe.Reporting //List lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay); List lROs = Create(month, year, orgaOid, empOid, startDay, endDay, serviceCategoryOid); - if (lROs.Count > 0) + // Claude: Ein RO kann mehrere Reports liefern (je Mitarbeiter ein Tätigkeitsnachweis), daher flache Liste sammeln und danach zusammenführen + var reports = new List(); + foreach (var ro in lROs) { - var rootReport = CreateServicesOverviewReportForRo(lROs[0], serviceCategoryOid); - rootReport.CreateDocument(); - for (int i = 1; i < lROs.Count; i++) - { - var lNext = CreateServicesOverviewReportForRo(lROs[i], serviceCategoryOid); - lNext.CreateDocument(); - rootReport.Pages.AddRange(lNext.Pages); - } - - return rootReport; + reports.AddRange(CreateServicesOverviewReportsForRo(ro, serviceCategoryOid)); } - return new XtraReport(); + + return MergeReports(reports); } private List Create(int pMonth, int pYear, long orgaOid, long empOid, int startDay, int endDay, long? serviceCategoryOid = null) @@ -124,43 +118,133 @@ namespace JusinaJugendhilfe.Reporting } } - if (roList.Count > 0) + // Claude: Ein RO kann mehrere Reports liefern (je Mitarbeiter ein Tätigkeitsnachweis), daher flache Liste sammeln und danach zusammenführen + var reports = new List(); + foreach (var ro in roList) { - var rootReport = CreateServicesOverviewReportForRo(roList[0], serviceCategoryOid); - rootReport.CreateDocument(); - for (int i = 1; i < roList.Count; i++) - { - var lNext = CreateServicesOverviewReportForRo(roList[i], serviceCategoryOid); - lNext.CreateDocument(); - rootReport.Pages.AddRange(lNext.Pages); - } - - return rootReport; + reports.AddRange(CreateServicesOverviewReportsForRo(ro, serviceCategoryOid)); } - return new XtraReport(); + + return MergeReports(reports); } public override XtraReport CreateServiceOverviewSingleCustomerReport(long customerOid, int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay) { var ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid); - return CreateServicesOverviewReportForRo(ro, serviceCategoryOid); + + var reports = CreateServicesOverviewReportsForRo(ro, serviceCategoryOid); + + // Claude: Bei nur einem Report unverändertes Verhalten beibehalten (Dokument wird erst vom Aufrufer erzeugt) + if (reports.Count == 1) + { + return reports[0]; + } + + return MergeReports(reports); } - private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid) + private List CreateServicesOverviewReportsForRo(ServicesOverviewRO ro, long? serviceCategoryOid) { - IBeWoReport report = null; + var reports = new List(); if (ro.Costbearer.Contains("Kreis Borken")) { - report = new QuittierungsbelegKreisBorken(); - } - if (report == null) - { - report = new Taetigkeitsnachweis(); - } - report.SetReportDataSource(ro); + IBeWoReport report = new QuittierungsbelegKreisBorken(); + report.SetReportDataSource(ro); + reports.Add(report as XtraReport); - return report as XtraReport; + return reports; + } + + // Claude: Für Stadt Bocholt / Stadt Borken wird je dokumentierendem Mitarbeiter ein eigener Tätigkeitsnachweis erstellt + if (ro.Costbearer.Contains("Stadt Bocholt") || ro.Costbearer.Contains("Stadt Borken")) + { + foreach (var employeeRo in SplitRoByEmployee(ro)) + { + IBeWoReport employeeReport = new Taetigkeitsnachweis(); + employeeReport.SetReportDataSource(employeeRo); + reports.Add(employeeReport as XtraReport); + } + + return reports; + } + + IBeWoReport defaultReport = new Taetigkeitsnachweis(); + defaultReport.SetReportDataSource(ro); + reports.Add(defaultReport as XtraReport); + + return reports; + } + + /// + /// Claude: Zerlegt ein ServicesOverviewRO in je ein RO pro Mitarbeiter, der dokumentiert hat (ServiceDetail.EmployeeOid). + /// + private static List SplitRoByEmployee(ServicesOverviewRO ro) + { + var result = new List(); + + if (ro.Services == null || ro.Services.Count == 0) + { + result.Add(ro); + return result; + } + + var employeeGroups = ro.Services + .GroupBy(s => s.EmployeeOid) + .OrderBy(g => GetEmployeeSortName(g.First())) + .ToList(); + + foreach (var employeeGroup in employeeGroups) + { + var employeeRo = ServicesOverviewRO.CopyFromRO(ro); + employeeRo.Services = employeeGroup.OrderBy(s => s.StartDate).ToList(); + employeeRo.ServicesDouble = ro.ServicesDouble; + employeeRo.FilteredEmployeeOid = employeeGroup.Key; + + var employeeName = employeeGroup.First().EmployeeFullname; + if (!string.IsNullOrWhiteSpace(employeeName)) + { + // Claude: Im Kopf des Tätigkeitsnachweises steht der Mitarbeiter, dessen Leistungen der Beleg enthält + employeeRo.MainAttendant = employeeName; + employeeRo.MainAttendantCommaSeperated = employeeGroup.First().EmployeeNameCommaSeparated; + } + + result.Add(employeeRo); + } + + return result; + } + + private static string GetEmployeeSortName(ServicesOverviewRO.ServiceDetail serviceDetail) + { + if (!string.IsNullOrWhiteSpace(serviceDetail.EmployeeNameCommaSeparated)) + { + return serviceDetail.EmployeeNameCommaSeparated; + } + + return serviceDetail.EmployeeFullname ?? serviceDetail.EmployeeAbbr ?? string.Empty; + } + + /// + /// Claude: Erzeugt die Dokumente aller Reports und hängt sie an den ersten Report an. + /// + private static XtraReport MergeReports(List reports) + { + if (reports.Count == 0) + { + return new XtraReport(); + } + + var rootReport = reports[0]; + rootReport.CreateDocument(); + + for (int i = 1; i < reports.Count; i++) + { + reports[i].CreateDocument(); + rootReport.Pages.AddRange(reports[i].Pages); + } + + return rootReport; } } } diff --git a/ReportImp/JusinaJugendhilfe/Reporting/Taetigkeitsnachweis.Designer.cs b/ReportImp/JusinaJugendhilfe/Reporting/Taetigkeitsnachweis.Designer.cs index ab37701fc..addbf90f7 100644 --- a/ReportImp/JusinaJugendhilfe/Reporting/Taetigkeitsnachweis.Designer.cs +++ b/ReportImp/JusinaJugendhilfe/Reporting/Taetigkeitsnachweis.Designer.cs @@ -29,6 +29,7 @@ namespace JusinaJugendhilfe.Reporting /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Taetigkeitsnachweis)); DevExpress.XtraReports.UI.XRSummary xrSummary1 = new DevExpress.XtraReports.UI.XRSummary(); DevExpress.XtraReports.UI.XRWatermark xrWatermark1 = new DevExpress.XtraReports.UI.XRWatermark(); @@ -60,7 +61,6 @@ namespace JusinaJugendhilfe.Reporting this.xrTableCell28 = new DevExpress.XtraReports.UI.XRTableCell(); this.xrTableCell1 = new DevExpress.XtraReports.UI.XRTableCell(); this.xrTableCell48 = new DevExpress.XtraReports.UI.XRTableCell(); - this.bindingSource1 = new System.Windows.Forms.BindingSource(); this.formattingRuleStartDate = new DevExpress.XtraReports.UI.FormattingRule(); this.ReportHeader = new DevExpress.XtraReports.UI.ReportHeaderBand(); this.xrPictureBox2 = new DevExpress.XtraReports.UI.XRPictureBox(); @@ -82,8 +82,6 @@ namespace JusinaJugendhilfe.Reporting this.xrLabel12 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel9 = new DevExpress.XtraReports.UI.XRLabel(); this.xrLabel1 = new DevExpress.XtraReports.UI.XRLabel(); - this.xrPictureBox1 = new DevExpress.XtraReports.UI.XRPictureBox(); - this.xrLabel17 = new DevExpress.XtraReports.UI.XRLabel(); this.fieldKontaktArt = new DevExpress.XtraReports.UI.CalculatedField(); this.fieldStdBrutto = new DevExpress.XtraReports.UI.CalculatedField(); this.fieldPKontakt = new DevExpress.XtraReports.UI.CalculatedField(); @@ -93,6 +91,12 @@ namespace JusinaJugendhilfe.Reporting this.fieldMed = new DevExpress.XtraReports.UI.CalculatedField(); this.fieldSonstiges = new DevExpress.XtraReports.UI.CalculatedField(); this.fieldDoku = new DevExpress.XtraReports.UI.CalculatedField(); + this.xrPictureBox1 = new DevExpress.XtraReports.UI.XRPictureBox(); + this.xrLabel17 = new DevExpress.XtraReports.UI.XRLabel(); + this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components); + this.lblUnterschriftKlient = new DevExpress.XtraReports.UI.XRLabel(); + this.pbCustomerUnterschrift = new DevExpress.XtraReports.UI.XRPictureBox(); + this.lblCustomerUnterschrift = new DevExpress.XtraReports.UI.XRLabel(); ((System.ComponentModel.ISupportInitialize)(this.xrTable3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.xrTableServiceRecords1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit(); @@ -521,10 +525,6 @@ namespace JusinaJugendhilfe.Reporting this.xrTableCell48.TextAlignment = DevExpress.XtraPrinting.TextAlignment.BottomCenter; this.xrTableCell48.Weight = 1.4690088582907872D; // - // bindingSource1 - // - this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.ServicesOverviewRO); - // // formattingRuleStartDate // this.formattingRuleStartDate.Condition = "[StartDate2] < [StartDate]"; @@ -713,14 +713,17 @@ namespace JusinaJugendhilfe.Reporting // GroupFooter1 // this.GroupFooter1.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] { + this.lblUnterschriftKlient, + this.pbCustomerUnterschrift, + this.lblCustomerUnterschrift, + this.xrPictureBox1, + this.xrLabel17, this.xrLabel6, this.lblUnterschriftMitarbeiter, this.xrLabel12, this.xrLabel9, - this.xrLabel1, - this.xrPictureBox1, - this.xrLabel17}); - this.GroupFooter1.HeightF = 170.8333F; + this.xrLabel1}); + this.GroupFooter1.HeightF = 170.8334F; this.GroupFooter1.KeepTogether = true; this.GroupFooter1.Name = "GroupFooter1"; // @@ -744,10 +747,10 @@ namespace JusinaJugendhilfe.Reporting // this.lblUnterschriftMitarbeiter.Borders = DevExpress.XtraPrinting.BorderSide.Top; this.lblUnterschriftMitarbeiter.Font = new DevExpress.Drawing.DXFont("Arial", 8F); - this.lblUnterschriftMitarbeiter.LocationFloat = new DevExpress.Utils.PointFloat(1.028156F, 115.3333F); + this.lblUnterschriftMitarbeiter.LocationFloat = new DevExpress.Utils.PointFloat(1.028188F, 150.8334F); this.lblUnterschriftMitarbeiter.Name = "lblUnterschriftMitarbeiter"; this.lblUnterschriftMitarbeiter.Padding = new DevExpress.XtraPrinting.PaddingInfo(3, 2, 0, 0, 100F); - this.lblUnterschriftMitarbeiter.SizeF = new System.Drawing.SizeF(336.6944F, 19.99998F); + this.lblUnterschriftMitarbeiter.SizeF = new System.Drawing.SizeF(240.8611F, 19.99998F); this.lblUnterschriftMitarbeiter.StylePriority.UseBackColor = false; this.lblUnterschriftMitarbeiter.StylePriority.UseBorders = false; this.lblUnterschriftMitarbeiter.StylePriority.UseFont = false; @@ -808,29 +811,6 @@ namespace JusinaJugendhilfe.Reporting this.xrLabel1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; this.xrLabel1.TextFormatString = "{0:0.00}"; // - // xrPictureBox1 - // - this.xrPictureBox1.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { - new DevExpress.XtraReports.UI.XRBinding("ImageSource", null, "EmployeeSignature")}); - this.xrPictureBox1.LocationFloat = new DevExpress.Utils.PointFloat(137.329F, 135.3333F); - this.xrPictureBox1.Name = "xrPictureBox1"; - this.xrPictureBox1.Scripts.OnBeforePrint = "xrPictureBox1_BeforePrint"; - this.xrPictureBox1.SizeF = new System.Drawing.SizeF(199.3611F, 35.50002F); - this.xrPictureBox1.Sizing = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage; - // - // xrLabel17 - // - this.xrLabel17.BackColor = System.Drawing.Color.Transparent; - this.xrLabel17.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { - new DevExpress.XtraReports.UI.XRBinding("Text", null, "EmployeeSignatureDate", "{0:dd.MM.yyyy}")}); - this.xrLabel17.LocationFloat = new DevExpress.Utils.PointFloat(0F, 135.3333F); - this.xrLabel17.Name = "xrLabel17"; - this.xrLabel17.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); - this.xrLabel17.SizeF = new System.Drawing.SizeF(136.8289F, 35.50002F); - this.xrLabel17.StylePriority.UseBackColor = false; - this.xrLabel17.StylePriority.UseTextAlignment = false; - this.xrLabel17.TextAlignment = DevExpress.XtraPrinting.TextAlignment.BottomCenter; - // // fieldKontaktArt // this.fieldKontaktArt.DataMember = "Services"; @@ -888,6 +868,72 @@ namespace JusinaJugendhilfe.Reporting this.fieldDoku.Expression = "Iif(Contains([ServiceDescription], \'Dokumentation\'), \'x\', \'\')"; this.fieldDoku.Name = "fieldDoku"; // + // xrPictureBox1 + // + this.xrPictureBox1.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { + new DevExpress.XtraReports.UI.XRBinding("ImageSource", null, "EmployeeSignature")}); + this.xrPictureBox1.LocationFloat = new DevExpress.Utils.PointFloat(71.2039F, 115.3333F); + this.xrPictureBox1.Name = "xrPictureBox1"; + this.xrPictureBox1.Scripts.OnBeforePrint = "xrPictureBox1_BeforePrint"; + this.xrPictureBox1.SizeF = new System.Drawing.SizeF(170.6853F, 35.50002F); + this.xrPictureBox1.Sizing = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage; + // + // xrLabel17 + // + this.xrLabel17.BackColor = System.Drawing.Color.Transparent; + this.xrLabel17.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { + new DevExpress.XtraReports.UI.XRBinding("Text", null, "EmployeeSignatureDate", "{0:dd.MM.yyyy}")}); + this.xrLabel17.LocationFloat = new DevExpress.Utils.PointFloat(0F, 115.3333F); + this.xrLabel17.Name = "xrLabel17"; + this.xrLabel17.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.xrLabel17.SizeF = new System.Drawing.SizeF(71.2039F, 35.50002F); + this.xrLabel17.StylePriority.UseBackColor = false; + this.xrLabel17.StylePriority.UseTextAlignment = false; + this.xrLabel17.TextAlignment = DevExpress.XtraPrinting.TextAlignment.BottomCenter; + // + // bindingSource1 + // + this.bindingSource1.DataSource = typeof(BeWo.Report.ReportObjects.ServicesOverviewRO); + // + // lblUnterschriftKlient + // + this.lblUnterschriftKlient.Borders = DevExpress.XtraPrinting.BorderSide.Top; + this.lblUnterschriftKlient.Font = new DevExpress.Drawing.DXFont("Arial", 8F); + this.lblUnterschriftKlient.LocationFloat = new DevExpress.Utils.PointFloat(394.139F, 150.8334F); + this.lblUnterschriftKlient.Name = "lblUnterschriftKlient"; + this.lblUnterschriftKlient.Padding = new DevExpress.XtraPrinting.PaddingInfo(3, 2, 0, 0, 100F); + this.lblUnterschriftKlient.SizeF = new System.Drawing.SizeF(264.3191F, 20F); + this.lblUnterschriftKlient.StylePriority.UseBackColor = false; + this.lblUnterschriftKlient.StylePriority.UseBorders = false; + this.lblUnterschriftKlient.StylePriority.UseFont = false; + this.lblUnterschriftKlient.StylePriority.UsePadding = false; + this.lblUnterschriftKlient.StylePriority.UseTextAlignment = false; + this.lblUnterschriftKlient.Text = "Datum und Unterschrift Klient/in"; + this.lblUnterschriftKlient.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter; + this.lblUnterschriftKlient.Visible = false; + // + // pbCustomerUnterschrift + // + this.pbCustomerUnterschrift.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { + new DevExpress.XtraReports.UI.XRBinding("ImageSource", null, "CustomerSignature")}); + this.pbCustomerUnterschrift.LocationFloat = new DevExpress.Utils.PointFloat(481.4723F, 115.3333F); + this.pbCustomerUnterschrift.Name = "pbCustomerUnterschrift"; + this.pbCustomerUnterschrift.SizeF = new System.Drawing.SizeF(176.9858F, 35.50002F); + this.pbCustomerUnterschrift.Sizing = DevExpress.XtraPrinting.ImageSizeMode.ZoomImage; + this.pbCustomerUnterschrift.Visible = false; + // + // lblCustomerUnterschrift + // + this.lblCustomerUnterschrift.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { + new DevExpress.XtraReports.UI.XRBinding("Text", null, "CustomerSignatureDate", "{0:dd.MM.yyyy}")}); + this.lblCustomerUnterschrift.LocationFloat = new DevExpress.Utils.PointFloat(394.1389F, 115.3333F); + this.lblCustomerUnterschrift.Name = "lblCustomerUnterschrift"; + this.lblCustomerUnterschrift.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F); + this.lblCustomerUnterschrift.SizeF = new System.Drawing.SizeF(87.33334F, 35.50002F); + this.lblCustomerUnterschrift.StylePriority.UseTextAlignment = false; + this.lblCustomerUnterschrift.TextAlignment = DevExpress.XtraPrinting.TextAlignment.BottomCenter; + this.lblCustomerUnterschrift.Visible = false; + // // Taetigkeitsnachweis // this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { @@ -966,8 +1012,6 @@ namespace JusinaJugendhilfe.Reporting private DevExpress.XtraReports.UI.XRLabel xrLabel1; private DevExpress.XtraReports.UI.XRLabel xrLabel12; private DevExpress.XtraReports.UI.XRLabel lblUnterschriftMitarbeiter; - private DevExpress.XtraReports.UI.XRPictureBox xrPictureBox1; - private DevExpress.XtraReports.UI.XRLabel xrLabel17; private DevExpress.XtraReports.UI.XRTableCell xrTableCell33; private DevExpress.XtraReports.UI.XRTableCell xrTableCell11; private DevExpress.XtraReports.UI.XRTableCell xrTableCell6; @@ -991,5 +1035,10 @@ namespace JusinaJugendhilfe.Reporting private DevExpress.XtraReports.UI.CalculatedField fieldMed; private DevExpress.XtraReports.UI.CalculatedField fieldSonstiges; private DevExpress.XtraReports.UI.CalculatedField fieldDoku; + private DevExpress.XtraReports.UI.XRPictureBox xrPictureBox1; + private DevExpress.XtraReports.UI.XRLabel xrLabel17; + private DevExpress.XtraReports.UI.XRLabel lblUnterschriftKlient; + private DevExpress.XtraReports.UI.XRPictureBox pbCustomerUnterschrift; + private DevExpress.XtraReports.UI.XRLabel lblCustomerUnterschrift; } } diff --git a/ReportImp/JusinaJugendhilfe/Reporting/Taetigkeitsnachweis.cs b/ReportImp/JusinaJugendhilfe/Reporting/Taetigkeitsnachweis.cs index 2d956a847..fae58b9a5 100644 --- a/ReportImp/JusinaJugendhilfe/Reporting/Taetigkeitsnachweis.cs +++ b/ReportImp/JusinaJugendhilfe/Reporting/Taetigkeitsnachweis.cs @@ -22,6 +22,14 @@ namespace JusinaJugendhilfe.Reporting public void SetReportDataSource(ServicesOverviewRO pRO) { _rowCounter = 0; + + if (pRO.Costbearer.Contains("Stadt Bocholt")) + { + pbCustomerUnterschrift.Visible = true; + lblUnterschriftKlient.Visible = true; + lblCustomerUnterschrift.Visible = true; + } + bindingSource1.DataSource = pRO; } @@ -30,5 +38,33 @@ namespace JusinaJugendhilfe.Reporting _rowCounter++; xrTableCell7.Text = _rowCounter.ToString(); } + + private void picSignature_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) + { + XRPictureBox xrBox = sender as XRPictureBox; + //var test = this.GetCurrent + string base64String = xrBox.Tag as string; + if (!String.IsNullOrWhiteSpace(base64String)) + { + var base64Data = Regex.Match(base64String, @"data:image/(?.+?),(?.+)").Groups["data"].Value; + var binData = Convert.FromBase64String(base64Data); + Image img = ByteArrayToImage(binData); + xrBox.Image = Utils.CropImage(img); + } + else + { + xrBox.Image = null; + } + } + + public Image ByteArrayToImage(byte[] byteArrayIn) + { + using (var memoryStream = new MemoryStream(byteArrayIn)) + { + return Image.FromStream(memoryStream); + } + } } + + }