<form method="post" action="<?php echo e(route('home.filtres')); ?>">
    <?php echo csrf_field(); ?>

    <div class="row">
        
        <?php if(!Auth::user()->hasRole(ROLE::RESPONSABLE_PERFORMANCE_ARS)): ?>
        <div class="col-md-3">
            <div class="form-group row">
                <label for="paat" class="col-sm-4 col-form-label">PAAT</label>
                <div class="col-sm-8">
                    <select id="filtre_paat" name="paat_id" class="form-control">
                        <?php $__currentLoopData = $paats; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $id => $description): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($id); ?>" <?php if($paat_id==$id): ?> selected <?php endif; ?>><?php echo e($description); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
        </div>
        <?php endif; ?>
        
        <div class="col-md-3">
            <div class="form-group row">
                <label for="date_debut" class="col-md-4 col-form-label text-md-right">Du</label>
                <div class="col-md-8">
                    <div class="input-group">
                        <input id="date_debut" type="text" class="form-control" name="date_debut"
                            value="<?php echo e(date('d/m/Y', strtotime($date_debut))); ?>">
                        <div class="input-group-append">
                            <span class="input-group-text">
                                <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-calendar3"
                                    fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                                    <path fill-rule="evenodd"
                                        d="M14 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM1 3.857C1 3.384 1.448 3 2 3h12c.552 0 1 .384 1 .857v10.286c0 .473-.448.857-1 .857H2c-.552 0-1-.384-1-.857V3.857z" />
                                    <path fill-rule="evenodd"
                                        d="M6.5 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm-9 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm-9 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2z" />
                                </svg>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="col-md-3">
            <div class="form-group row">
                <label for="date_fin" class="col-md-4 col-form-label text-md-right">au</label>
                <div class="col-md-8">
                    <div class="input-group">
                        <input id="date_fin" type="text" class="form-control" name="date_fin"
                            value="<?php echo e(date('d/m/Y', strtotime($date_fin))); ?>">
                        <div class="input-group-append">
                            <span class="input-group-text">
                                <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-calendar3"
                                    fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                                    <path fill-rule="evenodd"
                                        d="M14 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM1 3.857C1 3.384 1.448 3 2 3h12c.552 0 1 .384 1 .857v10.286c0 .473-.448.857-1 .857H2c-.552 0-1-.384-1-.857V3.857z" />
                                    <path fill-rule="evenodd"
                                        d="M6.5 7a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm-9 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm-9 3a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm3 0a1 1 0 1 0 0-2 1 1 0 0 0 0 2z" />
                                </svg>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <?php if($utilisateurs != null): ?>
        <div class="col-md-3">
            <div class="form-group row">
                <label for="utilisateur_id" class="col-sm-4 col-form-label">Utilisateur</label>
                <div class="col-sm-8">
                    <select id="utilisateur_id" name="utilisateur_id" class="form-control">
                        <option value="">Tous</option>
                        <?php $__currentLoopData = $utilisateurs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($u->id); ?>" <?php if($utilisateur_id==$u->id): ?> selected
                            <?php endif; ?>><?php echo e($u->nom_complet()); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
        </div>
        <?php endif; ?>
    </div>
    <div class="row">
        
        <div class="col-md-3">
            <div class="form-group row">
                <label for="famille_id" class="col-sm-4 col-form-label">Famille</label>
                <div class="col-sm-8">
                    <select id="famille_id" name="famille_id" class="form-control">
                        <option value="">Tous</option>
                        <?php $__currentLoopData = $familles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $f): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($f->id); ?>" <?php if($famille_id==$f->id): ?> selected <?php endif; ?>><?php echo e($f->nom); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
        </div>
        
        <div class="col-md-3">
            <div class="form-group row">
                <label for="domaine_id" class="col-sm-4 col-form-label">Domaine</label>
                <div class="col-sm-8">
                    <select id="domaine_id" name="domaine_id" class="form-control">
                        <option value="">Tous</option>
                        <?php $__currentLoopData = $domaines; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($d->famille_id . '_' . $d->id); ?>" <?php if($d->famille_id . '_' . $d->id ===
                            $d->famille_id . '_' . $domaine_id): ?> selected <?php endif; ?>
                            <?php if($d->famille_id != $famille_id): ?> style="display: none" <?php endif; ?>>
                            <?php echo e($d->nom); ?>

                        </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
        </div>
        
        <div class="col-md-3">
            <div class="form-group row">
                <label for="categorie_id" class="col-sm-4 col-form-label">Catégorie</label>
                <div class="col-sm-8">
                    <select id="categorie_id" name="categorie_id" class="form-control">
                        <option value="">Tous</option>
                        <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($c->domaine_id . '_' . $c->id); ?>" <?php if($c->domaine_id . '_' . $c->id ===
                            $c->domaine_id . '_' . $categorie_id): ?> selected <?php endif; ?>
                            <?php if($c->domaine_id != $domaine_id): ?> style="display: none" <?php endif; ?>>
                            <?php echo e($c->nom); ?>

                        </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
        </div>
        
        <div class="col-md-3">
            <div class="form-group row">
                <label for="segment_id" class="col-sm-4 col-form-label">Segment</label>
                <div class="col-sm-8">
                    <select id="segment_id" name="segment_id" class="form-control">
                        <option value="">Tous</option>
                        <?php $__currentLoopData = $segments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $s): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($s->categorie_id . '_' . $s->id); ?>" <?php if($s->categorie_id . '_' . $s->id ===
                            $s->categorie_id . '_' . $segment_id): ?> selected <?php endif; ?>
                            <?php if($s->categorie_id != $categorie_id): ?> style="display: none" <?php endif; ?>>
                            <?php echo e($s->nom); ?>

                        </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="form-group">
            <button type="submit" class="btn btn-outline-primary">
                <i class="fas fa-filter"></i>
                Filtrer
            </button>
            

            <?php if(Auth::user()->can('export_indicateurs') || Auth::user()->hasRole(ROLE::RESPONSABLE_PERFORMANCE_ARS)): ?>
            <?php if($show_export_button): ?>
            <a class="btn btn-outline-primary" data-toggle="modal" data-target="#modal-export-pdf">
                <i class="far fa-file-pdf" style="color: red;"></i>
                Exporter</button>
            </a>
            <?php else: ?>
            <span class="d-inline-block" tabindex="0" data-toggle="tooltip" title="Pas de donnée à exporter">
                <button type="button" class="btn btn-outline-primary" style="pointer-events: none;" disabled>
                    <i class="far fa-file-pdf" style="color: red;"></i>
                    Exporter</button>
            </span>
            <?php endif; ?>
            <button type="button" class="btn btn-outline-primary" data-toggle="modal"
                data-target="#modal-historique-pdf">
                <i class="far fa-file-pdf" style="color: red;"></i>
                Historique
            </button>
            <?php endif; ?>
            <?php if(auth()->check() && auth()->user()->hasRole(ROLE::RESPONSABLE_PERFORMANCE_ARS)): ?>
            <button type="button" class="btn btn-outline-primary ml-auto" data-toggle="modal"
                data-target="#modal-export-paats-resp-ars">
                <i class="far fa-file-excel" style="color: green;"></i>
                Exporter
            </button>
            <?php endif; ?>
        </div>
    </div>
</form>


<?php if(Auth::user()->can('export_indicateurs') || Auth::user()->hasRole(ROLE::RESPONSABLE_PERFORMANCE_ARS)): ?>
<div class="modal fade" id="modal-export-pdf" tabindex="-1" aria-labelledby="modal-export-pdf" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Commentaires du rapport d'activité</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form id="form-export-pdf" action="<?php echo e(route('home.save_export_pdf')); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>

                    <div class="form-group">
                        <label for="modal-export-pdf-titre">Titre du rapport</label>
                        <input type="text" class="form-control" id="modal-export-pdf-titre"
                            name="modal-export-pdf-titre" required
                            value="<?php echo e(old('modal-export-pdf-titre', $user_rapport_activite ? $user_rapport_activite->titre : '')); ?>">
                    </div>

                    <div class="form-group">
                        <label for="modal-export-pdf-date-paat">Date du PAAT</label>
                        <input type="text" class="form-control" id="modal-export-pdf-date-paat"
                            name="modal-export-pdf-date-paat" required
                            value="<?php echo e(old('modal-export-pdf-date-paat', $user_rapport_activite ? $user_rapport_activite->date_paat : '')); ?>">
                    </div>

                    <div class="form-group">
                        <label for="modal-export-pdf-periode-reference">Période de référence</label>
                        <input type="text" class="form-control" id="modal-export-pdf-periode-reference"
                            name="modal-export-pdf-periode-reference" required
                            value="<?php echo e(old('modal-export-pdf-periode-reference', $user_rapport_activite ? $user_rapport_activite->periode_reference : '')); ?>">
                    </div>

                    <div class="form-group">
                        <label for="modal-export-pdf-commentaires">Commentaires</label>
                        <textarea class="form-control" id="modal-export-pdf-commentaires"
                            name="modal-export-pdf-commentaires" required
                            rows="3"><?php echo e($user_rapport_activite ? $user_rapport_activite->commentaires : ''); ?></textarea>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
                <button type="submit" class="btn btn-primary" form="form-export-pdf">
                    <i class="far fa-save"></i>
                    Sauvegarder
                </button>
                <button type="button" class="btn btn-success" id="exporter_pdf">
                    <i class="fas fa-download"></i>
                    Télécharger
                </button>
            </div>
        </div>
    </div>
</div>
<?php endif; ?>


<div class="modal fade" id="modal-export-paats-resp-ars" tabindex="-1" aria-labelledby="modal-export-paats-resp-ars"
    aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Exporter les données des PAAT</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form id="form-export-paats-resp-ars" action="<?php echo e(route('home.export_paats_resp_ars')); ?>" method="GET">
                    <?php echo method_field('GET'); ?>

                    <div class="form-group">
                        <label for="annee-export-paats-resp-ars">Année référence PAAT</label>
                        <select class="form-control" id="annee-export-paats-resp-ars"
                            name="annee-export-paats-resp-ars">
                            <option value="-1">Toutes</option>
                            <?php $__currentLoopData = $liste_paat_annees; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $annee): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($annee->id); ?>"><?php echo e($annee->annee_reference); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>

                    <div class="form-group">
                        <label for="structure-export-paats-resp-ars">Structure</label>
                        <select class="form-control" id="structure-export-paats-resp-ars"
                            name="structure-export-paats-resp-ars">
                            <option value="-1">Toutes</option>
                            <?php $__currentLoopData = $liste_structures; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $structure): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($structure->id); ?>"><?php echo e($structure->nom); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
                <button type="submit" class="btn btn-success ml-auto" form="form-export-paats-resp-ars">
                    <i class="far fa-file-excel"></i>
                    Télécharger
                </button>
            </div>
        </div>
    </div>
</div>



<?php if(Auth::user()->can('export_indicateurs') || Auth::user()->hasRole(ROLE::RESPONSABLE_PERFORMANCE_ARS)): ?>
<div class="modal fade" id="modal-historique-pdf" tabindex="-1" aria-labelledby="modal-historique-pdf" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Historique des exports</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <?php if(sizeof($user_liste_rapports_activite) === 0): ?>
                    <div class="h6">Pas de données disponible.</div>
                <?php else: ?>
                    <table class="table table-striped table-bordered">
                        <thead>
                            <tr>
                                <th>Titre</th>
                                <th>Date</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php $__currentLoopData = $user_liste_rapports_activite; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $export): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <tr>
                                <td><?php echo e($export->titre); ?></td>
                                <td style="width: 10%"><?php echo e(Carbon\Carbon::createFromFormat('Y-m-d', $export->date_rapport)->format('d/m/Y')); ?></td>
                                <td style="width: 20%">
                                    <?php if(isset($export->fichier_id)): ?>
                                        <a class="btn btn-primary" href="<?php echo e(route('fichiers.download_export_pdf', $export->fichier_id ?? -1)); ?>"
                                            data-toggle="tooltip" data-placement="top" title="Télécharger">
                                            <i class="fas fa-file-pdf" style="color: red;"></i>
                                        </a>
                                        <form class="inline-form-table" action="<?php echo e(route('fichiers.notify_export_pdf', [ $export->fichier_id, ROLE::DIRECTEUR_ACHAT ])); ?>" method="POST">
                                            <?php echo csrf_field(); ?>
                                            <?php echo e(method_field('PUT')); ?>

                                            <button type="submit" class="btn btn-primary"
                                                data-toggle="tooltip" data-placement="top" title="Notifier directeur achat">
                                                <i class="fas fa-bell" style="color: yellow;"></i>
                                            </button>
                                        </form>
                                        <form class="inline-form-table" action="<?php echo e(route('fichiers.notify_export_pdf', [ $export->fichier_id, ROLE::RESPONSABLE_PERFORMANCE_ARS ])); ?>" method="POST">
                                            <?php echo csrf_field(); ?>
                                            <?php echo e(method_field('PUT')); ?>

                                            <button type="submit" class="btn btn-primary"
                                                data-toggle="tooltip" data-placement="top" title="Notifier responsable performance ARS">
                                                <i class="fas fa-bell" style="color: yellow;"></i>
                                            </button>
                                        </form>
                                    <?php else: ?>
                                        <span class="d-inline-block" tabindex="0" data-toggle="tooltip" title="Pas de rapport d'enregistré">
                                            <button type="button" class="btn btn-primary" style="pointer-events: none;" disabled>
                                                <i class="fas fa-file-pdf" style="color: red;"></i>
                                            </button>
                                        </span>
                                        <span class="d-inline-block" tabindex="0" data-toggle="tooltip" title="Impossible de notifier">
                                            <button type="button" class="btn btn-primary" style="pointer-events: none;" disabled>
                                                <i class="fas fa-bell" style="color: yellow;"></i>
                                            </button>
                                        </span>
                                    <?php endif; ?>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </tbody>
                    </table>
                <?php endif; ?>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
            </div>
        </div>
    </div>
</div>

<meta name="_token" content="<?php echo e(csrf_token()); ?>">
<?php endif; ?><?php /**PATH /var/www/html/resources/views/home/filtres/filtres.blade.php ENDPATH**/ ?>