 
 <?php $__env->startSection('content'); ?>
<div class="card">
        <div class="card-header">
            <h3 class="card-title">New Game Winner List</h3>
        </div>
         <div class="card-body">
        
       </div>

        <!-- /.card-header -->
        <div class="card-body">
            <?php if(session()->has('message')): ?>
                <div class="alert alert-success">
                    <?php echo e(session()->get('message')); ?>

                </div>
            <?php 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_asc" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    aria-sort="ascending"
                                    aria-label="Rendering engine: activate to sort column descending"
                                    style="width: 60px;">S.No
                                </th>
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    aria-label="Browser: activate to sort column ascending" style="width: 207px;">
                                    Game Name
                                </th>
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    aria-label="Browser: activate to sort column ascending" style="width: 207px;">
                                   Day
                                </th>
                               
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    aria-label="Browser: activate to sort column ascending" style="width: 207px;">
                                  Open Time
                                </th>
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    aria-label="Browser: activate to sort column ascending" style="width: 207px;">
                                  Close Time
                                </th>
                                 <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    aria-label="Browser: activate to sort column ascending" style="width: 207px;">
                                  Add Open Result
                                </th>
                                 <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    aria-label="Browser: activate to sort column ascending" style="width: 207px;">
                                  Add Close Result
                                </th>
                              
                           
                                
                            </tr>
                            </thead>
                            <tbody>
                            <?php 
    $page = Request::input('page', 1);
    $sort = $lists->perPage();
?>

<?php $__empty_1 = true; $__currentLoopData = $lists; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $list): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
    <?php 
        $rowspan = count($list->storesDay); 
    ?>
    <?php if($rowspan > 0): ?>
        <?php $__currentLoopData = $list->storesDay; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $storesDay): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <tr>
                <?php if($index == 0): ?>
                    <td rowspan="<?php echo e($rowspan); ?>"><?php echo e($sort * ($page - 1) + ($key + 1)); ?></td>
                    <td rowspan="<?php echo e($rowspan); ?>"><?php echo e($list->name); ?></td>
                <?php endif; ?>
                
                    <td><?php echo e($storesDay->Day->name); ?></td>
                <td><?php echo e(timeShow($storesDay->opent_time)); ?></td>
                
                <td><?php if($list->id != 9): ?><?php echo e(timeShow($storesDay->close_time)); ?><?php endif; ?></td>
                <td>
                    <?php
                        // Find the winner that corresponds to the current storesDay
                        $matchingWinner = $list->winners->firstWhere('time_id', $storesDay->id);
                    ?>

                  <?php if($list->id != 9): ?>
                    <?php if($matchingWinner): ?>
                        <!-- Display the buttons for a winner with matching time_id -->
                        <?php if(!empty($matchingWinner->open_time)): ?>
                            <a href="#" class="btn btn-primary"><?php echo e($matchingWinner->open_time); ?></a>
                            <a href="<?php echo e(url('admin/addnewreverseopen/'.$storesDay->id)); ?>" class="btn btn-warning">Reverse Result</a>
                            <a href="<?php echo e(url('admin/newgamewinnerresult/'.$storesDay->id)); ?>" class="btn btn-info"><i class="fa fa-eye" aria-hidden="true"></i></a>
                        <?php endif; ?>
                    <?php else: ?>
                        <!-- Display the Add Open Result button if no matching winner is found -->
                        <a href="<?php echo e(url('admin/addopenresults/'.$storesDay->id)); ?>" class="btn btn-info">Add Open Result</a>
                    <?php endif; ?>
                    <?php endif; ?>
                </td>
                <td>
                    <?php if($list->id == 9): ?>
                     <?php if($matchingWinner && !empty($matchingWinner->close_time)): ?>
                        <a href="#" class="btn btn-primary"><?php echo e(isset($matchingWinner->open_time[4])  &&  isset($matchingWinner->close_time[0]) ? $matchingWinner->open_time[4] . $matchingWinner->close_time[0] : ''); ?></a>
                        <a href="<?php echo e(url('admin/addnewreverseclose/'.$storesDay->id)); ?>" class="btn btn-warning">Reverse Result</a>
                        <a href="<?php echo e(url('admin/newgamewinnerresultclose/'.$storesDay->id)); ?>" class="btn btn-info"><i class="fa fa-eye" aria-hidden="true"></i></a>
                    <?php else: ?>
                        <a href="<?php echo e(url('admin/addcloseresults/'.$storesDay->id)); ?>" class="btn btn-info"><?php echo e($storesDay->id != 9 ? 'Add Close Result' : 'Add Result'); ?></a>
                    <?php endif; ?>
                    <?php else: ?>
                     <?php if($matchingWinner && !empty($matchingWinner->close_time)): ?>
                        <a href="#" class="btn btn-primary"><?php echo e($matchingWinner->close_time); ?></a>
                        <a href="<?php echo e(url('admin/addnewreverseclose/'.$storesDay->id)); ?>" class="btn btn-warning">Reverse Result</a>
                        <a href="<?php echo e(url('admin/newgamewinnerresultclose/'.$storesDay->id)); ?>" class="btn btn-info"><i class="fa fa-eye" aria-hidden="true"></i></a>
                    <?php else: ?>
                        <a href="<?php echo e(url('admin/addcloseresults/'.$storesDay->id)); ?>" class="btn btn-info"><?php echo e($storesDay->id != 9 ? 'Add Close Result' : 'Add Result'); ?></a>
                    <?php endif; ?>
                    
                    <?php endif; ?>
                   
                    
                </td>
            </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    <?php else: ?>
        <tr>
            <td><?php echo e($sort * ($page - 1) + ($key + 1)); ?></td>
            <td><?php echo e($list->name); ?></td>
            <td colspan="5">No store day times available</td>
        </tr>
    <?php endif; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
    <tr>
        <td colspan="9">Record not found</td>
    </tr>
<?php endif; ?>



                            </tbody>
                   </table>
                   </div>
                   </div>
                    <div class="row">
              <div class="col-md-6 text-left" style="margin: 20px 0px;">
                Showing  <?php echo e($lists->firstItem()); ?> to <?php echo e($lists->lastItem()); ?> of <?php echo e($lists->total()); ?>

              </div>
              <div class="col-md-6 text-right">
                <?php echo $lists->appends(request()->input())->links(); ?>

              </div>
            </div>
                  </div>
                </div>
              </div>
            </div>
          </div>


 <?php $__env->stopSection(); ?>
<?php $__env->startSection('js-content'); ?>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.main-layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/a1gamess/public_html/admin.a1gamess.com/resources/views/admin/new-game-winner/index.blade.php ENDPATH**/ ?>