<?php $__env->startSection('title', '| Modifier Région'); ?>

<?php $__env->startSection('content'); ?>

    <div class="content-wrapper">

        <div class="container">
            <div class="content-header">
                <div class="container-fluid">
                    <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0 text-info">GESTION DES PROJETS</h1>
                    </div><!-- /.col -->
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="<?php echo e(route('go.menu', ['projet_id'=>$projet_id])); ?>" role="button" class="btn btn-success">menu</a></li>
                            <li class="breadcrumb-item"><a href="<?php echo e(route('fiche.indicateur.projet', ['projet_id'=>$projet_id])); ?>" role="button" class="btn btn-success">Fiche de suivi des indicateurs</a></li>

                        </ol>
                    </div><!-- /.col -->
                    </div><!-- /.row -->
                </div><!-- /.container-fluid -->
            </div>

        <?php echo Form::model($resultat, ['method'=>'PATCH','route'=>['resultat.update', $resultat->id]]); ?>

            <?php echo csrf_field(); ?>
             <div class="card border-danger border-0">
                        <div class="card-header bg-success text-center">FORMULAIRE DE MODIFICATION RESULTAT</div>
                            <div class="card-body">
                                <?php if($errors->any()): ?>
                                    <div class="alert alert-danger">
                                        <ul>
                                            <?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>
                                    </div>
                                <?php endif; ?>
                                <div class="col-lg-6">
                                    <div class="form-group">
                                        <label>indicateur</label>
                                        <select class="form-control" id="indicateur_id" name="indicateur_id" required="">
                                            <option value="">Selectionnez</option>
                                            <?php $__currentLoopData = $indicateurs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $indicateur): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($indicateur->id); ?>" <?php echo e($indicateur->id == $resultat->indicateur_id ? 'selected' : ''); ?> ><?php echo e($indicateur->indicateur); ?></option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                        </select>
                                    </div>
                                </div>
                                <div class="col-lg-6">
                                    <div class="form-group">
                                        <label>Valeur atteinte</label>
                                        <input type="number" name="rts" value="<?php echo e($resultat->rts); ?>" class="form-control" required>
                                    </div>
                                </div>
                                <div class="containers">
                                    <?php $__currentLoopData = $resultatDetails; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $resultatDetail): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <div class="col-lg-6">
                                        <div class="form-group">
                                            <label>Valeur pour <?php echo e($resultatDetail->titre); ?></label>
                                            <input type="number" name='valeur[]'  value='<?php echo e($resultatDetail->valeur); ?>' class='form-control'  required>
                                            <input type='hidden' name='desagrege_id[]'  value="<?php echo e($resultatDetail->desagrege_id); ?>" class='form-control'  required >
                                        </div>
                                    </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </div>
                                <div class="col-lg-6">
                                    <div class="form-group">
                                        <label>Observation</label>
                                        <textarea name="observation" class="form-control" required> <?php echo e($resultat->observation); ?></textarea>
                                    </div>
                                </div>
                                <div class="col-lg-6">
                                    <div class="form-group">
                                        <label>Date Debut </label>
                                        <input type="date" name="debut"  value="<?php echo e($resultat->debut); ?>" class="form-control"  required>
                                    </div>
                                </div>
                                <div class="col-lg-6">
                                    <div class="form-group">
                                        <label>Date Fin </label>
                                        <input type="date" name="fin"  value="<?php echo e($resultat->fin); ?>" class="form-control"  required>
                                    </div>
                                </div>

                                <div class="col-lg-6">
                                    <div class="form-group">
                                        <label>Commune</label>
                                        <select class="form-control" id="commune_id" name="commune_id" required="">
                                            <option value="">Selectionnez</option>
                                            <?php $__currentLoopData = $communes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $commune): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($commune->id); ?>" <?php echo e($commune->id == $resultat->commune_id ? 'selected' : ''); ?>><?php echo e($commune->nomc); ?></option>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                        </select>
                                    </div>
                                </div>
                                <?php if($projet->typecadre=="Cadre de  resultat"): ?>
                                <div class="col-lg-6">
                                    <label>Année</label>
                                    <select class="form-control" name="annee" required="">
                                        <option value="">Selectionnez</option>
                                        <?php for($i=1; $i <= $projet->duree; $i++): ?>
                                        <option value="<?php echo e($i); ?>" <?php echo e($resultat->annee == 'annee '.$i ? 'selected' : ''); ?>>annee <?php echo e($i); ?></option>
                                        <?php endfor; ?>

                                    </select>
                                </div>
                                <?php endif; ?>
                                <input type="hidden" value="<?php echo e($projet_id); ?>" name="projet_id">
                                <div>
                                    <center>
                                        <button type="submit" class="btn btn-success btn btn-lg "> MODIFIER</button>
                                    </center>
                                </div>


                            </div>
                        </div>
    <?php echo Form::close(); ?>

                </div>
        </div>

    </div>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script type=text/javascript>
    $("#indicateur_id").change(function () {

        //var selectedClasse = $(this).children("option:selected").val();
    var idv =  $("#indicateur_id").children("option:selected").val();
        //alert("You have selected the country - " + idv);
        var numero_id = "";
        $.ajax({
            type:'GET',
            //url:'/suivievaluation/public/desagrege/by/indicateur/'+idv,
            url:'http://127.0.0.1:8000/desagrege/by/indicateur/'+idv,
            data:'_token = <?php echo csrf_token() ?>',
            success:function(data) {

                numero_id += " <option value=''>Sélectionner</option>";
                $.each(data,function(index,row){
                    $(".containers").append("<div class='col-lg-6'> <div class='form-group  test'><label class='fieldlabels'>Valeur pour "+row.titre+":</label>"+
                    "<input type='number' name='valeur[]'  value='<?php echo e(old('valeur')); ?>' class='form-control'  required >"+
                    "<input type='hidden' name='desagrege_id[]'  value="+row.id+" class='form-control'  required >");
                });
                $("#numero_id").empty();
                $("#numero_id").append(numero_id);
            }
        });

    });
</script>

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


<?php echo $__env->make('layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\enda\RFA\plateforme RFA\rfaBackend\resources\views/resultat/edit.blade.php ENDPATH**/ ?>