class ArticleGroup { constructor(idx, description) { this.idx = idx; this.description = description; } } class Booking { constructor(itemnbr, amount,credit, subitems) { this.itemnbr = itemnbr; this.amount = amount; this.credit = credit; this.subitems = subitems; } create = function (obj) { var t = new Booking(); for (var prop in obj) { if (t.hasOwnProperty(prop)) { t[prop] = obj[prop]; } } return t; } } class BlockSlot { constructor(itemnbr, subitem, time) { this.itemnbr = itemnbr; this.subitem = subitem; this.time = time; } } class SubItem { constructor(amount,time, subitemnbr) { this.amount = amount; this.time = time; this.subitemnbr = subitemnbr; this.isOption = false; this.nfp = false; this.persons = []; } } class Warenkorb{ constructor() { this.articles = []; this.tage = []; this.actDate = ""; this.actTime = ""; this.actTimeEnd = ""; this.rabattCode=undefined; this.wertkarte=undefined; } hasDay(tag) { var returnval = false; this.tage.forEach(function(row) { if(row.date == tag) { returnval= true; } }); return returnval; } getDay(tag) { var returndate = UNDEF; this.tage.forEach(function(row) { if(row.date == tag) { returndate= row; } }); return returndate; } addTag(tag) { var self = this; $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "addTag", "tag":tag}, method: POST, async: false, success: function(e) { if(e == "1") { self.actDate=tag; if(!self.hasDay(tag)) { var t = new Tag(tag); self.addTagObject(t); } } } }); } addTagObject(tag) { var add = this.tage.length==0; if(add == false) { add=true; this.tage.forEach(function(row) { if(row.date == tag.date) { add=false; } }); } if(add) { this.tage.push(tag); } } addTimes(zeit, zeitEnde) { var self = this; $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "addTimes", "zeit":zeit, "zeitEnde": zeitEnde}, method: POST, async: false, success: function(e) { if(e == "1") { self.tage.forEach(function(row) { if(row.date == self.actDate) { self.actTime = zeit; self.actTimeEnd= zeitEnde; row.addZeit(zeit, zeitEnde); } }, self); } } }); } removeTag(index) { if(this.tage != UNDEF) { this.tage.splice(index,1); } } addArticle(article) { this.articles.push(article); } insertArticleZumZeitpunkt(article, index) { var self = this; $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "addArticleZumZeitpunkt", "article":article.itemnbr, "amount":article.amount}, method: POST, async: false, success: function(e) { if(e == "1") { if(self.getDay(self.actDate)!= UNDEF) { if(self.getDay(self.actDate).getZeit(self.actTime, self.actTimeEnd)!= UNDEF) { self.getDay(self.actDate).getZeit(self.actTime, self.actTimeEnd).insertArticle(article, index); }else { console.log("notime"); } } else { console.log("noday"); } } } }); } addArticleZumZeitpunkt(article) { var amount = 0; var self = this; $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "addArticleZumZeitpunkt", "article":article.itemnbr, "amount":article.amount, "subitem":article.subItem }, method: POST, async: false, success: function(e) { if(e == "1") { if(article.isWertkartenArtikel()==false) { } else { article.credit = article.amount; article.amount = 1; } if(self.getDay(self.actDate)!= UNDEF) { if(self.getDay(self.actDate).getZeit(self.actTime, self.actTimeEnd)!= UNDEF) { self.getDay(self.actDate).getZeit(self.actTime, self.actTimeEnd).addArticle(article); amount+=article.amount; console.log("hier2", amount); } else { console.log("notime"); } } else { console.log("noday"); } } else if(e == "-1") { amount-=1; } else { console.log("e", e); } } }); return amount; } removeArticleZumZeitpunkt(itemnbr,subItem=0) { var self = this; $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "removeArticleZumZeitpunkt", "article":itemnbr, "subItem":subItem}, method: POST, async: false, success: function(e) { if(e == "1") { if(self.getDay(self.actDate)!= UNDEF) { if(self.getDay(self.actDate).getZeit(self.actTime, self.actTimeEnd)!= UNDEF) { self.getDay(self.actDate).getZeit(self.actTime, self.actTimeEnd).removeArticle(itemnbr,subItem); }else { console.log("notime"); } } else { console.log("noday"); } } } }); } getAmountAnyArticles() { var returnval = 0; for(var i = 0;i0; if(returnval)return true; for(var i = 0;i=0) { this.articles.splice(index,1); } } } decreaseArticle(itemnbr, subItem = 0) { if(this.articles != UNDEF) { for(var i = 0;i0; if(returnval)return true; for(var i = 0;i0; } getAllArticle() { return this.articles; } getAllPersons() { var returnval = []; this.articles.forEach(function(article) { returnval = returnval.concat(article.getAllPersons()); }); return returnval; } getAmountAnyArticles() { var returnval = 0; for(var i = 0;i=0) { this.articles.splice(index,1); } } } decreaseArticle(itemnbr, subItem = 0) { if(this.articles != UNDEF) { for(var i = 0;i=td && gebThisYear<= ttDate) { before6Years = this.addDays(1,this.subtractYears (6,new Date(gebThisYear))); before17Years = this.addDays(1,this.subtractYears (18,new Date(gebThisYear))); } if(this.customerRequired ==2 && gebdat >= before6Years) //Kind bis 6 jahre { return true; } else if(this.customerRequired==3 && gebdat= before17Years) // Jugendlich (7-17) { return true; } else if(this.customerRequired==4 && gebdat= before17Years) //(0-17) { return true; } else if(this.customerRequired==6 && gebdat < before6Years) //7+ { return true; } } return false; } subtractYears (numOfYears, date = new Date()) { date.setFullYear(date.getFullYear() - numOfYears); return date; } addDays (numOfDays, date = new Date()) { date.setDate(date.getDate() + numOfDays); return date; } create = function (obj) { var t = new Article(); for (var prop in obj) { if (t.hasOwnProperty(prop)) { t[prop] = obj[prop]; } } return t; } init() { for(var i = 0;i= 9) { var ticketcode = x.substring(9); setWS(WS_TC, ticketcode); var ja = getWS("JOINACTION"); if(ja == UNDEF) { ja = 0; } $.ajax({ url: PHP_TCHECK, cache: false, data: { "ticketcode": getWS(WS_TC), "ja":ja}, method: POST, success: function(r) { if(r == "-1") { setWS(WS_NEXTP, P_TICKET + "=" + getWS(WS_TC)); navigate(P_LOGIN); } else if(r == "-2" || r == -2) { setWS(WS_NEXTP, x); navigate(P_LOGIN); } else { $(T_CONTENT).html(r); setWS(WS_TC, ""); $('.startBooking').click(function () { var id = $(this).data(PID); if(!isNullOrEmpty(id)) { setWS(WS_PWC, id); navigate(P_BOOKING); } }); } $('.joinaction').click(function () { setWS("JOINACTION", 1);location.reload();}); } }); } else { navigate(P_BOOKING); } } else if(x.startsWith(P_TICKET)) { if(x.length >= 8) { var ticketcode = x.substring(8); setWS(WS_TC, ticketcode); user = setUserFromWS(); if(user != UNDEF && isLogedIn()) { $.ajax({ url: PHP_TCHECK, cache: false, data: { "ticketcode": getWS(WS_TC)}, method: POST, success: function(r) { if(r == "-1") { setWS(WS_NEXTP, x); navigate(P_LOGIN); } else { $(T_CONTENT).html(r); setWS(WS_TC, ""); $('.startBooking').click(function () { var id = $(this).data(PID); if(!isNullOrEmpty(id)) { setWS(WS_PWC, id); navigate(P_BOOKING); } }); } } }); } else { setWS(WS_NEXTP, x); navigate(P_LOGIN); } } else { navigate(P_LOGIN); } } else if(x == P_AGB) { $(T_CONTENT).load(HTML_AGB); } else if(x == P_AGBCORNA) { $(T_CONTENT).load(HTML_AGBCORONA); } else if(x == P_IMPRESSUM) { $(T_CONTENT).load(HTML_IMPRESSUM); } else if(x == P_NUTZUNGSBEDINGUNGEN) { $(T_CONTENT).load(HTML_NUTZUNGSBEDINGUNGEN); } else if(x == P_DATENSCHUTZ) { $(T_CONTENT).load(HTML_DATENSCHUTZ); } else if(x == P_FREESLOTS) { user = setUserFromWS(); if(user == UNDEF || isLogedIn() == false) { setWS(WS_NEXTP, x); navigate(P_LOGIN); return; } loadFreeSlots(); } else if(x.startsWith(P_UNSUBSCRIBE)) { unsubscribe(x); } else { $( T_CONTENT ).load(HTML_HOME); } var navMain = $("#navbar"); navMain.collapse('hide'); } function saveWKNotes() { var val = $("#booking_notes").val(); console.log(val); $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "notes", "note": val}, method: POST, async:false, success: function(data) { } }); } function unsubscribe(parameter) { $.ajax({ url: PHP_MAIN, cache: false, data: {"admin": "unsubscribe", "user": parameter.substring(12)}, method: POST, dataType: "html", success: function(data) { if(data === "1") { $(T_CONTENT).load(HTML_UNSUBSCRIBE); } else { $(T_CONTENT).load(HTML_UNSUBSCRIBEERROR); } } }); } function loadUserPage() { $.ajax({ url: PHP_USER, cache: false, method: POST, success: function(e) { $(T_CONTENT).html(e); }, error: function e() { setWS(WS_NEXTP, x); navigate(P_LOGIN); } }); } function loadBooking() { $.ajax({ url: PHP_BOOK, cache: false, method: POST, dataType: "html", success: function(data) { $(T_CONTENT).html(''); $(T_CONTENT).html(data); $('.nextloginbutton').click(function () {nextLogin();}); $('.addDay').click(function () {navigate(P_BOOKING + "_1")}); $('#content').css("width", ""); $('.navbar-toggle').css("float", "right"); $('.navbar-toggle').css("margin-left", "0px"); $('.navbar-toggle').css("margin-right", "15px"); initFormBooking(); } }); } function getActBookingStep() { return $.ajax({ url: PHP_MAIN, cache: false, async:false, data: {"wk": "getstep"}, method: POST, success: function(e) { return e; } }).responseText; } function getActBookingDate() { return $.ajax({ url: PHP_MAIN, cache: false, async:false, data: {"wk": "actDate"}, method: POST, success: function(e) { return e; } }).responseText; } function loadFreeSlots() { } function loadOverViewFree() { } function saveAdminToDataBase(admin, infotext, items) { var userid = 0; var nameAppend = ""; if(isLogedIn() && user != UNDEF) { userid = parseInt(user.idcustomer); if(isNaN(userid)) { userid = 0; } else { nameAppend = " (" + user.name + ")"; } } if(admin == "block" && infotext == "") { infotext = admin; } if(infotext != "" && infotext.indexOf(nameAppend)<0) { infotext = infotext + nameAppend; } var fdata = new FormData(); fdata.append("admin", admin); fdata.append("ticketinfo", infotext); fdata.append("bookingid", admin +"-"+ uuidv4()); fdata.append("items", JSON.stringify(items)); fdata.append(WS_BDATE, getWS(WS_BDATE)); fdata.append("booking", PADMIN); $.ajax({ type: POST, url: PHP_MAIN, data: fdata, dataType: 'json', contentType: false, cache: false, processData:false, success: function (res) { } }); } function initFormBooking() { if(checkRefreshNeeded()) { return; } var bookingstartdate = getMinDate(); var bookingstep = getActBookingStep(); console.log(bookingstep); if(bookingstep == UNDEF || bookingstep < initialpage){bookingstep = initialpage;} var tempdate = getActBookingDate(); var datetoshow = ""; if(!isNullOrEmpty(tempdate)) { datetoshow= tempdate; } else { datetoshow = getFormatedDate(bookingstartdate); setWS(WS_BDATE,datetoshow); } var temptime = getWS(WS_BTIME); var temptimeend = getWS(WS_BTIMEEND); var amountAnyArtikel = 0; $('#chk_oneHouse').change(function() { CheckAmounts(); setWS(WS_OHH,this.checked); }); //Setze den Titel des Untermenüs if(bookingstep == 4) { amountAnyArtikel = getAmountAnyArticles(); if(amountAnyArtikel <=0) { back(); } } else if(bookingstep == 5) { amountAnyArtikel = getAmountAnyArticles(); if(amountAnyArtikel <=0) { back(); } $('#btnWKArtikelAmount').html('(' + amountAnyArtikel + ') Artikel'); } else if(bookingstep == 6) { } if(bookingstep == 5) { } else if(bookingstep == 6) { return; } else if(bookingstep == 7) { return; } } function getArticleZumzeitpunkt() { return JSON.parse($.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "getArticleZumzeitpunkt" }, method: POST, async: false, success: function(e) { return e; } }).responseText); } function delArticle(item) { var itemnbr = item.data('itemnbr'); var subItem = item.data('subItem'); var itemSize = item.data('itemsize'); if(itemSize != UNDEF && itemSize >0) { removeArticleZumZeitpunkt(itemnbr, subItem,itemSize); } else { removeArticleZumZeitpunkt(itemnbr, subItem); $('#itemnbr_' + itemnbr).val(''); $('#del_' + itemnbr).hide(); $('#lstAddedSizes_' + itemnbr).html(''); setPriceDisplay(itemnbr, 1); } saveWK(); } function decArticle(item) { var itemnbr = item.data('itemnbr'); var subItem = item.data('subItem'); var itemSize = item.data('itemsize'); if(itemSize != UNDEF && itemSize >0) { decreaseArticleZumZeitpunkt(itemnbr, subItem,itemSize); } saveWK(); } function incArticle(item) { var itemnbr = item.data('itemnbr'); var subItem = item.data('subItem'); var itemSize = item.data('itemsize'); if(itemSize != UNDEF && itemSize >0) { increaseArticleZumZeitpunkt(itemnbr, subItem,itemSize); } saveWK(); } function drawArticleStorage(itemnbr, subItem=1) { var am = 0; am = $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "getArticleStorageItemsZumzeitpunkt", "itemnbr":itemnbr, "subitem":subItem}, method: POST, async: false, success: function(e) { console.log(e); e=JSON.parse(e); var addstring = "Bisher hinzugefügt:"; var amount = 0; e.forEach(function(store) { var deltag = 'data-itemnbr="' + itemnbr + '"'; deltag += 'data-subItem="' + subItem + '"'; deltag += ' data-itemSize="' + store.itemSize + '"'; addstring += '
  • Größe ' + store.itemSize + ' Menge ' + store.AmountWK + ''; addstring += ''; addstring += ''; addstring += '
  • '; amount+= store.AmountWK; }); $('#lstAddedSizes_' + itemnbr).html(addstring); $('#itemnbr_'+ itemnbr).val(amount); setPriceDisplay(itemnbr, amount); $('.delArticle').off('click'); $('.delArticle').on('click', function() { delArticle($(this)); }); $('.decArticle').off('click'); $('.decArticle').on('click', function() { decArticle($(this)); }); $('.incArticle').off('click'); $('.incArticle').on('click', function() { incArticle($(this)); }); return e; } }).responseText; return am; } function hasArticleZumZeitpunkt(itemnbr, subItem=1) { $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "hasArticleZumZeitpunkt", "article":itemnbr, "subItem":subItem}, method: POST, async: false, success: function(e) { } }); } function removeArticleZumZeitpunkt(itemnbr,subItem=1, itemSize=0) { $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "removeArticleZumZeitpunkt", "article":itemnbr, "subItem":subItem, "itemSize":itemSize}, method: POST, async: false, success: function(e) { if(itemSize >0) { drawArticleStorage(itemnbr, subItem); } } }); } function decreaseArticleZumZeitpunkt(itemnbr,subItem=1, itemSize=0) { $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "decreaseArticleZumZeitpunkt", "article":itemnbr, "subItem":subItem, "itemSize":itemSize}, method: POST, async: false, success: function(e) { if(itemSize >0) { drawArticleStorage(itemnbr, subItem); } } }); } function increaseArticleZumZeitpunkt(itemnbr,subItem=1, itemSize=0) { $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "increaseArticleZumZeitpunkt", "article":itemnbr, "subItem":subItem, "itemSize":itemSize}, method: POST, async: false, success: function(e) { if(itemSize >0) { drawArticleStorage(itemnbr, subItem); } } }); } function hasArticleZeitlos(itemnbr, subItem=1) { return $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "hasArticleZeitlos", "article":itemnbr, "subItem":subItem}, method: POST, async: false, success: function(e) { return e; } }).responseText; } function removeArticleZeitlos(itemnbr,subItem=1) { $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "removeArticleZeitlos", "article":itemnbr, "subItem":subItem}, method: POST, async: false, success: function(e) { } }); } function getAmountAnyArticles() { return $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "getAmountAnyArticles"}, method: POST, async: false, success: function(e) { return e; } }).responseText; } function getFormatedDate(input) { var d = input; var mm = d.getMonth() + 1; // getMonth() is zero-based var dd = d.getDate(); return [(dd > 9 ? '' : '0') + dd, (mm > 9 ? '' : '0') + mm, d.getFullYear()].join('.'); } function checkRefreshNeeded() { var lastrefresh = getWS(WS_LASTREFRESH); var yesterday = new Date(); yesterday = yesterday.setDate(yesterday.getDate() - 1); //console.log(lastrefresh); if(lastrefresh == UNDEF || lastrefresh == NULL || lastrefresh 0) { $('#free_usage').html(res.free); $('.addbutton').removeAttr(DISABLED); } else { var iswertkarte = false; articles.forEach(function(ar) { if(ar.itemnbr == selectedTarif) { iswertkarte = ar.isWertkartenArtikel(); if(iswertkarte) { $('.timediv').css(CSS_DSP, CSS_NONE); $('#booking_time_label').css(CSS_DSP, CSS_NONE); $('#v_oneHouse').css(CSS_DSP, CSS_NONE); $('#article_price').css(CSS_DSP, CSS_NONE); if(ar.type == TYPEGUTSCHEIN) { addType7Text(); $('#booking_time').css(CSS_DSP, CSS_INB); } else { $('#div_ggValue').remove(); } } else { $('.timediv').css(CSS_DSP, CSS_B); } } }); if(isNullOrEmpty(selectedTarif)) { $('#free_usage').html("Artikel auswählen"); }else { if(iswertkarte) { $('#free_usage').html(""); } else { $('#free_usage').html("Keine"); } } if(res.free != -99) { $('.addbutton').attr(DISABLED,DISABLED); } else { $('.addbutton').removeAttr(DISABLED); } } } else { $('.spacedisplay').css(CSS_DSP,CSS_NONE); } } }); } function getArticleAmountWK() { $.ajax({ type: POST, url: PHP_MAIN, data: {"wk": "getArticleAmountWK"}, method: POST, dataType: 'json', cache: false, success: function (res) { } }); } function setPriceDisplay(itemnbr, amount) { var singleprice = 0; $.ajax({ type: POST, url: PHP_MAIN, data: {"article": "totalprice", "itemnbr":itemnbr, "amount": amount}, method: POST, dataType: 'json', cache: false, success: function (res) { singleprice=res; if(singleprice > 0) { $('#' + itemnbr + '_price').html(formatPrice(singleprice)) } } }); } function countPersons() { var selectedtime = getWS(WS_BTIME); var selectedtimes = JSON.parse(selectedtime); var amountCols = 0; if(selectedtimes != UNDEF) { var listrows = [] selectedtimes.forEach(elm => { var split = elm.split("_"); if(!listrows.includes(split[0])) { amountCols++; listrows.push(split[0]); } }); } return amountCols; } function setTime(time, time_end) { setWS(WS_BTIME,time); setWS(WS_BTIMEEND,time_end); addTimes(time, time_end); saveWK(); } function addTimes(zeit, zeitEnde) { $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "addTimes", "zeit":zeit, "zeitEnde": zeitEnde}, method: POST, async: false, success: function(e) { if(e == "1") { } } }); } function saveWK() { var amount = getAmountAnyArticles(); if(amount>0) { $('#mnuBtnChart').css(CSS_DSP,CSS_INB); $('#amountinChart').html(amount); } else { $('#amountinChart').html("0"); $('#mnuBtnChart').css(CSS_DSP,CSS_NONE); } } function toggleTime(time, subitem) { var combined = subitem + "_" + time; var times= []; var temp = getWS(WS_BTIME); if(!isNullOrEmpty(temp)) { times = JSON.parse(temp); } var added = false; if(!times.includes(combined)) { times.push(combined); added=true; } else { var index = times.indexOf(combined); times.splice(index, 1); } times.sort(); setWS(WS_BTIME,JSON.stringify(times)); return added; } function removeTime(time, subitem) { var combined = subitem + "_" + time; var times= []; var temp = getWS(WS_BTIME); if(!isNullOrEmpty(temp)) { times = JSON.parse(temp); } if(times.includes(combined)== true) { var index = times.indexOf(combined); times.splice(index, 1); } times.sort(); setWS(WS_BTIME,JSON.stringify(times)); } function uuidv4() { return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) ); } function initFormRegister() { var options = { onLoad: function () { }, onKeyUp: function (evt) { $(evt.target).pwstrength("outputErrorList"); }/*, activated:{ wordNotEmail: true, wordMinLength: true, wordMaxLength: false, wordInvalidChar: true, wordSimilarToUsername: true, wordSequences: true, wordTwoCharacterClasses: false, wordRepetitions: false, wordLowercase: true, wordUppercase: true, wordOneNumber: true, wordThreeNumbers: true, wordOneSpecialChar: true, wordTwoSpecialChar: true, wordUpperLowerCombo: true, wordLetterNumberCombo: true, wordLetterNumberCharCombo: true }, rules : { commonPasswords:['12345678', 'password', 'passwort','000000000'] }*/ }; $('#user_pwd').pwstrength(options); $('#user_prename').focus(); $("#user_email").on('blur', function(e){ emailInValidorDouble(); }); if(FIRMAPOSSIBLE) { $('#row_firmapossible').css(CSS_DSP, CSS_B); $('#user_iscompany').change(function() { if(this.checked) { $('#row_firma').css(CSS_DSP, CSS_B); } else { $('#row_firma').css(CSS_DSP, CSS_NONE); } }); } var submitActor = null; var $form = $('#register_formular'); var $submitActors = $form.find('button[type=submit]'); $submitActors.click(function(event) { submitActor = this; }); $("#register_formular").on('submit', function(e){ if (null === submitActor) { // If no actor is explicitly clicked, the browser will // automatically choose the first in source-order // so we do the same here submitActor = $submitActors[0]; } var autologinAndSendToMyInformation = submitActor.value == "RegisterAndMore"; //console.log(autologinAndSendToMyInformation); e.preventDefault(); var gebdat = getFormatedGebDat($('#user_gebdat').val()); var nomobile = $('#user_nomobile').is(':checked'); var mobile = ""; $("#register_formular"). attr("disabled", true); var formok = true; var fieldok = validateText(UPRENAME); if(!fieldok) {formok = false;} fieldok = validateText(UNAME); if(!fieldok) {formok = false;} fieldok = validateEmail(UEMAIL); if(!fieldok) {formok = false;} cleanMobile(UMOBILE); if(!nomobile) { fieldok =validateMobile(UMOBILE,"user_mobilepraefix"); if(!fieldok) {formok = false;} mobile = $('#' + UMOBILE).val().trim(); if(mobile.startsWith("0")) { mobile = $('#user_mobilepraefix').val().trim() + mobile.substring(1); } else { mobile = $('#user_mobilepraefix').val().trim() + mobile; } } else { mobile=""; setSuccess(UMOBILE); } fieldok = validatePlz(UPLZ); if(!fieldok) {formok = false;} fieldok = validateText(UCITY); if(!fieldok) {formok = false;} fieldok = validateText(USTREET); if(!fieldok) {formok = false;} fieldok = validateText(UPWD); if(!fieldok) {formok = false;} fieldok = validateText(UPWD2); if(!fieldok) {formok = false;} var isCompany = 0; if(FIRMAPOSSIBLE) { if($('#user_iscompany').prop('checked')==true) { isCompany = 1; fieldok = validateText(UCOMPANY); if(!fieldok) {formok = false;} } } if($('#user_pwd').val() != $('#user_pwd2').val()) { var div = $("#user_pwd2").closest("div"); $("#glypcnuser_pwd2").remove(); toggleClasses(div, "has-success", "has-error has-feedback"); div.append(''); formok=false; } if(formok) { if(emailInValidorDouble()){formok = false;} var checkval = checkAccountExists(); if(checkval) { if(confirm("Es scheint als haben sie bereits einen Account. Registrierung trotzdem fortsetzen?") == false) { formok = false; } } } if(!formok) { $("#register_formular"). attr("disabled", false); return false; } var consent = 0; var chk_agb = $('#chk_agb').prop('checked'); if(chk_agb == true) { consent+=1; } var chk_dsgvo = $('#chk_dsgvo').prop('checked'); if(chk_dsgvo == true) { consent+=4; } var chk_nutzungsbedingungen = $('#chk_nutzungsbedingungen').prop('checked'); if(chk_nutzungsbedingungen == true) { consent+=2; } var formdata = new FormData(); formdata.append(UPRENAME, $('#user_prename').val().trim()); formdata.append(UNAME, $('#user_name').val().trim()); formdata.append(UEMAIL, $('#user_email').val().trim()); formdata.append(UPLZ, $('#user_plz').val().trim()); formdata.append(UCITY, $('#user_city').val().trim()); formdata.append(USTREET, $('#user_street').val().trim()); formdata.append(UPWD, md5($('#user_pwd').val())); formdata.append(UMOBILE, mobile); formdata.append(UCOMPANY, $('#user_companyname').val().trim()); formdata.append("iscompany", isCompany); formdata.append("gebdat", gebdat); formdata.append("notes", $('#user_notes').val().trim()); formdata.append("consents", consent); var urltocall = PHP_MAIN + "?register=me"; $.ajax({ type: POST, url: urltocall, data: formdata, dataType: 'json', contentType: false, cache: false, processData:false, success: function (response) { if(response == RES_SUCCESS) { if(autologinAndSendToMyInformation == false) { alert("Registrierung erfolgreich"); navigate(P_LOGIN); } else { alert("Registrierung erfolgreich. Auf der nächsten Seite kannst du deine Freunde hinterlegen."); var formdata = new FormData(); formdata.append("login_user",$('#user_email').val()); formdata.append("login_pwd", md5($('#user_pwd').val())); doLogin(formdata,P_USER); } } else if(response == "-1") { alert('E-Mailadresse bereits verwendet'); $("#register_formular"). attr("disabled", false); } else { alert("Registrierung fehlgeschlagen"); $("#register_formular"). attr("disabled", false); } }, statusCode: { 401: function () { navigate(P_BOOKING); }, 404: function () { navigate(P_BOOKING); } } }); return false; }); } function doLogin(formdata, successpage) { var urltocall = PHP_MAIN + "?login=me"; $.ajax({ type: POST, url: urltocall, data: formdata, dataType: 'json', contentType: false, cache: false, processData:false, success: function (res) { if(res != "0" && res!= "-1") { user = new User(res.idcustomer, res.name, res.prename, res.email, res.mobile, res.street, res.plz, res.city, "", res.hasVIP, res.infoanstate, res.infoan, res.gebdat, res.companyname, res.iscompany, res.consents, res.contact_choice); user.hasAdmin = res.hasAdmin; user.hasOV = res.hasOV; user.bemerkung = res.bemerkung; user.hasReserv = res.hasReserv; setWS(WS_USER,JSON.stringify(user)); setWS(WS_LOGEDIN,TRUE); bookingallowed=true; if(res.custasp != UNDEF && res.custasp != "0") { custasp = res.custasp; setWS(WS_ASP,JSON.stringify(custasp)); } else { custasp = []; } setLogedIn(); refreshUser(); var nextpage = getWS(WS_NEXTP); if(nextpage == UNDEF || nextpage == null || nextpage == "") { navigate(successpage); } else { setWS(WS_NEXTP, ""); navigate(nextpage); } } else if(res == "-1") { setError("login_pwd"); setError("login_user"); $('#result').html('Dein Konto wurde gesperrt. Dafür gibt es einen Grund. Diesen bitte bei der SAPB erfragen.'); } else { setError("login_pwd"); setError("login_user"); $('#result').html('Passwort oder Benutzername ungültig.'); } }, error: function (rest) { alert(rest); } }); } function checkAccountExists() { var formok = true; var fieldok = false; if($('#user_prename').val().trim() != "") { fieldok=validateText(UPRENAME); if(!fieldok) {formok = false;} } if($('#user_name').val().trim() != "") { fieldok=validateText(UNAME); if(!fieldok) {formok = false;} } if($('#user_street').val().trim() != "") { fieldok=validateText(USTREET); if(!fieldok) {formok = false;} } if(!formok) { return false; } var fdata = new FormData(); fdata.append(UPRENAME, $('#user_prename').val().trim()); fdata.append(UNAME, $('#user_name').val().trim()); fdata.append(USTREET, $('#user_street').val().trim()); fdata.append(PREGISTER, "checkuserdata"); var resp = ""; var responseText= $.ajax({ type: POST, url: PHP_MAIN, data: fdata, dataType: 'json', contentType: false, cache: false, async: false, processData:false, success: function (response) { if(response == "-1") { var div = $("#user_prename").closest("div"); $("#glypcnuser_prename").remove(); toggleClasses(div, "has-success", "has-warning has-feedback"); div.append(''); div = $("#user_name").closest("div"); $("#glypcnuser_name").remove(); toggleClasses(div, "has-success", "has-warning has-feedback"); div.append(''); div = $("#user_street").closest("div"); $("#glypcnuser_street").remove(); toggleClasses(div, "has-success", "has-warning has-feedback"); div.append(''); } resp= response; }, statusCode: { 401: function () { navigate(P_BOOKING); }, 404: function () { navigate(P_BOOKING); } } }).responseText; return resp == "-1"; } function emailInValidorDouble() { var formok = true; var fieldok = validateEmail(UEMAIL); if(!fieldok) {formok = false;} if(!formok) { return false; } var fdata = new FormData(); fdata.append(UEMAIL, $('#user_email').val()); fdata.append(PREGISTER, "checkmail"); return $.ajax({ type: POST, url: PHP_MAIN, data: fdata, dataType: 'json', contentType: false, cache: false, async: false, processData:false, success: function (response) { if(response == "-1") { var div = $("#user_email").closest("div"); $("#glypcnuser_email").remove(); toggleClasses(div, "has-success", "has-error has-feedback"); div.append(''); alert('Diese E-Mail Adresse wird bereits verwendet.\nBitte versuchen Sie sich NICHT erneut zu registrieren!\nVerwenden Sie besser die "Passwort ändern" Funktion, Sie erhalten dann eine E-Mail und können Ihr Passwort ändern - oder falls noch keines vergeben, ein Neues erstellen. Danke dafür.'); $("#user_email").val(""); } }, statusCode: { 401: function () { navigate(P_BOOKING); }, 404: function () { navigate(P_BOOKING); } } }).responseText == RES_SUCCESS; } function initFormLogin() { $('#login_user').focus(); $("#login_formular").on('submit', function(e){ e.preventDefault(); var formok = true; var fieldok = validateEmail("login_user"); if(!fieldok) {formok = false;} fieldok = validateText("login_pwd"); if(!formok) { return false; } var formdata = new FormData(); formdata.append("login_user", $('#login_user').val()); formdata.append("login_pwd", md5($('#login_pwd').val())); doLogin(formdata,P_BOOKING); return false; }); } function initFormPwdForget() { $("#pwdforget_formular").on('submit', function(e){ e.preventDefault(); var formok = true; var fieldok = validateEmail(WS_USER); if(!fieldok) {formok = false;} if(!formok) { return false; } var formdata = new FormData(); formdata.append(WS_USER, $('#user').val()); var urltocall = PHP_MAIN + "?pwdforget=me"; $.ajax({ type: POST, url: urltocall, data: formdata, dataType: 'json', contentType: false, cache: false, processData:false, success: function (res) { if(res == RES_SUCCESS) { $('#result').html("Sie erhalten in Kürze eine E-Mail um ihr Passwort zurück zu setzen."); } }, statusCode: { 401: function () { navigate(P_LOGIN); }, 404: function () { navigate(P_LOGIN); } } }); return false; }); } function initFormPwdForget2(flag, user) { var options = { onLoad: function () { // $('#messages').text('Start typing password'); }, onKeyUp: function (evt) { $(evt.target).pwstrength("outputErrorList"); } /*, rules : { commonPasswords:['12345678', 'password', 'passwort','000000000'] }*/ }; $('#pwd').pwstrength(options); $('#flag').val(flag); $('#user').val(user); var formdata = new FormData(); formdata.append("flag", $('#flag').val()); var urltocall = PHP_MAIN + "?pwdforget=cf"; $.ajax({ type: POST, url: urltocall, data: formdata, dataType: 'json', contentType: false, cache: false, processData:false, success: function (res) { if(res != RES_SUCCESS) { $('#result').html('Der Link ist ungültig'); $('#pwdforget2_fs').attr(DISABLED,DISABLED); } }, statusCode: { 401: function () { navigate(P_LOGIN); }, 404: function () { navigate(P_LOGIN); } } }); $("#pwdforget2_formular").on('submit', function(e){ e.preventDefault(); var formok = true; var fieldok = validateText("pwd"); if(!fieldok) {formok = false;} fieldok = validateText("pwd2"); if(!fieldok) {formok = false;} if($('#pwd').val() != $('#pwd2').val()) { var div = $("#pwd2").closest("div"); $("#glypcnpwd2").remove(); toggleClasses(div, "has-success", "has-error has-feedback"); div.append(''); formok=false; } if(!formok) { return false; } var formdata = new FormData(); formdata.append("pwd", md5($('#pwd').val())); formdata.append("flag", $('#flag').val()); formdata.append(WS_USER, $('#user').val()); var urltocall = PHP_MAIN + "?pwdforget=new"; $.ajax({ type: POST, url: urltocall, data: formdata, dataType: 'json', contentType: false, cache: false, processData:false, success: function (res) { if(res == RES_SUCCESS) { $('#result').html('Passwort erfolgreich zurück gesetzt'); window.setTimeout( returnToLogin, 3000 ); } else { $('#result').html('Fehler beim zurücksetzen des Passworts'); } }, statusCode: { 401: function () { navigate(P_LOGIN); }, 404: function () { navigate(P_LOGIN); } } }); return false; }); } function returnToLogin() { navigate(P_LOGIN); } function resetUserChangeButtons() { $('#user_changedata').removeClass('bgsuccess') .removeClass('bgerror') .removeClass('bginfo'); $('#user_changedata_info').removeClass('success') .removeClass('error') .removeClass('info') .css(CSS_DSP,CSS_NONE) .html(''); $('#u_chgpwd').removeClass('bgsuccess') .removeClass('bgerror') .removeClass('bginfo'); $('#u_chgpwd_info').removeClass('success') .removeClass('error') .removeClass('info') .css(CSS_DSP,CSS_NONE) .html(''); $('.saveasp').removeClass('bgsuccess') .removeClass('bgerror') .removeClass('bginfo'); $('#user_asp_info').removeClass('success') .removeClass('error') .removeClass('info') .css(CSS_DSP,CSS_NONE) .html(''); } function initFormTickets() { user = setUserFromWS(); if(user != UNDEF) { loadMyTickets(RES_SUCCESS); $("#select_mytickets_filter").change(function() { var selected = $('#select_mytickets_filter').val(); setWS("ticketfilter",selected); loadMyTickets(selected); }); } } function loadMyTickets(filter) { user = setUserFromWS(); if(user != UNDEF ) { $.ajax({ url: PHP_MAIN, cache: false, data: {"mytickets": PME, "filter": filter}, method: POST, dataType: 'json', success: function(data) { $('#tickets_ready').html(''); $('#credits_ready').html(''); var cont_T = ""; var cont_C = ""; var count_T = 0; var count_C = 0; if(data == "0") { cont_T = '
    '; cont_C = '
    '; } else if(data == "-999") { logout(); } else { data.forEach(function(t){ if(t.type != 3 && t.type != 7 && t.type != 8 && t.type != 14) { var color = "odd"; if(count_T%2 == 0) {color="even";} cont_T += '
    '; cont_T += '
    '; cont_T += ''; cont_T+= '
    '; cont_T += '
    '; cont_T += ''; try { if(t.ticketjson != UNDEF && t.ticketjson != "") { cont_T += '
    '; } } catch{ } cont_T += '
    '; cont_T += '
    '; cont_T += ''; cont_T+= '
    '; cont_T += '
    '; cont_T += ''; cont_T+= '
    '; cont_T += '
    '; cont_T += ''; if(STORNOALLOWED) { var date1 = germanDateToDate(t.ticket_date); var Difference_In_Time = date1.getTime() - new Date().getTime(); var Difference_In_Days = Difference_In_Time / (1000 * 3600); if(filter == 1) { if (Difference_In_Days >= STORNOTIMEOUT) cont_T += ''; } else if(filter == -2) { if (Difference_In_Days >= STORNOTIMEOUT) cont_T += ''; } } if(!isNullOrEmpty(t.last_usage)) { cont_T += ''; } cont_T+= '
    '; cont_T += '
    '; if(t.ref_id_cust_asp > 0) { cont_T += ''; if(filter == 0) cont_T += ''; } cont_T+= '
    '; cont_T+= '
    '; count_T++; } else { var color = "odd"; if(count_C%2 == 0){color="even";} cont_C += '
    '; cont_C += '
    '; cont_C += ''; cont_C+= '
    '; cont_C += '
    '; cont_C += ''; cont_C+= '
    '; cont_C += '
    '; cont_C += ''; cont_C+= '
    '; cont_C += '
    '; cont_C += ''; cont_C+= '
    '; cont_C += '
    '; cont_C += ''; if(!isNullOrEmpty(t.last_usage)) { cont_C += ''; } if(t.valid == -99) { cont_C += ''; } cont_C+= '
    '; cont_C += '
    '; if(t.ref_id_cust_asp > 0) { cont_C += ''; } if(t.valid >=0 && t.credit > 0) { cont_C += ' '; } //cont_C += ''; cont_C+= '
    '; cont_C+= '
    '; count_C++; } }); } if(cont_T == "") { cont_T += '
    '; cont_T += '
    '; cont_T += ''; cont_T+= '
    '; cont_T+= '
    '; } if(cont_C == "") { cont_C += '
    '; cont_C += '
    '; cont_C += ''; cont_C+= '
    '; cont_C+= '
    '; } $('#tickets_ready').html(cont_T); $('#credits_ready').html(cont_C); $(".buyHistory").click(function() { var value = $(this).data(PID); showBuyHistory(value); }); $(".changeasp").click(function() { var value = $(this).data(PID); var prename = $(this).data("prename"); var name = $(this).data("name"); editASP(value, prename, name); }); $(".stornoTicket").click(function() { var value = $(this).data(PID); var ticketcode = $(this).data("tc"); var destination = $(this).data("destination"); stornoTicket($(this), ticketcode, destination); }); $('#btn_take_ticket_ownership').click(function() { $('#ticketinfo').removeClass("error"); $('#ticketinfo').html(''); var ticketcode = $('#tb_take_ticket_ownership').val(); if(ticketcode != "") { if(ticketcode.length <9) { $('#ticketinfo').html("Der Ticketcode ist zu kurz. (9 Stellen)"); $('#ticketinfo').addClass("error"); return; } else if(ticketcode.length >9) { $('#ticketinfo').html("Der Ticketcode ist zu lang. (9 Stellen)"); $('#ticketinfo').addClass("error"); return; } if(takeTicketOwnership(ticketcode) == "-1") { $('#ticketinfo').html("Fehler beim Abrufen der Ticketdaten."); $('#ticketinfo').addClass("error"); } } else { $('#ticketinfo').html("Kein Ticketcode eingegeben"); $('#ticketinfo').addClass("error"); return; } }); } }); } else { returnToLogin(); } } function stornoTicket(sender, ticketcode, destination) { if(!STORNOALLOWED) return; if(!isNullOrEmpty(ticketcode)) { user = setUserFromWS(); if(user != UNDEF) { $.ajax({ type: POST, url: PHP_MAIN, data: {"mytickets": "stornoTicket", "ticketcode": ticketcode, "user": user.idcustomer, "stornodestination":destination}, method: POST, dataType: 'json', cache: false, success: function (res) { if(res == 1) { sender.addClass("bgsuccess"); sender.html("Storno erfolgreich"); sender.delay(2000).queue(function() { loadMyTickets(1); }); } else { sender.addClass("bgerror"); sender.html("Storno nicht erfolgreich"); sender.delay(2000).queue(function() { $(this).html(sender.data("content")); $(this).removeClass("bgerror"); }); } } }); } else { return "-1"; } } else { return "-1"; } } function takeTicketOwnership(ticketcode) { if(!isNullOrEmpty(ticketcode)) { user = setUserFromWS(); if(user != UNDEF) { $.ajax({ type: POST, url: PHP_MAIN, data: {"mytickets": "takeownership", "ticketcode": ticketcode, "user": user.idcustomer}, method: POST, dataType: 'json', cache: false, success: function (res) { $('#ticketinfo').removeClass("success"); $('#ticketinfo').removeClass("error"); if(res == 1) { loadMyTickets(1); $('#ticketinfo').html("Ticket erfolgreich übernommen."); $('#ticketinfo').addClass("success"); } else if(res == "0") { $('#ticketinfo').html("Kein passendes Ticket gefunden."); $('#ticketinfo').addClass("error"); } else if(res == "-1") { $('#ticketinfo').html("Kein passendes Ticket gefunden."); $('#ticketinfo').addClass("error"); } else if(res == "-2") { $('#ticketinfo').html("Kein eindeutiges Ticket gefunden."); $('#ticketinfo').addClass("error"); } else if(res == "-3") { $('#ticketinfo').html("Fehler beim Einlösen. Bitte noch einmal probieren."); $('#ticketinfo').addClass("error"); } else if(res == "-4") { $('#ticketinfo').html("Der Gutschein wurde bereits eingelöst."); $('#ticketinfo').addClass("error"); } else if(res == "-5") { loadMyTickets(1); $('#ticketinfo').html("Der Gutschein gehört bereits diesem Konto."); $('#ticketinfo').addClass("success"); } else if(res == "-99") { $('#ticketinfo').html("Das Guthaben ist aufgebraucht."); $('#ticketinfo').addClass("error"); } else { $('#ticketinfo').html(res); $('#ticketinfo').addClass("error"); } } }); } else { return "-1"; } } else { return "-1"; } } function editASP(value, prename, name) { $('#nameToReplace_' + value)[0].parentElement.innerHTML+= (''); } function setCreditItem(value, itemnbr) { user = setUserFromWS(); if(user != UNDEF) { if(isLogedIn()) { setWS(WS_PWC, value); setWS(WS_PWCA, itemnbr); loadBooking(); } } } function showBuyHistory(id) { alert("TODO, Anzeige der Historie implementieren."); } function loadArtikelWGFilter(loadAlways = false) { } function formatPrice(value) { var price = new Intl.NumberFormat('de-DE', { style: 'currency', currency: EUR }).format(value); return price; } function logout() { $.ajax({ type: POST, url: PHP_MAIN, data: {"logout": "me"}, method: POST, dataType: 'json', cache: false, async:false, success: function (res) { } }); } function setLogedIn() { if(isLogedIn()) { $('#mnu_login').css(CSS_DSP,CSS_NONE); $('#mnu_reg').css(CSS_DSP,CSS_NONE); $('#mnu_logout').css(CSS_DSP,CSS_B); $('#personaldata').css(CSS_DSP,CSS_B); } else { $('#mnu_login').css(CSS_DSP,CSS_B); $('#mnu_reg').css(CSS_DSP,CSS_B); $('#mnu_logout').css(CSS_DSP,CSS_NONE); $('#loged_in_user').html("Benutzer"); $('#personaldata').css(CSS_DSP,CSS_NONE); } } function germanDateToDate(dateval) { var splittdate = dateval.split('.'); if(splittdate.length == 3) { return new Date(splittdate[2] + "-" + splittdate[1] + "-" + splittdate[0]); } return new Date(); } function addOption(itemnbr, parentitem) { if(!isArtikelSet(ba[parentitem])) { alert("Bitte erst den Artikel/Tarif mit Zeitslot in den Warenkorb legen."); return; } else { if(!isArtikelSet(ba[itemnbr])) { ba[itemnbr] = new Booking(itemnbr, ba[parentitem].amount, UNDEF,[]); ba[parentitem].subitems.forEach(function(subitem) { var subi = new SubItem(subitem.amount, subitem.time, subitem.subitemnbr) subi.isOption=true; ba[itemnbr].subitems.push(subi); }) } else { //console.log(ba); ba[itemnbr].amount++; if(ba[itemnbr].subitems.length == 0) { ba[parentitem].subitems.forEach(function(subitem) { var subi = new SubItem(subitem.amount, subitem.time, subitem.subitemnbr) subi.isOption=true; ba[itemnbr].subitems.push(subi); }) } else { ba[itemnbr].subitems.forEach(function(item) {item.amount++;}); } } saveWK(); } } function isLogedIn() { var returnval = $.ajax({ type: POST, url: PHP_MAIN + "?login=check", method: POST, dataType: 'json', cache: false, async:false, success: function (res) { return res; } }).responseText; return returnval == 1; } function hasOV() { if(user == UNDEF) { user = setUserFromWS(); } if(user != UNDEF) { return user.infoan.includes('ov') || user.infoan.includes('admin'); } return false; } function hasOVViewOnly() { if(user == UNDEF) { user = setUserFromWS(); } if(user != UNDEF) { return user.infoan.includes('view'); } return false; } function back() { $.ajax({ type: POST, url: PHP_MAIN, data: {"wk": "back"}, method: POST, dataType: 'json', cache: false, async:false, success: function (res) { var step= res; if(step <=initialpage) { step = initialpage; } else if(step == 5) { } loadBooking(); } }); } function removeReservation(itemnbr) { var selectedDate = getWS(WS_BDATE); var selectedTime = getWS(WS_BTIME); $.ajax({ type: POST, url: PHP_MAIN, data: {"reservation": "removeReservation", "selectedDate": selectedDate, "selectedTime": selectedTime, "selectedArticle": itemnbr}, method: POST, dataType: 'json', cache: false, async:false, success: function (res) { return res; } }) } function getSlotRemainingTime() { return Date.parse($.ajax({ type: POST, url: PHP_MAIN, data: {"reservation": "remainingTime"}, method: POST, dataType: 'json', cache: false, async:false, success: function (res) { // console.log("res", res); if(res == "stop") { cleanWK(); localtion.reload(); } } }).responseText); } function addPersonToArticle(tag, zeit, zeitEnde, itemnbr, subitem, person) { return Date.parse($.ajax({ type: POST, url: PHP_MAIN, data: {"wk": "addPersonToArticle", "tag": tag, "zeit": zeit, "zeitende": zeitEnde, "itemnbr": itemnbr, "subitem": subitem, "person": person}, method: POST, dataType: 'json', cache: false, async:false, success: function (res) { } }).responseText); } function validateCheckboxes() { var ok = true; if(CORONACHECKBOXES) { var chk1 = $('#chk_corona1').prop('checked'); var chk2 = $('#chk_corona2').prop('checked'); if(chk1 == false) { setError("chk_corona1"); ok=false; } else { setSuccess("chk_corona1") } if(chk2 == false) { setError("chk_corona2"); ok=false; } else { setSuccess("chk_corona2") } } var chk_agb = $('#chk_agb').prop('checked'); if(chk_agb == false) { setError("chk_agb"); ok=false; } else { setSuccess("chk_agb"); } var chk_dsgvo = $('#chk_dsgvo').prop('checked'); if(chk_dsgvo == false) { setError("chk_dsgvo"); ok=false; } else { setSuccess("chk_dsgvo"); } var chk_nutzungsbedingungen = $('#chk_nutzungsbedingungen').prop('checked'); if(chk_nutzungsbedingungen == false) { setError("chk_nutzungsbedingungen"); ok=false; } else { setSuccess("chk_nutzungsbedingungen"); } return ok; } function nextLogin() { $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "next"}, method: POST, success: function(e) { $(T_CONTENT).load(HTML_LOGIN , function() { initFormLogin(); } ); } }); } function refreshUser() { if(user != UNDEF) { $('#user_prename').val(user.prename); $('#user_name').val(user.name); $('#user_street').val(user.street); $('#user_plz').val(user.plz); $('#user_city').val(user.city); $('#user_email').val(user.email); $('#user_mobile').val(user.mobile); $('#user_notes').val(user.bemerkung); $('#user_iscompany').prop('checked', user.iscompany==1) $('#user_companyname').val(user.companyname); $('#loged_in_user').html(user.prename + " " + user.name); $('#u_chgpwd').prop(DISABLED,false); $('#user_gebdat').val(user.gebdat); $('#user_email_consent').prop('checked', user.getContactEmail()==1) $('#user_mobile_consent').prop('checked', user.getContactMobile()==1) if($('#user_iscompany').prop('checked')==true) { $('#row_firma').css(CSS_DSP, CSS_B); } else { $('#row_firma').css(CSS_DSP, CSS_NONE); } } else { $('#user_prename').val(""); $('#user_name').val(""); $('#user_street').val(""); $('#user_plz').val(""); $('#user_city').val(""); $('#user_email').val(""); $('#user_mobile').val(""); $('#user_iscompany').prop('checked', false) $('#user_companyname').val(""); $('#loged_in_user').html(""); $('#u_chgpwd').val(DISABLED,true); $('#user_gebdat').val(""); $('#user_email_consent').prop('checked', false) $('#user_mobile_consent').prop('checked', false) } } function toggleClasses(object, oldclass, newclass) { object.removeClass(oldclass); object.addClass(newclass); } function setWS(cname, cvalue) { sessionStorage.setItem(cname, cvalue); } function getWS(cname) { return sessionStorage.getItem(cname); } function validateText(id) { if ($("#" + id).val()== UNDEF || $("#" + id).val() == null || $("#" + id).val().trim() == "") { setError(id); return false; } else { setSuccess(id); return true; } } function setSuccess(id) { var div = $("#" + id).closest("div"); $("#glypcn" + id).remove(); toggleClasses(div, "has-error", "has-success has-feedback"); div.append(''); } function setError(id) { var div = $("#" + id).closest("div"); $("#glypcn" + id).remove(); toggleClasses(div, "has-success", "has-error has-feedback"); div.append(''); } function validateEmail(id) { var email_regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i; if ($("#" + id).val() != null && !email_regex.test($("#" + id).val().trim())) { setError(id); return false; } else { setSuccess(id); return true; } } function validateMobile(id, id_praefix="") { var mobile = $("#" + id).val().trim(); var mpraefix = ""; if(id_praefix !="") { mpraefix = $("#" + id_praefix).val().trim(); mobile = mpraefix + "" + mobile; } var mobil_regex = /^(([\+][\d]{2,3}|[0]{2}[\d]{2})|0)(15|16|17)([ -\/\d]*)$/; var match = false; if (mobil_regex.test(mobile)) { match = true; } else { var mobil_regex = /^(([\+][\d]{2,3}|[0]{2}[\d]{2,3}))([ -\/\d]*)$/; var match_unspecific = mobil_regex.exec(mobile); if(match_unspecific) { var dictVorwahlen={31:[654,655,653,651,62],43:[663,664,650,676,699,660],41:[79,76,7],420:[602,603,605,6],33:[689,607,608,604,680,681,685,609,603,611,618,612,614,66],32:[475,476,477,478,479,494,495,496,497,498,499,484,485,486],39:[347,348,349,335,338,339,3],48:[601,603,605,607,609,691,693,695,697,699,600,602,604,606,608,692,694,696,698,501,502,503,504,505,506,507,508,509],45:[208,209,405,406,407,408,409,401,402,403,404,201,202,203,204,205,21],421:[903,905],352:[621,628,661,668,691,698],49:[151,1511,160,170,171,175,152,1520,162,172,173,174,157,163,177,178,159,176,179,160,161,162,163,164]}; for(var key in dictVorwahlen) { if(match) { continue; } var praefix = key; dictVorwahlen[key].forEach((vorwahl)=> { if(mobile.startsWith("+" + praefix + vorwahl) || mobile.startsWith("+" + praefix + "0" + vorwahl)) { match=true; } }); } } } if(match) { setSuccess(id); return true; } else { setError(id); return false; } } function cleanMobile(id) { var val = $("#" + id).val(); if(val != UNDEF && val.trim().length > 0) { val = val.trim().replace(/[^+\d]+/g, ""); $("#" + id).val(val); } } function validatePlz(id) { var plz_regex = /^\d{4,5}$/i; if (!plz_regex.test($("#" + id).val().trim())) { setError(id); return false; } else { setSuccess(id); return true; } } function isNullOrEmpty(input) { if(input == UNDEF || input == null || input == "") { return true; } else { return false; } } function getFormatedGebDat(dateinput) { if(dateinput != "") { return dateinput; dateinput = new Date(dateinput); var mm = dateinput.getMonth() + 1; // getMonth() is zero-based var dd = dateinput.getDate(); dateinput = [(dd > 9 ? '' : '0') + dd, (mm > 9 ? '' : '0') + mm, dateinput.getFullYear()].join('.'); } return dateinput; } function getFormatedTime(input, withseconds=false) { var td = input; var hh = td.getHours(); var MM = td.getMinutes(); var returnstring = [(hh > 9 ? '' : '0') + hh, (MM > 9 ? '' : '0') + MM].join(':'); if(withseconds) { var ss = td.getSeconds(); returnstring += ":" + (ss > 9 ? '' : '0') +ss; } return returnstring; } function md5(str) { var xl; var rotateLeft = function(lValue, iShiftBits) { return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits)); }; var addUnsigned = function(lX, lY) { var lX4, lY4, lX8, lY8, lResult; lX8 = (lX & 0x80000000); lY8 = (lY & 0x80000000); lX4 = (lX & 0x40000000); lY4 = (lY & 0x40000000); lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF); if (lX4 & lY4) { return (lResult ^ 0x80000000 ^ lX8 ^ lY8); } if (lX4 | lY4) { if (lResult & 0x40000000) { return (lResult ^ 0xC0000000 ^ lX8 ^ lY8); } else { return (lResult ^ 0x40000000 ^ lX8 ^ lY8); } } else { return (lResult ^ lX8 ^ lY8); } }; var _F = function(x, y, z) { return (x & y) | ((~x) & z); }; var _G = function(x, y, z) { return (x & z) | (y & (~z)); }; var _H = function(x, y, z) { return (x ^ y ^ z); }; var _I = function(x, y, z) { return (y ^ (x | (~z))); }; var _FF = function(a, b, c, d, x, s, ac) { a = addUnsigned(a, addUnsigned(addUnsigned(_F(b, c, d), x), ac)); return addUnsigned(rotateLeft(a, s), b); }; var _GG = function(a, b, c, d, x, s, ac) { a = addUnsigned(a, addUnsigned(addUnsigned(_G(b, c, d), x), ac)); return addUnsigned(rotateLeft(a, s), b); }; var _HH = function(a, b, c, d, x, s, ac) { a = addUnsigned(a, addUnsigned(addUnsigned(_H(b, c, d), x), ac)); return addUnsigned(rotateLeft(a, s), b); }; var _II = function(a, b, c, d, x, s, ac) { a = addUnsigned(a, addUnsigned(addUnsigned(_I(b, c, d), x), ac)); return addUnsigned(rotateLeft(a, s), b); }; var convertToWordArray = function(str) { var lWordCount; var lMessageLength = str.length; var lNumberOfWords_temp1 = lMessageLength + 8; var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - (lNumberOfWords_temp1 % 64)) / 64; var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16; var lWordArray = new Array(lNumberOfWords - 1); var lBytePosition = 0; var lByteCount = 0; while (lByteCount < lMessageLength) { lWordCount = (lByteCount - (lByteCount % 4)) / 4; lBytePosition = (lByteCount % 4) * 8; lWordArray[lWordCount] = (lWordArray[lWordCount] | (str.charCodeAt(lByteCount) << lBytePosition)); lByteCount++; } lWordCount = (lByteCount - (lByteCount % 4)) / 4; lBytePosition = (lByteCount % 4) * 8; lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition); lWordArray[lNumberOfWords - 2] = lMessageLength << 3; lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29; return lWordArray; }; var wordToHex = function(lValue) { var wordToHexValue = '', wordToHexValue_temp = '', lByte, lCount; for (lCount = 0; lCount <= 3; lCount++) { lByte = (lValue >>> (lCount * 8)) & 255; wordToHexValue_temp = '0' + lByte.toString(16); wordToHexValue = wordToHexValue + wordToHexValue_temp.substr(wordToHexValue_temp.length - 2, 2); } return wordToHexValue; }; var utf8_encode = function(string) { string = (string+'').replace(/\r\n/g, "\n").replace(/\r/g, "\n"); var utftext = ""; var start, end; var stringl = 0; start = end = 0; stringl = string.length; for (var n = 0; n < stringl; n++) { var c1 = string.charCodeAt(n); var enc = null; if (c1 < 128) { end++; } else if((c1 > 127) && (c1 < 2048)) { enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128); } else { enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128); } if (enc != null) { if (end > start) { utftext += string.substring(start, end); } utftext += enc; start = end = n+1; } } if (end > start) { utftext += string.substring(start, string.length); } return utftext; }; var x = []; var k, AA, BB, CC, DD, a, b, c, d, S11 = 7; var S12 = 12; var S13 = 17; var S14 = 22; var S21 = 5; var S22 = 9; var S23 = 14; var S24 = 20; var S31 = 4; var S32 = 11; var S33 = 16; var S34 = 23; var S41 = 6; var S42 = 10; var S43 = 15; var S44 = 21; str = utf8_encode(str); x = convertToWordArray(str); a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476; xl = x.length; for (k = 0; k < xl; k += 16) { AA = a; BB = b; CC = c; DD = d; a = _FF(a, b, c, d, x[k + 0], S11, 0xD76AA478); d = _FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756); c = _FF(c, d, a, b, x[k + 2], S13, 0x242070DB); b = _FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE); a = _FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF); d = _FF(d, a, b, c, x[k + 5], S12, 0x4787C62A); c = _FF(c, d, a, b, x[k + 6], S13, 0xA8304613); b = _FF(b, c, d, a, x[k + 7], S14, 0xFD469501); a = _FF(a, b, c, d, x[k + 8], S11, 0x698098D8); d = _FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF); c = _FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1); b = _FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE); a = _FF(a, b, c, d, x[k + 12], S11, 0x6B901122); d = _FF(d, a, b, c, x[k + 13], S12, 0xFD987193); c = _FF(c, d, a, b, x[k + 14], S13, 0xA679438E); b = _FF(b, c, d, a, x[k + 15], S14, 0x49B40821); a = _GG(a, b, c, d, x[k + 1], S21, 0xF61E2562); d = _GG(d, a, b, c, x[k + 6], S22, 0xC040B340); c = _GG(c, d, a, b, x[k + 11], S23, 0x265E5A51); b = _GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA); a = _GG(a, b, c, d, x[k + 5], S21, 0xD62F105D); d = _GG(d, a, b, c, x[k + 10], S22, 0x2441453); c = _GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681); b = _GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8); a = _GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6); d = _GG(d, a, b, c, x[k + 14], S22, 0xC33707D6); c = _GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87); b = _GG(b, c, d, a, x[k + 8], S24, 0x455A14ED); a = _GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905); d = _GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8); c = _GG(c, d, a, b, x[k + 7], S23, 0x676F02D9); b = _GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A); a = _HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942); d = _HH(d, a, b, c, x[k + 8], S32, 0x8771F681); c = _HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122); b = _HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C); a = _HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44); d = _HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9); c = _HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60); b = _HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70); a = _HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6); d = _HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA); c = _HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085); b = _HH(b, c, d, a, x[k + 6], S34, 0x4881D05); a = _HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039); d = _HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5); c = _HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8); b = _HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665); a = _II(a, b, c, d, x[k + 0], S41, 0xF4292244); d = _II(d, a, b, c, x[k + 7], S42, 0x432AFF97); c = _II(c, d, a, b, x[k + 14], S43, 0xAB9423A7); b = _II(b, c, d, a, x[k + 5], S44, 0xFC93A039); a = _II(a, b, c, d, x[k + 12], S41, 0x655B59C3); d = _II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92); c = _II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D); b = _II(b, c, d, a, x[k + 1], S44, 0x85845DD1); a = _II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F); d = _II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0); c = _II(c, d, a, b, x[k + 6], S43, 0xA3014314); b = _II(b, c, d, a, x[k + 13], S44, 0x4E0811A1); a = _II(a, b, c, d, x[k + 4], S41, 0xF7537E82); d = _II(d, a, b, c, x[k + 11], S42, 0xBD3AF235); c = _II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB); b = _II(b, c, d, a, x[k + 9], S44, 0xEB86D391); a = addUnsigned(a, AA); b = addUnsigned(b, BB); c = addUnsigned(c, CC); d = addUnsigned(d, DD); } var temp = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d); return temp.toLowerCase(); } })();