324 lines
12 KiB
JavaScript
324 lines
12 KiB
JavaScript
function initializeYearAndMonths() {
|
|
calculateDays();
|
|
}
|
|
|
|
function initializeReportView() {
|
|
checkForExistingSignature();
|
|
|
|
qbFilterSelectionChange();
|
|
|
|
filterCheckBoxChange();
|
|
}
|
|
|
|
function calculateDays() {
|
|
var month = $("#month-select option:selected").val();
|
|
var year = $("#year-select option:selected").val();
|
|
|
|
var monthInt = parseInt(month, 10) - 1;
|
|
|
|
var begin = moment(new Date(year, monthInt, 1)).date();
|
|
var end = moment(new Date(year, monthInt, 1)).add(1, "months").add(-1, "days").date();
|
|
|
|
$("#start-day-select").empty();
|
|
$("#end-day-select").empty();
|
|
|
|
for (var i = begin; i <= end; i++) {
|
|
var option = new Option(i, i);
|
|
var option2 = new Option(i, i);
|
|
|
|
$("#start-day-select").append(option);
|
|
$("#end-day-select").append(option2);
|
|
}
|
|
|
|
$("#start-day-select").val(1);
|
|
$("#end-day-select").val(end);
|
|
|
|
var startDay = $("#start-day-select option:selected").val();
|
|
var endDay = $("#end-day-select option:selected").val();
|
|
|
|
if(startDay === 0 || endDay === 0 || year === 0 || month === 0 || areUndefinedOrNull([month, year, startDay, endDay])) {
|
|
return;
|
|
}
|
|
|
|
var changeDateSelectionUrl = getChangeDateSelectionUrl();
|
|
|
|
$.get(changeDateSelectionUrl, { startDayString: startDay, endDayString: endDay, monthString: month, yearString: year});
|
|
}
|
|
|
|
function initializeReportSignature(overwrite) {
|
|
$("#report-form-container").hide();
|
|
$("#report-signature-container").addClass("d-block");
|
|
|
|
if(overwrite) {
|
|
$("#overwriting-employee-signature-alert").addClass("d-block");
|
|
}
|
|
|
|
var text = $("#signature-canvas-information").val();
|
|
|
|
var serviceRecordCount = $("#service-record-count").val();
|
|
|
|
$("#report-info-column").html("Unterschrift für " + serviceRecordCount + " erbrachte Leistungen von " + text);
|
|
|
|
resizeCanvas("#report-sketch-pad", "#report-canvas-row");
|
|
|
|
var canvas = document.getElementById("report-sketch-pad");
|
|
|
|
var signaturePad = new SignaturePad(canvas, { backgroundColor: "rgba(255, 255, 255, 0)" });
|
|
|
|
var saveButton = document.getElementById("save-report-signature-btn");
|
|
var clearButton = document.getElementById("clear-report-canvas-btn");
|
|
var cancelButton = document.getElementById("cancel-report-signature-btn");
|
|
|
|
saveButton.addEventListener("click", function() {
|
|
var clonedCanvas = trimCanvas(cloneCanvas(document.getElementById("report-sketch-pad")));
|
|
|
|
var context = clonedCanvas.getContext("2d");
|
|
context.globalCompositeOperation = "destination-over";
|
|
context.fillStyle = "white";
|
|
context.fillRect(0, 0, clonedCanvas.width, clonedCanvas.height);
|
|
|
|
var dataUrl = clonedCanvas.toDataURL("image/png");
|
|
|
|
showMessagePopupWithCallback("Unterschrift speichern", "Mit dem Speichern der Unterschrift ist es nicht mehr möglich, die betroffenen Einträge der Zeiterfassung zu ändern.", function() {
|
|
showSpinner();
|
|
|
|
var signatureCreationUrl = getCreateSignatureForServiceOverviewUrl();
|
|
|
|
showSpinner();
|
|
|
|
$.post(signatureCreationUrl, { base64SignatureString: dataUrl, customerOidString: null, isCustomerSignature: false, overwrite: overwrite }).done(function(json) {
|
|
hideSpinner();
|
|
|
|
if(isEmptyOrSpaces(json)) {
|
|
// Ist umbenannt in report-signature-container
|
|
$("#signature-container").removeClass("d-block");
|
|
$("#main-container, #checkbox-container").show();
|
|
showMessagePopupWithCallback("Unterschrift", "Die Unterschrift wurde erfolgreich gespeichert.", function() {
|
|
showSpinner();
|
|
location.reload();
|
|
}, true);
|
|
} else {
|
|
showMessagePopup("Fehler", json);
|
|
signaturePad.clear();
|
|
}
|
|
});
|
|
}, false);
|
|
});
|
|
|
|
clearButton.addEventListener("click", function() {
|
|
signaturePad.clear();
|
|
});
|
|
|
|
cancelButton.addEventListener("click", function() {
|
|
showMessagePopupWithCallback("Unterschrift", "Sind Sie sicher, dass Sie die Unterschrift nicht speichern möchten?",
|
|
function() {
|
|
$("#report-signature-container").removeClass("d-block");
|
|
$("#report-form-container").show();
|
|
|
|
signaturePad.clear();
|
|
}, false);
|
|
});
|
|
}
|
|
|
|
function confirmReportSignatureCancellation() {
|
|
showMessagePopupWithCallback("Unterschrift", "Sind Sie sicher, dass Sie die Unterschrift nicht speichern möchten?",
|
|
function() {
|
|
$("#report-signature-container").removeClass("d-block");
|
|
$("#report-form-container").show();
|
|
|
|
var canvas = document.getElementById("sketch-pad");
|
|
var context = canvas.getContext("2d");
|
|
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
|
|
}, false);
|
|
}
|
|
|
|
function onMonthOrYearChange() {
|
|
calculateDays();
|
|
|
|
checkForExistingSignature();
|
|
}
|
|
|
|
function checkForExistingSignature() {
|
|
var month = $("#month-select option:selected").val();
|
|
var year = $("#year-select option:selected").val();
|
|
var startDay = $("#start-day-select option:selected").val();
|
|
var endDay = $("#end-day-select option:selected").val();
|
|
|
|
if(startDay === 0 || endDay === 0 || year === 0 || month === 0 || areUndefinedOrNull([month, year, startDay, endDay])) {
|
|
return;
|
|
}
|
|
|
|
var changeDateSelectionUrl = getChangeDateSelectionUrl();
|
|
|
|
$.get(changeDateSelectionUrl,
|
|
{
|
|
startDayString: startDay,
|
|
endDayString: endDay,
|
|
monthString: month,
|
|
yearString: year
|
|
});
|
|
}
|
|
|
|
function qbFilterSelectionChange() {
|
|
/*
|
|
* 0: Für alle Klienten
|
|
* 1: Für Klienten meiner Teams
|
|
* 2: Für meine Klienten
|
|
* 3: Klienten auswählen
|
|
* 4: Team auswählen
|
|
*/
|
|
|
|
var selectedOption = $("#qb-filter-select option:selected").val();
|
|
|
|
switch(selectedOption) {
|
|
case "3":
|
|
$("#team-selection-container").removeClass("d-block");
|
|
$("#team-selection-container").addClass("d-none");
|
|
|
|
$("#customer-selection-container").removeClass("d-none");
|
|
$("#customer-selection-container").addClass("d-block");
|
|
break;
|
|
case "4":
|
|
$("#customer-selection-container").removeClass("d-block");
|
|
$("#customer-selection-container").addClass("d-none");
|
|
|
|
$("#team-selection-container").removeClass("d-none");
|
|
$("#team-selection-container").addClass("d-block");
|
|
break;
|
|
default:
|
|
$("#customer-selection-container, #team-selection-container").removeClass("d-block");
|
|
$("#customer-selection-container, #team-selection-container").addClass("d-none");
|
|
break;
|
|
}
|
|
|
|
var selectedFilterEnumUrl = getSetQbFilterEnumUrl();
|
|
|
|
$.get(selectedFilterEnumUrl, { filterEnumString: selectedOption});
|
|
}
|
|
|
|
function filterCheckBoxChange() {
|
|
var changeFiltersUrl = getChangeFiltersUrl();
|
|
|
|
var isEmployeeSelected = $("#selected-employee-cb").is(":checked");
|
|
var isOrganisationSelected = $("#selected-organisation-cb").is(":checked");
|
|
var isCategorySelected = $("#selected-category-cb").is(":checked");
|
|
|
|
var employeeOid = isEmployeeSelected ? $("#employee-select option:selected").val() : null;
|
|
var organisationOid = isOrganisationSelected ? $("#organisation-select option:selected").val() : null;
|
|
var categoryOid = isCategorySelected ? $("#category-select option:selected").val() : null;
|
|
|
|
$.get(changeFiltersUrl,
|
|
{
|
|
employeeOidStr: employeeOid,
|
|
organisationOidStr: organisationOid,
|
|
categoryOidStr: categoryOid
|
|
});
|
|
}
|
|
|
|
function onCustomerSelectionChange() {
|
|
var url = getSetCustomerUrl();
|
|
|
|
var selectedCustomerOid = $("#customers-drop-down option:selected").val();
|
|
|
|
$.get(url, { customerOid: selectedCustomerOid}).done(function() {
|
|
checkForExistingSignature();
|
|
});
|
|
}
|
|
|
|
function openCustomerSignaturePopup(numberOfEntries, customerName, timeSpan, customerOid, overwrite) {
|
|
// Popup anzeigen
|
|
$("#report-form-container").hide();
|
|
|
|
$("#report-customer-signature-container").addClass("d-block");
|
|
|
|
$("#report-customer-info-column").html("Unterschrift für " + numberOfEntries + " erbrachte Leistungen von " + customerName + " (" + timeSpan + ")");
|
|
|
|
if (overwrite) {
|
|
$("#overwriting-customer-signature-alert").addClass("d-block");
|
|
}
|
|
|
|
resizeCanvas("#report-customer-sketch-pad", "#report-customer-canvas-row");
|
|
|
|
var canvas = document.getElementById("report-customer-sketch-pad");
|
|
|
|
var signaturePad = new SignaturePad(canvas, { backgroundColor: "rgba(255, 255, 255, 0)" });
|
|
|
|
var saveButton = document.getElementById("save-report-customer-signature-btn");
|
|
var clearButton = document.getElementById("clear-report-customer-canvas-btn");
|
|
var cancelButton = document.getElementById("cancel-report-customer-signature-btn");
|
|
|
|
saveButton.addEventListener("click", function() {
|
|
var clonedCanvas = trimCanvas(cloneCanvas(document.getElementById("report-customer-sketch-pad")));
|
|
|
|
var context = clonedCanvas.getContext("2d");
|
|
context.globalCompositeOperation = "destination-over";
|
|
context.fillStyle = "white";
|
|
context.fillRect(0, 0, clonedCanvas.width, clonedCanvas.height);
|
|
|
|
var dataUrl = clonedCanvas.toDataURL("image/png");
|
|
|
|
showMessagePopupWithCallback("Unterschrift speichern", "Mit dem Speichern der Unterschrift ist es nicht mehr möglich, die betroffenen Einträge der Zeiterfassung zu ändern.",
|
|
function() {
|
|
var url = getCreateSignatureForServiceOverviewUrl();
|
|
|
|
$.post(url, { base64SignatureString: dataUrl, customerOidString: customerOid, isCustomerSignature: true, overwrite: overwrite }).done(function(json) {
|
|
hideSpinner();
|
|
|
|
if(isEmptyOrSpaces(json)) {
|
|
showMessagePopupWithCallback("Unterschrift",
|
|
"Die Unterschrift wurde erfolgreich gespeichert.",
|
|
function() {
|
|
showSpinner();
|
|
location.reload();
|
|
},
|
|
true);
|
|
} else {
|
|
showMessagePopup("Fehler", json);
|
|
signaturePad.clear();
|
|
}
|
|
});
|
|
},
|
|
false);
|
|
});
|
|
|
|
clearButton.addEventListener("click", function() {
|
|
signaturePad.clear();
|
|
});
|
|
|
|
cancelButton.addEventListener("click", function() {
|
|
showMessagePopupWithCallback("Unterschrift", "Sind Sie sicher, dass Sie die Unterschrift nicht speichern möchten?",
|
|
function() {
|
|
$("#report-customer-signature-container").removeClass("d-block");
|
|
$("#overwriting-customer-signature-alert").removeClass("d-block");
|
|
$("#report-form-container").show();
|
|
|
|
signaturePad.clear();
|
|
}, false);
|
|
});
|
|
}
|
|
|
|
function showCustomerSignature(signatureOid) {
|
|
loadConfirmationReceiptSignature(signatureOid);
|
|
}
|
|
|
|
function loadConfirmationReceiptSignature(signatureOid) {
|
|
var url = getLoadConfirmationReceiptSignatureUrl();
|
|
|
|
$.get(url, { signatureOidString: signatureOid }).done(function(json) {
|
|
$("#signature-img-popup").addClass("d-block");
|
|
|
|
$("#signature-holder-img").prop("src", json);
|
|
});
|
|
}
|
|
|
|
function hideConfirmationReceiptSignature() {
|
|
$("#signature-img-popup").removeClass("d-block");
|
|
$(".modal-backdrop").hide();
|
|
}
|
|
|
|
function showEmployeeSignature(signatureOid) {
|
|
$("#employee-signature-list").hide();
|
|
|
|
loadConfirmationReceiptSignature(signatureOid);
|
|
} |