<script>
mostrarCargaImg = function(){ $('#s_ImagenLoad')[0].style.display = 'inline'; }
ocultarCargaImg = function(){ $('#s_ImagenLoad')[0].style.display = 'none'; }

mostrarMensajeError = function( s_MensajeError )
{
    $( "#resultContent" ).html( '<div id="mensaje_error_content" class="error">' + s_MensajeError + '</div>' );
    setTimeout( function(){ $( "#mensaje_error_content" ).fadeOut( 800 ).fadeIn( 800 ).fadeOut( 500 ).fadeIn( 500 ).fadeOut( 300 ); }, 4000 );
}
</script>
<script>
ejecutarGuardar = function()
{
    mostrarCargaImg();
    var strFormSerialize = $( 'form' ).serialize();
    executeAjaxJson( 
                        "<?php echo buildUrl( $NomMod.'/saveAddEdit' ) ?>", 
                        strFormSerialize,
                        function( o_json )
                        {
                            console.log( o_json );
                            ocultarCargaImg();
                            if( o_json.error )
                            {
                                mostrarMensajeError( o_json.mensaje_error );
                                return false;
                            }
                            //return false;
                            switch ( o_json.type_sub )
                            {
                                case "0":
                                    location.href = "<?=buildUrl( $NomMod.'/addedit', "TipoProc=upd&Id=")?>" + o_json.id;
                                break;
                                case "1":
                                    location.href = "<?=buildUrl( $NomMod.'/list' )?>";
                                break;
                            }
                        } 
                   );
}
</script>

<?php if( $o_DefaultBN->getIdVehiculo() ){ $s_Disabled = "disabled"; }else{ $s_Disabled = ""; } ?>
<input type="hidden" name="Id" id="Id" value="<?=$o_DefaultBN->getIdVehiculo()?>">
<div id="resultContent" style=""></div>

<div class="card">
    <div class="container">
            <div class="form-row mx-0">
                <div class="col-md-6 mb-1">
                    <label class="col-form-label" for="VehiculoPlaca">Placa 1</label>
                    <input class="form-control" type="text" name="VehiculoPlaca" id="VehiculoPlaca" size="15" maxlength="15" value="<?=$o_DefaultBN->getVehiculoPlaca();?>" onblur="this.value=this.value.toUpperCase();"/>
            	</div><div class="col-md-6 mb-1">
                    <label class="col-form-label" for="VehiculoPlaca2">Placa 2</label>
                    <input class="form-control" type="text" name="VehiculoPlaca2" id="VehiculoPlaca2" size="15" maxlength="15" value="<?=$o_DefaultBN->getVehiculoPlaca2();?>" onblur="this.value=this.value.toUpperCase();"/>
            	</div>
            </div>
            <div class="form-row mx-0">
                <div class="col-md-6 mb-1">
                    <label class="col-form-label" for="VehiculoMdelo">Modelo</label>
                    <input class="form-control" type="text" name="VehiculoMdelo" id="VehiculoMdelo" maxlength="12" value="<?=$o_DefaultBN->getVehiculoMdelo();?>" onblur="this.value=this.value.toUpperCase();" />
            	</div>
            	<div class="col-md-6 mb-1">
                    <label class="col-form-label" for="VehiculoMarca">Marca</label>
                    <input class="form-control" type="text" name="VehiculoMarca" id="VehiculoMarca" maxlength="200" value="<?=$o_DefaultBN->getVehiculoMarca();?>" onblur="this.value=this.value.toUpperCase();" />
            	</div>
            </div>
            <div class="form-row mx-0">
                <div class="col-md-6 mb-1">
                    <label class="col-form-label" for="NroMotor">Numero de Motor</label>
                    <input class="form-control" type="text" name="NroMotor" id="NroMotor" maxlength="12" value="<?=$o_DefaultBN->getNroMotor();?>" onblur="this.value=this.value.toUpperCase();" />
            	</div>
            </div>
            <div class="form-row mx-0">
                <div class="col-md-6 mb-1">
                    <label class="col-form-label" for="Altura">Altura</label>
                    <input class="form-control" type="text" name="Altura" id="Altura" maxlength="12" value="<?=$o_DefaultBN->getAltura();?>" />
            	</div>
            	<div class="col-md-6 mb-1">
                    <label class="col-form-label" for="Volumen">Volumen</label>
                    <input class="form-control" type="text" name="Volumen" id="Volumen" maxlength="200" value="<?=$o_DefaultBN->getVolumen();?>" />
            	</div>
            </div>
            <div class="form-row mx-0">
                <div class="col-md-6 mb-1">
                    <label class="col-form-label" for="NroSOAT">Numero de SOAT</label>
                    <input class="form-control" type="text" name="NroSOAT" id="NroSOAT" maxlength="12" value="<?=$o_DefaultBN->getNroSOAT();?>" onblur="this.value=this.value.toUpperCase();" />
            	</div>
            	<div class="col-md-6 mb-1">
                    <label class="col-form-label" for="VencSOAT">Vencimiento SOAT</label>
                    <input class="form-control" type="text" name="VencSOAT" id="VencSOAT" maxlength="200" value="<?=substr( $o_DefaultBN->getVencSOAT(), 0, 10 );?>" autocomplete="off" />
                    <script type="text/javascript">
                    $( "#VencSOAT" ).datepicker( { dateFormat: "yy-mm-dd", changeYear:true, yearRange: "-0:+5", changeMonth: true, onClose: function (){ this.focus(); } } );
                    </script>
            	</div>
            </div>
            <div class="form-row mx-0">
                <div class="col-md-6 mb-1">
                    <label class="col-form-label" for="NroMTC">Numero MTC</label>
                    <input class="form-control" type="text" name="NroMTC" id="NroMTC" maxlength="12" value="<?=$o_DefaultBN->getNroMTC();?>" />
            	</div>
            	<div class="col-md-6 mb-1">
                    <label class="col-form-label" for="RUCtransportista">RUC Transportista</label>
                    <input class="form-control" type="text" name="RUCtransportista" id="RUCtransportista" maxlength="200" value="<?=$o_DefaultBN->getRUCtransportista();?>" />
            	</div>
            </div>
            <div class="form-row mx-0">
            	<div class="col-md-6 mb-1">
                    <label class="col-form-label" for="Estado">Estado</label>
                    <select class="form-control" name="Estado" id="Estado" >
                    	<option value=""> - Seleccione - </option>
                        <option value="A" <?php if( $o_DefaultBN->getEstado()=="A" ){ echo "SELECTED"; } ?>> ACTIVO </option>
                        <option value="I" <?php if( $o_DefaultBN->getEstado()=="I" ){ echo "SELECTED"; } ?>> INACTIVO </option>
                    </select>
            	</div>
            </div>
            
            <?php if( $o_DefaultBN->getIdVehiculo() ){ ?>
            <br>
            
            <button type="button" class="btn btn-primary btn-lg btn-block" id="btnAudi">Auditoria</button>
            
                   <script>
                    $( "#btnAudi" )
                    .click
                    (
                        function()
                        {
                            $( '#myIframe' ).attr( 'src', '<?=buildUrl( $NomMod.'/audi', 'Id='.$o_DefaultBN->getIdVehiculo() )?>' );
                            $( '#dialog' ).dialog( 'open' );
                        }
                    )
                    </script>
             <br>  
            <?php } ?>
            <div class="form-group col-14"><hr style="border-top: 1px solid #8c8b8b;"></div>
        
    </div>
</div>

<div id="dialog" style="display:none;"><iframe id="myIframe" src="" frameborder="0" height="100%" width="100%"></iframe></div>
<script>
    objMainTab.modalUIDialog( "#dialog", { title : "Auditoria", width : 425, height  : 230 } );
</script>
                                                    
<script>
$.validator.setDefaults
(
    {
        submitHandler: function( form ) 
        {
            ejecutarGuardar();
        }
    }
);
$( "#form1" ).validate();
</script>