 @extends('admin.layouts.main-layout')
 @section('content')
<div class="card">
        
        
        
        <div align="left">
            <a href="{{ url('admin/stores-game-schedule/create') }}" class="btn btn-info mx-3 mt-2">Add Market </a>
        </div>
        
        <div class="card-body">
            @if(session()->has('message'))
                <div class="alert alert-success">
                    {{ session()->get('message') }}
                </div>
            @endif
            <div id="example1_wrapper" class=" dt-bootstrap4">
                <div class="row">
                    <div class="col-sm-12">
                          <div class='tablescroll'>
                            <div class="table-responsive">
                        <table id="example1" class="table table-bordered table-striped dataTable" role="grid"
                               aria-describedby="example1_info">
                            <thead>
                            <tr role="row">
                               
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 207px;">
                                    Market
                                </th>
                                
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 207px;">
                                    Monday
                                </th>
                                
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 207px;">
                                    Tuesday
                                </th>
                                
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 207px;">
                                    Wednesday
                                </th>
                                
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 207px;">
                                    Thursday
                                </th>
                                
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 207px;">
                                    Friday
                                </th>
                                
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 207px;">
                                    Saturday
                                </th>
                                
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    style="width: 207px;">
                                    Sunday
                                </th>
                                
                              
                               
                                
                            </tr>
                            </thead>
                            <tbody>
                              @php 
                    $page=1;
                    if(Request::input('page'))
                    $page=Request::input('page');
                    $sort = $lists->perPage();
                  @endphp
                  @forelse($lists as $key => $list)
                
                        <tr>
                          <td>
                            <a>{{$list->name}}</a>
                            <br>
                             <a href="{{url('admin/stores-game-schedule/'.$list->id.'/edit')}}"
                                   class="btn btn-primary btn-sm mt-1"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Edit</a>
                                   
                            <a href="{{url('/admin/gamedelete/'.$list->id)}}" class="btn btn-sm btn-danger button_flow mt-1" data-toggle="tooltip" data-placement="top" title="" onclick="return confirm('Are you sure you want to delete this Game ?')"><i class="fa fa-trash"></i> Delete</a>
                            
                          </td>
                          @foreach($list->storesDayGame as $daykey => $day)
                           <td>
                           @if($day->status == 1)

                                <span class="badge bg-success">
                                    Active
                                </span>
                            
                            @else
                            
                                <span class="badge bg-danger">
                                    Inactive
                                </span>
                            
                            @endif
                            <br>
                            <a>Open: {{timeShow($day->opent_time)}}</a>
                            <br>
                            <a>Close: {{timeShow($day->close_time)}}</a>
                            <br> 
                            <a href="javascript:void(0)"
                               class="btn btn-primary btn-sm mt-1"
                               data-toggle="modal"
                               data-target="#editDayModal{{ $day->id }}">
                                <i class="fa fa-pencil-square-o"></i>
                            </a>
                             <div class="modal fade"
                                 id="editDayModal{{ $day->id }}"
                                 tabindex="-1"
                                 role="dialog"
                                 aria-hidden="true">
                            
                                <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                            
                                        <form method="POST"
                                              action="{{ url('admin/store-game/update/'.$day->id) }}">
                            
                                            @csrf
                            
                                            <div class="modal-header">
                                                <h5 class="modal-title">Edit Day Time</h5>
                                                <button type="button" class="close" data-dismiss="modal">
                                                    <span>&times;</span>
                                                </button>
                                            </div>
                            
                                            <div class="modal-body">
                            
                                                <div class="form-group">
                                                    <label>Open Time</label>
                                                    <input type="time"
                                                           name="opent_time"
                                                           value="{{ $day->opent_time }}"
                                                           class="form-control"
                                                           required>
                                                </div>
                            
                                                <div class="form-group">
                                                    <label>Close Time</label>
                                                    <input type="time"
                                                           name="close_time"
                                                           value="{{ $day->close_time }}"
                                                           class="form-control"
                                                           required>
                                                </div>
                            
                                                <div class="form-group">
                                                    <label>Status</label>
                                                    <select name="status" class="form-control">
                                                        <option value="1" {{ $day->status == 1 ? 'selected' : '' }}>Active</option>
                                                        <option value="0" {{ $day->status == 0 ? 'selected' : '' }}>Inactive</option>
                                                    </select>
                                                </div>
                            
                                            </div>
                            
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-secondary" data-dismiss="modal">
                                                    Close
                                                </button>
                            
                                                <button type="submit" class="btn btn-success">
                                                    Update
                                                </button>
                                            </div>
                            
                                        </form>
                            
                                    </div>
                                </div>
                            
                            </div>
                          </td>
                          @endforeach
                          
                        
                        </tr>
                         @empty
                  <tr>
                    <td colspan="6">Record not found </td>
                  </tr>
                  @endforelse
                            </tbody>
                   </table>
                   </div>
                   </div>
                    <div class="row">
              <div class="col-md-6 text-left" style="margin: 20px 0px;">
                Showing  {{$lists->firstItem()}} to {{$lists->lastItem()}} of {{$lists->total()}}
              </div>
              <div class="col-md-6 text-right">
                {!! $lists->appends(request()->input())->links() !!}
              </div>
            </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          
         


 @endsection
@section('js-content')
@endsection