<?php $__env->startSection('content'); ?>
<div class="d-flex flex-wrap justify-content-between align-items-center gap-3 mb-4">
    <h1 class="h3 mb-0">Handling Fees Report</h1>
    <form class="row g-2 ajax-filter" method="GET" action="<?php echo e(route('reports.handling-fees')); ?>" data-ajax-target="#report-results">
        <div class="col-auto">
            <input class="form-control" name="date_from" type="date" value="<?php echo e($filters['date_from'] ?? ''); ?>" placeholder="From Date">
        </div>
        <div class="col-auto">
            <input class="form-control" name="date_to" type="date" value="<?php echo e($filters['date_to'] ?? ''); ?>" placeholder="To Date">
        </div>
        <div class="col-auto">
            <select class="form-select" name="agent_id">
                <option value="">All agents</option>
                <?php $__currentLoopData = $agents; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $agent): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($agent->id); ?>" <?php if(($filters['agent_id'] ?? '') == $agent->id): echo 'selected'; endif; ?>>
                        <?php echo e($agent->name); ?>

                    </option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
        </div>
        <div class="col-auto">
            <button class="btn btn-primary" type="submit">Filter</button>
        </div>
        <div class="col-auto">
            <a class="btn btn-outline-success export-link" href="<?php echo e(route('reports.handling-fees', array_merge(request()->except('export'), ['export' => 'xls']))); ?>">Excel</a>
        </div>
    </form>
</div>

<div class="row mb-4">
    <div class="col-md-6">
        <div class="card bg-light">
            <div class="card-body py-3">
                <h6 class="card-subtitle mb-2 text-muted">Total Handling Fees By Currency</h6>
                <?php $__empty_1 = true; $__currentLoopData = $totalFees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $currency => $total): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <div class="d-flex justify-content-between mb-1 border-bottom pb-1">
                        <span class="fw-semibold"><?php echo e($currency); ?></span>
                        <span class="text-success"><?php echo e(number_format($total, 2)); ?></span>
                    </div>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <p class="mb-0 text-muted">No handling fees recorded.</p>
                <?php endif; ?>
            </div>
        </div>
    </div>
</div>

<div id="report-results">
<div class="card">
    <div class="card-body">
        <div class="table-responsive">
            <table class="table table-striped align-middle">
                <thead>
                    <tr>
                        <th>Date</th>
                        <th>Type</th>
                        <th>Currency</th>
                        <th>Agent</th>
                        <th class="text-end">Handling Fee</th>
                        <th>Fee Currency</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 class="text-capitalize"><?php echo e($transaction->type); ?></td>
                            <td><?php echo e($transaction->currency->code); ?></td>
                            <td><?php echo e(optional($transaction->agent)->name ?? '-'); ?></td>
                            <td class="text-end fw-semibold text-success"><?php echo e(number_format((float) $transaction->handling_fee, 4)); ?></td>
                            <td><?php echo e($transaction->fee_currency); ?></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="7">No handling fees 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\currencychangerui\resources\views/reports/handling_fees.blade.php ENDPATH**/ ?>