@extends('adminlte::page')
@section('content_header')
    <h1>Capture {{request()->session()->get('session_tname')}}</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_tname')}}
        </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-2 control-label" for="email">Capture the {{request()->session()->get('session_tname')}}s of seat<span style="color: red;">*</span></label>
          <div class="col-md-6">
            <select name="seatname" id="seatname" class="form-control">
              <option value="">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-5 text-right">
            <br>
                <button type="submit" class="btn btn-responsive btn-primary btn-sm" id="btn"  onclick="getlistoftapal();">Fetch {{request()->session()->get('session_tname')}}s</button>
            </div>
        </div>   
      </div>
    </div>
    <div class="panel panel-body">  
      <table class="table table-bordered" id="tapallistdiv">
        <thead>
          <tr>
               <th>Number</th>
               <th>Date</th>
               <th>Title</th>
               <th>SUbject Group</th>
               <th>Actions</th>
          </tr>
        </thead>
      </table>
    </div>  
  </div>
  <!--md-12 ends-->
</div>    
<script>
  function getlistoftapal()
  {
    var id = document.getElementById("seatname").value;
    $('#tapallistdiv').DataTable({
        processing: true,
        serverSide: true,
        destroy: true,
        ajax: '{!! url('gettapallist') !!}'+"/"+id,
        columns: [
            { data: 'tapal_no', name: 'tapal_no' },
            { data: 'created_at', name: 'created_at' },
            { data: 'title', name: 'title' },
            { data: 'subject_group', name: 'subject_group' },
            { data: 'action', name: 'action' }           
        ]
    });      
  }
</script>                     
@stop