<?php $__env->startSection('content'); ?>
<h1 class="h3 mb-4">Account Report</h1>

<form class="row g-2 mb-4 ajax-filter" method="GET" action="<?php echo e(route('reports.accounts')); ?>" data-ajax-target="#report-results">
    <div class="col-md-3">
        <input class="form-control" name="date" type="date" value="<?php echo e($filters['date'] ?? ''); ?>">
    </div>
    <div class="col-md-3">
        <select class="form-select" name="currency_id">
            <option value="">All currencies</option>
            <?php $__currentLoopData = $currencies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $currency): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($currency->id); ?>" <?php if(($filters['currency_id'] ?? '') == $currency->id): echo 'selected'; endif; ?>><?php echo e($currency->code); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
    </div>
    <div class="col-md-3">
        <select class="form-select" name="account_id">
            <option value="">All accounts</option>
            <?php $__currentLoopData = $accounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $account): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($account->id); ?>" <?php if(($filters['account_id'] ?? '') == $account->id): echo 'selected'; endif; ?>><?php echo e($account->name); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
    </div>
    <div class="col-md-3 d-flex gap-2">
        <button class="btn btn-primary" type="submit">Filter</button>
        <a class="btn btn-outline-success export-link" href="<?php echo e(route('reports.accounts', array_merge(request()->except('export'), ['export' => 'xls']))); ?>">Excel</a>
    </div>
</form>

<div id="report-results">
<div class="card mb-4">
    <div class="card-body">
        <h2 class="h4 mb-3">All Balances</h2>
        <div class="table-responsive">
            <table class="table table-striped align-middle">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Currency</th>
                        <th>Type</th>
                        <th class="text-end">Current Balance</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $accounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $account): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td class="fw-semibold"><?php echo e($account->name); ?></td>
                            <td><?php echo e($account->currency->code); ?></td>
                            <td class="text-capitalize"><?php echo e($account->type); ?></td>
                            <td class="text-end"><?php echo e(number_format((float) $account->balance, 4)); ?> <?php echo e($account->currency->code); ?></td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td class="text-muted text-center" colspan="4">No accounts found.</td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="card">
    <div class="card-body">
        <h2 class="h4 mb-3">Transaction History</h2>
        <div class="table-responsive">
            <table class="table table-striped align-middle">
                <thead>
                    <tr>
                        <th>Date</th>
                        <th>Account</th>
                        <th>Type</th>
                        <th>Currency</th>
                        <th class="text-end">Transaction Amount</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $transaction): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($transaction->created_at->format('Y-m-d H:i')); ?></td>
                            <td><?php echo e($transaction->account->name); ?></td>
                            <td class="text-capitalize"><?php echo e($transaction->type); ?></td>
                            <td><?php echo e($transaction->currency->code); ?></td>
                            <td class="text-end"><?php echo e(number_format((float) $transaction->amount_lkr, 4)); ?> <?php echo e($transaction->account->currency->code); ?></td>
                            <td class="text-end"><a class="btn btn-outline-primary btn-sm" href="<?php echo e(route('reports.transactions.show', $transaction)); ?>">Details</a></td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td class="text-muted text-center" colspan="6">No transactions found.</td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH F:\christopher\currencychanger\resources\views/reports/accounts.blade.php ENDPATH**/ ?>