<?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-plus"></i> <strong>Registrar Nota de Remisión Ventas</strong></h4>
</div>
<form action="remision_control.php" method="post" accept-charset="utf-8" class="form-horizontal" >
    <div class="modal-body">
        <input type="hidden" name="accion"  value="1">
        <input type="hidden" name="vid_nrv" value="0"/>
        <div class="row">
            <div class="col-md-4">
                <label class="control-label">Fecha</label>
                <input type="date" required="" class="form-control" value="<?php echo date("Y-m-d") ?>" max="<?php echo date("Y-m-d") ?>">
            </div>
            <div class="col-md-8">
                <label class="control-label">Destinatario</label>
                <select name="vid_cliente" id="vid_cliente" class="select2 form-control" required="" style="width: 100%" onchange="selclientes()">
                    <option value="">Seleccione un destinatario</option>
                    <?php $clientes = consultas::get_datos("SELECT * from v_clientes where id_cliente in (select id_cliente from cobros)"); ?>
                    <?php if (!empty($clientes)) {
                        foreach ($clientes as $cliente) { ?>                            
                            <option value="<?php echo $cliente['id_cliente']; ?>">
                                <?php echo $cliente['cliente']; ?></option>
                            <?php
                        }
                    } else {
                        ?>
                        <option value="">No existen registros</option>
                    <?php } ?>
                </select>
            </div>                                            
        </div>
        <div class="row">
            <div class="col-md-4">                
                <label class="control-label">Motivo Traslado</label>
                <select name="vmotivo_translado" class="select2 form-control" required="" style="width: 100%">                        
                            <option value="VENTAS">VENTAS</option>
                </select>
            </div>
            <div class="col-md-8" id="div_comprobantes">
                <label class="control-label">N° Comprobante de Venta</label>
                <select name="vid_cobro" class="select2 form-control" required="" style="width: 100%">                        
                            <option value="">Seleccione un destinatario</option>
                </select>                
            </div>                                            
        </div>         
        <div class="row">
            <div class="col-md-4" >
                <?php $empleados = consultas::get_datos("SELECT * from v_empleados"); ?>                                 
                <label class="control-label">Conductor</label>
                <select name="vid_empleado" class="select2 form-control" required="" style="width: 100%">
                    <?php if (!empty($empleados)) {
                        foreach ($empleados as $emp) { ?>
                            <option value="<?php echo $emp['id_empleado']; ?>">
                                <?php echo $emp['empleado']; ?></option>
                            <?php
                        }
                    } else {
                        ?>
                        <option value="">No existen registros</option>
                    <?php } ?>
                </select>
            </div>
            <div class="col-md-8" >
                <?php $prv = consultas::get_datos("SELECT * from v_vehiculos"); ?>                                 
                <label class="control-label">Vehiculo</label>
                <select name="vvehiculo" class="select2 form-control" required="" style="width:100%">
                    <?php if (!empty($prv)) {
                        foreach ($prv as $prv) { ?>
                            <option value="<?php echo $prv['id_vehi']; ?>">
                                <?php echo $prv['vehiculo']; ?></option>
                            <?php
                        }
                    } else {
                        ?>
                        <option value="">No existen registros</option>
                    <?php } ?>

                </select>
            </div>
        </div>
        <div class="row">
            <div class="col-md-4">
                <label class="control-label">Inicio Traslado</label>
                <input type="date" name="vfinicio_translado" required="" class="form-control" value="<?php echo date("Y-m-d") ?>" max="<?php echo date("Y-m-d") ?>">
            </div>
            <div class="col-md-4">
                <label class="control-label">Fin Traslado</label>
                <input type="date" name="vffin_translado" required="" class="form-control" value="<?php echo date("Y-m-d") ?>" max="<?php echo date("Y-m-d") ?>">
            </div>            
        </div>        
        <div class="modal-footer">
            <button type="submit" class="btn btn-primary">
                <i class="fa fa-floppy-o"></i> Registrar</button>
        </div>
    </div> 
</form>

<script type="text/javascript">
    $(".select2").select2();
</script>