@extends('layouts.app')

@section('content')
<div class="container">

 

<!-- Modal -->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered modal-xl" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLongTitle">Peti Besi</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <table class='table table-striped table-hover' id='table-PetiBesi' style="width:100%;">
          <thead class="thead-dark">
              <tr>
                  <th>Bil</th>
                  <th width="60%">Tarikh</th>
                  <th>C/F</th>
                  <th>Keluar</th>
                  <th>Masuk</th>
                  <th>Pendahuluan</th>
                  <th>Serahan</th>
                  <th>Panjar</th>
                  <th>B/F</th>
              </tr>
          </thead>
          <tbody>
            {{-- {{ dd($petibesi) }} --}}
              @foreach ($petibesi as $tunai)
                <tr>
                <td>{{ $loop->iteration }}</td>
                <td>{{ $Tarikh = date("d-m-Y", strtotime($tunai['tarikh']))  }}</td>
                <td>{{ number_format($tunai['bakiawal'],2) }}</td>
                <td>{{ number_format($tunai['keluar'],2) }}</td>
                <td>{{ number_format($tunai['masuk'],2) }}</td>
                <td>{{ number_format($tunai['pendahuluan'],2) }}</td>
                <td>{{ number_format($tunai['serahan'],2) }}</td>
                <td>{{ number_format($tunai['totpanjar'],2) }}</td>
                <td>{{ number_format($tunai['bakiakhir'],2) }}</td>
                </tr>
              @endforeach
          </tbody>
      </table>
      </div>
      {{-- <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button>
      </div> --}}
    </div>
  </div>
</div>

    <div class="row justify-content-center">
        <div class="col-md-12">
            <div class="card">

              <nav aria-label="breadcrumb">
                <ol class="breadcrumb pb-3">
                  <li class="breadcrumb-item"><a href="{{ route('home') }}">Home</a></li>
                  <li class="breadcrumb-item active" aria-current="page">Aliran Tunai</li>
                </ol>

                <button type="button" class="btn btn-danger float-right mr-3" data-toggle="modal" data-target="#exampleModalCenter">
                  Peti Besi
                </button>
              </nav>

                {{-- {{ dd($tunai) }} --}}
                <div class="card-body text-center">
                    
                    <div class="row mb-4">
                        <div class="col-2 justify-content-start">
                        
                        </div>
                        <div class="col-8 mt-3 justify-content-center">
                        </div>
                        <div class="col-2">
                          
                        </div>
                        {{-- <div class="col-12 justify-content-center d-flex">
                          <ul class="nav nav-pills mb-3 mt-2 " id="pills-tab" role="tablist">  
                            <li class="nav-item">
                              <a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-Tunai" role="tab" aria-controls="pills-home" aria-selected="true">Tunai</a>
                            </li>
                            <li class="nav-item">
                              <a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-PetiBesi" role="tab" aria-controls="pills-profile" aria-selected="false">Peti Besi</a>
                            </li>
                          </ul>
                        </div> --}}
                        {{-- <a id="pills-profile-tab" data-toggle="pill" href="#pills-PetiBesi" role="tab" aria-controls="pills-profile" aria-selected="false">Peti Besi</a> --}}
                    </div>

                     <!-- Button trigger modal -->


                    <div class="tab-content" id="pills-tabContent">

                      <div class="tab-pane fade show active" id="pills-Tunai" role="tabpanel" aria-labelledby="pills-home-tab">

                        <div class="container" id="exTab1">

                          {{-- {{ dd($arraytunai) }} --}}

                          <ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">  
                            <script> let listu = [];</script>
                            @foreach($teller as $index1=>$ls)
                            <script> listu.push("{{ $loop->iteration }}"); </script>
                            
                              @if($index1 == 0)
                                <li class="nav-item">
                                  <a class="nav-link active" id="pills-home-tab" data-toggle="pill" href="#pills-{{ $loop->iteration }}" role="tab" aria-controls="pills-home" aria-selected="true">{{ $ls['kodlaluan'] }}</a>
                                </li>
                              @else
                                <li class="nav-item">
                                  <a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-{{ $loop->iteration }}" role="tab" aria-controls="pills-profile" aria-selected="false">{{ $ls['kodlaluan'] }}</a>
                                </li>
                              @endif
  
                            @endforeach
                            </ul>

                          
                          <div class="tab-content" id="pills-tabContent">

                            @foreach($teller as $index1=>$ls)

                            @if($index1 == 0)
                              <div class="tab-pane fade show active" id="pills-{{ $loop->iteration }}" role="tabpanel" aria-labelledby="pills-home-tab">

                                <fieldset class="border p-2">
                                  <legend  class="w-auto">Hari Ini</legend>
                                  <div class="col-12 row">
                                    <div class="col-lg-6 col-xl-4 col-12">
                                      <!-- small box -->
                                      <div class="small-box bg-secondary">
                                        <div class="inner">
                                          <h5>RM {{ (empty($arraytunaiharini[$index1])) ? '0.00' : number_format($arraytunaiharini[$index1]['bakiawal'],2) }}</h5>
                    
                                          <p>Baki Awal Tunai</p>
                                        </div>
                                        <div class="icon">
                                        </div>
                                      </div>
                                    </div>
          
                                    <div class="col-lg-6 col-xl-4 col-12">
                                      <!-- small box -->
                                      <div class="small-box bg-secondary">
                                        <div class="inner">
                                          <h5>RM {{ (empty($arraytunaiharini[$index1])) ? '0.00' : number_format($arraytunaiharini[$index1]['tambah'],2) }}</h5>
                    
                                          <p>Pendahuluan</p>
                                        </div>
                                        <div class="icon">
                                        </div>
                                      </div>
                                    </div>
          
                                    <div class="col-lg-6 col-xl-4 col-12">
                                      <!-- small box -->
                                      <div class="small-box bg-secondary">
                                        <div class="inner">
                                          <h5>RM {{ (empty($arraytunaiharini[$index1])) ? '0.00' : number_format($arraytunaiharini[$index1]['kurang'],2) }}</h5>
                    
                                          <p>Serahan</p>
                                        </div>
                                        <div class="icon">
                                        </div>
                                      </div>
                                    </div>
                                </div>
          
                                <div class="col-12 row">
                                    <div class="col-lg-6 col-xl-4 col-12">
                                        <!-- small box -->
                                        <div class="small-box bg-secondary">
                                          <div class="inner">
                                            <h5>RM {{ (empty($arraytunaiharini[$index1])) ? '0.00' : number_format($arraytunaiharini[$index1]['baki'],2) }}</h5>
                      
                                            <p>Baki Akhir Tunai</p>
                                          </div>
                                          <div class="icon">
                                          </div>
                                        </div>
                                      </div>
            
                                      <div class="col-lg-6 col-xl-4 col-12">
                                        <!-- small box -->
                                        <div class="small-box bg-secondary">
                                          <div class="inner">
                                            <h5>RM {{ (empty($arraytunaiharini[$index1])) ? '0.00' : number_format($arraytunaiharini[$index1]['keluar'],2) }}</h5>
                      
                                            <p>Pembiayaan</p>
                                          </div>
                                          <div class="icon">
                                          </div>
                                        </div>
                                      </div>
            
                                      <div class="col-lg-6 col-xl-4 col-12">
                                        <!-- small box -->
                                        <div class="small-box bg-secondary">
                                          <div class="inner">
                                            <h5>RM {{ (empty($arraytunaiharini[$index1])) ? '0.00' : number_format($arraytunaiharini[$index1]['masuk'],2) }}</h5>
                      
                                            <p>Penyelesaian Pembiayaan</p>
                                          </div>
                                          <div class="icon">
                                          </div>
                                        </div>
                                      </div>
                                </div>

                               </fieldset>

                                

                                <ul class="nav nav-tabs mt-4" id="myTab" role="tablist">
                                  <li class="nav-item">
                                    <a class="nav-link active" id="history-tab" data-toggle="tab" href="#nav-{{ $loop->iteration }}-history" role="tab" aria-controls="home" aria-selected="true">Rekod Tunai</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" id="addtunai-tab" data-toggle="tab" href="#nav-{{ $loop->iteration }}-addtunai" role="tab" aria-controls="profile" aria-selected="false">Tunai</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" id="gt-tab" data-toggle="tab" href="#nav-{{ $loop->iteration }}-gt" role="tab" aria-controls="contact" aria-selected="false">Pembiayaan/Penyelesaian Pem.</a>
                                  </li>
                                  <li class="nav-item">
                                    <a class="nav-link" id="tuntutbaki-tab" data-toggle="tab" href="#nav-{{ $loop->iteration }}-tuntutbaki" role="tab" aria-controls="contact" aria-selected="false">Tuntut Baki</a>
                                  </li>
                                </ul>

                                <div class="mt-3">
                                  <div class="tab-content" id="myTabContent">
                                    <div class="tab-pane fade show active" id="nav-{{ $loop->iteration }}-history" role="tabpanel" aria-labelledby="history-tab">
                                    
                                      

                                        <table class='table table-striped table-hover' id='table-{{ $loop->iteration }}' style="width:100%;">
                                          <thead class="thead-dark">
                                              <tr>
                                                  <th>Bil</th>
                                                  <th>Tarikh</th>
                                                  <th>C/F</th>
                                                  <th>Pendahuluan</th>
                                                  <th>Serahan</th>
                                                  <th>Pembiayaan</th>
                                                  <th>Penyelesaian Pem.</th>
                                                  <th>B/F</th>
                                              </tr>
                                          </thead>
                                          <tbody>
                                              @foreach ($arraytunai[$index1] as $tunai)
                                                <tr>
                                                <td>{{ $loop->iteration }}</td>
                                                <td>{{ $Tarikh = date("d-m-Y", strtotime($tunai['tarikh']))  }}</td>
                                                <td>{{ number_format($tunai['bakiawal'],2) }}</td>
                                                <td>{{ number_format($tunai['tambah'],2) }}</td>
                                                <td>{{ number_format($tunai['kurang'],2) }}</td>
                                                <td>{{ number_format($tunai['keluar'],2) }}</td>
                                                <td>{{ number_format($tunai['masuk'],2) }}</td>
                                                <td>{{ number_format($tunai['baki'],2) }}</td>
                                                </tr>
                                              @endforeach
                                          </tbody>
                                        </table>
                                    
                                    
                                    </div>
                                    <div class="tab-pane fade" id="nav-{{ $loop->iteration }}-addtunai" role="tabpanel" aria-labelledby="addtunai-tab">
                                    
                                      {{-- <div class="input-group mb-3 col-4" style="margin-left:-15px;">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">Tarikh</span>
                                        </div>
                                        <input type="text" class="form-control" placeholder="Pilih Tarikh" aria-label="Tarikh" id="datetarikh" name="datetarikh" aria-describedby="basic-addon1">
                                      </div> --}}

                                      <table class="table table-striped table-hover text-center" id="tableaddtunai-{{ $loop->iteration }}">
                                        <thead class="thead-dark">
                                            <tr>
                                                <th>Bil</th>
                                                <th>Masa</th>
                                                <th>Debit (RM)</th>
                                                <th>Kredit (RM)</th>
                                                <th>Nota</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                          @if(is_object($arrayaddtunai) || is_array($arrayaddtunai))
                                            @foreach($arrayaddtunai[$index1] as $at)
                                            <tr>
                                              <td> {{ $loop->iteration }} </td>
                                              <td> {{ $Tarikh = date("d-m-Y", strtotime($at['tarikh'])) }} </td>
                                              <td> {{ number_format($at['tambah'],2) }} </td>
                                              <td> {{ number_format($at['kurang'],2) }} </td>
                                              <td> {{ $at['nota'] }} </td>
                                            </tr>
                                            @endforeach
                                          @endif
                                      </tbody>
                                      </table>
                                    
                                    </div>
                                    <div class="tab-pane fade" id="nav-{{ $loop->iteration }}-gt" role="tabpanel" aria-labelledby="gt-tab">
                                    
                                      {{-- <div class="input-group mb-3 col-4" style="margin-left:-15px;">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">Tarikh</span>
                                        </div>
                                        <input type="text" class="form-control" placeholder="Pilih Tarikh" aria-label="Tarikh" id="datetarikh" name="datetarikh" aria-describedby="basic-addon1">
                                      </div> --}}

                                      <table class="table text-center table-striped table-hover" id="tablegadaitebus-{{ $loop->iteration }}">
                                        <thead class="thead-dark">
                                            <tr>
                                                <th>Bil</th>
                                                <th>No Rujukan</th>
                                                <th>Pinjaman (RM)</th>
                                                <th>Nilai Marhun (RM)</th>
                                                <th>Jenis Transaksi</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @if(is_object($arraygadaitebus) || is_array($arraygadaitebus))
                                            @foreach($arraygadaitebus[$index1] as $gt)
                                            <tr>
                                            <td> {{ $loop->iteration }} </td>
                                            <td> {{ $gt['norujukan'] }} </td>
                                            <td> {{ number_format($gt['pinjaman'],2) }} </td>
                                            <td> {{ number_format($gt['nilaimarhun'],2) }} </td>
                                            <td> @php if($gt['jenistebus'] == ''){
                                                      echo '<h4><span class="badge badge-success">Gadai</span></h4>';
                                                    }else{
                                                      echo '<h4><span class="badge badge-danger">Tebus</span></h4>';
                                                    }  
                                            @endphp </td>
                                            </tr>
                                            @endforeach
                                            @endif
                                        </tbody>
                                      </table>
                                    
                                    </div>
                                    <div class="tab-pane fade" id="nav-{{ $loop->iteration }}-tuntutbaki" role="tabpanel" aria-labelledby="tuntutbaki-tab">
                                    
                                      {{-- <div class="input-group mb-3 col-4" style="margin-left:-15px;">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">Tarikh</span>
                                        </div>
                                        <input type="text" class="form-control" placeholder="Pilih Tarikh" aria-label="Tarikh" id="datetarikh" name="datetarikh" aria-describedby="basic-addon1">
                                      </div> --}}
                                      
                                      <table class="table text-center table-striped table-hover" id="tabletuntutbaki-{{ $loop->iteration }}">
                                        <thead class="thead-dark">
                                            <tr>
                                                <th>Bil</th>
                                                <th>Tarikh</th>
                                                <th>Caj Lelong (RM)</th>
                                                <th>Jumlah (RM)</th>
                                                <th>Jenis</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @if(is_object($arraytuntutbaki) || is_array($arraytuntutbaki))
                                            @foreach($arraytuntutbaki[$index1] as $tb)
                                            <tr>
                                            <td> {{ $loop->iteration }} </td>
                                            <td> {{ $Tarikh = date("d-m-Y", strtotime($tb['tarikh'])) }} </td>
                                            <td> {{ number_format($tb['cajlelong'],2) }} </td>
                                            <td> {{ number_format($tb['jumlah'],2) }} </td>
                                            <td> @php if($tb['jenis'] == 'T'){
                                                    echo '<h4><span class="badge badge-success">Baki Lelong</span></h4>';
                                            }else{
                                                echo '<h4><span class="badge badge-danger">Rugi Lelong</span></h4>';
                                            }  
                                            @endphp </td>
                                            </tr>
                                            @endforeach
                                            @endif
                                        </tbody>
                                      </table>
                                    
                                    </div>

                                  </div>
                                </div>
                                

                              </div>
                            @else
                              <div class="tab-pane fade" id="pills-{{ $loop->iteration }}" role="tabpanel" aria-labelledby="pills-profile-tab">

                                <fieldset class="border p-2">
                                  <legend  class="w-auto">Hari Ini</legend>

                                  <div class="col-12 row">
                                    <div class="col-lg-6 col-xl-4 col-12">
                                      <!-- small box -->
                                      <div class="small-box bg-secondary">
                                        <div class="inner">
                                          <h5>RM {{ (empty($arraytunaiharini[$index1])) ? '0.00' : number_format($arraytunaiharini[$index1]['bakiawal'],2) }}</h5>
                    
                                          <p>Baki Awal Tunai</p>
                                        </div>
                                        <div class="icon">
                                        </div>
                                      </div>
                                    </div>
          
                                    <div class="col-lg-6 col-xl-4 col-12">
                                      <!-- small box -->
                                      <div class="small-box bg-secondary">
                                        <div class="inner">
                                          <h5>RM {{ (empty($arraytunaiharini[$index1])) ? '0.00' : number_format($arraytunaiharini[$index1]['tambah'],2) }}</h5>
                    
                                          <p>Pendahuluan</p>
                                        </div>
                                        <div class="icon">
                                        </div>
                                      </div>
                                    </div>
          
                                    <div class="col-lg-6 col-xl-4 col-12">
                                      <!-- small box -->
                                        <div class="small-box bg-secondary">
                                          <div class="inner">
                                            <h5>RM {{ (empty($arraytunaiharini[$index1])) ? '0.00' : number_format($arraytunaiharini[$index1]['kurang'],2) }}</h5>
                      
                                            <p>Serahan</p>
                                          </div>
                                          <div class="icon">
                                          </div>
                                        </div>
                                    </div>
                                  </div>
          
                                <div class="col-12 row">
                                    <div class="col-lg-6 col-xl-4 col-12">
                                        <!-- small box -->
                                        <div class="small-box bg-secondary">
                                          <div class="inner">
                                            <h5>RM {{ (empty($arraytunaiharini[$index1])) ? '0.00' : number_format($arraytunaiharini[$index1]['baki'],2) }}</h5>
                      
                                            <p>Baki Akhir Tunai</p>
                                          </div>
                                          <div class="icon">
                                          </div>
                                        </div>
                                      </div>
            
                                      <div class="col-lg-6 col-xl-4 col-12">
                                        <!-- small box -->
                                        <div class="small-box bg-secondary">
                                          <div class="inner">
                                            <h5>RM {{ (empty($arraytunaiharini[$index1])) ? '0.00' : number_format($arraytunaiharini[$index1]['keluar'],2) }}</h5>
                      
                                            <p>Pembiayaan</p>
                                          </div>
                                          <div class="icon">
                                          </div>
                                        </div>
                                      </div>
            
                                      <div class="col-lg-6 col-xl-4 col-12">
                                        <!-- small box -->
                                        <div class="small-box bg-secondary">
                                          <div class="inner">
                                            <h5>RM {{ (empty($arraytunaiharini[$index1])) ? '0.00' : number_format($arraytunaiharini[$index1]['masuk'],2) }}</h5>
                      
                                            <p>Penyelesaian Pem.</p>
                                          </div>
                                          <div class="icon">
                                          </div>
                                        </div>
                                      </div>
                                </div>

                               </fieldset>

                                  

                                  <ul class="nav nav-tabs mt-4" id="myTab" role="tablist">
                                    <li class="nav-item">
                                      <a class="nav-link active" id="history-tab" data-toggle="tab" href="#nav-{{ $loop->iteration }}-history" role="tab" aria-controls="home" aria-selected="true">Rekod Tunai</a>
                                    </li>
                                    <li class="nav-item">
                                      <a class="nav-link" id="addtunai-tab" data-toggle="tab" href="#nav-{{ $loop->iteration }}-addtunai" role="tab" aria-controls="profile" aria-selected="false">Tunai</a>
                                    </li>
                                    <li class="nav-item">
                                      <a class="nav-link" id="gt-tab" data-toggle="tab" href="#nav-{{ $loop->iteration }}-gt" role="tab" aria-controls="contact" aria-selected="false">Pembiayaan/Penyelesaian Pem.</a>
                                    </li>
                                    <li class="nav-item">
                                      <a class="nav-link" id="tuntutbaki-tab" data-toggle="tab" href="#nav-{{ $loop->iteration }}-tuntutbaki" role="tab" aria-controls="contact" aria-selected="false">Tuntut Baki</a>
                                    </li>
                                  </ul>


                                <div class="mt-3">
                                  <div class="tab-content" id="myTabContent">
                                    <div class="tab-pane fade show active" id="nav-{{ $loop->iteration }}-history" role="tabpanel" aria-labelledby="history-tab">
                                    
                                      

                                        <table class='table table-striped table-hover' id='table-{{ $loop->iteration }}' style="width:100%;">
                                          <thead class="thead-dark">
                                              <tr>
                                                  <th>Bil</th>
                                                  <th>Tarikh</th>
                                                  <th>C/F</th>
                                                  <th>Pendahuluan</th>
                                                  <th>Serahan</th>
                                                  <th>Pembiayaan</th>
                                                  <th>Penyelesaian Pem.</th>
                                                  <th>B/F</th>
                                              </tr>
                                          </thead>
                                          <tbody>
                                              @foreach ($arraytunai[$index1] as $tunai)
                                                <tr>
                                                <td>{{ $loop->iteration }}</td>
                                                <td>{{ $Tarikh = date("d-m-Y", strtotime($tunai['tarikh'])) }}</td>
                                                <td>{{ number_format($tunai['bakiawal'],2) }}</td>
                                                <td>{{ number_format($tunai['tambah'],2) }}</td>
                                                <td>{{ number_format($tunai['kurang'],2) }}</td>
                                                <td>{{ number_format($tunai['keluar'],2) }}</td>
                                                <td>{{ number_format($tunai['masuk'],2) }}</td>
                                                <td>{{ number_format($tunai['baki'],2) }}</td>
                                                </tr>
                                              @endforeach
                                          </tbody>
                                        </table>
                                    
                                    
                                    </div>
                                    <div class="tab-pane fade" id="nav-{{ $loop->iteration }}-addtunai" role="tabpanel" aria-labelledby="addtunai-tab">
                                    
                                     
                                        {{-- <div class="input-group mb-3 col-4" style="margin-left:-15px;">
                                            <div class="input-group-prepend">
                                                <span class="input-group-text" id="basic-addon1">Tarikh</span>
                                            </div>
                                            <input type="text" class="form-control" placeholder="Pilih Tarikh" aria-label="Tarikh" id="datetarikh" name="datetarikh" aria-describedby="basic-addon1">
                                        </div> --}}
                                   

                                      <table class="table text-center table-striped table-hover" id="tableaddtunai-{{ $loop->iteration }}">
                                        <thead class="thead-dark">
                                            <tr>
                                                <th>Bil</th>
                                                <th>Masa</th>
                                                <th>Debit (RM)</th>
                                                <th>Kredit (RM)</th>
                                                <th>Nota</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                          @if(is_object($arrayaddtunai) || is_array($arrayaddtunai))
                                            @foreach($arrayaddtunai[$index1] as $at)
                                            <tr>
                                              <td> {{ $loop->iteration }} </td>
                                              <td> {{ $Tarikh = date("d-m-Y", strtotime($at['tarikh'])) }} </td>
                                              <td> {{ number_format($at['tambah'],2) }} </td>
                                              <td> {{ number_format($at['kurang'],2) }} </td>
                                              <td> {{ $at['nota'] }} </td>
                                            </tr>
                                            @endforeach
                                          @endif
                                      </tbody>
                                    </table>
                                    
                                    
                                    </div>
                                    <div class="tab-pane fade" id="nav-{{ $loop->iteration }}-gt" role="tabpanel" aria-labelledby="gt-tab">
                                    
                                      {{-- <div class="input-group mb-3 col-4" style="margin-left:-15px;">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">Tarikh</span>
                                        </div>
                                        <input type="text" class="form-control" placeholder="Pilih Tarikh" aria-label="Tarikh" id="datetarikh" name="datetarikh" aria-describedby="basic-addon1">
                                      </div> --}}


                                      <table class="table text-center table-striped table-hover" id="tablegadaitebus-{{ $loop->iteration }}">
                                        <thead class="thead-dark">
                                            <tr>
                                                <th>Bil</th>
                                                <th>No Rujukan</th>
                                                <th>Pinjaman (RM)</th>
                                                <th>Nilai Marhun (RM)</th>
                                                <th>Jenis Transaksi</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @if(is_object($arraygadaitebus) || is_array($arraygadaitebus))
                                            @foreach($arraygadaitebus[$index1] as $gt)
                                            <tr>
                                            <td> {{ $loop->iteration }} </td>
                                            <td> {{ $gt['norujukan'] }} </td>
                                            <td> {{ number_format($gt['pinjaman'],2) }} </td>
                                            <td> {{ number_format($gt['nilaimarhun'],2) }} </td>
                                            <td> @php if($gt['jenistebus'] == ''){
                                                      echo '<h4><span class="badge badge-success">Gadai</span></h4>';
                                                    }else{
                                                      echo '<h4><span class="badge badge-danger">Tebus</span></h4>';
                                                    }  
                                            @endphp </td>
                                            </tr>
                                            @endforeach
                                            @endif
                                        </tbody>
                                      </table>
                                    
                                    </div>
                                    <div class="tab-pane fade" id="nav-{{ $loop->iteration }}-tuntutbaki" role="tabpanel" aria-labelledby="tuntutbaki-tab">
                                    
                                      {{-- <div class="input-group mb-3 col-4" style="margin-left:-15px;">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text" id="basic-addon1">Tarikh</span>
                                        </div>
                                        <input type="text" class="form-control" placeholder="Pilih Tarikh" aria-label="Tarikh" id="datetarikh" name="datetarikh" aria-describedby="basic-addon1">
                                      </div> --}}


                                      <table class="table text-center table-striped table-hover" id="tabletuntutbaki-{{ $loop->iteration }}">
                                        <thead class="thead-dark">
                                            <tr>
                                                <th>Bil</th>
                                                <th>Tarikh</th>
                                                <th>Caj Lelong (RM)</th>
                                                <th>Jumlah (RM)</th>
                                                <th>Jenis</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            @if(is_object($arraytuntutbaki) || is_array($arraytuntutbaki))
                                            @foreach($arraytuntutbaki[$index1] as $tb)
                                            <tr>
                                            <td> {{ $loop->iteration }} </td>
                                            <td> {{ $Tarikh = date("d-m-Y", strtotime($tb['tarikh'])) }} </td>
                                            <td> {{ number_format($tb['cajlelong'],2) }} </td>
                                            <td> {{ number_format($tb['jumlah'],2) }} </td>
                                            <td> @php if($tb['jenis'] == 'T'){
                                                    echo '<h4><span class="badge badge-success">Baki Lelong</span></h4>';
                                            }else{
                                                echo '<h4><span class="badge badge-danger">Rugi Lelong</span></h4>';
                                            }  
                                            @endphp </td>
                                            </tr>
                                            @endforeach
                                            @endif
                                        </tbody>
                                      </table>
                                    
                                    </div>

                                  </div>
                                </div>
                              </div>
                            @endif

                            @endforeach

                            
                          </div>


                        </div>
                      </div>

                      <div class="tab-pane fade" id="pills-PetiBesi" role="tabpanel" aria-labelledby="pills-profile-tab">

                      

                      </div>
                    </div>


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

  $(document).ready(function() {

    $(listu).each(function(index,element) {
      var tabletunai = $('#table-' + element).DataTable({
      });

      var tablegadaitebus = $('#tablegadaitebus-' + element).DataTable({
      });

      var tabletuntutbaki = $('#tabletuntutbaki-' + element).DataTable({
      });

      var tableaddtunai = $('#tableaddtunai-' + element).DataTable({
      });
    });
   
    var tablecapaian = $('#table-PetiBesi').DataTable({
    });

  });

    
</script>

@endsection
