Files
BeWoPlaner/BeWoPlanerMobil/Models/ReportModel.cs
2026-04-28 12:01:37 +02:00

383 lines
12 KiB
C#

using BeWo.Report;
using BeWoPlanerMobil.Controllers;
using BeWoPlanerMobil.Util;
using BeWoPlanerMobil.Util.ReportUtils;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.DataContracts.Compact;
using BS.Shared.Extensions;
using DevExpress.XtraReports.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web.Mvc;
namespace BeWoPlanerMobil.Models
{
public class ReportModel : AbstractModel, ISignable
{
public ReportModel()
{
SessionModel = new ReportSessionModel();
}
public ReportSessionModel ReportSessionModel => SessionModel as ReportSessionModel;
public QbSignatureIntervalSelection SelectedIntervalSelection
{
get => ReportSessionModel.SelectedIntervalSelection;
set => ReportSessionModel.SelectedIntervalSelection = value;
}
public List<SelectListItem> IntervalSelections => new List<SelectListItem>
{
new SelectListItem
{
Text = QbSignatureIntervalSelection.FirstHalf.GetEnumDescription(),
Value = ((int) QbSignatureIntervalSelection.FirstHalf).ToString(),
Selected = SelectedIntervalSelection == QbSignatureIntervalSelection.FirstHalf
},
new SelectListItem
{
Text = QbSignatureIntervalSelection.SecondHalf.GetEnumDescription(),
Value = ((int) QbSignatureIntervalSelection.SecondHalf).ToString(),
Selected = SelectedIntervalSelection == QbSignatureIntervalSelection.SecondHalf
},
new SelectListItem
{
Text = QbSignatureIntervalSelection.WholeMonth.GetEnumDescription(),
Value = ((int) QbSignatureIntervalSelection.WholeMonth).ToString(),
Selected = SelectedIntervalSelection == QbSignatureIntervalSelection.WholeMonth
}
};
[Display(Name = "Klient")]
public long? SelectedCustomerOid
{
get => ReportSessionModel.SelectedCustomerOid;
set => ReportSessionModel.SelectedCustomerOid = value;
}
public CompactCustomerDC SelectedCustomer { get; set; }
[Display(Name = "Monat")]
public int? SelectedMonth
{
get => ReportSessionModel.SelectedMonth;
set => ReportSessionModel.SelectedMonth = value;
}
[Display(Name = "Jahr")]
public int? SelectedYear
{
get => ReportSessionModel.SelectedYear;
set => ReportSessionModel.SelectedYear = value;
}
public List<SelectListItem> Months
{
get
{
var result = new List<SelectListItem>();
for(var i = 1; i < 13; i++)
{
result.Add(new SelectListItem
{
Value = i.ToString(),
Text = new DateTime(DateTime.Now.Year, i, 1).ToString("MMMM")
});
}
return result;
}
}
public List<SelectListItem> Years
{
get
{
var result = new List<SelectListItem>();
for(var i = DateTime.Today.Year; i > DateTime.Today.Year - 11; i--)
{
result.Add(new SelectListItem
{
Value = i.ToString(),
Text = i.ToString()
});
}
return result;
}
}
public List<SelectListItem> Days
{
get
{
var result = new List<SelectListItem>();
var month = SelectedMonth ?? DateTime.Today.Month;
var year = SelectedYear ?? DateTime.Today.Year;
var last = new DateTime(year, month, 1).AddMonths(1).AddDays(-1).Day;
for(var i = 1; i <= last; i++)
{
result.Add(new SelectListItem
{
Value = i.ToString(),
Text = i.ToString()
});
}
return result;
}
}
[Display(Name = "Vom")]
public int? SelectedStartDay
{
get => ReportSessionModel.SelectedStartDay;
set => ReportSessionModel.SelectedStartDay = value;
}
[Display(Name = "Bis")]
public int? SelectedEndDay
{
get => ReportSessionModel.SelectedEndDay;
set => ReportSessionModel.SelectedEndDay = value;
}
public ConfirmationReceiptObject ConfirmationReceiptObject
{
get => ReportSessionModel.ConfirmationReceiptObject;
set => ReportSessionModel.ConfirmationReceiptObject = value;
}
[Display(Name = "Mitarbeiter")]
public long? SelectedEmployeeOid
{
get => ReportSessionModel.SelectedEmployeeOid;
set => ReportSessionModel.SelectedEmployeeOid = value;
}
public CompactEmployeeDC SelectedEmployee { get; set; }
[Display(Name="Kostenträger")]
public long? SelectedOrganisationOid
{
get => ReportSessionModel.SelectedOrganisationOid;
set => ReportSessionModel.SelectedOrganisationOid = value;
}
public CompactOrganisationDC SelectedOrganisation { get; set; }
public List<CompactOrganisationDC> Organisations { get; set; } = new List<CompactOrganisationDC>();
[Display(Name = "Leistungskategorie")]
public long? SelectedServiceCategoryOid
{
get => ReportSessionModel.SelectedServiceCategoryOid;
set => ReportSessionModel.SelectedServiceCategoryOid = value;
}
public ServiceCategoryDC SelectedServiceCategory { get; set; }
public List<ServiceCategoryDC> ServiceCategories { get; set; } = new List<ServiceCategoryDC>();
public List<SelectListItem> ServiceCategoryItems
{
get
{
var result = new List<SelectListItem>();
foreach(var serviceCategory in ServiceCategories)
{
if(serviceCategory.ServiceCategoryOid == null)
{
continue;
}
result.AddIfNotIn(new SelectListItem
{
Value = serviceCategory.ServiceCategoryOid.ToString(),
Text = serviceCategory.Name
});
}
return result;
}
}
[Display(Name="Filter")]
public QbFilterItem SelectedFilterItem
{
get
{
if(QbFilters is null || false == SelectedFilterItemId.HasValue)
{
return null;
}
return QbFilters.FirstOrDefault(f => f.FilterEnum == SelectedFilterItemId.Value);
}
}
public QBFilterEnum? SelectedFilterItemId
{
get => ReportSessionModel.SelectedFilterItemId;
set => ReportSessionModel.SelectedFilterItemId = value;
}
public List<QbFilterItem> QbFilters { get; set; } = new List<QbFilterItem>();
public List<SelectListItem> QbFilterItems
{
get
{
var result = new List<SelectListItem>();
foreach(var qbFilter in QbFilters)
{
result.AddIfNotIn(new SelectListItem
{
Value = ((int) qbFilter.FilterEnum).ToString(),
Text = qbFilter.Name
});
}
return result;
}
}
[Display(Name = "Team")]
public long? SelectedTeamOid
{
get => ReportSessionModel.SelectedTeamOid;
set => ReportSessionModel.SelectedTeamOid = value;
}
public CompactTeamDC SelectedTeam { get; set; }
public List<CompactTeamDC> AllTeams { get; set; }
public List<SelectListItem> Teams
{
get
{
var result = new List<SelectListItem>();
AllTeams?.DoForEach(team =>
{
result.Add(new SelectListItem
{
Value = team.TeamOid.ToString(),
Text = team.Name
});
});
return result;
}
}
public List<long> ReportServiceRecordOids { get; set; }
public List<ConfirmationReceiptSignatureDC> ConfirmationReceiptSignatures
{
get => ReportSessionModel.ConfirmationReceiptSignatures;
set => ReportSessionModel.ConfirmationReceiptSignatures = value;
}
public ConfirmationReceiptSignatureDC GetConfirmationReceiptSignatureByOid(long confirmationReceiptSignatureOid)
{
return ConfirmationReceiptSignatures.FirstOrDefault(crs => crs.ConfirmationReceiptSignatureOid == confirmationReceiptSignatureOid);
}
public List<ConfirmationReceiptSignatureDC> GetConfirmationReceitSignaturesByOids(List<long> confirmationReceiptSignatureOids)
{
return confirmationReceiptSignatureOids == null ?
new List<ConfirmationReceiptSignatureDC>() :
ConfirmationReceiptSignatures.Where(crs => crs.ConfirmationReceiptSignatureOid != null && confirmationReceiptSignatureOids.Contains(crs.ConfirmationReceiptSignatureOid.Value)).ToList();
}
public bool IsForSelectedEmployeesOnly
{
get => ReportSessionModel.IsForSelectedEmployeesOnly;
set => ReportSessionModel.IsForSelectedEmployeesOnly = value;
}
public bool IsForSelectedCostbearersOnly
{
get => ReportSessionModel.IsForSelectedCostbearersOnly;
set => ReportSessionModel.IsForSelectedCostbearersOnly = value;
}
public bool IsForSelectedCategoryOnly
{
get => ReportSessionModel.IsForSelectedCategoryOnly;
set => ReportSessionModel.IsForSelectedCategoryOnly = value;
}
public List<ConfirmationReceiptSignatureObject> SelectedConfirmationReceiptSignatures
{
get => ReportSessionModel.SelectedConfirmationReceiptSignatures;
set => ReportSessionModel.SelectedConfirmationReceiptSignatures = value;
}
public Quittierungsbelegsunterschriftenobjekt Quittierungsbelegsunterschriftenobjekt
{
get => ReportSessionModel.Quittierungsbelegsunterschriftenobjekt;
set => ReportSessionModel.Quittierungsbelegsunterschriftenobjekt = value;
}
public AbstractReportCreator ReportCreator { get; set; }
public QuittierungsbelegsReportSettings QuittierungsbelegsReportSettings
{
get => ReportSessionModel.QuittierungsbelegsReportSettings;
set => ReportSessionModel.QuittierungsbelegsReportSettings = value;
}
public XtraReport QuittierungsbelegsReport { get; set; }
public int QbEntryCount
{
get => ReportSessionModel.QbEntryCount;
set => ReportSessionModel.QbEntryCount = value;
}
public int MaxResults { get; set; } = 10;
public int QbEntryPageCount
{
get => ReportSessionModel.QbEntryPageCount;
set => ReportSessionModel.QbEntryPageCount = value;
}
public int CurrentQbEntryPage
{
get => ReportSessionModel.CurrentQbEntryPage;
set => ReportSessionModel.CurrentQbEntryPage = value;
}
public List<RatingTypeDC> GoalRatingTypes { get; set; } = new List<RatingTypeDC>();
public Dictionary<long, List<string>> ServiceRecordOids2GoalHeader
{
get => ReportSessionModel.ServiceRecordOids2GoalHeader;
set => ReportSessionModel.ServiceRecordOids2GoalHeader = value;
}
public ValueListEntryDC[] Dokutypes { get; set; }
public int NumberOfDokuTypes => Dokutypes?.Length ?? 0;
public string SignaturePopupTitle { get; set; }
}
}