
<?php $__env->startSection('title', 'Devoir Create'); ?>
<?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="row">
                    <div class="col-sm-12">
                        <div class="card">
                            <div class="card-header mb-0 pb-0">
                                <div class="d-flex justify-content-between">
                                    <h4>Nouveau Devoirs</h4>
                                    <strong style="font-size: 17px"><?php echo e($classe['libelle']. ' [ '.ucwords($cutting->cutting->libelle).']'); ?></strong>
                                    <span>
                                        <a href="<?php echo e(route('program.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="mt-0 mx-3">
                            <div class="card-block mx-lg-3 pt-lg-3">
                                <form action="<?php echo e(route('program.store')); ?>" method="post">
                                    <?php echo csrf_field(); ?>
                                    <div class="table-responsive">
                                        <table class="table table-bordered nowrap mb-1" id="myTable">
                                            <thead>
                                                <tr>
                                                    <th></th>
                                                    <th class="text-center" style="width: 25%">Matière</th>
                                                    <th class="text-center" style="width: 25%">Date</th>
                                                    <th class="text-center" style="width: 25%">Heure</th>
                                                    <th class="text-center" style="width: 20%">Période</th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <tr>
                                                    <th class="text-center pb-0">1</th>
                                                    <td class="p-0">
                                                        <select name="matters[]" class="form-control my-0" id="level">
                                                            <option value=" ">Matière ...</option>
                                                            <?php $__currentLoopData = $matters; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $matter): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option value="<?php echo e($matter['id']); ?>" title="<?php echo e(ucfirst($matter['libelle'])); ?>"><?php echo e(ucfirst($matter['abbreviated'])); ?></option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        </select>
                                                    </td>
                                                    <td class="p-0">
                                                        <input type="date" name="dates[]" class="form-control my-0">
                                                    </td>
                                                    <td class="p-0">
                                                        <div class="d-flex justify-content-between my-0">
                                                            <input type="time" name="debuts[]" class="form-control my-0">
                                                            <input type="time" name="fins[]" class="form-control my-0">
                                                        </div>
                                                    </td>
                                                    <td class="p-0 text-center">
                                                        <div class="radio-inline mt-2">
                                                            <label>
                                                                <input type="radio" name="period" value="1" checked>
                                                                <i class="helper"></i>Matin
                                                            </label>
                                                        </div>
                                                        <div class="radio-inline mt-2">
                                                            <label>
                                                                <input type="radio" name="period" value="2">
                                                                <i class="helper"></i>Après midi
                                                            </label>
                                                        </div>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                        <div class="float-right my-0">
                                            <button type="button" class="btn btn-inverse btn-outline-inverse btn-sm py-1" id="addRow">➕</button>
                                            
                                        </div>
                                    </div>
                                    <hr class="text-center">
                                    <input type="hidden" name="choix" id="hidden-choix">
                                    <input type="hidden" name="class" value="<?php echo e($classe['id']); ?>">
                                    <input type="hidden" name="cutting" value="<?php echo e($cutting->id); ?>">
                                    <div class="text-center">
                                        <button type="submit" class="btn btn-inverse btn-outline-inverse py-2 w-25" id="valider">Valider</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script src="<?php echo e(asset('assets/pages/data-table/extensions/colreorder/js/colreorder-custom.js')); ?>"></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
        $i = 1; // Compte le nombre de lignes ajoutées
        $("#addRow").on('click', function() {

            let newRow = `
            <tr>
                <th class="text-center pb-0">`+($i+=1)+`</th>
                <td class="p-0">
                    <select name="matters[]" class="form-control my-0" id="level">
                        <option value=" ">Matière ...</option>
                        <?php $__currentLoopData = $matters; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $matter): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($matter['id']); ?>" title="<?php echo e(ucfirst($matter['libelle'])); ?>"><?php echo e(ucfirst($matter['abbreviated'])); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </td>
                <td class="p-0">
                    <input type="date" name="dates[]" class="form-control my-0">
                </td>
                <td class="p-0">
                    <div class="d-flex justify-content-between my-0">
                        <input type="time" name="debuts[]" class="form-control my-0" id="debuts">
                        <input type="time" name="fins[]" class="form-control my-0" id="fins">
                    </div>
                </td>
                <td class="p-0 text-center">
                    <div class="radio-inline mt-2">
                        <label>
                            <input type="radio" class="radio" name="period`+$i+`" value="1" checked>
                            <i class="helper"></i>Matin
                        </label>
                    </div>
                    <div class="radio-inline mt-2">
                        <label>
                            <input type="radio" class="radio" name="period`+$i+`" value="2">
                            <i class="helper"></i>Après midi
                        </label>
                    </div>
                </td>
            </tr>`;
            
            $("#myTable tbody").append(newRow);
        });


        // Récupérer les valeurs des radios cochées
        $('#valider').on('click', function() {
            let valeurs = [];

            // Pour chaque groupe de radio
            $('#myTable tr').each(function() {
            let checked = $(this).find('input[type=radio]:checked').val();
                if (checked) {
                    valeurs.push(checked);
                }
            });

            // Mettre dans le champ caché (format JSON ou liste)
            $('#hidden-choix').val(valeurs);
            console.log('Valeurs choisies :', valeurs);
        });
    })
</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\devoirs\create.blade.php ENDPATH**/ ?>