242 lines
8.1 KiB
C#
242 lines
8.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BeWo.Data;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace PassgenauUG
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
public override XtraReport CreateEmployeeHourReport(long? employeeOid, IList<long> teamOids, DateTime startDate, DateTime endDate,
|
|
int ansicht)
|
|
{
|
|
if (ansicht == 0 && teamOids != null && teamOids.Count == 1)
|
|
{
|
|
var oid = teamOids[0];
|
|
|
|
var team = DAOFactory.GenericDAO.LoadByID<Team>(oid);
|
|
if (team.Name.Contains("Schulbegleitung") && team.Name.Contains("Alle"))
|
|
{
|
|
|
|
var report = new TeamstundenkontoSbd();
|
|
|
|
var x = MitarbeiterstundenkontoRO.Create(employeeOid, teamOids, startDate, endDate, null);
|
|
report.SetReportDataSource(x);
|
|
|
|
return report;
|
|
}
|
|
|
|
}
|
|
return base.CreateEmployeeHourReport(employeeOid, teamOids, startDate, endDate, ansicht);
|
|
|
|
}
|
|
|
|
public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
|
|
{
|
|
List<ServicesOverviewRO> lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay);
|
|
|
|
if (lROs.Count > 0)
|
|
{
|
|
|
|
var rootReport = CreateServicesOverviewReportForRo(lROs[0], serviceCategoryOid);
|
|
if (rootReport.Pages.Count == 0)
|
|
{
|
|
rootReport.CreateDocument();
|
|
}
|
|
|
|
for (int i = 1; i < lROs.Count; i++)
|
|
{
|
|
var lNext = CreateServicesOverviewReportForRo(lROs[i], serviceCategoryOid);
|
|
if (lNext.Pages.Count == 0)
|
|
{
|
|
lNext.CreateDocument();
|
|
}
|
|
|
|
rootReport.Pages.AddRange(lNext.Pages);
|
|
}
|
|
|
|
return rootReport;
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
|
|
public override XtraReport CreateServiceOverviewSingleCustomerReport(long customerOid, int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
|
|
{
|
|
if (customerOid == 0)
|
|
{
|
|
return CreateReportForSbdROs(SbdStundenaufstellungRO.Create(customerOid, month, year, orgaOid, empOid, serviceCategoryOid ?? 0, startDay, endDay, false, "niedersachsen"));
|
|
|
|
return CreateSbdLeistungsnachweisForSingleCustomerReport(customerOid, month, year, orgaOid, empOid, serviceCategoryOid ?? 0, startDay, endDay, false, "niedersachsen");
|
|
}
|
|
var ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
|
|
|
|
return CreateServicesOverviewReportForRo(ro, serviceCategoryOid);
|
|
|
|
}
|
|
|
|
private XtraReport CreateReportForSbdROs(IList<SbdStundenaufstellungRO> ros)
|
|
{
|
|
if (ros.Count > 0)
|
|
{
|
|
var lServiceOverviewAllCustomersReport = this.FindReportImp<SbdStundenaufstellungRO>();
|
|
lServiceOverviewAllCustomersReport.SetReportDataSource(ros[0]);
|
|
(lServiceOverviewAllCustomersReport as XtraReport).CreateDocument();
|
|
var Report = lServiceOverviewAllCustomersReport as XtraReport;
|
|
|
|
for (int i = 1; i < ros.Count; i++)
|
|
{
|
|
var ro = ros[i];
|
|
var customer = DAOFactory.GenericDAO.LoadByID<Customer>(ro.CustomerOid);
|
|
|
|
if (HasValidSupportConcept(customer, ro.StartDate))
|
|
{
|
|
|
|
var lNext = FindReportImp<SbdStundenaufstellungRO>();
|
|
lNext.SetReportDataSource(ro);
|
|
(lNext as XtraReport).CreateDocument();
|
|
Report.Pages.AddRange((lNext as XtraReport).Pages);
|
|
}
|
|
}
|
|
|
|
return lServiceOverviewAllCustomersReport as XtraReport;
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
|
|
private bool HasValidSupportConcept(Customer c, DateTime monat)
|
|
{
|
|
foreach (var sc in c.SupportConcepts)
|
|
{
|
|
if (sc.IsActive == ActivationTypeId.Active && sc.StartDate.HasValue && sc.StartDate < monat.AddMonths(1) && sc.EndDate.HasValue && sc.EndDate.Value >= monat)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public override XtraReport CreateReportForServicesOverviewRo(ServicesOverviewRO ro, string reportId)
|
|
{
|
|
return CreateServicesOverviewReportForRo(ro, null);
|
|
}
|
|
|
|
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
|
|
{
|
|
XtraReport report = null;
|
|
|
|
ServicesOverviewRO sbdRo = ServicesOverviewRO.CopyFromRO(ro);
|
|
ServicesOverviewRO sonstigeRo = ServicesOverviewRO.CopyFromRO(ro);
|
|
|
|
if (ro.Services != null)
|
|
{
|
|
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
|
|
{
|
|
ServicesOverviewRO.CreateSignatureString(s);
|
|
|
|
if (s.ServiceCategory.ToLower().Contains("schulassistenz"))
|
|
{
|
|
sbdRo.Services.Add(s);
|
|
}
|
|
else if (!s.ServiceDescription.Contains("Fartkosten") && !s.ServiceDescription.Contains("Fahrtkosten"))
|
|
{
|
|
sonstigeRo.Services.Add(s);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sbdRo.Services.Count > 0)
|
|
{
|
|
var list = CreateSbdRoFromServicesRo(sbdRo);
|
|
|
|
foreach (var sbdStundenaufstellungRo in list)
|
|
{
|
|
report = AddSbdReportToReport<LeistungsnachweisSbd>(report, sbdStundenaufstellungRo);
|
|
}
|
|
}
|
|
|
|
report = AddReportToReport<Leistungsnachweis>(report, sonstigeRo);
|
|
|
|
|
|
//report = AddReportToReport(report, eingliederungshilfe);
|
|
|
|
if (report == null)
|
|
report = new XtraReport();
|
|
return report;
|
|
}
|
|
|
|
private List<SbdStundenaufstellungRO> CreateSbdRoFromServicesRo(ServicesOverviewRO servicesRo)
|
|
{
|
|
|
|
var sbdRos = SbdStundenaufstellungRO.Create(servicesRo.CustomerOid, servicesRo.StartDate.Month, servicesRo.StartDate.Year, 0, 0, 0, servicesRo.StartDate.Day, servicesRo.EndDate.Day, false, "niedersachsen");
|
|
|
|
return sbdRos;
|
|
}
|
|
|
|
|
|
private XtraReport AddReportToReport<T>(XtraReport report, ServicesOverviewRO ro) where T : XtraReport, IBeWoReport<ServicesOverviewRO>, new()
|
|
{
|
|
if (ro.Services.Count > 0)
|
|
{
|
|
if (report == null)
|
|
{
|
|
report = new T();
|
|
((T)report).SetReportDataSource(ro);
|
|
|
|
}
|
|
else
|
|
{
|
|
if (report.Pages.Count == 0)
|
|
{
|
|
report.CreateDocument();
|
|
}
|
|
|
|
XtraReport newReport = new T();
|
|
((T)newReport).SetReportDataSource(ro);
|
|
|
|
newReport.CreateDocument();
|
|
report.Pages.AddRange(newReport.Pages);
|
|
}
|
|
}
|
|
return report;
|
|
}
|
|
|
|
private XtraReport AddSbdReportToReport<T>(XtraReport report, SbdStundenaufstellungRO ro) where T : XtraReport, IBeWoReport<SbdStundenaufstellungRO>, new()
|
|
{
|
|
if (ro.Services.Count > 0)
|
|
{
|
|
if (report == null)
|
|
{
|
|
report = new T();
|
|
((T)report).SetReportDataSource(ro);
|
|
|
|
}
|
|
else
|
|
{
|
|
if (report.Pages.Count == 0)
|
|
{
|
|
report.CreateDocument();
|
|
}
|
|
|
|
XtraReport newReport = new T();
|
|
((T)newReport).SetReportDataSource(ro);
|
|
|
|
newReport.CreateDocument();
|
|
report.Pages.AddRange(newReport.Pages);
|
|
}
|
|
}
|
|
return report;
|
|
}
|
|
}
|
|
}
|