@extends('layouts.cartMaster') @section('myscript') var payment_url = '/bookings//payment'; var total_price = 0; var seat_prices = []; $(function() { $('#clear_selection').on('click', function() { clear_selection(); }); $('.seat_toggle').on('click', function() { selectToggle($(this)); }); $('#btn_save').hide(); $('.seatmap').hide(); $('.seatmap:first').show(); $('#btn_save').on('click', function(){ var post_data = new Array(); var i = 0; // pax var j = 0; // journey var k = 0; // segment $.each(seats_data, function(k, v) { // pax_level post_data[i] = new Array(); j = 0; $.each(v, function(key, value) { // journey level k = 0; post_data[i][j] = new Array(); $.each(value, function(seg_key, seg_value) { // seg level post_data[i][j][k] = seg_value[0]; k++; if(typeof(seg_value[0]) !== 'undefined') { total_price += parseFloat(seat_prices[seg_value[0]]); } }); j++; }); i++; }); $('#btn_save').hide(); $('#clear_selection').hide(); $('.seat_msg_progress').show(); $.ajax({ url:"/seatmap/book", type:"POST", data: JSON.stringify({MAP: post_data, total_price: total_price, component_id: "" ,locator: "", account: ""}), contentType:"application/json; charset=utf-8", dataType:"json", success: function(data){ $('.seat_msg_progress').hide(); if(data.status == 'SUCCESS') { $('.seat_msg_success').show(); $('.seat_msg_error').hide(); $('#seat_err_choose_generic').hide(); location.replace(payment_url); } else { $('.seat_msg_success').hide(); $('.seat_msg_error').show(); //$('#seat_err_choose_generic').show(); //clear_selection(); //$( ".seatmap_container" ).each( function( index, el ) { // $( el ).html( display_toggle() ); //}); //$('.seat_toggle').on('click', function() { // selectToggle($(this)); //}); //$('#btn_save').show(); } } }); total_price = 0; }); $('.pax_btn').on('click', function() { pax_id = this.attributes.pax.value; carrier = this.attributes.carrier.value; flt = this.attributes.flt.value; from = this.attributes.from.value; to = this.attributes.to.value; depdate = this.attributes.depdate.value; journey = this.attributes.journey.value; segment_key = this.attributes.seg_key.value; input_id = this.attributes.id.value; $('.pax_btn').removeClass('btn-primary'); $('#'+input_id).removeClass('btn-secondary'); $('#'+input_id).addClass('btn-primary'); // select seats taken by other pax on that flight fltkey = carrier+flt; $.each(seats_data, function(k, v) { // pax $.each(v, function(key, value) { // journey seg_count = 0; $.each(value, function(seg_key, seg_value) { // segment if(seg_value[0] != undefined && seg_key == fltkey) { $('#btn_save').show(); $('#S'+seg_value[0]).removeClass(); $('#S'+seg_value[0]).addClass('seat'); $('#S'+seg_value[0]).addClass('seat_selected'); $('#S'+seg_value[0]).addClass('seat_pax_'+fltkey+k); } if(journey != key || segment_key != seg_count) { $('#seatmap_'+key+'_'+seg_count).hide(); } else { $('#seatmap_'+key+'_'+seg_count).show(); $('#seatmap_'+key+'_'+seg_count + ' .seatmap').show(); } seg_count++; }); }); }); }); }); var account = ''; var locator = ''; var pax_id = -1; var input_id = -1; var carrier = -1; var flt = -1; var from = -1; var to = -1; var depdate = -1; var journey = -1; var seats_data = []; function display_toggle() { var html = "