Files
BeWoPlaner/BeWoPlanerMobil/Scripts/mainView.js

2452 lines
85 KiB
JavaScript

var breitenGrad, langenGrad, date;
var dataURL = "";
var blob, newday, longrider;
var xinner = $("#GeoLocSaveXCOOR");
var yinner = $("#GeoLocSaveYCOOR");
var KalenderDatakonstrukt = [];
var ZeiterfassungDatakonstrukt = [];
var KlientDatakonstrukt = [];
var Kalenderzwischenspeicher = [];
var Klientzwischenspeicher = [];
var SetTimeoutTime = 10000;
var UpdatekalenderOid, Updatekalenderbetreff, Updatekalendernotice, UpdatekalenderstartZ, UpdatekalenderendZ, Updatekalenderday;
function BuildCollapsibleSet(jsonString) {
try {
if (jsonString.length === 0) {
return;
}
var kollektion = $.parseJSON(jsonString);
actuallyBuildCollapsibleSet(kollektion);
} catch (exception) {
console.log("Fehler(BuildCollapsibleSet): " + exception.message);
}
}
function actuallyBuildCollapsibleSet(kollektion) {
$("#kollabierbar1").empty();
collapsibleHtml = "";
$.each(kollektion, function (index) {
buildGoalTreeItem(kollektion[index]);
});
$("#kollabierbar1").append(collapsibleHtml);
}
var collapsibleHtml;
function buildGoalTreeItem(goalItem) {
collapsibleHtml += '<input onclick="toggleOnclick(this);" type="button" class="toggle-btn" value="' + goalItem.Header + '" style="margin-right: 0; padding-right: 0;" />';
collapsibleHtml += '<div style="margin-right: 0; padding-right: 0;display: none;" class="kollabierbar">';
try {
$.each(goalItem.Children, function (index) {
if (!goalItem.Children[index].IsLeaf) {
buildGoalTreeItem(goalItem.Children[index]);
} else {
var goalOid = goalItem.Children[index].ValueListEntryOid;
var goalHeader = goalItem.Children[index].Header;
collapsibleHtml += '<div style="margin-right: 0; padding-right: 0;display: block;"><input type="checkbox" style="margin-right: 0; padding-right: 0;width: auto;" onclick="updateGoals(' + goalOid + ')" value="' + goalHeader + '" /></div>';
}
});
} catch (exception) {
console.log("Fehler bei der Baumkonstruktion: " + exception.message);
}
collapsibleHtml += "</div>";
}
function loadGoalsOnSuccess(json) {
if (json === "SessionTimeout") {
window.location.href = redirectLink;
return;
}
BuildCollapsibleSet(json);
}
function loadServiceCategoriesOnSuccess(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('<option value="' + leistung.ServiceDescriptionOid + '">' + leistung.Name + "</option>");
});
if (liste[0] !== undefined) {
$("#leistungen_select").val(liste[0].ServiceDescriptionOid);
makeAjaxCall("GET", setServiceDescriptionUrl, null, { pServiceDescriptionOid: liste[0].ServiceDescriptionOid }, 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();
//}, SetTimeoutTime);
//}
//else
toggleErrorPopup(jqXHR.status + " " + errorThrown);
}
function showErrorMsg(message) {
toggleErrorPopup(message);
}
function resizeLabelColumns() {
$("#tabLbl").css("width", $("#zieleLbl").css("width"));
}
zeitRegEx = /^(2[0-3]|[01]?[0-9])(:|,|\.|#|;)?([0-5][0-9])$/;
function calcDurationByStartEnd() {
if ($("#enddatum_textbox").val() == $("#datum_textbox").val() || $("#enddatum_textbox").val() =="") {
var shm = getDateObj(true);
var ehm = getDateObj(false);
var dur = 0;
if (shm.getTime() < ehm.getTime()) {
dur = parseInt(subtractDates(ehm, shm));
}
$("#duration_textbox").val(dur).trigger("change");
}
else {
aktualDurationwithEndDate();
}
}
function calcEndByStartDuration() {
if ($("#enddatum_textbox").val() == $("#datum_textbox").val() || $("#enddatum_textbox").val() == "") {
var shm2 = getDateObj(true);
var dauer = parseInt($("#duration_textbox").val());
if (isNaN(dauer)) return;
var neu = addMinutes(shm2, dauer);
var ende = (neu.getHours() < 10 ? "0" : "") + neu.getHours() + ':' + (neu.getMinutes() < 10 ? "0" : "") + neu.getMinutes();
//if (isNaN(ende)) return;
$("#ende_textbox").val(ende).trigger("change");
}
else {
aktualDurationwithEndDate();
}
}
function calcStartByEndDuration() {
var ehm2 = getDateObj(false);
var dauer2 = parseInt($("#duration_textbox").val());
if (isNaN(dauer2)) return;
var neu2 = addMinutes(ehm2, dauer2 * -1);
$("#start_textbox").val((neu2.getHours() < 10 ? "0" : "") + neu2.getHours() + (neu2.getMinutes() < 10 ? "0" : "") + neu2.getMinutes()).trigger("change");
}
function getDateObj(isFromStart) {
var roh = $("#datum_textbox").val();
var dd = parseInt(roh.slice(0, 2));
var mm = parseInt(roh.slice(3, 5));
var yyyy = parseInt(roh.slice(6, 10));
var date = new Date();
if (!isNaN(dd) && !isNaN(mm) && !isNaN(yyyy)) {
date = new Date(yyyy, mm - 1, dd);
}
var hm = [0, 0];
var ds = $("#ende_textbox").val();
if (isFromStart) {
ds = $("#start_textbox").val();
}
if (ds != "") {
hm = stringToTime(ds);
}
date.setHours(hm[0]);
date.setMinutes(hm[1]);
return date;
}
function loadGoals(actionPath) {
var selectedSC = $($("#scDropDown")).find(":selected").val();
makeAjaxCall("GET", actionPath, loadGoalsOnSuccess, { pCostbearer2SupportConceptOid: selectedSC }, null);
}
function toggleMenu() {
var menuDiv = $("#menu-div");
$(menuDiv).fadeToggle("fast");
}
function loadServiceDescriptions() {
var selectedCategory = $("#kategorien_select").find(":selected").val();
makeAjaxCall("GET", loadServiceCategoriesUrl, loadServiceCategoriesOnSuccess, { pServiceCategoryOid: selectedCategory }, null);
loadTextbausteineForServiceCategory(selectedCategory);
}
function loadTextbausteineForServiceCategory(serviceCategoryOid) {
//makeAjaxCall("GET", loadTextbausteineForCategoryUrl, loadTextbausteineForCategoryOnSuccess, { pServiceCategoryOid: serviceCategoryOid }, null);
}
function loadTextbausteineForCategoryOnSuccess(json) {
if (json == null) {
return;
}
buildCollapsableSet2(json);
}
var textModules;
var collapsibleHtml2;
function buildTextModuleTreeItem(moduleItem) {
// TODO: Nur, wenn es sich um eine Textbausteinkategorie handelt!
if (moduleItem.IsParent) {
collapsibleHtml2 += '<input onclick="toggleOnclick(this);" type="button" class="toggle-btn" value="' + moduleItem.Name + " (" + moduleItem.Oid + ')" />';
collapsibleHtml2 += '<div style="display: none;" class="kollabierbar"';
try {
$.each(moduleItem.Children, function (index) {
buildTextModuleTreeItem(moduleItem.Children[index]);
});
} catch (exception) {
console.log("Fehler bei der Textbausteinbaumkonstruktion: " + exception.message);
}
collapsibleHtml2 += "</div>";
} else {
var moduleOid = moduleItem.Oid;
var header = moduleItem.Name;
collapsibleHtml2 += '<div style="display: block;"><input type="button" style="width: 100%;" onclick="setTextModule(' + moduleOid + ')" value="' + header + '" /></div>';
}
}
function buildCollapsableSet2(jsonString) {
try {
if (jsonString.length === 0) {
return;
}
textModules = $.parseJSON(jsonString);
console.log(textModules);
actuallyBuildCollapsibleSet2(textModules);
} catch (exception) {
console.log("Fehler(BuildCollapsibleSet2): " + exception.message);
}
}
function actuallyBuildCollapsibleSet2(tmodules) {
$("#kollabierbar2").empty();
collapsibleHtml2 = "";
$.each(tmodules, function (index) {
buildTextModuleTreeItem(tmodules[index]);
});
$("#kollabierbar2").append(collapsibleHtml2);
}
function setTextModule(moduleOid) {
// TODO: ausgewähltes Dokufeld ermitteln und den entsprechenden Text hinzufügen
}
function setTextbaustein() {
var selectedTextbausteinOid = $("#textbausteine_select").find(":selected").val();
if (selectedTextbausteinOid > 0) {
makeAjaxCall("GET", loadCompleteTextbausteinByOidUrl, loadTextbausteinContentOnSuccess, { pTextbausteinOid: selectedTextbausteinOid }, null);
}
}
function loadTextbausteinContentOnSuccess(textbausteintext) {
if (focusedDokuTextarea != null) {
var cursorPosition = focusedDokuTextarea.prop("selectionStart");
var v = focusedDokuTextarea.val();
var textBefore = v.substring(0, cursorPosition);
var textAfter = v.substring(cursorPosition, v.length);
focusedDokuTextarea.val(textBefore + textbausteintext + textAfter);
} else {
console.log("focusedDokuTextarea ist null!");
}
}
function updateGoals(cbId) {
makeAjaxCall("GET", updateGoalsUrl, null, { pGoalOid: cbId }, null);
}
function setServiceDescription() {
var sdOid = $("#leistungen_select").find(":selected").val();
makeAjaxCall("GET", setServiceDescriptionUrl, null, { pServiceDescriptionOid: sdOid }, null);
}
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();
for (var i = 0; i < goals.length; i++) {
idArray[goals[i].ValueListEntryOid] = goals[i].ValueListEntryOid;
}
$.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 s = record.Start[18] == "1" ? "" : record.Start.slice(11, 16);
var e = 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 ENDjahr = record.End.slice(0, 4);
var ENDmonat = record.End.slice(5, 7);
var ENDtag = record.End.slice(8, 10);
var ENDdatum = ENDtag + "." + ENDmonat + "." + ENDjahr;
$("#start_textbox").val(s);
$("#ende_textbox").val(e);
$("#datum_textbox").val(datum);
$("#notiz_textbox").val(record.Notice);
$("#enddatum_textbox").val(ENDdatum)
$("#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);
$("#employeesDropDown").val(record.Employee.EmployeeOid);
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('<option value="' + leistung.ServiceDescriptionOid + '">' + leistung.Name + '</option>');
});
$("#leistungen_select").val(record.ServiceDescription.ServiceDescriptionOid);
makeAjaxCall("GET", setServiceDescriptionUrl, null, { pServiceDescriptionOid: record.ServiceDescription.ServiceDescriptionOid }, null);
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);
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);
$("#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();
$("#start_textbox").val("").trigger("change");
$("#ende_textbox").val("").trigger("change");
$("#notiz_textbox").val("").trigger("change");
$("#duration_textbox").val("").trigger("change");
$("#datum_textbox").val(getDateStringWithLeadingZeros(new Date()));
$("#kategorien_select").val($("#kategorien_select option").eq(0).val());
var selectedCategory = $("#kategorien_select").find(":selected").val();
$.ajax({
type: "GET",
url: loadServiceCategoriesUrl,
data: { pServiceCategoryOid: selectedCategory },
success: function (json) {
loadServiceCategoriesOnSuccess(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 + "xxx-Zeit in einem g&uuml;ltigen Format (HH:MM oder HHMM) an.");
return false;
} else {
clearZED();
return true;
}
}
recordToDelete = 0;
function togglePopup(serviceRecordOid) {
recordToDelete = serviceRecordOid;
var isShowing = $(".modalWrapper").css("display") == "none";
var displayValue = $(".modalWrapper").css("display") == "block" ? "none" : "block";
toggleModalWrapper();
$("#popupDiv").css("display", displayValue);
if (isShowing) {
var h = 0;
var t = $("#popupTitle").outerHeight();
var u = $("#popupText").outerHeight();
var v = $("#popupBtnDiv").outerHeight();
var w = $(".popupBtn").outerHeight();
h += t + u + v + w + w;
$("#popupDiv").css("height", h + "px");
$("#popupDiv").css("top", window.pageYOffset + window.innerHeight / 2 - h / 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 () {
$('#deletionForm').submit(function () {
$.ajax({
type: "GET",
url: setRecordForDeletionUrl,
data: { serviceRecordOid: recordToDelete },
success: function () {
return true;
},
error: function () {
showAjaxError();
return false;
}
});
return true;
});
});
function toggleLabel(inputId) {
var label = $('label[for="' + inputId + '"]');
var topValue;
if ($("#" + inputId).is(":focus")) {
$(label).animate({ top: "-6px" }, 100);
return;
}
topValue = "12px";
if ($("#" + inputId).val()) {
topValue = "-6px";
}
$(label).animate({ top: topValue }, 75);
}
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);
var results = meldungen.ValidationResults;
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;
}
});
var exitLoop = false;
for (var i = 0; i < results.length; i++) {
if (exitLoop)
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?");
isValidRecord = r;
exitLoop = !isValidRecord;
} else {
writeFatalErrorMessage(msg1);
isValidRecord = false;
exitLoop = true;
}
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?");
isValidRecord = r2;
exitLoop = !isValidRecord;
} else {
writeFatalErrorMessage(msg2);
isValidRecord = false;
exitLoop = true;
}
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.");
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 r3 = confirm(msg3 + " Möchten Sie trotzdem speichern?");
isValidRecord = r3;
exitLoop = !isValidRecord;
} else {
writeFatalErrorMessage(msg3);
isValidRecord = false;
exitLoop = true;
}
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.");
isValidRecord = false;
exitLoop = true;
break;
case 5:
writeFatalErrorMessage("Beim Speichern ist ein Fehler aufgetreten. Speichern nicht möglich.");
isValidRecord = false;
exitLoop = true;
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) {
msg6 = "Sie können den Eintrag nicht bearbeiten, da bereits eine Spitzabrechnung für diesen Hilfeplan erstellt wurde. Speichern nicht möglich.";
}
writeFatalErrorMessage(msg6);
isValidRecord = false;
exitLoop = true;
break;
case 7:
var msg7 = "Sie können keine neuen Leistungen dokumentieren, da die Frist zur Bearbeitung abgelaufen ist. Das Speichern ist nicht möglich.";
writeFatalErrorMessage(msg7);
isValidRecord = false;
exitLoop = true;
break;
default:
writeFatalErrorMessage(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") {
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 DatenVorladen(oid){
$.ajax({
type: "GET",
url: getSelectedRecordInformationUrlWithOid,
data: {oid:oid},
success: function (jsonServiceRecord) {
try{
if (jsonServiceRecord == "SessionTimeout") {
window.location.href = redirectLink;
return;
}
var record = $.parseJSON(jsonServiceRecord);
var s = record.Start[18] == "1" ? "" : record.Start.slice(11, 16);
var e = 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 y = record.ServiceDescription.Name;
var z = 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: " + z);
$("#UnterschriftLeistung").val("Leistungen: " + y);
$("#UnterschriftDatum").val("Datum / Uhrzeit: " + datum + " / " + s + " - " + e);
$("#SaveRecordOID").val(oid);
console.log("Lade Daten OID:" + document.getElementById("SaveRecordOID").value);
}catch(exception){
console.log("Internal Server Error");
}
}
});
}
function writeFatalErrorMessage(msg,i) {
toggleErrorPopup(msg,i);
}
function showZeiterfassungsError(msg) {
$("#zeiterfassungsErrorTableRow").css("display", "table-row");
$("#zeiterfassungsErrorTableCell").css("display", "table-cell");
$("#zeiterfassungsErrorDisplay").html(msg + "<br />");
}
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();
}
var ChartAnz;
var ArrayStatistika;
var StringProvided = "Geleistet diese Woche";
var StringProvidedTotal = "Gesamt";
var StringApproved = "Bewilligt pro Woche";
var StringApprovedTotal = "Gesamt";
var StringFree = "Frei pro Woche (Ø)";
var StringFreeTotal = "Gesamt";
function ShowStatistics() {
$("#customersDropDown").val($("#customersDropDown option").eq(0).val());
$("#zeiterfassung").css("display", "none");
$("#KalenderNavigation").css("display", "none");
$("#Kalender").css("display", "none");
$("#klienten").css("display", "none");
$("#colorRibbon").css("background-color", "#04b4d0");
$("#UnterschriftBereich").css("display", "none");
$("#Statistics").css("display","none");
$("#SupportStatistik").css("display", "block");
var zahl = $("#scDropDown").val();
if (zahl >= 0) {
$("#StatisticUberschrift").val("Hilfeplan Statistik: " + $("#scDropDown option[value='" + zahl + "']").text());
LoadSupportConceptStatistics(zahl);
} else {
$("#StatisticUberschrift").val("Hilfeplan Statistik: Es wurde kein Hilfeplan ausgewählt");
$("#Statistic1").val("Keine Datensätze gefunden ");
$("#Statistic2").val("Keine Datensätze gefunden ");
$("#Statistic3").val("Keine Datensätze gefunden ");
document.getElementById("Statistic1").onclick = "";
document.getElementById("Statistic2").onclick = "";
document.getElementById("Statistic3").onclick = "";
StatisticDesign(100, 200);
$("#LegendStatistic2").val(100);
$("#LegendStatistic1").val(200);
}
}
function StatisticDesign(wert1,wert2,string1,string2) {
var data = [
{
value: wert1,
color: "#F7464A",
highlight: "#FF5A5E",
label: string1
},
{
value: wert2,
color: "#00FF00",
highlight: "#99FF00",
label: string2
}];
var options = {
scaleShowLabelBackdrop: true,
scaleBackdropColor: "rgba(255,255,255,0.75)",
scaleBeginAtZero: true,
scaleBackdropPaddingY: 2,
scaleBackdropPaddingX: 2,
scaleShowLine: true,
segmentShowStroke: true,
segmentStrokeColor: "#fff",
segmentStrokeWidth: 1,
animationSteps: 150,
animationEasing: "easeOutBounce",
responsive: true,
animateRotate: true,
animateScale: true,
legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>"
}
var ctx = document.getElementById("myChart").getContext("2d");
if (ChartAnz != null) {
ChartAnz.destroy();
}
ChartAnz = new Chart(ctx).Doughnut(data, options);
}
function LoadSupportConceptStatistics(oid) {
$.ajax({
type: "GET",
url: LoadStatisticsUrl,
data: {oid:oid },
success: function (jsonServiceRecord) {
var KalenderRec = $.parseJSON(jsonServiceRecord);
var Description = KalenderRec.Subject;
var Provided = KalenderRec.MinutesProvidedThisWeek;
var Approved = KalenderRec.MinutesApprovedPerWeek;
var FreeWeek = KalenderRec.MinutesFreePerWeekAverage;
var ProvidedTotal = KalenderRec.MinutesProvidedTotalRounded;
var ApprovedTotal = KalenderRec.MinutesApprovedTotal;
var FreeWeekTotal = ApprovedTotal - ProvidedTotal;
Provided = (Provided / 60).toFixed(2);
Approved = (Approved / 60).toFixed(2);
FreeWeek = (FreeWeek / 60).toFixed(2);
ProvidedTotal = (ProvidedTotal / 60).toFixed(2);
ApprovedTotal = (ApprovedTotal / 60).toFixed(2);
FreeWeekTotal = (FreeWeekTotal / 60).toFixed(2);
ArrayStatistika = new Array();
ArrayStatistika[0] = Provided;
ArrayStatistika[1] = Approved;
ArrayStatistika[2] = FreeWeek;
ArrayStatistika[3] = ProvidedTotal;
ArrayStatistika[4] = ApprovedTotal;
ArrayStatistika[5] = FreeWeekTotal;
var berechne = ArrayStatistika[3] - ArrayStatistika[0];
if (berechne < 0)berechne = 0;
StatisticDesign(ArrayStatistika[0], berechne, StringProvided, StringProvidedTotal);
$("#LegendStatistic2").val(ArrayStatistika[0] + " / " + StringProvided);
$("#LegendStatistic1").val(ArrayStatistika[3] + " / " + StringProvidedTotal);
LoadDataIntoTXTField(ArrayStatistika);
}
});
}
function LoadDataIntoTXTField(ArrayStatistika) {
if ($("#Statistic1").val() == "") {
$("#Statistic1").val(StringProvided + ": " + ArrayStatistika[0] + " / Gesamt: " + ArrayStatistika[3]);
$("#Statistic2").val(StringApproved + ": " + ArrayStatistika[1] + " / Gesamt: " + ArrayStatistika[4]);
$("#Statistic3").val(StringFree + ": " + ArrayStatistika[2] + " / Gesamt: " + ArrayStatistika[5]);
}
}
function StatisticÄnderung(value) {
if (value == 1) {
var berechne = ArrayStatistika[3] - ArrayStatistika[0];
if (berechne < 0) berechne = 0;
StatisticDesign(ArrayStatistika[0], berechne, StringProvided, StringProvidedTotal);
$("#LegendStatistic2").val(ArrayStatistika[0] + " / " + StringProvided);
$("#LegendStatistic1").val(ArrayStatistika[3] + " / " + StringProvidedTotal);
}
if (value == 2) {
var berechne = ArrayStatistika[4] - ArrayStatistika[1];
if (berechne < 0) berechne = 0;
StatisticDesign(ArrayStatistika[1], berechne, StringApproved, StringApprovedTotal);
$("#LegendStatistic2").val(ArrayStatistika[1] + " / " + StringApproved);
$("#LegendStatistic1").val(ArrayStatistika[4] + " / " + StringApprovedTotal);
}
if (value == 3) {
var berechne = ArrayStatistika[5] - ArrayStatistika[2];
if (berechne < 0) berechne = 0;
StatisticDesign(ArrayStatistika[2], berechne, StringFree, StringFreeTotal);
$("#LegendStatistic2").val(ArrayStatistika[2] + " / " + StringFree);
$("#LegendStatistic1").val(ArrayStatistika[5] + " / " + StringFreeTotal);
}
}
function showUsAendern() {
$("#TerminSpeichern").prop('disabled', false);
$("#AenderePopupDivSchalter").val("true");
}
function showUsVerwerfen() {
if ($("#AenderePopupDivSchalter").val() === "true") {
AendereTerminPopup("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").css("display", "block");
$("#KalenderTable").css("display", "none");
$("#KalenderNavigation").css("display", "none");
$("#KalenderTableTask").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").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");
$("#StartDate").val("");
}
function nextDayButtonClick() {
var nextdatum = new Date($("#KalenderDatum").val());
nextdatum.setDate((nextdatum.getDate() + 1));
$("#KalenderDatum").val(toDateStringYearMonthDay(nextdatum));
var newtoday = getDateStringWithLeadingZeros(nextdatum);
$("#KalenderDatumFormat").val(newtoday);
loadAppointments(newtoday);
}
function previousDayButtonClick() {
var nextdatum = new Date($("#KalenderDatum").val());
nextdatum.setDate((nextdatum.getDate() - 1));
$("#KalenderDatum").val(toDateStringYearMonthDay(nextdatum));
var newtoday = getDateStringWithLeadingZeros(nextdatum);
$("#KalenderDatumFormat").val(newtoday);
loadAppointments(newtoday);
}
function selectDate() {
var dp = $("#KalenderDatumFormat").val();
var dateParts = dp.split(".");
var nextdatum2 = new Date(dateParts[2], (dateParts[1] - 1), dateParts[0]);
$("#KalenderDatum").val(toDateStringYearMonthDay(nextdatum2));
$("#KalenderDatumFormat").val(dp);
loadAppointments(dp);
}
array2 = new Array();
appointments = new Array();
function loadAppointments(newtoday) {
$.ajax({
type: "GET",
url: getSelectedKalenderUrl,
data: { newtoday: newtoday },
success: function (json) {
var kalenderRec = $.parseJSON(json);
var html = "";
$("#KalenderTable").empty();
var i = 0;
$.each(kalenderRec, function (index, termin) {
var description = termin.Subject;
var startD = termin.StartDate;
var endD = termin.EndDate;
var date = new Date(startD);
var dateend = new Date(endD);
console.log("" + index + ": " + startD.toString() + " - " + endD.toString());
var farbe = "2B508B";
appointments[termin.SchedulerAppointmentOid] = termin;
html +=
'<tr class="testklasse">' +
'<td class="kalender-td kalender-uhrzeit">' + getHoursAndMinutesWithLeadingZeros(date) + " - " + getHoursAndMinutesWithLeadingZeros(dateend).fontcolor(farbe) + "</td>" +
'<td class="kalender-td" onclick="appointmentOnClick(' + termin.SchedulerAppointmentOid + ')">' + description + "</td>" +
"</tr>";
i++;
});
$("#KalenderTable").append(html);
loadBeWoTask(newtoday);
}
});
}
function appointmentOnClick(appointmentOid) {
if(appointmentOid === null) {
return;
}
var selectedAppointment = appointments[appointmentOid];
if(selectedAppointment.RecurrenceInfo !== null) {
return;
}
var startDate = new Date(selectedAppointment.StartDate);
var endDate = new Date(selectedAppointment.EndDate);
var startTime = getHoursAndMinutesWithLeadingZeros(startDate);
var endTime = getHoursAndMinutesWithLeadingZeros(endDate);
UpdatekalenderOid = selectedAppointment.SchedulerAppointmentOid;
$("#AppointmentEditForm").css("display", "block");
$("#KalenderTable").css("display", "none");
$("#KalenderNavigation").css("display", "none");
$("#KalenderTableTask").css("display", "none");
$("#StartDate").val(getDateStringWithLeadingZeros(startDate));
$("#EndDate").val(getDateStringWithLeadingZeros(endDate));
$("#TerminStartZeit").val(startTime);
$("#TerminEndZeit").val(endTime);
$("#TerminBetreff").val(selectedAppointment.Subject);
$("#TerminNotiz").val(selectedAppointment.Description);
$("#TerminSpeichernAbbrechen").val("Schließen");
$("#TerminSpeichern").val("Speichern");
$("#TerminSpeichern").prop("disabled", true);
$("#TerminSpeichern").css("display", "inline");
$("#InsertAppointmentButton").css("display", "none");
}
function updateSelectedAppointment(){
Updatekalenderbetreff = $("#TerminBetreff").val();
Updatekalendernotice = $("#TerminNotiz").val();
UpdatekalenderstartZ = $("#TerminStartZeit").val();
UpdatekalenderendZ = $("#TerminEndZeit").val();
Updatekalenderday = $("#KalenderDatumFormat").val();
var newEndDate = $("#EndDate").val();
$.ajax({
type: "POST",
url: UpdateKalenderUrl,
data: {
oid: UpdatekalenderOid,
betreff: Updatekalenderbetreff,
notice: Updatekalendernotice,
startZeit: UpdatekalenderstartZ,
endZeit: UpdatekalenderendZ,
day: Updatekalenderday,
endDate: newEndDate
}, success: function() {
var dp = $("#KalenderDatumFormat").val();
var dateParts = dp.split(".");
var nextdatum2 = new Date(dateParts[2], (dateParts[1] - 1), dateParts[0]);
$("#KalenderDatum").val(toDateStringYearMonthDay(nextdatum2));
$("#KalenderDatumFormat").val(dp);
$("#AppointmentEditForm").css("display", "none");
$("#KalenderTable").css("display", "block");
$("#KalenderNavigation").css("display", "block");
$("#KalenderTableTask").css("display", "block");
loadAppointments(dp);
}
});
}
function updateAppointmentOnClick() {
if (checkAppointmentFields()) {
updateSelectedAppointment();
}
}
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();
insertNewAppointment(Kalenderzwischenspeicher[0], Kalenderzwischenspeicher[1], Kalenderzwischenspeicher[2], Kalenderzwischenspeicher[3], Kalenderzwischenspeicher[4], Kalenderzwischenspeicher[5]);
}
}
function checkAppointmentFields() {
var newTerminDatum = $("#StartDate").val();
var newEndDate = $("#EndDate").val();
var newTerminStartZeit = $("#TerminStartZeit").val();
var newTerminEndZeit = $("#TerminEndZeit").val();
var newTerminBetreff = $("#TerminBetreff").val();
if (newTerminDatum === "" || newEndDate === "" || newTerminStartZeit === "" || newTerminEndZeit === "" || newTerminBetreff === "") {
writeFatalErrorMessage("Bitte geben Sie Uhrzeit und Betreff ein.");
return false;
}
return true;
}
function insertNewAppointment(datum, startZ, endZ, betreff, notice, endDate) {
$.ajax({
type: "GET",
url: setSelectedKalenderUrl,
data: {
day: datum,
startZeit: startZ,
endZeit: endZ,
betreff: betreff,
notice: notice,
endDate: endDate
}, success: function () {
$("#AppointmentEditForm").css("display", "none");
$("#KalenderTable").css("display", "block");
$("#KalenderNavigation").css("display", "block");
$("#KalenderTableTask").css("display", "block");
loadAppointments(datum);
}, error: function() {
/*saveOnlyKalender(); Save bei error Kalender daten */
}
});
}
function loadBeWoTask(newtoday) {
$.ajax({
type: "GET",
url: getSelectedKalenderTaskUrl,
data: { newtoday: newtoday },
success: function (json) {
var kalenderRec = $.parseJSON(json);
var html = "";
$("#KalenderTableTask").empty();
var zahl = 0;
$.each(kalenderRec, function (index, termin) {
var description = termin.Title;
var date = new Date(termin.DueDate);
if (zahl === 0) {
html += "<thead><tr><th style='width: 150px; border-bottom: solid 1px #D8D8D8;'>Aufgaben</th><th style='width: 80%; border-bottom: solid 1px #D8D8D8;'></th></tr></thead>";
}
var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes().toString() : date.getMinutes().toString();
var hours = date.getHours() < 10 ? "0" + date.getHours().toString() : date.getHours().toString();
var farbe = "2B508B";
html += '<tr><td style="width: 150px; border-bottom: solid 1px #D8D8D8;">' + hours.fontcolor(farbe) + ":" + minutes.fontcolor(farbe) + ' </td><td style="width: 80%; border-bottom: solid 1px #D8D8D8;">' + description + "</td></tr>";
zahl++;
});
$("#KalenderTableTask").append(html);
}
});
}
var canvas, ctx;
var mouseX, mouseY, mouseDown = 0;
var lastpositionx = 0;
var lastpositiony = 0;
var newpositionx = 0;
var newpositiony = 0;
var minuswert = -20;
var maxwert = 20;
var posix = 0;
var posiy = 0;
function loadUnterschriftFeldFunktion() {
function drawDot(ctx, x, y, size) {
r = 0; g = 0; b = 0; a = 255;
ctx.fillStyle = "rgba(" + r + "," + g + "," + b + "," + (a / 255) + ")";
if (lastpositionx != 0) {
ctx.beginPath();
ctx.arc(x, y, size, 1, Math.PI * 0.25, true);
newpositionx = x;
newpositiony = y;
posix = newpositionx - lastpositionx;
posiy = newpositiony - lastpositiony;
if (posiy > minuswert && posix > minuswert && posiy < maxwert && posix < maxwert) {
ctx.lineTo(lastpositionx + 2, lastpositiony + 2);
ctx.lineWidth = 2;
ctx.lineCap = "butt";
ctx.lineJoin = "round";
ctx.stroke();
lastpositionx = x;
lastpositiony = y;
} else {
lastpositionx = 0;
lastpositiony = 0;
}
ctx.closePath();
ctx.fill();
} else {
ctx.beginPath();
ctx.arc(x, y, size, 1, Math.PI * 0.25, true);
ctx.closePath();
ctx.fill();
lastpositionx = x;
lastpositiony = y;
}
}
function sketchpad_mouseDown() {
mouseDown = 1;
drawDot(ctx, mouseX, mouseY, 3);
}
function sketchpad_mouseUp() {
mouseDown = 0;
}
function sketchpad_mouseMove(e) {
getMousePos(e);
if (mouseDown == 1) {
drawDot(ctx, mouseX, mouseY, 3);
}
}
function getMousePos(e) {
if (!e) {
var e = event;
}
if (e.offsetX) {
mouseX = e.offsetX;
mouseY = e.offsetY;
}
else if (e.layerX) {
mouseX = e.layerX;
mouseY = e.layerY;
}
}
function sketchpad_touchStart() {
getTouchPos();
drawDot(ctx, touchX, touchY, 3);
event.preventDefault();
}
function sketchpad_touchMove(e) {
getTouchPos(e);
drawDot(ctx, touchX, touchY, 3);
event.preventDefault();
}
function getTouchPos(e) {
if (!e) {
var e = event;
}
if (e.touches) {
if (e.touches.length == 1) {
var touch = e.touches[0];
touchX = touch.pageX - touch.target.offsetLeft;
touchY = touch.pageY - touch.target.offsetTop;
}
}
}
function init() {
canvas = document.getElementById('sketchpad');
if (canvas.getContext) {
ctx = canvas.getContext('2d');
}
if (ctx) {
canvas.addEventListener('mousedown', sketchpad_mouseDown, false);
canvas.addEventListener('mousemove', sketchpad_mouseMove, false);
window.addEventListener('mouseup', sketchpad_mouseUp, false);
canvas.addEventListener('touchstart', sketchpad_touchStart, false);
canvas.addEventListener('touchmove', sketchpad_touchMove, false);
}
}
init();
}
function showUnterschrift(Uebergabe, zahl) {
$("#customersDropDown").val($("#customersDropDown option").eq(0).val());
$("#zeiterfassung").css("display", "none");
$("#KalenderNavigation").css("display", "none");
$("#Kalender").css("display", "none");
$("#klienten").css("display", "none");
$("#colorRibbon").css("background-color", "#04b4d0");
$("#UnterschriftBereich").css("display", "block");
$("#Statistics").css("display", "none");
$("#SupportStatistik").css("display", "none");
if (zahl == 1) {
Uebergabe = document.getElementById("ServiceRecordOIDSave").value;
toggleSuccessPopup("");
loadUnterschriftFeldFunktion();
LadeDatenVor(Uebergabe);
} else {
loadUnterschriftFeldFunktion();
LadeDatenVor(Uebergabe);
}
}
function backToZeiterfassung() {
$("#customersDropDown").val($("#customersDropDown option").eq(0).val());
$("#zeiterfassung").css("display", "block");
$("#KalenderNavigation").css("display", "none");
$("#Kalender").css("display", "none");
$("#klienten").css("display", "none");
$("#colorRibbon").css("background-color", "#c80000");
$("#UnterschriftBereich").css("display", "none");
$("#Statistics").css("display", "none");
$("#SupportStatistik").css("display", "none");
loescheUnterschrift(canvas, ctx);
}
function speichereUnterschrift() {
date = "";
date = new Date();
dataURL = "";
dataURL = canvas.toDataURL();
blob = new Blob([dataURL], { type: "URL/String" });
lastpositionx = 0;
lastpositiony = 0;
var dd = date.getDate();
var mm = date.getMonth() + 1;
var yyyy = date.getFullYear();
var hh = date.getHours();
var Min = date.getMinutes();
var Sec = date.getSeconds();
var ddStr = dd < 10 ? "0" + dd : dd;
var mmStr = mm < 10 ? "0" + mm : mm;
var hhStr = hh < 10 ? "0" + hh : hh;
var MnStr = Min < 10 ? "0" + Min : Min;
var ScStr = Sec < 10 ? "0" + Sec : Sec;
newday = "";
newday = ddStr + '.' + mmStr + '.' + yyyy + " " + hhStr + ":" + MnStr + ":" + ScStr;
var serviceRecordOid = $("#SaveRecordOID").val();
//console.log(ServRecord + " das ist die Oid");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition, showError);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
var breitenGrad = "";
var langenGrad = "";
//var breitenGrad = position.coords.latitude;
//var langenGrad = position.coords.longitude;
longrider = "";
//longrider = langenGrad.toString();
//console.log(ServRecord);
$.ajax({
type: "POST",
url: setSelectedUnterschriftUrl,
data: { breitengrad: breitenGrad, langengrad: langenGrad, blob: dataURL, zeitstempel: newday, ServiceRecord: serviceRecordOid },
success: function () {
loescheUnterschrift(canvas, ctx);
backToZeiterfassung();
toggleSuccessPopup("Die Unterschrift wurde erfolgreich gespeichert.", 2);
},
error: function () {
toggleSuccessPopup("Ein Fehler ist aufgetreten. Bitte wenden Sie sich an den Support", 3);
}
});
}
function showError(error) {
var message = "Fehler";
switch (error.code) {
case error.PERMISSION_DENIED:
message = "Ortungsanfrage abgelehnt.";
break;
case error.POSITION_UNAVAILABLE:
message = "Ortsangabe ist nicht verfügbar.";
break;
case error.TIMEOUT:
message = "Timeout.";
break;
case error.UNKNOWN_ERROR:
message = "Ein unbekannter Fehler ist aufgetreten.";
break;
}
//console.log(message);
showPosition(null);
}
//getLocation();
showPosition(null);
}
function loescheUnterschrift(canvas, ctx) {
ctx.clearRect(0, 0, canvas.width, canvas.height);
lastpositionx = 0;
lastpositiony = 0;
}
function LadeDatenVor() {
var zahl = $("#scDropDown").val();
$("#UnterschriftHilfeplan").val("HilfePlan: " + $("#scDropDown option[value='" + zahl + "']").text());
$("#UnterschriftEmployee").val("Mitarbeiter: " + $("#employeesDropDown option:selected").text());
$("#UnterschriftKategorie").val("Kategorie: " + $("#kategorien_select option:selected").text());
$("#UnterschriftLeistung").val("Leistungen: " + $("#leistungen_select option:selected").text());
$("#UnterschriftDatum").val("Datum / Uhrzeit: " + $("#datum_textbox").val() + " / " + $("#start_textbox").val() + " - " + $("#ende_textbox").val());
}
function LadeDatenVor(UebergabeServiceRecord) {
DatenVorladen(UebergabeServiceRecord);
}
function showServiceRecords() {
location.reload();
$("#customersDropDown").val($("#customersDropDown option").eq(0).val());
$("#klientenTabelle").css("display", "none");
$("#zeiterfassung").css("display", "block");
$("#KalenderNavigation").css("display", "none");
$("#klienten").css("display", "none");
$("#Kalender").css("display", "none");
$("#colorRibbon").css("background-color", "#c80000");
$("#UnterschriftBereich").css("display", "none");
$("#Statistics").css("display", "block");
$("#SupportStatistik").css("display", "none");
toggleMenu();
}
function goBackToZeiterfassung() {
showSanduhr();
$("#customersDropDown").val($("#customersDropDown option").eq(0).val());
$("#klientenTabelle").css("display", "none");
$("#zeiterfassung").css("display", "block");
$("#KalenderNavigation").css("display", "none");
$("#klienten").css("display", "none");
$("#Kalender").css("display", "none");
$("#colorRibbon").css("background-color", "#c80000");
$("#UnterschriftBereich").css("display", "none");
$("#Statistics").css("display", "block");
$("#SupportStatistik").css("display", "none");
}
function klientenLaden() {
$("#map-canvas").fadeOut();
showSanduhr();
var oid = parseInt($("#customersDropDown").find(":selected").val());
if (oid == -1) {
$("#klientenTabelle").css("display", "none");
$("#umfeldContainer").css("display", "none");
hideSanduhr();
return;
}
makeAjaxCall("GET", getSelectedCustomerUrl, function (json) {
$("#klientenTabelle").css("display", "block");
$("#umfeldContainer").css("display", "block");
if (json == "SessionTimeout") {
window.location.href = 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.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);
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 l = 0;
var h = 0;
var n = 0;
$(".eigenschaftsdiv").each(
function (i, e) {
var x = $(e).clone().css({ "height": "auto", "width": "auto" }).appendTo("body");
var tempL = x.outerWidth(true);
var tempH = x.outerHeight(true);
x.remove();
n++;
if (tempL > l) {
l = tempL;
}
if (tempH > h) {
h = tempH;
}
}
);
minSizes = { minWidth: l, minHeight: h, divCount: n };
}
function updateEigenschaftsfelder() {
var cw = $("#klientenTabelle").width();
$("#map-canvas").css("width", cw - 16);
$("#map-canvas").css("height", cw - 16);
if (minSizes == undefined)
return;
var mitPadding = minSizes.minWidth;
var maxAnzahl = parseInt(cw / mitPadding);
if (maxAnzahl > minSizes.divCount)
maxAnzahl = minSizes.divCount;
var width = parseInt(cw / maxAnzahl) - 16;
if (minSizes != undefined) {
$(".eigenschaftsdiv").each(
function (i2, e2) {
$(e2).css("width", width + "px");
$(e2).css("height", (minSizes.minHeight - 16) + "px");
}
);
}
}
$(window).resize(function () {
if ($("#klientenTabelle").css("display") === "block") {
updateEigenschaftsfelder();
}
});
function showSanduhr() {
$(".modalWrapper").css("display", "block");
$(".modalWrapper").css("height", $(document).height());
$(".warte-animation").css("display", "inline-block");
}
function hideSanduhr() {
if ($("#errorPopupDiv").css("display") == "none" && $("#popupDiv").css("display") == "none") {
$(".modalWrapper").css("display", "none");
$(".modalWrapper").css("height", "0");
}
if ($("#SuccessPopupDiv").css("display") == "none" && $("#popupDiv").css("display") == "none") {
$(".modalWrapper").css("display", "none");
$(".modalWrapper").css("height", "0");
}
if ($("#AendernPopupDiv").css("display") == "none" && $("#popupDiv").css("display") == "none") {
$(".modalWrapper").css("display", "none");
$(".modalWrapper").css("height", "0");
}
$(".warte-animation").css("display", "none");
}
function submitDeletionForm() {
showSanduhr();
$("#deletionForm").submit();
}
function toggleErrorPopup(errorMessage, i , zeit) {
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('')";
DeletStorage(1);
//SaveOnly(); // Speichere Daten bei absturz
}
else {
$("#errorPopupTitle").text("Fehler");
$("#errorPopupOkBtn").onclick = "toggleErrorPopup('')";
}
var h = 0;
var t = $("#errorPopupTitle").outerHeight();
var u = $("#errorPopupText").outerHeight();
var v = $("#errorPopupBtnDiv").outerHeight();
var w = $("#errorPopupOkBtn").outerHeight();
h += t + u + v + w + w;
$("#errorPopupDiv").css("height", h + "px");
$("#errorPopupDiv").css("top", window.pageYOffset + window.innerHeight / 2 - h / 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 h = 0;
var t = $("#SuccessPopupTitle").outerHeight();
var u = $("#SuccessPopupText").outerHeight();
var v = $("#SuccessPopupBtnDiv").outerHeight();
var w = $(".SuccessPopupOkBtn").outerHeight();
var x = $(".SuccessPopupUSchrift").outerHeight();
h += t + u + v + w + x;
$("#SuccessPopupDiv").css("height", h + "px");
$("#SuccessPopupDiv").css("top", window.pageYOffset + window.innerHeight / 2 - h / 2);
$("#SuccessPopupDiv").css("margin-top", "0");
} else {
$("#SuccessPopupDiv").css("margin-top", "auto");
}
}
function AendereTerminPopup(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 h = 0;
var t = $("#AendernPopupTitle").outerHeight();
var u = $("#AendernPopupText").outerHeight();
var v = $("#AendernPopupBtnDiv").outerHeight();
var w = $(".AendernPopupOkBtn").outerHeight();
var x = $(".AendernPopupUSchrift").outerHeight();
h += t + u + v + w + x;
$("#AendernPopupDiv").css("height", h + "px");
$("#AendernPopupDiv").css("top", window.pageYOffset + window.innerHeight / 2 - h / 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 mitarbeiterLaden() {
var oid = parseInt($("#employeesDropDown").find(":selected").val());
if (isNaN(oid)) {
return;
}
serviceRecordEmployeeOid = oid;
makeAjaxCall("GET", setServiceRecordEmployeeUrl, function () { }, { employeeOid: serviceRecordEmployeeOid }, null);
}
function SaveOnly() {
if (navigator.onLine == true) {
if(typeof (Storage) != "undefined") {
DeletStorage(1);
var zahl = $("#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();
}
ZeiterfassungDatakonstrukt.push(zahl, hilfeplan, mitarbeiter, kategorie,
leistung, $("#datum_textbox").val(), $("#start_textbox").val(), $("#ende_textbox").val(),
duration, notiz, zahl, notiz2, notiz3, notiz4, notiz5, $("#enddatum_textbox").val());
localStorage.setItem("Zeitdaten", ZeiterfassungDatakonstrukt);
}
} else {
if (typeof (Storage) != "undefined") {
DeletStorage(1);
var zahl = $("#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").text();
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();
}
ZeiterfassungDatakonstrukt.push(zahl, hilfeplan, mitarbeiter, kategorie,
leistung, $("#datum_textbox").val(), $("#start_textbox").val(), $("#ende_textbox").val(),
duration, notiz, zahl, notiz2, notiz3, notiz4, notiz5, $("#enddatum_textbox").val());
localStorage.setItem("Zeitdaten", ZeiterfassungDatakonstrukt);
}
}
}
function DeletStorage(i) {
if(i === 1) {
localStorage.removeItem("Zeitdaten");
}
if(i === 2) {
localStorage.removeItem("Kalenderdaten");
}
}
function saveOnlyKalender() {
if (navigator.onLine) {
DeletStorage(2);
var TerminDatum = Kalenderzwischenspeicher[0];
var TerminStratZeit = Kalenderzwischenspeicher[1];
var TerminEndZeit = Kalenderzwischenspeicher[2];
var TerminBetreff = Kalenderzwischenspeicher[3];
var TerminNotiz = Kalenderzwischenspeicher[4];
KalenderDatakonstrukt.push(TerminDatum, TerminStratZeit, TerminEndZeit, TerminBetreff, TerminNotiz);
localStorage.setItem("Kalenderdaten", KalenderDatakonstrukt);
location.reload();
}
}
function insertNewAppointmentfterCrash(Datum, StartZ, EndZ, Betreff, Notice) {
$.ajax({
type: "GET",
url: setSelectedKalenderUrl,
data: { day: Datum, startZeit: StartZ, endZeit: EndZ, betreff: Betreff, notice: Notice }, success: function () { }, error: function () { }
});
}
function saveZeiterfassungAfterCrash(datum,startd,endd,dauer,doku,leistung, oid, doku2,doku3,doku4,doku5,enddatum) {
var x = getDateObj(true);
var y = getDateObj(false);
var vonDatum = getDateTimeStringWithLeadingZeros(x);
var bisDatum = getDateTimeStringWithLeadingZeros(y);
if (oid == -2) {
$.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 () { }
});
} else {
$.ajax({
type: "GET",
url: CheckRightsAfterCrashUrl,
data: { von: vonDatum, bis: bisDatum, inEditMode: false, dateString: datum, startString: startd, endString: endd, costbearerOId: oid, leistung:leistung},
success: function (json) {
var x = json;
if (x == "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 {
DeletStorage(1);
setTimeout(function () {
$("#scDropDown option[value='" + oid + "']").attr('selected', true).trigger("change");
}, 4500);
}
}, error: function () {
DeletStorage(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");
}
});
}
}
function LoadOnly(i, x) {
var zeitdata = localStorage.getItem("Zeitdaten");
var kalenderdata = localStorage.getItem("Kalenderdaten");
if (zeitdata != null || kalenderdata != null) {
if (zeitdata && i == 1) {
var zeit = zeitdata.split(",");
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);
showServiceRecords();
}, SetTimeoutTime);
}
}
if (kalenderdata && x == 2) {
var kalezeit = kalenderdata.split(",");
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);
setTimeout(function(){
insertNewAppointmentfterCrash(kalezeit[0], kalezeit[1], kalezeit[2], kalezeit[3], kalezeit[4]);
DeletStorage(2);
showServiceRecords();
}, SetTimeoutTime);
}
}
}
}
function ErrorZeiterfassungAfterCrash() {
var errorwert = 1;
if (document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == 1 || document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == null || document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == 0) {
// Es soll nix passieren
console.log("Bin in error zeiterfassung ");
} 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);
setTimeout(function(){
$.ajax({
type: "GET",
url: ErrorZeiterfassungAnzeigenUrl,
data: { errorwert: errorwert }
});
}, SetTimeoutTime);
} 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);
setTimeout(function(){
$.ajax({
type: "GET",
url: ErrorZeiterfassungAnzeigenUrl,
data: { errorwert: errorwert }
});
}, SetTimeoutTime);
} 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);
setTimeout(function(){
$.ajax({
type: "GET",
url: ErrorZeiterfassungAnzeigenUrl,
data: { errorwert: errorwert }
});
}, SetTimeoutTime);
} 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);
setTimeout(function(){
$.ajax({
type: "GET",
url: ErrorZeiterfassungAnzeigenUrl,
data: { errorwert: errorwert }
});
}, SetTimeoutTime);
}
}
function aktualDurationwithEndDate() {
if ($("#enddatum_textbox").val() != "") {
if ($("#enddatum_textbox").val() != $("#datum_textbox").val()) {
var a = getEndDateObj().getDate();
var sum = a - getDateObj().getDate();
var et = $("#ende_textbox").val();
var st = $("#start_textbox").val();
var duri = et - st;
var rest = duri % 100;
duri = duri - rest;
duri = duri / 100 * 60;
var enddur = sum * 24 * 60 + duri + rest;
$("#duration_textbox").val(enddur).trigger("change");
}
}
}
function getEndDateObj() {
var 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];
var date = new Date();
if (!isNaN(dd) && !isNaN(mm) && !isNaN(yyyy)) {
date = new Date(yyyy, mm - 1, dd);
}
var ds = $("#ende_textbox").val();
if (ds != "") {
hm = stringToTime(ds);
}
date.setHours(hm[0]);
date.setMinutes(hm[1]);
return date;
}
function focusOnTab(x) {
if (x === 1) {
setTimeout(function () {
$("#notiz_textbox1").focus();
focusedDokuTextarea = $("#notiz_textbox1");
}, 100);
}
if (x === 2) {
setTimeout(function () {
$("#notiz_textbox2").focus();
focusedDokuTextarea = $("#notiz_textbox2");
}, 100);
}
if (x === 3) {
setTimeout(function () {
$("#notiz_textbox3").focus();
focusedDokuTextarea = $("#notiz_textbox3");
}, 100);
}
if (x === 4) {
setTimeout(function () {
$("#notiz_textbox4").focus();
focusedDokuTextarea = $("#notiz_textbox4");
}, 100);
}
if (x === 5) {
setTimeout(function () {
$("#notiz_textbox5").focus();
focusedDokuTextarea = $("#notiz_textbox5");
}, 100);
}
}