346 lines
16 KiB
C#
346 lines
16 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BeWoPlanerMobil.Service;
|
|
using BeWoPlanerMobil.Util;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace BeWoPlanerMobil.Models
|
|
{
|
|
public class AbstractModel
|
|
{
|
|
public bool HasRightToEditEmployeeAbsenceTimes => CheckRight(UserRightType.Employee_AllowEditAbsenceTimes);
|
|
public bool IsDeleteBtnVisible => CheckRight(UserRightType.ServiceRecordView_Delete);
|
|
|
|
public bool IsAllowedToSeeScheduler => LoggedInUser != null && CheckRight(UserRightType.KalenderAnsehen) || CheckRight(UserRightType.ViewAll);
|
|
|
|
public bool IsAllowedToSeeCustomers => CheckRight(UserRightType.ViewAll) || CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers);
|
|
|
|
public bool IsEmployeeSelectionVisible => CheckRight(UserRightType.ServiceRecord_AllowCreationForOtherEmployees) || CheckRight(UserRightType.ServiceRecord_AllowCreationForOtherTeamMember);
|
|
|
|
public bool IsAllowedToSeePersons => CheckRight(UserRightType.ViewAll) || CheckRight(UserRightType.PersonView_View);
|
|
|
|
public bool IsAllowedToSeeCustomerNotes => CheckRight(UserRightType.ViewAll) || CheckRight(UserRightType.Customer_ViewNotizen);
|
|
|
|
public bool HasRightForGroupBookings => CheckRight(UserRightType.ServiceRecord_AllowCreatingGroupBooking);
|
|
|
|
public bool HasRightToViewCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAlleAnsehen) || CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers) || CheckRight(UserRightType.Customer_ViewMyTeams);
|
|
public bool HasRightToViewEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAnsehen) || CheckRight(UserRightType.ViewAll);
|
|
public bool HasRightToViewAllResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAnsehen) || CheckRight(UserRightType.ViewAll);
|
|
|
|
public BaseSessionModel SessionModel { get; internal set; }
|
|
|
|
public UserDC LoggedInUser { get; set; }
|
|
|
|
public MokMandator Mandator { get; set; }
|
|
|
|
public EmployeeDC LoggedInEmployee { get; set; }
|
|
|
|
public string LoggedInEmplyeeFirstNameLastName => LoggedInEmployee != null ? $"{LoggedInEmployee.FirstName} {LoggedInEmployee.LastName}" : "BeWoPlaner";
|
|
|
|
public bool HasRightToSeeAllSupportConcepts => CheckRight(UserRightType.SupportConcept_ViewAllSupportConcepts) || CheckRight(UserRightType.ViewAll);
|
|
|
|
public bool HasRightToSeeTextModules => CheckRight(UserRightType.TextbausteineNurEigeneAnsehen) || CheckRight(UserRightType.TextbausteineAlleAnsehen);
|
|
public bool HasRightToSeeOwnTextModules => CheckRight(UserRightType.TextbausteineNurEigeneAnsehen);
|
|
public bool HasRightToSeeGlobalTextModules => CheckRight(UserRightType.TextbausteineAlleAnsehen);
|
|
|
|
public bool HasRightToSeeServiceRecords => CheckRight(UserRightType.ServiceRecordView_View) && CheckRight(UserRightType.ServiceRecordView_Create);
|
|
|
|
public static string TimeOfLastAction
|
|
{
|
|
get => MobileSessionFacade.TimeOfLastAction;
|
|
set => MobileSessionFacade.TimeOfLastAction = value;
|
|
}
|
|
|
|
public bool HasRightToInsertRessourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAnlegen) || CheckRight(UserRightType.CreateAll);
|
|
|
|
public bool HasRightToUseAiVoice
|
|
{
|
|
get
|
|
{
|
|
|
|
var showAiVoice = MobileUtils.GetSettingValue(Mandator.Settings, SettingsKeys.ShowAIVoice);
|
|
var showOwnChat = MobileUtils.GetSettingValue(Mandator.Settings, SettingsKeys.ShowChat);
|
|
|
|
#if DEBUG
|
|
showAiVoice = "1";
|
|
showOwnChat = "1";
|
|
|
|
//tenant = "4368658435";
|
|
//var serverUrl = OwnChatHelper.ErmittleServerURL("1", tenant);
|
|
//var apikey = "hNykpBwxE1Y6NmwZBTDQOpPXW6xCgnVHjJ5lh0QDQyCefgcnimC32aZ3CwB4qQl4";
|
|
//var userid = "1432790061";
|
|
|
|
Mandator.OwnChatCode = "HcYki-8hLbQ";
|
|
|
|
return true;
|
|
#endif
|
|
if ("1".Equals(showAiVoice) && CheckRight(UserRightType.AiVoiceView))
|
|
{
|
|
if (LoggedInEmployee != null && Mandator.OwnChatCode == null)
|
|
{
|
|
Mandator.OwnChatCode = "";
|
|
|
|
if ("1".Equals(showOwnChat))
|
|
{
|
|
var es = new BeWo.Service.ServiceImplementations.EmployeeServiceImp();
|
|
var empAppCodes = es.GetAllEmployeeAppCodes(LoggedInEmployee.EmployeeOid.Value);
|
|
|
|
if (empAppCodes != null && empAppCodes.Count > 0)
|
|
{
|
|
foreach (var item in empAppCodes)
|
|
{
|
|
if (item.EmployeeCode != null && !item.EmployeeCode.Equals(""))
|
|
Mandator.OwnChatCode = item.EmployeeCode;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return !String.IsNullOrEmpty(Mandator.OwnChatCode);
|
|
}
|
|
}
|
|
|
|
public bool HasRightToViewQuittierungsbelege
|
|
{
|
|
get
|
|
{
|
|
|
|
var showEmployeeSignatureSetting = MobileUtils.GetSettingValue(Mandator.Settings, SettingsKeys.ShowSignature);
|
|
#if DEBUG
|
|
showEmployeeSignatureSetting = "1";
|
|
#endif
|
|
return CheckRights(new List<UserRightType> { UserRightType.Analysis_ServiceOverview_View, UserRightType.Signature_ProvideMonthlySignature }) && (showEmployeeSignatureSetting?.Equals("1") ?? false);
|
|
}
|
|
}
|
|
|
|
|
|
public bool IsAllowedToSeeSupportConceptFilter
|
|
{
|
|
get
|
|
{
|
|
var user = LoggedInUser;
|
|
|
|
if(user != null)
|
|
{
|
|
return
|
|
user.CheckForAtLeastOneRight(new List<UserRightType> { UserRightType.ViewAll, UserRightType.SupportConcept_ViewAllSupportConcepts }) ||
|
|
user.HasRight(UserRightType.SupportConcept_ViewMyTeams);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public string UserSettings
|
|
{
|
|
get
|
|
{
|
|
var user = LoggedInUser;
|
|
|
|
return user?.Settings.FirstOrDefault(f => f.Type.Equals(SettingsType.ApplicationSettings))?.Value;
|
|
}
|
|
}
|
|
|
|
public MokSettings MokSettings { get; set; }
|
|
|
|
public bool IsAllowedToSeeCustomerFilter => LoggedInUser?.CheckForAtLeastOneRight(new List<UserRightType> { UserRightType.ViewAll, UserRightType.CustomerView_View, UserRightType.Customer_ViewMyTeams }) ?? false;
|
|
|
|
public bool IsAllowedToSeeMedikamentenliste
|
|
{
|
|
get
|
|
{
|
|
#if DEBUG
|
|
return true;
|
|
#endif
|
|
var mandator = Mandator;
|
|
|
|
var hasSetting = MobileUtils.GetSettingValue(mandator.Settings, SettingsKeys.ShowMedication) == "1";
|
|
|
|
var hasRight = CheckRight(UserRightType.Customer_ViewMedication);
|
|
|
|
return hasSetting && hasRight;
|
|
}
|
|
}
|
|
|
|
public bool CheckRight(UserRightType userRightType)
|
|
{
|
|
return LoggedInUser.HasRight(userRightType);
|
|
}
|
|
|
|
public bool CheckRights(List<UserRightType> userRightTypes)
|
|
{
|
|
return userRightTypes.All(LoggedInUser.HasRight);
|
|
}
|
|
|
|
public bool CheckForAtLeastOneRight(UserRightType[] rights)
|
|
{
|
|
return rights.Any(LoggedInUser.HasRight);
|
|
}
|
|
|
|
public bool HasRightToInsertEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAnlegen) ||
|
|
CheckRight(UserRightType.CreateAll);
|
|
|
|
public bool HasRightToEditEmployeeAppointments => CheckRight(UserRightType.KalenderMitarbeitertermineAendern) || CheckRight(UserRightType.EditAll);
|
|
|
|
public bool HasRightToEditResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAendern) || CheckRight(UserRightType.EditAll);
|
|
public bool HasRightToEditOthersResourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAndererAendern) || CheckRight(UserRightType.EditAll);
|
|
|
|
public bool HasRightToInsertCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAnlegen) &&
|
|
(CheckRight(UserRightType.CustomerView_View) ||
|
|
CheckRight(UserRightType.Customer_ViewMyCustomers) ||
|
|
CheckRight(UserRightType.Customer_ViewMyTeams)) ||
|
|
CheckRight(UserRightType.CreateAll);
|
|
public bool HasRightToEditCustomerAppointments => CheckRight(UserRightType.KalenderKliententermineAendern) || CheckRight(UserRightType.EditAll);
|
|
|
|
public bool ShowServiceRecordInsertedOn { get; set; }
|
|
|
|
public bool HasRightToViewCustomerSelectionInScheduler => CheckRight(UserRightType.CustomerView_View) || CheckRight(UserRightType.Customer_ViewMyCustomers) || CheckRight(UserRightType.Customer_ViewMyTeams);
|
|
|
|
public bool HasRightToViewTeams => CheckRight(UserRightType.TeamView_ViewMyTeams) || CheckRight(UserRightType.TeamView_ViewAll);
|
|
|
|
public bool HasRightForMultiBooking => CheckRight(UserRightType.ServiceRecord_AllowCreatingMultiBooking);
|
|
|
|
public bool HasRightToDeleteReceiptSignatures => CheckRight(UserRightType.ConfirmationReceiptSignatures_Delete);
|
|
|
|
public bool HasRightToRateGoals => CheckRight(UserRightType.BewertenInZeiterfassung);
|
|
|
|
public bool HasRightToChangePassword => CheckRight(UserRightType.UserView_AllowChangePassword) || CheckRight(UserRightType.AllowChangeOwnPassword);
|
|
|
|
public bool HasRightToEditCustomers => CheckRight(UserRightType.CustomerView_Edit);
|
|
|
|
public bool HasRightMitarbeiterstundenkontoViewAll => CheckRight(UserRightType.Mitarbeiterstundenkonto_ViewAll);
|
|
public bool HasRightMitarbeiterstundenkontoViewTeams => CheckRight(UserRightType.Mitarbeiterstundenkonto_ViewTeams);
|
|
public bool HasRightMitarbeiterstundenkontoViewSelf => CheckRight(UserRightType.Mitarbeiterstundenkonto_ViewSelf);
|
|
|
|
public bool HasRightToViewReports => CheckForAtLeastOneRight(new UserRightType[]
|
|
{
|
|
UserRightType.ViewAll,
|
|
UserRightType.QueryView_View,
|
|
UserRightType.Analysis_ServiceOverview_View,
|
|
UserRightType.Analysis_Auslastung_View,
|
|
UserRightType.Analysis_AuslastungAllEmployee_View,
|
|
UserRightType.Analysis_AuslastungTeam_View,
|
|
UserRightType.Kilometerauswertung_View,
|
|
UserRightType.KilometerauswertungEigene_View,
|
|
UserRightType.BewertungAuswertung_View,
|
|
UserRightType.PivotTabelleAnsehen,
|
|
UserRightType.DienstplanungAnsehen,
|
|
UserRightType.AbwesenheitsPlanungAnsehen,
|
|
UserRightType.Mitarbeiterstundenkonto_ViewAll,
|
|
UserRightType.Mitarbeiterstundenkonto_ViewSelf,
|
|
UserRightType.Mitarbeiterstundenkonto_ViewTeams,
|
|
UserRightType.Jahresbericht,
|
|
UserRightType.Auswertungen_BerichteAnsehen,
|
|
UserRightType.Auswertungen_StundenuebersichtAnsehen,
|
|
UserRightType.Auswertungen_HilfeplanuebersichtAnsehen
|
|
});
|
|
|
|
public bool HasRightToViewMitarbeiterstundenkonto
|
|
{
|
|
get
|
|
{
|
|
return MobileSessionFacade.Tenant != "3010479871" && CheckForAtLeastOneRight(new[] { UserRightType.Mitarbeiterstundenkonto_ViewAll, UserRightType.Mitarbeiterstundenkonto_ViewTeams, UserRightType.Mitarbeiterstundenkonto_ViewSelf });
|
|
}
|
|
}
|
|
|
|
public bool HasRightToViewDiagnosen => CheckRight(UserRightType.Customer_ViewDiagnosis);
|
|
|
|
public bool HasRightToProvideSingleSignature => CheckRight(UserRightType.Signature_ProvideSingleSignature);
|
|
|
|
public bool HasRightToViewOwnCustomersBargeldkassen => CheckRight(UserRightType.BargeldverwaltungNurEigeneAnsehen);
|
|
|
|
public bool HasRightToViewAllCustomersBargeldkassen => CheckRight(UserRightType.BargeldverwaltungAnsehen);
|
|
|
|
public bool HasRightToDeleteCustomerBargeldkassen => CheckRight(UserRightType.BargeldverwaltungLoeschen);
|
|
|
|
public bool HasRightToCreateCustomerBargeldkassen => CheckRight(UserRightType.BargeldverwaltungAnlegen);
|
|
|
|
public bool HasRightToEditCustomerBargeldkassen => CheckRight(UserRightType.BargeldverwaltungBearbeiten);
|
|
|
|
public bool HasRightToViewCustomerAbsenceTimes => CheckRight(UserRightType.Customer_ViewAbsenceTimes);
|
|
|
|
public bool HasRightToProvideEmployeeSignatureForOthers => CheckRight(UserRightType.Signature_ProvideMonthlySignatureByProxy);
|
|
|
|
public bool HasRightToViewBetreuung => CheckRight(UserRightType.Customer_ViewBetreuung);
|
|
|
|
public bool HasRightToViewCustomerDocuments => CheckForAtLeastOneRight(new[] { UserRightType.ViewAll, UserRightType.DokumenteKlienten });
|
|
|
|
public bool HasRightToViewOwnEmployee => CheckForAtLeastOneRight(new[] { UserRightType.ViewAll, UserRightType.Employee_AllowViewOwnEmployees }) &&
|
|
CheckForAtLeastOneRight(new[] { UserRightType.EditAll, UserRightType.Employee_AllowEditOwnEmployees });
|
|
|
|
|
|
|
|
//public string UserMessage { get; set; }
|
|
|
|
public XtraReport Report { get; set; }
|
|
public string ReportName { get; set; }
|
|
|
|
protected string GetIsNotApproved(SupportConceptCostBearerRelDC rel)
|
|
{
|
|
var result = string.Empty;
|
|
|
|
var customer = rel.SupportConcept.Customer;
|
|
|
|
if(customer.TerminationDate.HasValue)
|
|
{
|
|
var terminationReason = string.Empty;
|
|
|
|
if(!string.IsNullOrEmpty(customer.TerminationReason))
|
|
{
|
|
terminationReason += $", Begründung: {customer.TerminationReason}";
|
|
}
|
|
|
|
result += $" (Betreuung beendet am: {customer.TerminationDate:dd.MM.yyyy}{terminationReason})";
|
|
}
|
|
|
|
if(rel.ApprovedStartDate is null || rel.ApprovedEndDate is null)
|
|
{
|
|
result += " nicht bewilligt!";
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public List<CompactEmployeeDC> Employees { get; set; } = new List<CompactEmployeeDC>();
|
|
|
|
public List<CompactCustomerDC> Customers { get; set; } = new List<CompactCustomerDC>();
|
|
|
|
public List<CompactPersonDC> Persons { get; set; } = new List<CompactPersonDC>();
|
|
|
|
public Dictionary<string, bool> Collapsibles2IsShown
|
|
{
|
|
get => SessionModel.Collapsibles2IsShown;
|
|
set => SessionModel.Collapsibles2IsShown = value;
|
|
}
|
|
|
|
public bool ShowDifferentQBInterval
|
|
{
|
|
get
|
|
{
|
|
var settingsValue = MobileUtils.GetSettingValue(Mandator.Settings, SettingsKeys.ShowServicesOverviewHalfOrWholeMonth);
|
|
|
|
return "1" == settingsValue;
|
|
}
|
|
}
|
|
|
|
public bool ShowDistanceField { get; set; }
|
|
|
|
public bool ShowBetrag { get; set; }
|
|
|
|
public bool IsServiceRecordGoalMandatory { get; set; }
|
|
|
|
public bool HasRightToViewPersonDocuments => CheckForAtLeastOneRight(new[] { UserRightType.ViewAll, UserRightType.DokumentePersonen });
|
|
public bool HasRightToViewPersonUmfeld => CheckForAtLeastOneRight(new[] { UserRightType.ViewAll, UserRightType.Person_FamilyView });
|
|
|
|
public bool HasRightKalenderMitarbeitertermineAnsehen => CheckRight(UserRightType.KalenderMitarbeitertermineAnsehen);
|
|
}
|
|
}
|