<?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 {
    width: 1200px;
 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: #e48787!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>
    <div class="container-fluid">
        <div class="page-titles">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="javascript:void(0)">Reports</a></li>
                <li class="breadcrumb-item active"><a href="javascript:void(0)">Showwise Report</a></li>
            </ol>
        </div>
        <div class="row">
            <div class="col-12">
                <div class="card card-primary">
                    <div class="card-body"> 
                        <div class="form-row">
                            <div class="form-group col-6">
                                <?php
                                    $date_from_crt = date("d-M-Y", strtotime($date_from));
                                ?>
                                <u><b>Show Date : <?php echo e($date_from_crt); ?></b></u>
                            </div>
                            
                        </div>                
                        <div class="table-responsive"> 
                            <?php if(isset($facilities)): ?>
                                <table class="table table-sm table-responsive-lg mb-0" style="font-size:90%;">
                                    <div class="card-header">
                                        <span style="color: blue;"><b><?php echo e(strtoupper($facilities->facility_name)); ?></b></span>
                                    </div>
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>Show Time</th>
                                            <th style="text-align: center;"># of Tickets</th>
                                            <th style="text-align: center;"># of Adults</th>
                                            <th style="text-align: center;"># of Children</th>
                                        </tr>
                                    </thead>
                                    <?php                                                        
                                        $facility_id = $facilities->id;
                                        $total_adults =0;
                                        $total_children = 0;
                                        $total_tickets=0;
                                        //dd($regular_showtimings);
                                    ?>
                                    <!-- regular show -->
                                        <tr>
                                            <td colspan="5">
                                                <b style="color: green;">REGULAR SHOW</b>
                                            </td>
                                        </tr>
                                        <?php
                                            $n=0;
                                        ?>
                                        <?php if(isset($regular_showtimings)): ?>
                                            <?php $__currentLoopData = $regular_showtimings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $regular_showtiming): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <?php
                                                    $fixedseatflag ="";
                                                    $show_time = "";
                                                    $showdate= "";
                                                    $show_time_id = $regular_showtiming->id;
                                                ?> 
                                                <?php if($regular_ticket_count[$show_time_id]): ?>
                                                    <?php
                                                        $n++;
                                                        if($total_tickets)
                                                        {
                                                            $total_tickets = $total_tickets+$regular_ticket_count[$show_time_id];
                                                        }
                                                        else
                                                        {
                                                            $total_tickets = $regular_ticket_count[$show_time_id];
                                                        }
                                                        if($total_adults)
                                                        {
                                                            $total_adults = $total_adults+$regular_adult_count[$show_time_id];
                                                        }
                                                        else
                                                        {
                                                            $total_adults = $regular_adult_count[$show_time_id];
                                                        }
                                                        if($total_children)
                                                        {
                                                            $total_children = $total_children+$regular_child_count[$show_time_id];
                                                        }
                                                        else
                                                        {
                                                            $total_children = $regular_child_count[$show_time_id];
                                                        }
                                                        $show_time = $regular_showtiming->from_time." to ".$regular_showtiming->to_time;
                                                        $fixedseatflag = $regular_showtiming->facility->fixedseatflag;
                                                        $facility_id = $regular_showtiming->facility_id;
                                                        
                                                    ?>
                                                    <tr>
                                                        <td><?php echo e($n); ?></td>
                                                        <td>
                                                            <?php if($fixedseatflag==1): ?>
                                                                <a href='#ShowModal' data-toggle='modal' data-target='#ShowModal' onclick="loadshow('<?php echo e($regular_showtiming->id); ?>','<?php echo e($date_from); ?>','<?php echo e($facility_id); ?>');"><?php echo e($show_time); ?></a>
                                                            <?php else: ?>
                                                                <?php echo e($show_time); ?>

                                                            <?php endif; ?>
                                                        </td>
                                                        <td style="text-align: center;"><?php echo e($regular_ticket_count[$show_time_id]); ?></td>
                                                        <td style="text-align: center;"><?php echo e($regular_adult_count[$show_time_id]); ?></td>
                                                        <td style="text-align: center;"><?php echo e($regular_child_count[$show_time_id]); ?></td>
                                                    </tr>
                                                <?php endif; ?>             
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>                                                                                                     
                                        <?php endif; ?>
                                    <!-- end -->
                                    <!--special shows-->
                                        <tr>
                                            <td colspan="5">
                                                <b style="color: green;">SPECIAL SHOW</b>
                                            </td>
                                        </tr>
                                        <?php
                                            $n = 0;
                                        ?>
                                        <?php if(isset($special_showtimings)): ?>
                                            <?php $__currentLoopData = $special_showtimings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $special_showtiming): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <?php
                                                    $fixedseatflag_spl ="";
                                                    $special_show_time = "";
                                                    $show_time_id = $special_showtiming->id;
                                                ?> 
                                                <?php if($special_ticket_count[$show_time_id]): ?>
                                                    <?php
                                                        $n++;
                                                        if($total_tickets)
                                                        {
                                                            $total_tickets = $total_tickets+$special_ticket_count[$show_time_id];
                                                        }
                                                        else
                                                        {
                                                            $total_tickets = $special_ticket_count[$show_time_id];
                                                        }
                                                        if($total_adults)
                                                        {
                                                            $total_adults = $total_adults+$special_adult_count[$show_time_id];
                                                        }
                                                        else
                                                        {
                                                            $total_adults = $special_adult_count[$show_time_id];
                                                        }
                                                        if($total_children)
                                                        {
                                                            $total_children = $total_children+$special_child_count[$show_time_id];
                                                        }
                                                        else
                                                        {
                                                            $total_children = $special_child_count[$show_time_id];
                                                        }
                                                        $special_show_time = $special_showtiming->from_time." to ".$special_showtiming->to_time;
                                                        $fixedseatflag_spl = $special_showtiming->facility->fixedseatflag;
                                                        $facility_id = $special_showtiming->facility_id;
                                                    ?>
                                                    <tr>
                                                        <td><?php echo e($n); ?></td>
                                                        <td>
                                                            <?php if($fixedseatflag_spl==1): ?>
                                                                <a href='#ShowModal' data-toggle='modal' data-target='#ShowModal' onclick="loadshow('<?php echo e($special_showtiming->id); ?>','<?php echo e($date_from); ?>','<?php echo e($facility_id); ?>');"><?php echo e($special_show_time); ?></a>
                                                            <?php else: ?>
                                                                <?php echo e($special_show_time); ?>

                                                            <?php endif; ?>
                                                        </td>
                                                        <td style="text-align: center;"><?php echo e($special_ticket_count[$show_time_id]); ?></td>
                                                        <td style="text-align: center;"><?php echo e($special_adult_count[$show_time_id]); ?></td>
                                                        <td style="text-align: center;"><?php echo e($special_child_count[$show_time_id]); ?></td>
                                                    </tr>
                                                <?php endif; ?>             
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>                                                                                                     
                                        <?php endif; ?>
                                    <!-- end -->

                                    <tr>
                                        <td><b>Total</b></td>
                                        <td></td>
                                        <td style="text-align: center;"><b><?php echo e($total_tickets); ?></b></td>
                                        <td style="text-align: center;"><b><?php echo e($total_adults); ?></b></td>
                                        <td style="text-align: center;"><b><?php echo e($total_children); ?></b></td>
                                    </tr> 
                                </table>
                            <?php endif; ?>
                        </div>                                       
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="ShowModal" role="dialog" aria-labelledby="myModalLabel" >
        <div class="modal-dialog" role="document"  style="width:1300px; max-width: 1300px;" >
            <div class="modal-content" style="width: 1300px !important;" >
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel"> SEATS SELECTED FOR THIS SHOW </h4>
                </div>
                <div id="seatSelectiondiv">
                    <?php if(isset($facilities)): ?>
                        <?php if($facilities->fixedseatflag==1): ?>
                            <div class="card card-body" width="100%">
                                <!--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 = $facilities->layout->total_row; 
                                            $cols = $facilities->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[$facilities->id][$i];
                                                    $middlecol = ceil($totalcolinrow/2);
                                                    if($middlecol<13)
                                                    {
                                                        $diffcol = 13-$middlecol;
                                                        for($m=1;$m<=$diffcol;$m++)
                                                        {
                                                            ?>
                                                            <td>&nbsp;</td>
                                                            <?php
                                                        }
                                                    }
                                               ?>
                                               <td>
                                                   &nbsp;
                                               </td>
                                               <?php if(isset($seats[$facilities->id][$i])): ?>
                                                   <?php $colcount = 1; ?>
                                                   <?php $__currentLoopData = $seats[$facilities->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"> <?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++; ?>
                                                   <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                               <?php endif; ?> 
                                               <td>
                                                   &nbsp;
                                               </td>
                                               
                                            </tr>
                                        <?php
                                            }
                                        ?>
                                    </table>
                                </div>
                            </div>
                            <div class="screencontainer"><div class="round-bottom">SCREEN</div></div>
                        <?php endif; ?>
                    <?php endif; ?>   
                </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>
<script>
    var seatarrayjson = <?php echo json_encode($seats) ?>;
    const seatarrayjs = [];
    for(var i in seatarrayjson) 
    {
        seatarrayjs.push([i,seatarrayjson[i]]);
    }
    var totalrowsscript = <?php echo "$totalrows"; ?>;    
    function loadshow(showid,show_date,facility_id)
    {
        $('#spinnerdiv').show();
        ////seat remove class blocked. add class available///
        for(let j = 1; j<=totalrowsscript; j++)
        {    
            for(let k=0; k<seatarrayjs[0][facility_id][j].length; k++)
            {
                $('#seat'+seatarrayjs[0][facility_id][j][k]['id']).removeClass('_blocked');
                $('#seat'+seatarrayjs[0][facility_id][j][k]['id']).addClass('_available');
                $('#seat'+seatarrayjs[0][facility_id][j][k]['id']).prop("onclick", null).off("click");
            }
        }
        /////////////////////////////////////////
        var selectflag = 0; 
        var layoutflag = 1;
        var layoutfacility=facility_id;
        //check if layout needs to be loaded
        if(layoutflag==1)
        {
            //get blocked seats using ajax
            $.ajax({
                  type: "GET",
                  url: "<?php echo e(url('/fetchBookedSeatsOffline')); ?>/"+layoutfacility+"/"+showid+"/"+show_date,
                  success: function( result ) {
                    for (let i = 0; i < result.length; 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();
        }
        $(window).scrollTop(0);
    }
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layout.default', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/html/ksstmprod/resources/views/Reports/show_wise_report_list.blade.php ENDPATH**/ ?>