930 lines
36 KiB
C#
930 lines
36 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.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 MainModel()
|
|
{
|
|
SessionModel = new MainSessionModel();
|
|
SessionModel.ResetValues();
|
|
|
|
NewServiceRecord = new ServiceRecordDC();
|
|
ShowOnlyOwnSupportConcepts = true;
|
|
ErrorWert = 1;
|
|
}
|
|
|
|
public MainSessionModel MainSessionModel => SessionModel as MainSessionModel;
|
|
|
|
public bool SessionInitialized
|
|
{
|
|
get => MainSessionModel.SessionInitialized;
|
|
set => MainSessionModel.SessionInitialized = value;
|
|
}
|
|
|
|
[Display(Name = "Nur meine Klienten anzeigen")]
|
|
public bool ShowOnlyOwnSupportConcepts
|
|
{
|
|
get => MainSessionModel.ShowOnlyOwnSupportConcepts;
|
|
set => MainSessionModel.ShowOnlyOwnSupportConcepts = value;
|
|
}
|
|
|
|
[Display(Name = "Nur Klienten meiner Teams anzeigen")]
|
|
public bool ShowOnlyMyTeamsSupportConcepts
|
|
{
|
|
get => MainSessionModel.ShowOnlyMyTeamsSupportConcepts;
|
|
set => MainSessionModel.ShowOnlyMyTeamsSupportConcepts = value;
|
|
}
|
|
|
|
public CustomerFilterEnum SelectedSupportConceptFilter
|
|
{
|
|
get => MainSessionModel.SelectedSupportConceptFilter;
|
|
set => MainSessionModel.SelectedSupportConceptFilter = value;
|
|
}
|
|
|
|
public long? TransferringAppointmentOid
|
|
{
|
|
get => MainSessionModel.TransferringAppointmentOid;
|
|
|
|
set
|
|
{
|
|
var callingMethodName = new StackTrace().GetFrame(1).GetMethod().Name;
|
|
|
|
Debug.WriteLine($">>>>{callingMethodName} ändert TransferringAppointment von {MainSessionModel.TransferringAppointmentOid} zu {value}");
|
|
|
|
MainSessionModel.TransferringAppointmentOid = value;
|
|
}
|
|
}
|
|
public bool IsInTransferMode
|
|
{
|
|
get => MainSessionModel.IsInTransferMode;
|
|
set => MainSessionModel.IsInTransferMode = value;
|
|
}
|
|
|
|
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 = 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.HasRight(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.HasRight(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 => MainSessionModel.ShowExpiredSupportConcepts;
|
|
set => MainSessionModel.ShowExpiredSupportConcepts = value;
|
|
}
|
|
|
|
[Display(Name = "Hilfeplan")]
|
|
public long? SelectedCostBearerSupportConceptOid
|
|
{
|
|
get => MainSessionModel.SelectedCostBearerSupportConceptOid;
|
|
set => MainSessionModel.SelectedCostBearerSupportConceptOid = value;
|
|
}
|
|
|
|
public long? SelectedServiceCategoryOid
|
|
{
|
|
get => MainSessionModel.SelectedServiceCategoryOid;
|
|
set => MainSessionModel.SelectedServiceCategoryOid = value;
|
|
}
|
|
|
|
public long? SelectedServiceDescriptionOid { get => MainSessionModel.SelectedServiceDescriptionOid;
|
|
set => MainSessionModel.SelectedServiceDescriptionOid = value;
|
|
}
|
|
|
|
|
|
public bool IsAllowedToDeleteServiceRecord(ServiceRecordDC serviceRecord)
|
|
{
|
|
var allowed = false;
|
|
|
|
if(LoggedInUser.HasRight(UserRightType.ServiceRecordView_Delete))
|
|
{
|
|
allowed = true;
|
|
}
|
|
else if(LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowChangeWithin24Hours))
|
|
{
|
|
if(serviceRecord.InsertedOn.HasValue)
|
|
{
|
|
if(DateTime.Now < serviceRecord.InsertedOn.Value.AddDays(ApplicationSettings.ServiceRecordAllowChangeHours))
|
|
{
|
|
allowed = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(allowed && ApplicationSettings.MaxDaysEditServiceRecordsAllowed > 0)
|
|
{
|
|
if(!LoggedInUser.HasRight(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 (!LoggedInUser.HasRight(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 && !LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowEditForOtherEmployees))
|
|
{
|
|
if(LoggedInUser.Employee.EmployeeOid != serviceRecord.Employee.EmployeeOid)
|
|
{
|
|
allowed = false;
|
|
}
|
|
}
|
|
|
|
if(allowed && serviceRecord.GroupOid.HasValue)
|
|
{
|
|
if(!LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking))
|
|
{
|
|
allowed = false;
|
|
}
|
|
}
|
|
|
|
return allowed;
|
|
}
|
|
|
|
public long? SelectedServiceRecordOid
|
|
{
|
|
get => MainSessionModel.SelectedServiceRecordOid;
|
|
set => MainSessionModel.SelectedServiceRecordOid = value;
|
|
}
|
|
|
|
public ServiceRecordDC SelectedServiceRecord { get; set; }
|
|
|
|
public long? SelectedSupportConceptOid
|
|
{
|
|
get => MainSessionModel.SelectedSupportConceptOid;
|
|
set => MainSessionModel.SelectedSupportConceptOid = value;
|
|
}
|
|
|
|
public CompactSupportConceptDC SelectedSupportConcept { get; set; }
|
|
|
|
public MokSupportConceptListObject SelectedSupportConceptListObject { get; set; }
|
|
|
|
|
|
public int Zeitraum { get; set; }
|
|
|
|
public int ErrorWert { get; set; }
|
|
|
|
public bool ShowSignature { get; set; }
|
|
|
|
public long LastCreatedServiceRecordOid
|
|
{
|
|
get => MainSessionModel.LastCreatedServiceRecordOid;
|
|
set => MainSessionModel.LastCreatedServiceRecordOid = value;
|
|
}
|
|
|
|
public List<long> SupportConceptOids
|
|
{
|
|
get => MainSessionModel.SupportConceptOids;
|
|
set => MainSessionModel.SupportConceptOids = value;
|
|
}
|
|
|
|
public List<CompactSupportConceptDC> 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 is null)
|
|
{
|
|
return _ServiceRecords = new List<ServiceRecordDC>();
|
|
}
|
|
|
|
return _ServiceRecords.OrderByDescending(sr => sr.Start).ToList();
|
|
}
|
|
|
|
set => _ServiceRecords = value;
|
|
}
|
|
|
|
public List<long> SelectedGoalOids
|
|
{
|
|
get => MainSessionModel.SelectedGoalOids;
|
|
set => MainSessionModel.SelectedGoalOids = value;
|
|
}
|
|
|
|
|
|
public IList<MokZiel> SelectedGoals
|
|
{
|
|
get => MainSessionModel.SelectedGoals;
|
|
set => MainSessionModel.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 IList<MokSupportConceptListObject> SupportConceptListObjects
|
|
{
|
|
get => MainSessionModel.SupportConceptListObjects;
|
|
set => MainSessionModel.SupportConceptListObjects = value;
|
|
}
|
|
|
|
public IList<MokSupportConceptListObject> SupportConceptListObjectsForGroupBooking { get; set; }
|
|
|
|
|
|
public IEnumerable<SelectListItem> GroupOfPeopleListItems
|
|
{
|
|
get
|
|
{
|
|
return GroupsOfPeople.Select(group => new SelectListItem {Value = $"{group.GroupOfPeopleOid.Value}", Text = group.Name}).ToList();
|
|
}
|
|
}
|
|
|
|
public List<CompactEmployeeDC> EmployeesForGroupAndMultiBooking { get; set; }
|
|
|
|
public List<CompactEmployeeDC> AllEmployees { get; set; }
|
|
|
|
[Display(Name = "Mitarbeiter")]
|
|
public long? SelectedEmployeeOid
|
|
{
|
|
get => MainSessionModel.SelectedEmployeeOid;
|
|
set => MainSessionModel.SelectedEmployeeOid = value;
|
|
}
|
|
|
|
public CompactEmployeeDC SelectedEmployee { get; set; }
|
|
|
|
public List<GroupOfPeopleDC> GroupsOfPeople { get; set; } = new List<GroupOfPeopleDC>();
|
|
|
|
public List<long> GroupBookingSelectedGroupOfPeopleOids { get { return MainSessionModel.GroupBookingSelectedGroupOfPeopleOids; } set { MainSessionModel.GroupBookingSelectedGroupOfPeopleOids = value; } }
|
|
|
|
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(LoggedInUser.Employee)}).OrderBy(s => s.Text).ToList());
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public ValueListEntryDC[] Dokutypes { get; set; }
|
|
|
|
public int NumberOfDokuTypes => Dokutypes?.Length ?? 0;
|
|
|
|
|
|
//public List<long> GroupBookingSelectedSupportConceptOids { get { return MainSessionModel.GroupBookingSelectedSupportConceptOids; } set { MainSessionModel.GroupBookingSelectedSupportConceptOids = value; } }
|
|
//public List<CompactSupportConceptDC> GroupBookingSelectedSupportConcepts { get; set; } = new List<CompactSupportConceptDC>();
|
|
|
|
public List<long> GroupBookingSelectedCostBearerSupportConceptOids { get { return MainSessionModel.GroupBookingSelectedCostBearerSupportConceptOids; } set { MainSessionModel.GroupBookingSelectedCostBearerSupportConceptOids = value; } }
|
|
|
|
public List<SupportConceptCostBearerRelDC> GroupBookingSelectedCostBearerSupportConcepts { get; set; } = new List<SupportConceptCostBearerRelDC>();
|
|
|
|
public GroupBookingSelectionObject GroupBookingSelectionObject => new GroupBookingSelectionObject(GroupBookingSelectedCostBearerSupportConcepts, GroupBookingSelectedGroupOfPeopleOids);
|
|
|
|
public List<long> GroupBookingSelectedEmployeeOids { get { return MainSessionModel.GroupBookingSelectedEmployeeOids; } set { MainSessionModel.GroupBookingSelectedEmployeeOids = value; } }
|
|
public List<CompactEmployeeDC> GroupBookingSelectedEmployees { get; set; } = new List<CompactEmployeeDC>();
|
|
|
|
[Display(Name = "Gruppenbuchung")]
|
|
public bool IsInGroupBookingMode
|
|
{
|
|
get => MainSessionModel.IsInGroupBookingMode;
|
|
|
|
set
|
|
{
|
|
MainSessionModel.IsInGroupBookingMode = value;
|
|
|
|
if(!MainSessionModel.IsInGroupBookingMode)
|
|
{
|
|
GroupBookingSelectedCostBearerSupportConceptOids?.Clear();
|
|
GroupBookingSelectedCostBearerSupportConcepts.Clear();
|
|
GroupBookingSelectedEmployeeOids.Clear();
|
|
GroupBookingSelectedEmployees?.Clear();
|
|
GroupBookingSelectedGroupOfPeopleOids.Clear();
|
|
//GroupBookingSelectedSupportConcept?.Clear();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public bool IsInEditingMode
|
|
{
|
|
get => MainSessionModel.IsInEditingMode;
|
|
set => MainSessionModel.IsInEditingMode = value;
|
|
}
|
|
|
|
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 long? PreviouslySelectedEmployeeOid
|
|
{
|
|
get => MainSessionModel.PreviouslySelectedEmployeeOid;
|
|
set => MainSessionModel.PreviouslySelectedEmployeeOid = value;
|
|
}
|
|
|
|
public CompactEmployeeDC PreviouslySelectedEmployee { get; set; }
|
|
|
|
//public long? PreviouslySelectedSupportConceptOid { get { return MainSessionModel.PreviouslySelectedSupportConceptOid; } set { MainSessionModel.PreviouslySelectedSupportConceptOid = value; } }
|
|
//public SupportConceptDC PreviouslySelectedSupportConcept { get; set; }
|
|
|
|
|
|
public long? PreviouslySelectedCostbearer2SupportConceptOid
|
|
{
|
|
get => MainSessionModel.PreviouslySelectedCostbearer2SupportConceptOid;
|
|
set
|
|
{
|
|
var stackTrace = new StackTrace();
|
|
var callingMethodsName = stackTrace.GetFrame(1).GetMethod().Name;
|
|
|
|
var alt = MainSessionModel.PreviouslySelectedCostbearer2SupportConceptOid;
|
|
|
|
Log.Info($"PreviouslySelectedCostbearer2SupportConceptOid-Set von {alt} zu {value} von Methode: {callingMethodsName}");
|
|
|
|
MainSessionModel.PreviouslySelectedCostbearer2SupportConceptOid = value;
|
|
}
|
|
}
|
|
public bool IsEndDateVisible { get; set; }
|
|
|
|
public static string GetServiceRecordTimeHeader(MokServiceRecord 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 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 dauerInfo = string.Empty;
|
|
var signatureToken = serviceRecord.SignatureOid.HasValue && isForServiceRecordsList ? "✔" : string.Empty;
|
|
|
|
var dauer = (end - start).TotalMinutes;
|
|
if (serviceRecord.DurationInStunden.HasValue && serviceRecord.DurationInStunden == ZeiterfassungsDauer.Stunden)
|
|
{
|
|
dauer /= 60;
|
|
dauerInfo = $" ({dauer:0.0#} h)";
|
|
}
|
|
else
|
|
{
|
|
dauerInfo = $" ({dauer:0.##} min.)";
|
|
}
|
|
if (serviceRecord.GroupOid.HasValue)
|
|
{
|
|
gruppenInfo = $" Gruppe ({serviceRecord.GroupPersonCount} Teilnehmer, {serviceRecord.GroupEmployeeCount} Betreuer)";
|
|
}
|
|
|
|
|
|
return $"{GetServiceRecordTimeString(serviceRecord)}{gruppenInfo}{dauerInfo} {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 static string GetServiceRecordTimeString(MokServiceRecord 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(LoggedInUser.HasRight(UserRightType.ServiceRecordView_Edit))
|
|
{
|
|
allowed = true;
|
|
}
|
|
else if(LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowChangeWithin24Hours))
|
|
{
|
|
if(serviceRecord.InsertedOn != null)
|
|
{
|
|
if(DateTime.Now < serviceRecord.InsertedOn.Value.AddDays(1))
|
|
{
|
|
allowed = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(allowed && ApplicationSettings.MaxDaysEditServiceRecordsAllowed > 0)
|
|
{
|
|
if(!LoggedInUser.HasRight(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 && !LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowEditForOtherEmployees))
|
|
{
|
|
if(LoggedInUser.Employee.EmployeeOid != serviceRecord.Employee.EmployeeOid)
|
|
{
|
|
allowed = false;
|
|
}
|
|
}
|
|
|
|
if(allowed && serviceRecord.GroupOid.HasValue)
|
|
{
|
|
if(!LoggedInUser.HasRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking))
|
|
{
|
|
allowed = false;
|
|
}
|
|
}
|
|
|
|
if(allowed && ApplicationSettings.AnzTageZeiterfassErfolgt > 0)
|
|
{
|
|
if(!LoggedInUser.HasRight(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 (SelectedServiceRecord != null)
|
|
{
|
|
var duration = SelectedServiceRecord.RoundedDuration;
|
|
|
|
if (SelectedDurationUnit == "Stunden")
|
|
{
|
|
return Math.Round(duration / 60, 2, MidpointRounding.AwayFromZero).ToString();
|
|
}
|
|
return Math.Round(duration, 0, MidpointRounding.AwayFromZero).ToString();
|
|
}
|
|
|
|
return string.Empty;
|
|
}
|
|
}
|
|
|
|
public string DistanceToEdit
|
|
{
|
|
get
|
|
{
|
|
if(SelectedServiceRecord != null && SelectedServiceRecord.DistanceInMeterDecimal.HasValue)
|
|
{
|
|
var dist = SelectedServiceRecord.DistanceInMeterDecimal.Value;
|
|
|
|
return Math.Round(dist, 2, MidpointRounding.AwayFromZero).ToString();
|
|
}
|
|
|
|
return 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 FindServiceRecord(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 { return MainSessionModel.SelectedZeitraum; } set { MainSessionModel.SelectedZeitraum = value; } }
|
|
|
|
public bool IsOnlyYearMonthVisible { get; set; }
|
|
|
|
#region Mehrfachbuchung
|
|
|
|
|
|
[Display(Name = "Mehrfachbuchung")]
|
|
public bool IsInMultiBookingMode { get { return MainSessionModel.IsInMultiBookingMode; } set { MainSessionModel.IsInMultiBookingMode = value; } }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
public bool IsPasswordSecurityEnabled { get; set; }
|
|
|
|
public bool ShowMarker { get; set; }
|
|
|
|
#region ServiceRecord-Pagination
|
|
public int ServiceRecordCount { get; set; }
|
|
|
|
public int CurrentPage { get { return MainSessionModel.CurrentPage; } set { MainSessionModel.CurrentPage = value; } }
|
|
|
|
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 List<ValueListEntryDC> AllGoals { get; internal 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 BookingMode CurrentBookingMode
|
|
{
|
|
get
|
|
{
|
|
if(IsInGroupBookingMode)
|
|
{
|
|
return BookingMode.GroupBookingMode;
|
|
}
|
|
|
|
return IsInMultiBookingMode ? BookingMode.MultiBookingMode : BookingMode.SingleBookingMode;
|
|
}
|
|
}
|
|
|
|
public string BookingModePrefix
|
|
{
|
|
get
|
|
{
|
|
var result = "sb";
|
|
|
|
switch(CurrentBookingMode)
|
|
{
|
|
case BookingMode.GroupBookingMode:
|
|
result = "gb";
|
|
break;
|
|
case BookingMode.MultiBookingMode:
|
|
result = "mb";
|
|
break;
|
|
default:
|
|
result = "sb";
|
|
break;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
public string GroupMembers(long groupOid)
|
|
{
|
|
var group = GroupsOfPeople.FirstOrDefault(f => f.GroupOfPeopleOid.Equals(groupOid));
|
|
|
|
if(group is null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
var result = string.Empty;
|
|
|
|
foreach(var item in group.SupportConceptList)
|
|
{
|
|
foreach(var costBearerRelOid in item.CostBearerRelOids)
|
|
{
|
|
result += $"{costBearerRelOid},";
|
|
}
|
|
}
|
|
|
|
return result.Trim(',');
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |