<?php $__env->startSection('content'); ?>
    <div class="container">
        <div class="row">
            <?php echo $__env->make('admin.sidebar', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
            <div class="col-md-9">
                <div class="card">
                    <h3 class="card-header">Créer un nouveau Jury</h3>
                    <div class="card-body">
                        <?php if($type == 'select-filiere'): ?>
                        <a href="<?php echo e(url('/admin/jury')); ?>" title="Back">
                            <button class="btn btn-warning btn-sm">
                                <i class="fa fa-arrow-left" aria-hidden="true"></i>
                                Retour
                            </button>
                        </a>
                        <?php else: ?>
                        <a href="<?php echo e(url('/admin/jury/create')); ?>" title="Back">
                            <button class="btn btn-warning btn-sm">
                                <i class="fa fa-arrow-left" aria-hidden="true"></i>
                                Choix filiere
                            </button>
                        </a>
                        <?php endif; ?>
                        <br />
                        <br />
                        <?php if($errors->any()): ?>
                            <ul class="alert alert-danger">
                                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li><?php echo e($error); ?></li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        <?php endif; ?>
                        <?php if($type == 'select-filiere'): ?>
                        <form
                            method="POST"
                            action="<?php echo e(url('/admin/jury')); ?>"
                            accept-charset="UTF-8"
                            style="display:inline"
                        >
                            <?php echo e(csrf_field()); ?>

                            <div class="form-group <?php echo e($errors->has('id_filiere') ? 'has-error' : ''); ?>">
                                <label for="id_filiere" class="control-label"><?php echo e('Filière'); ?></label>
                                <select name="id_filiere" class="form-control" id="id_filiere" required="required">
                                <?php $__currentLoopData = $filieres; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $filiere): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option
                                        value="<?php echo e($filiere->idFiliere); ?>" <?php echo e((isset($jury->id_filiere) && $jury->id_filiere == $filiere->idFiliere) ? 'selected' : ''); ?>

                                    >
                                        <?php echo e($filiere->intituleFilieres); ?>

                                    </option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                                <input type="hidden" name="_type" value="select-filiere">
                                <?php echo $errors->first('id_filiere', '<p class="help-block">:message</p>'); ?>

                            </div>
                            <div class="form-group">
                                <label for="id_niveau" class="control-label"><?php echo e('Niveau formation'); ?></label>
                                <select name="id_niveau" class="form-control" id="id_niveau" required="required">
                                    <option value="2"> Master </option>
                                    <option value="0"> Master Grade Ingénieur</option>
                                    <option value="1"> Licence </option>
                                </select>
                            </div>
                            <button type="submit" class="btn no-delete btn-primary btn-sm"><i class="fa fa-check-o" aria-hidden="true"></i> Choisir </button>
                        </form>
                        <?php else: ?>
                        <form
                            id="createJuryForm"
                            method="POST"
                            action="<?php echo e(url('/admin/jury')); ?>"
                            accept-charset="UTF-8"
                            class="form-horizontal"
                            enctype="multipart/form-data"
                        >
                            <?php echo e(csrf_field()); ?>

                            <input type="hidden" name="_type" value="submission">
                            <?php echo $__env->make('admin.jury.form', [
                                'formMode' => 'create',
                                'filieres' => $filieres,
                                'membres_jury' => $membres_jury,
                                'etudiants' => $etudiants,
                                'salles' => $salles,
                                'signataires' => $signataires,
                                'type' => $type,
                                'selected_filiere' => $selected_filiere
                            ], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                        </form>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
<script src="<?php echo e(asset('ample-admin-new/plugins/bower_components/jquery/dist/jquery.min.js')); ?>"></script>
<script type="text/javascript">
    $('#createJuryForm').submit(function( event ) {
        event.preventDefault();
        var action = $(this).attr("action");
        var request_method = $(this).attr("method");
        var form_data = $(this).serialize(); //Encode form elements for submission

        $.ajax({
            url : action,
            type: request_method,
            data : form_data
        }).done(function(response) {
            swal({
                title: response.message,
                icon: response.status,
                confirmButtonText:
                'Continue<i class="fa fa-arrow-right"></i>',
            });
            if (response.status == "success") {
                setTimeout(function(){ 
                    window.location = "<?php echo e(url('/admin/jury')); ?>";
                }, 2000);
            }
            if (response.id_jury_conflituel) {
                setTimeout(function(){ 
                    var host = "<?php echo e(url('')); ?>";
                    var url = "/admin/jury/" + response.id_jury_conflituel
                    console.log('host :', host, ',  url:', url)
                    window.open(host  + url);
                    window.focus()
                }, 500);
            }
        });
    });
</script>
<?php $__env->stopSection(); ?>

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