diff --git a/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs b/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs index 33c7bc663..f1574b9b0 100644 --- a/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs +++ b/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs @@ -76,7 +76,7 @@ namespace BeWo.Scheduler.ViewModel ServiceFacade.DoEmployeeServiceSync(s => originator = s.FindCompactEmployeeByFullname(abwesenheit.InsUser)); } - if(!(dc is null)) + if(false == dc is null) { subject += $" ({dc.SimpleDescription})"; } diff --git a/BeWo/ownChat/ChatDokumentationsView.xaml.cs b/BeWo/ownChat/ChatDokumentationsView.xaml.cs index 68031b05a..de4d021bc 100644 --- a/BeWo/ownChat/ChatDokumentationsView.xaml.cs +++ b/BeWo/ownChat/ChatDokumentationsView.xaml.cs @@ -162,12 +162,12 @@ namespace BeWo.ownChat var goalCategoryDict = vm.AllGoalCategories.ToDictionary(goalCat => goalCat.ValueListEntryOid.Value); - foreach (var goal in infoDC.SupportConceptGoals) + foreach(var goal in infoDC.SupportConceptGoals) { - if (goal.ParentOid != null && goalCategoryDict.ContainsKey(goal.ParentOid.Value)) + if(goal.ParentOid != null && goalCategoryDict.ContainsKey(goal.ParentOid.Value)) { var path = ServiceRecordListVM.GetAllParentGoalCategoies(goalCategoryDict, goal); - foreach (var goalCat in path) + foreach(var goalCat in path) { goalCats.Add(goalCat); goalCategoryDict.Remove(goalCat.ValueListEntryOid.Value); @@ -214,7 +214,6 @@ namespace BeWo.ownChat { vm.FetchStatistics(cb2ScOid.Value); } - serviceRecordEditView.InitView(vm, _ServiceRecord, hideCustomerCombo); diff --git a/BeWoPlanerMobil/Controllers/CustomerController.cs b/BeWoPlanerMobil/Controllers/CustomerController.cs index 8066b5d75..19d89099b 100644 --- a/BeWoPlanerMobil/Controllers/CustomerController.cs +++ b/BeWoPlanerMobil/Controllers/CustomerController.cs @@ -146,7 +146,7 @@ namespace BeWoPlanerMobil.Controllers return; } - if(customerOid == -1) + if(customerOid <= 0) { Model.CustomerSessionModel.ResetValues(); } diff --git a/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs b/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs index e767001bf..e9d48c8d9 100644 --- a/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs +++ b/BeWoPlanerMobil/Controllers/DevExpressSchedulerController.cs @@ -22,7 +22,6 @@ namespace BeWoPlanerMobil.Controllers /* * ToDo: * 1. Filterung einbauen (Mitarbeiter, Klienten, Ressourcen, Privat, Aufgaben, Abwesenheiten) - * Das Filtern muss über den CustomCallback geschehen, damit die Termin-Liste aktualisiert wird. * 2. "In die Zeiterfassung übertragen" und "Verfügbare Mitarbeiter prüfen" einbauen * 3. Rechte implementieren! * 4. Übersetzungen @@ -94,12 +93,14 @@ namespace BeWoPlanerMobil.Controllers private void InitViewModel() { - if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || Model?.LoggedInEmployee?.EmployeeOid is null) + if(false == MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || Model?.LoggedInEmployee?.EmployeeOid is null) { Logout(); return; } + var x = Model.SelectedEmployeeOidsForFiltering; + Model.PossibleEmployees = EmployeeService.GetAllAuthorizedCompactEmployees(); Model.PossibleCustomers = CustomerService.GetAllAuthorizedCompactCustomers(); Model.PossibleResources = KalenderService.GetAllResources(); @@ -263,7 +264,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult DevExpressScheduler() { - if(!MobileSessionFacade.IsUserLoggedIn() || Model is null) + if(false == MobileSessionFacade.IsUserLoggedIn() || Model is null) { return RedirectToActionPermanent("Index", "Login"); } @@ -515,7 +516,16 @@ namespace BeWoPlanerMobil.Controllers return PartialView("AptFltEmployeePopupListPartial"); } - Model.SelectedEmployeeOidsForFiltering = Model.PossibleEmployees.Select(employee => employee.EmployeeOid).ToList(); + if(isChecked) + { + Model.SelectedEmployeesForFiltering = Model.PossibleEmployees; + Model.SelectedEmployeeOidsForFiltering = Model.PossibleEmployees.Select(employee => employee.EmployeeOid).ToList(); + } + else + { + Model.SelectedEmployeesForFiltering?.Clear(); + Model.SelectedEmployeeOidsForFiltering?.Clear(); + } return PartialView("AptFltEmployeePopupListPartial", Model); } @@ -529,7 +539,16 @@ namespace BeWoPlanerMobil.Controllers return PartialView("AptFltCustomerPopupListPartial"); } - Model.SelectedCustomerOidsForFiltering = Model.PossibleCustomers.Select(customer => customer.CustomerOid).ToList(); + if(isChecked) + { + Model.SelectedCustomerOidsForFiltering = Model.PossibleCustomers.Select(customer => customer.CustomerOid).ToList(); + Model.SelectedCustomersForFiltering = Model.PossibleCustomers; + } + else + { + Model.SelectedCustomerOidsForFiltering?.Clear(); + Model.SelectedCustomersForFiltering?.Clear(); + } return PartialView("AptFltCustomerPopupListPartial", Model); } @@ -543,9 +562,18 @@ namespace BeWoPlanerMobil.Controllers return PartialView("AptFltResourcePopupListPartial"); } - Model.SelectedResourceOidsForFiltering = Model.PossibleResources.Where(resource => resource.ResourceOid.HasValue).Select(resource => resource.ResourceOid.Value).ToList(); + if(isChecked) + { + Model.SelectedResourceOidsForFiltering = Model.PossibleResources.Where(resource => resource.ResourceOid.HasValue).Select(resource => resource.ResourceOid.Value).ToList(); + Model.SelectedResourcesForFiltering = Model.PossibleResources; + } + else + { + Model.SelectedResourceOidsForFiltering?.Clear(); + Model.SelectedResourcesForFiltering?.Clear(); + } - return PartialView("AptFltResourcePopupListPartial"); + return PartialView("AptFltResourcePopupListPartial", Model); } [Authorize] @@ -561,14 +589,17 @@ namespace BeWoPlanerMobil.Controllers if(selectedTeam is null) { - return PartialView("AptFltEmployeePopupListPartial"); + return PartialView("AptFltEmployeePopupListPartial", Model); } var fullTeamObj = EmployeeService.LoadTeam(teamOid); - Model.SelectedEmployeeOids.AddRangeIfElementsNotIn(fullTeamObj.Member.Select(member => member.EmployeeOid)); + var teamMembers = fullTeamObj?.Member ?? new List(); - return PartialView("AptFltEmployeePopupListPartial"); + Model.SelectedEmployeesForFiltering.AddRangeIfElementsNotIn(teamMembers); + Model.SelectedEmployeeOids.AddRangeIfElementsNotIn(teamMembers.Select(member => member.EmployeeOid)); + + return PartialView("AptFltEmployeePopupListPartial", Model); } [Authorize] @@ -582,6 +613,7 @@ namespace BeWoPlanerMobil.Controllers var selectedEmployees = Model.PossibleEmployees.Where(possibleEmployee => selectedEmployeeOids.Contains(possibleEmployee.EmployeeOid)).ToList(); + Model.SelectedEmployeesForFiltering = selectedEmployees; Model.SelectedEmployeeOidsForFiltering = selectedEmployees.Select(employee => employee.EmployeeOid).ToList(); return PartialView("AptFltEmployeePopupListPartial", Model); @@ -598,6 +630,9 @@ namespace BeWoPlanerMobil.Controllers var selectedCustomers = Model.PossibleCustomers.Where(possibleCustomer => selectedCustomerOids.Contains(possibleCustomer.CustomerOid)).ToList(); + Model.SelectedCustomersForFiltering = selectedCustomers; + Model.SelectedCustomerOidsForFiltering = selectedCustomers.Select(customer => customer.CustomerOid).ToList(); + return PartialView("AptFltCustomerPopupListPartial", Model); } @@ -610,7 +645,30 @@ namespace BeWoPlanerMobil.Controllers return PartialView("AptFltResourcePopupListPartial"); } + var selectedResources = Model.PossibleResources.Where(possibleResource => possibleResource.ResourceOid.HasValue && selectedResourceOids.Contains(possibleResource.ResourceOid.Value)).ToList(); + + Model.SelectedResourcesForFiltering = selectedResources; + Model.SelectedResourceOidsForFiltering = selectedResources.Where(resource => resource.ResourceOid.HasValue).Select(resource => resource.ResourceOid.Value).ToList(); + return PartialView("AptFltResourcePopupListPartial", Model); } + + [Authorize] + public string GetSelectedEmployeesForAptFlt() + { + return JsonConvert.SerializeObject(Model.SelectedEmployeeOidsForFiltering.Count); + } + + [Authorize] + public string GetSelectedCustomersForAptFlt() + { + return JsonConvert.SerializeObject(Model.SelectedCustomerOidsForFiltering.Count); + } + + [Authorize] + public string GetSelectedResourcesForAptFlt() + { + return JsonConvert.SerializeObject(Model.SelectedResourceOidsForFiltering.Count); + } } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index a862b29be..aaf240883 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -16,6 +16,7 @@ using DevExpress.XtraScheduler; using DevExpress.XtraScheduler.Compatibility; using Newtonsoft.Json; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; @@ -25,13 +26,13 @@ using System.Net.Sockets; using System.Text; using System.Web.Mvc; using System.Windows.Forms; -using DevExpress.XtraRichEdit.Commands.Internal; using static BeWoPlanerMobil.Util.MobileUtils; using static BS.Shared.ServiceRecordValidationResult; using FormCollection = System.Web.Mvc.FormCollection; using GoalRating = BeWoPlanerMobil.Util.GoalRating; using Image = System.Drawing.Image; using ServiceRecordDC = BS.Shared.DataContracts.ServiceRecordDC; +using BeWo.Service.AI; /* * ToDo: Bug, wenn man auf "bearbeiten" bei einem Eintrag klickt, wird die Leistung nicht geladen @@ -42,6 +43,13 @@ namespace BeWoPlanerMobil.Controllers { public class MainController : SignableController { + // Speichert den Status externer Aufrufe (callId -> Callback-Daten) + private static readonly ConcurrentDictionary _externalCallResults = new ConcurrentDictionary(); + // Speichert optionale Statusmeldungen für laufende externe Aufrufe (callId -> Statustext) + private static readonly ConcurrentDictionary _externalCallStatusMessages = new ConcurrentDictionary(); + // Speichert das Aufnametoken für laufende externe Aufrufe (callId -> Token) + private static readonly ConcurrentDictionary _externalCallTokens = new ConcurrentDictionary(); + public MainController() { int test = 0; @@ -618,7 +626,7 @@ namespace BeWoPlanerMobil.Controllers { try { - if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) + if(false == MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer")) { var isNewSession = Session.IsNewSession; @@ -630,7 +638,7 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } - if(!Model.SessionInitialized) + if(false == Model.SessionInitialized) { Model.SessionInitialized = true; var mokSessionTimeout = UserSettingsUtils.GetSettingValueAsInteger(Model.Mandator.Settings, SettingsKeys.MoKSessionTimeout, 20); @@ -653,12 +661,17 @@ namespace BeWoPlanerMobil.Controllers break; } - if(!string.IsNullOrEmpty(tempDataValue)) + if(false == string.IsNullOrEmpty(tempDataValue)) { TempData[TempDataConstants.ShowPwChPopupKey] = tempDataValue; } } } + + if(TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] is SchedulerAppointmentDC occurrenceToInsert) + { + TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] = occurrenceToInsert; + } } catch(Exception e) { @@ -1293,6 +1306,10 @@ namespace BeWoPlanerMobil.Controllers var app = DAOFactory.GenericDAO.LoadByID(Model.TransferringAppointmentOid.Value); appointmentPrototype = MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDC(app); } + else if(TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] is SchedulerAppointmentDC occurrenceToInsert) + { + appointmentPrototype = occurrenceToInsert; + } var marker = "on" == collection[FormCollectionConstants.MarkerKey]; @@ -1318,7 +1335,7 @@ namespace BeWoPlanerMobil.Controllers var distanz = collection[FormCollectionConstants.DistanceKey]; decimal? distanceInMeters = null; - if(!string.IsNullOrEmpty(distanz)) + if(false == string.IsNullOrEmpty(distanz)) { if(decimal.TryParse(distanz, out var parsedDistance)) { @@ -1350,7 +1367,7 @@ namespace BeWoPlanerMobil.Controllers durationAsString = durationAsString?.Replace('.', ','); - if(!string.IsNullOrEmpty(durationAsString)) + if(false == string.IsNullOrEmpty(durationAsString)) { decimal.TryParse(durationAsString, out dauer); } @@ -1417,23 +1434,23 @@ namespace BeWoPlanerMobil.Controllers if(Model.LoggedInEmployee.EmployeeOid.HasValue) { - if(!Model.IsInEditingMode) + if(false == Model.IsInEditingMode) { Model.NewServiceRecord.Employee = Model.SelectedEmployee ?? LoggedInUser.Employee; } else { - if(!(Model.SelectedEmployee is null)) + if(Model.SelectedEmployee != null) { Model.NewServiceRecord.Employee = Model.SelectedEmployee; } } - var sclo = Model.SupportConceptListObjects.FirstOrDefault(a => a.CostBearer2SupportConceptOid.Equals(selectedCostbearerScRelOid)); + var mokSupportConceptListObject = Model.SupportConceptListObjects.FirstOrDefault(a => a.CostBearer2SupportConceptOid.Equals(selectedCostbearerScRelOid)); - if(!(sclo is null)) + if(mokSupportConceptListObject != null) { - var sc = GetCompactSupportConcept(sclo.SupportConceptOid, selectedCostbearerScRelOid); + var sc = GetCompactSupportConcept(mokSupportConceptListObject.SupportConceptOid, selectedCostbearerScRelOid); Model.NewServiceRecord.SupportConcept = sc; @@ -1479,7 +1496,7 @@ namespace BeWoPlanerMobil.Controllers var serviceDescOid = 0L; - if(!string.IsNullOrEmpty(collection[FormCollectionConstants.ServiceDescriptionKey])) + if(false == string.IsNullOrEmpty(collection[FormCollectionConstants.ServiceDescriptionKey])) { serviceDescOid = Convert.ToInt64(collection[FormCollectionConstants.ServiceDescriptionKey]); } @@ -1508,77 +1525,52 @@ namespace BeWoPlanerMobil.Controllers return Model.NewServiceRecord.ServiceRecordOid.HasValue ? SaveGroupBooking() : UpdateGroupBooking(); } - if(!Model.IsInEditingMode) + if(false == Model.IsInEditingMode) { - var valRes = OperationsService.ValidateServiceRecord(Model.NewServiceRecord, null, 0, null, null); - bool doppelt = false; - if (valRes.Count > 0 && valRes.FirstOrDefault(v => v.ResultType == ServiceRecordValidationResult.DoppelterEintrag) != null) + if(Model.NewServiceRecord.CostBearer != null && Model.ShowSignature && (Model.NewServiceRecord.ServiceDescription.Category.IsBillable || Model.NewServiceRecord.ServiceDescription.Category.BillableAmount > 0m || Model.NewServiceRecord.ServiceDescription.BillableAmount > 0m)) { - doppelt = true; - - - } - if (!doppelt) - { - var oidList = OperationsService.InsertNewServiceRecords(new List { Model.NewServiceRecord }); - - Model.LastCreatedServiceRecordOid = oidList[0]; - - - if (Model.IsAllowedToCreateSignature(Model.NewServiceRecord)) + var valRes = OperationsService.ValidateServiceRecord(Model.NewServiceRecord, null, 0, null, null); + bool doppelt = false; + if(valRes.Count > 0 && valRes.FirstOrDefault(v => v.ResultType == ServiceRecordValidationResult.DoppelterEintrag) != null) { - if (Model.NewServiceRecord.CostBearer != null && Model.ShowSignature && (Model.NewServiceRecord.ServiceDescription.Category.IsBillable || Model.NewServiceRecord.ServiceDescription.Category.BillableAmount > 0m || Model.NewServiceRecord.ServiceDescription.BillableAmount > 0m)) + doppelt = true; + } + + if(!doppelt) + { + var oidList = OperationsService.InsertNewServiceRecords(new List { Model.NewServiceRecord }); + + Model.LastCreatedServiceRecordOid = oidList[0]; + + + if(Model.IsAllowedToCreateSignature(Model.NewServiceRecord)) { - TempData[TempDataConstants.ShowSignatureSuggestionPopup] = true; + if(Model.NewServiceRecord.CostBearer != null && Model.ShowSignature && (Model.NewServiceRecord.ServiceDescription.Category.IsBillable || Model.NewServiceRecord.ServiceDescription.Category.BillableAmount > 0m || Model.NewServiceRecord.ServiceDescription.BillableAmount > 0m)) + { + TempData[TempDataConstants.ShowSignatureSuggestionPopup] = true; + } } } } - TempData[TempDataConstants.AfterInsertKey] = true; - if (appointmentPrototype is object) + if(appointmentPrototype is object) { - var isRecurring = !(appointmentPrototype.RecurrenceInfo is null); + var serviceRecord = OperationsService.GetServiceRecordById(Model.LastCreatedServiceRecordOid); - if(isRecurring && appointmentPrototype.Type != (int) AppointmentType.ChangedOccurrence) + if(appointmentPrototype.ServiceRecordList is null) { - var id = appointmentPrototype.RecurrenceIdReference; - - var recurrenceInfo = new RecurrenceInfo(); - recurrenceInfo.FromXml(appointmentPrototype.RecurrenceInfo); - var occurrenceCalculator = OccurrenceCalculator.CreateInstance(recurrenceInfo); - - var pattern = StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern); - pattern.RecurrenceInfo.FromXml(appointmentPrototype.RecurrenceInfo); - pattern.Start = pattern.RecurrenceInfo.Start; - pattern.End = pattern.RecurrenceInfo.End; - - var occurrence = occurrenceCalculator.CalcOccurrences(new TimeInterval(appointmentPrototype.StartDate.Value, appointmentPrototype.EndDate.Value), pattern).FirstOrDefault(); - - if(!(occurrence is null)) - { - var index = occurrence.RecurrenceIndex; - appointmentPrototype = SchedulerController.CloneAppointment(appointmentPrototype, $"", (int)AppointmentType.ChangedOccurrence); - } - else - { - appointmentPrototype = null; - } + appointmentPrototype.ServiceRecordList = new List(); } - if(appointmentPrototype is object) + appointmentPrototype.ServiceRecordList.AddIfNotIn(serviceRecord); + + if(appointmentPrototype.SchedulerAppointmentOid.HasValue) { - var serviceRecord = OperationsService.GetServiceRecordById(Model.LastCreatedServiceRecordOid); - - appointmentPrototype.ServiceRecordList.AddIfNotIn(serviceRecord); - - if(appointmentPrototype.SchedulerAppointmentOid.HasValue) - { - KalenderService.UpdateSchedulerAppointments(new List { appointmentPrototype }); - } - else - { - KalenderService.InsertSchedulerAppointments(new List { appointmentPrototype }); - } + KalenderService.UpdateSchedulerAppointments(new List { appointmentPrototype }); + } + else + { + KalenderService.InsertSchedulerAppointments(new List { appointmentPrototype }); } } } @@ -1592,7 +1584,7 @@ namespace BeWoPlanerMobil.Controllers var previousStartDate = Model.IsInEditingMode ? Model.SelectedServiceRecord?.Start : Model.NewServiceRecord?.Start; var previousEndDate = Model.IsInEditingMode ? Model.SelectedServiceRecord?.End : Model.NewServiceRecord?.End; - if(!(previousStartDate is null) && !(previousEndDate is null)) + if(previousStartDate.HasValue && previousEndDate.HasValue) { var duration = (previousEndDate - previousStartDate).Value.TotalMinutes; @@ -1607,7 +1599,7 @@ namespace BeWoPlanerMobil.Controllers { Log.Error(e.Message, e); } - if (!Model.IsInGroupBookingMode && !Model.IsInMultiBookingMode) + if (false == Model.IsInGroupBookingMode && !Model.IsInMultiBookingMode) { //Setze den zuletzt ausgewählten HP zurück, sonst springt die Anzeige dorthin Model.PreviouslySelectedCostbearer2SupportConceptOid = null; @@ -1617,7 +1609,7 @@ namespace BeWoPlanerMobil.Controllers long? oldCatOid = null; long? oldDescOid = null; - if(!Model.IsInEditingMode) + if(false == Model.IsInEditingMode) { oldCatOid = Model.SelectedServiceCategoryOid; oldDescOid = Model.SelectedServiceDescriptionOid; @@ -1686,6 +1678,12 @@ namespace BeWoPlanerMobil.Controllers if(newDCList.Count == 1) { OperationsService.InsertNewServiceRecords(newDCList); + + if(TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] is SchedulerAppointmentDC occurrenceToInsert) + { + KalenderService.InsertSchedulerAppointment(occurrenceToInsert); + } + TempData[TempDataConstants.AfterInsertKey] = true; } else @@ -1715,13 +1713,28 @@ namespace BeWoPlanerMobil.Controllers TempData[TempDataConstants.AfterInsertKey] = true; - if(Model.TransferringAppointmentOid.HasValue && Model.LoggedInEmployee.EmployeeOid.HasValue) + if((Model.TransferringAppointmentOid is null && TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] is null) || Model.LoggedInEmployee?.EmployeeOid is null) { - var app = DAOFactory.GenericDAO.LoadByID(Model.TransferringAppointmentOid.Value); - var appointment = MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDC(app); + return ResetEditingMode(); + } - appointment.ServiceRecordList.AddRange(serviceRecords); + var appointment = Model.TransferringAppointmentOid is null ? + (SchedulerAppointmentDC) TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] : + MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDC(DAOFactory.GenericDAO.LoadByID(Model.TransferringAppointmentOid.Value)); + if(appointment.ServiceRecordList is null) + { + appointment.ServiceRecordList = new List(); + } + + appointment.ServiceRecordList.AddRange(serviceRecords); + // ToDo: Ist immer noch nicht mit den ServiceRecords verbunden! + if(appointment.SchedulerAppointmentOid is null) + { + KalenderService.InsertSchedulerAppointments(new List { appointment }); + } + else + { KalenderService.UpdateSchedulerAppointments(new List { appointment }); } } @@ -2724,6 +2737,11 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } + if(TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] is SchedulerAppointmentDC occurrenceToInsert) + { + TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] = occurrenceToInsert; + } + var inEditMode = Model.IsInEditingMode; var von = formCollection[FormCollectionConstants.DateKey]; @@ -2752,12 +2770,12 @@ namespace BeWoPlanerMobil.Controllers var startHoursDt = ConvertTimeStringToDateTime(start); var endHoursDt = ConvertTimeStringToDateTime(end); - if(!DateTime.TryParse(von, out var startDate)) + if(false == DateTime.TryParse(von, out var startDate)) { startDate = DateTime.Now.Date; } - if(!DateTime.TryParse(bis, out var endDate)) + if(false == DateTime.TryParse(bis, out var endDate)) { endDate = DateTime.Now.Date; } @@ -2815,10 +2833,7 @@ namespace BeWoPlanerMobil.Controllers if(supportConcept != null) { - if(supportConcept.SupportConceptOid != null) - { - checkServiceRecord.SupportConcept = GetCompactSupportConcept(supportConcept.SupportConceptOid, Model.SelectedCostBearerSupportConceptOid); - } + checkServiceRecord.SupportConcept = GetCompactSupportConcept(supportConcept.SupportConceptOid, Model.SelectedCostBearerSupportConceptOid); checkServiceRecord.Customer = supportConcept.Customer; var costbearer = supportConcept.CostBearerList.FirstOrDefault(); @@ -3551,6 +3566,131 @@ namespace BeWoPlanerMobil.Controllers return View("Main", Model); } + /// + /// Ermittelt die externe URL, die beim Klick auf den Test-Button aufgerufen werden soll. + /// Die callbackUrl wird als Parameter mitgegeben, damit das externe System sie verwenden kann. + /// + [HttpGet] + [Authorize] + public JsonResult GetExternalCallUrl(string callId, string callbackUrl) + { + try + { + var externalUrl = ""; + + if (Mandator?.OwnChatCode != null) + { + var ts = new TranscriptionService(); + var avd = ts.InitTranskription(MobileSessionFacade.Tenant, false); + + externalUrl = avd.ResultUrl; + + if (!string.IsNullOrEmpty(callId) && !string.IsNullOrEmpty(avd.Token)) + { + _externalCallTokens[callId] = ts.MapAiVoiceDataDC(avd); + } + + //var externalBaseUrl = "https://example.com/external-service"; + //var externalUrl = externalBaseUrl + // + "?callbackUrl=" + Uri.EscapeDataString(callbackUrl) + // + "&callId=" + Uri.EscapeDataString(callId); + } + + + return Json(new { success = true, url = externalUrl }, JsonRequestBehavior.AllowGet); + } + catch(Exception ex) + { + return Json(new { success = false, message = "Fehler beim Ermitteln der externen URL: " + ex.Message }, JsonRequestBehavior.AllowGet); + } + } + + /// + /// Callback-Endpunkt, der vom externen System aufgerufen wird. + /// Markiert den externen Aufruf als abgeschlossen. + /// + [HttpGet] + [AllowAnonymous] + public ActionResult ExternalCallCallback(string callId, string data = null) + { + if(!string.IsNullOrEmpty(callId)) + { + _externalCallResults[callId] = data ?? string.Empty; + _externalCallStatusMessages.TryRemove(callId, out _); + _externalCallTokens.TryRemove(callId, out _); + } + + return Content("OK"); + } + + /// + /// Kann vom externen System aufgerufen werden, um eine Statusmeldung zu setzen, + /// die dem Benutzer im Wartedialog angezeigt wird (ohne den Vorgang abzuschließen). + /// + [HttpGet] + [AllowAnonymous] + public ActionResult ExternalCallUpdateStatus(string callId, string message) + { + if(!string.IsNullOrEmpty(callId) && message != null) + { + _externalCallStatusMessages[callId] = message; + } + + return Content("OK"); + } + + /// + /// Wird vom Browser per Polling aufgerufen, um zu prüfen ob der Callback bereits eingegangen ist. + /// Gibt bei completed=false optional eine Statusmeldung zurück. + /// + [HttpGet] + [Authorize] + public JsonResult CheckExternalCallStatus(string callId) + { + if(!string.IsNullOrEmpty(callId) && _externalCallResults.TryRemove(callId, out var data)) + { + _externalCallStatusMessages.TryRemove(callId, out _); + _externalCallTokens.TryRemove(callId, out _); + return Json(new { completed = true, data }, JsonRequestBehavior.AllowGet); + } + + string statusMessage = null; + if(!string.IsNullOrEmpty(callId) && _externalCallTokens.TryRemove(callId, out var avddc)) + { + var ts = new TranscriptionService(); + + var avd = ts.MapAiVoiceData(avddc); + + avd = ts.GetTranskription(avd); + statusMessage = avd.StatusMessage; + avddc = ts.MapAiVoiceDataDC(avd); + + _externalCallTokens[callId] = avddc; + + //_externalCallStatusMessages.TryGetValue(callId, out statusMessage); + } + + return Json(new { completed = false, statusMessage }, JsonRequestBehavior.AllowGet); + } + + /// + /// Wird aufgerufen, wenn der Benutzer den externen Aufruf abbricht. + /// Räumt den Eintrag auf, falls vorhanden. + /// + [HttpPost] + [Authorize] + public ActionResult CancelExternalCall(string callId) + { + if(!string.IsNullOrEmpty(callId)) + { + _externalCallResults.TryRemove(callId, out _); + _externalCallStatusMessages.TryRemove(callId, out _); + _externalCallTokens.TryRemove(callId, out _); + } + + return new HttpStatusCodeResult(200); + } + [HttpPost] [Authorize] public ActionResult ResetGroupBookingForm() @@ -3962,7 +4102,7 @@ namespace BeWoPlanerMobil.Controllers try { - if(!Model.IsInEditingMode) + if(false == Model.IsInEditingMode) { if(Model.GroupBookingSelectedCostBearerSupportConceptOids.Count == 1) { @@ -4247,8 +4387,6 @@ namespace BeWoPlanerMobil.Controllers return LeerzeichenFuerGetMethoden; } - - /// /// Bereitet die Übernahme eines Termins in die Zeiterfassung vor. Wird im SchedulerController aufgerufen. @@ -4257,7 +4395,7 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult PrepareServiceRecordInsert() { - if(!IsUserLoggedIn()) + if(false == IsUserLoggedIn()) { TempData[TempDataConstants.DoLogoutKey] = true; return Logout(); @@ -4281,19 +4419,11 @@ namespace BeWoPlanerMobil.Controllers var startRaw = TempData[TempDataConstants.AppointmentStartKey]?.ToString(); var endRaw = TempData[TempDataConstants.AppointmentEndKey]?.ToString(); var subject = TempData[TempDataConstants.AppointmentSubjectKey]?.ToString(); - var isAllDay = false; - - if(TempData[TempDataConstants.AppointmentIsAllDayKey] is bool isAllDayRaw && isAllDayRaw) - { - isAllDay = true; - } - else if(appointment != null) - { - isAllDay = appointment.AllDay; - } + var isAllDay = TempData[TempDataConstants.AppointmentIsAllDayKey] is true; var customerOids = new List(); var employeeOids = new List(); + var resourceOids = new List(); if(TempData[TempDataConstants.AppointmentEmployeeOidsKey] is string employeeOidsRaw && employeeOidsRaw.Length > 0) { @@ -4305,22 +4435,24 @@ namespace BeWoPlanerMobil.Controllers customerOids = Utils.ConvertCharSeparatedValuesToLongList(customerOidsRaw, ','); } - var isStartParsingSuccessful = DateTime.TryParse(startRaw, out var parsedStart); - var isEndParsingSuccessful = DateTime.TryParse(endRaw, out var parsedEnd); + if(TempData[TempDataConstants.AppointmentResourceOidsKey] is string resourceOidsRaw && resourceOidsRaw.Length > 0) + { + resourceOids = Utils.ConvertCharSeparatedValuesToLongList(resourceOidsRaw, ','); + } - var start = appointment is null ? parsedStart : appointment.StartDate; - var end = appointment is null ? parsedEnd : appointment.EndDate; + DateTime.TryParse(startRaw, out var start); + DateTime.TryParse(endRaw, out var end); if(appointment is object) { customerOids = appointment.CustomerList.Select(customer => customer.CustomerOid).ToList(); employeeOids = appointment.EmployeeList.Select(e2a => e2a.Employee.EmployeeOid).ToList(); } - - if(isAllDay && start.HasValue && end.HasValue) + + if(isAllDay) { - start = start.Value.MergeDateWithHoursMinutesSeconds(0, 0, 1); - end = end.Value.MergeDateWithHoursMinutesSeconds(0, 0, 1); + start = start.MergeDateWithHoursMinutesSeconds(0, 0, 1); + end = end.MergeDateWithHoursMinutesSeconds(0, 0, 1); } if(employeeOids.Count == 0) @@ -4329,11 +4461,16 @@ namespace BeWoPlanerMobil.Controllers } var notice = appointment?.Description ?? TempData[TempDataConstants.AppointmentSubjectKey]?.ToString(); + if(appointment is null) + { + notice = TempData[TempDataConstants.AppointmentDescriptionKey]?.ToString() ?? + TempData[TempDataConstants.AppointmentSubjectKey]?.ToString(); + } Model.SupportConceptListObjects.Clear(); //Macht, dass beim Init die SupportConcepts neu geladen werden InitViewModel(true); - var supportConcepts = Model.SupportConcepts.Where(sc => customerOids.Contains(sc.Customer.CustomerOid) && sc.StartDate.HasValue && sc.EndDate.HasValue && start.Value.AreInBetweenDates(end.Value, sc.StartDate.Value, sc.EndDate.Value)).ToList(); + var supportConcepts = Model.SupportConcepts.Where(sc => customerOids.Contains(sc.Customer.CustomerOid)).ToList(); var supportConceptList = new List(); @@ -4349,6 +4486,49 @@ namespace BeWoPlanerMobil.Controllers supportConceptList.AddIfNotIn(supportConcept); } + // Falls es sich um einen Serientermin handelt, Ausnahme erstellen und speichern, nachdem der Eintrag in der Datenbank gespeichert wurde. + if(isSerientermin && appointment is null) + { + var customers = CustomerService.GetCompactCustomersById(customerOids); + var employees = EmployeeService.GetActiveCompactEmployeesByOids(employeeOids); + var resources = OperationsService.GetResourcesByOids(resourceOids); + + appointment = new SchedulerAppointmentDC + { + StartDate = start, + EndDate = end, + ActivationType = ActivationTypeId.Active, + AllDay = isAllDay, + CustomerList = customers, + ResourceList = resources, + EmployeeList = new List(), + Location = TempData[TempDataConstants.AppointmentLocationKey]?.ToString(), + IsPrivate = TempData[TempDataConstants.AppointmentIsPrivateKey] is true, + Subject = subject, + SupportConceptList = supportConceptList, + Type = (int) AppointmentType.ChangedOccurrence, + Originator = Model.LoggedInUser.Employee + }; + + foreach(var employee in employees) + { + appointment.EmployeeList.Add(new Employee2SchedulerAppointmentDC { Employee = employee }); + } + + var recurrenceInfo = TempData[TempDataConstants.AppointmentRecurrenceInfoKey].ToString(); + + var pattern = StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern); + pattern.RecurrenceInfo.FromXml(recurrenceInfo); + pattern.Start = pattern.RecurrenceInfo.Start; + pattern.End = pattern.RecurrenceInfo.End; + + var apt = pattern.CreateException(AppointmentType.ChangedOccurrence, recurrenceIndex.Value); + + appointment = SchedulerAppointmentDC.RecurringExceptionFromDevExpressAppointment(apt, appointment, recurrenceIndex.Value, pattern.RecurrenceInfo.Id.ToString()); + + TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] = appointment; + } + // Ohne Hilfeplan if(supportConceptList.Count == 0) { @@ -4361,7 +4541,7 @@ namespace BeWoPlanerMobil.Controllers if(Model.SelectedServiceDescription != null) { Model.SelectedServiceCategory = Model.SelectedServiceDescription.Category; - var serviceRecord = CreateServiceRecordFromScratch(start.Value, end.Value, null, Model.SelectedEmployee, notice); + var serviceRecord = CreateServiceRecordFromScratch(start, end, null, Model.SelectedEmployee, notice); serviceRecord.ServiceDescription = Model.SelectedServiceDescription; Model.SelectedServiceRecord = serviceRecord; } @@ -4389,7 +4569,7 @@ namespace BeWoPlanerMobil.Controllers LoadSupportConceptThings(scListObject.CostBearer2SupportConceptOid, true); } - var serviceRecord = CreateServiceRecordFromScratch(start.Value, end.Value, compactSupportConcept?.Customer, Model.SelectedEmployee, notice); + var serviceRecord = CreateServiceRecordFromScratch(start, end, compactSupportConcept?.Customer, Model.SelectedEmployee, notice); var costBearer = compactSupportConcept?.CostBearerList.FirstOrDefault(); @@ -4403,6 +4583,7 @@ namespace BeWoPlanerMobil.Controllers { Model.SelectedServiceRecord = serviceRecord; } + Model.SelectedCostBearerSupportConceptOid = cb2ScOid; } else // Gruppenbuchung @@ -4411,9 +4592,9 @@ namespace BeWoPlanerMobil.Controllers Model.GroupBookingSelectedEmployees = Model.AllEmployees.Where(w => employeeOids.Contains(w.EmployeeOid)).ToList(); - var roundedDuration = (int) ((end - start)?.TotalMinutes ?? 0); + var roundedDuration = (int) (end - start).TotalMinutes; - Model.SelectedServiceRecord = new ServiceRecordDC() + Model.SelectedServiceRecord = new ServiceRecordDC { Start = start, End = end, @@ -4439,29 +4620,12 @@ namespace BeWoPlanerMobil.Controllers if(costBearer2SupportConceptOids.Any()) { Model.GroupBookingSelectedCostBearerSupportConceptOids = costBearer2SupportConceptOids; - //Model.SelectedConceptCostBearerRelations = costBearer2SupportConcepts; - //Model.GroupBookingSelectedSupportConcepts = supportConceptsForGroupBooking; } + Model.GroupBookingSelectedEmployeeOids = employeeOids; - } } - // ToDo: Falls es sich um einen Serientermin handelt, Ausnahme erstellen und speichern, nachdem der Eintrag in der Datenbank gespeichert wurde. - if(isSerientermin) - { - var recurrenceInfo = appointment.RecurrenceInfo; - - var pattern = StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern); - pattern.RecurrenceInfo.FromXml(recurrenceInfo); - - var apt = pattern.CreateException(AppointmentType.ChangedOccurrence, recurrenceIndex.Value); - - var changedOccurrence = SchedulerAppointmentDC.RecurringExceptionFromDevExpressAppointment(apt, appointment); - - var x = apt.RecurrenceIndex; - } - Model.SelectedServiceRecordOid = Model.SelectedServiceRecord?.ServiceRecordOid; SetSelectedObjects(); @@ -4541,7 +4705,6 @@ namespace BeWoPlanerMobil.Controllers return RedirectToActionPermanent("Main"); } - #region Mehrfachbuchung [Authorize] @@ -4559,8 +4722,6 @@ namespace BeWoPlanerMobil.Controllers return PartialView("MultiBookingSelectionPartial", Model); } - - [Authorize] public ActionResult RemoveSupportConceptCostbearerRelFromMultiBooking(string relOid) { @@ -4850,6 +5011,11 @@ namespace BeWoPlanerMobil.Controllers OperationsService.InsertNewServiceRecords(serviceRecordsToInsert); + if(TempData[TempDataConstants.AppointmentOccurrenceToInsertKey] is SchedulerAppointmentDC occurrenceToInsert) + { + KalenderService.InsertSchedulerAppointment(occurrenceToInsert); + } + TempData[TempDataConstants.AfterInsertKey] = true; } } diff --git a/BeWoPlanerMobil/Controllers/ReportController.cs b/BeWoPlanerMobil/Controllers/ReportController.cs index 34951a2f6..2265a2472 100644 --- a/BeWoPlanerMobil/Controllers/ReportController.cs +++ b/BeWoPlanerMobil/Controllers/ReportController.cs @@ -17,7 +17,6 @@ using BeWo.Service.Plugins; using DevExpress.XtraReports.UI; // Controller des Quittierungsbelegsmoduls - namespace BeWoPlanerMobil.Controllers { public class ReportController : AbstractBaseController @@ -152,7 +151,7 @@ namespace BeWoPlanerMobil.Controllers { try { - if(!MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || Model?.LoggedInEmployee?.EmployeeOid is null) + if(false == MobileSessionFacade.IsUserLoggedIn() || Request.Browser.Browser.Equals("InternetExplorer") || Model?.LoggedInEmployee?.EmployeeOid is null) { return Logout(); } @@ -247,10 +246,6 @@ namespace BeWoPlanerMobil.Controllers { var stringBuilder = new StringBuilder(isDativ ? string.Empty : "Einträge für "); - // Einträge für [alle Klienten/die Klienten meines Teams/meine Klienten/[CustomerName]/[TeamName]] [von [Mitarbeiter] [bei [Kostenträger]] und [Leistungskategorie]] vom 01.10. bis 31.10.2020 - // Einträge für Grube, Clair von Fisher, George bei LWL und face-to-face vom 01.10. bis 31.10.2020 - // Unterschrift für x erbrachte Leistungen von - switch(Model.SelectedFilterItem?.FilterEnum) { case QBFilterEnum.KlientenAuswahl: @@ -1012,6 +1007,7 @@ namespace BeWoPlanerMobil.Controllers TempData[TempDataConstants.DoLogoutKey] = true; return PartialView("QuittierungsbelegsPreviewPartial"); } + Model.QuittierungsbelegsReport = CreateQuittierungsbelegsReportFromSettings(); return PartialView("QuittierungsbelegsPreviewPartial", Model); @@ -1019,16 +1015,17 @@ namespace BeWoPlanerMobil.Controllers private XtraReport CreateQuittierungsbelegsReportFromSettings() { - if (Model.QuittierungsbelegsReportSettings == null) + if(Model.QuittierungsbelegsReportSettings is null) { return null; } - var s = Model.QuittierungsbelegsReportSettings; - DateTime startDate = new DateTime(s.Year, s.Month, s.StartDay); - DateTime endDate = new DateTime(s.Year, s.Month, s.EndDay); + var reportSettings = Model.QuittierungsbelegsReportSettings; - var report = Model.ReportCreator.CreateServiceOverviewReportNew(s.FilterEnum, s.CustomerOid, s.TeamOid, s.EmployeeOid, s.OrganisationOid, s.ServiceCategoryOid, startDate, endDate, false); + var startDate = new DateTime(reportSettings.Year, reportSettings.Month, reportSettings.StartDay); + var endDate = new DateTime(reportSettings.Year, reportSettings.Month, reportSettings.EndDay); + + var report = Model.ReportCreator.CreateServiceOverviewReportNew(reportSettings.FilterEnum, reportSettings.CustomerOid, reportSettings.TeamOid, reportSettings.EmployeeOid, reportSettings.OrganisationOid, reportSettings.ServiceCategoryOid, startDate, endDate, false); report.ExportOptions.PrintPreview.DefaultFileName = CreateFileName(); report.DisplayName = CreateFileName(); @@ -1042,6 +1039,7 @@ namespace BeWoPlanerMobil.Controllers var selectedFilter = Model.SelectedFilterItem.FilterEnum; var filterText = string.Empty; + switch(selectedFilter) { case QBFilterEnum.AlleKlienten: @@ -1083,7 +1081,7 @@ namespace BeWoPlanerMobil.Controllers fileName += $"{selectedServiceCategory.Name}_"; } - if(!Model.SelectedMonth.HasValue || !Model.SelectedYear.HasValue || !Model.SelectedStartDay.HasValue || !Model.SelectedEndDay.HasValue) + if(false == Model.SelectedMonth.HasValue || false == Model.SelectedYear.HasValue || false == Model.SelectedStartDay.HasValue || false == Model.SelectedEndDay.HasValue) { return fileName; } @@ -1229,9 +1227,6 @@ namespace BeWoPlanerMobil.Controllers reportObjects = reportObjects.Where(servicesOverview => false == servicesOverview is null).ToList(); var srOids = new List(); - //var srOidsBillable = new List(); - - //reportObjects.DoForEach(servicesOverview => servicesOverview.Services.DoForEach(s => srOids.AddIfNotIn(s.ServiceRecordOid))); foreach(var reportObject in reportObjects) { @@ -1441,7 +1436,7 @@ namespace BeWoPlanerMobil.Controllers [Serializable] public class ConfirmationReceiptSignatureObject { - public String Identifier { get; } + public string Identifier { get; } public string ImageStr { get; } public string InsTsStr { get; } public string PersonName { get; } diff --git a/BeWoPlanerMobil/Controllers/ReportViewerController.cs b/BeWoPlanerMobil/Controllers/ReportViewerController.cs index e6f982bdd..6fd41d43d 100644 --- a/BeWoPlanerMobil/Controllers/ReportViewerController.cs +++ b/BeWoPlanerMobil/Controllers/ReportViewerController.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Web.Mvc; -using BeWo.Data.Entities; using BeWo.Report; using BeWo.Service.Plugins; using BeWo.View.Navigation.Filter; @@ -17,7 +16,6 @@ using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; // Controller des Auswertungsmoduls - namespace BeWoPlanerMobil.Controllers { public class ReportViewerController : ReportBaseController @@ -28,30 +26,20 @@ namespace BeWoPlanerMobil.Controllers { get { - if(!MobileSessionFacade.IsUserLoggedIn()) + if(false == MobileSessionFacade.IsUserLoggedIn()) { RedirectToActionPermanent("Index", "Login"); return null; } - if (_Model == null) + if(_Model is null) { _Model = new ReportViewerModel { ReportCreator = GetReportCreator() }; InitModel(_Model); InitViewModel(); } - //if (((ReportViewerModel)Session[ModelSessionConstants.ReportViewerModelKey])?.LoggedInEmployee is null) - //{ - // _Model = new ReportViewerModel { ReportCreator = GetReportCreator() }; - // Session[ModelSessionConstants.ReportViewerModelKey] = _Model; - //} - //else - //{ - // _Model = (ReportViewerModel)Session[ModelSessionConstants.ReportViewerModelKey]; - //} - return _Model; } } @@ -203,8 +191,6 @@ namespace BeWoPlanerMobil.Controllers return Logout(); } - - return View(Model); } @@ -323,25 +309,6 @@ namespace BeWoPlanerMobil.Controllers return PartialView("BerichteFormPartialView", Model); } - //[Authorize] - //private string GetQueryReportUrl(QueryDC query) - //{ - // var url = Request?.Url; - - // if(Model?.Employee?.EmployeeOid is null || url is null || query is null) - // { - // return null; - // } - - // //DEBUG: http://localhost:3777/service - // //RELEASE: https://app4.bewoplaner.de/service - // // http://localhost:3777/Host/ReportView.aspx?dcid=demoqueryeoid372&qoid=1304&type=QueryReport - - // var urlSuffix = $"/ReportView.aspx?dcid={MobileSessionFacade.Tenant}queryeoid{Model.Employee.EmployeeOid.Value}&qoid={query.Oid}&type={Utils.EnumName(ReportTypes.QueryReport)}"; - - // return GetSiteOfOrigin() + urlSuffix; - //} - private string GetSiteOfOrigin() { if(Model?.LoggedInEmployee?.EmployeeOid is null) diff --git a/BeWoPlanerMobil/Controllers/SchedulerController.cs b/BeWoPlanerMobil/Controllers/SchedulerController.cs index c936d9544..56bc75df4 100644 --- a/BeWoPlanerMobil/Controllers/SchedulerController.cs +++ b/BeWoPlanerMobil/Controllers/SchedulerController.cs @@ -1433,21 +1433,27 @@ namespace BeWoPlanerMobil.Controllers if(appointment?.RecurrenceInfo != null) { - TempData[TempDataConstants.AppointmentRecurrenceIndexKey] = appointment?.RecurrenceIndex; + TempData[TempDataConstants.AppointmentRecurrenceInfoKey] = appointment.RecurrenceInfo; + TempData[TempDataConstants.AppointmentRecurrenceIndexKey] = appointment.RecurrenceIndex; } + TempData[TempDataConstants.AppointmentLocationKey] = appointment?.Location; + TempData[TempDataConstants.AppointmentIsPrivateKey] = appointment?.IsPrivate ?? false; + TempData[TempDataConstants.AppointmentDescriptionKey] = appointment?.Description; + TempData[TempDataConstants.AppointmentStartKey] = appointment?.StartDate; TempData[TempDataConstants.AppointmentEndKey] = appointment?.EndDate; TempData[TempDataConstants.AppointmentSubjectKey] = appointment?.Subject; TempData[TempDataConstants.AppointmentIsAllDayKey] = appointment?.AllDay ?? false; - TempData[TempDataConstants.AppointmentCustomerOidsKey] = string.Join(",", appointment?.CustomerList.Select(s => s.CustomerOid) ?? new List()); + TempData[TempDataConstants.AppointmentCustomerOidsKey] = string.Join(",", appointment?.CustomerList.Select(customer => customer.CustomerOid) ?? new List()); - TempData[TempDataConstants.AppointmentEmployeeOidsKey] = string.Join(",", appointment?.EmployeeList.Select(s => s.Employee.EmployeeOid) ?? new List()); + TempData[TempDataConstants.AppointmentEmployeeOidsKey] = string.Join(",", appointment?.EmployeeList.Select(employee2Appointment => employee2Appointment.Employee.EmployeeOid) ?? new List()); + + TempData[TempDataConstants.AppointmentResourceOidsKey] = string.Join(",", appointment?.ResourceList.Where(resource => resource.ResourceOid.HasValue).Select(resource => resource.ResourceOid.Value) ?? new List()); TempData[TempDataConstants.AppointmentIsSerienterminKey] = appointment != null && appointment.SchedulerAppointmentOid is null && appointment.RecurrenceInfo is string; - return RedirectToActionPermanent("PrepareServiceRecordInsert", "Main"); } diff --git a/BeWoPlanerMobil/Models/AbstractModel.cs b/BeWoPlanerMobil/Models/AbstractModel.cs index bceaec876..da1353a2f 100644 --- a/BeWoPlanerMobil/Models/AbstractModel.cs +++ b/BeWoPlanerMobil/Models/AbstractModel.cs @@ -58,11 +58,61 @@ namespace BeWoPlanerMobil.Models public bool HasRightToInsertRessourceAppointments => CheckRight(UserRightType.KalenderRessourcentermineAnlegen) || CheckRight(UserRightType.CreateAll); - public bool HasRightToViewQuittierungsbelege + 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"; @@ -72,7 +122,6 @@ namespace BeWoPlanerMobil.Models } - public bool IsAllowedToSeeSupportConceptFilter { get diff --git a/BeWoPlanerMobil/Models/MokMandator.cs b/BeWoPlanerMobil/Models/MokMandator.cs index 5840305ae..e9763de58 100644 --- a/BeWoPlanerMobil/Models/MokMandator.cs +++ b/BeWoPlanerMobil/Models/MokMandator.cs @@ -18,6 +18,7 @@ namespace BeWoPlanerMobil.Models //public string Website { get; set; } //public string PostalCode { get; set; } public string Settings { get; set; } + public string OwnChatCode { get; set; } //public string State { get; set; } //public string Street { get; set; } //public string Town { get; set; } diff --git a/BeWoPlanerMobil/Models/ReportModel.cs b/BeWoPlanerMobil/Models/ReportModel.cs index bcaa935db..2742164c5 100644 --- a/BeWoPlanerMobil/Models/ReportModel.cs +++ b/BeWoPlanerMobil/Models/ReportModel.cs @@ -54,7 +54,11 @@ namespace BeWoPlanerMobil.Models }; [Display(Name = "Klient")] - public long? SelectedCustomerOid { get { return ReportSessionModel.SelectedCustomerOid; } set { ReportSessionModel.SelectedCustomerOid = value; } } + public long? SelectedCustomerOid + { + get => ReportSessionModel.SelectedCustomerOid; + set => ReportSessionModel.SelectedCustomerOid = value; + } public CompactCustomerDC SelectedCustomer { get; set; } @@ -148,22 +152,38 @@ namespace BeWoPlanerMobil.Models set => ReportSessionModel.SelectedEndDay = value; } - public ConfirmationReceiptObject ConfirmationReceiptObject { get { return ReportSessionModel.ConfirmationReceiptObject; } set { ReportSessionModel.ConfirmationReceiptObject = value; } } + public ConfirmationReceiptObject ConfirmationReceiptObject + { + get => ReportSessionModel.ConfirmationReceiptObject; + set => ReportSessionModel.ConfirmationReceiptObject = value; + } [Display(Name = "Mitarbeiter")] - public long? SelectedEmployeeOid { get { return ReportSessionModel.SelectedEmployeeOid; } set { ReportSessionModel.SelectedEmployeeOid = value; } } + public long? SelectedEmployeeOid + { + get => ReportSessionModel.SelectedEmployeeOid; + set => ReportSessionModel.SelectedEmployeeOid = value; + } public CompactEmployeeDC SelectedEmployee { get; set; } [Display(Name="Kostenträger")] - public long? SelectedOrganisationOid { get { return ReportSessionModel.SelectedOrganisationOid; } set { ReportSessionModel.SelectedOrganisationOid = value; } } + public long? SelectedOrganisationOid + { + get => ReportSessionModel.SelectedOrganisationOid; + set => ReportSessionModel.SelectedOrganisationOid = value; + } public CompactOrganisationDC SelectedOrganisation { get; set; } public List Organisations { get; set; } = new List(); - [Display(Name="Leistungskategorie")] - public long? SelectedServiceCategoryOid { get { return ReportSessionModel.SelectedServiceCategoryOid; } set { ReportSessionModel.SelectedServiceCategoryOid = value; } } + [Display(Name = "Leistungskategorie")] + public long? SelectedServiceCategoryOid + { + get => ReportSessionModel.SelectedServiceCategoryOid; + set => ReportSessionModel.SelectedServiceCategoryOid = value; + } public ServiceCategoryDC SelectedServiceCategory { get; set; } @@ -200,10 +220,11 @@ namespace BeWoPlanerMobil.Models { get { - if (QbFilters == null || !SelectedFilterItemId.HasValue) + if(QbFilters is null || false == SelectedFilterItemId.HasValue) { return null; } + return QbFilters.FirstOrDefault(f => f.FilterEnum == SelectedFilterItemId.Value); } } @@ -235,8 +256,12 @@ namespace BeWoPlanerMobil.Models } } - [Display(Name = "Team")] - public long? SelectedTeamOid { get { return ReportSessionModel.SelectedTeamOid; } set { ReportSessionModel.SelectedTeamOid = value; } } + [Display(Name = "Team")] + public long? SelectedTeamOid + { + get => ReportSessionModel.SelectedTeamOid; + set => ReportSessionModel.SelectedTeamOid = value; + } public CompactTeamDC SelectedTeam { get; set; } @@ -281,13 +306,36 @@ namespace BeWoPlanerMobil.Models ConfirmationReceiptSignatures.Where(crs => crs.ConfirmationReceiptSignatureOid != null && confirmationReceiptSignatureOids.Contains(crs.ConfirmationReceiptSignatureOid.Value)).ToList(); } - public bool IsForSelectedEmployeesOnly { get { return ReportSessionModel.IsForSelectedEmployeesOnly; } set { ReportSessionModel.IsForSelectedEmployeesOnly = value; } } - public bool IsForSelectedCostbearersOnly { get { return ReportSessionModel.IsForSelectedCostbearersOnly; } set { ReportSessionModel.IsForSelectedCostbearersOnly = value; } } - public bool IsForSelectedCategoryOnly { get { return ReportSessionModel.IsForSelectedCategoryOnly; } set { ReportSessionModel.IsForSelectedCategoryOnly = value; } } + public bool IsForSelectedEmployeesOnly + { + get => ReportSessionModel.IsForSelectedEmployeesOnly; + set => ReportSessionModel.IsForSelectedEmployeesOnly = value; + } - public List SelectedConfirmationReceiptSignatures { get { return ReportSessionModel.SelectedConfirmationReceiptSignatures; } set { ReportSessionModel.SelectedConfirmationReceiptSignatures = value; } } + public bool IsForSelectedCostbearersOnly + { + get => ReportSessionModel.IsForSelectedCostbearersOnly; + set => ReportSessionModel.IsForSelectedCostbearersOnly = value; + } - public Quittierungsbelegsunterschriftenobjekt Quittierungsbelegsunterschriftenobjekt { get { return ReportSessionModel.Quittierungsbelegsunterschriftenobjekt; } set { ReportSessionModel.Quittierungsbelegsunterschriftenobjekt = value; } } + public bool IsForSelectedCategoryOnly + { + get => ReportSessionModel.IsForSelectedCategoryOnly; + set => ReportSessionModel.IsForSelectedCategoryOnly = value; + } + + + public List SelectedConfirmationReceiptSignatures + { + get => ReportSessionModel.SelectedConfirmationReceiptSignatures; + set => ReportSessionModel.SelectedConfirmationReceiptSignatures = value; + } + + public Quittierungsbelegsunterschriftenobjekt Quittierungsbelegsunterschriftenobjekt + { + get => ReportSessionModel.Quittierungsbelegsunterschriftenobjekt; + set => ReportSessionModel.Quittierungsbelegsunterschriftenobjekt = value; + } public AbstractReportCreator ReportCreator { get; set; } diff --git a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js index 46cafe6e3..22b0589ed 100644 --- a/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js +++ b/BeWoPlanerMobil/Scripts/ownSoft-Scripts/view-scripts/main.js @@ -92,6 +92,7 @@ function changeGroupBookingFormEnableState(enableState) { "#gb-distance-input, " + "textarea, " + "#reset-button, " + + "#aivoice-button, " + "#create-button, " + "#gb-textbausteine-btn, " + "#gb-hours-minutes-dropdown-btn, " + @@ -116,6 +117,7 @@ function changeSingleBookingFormEnableState(enableState) { "#goals-button, " + "textarea, " + "#reset-button, " + + "#aivoice-button, " + "#create-button, " + "#statistics-button, " + "#timeFrameSelect, " + diff --git a/BeWoPlanerMobil/Util/FormCollectionConstants.cs b/BeWoPlanerMobil/Util/FormCollectionConstants.cs index efce2ea10..8ff79a53b 100644 --- a/BeWoPlanerMobil/Util/FormCollectionConstants.cs +++ b/BeWoPlanerMobil/Util/FormCollectionConstants.cs @@ -109,5 +109,11 @@ public static string IsGroupTabActiveKey => "IsGroupTabActive"; public static string AfterInsertKey => "AfterInsert"; public static string AppointmentRecurrenceIndexKey => "AppointmentRecurrenceIndex"; + public static string AppointmentRecurrenceInfoKey => "AppointmentRecurrenceInfo"; + public static string AppointmentResourceOidsKey => "AppointmentResourceOids"; + public static string AppointmentLocationKey => "Location"; + public static string AppointmentIsPrivateKey => "IsPrivate"; + public static string AppointmentDescriptionKey => "Description"; + public static string AppointmentOccurrenceToInsertKey => "AppointmentOccurrenceToInsert"; } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltCustomersPartial.cshtml b/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltCustomersPartial.cshtml index 2f43c6437..53cb5859a 100644 --- a/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltCustomersPartial.cshtml +++ b/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltCustomersPartial.cshtml @@ -50,7 +50,15 @@ $("#all-customers-checkbox").prop("checked", (allCustomersCount === selectedCustomersCount)); - $("#customer-input-container").load("@Url.Action("UpdateCustomerSelection")", { selectedCustomerOids: selectedCustomerOids }, () => { scheduler.Refresh(); }); + showSpinner(); + $("#customer-input-container").load( + "@Url.Action("UpdateCustomerSelection")", + { selectedCustomerOids: selectedCustomerOids }, + () => { + scheduler.Refresh(); + hideSpinner(); + } + ); } diff --git a/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltEmployeesPartial.cshtml b/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltEmployeesPartial.cshtml index 994357cd0..8acfca795 100644 --- a/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltEmployeesPartial.cshtml +++ b/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltEmployeesPartial.cshtml @@ -54,10 +54,20 @@ const selectedEmployeeOids = $("#employee-input-container input:checked").map(function() { return $(this).attr("id").split("-")[1]; }).get(); const allEmployeesCount = $("#employee-input-container input[type=checkbox]").map(function () { return $(this).attr("id").split("-")[1]; }).get().length; const selectedEmployeesCount = selectedEmployeeOids.length; - console.log(selectedEmployeeOids); + $("#all-employees-checkbox").prop("checked", (allEmployeesCount === selectedEmployeesCount)); - $("#employee-input-container").load("@Url.Action("UpdateEmployeeSelection", "DevExpressScheduler")", {selectedEmployeeOids: selectedEmployeeOids }, () => { scheduler.Refresh(); }); + showSpinner(); + + $("#employee-input-container").load( + "@Url.Action("UpdateEmployeeSelection", "DevExpressScheduler")", + { + selectedEmployeeOids: selectedEmployeeOids + }, + () => { + scheduler.Refresh(); + hideSpinner(); + }); } diff --git a/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltResourcesPartial.cshtml b/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltResourcesPartial.cshtml index 2a7e96c41..4dce81421 100644 --- a/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltResourcesPartial.cshtml +++ b/BeWoPlanerMobil/Views/DevExpressScheduler/AptFltResourcesPartial.cshtml @@ -1,5 +1,4 @@ -@using BeWoPlanerMobil.Util -@using BS.Shared.Extensions +@using BS.Shared.Extensions @model BeWoPlanerMobil.Models.DevExpressSchedulerModel diff --git a/BeWoPlanerMobil/Views/DevExpressScheduler/DevExpressScheduler.cshtml b/BeWoPlanerMobil/Views/DevExpressScheduler/DevExpressScheduler.cshtml index 6569b1a64..2d5b36566 100644 --- a/BeWoPlanerMobil/Views/DevExpressScheduler/DevExpressScheduler.cshtml +++ b/BeWoPlanerMobil/Views/DevExpressScheduler/DevExpressScheduler.cshtml @@ -1,140 +1,157 @@ -@using BeWoPlanerMobil.Util.Constants -@using BeWoPlanerMobil.Util.SchedulerUtils -@using BS.Shared.DataContracts.Compact -@model BeWoPlanerMobil.Models.DevExpressSchedulerModel +@model BeWoPlanerMobil.Models.DevExpressSchedulerModel @{ ViewBag.Title = "DevExpressScheduler"; } diff --git a/BeWoPlanerMobil/Views/Main/SingleBookingPartial.cshtml b/BeWoPlanerMobil/Views/Main/SingleBookingPartial.cshtml index 6167dcd2a..2df806ba4 100644 --- a/BeWoPlanerMobil/Views/Main/SingleBookingPartial.cshtml +++ b/BeWoPlanerMobil/Views/Main/SingleBookingPartial.cshtml @@ -168,6 +168,94 @@ } + + @using(Html.BeginForm("ResetSingleBookingForm", "Main", FormMethod.Post, new { Id = "reset-single-booking-form-form" })) { }
@@ -580,29 +668,47 @@
} -
- +
+ - @if(Model.IsInEditingMode) + @if (Model.IsInEditingMode) + { + using (Html.BeginForm("ResetEditingMode", "Main", FormMethod.Post)) { - using(Html.BeginForm("ResetEditingMode", "Main", FormMethod.Post)) - { - - } + } - else if(Model.IsInTransferMode) + } + else if (Model.IsInTransferMode) + { + using (Html.BeginForm("ResetTransferMode", "Main", FormMethod.Post)) { - using(Html.BeginForm("ResetTransferMode", "Main", FormMethod.Post)) - { - - } + } - else - { - - } - - @Html.Partial("RestoreServiceRecordInputsPartial", Model) + } + else + { + + } + + @if (Model.HasRightToUseAiVoice) + { + + } + + + + @Html.Partial("RestoreServiceRecordInputsPartial", Model) +
+ + @* Waiting-Overlay für externen Aufruf *@ + }
diff --git a/BeWoPlanerMobil/Views/Scheduler/OneDaySchedulerPartial.cshtml b/BeWoPlanerMobil/Views/Scheduler/OneDaySchedulerPartial.cshtml index 014309b5d..900d3c3c1 100644 --- a/BeWoPlanerMobil/Views/Scheduler/OneDaySchedulerPartial.cshtml +++ b/BeWoPlanerMobil/Views/Scheduler/OneDaySchedulerPartial.cshtml @@ -266,7 +266,7 @@
} - @if(Model.HasRightToEditAppointment(appointment.Identifier) && !appointment.IsTask && appointment.CanBeEdited) + @if(Model.HasRightToEditAppointment(appointment.Identifier) && false == appointment.IsTask && appointment.CanBeEdited) {
@if(appointment.Oid.HasValue) @@ -283,9 +283,9 @@ }
- +