@extends('layouts.appmin')

@section('tajuk')
Pemeriksaan Tapak Permohonan Lesen Penjaja
@endsection

@section('css')

    <!-- Select2 -->
    <link rel="stylesheet" href="{{ asset('plugins/select2/css/select2.min.css') }}">
    <link rel="stylesheet" href="{{ asset('plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css') }}">
<link href="{{ asset('css/jsapi-template-main.css') }}" rel="stylesheet" type="text/css"/>
<link href="https://js.arcgis.com/4.25/esri/css/main.css" rel="stylesheet" type="text/css" />
<style>
#viewDiv {
  padding: 0;
  margin: 0;
  height: 500px;
  width: 100%;
}
</style>
@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="#">Cetakan Laporan</a>
    </li>
</ul>
@endsection

@section('content')                

    <div class="row">        
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                <div class="card-title">Senarai Permohonan</div>
                </div>
                <div class="card-body">
                    <div class="row mt-4">
                        <div class="col-lg-12">    
                            <form method="GET" action="{{ route('admin.senarai_all') }}" class="row mb-4">
                                @csrf
                                <div class="col-md-4">
                                    <input type="text" name="katakunci" value="{{ request('katakunci') }}" 
                                        class="form-control" placeholder="Cari nama pemohon atau syarikat...">
                                </div>
                                <div class="col-md-3">
                                    <select name="tahun" class="form-select">
                                        <option value="">-- Semua Tahun --</option>
                                        @foreach(range(date('Y'), 2024) as $y)
                                            <option value="{{ $y }}" {{ request('tahun') == $y ? 'selected' : '' }}>
                                                {{ $y }}
                                            </option>
                                        @endforeach
                                    </select>
                                </div>
                                <div class="col-md-3">
                                    <button type="submit" class="btn btn-primary">Cari</button>
                                    <a href="{{ route('admin.senarai_all') }}" class="btn btn-secondary">Reset</a>
                                </div>
                            </form>

                            <div class="table-responsive p-0 text-sm text-secondary">
                                <table class="table align-items-center mb-0"  id="senarai">
                                    <thead>
                                        <tr>
                                            <th style="width: 10px">#</th>
                                            <th>Tarikh<br>Mohon</th>
                                            <th>Pemohon</th>
                                            <th>Syarikat</th>
                                            <th>Alamat Aktiviti</th>
                                            <th>Status</th>
                                            <th>&nbsp;</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @forelse($senarais as $senarai)
                                            
                                        <tr class="align-middle text-sm">
                                            <td>{{ $loop->iteration + ($senarais->currentPage()-1) * $senarais->perPage() }}.</td>
                                            <td>{{ \Carbon\Carbon::parse($senarai->created_at)->format('d/m/Y') }}</td>
                                            <td>{{stripslashes($senarai->user->name)}}<br><small>{{$senarai->user->nokp}}</small></td>
                                            <td>{{$senarai->syarikat->name}}<br><small>{{$senarai->syarikat->nossm}}</small></td>
                                            <td>{{ucwords(strtolower($senarai->lokasi_penjajaan()))}}</td>
                                            <td>{{$senarai->status_progress}}</td>
                                            <td><a href="{{route('admin.papar', [$senarai->id])}}"><i class="far fa-eye"></i></a></td>
                                        </tr>
                                        @empty
                                            <tr>
                                                <td colspan="7" class="text-center text-muted">Tiada rekod ditemui</td>
                                            </tr>
                                        @endforelse
                                    </tbody>
                                </table>                   
                            </div>                        
                        </div> <!-- /.col -->                   
                    </div> <!--end::Row-->
                    <div class="mt-3">
                        <div class="d-flex justify-content-between align-items-center flex-wrap">
                            <div class="text-muted small">
                                Paparan {{ $senarais->firstItem() }} - {{ $senarais->lastItem() }} daripada {{ $senarais->total() }} rekod
                            </div>
                            <div>
                                {{ $senarais->links('pagination::bootstrap-5') }}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection

