<?php $__env->startSection('title', 'Dashboard'); ?>

<?php $__env->startSection('content'); ?>
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">

<div class="table-responsive">

        

        <?php if(session('success')): ?>
            <div class="alert alert-success alert-dismissible fade show" role="alert">
                <?php echo e(session('success')); ?>

                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>

        <?php endif; ?>

        <?php if(session('error')): ?>
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                <?php echo e(session('error')); ?>

                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
        <?php endif; ?>

        <?php if($errors->any()): ?>
            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                <ul class="mb-0">
                    <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <li><?php echo e($error); ?></li>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </ul>
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
        <?php endif; ?>

        <!-- <div class="text-center mb-1"> -->
            <!-- <h1 class="display-8 fw-bold text-uppercase text-danger" style="letter-spacing: 2px;">
                Khan Motor's 
            </h1> -->
            <!-- <hr class="w-25 mx-auto border-5 border-danger"> -->
        </div>
        <div class="container py-0">
    <h2 class="mb-1 text-center">All Reports</h2>
    <div class="mb-3 d-flex justify-content-end">
        <div class="input-group" style="width: 30%;">
            <span class="input-group-text bg-white">
                <i class="bi bi-search"></i>
            </span>
            <input type="text" id="tableSearch" class="form-control" placeholder="Search in table...">
        </div>
    </div>
    <div class="card">
        <div class="card-body">
            <table class="table table-hover table-bordered">
                <thead class="table-dark">
            <tr>
                <th>#</th>
                <th>Report No</th>
                <th>Make</th>
                <th>Model</th>
                <th>Varient</th>
                <th>Color</th>
                <th>Registered City</th>
                <th>Transmission Type</th>
                <th>Registration No</th>
                <th>Engine</th>
                <th>Mileage</th>
                <th>Fuel Type</th>
                <th>Inspection Date</th>
                <th>Chassis No</th>
                <th>Engine No</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            <?php $__currentLoopData = $cars; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $car): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            
            <?php if(!in_array($car->status, [2])): ?>
            <tr data-car-id="<?php echo e($car->id); ?>">

            <?php else: ?>
            <tr data-car-id="<?php echo e($car->id); ?>" class="table-success">

            <?php endif; ?>

                <td><?php echo e($loop->iteration); ?></td>
                    <td >KM-<?php echo e(\Carbon\Carbon::parse($car->inspection_date)->format('Y')); ?>-<?php echo e($car->id); ?></td>
                    <td><?php echo e($car->make); ?></td>
                    <td><?php echo e($car->model); ?></td>
                    <td><?php echo e($car->varient); ?></td>
                    <td><?php echo e($car->color); ?></td>
                    <td><?php echo e($car->registered_city); ?></td>
                    <td><?php echo e($car->transmission); ?></td>
                    <td><?php echo e($car->registration_no); ?></td>
                    <td><?php echo e($car->engine_capacity); ?></td>
                    <td><?php echo e($car->mileage); ?></td>
                    <td><?php echo e($car->fuel_type); ?></td>
                    <td><?php echo e(\Carbon\Carbon::parse($car->inspection_date)->format('d/m/Y')); ?></td>
                    <td><?php echo e($car->chassis_no); ?></td>
                    <td><?php echo e($car->engine_no); ?></td>
                    <td class="action-buttons">
                        <a href="<?php echo e(route('cars.print', $car->id)); ?>" class="btn btn-info" target="_blank"><i class="bi bi-printer"></i></a>
                        <a href="<?php echo e(route('cars.show', $car->id)); ?>" class="btn btn-warning"><i class="bi bi-eye"></i></a>

                        <a href="<?php echo e(route('cars.edit', $car->id)); ?>" class="btn btn btn-success"><i class="bi bi-pencil"></i></a>
                        <br>

                        <?php if(auth()->user()->is_admin == 0): ?>

                        <?php else: ?>
                        <form action="<?php echo e(route('cars.destroy', $car->id)); ?>" method="POST" style="display:inline;">
                            <?php echo csrf_field(); ?>
                            <?php echo method_field('DELETE'); ?>
                            <button type="submit" class="btn btn btn-danger" onclick="return confirm('Are you sure you want to delete this car?')"><i class="bi bi-Trash"></i></button>
                        </form>
                        <?php endif; ?>

                        <!-- <a href="<?php echo e(route('cars.sell', $car->id)); ?>" class="btn btn-primary btn-sm">Sell</a> -->

                        <?php if(!in_array($car->status, [2])): ?>

                        <?php else: ?>
                            <form action="<?php echo e(route('cars.renew', $car->id)); ?>" method="POST" style="display:inline;">
                                <?php echo csrf_field(); ?>
                                <button type="submit" class="btn btn-secondary" onclick="return confirm('Are you sure you want to renew this car?')">
                                    <i class="bi bi-arrow-clockwise"></i>
                                </button>
                            </form>                        
                        <?php endif; ?>



                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </tbody>

    </table>
</div>

<style>
    .action-buttons {
        white-space: nowrap;
        line-height: 35px;
        }

    thead th {
        vertical-align: top !important;
    }
    
</style>

<script>
function printForm(carId) {
    window.open(`/cars/${carId}/print`, '_blank');
}
</script>
<?php $__env->stopSection(); ?>
<script>
function printForm(carId) {
    window.open(`/cars/${carId}/print`, '_blank');
}

document.addEventListener('DOMContentLoaded', function () {
    const searchInput = document.getElementById('tableSearch');
    const tableRows = document.querySelectorAll('table tbody tr');

    searchInput.addEventListener('keyup', function () {
        const query = this.value.toLowerCase();

        tableRows.forEach(function (row) {
            const rowText = row.textContent.toLowerCase();
            row.style.display = rowText.includes(query) ? '' : 'none';
        });
    });
});
</script>










<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Applications/XAMPP/xamppfiles/htdocs/laravel-app12/resources/views/cars/index2.blade.php ENDPATH**/ ?>