<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( 'turno/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( 'turno/addedit', "block=001&s_TipoProc=upd&i_Id=")?>" + o_json.id;
                                break;
                                case "1":
                                    location.href = "<?=buildUrl( 'turno/list', "block=001")?>";
                                break;
                            }
                        } 
                   );
}
</script>
<?php if( false ){ $s_Disabled = "disabled"; }else{ $s_Disabled = ""; } ?>

<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="TurnoDescripcion">Descripcion</label>
                    <input type="text" class="form-control" autocomplete="off"  name="TurnoDescripcion" id="TurnoDescripcion" value="<?=$o_TR_TurnoBN->getTurnoDescripcion() ?>" onblur="this.value=this.value.toUpperCase();" >
            	</div>
            	<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_TR_TurnoBN->getEstado()=="A" ){ echo "SELECTED"; } ?> > ACTIVO </option>
                        <option value="I" <?php if( $o_TR_TurnoBN->getEstado()=="I" ){ echo "SELECTED"; } ?> > INACTIVO </option>
                    </select>
                </div>
                
            </div>
            <div class="form-row mx-0">
                <div class="col-md-6 mb-1">
                        <label class="col-form-label" for="TurnoDescHora">Horas</label>
                        <input type="text" class="form-control" autocomplete="off" name="TurnoDescHora" id="TurnoDescHora" value="<?=$o_TR_TurnoBN->getTurnoDescHora() ?>" onblur="this.value=this.value.toUpperCase();" >
                	</div>
                <div class="col-md-6 mb-1">
                    <label class="col-form-label" for="TurnoDescMin">Minutos</label>
                    <input class="form-control" type="text" name="TurnoDescMin" id="TurnoDescMin" value="<?=$o_TR_TurnoBN->getTurnoDescMin() ?>"  onblur="this.value=this.value.toUpperCase();"/>
                </div>
                
            </div>

            <div class="form-group col-14"><hr style="border-top: 1px solid #8c8b8b;"></div>
        
    </div>
</div>


<div id="dialog"><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();

$( document ).ready(function() {
    if($("#IdCompania").val() != ''){
        //alert($("#IdCompania").val());
        //$('#IdGrupoAlmacen')[0].options.length = 1; 
        //publicForSelectAjaxJSON("<?php echo buildUrl( 'almacen/request', 'block=001') ?>", $( 'form' ).serialize() + '&TipoProc=LoadGrupo', 'IdGrupoAlmacen');
    }
});
</script>