var max=10; var pocet=0; $(function () { var settings = { rows: 200000, cols: 5, rowCssPrefix: 'row-', colCssPrefix: 'col-', seatWidth: 35, seatCss: 'seat', selectedSeatCss: 'selectedSeat', bookedSeatCss: 'bookedSeat', selectingSeatCss: 'selectingSeat' }; var eventId = 52; var sectorMeta = [{"slug":"sec-hlavn---s--l","label":"Hlavní sál"},{"slug":"sec-galerie-1","label":"Galerie 1"}]; var seatsBySector = {"sec-galerie-1":[{"id":45547,"height":115,"width":94,"name":"Stůl 4 \/ Místo 1 (0 Kč)"},{"id":45548,"height":115,"width":106,"name":"Stůl 4 \/ Místo 2 (0 Kč)"},{"id":45549,"height":134,"width":125,"name":"Stůl 4 \/ Místo 3 (0 Kč)"},{"id":45550,"height":146,"width":125,"name":"Stůl 4 \/ Místo 4 (0 Kč)"},{"id":45551,"height":165,"width":94,"name":"Stůl 4 \/ Místo 5 (0 Kč)"},{"id":45552,"height":165,"width":106,"name":"Stůl 4 \/ Místo 6 (0 Kč)"},{"id":45553,"height":134,"width":75,"name":"Stůl 4 \/ Místo 7 (0 Kč)"},{"id":45554,"height":146,"width":75,"name":"Stůl 4 \/ Místo 8 (0 Kč)"}],"sec-hlavn---s--l":[{"id":45555,"height":125,"width":74,"name":"Stůl 1 \/ Místo 1 (0 Kč)"},{"id":45556,"height":125,"width":86,"name":"Stůl 1 \/ Místo 2 (0 Kč)"},{"id":45557,"height":144,"width":105,"name":"Stůl 1 \/ Místo 3 (0 Kč)"},{"id":45558,"height":156,"width":105,"name":"Stůl 1 \/ Místo 4 (0 Kč)"},{"id":45559,"height":175,"width":74,"name":"Stůl 1 \/ Místo 5 (0 Kč)"},{"id":45560,"height":175,"width":86,"name":"Stůl 1 \/ Místo 6 (0 Kč)"},{"id":45561,"height":144,"width":55,"name":"Stůl 1 \/ Místo 7 (0 Kč)"},{"id":45562,"height":156,"width":55,"name":"Stůl 1 \/ Místo 8 (0 Kč)"},{"id":45563,"height":305,"width":74,"name":"Stůl 2 \/ Místo 1 (0 Kč)"},{"id":45564,"height":305,"width":86,"name":"Stůl 2 \/ Místo 2 (0 Kč)"},{"id":45565,"height":324,"width":105,"name":"Stůl 2 \/ Místo 3 (0 Kč)"},{"id":45566,"height":336,"width":105,"name":"Stůl 2 \/ Místo 4 (0 Kč)"},{"id":45567,"height":355,"width":74,"name":"Stůl 2 \/ Místo 5 (0 Kč)"},{"id":45568,"height":355,"width":86,"name":"Stůl 2 \/ Místo 6 (0 Kč)"},{"id":45569,"height":324,"width":55,"name":"Stůl 2 \/ Místo 7 (0 Kč)"},{"id":45570,"height":336,"width":55,"name":"Stůl 2 \/ Místo 8 (0 Kč)"},{"id":45571,"height":215,"width":74,"name":"Stůl 3 \/ Místo 1 (0 Kč)"},{"id":45572,"height":215,"width":86,"name":"Stůl 3 \/ Místo 2 (0 Kč)"},{"id":45573,"height":234,"width":105,"name":"Stůl 3 \/ Místo 3 (0 Kč)"},{"id":45574,"height":246,"width":105,"name":"Stůl 3 \/ Místo 4 (0 Kč)"},{"id":45575,"height":265,"width":74,"name":"Stůl 3 \/ Místo 5 (0 Kč)"},{"id":45576,"height":265,"width":86,"name":"Stůl 3 \/ Místo 6 (0 Kč)"},{"id":45577,"height":234,"width":55,"name":"Stůl 3 \/ Místo 7 (0 Kč)"},{"id":45578,"height":246,"width":55,"name":"Stůl 3 \/ Místo 8 (0 Kč)"}]}; var initSector = function (sectorSlug, reservedSeat, bookedSeat) { var sectorSeats = seatsBySector[sectorSlug] || []; var str = [], className; for (var idx = 0; idx < sectorSeats.length; idx++) { className = settings.seatCss + ' ' + settings.rowCssPrefix + idx.toString() + ' ' + settings.colCssPrefix + '0'; if ($.isArray(reservedSeat) && $.inArray(sectorSeats[idx].id, reservedSeat) != -1) { className += ' ' + settings.selectedSeatCss; } if ($.isArray(bookedSeat) && $.inArray(sectorSeats[idx].id, bookedSeat) != -1) { className += ' ' + settings.bookedSeatCss; } str.push('
'); } $('#place' + eventId + '-' + sectorSlug).html(str.join('')); }; var bookedSeats = []; var reservatedSeats = []; for (var si = 0; si < sectorMeta.length; si++) { initSector(sectorMeta[si].slug, bookedSeats, reservatedSeats); } $(document).on('click','.stud',function() { document.getElementById('st'+$(this).val()).style.display = 'inline'; }); $(document).on('click', '.' + settings.seatCss, function () { if ($(this).hasClass(settings.selectedSeatCss)){ alert('Toto místo momentálně není možno rezervovat'); } else { if (pocet==max && !$(this).hasClass(settings.selectingSeatCss)) { alert('Překlročili jste maximilní počet vstupenek.'); } else { var id= $(this).attr('id'); var akce; if ($(this).hasClass(settings.selectingSeatCss)){ akce='deselect'; } else { akce='select'; } $.get("rezervace.php", { akce:akce.toString(), sedadlo:id }, function(data) { if (akce=='select'){ if (data!=-1){ pocet++; $("#"+id).toggleClass(settings.selectingSeatCss); $(""+ data + " ").appendTo("#vstupenky"); $('').attr({ type: 'hidden', id: 'rezervace'+id, value: id, name: 'rezervace[]' }).appendTo('#form1'); } else { $("#"+id).toggleClass(settings.selectedSeatCss); alert('Toto místo momentálně není možno rezervovat'); } } else { $("#"+id).toggleClass(settings.selectingSeatCss); pocet--; $("#rezervace"+id).remove(); $("#vstupenka"+id).remove(); } }); } } }); $(document).on('click','.seatselect',function() { var id= $(this).attr('id'); $.get("/rezervace.php", { akce:'deselect', sedadlo:id }, function(data) { $("#"+id).toggleClass(settings.selectingSeatCss); pocet--; $("#rezervace"+id).remove(); $("#vstupenka"+id).remove(); }); }); $('#btnShow').click(function () { var str = []; $.each($('li.' + settings.selectedSeatCss + ', li.'+ settings.selectingSeatCss), function (index, value) { str.push($(this).attr('title')); }); alert(str.join(',')); }); $('#btnShowNew').click(function () { var str = [], item; $.each($('li.' + settings.selectingSeatCss), function (index, value) { item = $(this).attr('title'); str.push(item); }); alert(str.join(',')); }); }); (function($,W,D) { var JQUERY4U = {}; JQUERY4U.UTIL = { setupFormValidation: function() { $("#form1").validate({ rules: { jmeno: "required", email: { required: true, email: true }, adress: "required", city: "required", zip: "required", telefon: "required" }, messages: { jmeno: "Vložte Vaše jméno", telefon: "Vložte telefon", email: "Vložte platný mail", adress: "Vložte adresu", city: "Vložte město", zip: "Vložte PSČ" }, submitHandler: function(form) { $("#reservate").prop("disabled", true); form.submit(); } }); } } $(D).ready(function($) { JQUERY4U.UTIL.setupFormValidation(); }); })(jQuery, window, document); var counter = 0, interval; window.onload = function() { interval = setInterval(addCounter, 1000); } function addCounter() { counter++; if(counter === 900) { $("#reservate").prop("disabled", true); alert('Objednávka trvala píliš dlouho. Prosíme, vyberte vstupenky znovu.'); location.reload(); } }