From f4e7d42d444688cf1dd87ae98497b52ae77e6d2e Mon Sep 17 00:00:00 2001 From: Lyndon Date: Mon, 10 Dec 2018 23:40:38 -0400 Subject: [PATCH] =?UTF-8?q?Die=20ServiceRecord-Validierung=20geschieht=20j?= =?UTF-8?q?etzt=20ausschlie=C3=9Flich=20auf=20dem=20Server.=20Der=20Benutz?= =?UTF-8?q?er=20wird=20lediglich=20gefragt,=20ob=20trotz=20vorhandener=20?= =?UTF-8?q?=C3=9Cberschneidungen=20etc.=20gespeichert=20werden=20soll,=20s?= =?UTF-8?q?ofern=20er=20die=20Rechte=20dazu=20hat.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BeWoPlanerMobil/BeWoPlanerMobil.csproj | 1 + BeWoPlanerMobil/Content/BeWoMobileStyle.css | 147 +++-- BeWoPlanerMobil/Controllers/MainController.cs | 519 ++++++++++++++---- BeWoPlanerMobil/Scripts/gruppenbuchung.js | 49 +- BeWoPlanerMobil/Scripts/initialization.js | 62 ++- BeWoPlanerMobil/Scripts/mainView.js | 282 ++-------- .../Scripts/serviceRecordValidation.js | 104 ++++ BeWoPlanerMobil/Scripts/textbausteine.js | 12 +- BeWoPlanerMobil/Util/MobileUtils.cs | 46 ++ .../Util/ServiceRecord2Validation.cs | 5 +- BeWoPlanerMobil/Util/ValidationResult.cs | 11 +- BeWoPlanerMobil/Views/Main/Main.cshtml | 97 ++-- BeWoPlanerMobil/Views/Shared/_Layout.cshtml | 1 + Service/Plugins/PluginLoader.cs | 2 +- Service/Plugins/ServiceRecordValidator.cs | 7 +- Shared/DataContracts/ServiceRecordDC.cs | 4 +- 16 files changed, 795 insertions(+), 554 deletions(-) create mode 100644 BeWoPlanerMobil/Scripts/serviceRecordValidation.js diff --git a/BeWoPlanerMobil/BeWoPlanerMobil.csproj b/BeWoPlanerMobil/BeWoPlanerMobil.csproj index d487dd916..4812f262d 100644 --- a/BeWoPlanerMobil/BeWoPlanerMobil.csproj +++ b/BeWoPlanerMobil/BeWoPlanerMobil.csproj @@ -216,6 +216,7 @@ + diff --git a/BeWoPlanerMobil/Content/BeWoMobileStyle.css b/BeWoPlanerMobil/Content/BeWoMobileStyle.css index 8c3705983..fc14b6ea7 100644 --- a/BeWoPlanerMobil/Content/BeWoMobileStyle.css +++ b/BeWoPlanerMobil/Content/BeWoMobileStyle.css @@ -16,6 +16,11 @@ table { margin: 1em auto; } +button { + -webkit-border-radius: 0; + border-radius: 0; +} + hr { border: 0; height: 0; @@ -386,19 +391,19 @@ ul { right:0; } -#popupDiv, #errorPopupDiv,#SuccessPopupDiv,#AendernPopupDiv { - width:90%; - height: 20%; - background-color: #ffffff; - border: 1px solid #FF5A00; - display: none; - margin: auto; - position: absolute; +#popupDiv, #errorPopupDiv, #SuccessPopupDiv, #AendernPopupDiv, #validationPopupDiv { + width: 90%; + height: 20%; + background-color: #ffffff; + border: 1px solid #FF5A00; + display: none; + margin: auto; + position: absolute; z-index: 900; - top: 0; - left: 0; - bottom: 0; - right: 0; + top: 0; + left: 0; + bottom: 0; + right: 0; } .popupBtn{ @@ -681,81 +686,10 @@ input[type="checkbox"] { background-size: contain; } -article.infobox section { - position: absolute; - display: table-row; - width: 100%; - background-color: #ffffff; - top: 30px; -} - -article.infobox section textarea:focus { - border-color: #FF5A00; -} - -article.infobox section h2 { - position: absolute; - left: 0; - top: -30px; - - width: 25%; - height: 29px; - font-size: 12px; - font-weight: normal; - - margin: 0; - background-color: rgba(0, 0, 0, 0.1); - border-radius: 0 0 0 0; - border: double #ffffff; - border-width: 1px 1px 0 1px; - z-index: 0; - word-wrap: break-word; - border-color: rgba(0, 0, 0, 0.1); -} - -article.infobox section:nth-child(2) h2{ - left: 25%; - z-index: 1; -} - -article.infobox section:nth-child(3) h2{ - left: 50%; - z-index:2; -} - -article.infobox section:nth-child(4) h2{ - left: 75%; - z-index: 3; -} - -article.infobox section:nth-child(5) h2{ - left: 90%; - z-index: 4; -} - -article.infobox section h2 a { - display: block; - margin: 5px 0 0 0; - text-align: center; - text-decoration: none; - color:#000000; -} - -article.infobox section:target, article.infobox section:target h2 { - color: #000000; - z-index: 1; - background-color: #FFFFFF; - border-color:#FF5A00; -} - -article.infobox section:target h2 a { - color: #000000; - border-color:#FF5A00; -} - .documentationTextArea { height: 60px; display: none; + margin-top: 0; } .removeButton { @@ -897,5 +831,48 @@ article.infobox section:target h2 a { } #employeeCollapsible { - max-height: 50%; + overflow-y: auto; +} + +#employeePopupDiv { + overflow-y: hidden; +} + +/* Neue Dokumentationstabs */ +.doku-tab { + overflow: hidden; + margin-bottom: 0; + word-wrap: break-word; +} + +.doku-tab-link { + display: none; + padding: 10px 20px; + float: left; + border: none; + outline: none; + background-color: #e5e5e5; + width: 20%; + font-size: 13px; +} + +.doku-tab-link.active { + background-color: #ff5a00; + color: white; +} + +.doku-tab-link:disabled { + background-color: #e5e5e5; + color: black; +} + +.doku-tab-content { + display: none; +} + + +#validationPopupDiv { + height: auto; + z-index: 9999; + padding: 0 1.5em; } \ No newline at end of file diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index f45c2f4cc..83584d0b7 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -4,7 +4,7 @@ using System.Diagnostics; using System.Linq; using System.Text; using System.Web.Mvc; -using BeWo.Service.DCEntityMapper; + using BeWo.Service.ServiceImplementations; using BeWoPlanerMobil.Models; @@ -23,6 +23,7 @@ using BS.Shared.Services; using DevExpress.XtraScheduler; using DevExpress.XtraScheduler.Compatibility; +using static BS.Shared.ServiceRecordValidationResult; using ServiceRecordDC = BS.Shared.DataContracts.ServiceRecordDC; namespace BeWoPlanerMobil.Controllers @@ -158,6 +159,11 @@ namespace BeWoPlanerMobil.Controllers { LoadRecordsToModel(); } + + if (Model.SelectedEmployee == null) + { + Model.SelectedEmployee = MobileSessionFacade.LoggedInCompactEmployee; + } } catch (Exception e) { @@ -171,6 +177,11 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult SetShowOnlyOwnSupportConcepts(FormCollection collection) { + if (Model == null) + { + return RedirectToActionPermanent("Index", "Login"); + } + var newValue = "true,false" == collection["ShowOnlyOwnSupportConcepts"]; Model.ShowOnlyOwnSupportConcepts = newValue; @@ -182,6 +193,11 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public ActionResult SetShowExpiredSupportConcepts(FormCollection pCollection) { + if (Model == null) + { + return RedirectToActionPermanent("Index", "Login"); + } + var newValue = "true,false" == pCollection["ShowExpiredSupportConcepts"]; Model.ShowExpiredSupportConcepts = newValue; @@ -191,6 +207,12 @@ namespace BeWoPlanerMobil.Controllers public ActionResult UpdateSettings(string pKey, string pValue) { + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + var userSettings = GetUser().Settings; UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, pKey, pValue, userSettings); @@ -211,7 +233,8 @@ namespace BeWoPlanerMobil.Controllers { if (Model == null) { - return "SessionTimeout"; + RedirectToActionPermanent("Index", "Login"); + return null; } var sc = Model.SupportConcepts.FirstOrDefault(f => f.CostBearerRelations.Any(cbr => cbr.CostBearer2SupportConceptOid.HasValue && cbr.CostBearer2SupportConceptOid.Value.Equals(pCostbearer2SupportConceptOid))); @@ -305,8 +328,15 @@ namespace BeWoPlanerMobil.Controllers } } + [Authorize] public string LoadBWPSettings() { + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + var m = OperationsService.GetMandator(); var time = MobileUtils.GetSettingValue(m.Settings, "TimeUntilUILock"); @@ -315,6 +345,12 @@ namespace BeWoPlanerMobil.Controllers public string CheckEndDate() { + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + var m = OperationsService.GetMandator(); var endtime = MobileUtils.GetSettingValue(m.Settings, "IsEndDateVisible"); @@ -323,6 +359,12 @@ namespace BeWoPlanerMobil.Controllers public string CheckOnlyYearMonth() { + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + var m = OperationsService.GetMandator(); var yearMonth = MobileUtils.GetSettingValue(m.Settings, "IsOnlyYearMonthVisible"); @@ -331,6 +373,12 @@ namespace BeWoPlanerMobil.Controllers public string CheckIsZeiterfassDateNormal() { + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + var m = OperationsService.GetMandator(); var normal = MobileUtils.GetSettingValue(m.Settings, "IsZeiterfassDateNormal"); @@ -339,6 +387,12 @@ namespace BeWoPlanerMobil.Controllers public string CheckIsZeiterfassungInStdMin() { + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + var m = OperationsService.GetMandator(); var zeiterInStdMin = MobileUtils.GetSettingValue(m.Settings, "IsZeiterfassungInStdMin"); @@ -347,6 +401,12 @@ namespace BeWoPlanerMobil.Controllers public string CheckDokuReiter() { + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + return SerializeObject(Model.Dokutypes); } @@ -370,10 +430,11 @@ namespace BeWoPlanerMobil.Controllers { try { - + if (Model == null) { - return "SessionTimeout"; + RedirectToActionPermanent("Index", "Login"); + return null; } var date = DateTime.ParseExact(newtoday, "dd.MM.yyyy", null); @@ -470,9 +531,10 @@ namespace BeWoPlanerMobil.Controllers { try { - if(Model == null) + if (Model == null) { - return "SessionTimeout"; + RedirectToActionPermanent("Index", "Login"); + return null; } var supportConceptStatistics = OperationsService.CreateSupportConceptStatistics(oid, DateTime.Now); @@ -493,7 +555,8 @@ namespace BeWoPlanerMobil.Controllers { if (Model == null) { - SerializeObject("SessionTimeout"); + RedirectToActionPermanent("Index", "Login"); + return; } var date = DateTime.Parse(day); @@ -523,7 +586,8 @@ namespace BeWoPlanerMobil.Controllers { if (Model == null) { - SerializeObject("SessionTimeout"); + RedirectToActionPermanent("Index", "Login"); + return; } var date = DateTime.Parse(pStartDate); @@ -542,13 +606,14 @@ namespace BeWoPlanerMobil.Controllers Originator = MobileSessionFacade.LoggedInCompactEmployee }; - var newE2S = new Employee2SchedulerAppointmentDC(); - newE2S.Employee = MobileSessionFacade.LoggedInCompactEmployee; + var newE2S = new Employee2SchedulerAppointmentDC + { + Employee = MobileSessionFacade.LoggedInCompactEmployee + }; newApp.EmployeeList.Add(newE2S); - var list = new List(); - list.Add(newApp); + var list = new List {newApp}; //var a1 = new List { // new SchedulerAppointmentDC // { @@ -579,7 +644,8 @@ namespace BeWoPlanerMobil.Controllers { if (Model == null) { - return "SessionTimeout"; + RedirectToActionPermanent("Index", "Login"); + return null; } var date = DateTime.ParseExact(newtoday, "dd.MM.yyyy", null); @@ -603,7 +669,8 @@ namespace BeWoPlanerMobil.Controllers { if (Model == null) { - SerializeObject("SessionTimeout"); + RedirectToActionPermanent("Index", "Login"); + return; } var date = DateTime.Parse(zeitstempel); @@ -630,7 +697,8 @@ namespace BeWoPlanerMobil.Controllers { if (Model == null) { - return SerializeObject("SessionTimeout"); + RedirectToActionPermanent("Index", "Login"); + return null; } Model.SaveSignature = save; @@ -645,7 +713,13 @@ namespace BeWoPlanerMobil.Controllers public string LoadServiceCategories(long pServiceCategoryOid) { - try + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + + try { var scm = Model?.ServiceCategories.FirstOrDefault(s => s.ServiceCategoryOid.Value == pServiceCategoryOid); @@ -661,6 +735,12 @@ namespace BeWoPlanerMobil.Controllers [Authorize] public string LoadTextbausteineForServiceCategory(long pServiceCategoryOid) { + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + try { if (!MobileSessionFacade.CheckForUserRight(UserRightType.TextbausteineNurEigeneAnsehen) && !MobileSessionFacade.CheckForUserRight(UserRightType.TextbausteineAlleAnsehen)) @@ -709,6 +789,12 @@ namespace BeWoPlanerMobil.Controllers public string LoadCompleteTextbausteinByOid(long pTextbausteinOid) { + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + var abc = Model.Textbausteine.FirstOrDefault(f => f.TextModuleOid.HasValue && f.TextModuleOid.Value == pTextbausteinOid); return abc?.Text; @@ -718,14 +804,13 @@ namespace BeWoPlanerMobil.Controllers { try { - if (Model == null) + if (Model == null) { - SerializeObject("SessionTimeout"); - } - else - { - Model.ErrorWert = errorwert; + RedirectToActionPermanent("Index", "Login"); + return; } + + Model.ErrorWert = errorwert; } catch (Exception e) { @@ -891,12 +976,12 @@ namespace BeWoPlanerMobil.Controllers Model.NewServiceRecord.ServiceRecordFormat = ServiceRecordFormate.OriginaleZeiterfassung; - Model.NewServiceRecord.Notice = doku1 == string.Empty ? null : doku1; + Model.NewServiceRecord.Notice = string.IsNullOrEmpty(doku1) ? null : doku1; - Model.NewServiceRecord.Notice2 = doku2 == string.Empty ? null : doku2; - Model.NewServiceRecord.Notice3 = doku3 == string.Empty ? null : doku3; - Model.NewServiceRecord.Notice4 = doku4 == string.Empty ? null : doku4; - Model.NewServiceRecord.Notice5 = doku5 == string.Empty ? null : doku5; + Model.NewServiceRecord.Notice2 = string.IsNullOrEmpty(doku2) ? null : doku2; + Model.NewServiceRecord.Notice3 = string.IsNullOrEmpty(doku3) ? null : doku3; + Model.NewServiceRecord.Notice4 = string.IsNullOrEmpty(doku4) ? null : doku4; + Model.NewServiceRecord.Notice5 = string.IsNullOrEmpty(doku5) ? null : doku5; var serviceDescOid = 0L; @@ -1357,52 +1442,6 @@ namespace BeWoPlanerMobil.Controllers } } } - - private static ServiceRecordDC CloneServiceRecordForGroupBooking(ServiceRecordDC pOriginal) - { - var m = pOriginal; - - var clone = new ServiceRecordDC - { - CostBearer = m.CostBearer, - CostBearer2SupportConceptOid = m.CostBearer2SupportConceptOid, - Customer = m.Customer, - Employee = m.Employee, - End = m.End, - Goals = m.Goals, - GroupEmployeeCount = m.GroupEmployeeCount, - GroupOid = m.GroupOid, - SignatureOid = m.SignatureOid, - GroupPersonCount = m.GroupPersonCount, - GroupRoundedDuration = m.GroupRoundedDuration, - InsUser = m.InsUser, - InsertedOn = m.InsertedOn, - Notice = m.Notice, - Notice2 = m.Notice2, - Notice3 = m.Notice3, - Notice4 = m.Notice4, - Notice5 = m.Notice5, - RTFNotice1 = m.RTFNotice1, - RTFNotice2 = m.RTFNotice2, - RTFNotice3 = m.RTFNotice3, - RTFNotice4 = m.RTFNotice4, - RTFNotice5 = m.RTFNotice5, - RoundedDuration = m.RoundedDuration, - ServiceDescription = m.ServiceDescription, - Start = m.Start, - SupportConcept = m.SupportConcept, - ServiceRecordType = m.ServiceRecordType, - DistanceInMeter = m.DistanceInMeter, - IP = m.IP, - Relevance = m.Relevance, - IsCreatedInMobileClient = true, - WohnheimbuchungsOid = m.WohnheimbuchungsOid, - DurationInStunden = m.DurationInStunden, - ServiceRecordFormat = m.ServiceRecordFormat - }; - - return clone; - } [Authorize] public ActionResult SaveZeiterfassungAfterCrash(string pDatum, string pStartDate, string pEndDate, string pDuration, string pNotice, string pServiceDescription, string pNotice2, string pNotice3, string pNotice4, string pNotice5, string pEndDate2) @@ -1699,7 +1738,7 @@ namespace BeWoPlanerMobil.Controllers if (Model == null) { RedirectToActionPermanent("Index", "Login"); - return " "; + return null; } Model.SelectedServiceDescriptionOid = pServiceDescriptionOid; @@ -1730,7 +1769,13 @@ namespace BeWoPlanerMobil.Controllers private void LoadRecordsToModel() { - if(Model.Zeitraum < 0 || Model.CostBearer2SupportConceptOid.HasValue && Model.CostBearer2SupportConceptOid.Value == -1) + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return; + } + + if (Model.Zeitraum < 0 || Model.CostBearer2SupportConceptOid.HasValue && Model.CostBearer2SupportConceptOid.Value == -1) { Model.ServiceRecords = new List(); return; @@ -1833,6 +1878,12 @@ namespace BeWoPlanerMobil.Controllers public string GetSelectedRecordInformation() { + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + var result = string.Empty; if (Model.SelectedServiceRecordOid.HasValue) @@ -1845,16 +1896,24 @@ namespace BeWoPlanerMobil.Controllers public string GetSelectedRecordInformationWithOid(long oid) { + if (Model == null) + { + RedirectToActionPermanent("Index", "Login"); + return null; + } + LoadRecordsToModel(); return SerializeObject(Model.ServiceRecords.First(f => f.ServiceRecordOid == oid)); } + [Authorize] public string CheckRights(string von, string bis, bool inEditMode, string dateString, string startString, string endString) - { + { if (Model == null) { - return "SessionTimeout"; + RedirectToActionPermanent("Index", "Login"); + return null; } log.Info($"CheckRights: von:{von};bis:{bis};inEditMode:{inEditMode};dateString:{dateString};startString:{startString};endString:{endString}"); @@ -1898,10 +1957,14 @@ namespace BeWoPlanerMobil.Controllers checkSR.Start = startDt; checkSR.End = endDt; - if (Model.Employee.EmployeeOid != null) + checkSR.IP = Request.UserHostAddress; + + checkSR.ServiceDescription = OperationsService.GetServiceDescription(Model.SelectedServiceDescriptionOid.Value); + + checkSR.Employee = Model.SelectedEmployee ?? MobileSessionFacade.LoggedInCompactEmployee; + + if (Model.SelectedEmployee != null && !Model.IsInGroupBookingMode) { - checkSR.Employee = MobileSessionFacade.LoggedInCompactEmployee; - var sc = Model.SupportConcepts.FirstOrDefault(fod => fod.CostBearerRelations.Any(a => a.CostBearer2SupportConceptOid.HasValue && a.CostBearer2SupportConceptOid.Value.Equals(Model.CostBearer2SupportConceptOid))); if (sc != null) @@ -1918,26 +1981,25 @@ namespace BeWoPlanerMobil.Controllers if (intervall > 0) { - checkSR.RoundedDuration = dauer % intervall != 0 ? dauer + (intervall - (dauer % intervall)) : dauer; + checkSR.RoundedDuration = dauer % intervall != 0 ? dauer + (intervall - dauer % intervall) : dauer; } checkSR.CostBearer2SupportConceptOid = Model.CostBearer2SupportConceptOid; } } - checkSR.IP = Request.UserHostAddress; - checkSR.InsertedOn = DateTime.Now; - checkSR.InsUser = $"{MobileSessionFacade.LoggedInEmployee.FirstName} {MobileSessionFacade.LoggedInEmployee.LastName}"; - - checkSR.ServiceDescription = OperationsService.GetServiceDescription(Model.SelectedServiceDescriptionOid.Value); - var mandator = OperationsService.GetMandator(); var settings = mandator.Settings ?? string.Empty; var splitSettings = settings.Split(';'); var maxDaysEditSRsAllowedSetting = splitSettings.ToList().FirstOrDefault(f => f.Contains("MaxDaysEditServiceRecordsAllowed")); var maxDaysEditSRsAllowed = maxDaysEditSRsAllowedSetting != null ? int.Parse(maxDaysEditSRsAllowedSetting.Split('=')[1]) : 0; var limitFuerZeiterfassungSetting = splitSettings.ToList().FirstOrDefault(f => f.Contains("AnzTageZeiterfassErfolgt")); - var limitFuerZeiterfassung = limitFuerZeiterfassungSetting != null ? limitFuerZeiterfassungSetting.Split('=')[1] : "0"; + var limitFuerZeiterfassung = limitFuerZeiterfassungSetting != null ? int.Parse(limitFuerZeiterfassungSetting.Split('=')[1]) : 0; + + if (MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowEditAfterMaxDaysInNextMonth)) + { + maxDaysEditSRsAllowed = -1; + } SupportConceptStatisticsDC stats = null; @@ -1948,7 +2010,10 @@ namespace BeWoPlanerMobil.Controllers var employees = new List {checkSR.Employee.EmployeeOid}; - var newResult = new ValidationResult(); + var validationResults = new List(); + + checkSR.ServiceRecordFormat = ServiceRecordFormate.OriginaleZeiterfassung; + checkSR.DurationInStunden = ZeiterfassungsDauer.Minuten; string dateRangeString; @@ -1967,33 +2032,21 @@ namespace BeWoPlanerMobil.Controllers var cb2scOids = (from scDc in Model.SelectedSupportConcepts where scDc.CostBearerRelations != null && scDc.CostBearerRelations.Count > 0 select scDc.CostBearerRelations[0].CostBearer2SupportConceptOid.Value).ToList(); - var nodes = new List(); - foreach (var sc in CustomerService.LoadCompactSupportConceptsById(Model.SelectedSupportConcepts.Select(s => s.SupportConceptOid.Value))) + var relations = CustomerService.GetSupportConceptCostBearerRelationsById(cb2scOids); + + foreach (var rel in relations) { - nodes.Add(CreateFlatSupportConceptItem(sc, null)); - } + var sr = CloneServiceRecordForGroupBooking(checkSR); - foreach (var node in nodes) - { - if (node?.SupportConceptTreeNodeDC != null) - { - var scDc = node.SupportConceptTreeNodeDC.SupportConcept; - var cbDc = node.SupportConceptTreeNodeDC.CostBearer; - var relDc = node.SupportConceptTreeNodeDC.SupportConceptCostBearerRelDC; + sr.SupportConcept = rel.SupportConcept; + sr.CostBearer = rel.CostBearer; + sr.CostBearer2SupportConceptOid = rel.CostBearer2SupportConceptOid; + - checkSR.SupportConcept = scDc; - checkSR.CostBearer = cbDc; + var result = OperationsService.ValidateServiceRecord(sr, null, maxDaysEditSRsAllowed, employees, cb2scOids); + dateRangeString = rel.DateRangeString; - if (relDc != null) - { - checkSR.CostBearer2SupportConceptOid = relDc.CostBearer2SupportConceptOid; - } - } - - var result = OperationsService.ValidateServiceRecord(checkSR, stats, maxDaysEditSRsAllowed, employees, cb2scOids); - dateRangeString = node?.SupportConceptTreeNodeDC != null ? node.SupportConceptTreeNodeDC.SupportConceptCostBearerRelDC.DateRangeString : ""; - - newResult.ServiceRecord2Validations.Add(new ServiceRecord2Validation(checkSR, result, dateRangeString)); + validationResults.Add(new ServiceRecord2Validation(sr, result, dateRangeString)); } } else @@ -2002,15 +2055,142 @@ namespace BeWoPlanerMobil.Controllers dateRangeString = node?.SupportConceptTreeNodeDC != null ? node.SupportConceptTreeNodeDC.SupportConceptCostBearerRelDC.DateRangeString : ""; var result = OperationsService.ValidateServiceRecordEntry(checkSR, stats, maxDaysEditSRsAllowed, checkSR.GroupOid.HasValue, employees); - newResult.ServiceRecord2Validations.Add(new ServiceRecord2Validation(checkSR, result, dateRangeString)); + validationResults.Add(new ServiceRecord2Validation(checkSR, result, dateRangeString)); } - - newResult.MaxDaysEditServiceRecordsAllowed = maxDaysEditSRsAllowed.ToString(); - newResult.LimitFuerZeiterfassung = limitFuerZeiterfassung; - newResult.Rights.Add(0, MobileSessionFacade.LoggedInUser.UserGroups.Any(a => a.Rights.Any(f => f.RightType.Equals(UserRightType.ServiceRecord_AllowCreateOverlappingFLS)))); - newResult.Rights.Add(1, MobileSessionFacade.LoggedInUser.UserGroups.Any(a => a.Rights.Any(f => f.RightType.Equals(UserRightType.ServiceRecord_AllowCreateMoreFLSThanApproved)))); - newResult.Rights.Add(2, MobileSessionFacade.LoggedInUser.UserGroups.Any(a => a.Rights.Any(f => f.RightType.Equals(UserRightType.BookServiceRecordAfterSettlementInvoice)))); + var allowOverlappingFLS = MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreateOverlappingFLS); + var allowMoreFLSThanApproved = MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreateMoreFLSThanApproved); + var bookAfterSettlementInvoice = MobileSessionFacade.CheckForUserRight(UserRightType.BookServiceRecordAfterSettlementInvoice); + + var newResult = new ValidationResult(); + var exitLoop = false; + foreach (var sr2v in validationResults) + { + if(exitLoop) + { + break; + } + + foreach (var vr in sr2v.ValidationResults) + { + if (exitLoop) + { + break; + } + + switch(vr.ResultType) + { + case ServiceRecordOverlapping: + if (allowOverlappingFLS) + { + newResult.KannTrotzdemGespeichertWerden = true; + newResult.Message += "An dem gewählten Datum '" + von + "' existiert bereits ein Eintrag (" + vr.Message + " bei Klient/in " + vr.CustomerName + "). Möchten Sie trotzdem speichern?
"; + exitLoop = false; + } + else + { + newResult.Message += "An dem gewählten Datum '" + von + "' existiert bereits ein Eintrag (" + vr.Message + " bei Klient/in " + vr.CustomerName + "). Speichern nicht möglich.
"; + exitLoop = true; + newResult.KannTrotzdemGespeichertWerden = false; + } + break; + case EmployeeOverlapping: + if (allowOverlappingFLS) + { + newResult.Message += "An dem gewählten Datum " + von + " existiert bereits ein Eintrag von " + vr.EmployeeName + " (" + vr.Message + "). Möchten Sie trotzdem speichern?
"; + exitLoop = false; + newResult.KannTrotzdemGespeichertWerden = true; + } + else + { + newResult.Message += "An dem gewählten Datum " + von + " existiert bereits ein Eintrag von " + vr.EmployeeName + " (" + vr.Message + "). Speichern nicht möglich.
"; + + exitLoop = true; + newResult.KannTrotzdemGespeichertWerden = false; + } + break; + case OutsideOfSupportConcept: + newResult.Message += "Das gewählte Datum " + von.Substring(0, 10) + " liegt außerhalb des Zeitraumes des gewählten Hilfeplans (" + sr2v.HilfePlanZeitraum + "). Speichern nicht möglich.
"; + + newResult.KannTrotzdemGespeichertWerden = false; + exitLoop = true; + break; + case ApprovedFLSOverspending: + var klient = "diesen Hilfeplan"; + if (!string.IsNullOrEmpty(vr.CustomerName)) + { + klient = "Klient/in " + vr.CustomerName; + } + + var msg = "Die für " + klient + " genehmigten FLS (" + vr.ApprovedHours + ") werden mit diesem Eintrag überschritten. (" + vr.HoursNew + ")."; + if (allowMoreFLSThanApproved) + { + newResult.Message += msg + " Möchten Sie trotzdem speichern?
"; + exitLoop = false; + newResult.KannTrotzdemGespeichertWerden = true; + } + else + { + newResult.Message += msg + " Speichern nicht möglich.
"; + exitLoop = true; + newResult.KannTrotzdemGespeichertWerden = false; + } + + break; + case OutOfEditLimit: + newResult.Message += "Sie können keine neuen Leistungen für den " + von + " dokumentieren, da bereits der " + maxDaysEditSRsAllowed + ". des nachfolgenden Monats überschritten ist. Speichern nicht möglich.
"; + exitLoop = true; + newResult.KannTrotzdemGespeichertWerden = false; + + break; + case Error: + newResult.Message += "Beim Speichern ist ein Fehler aufgetreten. Speichern nicht möglich.
"; + exitLoop = true; + newResult.KannTrotzdemGespeichertWerden = false; + + break; + case SettlementInvoiceAlreadyExisting: + var klient2 = "diesen Hilfeplan"; + if(!string.IsNullOrEmpty(vr.CustomerName)) + { + klient2 = "Klient/in " + vr.CustomerName; + } + + if (bookAfterSettlementInvoice) + { + newResult.Message += "Es existiert bereits eine Spitzabrechnung für " + klient2 + ". Um diesen Eintrag zu berücksichtigen, muss eventuell eine neue Spitzabrechnung erstellt werden. Möchten Sie trotzdem speichern?
"; + exitLoop = false; + newResult.KannTrotzdemGespeichertWerden = true; + } + else + { + newResult.Message += "Sie können den Eintrag nicht bearbeiten, da bereits eine Spitzabrechnung für " + klient2 + " erstellt wurde. Speichern nicht möglich.
"; + exitLoop = true; + newResult.KannTrotzdemGespeichertWerden = false; + } + + break; + case FristAbgelaufen: + var intervall = "einem Tag"; + if (limitFuerZeiterfassung != 1) + { + intervall = "" + limitFuerZeiterfassung + " Tagen"; + } + + newResult.Message += "Sie können keine neuen Leistungen für den " + von + " dokumentieren, da die Zeiterfassung innerhalb von " + intervall + " erfolgen muss. Das Speichern ist nicht möglich.
"; + exitLoop = true; + newResult.KannTrotzdemGespeichertWerden = false; + + break; + case Custom: + newResult.Message += vr.Message + "
"; + + exitLoop = true; + newResult.KannTrotzdemGespeichertWerden = false; + break; + } + } + } Model.NewServiceRecord = new ServiceRecordDC(); @@ -2264,6 +2444,8 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedEmployees.Clear(); Model.SelectedSupportConcepts.Clear(); + Model.SelectedEmployee = MobileSessionFacade.LoggedInCompactEmployee; + if (Model.SelectedSupportConcept != null) { var details = OperationsService.GetSupportConceptTreeNodeDetailInfo(Model.SelectedSupportConcept.Customer.CustomerOid, Model.SelectedSupportConcept.SupportConceptOid, Model.CostBearer2SupportConceptOid); @@ -2429,5 +2611,104 @@ namespace BeWoPlanerMobil.Controllers return MainModel.IsEmployeeSelectionVisible.ToString(); } + + private IEnumerable CalculateGroupBookingDuration(int pEmployeeCount, int pCustomerCount, ICollection cb2ScOids, ServiceRecordDC pBaseRecord) + { + var compactSupportConcepts = CustomerServiceImp.GetCompactSupportConcepts((from sc in Model.SelectedSupportConcepts where sc.SupportConceptOid != null select sc.SupportConceptOid.Value).ToList(), GetUser().Employee.EmployeeOid); + + var nodes = (from supportConcept in Model.SelectedSupportConcepts let cb = supportConcept.CostBearerRelations.FirstOrDefault(f => cb2ScOids.Contains(f.CostBearer2SupportConceptOid.Value)) let sc = compactSupportConcepts.FirstOrDefault(f => f.SupportConceptOid == supportConcept.SupportConceptOid) where cb != null && sc != null select SupportConceptService.CreateFlatSupportConceptItem(sc, CustomerService.LoadOrganisationCompact(cb.CostBearer.OrganisationOid))).ToList(); + + var list = new List(); + foreach(var node in nodes) + { + var sc = CloneServiceRecordForGroupBooking(pBaseRecord); + + if(pBaseRecord.RoundedDuration == 0) + { + if(pBaseRecord.Start.HasValue && pBaseRecord.End.HasValue) + { + var minutes = pBaseRecord.End.Value.Subtract(pBaseRecord.Start.Value).TotalMinutes; + + pBaseRecord.RoundedDuration = (decimal)minutes; + } + } + + sc.GroupRoundedDuration = pBaseRecord.RoundedDuration; + + sc.CostBearer2SupportConceptOid = node.SupportConceptTreeNodeDC.SupportConceptCostBearerRelDC.CostBearer2SupportConceptOid; + + sc.SupportConcept = node.SupportConceptTreeNodeDC.SupportConcept; + + sc.CostBearer = node.SupportConceptTreeNodeDC.CostBearer; + + sc.Customer = node.SupportConceptTreeNodeDC.Customer; + + sc.GroupEmployeeCount = pEmployeeCount; + + sc.GroupPersonCount = pCustomerCount; + + list.Add(sc); + } + + var roundDuration = false; + var minuteInterval = 0; + string calcdId = null; + var lastMinuteInterval = -1; + + if(Model.SelectedServiceDescriptionOid.HasValue && IsBillable(Model.SelectedServiceDescriptionOid.Value, Model.GetServiceDesctiptions())) + { + roundDuration = true; + + foreach(var org in from dc in Model.SelectedSupportConcepts where dc.CostBearerRelations.Count > 0 select dc.CostBearerRelations.First().CostBearer) + { + if(org != null) + { + minuteInterval = org.ActualMinuteIntervall; + + if(lastMinuteInterval == -1) + { + lastMinuteInterval = minuteInterval; + calcdId = org.CostBearerID; + } + else if(lastMinuteInterval != minuteInterval) + { + roundDuration = false; + } + } + else if(minuteInterval >= 0) + { + roundDuration = false; + } + else + { + minuteInterval = 0; + } + } + } + + var duration = Model.NewServiceRecord.RoundedDuration; + var totalDuration = duration; + + var groupDuration = OperationsService.CalculateGroupDuration2(pCustomerCount, pEmployeeCount, Model.NewServiceRecord.RoundedDuration, nodes.Select(s => s.SupportConceptTreeNodeDC.SupportConceptCostBearerRelDC.CostBearer2SupportConceptOid.Value).ToArray()); + + if(groupDuration != null) + { + pBaseRecord.GroupRoundedDuration = groupDuration.TotalDuration; + pBaseRecord.RoundedDuration = groupDuration.SingleDuration; + } + else + { + if(minuteInterval > 0 && roundDuration) + { + var calc = Calculations.GetInstance(calcdId); + totalDuration = calc.GetRoundedDuration(minuteInterval, duration); + } + + pBaseRecord.RoundedDuration = Math.Round(totalDuration / pCustomerCount, 0, MidpointRounding.AwayFromZero); + pBaseRecord.GroupRoundedDuration = totalDuration; + } + + return list; + } } } diff --git a/BeWoPlanerMobil/Scripts/gruppenbuchung.js b/BeWoPlanerMobil/Scripts/gruppenbuchung.js index 888003ea8..63e36c7d6 100644 --- a/BeWoPlanerMobil/Scripts/gruppenbuchung.js +++ b/BeWoPlanerMobil/Scripts/gruppenbuchung.js @@ -1,8 +1,6 @@ function selectGroupBookingForEditing(serviceRecordOid) { hideSanduhr(); - console.log("Gruppenbuchung wird bearbeitet"); - setGroupEditingFlag(true); $("#editGroupServiceRecord_" + serviceRecordOid).submit(); @@ -39,7 +37,8 @@ function getGroupEditingFlag() { return flagData.obj || {}; } -/* NEUE GRUPPENBUCHUNG */ + + function hideGroupBookingPopup() { var btn = $("#groupBookingOpenPopupBtn"); var container = $("#groupBookingPopupDivContainer"); @@ -48,12 +47,12 @@ function hideGroupBookingPopup() { var rightContent = $("#rightContent"); var leftContent = $("#leftContent"); - hideElement(container); - hideElement(popup); - hideElement(collapsible); + container.hide(); + popup.hide(); + collapsible.hide(); - hideElement(rightContent); - hideElement(leftContent); + rightContent.hide(); + leftContent.hide(); btn.css("background-image", "url('../Content/images/toggle-icon-d.svg')"); } @@ -70,9 +69,8 @@ function openGroupBookingDiv() { var popup = $("#groupBookingPopupDiv"); - showElement(container); - showElement(popup); - + container.show(); + popup.show(); btn.css("background-image", "url('../Content/images/toggle-icon-u.svg')"); @@ -84,7 +82,7 @@ function openGroupBookingDiv() { popup.css("top", parseInt(sum) + "px"); popup.css("width", (btn.innerWidth() - 2) + "px"); - showElement(collapsible); + collapsible.show(); openGroupBookingTab(true); } @@ -98,13 +96,13 @@ function openGroupBookingTab(isSupportConceptTab) { if (isSupportConceptTab) { leftBtn.addClass("active"); rightBtn.removeClass("active"); - showElement(leftContent); - hideElement(rightContent); + leftContent.show(); + rightContent.hide(); } else { rightBtn.addClass("active"); leftBtn.removeClass("active"); - showElement(rightContent); - hideElement(leftContent); + rightContent.show(); + leftContent.hide(); } } @@ -115,10 +113,9 @@ function addSupportConcepts() { $("#groupBookingSupportConceptSelectionForm").submit(); } -/* ------------------- */ -/* NEUE MITARBEITERMEHRFACHAUSWAHL */ + function openEmployeePopup() { var container = $("#employeePopupContainer"); @@ -131,8 +128,8 @@ function openEmployeePopup() { var collapsible = $("#employeeCollapsible"); var popup = $("#employeePopupDiv"); - showElement(container); - showElement(popup); + container.show(); + popup.show(); btn.css("background-image", "url('../Content/images/toggle-icon-u.svg')"); @@ -143,8 +140,11 @@ function openEmployeePopup() { popup.css("top", parseInt(sum) + "px"); popup.css("width", (btn.innerWidth() - 2) + "px"); + popup.css("max-width", (btn.innerWidth() - 2) + "px"); - showElement(collapsible); + collapsible.height(($(window).height() / 2) + "px"); + + collapsible.show(); } function hideEmployeePopup() { @@ -158,9 +158,9 @@ function hideEmployeePopup() { var collapsible = $("#employeeCollapsible"); var popup = $("#employeePopupDiv"); - hideElement(container); - hideElement(popup); - hideElement(collapsible); + container.hide(); + popup.hide(); + collapsible.hide(); btn.css("background-image", "url('../Content/images/toggle-icon-d.svg')"); } @@ -172,4 +172,3 @@ function addEmployees() { $("#groupBookingEmployeeSelectionForm").submit(); } -/* ------------------------------- */ \ No newline at end of file diff --git a/BeWoPlanerMobil/Scripts/initialization.js b/BeWoPlanerMobil/Scripts/initialization.js index e492f8f02..9de200e38 100644 --- a/BeWoPlanerMobil/Scripts/initialization.js +++ b/BeWoPlanerMobil/Scripts/initialization.js @@ -94,7 +94,7 @@ function initBeWoMobile(actionPath) { toggleSelectClassesForElement("#recordLoader_select", "#record-loader-select-container"); toggleSelectClassesForElement("#textbausteine_select", "#textbausteine-select-container"); - var selectedServiceCategory = $($("#scDropDown")).find(":selected").val(); + var selectedServiceCategory = $("#scDropDown").find(":selected").val() if(isInGroupBookingMode() && isInEditingMode()) { if(getGroupEditingFlag().flag === false) { @@ -164,10 +164,10 @@ function initBeWoMobile(actionPath) { }); var supportConceptTableHasEntries = $("#leftContent input:checked").length; - var employeesTableHasEntries = $("#rightContent input:checked").length; + var employeesTableHasEntries = $("#employeeCollapsible input:checked").length; if (isInGroupBookingMode()) { - var value = (supportConceptTableHasEntries === 0 || employeesTableHasEntries === 0) ? false : true; + var value = supportConceptTableHasEntries > 0 && employeesTableHasEntries > 0 ? false : true; $("#anlegenEditierenBtn").prop("disabled", value); } @@ -254,14 +254,18 @@ function loadSettingsAccordingToBWP() { } function initializeDocumentationTextareas() { - $.ajax({ - type: "GET", - url: CheckDokuReiterUrl, - success: function (json) { - var documentationTypes = $.parseJSON(json); - numberOfDocumentationTypes = documentationTypes.length; + makeAjaxCall( + "GET", + CheckDokuReiterUrl, + function (json) { + var dokuTypes = $.parseJSON(json); - if(numberOfDocumentationTypes === 0) { + numberOfDocumentationTypes = dokuTypes.length; + + var tabWidth = 100 / numberOfDocumentationTypes; + $(".doku-tab-link").css("width", tabWidth + "%"); + + if (numberOfDocumentationTypes === 0) { $("#tddokureiter").css("display", "none"); $("#trnormalDoku").css("display", "table-row"); window.focusedDokuTextarea = $("#notiz_textbox"); @@ -269,28 +273,44 @@ function initializeDocumentationTextareas() { window.focusedDokuTextarea = $("#notiz_textbox1"); } - if(numberOfDocumentationTypes === 1) { + if (numberOfDocumentationTypes === 1) { $("#tddokureiter").css("display", "none"); $("#trnormalDoku").css("display", "table-row"); - $("#trnormalDokuLabel").text(documentationTypes[0].TypeDescription); + $("#trnormalDokuLabel").text(dokuTypes[0].TypeDescription); } - if(numberOfDocumentationTypes > 1) { - for(var i = 0; i < numberOfDocumentationTypes; i++) { + if (numberOfDocumentationTypes > 1) { + var height = 0; + + for (var i = 0; i < numberOfDocumentationTypes; i++) { var idNumber = i + 1; - $('#DokName' + idNumber).text(documentationTypes[i].TypeDescription); - $('#Dokumentation' + idNumber).css("display", "block"); + var dokuTab = $("#doku-name-" + idNumber); + + dokuTab.html(dokuTypes[i].TypeDescription); + showElement(dokuTab); + + var outerHeight = dokuTab.outerHeight(); + + if (outerHeight > height) { + height = outerHeight; + } } + + $(".doku-tab-link").css("height", height + "px"); } - if(numberOfDocumentationTypes > 0) { - focusOnTab(1); + if (numberOfDocumentationTypes > 0) { + focusOnDoku(1); } - } - }); + }, + null, + null + ); } + +// Formulardaten im Browser speichern, um nach einem erneuten Laden der Seite (z.B. beim Hinzufügen von Hilfeplänen bzw. Gruppen oder Mitarbeitern) die Daten wiederherzustellen. var savedEditFormValues = {}; $(document).on("change", ".edit-form-input", @@ -298,8 +318,6 @@ $(document).on("change", ".edit-form-input", saveFormValuesLocally(); }); -//$(document).change(function() { console.log("test"); }); - function saveFormValuesLocally() { var recordObject = { category: $("#kategorien_select").val(), diff --git a/BeWoPlanerMobil/Scripts/mainView.js b/BeWoPlanerMobil/Scripts/mainView.js index 192c74b03..d22ac4089 100644 --- a/BeWoPlanerMobil/Scripts/mainView.js +++ b/BeWoPlanerMobil/Scripts/mainView.js @@ -43,7 +43,7 @@ var collapsibleHtml; function buildGoalTreeItem(goalItem, selectedGoalOids) { var goalOid = goalItem.ValueListEntryOid; var goalHeader = goalItem.Header; - var isChecked = selectedGoalOids != null && isElementInArray(selectedGoalOids, goalOid) ? "checked" : ""; + var isChecked = selectedGoalOids !== null && isElementInArray(selectedGoalOids, goalOid) ? "checked" : ""; if (!goalItem.IsLeaf) { //collapsibleHtml += ''; @@ -354,8 +354,8 @@ function selectServiceRecord(oid) { showElement($("#singleSCEmployeeSelectionContainer")); } - hideElement($("#groupBookingOpenPopupBtn")); - hideElement($("#groupBookingOpenEmployeeSelectionPopupBtn")); + $("#groupBookingOpenPopupBtn").hide(); + $("#groupBookingOpenEmployeeSelectionPopupBtn").hide(); }, null, null); } @@ -381,7 +381,8 @@ function selectServiceRecord(oid) { function activateForm(actionPath) { $("input").prop("disabled", false); - $("textarea").prop("disabled", false); + $("textarea").prop("disabled", false); + $(".doku-tab-link").prop("disabled", false); $("#kategorien_select, #leistungen_select, #recordLoader_select, #textbausteine_select").prop("disabled", false); toggleSelectClassesForElement("#kategorien_select", "#kategorien-select-container"); @@ -529,201 +530,7 @@ function toggleModalWrapper() { $(".modalWrapper").css("height", $(document).height()); } -function validateServiceRecordBeforeSubmit() { - function getLocation() { - if (navigator.geolocation) { - navigator.geolocation.getCurrentPosition(showPosition, showError); - } else { - console.log("Ortung wird von diesem Browser nicht unterstützt"); - showPosition(null); - } - } - var dateStr = $("#datum_textbox").val(); - var startStr = $("#start_textbox").val(); - var endStr = $("#ende_textbox").val(); - - var x = getDateObj(true); - - var y; - - if ($("#enddatum_textbox").val() !== "") { - y = getEndDateObj(); - } else { - y = getDateObj(false); - } - - var vonDatum = getDateTimeStringWithLeadingZeros(x); - var bisDatum = getDateTimeStringWithLeadingZeros(y); - - var isValidRecord = true; - - makeAjaxCall("POST", checkRightsUrl, function(json) { - if (json === "SessionTimeout") { - window.location.href = redirectLink; - return; - } - - if (json === "StartGreaterEnd") { - hideSanduhr(); - writeFatalErrorMessage("Die Startzeit darf nicht größer als die Endzeit sein!"); - return; - } - - var meldungen = $.parseJSON(json); - console.log(meldungen); - - var relations = meldungen.ServiceRecord2Validations; - var results = null; - var allowOverlappingFLS = false; - var allowMoreFLSThanApproved = false; - var bookAfterSettlementInvoice = false; - - $.each(meldungen.Rights, function(position) { - var value = meldungen.Rights[position]; - var key = parseInt(position); - - switch (key) { - case 0: - allowOverlappingFLS = value; - break; - case 1: - allowMoreFLSThanApproved = value; - break; - case 2: - bookAfterSettlementInvoice = value; - break; - default: - break; - } - }); - - for (var j = 0; j < relations.length; j++) { - results = relations[j].ValidationResults; - var exitLoop = false; - - for (var i = 0; i < results.length; i++) { - if (exitLoop) { - break; - } - - switch (results[i].ResultType) { - case 0: - // ServiceRecordOverlapping: ServiceRecord überschneidet sich mit einem anderen Eintrag - var msg1 = "An dem gewählten Datum '" + vonDatum + "' existiert bereits ein Eintrag (" + results[i].Message + " bei Klient/in " + results[i].CustomerName + "). Speichern nicht möglich."; - if (allowOverlappingFLS === true) { - var r = confirm("An dem gewählten Datum '" + vonDatum + "' existiert bereits ein Eintrag (" + results[i].Message + " bei Klient/in " + results[i].CustomerName + "). Möchten Sie trotzdem speichern?"); - isValidRecord = r; - exitLoop = !isValidRecord; - } else { - alert(msg1); - isValidRecord = false; - exitLoop = true; - } - break; - case 1: - // EmployeeOverlapping: Employee hat einen mit diesem Eintrag sich überschneidenden Eintrag - var msg2 = "An dem gewählten Datum " + vonDatum + " existiert bereits ein Eintrag von " + results[i].EmployeeName + "(" + results[i].Message + "). Speichern nicht möglich."; - if (allowOverlappingFLS === true) { - var r2 = confirm("An dem gewählten Datum " + vonDatum + " existiert bereits ein Eintrag von " + results[i].EmployeeName + "(" + results[i].Message + "). Möchten Sie trotzdem speichern?"); - isValidRecord = r2; - exitLoop = !isValidRecord; - } else { - alert(msg2); - isValidRecord = false; - exitLoop = true; - } - break; - case 2: - // OutsideOfSupportConcept: Der Eintrag liegt außerhalb des Hilfeplanzeitraumes - alert("Das gewählte Datum " + vonDatum.slice(0, 10) + " liegt außerhalb des Zeitraumes des gewählten Hilfeplans (" + relations[j].HilfePlanZeitraum + "). Speichern nicht möglich."); - //writeFatalErrorMessage("Das gewählte Datum " + vonDatum.slice(0, 10) + " liegt außerhalb des Zeitraumes des gewählten Hilfeplans (" + relations[j].HilfePlanZeitraum + "). Speichern nicht möglich."); - - isValidRecord = false; - exitLoop = true; - break; - case 3: - // ApprovedFLSOverspending: Die Anzahl der genehmigten FLS wird überschritten - var klient = "diesen Hilfeplan"; - if (results[i].CustomerName !== null && results[i].CustomerName.length >= 0) { - klient = "Klient/in " + results[i].CustomerName; - } - - var msg3 = "Die für " + klient + " genehmigten FLS (" + results[i].ApprovedHours + ") werden mit diesem Eintrag überschritten. (" + results[i].HoursNew + ")."; - if (allowMoreFLSThanApproved === true) { - var r3 = confirm(msg3 + " Möchten Sie trotzdem speichern?"); - isValidRecord = r3; - exitLoop = !isValidRecord; - } else { - alert(msg3); - isValidRecord = false; - exitLoop = true; - } - break; - case 4: - // OutOfEditLimit: MaxDaysEditServiceRecordAllowed überschritten - alert("Sie können keine neuen Leistungen für den " + vonDatum + " dokumentieren, da bereits der " + meldungen.MaxDaysEditServiceRecordsAllowed + ". des nachfolgenden Monats überschritten ist."); - isValidRecord = false; - exitLoop = true; - break; - case 5: - // Error: Ein genereller Fehler ist bei der Validierung aufgetreten - alert("Beim Speichern ist ein Fehler aufgetreten. Speichern nicht möglich."); - isValidRecord = false; - exitLoop = true; - break; - case 6: - // SettlementInvoiceAlreadyExisting: Es existiert bereits eine Spitzabrechnung - var klient2 = "diesen Hilfeplan"; - if (results[i].CustomerName !== null && results[i].CustomerName.length >= 0) { - klient2 = "Klient/in " + results[i].CustomerName; - } - - var msg6 = "Es existiert bereits eine Spitzabrechnung für " + klient2 + ". Um diesen Eintrag zu berücksichtigen, muss eventuell eine neue Spitzabrechnung erstellt werden. Das Speichern ist nicht möglich."; - if (bookAfterSettlementInvoice === true) { - msg6 = "Sie können den Eintrag nicht bearbeiten, da bereits eine Spitzabrechnung für " + klient2 + " erstellt wurde. Speichern nicht möglich."; - } - alert(msg6); - isValidRecord = false; - exitLoop = true; - break; - case 7: - // FristAbgelaufen: Die Frist zur Bearbeitung ist abgelaufen - var intervall = "einem Tag"; - - if (results[i].LimitFuerZeiterfassung !== "1") { - intervall = results[i].LimitFuerZeiterfassung + " Tagen"; - } - - var msg7 = "Sie können keine neuen Leistungen für den " + vonDatum + " dokumentieren, da die Zeiterfassung innerhalb von " + intervall + " erfolgen muss. Das Speichern ist nicht möglich."; - - alert(msg7); - isValidRecord = false; - exitLoop = true; - break; - default: - // Custom(8), da default: ServiceRecordValidationResult.Custom - alert(results[i].Message); - isValidRecord = false; - exitLoop = true; - break; - } - } - } - - $("#URLSave").val(dataURL); - $("#TimeStampSave").val(newday); - $("#GeoLocSaveXCOOR").val(langenGrad); - $("#GeoLocSaveYCOOR").val(breitenGrad); - - if (isValidRecord) { - $("#createSRForm").submit(); - } else { - hideSanduhr(); - } - }, - { von: vonDatum, bis: bisDatum, inEditMode: $("#anlegenEditierenBtn").val() === "Speichern", dateString: dateStr, startString: startStr, endString: endStr }); -} function ErfolgteSpx() { if (document.getElementById("SaveSignature").value === "True") { @@ -887,10 +694,10 @@ function initAppointmentEditForm() { currTime.setMinutes(currTime.getMinutes() + j); } - $("#AppointmentEditForm").css("display", "block"); - $("#KalenderTable").css("display", "none"); - $("#KalenderNavigation").css("display", "none"); - $("#KalenderTableTask").css("display", "none"); + $("#AppointmentEditForm").show();//css("display", "block"); + $("#KalenderTable").hide();//css("display", "none"); + $("#KalenderNavigation").hide();//css("display", "none"); + $("#KalenderTableTask").hide();//css("display", "none"); $("#StartDate").val($("#KalenderDatumFormat").val()); $("#EndDate").val($("#KalenderDatumFormat").val()); $("#TerminStartZeit").val(getHoursAndMinutesWithLeadingZeros(currTime)); @@ -908,21 +715,22 @@ function initAppointmentEditForm() { $("#TerminSpeichern").val("Speichern"); $("#TerminSpeichernAbbrechen").val("Abbrechen"); - $("#TerminSpeichern").css("display", "none"); + $("#TerminSpeichern").hide();//css("display", "none"); $("#InsertAppointmentButton").css("display", "inline"); } function hideEditForm() { - $("#AppointmentEditForm").css("display", "none"); - $("#KalenderTable").css("display", "block"); - $("#KalenderNavigation").css("display", "block"); - $("#KalenderTableTask").css("display", "block"); + $("#AppointmentEditForm").hide(); + $("#KalenderTable").show(); + $("#KalenderNavigation").show(); + $("#KalenderTableTask").show(); $("#StartDate").val(""); } function nextDayButtonClick() { - var nextdatum = new Date($("#KalenderDatum").val()); + var nextdatum = new Date($("#KalenderDatum").val() + "T00:00:00Z"); + nextdatum.setDate((nextdatum.getDate() + 1)); $("#KalenderDatum").val(toDateStringYearMonthDay(nextdatum)); @@ -1206,6 +1014,7 @@ function loescheUnterschrift(canvas, ctx) { + function preloadData(serviceRecordOid) { initSignatureInfo(serviceRecordOid); } @@ -1419,7 +1228,7 @@ function updateEigenschaftsfelder() { $("#map-canvas").css("width", customerTableWidth - 16); $("#map-canvas").css("height", customerTableWidth - 16); - if(minSizes == undefined) { + if(minSizes === undefined) { return; } @@ -1446,6 +1255,8 @@ $(window).resize(function () { if($("#klientenTabelle").css("display") === "block") { updateEigenschaftsfelder(); } + + updateDokuTabLinks(); }); function showSanduhr() { @@ -1457,21 +1268,21 @@ function showSanduhr() { function hideSanduhr() { if($("#errorPopupDiv").css("display") === "none" && $("#popupDiv").css("display") === "none") { - $(".modalWrapper").css("display", "none"); + $(".modalWrapper").hide(); $(".modalWrapper").css("height", "0"); } if($("#SuccessPopupDiv").css("display") === "none" && $("#popupDiv").css("display") === "none") { - $(".modalWrapper").css("display", "none"); + $(".modalWrapper").hide(); $(".modalWrapper").css("height", "0"); } if($("#AendernPopupDiv").css("display") === "none" && $("#popupDiv").css("display") === "none") { - $(".modalWrapper").css("display", "none"); + $(".modalWrapper").hide(); $(".modalWrapper").css("height", "0"); } - $(".warte-animation").css("display", "none"); + $(".warte-animation").hide(); } function submitDeletionForm() { @@ -1630,8 +1441,6 @@ function preselectCustomer() { function setSelectedEmployee() { var oid = parseInt($("#employeesDropDown").find(":selected").val()); - console.log('selected employee oid: ' + oid); - if(isNaN(oid)) { return; } @@ -1642,7 +1451,7 @@ function setSelectedEmployee() { } function SaveOnly() { - if(typeof(Storage) != "undefined") { + if(typeof Storage !== "undefined") { clearLocalStorage(1); var costBearer2SupportConceptOid = $("#scDropDown").val(); @@ -1776,19 +1585,50 @@ function showErrorAfterCrash() { } function focusOnTab(tabIdentifier) { + focusOnDoku(tabIdentifier); +} + +function focusOnDoku(number) { setTimeout(function() { var displayValue; - for(var i = 0; i < window.numberOfDocumentationTypes; i++) { + for (var i = 0; i < window.numberOfDocumentationTypes; i++) { var idNumber = i + 1; - displayValue = idNumber === tabIdentifier ? "block" : "none"; + displayValue = idNumber === number ? "block" : "none"; - $('#notiz_textbox' + idNumber).css("display", displayValue); + if (idNumber === number) { + $("#doku-name-" + idNumber).addClass("active"); + } else { + $("#doku-name-" + idNumber).removeClass("active"); + } + + $("#doku-tab-content-" + idNumber).css("display", displayValue); + $("#notiz_textbox" + idNumber).css("display", displayValue); } - $('#notiz_textbox' + tabIdentifier).get(0).focus(); - window.focusedDokuTextarea = $('#notiz_textbox' + tabIdentifier); + $("#notiz_textbox" + number).get(0).focus(); + window.focusedDokuTextarea = $("#notiz_textbox" + number); }, 100); } +function updateDokuTabLinks() { + if (numberOfDocumentationTypes !== undefined && numberOfDocumentationTypes > 1) { + var height = 0; + $(".doku-tab-link").css("height", "auto"); + + for (var i = 0; i < numberOfDocumentationTypes; i++) { + var idNumber = i + 1; + + var dokuTab = $("#doku-name-" + idNumber); + + var outerHeight = dokuTab.outerHeight(); + + if (outerHeight > height) { + height = outerHeight; + } + } + + $(".doku-tab-link").css("height", height + "px"); + } +} diff --git a/BeWoPlanerMobil/Scripts/serviceRecordValidation.js b/BeWoPlanerMobil/Scripts/serviceRecordValidation.js new file mode 100644 index 000000000..b1d8b40d9 --- /dev/null +++ b/BeWoPlanerMobil/Scripts/serviceRecordValidation.js @@ -0,0 +1,104 @@ +var isValidRecord = true; + +function validateServiceRecordBeforeSubmit() { + function getLocation() { + if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(showPosition, showError); + } else { + console.log("Ortung wird von diesem Browser nicht unterstützt"); + showPosition(null); + } + } + + var dateStr = $("#datum_textbox").val(); + var startStr = $("#start_textbox").val(); + var endStr = $("#ende_textbox").val(); + + var x = getDateObj(true); + + var y; + + if ($("#enddatum_textbox").val() !== "") { + y = getEndDateObj(); + } else { + y = getDateObj(false); + } + + var vonDatum = getDateTimeStringWithLeadingZeros(x); + var bisDatum = getDateTimeStringWithLeadingZeros(y); + + //console.log("Validiere Eintrag..."); + + makeAjaxCall("POST", window.checkRightsUrl, function (json) { + $("#URLSave").val(dataURL); + $("#TimeStampSave").val(newday); + $("#GeoLocSaveXCOOR").val(langenGrad); + $("#GeoLocSaveYCOOR").val(breitenGrad); + + if (json === "SessionTimeout") { + window.location.href = redirectLink; + return; + } + + if (json === "StartGreaterEnd") { + hideSanduhr(); + writeFatalErrorMessage("Die Startzeit darf nicht größer als die Endzeit sein!"); + return; + } + + var meldungen = $.parseJSON(json); + kannTrotzdemGespeichertWerden = meldungen.KannTrotzdemGespeichertWerden; + + //console.log("Validierung abgeschlossen. Meldung: " + meldungen.Message + "; Kann trotzdem gespeichert werden: " + meldungen.KannTrotzdemGespeichertWerden); + + if (meldungen.Message === null) { + submitCreationForm(); + return; + } + + toggleValidationPopup(meldungen.Message); + }, + { von: vonDatum, bis: bisDatum, inEditMode: $("#anlegenEditierenBtn").val() === "Speichern", dateString: dateStr, startString: startStr, endString: endStr }); +} + +var kannTrotzdemGespeichertWerden = false; + +function submitCreationForm() { + toggleValidationPopup(null); + + if (kannTrotzdemGespeichertWerden) { + $(".modalWrapper").show(); + $(".warte-animation").show(); + $("#createSRForm").submit(); + } else { + $(".warte-animation").hide(); + } +} + +function toggleValidationPopup(validationMessage) { + $(".warte-animation").hide(); + + var popupDiv = $("#validationPopupDiv"); + + popupDiv.toggle(); + + if (popupDiv.css("display") === "block" && validationMessage !== null && validationMessage !== undefined && validationMessage.length > 0) { + $("#validationPopupText").html(validationMessage); + + var t = $("#validationPopupTitle").outerHeight(); + var u = $("#validationPopupText").outerHeight(); + var v = $("#validationBtn1").outerHeight(); + var w = $("#validationBtn2").outerHeight(); + var x = $("#validationResultList").outerHeight(); + + var h = t + u + v + w + w + x; + + popupDiv.css("height", h + "px"); + + popupDiv.css("top", window.pageYOffset + window.innerHeight / 2 - h / 2); + popupDiv.css("margin-top", "0"); + } else { + $(".modalWrapper").hide(); + popupDiv.css("margin-top", "auto"); + } +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Scripts/textbausteine.js b/BeWoPlanerMobil/Scripts/textbausteine.js index 068d4c8f1..ce70ba35f 100644 --- a/BeWoPlanerMobil/Scripts/textbausteine.js +++ b/BeWoPlanerMobil/Scripts/textbausteine.js @@ -3,7 +3,7 @@ } function loadTextbausteineForCategoryOnSuccess(json) { - if (json == null) { + if (json === null) { return; } @@ -56,7 +56,7 @@ function buildTreeRecursively(textmodule) { } function setTextModule(moduleOid) { - if (window.focusedDokuTextarea == null) { + if (window.focusedDokuTextarea === null) { if ($("#trnormalDoku").css("display") !== "none") { window.focusedDokuTextarea = $("#notiz_textbox"); } else { @@ -78,7 +78,7 @@ function setTextbaustein() { } function loadTextbausteinContentOnSuccess(textbausteintext) { - if (focusedDokuTextarea != null) { + if (focusedDokuTextarea !== null) { var cursorPosition = focusedDokuTextarea.prop("selectionStart"); var v = focusedDokuTextarea.val(); var textBefore = v.substring(0, cursorPosition); @@ -104,7 +104,7 @@ function showTextModulesPopup() { } function hideTextModulePopup() { - hideElement($("#textModulePopupDivContainer")); - hideElement($("#textModulePopupDiv")); - hideElement($("#kollabierbar2")); + $("#textModulePopupDivContainer").hide(); + $("#textModulePopupDiv").hide(); + $("#kollabierbar2").hide(); } \ No newline at end of file diff --git a/BeWoPlanerMobil/Util/MobileUtils.cs b/BeWoPlanerMobil/Util/MobileUtils.cs index 786644459..62a8a67f6 100644 --- a/BeWoPlanerMobil/Util/MobileUtils.cs +++ b/BeWoPlanerMobil/Util/MobileUtils.cs @@ -328,5 +328,51 @@ namespace BeWoPlanerMobil.Util return flatNode; } + + public static ServiceRecordDC CloneServiceRecordForGroupBooking(ServiceRecordDC pOriginal) + { + var m = pOriginal; + + var clone = new ServiceRecordDC + { + CostBearer = m.CostBearer, + CostBearer2SupportConceptOid = m.CostBearer2SupportConceptOid, + Customer = m.Customer, + Employee = m.Employee, + End = m.End, + Goals = m.Goals, + GroupEmployeeCount = m.GroupEmployeeCount, + GroupOid = m.GroupOid, + SignatureOid = m.SignatureOid, + GroupPersonCount = m.GroupPersonCount, + GroupRoundedDuration = m.GroupRoundedDuration, + InsUser = m.InsUser, + InsertedOn = m.InsertedOn, + Notice = m.Notice, + Notice2 = m.Notice2, + Notice3 = m.Notice3, + Notice4 = m.Notice4, + Notice5 = m.Notice5, + RTFNotice1 = m.RTFNotice1, + RTFNotice2 = m.RTFNotice2, + RTFNotice3 = m.RTFNotice3, + RTFNotice4 = m.RTFNotice4, + RTFNotice5 = m.RTFNotice5, + RoundedDuration = m.RoundedDuration, + ServiceDescription = m.ServiceDescription, + Start = m.Start, + SupportConcept = m.SupportConcept, + ServiceRecordType = m.ServiceRecordType, + DistanceInMeter = m.DistanceInMeter, + IP = m.IP, + Relevance = m.Relevance, + IsCreatedInMobileClient = true, + WohnheimbuchungsOid = m.WohnheimbuchungsOid, + DurationInStunden = m.DurationInStunden, + ServiceRecordFormat = m.ServiceRecordFormat + }; + + return clone; + } } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Util/ServiceRecord2Validation.cs b/BeWoPlanerMobil/Util/ServiceRecord2Validation.cs index 5b7872789..64d7e3498 100644 --- a/BeWoPlanerMobil/Util/ServiceRecord2Validation.cs +++ b/BeWoPlanerMobil/Util/ServiceRecord2Validation.cs @@ -1,12 +1,13 @@ using System.Collections.Generic; + using BS.Shared.DataContracts; namespace BeWoPlanerMobil.Util { public class ServiceRecord2Validation { - public ServiceRecordDC ServiceRecord { get; set; } - public List ValidationResults { get; set; } + public ServiceRecordDC ServiceRecord { get; } + public List ValidationResults { get; } public string HilfePlanZeitraum { get; } public ServiceRecord2Validation(ServiceRecordDC pServiceRecord, List pValidationResults, string pHilfePlanZeitraum) diff --git a/BeWoPlanerMobil/Util/ValidationResult.cs b/BeWoPlanerMobil/Util/ValidationResult.cs index 621789fe5..402ed44e6 100644 --- a/BeWoPlanerMobil/Util/ValidationResult.cs +++ b/BeWoPlanerMobil/Util/ValidationResult.cs @@ -1,13 +1,8 @@ -using System.Collections.Generic; - -namespace BeWoPlanerMobil.Util +namespace BeWoPlanerMobil.Util { public class ValidationResult { - public Dictionary Rights { get; set; } = new Dictionary(); - public string MaxDaysEditServiceRecordsAllowed { get; set; } - public string LimitFuerZeiterfassung { get; set; } = "0"; - - public List ServiceRecord2Validations { get; set; } = new List(); + public bool KannTrotzdemGespeichertWerden { get; set; } = true; + public string Message { get; set; } } } \ No newline at end of file diff --git a/BeWoPlanerMobil/Views/Main/Main.cshtml b/BeWoPlanerMobil/Views/Main/Main.cshtml index 0beaef798..098d6e29f 100644 --- a/BeWoPlanerMobil/Views/Main/Main.cshtml +++ b/BeWoPlanerMobil/Views/Main/Main.cshtml @@ -196,64 +196,37 @@
- +
-
-
- - - - - -
+
+
+ + + + + +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
@@ -664,16 +637,15 @@
- @using (Html.BeginForm("AddEmployeesToGroupBooking", "Main", FormMethod.Post, new { id = "groupBookingEmployeeSelectionForm" })) + @using(Html.BeginForm("AddEmployeesToGroupBooking", "Main", FormMethod.Post, new { id = "groupBookingEmployeeSelectionForm" })) { var i = 0; - - @foreach (var ma in Model.EmployeeListItems) +
+ @foreach(var ma in Model.EmployeeListItems) {
- long.Parse(ma.Value).Equals(a.EmployeeOid))) { @Html.Raw("checked=\"checked\"") } /> + long.Parse(ma.Value).Equals(a.EmployeeOid))) { @Html.Raw("checked=\"checked\"") } /> @ma.Text @@ -683,8 +655,8 @@ }
} -
+
@@ -964,6 +936,15 @@
+
+

Validierung

+

+
+ + +
+
+