@extends('layouts.appmin')

@section('tajuk')
Dashboard
@endsection


@section('content')

    <div class="row">
        <div class="col-md-4">
            <a href="{{route('penjaja-mohon')}}" class="btn btn-primary">Mohon Lesen Penjaja</a>
        </div>
    </div>    
    <div class="row mt-4">
                    @foreach($permohonans as $permohonan)
        <div class="col-sm-12 col-md-6 col-lg-4">
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title">{{$permohonan->lokasi_penjajaan()}}</h5>
                    <h6 class="card-subtitle text-body-secondary">{{$permohonan->syarikat->name}}</h6>
                    <small class="mb-2">({{$permohonan->syarikat->nossm}})</small>
                    <div class="row">
                        <div class="col-sm-12 col-md-12">Jenis Lesen : {{$permohonan->jenis}}</div>
                    </div>
                    <div class="row">
                        <div class="col-sm-12 col-md-12">Status : {{ucwords($permohonan->status_progress)}}</div>
                    </div>
                            
                    @foreach($permohonan->bilpelbagais->where('jenis_bil', 'wang proses')->where('status_mylesen', '1') as $bil)
                    <div class="row">
                        <div class="col-sm-12 col-md-12">No. Bil Wang Proses : {{$bil->no_akaun_bilpelbagai}}</div>
                    </div>
                    <div class="row mb-3 mt-3 mx-5 alert alert-warning">
                        <div class="col-12">
                            <div class="d-flex justify-content-between">
                                <h3 class="text-info fw-bold">RM {{number_format($bil->amaun_bil(), 2, '.', ',')}}</h3>
                                <div>
                                    @if($permohonan->status_progress == 'menunggu bayaran proses') 
                                            <button type="submit" class="btn btn-primary">PBTPay</button> 
                                            <button type="submit" class="btn btn-primary">eKhidmat</button> 
                                    @else
                                        @if($bil->no_resit != '')
                                            <?php echo '<br /><label>No Resit : </label><br />('.$bil->no_resit.')'; ?>
                                        @else 
                                            <?php echo '<br /><label>Bayaran : </label><br />Belum'; ?>
                                        @endif
                                    @endif
                                </div>
                            </div>
                        </div>
                    </div>
                    @endforeach
                    @if($permohonan->status_progress == 'draf') 
                        <a href="{{route('edit_mohon', ['id' => $permohonan->id])}}" class="btn btn-secondary"><i class="fas fa-edit"></i> Edit</a> 
                        <a href="{{route('delete_mohon', ['id' => $permohonan->id])}}" class="btn btn-danger"><i class="fa-regular fa-trash-can"></i> Hapus</a> 
                    @else
                        <a href="{{route('penjaja-mohon-papar', ['id' => $permohonan->id])}}" class="btn btn-secondary"><i class="far fa-eye"></i> Lihat</a> 
                    @endif
                </div>
            </div>
                     
        </div> <!-- /.col --> 
                    @endforeach                 
    </div> <!--end::Row-->
@endsection

@section('js')
    <script src="https://cdn.datatables.net/2.1.8/js/dataTables.js"></script> 
    <script src="https://cdn.datatables.net/2.1.8/js/dataTables.bootstrap5.js"></script> 
<script>
$(document).ready(function () {
    $('#senarai_penggal').DataTable({
        dom: '<"row mb-3"<"col-md-3 col-sm-6"f><"col-md-8 col-sm-2"><"col-md-1 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