<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>

<div class="container-fluid">
    <div class="card">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h5 class="mb-0">Reports</h5>
            <div>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('reports.export')): ?>
                    <button id="export-revenue" class="btn btn-primary btn-sm">Export Revenue CSV</button>
                <?php endif; ?>
            </div>
        </div>
        <div class="card-body">
            <div class="row mb-3">
                <div class="col-md-3">
                    <input type="date" id="from" class="form-control" placeholder="From" />
                </div>
                <div class="col-md-3">
                    <input type="date" id="to" class="form-control" placeholder="To" />
                </div>
                <div class="col-md-3">
                    <button id="filter" class="btn btn-secondary">Filter</button>
                </div>
            </div>

            <table id="reports-revenue-table" class="table table-striped table-bordered" style="width:100%">
                <thead>
                    <tr>
                        <th>Month</th>
                        <th>Total</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script>
$(function() {
    var table = $('#reports-revenue-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: {
            url: '<?php echo e(route("admin.reports.revenue.data")); ?>',
            data: function(d) {
                d.from = $('#from').val();
                d.to = $('#to').val();
            }
        },
        columns: [
            { data: 'month', name: 'month' },
            { data: 'total', name: 'total' },
        ]
    });

    $('#filter').on('click', function() { table.ajax.reload(); });

    $('#export-revenue').on('click', function() {
        var from = $('#from').val();
        var to = $('#to').val();
        $.ajax({
            url: '<?php echo e(route("admin.reports.revenue.export")); ?>',
            method: 'POST',
            data: { from: from, to: to },
            headers: { 'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>' },
            success: function(res) {
                alert(res.message);
            },
            error: function() { alert('Export failed'); }
        });
    });
});
</script>
<?php $__env->stopPush(); ?>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH D:\herd\billing\laravel-app\resources\views\admin\reports.blade.php ENDPATH**/ ?>