<?php
require '../../conexion.php';
include '../../session.php';
?>

<div class="modal-header " >
    <button type="button" class="close"     
            data-dismiss="modal" arial-label="Close">x</button>
    <h4 class="modal-title"><i class="fa fa-user-plus"></i> <strong>Agregar Encargado de Servicio</strong></h4>
</div>
<form action="orden_empleado_control.php" method="get" accept-charset="utf-8" class="form-horizontal" >
    <div class="panel-body se">
        <input type="hidden" name="vcod" value="<?php echo $_REQUEST['idordent']; ?>" >
        <input type="hidden" name="accion"  value="1">
        <input type="hidden" name="vestado" value="TRABAJANDO">
        <input type="hidden" name="pagina" value="<?php echo "detorden_agregar.php?idordent=" . $_REQUEST['idordent']; ?>" >

        <div class="row">
            <div class="col-md-6" style="left: 30px">
                <label class="col-md-4 control-label" style="left: 50px">Empleado</label>
                <?php $empleados = consultas::get_datos("select * from v_empleados where id_empleado not in(select id_empleado from grupo_trabajo where id_ordent=".$_REQUEST['idordent'].")"); ?> 
                <select name="vempleado" class="select2" required="" style="width: 220px" >
                    <?php
                    if (!empty($empleados)) {
                        foreach ($empleados as $empleado) {
                            ?>
                            <option value="<?php echo $empleado['id_empleado']; ?>">
                                <?php echo $empleado['empleado']; ?></option>
                            <?php
                        }
                    } else {
                        ?>
                        <option value="0">Debe insertar un registro</option>
                    <?php } ?>
                </select>
            </div>

            <div class="form-group col-md-6" style="">
                <label class="col-md-8 control-label" style="left: 20px">Trabajo a realizar</label>
                <?php $empleados = consultas::get_datos("select * from servicios_ordent where id_ordent=" .$_REQUEST['idordent']."") ?>                                 
                <?php
                if (!empty($empleados)) {
                    foreach ($empleados as $empleado) {
                        ?>
                        <input name="vdescri" type="text" class="form-control" value="<?php echo $empleado['descripcion']; ?>">
                    <?php }
                    ?>
                <?php } ?>
            </div>
        </div>
    </div>

    <div class="modal-footer">
        <button type="submit" class="btn btn-primary center-block">
            <i class="fa fa-floppy-o"></i> Registrar</button>
    </div>
</form>
<?php 
$grupos = consultas::get_datos("select * from v_empleados where id_empleado in(select id_empleado from grupo_trabajo where id_ordent=".$_REQUEST['idordent'].")");
if(!empty($grupos)){ ?>    
<div class="modal-footer"> 
<div id="no-more-tables">
    <table class="col-lg-12 col-md-12 col-xs-12 table table-bordered table-striped table-condensed">
        <thead>
            <tr>
                <th class="text-left">C.I N°</th>
                <th class="text-left">Empleado</th>
            </tr>
        </thead>
        <tbody>
        <?php foreach ($grupos as $grupo) { ?> 
            <tr>
                <td data-title="C.I N°" class="text-left">
                    <?php echo $grupo['per_ci'];?>
                </td> 
                <td data-title="Empleado" class="text-left">
                    <?php echo $grupo['empleado'];?>
                </td>                     
            </tr>
          <?php  } ?>
        </tbody>
    </table>
</div> 
</div>     
<?php } ?>
<script type="text/javascript">
    $(".select2").select2();
</script>


