@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"/>

    <style>
        #viewDiv {
            padding: 0;
            margin: 0;
            height: 500px;
            width: 100%;
        }

        @if ($show === 'dokumen')
        #preview-container {
            overflow: auto;
            background: #f9f9f9;
            text-align: center;
        }

        #pdf-canvas {
            display: inline-block;
        }
        @endif
    </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="#">Pemeriksaan Tapak</a>
    </li>
    <li class="separator">
        <i class="icon-arrow-right"></i>
    </li>
    <li class="nav-item">
        <a href="#">Papar Permohonan</a>
    </li>
</ul>
@endsection

@section('content')
    <div class="row mb-3">
        <div class="col-md-12">
            <a href="{{route('admin.papar', [$mohon_id])}}" class="btn btn-primary mx-1 my-2">Permohonan</a>
            <a href="{{route('admin.papar-map', [$mohon_id])}}" class="btn btn-primary mx-1 my-2">Peta Lokasi</a>
            <a href="{{route('admin.papar-dokumen', [$mohon_id])}}" class="btn btn-primary mx-1 my-2">Dokumen</a>
            <a href="{{route('admin.papar-wangproses', [$mohon_id])}}" class="btn btn-primary mx-1 my-2">Wang Proses</a>
            
            @if(in_array($permohonan?->status_progress, ['lawatan tapak','ulasan pegawai','ulasan pengarah','sokong dibawa ke mesyuarat','ditangguhkan','keputusan diperolehi']))
            <a href="{{route('admin.papar-pemeriksaan', [$mohon_id])}}" class="btn btn-primary mx-1 my-2">Ulasan 
                @if(in_array($show, ['ulasan ik', 'cadangan pegawai', 'cadangan pengarah']))
                    <i class="fa fa-angle-down" aria-hidden="true"></i>
                @else
                    <i class="fa fa-angle-right" aria-hidden="true"></i>
                @endif
            </a>
            <a href="{{route('admin.papar-lesen', [$mohon_id])}}" class="btn btn-primary mx-1 my-2">Lesen </a>
            @endif
            
        </div>
    </div>
    @if($show == 'utama')
        @include('admin.penjaja.partials.pemohon_ssm')
    @elseif($show == 'lokasi')
        @include('admin.penjaja.partials.lokasi')
    @elseif($show == 'dokumen')
        @include('admin.penjaja.partials.dokumen')
    @elseif($show == 'wang proses')
        @include('admin.penjaja.partials.wangproses_nofail')
    @elseif($show == 'lesen')
        @include('admin.penjaja.partials.daftar_lesen')
    @elseif($show == 'ulasan ik')
        @include('admin.penjaja.partials.ulasan')
    @elseif($show == 'cadangan pegawai')
        @include('admin.penjaja.partials.cadangan_pegawai')
    @elseif($show == 'cadangan pengarah')
        @include('admin.penjaja.partials.ulasan_cadangan_pegawai')
    @endif
@endsection

@section('js')
  <!-- jQuery is required - ensure included once in layout -->
  <script src="{{ asset('plugins/select2/js/select2.full.min.js') }}"></script>

  <!-- Leaflet (keep) -->
  <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"/>
  <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>

  <!-- PDF.js (non-module - use global pdfjsLib) -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.16.105/pdf.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.16.105/pdf.worker.min.js"></script>

  <!-- Global toast placeholder (optional, used by our scripts) -->
  <div class="toast-container position-fixed bottom-0 end-0 p-3">
      <div id="globalToast" class="toast" role="alert" aria-live="assertive" aria-atomic="true">
          <div class="toast-header">
              <strong class="me-auto">Notis</strong>
              <button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
          </div>
          <div class="toast-body">...</div>
      </div>
  </div>

  <!-- Provide minimal config object for JS files -->
  <script>
      window.PermohonanConfig = {
          defaultKawasanId: "{{ $permohonan->kawasan_id ?? '' }}",
          defaultTamanId: "{{ $permohonan->taman_id ?? '' }}",
          defaultJalanId: "{{ $permohonan->jalan_id ?? '' }}",
          defaultPenempatanId: "{{ $permohonan->penempatan_id ?? '' }}",
          latitude: "{{ $permohonan?->latitude ?? '' }}",
          longitude: "{{ $permohonan?->longitude ?? '' }}"
      };
  </script>

  <!-- Our compiled/clean JS files -->
  <script src="{{ asset('js/papar_permohonan.js') }}"></script>
  <script src="{{ asset('js/papar_dokumen.js') }}"></script>
@endsection
