<div>
    <?php echo $__env->make('layouts.commons.success', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <?php echo $__env->make('layouts.commons.errors', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

    <div class="pb-3">
        <h4>Membres de l'équipe projet</h4>
    </div>

    
    <div class="row">
        
        <div class="col-8">
            <?php if(sizeof($projet->membres_projets) > 0): ?>
                <table id="membres" class="table table-striped table-bordered">
                    <thead>
                    <tr>
                        <th>Nom</th>
                        <th>Établissement</th>
                        <?php if(Auth::user()->can('edit_projet') && $editable): ?>
                            <th>Action</th>
                        <?php endif; ?>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $__currentLoopData = $projet->membres_projets; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $mp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($mp->user->nom_complet()); ?></td>
                            <td><?php if(isset($mp->user->direction)): ?> <?php echo e($mp->user->direction->nom); ?> <?php else: ?> - <?php endif; ?></td>
                            <?php if(Auth::user()->can('edit_projet') && $editable): ?>
                                <td style="width: 5%">
                                    <form class="inline-form-table" action="<?php echo e(route('projets.supprimer-membre', [$projet->id, $mp->user->id])); ?>" method="POST">
                                        <?php echo csrf_field(); ?>
                                        <?php echo e(method_field('DELETE')); ?>

                                        <button type="submit" class="btn btn-outline-danger"
                                            data-toggle="tooltip" data-placement="top" title="Supprimer">
                                            <i class="fas fa-trash-alt"></i>
                                        </button>
                                    </form>
                                </td>
                            <?php endif; ?>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            <?php else: ?>
                <div class="pt-2">
                    <h4>Pas de données disponible.</h4>
                </div>
            <?php endif; ?>
        </div>

        
        <?php if(Auth::user()->can('edit_projet') && $editable): ?>
            <div class="col-4">
                <span>Sélectionner ou rechercher le nom souhaité</span>
                <form method="POST" action="<?php echo e(route('projets.ajouter-membre', $projet->id)); ?>">
                    <?php echo csrf_field(); ?>
                    <?php echo e(method_field('PUT')); ?>


                    <select id="select-membre-projet" name="membre" style="width: 100%">
                        <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($u->id); ?>"><?php echo e($u->nom_complet()); ?><?php if(isset($u->direction)): ?> <?php echo e(' - ' . $u->direction->nom); ?> <?php endif; ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                    <button class="btn btn-outline-success float-right mt-3" type="submit">Enregistrer</button>
                </form>
            </div>
        <?php endif; ?>
    </div>


    <hr class="mt-5 mb-5">


    <div class="pb-3">
        <div class="row">
            <div class="col-11">
                <h4>Tâches du projet</h4>
            </div>
            <?php if($editable): ?>
                <div class="col-1">
                    <a href="<?php echo e(route('taches.create', $projet->id)); ?>" class="btn btn-outline-success float-right">Ajouter</a>
                </div>
            <?php endif; ?>
        </div>
    </div>

    
    <div class="row">
        <div class="col-12">
            <?php if(sizeof($projet->taches) > 0): ?>
                <table id="membres" class="table table-striped table-bordered">
                    <thead>
                    <tr>
                        <th>Tâche</th>
                        <th>Description</th>
                        <th>Responsable</th>
                        <th>Date de début</th>
                        <th>Date de fin</th>
                        <th>Charge estimée</th>
                        <?php if(Auth::user()->can('edit_projet') && $editable): ?>
                            <th>Actions</th>
                        <?php endif; ?>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $__currentLoopData = $projet->taches; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td><?php echo e($t->nom); ?></td>
                            <td><?php echo e($t->description ?? '-'); ?></td>
                            <td><?php echo e($t->responsable->nom_complet()); ?></td>
                            <td><?php echo e(date('d/m/Y', strtotime($t->date_debut))); ?></td>
                            <td><?php echo e(date('d/m/Y', strtotime($t->date_fin))); ?></td>
                            <td><?php echo e($t->nb_jours); ?> jour<?php echo e($t->nb_jours > 1 ? 's' : ''); ?></td>
                            <?php if(Auth::user()->can('edit_projet') && $editable): ?>
                                <td style="width: 12%">
                                    <a class="btn btn-outline-primary" href="<?php echo e(route('taches.edit', [$projet->id, $t->id])); ?>"
                                        data-toggle="tooltip" data-placement="top" title="Editer">
                                        <i class="fas fa-pencil-alt"></i>
                                    </a>
                                    <form class="inline-form-table" action="<?php echo e(route('taches.destroy', [$projet->id, $t->id])); ?>" method="POST">
                                        <?php echo csrf_field(); ?>
                                        <?php echo e(method_field('DELETE')); ?>

                                        <button type="submit" class="btn btn-outline-danger"
                                            data-toggle="tooltip" data-placement="top" title="Supprimer">
                                            <i class="fas fa-trash-alt"></i>
                                        </button>
                                    </form>
                                </td>
                            <?php endif; ?>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
            <?php else: ?>
                <div class="pt-2">
                    <h4>Pas de données disponible.</h4>
                </div>
            <?php endif; ?>
        </div>
    </div>
</div>

<script>
    $(document).ready(function() {
        $('#select-membre-projet').select2();
    });
</script>
<?php /**PATH /var/www/html/resources/views/projets/form/onglets/gestion-projet.blade.php ENDPATH**/ ?>