<?php $__env->startSection('content'); ?>
    <div class="container-fluid">
        <div class="page-titles">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="javascript:void(0)">Facility</a></li>
                <li class="breadcrumb-item active"><a href="javascript:void(0)">Facility</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">
                            <?php
                                $activeclass_other ="";
                                $activeclass = "";
                                $showclass ="";
                                $showclass_other = "";
                            ?>
                            <?php if($slugrolename=="counteruser"): ?>
                                <?php
                                    $activeclass = "active";
                                    $showclass = "show active";
                                ?>
                            <?php else: ?>
                                <?php
                                    $activeclass_other = "active";
                                    $showclass_other = "show active";
                                ?>
                            <?php endif; ?>
                            <ul class="nav nav-tabs" role="tablist">
                                <?php if($slugrolename!="counteruser"): ?>
                                <li class="nav-item">
                                    <a class="nav-link <?php echo e($activeclass_other); ?>" data-toggle="tab" href="#organisation_form"><b>Add Facility</b></a>
                                </li>
                                <?php endif; ?>
                                <li class="nav-item">
                                    <a class="nav-link <?php echo e($activeclass); ?>" data-toggle="tab" href="#listorgdata"><b>View Facility</b></a>
                                </li>
                            </ul>
                        </div>
                        <div class="card-body">
                            <div class="default-tab">
                                
                                <div class="tab-content">
                                    <?php if($slugrolename!="counteruser"): ?>
                                    <div class="tab-pane fade<?php echo e($showclass_other); ?>" id="organisation_form" role="tabpanel">
                                        <form id="organisation_form" class="form-horizontal" action="<?php echo e(URL::to('/facility_post')); ?>" method="post" onsubmit="return validation();" autocomplete="off" enctype="multipart/form-data">
                                            <?php echo e(csrf_field()); ?>

                                            <div class="form-group col-6">
                                                <label>Organisation</label>
                                                <select id="organisation_id" name="organisation_id" class="form-control" required>
                                                    <option value="">Choose Organisation</option>
                                                    <?php $__currentLoopData = $organisations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $organisation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <option value="<?php echo e($organisation->id); ?>"><?php echo e($organisation->organisation_name); ?>&nbsp;&nbsp;<?php echo e($organisation->city); ?></option>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>    
                                                </select>
                                            </div>
                                            <div class="form-row">
                                                <div class="form-group col-6">
                                                    <label>Facility Name</label>
                                                    <input type="text" class="form-control" id="facility_name" name="facility_name" placeholder="Enter Facility Name" required maxlength="250">
                                                </div>
                                                <div class="form-group col-3">
                                                    <label>Facility Short Code</label>
                                                    <input type="text" class="form-control" id="short_code" name="short_code" placeholder="Enter Facility Short Code" required maxlength="250">
                                                </div>
                                                <div class="form-group col-3">
                                                    <label>Order By</label>
                                                    <input type="text" name="order_by" id="order_by" class="form-control" maxlength="3" onkeypress="return isNumber(event);" placeholder="Enter Facility Order By">
                                                </div>
                                            </div>
                                            <div class="form-row">
                                                <div class="form-group col-6">
                                                    <label>Number of Seats</label>
                                                    <input type="text" class="form-control" id="noofseats" name="noofseats" placeholder="Enter Number of Seats" maxlength="3" onkeypress="return isNumber(event);">
                                                </div>
                                                <div class="form-group col-6">
                                                    <label>Maximum Ticket per Person</label>
                                                    <input type="text" class="form-control" id="maxticketperperson" name="maxticketperperson" placeholder="Enter Maximum Ticket per Person" maxlength="3" onkeypress="return isNumber(event);">
                                                </div>
                                            </div>
                                            <div class="form-row">
                                                <div class="form-group col-6">
                                                    <label>Fixed Show Time ?</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <input type="checkbox" checked="checked" name="timedshowflag" id="timedshowflag" data-toggle="toggle" data-on="Yes" data-off="No" data-onstyle="success" data-offstyle="danger" data-size="small" data-style="ios" value="1">
                                                </div>
                                                <div class="form-group col-6">
                                                    <label>Fixed Seat ?</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <input type="checkbox" checked="checked" name="fixedseatflag" id="fixedseatflag" data-toggle="toggle" data-on="Yes" data-off="No" data-onstyle="success" data-offstyle="danger" data-size="small" data-style="ios" value="1">
                                                </div>
                                            </div>
                                            
                                            <div class="card-footer">
                                                <button type="submit" class="btn btn-primary">Submit</button>
                                            </div>
                                        </form>
                                    </div>
                                    <?php endif; ?>
                                    <div class="tab-pane fade <?php echo e($showclass); ?>" id="listorgdata">
                                        <div class="table-responsive">
                                            
                                            <table class="display" style="width:100%" id="example" style="font-size: 70% !important;">
                                                <thead class="thead-info">
                                                    <tr>
                                                        <th>#</th>
                                                        <th>Organisation Name</th>
                                                        <th>Facility Name</th>
                                                        <!--<th width="7%">Fixed Show Time</th>-->
                                                        <th>Seats</th>
                                                        <!--<th>Fixed Seats</th>
                                                        <th width="7%">Max Ticket/Person</th>-->
                                                        <th>Status</th>
                                                        <th>Actions</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <?php if(count($faclities)==0): ?>
                                                        <tr>
                                                            <td colspan="3"><br><br>
                                                                <div class="alert alert-danger alert-dismissible fade show">
                                                                    <strong>No Facilities Added !!!</strong>
                                                                </div>
                                                                
                                                            </td>
                                                        </tr>
                                                    <?php endif; ?>
                                                    <?php
                                                        $n = 0;
                                                        $organisation_name= "";
                                                        $fixedseatflag_status ="";
                                                        $timedshowflag_status = "";
                                                        $maxticketperperson ="";
                                                        $status_name ="";
                                                    ?>
                                                    <?php if(isset($faclities)): ?>
                                                        <?php $__currentLoopData = $faclities; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $facility): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <?php  
                                                                $n++;
                                                                if($facility->organisation_id)
                                                                {
                                                                    $organisation_name = $facility->organisation->organisation_name;
                                                                    $city = $facility->organisation->city;
                                                                }
                                                                $timedshowflag = $facility->timedshowflag;
                                                                if($timedshowflag==1)
                                                                {
                                                                    $timedshowflag_status = "Yes";
                                                                }
                                                                else
                                                                {
                                                                    $timedshowflag_status = "No";
                                                                }
                                                                $fixedseatflag = $facility->fixedseatflag;
                                                                if($fixedseatflag==1)
                                                                {
                                                                    $fixedseatflag_status = "Yes";
                                                                }
                                                                else
                                                                {
                                                                    $fixedseatflag_status = "No";
                                                                }
                                                                if($facility->maxticketperperson)
                                                                {
                                                                    $maxticketperperson = $facility->maxticketperperson;
                                                                }
                                                                $status = $facility->active_flag;
                                                                if($status==1)
                                                                {
                                                                    $status_name = "Active";
                                                                }
                                                                else
                                                                {
                                                                    $status_name = "Not Active";
                                                                }
                                                            ?>
                                                            <tr>
                                                                <td><?php echo e($n); ?></td>
                                                                <td><?php echo e($organisation_name); ?>&nbsp;<?php echo e($city); ?></td>
                                                                <td><?php echo e($facility->facility_name); ?> (<?php echo e($facility->short_code); ?>)</td>
                                                                <!--<td><?php echo e($timedshowflag_status); ?></td>-->
                                                                <td><?php echo e($facility->noofseats); ?></td>
                                                                <!--<td><?php echo e($fixedseatflag_status); ?></td>
                                                                <td><?php echo e($maxticketperperson); ?></td>-->
                                                                <td><?php echo e($status_name); ?></td>
                                                                <td>
                                                                    <div class="form-group">
                                                                        <?php if($slugrolename!="counteruser"): ?>
                                                                        <div class="form-check form-check-inline" style="margin-right:0px !important;">
                                                                            <a href="<?php echo e(URL::to('/show_facility')); ?>/<?php echo e($facility->id); ?>" title="Update Facility" class="btn btn-primary shadow btn-xs sharp mr-1" style="padding: 0.438rem 0.5rem !important;"><i class="fa fa-pencil"></i></a>
                                                                        </div>
                                                                        <?php endif; ?>
                                                                        <div class="form-check form-check-inline" style="margin-right:0px !important;">
                                                                           <a href="<?php echo e(URL::to('/showtimings_create')); ?>/<?php echo e($facility->id); ?>" title="Show Timings" class="btn btn-warning shadow btn-xs" style="padding: 0.438rem 0.5rem !important;">Shows</a>
                                                                        </div>
                                                                        <?php if($slugrolename!="counteruser"): ?>
                                                                        <div class="form-check form-check-inline" style="margin-right:0px !important;">
                                                                           <a href="<?php echo e(URL::to('/layout_create')); ?>/<?php echo e($facility->id); ?>" title="Layout" class="btn btn-secondary shadow btn-xs" style="padding: 0.438rem 0.5rem !important;">Layout</a>
                                                                        </div>
                                                                        <?php endif; ?>
                                                                    </div>

                                                                    
                                                                    
                                                                    
                                                                </td>
                                                            </tr>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    <?php endif; ?>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="application/javascript">
        /////////validate integer fields///////////////////////////
        function isNumber(evt) 
        {
          evt = (evt) ? evt : window.event;
          var charCode = (evt.which) ? evt.which : evt.keyCode;
          if (charCode > 31 && (charCode < 48 || charCode > 57)) 
          {
            //alert("Please enter only Numbers.");
            return false;
          }

          return true;
        }
        /////////////////////////////////////////////////////////////////////
        $(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/Facility/facility.blade.php ENDPATH**/ ?>