<?php if (isset($component)) { $__componentOriginal91fdd17964e43374ae18c674f95cdaa3 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal91fdd17964e43374ae18c674f95cdaa3 = $attributes; } ?>
<?php $component = App\View\Components\AdminLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('admin-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AdminLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> 
     <?php $__env->endSlot(); ?>

    <!-- Main Outer Container -->
    <div class="p-0 font-sans bg-slate-50 min-h-screen">

        <?php if(session('success')): ?>
            <div x-data="{ show: true }" x-init="setTimeout(() => show = false, 3000)" x-show="show" 
                class="mx-4 mb-6 bg-emerald-50 p-3 rounded-lg shadow-sm relative md:mx-0"
                role="alert">
                <div class="flex">
                    <span class="font-semibold"><?php echo e(session('success')); ?></span>
                </div>
            </div>
        <?php endif; ?>

        <!-- SINGLE WHITE CARD CONTAINER -->
        <div class="bg-white border-none shadow-none md:rounded-none p-4 md:p-6 relative min-h-screen">

            <!-- Header Section (Inside Card) -->
            <div class="mb-6 flex items-center justify-between">
                <h5 class="text-[14px] font-bold text-gray-700 uppercase tracking-wide">
                    Gestion Finance / Journal des Opérations
                </h5>
            </div>

            <!-- Filter Section -->
            <div class="mb-6 p-4 bg-gray-50/50 border border-gray-200 rounded-sm">
                <form action="<?php echo e(route('admin.transactions.index')); ?>" method="GET">
                    <div class="flex flex-col md:flex-row md:items-center gap-4">
                        <!-- Type Filter -->
                        <div class="flex-1 min-w-[150px]">
                            <select name="type" onchange="this.form.submit()"
                                class="block w-full px-3 py-2 border border-gray-300 rounded-sm text-[13px] font-semibold text-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 bg-white transition-all h-[38px] cursor-pointer">
                                <option value="">Tous les types</option>
                                <option value="credit" <?php echo e(request('type') == 'credit' ? 'selected' : ''); ?>>Avis de Crédit (+)</option>
                                <option value="debit" <?php echo e(request('type') == 'debit' ? 'selected' : ''); ?>>Avis de Débit (-)</option>
                            </select>
                        </div>

                        <!-- Account Filter -->
                        <div class="flex-1 min-w-[180px]">
                            <select name="account_id" onchange="this.form.submit()"
                                class="block w-full px-3 py-2 border border-gray-300 rounded-sm text-[13px] font-semibold text-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 bg-white transition-all h-[38px] cursor-pointer">
                                <option value="">Tous les comptes</option>
                                <?php $__currentLoopData = $accounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $account): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option value="<?php echo e($account->id); ?>" <?php echo e(request('account_id') == $account->id ? 'selected' : ''); ?>>
                                        <?php echo e($account->name); ?>

                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </select>
                        </div>

                        <!-- Date Start -->
                        <div class="flex-1 min-w-[150px]">
                            <input type="date" name="date_start" value="<?php echo e(request('date_start')); ?>" onchange="this.form.submit()"
                                class="block w-full px-3 py-2 border border-gray-300 rounded-sm text-[13px] font-semibold text-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 bg-white transition-all h-[38px]">
                        </div>

                        <!-- Date End -->
                        <div class="flex-1 min-w-[150px]">
                            <input type="date" name="date_end" value="<?php echo e(request('date_end')); ?>" onchange="this.form.submit()"
                                class="block w-full px-3 py-2 border border-gray-300 rounded-sm text-[13px] font-semibold text-gray-700 focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 bg-white transition-all h-[38px]">
                        </div>

                        <!-- Buttons -->
                        <div class="flex items-center gap-2">
                            <button type="submit" 
                                class="inline-flex items-center px-4 py-2 border border-emerald-600 text-white text-[13px] font-bold rounded-sm hover:opacity-90 h-[38px] transition-all group"
                                style="background-color: #10b981 !important;">
                                <svg class="w-4 h-4 mr-2 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z" />
                                </svg>
                                Filtrer
                            </button>
                            <a href="<?php echo e(route('admin.transactions.index')); ?>" 
                                class="inline-flex items-center px-4 py-2 border border-red-600 text-white text-[13px] font-bold rounded-sm hover:opacity-90 h-[38px] transition-all group"
                                style="background-color: #e01e22 !important; text-decoration: none !important;">
                                <svg class="w-4 h-4 mr-2 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                                </svg>
                                Effacer
                            </a>
                        </div>
                    </div>
                </form>
            </div>

            <!-- Controls Row: Tabs and Buttons -->
            <div class="flex flex-col lg:flex-row lg:items-center justify-between mb-6 gap-4">
                <!-- Group: Navigation and Exports -->
                <div class="flex flex-col sm:flex-row items-stretch sm:items-center gap-3">
                    <!-- "Liste des opérations" -->
                    <button
                        class="inline-flex items-center justify-center px-4 py-2 border border-amber-400 shadow-sm text-[13px] font-bold text-black rounded-sm hover:opacity-90 h-[38px] transition-all"
                        style="background-color: #fbbf24 !important;">
                        Liste des opérations
                        <svg class="ml-2 w-4 h-4 text-black transform rotate-180" fill="currentColor"
                            viewBox="0 0 20 20">
                            <path fill-rule="evenodd"
                                d="M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z"
                                clip-rule="evenodd" />
                        </svg>
                    </button>

                    <div class="flex items-center gap-2">
                        <!-- Export PDF -->
                        <a href="<?php echo e(route('admin.transactions.export.pdf', request()->query())); ?>"
                            class="flex-1 sm:flex-initial inline-flex items-center justify-center px-4 py-2 text-white text-[13px] font-bold rounded-sm shadow-sm h-[38px] hover:opacity-90 transition-all group"
                            style="background-color: #e01e22 !important; border: 1px solid #e01e22 !important; text-decoration: none;">
                            <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor"
                                viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                                    d="M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z" />
                            </svg>
                            <span>PDF</span>
                        </a>
                    </div>
                </div>

                <?php if(auth()->user()->canManage()): ?>
                <!-- Group: Action Buttons -->
                <div class="flex flex-col sm:flex-row items-stretch sm:items-center gap-2">
                    <a href="<?php echo e(route('admin.transactions.create', ['type' => 'credit'])); ?>"
                        class="inline-flex items-center justify-center px-4 py-2 text-white text-[13px] font-bold rounded-sm shadow-sm h-[38px] transition-all hover:opacity-90 active:transform active:scale-95"
                        style="background-color: #5867dd !important;">
                        <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
                        </svg>
                        Avis de Crédit (+)
                    </a>
                    <a href="<?php echo e(route('admin.transactions.create', ['type' => 'debit'])); ?>"
                        class="inline-flex items-center justify-center px-4 py-2 text-white text-[13px] font-bold rounded-sm shadow-sm h-[38px] transition-all hover:opacity-90 active:transform active:scale-95"
                        style="background-color: #ef4444 !important;">
                        <svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4" />
                        </svg>
                        Avis de Débit (-)
                    </a>
                </div>
                <?php endif; ?>
            </div>

            <!-- Table (Inside Card) -->
            <div class="overflow-x-auto border border-gray-200 rounded-sm shadow-sm">
                <style>
                    .custom-v-lines th, .custom-v-lines td { border-right: 1px solid #d1d5db !important; }
                    .custom-v-lines th:last-child, .custom-v-lines td:last-child { border-right: none !important; }
                </style>
                <table class="min-w-full divide-y divide-gray-200 custom-v-lines">
                    <thead>
                        <tr class="bg-gray-50/80">
                            <th class="px-4 py-3.5 text-left text-[13px] font-bold text-slate-900 uppercase tracking-widest border-b border-gray-200 whitespace-nowrap">
                                Date
                            </th>
                            <th class="px-4 py-3.5 text-left text-[13px] font-bold text-slate-900 uppercase tracking-widest border-b border-gray-200 whitespace-nowrap">
                                Type
                            </th>
                            <th class="px-4 py-3.5 text-left text-[13px] font-bold text-slate-900 uppercase tracking-widest border-b border-gray-200 whitespace-nowrap">
                                Compte
                            </th>
                            <th class="px-4 py-3.5 text-left text-[13px] font-bold text-slate-900 uppercase tracking-widest border-b border-gray-200">
                                RIB
                            </th>
                            <th class="px-4 py-3.5 text-right text-[13px] font-bold text-slate-900 uppercase tracking-widest border-b border-gray-200 whitespace-nowrap">
                                Montant
                            </th>
                            <?php if(auth()->user()->canManage()): ?>
                            <th class="px-4 py-3.5 text-center text-[13px] font-bold text-slate-900 uppercase tracking-widest border-b border-gray-200">
                                Actions
                            </th>
                            <?php endif; ?>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-200 bg-white">
                        <?php $__empty_1 = true; $__currentLoopData = $transactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $transaction): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr class="hover:bg-gray-50/50 transition-colors">
                                <!-- Date -->
                                <td class="px-4 py-3.5 whitespace-nowrap">
                                    <span class="text-[13px] text-slate-900 font-bold">
                                        <?php echo e($transaction->date->format('d/m/Y')); ?>

                                    </span>
                                </td>

                                <!-- Type -->
                                <td class="px-4 py-3.5 whitespace-nowrap">
                                    <?php if($transaction->type === 'credit'): ?>
                                        <span class="inline-flex items-center px-3 py-1 rounded-full bg-emerald-100 text-emerald-800 border border-emerald-600 text-[10px] font-black uppercase tracking-widest">
                                            Crédit
                                        </span>
                                    <?php else: ?>
                                        <span class="inline-flex items-center px-3 py-1 rounded-full bg-rose-100 text-rose-800 border border-rose-600 text-[10px] font-black uppercase tracking-widest">
                                            Débit
                                        </span>
                                    <?php endif; ?>
                                </td>

                                <!-- Compte -->
                                <td class="px-4 py-3.5 whitespace-nowrap">
                                    <span class="text-[13px] text-slate-900 font-bold"><?php echo e($transaction->account->name); ?></span>
                                </td>

                                <!-- RIB -->
                                <td class="px-4 py-3.5">
                                    <span class="text-[13px] text-slate-900 font-bold"><?php echo e($transaction->account->account_number ?: 'N/A'); ?></span>
                                </td>

                                <!-- Montant -->
                                <td class="px-4 py-3.5 whitespace-nowrap text-right">
                                    <span class="text-[15px] font-black <?php echo e($transaction->type === 'credit' ? 'text-emerald-600' : 'text-red-700'); ?>">
                                        <?php echo e($transaction->type === 'credit' ? '+' : '-'); ?> <?php echo e(\App\Models\Setting::format($transaction->amount)); ?>

                                    </span>
                                </td>

                                <?php if(auth()->user()->canManage()): ?>
                                <!-- Actions -->
                                <td class="px-4 py-3.5 whitespace-nowrap text-center">
                                    <div class="flex items-center justify-center space-x-2">
                                        <a href="<?php echo e(route('admin.transactions.edit', $transaction)); ?>" 
                                            class="flex items-center justify-center w-8 h-8 rounded bg-indigo-50 text-indigo-600 border border-indigo-100 hover:bg-indigo-600 hover:text-white transition-colors">
                                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
                                            </svg>
                                        </a>
                                        <form id="delete-transaction-<?php echo e($transaction->id); ?>" action="<?php echo e(route('admin.transactions.destroy', $transaction)); ?>" method="POST" class="inline">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                            <button type="button" 
                                                data-action="delete-transaction"
                                                data-form-id="delete-transaction-<?php echo e($transaction->id); ?>"
                                                data-confirm-message="Supprimer cette opération ?"
                                                class="flex items-center justify-center w-8 h-8 rounded bg-red-50 text-red-600 border border-red-100 hover:bg-red-600 hover:text-white transition-colors">
                                                <svg class="w-4 h-4 pointer-events-none" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
                                                </svg>
                                            </button>
                                        </form>
                                    </div>
                                </td>
                                <?php endif; ?>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="<?php echo e(auth()->user()->canManage() ? 6 : 5); ?>" class="px-6 py-12 text-center bg-gray-50/30">
                                    <div class="flex flex-col items-center">
                                        <div class="w-16 h-16 bg-white border border-gray-100 rounded-full flex items-center justify-center mb-4 text-gray-300 shadow-sm">
                                            <svg class="w-8 h-8" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4" />
                                            </svg>
                                        </div>
                                        <h3 class="text-[13px] font-bold text-gray-400 uppercase tracking-widest">Aucune opération enregistrée</h3>
                                        <p class="text-[11px] text-gray-400 mt-1 uppercase tracking-tight">Utilisez les boutons ci-dessus pour ajouter votre première opération.</p>
                                    </div>
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>

            <!-- Pagination -->
            <?php if($transactions->hasPages()): ?>
                <div class="mt-6 border-t border-gray-100 pt-4">
                    <?php echo e($transactions->links()); ?>

                </div>
            <?php endif; ?>
        </div>
    </div>
    <?php echo $__env->make('partials.form-submit-script', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal91fdd17964e43374ae18c674f95cdaa3)): ?>
<?php $attributes = $__attributesOriginal91fdd17964e43374ae18c674f95cdaa3; ?>
<?php unset($__attributesOriginal91fdd17964e43374ae18c674f95cdaa3); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal91fdd17964e43374ae18c674f95cdaa3)): ?>
<?php $component = $__componentOriginal91fdd17964e43374ae18c674f95cdaa3; ?>
<?php unset($__componentOriginal91fdd17964e43374ae18c674f95cdaa3); ?>
<?php endif; ?>
<?php /**PATH /home/fonix-sa/Bureau/Fonix projects/GASOS/resources/views/admin/transactions/index.blade.php ENDPATH**/ ?>