diff --git a/BeWo/View/Detail/Report/DienstplanerView.xaml.cs b/BeWo/View/Detail/Report/DienstplanerView.xaml.cs index 9dd9300b0..96fd993d0 100644 --- a/BeWo/View/Detail/Report/DienstplanerView.xaml.cs +++ b/BeWo/View/Detail/Report/DienstplanerView.xaml.cs @@ -43,14 +43,6 @@ namespace BeWo.View.Detail.Report { private DienstplanerRootDC _DienstplanerRootObj; - //private List _Wohnheime; - //private List _DienstDCListe; - //private List _DienstEintragListe; - //private List _AlleDienste; - //private List _AlleDienstEintraege; - //private List _AlleDienstvertretungen; - //private List _Feiertage; - private GridColumn _ColumnEmp; private List _ColumnDays; private GridColumn _ColumnMonth; @@ -1419,7 +1411,19 @@ namespace BeWo.View.Detail.Report + "/ReportView.aspx" + "?type=" + Utils.EnumName(ReportTypes.RosterReport) + "&wid=" + wOid - + "&dt=" + date.ToString("MM.yyyy"); + + "&dt=" + date.ToString("MM.yyyy") + + "&ft="; + + + List tage = new List(); + + foreach (var feiertag in _DienstplanerRootObj.Feiertage) + { + if (feiertag.Datum.Month == date.Month) + tage.Add(feiertag.Datum.Day); + } + + url += string.Join(";", tage); linkPdfExport.NavigateUri = new Uri(url); } diff --git a/Host/ReportView.aspx.cs b/Host/ReportView.aspx.cs index d5d4cfc40..e32d4ffc4 100644 --- a/Host/ReportView.aspx.cs +++ b/Host/ReportView.aspx.cs @@ -699,8 +699,12 @@ namespace Host { DateTime dt = DateTime.ParseExact(Request.Params["dt"], "MM.yyyy", CultureInfo.InvariantCulture); long wOid = int.Parse(Request.Params["wid"]); + + List feiertage = new List(); - return reportCreator.CreateRosterReport(wOid, dt); + if (Request.Params["ft"] != null) + feiertage = Request.Params["ft"].Split(';').Select(int.Parse).ToList(); + return reportCreator.CreateRosterReport(wOid, dt, feiertage); } private XtraReport CreateVorlagenReport() diff --git a/Report/AbstractReportCreator.cs b/Report/AbstractReportCreator.cs index f0e3f14de..2fc33e589 100644 --- a/Report/AbstractReportCreator.cs +++ b/Report/AbstractReportCreator.cs @@ -81,7 +81,7 @@ namespace BeWo.Report public abstract XtraReport CreateAbsenceReport(DateTime dt, List abs, List empTypes, List teams, List feiertage); - public abstract XtraReport CreateRosterReport(long wOid, DateTime dt); + public abstract XtraReport CreateRosterReport(long wOid, DateTime dt, List feiertage); public abstract XtraReport CreateKilometerauswertung(long customerOid, DateTime rangeDate); diff --git a/Report/DefaultReportCreator.cs b/Report/DefaultReportCreator.cs index f041772d9..e623e1ea8 100644 --- a/Report/DefaultReportCreator.cs +++ b/Report/DefaultReportCreator.cs @@ -959,7 +959,7 @@ namespace BeWo.Report return report as XtraReport; } - public override XtraReport CreateRosterReport(long wOid, DateTime dt) + public override XtraReport CreateRosterReport(long wOid, DateTime dt, List feiertage) { var service = new OperationsServiceImp(); var service2 = new CustomerServiceImp(); @@ -984,7 +984,7 @@ namespace BeWo.Report //report.SetReportDataSource(RosterRO.Create(service.GetDienstEintraege(wOid, dt.Year, dt.Month), service.GetAllDienste(), service2.GetAllActiveWohnheimeCompact().First(x => x.WohnheimOid == wOid), dt.Year, dt.Month)); report.SetReportDataSource(RosterRO.CreateNew(dienstEintraege, vertretungen, employee, - service.GetAllDienste(), service2.GetAllActiveWohnheimeCompact().First(x => x.WohnheimOid == wOid), dt.Year, dt.Month)); + service.GetAllDienste(), service2.GetAllActiveWohnheimeCompact().First(x => x.WohnheimOid == wOid), dt.Year, dt.Month, feiertage)); return report as XtraReport; } diff --git a/Report/DefaultReports/RosterReport.cs b/Report/DefaultReports/RosterReport.cs index 470099673..4c9eb821e 100644 --- a/Report/DefaultReports/RosterReport.cs +++ b/Report/DefaultReports/RosterReport.cs @@ -23,9 +23,15 @@ namespace BeWo.Report.DefaultReports public Tuple Month { get; set; } public DateTime monthAndYear { get; set; } + public int Modifier { get; set; } + public int LastIndex { get; set; } + public bool LastCellWasWo { get; set; } + public List Feiertage { get; set; } public RosterReport() { + Modifier = 0; + LastCellWasWo = false; InitializeComponent(); InitializeComponent2(); } @@ -34,6 +40,7 @@ namespace BeWo.Report.DefaultReports { int days = DateTime.DaysInMonth(pRO.ReportDateTime.Year, pRO.ReportDateTime.Month); monthAndYear = new DateTime(pRO.ReportDateTime.Year, pRO.ReportDateTime.Month, 1); + Feiertage = pRO.Feiertage; Table1.BeginInit(); Table2.BeginInit(); @@ -69,7 +76,6 @@ namespace BeWo.Report.DefaultReports SetWeekDayNames(monthAndYear.Year, monthAndYear.Month, DateTime.DaysInMonth(monthAndYear.Year, monthAndYear.Month)); - bindingSource1.DataSource = pRO; List dienste = new List(); @@ -131,17 +137,7 @@ namespace BeWo.Report.DefaultReports } } - private void SetWeekDayNames(int year, int month, int numberOfDays) - { - for (int i = 1; i <= numberOfDays; i++) - { - DateTime date = new DateTime(year, month, i); - CultureInfo c = new CultureInfo("de-DE"); - string weekday = c.DateTimeFormat.GetAbbreviatedDayName(date.DayOfWeek); - - Table1.Rows[0].Cells[i].Text += "\n" + weekday; - } - } + private string AdaptTime(TimeSpan start, TimeSpan ende) { @@ -201,7 +197,7 @@ namespace BeWo.Report.DefaultReports - var empColumn = CreateColumn(0x0D, "Mitarbeiter", 0.5, false); + var empColumn = CreateColumn(0x0D, "Mitarbeiter", 0.33, false); empColumn.Item2.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, "RosterReportRows.Title")}); @@ -210,7 +206,7 @@ namespace BeWo.Report.DefaultReports Days = new Tuple[31]; for (int i = 0; i < Days.Length; i++) { - var dayColumn = CreateColumn(0x0C, $"{i + 1}.", 0.08, false); + var dayColumn = CreateColumn(0x0C, $"{i + 1}.", 0.10, false); monthAndYear = new DateTime(monthAndYear.Year, monthAndYear.Month, i + 1); dayColumn.Item2.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, $"RosterReportRows.Day{ i + 1 }") }); dayColumn.Item2.EvaluateBinding += new DevExpress.XtraReports.UI.BindingEventHandler(this.Cell_EvaluateBinding); @@ -220,7 +216,7 @@ namespace BeWo.Report.DefaultReports Weeks = new Tuple[6]; for (int i = 0; i < Weeks.Length; i++) { - var weekColumns = CreateColumn(0x0C, "Wo.", 0.16, false); + var weekColumns = CreateColumn(0x0C, "Wo.", 0.10, false); weekColumns.Item2.DataBindings.AddRange(new DevExpress.XtraReports.UI.XRBinding[] { new DevExpress.XtraReports.UI.XRBinding("Text", null, $"RosterReportRows.Week{ i + 1 }", "{0:F2}")}); weekColumns.Item2.EvaluateBinding += new DevExpress.XtraReports.UI.BindingEventHandler(this.Cell_EvaluateBinding); @@ -279,18 +275,87 @@ namespace BeWo.Report.DefaultReports { cell.BackColor = Color.Transparent; cell.ForeColor = Color.Black; - if (cell.Index <= DateTime.DaysInMonth(monthAndYear.Year, monthAndYear.Month)) + + var index = cell.Index; + + if (Table1.Rows[0].Cells[index].Text.Contains("Wo")) // Damit mal versuchen..int index = cell.Index; { - DateTime date = new DateTime(monthAndYear.Year, monthAndYear.Month, cell.Index); - if (date.DayOfWeek == DayOfWeek.Sunday) - cell.BackColor = Color.LightPink; - //else if (Feiertage != null) - //{ - // if (Feiertage.Contains(date.Day)) - // cell.BackColor = Color.LightPink; - //} + LastCellWasWo = true; + return; + } + if (LastCellWasWo) + { + cell.Row.Cells[index].BackColor = Color.LightPink; + LastCellWasWo = false; + } + else if (Feiertage != null) + { + if (Feiertage.Count > 0) + { + var header = Table1.Rows[0].Cells[index].Text; + int tag = 0; + if (header.Length == 4) + { + tag = int.Parse(header.Remove(2, 2)); + } + else + { + tag = int.Parse(header.Remove(1, 2)); + } + + foreach (var feiertag in Feiertage) + { + if (tag == feiertag) + cell.Row.Cells[index].BackColor = Color.LightPink; + + } + } + } + + + //if (index > LastIndex) + // Modifier = 0; + + //if (index <= DateTime.DaysInMonth(monthAndYear.Year, monthAndYear.Month)) + //{ + // DateTime date = new DateTime(monthAndYear.Year, monthAndYear.Month, index); + + // if (date.DayOfWeek == DayOfWeek.Sunday) + // { + // cell.Row.Cells[index].BackColor = Color.LightPink; + // Modifier++; + // } + // LastIndex = index; + + //else if (Feiertage != null) + //{ + // if (Feiertage.Contains(date.Day)) + // cell.BackColor = Color.LightPink; + //} + //} + } + } + private void SetWeekDayNames(int year, int month, int numberOfDays) + { + int skipper = 0; + for (int i = 1; i <= numberOfDays; i++) + { + if (!Table1.Rows[0].Cells[i + skipper].Text.Contains("Wo")) + { + DateTime date = new DateTime(year, month, i); + CultureInfo c = new CultureInfo("de-DE"); + string weekday = c.DateTimeFormat.GetAbbreviatedDayName(date.DayOfWeek); + weekday = weekday.Remove(weekday.Length - 1, 1); + + Table1.Rows[0].Cells[i + skipper].Text += weekday; + } + else + { + skipper++; + i--; } } + } private System.Windows.Media.Color TransformStringToColor(string colorString) diff --git a/Report/Report.csproj b/Report/Report.csproj index b6ccef6bd..626c4c552 100644 --- a/Report/Report.csproj +++ b/Report/Report.csproj @@ -431,7 +431,6 @@ ServicesOverviewReport.cs - diff --git a/Report/ReportObjects/RosterRO.cs b/Report/ReportObjects/RosterRO.cs index a9df396af..8ad6df7fb 100644 --- a/Report/ReportObjects/RosterRO.cs +++ b/Report/ReportObjects/RosterRO.cs @@ -14,6 +14,7 @@ namespace BeWo.Report.ReportObjects public string WohnheimName { get; set; } public List RosterReportRows { get; set; } public int FirstWeekDay { get; set; } + public List Feiertage { get; set; } public RosterRO() { @@ -82,7 +83,7 @@ namespace BeWo.Report.ReportObjects return res; } - public static RosterRO CreateNew(List dienstEintragDCs, List dienstvertretungDCs, List employee, List dienstInfoDCs, BS.Shared.DataContracts.Compact.CompactWohnheimDC compactWohnheimDC, int year, int month) + public static RosterRO CreateNew(List dienstEintragDCs, List dienstvertretungDCs, List employee, List dienstInfoDCs, BS.Shared.DataContracts.Compact.CompactWohnheimDC compactWohnheimDC, int year, int month, List feiertage) { var dt = new DateTime(year, month, 1); // Result @@ -90,7 +91,8 @@ namespace BeWo.Report.ReportObjects { WohnheimName = compactWohnheimDC.WohnheimName, ReportDateTime = dt, - FirstWeekDay = ((int)dt.DayOfWeek - 1) % 7 + FirstWeekDay = ((int)dt.DayOfWeek - 1) % 7, + Feiertage = feiertage }; // WD V F Formel // Mo 1 0 (tag - 1) / 7