<script type="text/javascript">
validacionesDoc = function( elm )
{
    if( elm.value.trim() != "" )
    {
        //pr( elm.value );
        var MontoIng = parseFloat( elm.value );
        //pr( MontoIng );
        var SaldoDoc = parseFloat( $( elm ).attr( "saldo" ) );
        //pr( SaldoDoc );
        if( MontoIng > SaldoDoc )
        {
        	showAlertBootStrap( 'content_alert', 'alert-danger', "El monto cobrado no debe ser mayor al saldo del Documento." );
        	elm.value = SaldoDoc;
            return false;
        }
    }
}
</script>
<div class="table-responsive">
    <table class="table table-sm table-bordered table-hover">
        <thead class="thead-light">
            <tr>
                <th width="5%" style="text-align: center;" scope="col">Nro</th>
                <th width="10%" style="text-align: center;" scope="col">Emitido</th>
                <th width="10%" style="text-align: center;" scope="col">TipoDoc</th>
                <th width="10%" style="text-align: center;" scope="col">Nro Documento</th>
                <th width="10%" style="text-align: center;" scope="col">Vence</th>
                <th width="10%" style="text-align: center;" scope="col">Moneda</th>
                <th width="10%" style="text-align: center;" scope="col">Monto</th>
                <th width="10%" style="text-align: center;" scope="col">Cobrado</th>
                <th width="10%" style="text-align: center;" scope="col">Saldo</th>
                <th width="10%" style="text-align: center;" scope="col">Aplicar</th>
            </tr>
        </thead>
        
        <tbody id="">
        <?php foreach ( $a_VTA_Documento as $i_Key => $o_VTA_DocumentoBN ){ ?>
            <?php
            $s_IdNumDoc = $o_VTA_DocumentoBN->getNumeroDocumento();
            $s_IdInput = $i_Key."_".$s_IdNumDoc;
            ?>
        <tr id="">
            <td align="center"><?=$o_VTA_DocumentoBN->getNumeroDocumento()?></td>
            <td nowrap="nowrap" align="center"><?=substr( $o_VTA_DocumentoBN->getFechaDocumento(), 0, 10 )?></td>
            <td align="center"><?=$o_VTA_DocumentoBN->getDocumentoCod()?></td>
            <td nowrap="nowrap" align="center"><?=$o_VTA_DocumentoBN->getDocumentoSerieNumero()?></td>
            <td nowrap="nowrap" align="center"><?=substr( $o_VTA_DocumentoBN->getFechaVencimiento(), 0, 10 )?></td>
            <td align="center"><?=$o_VTA_DocumentoBN->getObjectMoneda()->getDescripcion()?></td>
            <td align="right"><?=number_format( $o_VTA_DocumentoBN->getMontoTotal(), 2 )?></td>
            <td align="right"><?=number_format( $o_VTA_DocumentoBN->getMontoPagado(), 2 )?></td>
            <td align="right"><?=number_format( $o_VTA_DocumentoBN->getMontoSaldo(), 2 )?></td>
            <td>
                <input type="hidden" name="iddoc[]" id="<?=$s_IdInput?>_iddoc" value="<?=$s_IdNumDoc?>">
                <input type="text" class="form-control form-control-sm text-center" id="<?=$s_IdInput?>_monto" name="monto[]" value="" onfocus="this.select();" saldo="<?=$o_VTA_DocumentoBN->getMontoSaldo()?>" 
                    onkeypress="return NumCheckDecimal( event, this );" autocomplete="off" onblur="validacionesDoc( this ); actualizarSumaTotalReferencia();"
                    >
            </td>
        </tr>
        <?php } ?>
        </tbody>
        
    </table>
</div>