<?php $__env->startSection('title', 'Add new matter'); ?>
<?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">
                    <div class="card-header mb-0 pb-0">
                        <div class="d-flex justify-content-between pb-2">
                            <h4>Disciplines Pour <?php echo e(ucfirst($valeur)); ?></h4>
                            <span class="form-control-variant">Les champ avec asterisk (<code>*</code>) sont obligatoires.</span>
                            <span>
                                <a href="<?php echo e(route('matiere.index')); ?>" class="btn btn-inverse btn-outline-inverse  btn-sm py-1" title="Return Back"><i class="fas fa-reply mx-0"></i></a>
                            </span>
                        </div>
                    </div>
                    <hr class="mx-3 my-0">
                    <div class="card-block mx-3">
                        <form action="<?php echo e(route('matiere.store')); ?>" method="post">
                            <?php echo csrf_field(); ?>
                            <input type="hidden" value="<?php echo e($valeur); ?>" name="type">
                            <table class="table table-bordered mb-0" id="addStudent">
                                <tbody>
                                    <?php $i = 1; ?>
                                    <?php $__empty_1 = true; $__currentLoopData = $matters; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <?php $i++ ?>
                                    <tr class="py-0">
                                        <td class="py-0" style="width: 30%">
                                            <div class="form-group my-0">
                                                <label class="col-form-label fw-bold" for="name_<?php echo e($i); ?>">Nom de la matière<span class="text-danger">*</span> :</label>
                                                <input type="text" name="name[]" id="name_<?php echo e($i); ?>" class="form-control mb-0" value="<?php echo e($item->libelle); ?>" readonly>
                                            </div>
                                        </td>
                                        <td class="py-0" style="width: 30%">
                                            <div class="form-group my-0">
                                                <label class="col-form-label fw-bold" for="abrege_<?php echo e($i); ?>">Nom abrégé de la matière :</label>
                                                <input type="text" name="abrege[]" id="abrege_<?php echo e($i); ?>" class="form-control mb-0" value="<?php echo e($item->abbreviated); ?>" readonly>
                                            </div>
                                        </td>
                                        <td class="py-0" style="width: 30%">
                                            <div class="form-group my-0">
                                                <label class="col-form-label fw-bold" for="bilan_<?php echo e($i); ?>">Type <?php echo e($libelle); ?><span class="text-danger">*</span> :</label>
                                                <select name="bilan[]" id="bilan_<?php echo e($i); ?>" class="form-control" readonly>
                                                    <option value="">Choise one option</option>
                                                    <?php $__currentLoopData = $bilans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $bilan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <option value="<?php echo e($bilan->id); ?>" <?php echo e($item ? ($item->libelle_bilan_id == $bilan->id ? 'selected':null):null); ?>><?php echo e(ucwords($bilan->libelle)); ?></option>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </select>
                                            </div>
                                        </td>
                                        <td class="text-center py-0" style="width: 5%;">
                                            <div class="my-0" style="display: flex;align-items: flex-end;height: 70px;">
                                                <input type="checkbox" name="select" class="checkbox mb-0 ms-auto" style="margin-bottom: 0%">
                                            </div>
                                                
                                        </td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr class="py-0">
                                        <td class="py-0" style="width: 30%">
                                            <div class="form-group my-0">
                                                <label class="col-form-label fw-bold" for="name_1">Nom de la matière<span class="text-danger">*</span> :</label>
                                                <input type="text" name="name[]" id="name_1" class="form-control mb-0" placeholder="Entrez le nom de la matière">
                                            </div>
                                        </td>
                                        <td class="py-0" style="width: 30%">
                                            <div class="form-group my-0">
                                                <label class="col-form-label fw-bold" for="abrege_1">Nom abrégé de la matière :</label>
                                                <input type="text" name="abrege[]" id="abrege_1" class="form-control mb-0" placeholder="Entrez le nom abrégé de la matière">
                                            </div>
                                        </td>
                                        <td class="py-0" style="width: 30%">
                                            <div class="form-group my-0">
                                                <label class="col-form-label fw-bold" for="bilan_1">Type <?php echo e($libelle); ?><span class="text-danger">*</span> :</label>
                                                <select name="bilan[]" id="bilan_1" class="form-control">
                                                    <option value="">Choise one option</option>
                                                    <?php $__currentLoopData = $bilans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $bilan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <option value="<?php echo e($bilan->id); ?>"><?php echo e(ucwords($bilan->libelle)); ?></option>
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                </select>
                                            </div>
                                        </td>
                                        <td class="text-center py-0" style="width: 5%;">
                                            <div class="my-0" style="display: flex;align-items: flex-end;height: 70px;">
                                                <input type="checkbox" name="select" class="checkbox mb-0 ms-auto" style="margin-bottom: 0%">
                                            </div>
                                                
                                        </td>
                                    </tr>
                                    <?php endif; ?>
                                </tbody>
                            </table>
                            <div class="text-right mt-1">
                                <a href="#" class="btn btn-sm btn-danger" id="delete" title="Delete Row">-</a>
                                <a href="#" class="btn btn-sm btn-info" id="addRow" title="Add Row">+</a>
                            </div>
                            <hr class="text-center mt-3">
                            <div class="text-center">
                                <button type="submit" class="btn btn-inverse btn-outline-inverse py-2"> <i class="fas fa-check-circle"></i> Valider les informations</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(){

        // Ajouter une ligne
        let nbLignes = $('table#addStudent tbody tr').length;
        let cmpte = nbLignes;
        $('#addRow').on('click', function(){
            if($('#name_'+cmpte).val() && $('#bilan_'+cmpte).val()){
                cmpte += cmpte;
                let newRow = ('<tr class="py-0">'+
                    '<td class="py-0" style="width: 30%">'+
                        '<div class="form-group my-0">'+
                            '<label class="col-form-label fw-bold" for="name_'+cmpte+'">Nom de la matière<span class="text-danger">*</span> :</label>'+
                            '<input type="text" name="name[]" id="name_'+cmpte+'" class="form-control mb-0" placeholder="Entrez le nom de la matière">'+
                        '</div>'+
                    '</td>'+
                    '<td class="py-0" style="width: 30%">'+
                        '<div class="form-group my-0">'+
                            '<label class="col-form-label fw-bold" for="abrege_'+cmpte+'">Nom abrégé de la matière :</label>'+
                            '<input type="text" name="abrege[]" id="abrege_'+cmpte+'" class="form-control mb-0" placeholder="Entrez le nom abrégé de la matière">'+
                        '</div>'+
                    '</td>'+
                    '<td class="py-0" style="width: 30%">'+
                        '<div class="form-group my-0">'+
                            '<label class="col-form-label fw-bold" for="bilan_'+cmpte+'">Type <?php echo e($libelle); ?><span class="text-danger">*</span> :</label>'+
                            '<select name="bilan[]" id="bilan_'+cmpte+'" class="form-control">'+
                                '<option value="">Choise one option</option>'+
                                '<?php $__currentLoopData = $bilans; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $bilan): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>'+
                                    '<option value="<?php echo e($bilan->id); ?>"><?php echo e(ucwords($bilan->libelle)); ?></option>'+
                                '<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>'+
                            '</select>'+
                        '</div>'+
                    '</td>'+
                    '<td class="text-center py-0" style="width: 5%;">'+
                        '<div class="my-0" style="display: flex;align-items: flex-end;height: 70px;">'+
                            '<input type="checkbox" name="select" class="checkbox mb-0 ms-auto" style="margin-bottom: 0%">'+
                        '</div>'+
                    '</td>'+
                '</tr>');
                $('table#addStudent').append(newRow);
                
                $('#name_'+cmpte).focus();
                var nvlRow = $("table#addStudent tbody tr:last");
                $('html, body').animate({
                    scrollTop: nvlRow.offset().top
                }, 500);

                if(cmpte > 1){
                    $('.checkbox').prop('disabled', false);
                }
            }
        });

        // Supprimer une ligne
        $('#delete').on('click', function(){
            $("table#addStudent").find('input[name="select"]').each(function() {
                if ($(this).is(":checked")) {
                    cmpte-=1;
                    $(this).parents("table#addStudent tr").remove();
                    if(cmpte == 1){
                        $('.checkbox').prop('disabled', true);
                    }
                }
            });
        });
    })
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\Users\EDUCAS\Desktop\AppS\V4_001\resources\views\pages\matters\create.blade.php ENDPATH**/ ?>