diff --git a/ReportImp/SozialwirkstattSchmitz/CustomReportCreator.cs b/ReportImp/SozialwirkstattSchmitz/CustomReportCreator.cs new file mode 100644 index 000000000..3c6fa3dbe --- /dev/null +++ b/ReportImp/SozialwirkstattSchmitz/CustomReportCreator.cs @@ -0,0 +1,191 @@ +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 BeWo.Service.DCEntityMapper; +using BeWo.Service.Plugins; +using BS.Shared; +using BS.Shared.Extensions; +using DevExpress.XtraReports.Design; +using DevExpress.XtraReports.UI; + +namespace SozialwirkstattSchmitz +{ + public class IntegraReportCreator : DefaultReportCreator + { + public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay) + { + //List lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay); + List lROs = Create(month, year, orgaOid, empOid, startDay, endDay, serviceCategoryOid); + + 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(); + } + + private List Create(int pMonth, int pYear, long orgaOid, long empOid, int startDay, int endDay, long? serviceCategoryOid = null) + { + var roList = new List(); + + List customerOids = new List(); + + 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) + { + bool all = false; + foreach (var group in loggedInUser.UserGroups) + { + if (group.Name.ToLower().Contains("admin") || group.Name.ToLower().Contains("verwaltung")) + { + all = true; + } + } + + if (all) + { + customerOids.AddRange(DAOFactory.GenericDAO.GetAllActive() + .OrderBy(ob => ob.Person.LastName + ", " + ob.Person.FirstName).Select(c => c.Oid.Value)); + } + else + { + var teams = DAOFactory.SearchDAO.FindLeadingTeams(loggedInUser.Employee.Oid.Value); + + foreach (var team in teams) + { + foreach (var employee in team.MemberList) + { + foreach (var e2c in 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 CreateServiceOverviewReportForCustomers(IList customerOids, int month, int year, long? orgaOid, long? empOid, long? serviceCategoryOid, int startDay, int endDay, bool nurFehlende) + { + var roList = new List(); + + 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) + { + var ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid); + + return CreateServicesOverviewReportForRo(ro, serviceCategoryOid); + + } + + private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid) + { + IBeWoReport report = null; + String kt = ""; + if (!String.IsNullOrWhiteSpace(ro.Costbearer)) + kt = ro.Costbearer.Trim(); + + String function = ""; + if (ro.CostBearer2SupportConceptList != null) + { + foreach (var c2s in ro.CostBearer2SupportConceptList) + { + if (c2s.CostBearer.Organisation.Function != null && !String.IsNullOrWhiteSpace(ro.Costbearer) && c2s.CostBearer.Organisation.Name == ro.Costbearer) + function = c2s.CostBearer.Organisation.Function.Value; + } + } + + if (function.Contains("kasse")) + report = new SozialwirkstattSchmitz.LeistungsnachweisSoziotherapie(); + + if (report == null) + report = new SozialwirkstattSchmitz.Stundenzettel(); + report.SetReportDataSource(ro); + + return report as XtraReport; + } + } + } diff --git a/ReportImp/SozialwirkstattSchmitz/ServicesOverviewReport.Designer.cs b/ReportImp/SozialwirkstattSchmitz/ServicesOverviewReport.Designer.cs index 0e2bcc0c9..e15c14206 100644 --- a/ReportImp/SozialwirkstattSchmitz/ServicesOverviewReport.Designer.cs +++ b/ReportImp/SozialwirkstattSchmitz/ServicesOverviewReport.Designer.cs @@ -1,5 +1,5 @@ using BeWo.Report.ReportObjects; -namespace BeWo.SozialwirkstattSchmitz +namespace SozialwirkstattSchmitz { partial class Stundenzettel { diff --git a/ReportImp/SozialwirkstattSchmitz/ServicesOverviewReport.cs b/ReportImp/SozialwirkstattSchmitz/ServicesOverviewReport.cs index 4bde4fa8e..cde795c96 100644 --- a/ReportImp/SozialwirkstattSchmitz/ServicesOverviewReport.cs +++ b/ReportImp/SozialwirkstattSchmitz/ServicesOverviewReport.cs @@ -5,7 +5,7 @@ using DevExpress.XtraReports.UI; using BeWo.Report.ReportObjects; using BeWo.Report; -namespace BeWo.SozialwirkstattSchmitz +namespace SozialwirkstattSchmitz { public partial class Stundenzettel : DevExpress.XtraReports.UI.XtraReport, IBeWoReport { diff --git a/ReportImp/SozialwirkstattSchmitz/SozialwirkstattSchmitz.csproj b/ReportImp/SozialwirkstattSchmitz/SozialwirkstattSchmitz.csproj index aaf5836a0..76866f423 100644 --- a/ReportImp/SozialwirkstattSchmitz/SozialwirkstattSchmitz.csproj +++ b/ReportImp/SozialwirkstattSchmitz/SozialwirkstattSchmitz.csproj @@ -110,6 +110,7 @@ +