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;i0) { setWS(WS_WKT,getSlotRemainingTime()); wktimer = setInterval(reduceWKTimer, 1000); } } }); return returnval; } function cleanWK() { //console.log("cleanwk"); $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "clean"}, method: POST, async: false, success: function(e) { } }); } function loadPLZCitys() { $.ajax({ url: PHP_MAIN, cache: true, data: {"plz": "all"}, method: POST, success: function(e) { plz_city = JSON.parse(e); plzs = Object.keys(plz_city); } }); } function setUserFromWS() { var tempuser = getWS(WS_USER); user = UNDEF; if(!isNullOrEmpty(tempuser)) { user = new User().create(JSON.parse(tempuser)); refreshUser(); } return user; } $(window).on('hashchange', function () { doHashtagFunction(); }); function g(v) { return atob(v); } function doHashtagFunction() { var x = location.hash; if (!x) { return; } if(x==P_LOGOUT) { logout(); x= P_BOOKING; } var logedin = isLogedIn(); if(x==P_USER) { if(logedin) { user = setUserFromWS(); if(user != UNDEF) { $.ajax({ url: PHP_USER, cache: false, method: POST, success: function(e) { $(T_CONTENT).html(e); initFormUser(); loadASP(); }, error: function e() { setWS(WS_NEXTP, x); navigate(P_LOGIN); } }); } else { setWS(WS_NEXTP, x); navigate(P_LOGIN); } } else { setWS(WS_NEXTP, x); navigate(P_LOGIN); } } else if(x.startsWith(P_BOOKING)) { var step = x.split('_')[1]; if(step == UNDEF) { step = RES_NBR1; } setWS(WS_BOOKINGSTEP,step); loadBooking(); } else if(x==P_LOGIN) { $(T_CONTENT).load(HTML_LOGIN,function() { initFormLogin(); }); } else if(x==P_PWDFGT) { $(T_CONTENT).load(HTML_PWDFGT,function() { initFormPwdForget(); }); } else if(x.startsWith(P_PWDFGT2)) { var splitted = x.split('_'); var flag = splitted[1]; var user = ""; var unterstrich = ""; for (var i = 2; i < splitted.length; i++) { user += unterstrich + splitted[i]; unterstrich = "_"; } $(T_CONTENT).load(HTML_PWDFGT2 , function() { initFormPwdForget2(flag,user); } ); } else if(x==P_REG) { $(T_CONTENT).load(PHP_REG, function() { initFormRegister(); } ); } else if(x==P_MYTICKET) { if(logedin) { user = setUserFromWS(); if(user != UNDEF) { $.ajax({ url: PHP_MYTICKET, cache: false, method: POST, success: function(r) { if(r == "-1") { navigate(P_LOGIN); } else { $(T_CONTENT).html(r); initFormTickets(); } } }); } else{ setWS(WS_NEXTP, x); navigate(P_LOGIN); } } else{ setWS(WS_NEXTP, x); navigate(P_LOGIN); } } else if(x.startsWith(P_CHECKME)) { if(x.length >=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 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 loadBooking() { var bookingstep = getWS(WS_BOOKINGSTEP); if(bookingstep == UNDEF || bookingstep == 0){bookingstep = RES_NBR1;} $.ajax({ url: PHP_BOOK, cache: false, data: {"step":bookingstep}, method: POST, dataType: "html", success: function(data) { if(data.indexOf("GOTO LOGIN")) { // nextLogin(); } $(T_CONTENT).html(data); $('.nextbutton').click(function () { next();}); $('.nextloginbutton').click(function () {nextLogin();}); $('.backbutton').click(function () {back();}); $('.addbutton').click(function () {addItem();}); $('.addDay').click(function () {navigate(P_BOOKING + "_1")}); $('.step').click(function () { if(!$(this).hasClass('step-enabled')) { return; } var id = $(this).attr("id"); var s = id.split("_"); if(s.length > 1 && parseInt(s[1]) >0) { var stateObj = { "page": P_SUBBOOKING + s[1] }; history.pushState(stateObj, P_SUBBOOKING + s[1], P_SUBBOOKING + s[1]); setWS(WS_BOOKINGSTEP, s[1]); loadBooking(); //setWS(WS_BOOKINGSTEP, parseInt(s[1])); //initFormBooking(); } }); $('#content').css("width", ""); $('.navbar-toggle').css("float", "right"); $('.navbar-toggle').css("margin-left", "0px"); $('.navbar-toggle').css("margin-right", "15px"); initFormBooking(); } }); } function loadFreeSlots() { setUserFromWS(); if(isLogedIn() == true && hasOV() == false && hasOVViewOnly()==false) { alert("Keine Berechtigung diese Seite zu sehen. Bitte mit einen entsprechenden Benutzer einloggen."); return; } $('#content').css("width", "fit-content"); $('.navbar-toggle').css("float", "left"); $('.navbar-toggle').css("margin-left", "15px"); $('.navbar-toggle').css("margin-right", "5px"); $.ajax({ url: HTML_FREESLOTS, cache: false, method: POST, dataType: "html", success: function(data) { $(T_CONTENT).html(data); $('#freeslots_dp').datepicker({ format: "dd.mm.yyyy", language: "de", todayBtn: "linked", weekStart:1, clearBtn: true, todayHighlight: true, autoclose: true, }); var tempdate = getWS(WS_BDATE); var datetoshow = getFormatedDate(new Date()); if(tempdate != null) { datetoshow= tempdate; } else { datetoshow = getFormatedDate(new Date()); } $('#freeslots_dp').datepicker('update', datetoshow); $('#freeslots_dp').datepicker() .on('changeDate', function(e) { // `e` here contains the extra attributes checkRefreshNeeded(); var datetosave = getFormatedDate(e.date); setWS(WS_BDATE,datetosave); $('#div_freeslots').html('Lädt...'); $.when(loadArtikelWGFilter(true)).done(function() { loadOverViewFree(); }); }); $.when(loadArtikelWGFilter(true)).done(function() { $("#freeslots_tarifgruppe").change(function() { $('#div_freeslots').html('Lädt...'); loadOverViewFree(); }); loadOverViewFree(); }); $(".btnBlock").click(function() { var times = []; $('.active').each(function(zeit) { times.push(new BlockSlot($(this).data("artikel"),$(this).data("subitem"),$(this).data("item"))) }); saveAdminToDataBase("block",$('#inp_ticketinfo').val(),times); $('.active').removeClass('active'); clearInterval(overviewTimer); overviewTimer = setInterval(loadOverViewFree, 60000); loadOverViewFree(); }); $(".btnremBlock").click(function() { var toremove = []; $('.active').each(function(zeit) { if($(this).hasClass("notes") == false) { toremove.push($(this).data("ticketcode")); } }); saveAdminToDataBase("rem",$('#inp_ticketinfo').val(),toremove); $('.active').removeClass('active'); clearInterval(overviewTimer); overviewTimer = setInterval(loadOverViewFree, 60000); loadOverViewFree(); }); $(".btnNotiz").click(function() { var tickets = []; $('.active').each(function(zeit) { tickets.push($(this).data("ticketcode")); }); saveAdminToDataBase("notiz",$('#inp_ticketinfo').val(),tickets); $('.active').removeClass('active'); clearInterval(overviewTimer); overviewTimer = setInterval(loadOverViewFree, 60000); loadOverViewFree(); }); clearInterval(overviewTimer); overviewTimer = setInterval(loadOverViewFree, 60000); } }); } function loadOverViewFree() { arrtk=[]; var selectedfilter = $("#freeslots_tarifgruppe").val(); if(selectedfilter == null || selectedfilter == "") { selectedfilter = "0"; } var tempdate = getWS(WS_BDATE); var datetoshow = ""; if(tempdate != null) { datetoshow= tempdate; } else { datetoshow = getFormatedDate(new Date()); } if(user == UNDEF || isLogedIn()==false) { navigate(P_LOGIN); return; } if(isLogedIn() == true && hasOV() == false && hasOVViewOnly()==false) { alert("Keine Berechtigung diese Seite zu sehen. Bitte mit einen entsprechenden Benutzer einloggen."); return; } return $.ajax({ type: POST, url: PHP_MAIN, data: {"seatsdefine": "daymatrixartikeloverview", "date":datetoshow, "tgfilter": selectedfilter}, method: POST, dataType: 'json', cache: false, success: function (res) { //console.log(res); if(res != "0") { var bookingtext =""; var rowcount = 0; res.forEach(function(row) { var bookingtimecol = ""; bookingtext += ""; var colcount = 0; var s = row.key.split("_"); var timeid = s[0]; var timeidEnd = timeid; if(s.length>1) { timeidEnd=s[1]; } var formatedtimenow = getFormatedTime(new Date()); var formateddatenow = getFormatedDate(new Date()); var classforLinking = "timelinkoverview"; var past = false; var title = ""; var disabled = ""; var isolddate = false; var splittdate = datetoshow.split('.'); if(splittdate.length == 3) { var selecteddate = new Date(splittdate[2] + "-" + splittdate[1] + "-" + splittdate[0]); var nowdate = new Date(); var nowDateOnly = new Date(nowdate.getFullYear() + "-" +(nowdate.getMonth() + 1) + "-" + nowdate.getDate()); isolddate = selecteddate < nowDateOnly; } if(isolddate && timeidEnd < formatedtimenow) { past=true; classforLinking = "timelinkoverview"; title = "Abgelaufen"; } else if (timeidEnd < formatedtimenow && datetoshow == formateddatenow) { past=true; classforLinking = "timelinkoverview"; title = "Abgelaufen"; } else { title = "Verfügbar"; } var anythingOtherThenFree = true; if(rowcount ==0) { anythingOtherThenFree = false; } else { row.columns.forEach(function(col) { if(col.anzahlticketsToPay >-1 || col.anzahltickets >-1 || col.anzahlres >-1 || col.text != "") { anythingOtherThenFree=false; } }); } if(anythingOtherThenFree== false) { row.columns.forEach(function(col) { var color = "success"; var inlinestyle = ""; disabled=""; var name = ""; var stylenamen = ""; var ticketcode = ""; var notiz = ""; var anyBooking = false; var colColumn = col.articleColor; if(col.anzahltickets > 0) { anyBooking=true; title = "Gebucht!"; if(col.ticketNamen.length>0) { colColumn = col.ticketNamen[0][8]; if(col.ticketNamen[0][0] === "0") { ticketcode=col.ticketNamen[0][1]; name = col.ticketNamen[0][4]; title = name; color = "bgerror"; } else { ticketcode=col.ticketNamen[0][1]; disabled = "notes"; color = "bgblocked"; if(col.ticketNamen[0][5]=="1" && col.ticketNamen[0][6]=="1") { //color = "bgdevalued"; } if( col.ticketNamen[0][3] != UNDEF) { name = col.ticketNamen[0][3][0]; title = col.ticketNamen[0][3].join(","); if( col.ticketNamen[0][4] != UNDEF) { notiz = col.ticketNamen[0][4]; name += " " + col.ticketNamen[0][4]; title +=" " + col.ticketNamen[0][4]; } } } stylenamen='style="overflow:hidden;padding:0px 0px 0px 2px;color:white !important;cursor:help !important;"'; } } else if(col.anzahlticketsToPay > 0) { anyBooking=true; title = "Gebucht!"; if(col.ticketNamenToPay.length>0) { if(col.ticketNamenToPay[0][0] === "0") { ticketcode=col.ticketNamenToPay[0][1]; name = col.ticketNamenToPay[0][4]; title = name; color = "bgerror"; } else { disabled = "notes"; color = "bgreserved"; ticketcode=col.ticketNamenToPay[0][1]; if( col.ticketNamenToPay[0][3] != UNDEF) { name = col.ticketNamenToPay[0][3][0]; title = col.ticketNamenToPay[0][3].join(","); if( col.ticketNamenToPay[0][4] != UNDEF) { notiz = col.ticketNamenToPay[0][4]; name += " " + col.ticketNamenToPay[0][4]; title +=" " + col.ticketNamenToPay[0][4]; } } } stylenamen='style="overflow:hidden;padding:0px 0px 0px 2px;color:white !important;cursor:help !important;"'; } } else if(col.anzahlres > 0) { anyBooking=true; color = "bginfo"; title = "Bei einer Person im Warenkorb"; disabled = "disabled"; } else if(col.anzahlres==-1 && col.anzahltickets ==-1) { disabled = "disabled"; color = "bgblockslot"; title = "Nicht verfügbar"; if(col.text != "" && colcount > 0 && rowcount > 0) { title = col.text; name = col.text; } stylenamen='style="overflow:hidden;padding:0px 0px 0px 2px;color:black !important;"'; } else { title = "";//col.text; } if(rowcount >0 && colcount > 0) { bookingtext+=''; } else { if(past && rowcount > 0) { color = "past"; } else { color = ""; } var bgcolor = "overview-odd"; if(colcount%2==0) { bgcolor = "overview-even"; } inlinestyle = 'overview-tb '+ bgcolor; if(colcount == 0) { bookingtimecol = ''; bookingtext += bookingtimecol; } else { bookingtext+=''; } } colcount++; }); bookingtext+= bookingtimecol; bookingtext += ""; rowcount++; } }); bookingtext += "
'; bookingtext+= '
'; if(anyBooking) { bookingtext+= '
'; } bookingtext += '' +name + ''; bookingtext+= '
'+ col.text + ''+ col.text + '
"; bookingtext+= "aktualisiert am " + getFormatedDate(new Date()) +" " + getFormatedTime(new Date(),true) +""; $('#div_freeslots').html('').append(bookingtext); if(hasOVViewOnly() == false) { $(".timelinkoverview").click(function() { var isDisabled = $(this).hasClass("disabled"); var hasnotes = $(this).hasClass("notes"); if(hasnotes) { if(!$(this).hasClass('active')) { $('.bgerror').removeClass("active"); $(this).addClass('active'); clearInterval(overviewTimer); } else { $(this).removeClass('active'); if($('.active').length==0) { $('#div_blockMenue').css(CSS_DSP, CSS_NONE); } clearInterval(overviewTimer); overviewTimer = setInterval(loadOverViewFree, 60000); } $('#div_blockMenue').css(CSS_DSP, CSS_IN); $('#btnNotiz').css(CSS_DSP, CSS_IN); $('.btnBlock').css(CSS_DSP, CSS_NONE); $('#btnremblock').css(CSS_DSP, CSS_NONE); var title = $(this).data('notiz'); $('#inp_ticketinfo').val(title); } else if(!isDisabled) { $('.btnBlock').css(CSS_DSP, CSS_IN); $('#div_blockMenue').css(CSS_DSP, CSS_IN); $('#btnNotiz').css(CSS_DSP, CSS_NONE); var title = $(this).attr('title'); $('#inp_ticketinfo').val(title); if(title != "") { $('#btnremblock').css(CSS_DSP, CSS_IN); } else { $('#btnremblock').css(CSS_DSP, CSS_NONE); } if(!$(this).hasClass('active')) { $('.notes').removeClass("active"); $(this).addClass('active'); clearInterval(overviewTimer); } else { $(this).removeClass('active'); if($('.active').length==0) { $('#div_blockMenue').css(CSS_DSP, CSS_NONE); } clearInterval(overviewTimer); overviewTimer = setInterval(loadOverViewFree, 60000); } if(!user.infoan.includes("admin")) { ba = new Warenkorb(); var time = $(this).data("item"); var subitem = $(this).data("subitem"); var combined = subitem + "_" + time; var times= []; var temp = getWS(WS_BTIME); if(!isNullOrEmpty(temp)) { try { times = JSON.parse(temp); } catch { times=[]; } } if(!times.includes(combined)) { times.push(combined); } else { var index = times.indexOf(combined); times.splice(index, 1); } times.sort(); setWS(WS_BTIME,JSON.stringify(times)); var itemnbr = $(this).data("artikel"); setWS(WS_BTARIF,itemnbr); articles.forEach(function(a) { if(a.itemnbr == itemnbr) { if(a.type != 2) { var selectedtime = getWS(WS_BTIME); var selectedtimes = JSON.parse(selectedtime); var timeAmount = {}; var timeBahnen = {}; var times = []; selectedtimes.forEach(elm => { var split = elm.split("_"); if(times.includes(split[1])== false) { times.push(split[1]); timeAmount[split[1]] = 0; timeBahnen[split[1]] = []; } timeAmount[split[1]] +=1; timeBahnen[split[1]].push(split[0]); }); var subitems = []; iamount = 0; times.forEach(time => { if(a.subItemRequired==1) { var subitem = new SubItem(timeAmount[time], time, timeBahnen[time].join(",")); iamount+= timeAmount[time]; subitems.push(subitem); } else { var subitem = new SubItem(1, time, timeBahnen[time].join(",")); subitems.push(subitem); } }); if(a.subItemRequired==1) { ba[itemnbr] = new Booking(itemnbr, iamount, UNDEF,subitems); } else { ba[itemnbr] = new Booking(itemnbr, 1, UNDEF,subitems); } } } }); saveWK(); navigate(P_BOOKING); refreshWK(); } } }); } } else { $('#div_freeslots').css(CSS_DSP,CSS_NONE); } }, error: function(err){ console.log(err); } }); } 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 CheckAmounts() { } function initFormBooking() { checkRefreshNeeded(); var bookingstartdate = getMinDate(); var bookingstep = getWS(WS_BOOKINGSTEP); if(bookingstep == UNDEF || bookingstep == 0){bookingstep = RES_NBR1;} var tempdate = getWS(WS_BDATE); 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); $(".block").removeClass("block"); $(".active").removeClass("active"); $(".stemp").removeClass("step-enabled"); $('#booking_' + bookingstep).addClass(CSS_B); $('#step_' + bookingstep).addClass('active'); if(WKTIMERVALUE > 0 && wktimer == undefined) { wktimer = setInterval(reduceWKTimer, 1000); } else { $('.timeslot').css(CSS_DSP, CSS_NONE); } $('#chk_oneHouse').change(function() { oneHousehold = this.checked; CheckAmounts(); setWS(WS_OHH,this.checked); }); //Setze den Titel des Untermenüs if(bookingstep == RES_NBR1) { setWS("transaction", ""); $('#booking_title').html("Tagesauswahl"); loadCalendar(); } else if(bookingstep == 2) { if(ALM==2) { if(comingfrom==3) { back(); } else { next(); } } if(ba.hasDay(datetoshow)==false) { back(); return; } $('#booking_title').html("Zeitfensterauswahl"); $('#2_selectedday').html(datetoshow); loadTimes(); } else if(bookingstep == 3) { $('#booking_title').html("Tarifauswahl"); $('#3_selectedday').html(datetoshow); $('#3_selectedtime').html(temptime + " Uhr bis " + temptimeend + " Uhr"); if(ba.hasDay(datetoshow)==false) { back(); return; } if(ALM==2) { $("#booking_tarif").change(function() { setArticleInfos(); setTimes(datetoshow); }); $.when(loadArtikel()).done(function(a1) { setTimes(datetoshow); }); setNextButton(); } else { $.when(loadTarife()).done(function(a1) { drawTarife(); }); } } else if(bookingstep == 4) { setWS("transaction", ""); $('#4_selectedday').html(datetoshow); $('#4_selectedtime').html(temptime + " Uhr bis " + temptimeend + " Uhr"); var amount = ba.getAmountAnyArticles(); if(amount <=0) { back(); } if( amount == RES_NBR1) { $('#booking_title').html("Für wen möchtest du das Ticket?"); } else { $('#booking_title').html("Für wen möchtest du die Tickets?"); } } else if(bookingstep == 5) { var amount = ba.getAmountAnyArticles(); if(amount <=0) { back(); } $('#booking_title').html("Warenkorb"); $('#btnWKArtikelAmount').html('(' + amount + ') Artikel'); } else if(bookingstep == 6) { setWS("transaction", ""); $('#booking_title').html("Wie möchtest du bezahlen?"); } //Erfrische die Anzeige der durchgeführten Steps for(var i = RES_NBR1;i .ok').addClass('glyphicon glyphicon-ok'); $('#step_' + i).addClass('step-enabled'); $('#step_' + i).addClass('step'+i+'-finish'); } if(ba.hasAnyArticle()) { $('#step_5').addClass('step-enabled'); } if(bookingstep == 4) { drawPersonalData(); } else if(bookingstep == 5) { drawWarenkorb(); } else if(bookingstep == 6) { if(isNullOrEmpty(getWS(WS_BDATE))){back();} if(ba == UNDEF || ba.hasAnyArticle() == false) {back();} $.when(checkIfArtikelFree()).done( function(a2) { if(a2 == false || a2 <=0) { alert("Es tut uns leid, aber der gewählte Warenkorb ist nicht mehr verfügbar!"); ba = new Warenkorb(); cleanWK(); setWS(WS_WKT, Date.now()); setWS(WS_PWC, ""); setWS(WS_PWCA, ""); $('#booking_time').html(""); back(); } $.when(checkIfSlotUsed(true)).done(function (a3) { if(a3 ==false) { alert("Es tut uns leid, aber der gewählte Warenkorb ist nicht mehr verfügbar! (Slotprüfung)"); ba = new Warenkorb(); cleanWK(); setWS(WS_WKT, Date.now()); setWS(WS_PWC, ""); setWS(WS_PWCA, ""); $('#booking_time').html(""); back(); } var anyset = false; var paywithCredit = isCreditSet(); //console.log(ba); ba.getAllArticle().forEach(function(a){ a.rabattCode = ba.rabattCode; a.wertkarte = ba.wertkarte; anyset = true; if((a.isWertkartenArtikel() || a.isKeinEintrittArtikel()) && a.amount >0) // .== 3 { } else if(a.amount <0) { //console.log(a); paywithCredit=true; } }); if(!anyset){back();} if(ba.wertkarte != UNDEF) { paywithCredit=true; } var summe = 0; var creditsumme = 0; var purchaseunits = {}; var items = []; var wkitems = []; ba.getAllArticle().forEach(function(a){ var price = 0; var singleprice = 0; if(a.credit != UNDEF && a.credit > 0 ) { if(a.amount >0) { price = a.credit*a.amount; } singleprice = a.credit; } else { singleprice = a.getSinglePrice().toFixed(2); price = a.getTotalPrice(); } var artikelcesription = a.description ; if(a.credit != UNDEF && a.credit > 0) { artikelcesription += " (" + a.credit +" €)"; } else { artikelcesription += " (" +price.toFixed(2) +" €)"; } if(a.subItemRequired == 1) { artikelcesription += " (Bahn " + a.subItem + ")"; } summe += price; var item = { name:artikelcesription , quantity: a.amount, category: "DIGITAL_GOODS", item_number:a.itemnbr}; item.tax= {currency_code : EUR, value :"0"}; item.unit_amount= {currency_code : EUR, value :singleprice}; items.push(item); }); var restsumme = summe; var allesbezahlt = false; if(paywithCredit) { creditsumme= Math.min(ba.wertkarte.credit,summe).toFixed(2); if(summe.toFixed(2) == creditsumme) { allesbezahlt=true; restsumme =0; } else { restsumme -= creditsumme; var item = { name:"Wertguthaben (" + creditsumme + "€)" , quantity: -1, category: "DIGITAL_GOODS", item_number:getWS(WS_PWCA)}; item.tax= {currency_code : EUR, value :"0"}; item.unit_amount= {currency_code : EUR, value :creditsumme}; wkitems.push(item); } } var total = (summe-creditsumme).toFixed(2); summe = summe.toFixed(2); creditsumme = Number(creditsumme).toFixed(2); if(allesbezahlt) { total = "0.00"; } purchaseunits.amount = {currency_code:EUR, value : total}; purchaseunits.amount.breakdown = {}; purchaseunits.amount.breakdown.item_total = {currency_code : EUR, value :summe}; purchaseunits.amount.breakdown.tax_total = {currency_code : EUR, value :"0"}; purchaseunits.amount.breakdown.shipping_discount = {currency_code : EUR, value :creditsumme}; purchaseunits.items = items; if(!paywithCredit || (creditsumme > 0 && restsumme > 0)) { if(paypal != UNDEF) { logit("paypalbuttons generated"); paypal.Buttons({ createOrder: function(data, actions) { logit("createOrder"); return fetch('./v2.0/payment.php', { mode: "no-cors", method: 'post', headers: { 'content-type': 'application/json', 'X-CSRFToken': $('[name=csrfmiddlewaretoken]').val() } }).then(function(res) { return res.json(); }).then(function(orderData) { logit(orderData); return orderData; }); }, commit: false, onApprove: function(data, actions) { logit(data.paymentID + " approved"); return fetch('./v2.0/checkout.php?success=true&paymentId=' + data.paymentID + '&PayerID=' + data.payerID+ '&OrderID=' + data.orderID , { method: 'post' }).then(function(res) { return res.json(); }).then(function(orderData) { logit(orderData); var errorDetail =UNDEF; if(Array.isArray(orderData.details)) { errorDetail= JSON.parse(orderData.details[0]); } if (errorDetail && errorDetail.issue === 'INSTRUMENT_DECLINED') { return actions.restart(); } if (errorDetail && errorDetail.name === 'DUPLICATE_TRANSACTION') { $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "clean"}, method: POST, async: false, success: function(e) { back(); } }); } if (errorDetail) { var msg = 'Tut uns leid, deine Bestellung konnte nicht verarbeitet werden.'; if (errorDetail.message) msg += '\n\n' + errorDetail.message; if (orderData.debug_id) msg += ' (' + orderData.debug_id + ')'; return alert(msg); } next(); }); }, onError: function(data) { console.log("error"); console.log(data); logit("error"); logit(data); alert("Fehler beim der Verarbeitung von Paypal. Bitte noch einmal versuchen. (" + data + ")") }, locale: 'de_DE', }).render('#paypal-button-container'); // Display payment options on your web page } else { alert("Zahlungsmöglichkeiten konnten nicht geladen werden. Bitte neu laden oder den Cache Ihres Browsers leeren."); } } var c = '

Dein Warenkorb ist noch x Minuten für dich reserviert.

'; c += "

Artikel kostenpflichtig bestellen:

"; var sendmode = getWS(WS_SM); sendmode = "mail"; if(sendmode == "mail") { c += '

Bitte prüfe die untenstehende(n) E-Mailadresse(n) auf Korrektheit.

'; var allEmails = ""; var komma = ""; ba.getAllPersons().forEach(function(p) { if(allEmails.indexOf(p.email) == -1) { allEmails += komma + "[" + p.email + "]"; komma = ", "; } }); if(allEmails =="") { allEmails = "[" +user.email + "]"; } c += '

Die Zustellung der Tickets erfolgt per E-Mail an ' + allEmails + "

"; } else{ c += "

Die Zustellung der Tickets erfolgt per WhatsApp/SMS an " + persons[0].mobile + "

"; } c += "

Artikel:

    "; purchaseunits.items.forEach(function(i) { if(i.quantity>0) { c += "
  • " + i.quantity + "x " + i.name + "
  • "; } else { c += "
  • " + i.quantity + "x " + i.name + '
  • '; } }); c += "
"; if(purchaseunits.amount.breakdown.shipping_discount.value > 0) { c += "

Es werden " + new Intl.NumberFormat('de-DE', { style: 'currency', currency: purchaseunits.amount.currency_code }).format(purchaseunits.amount.breakdown.shipping_discount.value) + " mit Guthaben verrechnet.

"; } if(ba.rabattCode != UNDEF) { c += '

Verwendeter RabattCode: ' + ba.rabattCode.code + "

"; } c += '

Summe: ' + new Intl.NumberFormat('de-DE', { style: 'currency', currency: purchaseunits.amount.currency_code }).format(purchaseunits.amount.value) + "

"; $('#prebooking_details').html(c); $('.remove').click(function () { var value = $(this).data("item"); remove(value); location.reload(); }); if(!isLogedIn()) { $('#div_payment_methods').append(''); $('.toLogin').click(function() { navigate(P_MYTICKET); }); } else if(!paywithCredit) { var c2 = '
'; c2 += '
'; c2 += 'Wähle in deinem persönlichen Bereich eine Wertkarte aus, um damit zu bezahlen.'; c2 += '
'; c2 += '
'; $('#div_payment_methods').append(c2); $('#divSearchCoupon').on('click', function() { navigate(P_MYTICKET);}); } else { if(ba.wertkarte != UNDEF) { var restcredit =ba.wertkarte.credit-creditsumme; if(restcredit >= 0) { var c = ''; if(restcredit >=0) { c += '
'; c += '
'; c += ' Mit Wertkarte bezahlen (Restguthaben ' + restcredit.toFixed(2) + ' €)'; c += '
'; c += '
'; } c += '
'; c += '
'; c += ' Nicht mit Wertkarte bezahlen.'; c += '
'; c += '
'; $('#div_payment_methods').append(c); $('#addCreditValue').click(function() { addCreditValue(); }); } else { var c = '
'; c += '
'; c += ' Guthaben reicht nicht aus.'; c += '
'; c += '
'; $('#div_payment_methods').append(c); $('#paypal-button-container').remove(); } $('.remove').click(function () { var value = $(this).data("item"); remove(value); location.reload(); }); $('.removeCreditValue').click(function() { removeCreditValue(); }); } } setWS(WS_PWC, ""); setWS(WS_PWCA, ""); if(WKTIMERVALUE == 0) { $('.timeslot').css(CSS_DSP, CSS_NONE); } }); }); } else if(bookingstep == 7) { var ts = getTransaction(); if(isNullOrEmpty(ts)) { back(); } else { $('#booking_title').html("Buchung erfolgreich abgeschlossen"); var details = JSON.parse(ts); if(details.status == "COMPLETED") { var d = new Date(details.update_time); const ye = new Intl.DateTimeFormat('de', { year: 'numeric' }).format(d); const mo = new Intl.DateTimeFormat('de', { month: '2-digit' }).format(d); const day = new Intl.DateTimeFormat('de', { day: '2-digit' }).format(d); var cont = '

Bestellung erfolgreich durchgeführt. Du erhältst in Kürze deine Bestellung per E-Mail.

'; cont += "

Gekauft am : " + day + "." + mo + "." +ye + "

"; cont += "

Gekaufte Artikel:

    "; details.purchase_units.forEach(function(i) { if(i.subItemRequired==1) { cont += "
  • " + i.amount + "x " + i.description + " (Bahn " + i.subItem + ")
  • "; }else { cont += "
  • " + i.amount + "x " + i.description + "
  • "; } }); cont += "
"; if(details.creditsumme > 0) { cont += "

Es wurden " + new Intl.NumberFormat('de-DE', { style: 'currency', currency: "EUR" }).format(details.creditsumme) + " mit Guthaben verrechnet.

"; } cont += '

Summe: ' + formatPrice(details.endsumme) + "

";//+ " " + details.purchase_units[0].amount.currency_code $('#booking_details').html(cont); ba = new Warenkorb(); cleanWK(); setWS(WS_WKT, Date.now()); setWS(WS_PWC, ""); setWS(WS_PWCA, ""); saveWK(); } } } } function logit(data) { $.ajax({ url: PHP_LOG, cache: false, data: {"logdata": data}, method: POST, async: false, success: function(e) { } }); } function setTimes(date, refresh=true) { if(new Date() Buchungsystem noch nicht freigegeben'); $('#booking_tarif').find('option').remove(); return; } $('#booking_time').html(''); $('.spacedisplay').css(CSS_DSP,CSS_NONE); var userid = 0; if(user != UNDEF) { userid = user.idcustomer; } var itemnbr = getWS(WS_BTARIF); if(itemnbr ==0) { itemnbr = $('#booking_tarif').val(); } return $.ajax({ type: POST, url: PHP_MAIN, data: {"seatsdefine": "daymatrixartikel", "date":date, "ba": itemnbr, "userid": userid, "pbk":getWS(WS_PBK)}, method: POST, dataType: 'json', cache: false, success: function (res) { if(res != "" && res != "0") { var td = new Date(); var today = getFormatedDate(td); var time = getFormatedTime(td); var isToday = false; if(date == today) { isToday=true; } var selectedtime = getWS(WS_BTIME); var selectedtimes = JSON.parse(selectedtime); var selectedsubitem = getWS(WS_SUBTARIF); $('#booking_time').css(CSS_DSP,CSS_B); $('#booking_time_label').css(CSS_DSP,CSS_B); var selected = "";//no Preselect var disabled = ""; if(!isNullOrEmpty(selectedtime) && selectedtime != NULL) { selected = ""; } if(isNullOrEmpty(selectedsubitem) || selectedsubitem == NULL) { selectedsubitem = RES_SUCCESS; } var bookingtext =''; var maxcols = 0; res.forEach(function(sd) { if(sd.articlesubItemRequired==1 && parseInt(sd.max_acc) > parseInt(maxcols)) { maxcols = parseInt(sd.max_acc); } else if(sd.articlesubItemRequired==0) { maxcols = 1; } }); if (res.length > 0) { bookingtext+=""; for(var i = 0;i<=maxcols;i++) { if (i==0) { bookingtext+=''; } else { if(maxcols==1) { bookingtext+=''; } else { bookingtext+=''; } } } bookingtext+=""; } res.forEach(function(sd) { bookingtext+=""; bookingtext+=''; for(var i = 1;i<=maxcols;i++) { disabled = ""; if(selectedtimes!= UNDEF && selectedtimes.includes(i + "_" + sd.time)) { selected = "active"; } if(isToday && sd.time_end < time) { disabled =DISABLED; selected = ""; if(selectedtime == sd.time) { selectedtime = ""; } } var color = "success"; if(sd.reservations.includes(i.toString())) { color = "bginfo"; } if(sd.tickets.includes(i.toString()) || sd.tickets.includes('full') || sd.ticketsToPay.includes(i.toString())) { color = "bgerror" disabled = DISABLED; selected = "false"; removeTime(sd.time,i); } if(disabled == DISABLED) { //color = "bginfo" } if(selectedtimes!= UNDEF && selectedtimes.includes(i + "_" + sd.time)) { selected = "active"; } bookingtext+=''; selected=""; } bookingtext+=""; }); bookingtext += "
ZeitenBahn ' + i + '
' + sd.time + '
"; $('#booking_time').html('').append(bookingtext); $(".timelink").click(function() { var isDisabled = $(this).hasClass(DISABLED); if(!isDisabled) { var value = $(this).data("item"); var subvalue = $(this).data("subitem"); if(toggleTime(value,subvalue)) { $(this).addClass('active'); } else { $(this).removeClass('active'); } $('#booking_amount').val(countPersons()); var tempdate = getWS(WS_BDATE); var datetoshow = ""; showDiscountScale(); } }); $('#booking_amount').val(countPersons()); } else { if(res == "") { $('#booking_time').html("

Aufgrund einer Veranstaltung kann dieser Stand nicht gebucht werden.

"); } else { $('#booking_time').css(CSS_DSP,CSS_NONE); } $('#booking_time_label').css(CSS_DSP,CSS_NONE); } } }); } function drawPersonalData() { if(ba != UNDEF && ba.getArticleZumzeitpunkt()!= UNDEF) { var anypersonrequired = false; var cont = ''; if(ALM==2) { var zeiten = ba.getZeitenZumTag(); if(zeiten != UNDEF) { zeiten.sort((a,b) => (a.time > b.time) ? 1 : ((b.time > a.time) ? -1 : 0)) //console.log(zeiten); zeiten.forEach(zeit => { ba.actTime=zeit.time; ba.actTimeEnd = zeit.timeEnd; if(ba.hasAnyArticleZumZeitpunkt()==false) { return; } cont +=""; cont += '
'; ba.getArticleZumzeitpunkt().forEach(at => { //console.log(at); if(at.amount <=0) { //console.log(ba); $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "removeArticle", "article":at.itemnbr, "subItem":at.subItem, "tag": ba.actDate, "time":zeit.time, "timeend":zeit.timeEnd}, method: POST, async: false, success: function(e) { if(e == "1") { ba.getDay(ba.actDate).getZeit(zeit.time, zeit.timeEnd).removeArticle(at.itemnbr, at.subItem); saveWK(); var amount = ba.getAmountAnyArticles(); //console.log("amount", amount); if(amount <=0) { back(); } $('#btnWKArtikelAmount').html('(' + amount + ') Artikel'); } else if(e == "11") { location.reload(); } } }); return; } if(at.customerRequired > 0) { anypersonrequired=true; var gebdatoptional = (at.customerRequired == 1); for(var i = 0;ii) { person = at.persons[i]; } var idparent = (ba.actDate + '_' + ba.actTime + '_' + ba.actTimeEnd + '_' + at.itemnbr + '_' + at.subItem + '_' + i ).replaceAll(".","").replaceAll(":",""); cont += '
'; cont += '
'; cont += '
'; } var articledesc = at.description; if(at.itemnbr == BIRTHDAYPARENT) { articledesc += " (Name des Geburtstagskindes)"; } cont+='

✖ Artikel löschen

'; cont +='
' + articledesc + '
' var infotext = at.infotext; if(isNullOrEmpty(infotext))infotext="-"; if(at.subItem>0 && at.subItemRequired==1) { infotext += ' (Bahn ' + at.subItem + ')'; } cont +='
' +infotext + '
' cont +='

' + formatPrice(at.getSinglePrice()) + '

' cont += '
'; cont += '
' cont += ''; var display=""; var displayGebdat = ""; if(isselected) { display='style="display:none;"'; displayGebdat='style="display:none;"'; } if(!NEEDSBIRTHDAY) { displayGebdat='style="display:none;"'; } var firstname = ""; var lastname = ""; var geburtstag = ""; var email =""; if(person != UNDEF && person.idcustasp == -1) { firstname=person.prename; lastname=person.name; geburtstag=person.gebdat; email=person.email; } else if(person != UNDEF && person.idcustasp == 0) { geburtstag=person.gebdat; } if(person != UNDEF && person.gebdat == "" && !gebdatoptional) { displayGebdat = ""; } else if(isselected == true && !gebdatoptional && ((person == UNDEF && user.gebdat =="") || (person.idcustasp == 0 && person.gebdat ==""))) { displayGebdat = ""; } var optionalstring = ""; if(gebdatoptional) { optionalstring = " (Optional)"; } cont += '
'; cont += '
'; cont += '
'; cont += '
'; cont += '
'; cont += '
'; cont += '
'; cont += '
'; cont += '
'; } } }); cont+="
"; cont += "
"; }); } } else { cont = '
'; ba.getArticleZumzeitpunkt().forEach(at => { if(at.customerRequired > 0) { anypersonrequired=true; var gebdatoptional = (at.customerRequired == 1); for(var i = 0;ii) { person = at.persons[i]; } cont += '
'; cont += '
'; cont += '
'; } var articledesc = at.description; if(at.itemnbr == BIRTHDAYPARENT) { articledesc += " (Name des Geburtstagskindes)"; } cont +='
' + articledesc + '
' var infotext = at.infotext; if(isNullOrEmpty(infotext))infotext="-"; if(at.subItem>0) { infotext += " (Bahn " + at.subItem + ")"; } cont +='
' +infotext + '
' cont +='

' + formatPrice(at.getSinglePrice()) + '

' cont += '
'; cont += '
' cont += ''; var display=""; var displayGebdat = ""; if(isselected) { display='style="display:none;"'; displayGebdat='style="display:none;"'; } if(!NEEDSBIRTHDAY) { displayGebdat='style="display:none;"'; } var firstname = ""; var lastname = ""; var geburtstag = ""; var email =""; if(person != UNDEF && person.idcustasp == -1) { firstname=person.prename; lastname=person.name; geburtstag=person.gebdat; email=person.email; } else if(person != UNDEF && person.idcustasp == 0) { geburtstag=person.gebdat; } if(person != UNDEF && person.gebdat == "" && !gebdatoptional) { displayGebdat = ""; } else if(isselected == true && !gebdatoptional && ((person == UNDEF && user.gebdat =="") || (person.idcustasp == 0 && person.gebdat ==""))) { displayGebdat = ""; } var optionalstring = ""; if(gebdatoptional) { optionalstring = " (Optional)"; } cont += '
'; cont += '
'; cont += '
'; cont += '
'; cont += '
'; cont += '
'; cont += '
'; cont += '
'; cont += '
'; } } }); cont+="
"; } if(anypersonrequired == false) { console.log("no customer required total"); if(comingfrom==3) { next(); } else { back(); } } $('#booking_form_contacts').html(""); $('#booking_form_contacts').append(cont); var previous; $('.aspselect').on('focus', function () { // Store the current value on focus and on change //console.log("focus" + this.value); previous = this.value; }).change(function () { var thisid = $(this).attr("id"); var SelectedValue = $(this).val(); //console.log(SelectedValue + " (" + previous + ")"); if(SelectedValue>=0) { if(VALIDATEPERSONALDATABYDAY==false) { $('.div_' + thisid).hide(); $('.aspselect').each(function( index ) { if($(this).attr("id") != thisid) { var pickedOption = "#" + $(this).attr("id") + " option[value=" + SelectedValue + "]"; $(pickedOption).hide(); var pickedOption = "#" + $(this).attr("id") + " option[value=" + previous + "]"; $(pickedOption).show(); } }); } else { //console.log($(this).parent(':last-child').children(':last-child').children()); $(this).parent(':last-child').children(':last-child').children().each(function( index ) { //console.log($(this).attr("id")); $(this).hide(); }); } if(SelectedValue == 0) { if(user != UNDEF && user.gebdat =="" && NEEDSBIRTHDAY) { $('#' + thisid.replace("selectcustasp_", "div_gebdat_")).show(); } } else if(custasp != UNDEF && custasp.length > 0) { custasp.forEach(function(asp) { if(asp.id_cust_asp == SelectedValue) { if(asp.gebdat == "" && NEEDSBIRTHDAY) { $('#' + thisid.replace("selectcustasp_", "div_gebdat_")).show(); } } }); } } else { $('.div_' + thisid).show(); $('.aspselect').each(function( index ) { if($(this).attr("id") != thisid) { var pickedOption = "#" + $(this).attr("id") + " option[value=" + previous + "]"; $(pickedOption).show(); } }); } }); $('.delFromPD').click(function () { var tag = $(this).data("tag"); var time = $(this).data("time"); var timeEnd = $(this).data("timeend"); var itemnbr = $(this).data("itemnbr"); var subItem = $(this).data("subitem"); var lfnr = $(this).data("lfnr"); var idparent = (tag + '_' +time + '_' + timeEnd + '_' + itemnbr + '_' + subItem + "_" + lfnr).replaceAll(".","").replaceAll(":",""); $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "decreaseArticle", "article":itemnbr, "subItem":subItem, "tag": tag, "time":time, "timeend":timeEnd}, method: POST, async: false, success: function(e) { if(e == "1") { ba.getDay(tag).getZeit(time, timeEnd).decreaseArticle(itemnbr, subItem); saveWK(); //drawPersonalData(); $("#" + idparent).remove(); var amount = ba.getAmountAnyArticles(); if(amount <=0) { back(); } $('#btnWKArtikelAmount').html('(' + amount + ') Artikel'); } else if(e == "11") { location.reload(); } } }); }); } else { console.log("no data"); //Wenn der Warenkorb nicht gefüllt ist, gehe zu Schritt 2 back(); } } function drawWarenkorb() { var warenkorb = ""; if(ba != UNDEF) { var summe = 0; var counterdays = 0; var isGoingBack = false; ba.tage.forEach(function(tag){ if(tag.hasAnyArticle()==false) { return; } if(counterdays>0) { warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; } counterdays++; tag.times.forEach(function(time){ if(time.hasAnyArticle()) { warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+=' '; warenkorb+=' '; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; time.articles.forEach(function(article){ //console.log(article); article.setRabattcode(ba.rabattCode); article.setWertkarte(ba.wertkarte); summe+=article.getTotalPrice(); warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='

' +article.amount + 'x ' + article.description + '

'; var counter = 0; if(!isGoingBack && article.customerRequired >= 1 && article.persons.length <=0) { console.log("a required Person is not set"); isGoingBack=true; ba.getDay(tag.date).getZeit(time.time, time.timeEnd).removeArticle(article.itemnbr, article.subItem); back(); return; } article.persons.forEach(function(person){ if(counter '; counter++; } }) warenkorb+='
'; warenkorb+='
'; warenkorb+='

' + formatPrice(article.getTotalPrice()) + '

'; warenkorb+='
'; warenkorb+='

✖ Artikel löschen

'; warenkorb+='
'; warenkorb+='
'; }) } }) }); warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
Rabatt-Code:
'; warenkorb+='
'; warenkorb+='
'; warenkorb+=''; warenkorb+='
'; warenkorb+='
'; warenkorb+=''; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+=''; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; if(ba.wertkarte != UNDEF) { var description = "Wertkarte"; if(ba.wertkarte.description != UNDEF) { description = ba.wertkarte.description.split(" ")[0]; } var dis = Math.min(ba.wertkarte.credit, summe); warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='

verrechnet mit ' + description+ '

'; warenkorb+='
'; warenkorb+='
'; warenkorb+='

' + formatPrice(-dis) + '

'; warenkorb+='
'; warenkorb+='

✖ ' + description + ' löschen

'; warenkorb+='
'; summe = summe-dis; } warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; warenkorb+='

Summe:

'; warenkorb+='
'; warenkorb+='
'; warenkorb+='

' + formatPrice(summe) + '

'; warenkorb+='
'; warenkorb+='
'; warenkorb+='
'; $('#chart_details').html(warenkorb); if(ba.rabattCode != UNDEF) { $('#booking_rabattcode').val(ba.rabattCode.code); $('#hinweis_rabattcode').text(ba.rabattCode.hinweistext); } $('.delfromWK').click(function () { var tag = $(this).data("tag"); var time = $(this).data("time"); var timeEnd = $(this).data("timeend"); var itemnbr = $(this).data("itemnbr"); var subItem = $(this).data("subitem"); $.ajax({ url: PHP_MAIN, cache: false, data: {"wk": "removeArticle", "article":itemnbr, "subItem":subItem, "tag": tag, "time":time, "timeend":timeEnd}, method: POST, async: false, success: function(e) { if(e == "1") { ba.getDay(tag).getZeit(time, timeEnd).removeArticle(itemnbr, subItem); saveWK(); drawWarenkorb(); var amount = ba.getAmountAnyArticles(); if(amount <=0) { back(); } $('#btnWKArtikelAmount').html('(' + amount + ') Artikel'); } else if(e == "11") { location.reload(); } } }); }); $('.removeCreditValueWK').click(function() { setWS(WS_PWC, ""); setWS(WS_PWCA, ""); setWS(WS_DA, RES_SUCCESS); ba.wertkarte = UNDEF; saveWK(); drawWarenkorb(); }); $('#check_rabattcode').on('click',function(e){ var code = $('#booking_rabattcode').val(); CheckRabattCode(code); }); } else { back(); } } function CheckRabattCode(code) { var fdata = new FormData(); fdata.append("rabattcode", "check"); fdata.append("code", code); $.ajax({ type: POST, url: PHP_MAIN, data: fdata, dataType: 'json', contentType: false, cache: false, processData:false, success: function (res) { if(res == "-1") { ba.rabattCode=UNDEF; } else if (res == "0") { ba.rabattCode=UNDEF; setError("booking_rabattcode"); $('#hinweis_rabattcode').text("Der Rabattcode ist nicht gültig"); } else { ba.rabattCode=res; } saveWK(); drawWarenkorb(); } }); } function loadCalendar() { var numWeeks = BOOKINGLENGTH; if(user != UNDEF && user != null) { if(user.hasVIP) { numWeeks = BOOKINGLENGTHVIP; } } var bookingenddate = new Date(); var bookingstartdate = getMinDate(); if(numWeeks == 0) { bookingallowed=false; } bookingenddate.setDate(bookingenddate.getDate() + numWeeks * 7); var calendarEl = document.getElementById('calendar'); var calendar = new FullCalendar.Calendar(calendarEl, { initialView: 'dayGridMonth', header: { left: ' title', right:'today,prev,next' }, validRange: { start:bookingstartdate, end:bookingenddate }, locale:'de', droppable: false, weekends: true, allDaySlot: true ,dateClick: function(date, jsEvent, view) { /*console.log("===== dayClick ====="); console.log(date); console.log(date.dayEl.getElementsByClassName("fc-daygrid-day-events")[0].childElementCount); console.log(date.date); console.log("===== dayClick END =====");*/ if(date.dayEl.getElementsByClassName("fc-daygrid-day-events")[0].childElementCount>1) { var datetosave = getFormatedDate(date.date); setWS(WS_BDATE,datetosave); ba.addTag(datetosave); saveWK(); next(); } } ,eventClick: function(calEvent, jsEvent, view) { var datetosave = calEvent.event._def.publicId; setWS(WS_BDATE,datetosave); ba.addTag(datetosave); saveWK(); next(); }, loading: function(isLoading) { if(isLoading) { $('#calendar').css("pointer-events", "none"); $('#css_loader').show(); } else { $('#calendar').css("pointer-events", "auto"); $('#calendar').css("opacity",1); $('#css_loader').hide(); } }, eventSources:[ { url: PHP_MYFEED, method:'POST', extraParams: function() { // a function that returns an object return { }; }, failure: function() { alert('Die Öffnungszeiten konnten nicht abgerufen werden!'); } }] }); calendar.render(); } 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 || lastrefresh3) { //console.log("clean2"); ba = new Warenkorb(); cleanWK(); setWS(WS_WKT, Date.now()); setWS(WS_PWC, ""); setWS(WS_PWCA, ""); back(); } return; } } $('.timeslot').css(CSS_DSP, CSS_INB); const millis = Date.now() - wskt; if(WKTIMERVALUE-millis < 0) { //console.log("clean1"); clearInterval(wktimer); ba = new Warenkorb(); cleanWK(); setWS(WS_WKT, Date.now()); setWS(WS_PWC, ""); setWS(WS_PWCA, ""); back(); } $('.wktimer').html(msToTime(WKTIMERVALUE-millis)); } function msToTime(duration) { //var milliseconds = parseInt((duration % 1000) / 100), seconds = Math.floor((duration / 1000) % 60), minutes = Math.floor((duration / (1000 * 60)) % 60), //hours = Math.floor((duration / (1000 * 60 * 60)) % 24); //hours = (hours < 10) ? "0" + hours : hours; minutes = (minutes < 10) ? "0" + minutes : minutes; seconds = (seconds < 10) ? "0" + seconds : seconds; return minutes + ":" + seconds; // + "." + milliseconds; } function getCreditvalue() { user = setUserFromWS(); if(user != UNDEF) { if(getWS(WS_PWCA)== "") { var urltocall = PHP_MAIN; return $.ajax({ type: POST, url: urltocall, async: false, data: {"credits": "hasCredit", "logedin": isLogedIn()}, method: POST, dataType: 'json', cache: false, success: function (res) { return res; } }); } else { var urltocall = PHP_MAIN; return $.ajax({ type: POST, url: urltocall, async: false, data: {"credits": "hasCredit", "idticket":getWS(WS_PWC)}, method: POST, dataType: 'json', cache: false, success: function (res) { ba.wertkarte =res; } }); } } return 0; } function getArticle(itemnbr) { var urltocall = PHP_MAIN; return $.ajax({ type: POST, url: urltocall, async: false, data: {"article": "single", "itemnbr": itemnbr}, method: POST, dataType: 'json', cache: false, success: function (res) { return res; } }); return UNDEF; } function removeCreditValue() { $.ajax({ type: POST, url: PHP_MAIN, async: false, data: {"wk": "removeCreditValue"}, method: POST, dataType: 'json', cache: false, success: function (res) { } }); setWS(WS_PWC, ""); setWS(WS_PWCA, ""); setWS(WS_DA, RES_SUCCESS); ba.wertkarte = UNDEF; saveWK(); location.reload(); } function addCreditValue() { $.ajax({ type: POST, url: PHP_MAIN, data: {"wk": "finish"}, method: POST, dataType: 'json', cache: false, success: function (res) { if(res == "1") { setWS(WS_PWC, ""); setWS(WS_PWCA, ""); next(); } } }); } function getUsage(selectedDate, selectedTime, selectedTarif) { var returnval = 0 returnval = loadusage(selectedDate, selectedTime, selectedTarif); var retobj = JSON.parse(returnval); return retobj.free; } function loadusage(selectedDate, selectedTime, selectedTarif) { return $.ajax({ type: POST, url: PHP_MAIN, data: {"booking": "usage", "date": selectedDate, "time": selectedTime, "refitem": selectedTarif}, method: POST, dataType: 'json', cache: false, async:false, success: function (res) { } }).responseText; } function setUsage() { return; } function loadTimes() { if(new Date() Buchungsystem noch nicht freigegeben'); return; } var date = getWS(WS_BDATE); $('#booking_time').html(''); $('.spacedisplay').css(CSS_DSP,CSS_NONE); return $.ajax({ type: POST, url: PHP_MAIN, data: {"seatsdefine": "daymatrixartikel", "date":date, "ba": getWS(WS_BTARIF)}, method: POST, dataType: 'json', cache: false, success: function (res) { if(res != "0") { var td = new Date(); var today = getFormatedDate(td); var time = getFormatedTime(td); var isToday = false; if(date == today) { isToday=true; } var selectedtime = getWS(WS_BTIME); var selectedtimes = JSON.parse(selectedtime); var selectedsubitem = getWS(WS_SUBTARIF); $('#booking_time').css(CSS_DSP,CSS_B); $('#booking_time_label').css(CSS_DSP,CSS_B); var selected = "";//no Preselect var disabled = ""; if(!isNullOrEmpty(selectedtime) && selectedtime != NULL) { selected = ""; } if(isNullOrEmpty(selectedsubitem) || selectedsubitem == NULL) { selectedsubitem = RES_SUCCESS; } var bookingtext =''; var maxcols = 0; res.forEach(function(sd) { if(sd.articlesubItemRequired==1 && parseInt(sd.max_acc) > parseInt(maxcols)) { maxcols = parseInt(sd.max_acc); } else if(sd.articlesubItemRequired==0) { maxcols = 1; } }); if (res.length > 0) { bookingtext+=""; for(var i = 0;i<=maxcols;i++) { if (i==0) { bookingtext+=''; } else { if(maxcols==1) { bookingtext+=''; } else { bookingtext+=''; } } } bookingtext+=""; } res.forEach(function(sd) { bookingtext+=""; bookingtext+=''; for(var i = 1;i<=maxcols;i++) { disabled = ""; if(selectedtimes!= UNDEF && selectedtimes.includes(i + "_" + sd.time)) { selected = "active"; } if(isToday && sd.time_end < time) { disabled =DISABLED; selected = ""; if(selectedtime == sd.time) { selectedtime = ""; } } var color = "success"; if(sd.reservations.includes(i.toString())) { color = "bginfo"; } if(sd.tickets.includes(i.toString()) || sd.tickets.includes('full') || sd.ticketsToPay.includes(i.toString())) { color = "bgerror" disabled = DISABLED; selected = "false"; removeTime(sd.time,i); } if(disabled == DISABLED) { //color = "bginfo" } if(selectedtimes!= UNDEF && selectedtimes.includes(i + "_" + sd.time)) { selected = "active"; } bookingtext+=''; selected=""; } bookingtext+=""; }); bookingtext += "
ZeitenBahn ' + i + '
' + sd.time + '
"; $('#booking_time').html('').append(bookingtext); $(".timelink").click(function() { var isDisabled = $(this).hasClass(DISABLED); if(!isDisabled) { var value = $(this).data("item"); var subvalue = $(this).data("subitem"); if(toggleTime(value,subvalue)) { $(this).addClass('active'); } else { $(this).removeClass('active'); } $('#booking_amount').val(countPersons()); showDiscountScale(); } }); $('#booking_amount').val(countPersons()); } else { $('#booking_time').css(CSS_DSP,CSS_NONE); $('#booking_time_label').css(CSS_DSP,CSS_NONE); } } }); } function loadTarife() { var date = getWS(WS_BDATE); var timestart = getWS(WS_BTIME); var timeend = getWS(WS_BTIMEEND); if(new Date() < BOOKINGENABLED) { $('#booking_time').html('Buchungsystem noch nicht freigegeben'); $('#booking_tarif').find('option').remove(); return; } return $.ajax({ type: POST, url: PHP_MAIN, data: {"article": "withdaytime", "date": date, "time": timestart, "timeend":timeend}, method: POST, dataType: 'json', cache: false, success: function (res) { articles = new Array(); res.forEach(function(at) { var art = new Article(at.itemnbr, at.description, at.infotext, at.item_code, at.type, at.wgruppe, at.percent, at.discountable, at.displayColor, at.foreColor, at.subItemRequired); art.wgruppebezeichnung = at.wgruppeBezeichnung; art.datetimeRequired = at.datetimeRequired; art.customerRequired = at.customerRequired; art.setPicture(at.picture); if(at.discounts != null) { at.discounts.forEach(function(d) { var dis = new Discount(d.idx, d.ref_idx, d.amount, d.price, d.description, d.multiplier); art.discounts.push(dis); }); } articles.push(art); }); $.when(loadEvents()).done(function(a1) { setArticleInfos(); refreshWK(); setUsage(); }); } }); } function drawTarife() { var addstring = '
'; var actwg =0; addstring +='
'; var ins ="show"; articles.forEach(function(at) { if(actwg != at.wgruppe) { if(actwg > 0) { addstring +='
'; addstring +='
'; } actwg = at.wgruppe; addstring +='
'; addstring +='
'; addstring +='

'; addstring +=''; addstring +='

'; addstring +='
'; addstring +='
'; addstring +='
'; ins=""; if(at.wgruppe == 2) { addstring +='

Lauflernhilfen und Schlößer können nur vor Ort (in Bar) gekauft werden.

'; } } addstring += '
'; addstring += '
'; addstring += '
'; } addstring +='
' + at.description + '
' var infotext = at.infotext; if(isNullOrEmpty(infotext))infotext="-"; addstring +='
' +infotext + '
' addstring +='

' + formatPrice(at.discounts[0].price) + '

' addstring += '
'; addstring += '
'; if(at.isGutschein()) { addstring += ''; } else { if(at.itemnbr == BIRTHDAYPARENT) { addstring += ''; addstring += ' '; addstring += ''; } else { addstring += ''; addstring += ' '; addstring += ''; } } addstring += '
'; addstring += '
'; addstring += '
'; }); if(actwg > 0) { addstring +='
'; addstring +='
'; } addstring += '
'; $('#booking_tarife').html(addstring); getArticleAmountWK(); articles.forEach(function(at) { if(ba.hasArticleZumZeitpunkt(at.itemnbr)) { if(at.isGutschein()== false) { $('#itemnbr_' + at.itemnbr).val(ba.getArticleAmountZumzeitpunkt(at.itemnbr)); setPriceDisplay(at.itemnbr, $('#itemnbr_' + at.itemnbr).val()); } else { $('#itemnbr_' + at.itemnbr).val(ba.getArticleCreditZumzeitpunkt(at.itemnbr)); setPriceDisplay(at.itemnbr, $('#itemnbr_' + at.itemnbr).val()); } $('#del_' + at.itemnbr).css(CSS_DSP, CSS_INB); $('#del_' + at.itemnbr).data("tag", ba.actDate); $('#del_' + at.itemnbr).data("time", ba.actTime); $('#del_' + at.itemnbr).data("timeend", ba.actTimeEnd); $('#del_' + at.itemnbr).data("itemnbr", at.itemnbr); $('#del_' + at.itemnbr).data("subItem", at.subItem); } }); $('.delArticle').on('click', function() { var itemnbr = $(this).data("itemnbr"); var subItem = $(this).data("subItem"); ba.removeArticleZumZeitpunkt(itemnbr, subItem); $('#itemnbr_' + itemnbr).val(''); $('#del_' + itemnbr).hide(); saveWK(); }); $('.amountinput').on('input',function(e){ var amount = parseFloat($(this).val()); var itemnbr = $(this).data('itemnbr'); if(amount <0) { amount=0; $(this).val(0) } setPriceDisplay(itemnbr, amount); checkSupportNeeded(itemnbr, amount); if(amount<=0) { ba.removeArticleZumZeitpunkt(itemnbr); } else { articles.forEach(function(at) { if(at.itemnbr == itemnbr) { at.amount = amount; if(amount >0) { ba.addArticleZumZeitpunkt(at); } } }); } }); $('.amountselect').on('input',function(e){ var amount = parseInt($(this).val()); var itemnbr = $(this).data('itemnbr'); if(amount <0) { $(this).val(0) } if(itemnbr == BIRTHDAYPARENT) { if(amount >1) { amount = 1; $(this).val(1); } } setPriceDisplay(itemnbr, amount); checkSupportNeeded(itemnbr,amount); if(amount<=0) { ba.removeArticleZumZeitpunkt(itemnbr); } else { articles.forEach(function(at) { if(at.itemnbr == itemnbr) { at.amount = amount; if(amount >0) { ba.addArticleZumZeitpunkt(at); } } }); } }); $('#collapse2').on('show.bs.collapse', function () { hasWatchAdditionalItems=true; }); } function getArticleAmountWK() { $.ajax({ type: POST, url: PHP_MAIN, data: {"wk": "getArticleAmountWK"}, method: POST, dataType: 'json', cache: false, success: function (res) { } }); } function checkSupportNeeded(itemnbr, amount) { if(amount > 0) { articles.forEach(function(at){ if(at.itemnbr == itemnbr) { if(at.customerRequired==2) { var valp1 =0; if(isNullOrEmpty($('#itemnbr_' + PARENT1).val()) == false) { valp1 = parseInt($('#itemnbr_' + PARENT1).val()); } var valp2 = 0; if(isNullOrEmpty($('#itemnbr_' + PARENT2).val()) == false) { valp2 = parseInt($('#itemnbr_' + PARENT2).val()); } var valp3 = 0; if(isNullOrEmpty($('#itemnbr_' + PARENT3).val()) == false) { valp3 = parseInt($('#itemnbr_' + PARENT3).val()); } if(valp1 <=0 && valp2 <=0) { $('#notice_' + itemnbr).css(CSS_DSP, CSS_INB); $('#notice_' + itemnbr).html("Es wird eine zusätzliche erwachsene Begleitperson benötigt"); } else { $('#notice_' + itemnbr).css(CSS_DSP, CSS_NONE); } } } }); } else { $('#notice_' + itemnbr).css(CSS_DSP, CSS_NONE); } } function setPriceDisplay(itemnbr, amount) { var singleprice = 0; articles.forEach(function(at){ if(at.itemnbr == itemnbr) { if(at.isGutschein() == false) { singleprice = at.getSinglePrice(amount); } else { at.credit = amount; at.amount = 1; singleprice =at.getSinglePrice(1); } } }); 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); ba.addTimes(time, time_end); saveWK(); } function saveWK() { if(ba.hasAnyArticle()) { $('#mnuBtnChart').css(CSS_DSP,CSS_INB); $('#amountinChart').html(ba.getAmountAnyArticles()); } 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.hasReserv = res.hasReserv; user.bemerkung = res.bemerkung; 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(); // navigate(P_USER); 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.'); } } }); } 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 loadASP(loadOnly) { if(loadOnly == UNDEF) { loadOnly=false; } var formdata = new FormData(); formdata.append("userdatachange", "asp"); var urltocall = PHP_MAIN; $.ajax({ type: POST, url: urltocall, data: formdata, dataType: 'json', contentType: false, cache: false, processData:false, success: function (res) { if(res != "0") { custasp = res; setWS(WS_ASP,JSON.stringify(custasp)); if(!loadOnly) { drawASPTouser(); } } else { if(!loadOnly) { custasp = new Array() setWS(WS_ASP,JSON.stringify(custasp)); drawASPTouser(); } } }, statusCode: { 401: function () { navigate(P_LOGIN); }, 404: function () { navigate(P_LOGIN); } } }); } 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 initFormUser() { refreshUser(); drawASPTouser(); var options = { onLoad: function () { }, onKeyUp: function (evt) { $(evt.target).pwstrength("outputErrorList"); } }; $('#user_pwd').pwstrength(options); $('#u_chgpwd').prop(DISABLED,true); $('#user_changedata').prop(DISABLED,true); if(!isNullOrEmpty(user.infoanstate)) { $('#u_callForVIP').prop(DISABLED,true); $('#u_callForVIP_info').html(user.infoanstate); } 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); } }); } $('.userpwd').on('input', function() { var val1 = $('#user_pwd').val(); var val2 = $('#user_pwd2').val(); if(val1.length >7 && val1 == val2) { $('#u_chgpwd').prop(DISABLED,false); } else { $('#u_chgpwd').prop(DISABLED,true); } }); $('.userdata').on('input', function() { $('#user_changedata').prop(DISABLED,false); }); $("#user_changedata").on('click', function(e){ var isCompany = 0; if(FIRMAPOSSIBLE) { if($('#user_iscompany').prop('checked')==true) { isCompany = 1; } } if($('#user_email_consent').prop('checked')==true) { user.setContactEmail(); } else { user.remContactEmail(); } if($('#user_mobile_consent').prop('checked')==true) { user.setContactMobile(); } else { user.remContactMobile(); } if(user.getConsentAGB() && $('#chk_agb').prop('checked')==false) { user.remConsentAGB(); saveConsent("agb",0); } else if (user.getConsentAGB()==false && $('#chk_agb').prop('checked')) { user.setConsentAGB(); saveConsent("agb",1); } if(user.getConsentNutzungsbedingung() && $('#chk_nutzungsbedingungen').prop('checked')==false) { user.remConsentNutzungsbedingung(); saveConsent("nutz",0); } else if (user.getConsentNutzungsbedingung()==false && $('#chk_nutzungsbedingungen').prop('checked')) { user.setConsentNutzungsbedingung(); saveConsent("nutz",1); } if(user.getConsentDSGVO() && $('#chk_dsgvo').prop('checked')==false) { user.remConsentDSGVO(); saveConsent("dsgvo",0); } else if (user.getConsentDSGVO()==false && $('#chk_dsgvo').prop('checked')) { user.setConsentDSGVO(); saveConsent("dsgvo",1); } var gebdat = getFormatedGebDat($('#user_gebdat').val()); var tempuser = new User(user.idcustomer, $('#user_name').val(), $('#user_prename').val(), $('#user_email').val(), $('#user_mobile').val(), $('#user_street').val(), $('#user_plz').val(), $('#user_city').val(), "", user.hasVIP, user.infoanstate, user.infoan, gebdat, $('#user_companyname').val(),isCompany, user.consents, user.contact_choice); tempuser.bemerkung=$('#user_notes').val(); var dat = {"user_prename": $('#user_prename').val() ,"user_name": $('#user_name').val() ,"user_companyname": $('#user_companyname').val() ,"user_email": $('#user_email').val() ,"user_plz": $('#user_plz').val() ,"user_city": $('#user_city').val() ,"user_street": $('#user_street').val() ,"user_mobile": $('#user_mobile').val() ,"user_gebdat": gebdat ,"user_iscompany":isCompany ,"user_contact_choice":user.contact_choice ,"user_consents":user.consents ,"user_notes": $('#user_notes').val() ,"user_id": user.idcustomer ,"user_email_old": user.email ,"userdatachange": PME}; var urltocall = PHP_MAIN; $.ajax({ type: POST, url: urltocall, data: dat, dataType: 'json', cache: false, success: function (response) { var r = parseInt(response); if( r == RES_NBR1 ) { user = tempuser; setWS(WS_USER,JSON.stringify(tempuser)); refreshUser(); $('#user_changedata').prop(DISABLED,true) .addClass('bgsuccess'); $('#user_changedata_info').css(CSS_DSP,CSS_INB) .addClass('success') .html('Ändern der Daten erfolgreich'); } else { $('#user_changedata').prop(DISABLED,true) .addClass('bgerror'); if( r == -1 ) { $('#user_changedata_info').css(CSS_DSP,CSS_INB) .addClass('error') .html('Nicht aller erforderlichen Felder gefüllt.'); } else { $('#user_changedata_info').css(CSS_DSP,CSS_INB) .addClass('error') .html('Ändern der Daten nicht erfolgreich'); } } window.setTimeout( resetUserChangeButtons, 3000 ); }, statusCode: { 401: function () { navigate(P_BOOKING); }, 404: function () { navigate(P_BOOKING); } } }); return false; }); $("#u_chgpwd").on('click', function(e){ var val1 = $('#user_pwd').val(); var val2 = $('#user_pwd2').val(); if(val1.length <=7 || val1 != val2) { resetUserChangeButtons(); $('#u_chgpwd').addClass('bginfo') .prop(DISABLED,true); $('#u_chgpwd_info').addClass('info') .css(CSS_DSP,CSS_INB) .html('Kein Passwort zum Ändern angegeben'); window.setTimeout( resetUserChangeButtons, 3000 ); return; } var dat = {"user_pwd": md5(val1) ,"user_pwd2": md5(val2) ,"user_id": user.idcustomer ,"user_email_old": user.email ,"userdatachange": "pwdchange"}; $.ajax({ type: POST, url: PHP_MAIN, data: dat, dataType: 'json', cache: false, success: function (response) { var r = parseInt(response); $('#u_chgpwd_info').css(CSS_DSP,CSS_INB); if( r == RES_NBR1 ) { $('#u_chgpwd').prop(DISABLED,true); $('#user_pwd').val(''); $('#user_pwd2').val(''); refreshUser(); $('#u_chgpwd').addClass('bgsuccess'); $('#u_chgpwd_info').addClass('success').html('Ändern des Passworts erfolgreich.'); } else { $('#u_chgpwd').addClass('bgerror'); if(r == -1) { $('#u_chgpwd_info').addClass('error').html('Änderung nicht erfolgreich. Nicht aller erfolderlichen Felder gefüllt.'); } else { $('#u_chgpwd_info').addClass('error').html('Ändern des Passworts nicht erfolgreich.'); } } window.setTimeout( resetUserChangeButtons, 3000 ); }, statusCode: { 401: function () { navigate(P_BOOKING); }, 404: function () { navigate(P_BOOKING); } } }); return false; }); $("#u_callForVIP").on('click', function(e){ var dat = {"userdatachange": "wvip"}; var urltocall = PHP_MAIN; $.ajax({ type: POST, url: urltocall, data: dat, dataType: 'json', cache: false, success: function (response) { var r = parseInt(response); if( r == RES_NBR1 ) { user.infoanstate = "Deine VIP-Anfrage wurde gestellt. Du solltest in Kürze eine Rückmeldung dazu erhalten."; setWS(WS_USER,JSON.stringify(user)); refreshUser(); $('#u_callForVIP').prop(DISABLED,true) .addClass('bgsuccess'); $('#u_callForVIP_info').css(CSS_DSP,CSS_INB) .addClass('success') .html('Deine VIP-Anfrage wurde gestellt. Du solltest in Kürze eine Rückmeldung dazu erhalten.'); } else { $('#u_callForVIP').prop(DISABLED,true) .addClass('bgerror'); if( r == -1 ) { $('#u_callForVIP_info').css(CSS_DSP,CSS_INB) .addClass('error') .html('Die Anforderung war nicht erfolgreich.'); } } }, statusCode: { 401: function () { navigate(P_BOOKING); }, 404: function () { navigate(P_BOOKING); } } }); return false; });} function drawASPTouser() { if(custasp == "-2")return; var i = 1; $('#my_asp').html(''); if(custasp != UNDEF) { custasp.forEach(function(asp) { if(asp.prename != UNDEF) { var d = $("
").appendTo($('#my_asp')); $(d).addClass('row').addClass('asprow') .append($("
").addClass('col-md-1').html('')) .append($("
").addClass('col-md-1').html('')) .append($("
").addClass('col-md-2').html('')) .append($("
").addClass('col-md-1').html('')) .append($("
").addClass('col-md-1').html('Geburtstag: ')) .append($("
").addClass('col-md-2').html('')) .append($("
").addClass('col-md-1').html('')) .append($("
").addClass('col-md-1').html('')) .append($("
").addClass('col-md-2').html('') .append( ' ')); i++; } }); } var d = $("
").appendTo($('#my_asp')); $(d).addClass('row') .append($("
").addClass('col-md-1').html('')) .append($("
").addClass('col-md-1').html('')) .append($("
").addClass('col-md-2').html('')) .append($("
").addClass('col-md-1').html('')) .append($("
").addClass('col-md-1').html('Geburtstag: ')) .append($("
").addClass('col-md-2').html('')) .append($("
").addClass('col-md-1').html('')) .append($("
").addClass('col-md-1').html('')) .append($("
").addClass('col-md-2').html('')); $('#my_asp').fadeIn(500); for(var j = RES_NBR1;j<=i;j++) { autocomplete(document.getElementById('asp_plz_' + j), true); autocomplete(document.getElementById('asp_city_' + j)); } $(".saveasp").on('click', function(e){ var id = $(this).data(PID); var r = $(this).data("row"); if(!isNullOrEmpty($('#asp_email_' + r).val())) { var emailvalid = validateEmail('asp_email_' + r); if(!emailvalid) { return false; } } var anyfalse = false; var ok = validateText('asp_name_' + r); if(!ok) anyfalse=true; ok = validateText('asp_prename_' + r); if(!ok) anyfalse=true; ok = validateText('asp_mobile_' + r) || validateEmail('asp_email_' + r); if(!ok) anyfalse=true; if(anyfalse)return false; var aspname = $('#asp_name_'+ r).val().trim(); var aspprename = $('#asp_prename_' + r).val().trim(); if(aspname.toLowerCase() == user.name.toLowerCase() && aspprename.toLowerCase() == user.prename.toLowerCase()) { anyfalse=true; alert("Sie können sich nicht selbst als Ansprechpartner hinzufügen.") } if(!anyfalse) { for(var j = RES_NBR1;j<=i;j++) { if(j!=r) { var aspname_test = $('#asp_name_'+ j).val().trim().toLowerCase(); var aspprename_test = $('#asp_prename_'+ j).val().trim().toLowerCase(); if(aspname.toLowerCase() == aspname_test && aspprename.toLowerCase() == aspprename_test) { anyfalse=true; alert("Ein Anpsrechpartner mit diesem Namen existiert bereits!") } } } } if(anyfalse)return false; var aspgebdat = getFormatedGebDat($('#asp_gebdat_' + r).val()); var dat = {"asp_prename": aspprename ,"asp_name": aspname ,"asp_email": $('#asp_email_' + r).val().trim() ,"asp_plz": $('#asp_plz_' + r).val().trim() ,"asp_city": $('#asp_city_' + r).val().trim() ,"asp_street": $('#asp_street_' + r).val().trim() ,"asp_mobile": $('#asp_mobile_' + r).val().trim() ,"asp_gebdat": aspgebdat ,"id_cust_asp": id ,"userdatachange": "aspdata"}; var urltocall = PHP_MAIN; $.ajax({ type: POST, url: urltocall, data: dat, dataType: 'json', cache: false, success: function (response) { var r = parseInt(response); if( r == RES_NBR1 ) { $(e).addClass('bgsuccess'); $('#user_asp_info').css(CSS_DSP,CSS_INB) .addClass('success') .html('Ändern der Daten erfolgreich'); loadASP(false); } else if(r == RES_NBR2) { loadASP(false); } else { $(e).addClass('bgerror'); if( r == -1 ) { $('#user_asp_info').css(CSS_DSP,CSS_INB) .addClass('error') .html('Nicht aller erforderlichen Felder gefüllt.'); } else { $('#user_asp_info').css(CSS_DSP,CSS_INB) .addClass('error') .html('Ändern der Daten nicht erfolgreich'); } } window.setTimeout( resetUserChangeButtons, 3000 ); }, statusCode: { 401: function () { navigate(P_BOOKING); }, 404: function () { navigate(P_BOOKING); } } }); return false; }); $(".deleteasp").on('click', function(e){ var id = $(this).data(PID); var r = $(this).data("row"); var dat = {"id_cust_asp": id ,"userdatachange": "delasp"}; var urltocall = PHP_MAIN; $.ajax({ type: POST, url: urltocall, data: dat, dataType: 'json', cache: false, success: function (response) { var r = parseInt(response); if( r == RES_NBR1 ) { loadASP(); } else { $(e).addClass('bgerror'); $('#user_asp_info').css(CSS_DSP,CSS_INB) .addClass('error') .html('Ändern der Daten nicht erfolgreich'); } window.setTimeout( resetUserChangeButtons, 3000 ); }, statusCode: { 401: function () { navigate(P_BOOKING); }, 404: function () { navigate(P_BOOKING); } } }); return false; }); } 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 += ''; 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); $(".buyWith").click(function() { var value = $(this).data(PID); var itemnbr = $(this).data(PIDA); setWS(WS_PWC, value); setWS(WS_PWCA, itemnbr); $.when(getCreditvalue()).done(function(a1) { saveWK(); setCreditItem(value,itemnbr); }); }); $(".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); var step = parseInt(getWS(WS_BOOKINGSTEP)); location.hash = P_SUBBOOKING + step; } } } function showBuyHistory(id) { alert("TODO, Anzeige der Historie implementieren."); } function loadArtikelWGFilter(loadAlways = false) { var tempdate = getWS(WS_BDATE); var datetoshow = ""; if(loadAlways == false && new Date() < BOOKINGSTART) { return; } if(isNullOrEmpty(tempdate)) { datetoshow = getFormatedDate(getMinDate()); setWS(WS_BDATE,datetoshow); tempdate = datetoshow; } return $.ajax({ type: POST, url: PHP_MAIN, data: {"article": "withday", "date": tempdate}, method: POST, dataType: 'json', cache: false, success: function (res) { $('#freeslots_tarifgruppe').find('option').remove(); var selected = SELECTED; if(res.length > 0 && res[0] != 0) { $('#freeslots_tarifgruppe').append(''); } else { $('#freeslots_tarifgruppe').append(''); } articlegroups = new Array(); res.forEach(function(ar) { if(ar != 0) { var art = new Article(ar.item_nbr, ar.description, ar.infotext, ar.item_code, ar.type, ar.wgruppe, ar.percent, ar.discountable, ar.displayColor, ar.foreColor, ar.subItemRequired); art.datetimeRequired = ar.datetimeRequired; art.customerRequired = ar.customerRequired; art.setPicture(ar.picture); ar.discounts.forEach(function(d) { var dis = new Discount(d.idx, d.ref_idx, d.amount, d.price, d.description, d.multiplier); art.discounts.push(dis); }); if(art.type == TYPEEINTRITT) { var groupnew = true; articlegroups.forEach(function(g) { if(g.idx == art.wgruppe) { groupnew = false; } }); if(groupnew) { var group = new ArticleGroup(ar.wgruppe, ar.wgruppeBezeichnung); articlegroups.push(group); } } } }); articlegroups = articlegroups.sort((a,b) => (parseInt(a.idx) > parseInt(b.idx)) ? 1 : ((parseInt(b.idx) > parseInt(a.idx)) ? -1 : 0)); articlegroups.forEach(function(ar) { $('#freeslots_tarifgruppe').append(''); }); } }); } function loadEvents() { $('#booking_events').html(''); var tempdate = getWS(WS_BDATE); var temptime = getWS(WS_BTIME); var datetoshow = ""; if(new Date() < BOOKINGSTART) { $('#booking_time').html('Buchungsystem noch nicht freigegeben'); $('#booking_tarif').find('option').remove(); return; } $('#bk1_row_events').css(CSS_DSP, CSS_NONE); datetoshow= tempdate; return $.ajax({ type: POST, url: PHP_MAIN, data: {"article": "events", "date": datetoshow, "time": temptime}, method: POST, dataType: 'json', cache: false, success: function (res) { $('#booking_events').html(''); res.forEach(function(at) { if(at != 0) { $('#bk1_row_events').css(CSS_DSP, CSS_B); var art = new Article(at.item_nbr, at.description, at.infotext, at.item_code, at.type, at.wgruppe, at.percent, at.discountable, at.displayColor, at.foreColor, at.subItemRequired); art.datetimeRequired = at.datetimeRequired; art.customerRequired = at.customerRequired; art.setPicture(at.picture); if(at.discounts != null) { at.discounts.forEach(function(d) { var dis = new Discount(d.idx, d.ref_idx, d.amount, d.price, d.description, d.multiplier); art.discounts.push(dis); }); } var exists = false articles.forEach(function(exart) { if(art.itemnbr == exart.itemnbr) { exists=true; } }); if(exists == false) { articles.push(art); } var datetemp = at.seatsSchedule[0].schedule_start.split("-"); var eventdate = datetemp[2]+"."+datetemp[1]+"."+datetemp[0]; if(eventdate.startsWith("undefined")) { eventdate = ""; } var optionstring = '0 && at.discounts[0] != 0 && at.discounts[0].price > 0) { discountstring = ' ' + at.discounts[0].price + '€'; } optionstring += ' data-id="' + at.item_nbr + '" data-date="' + eventdate + '" data-time="' + at.seats[0].time + '" data-timeend="' + at.seats[0].time_end + '">'+ eventdate + ' - ' + at.description + discountstring + '
' + at.infotext + ''; if(at.type != TYPEWERTKARTE2) { $('#booking_events').append(optionstring); } if(at.type == TYPEEINTRITT && at.item_nbr == lastselectedTarif) { tarifexists=true; } } }); $('.eventlink').click(function () { var itemnbr = $(this).data(PID); var date = $(this).data("date"); var time = $(this).data("time"); var timeEnd = $(this).data("timeend"); var amount = $('#booking_amount').val(); var price = 0; var a = UNDEF; articles.forEach(function(exart) { if(exart.itemnbr == itemnbr) { a = exart; } }); if(amount == "") { amount = RES_NBR1; } var iAmount = parseInt(amount); if(iAmount <=0) { iAmount = 1; } if(!isNullOrEmpty(itemnbr)) { var times = []; times.push(new BlockSlot(itemnbr,1,time)) ba.addTimes(time,timeEnd); var art = new Article(itemnbr, a.description, a.infotext, a.item_code, a.type, a.wgruppe, a.percent, a.discountable, a.displayColor, a.foreColor, a.subItemRequired); art.datetimeRequired = a.datetimeRequired; art.customerRequired = a.customerRequired; art.setPicture(a.picture); if(a.discounts != UNDEF) { a.discounts.forEach(function(d) { var dis = new Discount(d.idx, d.ref_idx, d.amount, d.price, d.description, d.multiplier); art.discounts.push(dis); }); } art.subItem = 1; art.amount =iAmount; //console.log(art); ba.addArticleZumZeitpunkt(art); saveWK(); refreshWK(); } }); } }); } function loadArtikel() { $('#booking_tarif').find('option').remove(); var tempdate = getWS(WS_BDATE); //console.log(tempdate); var temptime = getWS(WS_BTIME); var datetoshow = ""; if(new Date() < BOOKINGENABLED) { $('#booking_time').html('Buchungsystem noch nicht freigegeben'); $('#booking_tarif').find('option').remove(); return; } if(isNullOrEmpty(tempdate)) { var ds =getMinDate(); datetoshow = getFormatedDate(ds); setWS(WS_BDATE,datetoshow); tempdate = datetoshow; } return $.ajax({ type: POST, url: PHP_MAIN, data: {"article": "withday", "date": tempdate}, method: POST, dataType: 'json', cache: false, success: function (res) { $('#booking_tarif').find('option').remove(); $('#booking_tarifgruppe').find('option').remove(); var selected = SELECTED; if(DISPLAYWGRUPPESELECT) { if(res.length > 0 && res[0] != 0) { $('#booking_tarifgruppe').append(''); $("#booking_tarifgruppe").change(function() { filterArticlelListe(); }); } else { $('#booking_tarifgruppe').append(''); } } var lastselectedTarif = getWS(WS_BTARIF); var tarifexists = false; articles = new Array(); articlegroups = new Array(); res.forEach(function(ar) { if(ar != 0) { var art = new Article(ar.item_nbr, ar.description, ar.infotext, ar.item_code, ar.type, ar.wgruppe, ar.percent, ar.discountable, ar.displayColor, ar.foreColor, ar.subItemRequired); art.datetimeRequired = ar.datetimeRequired; art.customerRequired = ar.customerRequired; art.setPicture(ar.picture); ar.discounts.forEach(function(d) { var dis = new Discount(d.idx, d.ref_idx, d.amount, d.price, d.description, d.multiplier); art.discounts.push(dis); }); if(ar.item_nbr == lastselectedTarif) { tarifexists=true; } if(ar.pooled == 1) { art.pool = ar.pool; art.pooled = 1; } articles.push(art); art.hide = ar.hide; if(ar.hide == UNDEF) { $('#booking_tarif').append(''); } if(DISPLAYWGRUPPESELECT) { var groupnew = true; articlegroups.forEach(function(g) { if(g.idx == art.wgruppe) { groupnew = false; } }); if(groupnew) { var group = new ArticleGroup(art.wgruppe, ar.wgruppeBezeichnung); articlegroups.push(group); /*$('#booking_tarifgruppe').append('');*/ } } selected=""; } }); if(tarifexists && lastselectedTarif != "") { $('#booking_tarif').val(lastselectedTarif); setWS(WS_BTARIF,0); } else { setWS(WS_BTARIF,$('#booking_tarif').val()); } articlegroups = articlegroups.sort((a,b) => (a.idx > b.idx) ? 1 : ((b.idx > a.idx) ? -1 : 0)); articlegroups.forEach(function(ar) { $('#booking_tarifgruppe').append(''); }); $.when(loadEvents()).done(function(a1) { setArticleInfos(); refreshWK(); }); } }); } function filterArticlelListe() { var selectedfilter = $("#booking_tarifgruppe").val(); $('#booking_tarif').find('option').remove(); var selected = SELECTED; //console.log(articles); articles.forEach(function(ar) { if(selectedfilter == 0 || selectedfilter == ar.wgruppe) { if(ar.hide == UNDEF) { $('#booking_tarif').append(''); selected=""; } } }); setArticleInfos(); var tempdate = getWS(WS_BDATE); var datetoshow = ""; if(!isNullOrEmpty(tempdate)) { datetoshow= tempdate; } else { datetoshow = getFormatedDate(bookingstartdate); setWS(WS_BDATE,datetoshow); } setTimes(datetoshow); } function showDiscountScale() { var sel = $('#booking_tarif').val(); $('#article_infotext').html(''); $('#article_price').html(''); articles.forEach(function(ar) { if(ar.itemnbr == sel) { $('#article_infotext').html(ar.infotext); var texttoset = ""; ar.discounts.forEach(discount => { //(discount.amount<=countperson) // if(discount.amount == 1) { texttoset += formatPrice(discount.price) + " - " + discount.description + "
"; } else { texttoset += "Ab " + discount.amount + " Personen: " + formatPrice(discount.price) + " - " + discount.description + "
"; } // }); $('#article_price').html(texttoset); } }); } function setArticleInfos() { var sel = $('#booking_tarif').val(); var oldsel = getWS(WS_BTARIF); if(oldsel == sel) { return; } setWS(WS_BTARIF, sel); $('#article_infotext').html(''); $('#article_price').html(''); //console.log(articles); articles.forEach(function(ar) { if(ar.itemnbr == sel) { $('#article_infotext').html(ar.infotext); var texttoset = ""; ar.discounts.forEach(discount => { //if(discount.amount<=countperson) //{ if(discount.amount == 1) { texttoset += formatPrice(discount.price) + " - " + discount.description + "
"; } else { texttoset += "Ab " + discount.amount + " Personen: " + formatPrice(discount.price) + " - " + discount.description + "
"; } //} }); $('#article_price').html(texttoset); var t = []; setWS(WS_BTIME,JSON.stringify(t)); texttoset = ""; if(ar.pooled==1) { ar.pool.forEach(pa => { if(pa.ref_seatsdefine == 0) { //console.log(pa); //console.log(articles); articles.forEach(function(arti) { if(arti.idx == pa.ref_sellartikle) { texttoset+= "

" +arti.description + '

'; } }); } }); } $('#article_optionen').html(texttoset); $('.btnAddOption').click(function () { var itemnbr = $(this).data("item"); var parentitem = $(this).data("parent"); //console.log(itemnbr + " " + parentitem); addOption(itemnbr, parentitem); }); //console.log(ar.subItemRequired); if(ALM != 2 && ar.subItemRequired == RES_SUCCESS) { $('.cdsp').css(CSS_DSP,CSS_NONE); } else { $('.cdsp').css(CSS_DSP,CSS_INB); } //console.log(ar); if(ar.isWertkartenArtikel()) { $('.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 if(ar.type != TYPEWERTKARTE) { $('#div_ggValue').remove(); } else { $('#div_ggValue').remove(); } if(ALM == 2 && ar.type == TYPEEINTRITT) { $('#booking_amount').prop(DISABLED,true); } else { $('#booking_amount').prop(DISABLED,false); } } else { $('#div_ggValue').remove(); $('.timediv').css(CSS_DSP, CSS_B); $('#booking_time_label').css(CSS_DSP, CSS_B); $('#booking_time').css(CSS_DSP, CSS_B); $('#v_oneHouse').css(CSS_DSP, CSS_INB); $('#article_price').css(CSS_DSP, CSS_INB); } return; } }); } function addType7Text() { var s = '
'; s+='
'; s+='
'; s+=' '; s+='
'; s+='
'; s+='
'; s+=' '; s+='
'; s+='
'; s+='
'; s+='
'; s+=' '; s+='
'; s+='
'; s+='
'; s+='
'; s+=' '; s+='
'; s+='
'; s+='
'; s+='
'; s+=' '; s+='
'; s+='
'; s+='
'; s+=' '; s+='
'; s+='
'; s+='
'; oldhtml = $('#booking_time').html(); $('#booking_time').html(s); } function timelinkClicked(item) { var isDisabled = $(item).hasClass(DISABLED); if(!isDisabled) { $('.activelink').removeClass('activelink'); $(item).addClass('activelink'); var value = $(item).data("item"); var tarif = $(item).data("article"); removeReservation(getWS(WS_BTARIF)); setWS(WS_BTARIF,tarif); setTime(value); } } 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) { } }); setWS(WS_USER,""); ba = new Warenkorb(); saveWK(); setWS(WS_ASP,""); setWS(WS_LOGEDIN,FALSE); setWS(WS_FPCHANGE,FALSE); setLogedIn(); } 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); if(hasOV()|| hasOVViewOnly()) { $('#overview').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); $('#overview').css(CSS_DSP,CSS_NONE); } } function isActDateSelected() { var datetoshow = getWS(WS_BDATE); if(!isNullOrEmpty(datetoshow)) { var splittdate = datetoshow.split('.'); if(splittdate.length == 3) { var selecteddate = new Date(splittdate[2] + "-" + splittdate[1] + "-" + splittdate[0]); var nowdate = new Date(); var nowDateOnly = new Date(nowdate.getFullYear() + "-" +(nowdate.getMonth() + 1) + "-" + nowdate.getDate()); var isolddate = selecteddate < nowDateOnly; if(isolddate) { datetoshow = getFormatedDate(nowdate); setWS(WS_BDATE,datetoshow); return false; } else if(selecteddate 0 && counterSuccess == counter) { $('#addbutton_info').css(CSS_DSP,CSS_IN) .addClass('success') .html('Zum Warenkorb hinzugefügt.'); if(WKTIMERVALUE >0) { clearInterval(wktimer); setWS(WS_WKT,getSlotRemainingTime()); wktimer = setInterval(reduceWKTimer, 1000); } } else if(counterSuccess < counter) { $('#addbutton_info').css(CSS_DSP,CSS_IN) .addClass('error') .html('Der Zeitslot ist bereits vergeben.'); } else { $('#addbutton_info').css(CSS_DSP,CSS_IN) .addClass('info') .html('Keine Zeitlots ausgewählt.'); } window.setTimeout( resetAddButtonInfo, 3000 ); } } }); setNextButton(); } function setNextButton() { if(ba != UNDEF && ba.getArticleZumzeitpunkt() != UNDEF && ba.getArticleZumzeitpunkt().length > 0) { $('.nextbutton').removeClass('disabled'); } else { $('.nextbutton').addClass('disabled'); } } function resetAddButtonInfo() { $('#addbutton_info').removeClass('success') .removeClass('error') .removeClass('info') .css(CSS_DSP,CSS_NONE) .html(''); } 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(); refreshWK(); } } function remove(itemnbr, time) { if(time == UNDEF) { if(ba.hasArticleZeitlos(itemnbr)) { ba.removeArticle(itemnbr); } else { if(itemnbr.toString().startsWith("-")) { if(ba.hasArticleZeitlos(itemnbr.toString().substr(1))) { ba.removeArticle(itemnbr.toString().substr(1)); } } } } else { if(ba.hasArticleZumZeitpunkt(itemnbr)) { ba.removeArticleZumZeitpunkt(itemnbr); } } saveWK(); refreshWK() } function isCreditSet() { return getWS(WS_PWC) != null&& getWS(WS_PWC) != "" && ba.wertkarte != UNDEF; } function isLogedIn() { return getWS(WS_LOGEDIN) == TRUE; } 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 refreshWK() { if(ba != UNDEF) { if(ba.hasAnyArticle()) { $('#mnuBtnChart').css(CSS_DSP,CSS_INB); $('#amountinChart').html(ba.getAmountAnyArticles()); } else { $('#amountinChart').html("0"); $('#mnuBtnChart').css(CSS_DSP,CSS_NONE); } $('#booking_wk').css(CSS_DSP,CSS_INB); $('#booking_articles').html(''); } } function back() { var step = parseInt(getWS(WS_BOOKINGSTEP)); comingfrom = step; //console.log("coming from: " + step); step--; //console.log(step); if(step <=1) { step = 1; clearInterval(wktimer); } var stateObj = { "page": P_SUBBOOKING + step }; history.pushState(stateObj, P_SUBBOOKING + step, P_SUBBOOKING + step); setWS(WS_BOOKINGSTEP, step); loadBooking(); } function next() { if(!isActDateSelected()) { return ; } var step = parseInt(getWS(WS_BOOKINGSTEP)); comingfrom = step; //console.log("coming from: " + step); if(step == RES_NBR1) { if(!reserveDateAndTime()){ return; } if(WKTIMERVALUE >0) { setWS(WS_WKT,getSlotRemainingTime()); wktimer = setInterval(reduceWKTimer, 1000); } } else if(step == 2) { hasWatchAdditionalItems = false; } else if(step == 3) { if(ba != UNDEF && ba.getArticleZumzeitpunkt() != UNDEF) { ba.getArticleZumzeitpunkt().forEach(function(a){ if(a.itemnbr == CHILD) { if(ba.hasArticleZumZeitpunkt(PARENT1)== false && ba.hasArticleZumZeitpunkt(PARENT2)== false && ba.hasArticleZumZeitpunkt(PARENT3)== false) { var articleToadd = UNDEF; articles.forEach(function(art){ if(articleToadd == UNDEF) { if(art.itemnbr == PARENT1) { articleToadd = art; } else if(art.itemnbr == PARENT2) { articleToadd = art; } else if(art.itemnbr == PARENT3) { articleToadd = art; } } }); articleToadd.amount = 1; ba.insertArticleZumZeitpunkt(articleToadd,0); $('#itemnbr_' + articleToadd.itemnbr).val(1); saveWK(); alert("Es wurde eine erwachsene Person dem Warenkorb hinzugefügt!"); } } else if(a.itemnbr == BIRTHDAYVISITOR) { if(ba.hasArticleZumZeitpunkt(BIRTHDAYPARENT)== false) { var articleToadd = UNDEF; articles.forEach(function(art){ if(art.itemnbr == BIRTHDAYPARENT) { articleToadd = art; } }); articleToadd.amount = 1; ba.insertArticleZumZeitpunkt(articleToadd,0); $('#itemnbr_' + articleToadd.itemnbr).val(1); saveWK(); } } }); } if(HASADDITIONALITEMS && hasWatchAdditionalItems==false) { var b = []; var secondTile = "Zur Personeneingabe"; if(NEEDSPERSONALDATA==false) { secondTile = "Zum Warenkorb"; } $("#dialog-next" ).dialog({ resizable: false, draggable: false, height: "auto", width: "auto", modal: true, buttons: { "Zu den weiteren Artikeln": function() { $( this ).dialog( "close" ); $('#collapse1').collapse('hide'); $('#collapse2').collapse('show'); }, secondTile: function() { $( this ).dialog( "close" ); hasWatchAdditionalItems=true; next(); } } }); return; } saveWK(); if(!isLogedIn()) { nextLogin(); return; } } else if(step == 4) { if(!validatePersonalData()) { return; } } else if(step == 5) { if(!validateCheckboxes()) { return; } if(!user.getConsentAGB()) { user.setConsentAGB(); saveConsent("agb",1); } if(!user.getConsentDSGVO()) { user.setConsentDSGVO(); saveConsent("dsgvo",1); } if(!user.getConsentNutzungsbedingung()) { user.setConsentNutzungsbedingung(); saveConsent("nutz",1); } } else if(step == 6) { sendmode = $("input[name='sendmode']:checked").val(); sendmode = "mail"; setWS(WS_SM, sendmode); if(WKTIMERVALUE > 0 && wktimer == undefined) { wktimer = setInterval(reduceWKTimer, 1000); } else { $('.timeslot').css(CSS_DSP, CSS_NONE); } } step++; var stateObj = { "page": P_SUBBOOKING + step }; $('#step_' + step).addClass('step'+step+'-finish'); history.pushState(stateObj, P_SUBBOOKING + step, P_SUBBOOKING + step); setWS(WS_BOOKINGSTEP, step); initFormBooking(); } function saveConsent(consent, value) { $.ajax({ type: POST, url: PHP_MAIN, data: {"userdatachange": "addconsent", "consent": consent, "wert": value}, method: POST, dataType: 'json', cache: false, async:false, success: function (res) { } }); } function reserveDateAndTime() { if(!checkIfSlotUsed()) { reserveSlot(); return true; } else { if(!checkIfSlotUsed(true)) { alert("Es tut uns leid, einer der gewünschten Zeiträume ist aktuell für einen anderen Kunden reserviert. Versuchen Sie es in 10 Minuten erneut.") return false ; } else { updateReserveSlot(); } return true; } } function checkIfSlotUsed(isMySlot=false) { var selectedDate = getWS(WS_BDATE); var selectedTime = getWS(WS_BTIME); var listArticle = []; articles.forEach(function(a) { if(isArtikelSet(a.itemnbr)) { listArticle.push(new Booking(a.itemnbr, ba[a.itemnbr].amount, UNDEF, ba[a.itemnbr].subitems)); } }); if(listArticle.length == 0 && (ALM == 2 || (ba[BIRTHDAYPARENT] == UNDEF && ba[SMALLROOM] == UNDEF))) { return true; } var ms = 0; if(isMySlot) { ms = 1; } var returnval = $.ajax({ type: POST, url: PHP_MAIN, data: {"reservation": "checkfree", "selectedDate": selectedDate, "selectedTime": selectedTime, "selectedArticle": JSON.stringify(listArticle), "uid": _uid, "mySlot": ms}, method: POST, dataType: 'json', cache: false, async:false, success: function (res) { return res; } }).responseText; return returnval == "0"; } function reserveSlot() { var selectedDate = getWS(WS_BDATE); var selectedTime = getWS(WS_BTIME); var listArticle = []; articles.forEach(function(a) { if(isArtikelSet(ba[a.itemnbr])) { listArticle.push(new Booking(a.itemnbr, ba[a.itemnbr].amount, UNDEF, ba[a.itemnbr].subitems)); } }); return $.ajax({ type: POST, url: PHP_MAIN, data: {"reservation": "reserve", "selectedDate": selectedDate, "selectedTime": selectedTime, "selectedArticle": JSON.stringify(listArticle), "uid": _uid}, method: POST, dataType: 'json', cache: false, async:false, success: function (res) { } }).responseText == RES_SUCCESS; } function updateReserveSlot() { var selectedDate = getWS(WS_BDATE); var selectedTime = getWS(WS_BTIME); var listArticle = []; articles.forEach(function(a) { if(isArtikelSet(ba[a.itemnbr])) { listArticle.push(new Booking(a.itemnbr, ba[a.itemnbr].amount, UNDEF, ba[a.itemnbr].subitems)); } }); return $.ajax({ type: POST, url: PHP_MAIN, data: {"reservation": "updatereservation", "selectedDate": selectedDate, "selectedTime": selectedTime, "selectedArticle": JSON.stringify(listArticle), "uid": _uid}, method: POST, dataType: 'json', cache: false, async:false, success: function (res) { } }).responseText == RES_SUCCESS; } function removeReservation(itemnbr) { var listArticle = []; articles.forEach(function(a) { if(isArtikelSet(ba[a.itemnbr])) { listArticle.push(new Booking(a.itemnbr, ba[a.itemnbr].amount, UNDEF, ba[a.itemnbr].subitems)); } }); 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 validatePersonalData() { var persons = new Array(); var returnvalue = true; if(VALIDATEPERSONALDATABYDAY) { ba.tage.forEach(tag => { tag.getZeiten().forEach(zeit => { persons = new Array(); zeit.getAllArticle().forEach(article => { if(article.customerRequired > 0) { var gebdatoptional = (article.customerRequired == 1) || NEEDSBIRTHDAY==false; for(var i = 0;i=0) { if(isASPSelected == 0) { aspprename = user.prename; aspsurname = user.name; aspemail = user.email; aspgebdat = user.gebdat; } else if(custasp != UNDEF && custasp.length > 0) { custasp.forEach(function(asp) { if(asp.id_cust_asp == isASPSelected) { aspprename = asp.prename; aspsurname = asp.name; aspemail = asp.email; aspgebdat = asp.gebdat; } }); } } else { validateText('pre_' + article.itemnbr + '_' + i); validateText('sur_' + article.itemnbr + '_' + i); validateEmail('email_' + article.itemnbr + '_' + i); if(custasp != UNDEF && custasp.length > 0) { custasp.forEach(function(asp) { if(aspsurname.toLowerCase() == asp.name.toLowerCase() && aspprename.toLowerCase() == asp.prename.toLowerCase()) { ok=false; alert("Ein Anpsrechpartner mit dem Namen " +aspprename + " " + aspsurname+ " existiert bereits!") returnvalue= false; } }); } } persons.forEach(function(asp) { if(aspsurname.toLowerCase() == asp.name.toLowerCase() && aspprename.toLowerCase() == asp.prename.toLowerCase()) { ok=false; alert("Der Anpsrechpartner mit dem Namen " +aspprename + " " + aspsurname+ " ist mehrfach in der Bestellung!") returnvalue= false; } }); if(aspprename == "" || aspsurname == "") { alert("Sie haben mindestens einen Ansprechpartner nicht ausgefüllt.") returnvalue= false; } if(isASPSelected !=0 && aspsurname.toLowerCase() == user.name.toLowerCase() && aspprename.toLowerCase() == user.prename.toLowerCase()) { ok=false; alert("Sie können sich nicht selbst als Ansprechpartner hinzufügen.") returnvalue= false; } var fieldval = returnvalue; if(aspgebdat == "" && !gebdatoptional) { fieldval = validateText('gebdat_' + article.itemnbr + '_'+ article.subItem + '_' + i); if(fieldval == false) returnvalue = fieldval; else aspgebdat = $('#gebdat_' + article.itemnbr + '_'+ article.subItem + '_' + i).val().trim(); } if(gebdatoptional || (fieldval && article.isPersonAllowed(aspgebdat, ba.actDate))) { setSuccess('gebdat_' + article.itemnbr + '_'+ article.subItem + '_' + i); } else { returnvalue=false; setError('gebdat_' + article.itemnbr + '_'+ article.subItem + '_' + i); } if(returnvalue == true) { var person = new Person(user.idcustomer, aspsurname, aspprename, aspemail, "", "", "", "", isASPSelected, aspgebdat); article.persons[i] = person; persons.push(person); addPersonToArticle(tag.date, zeit.time, zeit.timeEnd, article.itemnbr, article.subItem, person); } } } }); }); }); } else { ba.getArticleZumzeitpunkt().forEach(article => { //console.log("artikel zur uhrzeit", article); if(article.customerRequired > 0) { var gebdatoptional = (article.customerRequired == 1) || NEEDSBIRTHDAY==false; for(var i = 0;i=0) { if(isASPSelected == 0) { aspprename = user.prename; aspsurname = user.name; aspemail = user.email; aspgebdat = user.gebdat; } else if(custasp != UNDEF && custasp.length > 0) { custasp.forEach(function(asp) { if(asp.id_cust_asp == isASPSelected) { aspprename = asp.prename; aspsurname = asp.name; aspemail = asp.email; aspgebdat = asp.gebdat; } }); } } else { validateText('pre_' + article.itemnbr + '_' + i); validateText('sur_' + article.itemnbr + '_' + i); validateEmail('email_' + article.itemnbr + '_' + i); if(custasp != UNDEF && custasp.length > 0) { custasp.forEach(function(asp) { if(aspsurname.toLowerCase() == asp.name.toLowerCase() && aspprename.toLowerCase() == asp.prename.toLowerCase()) { ok=false; alert("Ein Anpsrechpartner mit dem Namen " +aspprename + " " + aspsurname+ " existiert bereits!") returnvalue= false; } }); } } persons.forEach(function(asp) { if(aspsurname.toLowerCase() == asp.name.toLowerCase() && aspprename.toLowerCase() == asp.prename.toLowerCase()) { ok=false; alert("Der Anpsrechpartner mit dem Namen " +aspprename + " " + aspsurname+ " ist mehrfach in der Bestellung!") returnvalue= false; } }); if(aspprename == "" || aspsurname == "") { alert("Sie haben mindestens einen Ansprechpartner nicht ausgefüllt.") returnvalue= false; } if(isASPSelected !=0 && aspsurname.toLowerCase() == user.name.toLowerCase() && aspprename.toLowerCase() == user.prename.toLowerCase()) { ok=false; alert("Sie können sich nicht selbst als Ansprechpartner hinzufügen.") returnvalue= false; } var fieldval = returnvalue; if(aspgebdat == "" && !gebdatoptional) { fieldval = validateText('gebdat_' + article.itemnbr + '_'+ article.subItem + '_' + i); if(fieldval == false) returnvalue = fieldval; else aspgebdat = $('#gebdat_' + article.itemnbr + '_'+ article.subItem + '_' + i).val().trim(); } if(gebdatoptional || (fieldval && article.isPersonAllowed(aspgebdat, ba.actDate))) { setSuccess('gebdat_' + article.itemnbr + '_'+ article.subItem + '_' + i); } else { returnvalue=false; setError('gebdat_' + article.itemnbr + '_'+ article.subItem + '_' + i); } if(returnvalue == true) { var person = new Person(user.idcustomer, aspsurname, aspprename, aspemail, "", "", "", "", isASPSelected, aspgebdat); article.persons[i] = person; persons.push(person); } } } }); } if(returnvalue) { saveWK(); return true; } return false; } 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() { var step = parseInt(getWS(WS_BOOKINGSTEP)); step++; setWS(WS_NEXTP, P_SUBBOOKING + step); setWS(WS_BOOKINGSTEP, step); $(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_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_notes').val(user.bemerkung); $('#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 isArtikelSet(itemnbr) { var tag = getWS(WS_BDATE); var zeit = getWS(WS_BTIME); var zeitEnde = getWS(WS_BTIMEEND); if(itemnbr != UNDEF && ba != UNDEF && ba.hasDay(tag) && ba.getDay(tag).hasZeit(zeit, zeitEnde) && ba.getDay(tag).hasZeit(zeit, zeitEnde).hasArticle(itemnbr)) { 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 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 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 autocomplete(inp, isPLZ) { /*the autocomplete function takes two arguments, the text field element and an array of possible autocompleted values:*/ var currentFocus; /*execute a function when someone writes in the text field:*/ inp.addEventListener("input", function(e) { var arr = []; if(isPLZ) { arr = plzs; } else { var nbr = this.id.split('_')[2]; var plz = $('#booking_plz_' + nbr).val(); arr = plz_city[plz]; if(arr != null && arr.length == RES_NBR1 && $('#booking_city_' + nbr).data('only') == "" && $('#booking_city_' + nbr).val() == "") { $('#booking_city_' + nbr).val(arr[0]); $('#booking_city_' + nbr).data('only', arr[0]); return; } } var a, b, i, val = this.value; /*close any already open lists of autocompleted values*/ closeAllLists(); if (!val) { return false;} currentFocus = -1; /*create a DIV element that will contain the items (values):*/ a = document.createElement("DIV"); a.setAttribute(PID, this.id + "autocomplete-list"); a.setAttribute("class", "autocomplete-items"); /*append the DIV element as a child of the autocomplete container:*/ this.parentNode.appendChild(a); /*for each item in the array...*/ var counter = 0; for (i = 0; i < arr.length; i++) { /*check if the item starts with the same letters as the text field value:*/ if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) { /*create a DIV element for each matching element:*/ b = document.createElement("DIV"); /*make the matching letters bold:*/ b.innerHTML = "" + arr[i].substr(0, val.length) + ""; b.innerHTML += arr[i].substr(val.length); /*insert a input field that will hold the current array item's value:*/ b.innerHTML += ""; /*execute a function when someone clicks on the item value (DIV element):*/ b.addEventListener("click", function(e) { /*insert the value for the autocomplete text field:*/ inp.value = this.getElementsByTagName("input")[0].value; /*close the list of autocompleted values, (or any other open lists of autocompleted values:*/ closeAllLists(); }); a.appendChild(b); counter++; if(isPLZ && counter>=9) { break; } } } }); inp.addEventListener("focus", function(e) { var arr = []; if(isPLZ) { arr = plzs; } else { var nbr = this.id.split('_')[2]; var plz = $('#booking_plz_' + nbr).val(); arr = plz_city[plz]; if(arr != null && arr.length == RES_NBR1 && $('#booking_city_' + nbr).data('only') == "" && $('#booking_city_' + nbr).val() == "") { $('#booking_city_' + nbr).val(arr[0]); $('#booking_city_' + nbr).data('only', arr[0]); return; } } var a, b, i, val = this.value; /*close any already open lists of autocompleted values*/ closeAllLists(); if (!val) { return false;} currentFocus = -1; /*create a DIV element that will contain the items (values):*/ a = document.createElement("DIV"); a.setAttribute(PID, this.id + "autocomplete-list"); a.setAttribute("class", "autocomplete-items"); /*append the DIV element as a child of the autocomplete container:*/ this.parentNode.appendChild(a); /*for each item in the array...*/ for (i = 0; i < arr.length; i++) { /*check if the item starts with the same letters as the text field value:*/ if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) { /*create a DIV element for each matching element:*/ b = document.createElement("DIV"); /*make the matching letters bold:*/ b.innerHTML = "" + arr[i].substr(0, val.length) + ""; b.innerHTML += arr[i].substr(val.length); /*insert a input field that will hold the current array item's value:*/ b.innerHTML += ""; /*execute a function when someone clicks on the item value (DIV element):*/ b.addEventListener("click", function(e) { /*insert the value for the autocomplete text field:*/ inp.value = this.getElementsByTagName("input")[0].value; /*close the list of autocompleted values, (or any other open lists of autocompleted values:*/ closeAllLists(); }); a.appendChild(b); } } }); /*execute a function presses a key on the keyboard:*/ inp.addEventListener("keydown", function(e) { var x = document.getElementById(this.id + "autocomplete-list"); if (x) x = x.getElementsByTagName("div"); if (e.keyCode == 40) { /*If the arrow DOWN key is pressed, increase the currentFocus variable:*/ currentFocus++; /*and and make the current item more visible:*/ addActive(x); } else if (e.keyCode == 38) { //up /*If the arrow UP key is pressed, decrease the currentFocus variable:*/ currentFocus--; /*and and make the current item more visible:*/ addActive(x); } else if (e.keyCode == 13) { /*If the ENTER key is pressed, prevent the form from being submitted,*/ e.preventDefault(); if (currentFocus > -1) { /*and simulate a click on the "active" item:*/ if (x) x[currentFocus].click(); } } }); function addActive(x) { /*a function to classify an item as "active":*/ if (!x) return false; /*start by removing the "active" class on all items:*/ removeActive(x); if (currentFocus >= x.length) currentFocus = 0; if (currentFocus < 0) currentFocus = (x.length - 1); /*add class "autocomplete-active":*/ x[currentFocus].classList.add("autocomplete-active"); } function removeActive(x) { /*a function to remove the "active" class from all autocomplete items:*/ for (var i = 0; i < x.length; i++) { x[i].classList.remove("autocomplete-active"); } } function closeAllLists(elmnt) { /*close all autocomplete lists in the document, except the one passed as an argument:*/ var x = document.getElementsByClassName("autocomplete-items"); for (var i = 0; i < x.length; i++) { if (elmnt != x[i] && elmnt != inp) { x[i].parentNode.removeChild(x[i]); } } } /*execute a function when someone clicks in the document:*/ document.addEventListener("click", function (e) { closeAllLists(e.target); }); } 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(); } })();