135 lines
4.0 KiB
C#
135 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.ReportObjects;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace AssistenzaReports
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
|
|
{
|
|
List<ServicesOverviewRO> lROs;
|
|
|
|
if (empOid > 0)
|
|
{
|
|
lROs = ServicesOverviewRO.Create(month, year, orgaOid, 0, startDay, endDay, serviceCategoryOid);
|
|
var e = DAOFactory.GenericDAO.LoadByID<Employee>(empOid);
|
|
foreach (var ro in lROs)
|
|
{
|
|
ro.MainAttendant = e.Person.FirstNameLastName;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay);
|
|
}
|
|
|
|
if (lROs.Count > 0)
|
|
{
|
|
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;
|
|
}
|
|
|
|
return new XtraReport();
|
|
}
|
|
|
|
public override XtraReport CreateServiceOverviewReportForCustomers(IList<long> customerOids, int month, int year, long? orgaOid, long? empOid, long? serviceCategoryOid, int startDay, int endDay, bool nurFehlende)
|
|
{
|
|
var roList = new List<ServicesOverviewRO>();
|
|
if (empOid > 0)
|
|
{
|
|
var e = DAOFactory.GenericDAO.LoadByID<Employee>((long)empOid);
|
|
|
|
foreach (var coid in customerOids)
|
|
{
|
|
var ro = ServicesOverviewRO.Create(coid, month, year, true, orgaOid ?? 0, 0, startDay, endDay, serviceCategoryOid);
|
|
if (ro != null)
|
|
{
|
|
ro.MainAttendant = e.Person.FirstNameLastName;
|
|
roList.Add(ro);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (var coid in customerOids)
|
|
{
|
|
var ro = ServicesOverviewRO.Create(coid, month, year, true, orgaOid ?? 0, empOid ?? 0, startDay, endDay, serviceCategoryOid);
|
|
if (ro != null)
|
|
{
|
|
roList.Add(ro);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (roList.Count > 0)
|
|
{
|
|
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;
|
|
}
|
|
|
|
return new XtraReport();
|
|
}
|
|
|
|
|
|
public override XtraReport CreateServiceOverviewSingleCustomerReport(long customerOid, int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
|
|
{
|
|
ServicesOverviewRO ro;
|
|
|
|
if (empOid > 0)
|
|
{
|
|
ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, 0, startDay, endDay, serviceCategoryOid);
|
|
|
|
var e = DAOFactory.GenericDAO.LoadByID<Employee>(empOid);
|
|
ro.MainAttendant = e.Person.FirstNameLastName;
|
|
}
|
|
else
|
|
{
|
|
ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
|
|
}
|
|
|
|
return CreateServicesOverviewReportForRo(ro, serviceCategoryOid);
|
|
}
|
|
|
|
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
|
|
{
|
|
IBeWoReport<ServicesOverviewRO> report = null;
|
|
|
|
// Bei Startdatum ab 1.1.24 Quittierungsbeleg, vorher Stundenzettel (ServicesOverviewReport)
|
|
if (ro.StartDate.Date >= new DateTime(2024, 01, 01))
|
|
report = new Quittierungsbeleg();
|
|
else
|
|
report = new Stundenzettel();
|
|
|
|
report.SetReportDataSource(ro);
|
|
|
|
return report as XtraReport;
|
|
}
|
|
}
|
|
|
|
}
|