<?php $__env->startSection('title', 'Raporlar'); ?>
<?php $__env->startSection('content'); ?>
<form method="GET" class="bg-white rounded shadow p-4 mb-6 flex flex-wrap gap-2 items-end">
    <div>
        <label class="block text-xs text-slate-500 mb-1">Başlangıç</label>
        <input type="date" name="date_from" value="<?php echo e($filters['date_from'] ?? ''); ?>" class="border rounded px-3 py-1.5 text-sm">
    </div>
    <div>
        <label class="block text-xs text-slate-500 mb-1">Bitiş</label>
        <input type="date" name="date_to" value="<?php echo e($filters['date_to'] ?? ''); ?>" class="border rounded px-3 py-1.5 text-sm">
    </div>
    <div>
        <label class="block text-xs text-slate-500 mb-1">Bayi</label>
        <select name="dealer_id" class="border rounded px-3 py-1.5 text-sm">
            <option value="">Tümü</option>
            <?php $__currentLoopData = $dealers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($d->id); ?>" <?php if(($filters['dealer_id'] ?? null)==$d->id): echo 'selected'; endif; ?>><?php echo e($d->company_name); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
    </div>
    <div>
        <label class="block text-xs text-slate-500 mb-1">Firma</label>
        <select name="company_id" class="border rounded px-3 py-1.5 text-sm">
            <option value="">Tümü</option>
            <?php $__currentLoopData = $companies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($c->id); ?>" <?php if(($filters['company_id'] ?? null)==$c->id): echo 'selected'; endif; ?>><?php echo e($c->name); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
    </div>
    <button class="bg-slate-800 text-white rounded px-4 py-1.5 text-sm">Filtrele</button>
    <a href="<?php echo e(route('panel.reports.export.excel', request()->query())); ?>" class="bg-green-600 text-white rounded px-4 py-1.5 text-sm">Excel</a>
    <a href="<?php echo e(route('panel.reports.export.csv', request()->query())); ?>" class="bg-emerald-600 text-white rounded px-4 py-1.5 text-sm">CSV</a>
    <a href="<?php echo e(route('panel.reports.export.pdf', request()->query())); ?>" class="bg-red-600 text-white rounded px-4 py-1.5 text-sm">PDF</a>
</form>

<div class="grid md:grid-cols-3 gap-6">
    <div class="bg-white rounded shadow p-4">
        <h3 class="font-semibold mb-2">Satış Raporu</h3>
        <p class="text-sm">Toplam Tamamlanan Satış: <strong><?php echo e($salesReport['total']); ?></strong></p>
        <p class="text-xs text-slate-400 mt-2">Aylık kırılım için Excel/PDF export kullanın.</p>
    </div>
    <div class="bg-white rounded shadow p-4">
        <h3 class="font-semibold mb-2">Finans Raporu</h3>
        <p class="text-sm">Toplam Hakediş: <strong><?php echo e(number_format($financeReport['total_earnings'],2,',','.')); ?> TL</strong></p>
        <p class="text-sm">Toplam Ödeme: <strong><?php echo e(number_format($financeReport['total_payments'],2,',','.')); ?> TL</strong></p>
        <p class="text-sm">Kalan Borç: <strong><?php echo e(number_format($financeReport['remaining_debt'],2,',','.')); ?> TL</strong></p>
    </div>
    <div class="bg-white rounded shadow p-4">
        <h3 class="font-semibold mb-2">Firma Performansı</h3>
        <ul class="text-sm space-y-1">
            <?php $__currentLoopData = $companyPerformance->take(5); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <li class="flex justify-between"><span><?php echo e($c->name); ?></span><span><?php echo e($c->total_sales); ?></span></li>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </ul>
    </div>
</div>

<div class="bg-white rounded shadow p-4 mt-6">
    <h3 class="font-semibold mb-3">Bayi Performans Raporu</h3>
    <table class="w-full text-sm">
        <thead class="text-left text-slate-400"><tr><th class="pb-2">Bayi</th><th>Toplam Satış</th><th>Toplam Hakediş</th><th>Ortalama Satış</th></tr></thead>
        <tbody>
        <?php $__currentLoopData = $dealerPerformance; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <tr class="border-t">
                <td class="py-2"><?php echo e($row['dealer']); ?></td>
                <td><?php echo e($row['total_sales']); ?></td>
                <td><?php echo e(number_format($row['total_earnings'],2,',','.')); ?> TL</td>
                <td><?php echo e(number_format($row['average_sale'],2,',','.')); ?> TL</td>
            </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </tbody>
    </table>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\a-azr\Desktop\kolayabonelik\resources\views/panel/reports/index.blade.php ENDPATH**/ ?>