From fd53e71ecacaef1da28bde54d49a6e3f02bf19e4 Mon Sep 17 00:00:00 2001 From: Lyndon Date: Fri, 2 Feb 2018 14:43:40 +0100 Subject: [PATCH] =?UTF-8?q?Das=20richtige=20Doku-Feld=20ist=20bei=20mehrer?= =?UTF-8?q?en=20Doku-Feldern=20ausgew=C3=A4hlt,=20nachdem=20neugeladen=20w?= =?UTF-8?q?urde.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bei einem Abbruch vom Ändern eines Zeiterfassungseintrags werden sämtliche Doku-Felder geleert. --- BeWoPlanerMobil/Content/BeWoMobileStyle.css | 4 + BeWoPlanerMobil/Controllers/MainController.cs | 73 +++--- BeWoPlanerMobil/Models/MainModel.cs | 43 +-- BeWoPlanerMobil/Scripts/initialization.js | 31 ++- BeWoPlanerMobil/Scripts/mainView.js | 245 ++++++++---------- BeWoPlanerMobil/Views/Main/Main.cshtml | 92 ++++--- 6 files changed, 237 insertions(+), 251 deletions(-) diff --git a/BeWoPlanerMobil/Content/BeWoMobileStyle.css b/BeWoPlanerMobil/Content/BeWoMobileStyle.css index 88908c14b..b614ba923 100644 --- a/BeWoPlanerMobil/Content/BeWoMobileStyle.css +++ b/BeWoPlanerMobil/Content/BeWoMobileStyle.css @@ -643,6 +643,10 @@ article.infobox section { top:30px; } +article.infobox section textarea:focus { + border-color: #FF5A00; +} + article.infobox section h2 { position: absolute; left: 0; diff --git a/BeWoPlanerMobil/Controllers/MainController.cs b/BeWoPlanerMobil/Controllers/MainController.cs index 4c853181e..e46db196e 100644 --- a/BeWoPlanerMobil/Controllers/MainController.cs +++ b/BeWoPlanerMobil/Controllers/MainController.cs @@ -33,7 +33,7 @@ namespace BeWoPlanerMobil.Controllers return null; } - if (Session[MainModelSessionKey] == null || ((MainModel)Session[MainModelSessionKey]).Employee == null) + if (((MainModel) Session[MainModelSessionKey])?.Employee == null) { _Model = new MainModel { Employee = MobileSessionFacade.LoggedInEmployee }; Session[MainModelSessionKey] = _Model; @@ -72,13 +72,15 @@ namespace BeWoPlanerMobil.Controllers Model.SelectedGoals = null; + Model.ShowDistanceField = "1" == GetSettingValue("ShowDistanceFields"); + Model.Dokutypes = ValueListService.GetAllValueListEntrysByType(ValueListEntryType.DocumentType); if (Model.Dokutypes != null) { Model.Dokutypes = Model.Dokutypes.OrderBy(s => s.ValueListEntryOid).ToArray(); } - if (MainModel.AllEmployees == null) + if(MainModel.AllEmployees == null) { MainModel.AllEmployees = EmployeeService.GetAllActiveEmployeesCompact(); } @@ -89,7 +91,7 @@ namespace BeWoPlanerMobil.Controllers { Model.Customers = CustomerService.GetAllActiveCustomers().OrderBy(k => k.LastName).ToList(); } - else if (MobileSessionFacade.CheckForUserRight(UserRightType.Customer_ViewMyCustomers)) + else if(MobileSessionFacade.CheckForUserRight(UserRightType.Customer_ViewMyCustomers)) { Model.Customers = CustomerService.GetActiveCustomersById(myRelatedCustomers.Select(c => c.Customer.CustomerOid).ToList()).OrderBy(k => k.LastName).ToList(); } @@ -98,11 +100,11 @@ namespace BeWoPlanerMobil.Controllers Model.Customers = new List(); } - if (MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreationForOtherEmployees)) + if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreationForOtherEmployees)) { Model.Employees = EmployeeService.GetAllActiveEmployeesCompact(); } - else if (MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreationForOtherTeamMember) && Model.Employee != null && Model.Employee.EmployeeOid != null) + else if(MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreationForOtherTeamMember) && Model.Employee != null && Model.Employee.EmployeeOid != null) { Model.Employees = EmployeeService.GetAllTeamMember(MobileSessionFacade.LoggedInCompactEmployee); } @@ -111,7 +113,7 @@ namespace BeWoPlanerMobil.Controllers Model.Employees = new List { MobileSessionFacade.LoggedInCompactEmployee }; } - if (Model.ShowOnlyOwnSupportConcepts == false && MobileSessionFacade.CheckForUserRight(UserRightType.SupportConcept_ViewAllSupportConcepts)) + if(Model.ShowOnlyOwnSupportConcepts == false && MobileSessionFacade.CheckForUserRight(UserRightType.SupportConcept_ViewAllSupportConcepts)) { Model.SupportConcepts = CustomerService.GetAllActiveSupportConcepts(); } @@ -190,38 +192,40 @@ namespace BeWoPlanerMobil.Controllers var goalTreeDic = new Dictionary(); - foreach (var ziel in ziele) + foreach(var ziel in ziele) { var treeItem = new GoalTreeItem {Children = new List(), Header = ziel.TypeDescription, ParentOid = ziel.ParentOid, ValueListEntryOid = ziel.ValueListEntryOid}; goalTreeDic.Add(ziel.ValueListEntryOid.Value, treeItem); - if (ziel.ParentOid == null) + if(ziel.ParentOid == null) { goalTree.Add(treeItem); } } - foreach (var zielMitEltern in goalTreeDic.Values.Where(w => w.ParentOid != null)) + foreach(var zielMitEltern in goalTreeDic.Values.Where(w => w.ParentOid != null)) { goalTreeDic[zielMitEltern.ParentOid.Value].Children.Add(zielMitEltern); } - foreach (var ziel in massnahmen) + foreach(var ziel in massnahmen) { var kind = new GoalTreeItem {Children = new List(), Header = ziel.TypeDescription, IsLeaf = true, ValueListEntryOid = ziel.ValueListEntryOid}; - if (ziel.ParentOid != null && goalTreeDic.ContainsKey(ziel.ParentOid.Value)) + if(ziel.ParentOid != null && goalTreeDic.ContainsKey(ziel.ParentOid.Value)) { kind.ParentOid = goalTreeDic[ziel.ParentOid.Value].ParentOid; goalTreeDic[ziel.ParentOid.Value].Children.Add(kind); } } - foreach (var item in goalTreeDic.Values) + foreach(var item in goalTreeDic.Values) { - if (item.Children.Count == 0 && item.ParentOid.HasValue) - item.IsLeaf = true; + if(item.Children.Count == 0 && item.ParentOid.HasValue) + { + item.IsLeaf = true; + } } return goalTree; @@ -229,15 +233,15 @@ namespace BeWoPlanerMobil.Controllers private void LoadMissingParents(long pParentOid) { - while (true) + while(true) { var parentDC = ValueListService.GetValueListEntryByOid(pParentOid); - if (!_ParentGoals.ContainsKey(parentDC.ValueListEntryOid.Value)) + if(!_ParentGoals.ContainsKey(parentDC.ValueListEntryOid.Value)) { _ParentGoals.Add(parentDC.ValueListEntryOid.Value, parentDC); - if (parentDC.ParentOid != null) + if(parentDC.ParentOid != null) { pParentOid = parentDC.ParentOid.Value; continue; @@ -256,7 +260,6 @@ namespace BeWoPlanerMobil.Controllers return SerializeObject(time); } - public string CheckEndDate() { var m = OperationsService.GetMandator(); @@ -291,7 +294,6 @@ namespace BeWoPlanerMobil.Controllers return SerializeObject(zeiterInStdMin); } - public string CheckDokuReiter() { @@ -649,16 +651,25 @@ namespace BeWoPlanerMobil.Controllers { doku1 = collection["Dokumentation6"]; } - - + log.Info($"CreateServiceRecord: datum:{collection["Datum"]}; start:{collection["Start"]}; ende:{collection["Ende"]}; dauer:{collection["Dauer"]}; doku:{doku1}; aktion:{collection["versteckt"]}"); - - + if (string.IsNullOrEmpty(collection["Datum"])) { return View("Main", Model); } + var distanz = collection["Distanz"]; + int? distanceInMeters = null; + + if(!string.IsNullOrEmpty(distanz)) + { + if(int.TryParse(distanz, out var parsedDistance)) + { + distanceInMeters = parsedDistance; + } + } + var submitBtnVal = collection["versteckt"]; var selectedCostbearerSCRelOid = Model.CostBearer2SupportConceptOid < 1 ? null : Model.CostBearer2SupportConceptOid; var datum = Convert.ToDateTime(collection["Datum"]); @@ -723,6 +734,8 @@ namespace BeWoPlanerMobil.Controllers Model.NewServiceRecord.Start = zeitenFeld[0]; Model.NewServiceRecord.End = zeitenFeld[1]; + Model.NewServiceRecord.DistanceInMeter = distanceInMeters; + if (Model.Employee.EmployeeOid != null) { if (!submitBtnVal.Equals("Speichern")) @@ -752,9 +765,7 @@ namespace BeWoPlanerMobil.Controllers if (intervall > 0) { - Model.NewServiceRecord.RoundedDuration = dauer%intervall != 0 - ? dauer + (intervall - (dauer%intervall)) - : dauer; + Model.NewServiceRecord.RoundedDuration = dauer%intervall != 0 ? dauer + (intervall - dauer%intervall) : dauer; } else { @@ -799,15 +810,14 @@ namespace BeWoPlanerMobil.Controllers Model.NewServiceRecord.IP = Request.UserHostAddress; Model.NewServiceRecord.InsertedOn = DateTime.Now; - Model.NewServiceRecord.InsUser = string.Format("{0} {1}", MobileSessionFacade.LoggedInEmployee.FirstName, MobileSessionFacade.LoggedInEmployee.LastName); + Model.NewServiceRecord.InsUser = $"{MobileSessionFacade.LoggedInEmployee.FirstName} {MobileSessionFacade.LoggedInEmployee.LastName}"; Model.NewServiceRecord.IsCreatedInMobileClient = true; - if (submitBtnVal.Equals("Anlegen")) { var oidList = OperationsService.InsertNewServiceRecords(new List { Model.NewServiceRecord }); - Model.SrviceRecoOID = oidList[0]; + Model.ServiceRecordOid = oidList[0]; } else { @@ -820,7 +830,6 @@ namespace BeWoPlanerMobil.Controllers { Model.ServiceRecords = OperationsService.FindServiceRecordsForLastDays(selectedCostbearerSCRelOid, Model.Zeitraum, Model.Employee.EmployeeOid).ToList(); } - } catch (Exception e) { @@ -1197,7 +1206,7 @@ namespace BeWoPlanerMobil.Controllers private void LoadRecordsToModel() { - if (Model.Zeitraum < 0 || (Model.CostBearer2SupportConceptOid.HasValue && Model.CostBearer2SupportConceptOid.Value == -1)) + if(Model.Zeitraum < 0 || Model.CostBearer2SupportConceptOid.HasValue && Model.CostBearer2SupportConceptOid.Value == -1) { Model.ServiceRecords = new List(); return; @@ -1206,7 +1215,7 @@ namespace BeWoPlanerMobil.Controllers var records = OperationsService.FindServiceRecordsForLastDays(Model.CostBearer2SupportConceptOid < 1 ? null : Model.CostBearer2SupportConceptOid, Model.Zeitraum, Model.Employee.EmployeeOid); var recordsOhneDuplikate = new List(); - foreach (var r in records.Where(r => !recordsOhneDuplikate.Any(a => a.GroupOid.HasValue && a.GroupOid.Value.Equals(r.GroupOid)))) + foreach(var r in records.Where(r => !recordsOhneDuplikate.Any(a => a.GroupOid.HasValue && a.GroupOid.Value.Equals(r.GroupOid)))) { recordsOhneDuplikate.Add(r); } diff --git a/BeWoPlanerMobil/Models/MainModel.cs b/BeWoPlanerMobil/Models/MainModel.cs index 537cc8370..725c4d8f6 100644 --- a/BeWoPlanerMobil/Models/MainModel.cs +++ b/BeWoPlanerMobil/Models/MainModel.cs @@ -38,25 +38,25 @@ namespace BeWoPlanerMobil.Models public bool ShowSignature { get; set; } - public long SrviceRecoOID { get; set; } + public long ServiceRecordOid { get; set; } public List SupportConcepts { get; set; } public List ServiceCategories { get; set; } public List Textbausteine { get; set; } - private List serviceRecords; + private List _ServiceRecords; public List ServiceRecords { get { - if(serviceRecords == null) - return serviceRecords = new List(); + if(_ServiceRecords == null) + return _ServiceRecords = new List(); - return serviceRecords.OrderByDescending(sr => sr.Start).ToList(); + return _ServiceRecords.OrderByDescending(sr => sr.Start).ToList(); } - set { serviceRecords = value; } + set { _ServiceRecords = value; } } public List SelectedGoals { get; set; } @@ -91,34 +91,15 @@ namespace BeWoPlanerMobil.Models } } - public static bool IsAllowedToSeeCustomers - { - get - { - return MobileSessionFacade.CheckForUserRight(UserRightType.CustomerView_View) || - MobileSessionFacade.CheckForUserRight(UserRightType.Customer_ViewMyCustomers); - } - } + public static bool IsAllowedToSeeCustomers => MobileSessionFacade.CheckForUserRight(UserRightType.CustomerView_View) || MobileSessionFacade.CheckForUserRight(UserRightType.Customer_ViewMyCustomers); - public static bool IsEmployeeSelectionVisible - { - get - { - return MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreationForOtherEmployees) || - MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreationForOtherTeamMember); - } - } + public static bool IsEmployeeSelectionVisible => MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreationForOtherEmployees) || MobileSessionFacade.CheckForUserRight(UserRightType.ServiceRecord_AllowCreationForOtherTeamMember); - public static bool IsTextbausteineVisible - { - get - { - return MobileSessionFacade.CheckForUserRight(UserRightType.TextbausteineAlleAnsehen) || - MobileSessionFacade.CheckForUserRight(UserRightType.TextbausteineNurEigeneAnsehen); - } - } + public static bool IsTextbausteineVisible => MobileSessionFacade.CheckForUserRight(UserRightType.TextbausteineAlleAnsehen) || MobileSessionFacade.CheckForUserRight(UserRightType.TextbausteineNurEigeneAnsehen); - public MainModel() + public bool ShowDistanceField { get; set; } + + public MainModel() { NewServiceRecord = new ServiceRecordDC(); ShowOnlyOwnSupportConcepts = true; diff --git a/BeWoPlanerMobil/Scripts/initialization.js b/BeWoPlanerMobil/Scripts/initialization.js index bdc709b11..c53b40d98 100644 --- a/BeWoPlanerMobil/Scripts/initialization.js +++ b/BeWoPlanerMobil/Scripts/initialization.js @@ -1,6 +1,8 @@ var isEnddateSet; +var numberOfDocumentationTypes; + $(document).ready(function () { - if (!$("#zeiterfassung").length) { + if(!$("#zeiterfassung").length) { return; } @@ -21,16 +23,14 @@ $(document).ready(function () { initBeWoMobile(loadGoalsUrl); - var h = $("#datum_textbox").css("height"); + const height = $("#datum_textbox").css("height"); - $(".dropdownlist-for").css("height", h); + $(".dropdownlist-for").css("height", height); - $("#statistik-button").css("height", h); - $("#statistik-button").css("width", h); + $("#statistik-button").css("height", height); + $("#statistik-button").css("width", height); - $("#statistik-button-td").css("width", h); - - + $("#statistik-button-td").css("width", height); //if (localStorage.getItem("Zeitdaten") != null || localStorage.getItem("Kalenderdaten") != null) { // console.log("Ich bin hier drinne weil Storage vorhanden"); @@ -39,8 +39,8 @@ $(document).ready(function () { // document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == 0) { // console.log("Ich bin hier beim Laden einer Zeiterfassung "); // LoadOnly(1, 2); - // DeletStorage(1); - // DeletStorage(2); + // deleteLocalStorage(1); + // deleteLocalStorage(2); // } else { // ErrorZeiterfassungAfterCrash(); // console.log(" ich bin hier nach dem Crash ") @@ -49,7 +49,6 @@ $(document).ready(function () { // console.log("Ich bin hier drinne weil Storage nicht vorhanden"); //} - ErfolgteSpx(); vm = new KlientenVM(); @@ -141,7 +140,7 @@ function toggleSelectClassesForElement(elementIdentifier, parentElement) { } function toggleErrorPopup2(errorMessage) { - const isDisplayNone = $("#errorPopupDiv2").css("display") == "none"; + const isDisplayNone = $("#errorPopupDiv2").css("display") === "none"; const displayValue = isDisplayNone ? "block" : "none"; $("#errorPopupDiv2").css("display", displayValue); @@ -230,7 +229,7 @@ function initializeDocumentationTextareas() { url: CheckDokuReiterUrl, success: function (json) { const documentationTypes = $.parseJSON(json); - const numberOfDocumentationTypes = documentationTypes.length; + numberOfDocumentationTypes = documentationTypes.length; if(numberOfDocumentationTypes === 0) { $("#tddokureiter").css("display", "none"); @@ -246,7 +245,7 @@ function initializeDocumentationTextareas() { $("#trnormalDokuLabel").text(documentationTypes[0].TypeDescription); } - if (numberOfDocumentationTypes > 2) { + if (numberOfDocumentationTypes > 1) { for(let i = 0; i < numberOfDocumentationTypes; i++) { const idNumber = i + 1; @@ -255,8 +254,8 @@ function initializeDocumentationTextareas() { } } - if (numberOfDocumentationTypes > 0) { - $("#DokName1").click(); + if(numberOfDocumentationTypes > 0) { + focusOnTab(1); } } }); diff --git a/BeWoPlanerMobil/Scripts/mainView.js b/BeWoPlanerMobil/Scripts/mainView.js index 7b7c0dd25..44f000a37 100644 --- a/BeWoPlanerMobil/Scripts/mainView.js +++ b/BeWoPlanerMobil/Scripts/mainView.js @@ -7,10 +7,8 @@ var yinner = $("#GeoLocSaveYCOOR"); var KalenderDatakonstrukt = []; var ZeiterfassungDatakonstrukt = []; var KlientDatakonstrukt = []; - -var Kalenderzwischenspeicher = []; - -var Klientzwischenspeicher = []; +var kalenderzwischenspeicher = []; +var klientzwischenspeicher = []; var SetTimeoutTime = 10000; @@ -133,7 +131,7 @@ function calcDurationByStartEnd() { $("#duration_textbox").val(dur).trigger("change"); } else { - aktualDurationwithEndDate(); + actualDurationWithEndDate(); } } @@ -152,7 +150,7 @@ function calcEndByStartDuration() { $("#ende_textbox").val(ende).trigger("change"); } else { - aktualDurationwithEndDate(); + actualDurationWithEndDate(); } } @@ -482,7 +480,11 @@ function resetRecordForm() { $("#kategorien_select").val($("#kategorien_select option").eq(0).val()); - var selectedCategory = $("#kategorien_select").find(":selected").val(); + for(let i = 0; i < numberOfDocumentationTypes; i++) { + $(`#notiz_textbox${(i + 1)}`).val(""); + } + + const selectedCategory = $("#kategorien_select").find(":selected").val(); $.ajax({ type: "GET", @@ -630,32 +632,32 @@ function validateServiceRecordBeforeSubmit() { } } - var dateStr = $("#datum_textbox").val(); - var startStr = $("#start_textbox").val(); - var endStr = $("#ende_textbox").val(); + const dateStr = $("#datum_textbox").val(); + const startStr = $("#start_textbox").val(); + const endStr = $("#ende_textbox").val(); - var x = getDateObj(true); + const x = getDateObj(true); var y; - if ($("#enddatum_textbox").val() != "") + if ($("#enddatum_textbox").val() !== "") { y = getEndDateObj(); - else + } else { y = getDateObj(false); - + } var vonDatum = getDateTimeStringWithLeadingZeros(x); - var bisDatum = getDateTimeStringWithLeadingZeros(y); + const bisDatum = getDateTimeStringWithLeadingZeros(y); var isValidRecord = true; makeAjaxCall("POST", checkRightsUrl, function(json) { - if (json == "SessionTimeout") { + if (json === "SessionTimeout") { window.location.href = redirectLink; return; } - if (json == "StartGreaterEnd") { + if (json === "StartGreaterEnd") { hideSanduhr(); writeFatalErrorMessage("Die Startzeit darf nicht größer als die Endzeit sein!"); return; @@ -669,20 +671,21 @@ function validateServiceRecordBeforeSubmit() { var bookAfterSettlementInvoice = false; $.each(meldungen.Rights, function(position) { - var value = meldungen.Rights[position]; - var key = parseInt(position); + const value = meldungen.Rights[position]; + const key = parseInt(position); + switch (key) { - case 0: - allowOverlappingFLS = value; - break; - case 1: - allowMoreFLSThanApproved = value; - break; - case 2: - bookAfterSettlementInvoice = value; - break; - default: - break; + case 0: + allowOverlappingFLS = value; + break; + case 1: + allowMoreFLSThanApproved = value; + break; + case 2: + bookAfterSettlementInvoice = value; + break; + default: + break; } }); @@ -692,9 +695,9 @@ function validateServiceRecordBeforeSubmit() { break; switch (results[i].ResultType) { case 0: - 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?"); + 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 { @@ -704,9 +707,9 @@ function validateServiceRecordBeforeSubmit() { } break; case 1: - var msg2 = "An dem gewählten Datum " + vonDatum + " existiert bereits ein Eintrag für den ausgewählten Mitarbeiter(" + results[i].EmployeeName + "). Speichern nicht möglich."; - if (allowOverlappingFLS == true) { - var r2 = confirm("An dem gewählten Datum " + vonDatum + " existiert bereits ein Eintrag für den ausgewählten Mitarbeiter(" + results[i].EmployeeName + "). Möchten Sie trotzdem speichern?"); + var msg2 = `An dem gewählten Datum ${vonDatum} existiert bereits ein Eintrag für den ausgewählten Mitarbeiter(${results[i].EmployeeName}). Speichern nicht möglich.`; + if (allowOverlappingFLS === true) { + var r2 = confirm(`An dem gewählten Datum ${vonDatum} existiert bereits ein Eintrag für den ausgewählten Mitarbeiter(${results[i].EmployeeName}). Möchten Sie trotzdem speichern?`); isValidRecord = r2; exitLoop = !isValidRecord; } else { @@ -716,14 +719,14 @@ function validateServiceRecordBeforeSubmit() { } break; case 2: - writeFatalErrorMessage("Das gewählte Datum " + vonDatum.slice(0, 10) + " liegt außerhalb des Zeitraumes des gewählten Hilfeplans. Speichern nicht möglich."); + writeFatalErrorMessage(`Das gewählte Datum ${vonDatum.slice(0, 10)} liegt außerhalb des Zeitraumes des gewählten Hilfeplans. Speichern nicht möglich.`); isValidRecord = false; exitLoop = true; break; case 3: - var msg3 = "Die für diesen Hilfeplan genehmigten FLS (" + results[i].ApprovedHours + ") werden mit diesem Eintrag überschritten. (" + results[i].HoursNew + ")."; - if (allowMoreFLSThanApproved == true) { + var msg3 = `Die für diesen Hilfeplan 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; @@ -734,7 +737,7 @@ function validateServiceRecordBeforeSubmit() { } break; case 4: - writeFatalErrorMessage("Sie können keine neuen Leistungen für den " + vonDatum + " dokumentieren, da bereits der " + meldungen.MaxDaysEditServiceRecordsAllowed + ". des nachfolgenden Monats überschritten ist."); + writeFatalErrorMessage(`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; @@ -745,7 +748,7 @@ function validateServiceRecordBeforeSubmit() { break; case 6: var msg6 = "Es existiert bereits eine Spitzabrechnung. Um diesen Eintrag zu berücksichtigen, muss eventuell eine neue Spitzabrechnung erstellt werden. Das Speichern ist nicht möglich."; - if (bookAfterSettlementInvoice == true) { + if (bookAfterSettlementInvoice === true) { msg6 = "Sie können den Eintrag nicht bearbeiten, da bereits eine Spitzabrechnung für diesen Hilfeplan erstellt wurde. Speichern nicht möglich."; } writeFatalErrorMessage(msg6); @@ -777,7 +780,7 @@ function validateServiceRecordBeforeSubmit() { hideSanduhr(); } }, - { von: vonDatum, bis: bisDatum, inEditMode: $("#anlegenEditierenBtn").val() == "Speichern", dateString: dateStr, startString: startStr, endString: endStr }); + { von: vonDatum, bis: bisDatum, inEditMode: $("#anlegenEditierenBtn").val() === "Speichern", dateString: dateStr, startString: startStr, endString: endStr }); } function ErfolgteSpx() { @@ -1329,14 +1332,14 @@ function updateAppointmentOnClick() { function insertAppointmentOnClick() { if (checkAppointmentFields()) { - Kalenderzwischenspeicher[0] = $("#StartDate").val(); - Kalenderzwischenspeicher[5] = $("#EndDate").val(); - Kalenderzwischenspeicher[1] = $("#TerminStartZeit").val(); - Kalenderzwischenspeicher[2] = $("#TerminEndZeit").val(); - Kalenderzwischenspeicher[3] = $("#TerminBetreff").val(); - Kalenderzwischenspeicher[4] = $("#TerminNotiz").val(); + kalenderzwischenspeicher[0] = $("#StartDate").val(); + kalenderzwischenspeicher[5] = $("#EndDate").val(); + kalenderzwischenspeicher[1] = $("#TerminStartZeit").val(); + kalenderzwischenspeicher[2] = $("#TerminEndZeit").val(); + kalenderzwischenspeicher[3] = $("#TerminBetreff").val(); + kalenderzwischenspeicher[4] = $("#TerminNotiz").val(); - insertNewAppointment(Kalenderzwischenspeicher[0], Kalenderzwischenspeicher[1], Kalenderzwischenspeicher[2], Kalenderzwischenspeicher[3], Kalenderzwischenspeicher[4], Kalenderzwischenspeicher[5]); + insertNewAppointment(kalenderzwischenspeicher[0], kalenderzwischenspeicher[1], kalenderzwischenspeicher[2], kalenderzwischenspeicher[3], kalenderzwischenspeicher[4], kalenderzwischenspeicher[5]); } } @@ -1960,7 +1963,7 @@ function toggleErrorPopup(errorMessage, i , zeit) { $("#errorPopupTitle").text("Fehler"); $("#errorPopupOkBtn").onclick = "toggleErrorPopup('')"; - DeletStorage(1); + deleteLocalStorage(1); //SaveOnly(); // Speichere Daten bei absturz } else { @@ -2109,7 +2112,7 @@ function mitarbeiterLaden() { function SaveOnly() { if (navigator.onLine == true) { if(typeof (Storage) != "undefined") { - DeletStorage(1); + deleteLocalStorage(1); var zahl = $("#scDropDown").val(); var hilfeplan = $("#scDropDown option[value='" + zahl + "']").text(); @@ -2151,7 +2154,7 @@ function SaveOnly() { } } else { if (typeof (Storage) != "undefined") { - DeletStorage(1); + deleteLocalStorage(1); var zahl = $("#scDropDown").val(); var hilfeplan = $("#scDropDown option[value='" + zahl + "']").text(); @@ -2193,7 +2196,7 @@ function SaveOnly() { } } -function DeletStorage(i) { +function deleteLocalStorage(i) { if(i === 1) { localStorage.removeItem("Zeitdaten"); } @@ -2205,15 +2208,11 @@ function DeletStorage(i) { function saveOnlyKalender() { if (navigator.onLine) { - DeletStorage(2); + deleteLocalStorage(2); - var TerminDatum = Kalenderzwischenspeicher[0]; - var TerminStratZeit = Kalenderzwischenspeicher[1]; - var TerminEndZeit = Kalenderzwischenspeicher[2]; - var TerminBetreff = Kalenderzwischenspeicher[3]; - var TerminNotiz = Kalenderzwischenspeicher[4]; + const [terminDatum, terminStratZeit, terminEndZeit, terminBetreff, terminNotiz] = kalenderzwischenspeicher; - KalenderDatakonstrukt.push(TerminDatum, TerminStratZeit, TerminEndZeit, TerminBetreff, TerminNotiz); + KalenderDatakonstrukt.push(terminDatum, terminStratZeit, terminEndZeit, terminBetreff, terminNotiz); localStorage.setItem("Kalenderdaten", KalenderDatakonstrukt); location.reload(); @@ -2258,7 +2257,7 @@ function saveZeiterfassungAfterCrash(datum,startd,endd,dauer,doku,leistung, oid, }); } else { - DeletStorage(1); + deleteLocalStorage(1); setTimeout(function () { $("#scDropDown option[value='" + oid + "']").attr('selected', true).trigger("change"); @@ -2266,7 +2265,7 @@ function saveZeiterfassungAfterCrash(datum,startd,endd,dauer,doku,leistung, oid, } }, error: function () { - DeletStorage(1); + deleteLocalStorage(1); writeFatalErrorMessage("Es konnte keine Verbindung zum Server aufgebaut werden. Bitte überprüfen Sie Ihre Internetverbindung."); // $("#scDropDown option[value='" + oid + "']").attr('selected', true).trigger("change"); } @@ -2275,37 +2274,37 @@ function saveZeiterfassungAfterCrash(datum,startd,endd,dauer,doku,leistung, oid, } function LoadOnly(i, x) { - var zeitdata = localStorage.getItem("Zeitdaten"); - var kalenderdata = localStorage.getItem("Kalenderdaten"); + const zeitdata = localStorage.getItem("Zeitdaten"); + const kalenderdata = localStorage.getItem("Kalenderdaten"); if (zeitdata != null || kalenderdata != null) { - if (zeitdata && i == 1) { + if (zeitdata && i === 1) { var zeit = zeitdata.split(","); - if (zeit[6] == "" && zeit[7] == "" && zeit[8] == "" && zeit[9] == "" && zeit[10] == "" && zeit[5] == "") { + if (zeit[6] === "" && zeit[7] === "" && zeit[8] === "" && zeit[9] === "" && zeit[10] === "" && zeit[5] === "") { // es wurden keine daten gefunden } else { writeFatalErrorMessage("Es ist ein nicht gespeicherter Eintrag vorhanden. Dieser wird nun an den Server gesendet."); setTimeout(function(){ saveZeiterfassungAfterCrash(zeit[6], zeit[7], zeit[8], zeit[8], zeit[10], zeit[5], zeit[11], zeit[12], zeit[13], zeit[14], zeit[15], zeit[16]); - DeletStorage(1); + deleteLocalStorage(1); showServiceRecords(); }, SetTimeoutTime); } } - if (kalenderdata && x == 2) { + if(kalenderdata && x === 2) { var kalezeit = kalenderdata.split(","); - if (kalezeit[0] == "" && kalezeit[1] == "" && kalezeit[2] == "" && kalezeit[3] == "" && kalezeit[4] == "") { + if (kalezeit[0] === "" && kalezeit[1] === "" && kalezeit[2] === "" && kalezeit[3] === "" && kalezeit[4] === "") { // es wurden keine daten gefunden } else { - writeFatalErrorMessage("Es ist ein nicht gespeicherter Kalender Eintrag vorhanden. Dieser wird nun an den Server gesendet.", 1); + writeFatalErrorMessage("Es ist ein nicht gespeicherter Kalendereintrag vorhanden. Dieser wird nun an den Server gesendet.", 1); setTimeout(function(){ insertNewAppointmentfterCrash(kalezeit[0], kalezeit[1], kalezeit[2], kalezeit[3], kalezeit[4]); - DeletStorage(2); + deleteLocalStorage(2); showServiceRecords(); }, SetTimeoutTime); } @@ -2322,7 +2321,7 @@ function ErrorZeiterfassungAfterCrash() { } else if (document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == 2) { writeFatalErrorMessage("Es konnte keine Verbindung zum Server aufgebaut werden. Bitte überprüfen sie ihre Internet Verbindung."); document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value = 1; - DeletStorage(1); + deleteLocalStorage(1); setTimeout(function(){ $.ajax({ type: "GET", @@ -2333,7 +2332,7 @@ function ErrorZeiterfassungAfterCrash() { } else if (document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == 3) { writeFatalErrorMessage("Es konnte keine Verbindung zum Server aufgebaut werden. Bitte überprüfen Sie Ihre Internet Verbindung."); document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value = 1; - DeletStorage(1); + deleteLocalStorage(1); setTimeout(function(){ $.ajax({ type: "GET", @@ -2344,7 +2343,7 @@ function ErrorZeiterfassungAfterCrash() { } else if (document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == 4) { writeFatalErrorMessage("Das Datum liegt außerhalb des Zeitraumes des gewählten Hilfeplans. Der Eintrag kann nicht gespeichert werden."); document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value = 1; - DeletStorage(1); + deleteLocalStorage(1); setTimeout(function(){ $.ajax({ type: "GET", @@ -2355,7 +2354,7 @@ function ErrorZeiterfassungAfterCrash() { } else if (document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == 5) { writeFatalErrorMessage("Die eingegebene Uhrzeit ist ungültig. Der Eintrag kann nicht gespeichert werden."); document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value = 1; - DeletStorage(1); + deleteLocalStorage(1); setTimeout(function(){ $.ajax({ type: "GET", @@ -2366,90 +2365,70 @@ function ErrorZeiterfassungAfterCrash() { } } -function aktualDurationwithEndDate() { - if ($("#enddatum_textbox").val() != "") { - if ($("#enddatum_textbox").val() != $("#datum_textbox").val()) { - var a = getEndDateObj().getDate(); +function actualDurationWithEndDate() { + if ($("#enddatum_textbox").val() !== "") { + if ($("#enddatum_textbox").val() !== $("#datum_textbox").val()) { + const endDate = getEndDateObj().getDate(); - var sum = a - getDateObj().getDate(); + const dateDifference = endDate - getDateObj().getDate(); - var et = $("#ende_textbox").val(); + const endDateString = $("#ende_textbox").val(); - var st = $("#start_textbox").val(); + const startDateString = $("#start_textbox").val(); - var duri = et - st; + let duration = endDateString - startDateString; - var rest = duri % 100; + const rest = duration % 100; - duri = duri - rest; + duration = duration - rest; - duri = duri / 100 * 60; + duration = duration / 100 * 60; - var enddur = sum * 24 * 60 + duri + rest; + duration = dateDifference * 24 * 60 + duration + rest; - $("#duration_textbox").val(enddur).trigger("change"); + $("#duration_textbox").val(duration).trigger("change"); } } } function getEndDateObj() { - var roh = $("#enddatum_textbox").val(); + const roh = $("#enddatum_textbox").val(); - var dd = parseInt(roh.slice(0, 2)); - var mm = parseInt(roh.slice(3, 5)); - var yyyy = parseInt(roh.slice(6, 10)); - var hm = [0, 0]; + const day = parseInt(roh.slice(0, 2)); + const month = parseInt(roh.slice(3, 5)); + const year = parseInt(roh.slice(6, 10)); + var hoursAndMinutes = [0, 0]; var date = new Date(); - if (!isNaN(dd) && !isNaN(mm) && !isNaN(yyyy)) { - date = new Date(yyyy, mm - 1, dd); + if (!isNaN(day) && !isNaN(month) && !isNaN(year)) { + date = new Date(year, month - 1, day); } - var ds = $("#ende_textbox").val(); + const endDateString = $("#ende_textbox").val(); - if (ds != "") { - hm = stringToTime(ds); + if (endDateString !== "") { + hoursAndMinutes = stringToTime(endDateString); } - date.setHours(hm[0]); - date.setMinutes(hm[1]); + date.setHours(hoursAndMinutes[0]); + date.setMinutes(hoursAndMinutes[1]); return date; } -function focusOnTab(x) { - if (x === 1) { - setTimeout(function () { - $("#notiz_textbox1").focus(); - focusedDokuTextarea = $("#notiz_textbox1"); - }, 100); - } +function focusOnTab(tabIdentifier) { + setTimeout(function() { + var displayValue; - if (x === 2) { - setTimeout(function () { - $("#notiz_textbox2").focus(); - focusedDokuTextarea = $("#notiz_textbox2"); - }, 100); - } + for(let i = 0; i < window.numberOfDocumentationTypes; i++) { + const idNumber = i + 1; + displayValue = idNumber === tabIdentifier ? "block" : "none"; - if (x === 3) { - setTimeout(function () { - $("#notiz_textbox3").focus(); - focusedDokuTextarea = $("#notiz_textbox3"); - }, 100); - } + $(`#notiz_textbox${idNumber}`).css("display", displayValue); + } - if (x === 4) { - setTimeout(function () { - $("#notiz_textbox4").focus(); - focusedDokuTextarea = $("#notiz_textbox4"); - }, 100); - } - - if (x === 5) { - setTimeout(function () { - $("#notiz_textbox5").focus(); - focusedDokuTextarea = $("#notiz_textbox5"); - }, 100); - } -} + $(`#notiz_textbox${tabIdentifier}`).get(0).focus(); + window.focusedDokuTextarea = $(`#notiz_textbox${tabIdentifier}`); + + }, 100); +} \ No newline at end of file diff --git a/BeWoPlanerMobil/Views/Main/Main.cshtml b/BeWoPlanerMobil/Views/Main/Main.cshtml index 3d48ada9a..ae37ce1e2 100644 --- a/BeWoPlanerMobil/Views/Main/Main.cshtml +++ b/BeWoPlanerMobil/Views/Main/Main.cshtml @@ -3,7 +3,6 @@ @model MainModel @{ ViewBag.Title = "Main"; - }
@@ -13,8 +12,7 @@