884 lines
35 KiB
C#
884 lines
35 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using BeWo.View.Navigation.Filter;
|
|
using BeWoPlanerMobil.Service;
|
|
using BeWoPlanerMobil.Util;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Settings;
|
|
|
|
namespace BeWoPlanerMobil.Models
|
|
{
|
|
public class MainModel : AbstractModel
|
|
{
|
|
protected static readonly log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
|
|
public long? SelectedCostBearerSupportConceptRelOid { get; set; }
|
|
|
|
[Display(Name = "Nur meine Klienten anzeigen")]
|
|
public bool ShowOnlyOwnSupportConcepts { get; set; }
|
|
|
|
[Display(Name = "Nur Klienten meiner Teams anzeigen")]
|
|
public bool ShowOnlyMyTeamsSupportConcepts { get; set; }
|
|
|
|
public CustomerFilterEnum SelectedSupportConceptFilter { get; set; }
|
|
|
|
public List<SelectListItem> SupportConceptFilter
|
|
{
|
|
get
|
|
{
|
|
/*
|
|
* Hat man das Recht "Hilfepläne ansehen (alle)":
|
|
* "Alle Hiflepläne anzeigen" und
|
|
* "Nur meine Hilfepläne anzeigen".
|
|
*
|
|
* Hat man die Rechte "Hilfepläne ansehen (alle)" und "Hilepläne ansehen (von Teams betreut)":
|
|
* "Alle Hiflepläne anzeigen",
|
|
* "Nur Hilfepläne meiner Teams anzeigen" und
|
|
* "Nur meine Hilfepläne anzeigen".
|
|
*
|
|
* Hat man das Recht "Hilepläne ansehen (von Mitarbeiter betreut):
|
|
* ENTFÄLLT -> nur die eigenen Hilfepläne
|
|
*
|
|
* Hat man die Rechte "Hilfepläne ansehen (von Mitarbeiter betreut)" und "Hilfepläne ansehen (von Teams betreut)":
|
|
* "Nur meine Hilfepläne anzeigen"
|
|
* "Nur Hilfepläne meiner Teams anzeigen"
|
|
*/
|
|
|
|
var result = new List<SelectListItem>();
|
|
|
|
var user = MobileSessionFacade.LoggedInUser;
|
|
|
|
var alle = new CustomerFilterItem(CustomerFilterEnum.All);
|
|
var nurMeine = new CustomerFilterItem(CustomerFilterEnum.MyCustomer);
|
|
var meinesTeams = new CustomerFilterItem(CustomerFilterEnum.TeamCustomer);
|
|
|
|
var allSupportConcepts = alle.CustomerFilterName;
|
|
var mySupportConceptsOnly = nurMeine.CustomerFilterName;
|
|
var myTeamsSupportConceptsOnly = meinesTeams.CustomerFilterName;
|
|
|
|
const string allSupportConceptsValue = "0";
|
|
const string mySupportConceptsValue = "1";
|
|
const string myTeamsSupportConceptsOnlyValue = "2";
|
|
|
|
if(user != null)
|
|
{
|
|
if(user.CheckForAtLeastOneRight(new List<UserRightType> { UserRightType.ViewAll, UserRightType.SupportConcept_ViewAllSupportConcepts }))
|
|
{
|
|
if(user.CheckForRight(UserRightType.SupportConcept_ViewMyTeams))
|
|
{
|
|
result.Add(new SelectListItem { Text = allSupportConcepts, Value = allSupportConceptsValue });
|
|
result.Add(new SelectListItem { Text = myTeamsSupportConceptsOnly, Value = myTeamsSupportConceptsOnlyValue });
|
|
result.Add(new SelectListItem { Text = mySupportConceptsOnly, Value = mySupportConceptsValue });
|
|
}
|
|
else
|
|
{
|
|
result.Add(new SelectListItem { Text = allSupportConcepts, Value = allSupportConceptsValue });
|
|
result.Add(new SelectListItem { Text = mySupportConceptsOnly, Value = mySupportConceptsValue });
|
|
}
|
|
}
|
|
else if(user.CheckForRight(UserRightType.SupportConcept_ViewMyTeams))
|
|
{
|
|
result.Add(new SelectListItem { Text = myTeamsSupportConceptsOnly, Value = myTeamsSupportConceptsOnlyValue });
|
|
result.Add(new SelectListItem { Text = mySupportConceptsOnly, Value = mySupportConceptsValue });
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
[Display(Name = "Abgelaufene Hilfepläne anzeigen")]
|
|
public bool ShowExpiredSupportConcepts { get; set; }
|
|
|
|
private long? _CostBearer2SupportConceptOid;
|
|
|
|
[Display(Name = "Hilfeplan")]
|
|
public long? CostBearer2SupportConceptOid
|
|
{
|
|
get => _CostBearer2SupportConceptOid;
|
|
|
|
set
|
|
{
|
|
Log.Info($"CostBearer2SupportConceptOid ausgewählt: {value}. Vorher: {_CostBearer2SupportConceptOid}; Benutzer: {MobileSessionFacade.LoggedInUser.LoginName} UserOid: {MobileSessionFacade.LoggedInUser.Oid}");
|
|
_CostBearer2SupportConceptOid = value;
|
|
}
|
|
}
|
|
|
|
public long? SelectedServiceCategoryOid => SelectedServiceCategory?.ServiceCategoryOid;
|
|
|
|
public long? SelectedServiceDescriptionOid => SelectedServiceDescription?.ServiceDescriptionOid;
|
|
|
|
public long? SelectedServiceRecordOid { get; set; }
|
|
|
|
public bool IsAllowedToDeleteServiceRecord(ServiceRecordDC serviceRecord)
|
|
{
|
|
var allowed = false;
|
|
|
|
if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecordView_Delete))
|
|
{
|
|
allowed = true;
|
|
}
|
|
else if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowChangeWithin24Hours))
|
|
{
|
|
if(serviceRecord.InsertedOn.HasValue)
|
|
{
|
|
if(DateTime.Now < serviceRecord.InsertedOn.Value.AddDays(ApplicationSettings.ServiceRecordAllowChangeHours))
|
|
{
|
|
allowed = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(allowed && ApplicationSettings.MaxDaysEditServiceRecordsAllowed > 0)
|
|
{
|
|
if(!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth))
|
|
{
|
|
if(serviceRecord.Start.HasValue)
|
|
{
|
|
var dateTime = new DateTime(serviceRecord.Start.Value.Year, serviceRecord.Start.Value.Month, 1);
|
|
dateTime = dateTime.AddMonths(1);
|
|
dateTime = dateTime.AddDays(ApplicationSettings.MaxDaysEditServiceRecordsAllowed);
|
|
|
|
if(DateTime.Now >= dateTime)
|
|
{
|
|
allowed = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (allowed && ApplicationSettings.AnzTageZeiterfassErfolgt > 0)
|
|
{
|
|
if (!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecordAllowEditAfterMindays))
|
|
{
|
|
if (serviceRecord.Start != null)
|
|
{
|
|
var dt = new DateTime(serviceRecord.Start.Value.Year, serviceRecord.Start.Value.Month, serviceRecord.Start.Value.Day);
|
|
dt = dt.AddDays(ApplicationSettings.AnzTageZeiterfassErfolgt + 1);
|
|
if (DateTime.Now >= dt)
|
|
{
|
|
allowed = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(allowed && !MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowEditForOtherEmployees))
|
|
{
|
|
if(MobileSessionFacade.LoggedInEmployee.EmployeeOid != serviceRecord.Employee.EmployeeOid)
|
|
{
|
|
allowed = false;
|
|
}
|
|
}
|
|
|
|
if(allowed && serviceRecord.GroupOid.HasValue)
|
|
{
|
|
if(!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking))
|
|
{
|
|
allowed = false;
|
|
}
|
|
}
|
|
|
|
return allowed;
|
|
}
|
|
|
|
public ServiceRecordDC SelectedServiceRecord { get; set; }
|
|
|
|
private SupportConceptDC _SelectedSupportConcept;
|
|
|
|
public SupportConceptDC SelectedSupportConcept
|
|
{
|
|
get => _SelectedSupportConcept;
|
|
|
|
set
|
|
{
|
|
var stackTrace = new StackTrace();
|
|
var callingMethodsName = stackTrace.GetFrame(1).GetMethod().Name;
|
|
Log.Info($"SC mit Oid {value?.SupportConceptOid} ausgewählt. Vorheriger SC: {_SelectedSupportConcept?.SupportConceptOid}. Aufrufende Methode: {callingMethodsName}");
|
|
|
|
_SelectedSupportConcept = value;
|
|
}
|
|
}
|
|
|
|
public int Zeitraum { get; set; }
|
|
|
|
public int ErrorWert { get; set; }
|
|
|
|
public bool ShowSignature { get; set; }
|
|
|
|
public long ServiceRecordOid { get; set; }
|
|
|
|
public List<SupportConceptDC> SupportConcepts { get; set; }
|
|
|
|
public List<TextModuleDC> Textbausteine { get; set; } = new List<TextModuleDC>();
|
|
|
|
public List<TextbausteinDisplayItem> TextModules { get; set; } = new List<TextbausteinDisplayItem>();
|
|
|
|
private List<ServiceRecordDC> _ServiceRecords;
|
|
|
|
public List<ServiceRecordDC> ServiceRecords
|
|
{
|
|
get
|
|
{
|
|
if(_ServiceRecords == null)
|
|
{
|
|
return _ServiceRecords = new List<ServiceRecordDC>();
|
|
}
|
|
|
|
return _ServiceRecords.OrderByDescending(sr => sr.Start).ToList();
|
|
}
|
|
set => _ServiceRecords = value;
|
|
}
|
|
|
|
private List<ValueListEntryDC> _SelectedGoals;
|
|
|
|
public List<ValueListEntryDC> SelectedGoals
|
|
{
|
|
get => _SelectedGoals ?? new List<ValueListEntryDC>();
|
|
|
|
set => _SelectedGoals = value;
|
|
}
|
|
|
|
private string GetRatingName(ValueListEntryDC ratedValueListEntry)
|
|
{
|
|
var rating = GoalRatingTypes.FirstOrDefault(f => f.RatingTypeOid.HasValue && f.RatingTypeOid.Value.Equals(ratedValueListEntry.RatingTypeOid));
|
|
|
|
return rating?.DisplayName ?? "NULL";
|
|
}
|
|
|
|
public ServiceRecordDC NewServiceRecord { get; set; }
|
|
|
|
public long? ServiceRecordOidToDelete { get; set; }
|
|
|
|
public MainModel()
|
|
{
|
|
NewServiceRecord = new ServiceRecordDC();
|
|
ShowOnlyOwnSupportConcepts = true;
|
|
ErrorWert = 1;
|
|
}
|
|
|
|
public IEnumerable<CostBearer2SupportConceptRelListObject> SupportConceptListObjects
|
|
{
|
|
get
|
|
{
|
|
var allCostBearerRelations = new List<CostBearer2SupportConceptRelListObject> {new CostBearer2SupportConceptRelListObject("Hilfeplan auswählen", "", "-1", false, false), new CostBearer2SupportConceptRelListObject("Ohne Hilfeplan", "", "-2", false, false) };
|
|
foreach(var sc in SupportConcepts.OrderBy(sc => sc.Customer.LastName))
|
|
{
|
|
allCostBearerRelations.AddRange(sc.CostBearerRelations.Where(w => ShowExpiredSupportConcepts || w.EndDate is null || w.EndDate.Value >= DateTime.Now.Date).Select(
|
|
cb => new CostBearer2SupportConceptRelListObject(
|
|
$"{sc.Customer.SimpleDescription} {(sc.Customer.DateOfBirth.HasValue ? "*" + sc.Customer.DateOfBirth.Value.ToString("dd.MM.yyyy") : string.Empty)}",
|
|
$"{cb.AuswahlBezeichnung} {cb.StartDate?.ToShortDateString().Remove(6, 2) ?? string.Empty}-{cb.EndDate?.ToShortDateString().Remove(6, 2) ?? string.Empty} {cb.CostBearer.Name}{GetIsNotApproved(cb)}",
|
|
cb.CostBearer2SupportConceptOid.ToString(),
|
|
cb.SupportConcept.IsAboutToExpire,
|
|
cb.SupportConcept.ExpiresIn3MonthOrLess))
|
|
);
|
|
}
|
|
return allCostBearerRelations;
|
|
}
|
|
}
|
|
|
|
public CostBearer2SupportConceptRelListObject SelectedCostBearer2SupportConceptRelListObject { get; set; }
|
|
|
|
public List<SupportConceptCostBearerRelDC> SelectedConceptCostBearerRelations { get; set; }
|
|
|
|
public GroupBookingSelectionObject GroupBookingSelectionObject => new GroupBookingSelectionObject(SelectedConceptCostBearerRelations, GroupBookingSelectedGroupOfPeopleOids);
|
|
|
|
public IEnumerable<CostBearer2SupportConceptRelListObject> SupportConceptListObjectsForGroupBooking
|
|
{
|
|
get
|
|
{
|
|
var allCostbearerRelations = new List<CostBearer2SupportConceptRelListObject>();
|
|
|
|
foreach(var sc in SupportConcepts.OrderBy(sc => sc.Customer.LastName))
|
|
{
|
|
allCostbearerRelations.AddRange(sc.CostBearerRelations.Where(w => ShowExpiredSupportConcepts || w.EndDate is null || w.EndDate.Value >= DateTime.Now).Select(
|
|
cb => new CostBearer2SupportConceptRelListObject(
|
|
$"{sc.Customer.SimpleDescription} {(sc.Customer.DateOfBirth.HasValue ? "*" + sc.Customer.DateOfBirth.Value.ToString("dd.MM.yyyy") : string.Empty)}",
|
|
$"{cb.AuswahlBezeichnung} {cb.StartDate?.ToShortDateString().Remove(6, 2) ?? string.Empty}-{cb.EndDate?.ToShortDateString().Remove(6, 2) ?? string.Empty} {cb.CostBearer.Name}",
|
|
cb.CostBearer2SupportConceptOid.ToString(),
|
|
cb.SupportConcept.IsAboutToExpire,
|
|
cb.SupportConcept.ExpiresIn3MonthOrLess))
|
|
);
|
|
}
|
|
|
|
return allCostbearerRelations;
|
|
}
|
|
}
|
|
|
|
public IEnumerable<SelectListItem> GroupOfPeopleListItems
|
|
{
|
|
get
|
|
{
|
|
return GroupsOfPeople.Select(group => new SelectListItem {Value = $"{group.GroupOfPeopleOid.Value}", Text = group.Name}).ToList();
|
|
}
|
|
}
|
|
|
|
public List<CompactEmployeeDC> Employees { get; set; }
|
|
|
|
public List<CompactEmployeeDC> EmployeesForGroupAndMultiBooking { get; set; }
|
|
|
|
public List<CompactEmployeeDC> AllEmployees { get; set; }
|
|
|
|
[Display(Name = "Mitarbeiter")]
|
|
public long? SelectedEmployeeOid => SelectedEmployee?.EmployeeOid;
|
|
|
|
public CompactEmployeeDC SelectedEmployee { get; set; }
|
|
|
|
public List<GroupOfPeopleDC> GroupsOfPeople { get; set; } = new List<GroupOfPeopleDC>();
|
|
|
|
public List<long> GroupBookingSelectedGroupOfPeopleOids { get; set; } = new List<long>();
|
|
|
|
public IEnumerable<SelectListItem> EmployeeListItems
|
|
{
|
|
get
|
|
{
|
|
var result = new List<SelectListItem>();
|
|
result.AddRange(Employees.Select(item => new SelectListItem {Value = item.EmployeeOid.ToString(), Text = $"{item.LastName}, {item.FirstName}", Selected = item.Equals(MobileSessionFacade.LoggedInCompactEmployee)}).OrderBy(s => s.Text).ToList());
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public ValueListEntryDC[] Dokutypes { get; set; }
|
|
|
|
public int NumberOfDokuTypes => Dokutypes?.Length ?? 0;
|
|
|
|
public static DateTime? GetEndDateOfSupportConcept(SupportConceptDC pSupportConcept)
|
|
{
|
|
DateTime? maxDate = null;
|
|
|
|
foreach(var relation in pSupportConcept.CostBearerRelations)
|
|
{
|
|
var end = relation.ApprovedEndDate ?? relation.RequestedEndDate;
|
|
|
|
if(maxDate == null || end != null && end.Value > maxDate.Value)
|
|
{
|
|
maxDate = end;
|
|
}
|
|
}
|
|
|
|
return maxDate;
|
|
}
|
|
|
|
public List<SupportConceptDC> GroupBookingSelectedSupportConcepts { get; set; } = new List<SupportConceptDC>();
|
|
|
|
public List<long> GroupBookingSelectedCostbearerRelOids { get; set; } = new List<long>();
|
|
|
|
public List<CompactEmployeeDC> GroupBookingSelectedEmployees { get; set; } = new List<CompactEmployeeDC>();
|
|
|
|
[Display(Name = "Gruppenbuchung")]
|
|
public bool IsInGroupBookingMode
|
|
{
|
|
get => _IsInGroupBookingMode;
|
|
|
|
set
|
|
{
|
|
_IsInGroupBookingMode = value;
|
|
|
|
if(!_IsInGroupBookingMode)
|
|
{
|
|
GroupBookingSelectedSupportConcepts?.Clear();
|
|
GroupBookingSelectedEmployees?.Clear();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool _IsInGroupBookingMode;
|
|
|
|
|
|
|
|
public bool IsInEditingMode { get; set; }
|
|
|
|
public List<ServiceDescriptionDC> GetServiceDesctiptions()
|
|
{
|
|
var result = new List<ServiceDescriptionDC>();
|
|
|
|
foreach(var category2Descriptions in Categories2Descriptions)
|
|
{
|
|
result.AddRangeIfElementsNotIn(category2Descriptions.Value);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public bool IsServiceRecordNoticeMandatory { get; set; } = true;
|
|
|
|
public CompactEmployeeDC PreviouslySelectedEmployee { get; set; }
|
|
public SupportConceptDC PreviouslySelectedSupportConcept { get; set; }
|
|
private long? _PreviouslySelectedCostbearer2SupportConceptOid;
|
|
|
|
public long? PreviouslySelectedCostbearer2SupportConceptOid
|
|
{
|
|
get => _PreviouslySelectedCostbearer2SupportConceptOid;
|
|
set
|
|
{
|
|
var stackTrace = new StackTrace();
|
|
var callingMethodsName = stackTrace.GetFrame(1).GetMethod().Name;
|
|
|
|
var alt = _PreviouslySelectedCostbearer2SupportConceptOid;
|
|
|
|
Log.Info($"PreviouslySelectedCostbearer2SupportConceptOid-Set von {alt} zu {value} von Methode: {callingMethodsName}");
|
|
|
|
_PreviouslySelectedCostbearer2SupportConceptOid = value;
|
|
}
|
|
}
|
|
public bool IsEndDateVisible { get; set; }
|
|
|
|
public static string GetServiceRecordTimeHeader(ServiceRecordDC serviceRecord, bool isForServiceRecordsList)
|
|
{
|
|
if (serviceRecord?.Start is null || serviceRecord.End is null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
var start = serviceRecord.Start.Value;
|
|
var end = serviceRecord.End.Value;
|
|
var gruppenInfo = string.Empty;
|
|
var signatureToken = serviceRecord.SignatureOid.HasValue && isForServiceRecordsList ? "✔" : string.Empty;
|
|
|
|
if(serviceRecord.GroupOid.HasValue)
|
|
{
|
|
gruppenInfo = $"Gruppe ({serviceRecord.GroupPersonCount} Teilnehmer, {serviceRecord.GroupEmployeeCount} Betreuer) Dauer: {(end - start).TotalMinutes} {signatureToken}";
|
|
}
|
|
|
|
return $"{GetServiceRecordTimeString(serviceRecord)} {gruppenInfo} {signatureToken}";
|
|
}
|
|
|
|
public static string GetServiceRecordTimeString(ServiceRecordDC serviceRecord)
|
|
{
|
|
if(serviceRecord?.Start is null || serviceRecord.End is null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
var start = serviceRecord.Start.Value;
|
|
var end = serviceRecord.End.Value; //start.AddMinutes((int) serviceRecord.RoundedDuration), AB, 12.03.2025: Änderung vom 12.11.2024 rückgängig; Endzeit bleibt bei Gruppen- und Einzelbuchungen die tatäschliche Zeit - genau wie FAK
|
|
|
|
if (start.Second == 0)
|
|
{
|
|
return start.Date != end.Date ?
|
|
$"{start.ToShortDateString()} {start.ToShortTimeString()} - {end.ToShortDateString()} {end.ToShortTimeString()}" :
|
|
$"{start.ToShortDateString()} {start.ToShortTimeString()} - {end.ToShortTimeString()}";
|
|
}
|
|
|
|
return start.Date != end.Date ?
|
|
$"{start.ToShortDateString()} - {end.ToShortDateString()}" :
|
|
$"{start.ToShortDateString()}";
|
|
}
|
|
|
|
public bool HasRightToEditServiceRecord(ServiceRecordDC serviceRecord)
|
|
{
|
|
var allowed = false;
|
|
|
|
if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecordView_Edit))
|
|
{
|
|
allowed = true;
|
|
}
|
|
else if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowChangeWithin24Hours))
|
|
{
|
|
if(serviceRecord.InsertedOn != null)
|
|
{
|
|
if(DateTime.Now < serviceRecord.InsertedOn.Value.AddDays(1))
|
|
{
|
|
allowed = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(allowed && ApplicationSettings.MaxDaysEditServiceRecordsAllowed > 0)
|
|
{
|
|
if(!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth))
|
|
{
|
|
if(serviceRecord.Start != null)
|
|
{
|
|
var date = new DateTime(serviceRecord.Start.Value.Year, serviceRecord.Start.Value.Month, 1);
|
|
date = date.AddMonths(1);
|
|
date = date.AddDays(ApplicationSettings.MaxDaysEditServiceRecordsAllowed);
|
|
|
|
if(DateTime.Now >= date)
|
|
{
|
|
allowed = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(allowed && !MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowEditForOtherEmployees))
|
|
{
|
|
if(MobileSessionFacade.LoggedInEmployee.EmployeeOid != serviceRecord.Employee.EmployeeOid)
|
|
{
|
|
allowed = false;
|
|
}
|
|
}
|
|
|
|
if(allowed && serviceRecord.GroupOid.HasValue)
|
|
{
|
|
if(!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking))
|
|
{
|
|
allowed = false;
|
|
}
|
|
}
|
|
|
|
if(allowed && ApplicationSettings.AnzTageZeiterfassErfolgt > 0)
|
|
{
|
|
if(!MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecordAllowEditAfterMindays))
|
|
{
|
|
if(serviceRecord.Start != null)
|
|
{
|
|
var date = new DateTime(serviceRecord.Start.Value.Year, serviceRecord.Start.Value.Month, serviceRecord.Start.Value.Day);
|
|
date = date.AddDays(ApplicationSettings.AnzTageZeiterfassErfolgt + 1);
|
|
if(DateTime.Now >= date)
|
|
{
|
|
allowed = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return allowed;
|
|
}
|
|
|
|
public bool IsZeiterfassungInStdMin => EinheitZeiterfassung == 2;
|
|
|
|
public int EinheitZeiterfassung { get; set; }
|
|
|
|
public string StartDateToEditJSFormat => SelectedServiceRecord?.Start?.ToString("yyyy-MM-dd") ?? DateTime.Today.ToString("yyyy-MM-dd");
|
|
|
|
public string EndDateToEditJSFormat => SelectedServiceRecord?.End?.ToString("yyyy-MM-dd") ?? DateTime.Today.ToString("yyyy-MM-dd");
|
|
|
|
public string StartDateToEdit => SelectedServiceRecord?.Start?.ToShortDateString() ?? DateTime.Today.ToShortDateString();
|
|
|
|
public string EndDateToEdit => SelectedServiceRecord?.End?.ToShortDateString() ?? DateTime.Today.ToShortDateString();
|
|
|
|
public string StartTimeToEdit
|
|
{
|
|
get
|
|
{
|
|
var start = SelectedServiceRecord?.Start;
|
|
|
|
if(start != null && !start.Value.GetServiceRecordNoDateTimeDate().Equals(start))
|
|
{
|
|
return start.Value.ToString("HH:mm");
|
|
}
|
|
|
|
return string.Empty;
|
|
}
|
|
}
|
|
|
|
public string EndTimeToEdit
|
|
{
|
|
get
|
|
{
|
|
var end = SelectedServiceRecord?.End;
|
|
|
|
if(end != null && end.Value.Second != 1)
|
|
{
|
|
return end.Value.ToString("HH:mm");
|
|
}
|
|
|
|
return string.Empty;
|
|
}
|
|
}
|
|
|
|
public string DurationToEdit
|
|
{
|
|
get
|
|
{
|
|
if(SelectedDurationUnit == "Stunden")
|
|
{
|
|
return SelectedServiceRecord is null ? string.Empty : (SelectedServiceRecord.RoundedDuration / 60).ToString();
|
|
}
|
|
|
|
return SelectedServiceRecord?.RoundedDuration.ToString() ?? string.Empty;
|
|
}
|
|
}
|
|
|
|
public string DistanceToEdit => SelectedServiceRecord?.DistanceInMeterDecimal.ToString() ?? string.Empty;
|
|
|
|
public string NoticeToEdit => SelectedServiceRecord?.NoticeList.FirstOrDefault() ?? string.Empty;
|
|
|
|
public List<string> NoticeListToEdit => SelectedServiceRecord != null ? SelectedServiceRecord.NoticeList : new List<string> {string.Empty, string.Empty, string.Empty, string.Empty, string.Empty};
|
|
|
|
public string SubmitButtonValue => IsInEditingMode || IsInGroupBookingMode ? "Speichern" : "Anlegen";
|
|
|
|
public long SelectedServiceRecordsServiceDescriptionOid => SelectedServiceRecord?.ServiceDescription?.ServiceDescriptionOid ?? 0L;
|
|
|
|
public ServiceRecordDC GetServiceRecord(long serviceRecordOid)
|
|
{
|
|
return ServiceRecords.FirstOrDefault(serviceRecord => serviceRecord.ServiceRecordOid.Equals(serviceRecordOid));
|
|
}
|
|
|
|
public List<RatingTypeDC> GoalRatingTypes { get; set; } = new List<RatingTypeDC>();
|
|
|
|
public ValueListEntryDC GetGoalByOid(long goalOid)
|
|
{
|
|
return SelectedSupportConcept?.Goals.FirstOrDefault(goal => goal.ValueListEntryOid == goalOid);
|
|
}
|
|
|
|
public bool HasAnyRatingTypes { get; set; }
|
|
|
|
public List<GoalTreeItem> GoalTree { get; set; } = new List<GoalTreeItem>();
|
|
public List<TextbausteinDisplayItem> AllTextModules { get; set; } = new List<TextbausteinDisplayItem>();
|
|
|
|
public bool SetStartTimeToEndTimeAfterSave { get; set; }
|
|
|
|
public DateTime? NewStartDate { get; set; }
|
|
public string NewStartTime
|
|
{
|
|
get
|
|
{
|
|
var start = NewStartDate;
|
|
|
|
if(start.HasValue && !start.Value.GetServiceRecordNoDateTimeDate().Equals(start))
|
|
{
|
|
return start.Value.ToString("HH:mm");
|
|
}
|
|
|
|
return string.Empty;
|
|
}
|
|
}
|
|
public string NewStartDateStr => NewStartDate?.ToShortDateString();
|
|
|
|
public DateTime? NewEndDate { get; set; }
|
|
public string NewEndTime
|
|
{
|
|
get
|
|
{
|
|
var start = NewEndDate;
|
|
|
|
if(start != null && !start.Value.GetServiceRecordNoDateTimeDate().Equals(start))
|
|
{
|
|
return start.Value.ToString("HH:mm");
|
|
}
|
|
|
|
return string.Empty;
|
|
}
|
|
}
|
|
public string NewEndDateStr => NewEndDate?.ToShortDateString();
|
|
|
|
public int? NewDuration
|
|
{
|
|
get
|
|
{
|
|
if(NewStartDate.HasValue && NewEndDate.HasValue)
|
|
{
|
|
return (int?) (NewEndDate.Value - NewStartDate.Value).TotalMinutes;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public bool IsShowingDurationInHours { get; set; }
|
|
|
|
public string SelectedDurationUnit => IsShowingDurationInHours ? "Stunden" : "Minuten";
|
|
|
|
public DateTime LastSelectedServiceRecordMonth { get; set; }
|
|
public int LastSelectedServiceRecordTimeIntervalDays { get; set; }
|
|
|
|
/// <summary>
|
|
/// Zeitraum der Zeiterfassungseintragsliste (z.B. Alle, Letzte 7 Tage, etc.)
|
|
/// </summary>
|
|
public ServiceRecordTimeInterval ServiceRecordTimeInterval { get; set; }
|
|
public int SelectedDayCount { get; set; }
|
|
public NullableDateTimeSpan SelectedZeitraum { get; set; }
|
|
|
|
public bool IsOnlyYearMonthVisible { get; set; }
|
|
|
|
#region Mehrfachbuchung
|
|
|
|
private bool _IsInMultiBookingMode;
|
|
|
|
[Display(Name = "Mehrfachbuchung")]
|
|
public bool IsInMultiBookingMode
|
|
{
|
|
get => _IsInMultiBookingMode;
|
|
|
|
set
|
|
{
|
|
_IsInMultiBookingMode = value;
|
|
|
|
if(!_IsInMultiBookingMode)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public List<SupportConceptDC> MultiBookingSelectedSupportConcepts { get; set; } = new List<SupportConceptDC>();
|
|
|
|
public List<long> MultiBookingSelectedGroupOfPeopleOids { get; set; } = new List<long>();
|
|
|
|
public List<SupportConceptCostBearerRelDC> MultiBookingSelectedConceptCostBearerRelations { get; set; }
|
|
|
|
public GroupBookingSelectionObject MultiBookingSelectionObject => new GroupBookingSelectionObject(MultiBookingSelectedConceptCostBearerRelations, MultiBookingSelectedGroupOfPeopleOids);
|
|
|
|
public List<long> MultiBookingSelectedCostbearerRelOids { get; set; } = new List<long>();
|
|
public List<CompactEmployeeDC> MultiBookingSelectedEmployees { get; set; } = new List<CompactEmployeeDC>();
|
|
|
|
public List<CostBearer2SupportConceptRelListObject> MultiBookingSupportConceptListObjects
|
|
{
|
|
get
|
|
{
|
|
var allCostbearerRelations = new List<CostBearer2SupportConceptRelListObject>();
|
|
|
|
foreach(var sc in SupportConcepts.OrderBy(sc => sc.Customer.LastName))
|
|
{
|
|
allCostbearerRelations.AddRange(sc.CostBearerRelations.Where(w => ShowExpiredSupportConcepts || w.EndDate == null || w.EndDate.Value >= DateTime.Now).Select(
|
|
cb => new CostBearer2SupportConceptRelListObject(
|
|
$"{sc.Customer.SimpleDescription} {(sc.Customer.DateOfBirth.HasValue ? "*" + sc.Customer.DateOfBirth.Value.ToString("dd.MM.yyyy") : string.Empty)}",
|
|
$"{cb.AuswahlBezeichnung} {cb.StartDate?.ToShortDateString().Remove(6, 2) ?? string.Empty}-{cb.EndDate?.ToShortDateString().Remove(6, 2) ?? string.Empty} {cb.CostBearer.Name}",
|
|
cb.CostBearer2SupportConceptOid.ToString(),
|
|
cb.SupportConcept.IsAboutToExpire,
|
|
cb.SupportConcept.ExpiresIn3MonthOrLess))
|
|
);
|
|
}
|
|
|
|
return allCostbearerRelations;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
public MandatorDC Mandator { get; set; }
|
|
|
|
public bool IsPasswordSecurityEnabled { get; set; }
|
|
|
|
public bool ShowMarker { get; set; }
|
|
|
|
#region ServiceRecord-Pagination
|
|
public int ServiceRecordCount { get; set; }
|
|
|
|
public int CurrentPage { get; set; }
|
|
|
|
public int MaxResults { get; set; } = 10;
|
|
|
|
public int ServiceRecordPageCount { get; set; }
|
|
|
|
#endregion
|
|
|
|
public string OneTimeLink { get; set; }
|
|
public string OneTimeLinkText { get; set; }
|
|
|
|
public string ShareDetails { get; set; }
|
|
|
|
public bool IsCustomerAbsence { get; set; }
|
|
public string CustomerAbsenceInfo { get; set; }
|
|
|
|
public Dictionary<long, List<string>> ServiceRecordOids2GoalHeader { get; set; }
|
|
|
|
public bool FilterGroupServiceCategories { get; set; }
|
|
|
|
public Dictionary<ServiceCategoryDC, List<ServiceDescriptionDC>> Categories2Descriptions { get; set; } = new Dictionary<ServiceCategoryDC, List<ServiceDescriptionDC>>();
|
|
|
|
public ServiceCategoryDC SelectedServiceCategory { get; set; }
|
|
|
|
public ServiceDescriptionDC SelectedServiceDescription { get; set; }
|
|
|
|
public ServiceDescriptionDC GetSelectedOrFirstServiceDescription()
|
|
{
|
|
if(SelectedServiceDescription != null || Categories2Descriptions is null)
|
|
{
|
|
return SelectedServiceDescription;
|
|
}
|
|
|
|
var firstServiceCategory2ServiceDescriptions = Categories2Descriptions.OrderBy(c2d => c2d.Key.Position).ThenBy(c2d => c2d.Key.ServiceCategoryOid).FirstOrDefault(c2d => c2d.Value.Any());
|
|
|
|
if(firstServiceCategory2ServiceDescriptions.Key != null && (firstServiceCategory2ServiceDescriptions.Value?.Any() ?? false))
|
|
{
|
|
return firstServiceCategory2ServiceDescriptions.Value.OrderBy(sd => sd.Position).ThenBy(sd => sd.ServiceDescriptionOid).First();
|
|
}
|
|
|
|
return SelectedServiceDescription;
|
|
}
|
|
|
|
public string LocalStorageKey => $"bwp_{MobileSessionFacade.Tenant}_{MobileSessionFacade.LoggedInUser.Oid}";
|
|
}
|
|
|
|
public class CustomSelectListItem
|
|
{
|
|
public string Text1 { get; }
|
|
public string Text2 { get; }
|
|
public string Value { get; }
|
|
public string TextColor { get; }
|
|
public long? SupportConceptOid { get; }
|
|
public long? CostBearer2SupportConceptOid { get; }
|
|
|
|
public CustomSelectListItem(string pText1, string pText2, string pValue, string pTextColor, long? supportConceptOid, long? costBearer2SupportConceptOid)
|
|
{
|
|
Text1 = pText1;
|
|
Text2 = pText2;
|
|
Value = pValue;
|
|
TextColor = pTextColor;
|
|
SupportConceptOid = supportConceptOid;
|
|
CostBearer2SupportConceptOid = costBearer2SupportConceptOid;
|
|
}
|
|
}
|
|
|
|
public class CostBearer2SupportConceptRelListObject
|
|
{
|
|
public string NameAndDateOfBirth { get; }
|
|
|
|
public string SupportConceptTimeSpan { get; }
|
|
|
|
public string CostBearer2SupportConceptOid { get; }
|
|
|
|
public string CostBearer2SupportConceptOidName { get; }
|
|
|
|
public bool IsAboutToExpire { get; }
|
|
public bool ExpiresInThreeMonthsOrLess { get; }
|
|
|
|
|
|
public CostBearer2SupportConceptRelListObject(string pNameAndDateOfBirth, string pSupportConceptTimeSpan, string pCostBearer2SupportConceptOid, bool isAboutToExpire, bool expiresIn3MonthOrLess)
|
|
{
|
|
NameAndDateOfBirth = pNameAndDateOfBirth;
|
|
SupportConceptTimeSpan = pSupportConceptTimeSpan;
|
|
CostBearer2SupportConceptOid = pCostBearer2SupportConceptOid;
|
|
|
|
CostBearer2SupportConceptOidName = "OidHolder_" + CostBearer2SupportConceptOid;
|
|
|
|
IsAboutToExpire = isAboutToExpire;
|
|
ExpiresInThreeMonthsOrLess = expiresIn3MonthOrLess;
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (!(obj is CostBearer2SupportConceptRelListObject))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var obj2 = (CostBearer2SupportConceptRelListObject) obj;
|
|
|
|
return Equals(CostBearer2SupportConceptOid, obj2.CostBearer2SupportConceptOid);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
unchecked
|
|
{
|
|
const int hashingBase = (int)2166136261;
|
|
const int hashingMultiplier = 16777619;
|
|
|
|
var hash = hashingBase;
|
|
|
|
hash = (hash * hashingMultiplier) ^ (NameAndDateOfBirth?.GetHashCode() ?? 0);
|
|
hash = (hash * hashingMultiplier) ^ (SupportConceptTimeSpan?.GetHashCode() ?? 0);
|
|
hash = (hash * hashingMultiplier) ^ (CostBearer2SupportConceptOid?.GetHashCode() ?? 0);
|
|
hash = (hash * hashingMultiplier) ^ IsAboutToExpire.GetHashCode();
|
|
hash = (hash * hashingMultiplier) ^ ExpiresInThreeMonthsOrLess.GetHashCode();
|
|
|
|
return hash;
|
|
}
|
|
}
|
|
}
|
|
} |