@extends('app')

@section('content')
<div class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <h1 class="m-0">Demandes terminées</h1>
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.container-fluid -->
</div>

<section class="content">
    <div class="container-fluid">
        <!-- Table cession-->
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <!-- <button type="button" class="btn btn-block bg-gradient-warning" style="color: #ffffff;" data-toggle="modal" data-target="#DemandeModal">Nouvelle demande</button> -->
                    </div>
                    <!-- ./card-header -->
                    <div class="card-body">
                        <table class="table table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th>N° Demande</th>
                                    <th>Date de demande</th>
                                    <th>Type attestaion</th>
                                    <th>Certificat</th>
                                    <th>Demandeur</th>
                                    <th>Nombre de factures</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($liste_demande as $art)

                                <tr>
                                    <td>
                                        {{ $art->id_demande }}
                                    </td>
                                    <td>{!! date ('d/m/Y', strtotime($art->date_dem)) !!}</td>
                                    <td>{{ $art->libelle }}</td>
                                    <td>{{ $art->certif }}</td>
                                    <td>{{ $art->demandeur }}</td>
                                    <td>{{ $art->nb_facture }}</td>
                                    <td>
                                        <button type="button" id="put_demande" value="{{ $art->id_demande }}" class="btn-tab bg-info" data-toggle="modal" data-target="#DemandeModal"><i class="fas fa-pencil-square-o" aria-hidden="true" style="color:#ffffff"></i></button>
                                        <button type="button" id="show_demande" value="{{ $art->id_demande }}" class="btn-tab bg-warning" data-toggle="modal" data-target="#ShowDemandeModal"><i class="fas fa-eye" aria-hidden="true" style="color:#ffffff"></i></button>
                                    </td>
                                </tr>
                                <!-- <tr class="spacer"><td colspan="100"></td></tr> -->
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                    <!-- /.card-body -->
                </div>
                <!-- /.card -->
            </div>
        </div>
        <!-- Fin table cession-->

        <!-- Ajouter une demande -->
        <div class="modal fade" id="DemandeModal" tabindex="-1" aria-labelledby="exampleModalLabel" data-backdrop="static" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Nouvelle demande</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <form action="#" method="POST" class="form" id="facture-form" enctype="multipart/form-data">
                            @csrf
                            <div class="bs-stepper">
                                <input type="text" name="id" id="id_demande_facture">
                                <div class="modal-body" id="facture">

                                </div>
                            </div>
                            <div class="modal-footer ">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
                                <button type="submit" id="enr_facture" class="btn btn-primary">Enregistrer</button>
                            </div>
                        </form>
                        <input type="hidden" name="count" id="add_more" value="1" />
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
        </div>
        <!-- Fin ajouter une demande -->

        <!-- Modification -->
        {{-- Modication --}}
        <div class="modal fade" id="modifDemandeModal" tabindex="-1" aria-labelledby="exampleModalLabel" data-bs-backdrop="static" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Modifier une demande</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <form action="#" method="POST" class="form" id="edt-demande-form" enctype="multipart/form-data">
                            @csrf
                            <input type="text" name="id" id="id_demande">
                            <div class="modal-body" id="show_demande">


                            </div>
                            <div class="modal-footer ">
                                <button type="button" id="ajoute" class="btn badge-danger mr-2" onclick="add_more1()">Ajouter une facture</button>
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
                                <button type="submit" id="edt_demande" class="btn btn-primary">Enregistrer les modifications</button>
                            </div>
                        </form>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
        </div>
        {{-- Fin modication --}}
        <!-- Fin modification -->

        <!-- Refus -->
        {{-- Refus --}}
        <div class="modal fade" id="ShowDemandeModal" tabindex="-1" aria-labelledby="exampleModalLabel" data-backdrop="static" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" id="modal-titre">Visualisation d'une demande</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    </div>

                    <div class="modal-body" id="show">

                    </div>

                    <div class="modal-footer" id="foot">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
                    </div>
                </div>
            </div>
        </div>
        {{-- Fin refus --}}
        <!-- Fin refus -->

        <!-- Refus -->
        {{-- Refus chargement --}}
        <div class="modal fade" id="RefusDemandeModal1" tabindex="-1" aria-labelledby="exampleModalLabel" data-backdrop="static" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Motif de refus</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    </div>
                    <form action="#" method="POST" class="form" id="refus_demande" enctype="multipart/form-data">
                        @csrf
                        <h3 style="color:red;"></h3>

                        <input type="hidden" name="id" id="idd">

                        <div class="form-step form-step-active">
                            <div class="input-group" style="width: 100%;">
                                <textarea name="refu1" class="form-control" maxlength="120" id="refu1" cols="30" rows="5" readonly></textarea>
                            </div>
                        </div>
                        <div class="modal-footer" id="foot">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        {{-- Fin refus --}}
        <!-- Fin refus -->

        <!-- Affichage en mode formulaire -->
        {{-- Affichage --}}
        <div class="modal fade" id="showDemandeModal" tabindex="-1" aria-labelledby="exampleModalLabel" data-backdrop="static" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Affichage des informations de cession </h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <form action="#" method="POST" class="form" id="aff-demande" enctype="multipart/form-data">
                            @csrf
                            <input type="hidden" name="id" id="id_demande">
                            <div class="bs-stepper">
                                <div class="bs-stepper-header" role="tablist">
                                    <!-- your steps here -->
                                    <div class="step active" data-target="#logins-part">
                                        <button type="button" class="step-trigger" role="tab" aria-controls="logins-part" id="logins-part-trigger" aria-selected="true">
                                            <span class="bs-stepper-circle">1</span>
                                            <span class="bs-stepper-label" style="color: #007bff;">Demande d'autorisation</span>
                                        </button>
                                    </div>
                                    <div class="line"></div>
                                    <div class="step" data-target="#information-part">
                                        <button type="button" class="step-trigger" role="tab" aria-controls="information-part" id="information-part-trigger" disabled="disabled">
                                            <span class="bs-stepper-circle">2</span>
                                            <span class="bs-stepper-label">Chargement</span>
                                        </button>
                                    </div>
                                    <div class="line"></div>
                                    <div class="step" data-target="#information-part">
                                        <button type="button" class="step-trigger" role="tab" aria-controls="information-part" id="information-part-trigger" disabled="disabled">
                                            <span class="bs-stepper-circle">3</span>
                                            <span class="bs-stepper-label">Déchargement</span>
                                        </button>
                                    </div>
                                </div>

                                <div class="modal-body">
                                    <div class="form-step form-step-active" style="font-size: 17px; margin-left: 1.5rem; color:black;">
                                        <div class="input-group">
                                            <label for="date" style="font-weight:bold;">Date prévisionnelle de cession : <span id="dprev" style="font-weight: lighter;"></span></label>
                                        </div>
                                        <div class="form-groups" id="exportateur">
                                            <span><label for="exampleInputEmail3" style="color:red;">Informations de l'exportateur</label></span>
                                            <div class="input-group">
                                                <label for="date" style="font-weight:bold;">Code agrément : <span id="numagr" style="font-weight: lighter;"></span></label>
                                            </div>
                                            <div class="input-group">
                                                <label for="date" style="font-weight:bold;">Nom exportateur : <span id="nomexp" style="font-weight: lighter;"></span></label>
                                            </div>
                                            <div class="input-group">
                                                <label for="maga" style="font-weight:bold;">Magasin : <span id="mag" style="font-weight: lighter;"></span></label>
                                            </div>
                                        </div>
                                        <div class="form-groups" id="receveur">
                                            <span><label for="exampleInputEmail3" style="color:red;">Informations de l'acquéreur</label></span>
                                            <div class="input-group">
                                                <label for="date" style="font-weight:bold;">Code agrément : <span id="ach" style="font-weight: lighter;"></span></label>
                                            </div>
                                            <div class="input-group">
                                                <label for="date" style="font-weight:bold;">Nom de l'acquéreur : <span id="nomacq" style="font-weight: lighter;"></span></label>
                                            </div>
                                        </div>
                                        <div class="form-groups" id="produit_box1">
                                            <span><label for="exampleInputEmail3" style="color:red;">Paiement</label></span>
                                            <div class="input-group">
                                                <label for="date" style="font-weight:bold;">Date de paiment : <span id="dpay" style="font-weight: lighter;"></span></label>
                                            </div>
                                            <div class="input-group">
                                                <label for="date" style="font-weight:bold;">Mode de paiement : <span id="mopay" style="font-weight: lighter;"></span></label>
                                            </div>
                                            <div class="input-group">
                                                <label for="date" style="font-weight:bold;">Montant du paiement (FCA) : <span id="mtpay" style="font-weight: lighter;"></span></label>
                                            </div>
                                            <div class="input-group">
                                                <label for="date" style="font-weight:bold;">Références du paiement : <span id="Rpay" style="font-weight: lighter;"></span></label>
                                            </div>
                                        </div>
                                        <div class="form-groups">
                                            <span><label for="exampleInputEmail3" style="color:red;">Fiches de cession concernées
                                                </label></span>
                                            <div class="row" id="liste_fiche1" style="width: 100%">

                                            </div>
                                        </div>

                                    </div>
                                </div>
                                <input type="hidden" name="nombre" id="nombre">
                            </div>
                            <div class="modal-footer ">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
                            </div>
                        </form>
                        <input type="hidden" name="add_more1" id="add_more1" />
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
        </div>
        {{-- Fin Affichage --}}
        <!-- Fin affichage en mode formulaire -->

        <!-- Soumission -->
        {{-- Soumettre --}}
        <div class="modal fade" id="soumettreDemandeModal" tabindex="-1" aria-labelledby="exampleModalLabel" data-backdrop="static" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Soumission d'une demande de cession</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <form action="#" method="POST" class="form" id="sou_dem" enctype="multipart/form-data">
                            @csrf

                            <input type="hidden" name="id" id="iddem">

                            <div class="form-groups">

                                <div class="form-group">
                                    <label for="exampleInputFile">Fiche de demande signée et cachetée</label>
                                    <div class="input-group">
                                        <input type="hidden" name="fichenames" id="fichename" placeholder="Aucun fichier choisi" class="form-control">
                                        <div class="custom-file">
                                            <input type="file" name="fichededemande" class="custom-file-input" id="fichededemande">
                                            <label id="fichenames" class="custom-file-label" for="exampleInputFile">Aucun fichier choisi</label>
                                        </div>
                                        <!-- <div class="input-group-append">
										<span id="btn-eye" class="input-group-text" style="background-color: #16B84E; border-color: #16B84E; border: 1px;"><i class="fas fa-eye" aria-hidden="true" style="color: #ffffff;"></i></span>
									</div> -->
                                    </div>
                                </div>
                                <div id="viewpdf"></div>

                            </div>
                    </div>
                    <div class="modal-footer" id="foot">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
                        <button type="submit" id="soumettre_btn" class="btn btn-primary">Soumettre</button>
                    </div>
                    </form>
                </div>
            </div>
        </div>
        {{-- Fin soumettre --}}
        <!-- Fin soumission -->

        <!-- Chargement -->
        {{-- Chargement --}}
        <div class="modal fade" id="charDemandeModal" tabindex="-1" aria-labelledby="exampleModalLabel" data-bs-backdrop="static" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Saisie des informations de chargement du Stock à céder</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <form action="#" method="POST" class="form" id="char_demande" enctype="multipart/form-data">
                            @csrf
                            <input type="hidden" name="id_demande1" id="id_demande1">
                            <div class="bs-stepper">
                                <div class="bs-stepper-header" role="tablist">
                                    <!-- your steps here -->
                                    <div class="step " data-target="#logins-part">
                                        <button type="button" class="step-trigger" role="tab" aria-controls="logins-part" id="logins-part-trigger" disabled="disabled">
                                            <span class="bs-stepper-circle">1</span>
                                            <span class="bs-stepper-label">Demande d'autorisation</span>
                                        </button>
                                    </div>
                                    <div class="line"></div>
                                    <div class="step active" data-target="#information-part">
                                        <button type="button" class="step-trigger" role="tab" aria-controls="information-part" id="information-part-trigger" aria-selected="true">
                                            <span class="bs-stepper-circle">2</span>
                                            <span class="bs-stepper-label" style="color: #007bff;">Chargement</span>
                                        </button>
                                    </div>
                                    <div class="line"></div>
                                    <div class="step" data-target="#information-part">
                                        <button type="button" class="step-trigger" role="tab" aria-controls="information-part" id="information-part-trigger" disabled="disabled">
                                            <span class="bs-stepper-circle">3</span>
                                            <span class="bs-stepper-label">Déchargement</span>
                                        </button>
                                    </div>
                                </div>

                                <div class="modal-body">

                                    <div class="form-step form-step-active">
                                        <div class="form-group">
                                            <label>Date de chargement</label>
                                            <input type="date" name="datechar" id="datechar" class="form-control" required>
                                        </div>


                                        <div class="form-group form-animate-text" id="magasin_exp_ach" style="margin-top:40px !important;">

                                        </div>

                                        <div class="form-groups" style="font-size: 17px; margin-left: 1.5rem; color:black;">
                                            <span><label for="exampleInputEmail3">Fiches de chargement concernées
                                                </label></span>
                                            <div class="row" id="listefiche2">

                                            </div>
                                            <input type="hidden" name="add" id="add" />
                                            <input type="hidden" name="id_sup" id="id_sup" />
                                        </div>
                                    </div>

                                </div>
                            </div>
                            <div class="modal-footer ">
                                <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
                                <button type="submit" class="btn btn-primary">Envoyer les informations</button>
                            </div>
                        </form>
                        <input type="hidden" name="add_more2" id="add_more2" />
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
        </div>
        {{-- Fin chargement --}}
        <!-- Fin chargement -->

        <!-- Affiche des informations de chargement -->
        {{-- Affiche chargement --}}
        <div class="modal fade" id="charAfficheDemandeModal" tabindex="-1" aria-labelledby="exampleModalLabel" data-backdrop="static" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Affichage des informations de chargement du Stock à céder</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    </div>
                    <form action="#" method="POST" class="form" id="char_demande" enctype="multipart/form-data">
                        @csrf
                        <input type="hidden" name="id_demande1" id="id_demande1">
                        <div class="bs-stepper">
                            <div class="bs-stepper-header" role="tablist">
                                <!-- your steps here -->
                                <div class="step " data-target="#logins-part">
                                    <button type="button" class="step-trigger" role="tab" aria-controls="logins-part" id="logins-part-trigger" disabled="disabled">
                                        <span class="bs-stepper-circle">1</span>
                                        <span class="bs-stepper-label">Demande d'autorisation</span>
                                    </button>
                                </div>
                                <div class="line"></div>
                                <div class="step active" data-target="#information-part">
                                    <button type="button" class="step-trigger" role="tab" aria-controls="information-part" id="information-part-trigger" aria-selected="true">
                                        <span class="bs-stepper-circle">2</span>
                                        <span class="bs-stepper-label" style="color: #007bff;">Chargement</span>
                                    </button>
                                </div>
                                <div class="line"></div>
                                <div class="step" data-target="#information-part">
                                    <button type="button" class="step-trigger" role="tab" aria-controls="information-part" id="information-part-trigger" disabled="disabled">
                                        <span class="bs-stepper-circle">3</span>
                                        <span class="bs-stepper-label">Déchargement</span>
                                    </button>
                                </div>
                            </div>
                            <div class="form-step form-step-active" style="font-size: 17px; margin-left: 1.5rem; color:black;">
                                <div class="input-groups">
                                    <label for="maga" style="font-weight:bold;">Référence de la demande : <span id="ref_demande" style="font-weight:lighter;"></span></label>
                                </div>
                                <div class="input-groups">
                                    <label for="date" style="font-weight:bold;">Date de chargement : <span id="d_chargement" style="font-weight:lighter;"></span></label>
                                </div>
                                <div class="input-groups">
                                    <label for="date" style="font-weight:bold;">Magasin de destination : <span id="m_dest" style="font-weight:lighter;"></span></label>
                                </div>
                                <div class="form-groups">
                                    <span><label for="exampleInputEmail3">Fiches de chargement concernées
                                        </label></span>
                                    <div class="row" id="listedesfiche2">

                                    </div>
                                    <input type="hidden" name="add" id="add" />
                                    <input type="hidden" name="id_sup" id="id_sup" />
                                </div>
                            </div>
                        </div>

                        <div class="modal-footer" id="foot">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
                        </div>
                    </form>
                    <input type="hidden" name="add_more2" id="add_more2" />
                </div>
            </div>
        </div>
        {{-- Fin affichage --}}
        <!-- Fin affichage -->

        <!-- Historique -->
        {{-- Historique --}}
        <div class="col-md-12">
            <div class="panel-body">
                <div class="col-md-12">
                    <div class="modal fade" id="HistoriqueModal" tabindex="-1" aria-labelledby="exampleModalLabel" data-backdrop="static" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title" style="font-weight: bold; color:black;" id="inf"></h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                </div>
                                <div class="modal-body" id="historique-area">

                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
                                </div>
                            </div><!-- /.modal-content -->
                        </div><!-- /.modal-dialog -->
                    </div><!-- /.modal -->
                </div>
            </div>
        </div>
        {{-- Fin historique --}}
        <!-- Fin historique -->
    </div>
</section>
@endsection