

<?php $__env->startSection('title', 'Purchase Invoices List'); ?>

<?php $__env->startSection('content'); ?>
<div class="container mt-5">
    <h2 class="mb-4 text-center">Purchase Invoices</h2>
    <a href="<?php echo e(route('purchase-invoice.create')); ?>" class="btn btn-success mb-3">+ New Invoice</a>

    <table class="table table-bordered table-striped">
        <thead class="table-dark">
            <tr>
                <th>ID</th>
                <th>Make</th>
                <th>Model</th>
                <th>Varient</th>
                <th>Registration No</th>
                <th>Purchase Date</th>
                <th>Purchase Price</th>
                <th>Vendor Name</th>
                <th> File upload</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $invoices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $invoice): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <tr>
                <td><?php echo e($invoice->id); ?></td>
                <td><?php echo e($invoice->make); ?></td>
                <td><?php echo e($invoice->model); ?></td>
                <td><?php echo e($invoice->varient); ?></td>
                <td><?php echo e($invoice->registration_no); ?></td>
                <td><?php echo e($invoice->purchase_date); ?></td>
                <td>$<?php echo e(number_format($invoice->purchase_price)); ?></td>
                <td><?php echo e($invoice->vendor_name); ?></td>
                <td>
                    <?php if($invoice->invoice_file_path): ?>
                    <a href="<?php echo e(asset('storage/' . $invoice->invoice_file_path)); ?>" class="btn btn-sm btn-dark" target="_blank">View File</a>

                    <?php endif; ?>
                </td>
                <td>

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

                <?php if($invoice->invoice_file_path): ?>
                    <?php else: ?> N/A <?php endif; ?>
                    <a href="<?php echo e(route('purchase-invoice.edit', $invoice)); ?>" class="btn btn-sm btn-primary">Edit</a>
                    <a href="<?php echo e(route('cars.create', ['invoice' => $invoice->id])); ?>" class="btn btn-sm btn-secondary">Report</a>
                    <a href="<?php echo e(route('purchase-invoice.print', $invoice->id)); ?>" target="_blank" class="btn btn-sm btn-warning">Print</a>
                <?php else: ?>
                <a href="<?php echo e(route('purchase-invoice.edit', $invoice)); ?>" class="btn btn-sm btn-primary">Edit</a>
                    <a href="<?php echo e(route('cars.create', ['invoice' => $invoice->id])); ?>" class="btn btn-sm btn-secondary">Report</a>
                    <a href="<?php echo e(route('purchase-invoice.print', $invoice->id)); ?>" target="_blank" class="btn btn-sm btn-warning">Print</a>
                
                    <!-- <a href="<?php echo e(route('purchase-invoice.report', $invoice->id)); ?>" class="btn btn-sm btn-secondary">Report</a> -->
                    <form action="<?php echo e(route('purchase-invoice.destroy', $invoice)); ?>" method="POST" style="display:inline;">
                        <?php echo csrf_field(); ?>
                        <?php echo method_field('DELETE'); ?>
                        <button type="submit" class="btn btn-sm btn-danger"
                            onclick="return confirm('Are you sure you want to delete this invoice?')">Delete</button>
                    </form>

                <?php endif; ?>
                </td>
            </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <tr>
                <td colspan="9" class="text-center">No invoices found.</td>
            </tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>
<?php $__env->stopSection(); ?>

<?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/purchase_invoice/index.blade.php ENDPATH**/ ?>