2016-06-27 01:45:38 +02:00
using System ;
using System.Collections.Generic ;
using System.ComponentModel.DataAnnotations ;
using System.Linq ;
using System.Web.Mvc ;
2020-12-16 21:49:47 +01:00
using BeWo.View.Navigation.Filter ;
2016-06-27 01:45:38 +02:00
using BeWoPlanerMobil.Service ;
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 ;
2016-06-27 01:45:38 +02:00
namespace BeWoPlanerMobil.Models
{
2019-07-25 14:56:11 +02:00
public class MainModel : AbstractModel
{
2024-07-24 16:45:56 +02:00
public long? SelectedCostBearerSupportConceptRelOid { get ; set ; }
2023-05-02 13:03:46 +02:00
[Display(Name = "Nur meine Klienten anzeigen")]
2016-06-27 01:45:38 +02:00
public bool ShowOnlyOwnSupportConcepts { get ; set ; }
2023-05-02 13:03:46 +02:00
[Display(Name = "Nur Klienten meiner Teams anzeigen")]
2020-12-16 21:49:47 +01:00
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 ;
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 } ) )
{
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 ;
}
}
2018-02-28 12:42:23 +01:00
[Display(Name = "Abgelaufene Hilfepläne anzeigen")]
public bool ShowExpiredSupportConcepts { get ; set ; }
2016-06-27 01:45:38 +02:00
[Display(Name = "Hilfeplan")]
public long? CostBearer2SupportConceptOid { get ; set ; }
2024-07-24 16:45:56 +02:00
public long? SelectedServiceCategoryOid = > SelectedServiceCategory ? . ServiceCategoryOid ;
public long? SelectedServiceDescriptionOid = > SelectedServiceDescription ? . ServiceDescriptionOid ;
2016-06-27 01:45:38 +02:00
public long? SelectedServiceRecordOid { get ; set ; }
2019-08-08 14:47:53 +02:00
public static 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 )
{
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 )
{
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 ; }
2018-04-18 14:33:21 +02:00
2016-06-27 01:45:38 +02:00
public SupportConceptDC SelectedSupportConcept { get ; set ; }
public int Zeitraum { get ; set ; }
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
2018-02-02 14:43:40 +01:00
public long ServiceRecordOid { get ; set ; }
2016-06-27 01:45:38 +02:00
public List < SupportConceptDC > SupportConcepts { get ; set ; }
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
{
2018-02-02 14:43:40 +01:00
if ( _ServiceRecords = = 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
}
2018-03-02 16:33:39 +01:00
set = > _ServiceRecords = value ;
2016-06-27 01:45:38 +02:00
}
2020-04-02 13:19:14 +02:00
private List < ValueListEntryDC > _SelectedGoals ;
public List < ValueListEntryDC > SelectedGoals
{
get = > _SelectedGoals ? ? new List < ValueListEntryDC > ( ) ;
set = > _SelectedGoals = value ;
}
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 ; }
2018-10-08 11:57:16 +02:00
public bool ShowDistanceField { get ; set ; }
2017-04-26 14:57:32 +02:00
2018-02-02 14:43:40 +01:00
public MainModel ( )
2016-06-27 01:45:38 +02:00
{
NewServiceRecord = new ServiceRecordDC ( ) ;
ShowOnlyOwnSupportConcepts = true ;
ErrorWert = 1 ;
}
2024-07-24 16:45:56 +02:00
public IEnumerable < CostBearer2SupportConceptRelListObject > SupportConceptListObjects
2019-07-19 17:13:57 +02:00
{
get
{
2024-07-24 16:45:56 +02:00
var allCostBearerRelations = new List < CostBearer2SupportConceptRelListObject > { new CostBearer2SupportConceptRelListObject ( "Hilfeplan auswählen" , "" , "-1" , false , false ) , new CostBearer2SupportConceptRelListObject ( "Ohne Hilfeplan" , "" , "-2" , false , false ) } ;
2019-07-19 17:13:57 +02:00
foreach ( var sc in SupportConcepts . OrderBy ( sc = > sc . Customer . LastName ) )
{
2023-06-12 17:27:53 +02:00
allCostBearerRelations . AddRange ( sc . CostBearerRelations . Where ( w = > ShowExpiredSupportConcepts | | w . EndDate is null | | w . EndDate . Value > = DateTime . Now . Date ) . Select (
2024-07-24 16:45:56 +02:00
cb = > new CostBearer2SupportConceptRelListObject (
2023-12-21 19:08:53 +01:00
$"{sc.Customer.SimpleDescription} {(sc.Customer.DateOfBirth.HasValue ? " * " + sc.Customer.DateOfBirth.Value.ToString(" dd . MM . yyyy ") : string.Empty)}" ,
2023-06-18 17:11:35 +02:00
$"{cb.AuswahlBezeichnung} {cb.StartDate?.ToShortDateString().Remove(6, 2) ?? string.Empty}-{cb.EndDate?.ToShortDateString().Remove(6, 2) ?? string.Empty} {cb.CostBearer.Name}{GetIsNotApproved(cb)}" ,
2019-07-19 19:50:15 +02:00
cb . CostBearer2SupportConceptOid . ToString ( ) ,
2019-07-29 19:40:14 +02:00
cb . SupportConcept . IsAboutToExpire ,
cb . SupportConcept . ExpiresIn3MonthOrLess ) )
2019-07-19 17:13:57 +02:00
) ;
}
return allCostBearerRelations ;
}
}
2024-07-24 16:45:56 +02:00
2022-04-28 20:03:43 +02:00
2024-07-24 16:45:56 +02:00
public CostBearer2SupportConceptRelListObject SelectedCostBearer2SupportConceptRelListObject { get ; set ; }
2019-07-19 17:13:57 +02:00
2023-01-16 14:55:13 +01:00
public List < SupportConceptCostBearerRelDC > SelectedConceptCostBearerRelations { get ; set ; }
2019-03-29 14:04:12 +01:00
2022-12-30 16:28:23 +01:00
public GroupBookingSelectionObject GroupBookingSelectionObject = > new GroupBookingSelectionObject ( SelectedConceptCostBearerRelations , GroupBookingSelectedGroupOfPeopleOids ) ;
2020-04-02 13:19:14 +02:00
2024-07-24 16:45:56 +02:00
public IEnumerable < CostBearer2SupportConceptRelListObject > SupportConceptListObjectsForGroupBooking
2019-07-19 17:13:57 +02:00
{
get
{
2024-07-24 16:45:56 +02:00
var allCostbearerRelations = new List < CostBearer2SupportConceptRelListObject > ( ) ;
2019-07-19 17:13:57 +02:00
foreach ( var sc in SupportConcepts . OrderBy ( sc = > sc . Customer . LastName ) )
{
2023-12-21 19:08:53 +01:00
allCostbearerRelations . AddRange ( sc . CostBearerRelations . Where ( w = > ShowExpiredSupportConcepts | | w . EndDate is null | | w . EndDate . Value > = DateTime . Now ) . Select (
2024-07-24 16:45:56 +02:00
cb = > new CostBearer2SupportConceptRelListObject (
2023-12-21 19:08:53 +01:00
$"{sc.Customer.SimpleDescription} {(sc.Customer.DateOfBirth.HasValue ? " * " + sc.Customer.DateOfBirth.Value.ToString(" dd . MM . yyyy ") : string.Empty)}" ,
2023-06-18 17:11:35 +02:00
$"{cb.AuswahlBezeichnung} {cb.StartDate?.ToShortDateString().Remove(6, 2) ?? string.Empty}-{cb.EndDate?.ToShortDateString().Remove(6, 2) ?? string.Empty} {cb.CostBearer.Name}" ,
2019-07-19 19:50:15 +02:00
cb . CostBearer2SupportConceptOid . ToString ( ) ,
cb . SupportConcept . IsAboutToExpire ,
cb . SupportConcept . ExpiresIn3MonthOrLess ) )
2019-07-19 17:13:57 +02:00
) ;
}
return allCostbearerRelations ;
}
}
2018-04-27 14:11:21 +02:00
public IEnumerable < SelectListItem > GroupOfPeopleListItems
{
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
2016-06-27 01:45:38 +02:00
public List < CompactEmployeeDC > Employees { get ; set ; }
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")]
2018-12-12 14:27:40 -04:00
public long? SelectedEmployeeOid = > SelectedEmployee ? . EmployeeOid ;
2016-06-27 01:45:38 +02:00
2018-12-12 14:27:40 -04: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 > ( ) ;
2022-12-30 16:28:23 +01:00
public List < long > GroupBookingSelectedGroupOfPeopleOids { get ; set ; } = new List < long > ( ) ;
2018-04-27 14:11:21 +02:00
2016-06-27 01:45:38 +02:00
public IEnumerable < SelectListItem > EmployeeListItems
{
get
{
var result = new List < SelectListItem > ( ) ;
2018-10-08 11:57:16 +02:00
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 ( ) ) ;
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 ;
public static DateTime ? GetEndDateOfSupportConcept ( SupportConceptDC pSupportConcept )
2018-02-28 12:42:23 +01:00
{
2018-03-02 16:33:39 +01:00
DateTime ? maxDate = null ;
2018-02-28 12:42:23 +01:00
foreach ( var relation in pSupportConcept . CostBearerRelations )
{
var end = relation . ApprovedEndDate ? ? relation . RequestedEndDate ;
2018-03-02 16:33:39 +01:00
if ( maxDate = = null | | end ! = null & & end . Value > maxDate . Value )
2018-02-28 12:42:23 +01:00
{
maxDate = end ;
}
}
return maxDate ;
}
2018-03-12 12:07:53 +01:00
2022-12-30 16:28:23 +01:00
public List < SupportConceptDC > GroupBookingSelectedSupportConcepts { get ; set ; } = new List < SupportConceptDC > ( ) ;
2018-04-18 14:33:21 +02:00
2022-12-30 16:28:23 +01:00
public List < long > GroupBookingSelectedCostbearerRelOids { get ; set ; } = new List < long > ( ) ;
2018-11-24 14:28:46 -04:00
2022-12-30 16:28:23 +01:00
public List < CompactEmployeeDC > GroupBookingSelectedEmployees { get ; set ; } = new List < CompactEmployeeDC > ( ) ;
2018-04-18 14:33:21 +02:00
[Display(Name = "Gruppenbuchung")]
public bool IsInGroupBookingMode
{
2018-11-30 16:47:57 -04:00
get = > _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
{
_IsInGroupBookingMode = value ;
if ( ! _IsInGroupBookingMode )
{
2022-12-30 16:28:23 +01:00
GroupBookingSelectedSupportConcepts ? . Clear ( ) ;
GroupBookingSelectedEmployees ? . Clear ( ) ;
2018-04-18 14:33:21 +02:00
}
}
}
private bool _IsInGroupBookingMode ;
2022-12-30 16:28:23 +01:00
2018-04-18 14:33:21 +02:00
public bool IsInEditingMode { get ; set ; }
public List < ServiceDescriptionDC > GetServiceDesctiptions ( )
{
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 ;
2020-04-02 13:19:14 +02:00
public CompactEmployeeDC PreviouslySelectedEmployee { get ; set ; }
public SupportConceptDC PreviouslySelectedSupportConcept { get ; set ; }
2024-03-14 17:18:35 +01:00
public long? PreviouslySelectedCostbearer2SupportConceptOid { get ; set ; }
2020-04-02 13:19:14 +02:00
public bool IsEndDateVisible { get ; set ; }
public static string GetServiceRecordTimeHeader ( ServiceRecordDC serviceRecord , bool isForServiceRecordsList )
{
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}" ;
}
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
2020-04-02 13:19:14 +02:00
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 ;
}
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
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" ) ;
}
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
{
if ( SelectedDurationUnit = = "Stunden" )
{
return SelectedServiceRecord is null ? string . Empty : ( SelectedServiceRecord . RoundedDuration / 60 ) . ToString ( ) ;
}
return SelectedServiceRecord ? . RoundedDuration . ToString ( ) ? ? string . Empty ;
}
}
2020-04-08 14:44:20 +02:00
2023-09-19 14:44:52 +02:00
public string DistanceToEdit = > SelectedServiceRecord ? . DistanceInMeterDecimal . ToString ( ) ? ? 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
public ServiceRecordDC GetServiceRecord ( long serviceRecordOid )
{
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 ; }
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" ;
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 ; }
public NullableDateTimeSpan SelectedZeitraum { get ; set ; }
2023-02-23 11:48:41 +01:00
public bool IsOnlyYearMonthVisible { get ; set ; }
2022-12-30 16:28:23 +01:00
#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 > ( ) ;
2023-01-16 15:04:29 +01:00
public List < SupportConceptCostBearerRelDC > MultiBookingSelectedConceptCostBearerRelations { get ; set ; }
2022-12-30 16:28:23 +01:00
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 > ( ) ;
2024-07-24 16:45:56 +02:00
public List < CostBearer2SupportConceptRelListObject > MultiBookingSupportConceptListObjects
2022-12-30 16:28:23 +01:00
{
get
{
2024-07-24 16:45:56 +02:00
var allCostbearerRelations = new List < CostBearer2SupportConceptRelListObject > ( ) ;
2022-12-30 16:28:23 +01:00
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 (
2024-07-24 16:45:56 +02:00
cb = > new CostBearer2SupportConceptRelListObject (
2023-12-21 19:08:53 +01:00
$"{sc.Customer.SimpleDescription} {(sc.Customer.DateOfBirth.HasValue ? " * " + sc.Customer.DateOfBirth.Value.ToString(" dd . MM . yyyy ") : string.Empty)}" ,
2023-06-18 17:11:35 +02:00
$"{cb.AuswahlBezeichnung} {cb.StartDate?.ToShortDateString().Remove(6, 2) ?? string.Empty}-{cb.EndDate?.ToShortDateString().Remove(6, 2) ?? string.Empty} {cb.CostBearer.Name}" ,
2022-12-30 16:28:23 +01:00
cb . CostBearer2SupportConceptOid . ToString ( ) ,
cb . SupportConcept . IsAboutToExpire ,
cb . SupportConcept . ExpiresIn3MonthOrLess ) )
) ;
}
return allCostbearerRelations ;
}
}
2023-07-13 13:39:41 +02:00
#endregion
2023-05-15 11:54:13 +02:00
public MandatorDC Mandator { get ; set ; }
2023-07-13 13:39:41 +02:00
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 ; }
public int CurrentPage { get ; set ; }
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 ; }
2024-06-26 12:29:22 +02:00
public ServiceDescriptionDC GetSelectedOrFirstServiceDescription ( )
{
if ( ! ( SelectedServiceDescription is 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 ;
}
2024-09-12 14:55:35 +02:00
public bool ShowBetrag { 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
}
}
2019-07-19 17:13:57 +02:00
2024-07-24 16:45:56 +02:00
public class CostBearer2SupportConceptRelListObject
2019-07-19 17:13:57 +02:00
{
2020-04-02 13:19:14 +02:00
public string NameAndDateOfBirth { get ; }
2019-07-19 17:13:57 +02:00
2020-04-02 13:19:14 +02:00
public string SupportConceptTimeSpan { get ; }
2019-07-19 17:13:57 +02:00
2020-04-02 13:19:14 +02:00
public string CostBearer2SupportConceptOid { get ; }
2019-07-19 17:13:57 +02:00
2020-04-02 13:19:14 +02:00
public string CostBearer2SupportConceptOidName { get ; }
2019-07-19 17:13:57 +02:00
2020-04-02 13:19:14 +02:00
public bool IsAboutToExpire { get ; }
public bool ExpiresInThreeMonthsOrLess { get ; }
2019-07-19 17:13:57 +02:00
2024-07-24 16:45:56 +02:00
public CostBearer2SupportConceptRelListObject ( string pNameAndDateOfBirth , string pSupportConceptTimeSpan , string pCostBearer2SupportConceptOid , bool isAboutToExpire , bool expiresIn3MonthOrLess )
2019-07-19 17:13:57 +02:00
{
NameAndDateOfBirth = pNameAndDateOfBirth ;
SupportConceptTimeSpan = pSupportConceptTimeSpan ;
CostBearer2SupportConceptOid = pCostBearer2SupportConceptOid ;
CostBearer2SupportConceptOidName = "OidHolder_" + CostBearer2SupportConceptOid ;
2020-02-07 15:21:36 +01:00
IsAboutToExpire = isAboutToExpire ;
ExpiresInThreeMonthsOrLess = expiresIn3MonthOrLess ;
2019-07-19 17:13:57 +02:00
}
2020-04-02 13:19:14 +02:00
public override bool Equals ( object obj )
{
2024-07-24 16:45:56 +02:00
if ( ! ( obj is CostBearer2SupportConceptRelListObject ) )
2020-04-02 13:19:14 +02:00
{
return false ;
}
2024-07-24 16:45:56 +02:00
var obj2 = ( CostBearer2SupportConceptRelListObject ) obj ;
2020-04-02 13:19:14 +02:00
2021-04-13 19:45:21 +02:00
return Equals ( CostBearer2SupportConceptOid , obj2 . CostBearer2SupportConceptOid ) ;
2020-04-02 13:19:14 +02:00
}
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 ;
}
}
2019-07-19 17:13:57 +02:00
}
2016-06-27 01:45:38 +02:00
}