<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-12">
        <div class="card mb-4">
            <h5 class="card-header"><?php echo e($facility->exists ? 'Edit Fasilitas' : 'Tambah Fasilitas'); ?></h5>
            <div class="card-body">
                <form method="POST" action="<?php echo e($action); ?>" class="row g-3">
                    <?php echo csrf_field(); ?>
                    <?php if($method !== 'POST'): ?>
                        <?php echo method_field($method); ?>
                    <?php endif; ?>

                    <div class="col-md-6">
                        <label class="form-label">Lokasi</label>
                        <select name="location_id" class="form-select" required>
                            <option value="">Pilih lokasi</option>
                            <?php $__currentLoopData = $locations; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $location): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($location->id); ?>" <?php if(old('location_id', $facility->location_id) == $location->id): echo 'selected'; endif; ?>><?php echo e($location->name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>

                    <div class="col-md-6">
                        <label class="form-label">Nama objek</label>
                        <input type="text" name="name" class="form-control" value="<?php echo e(old('name', $facility->name)); ?>" required>
                    </div>

                    <div class="col-md-6">
                        <label class="form-label">Kondisi</label>
                        <select name="current_condition" class="form-select" required>
                            <option value="good" <?php if(old('current_condition', $facility->current_condition) === 'good'): echo 'selected'; endif; ?>>Baik</option>
                            <option value="minor" <?php if(old('current_condition', $facility->current_condition) === 'minor'): echo 'selected'; endif; ?>>Rusak ringan</option>
                            <option value="major" <?php if(old('current_condition', $facility->current_condition) === 'major'): echo 'selected'; endif; ?>>Rusak berat</option>
                            <option value="lost" <?php if(old('current_condition', $facility->current_condition) === 'lost'): echo 'selected'; endif; ?>>Hilang</option>
                        </select>
                    </div>

                    <div class="col-md-6">
                        <label class="form-label">Tanggal pengecekan</label>
                        <input type="date" name="last_checked_at" class="form-control" value="<?php echo e(old('last_checked_at', optional($facility->last_checked_at)->format('Y-m-d'))); ?>">
                    </div>

                    <div class="col-12">
                        <label class="form-label">Catatan</label>
                        <textarea name="notes" class="form-control" rows="4"><?php echo e(old('notes', $facility->notes)); ?></textarea>
                    </div>

                    <div class="col-12">
                        <div class="form-check">
                            <input type="checkbox" name="is_active" class="form-check-input" id="is_active" value="1" <?php if(old('is_active', $facility->is_active ?? true)): echo 'checked'; endif; ?>>
                            <label class="form-check-label" for="is_active">Objek aktif</label>
                        </div>
                    </div>

                    <div class="col-12 text-end mt-4">
                        <a href="<?php echo e(route('facilities.index')); ?>" class="btn btn-label-secondary me-2">Kembali</a>
                        <button type="submit" class="btn btn-primary">Simpan Fasilitas</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', ['title' => 'Form Fasilitas', 'heading' => $facility->exists ? 'Edit Fasilitas' : 'Tambah Fasilitas'], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH G:\Project\inventaris-pondok\resources\views/facilities/form.blade.php ENDPATH**/ ?>