function getip() { return "https://bergwerk.berlin"; } function getWidth() { if (self.innerHeight) { return self.innerWidth; } if (document.documentElement && document.documentElement.clientHeight) { return document.documentElement.clientWidth; } if (document.body) { return document.body.clientWidth; } } function fagineum_ticket_client_check_step1($scope) { var error_list = []; $scope.error_relation_adults_children = false; var amount_children1 = $scope.get_ticket_count('0_1')*1; var amount_adults1 = $scope.get_ticket_count('0_3')*1 + $scope.get_ticket_count('0_2')*1; var amount_upgrade1 = $scope.get_ticket_count('0_9')*1 var amount_upgrade2 = $scope.get_ticket_count('0_10')*1 var amount_panel1 = $scope.get_ticket_count("0_1")*1 + $scope.get_ticket_count('0_2')*1 + $scope.get_ticket_count('1_2') + $scope.get_ticket_count('0_3')*1; var amount_panel2 = $scope.get_ticket_count("0_4")*1 + $scope.get_ticket_count("0_5")*1; if (amount_upgrade1 > amount_panel1) { error_list.push("

Achtung! Es dürfen nicht mehr Upgrades ("+amount_upgrade1+") eingetragen werden als Buchungen ("+amount_panel1+")

"); } if (amount_upgrade2 > amount_panel2) { error_list.push("

Achtung! Es dürfen nicht mehr Upgrades ("+amount_upgrade2+") eingetragen werden als Buchungen ("+amount_panel2+")

"); } var quote1 = 0; if (amount_adults1 > 0) { quote1 = amount_children1 / amount_adults1; } else { quote1 = 6; } if (amount_children1 > 0 && quote1 > 5) { var missing = amount_children1 / 5 - amount_adults1; if (Math.round(missing) < missing) { missing = Math.round(missing) + 1; } else { missing = Math.round(missing); } var err_text = '

Achtung! Für das Klettern von Kindern im Gipfelstürmer müssen Erwachsene mitklettern. Dabei darf ein Erwachsener maximal 5 Kinder begleiten. '; if (missing === 1) { err_text += 'Es fehlt noch 1 Erwachsener!'; } else { err_text += 'Es fehlen noch ' + missing + ' Erwachsene!'; } err_text += '

'; error_list.push(err_text); } var amount_adults2 = $scope.get_ticket_count('0_5')*1; var amount_children2 = $scope.get_ticket_count('0_4')*1; var quote2 = 0; if (amount_adults2 > 0) { quote2 = amount_children2 / amount_adults2; } else { quote2 = 6; } $scope.error_relation_adults_children2 = false if (amount_children2 > 0 && quote2 > 5) { var missing = amount_children2 / 5 - amount_adults2; if (Math.round(missing) < missing) { missing = Math.round(missing) + 1; } else { missing = Math.round(missing) } var err_text = '

Achtung! Für das Klettern von Kindern im BigJunior müssen Erwachsene mitklettern. Dabei darf ein Erwachsener maximal 5 Kinder begleiten. '; if (missing === 1) { err_text += 'Es fehlt noch 1 Erwachsener!'; } else { err_text += 'Es fehlen noch ' + missing + ' Erwachsene!'; } err_text += '

'; error_list.push(err_text); } if (amount_children2 === 0 && amount_adults2 * 1 > 0) { error_list.push('

Achtung! Erwachsene im BigJunior Parcours sind Erwachsene nur als Begleitung zugelassen!

'); } var amount_adults3 = $scope.get_ticket_count('0_7') * 1; var amount_children3 = $scope.get_ticket_count('0_6') * 1; if (amount_children3 === 0 && amount_adults3 * 1 > 0) { error_list.push('

Achtung! Erwachsene im KidsXXL-Paket sind nur als Begleitung zugelassen!

'); } if ($scope.ticketservice.event*1 === 1 && (amount_children1 + amount_children2 + amount_children3 + $scope.get_ticket_count('1_2')*1 + $scope.get_ticket_count('0_8')*1) === 0) { error_list.push('

Achtung! Für einen Kindergeburtstag muss es mindestens 1 Kind geben!

'); } if ($scope.ticketservice.event*1 === 1 && ($scope.get_count() < 4)) { error_list.push('

Achtung! Für einen Kindergeburtstag brauchen wir mindestens 4 Kletternde!

'); } return error_list; } function fagineum_ticket_client_warning_step1($scope) { var count_duration_250 = $scope.get_ticket_count('0_1') + $scope.get_ticket_count('0_2') + $scope.get_ticket_count('1_2') +$scope.get_ticket_count('0_3') + $scope.get_ticket_count('0_6') + $scope.get_ticket_count('0_7') + $scope.get_ticket_count('0_9'); var count_duration_150 = $scope.get_count() - count_duration_250; var warn_list = []; if (count_duration_250 > 0 && count_duration_150 > 0 && $scope.ticketservice.event*1 > 0) { var text = "Mir ist bewußt, dass die gewählten Tickets unterschiedliche Kletterdauer haben und dadurch Wartezeit entstehen, da die Anschlussveranstaltung erst nach der längsten Kletterzeit beginnt!"; if ($scope.ticketservice.warn['0_'+text] !== true) { warn_list.push(text); } } return warn_list; } function fagineum_ticket_client_additional_fields($scope) { var arr = []; if ($scope.ticketservice.event*1 === 1) { arr.push("Alter des Kindes"); } return arr; } function fagineum_has_selbstversorger($scope) { return $scope.ticketservice.equipment['_'+$scope.equipment['equipment'][4].id] !== undefined && $scope.ticketservice.equipment['_'+$scope.equipment['equipment'][4].id] * 1 > 0; } function fagineum_ticket_client_warning_step3($scope) { var warn_list = []; var count_equipment = 0; for (var i=0;i<$scope.equipment['equipment'].length;i++) { if ($scope.ticketservice.equipment['_'+$scope.equipment['equipment'][i].id] !== undefined) { count_equipment += $scope.ticketservice.equipment['_'+$scope.equipment['equipment'][i].id]*1; } } var text_alter_des_kindes = "Alter des Kindes"; var alter = $scope.ticketservice.additional_fields[text_alter_des_kindes]; if ($scope.ticketservice.additional_fields[text_alter_des_kindes] === undefined) { alter = 0; } var val2 = $scope.get_count(); var hasSelbstversorger = fagineum_has_selbstversorger($scope); if (hasSelbstversorger === false && val2 > count_equipment && count_equipment !== 0) { var text = " Achtung Es gibt mehr Kletterer als Menü's! OK?"; if ($scope.ticketservice.warn['3_'+text] !== true) { warn_list.push(text); } } return warn_list; } function fagineum_ticket_client_check_step3($scope) { var error_list = []; var count_equipment = 0; for (var i=0;i<$scope.equipment['equipment'].length;i++) { if ($scope.ticketservice.equipment['_'+$scope.equipment['equipment'][i].id] !== undefined) { count_equipment += $scope.ticketservice.equipment['_'+$scope.equipment['equipment'][i].id]*1; } } var hasSelbstversorger = fagineum_has_selbstversorger($scope); var text_alter_des_kindes = "Alter des Kindes"; var alter = $scope.ticketservice.additional_fields[text_alter_des_kindes]; if ($scope.ticketservice.additional_fields[text_alter_des_kindes] === undefined) { alter = 0; } if (alter === 0) { error_list.push("

Achtung Ihr habt kein Alter für das Kind eingegeben!

"); } if (alter > 0 && alter < 3 ) { error_list.push("

Achtung Das minimale Alter für Kindergeburtstage ist 3 Jahre!

"); } var val2 = $scope.get_count(); if (count_equipment > 10) { error_list.push("

Achtung Mehr als 10 Menü's sind über diesen Buchungsprozess nicht möglich. Kontaktiert uns, wenn eine größere 'Runde' plant ist!

"); } if (hasSelbstversorger === false && count_equipment < 6) { error_list.push("

Achtung Für das Feier im Bergwerk.Berlin werden mindestens 6 Menü's benötigt!

"); } return error_list; } function fagineum_ticket_client_custom_note($scope) { var note = ""; if ($scope.get_ticket_count('0_2')*1 > 0) { note = "Reservierung im Gipfelstürmer ist mit " + $scope.get_ticket_count('1_2') + " Erwachsenen Studenten/Schülern."; } var text_alter_des_kindes = "Alter des Kindes"; if ($scope.ticketservice.event*1 === 1) { note += "\nAlter des Kindes: "+$scope.ticketservice.additional_fields[text_alter_des_kindes]; } return note; } function fagineum_get_custom_location_id() { return 1; } function fill_it(until) { var list = []; for (var i = 0; i <= until; i++) { var el = {}; el.id = i * 1; el.el = (i < 10) ? "0" + i : "" + i; list.push(el); } return list; } function get_short_date_string(date) { var tag = date.getDate(); var monat = date.getMonth() + 1; if (("" + tag).length == 1) { tag = "0" + tag; } if (("" + monat).length == 1) { monat = "0" + monat; } return tag + "" + monat; } function add_days(date, day) { var date1 = date.clone(); date1.add(1, day); return date1; } Date.prototype.calc_easter = function () { var year = this.getFullYear(); var a = year % 19; var b = Math.floor(year / 100); var c = year % 100; var d = Math.floor(b / 4); var e = b % 4; var f = Math.floor((b + 8) / 25); var g = Math.floor((b - f + 1) / 3); var h = (19 * a + b - d - g + 15) % 30; var i = Math.floor(c / 4); var k = c % 4; var l = (32 + 2 * e + 2 * i - h - k) % 7; var m = Math.floor((a + 11 * h + 22 * l) / 451); var n0 = (h + l + 7 * m + 114) var n = Math.floor(n0 / 31) - 1; var p = n0 % 31 + 1; var date = new Date(year, n, p); return date; } Date.prototype.is_feiertag = function () { var tag = this.getDate(); var monat = this.getMonth(); var tag1 = tag; var monat1 = monat; if (("" + tag1).length === 1) { tag1 = "0" + tag; } if (("" + monat1).length === 1) { monat1 = "0" + monat1; } feiertage = new Array(); feiertage.push("0101"); //Neujahrstag feiertage.push("0105"); //Tag der Arbeit feiertage.push("0310"); //Tag der Deutschen Einheit feiertage.push("2512"); //Erster Weihnachtstag feiertage.push("2612"); //Zweiter Weihnachtstag var easter = this.calc_easter(); feiertage.push(get_short_date_string(add_days(easter, -2))); //Karfreitag feiertage.push(get_short_date_string(add_days(easter, 1))); //Ostermontag feiertage.push(get_short_date_string(add_days(easter, 39))); //Himmerfahrt feiertage.push(get_short_date_string(add_days(easter, 50))); //Pfingstmonat for (var i = 0; i < feiertage.length; i++) { if (feiertage[i] == (tag1 + "" + monat1)) { return true; } } return false; } Date.prototype.get_day_of_week = function () { if (this.is_feiertag() === true) { return 8; } else { var day_of_week = [7, 1, 2, 3, 4, 5, 6]; return day_of_week[this.getDay()]; } } Date.prototype.is_empty = false; // Provide month names Date.prototype.getMonthName = function () { var month_names = ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']; return month_names[this.getMonth()]; } // Provide month abbreviation Date.prototype.getMonthAbbr = function () { var month_abbrs = ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec']; return month_abbrs[this.getMonth()]; } // Provide full day of week name Date.prototype.getDayFull = function () { var days_full = ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag']; return days_full[this.getDay()]; }; // Provide full day of week name Date.prototype.getDayAbbr = function () { var days_abbr = ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa']; return days_abbr[this.getDay()]; }; Date.prototype.clone = function () { var date1 = new Date(this.getTime()); date1.is_empty = this.is_empty; return date1; } /** * Add date * @param {type} type 1: add day(s), 2: add weeks(s), 3: add month(s), 4: add year(s) * @param {type} amount: amount to be added, could be negativ = substraction */ Date.prototype.add = function (type, amount) { switch (type * 1) { case 1: var date = this.getDate(); this.setDate(date + amount); break; case 2: var date = this.getDate(); this.setDate(date + amount * 7); break; case 3: this.setMonth(this.getMonth() + amount); break; case 4: this.setFullYear(this.getFullYear() + amount); break; case 5: this.setHours(this.getHours() + amount); break; case 6: this.setMinutes(this.getMinutes() + amount); break; } }; // Provide the day of year 1-365 Date.prototype.getDayOfYear = function () { var onejan = new Date(this.getFullYear(), 0, 1); return Math.ceil((this - onejan) / 86400000); }; // Provide the day suffix (st,nd,rd,th) Date.prototype.getDaySuffix = function () { var d = this.getDate(); var sfx = ["th", "st", "nd", "rd"]; var val = d % 100; return (sfx[(val - 20) % 10] || sfx[val] || sfx[0]); }; // Provide Week of Year Date.prototype.getWeekOfYear = function () { var onejan = new Date(this.getFullYear(), 0, 1); return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7); } // Provide if it is a leap year or not Date.prototype.isLeapYear = function () { var yr = this.getFullYear(); if ((parseInt(yr) % 4) == 0) { if (parseInt(yr) % 100 == 0) { if (parseInt(yr) % 400 != 0) { return false; } if (parseInt(yr) % 400 == 0) { return true; } } if (parseInt(yr) % 100 != 0) { return true; } } if ((parseInt(yr) % 4) != 0) { return false; } }; // Provide Number of Days in a given month Date.prototype.getMonthDayCount = function () { var month_day_counts = [31, this.isLeapYear() ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; return month_day_counts[this.getMonth()]; } // format provided date into this.format format Date.prototype.format = function (dateFormat) { // break apart format string into array of characters dateFormat = dateFormat.split(""); var date = this.getDate(); var month = this.getMonth(); var hours = this.getHours(); var minutes = this.getMinutes(); var seconds = this.getSeconds(); // get all date properties ( based on PHP date object functionality ) var date_props = { d: date < 10 ? '0' + date : date, D: this.getDayAbbr(), j: this.getDate(), l: this.getDayFull(), S: this.getDaySuffix(), w: this.getDay(), z: this.getDayOfYear(), W: this.getWeekOfYear(), F: this.getMonthName(), m: month * 1 + 1 < 10 ? '0' + (month + 1) : month + 1, M: this.getMonthAbbr(), n: month * 1 + 1, t: this.getMonthDayCount(), L: this.isLeapYear() ? '1' : '0', Y: (this.getFullYear() + "").substring(2, 4), y: this.getFullYear(), a: hours > 12 ? 'pm' : 'am', A: hours > 12 ? 'PM' : 'AM', g: hours % 12 > 0 ? hours % 12 : 12, G: hours > 0 ? hours : "12", h: hours % 12 > 0 ? hours % 12 : 12, H: hours < 10 ? '0' + hours : hours, i: minutes < 10 ? '0' + minutes : minutes, s: seconds < 10 ? '0' + seconds : seconds }; // loop through format array of characters and add matching data else add the format character (:,/, etc.) var date_string = ""; for (var i = 0; i < dateFormat.length; i++) { var f = dateFormat[i]; if (f.match(/[a-zA-Z]/g)) { date_string += date_props[f] || date_props[f] == 0 ? date_props[f] : ''; } else { date_string += f; } } return date_string; }; Date.prototype.get_next_date = function (type, format) { var date1 = this.clone(); date1.add(type, 1); return date1.format(format); }; Date.prototype.get_before_date = function (type, format) { var date1 = this.clone(); date1.add(type, -1); return date1.format(format); }; Date.prototype.next = function (type) { this.add(type, 1); }; Date.prototype.before = function (type) { this.add(type, -1); }; Date.prototype.hour = function (newHour) { if (this.is_empty === undefined) { this.is_empty = false; } if (arguments.length > 0) { this.setHours(newHour * 1); this.is_empty = false; } else { return this.is_empty ? "" : this.getHours() * 1; } }; Date.prototype.minute = function (newMinute) { if (this.is_empty === undefined) { this.is_empty = false; } if (arguments.length > 0) { this.setMinutes(newMinute); this.is_empty = false; } else { return this.is_empty ? "" : this.getMinutes() * 1; } }; Date.prototype.second = function (newSecond) { if (this.is_empty === undefined) { this.is_empty = false; } if (arguments.length > 0) { this.setSeconds(newSecond); this.is_empty = false; } else { return this.is_empty ? "" : this.getSeconds() * 1; } }; Date.prototype.day = function (newDay) { if (this.is_empty === undefined) { this.is_empty = false; } if (arguments.length > 0) { this.setDate(newDay); this.is_empty = false; } else { return this.is_empty ? "" : this.getDate() * 1; } }; Date.prototype.month = function (newMonth) { if (this.is_empty === undefined) { this.is_empty = false; } if (arguments.length > 0) { this.setMonth(newMonth - 1); this.is_empty = false; } else { return this.is_empty ? "" : this.getMonth() * 1 + 1; } }; Date.prototype.year = function (newYear) { if (this.is_empty === undefined) { this.is_empty = false; } if (arguments.length > 0) { this.setYear(newYear); this.is_empty = false; } else { return this.is_empty ? "" : this.getFullYear() * 1; } }; Date.prototype.getHourList = function () { var list = []; for (var i = 0; i < 24; i++) { list.push(i); } return list; }; Date.prototype.getMinuteList = function () { var list = []; for (var i = 0; i < 60; i++) { list.push(i); } return list; }; Date.prototype.getYearList = function () { var list = []; var date = new Date(); for (var i = 0; i < 40; i++) { list.push(date.getFullYear() * 1 - 20 + i); } return list; }; Date.prototype.getMonthList = function () { var list = []; for (var i = 1; i <= 12; i++) { list.push("" + i); } return list; }; Date.prototype.getDaysList = function () { var list = []; for (var i = 1; i <= this.getMonthDayCount() * 1; i++) { list.push(i); } return list; }; Date.prototype.getEmptyDay = function () { var date1 = this.clone(); date1.setDate(1); var list = []; var t = date1.getDay() * 1 - 1; if (t * 1 < 0) { t = 6; } for (var i = 0; i < t; i++) { list.push(i); } return list; }; Date.prototype.init_empty = function () { this.is_empty = true; }; Date.prototype.init_not_empty = function () { this.is_empty = false; }; function from_sql_to_date(datestring) { var t = datestring.split(/[- :]/); if (t.length <= 3) { t[3] = 0; t[4] = 0; t[5] = 0; } var date1 = new Date(t[0], t[1] - 1, t[2], t[3], t[4], t[5]); date1.is_empty = false; return date1; } ; function time_object(hour_minute) { this.hour = parseInt(hour_minute/100); this.minute = (hour_minute % 100); this.get_value = function() { return this.hour*100 + this.minute*1; } this.print = function() { var hour_val = this.hour; if(this.hour < 10) { hour_val = "0" + this.hour; } var minute_val = this.minute; if(this.minute < 10) { minute_val = "0" + this.minute; } return hour_val+":"+minute_val; } }; 'use strict'; var fagineum_client_ticket_app = angular.module('fagineum_ticket_client', [ 'ngRoute', 'chieffancypants.loadingBar', 'fagineum_client_ticket.startpage', 'fagineum_client_ticket.main_controller', 'ngAnimate', 'ui.bootstrap' ]); fagineum_client_ticket_app.config(function (cfpLoadingBarProvider, $sceProvider) { cfpLoadingBarProvider.includeSpinner = true; $sceProvider.enabled(false); }); fagineum_client_ticket_app.config(['$routeProvider', function ($routeProvider) { $routeProvider.otherwise({redirectTo: '/maincontroller'}); $routeProvider.when('/startpage', { templateUrl: 'fagineum_client/html/startbutton.min.html?v=1', controller: 'startpage_controller' }); $routeProvider.when('/maincontroller', { templateUrl: 'fagineum_client/html/frame.min.html?v=1', controller: 'fagineum_main_controller' }); }]); var fagineum_main_controller_scope = null; var startpage_app = angular.module('fagineum_client_ticket.startpage', ['ngRoute', 'ngAnimate']); startpage_app.controller('startpage_controller', function ($scope, $http, $location, cfpLoadingBar) { $scope.go_step1 = function () { cfpLoadingBar.start(); document.getElementsByTagName("section")[0].style.display = 'none'; if (getWidth() < 450) { document.getElementsByTagName("nav")[0].style.display = 'none'; } $location.path("/maincontroller"); } }); function webservice_get_timeline($scope, $http) { var year = 0; var month = 0; var day = 0; if ($scope.booking_date !== null) { year = $scope.ticketservice.bookingdate.getFullYear(); month = $scope.ticketservice.bookingdate.getMonth() + 1; day = $scope.ticketservice.bookingdate.getDate(); } if (month * 1 < 10) { month = "0" + month; } if (day * 1 < 10) { day = "0" + day; } $http.get(getip() + "/services/timelist.php?booking_date=" + year + "-" + month + "-" + day + "&rand=" + Math.random()).success(function (response) { $scope.error_code = 0; if (response.success === true || response.success == "true") { $scope.timelist = response.data; $scope.is_loading = false; if ($scope.get_timelist_keys().length === 0) { $scope.set_grey = false; } else { $scope.set_grey = true; } } else { $scope.error_code = response.error_code * 1; $scope.is_loading = false; } }); } var check_big_group_counter = 0; function check_big_group(timelist, time, resourcetype_id, tickettype_id, duration, count, offset) { if (count * 1 === 0) { return false; } for (i = 0; i < parseInt(duration / 50); i++) { var current_time = time * 1 + i * 50 + offset * 1; for (var key in timelist[current_time]) { if (key * 1 === resourcetype_id * 1) { for (var key1 in timelist[current_time][key]) { for (j = 0; j < timelist[current_time][key][key1].tickettype_ids.length; j++) { if (timelist[current_time][key][key1].tickettype_ids[j] * 1 === tickettype_id * 1) { if (timelist[current_time][key][key1].type * 1 === 1) { if (i === 0) { if (count * 1 > timelist[current_time][key][key1].count_type_1 * 1) { return true; } } } else { if (count * 1 > timelist[current_time][key][key1].count_type_0 * 1) { return true; } } } } } } } } return false; } function check_booking_state(timelist, time, resourcetype_id, tickettype_id, duration, count, offset) { if (count * 1 === 0) { return 4; } for (i = 0; i < parseInt(duration / 50); i++) { var current_time = time * 1 + i * 50 + offset * 1; if (timelist[current_time] === undefined) { return 1; } for (var key in timelist[current_time]) { if (key * 1 === resourcetype_id * 1) { for (var key1 in timelist[current_time][key]) { for (j = 0; j < timelist[current_time][key][key1].tickettype_ids.length; j++) { if (timelist[current_time][key][key1].tickettype_ids[j] * 1 === tickettype_id * 1) { if (timelist[current_time][key][key1].type * 1 === 1) { if (i === 0) { if (timelist[current_time][key][key1].booking_type_1 * 1 + count * 1 > timelist[current_time][key][key1].count_type_1 * 1) { return 1; } } else { if (timelist[current_time][key][key1].booking_type_0 * 1 + count * 1 > timelist[current_time][key][key1].count_type_0 * 1) { return 1; } } } else { if (timelist[current_time][key][key1].booking_type_0 * 1 + count * 1 > timelist[current_time][key][key1].count_type_0 * 1) { return 1; } } } } } } } } return 3; } function get_to_plus_one_day() { var date = new Date(); date.setDate(date.getDate() + 1); return date; } fagineum_client_ticket_app.factory('fagineum_client_ticket_service', function () { var services = { eventtext: "", //Text für das Event equipment: [], additional_equipment: [], bookingdate: get_to_plus_one_day(), bookingtime: new Date(0, 0, 0, 0, 0, 0, 0), tickets: [], event: "0", warn: [], additional_fields: [], clear: function () { this.tickets = []; this.event = 0; this.warn = []; this.additional_fields = []; this.booking_date = new Date(); this.booking_time = new Date(0, 0, 0, 0, 0, 0, 0); }, tmp_price: [], get_price: function (price_list, tickettype_id, resourcetype_id) { if (this.tmp_price[tickettype_id + "_" + resourcetype_id + "_" + "_" + this.bookingdate.getTime()] !== undefined) { return this.tmp_price[tickettype_id+"_"+resourcetype_id+"_"+this.bookingdate.getTime()]; } for (var i = 0; i < price_list.length; i++) { if (price_list[i].tickettype_id * 1 === tickettype_id * 1 && price_list[i].resourcentype_id * 1 === resourcetype_id * 1) { var beginn = from_sql_to_date(price_list[i].season_beginn); var end = from_sql_to_date(price_list[i].season_end); if (beginn.getTime() <= this.bookingdate.getTime() && this.bookingdate.getTime() <= end.getTime()) { var day_of_weeks = price_list[i].weekday.split(","); for (var j = 0; j < day_of_weeks.length; j++) { if (this.bookingdate.get_day_of_week() * 1 === day_of_weeks[j] * 1) { this.tmp_price[tickettype_id+"_"+resourcetype_id+"_"+this.bookingdate.getTime()] = price_list[i].price * 1; return price_list[i].price * 1; } } } } } return 0.0; }, }; return services; }); fagineum_client_ticket_app.factory('fagineum_client_form_service', function() { var services = { customertyp: "1", has_error: false, error_text: "", salutation: "0", salutation_error: false, organisation: "", organisation_error: false, first_name: "", first_name_error: false, last_name: "", last_name_error: false, street: "", street_error: false, zipcode: "", zipcode_error: false, city: "", city_error: false, telefon: "", telefon_error: false, email: "", email_error: false, email1: "", email1_error: false, check1: false, check1_error: false, check2: false, check2_error: false, kostenpflichtig: false, check_kostenpflichtig: false, init_error : function() { this.has_error = false; this.error_text = ""; this.salutation_error = false; if(this.customertyp*1 !== 2) { this.organisation = ""; } this.organisation_error = false; this.first_name_error= false; this.last_name_error= false; this.street_error = false; this.zipcode_error= false; this.city_error= false; this.telefon_error= false; this.email_error= false; this.email1_error= false; this.email_equals_error = false; this.check1_error= false; this.check2_error= false; this.check_kostenpflichtig = false; }, validateEmail : function(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); }, check_error : function() { this.init_error(); if(this.salutation*1 === 0) { this.salutation_error = true; this.has_error = true; } if(this.customertyp*1 === 2 && this.organisation.length === 0) { this.organisation_error = true; this.has_error = true; } if(this.first_name.length === 0) { this.first_name_error = true; this.has_error = true; } if(this.last_name.length === 0) { this.last_name_error = true; this.has_error = true; } if(this.street.length === 0) { this.street_error = true; this.has_error = true; } if(this.zipcode.length === 0) { this.zipcode_error = true; this.has_error = true; } if(this.city.length === 0) { this.city_error = true; this.has_error = true; } if(this.telefon.length === 0) { this.telefon_error = true; this.has_error = true; } if(this.email.length === 0 || this.validateEmail(this.email) === false) { this.email_error = true; this.has_error = true; } if(this.email1.length === 0 || this.validateEmail(this.email1) === false) { this.email1_error = true; this.has_error = true; } if(this.email.length > 0 && this.email1.length > 0 && this.email != this.email1) { this.email_equals_error = true; this.has_error = true; } if(this.check1 !== true) { this.check1_error = true; this.has_error = true; } if(this.check2 !== true) { this.check2_error = true; this.has_error = true; } return this.has_error; } }; return services; }); function fill_with_zero(str, len) { diff = len - str.length; for (i = 0; i < diff; i++) { str = "0" + str; } return str; } function get_custom_date_str(custom_date, customer_time) { var year = custom_date.getFullYear() + ""; var month = fill_with_zero((custom_date.getMonth() + 1) + "", 2); var day = fill_with_zero(custom_date.getDate() + "", 2); var hour = fill_with_zero(customer_time.getHours() + "", 2); var minute = fill_with_zero(customer_time.getMinutes() + "", 2); return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":00"; } function get_custom_time(custom_time, additional) { var hour = additional / 100; var minutes = additional % 100; custom_time.setHours(custom_time.getHours() + hour); custom_time.setMinutes(custom_time.getMinutes() + minutes / 100 * 60); return custom_time; } function get_beginn_time(date, time, offset) { var custom_time = angular.copy(time); if (offset !== 0) { custom_time = get_custom_time(custom_time, offset); } return get_custom_date_str(date, custom_time); } function get_end_time(date, time, duration, offset) { var custom_time = angular.copy(time); if (offset !== 0) { custom_time = get_custom_time(custom_time, offset); } if (duration !== 0) { custom_time = get_custom_time(custom_time, duration); } return get_custom_date_str(date, custom_time); } get_analytics_item = function(name, sku, category, price, quantity) { return { item_id: sku, item_name: name, item_category: category, price: price, quantity: quantity, affiliation: 'BergwerkClient' }; } add_analytics_item = function (bookingnr, name, sku, category, price, quantity) { /* if (quantity > 0) { ga('ecommerce:addItem', { 'id': bookingnr, // Transaction ID. Required. 'name': name, // Product name. Required. 'sku': sku, // SKU/code. 'category': category, // Category or variation. 'price': price, // Unit price. 'quantity': quantity // Quantity. }); } */ return quantity > 0 ? get_analytics_item(name, sku, category, price, quantity) : undefined; } webservice_get_vticket_resourcetype_id = function($scope) { var resourcetype_id_list = []; for (var i=0;i<$scope.virtual_tickets.length;i++) { var vticket = $scope.virtual_tickets[i]; if (vticket.panel_type === 'single') { if ($scope.ticketservice.tickets['0_'+vticket.id]*1 > 0) { var ticket = $scope.get_ticket_by_id(vticket.ticket_id); var offset = 0; if (ticket.offset !== undefined) { offset = ticket.offset; } if (resourcetype_id_list.indexOf(ticket.resourcetype_id+"_"+ticket.duration+"_"+offset) === -1) { resourcetype_id_list.push(ticket.resourcetype_id+"_"+ticket.duration+"_"+offset); } } } if (vticket.panel_type === 'mix' || vticket.panel_type === 'virtual') { for (var j=0;j 0) { var ticket = $scope.get_ticket_by_id(vticket.ticket_id[j]); var offset = 0; if (ticket.offset !== undefined) { offset = ticket.offset; } if (resourcetype_id_list.indexOf(ticket.resourcetype_id+"_"+ticket.duration+"_"+offset) === -1) { resourcetype_id_list.push(ticket.resourcetype_id+"_"+ticket.duration+"_"+offset); } } } } } return resourcetype_id_list; } webservice_get_vticket_by_resourcetype_id_duration = function($scope, resourcetype_id, duration, offset) { var ticket_list = []; for (var i=0;i<$scope.virtual_tickets.length;i++) { var vticket = $scope.virtual_tickets[i]; if (vticket.panel_type === 'single') { if ($scope.ticketservice.tickets['0_'+vticket.id]*1 > 0) { var ticket = $scope.get_ticket_by_id(vticket.ticket_id); if (ticket.resourcetype_id*1 === resourcetype_id*1 && ticket.duration*1 === duration*1 && ((ticket.offset === undefined && offset === 0) || ticket.offset*1 === offset*1)) { ticket["count"] = $scope.ticketservice.tickets['0_'+vticket.id]*1; ticket_list.push(ticket); } } } if (vticket.panel_type === 'mix' || vticket.panel_type === 'virtual') { for (var j=0;j 0) { if (ticket.resourcetype_id*1 === resourcetype_id*1 && ticket.duration*1 === duration*1 && ((ticket.offset === undefined && offset === 0) || ticket.offset*1 === offset*1)) { ticket["count"] = $scope.ticketservice.tickets[counter+'_'+vticket.id]*1; ticket_list.push(ticket); } } } } } return ticket_list; } webservice_get_equipment = function($scope) { var list = []; for (var i=0;i<$scope.equipment['equipment'].length;i++) { var item = angular.copy($scope.equipment['equipment'][i]); if ($scope.ticketservice.equipment['_'+item.id] !== undefined && $scope.ticketservice.equipment['_'+item.id]*1 > 0) { item["count"] = $scope.ticketservice.equipment['_'+item.id]; list.push(item); } } for (var i=0;i<$scope.equipment['equipment_additional'].length;i++) { var item = angular.copy($scope.equipment['equipment_additional'][i]); if ($scope.ticketservice.equipment['additional_'+item.id] !== undefined && $scope.ticketservice.equipment['additional_'+item.id]*1 > 0) { item["count"] = $scope.ticketservice.equipment['additional_'+item.id]; list.push(item); } } return list; } webservice_do_booking = function ($scope, $http) { var fs = $scope.formservice; var ts = $scope.ticketservice; var obj = new Object(); obj.c_type = fs.customertyp; obj.c_salutation = fs.salutation; obj.c_organisation = fs.organisation; obj.c_first_name = fs.first_name; obj.c_last_name = fs.last_name; obj.c_street = fs.street; obj.c_zipcode = fs.zipcode; obj.c_city = fs.city; obj.c_telefon = fs.telefon; obj.c_email = fs.email; obj.booking_event_id = ts.event; obj.booking_event_name = ts.eventtext; obj.newsletter = fs.newsletter === true ? "1" : "0"; var resourcetype_id_list = webservice_get_vticket_resourcetype_id($scope); for (var i=0;i 0) { var event = $scope.get_event_by_id(ts.event); if (event !== undefined) { counter++; var offset = $scope.get_max_offset(1); obj["br_" + counter + "_resourcetype_id"] = event.resourcetype_id; obj["br_" + counter + "_beginn"] = get_beginn_time(ts.bookingdate, ts.bookingtime, offset); obj["br_" + counter + "_end"] = get_end_time(ts.bookingdate, ts.bookingtime, offset, event.duration); obj["br_" + counter + "_location_id"] = fagineum_get_custom_location_id(); obj["br_" + counter + "_ticket_1_ticket_id"] = event.tickettype_id; obj["br_" + counter + "_ticket_1_count"] = 1; obj["br_" + counter + "_peripheral_count"] = 0; obj["br_" + counter + "_ticket_count"] = 1; var eq_list = webservice_get_equipment($scope); for(var i=0;i 0) { obj["br_note_count"] = 1; obj["br_note_1_note"] = note; } else { obj["br_note_count"] = 0; } $http.post(getip()+'/services/booking_do.php', obj).success(function (response) { if (response.success == "true") { $scope.bookingnr = response.data.booking_id; $scope.bookingnr1 = response.data.booking_id1; $scope.step = 11; try { //ga('send', 'pageview', 'booking/step' + $scope.step); gtag('event', 'screen_view', { 'app_name': 'fagineum/bookingclient', 'screen_name': 'booking/step' + $scope.step }); /*ga('ecommerce:addTransaction', { 'id': $scope.bookingnr, // Transaction ID. Required. 'affiliation': 'BergwerkClient', // Affiliation or store name. 'revenue': $scope.get_amount(), // Grand Total. 'shipping': '0', // Shipping. 'tax': '0' // Tax. } ); */ var gtagItems = []; for (var i=0;i<$scope.panels.length;i++) { var vticket_list = $scope.get_virtual_tickets($scope.panels[i].id); for (var j=0;j 0) { var event = $scope.get_event_by_id(ts.event); gtagItems.push(add_analytics_item($scope.bookingnr, event.name, event.name, 'Essen', '0', 1)); var eq_list = webservice_get_equipment($scope); for(var i=0;i val !== undefined); var amount = gtagItems.reduce((prev, val) => prev + val.price * val.quantity, 0); gtag( "event", "purchase", { transaction_id: $scope.bookingnr, value: amount, tax: amount/1.19*0.19, shipping: 0, currency: "EUR", items: gtagItems } ); } catch (err) { console.log(err.message); } } else { if (response.error_code * 1 === 1000) { $scope.step = 8; //ga('send', 'pageview', 'booking/step' + $scope.step); gtag('event', 'screen_view', { 'app_name': 'fagineum/bookingclient', 'screen_name': 'booking/step' + $scope.step }); } else { $scope.step = 7; //ga('send', 'pageview', 'booking/step' + $scope.step); gtag('event', 'screen_view', { 'app_name': 'fagineum/bookingclient', 'screen_name': 'booking/step' + $scope.step }); } } }); } function webservice_load_equipment($scope, $http) { $http.get(getip() + "/services/equipment_list.php?rand=" + Math.random()).success(function (response) { $scope.error_code = 0; if (response.success === true || response.success == "true") { $scope.equipment = response.data; $scope.loading_equipment = true; $scope.loading_ready(); } else { $scope.error_code = response.error_code * 1; } }); } webservice_load_events_list = function($scope, $http) { $http.get(getip() + "/services/events_list.php?rand=" + Math.random()).success(function (response) { $scope.error_code = 0; if (response.success === true || response.success == "true") { $scope.events = response.data; $scope.loading_events = true; $scope.loading_ready(); } else { $scope.error_code = response.error_code * 1; } }); } webservice_load_panels_list = function($scope, $http) { $http.get(getip() + "/services/panel_list.php?rand=" + Math.random()).success(function (response) { $scope.error_code = 0; if (response.success === true || response.success == "true") { $scope.panels = response.data; $scope.loading_panels = true; $scope.loading_ready(); } else { $scope.error_code = response.error_code * 1; } }); } webservice_load_tickets_list = function($scope, $http) { $http.get(getip() + "/services/ticket_list.php?rand=" + Math.random()).success(function (response) { $scope.error_code = 0; if (response.success === true || response.success == "true") { $scope.tickets = response.data; $scope.loading_tickets = true; $scope.loading_ready(); } else { $scope.error_code = response.error_code * 1; } }); } webservice_load_season = function($scope, $http) { $http.get(getip() + "/services/season_list.php?rand=" + Math.random()).success(function (response) { $scope.error_code = 0; if (response.success === true || response.success == "true") { $scope.season_list = response.data; $scope.loading_seasons = true; $scope.loading_ready(); } else { $scope.error_code = response.error_code * 1; } }); } webservice_load_prepayment = function ($scope, $http) { $http.get(getip() + "/services/booking_prepayment_list.php?rand=" + Math.random()).success(function (response) { if (response.success === true || response.success == "true") { $scope.prepayment_setting_list = response.data; $scope.loading_prepayment = true; $scope.loading_ready(); } }); } webservice_load_price_list = function ($scope, $http) { $http.get(getip() + "/services/booking_price_list.php?rand=" + Math.random()).success(function (response) { if (response.success === true || response.success == "true") { $scope.price_list = response.data; } else { $scope.price_list = []; } $scope.loading_price = true; $scope.loading_ready(); }); } webservice_load_texte = function($scope, $http) { $http.get(getip() + "/services/texte_list.php?rand=" + Math.random()).success(function (response) { $scope.error_code = 0; if (response.success === true || response.success == "true") { $scope.texte = response.data; $scope.loading_texts = true; $scope.loading_ready(); } else { $scope.error_code = response.error_code * 1; } }); } webservice_load_virtual_tickets = function($scope, $http) { $http.get(getip() + "/services/virtual_ticket_list.php?rand=" + Math.random()).success(function (response) { $scope.error_code = 0; if (response.success === true || response.success == "true") { $scope.virtual_tickets = response.data; $scope.loading_virtual_tickets = true; $scope.loading_ready(); } else { $scope.error_code = response.error_code * 1; } }); } webservice_do_payment = function ($scope, $http, keys, values) { $scope.loading = true; var obj = {}; obj.type = 1; obj.type_id = $scope.bookingnr1; obj.key = $scope.paymentkey; for (var i = 0; i < keys.length; i++) { obj[keys[i]] = values[i]; } $http.post('services/create_payment.php', obj).success(function (response) { if (response.success == "true") { var data = response.data; $scope.paymentkey = data.key; if (data.action == "select") { $scope.payment_provider_list = []; for (var i = 0; i < data.parameter.length; i++) { if (data.parameter[i].key1.lastIndexOf("hint_", 0) === -1) { $scope.payment_provider_list.push(data.parameter[i]); } } for (var i = 0; i < data.parameter.length; i++) { if (data.parameter[i].key1.lastIndexOf("hint_", 0) === 0) { for (var j = 0; j < $scope.payment_provider_list.length; j++) { if (data.parameter[i].key1 == "hint_" + $scope.payment_provider_list[j].value) { $scope.payment_provider_list[j].hint = data.parameter[i].value; } } } } $scope.step = 6; } if (data.action == "link") { $scope.step = 9; var load_external_content = false; var url = []; var js_preload = []; var js_afterload = []; for (var i = 0; i < data.parameter.length; i++) { if (data.parameter[i].key1 == "forward") { if (data.parameter[i].value == "noforward") { $scope.step = 10; $scope.forward = false; } else { $scope.step = 9; $scope.forward = true; $scope.forward_url = data.parameter[i].value; if ($scope.forward_url.indexOf("javascript:") === -1 && $scope.forward_url.indexOf("javascripts:") === -1) { window.setTimeout(function () { window.location.href = $scope.forward_url; }, 5000); } else { url = $scope.forward_url.replace("javascript:", "").split("::::"); $scope.forward_url = ""; load_external_content = true; } } } if (data.parameter[i].key1 == "hint") { $scope.payment_hint = data.parameter[i].value; } if (data.parameter[i].key1 == "name") { $scope.payment_name = data.parameter[i].value; } if (data.parameter[i].key1 == "payment_provider_id") { $scope.payment_provider_id = data.parameter[i].value; } if (data.parameter[i].key1 == "html") { $scope.payment_html = data.parameter[i].value; } if (data.parameter[i].key1 == "js_preload") { js_preload = data.parameter[i].value.split("::::"); } if (data.parameter[i].key1 == "js_afterload") { js_afterload = data.parameter[i].value.split("::::"); } } if (load_external_content === true) { for (var i = 0; i < js_preload.length; i++) { var script = document.createElement('script'); script.text = js_preload[i]; document.body.appendChild(script); } window.setTimeout(function () { for (var i = 0; i < url.length; i++) { var script = document.createElement("script"); script.src = url[i]; document.body.appendChild(script); } window.setTimeout(function () { for (var i = 0; i < js_afterload.length; i++) { var script = document.createElement('script'); script.text = js_afterload[i]; document.body.appendChild(script); } }, 2000); }, 2000); } } try { //ga('send', 'pageview', 'coupon/step' + $scope.step); gtag('event', 'screen_view', { 'app_name': 'fagineum/bookingclient', 'screen_name': 'booking/step' + $scope.step }); } catch (err) { console.log(err.message); } } else { $scope.step = 7; try { //ga('send', 'pageview', 'coupon/step' + $scope.step); gtag('event', 'screen_view', { 'app_name': 'fagineum/bookingclient', 'screen_name': 'booking/step' + $scope.step }); } catch (err) { console.log(err.message); } } $scope.loading = false; }); }; webservice_get_coupon_info_and_add = function ($scope, $http) { $scope.load_coupon = true; var obj = {}; obj.coupon_key = $scope.coupon_key; $http.post('services/coupon_info.php', obj).success(function (response) { $scope.coupon_list.push(response.data); $scope.coupon_key = ""; }); }; var fagineum_main_controller = angular.module('fagineum_client_ticket.main_controller', ['ngRoute', 'ngAnimate']); fagineum_main_controller.controller('fagineum_main_controller', function ($scope, $http, $location, cfpLoadingBar, fagineum_client_ticket_service, fagineum_client_form_service, $timeout) { $scope.ticketservice = fagineum_client_ticket_service; $scope.formservice = fagineum_client_form_service; $scope.step = 1; $scope.hour_to_booking = 3; $scope.has_price_list = false; $scope.price_has_changed = false; $scope.price_list = []; $scope.season_list = []; $scope.prepayment_setting_list = []; $scope.is_loading = true; $scope.error_code = 0; $scope.error_text = ""; $scope.error_time_is_today_or_past = false; $scope.error_time_missing = false; $scope.error_ticket_missing = false; $scope.bookingnr = ""; $scope.bookingnr1 = ""; $scope.payment_provider_id = 0; $scope.payment_provider_list = []; $scope.payment_hint = ""; $scope.equipment = []; $scope.virtual_tickets = []; $scope.events = []; $scope.panels = []; $scope.loading_equipment = false; $scope.loading_events = false; $scope.loading_texts = false; $scope.loading_panels = false; $scope.loading_tickets = false; $scope.loading_seasons = false; $scope.loading_prepayment = false; $scope.loading_price = false; $scope.loading_virtual_tickets = false; $scope.choose_payment = function () { webservice_do_payment($scope, $http, ["payment_provider_id"], [$scope.payment_provider_id]); } $scope.load_lists = function () { $scope.loading_equipment = false; $scope.loading_events = false; $scope.loading_panels = false; $scope.loading_tickets = false; $scope.loading_seasons = false; $scope.loading_prepayment = false; $scope.loading_price = false; $scope.loading_texts = false; $scope.loading_virtual_tickets = false; webservice_load_equipment($scope, $http); webservice_load_events_list($scope, $http); webservice_load_panels_list($scope, $http); webservice_load_tickets_list($scope, $http); webservice_load_season($scope, $http); webservice_load_prepayment($scope, $http); webservice_load_price_list($scope, $http); webservice_load_texte($scope, $http); webservice_load_virtual_tickets($scope, $http); } $scope.loading_ready = function() { if( $scope.loading_equipment === true && $scope.loading_events === true && $scope.loading_panels === true && $scope.loading_texts === true && $scope.loading_tickets === true && $scope.loading_seasons === true && $scope.loading_prepayment === true && $scope.loading_price === true && $scope.loading_virtual_tickets === true) { $scope.has_price_list = true; $scope.is_loading = false; } } $scope.load_lists(); $scope.show_ticket_hint = []; $scope.close_ticket_hint = function(ticket_id) { $scope.show_ticket_hint['_'+ticket_id] = false; }; $scope.has_ticket_hint = function(ticket_id) { if ($scope.show_ticket_hint['_'+ticket_id] === undefined || $scope.show_ticket_hint['_'+ticket_id] === false) { return false; } return true; }; $scope.toggle_ticket_hint = function(ticket_id) { if ($scope.show_ticket_hint['_'+ticket_id] === true) { $scope.show_ticket_hint['_'+ticket_id] = false; } else { $scope.show_ticket_hint['_'+ticket_id] = true; } } $scope.tmp_virtual_tickets = []; $scope.get_virtual_tickets = function(panel_id) { if ($scope.virtual_tickets === undefined || $scope.virtual_tickets.length === 0) { return []; } if ($scope.tmp_virtual_tickets["_"+panel_id] === undefined || $scope.tmp_virtual_tickets["_"+panel_id].length === 0) { var ticket_list = []; for (var i=0;i<$scope.virtual_tickets.length;i++) { if ($scope.virtual_tickets[i].panel_id*1 === panel_id*1) { ticket_list.push($scope.virtual_tickets[i]); } } for (var i=0;i ticket_list[i].panel_order*1) { var tmp_ticket = angular.copy(ticket_list[i]); ticket_list[i] = angular.copy(ticket_list[i+1]); ticket_list[i+1] = tmp_ticket; } } return $scope.tmp_virtual_tickets["_"+panel_id] = ticket_list; } return $scope.tmp_virtual_tickets["_"+panel_id]; }; $scope.get_virtual_tickets_with_count = function(panel_id) { var vtickets = $scope.get_virtual_tickets(panel_id); var vticket_list = []; for (var i=0;i 0 || $scope.get_ticket_count1(vticket) > 0) { vticket_list.push(vticket); } } return vticket_list; } $scope.get_ticket_count1 = function(vticket) { if (vticket.ticket_id instanceof Array) { var sum = 0; for (var i=0;i 0) { val += $scope.get_virtual_ticket_price(vticket)*$scope.ticketservice.tickets['0_'+vticket.id]; } } if (vticket.panel_type === 'mix') { for (var j=0;j 0) { val += $scope.get_virtual_ticket_price(vticket)*$scope.ticketservice.tickets[j+'_'+vticket.id]; } } } } if ($scope.equipment !== undefined && $scope.equipment['equipment'] !== undefined) { for (var i=0;i<$scope.equipment['equipment'].length;i++) { var eq = $scope.equipment['equipment'][i]; if ($scope.ticketservice.equipment['_'+eq.id] !== undefined) { val += $scope.get_price(eq.tickettype_id, eq.resourcetype_id)*$scope.ticketservice.equipment['_'+eq.id]*1; } } } if ($scope.equipment !== undefined && $scope.equipment['equipment_additional'] !== undefined) { for (var i=0;i<$scope.equipment['equipment_additional'].length;i++) { var aeq = $scope.equipment['equipment_additional'][i]; if ($scope.ticketservice.equipment['additional_'+aeq.id] !== undefined) { val += $scope.get_price(aeq.tickettype_id, aeq.resourcetype_id)*$scope.ticketservice.equipment['additional_'+aeq.id]*1; } } } return val; }; $scope.get_count = function() { if ($scope.ticketservice === undefined || $scope.ticketservice.tickets === undefined) { return 0; } var val = 0; for (var i=0;i<$scope.virtual_tickets.length;i++) { var vticket = $scope.virtual_tickets[i]; if (vticket.panel_type === 'single' || vticket.panel_type === 'virtual') { if ($scope.ticketservice.tickets['0_'+vticket.id]*1 > 0) { val += $scope.ticketservice.tickets['0_'+vticket.id]*1; } } if (vticket.panel_type === 'mix') { for (var j=0;j 0) { val += $scope.ticketservice.tickets[j+'_'+vticket.id]*1; } } } } return val; }; $scope.get_amount_formatted = function() { return $scope.format_to_localized_currency($scope.get_amount()); }; $scope.unset_price_has_changed = function () { $scope.price_has_changed = false; } $scope.first_step = function () { $scope.step = 1; } $scope.reload = function () { $scope.step = 2; $scope.is_loading = true; webservice_get_timeline($scope, $http); }; $scope.show_ticket_details = false; $scope.is_ticket_details_open = function() { return $scope.show_ticket_details; }; $scope.do_show_ticket_details = function() { $scope.show_ticket_details = true; }; $scope.close_ticket_details = function() { $scope.show_ticket_details = false; }; $scope.next = function () { $scope.price_has_changed = false; $scope.step = $scope.step + 1; if ($scope.step * 1 === 2) { $scope.error_code = 0; $scope.error_time_missing = false; if ($scope.ticketservice.bookingdate === null || $scope.ticketservice.bookingdate === undefined) { $scope.step = 1; $scope.error_time_missing = true; } $scope.error_ticket_missing = false; if ($scope.get_amount() === 0 || $scope.get_count() === 0) { $scope.step = 1; $scope.error_ticket_missing = true; } var d1 = angular.copy($scope.ticketservice.bookingdate); d1.setHours(0); d1.setMinutes(0); d1.setSeconds(0); d1.setMilliseconds(0); var d2 = new Date(); d2.setHours(0); d2.setMinutes(0); d2.setSeconds(0); d2.setMilliseconds(0); if (d1.getTime() < d2.getTime()) { $scope.step = 1; $scope.error_time_is_today_or_past = true; } else { if(typeof window["fagineum_ticket_client_check_step1"] == 'function') { $scope.error_step1 = fagineum_ticket_client_check_step1($scope); if ($scope.error_step1 !== undefined && $scope.error_step1.length > 0) { $scope.step = 1; } } if(typeof window["fagineum_ticket_client_warning_step1"] == 'function') { $scope.warn_step1 = fagineum_ticket_client_warning_step1($scope); if ($scope.warn_step1 !== undefined && $scope.warn_step1.length > 0) { $scope.step = 1; } } } } if ($scope.step * 1 === 2) { $scope.is_loading = true; webservice_get_timeline($scope, $http); } if ($scope.step * 1 === 4) { if ($scope.ticketservice.event * 1 > 0) { $scope.error_step3 = []; $scope.warn_step3 = []; if(typeof window["fagineum_ticket_client_check_step3"] == 'function') { $scope.error_step3 = fagineum_ticket_client_check_step3($scope); } if(typeof window["fagineum_ticket_client_warning_step3"] == 'function') { $scope.warn_step3 = fagineum_ticket_client_warning_step3($scope); } if ($scope.texte['event_' + $scope.ticketservice.event + '_label'] !== undefined && $scope.ticketservice.eventtext.length === 0) { $scope.error_step3.push("

Achtung Es fehlt noch \""+$scope.texte['event_' + $scope.ticketservice.event + '_label']+"\"!"); } if ($scope.error_step3.length > 0 || $scope.warn_step3.length > 0) { $scope.step = $scope.step * 1 - 1; } } } if($scope.step*1 === 5) { if ($scope.formservice.check_error() === true) { $scope.step = 4; } else { if($scope.show_payment_hint === false) { $scope.step = 4; $scope.show_payment_hint = true; } else { if($scope.formservice.kostenpflichtig === true) { webservice_do_booking($scope, $http); } else { $scope.formservice.check_kostenpflichtig = true; $scope.step = 4; } } } } try { //ga('send', 'pageview', 'booking/step' + $scope.step); console.log('click'); gtag('event', 'screen_view', { 'app_name': 'fagineum/bookingclient', 'screen_name': 'booking/step' + $scope.step }); } catch (err) { console.log(err); } } $scope.back = function () { if($scope.step*1 === 6) { $scope.step = 11; } else { $scope.step = $scope.step - 1; } } $scope.close = function () { $location.path("/"); document.getElementsByTagName("section")[0].style.display = 'block'; document.getElementsByTagName("nav")[0].style.display = 'block'; } $scope.dateformat = "dd.MM.yyyy"; $scope.dateformat1 = "d.m.Y"; $scope.dateformat2 = "H:i"; $scope.paymentkey = ""; $scope.box_open = false; $scope.open_box = function () { $scope.box_open = true; } $scope.open_id = 0; $scope.set_open_id = function (counter) { $scope.open_id = counter; $scope.ticketservice.clear(); } $scope.timelist = []; $scope.get_free_place = function (counter) { for (var i = 0; i < $scope.timelist.length; i++) { if (counter * 1 === $scope.timelist[i].counter * 1) { var sum = $scope.timelist[i].t4 - $scope.timelist[i].t1 - $scope.timelist[i].t2 - $scope.timelist[i].t3; if (sum < 0) { return 0; } else { return sum; } } } return 0; } $scope.get_state_color = function (counter) { switch ($scope.get_state(counter)) { case 0: return ""; case 1: return "red"; case 2: return "orange"; case 3: return "green"; } return ""; } $scope.range = function(min, max, step) { step = step || 1; var input = []; for (var i = min; i <= max; i += step) { input.push(i); } return input; }; $scope.booking_group_size_is_to_big = function () { var tmptimelist = $scope.timelist; var timelistkeys = $scope.get_timelist_keys(); if (timelistkeys.length === 0) { return false; } var time = timelistkeys[0]; var check = []; var counter = []; for (var i=0;i<$scope.panels.length;i++) { var vticket_list= $scope.get_virtual_tickets($scope.panels[i].id); for (var j=0;j 0) { var offset = 0; if (ticket.offset !== undefined) { offset = ticket.offset; } var el = ticket.resourcetype_id+"_"+ticket.tickettype_id +"_"+ticket.duration+"_"+offset; if (counter[el] === undefined) { counter[el] = $scope.ticketservice.tickets['0_'+vticket.id]*1; } else { counter[el] += $scope.ticketservice.tickets['0_'+vticket.id]*1; } var cbs = check_big_group( tmptimelist, time, ticket.resourcetype_id, ticket.tickettype_id, ticket.duration, counter[el], offset ); check.push(cbs); } } if (vticket.panel_type === 'virtual' || vticket.panel_type === 'mix') { for (var k=0;k 0) { var offset = 0; if (ticket.offset !== undefined) { offset = ticket.offset; } var el = ticket.resourcetype_id+"_"+ticket.tickettype_id +"_"+ticket.duration+"_"+offset; if (counter[el] === undefined) { counter[el] = $scope.ticketservice.tickets[index_counter+'_'+vticket.id]*1; } else { counter[el] += $scope.ticketservice.tickets[index_counter+'_'+vticket.id]*1; } var cbs = check_big_group( tmptimelist, time, ticket.resourcetype_id, ticket.tickettype_id, ticket.duration, counter[el], offset ); check.push(cbs); } } } } } if ($scope.ticketservice.event*1 > 0) { var max_offset = $scope.get_max_offset()*50; var event = $scope.get_event_by_id($scope.ticketservice.event); var cbs = check_big_group( tmptimelist, time, event.resourcetype_id, event.tickettype_id, event.duration, 1, max_offset ); check.push(cbs); } for (i = 0; i < check.length; i++) { if (check[i] === true) { return true; } } return false; }; $scope.event_is_in_time = function() { var event = $scope.get_event_by_id($scope.ticketservice.event); if (event === undefined) { return false; } var check_date = new Date(); check_date.setDate(check_date.getDate() + event.durationdays); check_date.setMinutes(0); check_date.setHours(0); check_date.setSeconds(0); check_date.setMilliseconds(0); var bdate = angular.copy($scope.ticketservice.bookingdate); bdate.setHours(23); bdate.setMinutes(59); bdate.setSeconds(59); bdate.setMilliseconds(999); if (bdate.getTime() < check_date.getTime()) { return false; } return true; }; $scope.get_state = function (time) { var tmptimelist = $scope.timelist; var check = []; var counter = []; for (var i=0;i<$scope.panels.length;i++) { var vticket_list= $scope.get_virtual_tickets($scope.panels[i].id); for (var j=0;j 0) { var offset = 0; if (ticket.offset !== undefined) { offset = ticket.offset; } var el = ticket.resourcetype_id+"_"+ticket.tickettype_id +"_"+ticket.duration+"_"+offset; if (counter[el] === undefined) { counter[el] = $scope.ticketservice.tickets['0_'+vticket.id]*1; } else { counter[el] += $scope.ticketservice.tickets['0_'+vticket.id]*1; } var cbs = check_booking_state( tmptimelist, time, ticket.resourcetype_id, ticket.tickettype_id, ticket.duration, counter[el], offset ); check.push(cbs); } } if (vticket.panel_type === 'virtual' || vticket.panel_type === 'mix') { for (var k=0;k 0) { var offset = 0; if (ticket.offset !== undefined) { offset = ticket.offset; } var el = ticket.resourcetype_id+"_"+ticket.tickettype_id +"_"+ticket.duration+"_"+offset; if (counter[el] === undefined) { counter[el] = $scope.ticketservice.tickets[index_counter+'_'+vticket.id]*1; } else { counter[el] += $scope.ticketservice.tickets[index_counter+'_'+vticket.id]*1; } var cbs = check_booking_state( tmptimelist, time, ticket.resourcetype_id, ticket.tickettype_id, ticket.duration, counter[el], offset ); check.push(cbs); } } } } } if ($scope.ticketservice.event*1 > 0) { if ($scope.event_is_in_time() === false) { return 1; } var event = $scope.get_event_by_id($scope.ticketservice.event); var max_offset = $scope.get_max_offset()*50; var cbs = check_booking_state( tmptimelist, time, event.resourcetype_id, event.tickettype_id, event.duration, 1, max_offset ); check.push(cbs); } var min = 0; for (i = 0; i < check.length; i++) { if (check[i] !== 4) { if (min === 0) { min = check[i] * 1; } else { if (min > check[i]) { min = check[i]; } } } } return min; } $scope.time_format = function (time) { var diff = time - parseInt(time); if (diff > 0) { return parseInt(time) + ":" + diff * 60; } else { return parseInt(time) + ":00"; } } $scope.show_timer_hint = false; $timeout(function () { if ($scope.get_count() === 0) { $scope.show_timer_hint = true; } }, 10000); $scope.go_step2 = function () { $location.path("/step2"); } $scope.is_today = function () { var today = new Date(); if ($scope.ticketservice) { if ($scope.ticketservice.bookingdate) { if (today.getFullYear() * 1 === $scope.ticketservice.bookingdate.getFullYear() * 1) { if (today.getMonth() * 1 === $scope.ticketservice.bookingdate.getMonth() * 1) { if (today.getDate() * 1 === $scope.ticketservice.bookingdate.getDate() * 1) { return true; } } } } } return false; } $scope.format_time = function (time) { var hour = parseInt(time / 100); var minute = ((time - hour * 100)) * 60 / 100; var hour_str = hour; var minute_str = minute; if (hour * 1 < 10) { hour_str = "0" + hour_str; } if (minute * 1 < 10) { minute_str = "0" + minute_str; } return hour_str + ":" + minute_str; } $scope.format_to_localized_currency = function(number) { return new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(number); } $scope.get_event_by_id = function(event_id) { for (var i=0;i<$scope.events.length;i++) { if($scope.events[i].id*1 === event_id*1) { return $scope.events[i]; } } return undefined; } $scope.get_max_offset = function (diff) { var max_offset = 0; if (diff === undefined) { diff = 50; } for (var i=0;i<$scope.panels.length;i++) { var vticket_list= $scope.get_virtual_tickets($scope.panels[i].id); for (var j=0;j 0) { var offset = 0; if (ticket.offset !== undefined) { offset = ticket.offset; } if (max_offset < ticket.duration + offset) { max_offset = ticket.duration + offset; } } } if (vticket.panel_type === 'virtual' || vticket.panel_type === 'mix') { for (var k=0;k 0) { var offset = 0; if (ticket.offset !== undefined) { offset = ticket.offset; } if (max_offset < ticket.duration + offset) { max_offset = ticket.duration + offset; } } } } } } //var event = $scope.get_event_by_id($scope.ticketservice.event); //if (event !== undefined) { // max_offset += event.duration * 1; //} return parseInt(max_offset / diff); } $scope.get_timelist_keys = function () { var arr = []; for (var key in $scope.timelist) { arr.push(key); } var max_offset = $scope.get_max_offset(); arr.splice(arr.length - max_offset, max_offset); return arr; }; $scope.set_bookingtime = function (time) { $scope.ticketservice.bookingtime = new Date(0, 0, 0, 0, 0, 0); var hour = parseInt(time / 100); var minute = ((time % 100) / 100 * 60); $scope.ticketservice.bookingtime.setHours(hour); $scope.ticketservice.bookingtime.setMinutes(minute); }; $scope.do_mit_essen = function () { $scope.ticketservice.mit_essen.counter = 9; }; $scope.dateOptions = { startingDay: 1, showWeeks: false }; $scope.get_season_for_date = function () { for (var i = 0; i < $scope.season_list.length; i++) { var beginn_date = new Date($scope.season_list[i].beginn.replace(/-/g, "/")); beginn_date.setHours(0); beginn_date.setMinutes(0); beginn_date.setSeconds(0); beginn_date.setMilliseconds(0); var end_date = new Date($scope.season_list[i].end.replace(/-/g, "/")); end_date.setHours(23); end_date.setMinutes(59); end_date.setMilliseconds(999); end_date.setSeconds(59); if (beginn_date.getTime() <= $scope.ticketservice.bookingdate.getTime() && $scope.ticketservice.bookingdate.getTime() <= end_date.getTime()) { return $scope.season_list[i].id; } } return 0; }; $scope.get_custom_prepayment_amount = function (ps, count, vticket, ticket_id) { if (count*1 === 0) { return 0; } var ticket = $scope.get_ticket_by_id(ticket_id); if (ticket.tickettype_id * 1 === ps.tickettype_id * 1) { if (ps.type * 1 === 1) { return ps.value * count; } if (ps.type * 1 === 2) { return ps.value * count * $scope.get_virtual_ticket_price(vticket) / 100.0; } } return 0; }; $scope.get_prepayment_amount1_for_tickets = function(ps) { var val = 0; for (var i=0;i<$scope.virtual_tickets.length;i++) { var vticket = $scope.virtual_tickets[i]; if (vticket.panel_type === 'single') { if ($scope.ticketservice.tickets['0_'+vticket.id]*1 > 0) { val += $scope.get_custom_prepayment_amount(ps, $scope.ticketservice.tickets['0_'+vticket.id], vticket, vticket.ticket_id); } } if (vticket.panel_type === 'mix' || vticket.panel_type === 'virtual') { for (var j=0;j 0) { val += $scope.get_custom_prepayment_amount(ps, $scope.ticketservice.tickets[j+'_'+vticket.id], vticket, vticket.ticket_id[j]); } } } } return val; } $scope.get_prepayment_amount_for_item = function(ps, item, count) { if (item.tickettype_id*1 === ps.tickettype_id*1) { if (ps.type*1 === 1) { return ps.value * count; } if (ps.type*1 === 2) { return ps.value * count * $scope.get_price(item.tickettype_id, item.resourcetype_id) / 100.0; } } return 0; } $scope.get_prepayment_amount_for_equipment = function(ps) { var val = 0; for (var i=0;i<$scope.equipment['equipment'].length;i++) { var item = $scope.equipment['equipment'][i]; if ($scope.ticketservice.equipment['_'+item.id] !== undefined && $scope.ticketservice.equipment['_'+item.id]*1 > 0) { val += $scope.get_prepayment_amount_for_item(ps, item, $scope.ticketservice.equipment['_'+item.id]); } } for (var i=0;i<$scope.equipment['equipment_additional'].length;i++) { var item = $scope.equipment['equipment_additional'][i]; if ($scope.ticketservice.equipment['additional_'+item.id] !== undefined && $scope.ticketservice.equipment['additional_'+item.id]*1 > 0) { val += $scope.get_prepayment_amount_for_item(ps, item, $scope.ticketservice.equipment['additional_'+item.id]); } } return val; } $scope.get_prepayment_amount = function () { var payment = 0; var season_id = $scope.get_season_for_date(); for (var i = 0; i < $scope.prepayment_setting_list.length; i++) { var ps = $scope.prepayment_setting_list[i]; if (ps.season_id * 1 === season_id * 1) { payment += $scope.get_prepayment_amount1_for_tickets(ps); payment += $scope.get_prepayment_amount_for_equipment(ps); } } return payment; }; $scope.get_prepayment_amount_formatted = function() { return $scope.format_to_localized_currency($scope.get_prepayment_amount()); } $scope.get_open_prepayment_amount = function () { var val = $scope.get_prepayment_amount(); for (var i = 0; i < $scope.coupon_list.length; i++) { if ($scope.coupon_list[i].error * 1 === 0) { val = val - $scope.coupon_list[i].open_amount; } } if (val < 0) { val = 0; } return val; } $scope.remove_coupon = function (nr) { for (var i = 0; i < $scope.coupon_list.length; i++) { if ($scope.coupon_list[i].coupon_key == nr) { $scope.coupon_list.splice(i, 1); return; } } } $scope.remove_coupon_null = function (index) { $scope.coupon_list.splice(index, 1); } $scope.loading_coupon = false; $scope.coupon_list = []; $scope.coupon_key = ""; $scope.add_coupon = function () { for (var i = 0; i < $scope.coupon_list.length; i++) { if ($scope.coupon_list[i].coupon_key == $scope.coupon_key) { return; } } webservice_get_coupon_info_and_add($scope, $http); } $scope.next_coupon = function () { if($scope.payment_provider_list.length === 0) { var keys = []; var values = []; var count = 0; for (var i = 0; i < $scope.coupon_list.length; i++) { if ($scope.coupon_list[i].error * 1 === 0) { keys.push("coupon_key_" + (i + 1)); values.push($scope.coupon_list[i].coupon_key); count++; } } keys.push("coupon_count"); values.push(count); webservice_do_payment($scope, $http, keys, values); } else { $scope.step = 6; } } $scope.get_coupon_amount_after_payment = function(index, coupon) { var total_amount = $scope.get_prepayment_amount(); for(var i=0;i<$scope.coupon_list.length;i++) { if(index === i && coupon.error*1 === 0) { if(coupon.open_amount > total_amount) { return coupon.open_amount - total_amount; } else { return 0; } } if(coupon.error*1 === 0) { total_amount = total_amount - coupon.open_amount; } if(total_amount < 0) { total_amount = 0; } } return 0; } $scope.show_payment_hint = false; $scope.get_show_payment_hint = function() { return $scope.show_payment_hint; } $scope.get_day_of_week = function() { var day_of_week = $scope.ticketservice.bookingdate.getDay(); switch(day_of_week) { case 0: return "So"; break; case 1: return "Mo"; break; case 2: return "Di"; break; case 3: return "Mi"; break; case 4: return "Do"; break; case 5: return "Fr"; break; case 6: return "Sa"; break; } return ""; } $scope.show_backinformation = false; $scope.is_show_backinformation = function() { return $scope.show_backinformation; } $scope.unshow_backinformation = function() { $scope.show_backinformation = false; } $scope.doshow_backinformation = function() { $scope.show_backinformation = true; }; $scope.parse_request_parameter = function(querystring) { if (querystring == '') return []; var wertestring = querystring.slice(1); var paare = wertestring.split("&"); var paar, name, wert, ret = []; for (var i = 0; i < paare.length; i++) { paar = paare[i].split("="); name = paar[0]; wert = paar[1]; name = unescape(name).replace("+", " "); wert = unescape(wert).replace("+", " "); ret.push([name, wert]); } return ret; }; $scope.get_request_parameter = function(param) { for(var i=0;i<$scope.request_parameter.length;i++) { if($scope.request_parameter[i][0] == param) { return $scope.request_parameter[i][1]; } } return undefined; }; $scope.has_equipment_booking = function(item) { if (item === undefined) { return false; } for (var i=0;i 0) { return true; } } return false; }; $scope.request_parameter = $scope.parse_request_parameter(window.location.search); if($scope.request_parameter.length > 0 && $scope.get_request_parameter("date") !== undefined) { $scope.ticketservice.bookingdate = from_sql_to_date($scope.get_request_parameter("date")); console.log($scope.ticketservice.bookingdate); }; $scope.close_show_timer_hint = function() { $scope.show_timer_hint = false; }; $scope.get_booked_equipment = function() { var list = []; if ($scope.equipment['equipment'] === undefined) { return []; } for (var i=0;i<$scope.equipment['equipment'].length;i++) { var item = $scope.equipment['equipment'][i]; if ($scope.ticketservice.equipment['_'+item.id] !== undefined && $scope.ticketservice.equipment['_'+item.id]*1 > 0) { list.push(item); } } return list; }; $scope.get_booked_additional_equipment = function() { var list = []; if ($scope.equipment['equipment_additional'] === undefined) { return []; } for (var i=0;i<$scope.equipment['equipment_additional'].length;i++) { var item = $scope.equipment['equipment_additional'][i]; if ($scope.ticketservice.equipment['additional_'+item.id] !== undefined && $scope.ticketservice.equipment['additional_'+item.id]*1 > 0) { list.push(item); } } return list; }; $scope.get_count_equipment = function() { var count = 0; if ($scope.equipment['equipment'] === undefined) { return 0; } for (var i=0;i<$scope.equipment['equipment'].length;i++) { var item = $scope.equipment['equipment'][i]; if ($scope.ticketservice.equipment['_'+item.id] !== undefined && $scope.ticketservice.equipment['_'+item.id]*1 > 0) { count += $scope.ticketservice.equipment['_'+item.id]*1; } } return count; }; $scope.get_count_additional_equipment = function() { var count = 0; if ($scope.equipment['equipment_additional'] === undefined) { return 0; } for (var i=0;i<$scope.equipment['equipment_additional'].length;i++) { var item = $scope.equipment['equipment_additional'][i]; if ($scope.ticketservice.equipment['additional_'+item.id] !== undefined && $scope.ticketservice.equipment['additional_'+item.id]*1 > 0) { count += $scope.ticketservice.equipment['additional_'+item.id]*1; } } return count; }; $scope.is_in_time = function(time) { var current_date = new Date(); current_date.setHours(current_date.getHours() + $scope.hour_to_booking); var b_date = angular.copy($scope.ticketservice.bookingdate); var hour = parseInt(time/100); var minute = time % 100; b_date.setHours(hour); b_date.setMinutes(minute); b_date.setSeconds(0); b_date.setMilliseconds(0); if (current_date.getTime() >= b_date.getTime()) { return false; } return true; }; });