<?php use_helper( 'UrlFunctions' ); ?>
<?php use_helper( 'IncludePartial' ); ?>
<?php use_helper( 'UtilFunctions' ); ?>

<style type="text/css">
.table td, .table th {
    padding: .2rem;
    vertical-align: top;
    border-top: 1px solid #dee2e6;
}
</style>

<div id="resultContent" style=""></div>


<form action="" method="post" name="form1" id="form1">
    <input type="hidden" name="IdProveedor" id="IdProveedor" value="<?=$IdProveedor?>">

    <div class="form-row mx-0 mb-1">

        <div class="table-responsive">
            <table  class="table table-borderless border" style="margin-bottom: 0;">
                <tr>
                    <td  nowrap="nowrap" align="right" scope="row"><label for="ProveedorId">Proveedor :</label></td>
                    <td nowrap="nowrap">
                        <select class="form-control" id="ProveedorId" name="ProveedorId" style="width: 250px;" onchange="findControl();" >
                            <option value=""> - Seleccione - </option>
                            <?php foreach ( $a_MST_PersonaMast as $o_MST_PersonaMastBN ) { ?>
                            <option value="<?=$o_MST_PersonaMastBN->getIdPersona()?>" <?php if( $IdProveedor==$o_MST_PersonaMastBN->getIdPersona() ){ echo "SELECTED"; } ?> > <?=$o_MST_PersonaMastBN->getNombreCompleto()?> </option>
                            <?php } ?>
                        </select>
                    </td>
                    <td  nowrap="nowrap" align="right" scope="row"><label for="IdTipoDocumento">Tipo Documento :</label></td>
                    <td nowrap="nowrap" style="vertical-align: middle;">
                         <select class="form-control" id="IdTipoDocumento" name="IdTipoDocumento" style="width: 250px;" onchange="findControl();" >
                            <option value=""> - Seleccione - </option>
                            <option value="FC" selected="selected"> FACTURA ELECTRONICA </option>
                            <option value="BV"> BOLETA ELECTRONICA </option>
                        </select>
                    </td>
                 </tr>
                 <tr>
                    <td  nowrap="nowrap" align="right" scope="row"><label for="NumeroFactura">Numero Documento :</label></td>
                    <td nowrap="nowrap"><input type="text" class="form-control" name="NumeroFactura" id="NumeroFactura" onfocus="this.select();" style="width: 250px;" autocomplete="off"></td>
                    <td  nowrap="nowrap" align="right" scope="row"><label for="NumeroFactura">Fecha Documento :</label></td>
                    <td nowrap="nowrap" style="vertical-align: middle;">
                        <input type="text" class="form-control text-center" id="FechaDocumento1" name="FechaDocumento1" placeholder="Fecha Desde" value="" style="width: 250px;" autocomplete="off">
                        <script type="text/javascript">
                        $( "#FechaDocumento1" ).datepicker( { dateFormat: "yy-mm-dd", changeYear:true, yearRange: "-5:+1", changeMonth: true, onClose: function (){ this.focus(); findControl(); } } );
                        </script>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</form>

<script type="text/javascript">
$( "#NumeroFactura, #FechaDocumento1" ).keyup
(
    function( e ) 
    {
        findControl();
    }
);
</script>

<?php include_partial( "docrefGrid" ); ?>

<script>
//ESCAPE, DETECTA EL F5, CTRL+F5
$( document ).bind
(
    'keyup', 
    function( e ) 
    {
        //console.log( e.which );
        if( e.which === 13 ) //+
        {
            findControl();
        }
        if( e.which == 107 || e.which == 27 ) //tecla +
        {
            $( "#cotent_a_collapse" ).trigger( "click" );
        } 
        if( e.which === 27 ) //ESCAPE
        {
            $( "#NumeroFactura" ).focus();
        }
    }
);
</script>