{{-- @extends('layouts.layouts_index.main') --}}
@extends('layouts.layouts_index.layoutv6')

@section('title', 'EndoINDEX')
@section('style')
    <style>
        .table-w tr td:nth-child(1) {
            width: 20%;
        }

        .table-w tr td:nth-child(2) {
            width: 15%;
        }

        .table-w tr td:nth-child(3) {
            width: 20%;
        }

        .table-w tr td:nth-child(4) {
            width: 15%;
        }

        .table-w tr td:nth-child(5) {
            width: 10%;
        }

        .table-w tr td:nth-child(6) {
            width: 10%;
        }

        ::-webkit-scrollbar {
            width: 3px !important;
            height: 3px !important;
        }

        ::-webkit-scrollbar-track {
            background: #f1f1f1 !important;
        }

        ::-webkit-scrollbar-thumb {
            background: #888 !important;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: #555 !important;
        }
    </style>


@endsection

@section('content')


    <div class="card">
        <div class="card-header">
            <h4 class="card-title mb-0">เพิ่มโรงพยาบาลสำหรับ Screening</h4>
        </div>

        <form action="{{ url('admin/hospitalscreening') }}" method="post" enctype="multipart/form-data">
            @csrf
            <input type="hidden" name="event" value="screening_edit">
            <input type="hidden" name="hospital_id" value="{{@$hospital['_id']}}">

            <input type="hidden" name="user_id" value="{{@$user['email']}}">
            <div class="row cn p-3">
                <div class="col-auto">
                    <label for="basiInput" class="form-label">Hospital Code <span style="color: red">*</span></label>
                </div>
                <div class="col-2">
                    <input type="text" class="form-control bg-light" id="username" name="username"
                        placeholder="ใช้สำหรับล็อคอิน" required value="{{$user['user_email']}}" readonly>
                </div>
                <div class="col-auto">
                    <label for="basiInput" class="form-label">Password <span style="color: red">*</span></label>
                </div>
                <div class="col-2">
                    <input type="password" class="form-control bg-light" id="password" name="password"
                        placeholder="พาสเวริดใช้สำหรับล็อคอิน" required value="{{$user['password']}}">
                </div>
                <div class="col-3">

                    <select type="text" name="hospital_province_code" class="form-select bg-light" id="hospital_province"
                        placeholder="จังหวัด" required>
                        <option value="">กรุณาเลือกจังหวัด</option>
                        @foreach ($provinces as $code => $name)
                            <option value="{{ $code }}" data-name="{{ $name }}" {{ @$hospital['department_province_code'] == $code ? 'selected' : '' }}>{{ $name }}</option>
                        @endforeach
                    </select>
                    <input type="hidden" name="hospital_province_name" id="hospital_province_name" value="{{@$user['province_name']}}">
                </div>
                <div class="col-auto">
                    <label for="basiInput" class="form-label">จำนวน station</label>
                </div>
                <div class="col-2">

                    <input type="number" class="form-control bg-light" name="station_num" value="{{count(@$hospital['department_room'])}}">
                </div>
            </div>
            <div class="row cn p-3">
                <div class="col-auto">
                    <label for="basiInput" class="form-label">Hospital Name <span style="color: red">*</span></label>
                </div>
                <div class="col-2">
                    <input type="text" class="form-control bg-light" id="hospital_name" name="hospital_name" required value="{{$hospital['department_name']}}">
                </div>
                <div class="col-auto">
                    <label for="basiInput" class="form-label">Hospital Address<span style="color: red">*</span></label>
                </div>
                <div class="col-6">
                    <input type="text" class="form-control bg-light" id="hospital_address" name="hospital_address"
                        required value="{{$hospital['department_address']}}">
                </div>
            </div>
            <div class="row cn p-3">
                <div class="col-auto">
                    <label for="basiInput" class="form-label">Hospital Logo<span style="color: red">*</span></label>
                </div>
                <div class="col-4">

                    <input type="file" class="form-control bg-light"
                    id="hospital_logo" name="hospital_logo"
                    accept="image/png, image/gif, image/jpeg" >
                </div>
                <div class="mb-2 ">

                    <img src="{{@$hospital_logo}}" alt="Hospital Logo" style="max-width: 200px">

                </div>
            </div>
            <div class="col-12 p-3 text-end">
                    <a href="{{url('admin/hospitalscreening')}}" class="btn btn-secondary">Back</a>
                    <button class="btn btn-primary">Save</button>

            </div>
        </form>
    </div>

@endsection

@section('script')
<script>
    $('#hospital_province').change(function() {
        $('#hospital_province_name').val($(this).find('option:selected').data('name'));
    });
</script>
@endsection
