@extends('layouts.appmin')

@section('tajuk')
Senarai Pemeriksaan Tapak
@endsection


@section('breadcrumb')
    <ul class="breadcrumbs mb-3">
      <li class="nav-home">
        <a href="#">
          <i class="icon-home"></i>
        </a>
      </li>
      <li class="separator">
        <i class="icon-arrow-right"></i>
      </li>
      <li class="nav-item">
        <a href="#">Penjaja</a>
      </li>
      <li class="separator">
        <i class="icon-arrow-right"></i>
      </li>
      <li class="nav-item">
        <a href="#">Pemeriksaan Tapak</a>
      </li>
    </ul>
@endsection

@section('content')                    

    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header">
                    <h4 class="card-title">Pemeriksaan Tapak</h4>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table id="senarai" class="display table table-striped table-hover" >
                            <thead>
                                <tr>
                                    <th style="width: 10px">#</th>
                                    <th>Tarikh<br>Mohon</th>
                                    <th>Pemohon<br />Perniagaan</th>
                                    <th>Jenis Penjaja</th>
                                    <th>Alamat Aktiviti</th>
                                    <th>Status Bayaran</th>
                                    <th>No Fail<br />No Akaun Permohonan</th>
                                    <th>&nbsp;</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $i = 0; ?>
                                @foreach($senarais as $senarai)
                                <?php $i++; $txt_bayar = '';?>
                                <tr class="align-middle text-sm">
                                    <td><?php echo $i; ?></td>
                                    <td>{{$senarai->created_at}}</td>
                                    <td>{{stripslashes($senarai->user->name)}}<br>
                                        <small>[{{$senarai->syarikat->name}}]</small></td>
                                    <td>{{$senarai->jenis}}</td>
                                    <td>
                                @if(!is_null($senarai->penempatan?->nama)) {{ucwords($senarai->penempatan?->nama)}},<br /> @endif
                                @if(!is_null($senarai->jalan?->nama)) {{ucwords(strtolower($senarai->jalan?->nama))}},<br /> @endif
                                @if(!is_null($senarai->taman?->nama)) {{ucwords(strtolower($senarai->taman?->nama))}},<br /> @endif
                               {{ucwords(strtolower($senarai->kawasan->nama))}}</td>
                                    @foreach($senarai->bilpelbagais->where('jenis_bil', 'wang proses') as $bil)
                                        @if($bil->no_resit != '')
                                            @php $txt_bayar = 'Bayar<br />('.$bil->no_resit.')'; @endphp
                                        @else 
                                            @php $txt_bayar = 'Tiada'; @endphp
                                        @endif
                                    @endforeach
                                    <td><?php echo $txt_bayar; ?></td>
                                        <td>{{$senarai->no_fail_lesen}}
                                            <br />[{{$senarai->no_akaun_permohonan}}]</td>
                                    <td><a href="{{route('admin.papar-pemeriksaan', [$senarai->id])}}"><i class="far fa-eye"></i></a></td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>                      
                    </div>              
                </div>              
            </div>                                                  
        </div> <!-- /.col -->                   
    </div> <!--end::Row-->
@endsection
@section('js')
<script>
$(document).ready(function () {
    $('#senarai').DataTable({
        dom: '<"row mb-3"<"col-md-3 col-sm-6"f><"col-md-5 col-sm-2"><"col-md-3 col-sm-4"l>>' +
                '<"row"<"col-12"tr>>' +
                '<"row mt-3"<"col-md-5"i><"col-md-7"p>>',
        language: {
            search: '<span class="me-2">Cari:</span>',
            lengthMenu: '<span class="me-2">Show</span> _MENU_'
        },
        responsive: true
    });
});

</script>
@endsection