

<?php $__env->startSection('content'); ?>
    <div class="row">
        <div class="col-12">
            <div class="card me-2">
                <div class="card-header d-flex justify-content-between">
                    <div>
                        <h4>Expense Report</h4>
                    </div>
                    <div class="d-flex justify-content-end align-items-center mb-3 px-3">
                        <form method="GET" action="<?php echo e(route('expense-report')); ?>" class="d-flex align-items-center">
                            <div class="form-group me-3">
                                <input type="date" class="form-control <?php $__errorArgs = ['start_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                    id="start_date" name="start_date"
                                    value="<?php echo e(old('start_date', request()->get('start_date'))); ?>">

                                <!-- Display error message for start_date -->
                                <?php $__errorArgs = ['start_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <div class="invalid-feedback">
                                        <?php echo e($message); ?>

                                    </div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>

                            <div class="form-group me-3">
                                <input type="date" class="form-control <?php $__errorArgs = ['end_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                    id="end_date" name="end_date" value="<?php echo e(old('end_date', request()->get('end_date'))); ?>">

                                <!-- Display error message for end_date -->
                                <?php $__errorArgs = ['end_date'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                    <div class="invalid-feedback">
                                        <?php echo e($message); ?>

                                    </div>
                                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                            </div>
                            <div class="form-group me-2">
                                <select name="category" id="category" class="form-select">
                                    <option value="">Select Category</option>
                                    <?php $__currentLoopData = $category; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $id => $category_name): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($id); ?>" <?php echo e(old('category') == $id ? 'selected' : ''); ?>>
                                            <?php echo e($category_name); ?>

                                        </option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <button type="submit" class="btn btn-primary">Filter</button>
                        </form>
                    </div>
                </div>
                <div class="card-body">

                    <div class="table-responsive">
                        <table class="table text-sm" id="myTable2">
                            <thead>
                                <tr>
                                    <th class="text-center">#</th>
                                    <th class="text-center">Branch Name</th>
                                    <th class="text-center">Expense Category</th>
                                    <th class="text-center">Expense Name</th>
                                    <th class="text-center">Expense Amount</th>
                                    <th class="text-center">Expense Date</th>
                                    <th class="text-center">Created By</th>
                                    <th class="text-center">Updated By</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $expense; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td class="text-center"><?php echo e($loop->iteration); ?></td>
                                        <td class="text-center"><?php echo e($item->branch->name ?? ''); ?></td>
                                        <td class="text-center"><?php echo e($item->category->category_name ?? ''); ?></td>
                                        <td class="text-center"><?php echo e($item->expense_name ?? ''); ?></td>
                                        <td class="text-center"><?php echo e($item->expense_amount ?? ''); ?></td>
                                        <td class="text-center"><?php echo e($item->expense_date ?? ''); ?></td>
                                        <td class="text-center"><?php echo e($item->createdBy->name ?? ''); ?></td>
                                        <td class="text-center"><?php echo e($item->updatedBy->name ?? ''); ?></td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                            <tfoot>
                                <tr>
                                    <th colspan="4" class="text-end">Page Total:</th>
                                    <th id="page-total-selling" class="text-center">₹ 0.00</th>
                                    <th colspan="3"></th>
                                </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('scripts'); ?>

    <script>
        var table = $('#myTable2').DataTable({
            layout: {
                topStart: {
                    buttons: ['excel', 'pdf', 'print', 'colvis', 'pageLength']
                },
            }
        });
        function updatePageTotals() {
            var expenseTotal = 0;

            var rows = table.rows({ page: 'current' }).nodes();

            $(rows).each(function () {
                var expensePrice = parseFloat($(this).find('td:eq(4)').text().replace(/[^\d.-]/g, '')) || 0;

                expenseTotal += expensePrice;
            });

            $('#page-total-selling').html('₹ ' + Math.floor(expenseTotal).toFixed(2));

        }
        table.on('draw', function () {
            updatePageTotals();
        });

        table.on('page', function () {
            updatePageTotals();
        });

        updatePageTotals();
    </script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('layouts.layoutapp', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /opt/lampp/htdocs/lara_commonbilling_new/resources/views/reports/expenseReport.blade.php ENDPATH**/ ?>