@extends('layout')

@section('contenu')
    @include('/partials/modalModifierOperation')
    @include('/partials/modalConfirmSuppOperation')
    @include('/partials/modalAjouterOperation')
    @include('/partials/modalDetailsOperation')
    @include('partials/modalRapport')
    <section
        style="background-image: url('/img/board.png'); background-attachment: fixed; background-repeat: no-repeat; background-size: cover; min-height: 93.2vh;"
        class="section p-3 mt-0 mb-0 mx-2-touch columns mx-0 is-centered is-flex-desktop is-flex-direction-column is-justify-content-center">
        <nav class="panel mx-auto is-info column is-half p-0">
            <p class="panel-heading">
                Les transactions
            </p>
            <p class="panel-tabs has-background-white">
                <a id="default" class="tab" onclick="openContent(event, 'tout')">Tout</a>
                <a class="tab" onclick="openContent(event, 'depenses')">Dépenses</a>
                <a class="tab" onclick="openContent(event, 'encaissements')">Encaissements</a>
            </p>
            <div class="mb-5" style="background: #E4E9F2; height: 25rem; overflow-y: auto">
                <div class="has-text-centered p-3">
                    <a onclick="openForm('modalAjouterOperation')" class="button is-info is-rounded mr-3">
                        <strong>Ajouter Transaction</strong>
                    </a>
                    <a onclick="openForm('modalRapport')" class="button is-info is-rounded">
                        <strong>Rapport</strong>
                    </a>
                </div>
                <div id="tout" class="contenu-block columns m-0">
                    <div class="column px-0">
                        @foreach ($operations as $operation)
                            <span class="columns is-flex m-auto">
                                <span class="column is-three-quarters">
                                    <span class="panel-block">
                                        <span class="panel-icon">
                                            <i class="fas fa-money-bill" aria-hidden="true"></i>
                                        </span>
                                        {{ $operation->libelle }}({{ $operation->type_operation }}) par
                                        {{ $operation->user != null ? $operation->user->prenom . ' ' . $operation->user->nom : 'UPGROUP-PAY' }}
                                        {{ $operation->statut == 'annule' ? ' (Annulee)' : '' }}
                                    </span>
                                </span>
                                @if (auth()->user()->administrateur == 1)
                                    <span class="column px-0 is-flex is-justify-content-right">
                                        <a class="icon is-medium"
                                            onclick="openForm('modalDetailsOperation'); get_ref_det('{{ $operation->reference }}'); get_libelle_det('{{ addslashes($operation->libelle) }}'); get_type_det('{{ $operation->type_operation }}'); get_descr_det('{{ addslashes($operation->description == null ? '' : $operation->description) }}'); get_montant_det('{{ $operation->montant }}'); get_author_det('{{ $operation->user != null ? $operation->user->prenom . ' ' . $operation->user->nom : 'UPGROUP-PAY' }}'); get_date_det('{{ date('d/m/Y', strtotime($operation->created_at)) }}'); get_update_det('{{ date('d/m/Y', strtotime($operation->updated_at)) }}'); get_statut_det('{{ $operation->statut }}');">
                                            <i title="Détails" class="fas fa-info" aria-hidden="true"></i>
                                        </a>
                                        <a class="icon is-medium"
                                            onclick="openForm('modalModifierOperation'); get_id_operation({{ $operation->id }}); get_libelle_operation('{{ addslashes($operation->libelle) }}'); get_type_operation('{{ $operation->type_operation }}'); get_descr('{{ addslashes($operation->description == null ? '' : $operation->description) }}'); get_montant('{{ $operation->montant }}');">
                                            <i title="Modifier" class="fas fa-edit" aria-hidden="true"></i>
                                        </a>
                                        <a class="icon is-medium"
                                            onclick="get_id_operation({{ $operation->id }}); openForm('modalSuppOperation')">
                                            <i title="Supprimer" class="fas fa-trash-alt" aria-hidden="true"></i>
                                        </a>
                                    </span>
                                @endif
                            </span>
                        @endforeach
                    </div>
                </div>
                <div id="depenses" class="contenu-block columns m-0">
                    <div class="column">
                        @foreach ($depenses as $operation)
                            <span class="columns is-flex m-auto">
                                <span class="column is-three-quarters">
                                    <span class="panel-block">
                                        <span class="panel-icon">
                                            <i class="fas fa-money-bill" aria-hidden="true"></i>
                                        </span>
                                        {{ $operation->libelle }} par
                                        {{ $operation->user != null ? $operation->user->prenom . ' ' . $operation->user->nom : 'UPGROUP-PAY' }}
                                        {{ $operation->statut == 'annule' ? ' (Annulee)' : '' }}
                                    </span>
                                </span>
                                <span class="column is-flex is-justify-content-right">
                                    <a class="icon is-medium"
                                        onclick="openForm('modalDetailsOperation'); get_ref_det('{{ $operation->reference }}'); get_libelle_det('{{ addslashes($operation->libelle) }}'); get_type_det('{{ $operation->type_operation }}'); get_descr_det('{{ addslashes($operation->description == null ? '' : $operation->description) }}'); get_montant_det('{{ $operation->montant }}'); get_author_det('{{ $operation->user != null ? $operation->user->prenom . ' ' . $operation->user->nom : 'UPGROUP-PAY' }}'); get_date_det('{{ date('d/m/Y', strtotime($operation->created_at)) }}'); get_update_det('{{ date('d/m/Y', strtotime($operation->updated_at)) }}'); get_statut_det('{{ $operation->statut }}');">
                                        <i title="Détails" class="fas fa-info" aria-hidden="true"></i>
                                    </a>
                                    <a title="Modifier" class="icon is-medium"
                                        onclick="openForm('modalModifierOperation'); get_id_operation({{ $operation->id }}); get_libelle_operation('{{ addslashes($operation->libelle) }}'); get_type_operation('{{ $operation->type_operation }}'); get_descr('{{ addslashes($operation->description == null ? '' : $operation->description) }}'); get_montant('{{ $operation->montant }}');">
                                        <i class="fas fa-edit" aria-hidden="true"></i>
                                    </a>
                                    <a title="Supprimer" class="icon is-medium"
                                        onclick="get_id_matiere({{ $operation->id }}); openForm('modalSuppMatiere')">
                                        <i class="fas fa-trash-alt" aria-hidden="true"></i>
                                    </a>
                                </span>
                            </span>
                        @endforeach
                    </div>
                </div>
                <div id="encaissements" class="contenu-block columns m-0">
                    <div class="column">
                        @foreach ($encaissements as $operation)
                            <span class="columns is-flex m-auto">
                                <span class="column is-three-quarters">
                                    <span class="panel-block">
                                        <span class="panel-icon">
                                            <i class="fas fa-money-bill" aria-hidden="true"></i>
                                        </span>
                                        {{ $operation->libelle }} par
                                        {{ $operation->user != null ? $operation->user->prenom . ' ' . $operation->user->nom : 'UPGROUP-PAY' }}
                                        {{ $operation->statut == 'annule' ? ' (Annulee)' : '' }}
                                    </span>
                                </span>
                                <span class="column is-flex is-justify-content-right">
                                    <a class="icon is-medium"
                                        onclick="openForm('modalDetailsOperation'); get_ref_det('{{ $operation->reference }}'); get_libelle_det('{{ addslashes($operation->libelle) }}'); get_type_det('{{ $operation->type_operation }}'); get_descr_det('{{ addslashes($operation->description == null ? '' : $operation->description) }}'); get_montant_det('{{ $operation->montant }}'); get_author_det('{{ $operation->user != null ? $operation->user->prenom . ' ' . $operation->user->nom : 'UPGROUP-PAY' }}'); get_date_det('{{ date('d/m/Y', strtotime($operation->created_at)) }}'); get_update_det('{{ date('d/m/Y', strtotime($operation->updated_at)) }}'); get_statut_det('{{ $operation->statut }}');">
                                        <i title="Détails" class="fas fa-info" aria-hidden="true"></i>
                                    </a>
                                    <a title="Modifier" class="icon is-medium"
                                        onclick="openForm('modalModifierOperation'); get_id_operation({{ $operation->id }}); get_libelle_operation('{{ addslashes($operation->libelle) }}'); get_type_operation('{{ $operation->type_operation }}'); get_descr('{{ addslashes($operation->description == null ? '' : $operation->description) }}'); get_montant('{{ $operation->montant }}');">
                                        <i class="fas fa-edit" aria-hidden="true"></i>
                                    </a>
                                    <a title="Supprimer" class="icon is-medium"
                                        onclick="get_id_matiere({{ $operation->id }}); openForm('modalSuppMatiere')">
                                        <i class="fas fa-trash-alt" aria-hidden="true"></i>
                                    </a>
                                </span>
                            </span>
                        @endforeach
                    </div>
                </div>
            </div>
            <div class="columns"></div>
            <div style="position: relative;" class="is-flex is-justify-content-center">
                <img src="/img/upschool.svg" width="200" alt="">
            </div>
        </nav>
    </section>
    @include('/partials/operationJs')
@endsection
