<?php $__env->startSection('content'); ?>
    <?php if(count($empresasporregistrar) >= 1): ?>

        <div class="portlet light portlet-fit portlet-datatable bordered">
            <div class="portlet-title">
                <div class="caption">
                    <span class="caption-subject font-green sbold uppercase"> Empresas solicitando pertenecer al sistema</span>
                </div>
            </div>
            <div class="portlet-body">

                <table class="table table-hover nowrap dataTable dtr-inline collapsed tbEmpresasPorAceptar"
                       id="tbEmpresasPorAceptar"
                       width="100%" role="grid" aria-describedby="tbEmpresasPorAceptar_info">
                    <thead class="thead-default">
                    <tr>
                        <th>N°</th>
                        <th>Nombre</th>
                        <th>Ruc</th>
                        <th>Direcci&oacute;n</th>
                        <th>Telefono</th>
                        <th>Email</th>
                        <th>Rubro</th>
                        <th>Aprobaci&oacute;n</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php ($count = 1); ?>
                    <?php $__currentLoopData = $empresasporregistrar; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td> <?php echo e($count); ?> </td>
                            <td> <?php echo e($item->nombre_organizacion); ?> </td>
                            <td> <?php echo e($item->ruc); ?> </td>
                            <td> <?php echo e($item->direccion); ?> </td>
                            <td> <?php echo e($item->telefono); ?> </td>
                            <td> <?php echo e($item->email); ?> </td>
                            <td> <?php echo e($item->rubro); ?> </td>
                            <td>
                                <div class="form-actions">
                                    <a type="button" class="btn blue btn-sm" href="<?php echo e(url('empresas/afiliacion/aceptar',$item->id)); ?>"> Aceptar </a>
                                    <a type="button" class="btn red btn-sm " href="<?php echo e(url('empresas/afiliacion/rechazar',$item->id)); ?>"> Rechazar </a>
                                </div>
                            </td>

                        </tr>
                        <?php ($count++); ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </tbody>
                </table>

            </div>
        </div>

    <?php endif; ?>

    <div class="portlet light portlet-fit portlet-datatable bordered">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject font-green sbold uppercase"> Gesti&oacute;n de empresas registradas</span>
            </div>
        </div>
        <div class="portlet-body">

            <table class="table table-hover nowrap dataTable dtr-inline collapsed tbEmpresas"
                   id="tbEmpresas"
                   width="100%" role="grid" aria-describedby="tbPersonal_info">
                <thead class="thead-default">
                <tr>
                    <th>N°</th>
                    <th>Nombre</th>
                    <th>Ruc</th>
                    <th>Direcci&oacute;n</th>
                    <th>Telefono</th>
                    <th>Email</th>
                    <th>Rubro</th>
                    <th>Ofertas</th>
                    <th>Estado</th>
                </tr>
                </thead>
                <tbody>
                <?php ($count = 1); ?>
                <?php $__currentLoopData = $empresasregistradas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td> <?php echo e($count); ?> </td>
                        <td> <?php echo e($item->nombre_organizacion); ?> </td>
                        <td> <?php echo e($item->ruc); ?> </td>
                        <td> <?php echo e($item->direccion); ?> </td>
                        <td> <?php echo e($item->telefono); ?> </td>
                        <td> <?php echo e($item->email); ?> </td>
                        <td> <?php echo e($item->rubro); ?> </td>
                        <td> <a type="submit" class="btn blue" href="<?php echo e(url('gestionbolsa/empresas/ofertas',$item->id)); ?>">Ver Ofertas</a> </td>
                        <td>
                            <div class="onoffswitch">
                                <?php if($item->estado == 1): ?>
                                    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox chk"
                                           id="switch_<?php echo e($item->id); ?>" checked="checked">
                                <?php else: ?>
                                    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox chk"
                                           id="switch_<?php echo e($item->id); ?>">
                                <?php endif; ?>
                                <label class="onoffswitch-label" for="switch_<?php echo e($item->id); ?>"
                                       style="margin-bottom:0">
                                    <span class="onoffswitch-inner"></span>
                                    <span class="onoffswitch-switch"></span>
                                </label>
                            </div>
                        </td>

                    </tr>
                    <?php ($count++); ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>

        </div>
    </div>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
    <script>

        $('#tbEmpresas').DataTable({
            "lengthMenu": [[25, 20, 50, -1], [25, 20, 50, "Todas"]],
            bFilter: true,
            "bLengthChange": false,
            bInfo: true,
            responsive: true,
            "autoWidth": true,
            "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": false},
                {"bSearchable": true},
                {"bSearchable": true},
                {"bSearchable": true},
                {"bSearchable": false},
                {"bSearchable": false},
                {"bSearchable": true},
                {"bSearchable": false},
                {"bSearchable": false},

            ],
            "columns": [
                {"orderable": false},
                {"orderable": true},
                {"orderable": true},
                {"orderable": true},
                {"orderable": false},
                {"orderable": false},
                {"orderable": true},
                {"orderable": false},
                {"orderable": false},

            ]
        });

        $('#tbEmpresasPorAceptar').DataTable({
            "lengthMenu": [[25, 20, 50, -1], [25, 20, 50, "Todas"]],
            bFilter: true,
            "bLengthChange": false,
            bInfo: true,
            responsive: true,
            "autoWidth": true,
            "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": false},
                {"bSearchable": true},
                {"bSearchable": true},
                {"bSearchable": true},
                {"bSearchable": false},
                {"bSearchable": false},
                {"bSearchable": true},
                {"bSearchable": false},

            ],
            "columns": [
                {"orderable": false},
                {"orderable": true},
                {"orderable": true},
                {"orderable": true},
                {"orderable": false},
                {"orderable": false},
                {"orderable": true},
                {"orderable": false},

            ]
        });

        $('.chk').click(function () {
            var aux = this.id;
            var aux1 = aux.split("_");
            var id = aux1[1];

            $.ajax({
                url: "<?php echo e(url('gestionbolsa/empresas/estado')); ?>" + "/" + id,
                context: document.body,
                cache:false
            }).always(function () {
                swal("Se cambio el estado de la empresa!");
            });
        });


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