

<?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;
}

</style>
<div class="container-fluid">
    <div class="page-titles">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="javascript:void(0)">Sales</a></li>
            <li class="breadcrumb-item active"><a href="javascript:void(0)">Cancel Show</a></li>
        </ol>
    </div>
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-primary">
                    <div class="card-header custom-tab-1">
                        <ul class="nav nav-tabs">
                            <li class="nav-item">
                                <a class="nav-link active" data-toggle="tab" href="#organisation_form"><b>Cancel Shows</b></a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" data-toggle="tab" href="#listorgdata"><b>View Cancelled Shows</b></a>
                            </li>
                        </ul>
                    </div>
                    <div class="card-body">
                        <div class="default-tab">
                            <div class="tab-content">
                                <div class="tab-pane fade show active" id="organisation_form" role="tabpanel">
                                    <form id="organisation_form" class="form-horizontal" action="<?php echo e(URL::to('/show_cancellation_post')); ?>" method="post" onsubmit="return validation();" autocomplete="off" enctype="multipart/form-data">
                                        <?php echo e(csrf_field()); ?>

                                        <div class="form-group col-6">
                                            <label>Show Date</label>
                                            <input name="show_date" class="form-control" id="show_date" type="date" value="<?php echo e(date('Y-m-d')); ?>" onchange="clear_selection();">
                                        </div>
                                        <div class="form-group col-6">
                                            <label>Organisation</label>
                                            <select id="organisation_id" name="organisation_id" class="form-control" required onchange="load_facility(this.value);">
                                                <option value="">-- Select --</option>
                                                <?php $__currentLoopData = $organisations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $organisation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php if($organisation_id==$organisation->id): ?>
                                                        <option value="<?php echo e($organisation->id); ?>" selected=""><?php echo e($organisation->organisation_name); ?></option>
                                                    <?php else: ?> 
                                                        <option value="<?php echo e($organisation->id); ?>"><?php echo e($organisation->organisation_name); ?></option>
                                                    <?php endif; ?>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>    
                                            </select>
                                        </div>
                                        <div class="form-group col-6">
                                            <label>Facility</label>
                                            <select class="form-control" id="facility_id" name="facility_id" onchange="loadshows(this.value);">
                                              <option value="">Choose...</option>
                                              <?php $__currentLoopData = $facilities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $facility): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                  <option value="<?php echo e($facility->id); ?>"><?php echo e($facility->facility_name); ?></option>
                                              <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            </select>
                                        </div>
                                        <div class="form-group col-6">
                                            <label>Shows</label>
                                            <select class="form-control" id="show_time_id" name="show_time_id" onchange="load_ticket_count();">
                                              <option value="">Choose...</option>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                          <p><span id="totalseats" style="color:blue; font-size: small; font-weight: bold;"></span></p> 
                                          <p><span id="alreadycanceldiv" style="color:red; font-size: small; font-weight: bold;"></span></p>
                                        </div>
                                        <div class="card-footer">
                                          <div id="canceldiv">
                                            <button type="submit" class="btn btn-primary">Cancel Show</button>
                                          </div>
                                        </div>
                                    </form>
                                </div>
                                <div class="tab-pane fade" id="listorgdata">
                                    <div class="table-responsive">
                                        <table class="display" style="width:100%" id="example">
                                                <thead class="thead-info">
                                                    <tr>
                                                        <th>Slno</th>
                                                        <th>Facility Name</th>
                                                        <th>Show Time</th>
                                                        <th>Show Date</th>
                                                        <th>Cancel Time</th>
                                                        <th>Approval Status</th>
                                                        <th>Approved By</th>
                                                        <th>Actions</th>
                                                    </tr>
                                                </thead>
                                                <tbody>                                                    
                                                    <?php
                                                        $n = 0;
                                                        $approved_status ="";
                                                        $show_start_time= "";
                                                    ?>
                                                    <?php if(isset($cancelshows)): ?>
                                                        <?php $__currentLoopData = $cancelshows; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cancelshow): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <?php  
                                                                $n++;
                                                                $approval_flag = $cancelshow->approval_flag;
                                                                if($approval_flag==1)
                                                                {
                                                                  $approved_status = "Approved";
                                                                }
                                                                if($approval_flag==0)
                                                                {
                                                                  $approved_status = "Not Approved";
                                                                }
                                                                $show_start_time = date("g:i A", strtotime($cancelshow->showtime->from_time));
                                                                if(!$cancelshow->showtime->dont_show_to_time)
                                                                {
                                                                    $show_start_time .=  "-". date("g:i A", strtotime($cancelshow->showtime->to_time));
                                                                } 

                                                            ?>
                                                            <tr>
                                                                <td><?php echo e($n); ?></td>
                                                                <td><?php echo e($cancelshow->facility->facility_name); ?></td>
                                                                <td><?php echo e($show_start_time); ?></td>
                                                                <td><?php echo e(date("d-M-Y", strtotime($cancelshow->show_date))); ?></td>
                                                                <td><?php echo e(date("d-M-Y H:i:s", strtotime($cancelshow->cancelled_time))); ?></td>
                                                                <td><?php echo e($approved_status); ?></td>
                                                                <td>
                                                                  <?php if(isset($cancelshow->approved_by)): ?>
                                                                    <?php if($cancelshow->approvedby->id): ?>
                                                                      <?php echo e($cancelshow->approvedby->name); ?>

                                                                    <?php endif; ?>
                                                                  <?php endif; ?>
                                                                </td>
                                                                <td>
                                                                  <div class="form-group">
                                                                    <div class="form-check form-check-inline" style="margin-right:0px !important;">
                                                                      <a href="<?php echo e(URL::to('/offline_tickets')); ?>/<?php echo e($cancelshow->id); ?>" title="Offline Ticekts" class="btn btn-primary btn-xs">Offline</a>&nbsp;
                                                                      <a href="<?php echo e(URL::to('/online_tickets')); ?>/<?php echo e($cancelshow->id); ?>" title="Offline Ticekts" class="btn btn-warning btn-xs">Online</a>  &nbsp;
                                                                      <?php if($approval_flag==0): ?>
                                                                        <?php if(in_array('Approve', $permission_arr)): ?>
                                                                          <form  action="<?php echo e(URL::to('/approve_cancellation')); ?>" method="post">
                                                                            <?php echo e(csrf_field()); ?>

                                                                            <input type="hidden" name="cancel_id" id="cancel_id" value="<?php echo e($cancelshow->id); ?>">
                                                                            <button type="submit" class="btn btn-success btn-xs">Approve</button>
                                                                          </form>
                                                                        <?php endif; ?>
                                                                      <?php endif; ?>                                                                       
                                                                    </div> 
                                                                                                                                    
                                                                  </div>
                                                                </td>
                                                            </tr>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    <?php endif; ?>
                                                </tbody>
                                            </table>
                                    </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>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="application/javascript">
  function load_facility(organisation_id)
  {
      $.ajax({
         type:'GET',
         url: "<?php echo url('get_facility/"+organisation_id+"'); ?>",
         success:function(data)
         {
            $('#facility_id').empty();
            $('#facility_id').append("<option value=''>Choose...</option>");
            $.each(data, function(key, element) {
                $('#facility_id').append("<option value='" + key +"'>" + element + "</option>");
            }); 
         }
      });
  }
  function loadshows(facility_id)
  {
      $('#totalseats').html('');
      var show_date = $('#show_date').val();
      $.ajax({
         type:'GET',
         url: "<?php echo url('get_showtime/"+facility_id+"/"+show_date+"'); ?>",
         success:function(data)
         {
            $('#show_time_id').empty();
            $('#show_time_id').append("<option value=''>Choose...</option>");
            $.each(data, function(key, element) {
                $('#show_time_id').append("<option value='" + element.show_id +"'>" + element.show_time + "</option>");
            }); 
         }
      });
  }
  function load_ticket_count()
  {
      $('#spinnerdiv').show();
      var facility_id = $("#facility_id").val();
      var show_time_id = $("#show_time_id").val();
      var show_date = $("#show_date").val();
      $.ajax({
         type:'GET',
         url: "<?php echo url('get_ticket_count/"+facility_id+"/"+show_time_id+"/"+show_date+"'); ?>",
         success:function(data)
         {
             $('#totalseats').html("Total number of Visitors booked for this show: "+data[0]+"<br>Total number of tickets booked for this show: "+data[1]);
             $('#alreadycanceldiv').html(data[2]);
             if(data[2]!="")
             {
                $('#canceldiv').hide();
             }
             else
             {
                $('#canceldiv').show();
             }
             $('#spinnerdiv').hide();
         }
      });
  }
  function clear_selection()
  {
      $('#totalseats').html('');
      $('#show_time_id').val('');
      $('#facility_id').val('');
  }
  function confirmDeleteDepartment(dept_id) 
  {
      var x = confirm("Are you sure you want to delete?");
      if (x)
      {
          var csrf = "<?php echo e(csrf_token()); ?>";
          $.ajax({
              type: "POST",
              url: "<?php echo e(url('delete_department')); ?>",
              dataType : 'json',
              data: {_token: csrf, dept_id: dept_id},
              success: function( msg ) {
                if(msg)
                  alert("Department has been deleted");
                else
                  alert("Sections are assigned to Selected Department.");
                location.reload();
              }
          });  
      }
      else
      {
        return false;
      }
  }

  $(document).ready(function() {
        toastr.options.timeOut = 10000;
        <?php if(Session::has('error')): ?>
            toastr.error('<?php echo e(Session::get('error')); ?>');
        <?php elseif(Session::has('success')): ?>
            toastr.success('<?php echo e(Session::get('success')); ?>');
        <?php endif; ?>
    });
</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/ksstmorg/resources/views/Sales/show_cancellation.blade.php ENDPATH**/ ?>