





<?php $__env->startSection('content'); ?>


<style>

.circle { 
   width: 140px;
   height: 140px;
   background: lightgray; 
   -moz-border-radius: 70px; 
   -webkit-border-radius: 70px; 
   border-radius: 70px;
}

.showtime-pill-wrapper {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
}
.showtime-pill-container {
    margin: 8px;
}
.showtime-pill-container .showtime-pill {
    border: 1px solid #999;
    color: #4abd5d;
    padding: 4px;
    border-radius: 4px;
    width: 120px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    position: relative;
    font-size: 80%;
}
.showtime-pill-container .showtime-pill .__details .__text {
    margin: 0 auto;
}
.showtime-pill-container .showtime-pill .__details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 2px;
    height: 14px;
}

.oval {
 background-color: ghostwhite;
}

.seat {
  
}

.seat.selected {
  
}

.seat.occupied {
  
}

.seata {
    display: inline-block;
    font-size: 10px;
    line-height: 25px;
    font-weight: 400;
    background: #fff;
    vertical-align: top;

    border: 1px solid #1ea83c;

    width: 25px;
    height: 25px;
    border-radius: 2px;
    color: #1ea83c;
    text-align: center;
    font-size: 10px;
}

a._available {
    display: inline-block;
    font-size: 11px;
    line-height: 25px;
    font-weight: 400;
    background: #fff;
    vertical-align: top;

    border: 1px solid #1ea83c;

    width: 25px;
    height: 25px;
    border-radius: 2px;
    color: #1ea83c;
    text-align: center;
    font-size: 11px;
}

a._available:hover {
  background-color: yellow;
}

a._blocked {

    display: inline-block;
    font-size: 11px;
    line-height: 25px;
    font-weight: 400;
    background: #fff;
    vertical-align: top;

    border: 1px solid grey;

    width: 25px;
    height: 25px;
    border-radius: 2px;
    color: #1ea83c;
    text-align: center;
    font-size: 11px;

    background: #eee!important;
    cursor: default;
    color: #fff!important;
}

a._selected {
    display: inline-block;
    font-size: 11px;
    line-height: 25px;
    font-weight: 400;
    vertical-align: top;


    width: 25px;
    height: 25px;
    border-radius: 2px;
    text-align: center;
    font-size: 11px;

    color: #fff;
    background-color: #1ea83c!important;
    border-color: #1ea83c;
}

td {
    padding:  10px 5px 5px 5px !important;
}

.round-bottom { 
  border-bottom-left-radius: 50% 150px !important;
  border-bottom-right-radius: 50% 150px !important;
  position: relative;
  overflow: hidden;
  width: 160%; 
  margin-bottom:-50px;
  left:-30%; 
  background-color:#444;
  background-image:  background-position: center center;
  background-size: 42% auto;
  height:150px;
  color: white;
  text-align: center;
  font-size: 40px;
  vertical-align: middle;
}
.screencontainer { width: 100%; height: height:100px; padding-bottom:50px; overflow:hidden;}

</style>

<?php
    $visitor_name = '';
?>

<?php if(auth()->guard('publicuser')->check()): ?>
    <?php
        $visitor_name = auth('publicuser')->user()->name;

        $totalCount = $adultCount + $childCount;
    ?>
<?php endif; ?>

<script>
      const facilitiesarray = [];
      const showarray = [];    
      const seatnamearray = [];                                             
</script>



<form action="<?php echo url('/user/paymentprocessing'); ?>" method="post">
    <input type="hidden" id="loggedinUsername" name="loggedinUsername" value="<?php echo e($visitor_name); ?>">

    <input type="hidden" id="showDate" name="showDate" value="<?php echo e($date_of_visit); ?>">

    <input type="hidden" id="totalCount" name="totalCount" value="<?php echo e($totalCount); ?>">

    <input type="hidden" id="inputCentre" name="inputCentre" value="<?php echo e($inputCentre); ?>">

    <?php echo e(csrf_field()); ?>

            <!-- row -->
			<div class="container-fluid">
                
               

                

                <div class="row" id="facilitySelectdiv">
                    <div class="col-xl-12">
						<div class="row">
							
							<div class="col-lg-12">
								<div class="card">
									<div class="card-header">
										<strong><?php echo e($organisation->organisation_name); ?>, &nbsp;<?php echo e($organisation->city); ?></strong><span class="float-right">
                                    <strong>Date:&nbsp;</strong><?php echo e(date('d-m-Y', strtotime($date_of_visit))); ?><br>
                                    <?php if(!$groupBook): ?>
                                        <?php if($adultCount): ?>
                                            <strong>Adult:&nbsp;</strong><?php echo e($adultCount); ?>

                                        <?php endif; ?>
                                        <?php if($childCount): ?>
                                            <strong>Child:&nbsp;</strong><?php echo e($childCount); ?>

                                        <?php endif; ?>
                                    <?php else: ?>
                                        <?php if($adultCount): ?>
                                            <strong>Adult:&nbsp;</strong><?php echo e($adultCount); ?>

                                        <?php endif; ?>
                                        <?php if($childCount): ?>
                                            <strong>Child:&nbsp;</strong><?php echo e($childCount); ?>

                                        <?php endif; ?>
                                    <?php endif; ?>
                                    </span>
                                    <?php if(!$groupBook): ?>
                                        <input type="hidden" name="adultCount" id="adultCount" value="<?php echo e($adultCount); ?>">
                                        <input type="hidden" name="childCount" id="childCount" value="<?php echo e($childCount); ?>">
                                    <?php else: ?>
                                        <p><small><i>One Staff per <?php echo e($childperstaff); ?> children are calcuated with child rates.</i></small></p>
                                        <input type="hidden" name="adultCount" id="adultCount" value="<?php echo e($edustaffCount); ?>">
                                        <input type="hidden" name="childCount" id="childCount" value="<?php echo e($educhildCount); ?>">
                                    <?php endif; ?>
									</div>
									<div class="card-body">
										<div class="table-responsive">
                                            <table class="table table-sm table-responsive-lg mb-0" style="font-size:90%">
                                                <thead>
                                                    <tr>
                                                        <th class="align-middle">Facility</th>
                                                        <th class="align-middle">Seats</th>
                                                        <th class="align-middle pr-7">Amount</th>
                                                        <th class="align-middle" style="min-width: 12.5rem;">Show Timings</th>
                                                        <th class="no-sort"></th>
                                                    </tr>
                                                </thead>

                                                <?php $__currentLoopData = $facilities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $facility): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                                <script>
                                                    facilitiesarray.push(<?php echo e($facility->id); ?>)
                                                </script>
                                                <input type="hidden" name="iffacilitySelected<?php echo e($facility->id); ?>" id="iffacilitySelected<?php echo e($facility->id); ?>">
                                                <input type="hidden" name="showSelected<?php echo e($facility->id); ?>" id="showSelected<?php echo e($facility->id); ?>">
                                                <input type="hidden" name="iffacilityfixed<?php echo e($facility->id); ?>" id="iffacilityfixed<?php echo e($facility->id); ?>" value="<?php echo e($facility->fixedseatflag); ?>">

                                                <input type="hidden" name="famount<?php echo e($facility->id); ?>" id="famount<?php echo e($facility->id); ?>" value="0">

                                                <tr class="btn-reveal-trigger">
                                                    <td class="py-2">
                                                        <a href="#"><strong><?php echo e($facility->facility_name); ?></strong></a>
                                                        <p><small> 
                                                             <?php if(isset($rates[$facility->id])): ?>
                                                                Adult: &nbsp;<i class='fa fa-rupee'></i><?php echo e($rates[$facility->id]->adult_rate); ?>

                                                                Child: &nbsp;<i class='fa fa-rupee'></i><?php echo e($rates[$facility->id]->child_rate); ?>

                                                                <input type="hidden" name="rateadult<?php echo e($facility->id); ?>" id="rateadult<?php echo e($facility->id); ?>" value="<?php echo e($rates[$facility->id]->adult_rate); ?>">
                                                                <input type="hidden" name="ratechild<?php echo e($facility->id); ?>" id="ratechild<?php echo e($facility->id); ?>" value="<?php echo e($rates[$facility->id]->child_rate); ?>">
                                                            <?php endif; ?>
                                                        </small></p>
                                                    </td>
                                                    <td class="py-2" align="center">
                                                        <?php if($facility->noofseats): ?>
                                                            <strong><?php echo e($facility->noofseats); ?>&nbsp;</strong><p>
                                                            <span id="available<?php echo e($facility->id); ?>" style="color:blue; font-size: small; font-weight: bold;"></span></p> 
                                                        <?php else: ?>
                                                            <i>NA</i>
                                                        <?php endif; ?>
                                                    </td>
                                                    <td class="py-2">
                                                      <span id="amount<?php echo e($facility->id); ?>" style="color:green; font-size: small; font-weight: bold;"></span>
                                                    </td>
                                                    <td class="py-2">
                                                        <div class="showtime-pill-wrapper">
                                                        <?php if($facilityon[$facility->id]): ?>
                                                            <?php $__currentLoopData = $facility->showtimings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $show): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <?php if($showon[$show->id]): ?>
                                                                    <?php $remark =""; ?> 
                                                                    <?php if($show->remark): ?>
                                                                        <?php
                                                                            $remark = $show->remark;                                
                                                                        ?>
                                                                    <?php endif; ?> 
                                                                    <div class="showtime-pill-container <?php echo e($facility->id); ?>" onclick="showselect(this, <?php echo e($facility->id); ?>, <?php echo e($show->id); ?>);">
                                                                        <a class="showtime-pill" href="#!"  data-attributes="" title="<?php echo e($remark); ?>">
                                                                            <div class="__details">
                                                                                <div class="__text"><?php echo e(date("g:i A", strtotime($show->from_time))); ?>

                                                                                <?php if(!$show->dont_show_to_time): ?>
                                                                                -<?php echo e(date("g:i A", strtotime($show->to_time))); ?>

                                                                                <?php endif; ?>
                                                                                </div>
                                                                            </div>
                                                                        </a>
                                                                    </div>
                                                                    
                                                                <?php else: ?>

                                                                <?php endif; ?> 
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        <?php else: ?>
                                                               <i><span style="color:steelblue;"> No shows for this facility on this date </span></i>
                                                        <?php endif; ?>
                                                        </div>

                                                   

                                                    </td>
                                                    
                                                    <td class="py-2 text-right">
                                                        <?php if($facilityon[$facility->id]): ?>
                                                        <div class="dropdown text-sans-serif"><button class="btn btn-primary tp-btn-light sharp" type="button" id="order-dropdown-0" data-toggle="dropdown" data-boundary="viewport" aria-haspopup="true" aria-expanded="false"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="18px" height="18px" viewBox="0 0 24 24" version="1.1"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><rect x="0" y="0" width="24" height="24"></rect><circle fill="#000000" cx="5" cy="12" r="2"></circle><circle fill="#000000" cx="12" cy="12" r="2"></circle><circle fill="#000000" cx="19" cy="12" r="2"></circle></g></svg></span></button>
                                                            <div class="dropdown-menu dropdown-menu-right border py-0" aria-labelledby="order-dropdown-0">
                                                                <div class="py-2"><a class="dropdown-item" href="#!" onclick="clearselection(<?php echo e($facility->id); ?>);">Clear</a>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <?php endif; ?>
                                                    </td>
                                                </tr>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </table>
                                        </div>
									</div>
                                    <div class="card-footer">
                                        <span class="float-right" style="color: green; font-weight: bold;"><small>Amount Payable:&nbsp;<i class='fa fa-rupee'></i><span id="totalamount">0</span>/-</small></span>
                                        <br><span class="float-right"><button class="btn btn-primary btn-sm" id="facilitySelectbtn" type="button">Continue</button></span>
                                    </div>
								</div>
							</div>
                    </div>
                </div>
            </div>
        
            <div class="row modal-dialog modal-dialog-centered" id="spinnerdiv" style="display: none;"><div class="col-xl-12" style="text-align: center;"><div class="spinner-border"></div><h3>Please wait while we load</h3></div></div>

            <div class="row" id="seatSelectiondiv" style="display: none;">
                <div class="col-xl-12">
                    <div class="row">
                        
                        <div class="col-lg-12">
                            <div class="card">
                                <div class="card-header">
                                    Seat Selection
                                </div>

                                <?php $__currentLoopData = $facilities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $facility): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php if($facility->fixedseatflag): ?>
                                <div class="card-body">
                                    <?php echo e($facility->facility_name); ?><div class="float-right" style="font-size: 80%"><i>Selected Seats:&nbsp;<span id="currentSelected<?php echo e($facility->id); ?>" style="color: darkmagenta;">0&nbsp;</span>/&nbsp;<?php echo e($totalCount); ?></i></div>

                                    <!--Layout of teh facility-->
                                    <div class="table-responsive oval">
                                        <table class="table table-sm table-responsive-lg mb-0" style="font-size:80%">
                                            <?php 
                                                $totalrows = $facility->layout->total_row; 
                                                $cols = $facility->layout->maxinarow;
                                                $totalcols = $cols+2;



                                                for($i=1; $i<=$totalrows; $i++)
                                                {
                                            ?>
                                                <?php if($i==5): ?>
                                                    <tr style="background-color: lightgreen;"><td colspan="13"><i class='fa fa-angle-double-left'></i>&nbsp;&nbsp;EXIT</td><td colspan="14" align="right"><i class='fa fa-angle-double-left'></i>&nbsp;&nbsp;ENTRY</td></tr>
                                                <?php endif; ?>



                                                <tr>
                                                   <?php
                                                        //get middle col
                                                        $totalcolinrow = $seatcount[$facility->id][$i];
                                                        $middlecol = ceil($totalcolinrow/2);
                                                        if($middlecol<13)
                                                        {
                                                            $diffcol = 13-$middlecol;
                                                            for($m=1;$m<=$diffcol;$m++)
                                                            {
                                                    ?>
                                                                <td>&nbsp;</td>
                                                    <?php
                                                            }
                                                        }
                                                   ?>
                                                   <td>
                                                        <input type="checkbox" name="selectAllSeats<?php echo e($i); ?>" id="selectAllSeats<?php echo e($i); ?>" onclick="loadfirsthalfseats(this,'<?php echo e($i); ?>','<?php echo e($facility->id); ?>','<?php echo e($middlecol); ?>');" value="1">
                                                   </td>
                                                   <?php if(isset($seats[$facility->id][$i])): ?>
                                                       <?php $colcount = 1; ?>
                                                       <?php $__currentLoopData = $seats[$facility->id][$i]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $seat): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <td class="seat"><a href="#!" id="seat<?php echo e($seat->id); ?>" class="_available" onclick="seatselect(this,<?php echo e($facility->id); ?>,<?php echo e($seat->id); ?>);"> <?php echo e($seat->seat_name); ?></a></td>
                                                        <?php if($colcount==$middlecol): ?>
                                                            <?php if($i==5): ?>
                                                            <td align="center"><img  src="<?php echo e(asset('images/planetaurium.png')); ?>" alt="image"width="25"></td>
                                                            <?php else: ?>
                                                            <td>&nbsp;</td>
                                                            <?php endif; ?>
                                                        <?php endif; ?>
                                                        <?php $colcount++; ?>
                                                        <script>
                                                            seatnamearray[<?php echo e($seat->id); ?>]="<?php echo e($seat->seat_name); ?>";
                                                        </script>
                                                       <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                   <?php endif; ?> 

                                                   <td>
                                                        <input type="checkbox" name="selectAllSeats<?php echo e($i); ?>" id="selectAllSeats<?php echo e($i); ?>" onclick="loadsecondhalfseats(this,'<?php echo e($i); ?>','<?php echo e($facility->id); ?>','<?php echo e($middlecol); ?>');" value="1">
                                                   </td>
                                                   
                                                </tr>
                                            <?php
                                                }
                                            ?>
                                        </table>
                                    </div>

                                    

                                </div>
                                <input type="hidden" name="selectedseats<?php echo e($facility->id); ?>" id="selectedseats<?php echo e($facility->id); ?>" value="">
                                <div class="screencontainer"><div class="round-bottom">SCREEN</div></div>
                                <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                
                                <div class="card-footer">
                                    <span class="float-right"><button class="btn btn-primary btn-sm" type="button" id="seatSelectionbtn" style="display:none;">Continue</button></span>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row" id="paymentdiv" style="display:none;">
                <div class="col-xl-12">
                    <div class="row">
                        
                        <div class="col-lg-12">
                            <div class="card">
                                <div class="card-header">
                                    Booking Summary

                                </div>
                                <div class="card-body">
                                    <span class="small">Visitor Name: <b><?php echo e($visitor_name); ?></b></span>

                                    <span class="float-right small">
                                        <?php if(!$groupBook): ?>
                                            <?php if($adultCount): ?>
                                                <strong>Adult:&nbsp;</strong><?php echo e($adultCount); ?><br>
                                            <?php endif; ?>
                                            <?php if($childCount): ?>
                                                <strong>Child:&nbsp;</strong><?php echo e($childCount); ?>

                                            <?php endif; ?>
                                        <?php else: ?>
                                            <?php if($adultCount): ?>
                                                <strong>Adult:&nbsp;</strong><?php echo e($adultCount); ?><br>
                                            <?php endif; ?>
                                            <?php if($childCount): ?>
                                                <strong>Child:&nbsp;</strong><?php echo e($childCount); ?>

                                            <?php endif; ?>
                                        <?php endif; ?>

                                        </span><br>
                                    <span class="small">Centre: <b><?php echo e($organisation->organisation_name); ?>,&nbsp;<?php echo e($organisation->city); ?></b></span>
                                    <hr>
                                    <?php $__currentLoopData = $facilities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $facility): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <div id="paymentdivfacility<?php echo e($facility->id); ?>" style="display:none;">
                                            <small><strong><?php echo e($facility->facility_name); ?></strong>
                                                <?php if($facility->fixedseatflag): ?>
                                                    &nbsp;<i>[Selected Seats:&nbsp;<span id="paymentdivseats<?php echo e($facility->id); ?>"></span>]</i>
                                                <?php endif; ?>
                                                <span class="float-right" style="color:green;"><i class='fa fa-rupee'></i>&nbsp;<span id="paymentdivfamount<?php echo e($facility->id); ?>"></span>

                                                
                                                </span></small>
                                            <hr>
                                        </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <span class="float-right">Amount Payable:&nbsp;<i class='fa fa-rupee'></i>&nbsp;<span id="paymentdivtotalamount"></span></span>
                                    <input type="hidden" name="totalamountpayable" id="totalamountpayable">
                                </div>
                                <div class="card-footer">
                                    <span class="float-right"><button class="btn btn-primary btn-sm" type="submit">Proceed to Payment</button></span>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

                   
</form>

<script type="text/javascript">
var seatarrayjson = <?php echo json_encode($seats) ?>;
//console.log(seatarrayjson);
const seatarrayjs = [];

for(var i in seatarrayjson) {
    seatarrayjs.push([i,seatarrayjson[i]]);
}


//var seatarrayjs = seatarrayjstemp[0][1];

console.log(seatarrayjs[0][1][1]);
</script>

<script>
    function loadfirsthalfseats(chkobj,rowno,facilityid,middlecol)
    {
        $('#spinnerdiv').show();
       var totalCount = $('#totalCount').val();
        for(let i = 0; i < ((seatarrayjs[0][facilityid][rowno].length)/2); i++)
        {
            var seat_id = seatarrayjs[0][facilityid][rowno][i].id;
            //console.log(seat_id);
            var seatclassobj = document.getElementById('seat'+seat_id);
            if(chkobj.checked==true)
            {
                seatselect(seatclassobj, facilityid, seat_id);
            }
            if(chkobj.checked==false)
            {
                if(seatclassobj.className=='_selected')
                {
                    seatclassobj.className = '_available';
                    currentCount--;
                    var index = selectedseats.indexOf(seat_id);
                    if (index > -1) {
                       selectedseats.splice(index, 1);
                    }
                }
            }
        }
        if(chkobj.checked==false)
        {
            $('#selectedseats'+facilityid).val(selectedseats);
            $('#paymentdivseats'+facilityid).html('');
           for(s=0;s<selectedseats.length;s++)
           {
                var seatnewid = selectedseats[s];
                if($('#paymentdivseats'+facilityid).html())
                    $('#paymentdivseats'+facilityid).html($('#paymentdivseats'+facilityid).html()+','+seatnamearray[seatnewid]);
                else
                    $('#paymentdivseats'+facilityid).html(seatnamearray[seatnewid]);
           }
        }
       // alert(totalCount);
        if(currentCount==totalCount)
            $('#seatSelectionbtn').show();
        else
            $('#seatSelectionbtn').hide();
        $('#spinnerdiv').hide(); 

        
        
    }

    function loadsecondhalfseats(chkobj,rowno,facilityid,middlecol)
    {
        $('#spinnerdiv').show();
       var totalCount = $('#totalCount').val();
        for(let i = ((seatarrayjs[0][facilityid][rowno].length)-1); i >= ((seatarrayjs[0][facilityid][rowno].length)/2); i--)
        {
            var seat_id = seatarrayjs[0][facilityid][rowno][i].id;
            var seatclassobj = document.getElementById('seat'+seat_id);
            if(chkobj.checked==true)
            {
                seatselect(seatclassobj, facilityid, seat_id);
            }
            if(chkobj.checked==false)
            {
                if(seatclassobj.className=='_selected')
                {
                    seatclassobj.className = '_available';
                    currentCount--;
                    var index = selectedseats.indexOf(seat_id);
                    if (index > -1) {
                       selectedseats.splice(index, 1);
                    }
                }
            }

        }
        if(chkobj.checked==false)
        {
            $('#selectedseats'+facilityid).val(selectedseats);
            $('#paymentdivseats'+facilityid).html('');
           for(s=0;s<selectedseats.length;s++)
           {
                var seatnewid = selectedseats[s];
                if($('#paymentdivseats'+facilityid).html())
                    $('#paymentdivseats'+facilityid).html($('#paymentdivseats'+facilityid).html()+','+seatnamearray[seatnewid]);
                else
                    $('#paymentdivseats'+facilityid).html(seatnamearray[seatnewid]);
           }
        }
        if(currentCount==totalCount)
            $('#seatSelectionbtn').show();
        else
            $('#seatSelectionbtn').hide();
        $('#spinnerdiv').hide();

        
    }
    function showselect(obj, facilityid, showid)
    {
        $('#spinnerdiv').show();
        //alert("here");
        $("."+facilityid).css('background-color', '');

        if(obj.style.backgroundColor == 'lightgreen')
        {
            obj.style.backgroundColor = '';
            obj.style.color = '#4abd5d';
            //alert("here2");
        }
        else
        {
            obj.style.backgroundColor = 'lightgreen';
            //alert("here3");
            
        }

        if($('#showSelected'+facilityid).val()==showid)
        {
            clearselection(facilityid);
             $('#spinnerdiv').hide();
            return;
        }

        //select this facility
        //alert(facilitiesarray);
        //fetch available seats for this facility
        var showdate = $('#showDate').val();
        $.ajax({
              type: "GET",
              url: "<?php echo e(url('user/fetchAvailableSeats')); ?>/"+facilityid+"/"+showid+"/"+showdate,
              success: function( result ) {
                
                $('#available'+facilityid).html("Available: "+result);
                 
                //alert(result);
                $('#spinnerdiv').hide();
                
            }
        }); 

        $('#iffacilitySelected'+facilityid).val('1');
        $('#showSelected'+facilityid).val(showid);

        //show amount
        var adultrate = $('#rateadult'+facilityid).val();
        var childrate = $('#ratechild'+facilityid).val();

        if(!adultrate)
            adultrate = 0;
        if(!childrate)
            childrate = 0;

        var adults = $('#adultCount').val();
        var child = $('#childCount').val();
        //alert(adults);
        var amount = (adults*adultrate)+(child*childrate);
        //alert(amount);
        $('#amount'+facilityid).html("<i class='fa fa-rupee'></i> "+amount);
        $('#famount'+facilityid).val(amount);

        calculatetotal();

        //load details in payment div

        $('#paymentdivfacility'+facilityid).show();
        $('#paymentdivfamount'+facilityid).html(amount);
        
    }

    function calculatetotal()
    {
        var amt = 0;
        for(let i = 0; i < facilitiesarray.length; i++){
            
            var f = facilitiesarray[i];

            //alert(f);
            var facility_amt = $('#famount'+f).val();

            //alert(facility_amt);

            amt = amt*1 + facility_amt*1;

           

        }
        //alert(amt);
        $('#totalamount').html(amt);
        $('#paymentdivtotalamount').html(amt);
        $('#totalamountpayable').val(amt);

    }

    function clearselection(facilityid)
    {
        $("."+facilityid).css('background-color', '');
        $('#iffacilitySelected'+facilityid).val('');
        $('#showSelected'+facilityid).val('');
        $('#available'+facilityid).html('');
        $('#amount'+facilityid).html('');
        $('#famount'+facilityid).val(0);

        $('#paymentdivfacility'+facilityid).hide();
        $('#paymentdivfamount'+facilityid).html(0);

        calculatetotal();
    }
    var selectedseats=[];

    function seatselect(obj,facilityid,seatid)
    {
        //checking on how many to be selected
        var totalCount = $('#totalCount').val();



        
        //alert(obj.className);

        if(obj.className=='_selected')
        {
           
            obj.className = '_available';
            currentCount--;

            //remove this seat from selected list
            for( var ar = 0; ar < selectedseats.length; ar++){ 
                if ( selectedseats[ar] === seatid) { 
            
                    selectedseats.splice(ar, 1); 
                }
            }
        }
        else if(obj.className=='_available')
        {
            if(currentCount<totalCount)
            {
                obj.className = '_selected';
                currentCount++;

                //enter this seat to selected list
                selectedseats.push(seatid);
            }
            
        }
        //alert(currentCount);
        $('#currentSelected'+facilityid).html(currentCount);

        //console.log(seatnamearray);
        $('#selectedseats'+facilityid).val(selectedseats);

       $('#paymentdivseats'+facilityid).html('');
       for(s=0;s<selectedseats.length;s++)
       {
        var seatnewid = selectedseats[s];

        if($('#paymentdivseats'+facilityid).html())
            $('#paymentdivseats'+facilityid).html($('#paymentdivseats'+facilityid).html()+','+seatnamearray[seatnewid]);
        else
            $('#paymentdivseats'+facilityid).html(seatnamearray[seatnewid]);
       }
        

        if(currentCount==totalCount)
            $('#seatSelectionbtn').show();
        else
            $('#seatSelectionbtn').hide();


        
    }
    var currentCount = 0;

    $('#facilitySelectbtn').click(function(){


        $('#spinnerdiv').show();
        $('#facilitySelectdiv').hide();

        var selectflag = 0; 
        var layoutflag = 0;
        var layoutfacility='';
        //get all facilities selected
        for(let i = 0; i < facilitiesarray.length; i++){
            
            var f = facilitiesarray[i];

            //check if this facility is selected
            var ifselected = $('#iffacilitySelected'+f).val();
            if(ifselected)
            {
                console.log(f);
                selectflag = 1;

                //check if layout is there for the facility
                var iffacilityfixed = $('#iffacilityfixed'+f).val();

                if(iffacilityfixed==1)
                {
                    //alert(iffacilityfixed);
                    layoutflag = 1;
                    layoutfacility = f;

                }
            }

        }

        //if no facilities selected return false
        if(selectflag==0)
        {
            $('#spinnerdiv').hide();
            $('#facilitySelectdiv').show();

            return false;
        }

        //check if layout needs to be loaded
        if(layoutflag==1)
        {
            //alert('load layout');
            //get selected showid and showdate
            var showid = $('#showSelected'+layoutfacility).val();
            //alert(showid);
            var showdate = $('#showDate').val();

            //get blocked seats using ajax
            $.ajax({
                  type: "GET",
                  url: "<?php echo e(url('user/fetchBookedSeats')); ?>/"+layoutfacility+"/"+showid+"/"+showdate,
                  success: function( result ) {
                    
                   
                     
                    //alert(result);
                    for (let i = 0; i < result.length; i++) {
                      //console.log(result[i]);
                      //block this seat
                      $('#seat'+result[i]).removeClass('_available');
                      $('#seat'+result[i]).addClass('_blocked');
                      $('#seat'+result[i]).prop("onclick", null).off("click");
                    }

                    $('#spinnerdiv').hide();
                    
                }
            }); 



            $('#seatSelectiondiv').show();
            $('#spinnerdiv').hide();
        }
        else //if no layout proceed to payment page
        {
            $('#paymentdiv').show();
            $('#spinnerdiv').hide();
        }

        $(window).scrollTop(0);
        
    });

    $('#seatSelectionbtn').click(function(){
        $('#spinnerdiv').show();
        $('#seatSelectiondiv').hide();
        $('#paymentdiv').show();
        $('#spinnerdiv').hide();

        $(window).scrollTop(0);
    });
</script>

<?php $__env->stopSection(); ?>			
<?php echo $__env->make('layout.public', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/ksstmprod/resources/views/tickets/book.blade.php ENDPATH**/ ?>