2025-11-14 14:30:41 +01:00
using BeWo.View.Navigation.Filter ;
using BeWoPlanerMobil.Controllers ;
2020-04-02 13:19:14 +02:00
using BeWoPlanerMobil.Util ;
2016-06-27 01:45:38 +02:00
using BS.Shared ;
using BS.Shared.DataContracts ;
using BS.Shared.DataContracts.Compact ;
2018-04-18 14:33:21 +02:00
using BS.Shared.Extensions ;
2019-08-08 14:47:53 +02:00
using BS.Shared.Settings ;
2025-11-14 14:30:41 +01:00
using System ;
using System.Collections.Generic ;
using System.ComponentModel.DataAnnotations ;
using System.Diagnostics ;
using System.Linq ;
using System.Web.Mvc ;
2016-06-27 01:45:38 +02:00
namespace BeWoPlanerMobil.Models
{
2025-11-24 17:26:11 +01:00
public class MainModel : AbstractModel , ISignable
2019-07-25 14:56:11 +02:00
{
2025-05-21 19:34:42 +02:00
protected static readonly log4net . ILog Log = log4net . LogManager . GetLogger ( System . Reflection . MethodBase . GetCurrentMethod ( ) . DeclaringType ) ;
2025-06-11 22:56:25 +02:00
public MainModel ( )
{
SessionModel = new MainSessionModel ( ) ;
SessionModel . ResetValues ( ) ;
2025-05-21 19:34:42 +02:00
2025-06-11 22:56:25 +02:00
NewServiceRecord = new ServiceRecordDC ( ) ;
ShowOnlyOwnSupportConcepts = true ;
ErrorWert = 1 ;
}
2025-06-27 13:11:10 +02:00
public MainSessionModel MainSessionModel = > SessionModel as MainSessionModel ;
public bool SessionInitialized
2025-06-11 22:56:25 +02:00
{
2025-06-27 13:11:10 +02:00
get = > MainSessionModel . SessionInitialized ;
set = > MainSessionModel . SessionInitialized = value ;
2025-06-11 22:56:25 +02:00
}
2025-05-21 19:34:42 +02:00
2023-05-02 13:03:46 +02:00
[Display(Name = "Nur meine Klienten anzeigen")]
2025-06-27 13:11:10 +02:00
public bool ShowOnlyOwnSupportConcepts
{
get = > MainSessionModel . ShowOnlyOwnSupportConcepts ;
set = > MainSessionModel . ShowOnlyOwnSupportConcepts = value ;
}
2016-06-27 01:45:38 +02:00
2023-05-02 13:03:46 +02:00
[Display(Name = "Nur Klienten meiner Teams anzeigen")]
2025-06-27 13:11:10 +02:00
public bool ShowOnlyMyTeamsSupportConcepts
{
get = > MainSessionModel . ShowOnlyMyTeamsSupportConcepts ;
set = > MainSessionModel . ShowOnlyMyTeamsSupportConcepts = value ;
}
2025-06-11 22:56:25 +02:00
2025-06-27 13:11:10 +02:00
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 ;
}
}
2025-07-15 14:26:03 +02:00
public bool IsInTransferMode
{
get = > MainSessionModel . IsInTransferMode ;
set = > MainSessionModel . IsInTransferMode = value ;
}
2020-12-16 21:49:47 +01:00
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 > ( ) ;
2025-06-11 22:56:25 +02:00
var user = LoggedInUser ;
2020-12-16 21:49:47 +01:00
2023-05-02 13:03:46 +02:00
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 ;
2020-12-16 21:49:47 +01:00
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 } ) )
{
2025-06-11 22:56:25 +02:00
if ( user . HasRight ( UserRightType . SupportConcept_ViewMyTeams ) )
2020-12-16 21:49:47 +01:00
{
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 } ) ;
}
}
2025-06-11 22:56:25 +02:00
else if ( user . HasRight ( UserRightType . SupportConcept_ViewMyTeams ) )
2020-12-16 21:49:47 +01:00
{
result . Add ( new SelectListItem { Text = myTeamsSupportConceptsOnly , Value = myTeamsSupportConceptsOnlyValue } ) ;
result . Add ( new SelectListItem { Text = mySupportConceptsOnly , Value = mySupportConceptsValue } ) ;
}
}
return result ;
}
}
2018-02-28 12:42:23 +01:00
[Display(Name = "Abgelaufene Hilfepläne anzeigen")]
2025-06-27 13:11:10 +02:00
public bool ShowExpiredSupportConcepts
{
get = > MainSessionModel . ShowExpiredSupportConcepts ;
set = > MainSessionModel . ShowExpiredSupportConcepts = value ;
}
2025-06-11 22:56:25 +02:00
2025-05-21 19:34:42 +02:00
[Display(Name = "Hilfeplan")]
2025-06-27 13:11:10 +02:00
public long? SelectedCostBearerSupportConceptOid
{
get = > MainSessionModel . SelectedCostBearerSupportConceptOid ;
set = > MainSessionModel . SelectedCostBearerSupportConceptOid = value ;
}
2025-06-11 22:56:25 +02:00
2025-06-27 13:11:10 +02:00
public long? SelectedServiceCategoryOid
{
get = > MainSessionModel . SelectedServiceCategoryOid ;
set = > MainSessionModel . SelectedServiceCategoryOid = value ;
}
2016-06-27 01:45:38 +02:00
2025-06-27 13:11:10 +02:00
public long? SelectedServiceDescriptionOid { get = > MainSessionModel . SelectedServiceDescriptionOid ;
set = > MainSessionModel . SelectedServiceDescriptionOid = value ;
}
2016-06-27 01:45:38 +02:00
2025-06-11 22:56:25 +02:00
2025-05-21 19:34:42 +02:00
public bool IsAllowedToDeleteServiceRecord ( ServiceRecordDC serviceRecord )
2019-08-08 14:47:53 +02:00
{
var allowed = false ;
2025-06-11 22:56:25 +02:00
if ( LoggedInUser . HasRight ( UserRightType . ServiceRecordView_Delete ) )
2019-08-08 14:47:53 +02:00
{
allowed = true ;
}
2025-06-11 22:56:25 +02:00
else if ( LoggedInUser . HasRight ( UserRightType . ServiceRecord_AllowChangeWithin24Hours ) )
2019-08-08 14:47:53 +02:00
{
if ( serviceRecord . InsertedOn . HasValue )
{
2024-02-20 14:42:04 +01:00
if ( DateTime . Now < serviceRecord . InsertedOn . Value . AddDays ( ApplicationSettings . ServiceRecordAllowChangeHours ) )
2019-08-08 14:47:53 +02:00
{
allowed = true ;
}
}
}
if ( allowed & & ApplicationSettings . MaxDaysEditServiceRecordsAllowed > 0 )
{
2025-06-11 22:56:25 +02:00
if ( ! LoggedInUser . HasRight ( UserRightType . ServiceRecord_AllowEditAfterMaxDaysInNextMonth ) )
2019-08-08 14:47:53 +02:00
{
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 )
{
2025-06-11 22:56:25 +02:00
if ( ! LoggedInUser . HasRight ( UserRightType . ServiceRecordAllowEditAfterMindays ) )
2019-08-08 14:47:53 +02:00
{
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 ;
}
}
}
}
2025-06-11 22:56:25 +02:00
if ( allowed & & ! LoggedInUser . HasRight ( UserRightType . ServiceRecord_AllowEditForOtherEmployees ) )
2019-08-08 14:47:53 +02:00
{
2025-06-11 22:56:25 +02:00
if ( LoggedInUser . Employee . EmployeeOid ! = serviceRecord . Employee . EmployeeOid )
2019-08-08 14:47:53 +02:00
{
allowed = false ;
}
}
if ( allowed & & serviceRecord . GroupOid . HasValue )
{
2025-06-11 22:56:25 +02:00
if ( ! LoggedInUser . HasRight ( UserRightType . ServiceRecord_AllowCreatingGroupBooking ) )
2019-08-08 14:47:53 +02:00
{
allowed = false ;
}
}
return allowed ;
}
2025-06-27 13:11:10 +02:00
public long? SelectedServiceRecordOid
{
get = > MainSessionModel . SelectedServiceRecordOid ;
set = > MainSessionModel . SelectedServiceRecordOid = value ;
}
2025-05-21 19:34:42 +02:00
2025-06-11 22:56:25 +02:00
public ServiceRecordDC SelectedServiceRecord { get ; set ; }
2025-05-21 19:34:42 +02:00
2025-06-27 13:11:10 +02:00
public long? SelectedSupportConceptOid
{
get = > MainSessionModel . SelectedSupportConceptOid ;
set = > MainSessionModel . SelectedSupportConceptOid = value ;
}
2016-06-27 01:45:38 +02:00
2025-07-15 14:26:03 +02:00
public CompactSupportConceptDC SelectedSupportConcept { get ; set ; }
public MokSupportConceptListObject SelectedSupportConceptListObject { get ; set ; }
public int Zeitraum { get ; set ; }
2016-06-27 01:45:38 +02:00
public int ErrorWert { get ; set ; }
2017-02-01 13:53:59 +01:00
public bool ShowSignature { get ; set ; }
2016-06-27 01:45:38 +02:00
2025-06-27 13:19:36 +02:00
public long LastCreatedServiceRecordOid
{
get = > MainSessionModel . LastCreatedServiceRecordOid ;
2025-06-27 13:11:10 +02:00
set = > MainSessionModel . LastCreatedServiceRecordOid = value ;
}
2016-06-27 01:45:38 +02:00
2025-07-18 19:37:01 +02:00
public List < long > SupportConceptOids
{
get = > MainSessionModel . SupportConceptOids ;
set = > MainSessionModel . SupportConceptOids = value ;
}
2025-07-15 14:26:03 +02:00
public List < CompactSupportConceptDC > SupportConcepts { get ; set ; }
2016-06-27 01:45:38 +02:00
2020-11-11 14:21:29 +01:00
public List < TextModuleDC > Textbausteine { get ; set ; } = new List < TextModuleDC > ( ) ;
2017-04-26 14:57:32 +02:00
2022-08-19 13:53:32 +02:00
public List < TextbausteinDisplayItem > TextModules { get ; set ; } = new List < TextbausteinDisplayItem > ( ) ;
2018-02-02 14:43:40 +01:00
private List < ServiceRecordDC > _ServiceRecords ;
2016-06-27 01:45:38 +02:00
public List < ServiceRecordDC > ServiceRecords
{
get
{
2025-06-27 13:11:10 +02:00
if ( _ServiceRecords is null )
2018-03-02 16:33:39 +01:00
{
return _ServiceRecords = new List < ServiceRecordDC > ( ) ;
}
2016-06-27 01:45:38 +02:00
2018-02-02 14:43:40 +01:00
return _ServiceRecords . OrderByDescending ( sr = > sr . Start ) . ToList ( ) ;
2016-06-27 01:45:38 +02:00
}
2025-06-27 13:11:10 +02:00
2018-03-02 16:33:39 +01:00
set = > _ServiceRecords = value ;
2016-06-27 01:45:38 +02:00
}
2025-06-27 13:11:10 +02:00
public List < long > SelectedGoalOids
{
get = > MainSessionModel . SelectedGoalOids ;
set = > MainSessionModel . SelectedGoalOids = value ;
}
2025-06-11 22:56:25 +02:00
2025-07-15 14:26:03 +02:00
public IList < MokZiel > SelectedGoals
2020-04-02 13:19:14 +02:00
{
2025-07-15 14:26:03 +02:00
get = > MainSessionModel . SelectedGoals ;
set = > MainSessionModel . SelectedGoals = value ;
2020-04-02 13:19:14 +02:00
}
2022-08-10 14:13:29 +02:00
private string GetRatingName ( ValueListEntryDC ratedValueListEntry )
{
var rating = GoalRatingTypes . FirstOrDefault ( f = > f . RatingTypeOid . HasValue & & f . RatingTypeOid . Value . Equals ( ratedValueListEntry . RatingTypeOid ) ) ;
return rating ? . DisplayName ? ? "NULL" ;
}
2020-04-02 13:19:14 +02:00
public ServiceRecordDC NewServiceRecord { get ; set ; }
2016-06-27 01:45:38 +02:00
public long? ServiceRecordOidToDelete { get ; set ; }
2025-07-15 14:26:03 +02:00
public IList < MokSupportConceptListObject > SupportConceptListObjects
2019-07-19 17:13:57 +02:00
{
2025-07-15 14:26:03 +02:00
get = > MainSessionModel . SupportConceptListObjects ;
set = > MainSessionModel . SupportConceptListObjects = value ;
2019-07-19 17:13:57 +02:00
}
2025-07-15 14:26:03 +02:00
public IList < MokSupportConceptListObject > SupportConceptListObjectsForGroupBooking { get ; set ; }
2019-07-19 17:13:57 +02:00
2025-07-15 14:26:03 +02:00
public IEnumerable < SelectListItem > GroupOfPeopleListItems
2018-04-27 14:11:21 +02:00
{
get
{
2019-03-29 14:04:12 +01:00
return GroupsOfPeople . Select ( group = > new SelectListItem { Value = $"{group.GroupOfPeopleOid.Value}" , Text = group . Name } ) . ToList ( ) ;
2018-04-27 14:11:21 +02:00
}
}
2017-04-26 14:57:32 +02:00
2023-03-31 12:32:08 +02:00
public List < CompactEmployeeDC > EmployeesForGroupAndMultiBooking { get ; set ; }
2022-12-30 16:28:23 +01:00
public List < CompactEmployeeDC > AllEmployees { get ; set ; }
2016-06-27 01:45:38 +02:00
[Display(Name = "Mitarbeiter")]
2025-06-27 13:11:10 +02:00
public long? SelectedEmployeeOid
{
get = > MainSessionModel . SelectedEmployeeOid ;
set = > MainSessionModel . SelectedEmployeeOid = value ;
}
2016-06-27 01:45:38 +02:00
2025-06-11 22:56:25 +02:00
public CompactEmployeeDC SelectedEmployee { get ; set ; }
2016-06-27 01:45:38 +02:00
2018-11-24 14:28:46 -04:00
public List < GroupOfPeopleDC > GroupsOfPeople { get ; set ; } = new List < GroupOfPeopleDC > ( ) ;
2025-10-30 14:51:52 +01:00
public List < long > GroupBookingSelectedGroupOfPeopleOids
{
get = > MainSessionModel . GroupBookingSelectedGroupOfPeopleOids ;
set = > MainSessionModel . GroupBookingSelectedGroupOfPeopleOids = value ;
}
2018-04-27 14:11:21 +02:00
2025-07-15 14:26:03 +02:00
public IEnumerable < SelectListItem > EmployeeListItems
2016-06-27 01:45:38 +02:00
{
get
{
var result = new List < SelectListItem > ( ) ;
2025-06-11 22:56:25 +02:00
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 ( ) ) ;
2016-06-27 01:45:38 +02:00
return result ;
}
}
2018-03-02 16:33:39 +01:00
2017-02-01 13:53:59 +01:00
public ValueListEntryDC [ ] Dokutypes { get ; set ; }
2018-02-28 12:42:23 +01:00
2020-02-07 15:21:36 +01:00
public int NumberOfDokuTypes = > Dokutypes ? . Length ? ? 0 ;
2018-02-28 12:42:23 +01:00
2025-07-15 14:26:03 +02:00
//public List<long> GroupBookingSelectedSupportConceptOids { get { return MainSessionModel.GroupBookingSelectedSupportConceptOids; } set { MainSessionModel.GroupBookingSelectedSupportConceptOids = value; } }
//public List<CompactSupportConceptDC> GroupBookingSelectedSupportConcepts { get; set; } = new List<CompactSupportConceptDC>();
2018-02-28 12:42:23 +01:00
2025-10-30 14:51:52 +01:00
public List < long > GroupBookingSelectedCostBearerSupportConceptOids
{
get = > MainSessionModel . GroupBookingSelectedCostBearerSupportConceptOids ;
set = > MainSessionModel . GroupBookingSelectedCostBearerSupportConceptOids = value ;
}
2018-03-12 12:07:53 +01:00
2025-07-15 14:26:03 +02:00
public List < SupportConceptCostBearerRelDC > GroupBookingSelectedCostBearerSupportConcepts { get ; set ; } = new List < SupportConceptCostBearerRelDC > ( ) ;
2018-04-18 14:33:21 +02:00
2025-07-15 14:26:03 +02:00
public GroupBookingSelectionObject GroupBookingSelectionObject = > new GroupBookingSelectionObject ( GroupBookingSelectedCostBearerSupportConcepts , GroupBookingSelectedGroupOfPeopleOids ) ;
2018-11-24 14:28:46 -04:00
2025-10-30 14:51:52 +01:00
public List < long > GroupBookingSelectedEmployeeOids
{
get = > MainSessionModel . GroupBookingSelectedEmployeeOids ;
set = > MainSessionModel . GroupBookingSelectedEmployeeOids = value ;
}
2025-06-11 22:56:25 +02:00
public List < CompactEmployeeDC > GroupBookingSelectedEmployees { get ; set ; } = new List < CompactEmployeeDC > ( ) ;
2018-04-18 14:33:21 +02:00
[Display(Name = "Gruppenbuchung")]
public bool IsInGroupBookingMode
{
2025-06-11 22:56:25 +02:00
get = > MainSessionModel . IsInGroupBookingMode ;
2018-04-18 14:33:21 +02:00
2018-11-30 16:47:57 -04:00
set
2018-04-18 14:33:21 +02:00
{
2025-06-11 22:56:25 +02:00
MainSessionModel . IsInGroupBookingMode = value ;
2018-04-18 14:33:21 +02:00
2025-06-11 22:56:25 +02:00
if ( ! MainSessionModel . IsInGroupBookingMode )
2018-04-18 14:33:21 +02:00
{
2025-07-15 14:26:03 +02:00
GroupBookingSelectedCostBearerSupportConceptOids ? . Clear ( ) ;
GroupBookingSelectedCostBearerSupportConcepts . Clear ( ) ;
GroupBookingSelectedEmployeeOids . Clear ( ) ;
2022-12-30 16:28:23 +01:00
GroupBookingSelectedEmployees ? . Clear ( ) ;
2025-07-15 14:26:03 +02:00
GroupBookingSelectedGroupOfPeopleOids . Clear ( ) ;
//GroupBookingSelectedSupportConcept?.Clear();
2025-06-11 22:56:25 +02:00
}
2018-04-18 14:33:21 +02:00
}
}
2025-10-09 12:56:32 +02:00
public bool IsInEditingMode
{
get = > MainSessionModel . IsInEditingMode ;
set = > MainSessionModel . IsInEditingMode = value ;
}
2022-12-30 16:28:23 +01:00
2025-06-11 22:56:25 +02:00
public List < ServiceDescriptionDC > GetServiceDesctiptions ( )
2018-04-18 14:33:21 +02:00
{
var result = new List < ServiceDescriptionDC > ( ) ;
2024-08-02 12:11:53 +02:00
foreach ( var category2Descriptions in Categories2Descriptions )
{
result . AddRangeIfElementsNotIn ( category2Descriptions . Value ) ;
}
2018-04-18 14:33:21 +02:00
return result ;
}
2018-12-12 14:27:40 -04:00
public bool IsServiceRecordNoticeMandatory { get ; set ; } = true ;
2025-10-09 12:56:32 +02:00
public long? PreviouslySelectedEmployeeOid
{
get = > MainSessionModel . PreviouslySelectedEmployeeOid ;
set = > MainSessionModel . PreviouslySelectedEmployeeOid = value ;
}
2025-06-11 22:56:25 +02:00
2020-04-02 13:19:14 +02:00
public CompactEmployeeDC PreviouslySelectedEmployee { get ; set ; }
2025-06-11 22:56:25 +02:00
2025-06-17 13:06:29 +02:00
//public long? PreviouslySelectedSupportConceptOid { get { return MainSessionModel.PreviouslySelectedSupportConceptOid; } set { MainSessionModel.PreviouslySelectedSupportConceptOid = value; } }
//public SupportConceptDC PreviouslySelectedSupportConcept { get; set; }
2025-05-21 19:34:42 +02:00
2025-06-11 22:56:25 +02:00
2025-05-21 19:34:42 +02:00
public long? PreviouslySelectedCostbearer2SupportConceptOid
{
2025-06-11 22:56:25 +02:00
get = > MainSessionModel . PreviouslySelectedCostbearer2SupportConceptOid ;
2025-05-21 19:34:42 +02:00
set
{
var stackTrace = new StackTrace ( ) ;
var callingMethodsName = stackTrace . GetFrame ( 1 ) . GetMethod ( ) . Name ;
2025-06-11 22:56:25 +02:00
var alt = MainSessionModel . PreviouslySelectedCostbearer2SupportConceptOid ;
2025-05-21 19:34:42 +02:00
Log . Info ( $"PreviouslySelectedCostbearer2SupportConceptOid-Set von {alt} zu {value} von Methode: {callingMethodsName}" ) ;
2025-06-11 22:56:25 +02:00
MainSessionModel . PreviouslySelectedCostbearer2SupportConceptOid = value ;
2025-05-21 19:34:42 +02:00
}
}
2020-04-02 13:19:14 +02:00
public bool IsEndDateVisible { get ; set ; }
2025-06-17 13:06:29 +02:00
public static string GetServiceRecordTimeHeader ( MokServiceRecord serviceRecord , bool isForServiceRecordsList )
2020-04-02 13:19:14 +02:00
{
2023-06-18 17:11:35 +02:00
if ( serviceRecord ? . Start is null | | serviceRecord . End is null )
2020-04-02 13:19:14 +02:00
{
return string . Empty ;
2019-03-29 14:04:12 +01:00
}
2019-04-17 17:01:37 +02:00
2020-04-02 13:19:14 +02:00
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}" ;
}
2024-04-18 16:14:20 +02:00
return $"{GetServiceRecordTimeString(serviceRecord)} {gruppenInfo} {signatureToken}" ;
}
2025-06-17 13:06:29 +02:00
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 ;
2025-07-15 14:26:03 +02:00
var dauerInfo = string . Empty ;
2025-06-17 13:06:29 +02:00
var signatureToken = serviceRecord . SignatureOid . HasValue & & isForServiceRecordsList ? "✔" : string . Empty ;
2025-07-15 14:26:03 +02:00
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.)" ;
}
2025-06-17 13:06:29 +02:00
if ( serviceRecord . GroupOid . HasValue )
{
2025-07-15 14:26:03 +02:00
gruppenInfo = $" Gruppe ({serviceRecord.GroupPersonCount} Teilnehmer, {serviceRecord.GroupEmployeeCount} Betreuer)" ;
2025-06-17 13:06:29 +02:00
}
2025-07-15 14:26:03 +02:00
2025-06-17 13:06:29 +02:00
2025-07-15 14:26:03 +02:00
return $"{GetServiceRecordTimeString(serviceRecord)}{gruppenInfo}{dauerInfo} {signatureToken}" ;
2025-06-17 13:06:29 +02:00
}
2024-04-18 16:14:20 +02:00
public static string GetServiceRecordTimeString ( ServiceRecordDC serviceRecord )
{
if ( serviceRecord ? . Start is null | | serviceRecord . End is null )
{
return string . Empty ;
}
var start = serviceRecord . Start . Value ;
2025-03-12 16:42:26 +01:00
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
2024-04-18 16:14:20 +02:00
2025-03-12 16:42:26 +01:00
if ( start . Second = = 0 )
2020-04-02 13:19:14 +02:00
{
return start . Date ! = end . Date ?
2024-04-18 16:14:20 +02:00
$"{start.ToShortDateString()} {start.ToShortTimeString()} - {end.ToShortDateString()} {end.ToShortTimeString()}" :
$"{start.ToShortDateString()} {start.ToShortTimeString()} - {end.ToShortTimeString()}" ;
2020-04-02 13:19:14 +02:00
}
2024-04-18 16:14:20 +02:00
return start . Date ! = end . Date ?
$"{start.ToShortDateString()} - {end.ToShortDateString()}" :
$"{start.ToShortDateString()}" ;
2020-04-02 13:19:14 +02:00
}
2024-04-18 16:14:20 +02:00
2025-06-17 13:06:29 +02:00
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()}" ;
}
2020-04-02 13:19:14 +02:00
public bool HasRightToEditServiceRecord ( ServiceRecordDC serviceRecord )
{
var allowed = false ;
2025-06-11 22:56:25 +02:00
if ( LoggedInUser . HasRight ( UserRightType . ServiceRecordView_Edit ) )
2020-04-02 13:19:14 +02:00
{
allowed = true ;
}
2025-06-11 22:56:25 +02:00
else if ( LoggedInUser . HasRight ( UserRightType . ServiceRecord_AllowChangeWithin24Hours ) )
2020-04-02 13:19:14 +02:00
{
if ( serviceRecord . InsertedOn ! = null )
{
if ( DateTime . Now < serviceRecord . InsertedOn . Value . AddDays ( 1 ) )
{
allowed = true ;
}
}
}
if ( allowed & & ApplicationSettings . MaxDaysEditServiceRecordsAllowed > 0 )
{
2025-06-11 22:56:25 +02:00
if ( ! LoggedInUser . HasRight ( UserRightType . ServiceRecord_AllowEditAfterMaxDaysInNextMonth ) )
2020-04-02 13:19:14 +02:00
{
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 ;
}
}
}
}
2025-06-11 22:56:25 +02:00
if ( allowed & & ! LoggedInUser . HasRight ( UserRightType . ServiceRecord_AllowEditForOtherEmployees ) )
2020-04-02 13:19:14 +02:00
{
2025-06-11 22:56:25 +02:00
if ( LoggedInUser . Employee . EmployeeOid ! = serviceRecord . Employee . EmployeeOid )
2020-04-02 13:19:14 +02:00
{
allowed = false ;
}
}
if ( allowed & & serviceRecord . GroupOid . HasValue )
{
2025-06-11 22:56:25 +02:00
if ( ! LoggedInUser . HasRight ( UserRightType . ServiceRecord_AllowCreatingGroupBooking ) )
2020-04-02 13:19:14 +02:00
{
allowed = false ;
}
}
if ( allowed & & ApplicationSettings . AnzTageZeiterfassErfolgt > 0 )
{
2025-06-11 22:56:25 +02:00
if ( ! LoggedInUser . HasRight ( UserRightType . ServiceRecordAllowEditAfterMindays ) )
2020-04-02 13:19:14 +02:00
{
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 ;
}
2023-05-02 13:03:46 +02:00
public bool IsZeiterfassungInStdMin = > EinheitZeiterfassung = = 2 ;
public int EinheitZeiterfassung { get ; set ; }
2020-04-08 14:44:20 +02:00
2025-05-16 19:24:16 +02:00
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" ) ;
2020-04-08 14:44:20 +02:00
public string StartDateToEdit = > SelectedServiceRecord ? . Start ? . ToShortDateString ( ) ? ? DateTime . Today . ToShortDateString ( ) ;
public string EndDateToEdit = > SelectedServiceRecord ? . End ? . ToShortDateString ( ) ? ? DateTime . Today . ToShortDateString ( ) ;
2020-09-21 11:57:10 +02:00
public string StartTimeToEdit
{
get
{
var start = SelectedServiceRecord ? . Start ;
2021-06-16 15:11:39 +02:00
if ( start ! = null & & ! start . Value . GetServiceRecordNoDateTimeDate ( ) . Equals ( start ) )
2020-09-21 11:57:10 +02:00
{
return start . Value . ToString ( "HH:mm" ) ;
}
2025-10-30 14:51:52 +01:00
2020-09-21 11:57:10 +02:00
return string . Empty ;
}
}
2020-04-08 14:44:20 +02:00
2020-09-21 11:57:10 +02:00
public string EndTimeToEdit
{
get
{
var end = SelectedServiceRecord ? . End ;
2023-06-21 19:19:56 +02:00
if ( end ! = null & & end . Value . Second ! = 1 )
2020-09-21 11:57:10 +02:00
{
return end . Value . ToString ( "HH:mm" ) ;
}
return string . Empty ;
}
}
2020-04-08 14:44:20 +02:00
2023-05-15 11:54:13 +02:00
public string DurationToEdit
{
get
{
2025-11-14 14:30:41 +01:00
if ( SelectedServiceRecord ! = null )
2023-05-15 11:54:13 +02:00
{
2025-11-14 14:30:41 +01:00
var duration = SelectedServiceRecord . GroupRoundedDuration ? ? SelectedServiceRecord . RoundedDuration ;
2025-07-04 00:30:36 +02:00
2025-11-14 14:30:41 +01:00
if ( SelectedDurationUnit = = "Stunden" )
2025-07-04 00:30:36 +02:00
{
return Math . Round ( duration / 60 , 2 , MidpointRounding . AwayFromZero ) . ToString ( ) ;
}
2025-11-14 14:30:41 +01:00
2025-07-04 00:30:36 +02:00
return Math . Round ( duration , 0 , MidpointRounding . AwayFromZero ) . ToString ( ) ;
2023-05-15 11:54:13 +02:00
}
2025-07-04 00:30:36 +02:00
return string . Empty ;
2023-05-15 11:54:13 +02:00
}
}
2020-04-08 14:44:20 +02:00
2025-07-17 16:26:07 +02:00
public string DistanceToEdit
{
get
{
2025-10-09 12:56:32 +02:00
if ( SelectedServiceRecord ! = null & & SelectedServiceRecord . DistanceInMeterDecimal . HasValue )
2025-07-17 16:26:07 +02:00
{
var dist = SelectedServiceRecord . DistanceInMeterDecimal . Value ;
2025-10-09 12:56:32 +02:00
return Math . Round ( dist , 2 , MidpointRounding . AwayFromZero ) . ToString ( ) ;
2025-07-17 16:26:07 +02:00
}
return string . Empty ;
}
}
2020-04-08 14:44:20 +02:00
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" ;
2023-03-03 21:54:36 +01:00
public long SelectedServiceRecordsServiceDescriptionOid = > SelectedServiceRecord ? . ServiceDescription ? . ServiceDescriptionOid ? ? 0L ;
2021-04-13 19:45:21 +02:00
2025-07-17 16:26:07 +02:00
public ServiceRecordDC FindServiceRecord ( long serviceRecordOid )
2021-04-13 19:45:21 +02:00
{
return ServiceRecords . FirstOrDefault ( serviceRecord = > serviceRecord . ServiceRecordOid . Equals ( serviceRecordOid ) ) ;
}
2021-06-16 15:11:39 +02:00
public List < RatingTypeDC > GoalRatingTypes { get ; set ; } = new List < RatingTypeDC > ( ) ;
public ValueListEntryDC GetGoalByOid ( long goalOid )
{
2021-07-21 15:36:18 +02:00
return SelectedSupportConcept ? . Goals . FirstOrDefault ( goal = > goal . ValueListEntryOid = = goalOid ) ;
2021-06-16 15:11:39 +02:00
}
public bool HasAnyRatingTypes { get ; set ; }
2022-08-10 14:13:29 +02:00
public List < GoalTreeItem > GoalTree { get ; set ; } = new List < GoalTreeItem > ( ) ;
2022-08-19 13:53:32 +02:00
public List < TextbausteinDisplayItem > AllTextModules { get ; set ; } = new List < TextbausteinDisplayItem > ( ) ;
2022-09-07 13:19:08 +02:00
public bool SetStartTimeToEndTimeAfterSave { get ; set ; }
2025-10-30 14:51:52 +01:00
public DateTime ? NewStartDate
{
get = > MainSessionModel ? . NewStartDate ;
set = > MainSessionModel . NewStartDate = value ;
}
2022-09-07 13:19:08 +02:00
public string NewStartTime
{
get
{
var start = NewStartDate ;
if ( start . HasValue & & ! start . Value . GetServiceRecordNoDateTimeDate ( ) . Equals ( start ) )
{
return start . Value . ToString ( "HH:mm" ) ;
}
return string . Empty ;
}
}
2025-10-30 14:51:52 +01:00
2022-09-07 13:19:08 +02:00
public string NewStartDateStr = > NewStartDate ? . ToShortDateString ( ) ;
2025-10-30 14:51:52 +01:00
public DateTime ? NewEndDate
{
get = > MainSessionModel ? . NewEndDate ;
set = > MainSessionModel . NewEndDate = value ;
}
2022-09-07 13:19:08 +02:00
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" ;
2022-12-30 16:28:23 +01:00
public DateTime LastSelectedServiceRecordMonth { get ; set ; }
public int LastSelectedServiceRecordTimeIntervalDays { get ; set ; }
2023-05-15 11:54:13 +02:00
/// <summary>
/// Zeitraum der Zeiterfassungseintragsliste (z.B. Alle, Letzte 7 Tage, etc.)
/// </summary>
2022-12-30 16:28:23 +01:00
public ServiceRecordTimeInterval ServiceRecordTimeInterval { get ; set ; }
public int SelectedDayCount { get ; set ; }
2025-06-11 22:56:25 +02:00
public NullableDateTimeSpan SelectedZeitraum { get { return MainSessionModel . SelectedZeitraum ; } set { MainSessionModel . SelectedZeitraum = value ; } }
2022-12-30 16:28:23 +01:00
2023-02-23 11:48:41 +01:00
public bool IsOnlyYearMonthVisible { get ; set ; }
2022-12-30 16:28:23 +01:00
#region Mehrfachbuchung
[Display(Name = "Mehrfachbuchung")]
2025-06-11 22:56:25 +02:00
public bool IsInMultiBookingMode { get { return MainSessionModel . IsInMultiBookingMode ; } set { MainSessionModel . IsInMultiBookingMode = value ; } }
2022-12-30 16:28:23 +01:00
2025-07-15 14:26:03 +02:00
2022-12-30 16:28:23 +01:00
2023-07-13 13:39:41 +02:00
#endregion
public bool IsPasswordSecurityEnabled { get ; set ; }
2023-07-31 15:29:16 +02:00
public bool ShowMarker { get ; set ; }
2024-01-12 17:16:52 +01:00
#region ServiceRecord - Pagination
public int ServiceRecordCount { get ; set ; }
2025-12-10 13:37:14 +01:00
public int CurrentPage { get = > MainSessionModel . CurrentPage ; set = > MainSessionModel . CurrentPage = value ; }
2024-01-12 17:16:52 +01:00
public int MaxResults { get ; set ; } = 10 ;
public int ServiceRecordPageCount { get ; set ; }
#endregion
2024-04-18 16:14:20 +02:00
public string OneTimeLink { get ; set ; }
public string OneTimeLinkText { get ; set ; }
2024-04-23 17:24:14 +02:00
2024-04-30 12:18:38 +02:00
public string ShareDetails { get ; set ; }
2024-04-23 17:24:14 +02:00
public bool IsCustomerAbsence { get ; set ; }
public string CustomerAbsenceInfo { get ; set ; }
2024-06-05 14:45:33 +02:00
public Dictionary < long , List < string > > ServiceRecordOids2GoalHeader { get ; set ; }
public bool FilterGroupServiceCategories { get ; set ; }
2024-07-24 16:45:56 +02:00
public Dictionary < ServiceCategoryDC , List < ServiceDescriptionDC > > Categories2Descriptions { get ; set ; } = new Dictionary < ServiceCategoryDC , List < ServiceDescriptionDC > > ( ) ;
2024-06-05 14:45:33 +02:00
public ServiceCategoryDC SelectedServiceCategory { get ; set ; }
2024-06-26 18:53:59 +02:00
2024-06-05 14:45:33 +02:00
public ServiceDescriptionDC SelectedServiceDescription { get ; set ; }
2025-06-11 22:56:25 +02:00
public List < ValueListEntryDC > AllGoals { get ; internal set ; }
2024-06-26 12:29:22 +02:00
public ServiceDescriptionDC GetSelectedOrFirstServiceDescription ( )
{
2025-05-21 19:34:42 +02:00
if ( SelectedServiceDescription ! = null | | Categories2Descriptions is null )
2024-06-26 12:29:22 +02:00
{
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 ;
}
2024-09-12 14:55:35 +02:00
2025-08-08 13:45:37 +02:00
public BookingMode CurrentBookingMode
{
get
{
if ( IsInGroupBookingMode )
{
return BookingMode . GroupBookingMode ;
}
return IsInMultiBookingMode ? BookingMode . MultiBookingMode : BookingMode . SingleBookingMode ;
}
}
2025-08-15 10:10:25 +02:00
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 ;
}
}
2025-10-09 12:56:32 +02:00
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 ( ',' ) ;
}
2025-11-14 14:30:41 +01:00
public ServiceRecord2Monatsunterschrift ServiceRecord2Monatsunterschrift { get ; set ; }
2025-11-20 10:44:52 +01:00
public string SignaturePopupTitle { get ; set ; }
2019-04-17 17:01:37 +02:00
}
2019-03-29 14:04:12 +01:00
public class CustomSelectListItem
{
2020-04-02 13:19:14 +02:00
public string Text1 { get ; }
public string Text2 { get ; }
public string Value { get ; }
public string TextColor { get ; }
2024-06-26 12:29:22 +02:00
public long? SupportConceptOid { get ; }
public long? CostBearer2SupportConceptOid { get ; }
2019-03-29 14:04:12 +01:00
2024-06-26 12:29:22 +02:00
public CustomSelectListItem ( string pText1 , string pText2 , string pValue , string pTextColor , long? supportConceptOid , long? costBearer2SupportConceptOid )
2019-03-29 14:04:12 +01:00
{
2020-04-02 13:19:14 +02:00
Text1 = pText1 ;
Text2 = pText2 ;
Value = pValue ;
2019-03-29 14:04:12 +01:00
TextColor = pTextColor ;
2024-06-26 12:29:22 +02:00
SupportConceptOid = supportConceptOid ;
CostBearer2SupportConceptOid = costBearer2SupportConceptOid ;
2019-03-29 14:04:12 +01:00
}
}
2016-06-27 01:45:38 +02:00
}