var breitenGrad, langenGrad, date; var dataURL = ""; var blob, newday, longrider; var ZeiterfassungDatakonstrukt = []; var KlientDatakonstrukt = []; var klientzwischenspeicher = []; var timeOut = 10000; function buildCollapsibleSet(jsonString) { try { if(jsonString.length < 2) { return; } var kollektion = $.parseJSON(jsonString); actuallyBuildCollapsibleSet(kollektion, null); } catch(exception) { console.log("Fehler(BuildCollapsibleSet): " + exception.message); } } function actuallyBuildCollapsibleSet(kollektion, selectedGoalOids) { $("#kollabierbar1").empty(); collapsibleHtml = ""; $.each(kollektion, function (index) { buildGoalTreeItem(kollektion[index], selectedGoalOids); }); $("#kollabierbar1").append(collapsibleHtml); } var level = 0; var collapsibleHtml; zeitRegEx = /^(2[0-3]|[01]?[0-9])(:|,|\.|#|;)?([0-5][0-9])$/; function buildGoalTreeItem(goalItem, selectedGoalOids) { var goalOid = goalItem.ValueListEntryOid; var goalHeader = goalItem.Header; var isChecked = selectedGoalOids !== null && isElementInArray(selectedGoalOids, goalOid) ? "checked" : ""; if (!goalItem.IsLeaf) { //collapsibleHtml += ''; collapsibleHtml += '
' + goalHeader + '
'; //collapsibleHtml += ''; collapsibleHtml += '"; } else { collapsibleHtml += '
' + goalHeader + '
'; } } function loadGoalsOnSuccess(json) { if (json === "SessionTimeout") { window.location.href = redirectLink; return; } buildCollapsibleSet(json); } function loadServiceDescriptionsOnSuccess(json) { if (json === "SessionTimeout") { window.location.href = redirectLink; return; } var liste = $.parseJSON(json); $("#leistungen_select").empty(); $("#leistungen_select").val(""); $.each(liste, function(index, leistung) { $("#leistungen_select").append(''); }); if(liste[0] !== undefined) { if(isInEditingMode() === false) { $("#leistungen_select").val(liste[0].ServiceDescriptionOid); makeAjaxCall("GET", setServiceDescriptionUrl, null, { pServiceDescriptionOid: liste[0].ServiceDescriptionOid }, null); } else { makeAjaxCall("GET", loadCategoryAndDescriptionUrl, function(result) { var arr = result.split("/"); var descriptionOid = arr[0]; var categoryOid = arr[1]; $("#kategorien_select").val(categoryOid); $("#leistungen_select").val(descriptionOid); $("#leistungen_select").trigger("change"); }, {}, null); } } } function showAjaxError(jqXHR, textStatus, errorThrown) { hideSanduhr(); //if (jqXHR.status == 0) { //toggleErrorPopup("Es besteht zurzeit keine Internetverbindung." + // " Die Daten werden zwischengespeichert und beim nächsten Login an den Server gesendet. " + errorThrown,2); //setTimeout(function () { //showServiceRecords(); //}, timeOut); //} //else if(jqXHR.status === 0) { console.log("status is 0; ajax call aborted.\nError thrown: " + errorThrown + ";\nText status: " + textStatus); return; } toggleErrorPopup(jqXHR.status + " " + errorThrown); } function showErrorMsg(message) { toggleErrorPopup(message); } function resizeLabelColumns() { $("#tabLbl").css("width", $("#zieleLbl").css("width")); } function loadGoals(actionPath) { var selectedServiceRecord = $($("#scDropDown")).find(":selected").val(); if (selectedServiceRecord === -1) { return; } makeAjaxCall("GET", actionPath, loadGoalsOnSuccess, { pCostbearer2SupportConceptOid: selectedServiceRecord }, null); } function toggleMenu() { var menuDiv = $("#menu-div"); $(menuDiv).fadeToggle("fast"); } function loadServiceDescriptions() { var selectedCategory = $("#kategorien_select").find(":selected").val(); if (selectedCategory === null || selectedCategory === undefined) { console.log("Es wurde keine Leistungskategorie ausgewählt: " + selectedCategory); return; } makeAjaxCall("GET", loadServiceCategoriesUrl, loadServiceDescriptionsOnSuccess, { pServiceCategoryOid: selectedCategory }, null); loadTextbausteineForServiceCategory(selectedCategory); } function updateGoals(cbId) { makeAjaxCall("GET", updateGoalsUrl, null, { pGoalOid: cbId }, null); } var goalOidArray = new Array(); function updateChildGoals(goalOid) { goalOidArray = new Array(); var parent = document.getElementById("goal" + goalOid); alert("start"); CheckChildGoalNodes(parent); //makeAjaxCall("GET", updateGoalsUrl, null, { pGoalOid: cbId }, null); } function CheckChildGoalNodes(parent) { goalOidArray = new Array(); var next = parent.parentNode; alert(next); alert(next.nextSibling); var nodeList = next.childNodes; alert(nodeList.length); for (var i = 0; i < nodeList.length; i++) { var node = nodeList[i]; alert(node.nodeName); CheckChildGoalNodes(node); } //makeAjaxCall("GET", updateGoalsUrl, null, { pGoalOid: cbId }, null); } function setServiceDescription() { var sdOid = $("#leistungen_select").find(":selected").val(); makeAjaxCall("GET", setServiceDescriptionUrl, function(kek) { }, { pServiceDescriptionOid: sdOid }, function(kek) { }); } function selectServiceRecord(oid) { $("#versteckt").val("Speichern"); $("html, body").animate({ scrollTop: 0 }, "fast"); $.ajax({ type: "GET", url: setSelectedServiceRecordUrl, data: { recordOid: oid }, success: function () { $.ajax({ type: "GET", url: getSelectedRecordInformationUrl, success: function (jsonServiceRecord) { try { if(jsonServiceRecord === "SessionTimeout") { window.location.href = redirectLink; return; } var record = $.parseJSON(jsonServiceRecord); var goals = record.Goals; var idArray = new Array(); var meinGoalsArray = new Array(); var j = 0; for(var i = 0; i < goals.length; i++) { if(goals[i].ValueListEntryOid !== undefined) { idArray[j] = goals[i].ValueListEntryOid; j++; } } $.ajax({ type: "GET", url: loadGoalsUrl, data: { pCostbearer2SupportConceptOid: $($("#scDropDown")).find(":selected").val() }, success: function (goalsJson) { if (goalsJson === "SessionTimeout") { window.location.href = redirectLink; return; } try { meinGoalsArray = goalsJson !== "" ? $.parseJSON(goalsJson) : ""; } catch (exception) { console.log("Fehler beim JSON Parsing von selectServiceRecord(" + oid + "): " + exception.message); } var rawStartDateStr = record.Start[18] === "1" ? "" : record.Start.slice(11, 16); var rawEndDateStr = record.End[18] === "1" ? "" : record.End.slice(11, 16); var startDateYearStr = record.Start.slice(0, 4); var startDateMonthStr = record.Start.slice(5, 7); var startDateDayStr = record.Start.slice(8, 10); var dateStr = startDateDayStr + "." + startDateMonthStr + "." + startDateYearStr; var endDateYearStr = record.End.slice(0, 4); var endDateMonthStr = record.End.slice(5, 7); var endDateDayStr = record.End.slice(8, 10); var endDateDateStr = endDateDayStr + "." + endDateMonthStr + "." + endDateYearStr; $("#start_textbox").val(rawStartDateStr); $("#ende_textbox").val(rawEndDateStr); $("#datum_textbox").val(dateStr); $("#notiz_textbox").val(record.Notice); $("#enddatum_textbox").val(endDateDateStr); $("#notiz_textbox1").val(record.Notice); $("#notiz_textbox2").val(record.Notice2); $("#notiz_textbox3").val(record.Notice3); $("#notiz_textbox4").val(record.Notice4); $("#notiz_textbox5").val(record.Notice5); $("#duration_textbox").val(record.RoundedDuration); $("#distance_textbox").val(record.DistanceInMeter); $("#employeesDropDown").val(record.Employee.EmployeeOid); window.serviceRecordEmployeeOid = record.Employee.EmployeeOid; actuallyBuildCollapsibleSet(meinGoalsArray, idArray); $("#anlegenEditierenBtn").val("Speichern"); $.ajax({ type: "GET", url: loadServiceCategoriesUrl, success: function (result) { if (result === "SessionTimeout") { window.location.href = redirectLink; return; } $("#kategorien_select").val(record.ServiceDescription.Category.ServiceCategoryOid); var liste = $.parseJSON(result); $("#leistungen_select").empty(); $("#leistungen_select").val(""); $.each(liste, function (index, leistung) { $("#leistungen_select").append(''); }); $("#leistungen_select").val(record.ServiceDescription.ServiceDescriptionOid); makeAjaxCall("GET", setServiceDescriptionUrl, null, { pServiceDescriptionOid: record.ServiceDescription.ServiceDescriptionOid }, null); toggleLabel("distance_textbox"); toggleLabel("duration_textbox"); toggleLabel("start_textbox"); toggleLabel("ende_textbox"); $("input").prop("disabled", false); $("#abbrechenBtn").prop("disabled", true); $("select").prop("disabled", false); toggleSelectClassesForElement("#kategorien_select", "#kategorien-select-container"); toggleSelectClassesForElement("#leistungen_select", "#leistungen-select-container"); toggleSelectClassesForElement("#recordLoader_select", "#record-loader-select-container"); toggleSelectClassesForElement("#textbausteine_select", "#textbausteine-select-container"); $("#abbrechenBtn").prop("disabled", false); if (isInGroupBookingMode()) { $("#changeBookingModeCheckBox").prop("checked", false); console.log("Gruppenbuchungsmodus abgewählt"); makeAjaxCall("GET", window.resetGroupBookingModeViaGETUrl, function (result) { $("#changeBookingModeCheckBox").prop("checked", false); $("#leftContent input[type=checkbox]").prop("checked", false); $("#rightContent input[type=checkbox]").prop("checked", false); $("#employeeCollapsible input[type=checkbox]").prop("checked", false); $("#selectSCForm").show(); if (result.toLowerCase() === "true") { $("#singleSCEmployeeSelectionContainer").show(); } $("#groupBookingOpenPopupBtn").hide(); $("#groupBookingOpenEmployeeSelectionPopupBtn").hide(); }, null, null); } hideSanduhr(); }, error: showErrorMsg, data: { pServiceCategoryOid: record.ServiceDescription.Category.ServiceCategoryOid } }); }, error: showAjaxError, complete: hideSanduhr }); } catch (exception1) { console.log('Fehler beim JSON Parsing von selectServiceRecord(' + oid + '): ' + exception1.message); } }, error: showAjaxError }); } }); } function activateForm(actionPath) { $("input").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"); toggleSelectClassesForElement("#leistungen_select", "#leistungen-select-container"); toggleSelectClassesForElement("#recordLoader_select", "#record-loader-select-container"); toggleSelectClassesForElement("#textbausteine_select", "#textbausteine-select-container"); loadGoals(actionPath); $("#kategorien_select").val($("#kategorien_select option").eq(0).val()); loadServiceDescriptions(); } function resetRecordForm() { showSanduhr(); $("#versteckt").val("Anlegen"); $("#anlegenEditierenBtn").val("Anlegen"); clearZED(); if (isInGroupBookingMode()) { $("#changeBookingModeCheckBox").prop("checked", false); showSanduhr(); $("#groupBookingForm").submit(); } $("#start_textbox").val("").trigger("change"); $("#ende_textbox").val("").trigger("change"); $("#notiz_textbox").val("").trigger("change"); $("#duration_textbox").val("").trigger("change"); $("#distance_textbox").val("").trigger("change"); $("#datum_textbox").val(getDateStringWithLeadingZeros(new Date())); $("#enddatum_textbox").val(getDateStringWithLeadingZeros(new Date())); $("#kategorien_select").val($("#kategorien_select option").eq(0).val()); for(var i = 0; i < numberOfDocumentationTypes; i++) { $("#notiz_textbox" + (i + 1)).val(""); } var selectedCategory = $("#kategorien_select").find(":selected").val(); if(isInEditingMode()) { makeAjaxCall("POST", window.resetEditingModeUrl, function(response) { window.location.reload(); }, { pFormCollection: null }, null); } $.ajax({ type: "GET", url: loadServiceCategoriesUrl, data: { pServiceCategoryOid: selectedCategory }, success: function (json) { loadServiceDescriptionsOnSuccess(json); $.ajax({ type: "GET", url: setSelectedServiceRecordUrl, data: { recordOid: null }, success: function () { loadGoals(loadGoalsUrl); hideSanduhr(); }, error: showAjaxError }); } }); } function toggleOnclick(element) { var collapsedDiv = $(element).next("div"); var isHidden = "none" === $(collapsedDiv).css("display"); var newIcon = "url('"; newIcon += isHidden ? toggleIconUContentUrl : toggleIconDContentUrl; newIcon += "')"; $(element).css("background-image", newIcon); $(collapsedDiv).fadeToggle("fast"); } $(document).mouseup(function(e) { var menu = $("#menu-div"); var menuBtn = $("#menu-btn"); if(!menu.is(e.target) && !menuBtn.is(e.target) && menu.has(e.target).length === 0) { menu.fadeOut("fast"); } }); function saveCreateServicerecod() { showSanduhr(); //if (validateTimeField("#start_textbox") && validateTimeField("#ende_textbox")) { validateServiceRecordBeforeSubmit(); //} else { // hideSanduhr(); // } } function validateTimeField(id) { var timeStr = $(id).val(); var zeitStr = id === "#start_textbox" ? "Start" : "End"; if (timeStr !== "" && !zeitRegEx.test(timeStr)) { showZeiterfassungsError("Bitte geben Sie eine " + zeitStr + "-Zeit in einem gültigen Format (HH:MM oder HHMM) an."); return false; } else { clearZED(); return true; } } function togglePopup(serviceRecordOid) { $("#oidHolder").val(serviceRecordOid); var isShowing = $(".modalWrapper").css("display") === "none"; var displayValue = $(".modalWrapper").css("display") === "block" ? "none" : "block"; toggleModalWrapper(); $("#popupDiv").css("display", displayValue); if (isShowing) { var titleOuterHeight = $("#popupTitle").outerHeight(); var textOuterHeight = $("#popupText").outerHeight(); var buttonDivOuterHeight = $("#popupBtnDiv").outerHeight(); var btnOuterHeight = $(".popupBtn").outerHeight(); var newHeight = titleOuterHeight + textOuterHeight + buttonDivOuterHeight + btnOuterHeight + btnOuterHeight; $("#popupDiv").css("height", newHeight + "px"); $("#popupDiv").css("top", window.pageYOffset + window.innerHeight / 2 - newHeight / 2); $("#popupDiv").css("margin-top", "0"); } else { $("#popupDiv").css("margin-top", "auto"); } } function toggleModalWrapper() { var displayValue = $(".modalWrapper").css("display") === "block" ? "none" : "block"; $(".modalWrapper").css("display", displayValue); $(".modalWrapper").css("height", $(document).height()); } function ErfolgteSpx() { if (document.getElementById("SaveSignature").value === "True") { toggleSuccessPopup("Eintrag wurde gespeichert." + "\n" + "Möchte Sie diesen unterschreiben lassen?", 4); document.getElementById("SaveSignature").value = "False"; $.ajax({ type: "GET", url: SetSaveSignatureUrl, data: { save: false } }); } } function initSignatureInfo(serviceRecordOid){ $.ajax({ type: "GET", url: getSelectedRecordInformationUrlWithOid, data: {oid: serviceRecordOid}, success: function(jsonServiceRecord) { try { if(jsonServiceRecord === "SessionTimeout") { window.location.href = redirectLink; return; } var record = $.parseJSON(jsonServiceRecord); var startDate = record.Start[18] === "1" ? "" : record.Start.slice(11, 16); var endDate = record.End[18] === "1" ? "" : record.End.slice(11, 16); var jahr = record.Start.slice(0, 4); var monat = record.Start.slice(5, 7); var tag = record.Start.slice(8, 10); var datum = tag + "." + monat + "." + jahr; var serviceDescriptionName = record.ServiceDescription.Name; var serviceCategoryName = record.ServiceDescription.Category.Name; var zahl2 = $("#scDropDown").val(); $("#UnterschriftHilfeplan").val('HilfePlan: ' + $("#scDropDown option[value='" + zahl2 + "']").text()); $("#UnterschriftEmployee").val('Mitarbeiter: ' + record.Employee.FirstName + ' ' + record.Employee.LastName); $("#UnterschriftKategorie").val('Kategorie: ' + serviceCategoryName); $("#UnterschriftLeistung").val('Leistungen: ' + serviceDescriptionName); $("#UnterschriftDatum").val('Datum / Uhrzeit: ' + datum + ' / ' + startDate + ' - ' + endDate); $("#SaveRecordOID").val(serviceRecordOid); console.log('Loading data for service record: ' + $("#SaveRecordOID").value); } catch(exception) { console.log('Error: ' + + ''); } } }); } // Man kann nur eine fatale Fehlermeldung auf einmal anzeigen. Ein Aufruf dieser Methode bei einem bereits angezeigten Fehler führt dazu, dass das Popup wieder unsichtbar geschaltet wird. function writeFatalErrorMessage(msg, i) { toggleErrorPopup(msg, i); } function showZeiterfassungsError(msg) { $("#zeiterfassungsErrorTableRow").css("display", "table-row"); $("#zeiterfassungsErrorTableCell").css("display", "table-cell"); $("#zeiterfassungsErrorDisplay").html(msg + "
"); } function clearZED() { $("#zeiterfassungsErrorTableRow").css("display", "none"); $("#zeiterfassungsErrorDisplay").empty(); } function showCustomers() { $("#customersDropDown").val($("#customersDropDown option").eq(0).val()); preselectCustomer(); $("#zeiterfassung").css("display", "none"); $("#klienten").css("display", "block"); $("#KalenderNavigation").css("display", "none"); $("#Kalender").css("display", "none"); $("#map-canvas").css("width", $("#klientenTabelle").width()); $("#map-canvas").css("height", "500px"); $("#UnterschriftBereich").css("display", "none"); $("#Statistics").css("display", "none"); $("#SupportStatistik").css("display", "none"); $("#colorRibbon").css("background-color", "#3b7799"); toggleMenu(); } function showKalender() { $("#customersDropDown").val($("#customersDropDown option").eq(0).val()); $("#zeiterfassung").css("display", "none"); $("#KalenderNavigation").css("display", "block"); $("#Kalender").css("display", "block"); $("#klienten").css("display", "none"); $("#colorRibbon").css("background-color", "#04b4d0"); $("#UnterschriftBereich").css("display", "none"); $("#Statistics").css("display", "none"); $("#SupportStatistik").css("display", "none"); toggleMenu(); initCalendar(); } function showUsAendern() { $("#TerminSpeichern").prop('disabled', false); $("#AenderePopupDivSchalter").val("true"); } function showUsVerwerfen() { if ($("#AenderePopupDivSchalter").val() === "true") { toggleUpdateAppointmentPopup("Wollen Sie wirklich abbrechen und Ihre Änderungen verwerfen?"); $("#AenderePopupDivSchalter").val("false"); } else { hideEditForm(); } } function initCalendar() { $("#versteckt").val("Speichern"); $("html, body").animate({ scrollTop: 0 }, "fast"); var newtoday; var datumStr = $("#KalenderDatum").val(); var nextdatum; if(datumStr === "") { nextdatum = new Date(); var ddi0 = nextdatum.getDate(); var mmi0 = nextdatum.getMonth() + 1; var yyyyi0 = nextdatum.getFullYear(); var ddStri0 = ddi0 < 10 ? "0" + ddi0 : ddi0; var mmStri0 = mmi0 < 10 ? "0" + mmi0 : mmi0; $("#KalenderDatum").val(yyyyi0 + "-" + mmStri0 + "-" + ddStri0); newtoday = ddStri0 + '.' + mmStri0 + "." + yyyyi0; $("#KalenderDatumFormat").val(newtoday); loadAppointments(newtoday); } } function initAppointmentEditForm() { var currTime = new Date(); if (currTime.getMinutes() <= 30) { var k = 30 - currTime.getMinutes(); currTime.setMinutes(currTime.getMinutes() + k); } if (currTime.getMinutes() > 30) { var j = 60 - currTime.getMinutes(); currTime.setMinutes(currTime.getMinutes() + j); } $("#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)); $("#TerminEndZeit").val(""); $("#TerminBetreff").val(""); $("#TerminNotiz").val(""); $("#TerminBetreffLabel").val("Betreff"); $("#StartDate").prop("readonly", false); $("#EndDate").prop("readonly", false); $("#TerminStartZeit").prop("readonly", false); $("#TerminEndZeit").prop("readonly", false); $("#TerminBetreff").prop('readonly', false); $("#TerminNotiz").prop("readonly", false); $("#TerminSpeichern").val("Speichern"); $("#TerminSpeichernAbbrechen").val("Abbrechen"); $("#TerminSpeichern").hide();//css("display", "none"); $("#InsertAppointmentButton").css("display", "inline"); } function hideEditForm() { $("#AppointmentEditForm").hide(); $("#KalenderTable").show(); $("#KalenderNavigation").show(); $("#KalenderTableTask").show(); $("#StartDate").val(""); } function showServiceRecords() { location.reload(); $("#customersDropDown").val($("#customersDropDown option").eq(0).val()); $("#klientenTabelle").hide(); $("#zeiterfassung").show(); $("#KalenderNavigation").hide(); $("#klienten").hide(); $("#Kalender").hide(); $("#colorRibbon").css("background-color", "#c80000"); $("#UnterschriftBereich").hide(); $("#Statistics").show(); $("#SupportStatistik").hide(); toggleMenu(); } function goBackToZeiterfassung() { showSanduhr(); $("#customersDropDown").val($("#customersDropDown option").eq(0).val()); $("#klientenTabelle").hide(); $("#zeiterfassung").show(); $("#KalenderNavigation").hide(); $("#klienten").hide(); $("#Kalender").hide(); $("#colorRibbon").css("background-color", "#c80000"); $("#UnterschriftBereich").hide(); $("#Statistics").show(); $("#SupportStatistik").hide(); } function klientenLaden() { $("#map-canvas").fadeOut(); showSanduhr(); var oid = parseInt($("#customersDropDown").find(":selected").val()); if(oid === -1) { $("#klientenTabelle").hide(); $("#umfeldContainer").hide(); $("#kommentarContainer").hide(); hideSanduhr(); return; } makeAjaxCall("GET", getSelectedCustomerUrl, function (json) { $("#klientenTabelle").show(); $("#umfeldContainer").show(); $("#kommentarContainer").show(); if(json === "SessionTimeout") { window.location.href = window.redirectLink; return; } vm.update($.parseJSON(json)); $(".toggle-btn2").click(function () { toggleOnclick(this); }); }, { customerOid: oid }, hideSanduhr); } function KlientenVM() { this.vorname = ko.observable(""); this.nachname = ko.observable(""); this.geburtstag = ko.observable(""); this.geschlecht = ko.observable(""); this.adresszusatz = ko.observable(""); this.strasse = ko.observable(""); this.plz = ko.observable(""); this.ort = ko.observable(""); this.rechnungsadressename = ko.observable(""); this.rechnungsadressestrasse = ko.observable(""); this.rechnungsadressepostleitzahl = ko.observable(""); this.rechnungsadresseort = ko.observable(""); this.email = ko.observable(""); this.pureemail = ko.observable(""); this.fax = ko.observable(""); this.telefon = ko.observable(""); this.handy = ko.observable(""); this.umfeldpersonen = ko.observableArray([]); this.Wohnheim = ko.observable(""); this.mobileLink = ko.observable(""); this.landLineLink = ko.observable(""); this.kommentar = ko.observable(""); this.update = function (data) { this.vorname(data.Vorname); this.nachname(data.Nachname); this.geburtstag(data.Geburtstag); this.geschlecht(data.Geschlecht); this.adresszusatz(data.Adresszusatz); this.strasse(data.Strasse); this.plz(data.Postleitzahl); this.ort(data.Ort); this.rechnungsadressename(data.RechnungsadresseName); this.rechnungsadressestrasse(data.RechnungsadresseStrasse); this.rechnungsadressepostleitzahl(data.RechnungsadressePostleitzahl); this.rechnungsadresseort(data.RechnungsadresseOrt); this.email('mailto:'+data.EMail); this.pureemail(data.EMail); this.fax(data.Fax); this.telefon(data.Telefon); this.handy(data.Handy); this.mobileLink('tel:' + data.Handy); this.landLineLink('tel:' + data.Telefon); this.kommentar(data.Kommentar); var mappedUmfeldpersonen = $.map(data.Umfeldpersonen, function (item) { return new UmfPers(item); }); if (mappedUmfeldpersonen.length === 0) { $("#WohnheimContainer").css("display", "none"); } this.umfeldpersonen(mappedUmfeldpersonen); calcPropFieldMinSizes(); updateEigenschaftsfelder(); } } function UmfPers(initdata) { var self = this; self.umfvorname = ko.observable(initdata.Vorname); self.umfnachname = ko.observable(initdata.Nachname); self.umfstrnr = ko.observable(initdata.StrNameNr); self.umfplzort = ko.observable(initdata.PLZOrt); self.umftelnr = ko.observable("tel:" + initdata.TelNr); self.nurtelnr = ko.observable(initdata.TelNr); self.nurmobil = ko.observable(initdata.Mobil); self.umfmobil = ko.observable("tel:" + initdata.Mobil); self.umfemail = ko.observable("mailto:" + initdata.EMail); self.nuremail = ko.observable(initdata.EMail); self.umffax = ko.observable(initdata.Fax); self.umfrolle = ko.observable(initdata.Rolle); self.umftitel = ko.observable(initdata.Titel); self.formattedName = ko.computed(function () { var titel = self.umftitel() ? self.umftitel() + " " : ""; return titel + self.umfvorname() + " " + self.umfnachname(); }); self.update = function (updatedata) { self.umfvorname(updatedata.Vorname); self.umfnachname(updatedata.Nachname); self.umfstrnr(updatedata.StrNameNr); self.umfplzort(updatedata.PLZOrt); self.umfmobil("tel:" + updatedata.Mobil); self.nurmobil(updatedata.Mobil); self.umfemail("mailto:" + updatedata.EMail); self.nuremail(ko.observable(updatedata.EMail)); self.umffax(updatedata.Fax); self.umfrolle(updatedata.Rolle); self.umftitel(updatedata.Titel); self.umftelnr("tel:" + updatedata.TelNr); self.nurtelnr(updatedata.TelNr); } } minSizes = undefined; function calcPropFieldMinSizes() { var width = 0; var height = 0; var elementCount = 0; $(".eigenschaftsdiv").each( function (index, element) { var x = $(element).clone().css({ "height": "auto", "width": "auto" }).appendTo("body"); var temporaryWidth = x.outerWidth(true); var temporaryHeight = x.outerHeight(true); x.remove(); elementCount++; if(temporaryWidth > width) { width = temporaryWidth; } if(temporaryHeight > height) { height = temporaryHeight; } } ); window.minSizes = { minWidth: width, minHeight: height, divCount: elementCount }; } function updateEigenschaftsfelder() { var customerTableWidth = $("#klientenTabelle").width(); $("#map-canvas").css("width", customerTableWidth - 16); $("#map-canvas").css("height", customerTableWidth - 16); if(minSizes === undefined) { return; } var mitPadding = minSizes.minWidth; var maxAnzahl = parseInt(customerTableWidth / mitPadding); if(maxAnzahl > minSizes.divCount) { maxAnzahl = minSizes.divCount; } var width = parseInt(customerTableWidth / maxAnzahl) - 16; if(minSizes !== undefined) { $(".eigenschaftsdiv").each( function (index, element) { $(element).css("width", width + "px"); $(element).css("height", (minSizes.minHeight - 16) + "px"); } ); } } $(window).resize(function () { if($("#klientenTabelle").css("display") === "block") { updateEigenschaftsfelder(); } updateDokuTabLinks(); }); function showSanduhr() { $(".modalWrapper").show(); $(".modalWrapper").css("height", $(document).height()); $(".warte-animation").css("display", "inline-block"); } function hideSanduhr() { if($("#errorPopupDiv").css("display") === "none" && $("#popupDiv").css("display") === "none") { $(".modalWrapper").hide(); $(".modalWrapper").css("height", "0"); } if($("#SuccessPopupDiv").css("display") === "none" && $("#popupDiv").css("display") === "none") { $(".modalWrapper").hide(); $(".modalWrapper").css("height", "0"); } if($("#AendernPopupDiv").css("display") === "none" && $("#popupDiv").css("display") === "none") { $(".modalWrapper").hide(); $(".modalWrapper").css("height", "0"); } $(".warte-animation").hide(); } function submitDeletionForm() { showSanduhr(); $("#deletionForm").submit(); } function toggleErrorPopup(errorMessage, i) { var isDisplayNone = $("#errorPopupDiv").css("display") === "none"; var displayValue = isDisplayNone ? "block" : "none"; $("#errorPopupDiv").css("display", displayValue); $(".modalWrapper").css("display", displayValue); $(".modalWrapper").css("height", $(document).height()); if(isDisplayNone ) { $("#errorPopupText").text(errorMessage); if(i === 1) { $("#errorPopupTitle").text("Info"); $("#errorPopupOkBtn").onclick = "toggleErrorPopup('')"; } else if(i === 2) { $("#errorPopupTitle").text("Fehler"); $("#errorPopupOkBtn").onclick = "toggleErrorPopup('')"; clearLocalStorage(1); //SaveOnly(); // Speichere Daten bei absturz } else { $("#errorPopupTitle").text("Fehler"); $("#errorPopupOkBtn").onclick = "toggleErrorPopup('')"; } var errorPopupTitleOuterHeight = $("#errorPopupTitle").outerHeight(); var errorPopupTextOuterHeight = $("#errorPopupText").outerHeight(); var errorPopupButtonOuterHeight = $("#errorPopupBtnDiv").outerHeight(); var errorPopupOkButtonOuterHeight = $("#errorPopupOkBtn").outerHeight(); var height = errorPopupTitleOuterHeight + errorPopupTextOuterHeight + errorPopupButtonOuterHeight + errorPopupOkButtonOuterHeight + errorPopupOkButtonOuterHeight; $("#errorPopupDiv").css("height", height + "px"); $("#errorPopupDiv").css("top", window.pageYOffset + window.innerHeight / 2 - height / 2); $("#errorPopupDiv").css("margin-top", "0"); } else { $("#errorPopupDiv").css("margin-top", "auto"); } } function toggleSuccessPopup(message, i) { var isDisplayNone = $("#SuccessPopupDiv").css("display") === "none"; var displayValue = isDisplayNone ? "block" : "none"; $("#SuccessPopupDiv").css("display", displayValue); $(".modalWrapper").css("display", displayValue); $(".modalWrapper").css("height", $(document).height()); $("#SuccessPopupOkBtn").val("OK"); if(i === 2) { $(".SuccessPopupUSchrift").css("display", "none"); } else if(i === 3) { $(".SuccessPopupUSchrift").css("display", "none"); $("#SuccessPopupTitle").text("Es ist leider ein Fehler aufgetreten!"); } else if(i === 4) { $(".SuccessPopupUSchrift").css("display", "inline"); $("#SuccessPopupOkBtn").val("Nein"); } else { $(".SuccessPopupUSchrift").css("display", "inline"); } if(isDisplayNone) { $("#SuccessPopupText").text(message); var successPopupTitleOuterHeight = $("#SuccessPopupTitle").outerHeight(); var successPopupTextOuterHeight = $("#SuccessPopupText").outerHeight(); var successPopupButtonOuterHeight = $("#SuccessPopupBtnDiv").outerHeight(); var successPopupOkButtonOuterHeight = $(".SuccessPopupOkBtn").outerHeight(); var successPopupSignatureButtonOuterHeight = $(".SuccessPopupUSchrift").outerHeight(); var height = successPopupTitleOuterHeight + successPopupTextOuterHeight + successPopupButtonOuterHeight + successPopupOkButtonOuterHeight + successPopupSignatureButtonOuterHeight; $("#SuccessPopupDiv").css("height", height + "px"); $("#SuccessPopupDiv").css("top", window.pageYOffset + window.innerHeight / 2 - height / 2); $("#SuccessPopupDiv").css("margin-top", "0"); } else { $("#SuccessPopupDiv").css("margin-top", "auto"); } } function toggleUpdateAppointmentPopup(message) { var isDisplayNone = $("#AendernPopupDiv").css("display") === "none"; var displayValue = isDisplayNone ? "block" : "none"; $("#AendernPopupDiv").css("display", displayValue); $(".modalWrapper").css("display", displayValue); $(".modalWrapper").css("height", $(document).height()); if(isDisplayNone) { $("#AendernPopupText").text(message); var aendernPopupTitleOuterHeight = $("#AendernPopupTitle").outerHeight(); var aenderPopupTextOuterHeight = $("#AendernPopupText").outerHeight(); var aendernPopupButtonDivOuterHeight = $("#AendernPopupBtnDiv").outerHeight(); var aendernPopupOkButtonOuterHeight = $(".AendernPopupOkBtn").outerHeight(); var aendernPopupSignatureOuterHeight = $(".AendernPopupUSchrift").outerHeight(); var height = aendernPopupTitleOuterHeight + aenderPopupTextOuterHeight + aendernPopupButtonDivOuterHeight + aendernPopupOkButtonOuterHeight + aendernPopupSignatureOuterHeight; $("#AendernPopupDiv").css("height", height + "px"); $("#AendernPopupDiv").css("top", window.pageYOffset + window.innerHeight / 2 - height / 2); $("#AendernPopupDiv").css("margin-top", "0"); } else { $("#AendernPopupDiv").css("margin-top", "auto"); } } function confirmErrorPopup() { toggleErrorPopup(""); } function clearRecords() { $("#serviceRecords").empty(); } function preselectCustomer() { $.ajax({ type: "GET", url: getSupportConceptCustomerUrl, success: function (json) { if(json === "NoSupportConceptSelected") { return; } var valueToSelect = $.parseJSON(json); $("#customersDropDown option").each(function () { if(this.value === valueToSelect === true) { $("#customersDropDown").val(valueToSelect); $("#customersDropDown").trigger("change"); return false; } else { return true; } }); } }); } function setSelectedEmployee() { var oid = parseInt($("#employeesDropDown").find(":selected").val()); if(isNaN(oid)) { return; } window.serviceRecordEmployeeOid = oid; makeAjaxCall("GET", setServiceRecordEmployeeUrl, null, { employeeOid: window.serviceRecordEmployeeOid }, null); } function SaveOnly() { if(typeof Storage !== "undefined") { clearLocalStorage(1); var costBearer2SupportConceptOid = $("#scDropDown").val(); var hilfeplan = $("#scDropDown option[value='" + zahl + "']").text(); var mitarbeiter = $("#employeesDropDown option:selected").text(); var kategorie = $("#kategorien_select option:selected").text(); var leistung = $("#leistungen_select option:selected").val(); var duration = $("#duration_textbox").val(); var notiz = $("#notiz_textbox").val(); var notiz2, notiz3, notiz4, notiz5; if($("#notiz_textbox1").val() !== "") { notiz = $("#notiz_textbox1").val(); } if($("#notiz_textbox2").val() !== "") { notiz2 = $("#notiz_textbox2").val(); } if($("#notiz_textbox3").val() !== "") { notiz3 = $("#notiz_textbox3").val(); } if($("#notiz_textbox4").val() !== "") { notiz4 = $("#notiz_textbox4").val(); } if($("#notiz_textbox5").val() !== "") { notiz5 = $("#notiz_textbox5").val(); } localStorage.setItem("Zeitdaten", new LocalServiceRecord(costBearer2SupportConceptOid, hilfeplan, mitarbeiter, kategorie, leistung, $("#datum_textbox").val(), $("#start_textbox").val(), $("#ende_textbox").val(), duration, notiz, notiz2, notiz3, notiz4, notiz5, $("#enddatum_textbox").val())); } } function clearLocalStorage(i) { if(i === 1) { localStorage.removeItem("Zeitdaten"); } if(i === 2) { localStorage.removeItem("Kalenderdaten"); } } function saveZeiterfassungAfterCrash(datum, startd, endd, dauer, doku, leistung, costBearer2SupportConceptOid, doku2, doku3, doku4, doku5, enddatum) { var x = getDateObj(true); var y = getDateObj(false); var vonDatum = getDateTimeStringWithLeadingZeros(x); var bisDatum = getDateTimeStringWithLeadingZeros(y); if (costBearer2SupportConceptOid === -2) { $.ajax({ type: "GET", url: saveZeiterfassungAfterCrashUrl, data: { pDatum: datum, pStartDate: startd, pEndDate: endd, pDuration: dauer, pNotice: doku, pServiceDescription: leistung, pNotice2: doku2, pNotice3: doku3, pNotice4: doku4, pNotice5: doku5, pEndDate2: enddatum }, success: null, error: null }); } else { $.ajax({ type: "GET", url: CheckRightsAfterCrashUrl, data: { von: vonDatum, bis: bisDatum, inEditMode: false, dateString: datum, startString: startd, endString: endd, costbearerOId: costBearer2SupportConceptOid, leistung:leistung}, success: function (json) { var hasSufficientRights = json; if (hasSufficientRights === "True") { $.ajax({ type: "GET", url: saveZeiterfassungAfterCrashUrl, data: { Datum: datum, StartD: startd, EndeD: endd, Dauer: dauer, Doku: doku, Leistungen: leistung, Doku2: doku2, Doku3: doku3, Doku4: doku4, Doku5: doku5, EndDatum: enddatum }, success: function () { }, error: function () { writeFatalErrorMessage("Es konnte keine verbindung zum Server aufgebaut werden. Bitte überprüfen sie ihre Internet Verbindung."); /*$("#scDropDown option[value='" + oid + "']").attr('selected', true).trigger("change");*/ } }); } else { clearLocalStorage(1); setTimeout(function () { $("#scDropDown option[value='" + costBearer2SupportConceptOid + "']").attr("selected", true).trigger("change"); }, 4500); } }, error: function () { clearLocalStorage(1); writeFatalErrorMessage("Es konnte keine Verbindung zum Server aufgebaut werden. Bitte überprüfen Sie Ihre Internetverbindung."); // $("#scDropDown option[value='" + costBearer2SupportConceptOid + "']").attr('selected', true).trigger("change"); } }); } } function showErrorAfterCrash() { var errorAfterCrashSwitch = $("#ErrorZeiterfassungAfterCrashSchalter"); var switchValue = errorAfterCrashSwitch.val(); var errorMessage = ""; if(switchValue === 2 || switchValue === 3) { errorMessage = "Es konnte keine Verbindung zum Server aufgebaut werden. Bitte überprüfen sie ihre Internet Verbindung."; } else if(switchValue === 4) { errorMessage = "Das Datum liegt außerhalb des Zeitraumes des gewählten Hilfeplans. Der Eintrag kann nicht gespeichert werden."; } else if(switchValue === 5) { errorMessage = "Die eingegebene Uhrzeit ist ungültig. Der Eintrag kann nicht gespeichert werden."; } if(errorAfterCrashSwitch.val() > 1) { writeFatalErrorMessage(errorMessage); errorAfterCrashSwitch.val(1); clearLocalStorage(1); setTimeout(function() { $.ajax({ type: "GET", url: ErrorZeiterfassungAnzeigenUrl, data: { errorwert: 1 } }); }, timeOut); } } function focusOnTab(tabIdentifier) { focusOnDoku(tabIdentifier); } function focusOnDoku(number) { setTimeout(function() { var displayValue; for (var i = 0; i < window.numberOfDocumentationTypes; i++) { var idNumber = i + 1; displayValue = idNumber === number ? "block" : "none"; 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" + 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"); } }