<?php $__env->startSection('styles'); ?>
    <link href="<?php echo e(asset('css/icheck/skins/all.css')); ?>" rel="stylesheet" type="text/css"/>

    <style>
        option{
            background-color: white;
        }
        .min-tardanza{
            width: 10%;
        }
        .tbPersonal_filter{
            display: none;
        }
        .onoffswitch-inner:before{
            content: 'Rindio' !important;
        }
        .onoffswitch-inner:after{
            content: 'No Rindio' !important;
        }
        .onoffswitch{
            width: 100px;
        }
        .onoffswitch-switch{
            right: 70px;
        }
        .table.dataTable.dtr-inline.collapsed>tbody>tr>td:first-child:before, table.dataTable.dtr-inline.collapsed>tbody>tr>th:first-child:before{
            display: none !important;
        }
    </style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <h1 class="page-title">
        Registro de Notas | <?php echo e($curso['nombre']); ?>

    </h1>
    <div class="portlet light bordered">
        <div class="portlet-title">
            <div class="caption">
                <h4 class="modal-title caption-subject font-blue-secondary sbold uppercase"> Listado de Alumnos | Evaluaci&oacute;n: <?php echo e($detalle['nombre']); ?></h4>
                <input type="hidden" id="evalucion" value="<?php echo e($detalle['nombre']); ?>" data-curso="<?php echo e($detalle['id']); ?>" data-seccion="<?php echo e($id); ?>" />
            </div>
        </div>
        <div class="portlet-body">
            <div class="row">
                <div class="col-md-6">
                    <div class="col-md-12">
                        <div class="col-md-6">
                            <h4><i class="glyphicon glyphicon-search"></i>  Busqueda avanzada</h4>
                        </div>
                        <div class="col-md-6">
                            <h6 style="margin-bottom: 0px; margin-top: 16px">Por: C&oacute;digo, Nombre y Apellidos del Alumno</h6>
                        </div>
                        <input type="search" class="form-control input-md" id="text-filter" aria-controls="tbEncuestas">
                    </div>
                </div>
            </div>
            <div class="Forum-ForumTopicList row" style="margin:20px">
                <table class="table table-hover nowrap dataTable dtr-inline collapsed tbPersonal"
                       id="tbPersonal"
                       width="100%" role="grid" aria-describedby="tbPersonal_info">
                    <thead class="thead-default">
                    <tr>
                        <th class="col-sm-2 col-md-2 col-lg-2">C&oacute;digo de Alumno</th>
                        <th class="col-sm-2 col-md-2 col-lg-2">Nombre del Alumno</th>
                        <th class="col-sm-2 col-md-2 col-lg-2">Apellido Paterno</th>
                        <th class="col-sm-2 col-md-2 col-lg-2">Apellido Materno</th>
                        <th class="col-sm-2 col-md-2 col-lg-2">Nota</th>
                        <th class="col-sm-2 col-md-2 col-lg-2">Estado</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $__currentLoopData = $Arr; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td> <?php echo e($item->codigo); ?> </td>
                            <td> <?php echo e($item->uNombre); ?> </td>
                            <td> <?php echo e($item->uAP); ?> </td>
                            <td> <?php echo e($item->uAM); ?> </td>
                            <td>
                                <?php echo Form::number('costo', 0, array('id' => 'checkA_'.$item->id_alumno_seccion,'step'=>'any','min' => '0','max' => '20', 'style' => 'width: 60px','name' => 'check-Alumno','data-desc' => 'Rindio')); ?>

                                
                            <td>
                                <div class="onoffswitch">
                                    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox chk" id="switch_<?php echo e($item->id_alumno_seccion); ?>" checked="checked">
                                    <label class="onoffswitch-label" for="switch_<?php echo e($item->id_alumno_seccion); ?>" style="margin-bottom:0">
                                        <span class="onoffswitch-inner yes"></span>
                                        <span class="onoffswitch-switch no"></span>
                                    </label>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>
                <div class="col-md-12" style="text-align: left">
                    <button type="button" class="btn green confirm">Registrar Notas</button>
                    <a href="<?php echo e(url('registro/secciones')); ?>">
                        <button type="button" class="btn red cancel" btnCancel="N">Cancelar Registro</button>
                    </a>
                </div>
            </div>
        </div>
    </div>

    <div id="ModalEval"></div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    <script src="<?php echo e(asset('css/icheck/icheck.min.js')); ?>" type="text/javascript"></script>
    <script>
        var urlPrincipal = "<?php echo e(url('registro/secciones')); ?>";
        $(document).ready(function () {

            var cambiando = false;
            $('.chk').change(function () {
                if(cambiando) {
                    return false;
                }
                cambiando = true;
                var sw = this;
                $(sw).attr('disabled', true);
                var idButton = $(this).attr('id');
                var idObj = idButton.split('_');
                var AnuncioID = idObj[1];
                nextStatus = $('#' + idButton).prop('checked');

                if(nextStatus){
                    $('#checkA_' + AnuncioID).prop("disabled",false);
                    $('#checkA_' + AnuncioID).attr("data-desc",'Rindio');
                }
                else{
                    $('#checkA_' + AnuncioID).prop("disabled",true);
                    $('#checkA_' + AnuncioID).attr("data-desc",'No Rindio');

                    $('#checkA_' + AnuncioID).val('0');
                }

                cambiando = false;
                $(sw).prop('disabled', false);


            });


            var tablePersonal = $('#tbPersonal').DataTable({
                "lengthMenu": [[40, 20, 50, -1], [40, 20, 50, "Todas"]],
                bFilter: true,
                "bLengthChange": false,
                bInfo: true,
                "searching": true,
                responsive: false,
                "autoWidth": false,
                "language": {
                    "lengthMenu": "Mostrar _MENU_ Entradas",
                    "zeroRecords": "No se encontraron registros",
                    "info": "Mostrando la página _PAGE_ de _PAGES_",
                    "infoEmpty": "No hay registros disponibles",
                    "infoFiltered": "(filtrado de _MAX_ registros totales)",
                    "search": "Buscar: ",
                    "paginate": {
                        "first": "Primero",
                        "last": "Último",
                        "next": "Siguiente",
                        "previous": "Anterior"
                    }
                },
                "order": [],
                "aoColumns": [
                    {"bSearchable": true},
                    {"bSearchable": true},
                    {"bSearchable": true},
                    {"bSearchable": true},
                    {"bSearchable": false},
                    {"bSearchable": false}
                ],
                "columns": [
                    {"orderable": true},
                    {"orderable": true},
                    {"orderable": true},
                    {"orderable": true},
                    {"orderable": false},
                    {"orderable": false}
                ]
            });

            $("#tbPersonal_filter").hide();


            $("#text-filter").on('keyup',function () {
                tablePersonal
                    .search($(this).val())
                    .draw();
            });




            $(".btn.confirm").on('click',function () {
                var list = {};

                var gft = 0;


                $('input[name=check-Alumno]',tablePersonal.rows().nodes()).each(function(){
                    if($(this).val() > 20){
                        gft++;
                        $(this).css('border-color','#f36a5a')
                    }
                    else{
                        $(this).css('border-color','#a9a9a9')
                    }
                });

                if(gft > 0){
                    swal("Nota no valida", "Se ah detectado registro de notas mayores al máximo 20, por favor reingrese las notas resaltadas de rojo", "warning")
                }
                else{
                    list['NOTAS'] = $('input[name=check-Alumno]').map(function (){return this.value; }).get();
                    list['IAS'] = $('input[name=check-Alumno]').map(function (){return (this.id).substr(7); }).get();
                    list['D'] = $('input[name=check-Alumno]').map(function (){return this.getAttribute('data-desc'); }).get();

                    list['N'] = $('#evalucion').val();
                    list['C'] = $('#evalucion').data('curso');
                    list['S'] = $('#evalucion').data('seccion');


                    $.ajax({
                        type: "POST",
                        url: "<?php echo e(url('registro/secciones/notas')); ?>",
                        data: {datos : list},
                        success: function (data) {
                            if(data == 'true'){
                                swal({
                                    title: "¡ Atencion !",
                                    type: "success",
                                    text: "Se ha registrado correctamente las notas de la evaluacion",
                                    showConfirmButton: false
                                });

                                setTimeout(function(){

                                    location.href = urlPrincipal;
                                }, 4000);
                            }
                            else{
                                setTimeout(function(){
                                    swal({
                                        title: "¡ Atencion !",
                                        type: "error",
                                        text: "Se ha registrado un error al registrar las notas en breve podra reingresar",
                                        showConfirmButton: true
                                    });

                                    location.href = urlPrincipal;
                                }, 2000);
                            }
                        }
                    });
                }

            });


        });

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


<?php echo $__env->make('template.layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>