{{-- Extends layout --}}
@extends('layout.default')
@section('content')
    <div class="container-fluid">
        <div class="page-titles">
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="{{URL::to('/facility')}}">Facility</a></li>
                <li class="breadcrumb-item active"><a href="javascript:void(0)">Show Timings</a></li>
            </ol>
        </div>
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-primary">
                        <div class="card-body">
                            <form id="organisation_form" class="form-horizontal" action="{{URL::to('/showtimings_create_post')}}" method="post" onsubmit="return validation();" autocomplete="off" enctype="multipart/form-data">
                                {{ csrf_field() }}
                                <div class="card bg-light">
                                    <div class="card-header">
                                        <h5 class="card-title">{{$facilities->facility_name}}</h5>
                                    </div>
                                    <div class="card-body mb-0">
                                        <p class="card-text">
                                            <b>Organisation Name :</b> {{$facilities->organisation->organisation_name}}&nbsp;&nbsp;{{$facilities->organisation->city}}<br>
                                            <b>Number of Seats :</b> {{$facilities->noofseats}}
                                        </p>
                                    </div>
                                </div>
                                <div class="form-row">
                                    <div class="form-group  col-md-4">
                                        <label>Date</label>
                                        <input type="date" class="form-control" id="show_date" name="show_date" min="{{date('Y-m-d')}}" value="{{date('Y-m-d')}}">
                                        <input type="hidden" name="facility_id" id="facility_id" value="{{$facilities->id}}">
                                    </div>
                                    <div class="form-group col-4"><br>
                                        <label>Special Show ?</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <input type="checkbox" name="show_flag" id="show_flag" data-toggle="toggle" data-on="Yes" data-off="No" data-onstyle="success" data-offstyle="danger" data-size="small" data-style="ios" value="1" checked>
                                    </div>
                                </div>
                                <div class="form-row">
                                    <div class="form-group col-md-4">
                                        <label>Show Start Time</label>
                                        <div class="input-group clockpicker" data-placement="bottom" data-align="top" data-autoclose="true">
                                            <input type="time" class="form-control" name="show_start_time" id="show_start_time" required>  
                                        </div>
                                    </div>
                                    <div class="form-group col-md-4">
                                        <label>Show End Time</label>
                                        <div class="input-group clockpicker" data-placement="bottom" data-align="top" data-autoclose="true">
                                            <input type="time" class="form-control" name="show_end_time" id="show_end_time" required> 
                                        </div>
                                    </div>
                                </div>
                                <div class="form-row">
                                    <div class="form-group col-md-4">
                                        <label>Remark</label>
                                        <input type="text" class="form-control" name="remark" id="remark">  
                                    </div>
                                </div>
                                <div class="card-footer">
                                    <button type="submit" class="btn btn-primary">Submit</button>
                                    <a href="{{URL::to('/facility')}}" title="View Facility" class="btn btn-warning">Back</a>
                                </div>

                            </form>
                        </div> 
                        <div class="card-body  bg-light">      
                            <div class="table-responsive">
                                @if(count($showtimings)!=0)
                                <table class="display" style="width:100%" id="example">
                                    <thead class="thead-info">
                                        <tr>
                                            <th>Slno</th>
                                            <th>Date</th>
                                            <th>Show Start Time</th>
                                            <th>Show End Time</th>
                                            <th>Special/Normal Show</th>
                                            <th>Status</th>
                                            <th></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @if(count($showtimings)==0)
                                            <tr>
                                                <td colspan="3"><br><br>
                                                    <div class="alert alert-danger alert-dismissible fade show">
                                                        <strong>No Show TImings Added !!!</strong>
                                                    </div>
                                                    
                                                </td>
                                            </tr>
                                        @endif
                                        @php
                                            $n = 0;
                                            $status_name ="";
                                            $show_status ="";
                                        @endphp
                                        @if(isset($showtimings))
                                            @foreach($showtimings as $showtiming)
                                                @php  
                                                    $n++;
                                                    $status = $showtiming->active_flag;
                                                    if($status==1)
                                                    {
                                                        $status_name = "Active";
                                                    }
                                                    else
                                                    {
                                                        $status_name = "Not Active";
                                                    }
                                                    $show_flag = $showtiming->show_flag;
                                                    if($show_flag==1)
                                                    {
                                                        $show_status = "Special Show";
                                                    }
                                                    else
                                                    {
                                                        $show_status = "Normal Show";
                                                    }
                                                @endphp
                                                <tr>
                                                    <td>{{$n}}</td>
                                                    <td>
                                                        @if(isset($showtiming->date))
                                                            {{$showtiming->date}}
                                                        @endif
                                                    </td>
                                                    <td>{{$showtiming->from_time}}</td>
                                                    <td>{{$showtiming->to_time}}</td>
                                                    <td>{{$show_status}}</td>
                                                    <td>{{$status_name}}</td>
                                                    <td>
                                                        <div class="form-group">
                                                            <div class="form-check form-check-inline" style="margin-right:0px !important;">
                                                                <a href="{{URL::to('/showtimings_update')}}/{{$showtiming->id}}" title="Update Show Time" 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>
                                                        </div>
                                                    </td>
                                                </tr>
                                            @endforeach
                                        @endif
                                    </tbody>
                                </table>
                                @endif
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="application/javascript">
        $(document).ready(function() {
            toastr.options.timeOut = 10000;
            @if (Session::has('error'))
                toastr.error('{{ Session::get('error') }}');
            @elseif(Session::has('success'))
                toastr.success('{{ Session::get('success') }}');
            @endif
        });
    </script>
@stop
