<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-12 mb-4">
        <div class="card">
            <div class="card-header border-bottom">
                <h5 class="mb-0">Filter Histori</h5>
            </div>
            <div class="card-body mt-3">
                <form method="GET" class="row g-3">
                    <div class="col-md-5">
                        <label class="form-label">Kondisi</label>
                        <select name="condition" class="form-select">
                            <option value="">Semua</option>
                            <option value="good" <?php if(request('condition') === 'good'): echo 'selected'; endif; ?>>Baik</option>
                            <option value="minor" <?php if(request('condition') === 'minor'): echo 'selected'; endif; ?>>Rusak ringan</option>
                            <option value="major" <?php if(request('condition') === 'major'): echo 'selected'; endif; ?>>Rusak berat</option>
                            <option value="lost" <?php if(request('condition') === 'lost'): echo 'selected'; endif; ?>>Hilang</option>
                        </select>
                    </div>
                    <div class="col-md-5">
                        <label class="form-label">Sumber</label>
                        <select name="source" class="form-select">
                            <option value="">Semua</option>
                            <option value="public_qr" <?php if(request('source') === 'public_qr'): echo 'selected'; endif; ?>>QR Publik</option>
                            <option value="admin" <?php if(request('source') === 'admin'): echo 'selected'; endif; ?>>Admin</option>
                        </select>
                    </div>
                    <div class="col-md-2 d-flex align-items-end">
                        <button class="btn btn-label-secondary w-100" type="submit">Filter</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="col-12">
        <div class="card">
            <div class="card-datatable table-responsive pt-0">
                <table class="datatables-basic table">
                    <thead>
                        <tr>
                            <th>Objek</th>
                            <th>Petugas</th>
                            <th>Tanggal</th>
                            <th>Kondisi</th>
                            <th>Sumber</th>
                            <th>Foto</th>
                            <th>Catatan</th>
                            <th>Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $logs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $log): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td><strong><?php echo e($log->maintainable?->name ?? 'Objek terhapus'); ?></strong></td>
                                <td><?php echo e($log->submitter_name); ?></td>
                                <td><?php echo e($log->performed_at?->translatedFormat('l, d F Y H:i')); ?></td>
                                <td>
                                    <?php if($log->condition === 'good'): ?>
                                        <span class="badge bg-label-success">BAIK</span>
                                    <?php elseif($log->condition === 'minor'): ?>
                                        <span class="badge bg-label-warning">RUSAK RINGAN</span>
                                    <?php else: ?>
                                        <span class="badge bg-label-danger">RUSAK BERAT</span>
                                    <?php endif; ?>
                                </td>
                                <td><span class="badge bg-label-secondary"><?php echo e($log->source); ?></span></td>
                                <td>
                                    <?php if($log->photo_path): ?>
                                        <a href="<?php echo e(\Illuminate\Support\Facades\Storage::url($log->photo_path)); ?>" class="btn btn-sm btn-icon btn-text-primary rounded-pill" target="_blank"><i class="ti tabler-photo"></i></a>
                                    <?php else: ?>
                                        -
                                    <?php endif; ?>
                                </td>
                                <td><?php echo e($log->notes ?: '-'); ?></td>
                                <td>
                                    <div class="d-flex align-items-center gap-1">
                                        <a href="<?php echo e(route('maintenance.show', $log->id)); ?>" class="btn btn-sm btn-icon btn-label-info rounded-pill" title="Detail">
                                            <i class="ti tabler-eye"></i>
                                        </a>
                                        <a href="<?php echo e(route('maintenance.edit', $log->id)); ?>" class="btn btn-sm btn-icon btn-label-warning rounded-pill" title="Edit">
                                            <i class="ti tabler-edit"></i>
                                        </a>
                                        <form action="<?php echo e(route('maintenance.destroy', $log->id)); ?>" method="POST">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                            <button type="button" class="btn btn-sm btn-icon btn-label-danger rounded-pill confirm-delete" title="Hapus">
                                                <i class="ti tabler-trash"></i>
                                            </button>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
            <div class="card-footer d-flex justify-content-center">
                <?php echo e($logs->links()); ?>

            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script type="module">
    $(function() {
        var dt_basic_table = $('.datatables-basic');
        if (dt_basic_table.length) {
            let tableTitle = document.createElement('h5');
            tableTitle.classList.add('card-title', 'mb-0', 'text-md-start', 'text-center', 'pb-md-0', 'pb-6');
            tableTitle.innerHTML = 'Tabel Histori Maintenance';

            dt_basic_table.DataTable({
                displayLength: 10,
                lengthMenu: [7, 10, 25, 50, 75, 100],
                language: {
                    search: "Cari:",
                    lengthMenu: "Tampil _MENU_ data",
                    info: "Menampilkan _START_ sampai _END_ dari _TOTAL_ data",
                    paginate: {
                        next: '<i class="icon-base ti tabler-chevron-right scaleX-n1-rtl icon-18px"></i>',
                        previous: '<i class="icon-base ti tabler-chevron-left scaleX-n1-rtl icon-18px"></i>',
                        first: '<i class="icon-base ti tabler-chevrons-left scaleX-n1-rtl icon-18px"></i>',
                        last: '<i class="icon-base ti tabler-chevrons-right scaleX-n1-rtl icon-18px"></i>'
                    }
                },
                layout: {
                    top2Start: {
                        rowClass: 'row card-header flex-column flex-md-row border-bottom mx-0 px-3',
                        features: [tableTitle]
                    },
                    top2End: {
                        features: [
                            {
                                buttons: [
                                    {
                                        extend: 'collection',
                                        className: 'btn btn-label-primary dropdown-toggle me-2 waves-effect waves-light',
                                        text: '<span class="d-flex align-items-center gap-2"><i class="icon-base ti tabler-upload icon-xs me-sm-1"></i> <span class="d-none d-sm-inline-block">Export</span></span>',
                                        buttons: [
                                            { extend: 'print', text: '<span class="d-flex align-items-center"><i class="icon-base ti tabler-printer me-1"></i>Print</span>', className: 'dropdown-item' },
                                            { extend: 'csv', text: '<span class="d-flex align-items-center"><i class="icon-base ti tabler-file-text me-1"></i>Csv</span>', className: 'dropdown-item' },
                                            { extend: 'excel', text: '<span class="d-flex align-items-center"><i class="icon-base ti tabler-file-spreadsheet me-1"></i>Excel</span>', className: 'dropdown-item' },
                                            { extend: 'pdf', text: '<span class="d-flex align-items-center"><i class="icon-base ti tabler-file-description me-1"></i>Pdf</span>', className: 'dropdown-item' },
                                            { extend: 'copy', text: '<i class="icon-base ti tabler-copy me-1"></i>Copy', className: 'dropdown-item' }
                                        ]
                                    }
                                ]
                            }
                        ]
                    },
                    topStart: {
                        rowClass: 'row mx-0 px-3 my-0 justify-content-between border-bottom',
                        features: [
                            {
                                pageLength: {
                                    menu: [10, 25, 50, 100],
                                    text: 'Show_MENU_entries'
                                }
                            }
                        ]
                    },
                    topEnd: {
                        search: {
                            placeholder: ''
                        }
                    },
                    bottomStart: {
                        rowClass: 'row mx-3 justify-content-between',
                        features: ['info']
                    },
                    bottomEnd: 'paging'
                }
            });
        }
    });
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', ['title' => 'Histori Maintenance', 'heading' => 'Histori Maintenance'], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH G:\Project\inventaris-pondok\resources\views/maintenance/index.blade.php ENDPATH**/ ?>