<?php $__env->startSection('title', 'Finans / Ödemeler'); ?>
<?php $__env->startSection('content'); ?>

<?php if($cariHesap): ?>
<div class="grid md:grid-cols-3 gap-4 mb-6">
    <div class="bg-white rounded shadow p-4">
        <p class="text-xs text-slate-500"><?php echo e($cariHesap['label']); ?> — Toplam Hakediş</p>
        <p class="text-2xl font-bold"><?php echo e(number_format($cariHesap['total_earnings'], 2, ',', '.')); ?> TL</p>
    </div>
    <div class="bg-white rounded shadow p-4">
        <p class="text-xs text-slate-500">Ödenen Tutar</p>
        <p class="text-2xl font-bold text-green-600"><?php echo e(number_format($cariHesap['total_paid'], 2, ',', '.')); ?> TL</p>
    </div>
    <div class="bg-white rounded shadow p-4">
        <p class="text-xs text-slate-500">Kalan Bakiye</p>
        <p class="text-2xl font-bold <?php echo e($cariHesap['remaining_balance'] > 0 ? 'text-amber-600' : 'text-slate-400'); ?>">
            <?php echo e(number_format($cariHesap['remaining_balance'], 2, ',', '.')); ?> TL
        </p>
    </div>
</div>

<?php if($earnings->isNotEmpty()): ?>
<div class="bg-white rounded shadow p-4 mb-6">
    <h3 class="font-semibold mb-3">Son Hakedişler</h3>
    <table class="w-full text-sm">
        <thead class="text-left text-slate-400">
            <tr>
                <th class="pb-2">Bayi</th>
                <th>Abonelik</th>
                <th>Komisyon Tipi</th>
                <th>Sözleşme Tutarı</th>
                <th>Hakediş</th>
                <th>Durum</th>
                <th>Tarih</th>
            </tr>
        </thead>
        <tbody>
        <?php $__currentLoopData = $earnings; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $earning): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <tr class="border-t">
                <td class="py-2"><?php echo e($earning->dealer?->company_name); ?></td>
                <td><?php echo e($earning->subscription?->reference_no); ?></td>
                <td><?php echo e($earning->commission_type?->label()); ?></td>
                <td><?php echo e(number_format($earning->package_price, 2, ',', '.')); ?> TL</td>
                <td class="font-medium"><?php echo e(number_format($earning->total_amount, 2, ',', '.')); ?> TL</td>
                <td><?php echo e($earning->status?->label()); ?></td>
                <td><?php echo e($earning->created_at->format('d.m.Y')); ?></td>
            </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </tbody>
    </table>
    <p class="text-xs text-slate-400 mt-2">Hakedişler, abonelik "Tamamlandı" durumuna geçtiğinde otomatik oluşur.</p>
</div>
<?php endif; ?>
<?php endif; ?>

<div class="flex justify-between items-center mb-4">
    <form method="GET" class="flex gap-2">
        <?php if($dealers->isNotEmpty()): ?>
        <select name="dealer_id" class="border rounded px-3 py-1.5 text-sm">
            <option value="">Tüm Bayiler</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(request('dealer_id')==$d->id): echo 'selected'; endif; ?>><?php echo e($d->company_name); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
        <?php endif; ?>
        <input type="date" name="date_from" value="<?php echo e(request('date_from')); ?>" class="border rounded px-3 py-1.5 text-sm">
        <input type="date" name="date_to" value="<?php echo e(request('date_to')); ?>" class="border rounded px-3 py-1.5 text-sm">
        <button class="bg-slate-800 text-white rounded px-4 py-1.5 text-sm">Filtrele</button>
    </form>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('create', App\Models\Payment::class)): ?>
        <a href="<?php echo e(route('panel.payments.create')); ?>" class="bg-blue-600 text-white rounded px-4 py-2 text-sm font-medium">+ Ödeme Girişi</a>
    <?php endif; ?>
</div>
<div class="bg-white rounded shadow overflow-x-auto">
    <table class="w-full text-sm">
        <thead class="bg-slate-100 text-left"><tr><th class="p-3">Bayi</th><th class="p-3">Tutar</th><th class="p-3">Tarih</th><th class="p-3">Tür</th><th class="p-3">Açıklama</th></tr></thead>
        <tbody>
        <?php $__empty_1 = true; $__currentLoopData = $payments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <tr class="border-t">
                <td class="p-3"><?php echo e($payment->dealer->company_name); ?></td>
                <td class="p-3 font-medium"><?php echo e(number_format($payment->amount,2,',','.')); ?> TL</td>
                <td class="p-3"><?php echo e($payment->payment_date->format('d.m.Y')); ?></td>
                <td class="p-3"><?php echo e($payment->payment_type->label()); ?></td>
                <td class="p-3"><?php echo e($payment->description); ?></td>
            </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <tr><td colspan="5" class="p-6 text-center text-slate-400">Kayıt bulunamadı.</td></tr>
        <?php endif; ?>
        </tbody>
    </table>
</div>
<div class="mt-4"><?php echo e($payments->links()); ?></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/payments/index.blade.php ENDPATH**/ ?>