@extends('layouts.main')
@section('breadcrumbs')
    {{ Breadcrumbs::render(request()->route()->getName()) }}
@endsection
@php
    // $route = Route::currentRouteName();
    // dd($route); tender.prosespenawaran.create
    $route = explode('.', Route::currentRouteName());
@endphp

@section('content')
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">

   <div class="card border border-agi-100 pb-2.5">
        <div class="card-header bg-agi-50" id="basic_settings">
            <h3 class="card-title">
                Tambah Data Penawaran
            </h3>
            <div class="flex items-center gap-2">
                <a href="{{ route('tender.prosespenawaran.showPermohonan', $id) }}" class="btn btn-xs btn-primary" title="Detail"><i class="ki-filled ki-abstract-26"></i> Detail</a>
                <a href="{{ route('tender.prosespenawaran.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
            </div>
        </div><!-- $id = permohonan.id -->
        <form action="{{ route('tender.prosespenawaran.storePenawaran', $id) }}" method="POST">
            @csrf
            <div class="card-body grid gap-5">
                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                    <label class="form-label max-w-56">
                        Nomor Registrasi
                    </label>
                    <div class="flex flex-wrap items-baseline w-full">
                        <input class="flex w-full text-gray-600 font-medium text-sm input-custom" type="text"
                            name="nomor_registrasi" readonly value="{{ $permohonan->nomor_registrasi ?? '-' }}">
                    </div>
                </div>
                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                    <label class="form-label max-w-56">
                        Nama KJPP Sebelumnya
                    </label>
                    <div class="flex flex-wrap items-baseline w-full">
                        <input class="flex w-full text-gray-600 font-medium text-sm input-custom" type="text"
                            name="nama_kjpp_sebelumnya" readonly value="">
                    </div>
                </div>
                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                    <label class="form-label max-w-56">
                        Biaya KJPP Sebelumnya
                    </label>
                    <div class="flex flex-wrap items-baseline w-full">
                        <input class="flex w-full text-gray-600 font-medium text-sm input-custom" type="text"
                            name="biaya_kjpp_sebelumnya" readonly value="">
                    </div>
                    <label class="form-label max-w-56">
                        Tanggal Penilaian Sebelumnya
                    </label>
                    <div class="flex flex-wrap items-baseline w-full">
                        <input class="flex w-full text-gray-600 font-medium text-sm input-custom" type="text"
                            name="tanggal_penilaian_sebelumnya" readonly value="">
                    </div>
                </div>
                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                    <label class="form-label max-w-56">
                        Nomor Penawaran
                    </label>
                    <div class="flex flex-wrap items-baseline w-full">
                        -
                    </div>
                </div>
                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                    <label class="form-label max-w-56">
                        Data KJPP
                    </label>
                    <div class="flex flex-wrap items-baseline w-full">
                        <select name="kjpp[]" multiple="multiple"
                            class="input tomselect w-full @error('kjpp') border-danger @enderror" id="kjpp_select">
                            <option value=""> - Pilih KJPP - </option>
                            @foreach ($kjpp as $row)
                                @if (isset($kjpp))
                                    <option value="{{ $row->id }}"
                                        {{ in_array($row->id, old('kjpp', [])) ? 'selected' : '' }}>
                                        {{ $row->name }} | {{ $row->jenis_kantor }}
                                        @if($row->jenis_kantor == 'Kantor Cabang')
                                        {{ str_replace(['KOTA','KAB.','KAB'],'',$row->city->name) }}
                                            @endif
                                    </option>
                                @endif
                            @endforeach
                        </select>
                        @error('kjpp')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                        @enderror
                    </div>
                </div>
                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                    <label class="form-label max-w-56">
                        Tujuan Penilaian KJPP
                    </label>
                    <div class="flex flex-wrap items-baseline w-full">
                        <select id="tujuan_penilaian_kjpp_id"
                            class="select w-full @error('tujuan_penilaian_kjpp_id') border-danger  @enderror"
                            name="tujuan_penilaian_kjpp_id">
                            <option value=""> - Pilih Tujuan Penilaian KJPP - </option>
                            @if (isset($tujuan_penilaian_kjpp))
                                @foreach ($tujuan_penilaian_kjpp as $tp)
                                    <option value="{{ $tp->id }}"
                                        {{ old('tujuan_penilaian_kjpp_id') == $tp->id ? 'selected' : '' }}>
                                        {{ $tp->name }}
                                    </option>
                                @endforeach
                            @endif
                        </select>
                        @error('tujuan_penilaian_kjpp_id')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                        @enderror
                    </div>
                </div>
                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                    <label class="form-label max-w-56">
                        Tanggal Batas Waktu
                    </label>
                    <div class="flex flex-wrap items-baseline w-full">
                        <input class="input  @error('start_date') border-danger  @enderror" type="date"
                            name="start_date" value="{{ old('start_date') }}">
                        @error('start_date')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                        @enderror
                    </div>
                    -
                    <div class="flex flex-wrap items-baseline w-full">
                        <input class="input  @error('end_date') border-danger  @enderror" name="end_date"
                            value="{{ old('end_date') }}" type="date">
                        @error('end_date')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                        @enderror
                    </div>
                </div>
                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                    <label class="form-label max-w-56">
                        Catatan
                    </label>
                    <div class="flex flex-wrap items-baseline w-full">
                        <textarea class="textarea  @error('catatan') border-danger  @enderror" name="catatan" rows="3" id="address">{{ old('catatan') }}</textarea>
                        @error('catatan')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                        @enderror
                    </div>
                </div>
                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
                    <label class="form-label max-w-56">
                        Jenis Laporan
                    </label>
                    <div class="flex flex-wrap items-baseline w-full">
                        <select id="jenis_laporan_id"
                            class="select w-full @error('jenis_laporan_id') border-danger  @enderror"
                            name="jenis_laporan_id">
                            <option value=""> - Pilih Jenis Laporan - </option>
                            @if (isset($jenis_laporan))
                                @foreach ($jenis_laporan as $jl)
                                    <option value="{{ $jl->id }}"
                                        {{ old('jenis_laporan_id') == $jl->id ? 'selected' : '' }}>
                                        {{ $jl->name }}
                                    </option>
                                @endforeach
                            @endif
                        </select>
                        @error('jenis_laporan_id')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                        @enderror
                    </div>
                </div>
                <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 status-custom">
                    <label class="form-label max-w-56">
                        Status
                    </label>
                    <div class="flex flex-wrap items-baseline w-full">
                        <select class="select w-full @error('status') border-danger  @enderror" name="status">
                            <option value="">Pilih Status</option>
                            @if (isset($status))
                                @foreach ($status as $s)
                                    <option value="{{ $s->name }}"
                                        {{ old('status') == $s->name ? 'selected' : '' }}>
                                        {{ $s->name }}
                                    </option>
                                @endforeach
                            @endif
                        </select>
                        @error('status')
                            <em class="alert text-danger text-sm">{{ $message }}</em>
                        @enderror
                    </div>
                </div>
                <div class="flex justify-end gap-1.5">
                    @if (isset($penawaran->nomor_registrasi))
                        <a href="{{ route('tender.penawaran.showSuratTender', $noreg) }}" class="btn btn-primary">
                            Surat Tender
                        </a>
                    @endif
                    <button type="submit" class="btn btn-primary">
                        Save
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
@endsection
@push('styles')
    <style>
        input.input-custom:focus {
            outline: none;
            box-shadow: none;
        }

        @media (prefers-color-scheme: dark) {
            input.input-custom {
                background: none;
                color: var(--tw-gray-600);
            }
        }

        .status-custom {
            display: none
        }
    </style>
@endpush
