294 lines
8.7 KiB
JavaScript
294 lines
8.7 KiB
JavaScript
function preselectCustomer() {
|
|
$.ajax({
|
|
type: "GET",
|
|
url: window.getSupportConceptCustomerUrl,
|
|
success: function (json) {
|
|
if (json === "NoSupportConceptSelected") {
|
|
return;
|
|
}
|
|
|
|
var valueToSelect = $.parseJSON(json);
|
|
|
|
$("#customersDropDown option").each(function () {
|
|
|
|
if (this.value === valueToSelect.toString() === true) {
|
|
$("#customersDropDown").val(valueToSelect);
|
|
$("#customersDropDown").trigger("change");
|
|
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function loadCustomer() {
|
|
$("#map-canvas").fadeOut();
|
|
|
|
showSanduhr();
|
|
|
|
var oid = parseInt($("#customersDropDown").find(":selected").val());
|
|
|
|
if (oid === -1) {
|
|
$("#klientenTabelle").hide();
|
|
$("#umfeldContainer").hide();
|
|
$("#kommentarContainer").hide();
|
|
$("#aktenzeichenContainer").hide();
|
|
|
|
hideSanduhr();
|
|
|
|
return;
|
|
}
|
|
|
|
makeAjaxCall("GET", getSelectedCustomerUrl, function (json) {
|
|
$("#klientenTabelle").show();
|
|
$("#umfeldContainer").show();
|
|
$("#kommentarContainer").show();
|
|
$("#aktenzeichenContainer").show();
|
|
|
|
if (json === "SessionTimeout") {
|
|
window.location.href = window.redirectLink;
|
|
return;
|
|
}
|
|
|
|
vm.update($.parseJSON(json));
|
|
|
|
$(".toggle-btn2").click(function () {
|
|
toggleOnclick(this);
|
|
});
|
|
|
|
},
|
|
{
|
|
customerOid: oid
|
|
},
|
|
hideSanduhr);
|
|
}
|
|
|
|
function CustomerVM() {
|
|
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.aktenzeichenMitNotiz = ko.observableArray([]);
|
|
|
|
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); });
|
|
|
|
var mappedAktenzeichen = $.map(data.ReferenceNumbers, function (item) { return new AktenzeichenMitNotiz(item); });
|
|
|
|
if (mappedUmfeldpersonen.length === 0) {
|
|
$("#WohnheimContainer").css("display", "none");
|
|
}
|
|
|
|
this.umfeldpersonen(mappedUmfeldpersonen);
|
|
this.aktenzeichenMitNotiz(mappedAktenzeichen);
|
|
|
|
calcPropFieldMinSizes();
|
|
updateEigenschaftsfelder();
|
|
};
|
|
}
|
|
|
|
function AktenzeichenMitNotiz(referenceNumberAndNotice) {
|
|
var self = this;
|
|
|
|
self.aktenzeichen = ko.observable(referenceNumberAndNotice.ReferenceNumber);
|
|
self.notiz = ko.observable(referenceNumberAndNotice.Notice);
|
|
self.kostentraeger = ko.observable(referenceNumberAndNotice.Costbearer);
|
|
|
|
self.update = function (updateData) {
|
|
self.aktenzeichen(updateData.ReferenceName);
|
|
self.notice(updateData.Notice);
|
|
self.kostentraeger(updateData.Costbearer);
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
});
|
|
|
|
$(document).ready(function () {
|
|
if ($("#klienten").length === 0) {
|
|
return;
|
|
}
|
|
|
|
var count = 0;
|
|
|
|
if (typeof vm !== "undefined") {
|
|
count = vm.vorname.getSubscriptionsCount();
|
|
}
|
|
|
|
vm = new CustomerVM();
|
|
|
|
if (count === 0) {
|
|
ko.applyBindings(vm);
|
|
}
|
|
|
|
$("#map-canvas").css("width", $("#klientenTabelle").width());
|
|
$("#map-canvas").css("height", "500px");
|
|
$("#colorRibbon").css("background-color", "#3b7799");
|
|
|
|
$("#customersDropDown").val($("#customersDropDown option").eq(0).val());
|
|
|
|
preselectCustomer();
|
|
});
|
|
|
|
function karteAnzeigen() {
|
|
var blubb = $("#adressfeld").html().split(' ');
|
|
|
|
var strString = "";
|
|
for (var it = 0; it < blubb.length; it++) {
|
|
strString += blubb[it];
|
|
|
|
if (it < blubb.length - 1) {
|
|
strString += "+";
|
|
}
|
|
}
|
|
|
|
strString += ',' + $("#plzfeld").html() + $("#ortfeld").html();
|
|
|
|
window.open("https://www.google.de/maps/place/" + strString);
|
|
} |