<?php $__env->startSection('menu'); ?>
    <?php echo $__env->make('admin.menu', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<section class="user-details bg-light py-5">
    <div class="container">
        <div class="card shadow-sm">
            <div class="card-body">
                <h2 class="card-title text-center text-uppercase">Détails de la demande d'inscription</h2>

                <?php if(session('success')): ?>
                    <div class="alert alert-success">
                        <?php echo e(session('success')); ?>

                    </div>
                <?php endif; ?>

                <hr>

                <div class="row">
                    <div class="col-md-6">
                        <p><strong>Nom :</strong> <?php echo e($user->name); ?></p>
                        <p><strong>Prénoms :</strong> <?php echo e($user->surname); ?></p>
                        <p><strong>Téléphone :</strong><?php echo e($user->code_pays . " " . $user->phone); ?></p>
                        <p><strong>Email :</strong> <?php echo e($user->email); ?></p>
                        <p><strong>Date de naissance :</strong><?php echo e(\Carbon\Carbon::createFromFormat('Y-m-d', $user->birthday)->format('d-m-Y')); ?></p>
                        <p><strong>Sexe :</strong> <?php echo e($user->sexe); ?></p>
                        <p><strong>Nationnalité :</strong> <?php echo e($user->nationalite); ?> </p>
                        <p><strong>Statut de la validation d'inscription:</strong>
                            <span class="badge
                                <?php if($user->status == 'accepter'): ?> badge-success
                                <?php elseif($user->status == 'rejeter'): ?> badge-danger
                                <?php else: ?> badge-warning <?php endif; ?>">
                                <?php echo e(ucfirst($user->status)); ?>

                            </span>
                        </p>
                        <p><strong>Date de l'inscription :</strong> <?php echo e((new \DateTime($user->created_at))->format('d/m/Y')); ?></p>
                    </div>

                        <div class="col-md-6">
                        
                        <p><strong>Filière :</strong> <?php echo e($filiere); ?> </p>
                        <p><strong>Niveau de formation :</strong> <?php echo e($niveau); ?> </p>
                        <p><strong>Statut :</strong> <?php echo e($statut); ?></p>
                        <p><strong>Lieu de naissance :</strong><?php echo e($user->birthplace); ?></p>
                            <p><strong>Pièce jointe :</strong></p>

                            <?php if($user->attachment): ?>
                                <!-- Affichage de l'image -->
                                <?php if(in_array(pathinfo($user->attachment, PATHINFO_EXTENSION), ['jpg', 'jpeg', 'png', 'gif'])): ?>
                                    <img src="<?php echo e(asset('storage/' . $user->attachment)); ?>" class="img-fluid mt-3" alt="Attachment">
                                    <br>
                                    <a href="<?php echo e(asset('storage/' . $user->attachment)); ?>" download class="btn btn-primary btn-sm mt-2">
                                        <i class="fas fa-download"></i> Télécharger l'image
                                    </a>
                                <?php endif; ?>

                                <!-- Affichage du PDF -->
                                <?php if(pathinfo($user->attachment, PATHINFO_EXTENSION) == 'pdf'): ?>
                                    <embed src="<?php echo e(asset('storage/' . $user->attachment)); ?>" type="application/pdf" width="100%" height="600px">
                                    <br>
                                    <a href="<?php echo e(asset('storage/' . $user->attachment)); ?>" download class="btn btn-primary btn-sm mt-2">
                                        
                                        Télécharger le PDF
                                    </a>
                                <?php endif; ?>

                                <!-- Message pour les autres types de fichiers -->
                                <?php if(in_array(pathinfo($user->attachment, PATHINFO_EXTENSION), ['docx', 'xlsx', 'pptx'])): ?>
                                    <p>Ce fichier ne peut pas être prévisualisé.</p>
                                    <a href="<?php echo e(asset('storage/' . $user->attachment)); ?>" download class="btn btn-primary btn-sm mt-2">
                                        <i class="fas fa-download"></i> Télécharger pour voir
                                    </a>
                                <?php endif; ?>
                            <?php else: ?>
                                <p>Aucune pièce jointe</p>
                            <?php endif; ?>
                        </div>

                    </div>

                <!-- Action buttons (Accepter et Rejeter) -->
                <?php if($user->status === 'en attente'): ?>
                <div class="text-center mt-4">
                    <button class="btn btn-success btn-sm" data-bs-toggle="modal" data-bs-target="#acceptModal">
                        Accepter
                    </button>
                    <button class="btn btn-danger btn-sm" data-bs-toggle="modal" data-bs-target="#rejectModal">
                        Rejeter
                    </button>
                </div>
                <?php else: ?>

                <?php endif; ?>
                <!-- Retour à la liste -->
                <div class="text-center mt-4">
                    <a href="<?php echo e(route('show-Inscriptions')); ?>" class="btn btn-secondary">Retour à la liste</a>
                </div>
            </div>
        </div>
    </div>
</section>

<!-- Modal pour Accepter -->
<div class="modal fade" id="acceptModal" tabindex="-1" aria-labelledby="acceptModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="acceptModalLabel">Confirmer l'acceptation</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                Êtes-vous sûr de vouloir accepter cette demande d'inscription ?
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Annuler</button>
                <a href="<?php echo e(route('accept-Inscription', $user->id)); ?>" class="btn btn-success">Accepter</a>
            </div>
        </div>
    </div>
</div>

<!-- Modal pour Rejeter -->
<div class="modal fade" id="rejectModal" tabindex="-1" aria-labelledby="rejectModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="rejectModalLabel">Confirmer le rejet</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <form action="<?php echo e(route('reject-Inscription', $user->id)); ?>" method="POST">
                <?php echo csrf_field(); ?>
                <div class="modal-body">
                    <p>Êtes-vous sûr de vouloir rejeter cette demande d'inscription ?</p>
                    <div class="form-group">
                        <label for="rejectionReason">Motif du rejet :</label>
                        <textarea class="form-control" id="rejectionReason" name="rejectionReason" rows="3" required></textarea>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Annuler</button>
                    <button type="submit" class="btn btn-danger">Rejeter</button>
                </div>
            </form>
        </div>
    </div>
</div>


<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>


<?php $__env->stopSection(); ?>


<?php echo $__env->make('layouts.base', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/africawebstudent/public_html/alumnis/resources/views/admin/inscriptionDetails.blade.php ENDPATH**/ ?>