@extends('layouts.app')

@section('tajuk')
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: 700px;
  width: 100%;
}
</style>
@endsection


@section('breadcrumb')
    <ol class="breadcrumb float-sm-end">
        <li class="breadcrumb-item active"><a href="#">Home</a></li>
    </ol>
@endsection

@section('content')
    @if (session('success'))
        <div class="alert alert-success" role="alert">
            {{ session('success') }}
        </div>
    @endif
<form action="{{route('penjaja-simpan_mohon_upload')}}" method="post" enctype="multipart/form-data">
    @csrf
    <input type="hidden" name="pemohon_id" value="{{$user->id}}">
    <div class="row mt-4">
        <div class="col-lg-6">
            <div class="card card-primary">
                <div class="card-header">
                    <h3 class="card-title">MAKLUMAT PERIBADI PEMOHON</h3>
                </div> <!-- /.card-header -->
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-4">
                            <div class="mb-3">
                                <label for="nokp">No KP</label>
                                <input id="nokp" class="form-control" type="text" name="nokp" value="{{ old('nokp', $user->nokp) }}" readonly autofocus autocomplete="nokp" />
                            </div>
                        </div>
                        <div class="col-md-8">
                            <div class="mb-3">
                                <label for="name" >Nama</label>
                                <input id="name" name="name" type="text" class="form-control" value="{{ old('name', $user->name) }}" readonly autofocus autocomplete="name" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div> <!-- /.col -->  
        <div class="col-lg-6">
            <div class="card card-primary">
                <div class="card-header">
                    <h3 class="card-title">MAKLUMAT PERNIAGAAN ( SSM )</h3>
                </div> <!-- /.card-header -->
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-4">
                            <div class="mb-3">
                                <label for="nossm">No SSM</label>
                                <input id="nossm" name="nossm" type="text"
                                    value="{{ old('nossm', $permohonan?->syarikat->nossm) }}" required autofocus 
                                     class="form-control @error('nossm') is-invalid @enderror">
                                @error('nossm')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror
                            </div>
                        </div>
                        <div class="col-md-8">
                            <div class="mb-3">
                                <label for="nama_perniagaan">Nama Perniagaan</label>
                                <input id="nama_perniagaan" name="nama_perniagaan" type="text"  
                                    value="{{ old('nama_perniagaan', $permohonan?->syarikat->name) }}" required autofocus autocomplete="nama_perniagaan"
                                    class="form-control @error('nama_perniagaan') is-invalid @enderror">
                                    @error('nama_perniagaan')
                                        <div class="invalid-feedback">
                                            {{ $message }}
                                        </div>
                                    @enderror 
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div> <!-- /.col -->                   
    </div> <!--end::Row-->
    <div class="row mt-4">
        <div class="col-lg-6">
            <div class="card card-primary">
                <div class="card-header">
                    <h3 class="card-title">PERMOHONAN LESEN PENJAJA</h3>
                </div> <!-- /.card-header -->
                <div class="card-body">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="jenis_penjaja">Jenis Penjaja</label>
                                <select id="jenis_penjaja" class="form-select @error('jenis_penjaja') is-invalid @enderror" name="jenis_penjaja">
                                    <option value="">Pilih Jenis Penjaja</option>
                                    <option value="sementara" {{ old('jenis_penjaja', $permohonan?->jenis) == 'sementara' ? 'selected' : '' }}>sementara</option>
                                    <option value="buah bermusim" {{ old('jenis_penjaja', $permohonan?->jenis) == 'buah bermusim' ? 'selected' : '' }}>buah bermusim</option>
                                    <option value="foodtruck" {{ old('jenis_penjaja', $permohonan?->jenis) == 'foodtruck' ? 'selected' : '' }}>foodtruck</option>
                                    <option value="car boot sale" {{ old('jenis_penjaja', $permohonan?->jenis) == 'car boot sale' ? 'selected' : '' }}>car boot sale</option>
                                    <option value="lain-lain" {{ old('jenis_penjaja', $permohonan?->jenis) == 'lain-lain' ? 'selected' : '' }}>lain-lain</option>
                                </select>

                            @error('jenis_penjaja')
                                <div class="invalid-feedback">
                                    {{ $message }}
                                </div>
                            @enderror                              
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="jenis_kenderaan">Jenis Kenderaan</label>
                                <select id="jenis_kenderaan" class="form-select @error('jenis_kenderaan') is-invalid @enderror" name="jenis_kenderaan">
                                    <option value=""></option>
                                    <option value="kereta sorong" {{ old('jenis_kenderaan', $permohonan?->jenis_kenderaan) == 'kereta sorong' ? 'selected' : ''}}>kereta sorong</option>
                                    <option value="basikal" {{ old('jenis_kenderaan', $permohonan?->jenis_kenderaan) == 'basikal' ? 'selected' : ''}}>basikal</option>
                                    <option value="motosikal" {{ old('jenis_kenderaan', $permohonan?->jenis_kenderaan) == 'motosikal' ? 'selected' : ''}}>motosikal</option>
                                    <option value="beca / basikal roda tiga" {{ old('jenis_kenderaan', $permohonan?->jenis_kenderaan) == 'beca / basikal roda tiga' ? 'selected' : ''}}>beca / basikal roda tiga</option>
                                    <option value="motosikal roda tiga" {{ old('jenis_kenderaan', $permohonan?->jenis_kenderaan) == 'motosikal roda tiga' ? 'selected' : ''}}>motosikal roda tiga</option>
                                    <option value="kereta / wagon" {{ old('jenis_kenderaan', $permohonan?->jenis_kenderaan) == 'kereta / wagon' ? 'selected' : ''}}>kereta / wagon</option>
                                    <option value="van" {{ old('jenis_kenderaan', $permohonan?->jenis_kenderaan) == 'van' ? 'selected' : ''}}>van</option>
                                    <option value="lori" {{ old('jenis_kenderaan', $permohonan?->jenis_kenderaan) == 'lori' ? 'selected' : ''}}>lori</option>
                                </select>  

                                @error('jenis_kenderaan')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror
                                <small>Penjaja berkenderaan / Foodtruck / Car boot Sale sahaja</small>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="no_pendaftaran">No Pendaftaran Kenderaan</label>
                                <input id="no_pendaftaran" class="form-control @error('no_pendaftaran') is-invalid @enderror" type="text" name="no_pendaftaran" value="{{ old('no_pendaftaran', $permohonan?->no_pendaftaran) }}" autofocus autocomplete="no_pendaftaran">
                                @error('no_pendaftaran')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="status_tanah">Status Tanah</label>
                                <select id="status_tanah" class="form-select @error('status_tanah') is-invalid @enderror" name="status_tanah">
                                    <option value="">Pilih Status Tanah</option>
                                    <option value="hak milik persendirian" {{ old('status_tanah', $permohonan?->status_tanah) == 'hak milik persendirian' ? 'selected' : '' }}>hak milik persendirian</option>                                        
                                    <option value="tanah kerajaan(rezab)" {{ old('status_tanah', $permohonan?->status_tanah) == 'tanah kerajaan(rezab)' ? 'selected' : '' }}>tanah kerajaan(rezab)</option>
                                    <option value="tanah sewa" {{ old('status_tanah', $permohonan?->status_tanah) == 'tanah sewa' ? 'selected' : '' }}>tanah sewa</option>
                                    <option value="tapak parkir" {{ old('status_tanah', $permohonan?->status_tanah) == 'tapak parkir' ? 'selected' : '' }}>tapak parkir</option>
                                    <option value="lain-lain" {{ old('status_tanah', $permohonan?->status_tanah) == 'lain-lain' ? 'selected' : '' }}>lain-lain</option>
                                </select>

                                @error('status_tanah')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror      
                            </div>
                        </div>
                        <div class="col-md-8">
                            <div class="mb-3">
                                <label for="alamat_penjajaan">Alamat Aktiviti Penjajaan</label>
                                <textarea id="alamat_penjajaan" class="form-control @error('alamat_penjajaan') is-invalid @enderror" name="alamat_penjajaan" required autofocus autocomplete="alamat_penjajaan" rows="3" cols="40">{{ old('alamat_penjajaan', $permohonan?->alamat_penjajaan) }}</textarea>
                                
                                @error('alamat_penjajaan')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror      
                            </div>
                        </div>
                        <div class="col-md-4">  
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="mb-3">
                                        <label for="masa_jualan_mula">Masa Mula Jualan</label>
                                        <input id="masa_jualan_mula" class="form-control @error('masa_jualan_mula') is-invalid @enderror" type="time" name="masa_jualan_mula" value="{{ old('masa_jualan_mula', $permohonan?->masa_jualan_mula) }}" autofocus autocomplete="masa_jualan_mula">

                                        @error('masa_jualan_mula')
                                            <div class="invalid-feedback">
                                                {{ $message }}
                                            </div>
                                        @enderror
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="mb-3">
                                        <label for="masa_jualan_tamat">Masa Tamat Jualan</label>
                                        <input id="masa_jualan_tamat" class="form-control @error('masa_jualan_tamat') is-invalid @enderror" type="time" name="masa_jualan_tamat" value="{{ old('masa_jualan_tamat', $permohonan?->masa_jualan_tamat) }}" autofocus autocomplete="masa_jualan_tamat">

                                        @error('masa_jualan_tamat')
                                            <div class="invalid-feedback">
                                                {{ $message }}
                                            </div>
                                        @enderror
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-4">
                            <div class="mb-3">
                                <label for="makanan">Makanan</label>
                                <textarea id="makanan" class="form-control @error('makanan') is-invalid @enderror" name="makanan" autofocus autocomplete="makanan" rows="3" cols="40">{{ old('makanan', $permohonan?->makanan) }}</textarea>
                                
                                @error('makanan')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror   
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="mb-3">
                                <label for="minuman">Minuman</label>
                                <textarea id="minuman" class="form-control @error('minuman') is-invalid @enderror" name="minuman" autofocus autocomplete="minuman" rows="3" cols="40" >{{ old('minuman', $permohonan?->minuman) }}</textarea>
                                
                                @error('minuman')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror   
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="mb-3">
                                <label for="lain">Lain-lain</label>
                                <textarea id="lain" class="form-control @error('lain') is-invalid @enderror" name="lain" autofocus autocomplete="lain" rows="3" cols="40" >{{ old('lain', $permohonan?->lain) }}</textarea>
                                
                                @error('lain')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror   
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div> <!-- /.col -->      
        <div class="col-lg-6">
            <div class="card card-primary">
                <div class="card-header">
                    <h3 class="card-title">DOKUMEN DIPERLUKAN</h3>
                </div> <!-- /.card-header -->
                <div class="card-body">    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="doc_kad_pengenalan">Salinan Kad Pengenalan</label>
                                <input id="doc_kad_pengenalan" class="form-control @error('doc_kad_pengenalan') is-invalid @enderror" type="file" name="doc_kad_pengenalan" value="{{ old('doc_kad_pengenalan') }}" autofocus autocomplete="doc_kad_pengenalan"/>
                                 @error('doc_kad_pengenalan')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror
                            </div>
                        </div>
                        <div class="col-md-6">
                            @if(!is_null($doc_kad_pengenalan))
                                @if ($doc_kad_pengenalan->pivot->jenis_dokumen === 'pdf')
                                    <a href="{{ asset('storage/documents/' . $doc_kad_pengenalan->pivot->path) }}" target="_blank">View PDF</a>
                                @else
                                    <img src="{{ asset('storage/documents/' . $doc_kad_pengenalan->pivot->path) }}" alt="Salinan IC" style="max-width: 100px;">
                                @endif
                            @endif
                        </div>
                        <div class="col-6">
                            <div class="mb-3">
                                <label for="doc_gambar">Gambar Berukuran Passport</label>
                                <input id="doc_gambar" class="form-control @error('doc_gambar') is-invalid @enderror" type="file" name="doc_gambar" value="{{ old('doc_gambar') }}" autofocus autocomplete="doc_gambar"/>
                                @error('doc_gambar')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror
                            </div>
                        </div> 
                        <div class="col-md-6">
                            @if(!is_null($doc_gambar))
                                @if ($doc_gambar->pivot->jenis_dokumen === 'pdf')
                                    <a href="{{ asset('storage/documents/' . $doc_gambar->pivot->path) }}" target="_blank">View PDF</a>
                                @else
                                    <img src="{{ asset('storage/documents/' . $doc_gambar->pivot->path) }}" alt="Gambar Passport" style="max-width: 100px;">
                                @endif
                            @endif
                        </div>
                        <div class="col-6">
                            <div class="mb-3">
                                <label for="doc_lokasi">Gambar Lokasi / Pelan</label>
                                <input id="doc_lokasi" class="form-control @error('doc_lokasi') is-invalid @enderror" type="file" name="doc_lokasi" value="{{ old('doc_lokasi') }}" autofocus autocomplete="doc_lokasi"/>
                                @error('doc_lokasi')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                @enderror
                            </div>
                        </div> 
                        <div class="col-md-6">
                            @if(!is_null($doc_lokasi))
                                @if ($doc_lokasi->pivot->jenis_dokumen === 'pdf')
                                    <a href="{{ asset('storage/documents/' . $doc_lokasi->pivot->path) }}" target="_blank">View PDF</a>
                                @else
                                    <img src="{{ asset('storage/documents/' . $doc_lokasi->pivot->path) }}" alt="Gambar Lokasi" style="max-width: 100px;">
                                @endif
                            @endif
                        </div>
                        <div class="col-6">
                            <div class="mb-3">
                                <label for="doc_kebenaran">Surat kebenaran pemilik tanah / pemegang rezab /perjanjian yang sah</label>
                                <input id="doc_kebenaran" class="form-control" type="file" name="doc_kebenaran" value="{{ old('doc_kebenaran') }}" autofocus autocomplete="doc_kebenaran"/>
                            </div>
                        </div>
                        <div class="col-md-6">
                            @if(!is_null($doc_kebenaran))
                                @if ($doc_kebenaran->pivot->jenis_dokumen === 'pdf')
                                    <a href="{{ asset('storage/documents/' . $doc_kebenaran->pivot->path) }}" target="_blank">View PDF</a>
                                @else
                                    <img src="{{ asset('storage/documents/' . $doc_kebenaran->pivot->path) }}" alt="Surat Kebenaran" style="max-width: 100px;">
                                @endif
                            @endif
                        </div>
                        <div class="col-6">
                            <div class="mb-3">
                                <label for="doc_kenderaan">Gambar Kenderaan</label>
                                <input id="doc_kenderaan" class="form-control" type="file" name="doc_kenderaan" value="{{ old('doc_kenderaan') }}" autofocus autocomplete="doc_kenderaan"/>
                            </div>
                        </div> 
                        <div class="col-md-6">
                            @if(!is_null($doc_kenderaan))
                                @if ($doc_kenderaan->pivot->jenis_dokumen === 'pdf')
                                    <a href="{{ asset('storage/documents/' . $doc_kenderaan->pivot->path) }}" target="_blank">View PDF</a>
                                @else
                                    <img src="{{ asset('storage/documents/' . $doc_kenderaan->pivot->path) }}" alt="Gambar Kenderaan" style="max-width: 100px;">
                                @endif
                            @endif
                        </div>
                        <div class="col-6">
                            <div class="mb-3">
                                <label for="doc_kenderaan_geran">Salinan Geran Kenderaan</label>
                                <input id="doc_kenderaan_geran" class="form-control" type="file" name="doc_kenderaan_geran" value="{{ old('doc_kenderaan_geran') }}" autofocus autocomplete="doc_kenderaan_geran"/>
                            </div>
                        </div> 
                        <div class="col-md-6">
                            @if(!is_null($doc_kenderaan_geran))
                                @if ($doc_kenderaan_geran->pivot->jenis_dokumen === 'pdf')
                                    <a href="{{ asset('storage/documents/' . $doc_kenderaan_geran->pivot->path) }}" target="_blank">View PDF</a>
                                @else
                                    <img src="{{ asset('storage/documents/' . $doc_kenderaan_geran->pivot->path) }}" alt="Gambar Kenderaan" style="max-width: 100px;">
                                @endif
                            @endif
                        </div>
                        <div class="col-6">
                            <div class="mb-3">
                                <label for="doc_suntikan_ty2">Salinan Sijil Suntikan TY2 (Pengendali makanan sahaja)</label>
                                <input id="doc_suntikan_ty2" class="form-control" type="file" name="doc_suntikan_ty2" value="{{ old('doc_suntikan_ty2') }}" autofocus autocomplete="doc_suntikan_ty2"/>
                            </div>
                        </div>
                        <div class="col-md-6">
                            @if(!is_null($doc_suntikan_ty2))
                                @if ($doc_suntikan_ty2->pivot->jenis_dokumen === 'pdf')
                                    <a href="{{ asset('storage/documents/' . $doc_suntikan_ty2->pivot->path) }}" target="_blank">View PDF</a>
                                @else
                                    <img src="{{ asset('storage/documents/' . $doc_suntikan_ty2->pivot->path) }}" alt="Salinan Suntikan" style="max-width: 100px;">
                                @endif
                            @endif
                        </div>
                        <div class="col-6">
                            <div class="mb-3">
                                <label for="doc_kursus_makanan">Salinan Sijil Kursus Pengendalian Makanan</label>
                                <input id="doc_kursus_makanan" class="form-control" type="file" name="doc_kursus_makanan" value="{{ old('doc_kursus_makanan') }}" autofocus autocomplete="doc_kursus_makanan"/>
                            </div>
                        </div> 
                        <div class="col-md-6">
                            @if(!is_null($doc_kursus_makanan))
                                @if ($doc_kursus_makanan->pivot->jenis_dokumen === 'pdf')
                                    <a href="{{ asset('storage/documents/' . $doc_kursus_makanan->pivot->path) }}" target="_blank">View PDF</a>
                                @else
                                    <img src="{{ asset('storage/documents/' . $doc_kursus_makanan->pivot->path) }}" alt="Salinan Sijil Kursus Pengendalian Makanan" style="max-width: 100px;">
                                @endif
                            @endif
                        </div>
                    </div> 
                </div>
            </div>
        </div> <!-- /.col -->               
    </div> <!--end::Row-->
    <div class="row mt-4">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body text-center">
                <input id="hantar" class="btn btn-primary" type="submit" value="Hantar"/>
                </div> <!-- /.card-header -->
            </div> <!-- /.card-header -->
        </div> <!-- /.col -->               
    </div> <!--end::Row-->
</form>
@endsection

@section('js')
  <!-- Select2 -->
    <script src="{{ asset('plugins/select2/js/select2.full.min.js') }}"></script>
    <script type="text/javascript" src="https://js.arcgis.com/4.25/"></script>

@endsection