@extends('admin.layout')
@section('title','Transaction Details')
@section('content')
<h3 align="center">Détails des transactions bancaires</h3>

<section class="content">
    <div class="container-fluid">
        <!-- Filter Form -->
        <form method="POST" action="{{ route('transaction.filter') }}">
            @csrf
            <div class="row mb-4">
                <div class="col-md-4">
                    <label for="agence">Agence</label>
                    <select name="agence" class="form-control select2bs4"  id="">
                        <option value="">Selectionnez l'agence</option>
                        @foreach($serveurs as $serveur)
                            <option value="{{ $serveur->code_agence }}" {{ request()->get('agence') == $serveur->code_agence ?'selected' : '' }}>{{ $serveur->libelle_agence }}</option>
                        @endforeach
                    </select>
                </div>
                <div class="col-md-4">
                    <label for="type_mouvement">Type Mouvement</label>
                    <select class="form-control select2bs4" name="type_mouvement" id="type_mouvement">
                        <option value="">Select Type</option>
                        <option value="client" {{ request()->get('type_mouvement') == 'client' ? 'selected' : '' }}>Client</option>
                        <option value="comptable" {{ request()->get('type_mouvement') == 'comptable' ? 'selected' : '' }}>Comptable</option>
                    </select>
                </div>
                <!-- select B2W or W2B -->
                <div class="col-md-4">
                    <label for="type_ops">Type de ops</label>
                    <select class="form-control select2bs4" name="type_ops" id="type_ops">
                        <option value="all">Select B2W/W2B</option>
                        <option value="B2W" {{ request()->get('type_ops') == 'B2W' ? 'selected' : '' }}>B2W</option>
                        <option value="W2B" {{ request()->get('type_ops') == 'W2B' ? 'selected' : '' }}>W2B</option>
                    </select>
                </div>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <label for="date1">Date de début</label>
                    <input type="datetime-local" class="form-control" name="date1" id="date1" value="{{ request()->get('date1') }}">
                </div>
                <div class="col-md-6">
                    <label for="date2">Date de fin</label>
                    <input type="datetime-local" class="form-control" name="date2" id="date2" value="{{ request()->get('date2') }}">
                </div>

            </div>
            <button type="submit" class="btn btn-primary">Filtre</button>
        </form>

        <!-- Table of Transactions -->
        <div class="row">

            @if (isset($type_mouvement) && $type_mouvement === 'client')
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <h3 class="card-title">Liste des transactions mouvements clients</h3>
                    </div>
                    <div class="card-body">
                        <table id="example1" class="table table-bordered table-striped">
                            <thead class="thead-dark">
                                <tr>
                                    <th>#</th>
                                    <th>Code Entreprise</th>
                                    <th>Numéro Mouvement</th>
                                    <th>Numéro Compte</th>
                                    <th>Code Produit</th>
                                    <th>Type Transaction</th>
                                    <th>Sous-type Transaction</th>
                                    <th>Code Système</th>
                                    <th>Date Mouvement</th>
                                    <th>Numéro Document</th>
                                    <th>État Mouvement</th>
                                    <th>Indicateur Appliqué</th>
                                    <th>Montant Mouvement</th>
                                    <th>Description Mouvement</th>
                                    <th>Système Source</th>
                                    <th>Numéro Mouvement Source</th>
                                    <th>Code Agence</th>
                                    <th>Code Utilisateur</th>
                                    <th>Référence</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse ($transactions as $transaction)
                                    <tr>
                                        <td><input type="checkbox"></td>
                                        <td>{{ $transaction->COD_EMPRESA }}</td>
                                        <td>{{ $transaction->NUM_MOVIMIENTO }}</td>
                                        <td>{{ $transaction->NUM_CUENTA }}</td>
                                        <td>{{ $transaction->COD_PRODUCTO }}</td>
                                        <td>{{ $transaction->TIP_TRANSACCION }}</td>
                                        <td>{{ $transaction->SUBTIP_TRANSAC }}</td>
                                        <td>{{ $transaction->COD_SISTEMA }}</td>
                                        <td>{{ $transaction->FEC_MOVIMIENTO }}</td>
                                        <td>{{ $transaction->NUM_DOCUMENTO }}</td>
                                        <td>{{ $transaction->EST_MOVIMIENTO }}</td>
                                        <td>{{ $transaction->IND_APL_CARGO }}</td>
                                        <td>{{ $transaction->MON_MOVIMIENTO }}</td>
                                        <td>{{ $transaction->DES_MOVIMIENTO }}</td>
                                        <td>{{ $transaction->SISTEMA_FUENTE }}</td>
                                        <td>{{ $transaction->NUM_MOV_FUENTE }}</td>
                                        <td>{{ $transaction->COD_AGENCIA }}</td>
                                        <td>{{ $transaction->COD_USUARIO }}</td>
                                        <td>{{ $transaction->DES_REFERENCIA }}</td>
                                    </tr>
                                @empty
                                    <tr>
                                        <td colspan="19" align="center">Aucune transaction trouvée.</td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                                @endforelse
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            @elseif (isset($type_mouvement) && $type_mouvement === 'comptable')
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <h3 class="card-title">Liste des transactions mouvements comptables</h3>
                    </div>
                    <div class="card-body">
                        <table id="example1" class="table table-bordered table-striped">
                            <thead class="thead-dark">
                                <tr>
                                    <th>Code Entreprise</th>
                                    <th>Numéro Codification</th>
                                    <th>Code Système</th>
                                    <th>Code Produit</th>
                                    <th>Type Transaction</th>
                                    <th>Sous-type Transaction</th>
                                    <th>Description Codification</th>
                                    <th>Type Codification</th>
                                    <th>Date Enregistrement</th>
                                    <th>État Codification</th>
                                    <th>Fréquence</th>
                                    <th>Jour Asiento</th>
                                    <th>Code Unité (Résumé)</th>
                                    <th>Numéro Ligne</th>
                                    <th>Compte Comptable</th>
                                    <th>Type Mouvement</th>
                                    <th>Montant Mouvement</th>
                                    <th>Détail</th>
                                    <th>Code Unité (Détail)</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse ($transactions as $transaction)
                                    <tr>
                                        <td>{{ $transaction->COD_EMPRESA }}</td>
                                        <td>{{ $transaction->NUM_CODIFICACION }}</td>
                                        <td>{{ $transaction->COD_SISTEMA }}</td>
                                        <td>{{ $transaction->COD_PRODUCTO }}</td>
                                        <td>{{ $transaction->TIP_TRANSACCION }}</td>
                                        <td>{{ $transaction->SUBTIP_TRANSAC }}</td>
                                        <td>{{ $transaction->DES_CODIFICACION }}</td>
                                        <td>{{ $transaction->TIP_CODIFICACION }}</td>
                                        <td>{{ $transaction->FEC_REGISTRO }}</td>
                                        <td>{{ $transaction->EST_CODIFICACION }}</td>
                                        <td>{{ $transaction->FRECUENCIA }}</td>
                                        <td>{{ $transaction->DIA_ASIENTO }}</td>
                                        <td>{{ $transaction->COD_UNIDAD_RESUMEN }}</td>
                                        <td>{{ $transaction->NUM_LINEA }}</td>
                                        <td>{{ $transaction->CUENTA_CONTABLE }}</td>
                                        <td>{{ $transaction->TIP_MOVIMIENTO }}</td>
                                        <td>{{ $transaction->MON_MOVIMIENTO }}</td>
                                        <td>{{ $transaction->DETALLE }}</td>
                                        <td>{{ $transaction->COD_UNIDAD_DETALLE }}</td>
                                    </tr>
                                @empty
                                    <tr>
                                        <td colspan="19" class="text-center">Aucune transaction trouvée.</td>
                                    </tr>
                                @endforelse
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            @endif



        </div>
    </div>
</section>
@stop
