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

<div class="shadow-sm p-3 mb-2 bg-white rounded card card-body">
    <div class="row">
        <div class="col mb-1">
            <h4 class="text-info text-nowrap mb-0"><?=$s_Titulo?></h4>
        </div>
    </div>
</div>

<script>
saveForm = function()
{
    x = confirm( "Esta seguro de eliminar el registro?" )
    if( x )
    {
        blockContent('content_buttons');
        var strFormSerialize = $('form').serialize();
        executeAjaxJson
        (
            "<?php echo buildUrl( 'subfamilia/deleteRow' ) ?>",
            strFormSerialize,
            function (o_json) {
                unBlockContent('content_buttons');
                if (o_json.error) {
                    showAlertBootStrap('content_alert', 'alert-danger', o_json.mensaje_error);
                    return false;
                }
                parent.findControl();
                parent.closeWindow('dialog');
            }
        );
    }

    return false;
}
</script>

<form name="form1" id="form1" method="POST" action="" onsubmit="return saveForm();">
    <input type="hidden" name="s_TipoProc" id="s_TipoProc" value="<?=$s_TipoProc?>">
    <input type="hidden" name="TypeSub" id="TypeSub" value="0">
    <input type="hidden" name="i_Id" id="i_Id" value="<?=$i_Id ?>">
    
    <?php include_partial
    ( 
        "addedit", 
        array
        ( 
                "o_MST_ClaseSubFamiliaBN" => $o_MST_ClaseSubFamiliaBN,
                "a_MST_ClaseLinea"      => $a_MST_ClaseLinea,
                "a_MST_ClaseFamilia"    => $a_MST_ClaseFamilia
        )
     ); ?>

    <div class="form-row mx-0" style="padding: 10px;" id="content_buttons">
        <div class="col-md-6 mb-1">
            <button type="button" class="btn btn-danger btn-lg btn-block no-disabled" onclick="parent.closeWindow('dialog');">CANCELAR</button>
        </div>
        <?php if( $s_TipoProc ==  "dlt" ){ ?>
        <div class="col-md-6 mb-1">
            <button type="submit" class="btn btn-primary btn-lg btn-block no-disabled" onclick="">Eliminar</button>
        </div>
        <?php } ?>
    </div>
</form>

<script type="text/javascript">
/*convertirTextoTodosLosInputs = function()
{
    pr( "Ingresa" );

    $.each
    (
        $('input, select, textarea, button'), function()
        {
            //pr( this );
            var nodeName = typeof $( this ).attr( 'nodeName' ) === 'undefined' ? $( this ).prop( 'nodeName' ) : $( this ).attr( 'nodeName' );
            var nodeType = $( this ).attr( 'type' );

            //console.log( nodeName + " - " + nodeType );

            if( $( this ).length > 0 )
            {
                switch( nodeName )
                {
                    case "SELECT":
                        $( this ).prop( "disabled", true );
                    break;
                    case "TEXTAREA":
                        pr( this );
                        $( this ).prop( "disabled", true );
                    break;
                    case "INPUT":
                        switch( nodeType )
                        {
                            case "textarea":
                                //pr( this );
                            break;
                            case "text":
                                //pr( this );
                                $( this ).prop( "disabled", true );
                            break;
                            case "button":
                                //$( this ).prop( "disabled", true );
                            break;
                            case "checkbox":
                                $( this ).prop( "disabled", true );
                            break;
                            case "hidden":
                                //$( this ).remove();
                            break;
                        }
                    break;
                    case "BUTTON":
                        pr( $( this ).attr('class') );
                        if( $( this ).attr('id') != "btnAudi" && $( this ).attr('class') == "index.js:128 ui-dialog-titlebar-close" )
                        {
                            $( this ).prop( "disabled", true );
                        }
                    break;
                }
            }
        }
    );
}*/
//convertirTextoTodosLosInputs();
convertirDisabledTodosLosInputs();
</script>
