267 lines
9.8 KiB
C#
267 lines
9.8 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 AlphaEv
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
public override XtraReport CreateEmployeeHourReport(long? employeeOid, IList<long> teamOids, DateTime startDate, DateTime endDate, int ansicht)
|
|
{
|
|
if (ansicht == 0)
|
|
{
|
|
return base.CreateEmployeeHourReport(employeeOid, teamOids, startDate, endDate, ansicht);
|
|
}
|
|
else
|
|
{
|
|
var report = new MitarbeiterstundenkontoJahr();
|
|
var jahrStart = new DateTime(startDate.Year, 1, 1);
|
|
var ds = new MitarbeiterstundenkontoMonateRO(employeeOid, teamOids, jahrStart, endDate, null);
|
|
report.SetReportDataSource(ds);
|
|
|
|
return report;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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, false, null, true, false);
|
|
List<ServicesOverviewRO> lROs = Create(month, year, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
|
|
|
|
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();
|
|
}
|
|
|
|
private List<ServicesOverviewRO> Create(int pMonth, int pYear, long orgaOid, long empOid, int startDay, int endDay, long? serviceCategoryOid = null)
|
|
{
|
|
var roList = new List<ServicesOverviewRO>();
|
|
|
|
List<long> customerOids = new List<long>();
|
|
|
|
ApplicationUser loggedInUser = null;
|
|
|
|
if (LoggedInUserOperationContextExt.Current != null && LoggedInUserOperationContextExt.Current.User != null)
|
|
{
|
|
loggedInUser = LoggedInUserOperationContextExt.Current.User;
|
|
}
|
|
else
|
|
{
|
|
loggedInUser = SessionFacade.LoggedInUser;
|
|
}
|
|
|
|
if (loggedInUser != null && loggedInUser.Employee != null)
|
|
{
|
|
foreach (var e2c in loggedInUser.Employee.Employee2CustomerList)
|
|
{
|
|
if (e2c.Customer.IsActive == ActivationTypeId.Active)
|
|
{
|
|
foreach (var v2o in e2c.ValueList)
|
|
{
|
|
if (v2o.Entry.Type == ValueListEntryType.StaffRoleType &&
|
|
v2o.Entry.Value.Contains("Hauptbetreuung"))
|
|
{
|
|
if (!customerOids.Contains(e2c.Customer.Oid.Value))
|
|
{
|
|
customerOids.Add(e2c.Customer.Oid.Value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
foreach (var coid in customerOids)
|
|
{
|
|
var ro = ServicesOverviewRO.Create(coid, pMonth, pYear, true, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
|
|
|
|
//ServicesOverviewRO ro = ServicesOverviewRO.Create(customer, pSpan, disableEmptySupportConcepts, orgaOid, empOid, searchServiceRecordsByEndDate, serviceCategoryOid);
|
|
if (ro != null)
|
|
{
|
|
roList.Add(ro);
|
|
}
|
|
}
|
|
|
|
return roList.OrderBy(r => r.CustomerLastName + ", " + r.CustomerFirstName).ToList();
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid)
|
|
{
|
|
XtraReport report = null;
|
|
|
|
ServicesOverviewRO flsRo = CopyFromRO(ro);
|
|
ServicesOverviewRO assiRo = CopyFromRO(ro);
|
|
|
|
if (ro.Services != null)
|
|
{
|
|
foreach (ServicesOverviewRO.ServiceDetail s in ro.Services)
|
|
{
|
|
if (s.IsBillable)
|
|
{
|
|
if (!String.IsNullOrWhiteSpace(s.EmployeeFirstName) && !String.IsNullOrWhiteSpace(s.EmployeeLastName) && s.EmployeeFirstName.Length > 1 && s.EmployeeLastName.Length > 1)
|
|
{
|
|
s.EmployeeAbbr = s.EmployeeFirstName.Substring(0, 2) + s.EmployeeLastName.Substring(0, 2);
|
|
}
|
|
ServicesOverviewRO.CreateSignatureString(s);
|
|
|
|
if (s.ServiceCategory.ToLower().Contains("assistenz"))
|
|
{
|
|
assiRo.Services.Add(s);
|
|
}
|
|
else
|
|
{
|
|
flsRo.Services.Add(s);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
report = AddReportToReport(report, flsRo, false);
|
|
report = AddReportToReport(report, assiRo, true);
|
|
|
|
//report = AddReportToReport(report, eingliederungshilfe);
|
|
|
|
if (report == null)
|
|
report = new XtraReport();
|
|
return report;
|
|
}
|
|
|
|
private ServicesOverviewRO CopyFromRO(ServicesOverviewRO ro)
|
|
{
|
|
ServicesOverviewRO newRo = new ServicesOverviewRO();
|
|
|
|
newRo.StartDate = ro.StartDate;
|
|
newRo.Abwesenheiten = ro.Abwesenheiten;
|
|
newRo.AbsenceTimes = ro.AbsenceTimes;
|
|
newRo.ApprovedEndDate = ro.ApprovedEndDate;
|
|
newRo.ApprovedFLSPerMonth = ro.ApprovedFLSPerMonth;
|
|
newRo.ApprovedFLSPerMonthTotal = ro.ApprovedFLSPerMonthTotal;
|
|
newRo.ApprovedFLSPerWeek = ro.ApprovedFLSPerWeek;
|
|
newRo.ApprovedFLSPerWeekTotal = ro.ApprovedFLSPerWeekTotal;
|
|
newRo.ApprovedFLSTotal = ro.ApprovedFLSTotal;
|
|
newRo.ApprovedStartDate = ro.ApprovedStartDate;
|
|
newRo.ContactEmployee = ro.ContactEmployee;
|
|
newRo.CostBearer2SupportConceptList = ro.CostBearer2SupportConceptList;
|
|
newRo.Costbearer = ro.Costbearer;
|
|
newRo.CustomerBirthday = ro.CustomerBirthday;
|
|
newRo.CustomerLastName = ro.CustomerLastName;
|
|
newRo.CustomerCity = ro.CustomerCity;
|
|
newRo.CustomerFirstName = ro.CustomerFirstName;
|
|
newRo.CustomerName = ro.CustomerName;
|
|
newRo.CustomerPostalCode = ro.CustomerPostalCode;
|
|
newRo.CustomerStreet = ro.CustomerStreet;
|
|
newRo.EndDate = ro.EndDate;
|
|
newRo.FreeMinutesThisMonth = ro.FreeMinutesThisMonth;
|
|
newRo.Month = ro.Month;
|
|
newRo.Year = ro.Year;
|
|
newRo.MainAttendant = ro.MainAttendant;
|
|
newRo.MainAttendantCommaSeperated = ro.MainAttendantCommaSeperated;
|
|
newRo.ReferenceNumber = ro.ReferenceNumber;
|
|
newRo.TotalFLMBillable = ro.TotalFLMBillable;
|
|
newRo.TotalFLM = ro.TotalFLM;
|
|
newRo.TotalFLMQualified = ro.TotalFLMQualified;
|
|
newRo.TotalFLMUnqualified = ro.TotalFLMUnqualified;
|
|
newRo.TotalFLS = ro.TotalFLS;
|
|
newRo.TotalFLSQualified = ro.TotalFLSQualified;
|
|
newRo.TotalFLSUnqualified = ro.TotalFLSUnqualified;
|
|
newRo.TotalFLSPerCostBearer = ro.TotalFLSPerCostBearer;
|
|
newRo.TotalGefahreneKilometer = ro.TotalGefahreneKilometer;
|
|
newRo.SupportConceptCostBearer = ro.SupportConceptCostBearer;
|
|
newRo.Mandator = ro.Mandator;
|
|
|
|
return newRo;
|
|
}
|
|
|
|
private XtraReport AddReportToReport(XtraReport report, ServicesOverviewRO ro, bool isAssi)
|
|
{
|
|
if (ro.Services.Count > 0)
|
|
{
|
|
if (report == null)
|
|
{
|
|
if (isAssi)
|
|
{
|
|
report = new StundenzettelAssistenz();
|
|
((StundenzettelAssistenz)report).SetReportDataSource(ro);
|
|
}
|
|
else
|
|
{
|
|
report = new Stundenzettel();
|
|
((Stundenzettel)report).SetReportDataSource(ro);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (report.Pages.Count == 0)
|
|
{
|
|
report.CreateDocument();
|
|
}
|
|
|
|
XtraReport newReport = null;
|
|
if (isAssi)
|
|
{
|
|
newReport = new StundenzettelAssistenz();
|
|
((StundenzettelAssistenz)newReport).SetReportDataSource(ro);
|
|
}
|
|
else
|
|
{
|
|
newReport = new Stundenzettel();
|
|
((Stundenzettel)newReport).SetReportDataSource(ro);
|
|
}
|
|
if (newReport != null)
|
|
{
|
|
newReport.CreateDocument();
|
|
report.Pages.AddRange(newReport.Pages);
|
|
}
|
|
}
|
|
}
|
|
return report;
|
|
}
|
|
|
|
}
|
|
}
|