@extends('adminlte::page')

@section('content_header')
    <h1>Capture {{request()->session()->get('session_fname')}}s</h1>
@stop


<script src="//code.jquery.com/jquery.js"></script>

@section('content')
    
        @if ($errors->any())
            <div class="alert alert-danger">
                <ul>
                    @foreach ($errors->all() as $error)
                        <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
        @endif

              @if (session('status'))
            <div class="alert alert-success">
                {{ session('status') }}
            </div>
            @endif

            <div class="row">
            <!--row starts-->

            <div class="col-md-12">
               
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                           Capture {{request()->session()->get('session_fname')}}
                        </h3>
                </div>

                <div class="panel-body">
                       
                            <!-- CSRF Token -->
                             <input type="hidden" name="_token" value="{{csrf_token()}}">
                                <!-- Name input-->
                              
                                <br>
                                 <div class="form-group">
                                    <label class="col-md-3 control-label" for="email">Capture the {{request()->session()->get('session_fname')}}s of seat<span style="color: red;">*</span></label>
                                    <div class="col-md-9">
                                      <select name="seatname" id="seatname" class="form-control">
                                        <option value="0">Select One</option>
                                       @foreach ($allseats as $seat)
                                       @if(in_array($seat->id,$charray))
                                        <option value="{{$seat->id}}">{{$seat->seat_name}}</option>
                                        @endif

                                       @endforeach

                                      </select>
                                      </div>
                                </div>
                               
                                <!-- Form actions -->
                                <div class="form-position">
                                    <div class="col-md-12 text-right">
                                    <br>
                                        <button type="submit" class="btn btn-responsive btn-primary btn-sm" id="btn"  onclick="getlistoffile();">Fetch {{request()->session()->get('session_fname')}}</button>
                                    </div>
                                </div>
                       
                    </div>
                </div>
               
            </div>
            <!--md-12 ends-->
        </div>


        



<table class="table table-bordered" id="filelistdiv">
        <thead>
            <tr>
                 <th>Number</th>
                 <th>Date</th>
                 <th>Title</th>
                 <th>{{request()->session()->get('session_fname')}} Group</th>
                 <th>Actions</th>
            </tr>
        </thead>
    </table>

<script>
  
             function getlistoffile(){

                var id = document.getElementById("seatname").value;

                $('#filelistdiv').DataTable({
                    processing: true,
                    serverSide: true,
                    destroy: true,
                    ajax: '{!! url('getfilelist') !!}'+"/"+id,
                    columns: [
                        { data: 'file_no', name: 'file_no' },
                        { data: 'created_at', name: 'created_at' },
                        { data: 'title', name: 'title' },
                        { data: 'file_group', name: 'file_group' },
                        { data: 'action', name: 'action' }

                       
                    ]
                });      
               
             }


        </script>
                      
@stop
