<?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"><strong><center>Registrar Nota de Debito</center></strong></h4>
</div>
<form action="debito_control.php" method="post" accept-charset="utf-8" class="form-horizontal" >
    <div class="panel-body se">
        <input type="hidden" name="accion"  value="1">
        <input type="hidden" name="vtotal" value="0">
        <input type="hidden" name="vtotiva" value="0">
        <input type="hidden" name="vusu" value="<?php echo $_SESSION['usu_cod']; ?>">
        <input type="hidden" name="vsuc" value="<?php echo $_SESSION['cod_suc']; ?>">
        <input type="hidden" name="pagina" value="debito_index.php" id="vcod">
        <input type="hidden" name="vcod" value="0"/> 
        <div class="row">

            <div class="col-md-4" style="left: 100px">
                <label class="control-label">Fecha</label>
                <input type="date" required="" 
                       placeholder="Especifique fecha"
                       class="form-control"
                       value="<?php echo date("Y-m-d") ?>"
                       name="vfecha" 
                       style="width: 145px"
                       max="<?php echo date('Y-m-d'); ?>">
            </div>

            <div class="col-md-5" style="margin-left: 100px">
                <label class="control-label" style="margin-left: 50px">Motivo</label>
                <?php $ord = consultas::get_datos("SELECT * from motivo_nota where mot_nota in (3,4);"); ?>                                 
                <select name="vmotivo" class="select2" required="" style="width: 180px">
                    <?php
                    if (!empty($ord)) {
                        foreach ($ord as $or) {
                            ?>
                            <option value="<?php echo $or['mot_nota']; ?>">
                                <?php echo $or['mot_descri']; ?></option>
                            <?php
                        }
                    } else {
                        ?>
                        <option value="0">Debe insertar un registro</option>
                    <?php } ?>
                </select>
            </div>
        </div>


        <div class="row">
            <div class="col-md-5">
                <?php $prv = consultas::get_datos("SELECT * from proveedores"); ?>                                 
                <label class="control-label">Proveedor</label>
                <select name="vprv" id="prv_cod" class="select2" required="" style="width: 220px" onchange="div_pres()">
                    <option value="">Seleccione un Proveedor</option>
                    <?php if (!empty($prv)) { 
                        foreach ($prv as $prv) {
                            ?>
                            <option value="<?php echo $prv['prv_cod']; ?>">
                                <?php echo $prv['prv_razonsoc']; ?></option>
                            <?php
                        }
                    } else {
                        ?>
                        <option value="">No existen Proveedores</option>
                    <?php } ?>

                </select>
            </div>


            <div class="form-group" id="div_presu" style="display:block">

            </div>
        </div>

        <div class="row">

            <div class="col-md-4"  >
                <label class="control-label">Nro Documento</label>
                <input type="text" required=""
                       placeholder="Digite factura"
                       class="form-control"
                       name="vnumero" style="width : 180px"
                       id="vnrofac"maxlength="10" pattern="[0-9-]+">
            </div>

            <div class="col-md-4" style="left:15px ">
                <label class="control-label">Nro Timbrado</label>
                <input type="text" required=""
                       placeholder="Digite timbrado"
                       class="form-control"
                       name="vtimbrado" style="width : 160px"
                       id="vnrotim" maxlength="8"
                       pattern="[0-9]+">
            </div>

            <div class="col-md-4" style="left:15px ">
                <label class="control-label">Vencimiento timbrado</label>
                <input type="date" required="" 
                       placeholder="Especifique fecha"
                       class="form-control"
                       value="<?php echo date("Y-m-d") ?>"
                       name="venc_tim" 
                       style="width: 145px"
                       max="<?php echo date('Y-m-d'); ?>">
            </div>
            <div class="row" id="div_pres_detalle"></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>
    </div>
</form>

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