<?php $__env->startSection('title', 'Add new parent'); ?>
<?php $__env->startSection('link'); ?>
<style>
    #blinks {
        color: red !important;
        font-size: 15px !important;
        animation: blinker 1.5s linear infinite;
    }
    @keyframes blinker {  
      50% { opacity: 0; }
    }
</style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<div class="pcoded-inner-content">
    <?php echo $__env->make('includes._alert', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <div class="main-body">
        <div class="page-wrapper">
            <div class="page-body">
                <div class="card px-2">
                    <div class="card-header my-0 pb-0">
                        <div class="d-flex justify-content-between mb-2">                        
                            <h4>Parent en charge des études</h4>
                            <span class="form-control-variant">Les champ avec asterisk (<code>*</code>) sont obligatoires.</span>
                            <span>
                                <?php if(!$parent): ?>
                                <a href="<?php echo e(route('parent.create')); ?>" class="btn btn-inverse btn-outline-inverse  btn-sm py-1 mr-2" title="Refresh page" id="btnActual" style="display: none"><i class="fas fa-sync m-0"></i></a>
                                <?php endif; ?>
                                <a href="<?php echo e(route( $parent ? 'parent.index':'inscription.index')); ?>" class="btn btn-inverse btn-outline-inverse  btn-sm py-1" title="Return back"><i class="fas fa-reply m-0"></i></a>
                            </span>
                        </div>
                    </div>
                    <hr class="my-0 mx-3">
                    <span class="form-control-variant text-center mt-3" id="blinks" style="display: none">Parent Existe ...</span>   
                    <div class="card-block mt-3">
                        <form action="<?php echo e(route($parent ? 'parent.update':'parent.store', $parent ? $parent->id:null)); ?>" method="post">
                            <?php echo csrf_field(); ?>
                            <?php echo method_field($parent ? 'put':'post'); ?>
                            <input type="hidden" name="id" value="" id="IdParent">
                            <div class="form-group row">        
                                <label class="col-sm-2 col-form-label text-right" for="phon1">Numéro de téléphone 1<span class="text-danger">*</span> :</label>
                                <div class="col-sm-10">
                                    <input type="text" name="phon1" id="phon1" class="form-control phon1 <?php $__errorArgs = ['phon1'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('phon1', $parent ? $parent->telephon1:null)); ?>" maxlength="10" placeholder="Entrez son numéro de téléphone principal">
                                    <?php $__errorArgs = ['phon1'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <span class="form-bar text-danger" role="alert">
                                            <?php echo e($message); ?>

                                        </span>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label text-right" for="phon2">Numéro de téléphone 2 :</label>
                                <div class="col-sm-10">
                                    <input type="text" name="phon2" id="phon2" class="form-control phon2 <?php $__errorArgs = ['phon2'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('phon2', $parent ? $parent->telephon2:null)); ?>" maxlength="10" placeholder="Entrez son numéro de téléphone 2 (facultatif)">
                                    <?php $__errorArgs = ['phon2'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <span class="form-bar text-danger" role="alert">
                                            <?php echo e($message); ?>

                                        </span>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label text-right" for="firstName">Nom<span class="text-danger">*</span> :</label>
                                <div class="col-sm-10">
                                    <input type="text" name="firstName" id="firstName" class="form-control <?php $__errorArgs = ['firstName'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('firstName', $parent ? $parent->first_name:null)); ?>" placeholder="Entre son nom ...">
                                    <?php $__errorArgs = ['firstName'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <span class="form-bar text-danger" role="alert">
                                            <?php echo e($message); ?>

                                        </span>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label text-right" for="latsName">Prénoms<span class="text-danger">*</span> :</label>
                                <div class="col-sm-10">
                                    <input type="text" name="latsName" id="latsName" class="form-control <?php $__errorArgs = ['latsName'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('latsName', $parent ? $parent->last_name:null)); ?>" placeholder="Entrez son prénoms ...">
                                    <?php $__errorArgs = ['latsName'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <span class="form-bar text-danger" role="alert">
                                            <?php echo e($message); ?>

                                        </span>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label text-right" for="sexeUser">Sexe<span class="text-danger">*</span> :</label>
                                <div class="col-sm-10">
                                    <span class="mr-3">
                                        <input type="radio" name="sexe" class="checkSexe" id="femme" data-div="F" value="F" <?php echo e(old('sexe') == 'F' ? 'checked':null); ?> <?php echo e($parent ? ($parent->sexe == 'F' ? 'checked':null):null); ?>>
                                        <label for="femme" class="mx-1 form-control-variant">Femme</label>
                                    </span>
                                    <span class="mx-3">
                                        <input type="radio" name="sexe" class="checkSexe" id="homme"data-div="H"  value="H" <?php echo e(old('sexe') == 'H' ? 'checked':null); ?> <?php echo e($parent ? ($parent->sexe == 'H' ? 'checked':null):null); ?>>
                                        <label for="homme" class="mx-1 form-control-variant">Homme</label>
                                    </span> <br>
                                    <?php $__errorArgs = ['sexe'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <span class="form-bar text-danger" role="alert">
                                            <?php echo e($message); ?>

                                        </span>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label text-right" for="profession">Profession<span class="text-danger">*</span> :</label>
                                <div class="col-sm-10">
                                    <input type="text" name="profession" id="profession" class="form-control <?php $__errorArgs = ['profession'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('profession', $parent ? $parent->profession:null)); ?>" placeholder="Entrez sa profession ...">
                                    <?php $__errorArgs = ['profession'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <span class="form-bar text-danger" role="alert">
                                            <?php echo e($message); ?>

                                        </span>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                </div>
                            </div>
                            <div class="form-group row" id="getMsg" style="display: none">
                                <label class="col-sm-2 col-form-label" for="profession"></label>
                                <div class="col-sm-10">
                                    <label class="mx-2 col-form-label" for="info" id="message"></label>
                                    <input type="checkbox" name="info" id="info" value="1">
                                </div>
                            </div>

                            <?php if($parent): ?>
                            <div class="form-group row">
                                <label class="col-sm-2 col-form-label" for="profession"></label>
                                <div class="col-sm-10">
                                    <span class="mr-3">
                                        <input type="checkbox" name="messagerie" id="messagerie" value="1" <?php echo e($parent->messagerie ? 'checked':null); ?>>
                                        <label for="messagerie" class="mx-1 form-control-variant">Message</label>
                                    </span>
                                    <span class="mx-3">
                                        <input type="checkbox" name="status" id="status" value="1" <?php echo e($parent->status ? 'checked':null); ?>>
                                        <label for="status" class="mx-1 form-control-variant">Status</label>
                                    </span>
                                </div>
                            </div>
                            <?php endif; ?>
                            <hr class="text-center" style="margin-top: 30px">
                            <div class="text-center">
                                <button type="submit" class="btn btn-inverse btn-outline-inverse py-2"> <i class="fas fa-check-circle"></i> Valider cette étape</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script src="<?php echo e(asset('assets/js/pcoded.min.js')); ?>"></script>
<script src="<?php echo e(asset('assets/js/vartical-layout.min.js')); ?>"></script>
<script src="<?php echo e(asset('assets/js/jquery.mCustomScrollbar.concat.min.js')); ?>"></script>
<script>
    $(document).ready(function(){

        $('#phon1,  #phon2').on('keypress', function(e) {
            var charCode = e.which ? e.which : e.keyCode;
            if (charCode < 48 || charCode > 57) {
                e.preventDefault(); // Empêche la saisie si ce n'est pas un chiffre
            }
        });

       // Récherché un parent à partir de son numer de téléphone
       $('#phon1, #phon2').change(function() {
            let val = $(this).val();
            if(val){
                $.ajax({
                    url: '<?php echo e(route('parent.search2')); ?>',
                    method: 'GET',
                    data: {
                        data: val
                    },
                    success: function(response){
                        // Traitez la réponse et mettez à jour l'interface utilisateur
                        if(response['id']){
                            $('#phon1').val(response['telephon1']);
                            $('#phon1').attr('disabled',true);
                            $('#phon2').val(response['telephon2']);
                            $('#phon2').attr('disabled',true);
                            $('#firstName').val(response['first_name']);
                            $('#firstName').attr('disabled',true);
                            $('#latsName').val(response['last_name']);
                            $('#latsName').attr('disabled',true);
                            $('#profession').val(response['profession']);
                            $('#profession').attr('disabled',true);
                            response['sexe'] == 'F' ? $('#femme').attr('checked','checked'):$('#homme').attr('checked','checked')
                            $('#femme').attr('disabled',true); $('#homme').attr('disabled',true);
                            $('#IdParent').val(response['id']);
                            $('#blinks, #btnActual').slideDown();
                        }
                        else{
                            $('#blinks, #btnActual').slideUp();
                        }
                    },
                });
            }
        });

        // Récupérer la valeur de l'attribut 'data-div' de l'élément cliqué
        $('.checkSexe').click(function() {
            if($(this).data('div') == 'H'){
                $('#message').text('Etes-vous le père biologique de l\'enfant ?');
                $('#getMsg').slideDown();
            }
            else if($(this).data('div') == 'F'){
                $('#message').text('Etes-vous la mère biologique de l\'enfant ?');
                $('#getMsg').slideDown();
            }
        });
    })
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/educasnsa/public_html/neuroschool/resources/views/pages/parent/create.blade.php ENDPATH**/ ?>