 @extends('admin.layouts.main-layout')
 @section('content')
<div class="card">
        <div class="card-header">
            <h3 class="card-title">Double Patti</h3>
        </div>
        <div align="left">
        </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">
                        @php 
                       $page=1;
                    if(Request::input('page'))
                    $page=Request::input('page');
                    $sort = $lists->perPage();
                  @endphp
                  @forelse($lists as $key => $list)
                      <h3>{{$list->name}}(Open)({{isset($list->storeGame->opent_time) ? timeShow($list->storeGame->opent_time) : ''}}) </h3>
                        <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;">
                                   User 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;">
                                   Bit
                                </th>
                               
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    aria-label="Platform(s): activate to sort column ascending" style="width: 183px;">
                                    Total
                                </th>
                                
                            </tr>
                            </thead>
                            <tbody>
                             @if(count($list->doublepatti)>0)  
                           @foreach($list->doublepatti as $key => $bits)
                              @foreach($bits->doublepatti as $co => $double)
                                <tr>
                                  <td rowspan="{{count($double->doublePattiPannaBit)}}" scope="column">{{++$key}}</td>
                                  <td rowspan="{{count($double->doublePattiPannaBit)}}" scope="column">{{$bits->username->name}} </td>
                                  @foreach($double->doublePattiPannaBit as $co=>$doublePattiPannaBit)
                                   @if($co>0)
                                  <tr>
                                  <td>{{$doublePattiPannaBit->bit_place}}</td>
                                  <td>{{$doublePattiPannaBit->amount}}</td>
                                  </tr>
                                  @else
                                  <td>{{$doublePattiPannaBit->bit_place}}</td>
                                  <td>{{$doublePattiPannaBit->amount}}</td>
                                  @endif
                                   @endforeach
                                </tr>
                              @endforeach  
                            @endforeach
                            <tr><td colspan="2" style="text-align: center;">Grand Total </td>
                               @for($i=0;$i<10;$i++)
                                   <td>{{doublePattiBitTotalAmount($bits->user_id,$bits->id,$i)}}</td>
                                  @endfor
                                  <td>{{bitTotalAmount(5)}}</td>
                            </tr>
                            @endif
                      </tbody>
                   </table>
                    @empty
                      <h3>No Store</h3>
                    @endforelse
                     @forelse($lists as $key => $list)
                      <h3>{{$list->name}}(Close)({{isset($list->storeGame->close_time) ? timeShow($list->storeGame->opent_time) : ''}}) </h3>
                        <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;">
                                   User 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;">
                                   Bit
                                </th>
                               
                                <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                                    aria-label="Platform(s): activate to sort column ascending" style="width: 183px;">
                                    Total
                                </th>
                                
                            </tr>
                            </thead>
                            <tbody>
                             @if(count($list->doublepattiClose)>0)  
                           @foreach($list->doublepattiClose as $key => $bits)
                              @foreach($bits->doublepattiClose as $co => $double)
                                <tr>
                                  <td rowspan="{{count($double->doublePattiPannaBit)}}" scope="column">{{++$key}}</td>
                                  <td rowspan="{{count($double->doublePattiPannaBit)}}" scope="column">{{$bits->username->name}} </td>
                                  @foreach($double->doublePattiPannaBit as $co=>$doublePattiPannaBit)
                                   @if($co>0)
                                  <tr>
                                  <td>{{$doublePattiPannaBit->bit_place}}</td>
                                  <td>{{$doublePattiPannaBit->amount}}</td>
                                  </tr>
                                  @else
                                  <td>{{$doublePattiPannaBit->bit_place}}</td>
                                  <td>{{$doublePattiPannaBit->amount}}</td>
                                  @endif
                                   @endforeach
                                </tr>
                              @endforeach  
                            @endforeach
                            <tr><td colspan="2" style="text-align: center;">Grand Total </td>
                               @for($i=0;$i<10;$i++)
                                   <td>{{doublePattiBitTotalAmount($bits->user_id,$bits->id,$i)}}</td>
                                  @endfor
                                  <td>{{bitTotalAmount(5)}}</td>
                            </tr>
                            @endif
                      </tbody>
                   </table>
                    @empty
                      <h3>No Store</h3>
                    @endforelse
                    
            </div>
                  </div>
                </div>
              </div>
            </div>
          </div>


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