<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>Rapport Financier - Association Sénégalaise de la Valls Icamp</title>
    <style>
        @page {
            margin: 30px;
        }

        body {
            font-family: 'Helvetica', sans-serif;
            color: #000;
            margin: 0;
            padding: 0;
        }

        .title-container {
            text-align: center;
            margin-bottom: 30px;
        }

        .main-title {
            font-size: 18px;
            font-weight: bold;
            text-transform: uppercase;
            text-decoration: underline;
        }

        .sub-title {
            font-size: 14px;
            margin-top: 5px;
            font-weight: bold;
        }

        .stats-summary {
            margin-bottom: 25px;
            width: 100%;
            border-collapse: collapse;
        }

        .stats-summary td {
            border: 1px solid #000;
            padding: 10px;
            text-align: center;
            width: 20%;
        }

        .stats-label {
            font-size: 10px;
            font-weight: bold;
            text-transform: uppercase;
            display: block;
            margin-bottom: 5px;
        }

        .stats-value {
            font-size: 13px;
            font-weight: bold;
        }

        .total-balance-box {
            margin-bottom: 25px;
            border: 2px solid #000;
            padding: 10px;
            text-align: center;
            background-color: #f0f0f0;
        }

        .total-balance-text {
            font-size: 14px;
            font-weight: bold;
            text-transform: uppercase;
        }

        .section-header {
            font-size: 13px;
            font-weight: bold;
            text-transform: uppercase;
            text-decoration: underline;
            margin-bottom: 10px;
            margin-top: 10px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }

        th,
        td {
            border: 1px solid #000;
            padding: 8px 10px;
            text-align: left;
        }

        th {
            background-color: #fff;
            font-weight: bold;
            text-transform: uppercase;
            font-size: 11px;
            color: #000;
        }

        td {
            font-size: 11px;
            vertical-align: top;
            color: #000;
            font-weight: bold;
        }

        .item-bold {
            font-weight: bold;
        }

        .text-right {
            text-align: right;
        }

        .footer {
            position: fixed;
            bottom: 0px;
            right: 0px;
            text-align: right;
            font-size: 11px;
            color: #000;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <div class="footer">
        Date de génération : <?php echo e(date('d/m/Y H:i')); ?>

    </div>

    <div class="title-container">
        <div class="main-title">Association Sénégalaise de la Valls Icamp</div>
        <div class="sub-title">
            RAPPORT FINANCIER GLOBAL
            <br>
            <span style="text-decoration: none; font-style: normal; font-weight: bold; font-size: 11px; color: #000000;">
                <?php if($filters['start_date'] && $filters['end_date']): ?>
                    Période du <?php echo e(\Carbon\Carbon::parse($filters['start_date'])->format('d/m/Y')); ?> au
                    <?php echo e(\Carbon\Carbon::parse($filters['end_date'])->format('d/m/Y')); ?>

                <?php elseif($filters['start_date']): ?>
                    Depuis le <?php echo e(\Carbon\Carbon::parse($filters['start_date'])->format('d/m/Y')); ?>

                <?php elseif($filters['end_date']): ?>
                    Jusqu'au <?php echo e(\Carbon\Carbon::parse($filters['end_date'])->format('d/m/Y')); ?>

                <?php else: ?>
                    Période globale
                <?php endif; ?>
            </span>

            <?php if(array_filter($filters)): ?>
                <div style="margin-top: 10px; font-size: 11px; color: #000; font-weight: bold;">
                    <?php if($filters['year']): ?>
                        <span style="margin-right: 15px;"><strong>Gestion :</strong> <?php echo e($filters['year']); ?></span>
                    <?php endif; ?>
                    <?php if($filters['project']): ?>
                        <span style="margin-right: 15px;"><strong>Projet :</strong> <?php echo e($filters['project']); ?></span>
                    <?php endif; ?>
                    <?php if($filters['member']): ?>
                        <span style="margin-right: 15px;"><strong>Membre :</strong> <?php echo e($filters['member']); ?></span>
                    <?php endif; ?>
                    <?php if($filters['account']): ?>
                        <span style="margin-right: 15px;"><strong>Compte :</strong> <?php echo e($filters['account']); ?></span>
                    <?php endif; ?>
                </div>
            <?php endif; ?>
        </div>
    </div>

    <table class="stats-summary">
        <tr>
            <td>
                <span class="stats-label">Cotisations Perçues</span>
                <span class="stats-value"><?php echo e(number_format($totalContributions, 0, ',', ' ')); ?> <?php echo e($currency); ?></span>
            </td>
            <td>
                <span class="stats-label">En Attente</span>
                <span class="stats-value"><?php echo e(number_format($totalPending, 0, ',', ' ')); ?> <?php echo e($currency); ?></span>
            </td>
            <td>
                <span class="stats-label">Total Crédits</span>
                <span class="stats-value"><?php echo e(number_format($totalCredits, 0, ',', ' ')); ?> <?php echo e($currency); ?></span>
            </td>
            <td>
                <span class="stats-label">Total Débits</span>
                <span class="stats-value"><?php echo e(number_format($totalDebits, 0, ',', ' ')); ?> <?php echo e($currency); ?></span>
            </td>
        </tr>
    </table>

    <div class="total-balance-box">
        <span class="total-balance-text">
            SOLDE TOTAL DE TOUS LES COMPTES : <?php echo e(number_format($totalAccountBalance, 0, ',', ' ')); ?> <?php echo e($currency); ?>

        </span>
    </div>

    <div class="section-header">Détail des Cotisations</div>
    <table>
        <thead>
            <tr>
                <th style="width: 15%;">Date</th>
                <th style="width: 25%;">Membre</th>
                <th style="width: 25%;">Projet</th>
                <th style="width: 20%;">Compte</th>
                <th style="width: 15%;" class="text-right">Montant</th>
            </tr>
        </thead>
        <tbody>
            <?php $__currentLoopData = $contributions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td><?php echo e($item->payment_date ? $item->payment_date->format('d/m/Y') : '-'); ?></td>
                    <td class="item-bold"><?php echo e($item->user->name ?? ($item->user->first_name . ' ' . $item->user->last_name)); ?></td>
                    <td><?php echo e($item->project->name ?? '-'); ?></td>
                    <td><?php echo e($item->account->name ?? '-'); ?></td>
                    <td class="text-right item-bold"><?php echo e(number_format($item->amount, 0, ',', ' ')); ?> <?php echo e($currency); ?></td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php if($contributions->isEmpty()): ?>
                <tr>
                    <td colspan="5" style="text-align: center; font-style: italic;">Aucune cotisation trouvée</td>
                </tr>
            <?php endif; ?>
        </tbody>
    </table>

    <div style="page-break-before: always;"></div>

    <div class="section-header">Détail des Opérations Financières</div>
    <table>
        <thead>
            <tr>
                <th style="width: 15%;">Date</th>
                <th style="width: 15%;">Type</th>
                <th style="width: 35%;">Description</th>
                <th style="width: 20%;">Compte</th>
                <th style="width: 15%;" class="text-right">Montant</th>
            </tr>
        </thead>
        <tbody>
            <?php $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <tr>
                    <td><?php echo e($item->date ? $item->date->format('d/m/Y') : '-'); ?></td>
                    <td class="item-bold"><?php echo e(ucfirst($item->type)); ?></td>
                    <td><?php echo e($item->description); ?></td>
                    <td><?php echo e($item->account->name ?? '-'); ?></td>
                    <td class="text-right item-bold">
                        <?php echo e($item->type === 'credit' ? '+' : '-'); ?> <?php echo e(number_format($item->amount, 0, ',', ' ')); ?> <?php echo e($currency); ?>

                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            <?php if($transactions->isEmpty()): ?>
                <tr>
                    <td colspan="5" style="text-align: center; font-style: italic;">Aucune opération trouvée</td>
                </tr>
            <?php endif; ?>
        </tbody>
    </table>
</body>

</html>
<?php /**PATH /home/fonix-sa/Bureau/Fonix projects/GASOS/resources/views/admin/reports/export-pdf.blade.php ENDPATH**/ ?>