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

<?php $__env->startSection('content'); ?>
<div class="d-flex justify-content-between align-items-center mb-4">
    <h2 class="fw-bold">Sales Report</h2>
</div>

<div class="card mb-4">
    <div class="card-body">
        <form action="<?php echo e(route('reports.sales')); ?>" method="GET" class="row align-items-end">
            <div class="col-md-4">
                <label class="form-label">From Date</label>
                <input type="date" name="from_date" class="form-control" value="<?php echo e($fromDate); ?>" required>
            </div>
            <div class="col-md-4">
                <label class="form-label">To Date</label>
                <input type="date" name="to_date" class="form-control" value="<?php echo e($toDate); ?>" required>
            </div>
            <div class="col-md-4">
                <button type="submit" class="btn btn-primary"><i class="fas fa-filter"></i> Filter</button>
                <a href="<?php echo e(route('reports.sales')); ?>" class="btn btn-secondary">Reset</a>
            </div>
        </form>
    </div>
</div>

<div class="card-table-wrapper">
    <div class="table-responsive">
        <table id="salesTable" class="table">
            <thead>
                <tr>
                    <th>Invoice No</th>
                    <th>Date</th>
                    <th>Customer Name</th>
                    <th class="text-end">Amount (₹)</th>
                </tr>
            </thead>
            <tbody>
                <?php $__currentLoopData = $invoices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $invoice): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td><span class="badge bg-primary bg-opacity-10 text-primary px-2 py-1"><?php echo e($invoice->invoice_no); ?></span></td>
                    <td><?php echo e($invoice->invoice_date->format('d/m/Y')); ?></td>
                    <td class="fw-bold text-dark"><?php echo e($invoice->customer->customer_name); ?></td>
                    <td class="text-end fw-bold text-success"><?php echo e(number_format($invoice->grand_total, 2)); ?></td>
                </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
            <tfoot>
                <tr class="fw-bold bg-light border-top">
                    <td colspan="3" class="text-end py-3">Total Sales:</td>
                    <td class="text-end text-primary fs-5 py-3">₹<?php echo e(number_format($totalSales, 2)); ?></td>
                </tr>
            </tfoot>
        </table>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<style>
    /* DataTables Buttons Customization */
    .dt-buttons .btn {
        background: #10B981;
        color: white;
        border: none;
        border-radius: 8px;
        font-weight: 600;
        padding: 6px 16px;
        margin-left: 10px;
        transition: all 0.2s ease;
    }
    .dt-buttons .btn:hover {
        background: #059669;
        transform: translateY(-1px);
        box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
    }
</style>
<script>
$(document).ready(function() {
    $('#salesTable').DataTable({
        "order": [[ 1, "asc" ]],
        "dom": "<'row mb-3'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6 d-flex justify-content-md-end justify-content-center'fB>>" +
               "<'row'<'col-sm-12'tr>>" +
               "<'row mt-3'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
        "buttons": [
            {
                extend: 'excelHtml5',
                text: '<i class="fas fa-file-excel me-1"></i> Export to Excel',
                className: 'btn btn-success btn-sm',
                title: 'Riyasri Silks - Sales Report',
                footer: true
            }
        ]
    });
});
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH E:\xampp\htdocs\riya\billing\resources\views/reports/sales.blade.php ENDPATH**/ ?>