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

<?php
/** @var MST_PersonaMastBN[] $a_MST_PersonaMast */
/** @var MST_ColorBN $o_DefaultBN */
?>

<script>
    ejecutarGuardar = function()
    {
        x = confirm( "Esta seguro de guardar los cambios?" )
        if( x )
        {
            blockContent('form1');
            var strFormSerialize = $('form').serialize();
            executeAjaxJson
            (
                "<?php echo buildUrl( 'color/saveAddEdit' ) ?>",
                strFormSerialize,
                function (o_json)
                {
                    unBlockContent('form1');
                    if (o_json.error)
                    {
                        showAlertBootStrap( 'content_alert', 'alert-danger', o_json.mensaje_error );
                        return false;
                    }
                    location.href = "<?=buildUrl( 'color/list' )?>";
                }
            );
        }
        return false;
    }
</script>

<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>

<div id="content_alert" style=""></div>
<form id="form1" name="form1" method="POST" onsubmit="return ejecutarGuardar();"  enctype="multipart/form-data">
    <input type="hidden" name="tipoProc" id="tipoProc" value="<?=$s_TipoProc?>">
    <input type="hidden" name="id" id="id" value="<?=$i_Id?>">

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

    <div class="card mb-2" id="content_form">
        <div class="container">
            <div class="form-row mx-0">
                <div class="col-md-12 mb-1">
                    <label class="col-form-label" for="IdProveedor">Proveedor</label>
                    <select class="form-control form-control-sm custom-select my-0 mr-sm-2" name="IdProveedor" id="IdProveedor" required>
                        <option value=""> - Seleccione - </option>
                        <?php foreach ( $a_MST_PersonaMast as $o_MST_PersonaMastBN ){ ?>
                            <option value="<?=$o_MST_PersonaMastBN->getIdPersona()?>"  <?php if( $o_DefaultBN->getIdProveedor()==$o_MST_PersonaMastBN->getIdPersona() ){ echo "selected"; } ?> > <?=$o_MST_PersonaMastBN->getNombreCompleto()?> </option>
                        <?php } ?>
                    </select>
                </div>
            </div>
            <div class="form-row mx-0">
                <div class="col-md-6 mb-1">
                    <label class="col-form-label" for="Codigo">Codigo</label>
                    <input type="text" class="form-control" name="Codigo" id="Codigo" autocomplete="off" value="<?=$o_DefaultBN->getCodigo()?>" required >
                </div>
            </div>
            <div class="form-row mx-0">
                <div class="col-md-12 mb-1">
                    <label class="col-form-label" for="Descripcion">Descripci&oacute;n</label>
                    <input type="text" class="form-control" name="Descripcion" id="Descripcion" autocomplete="off" value="<?=$o_DefaultBN->getDescripcion()?>"  required >
                </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 form-control-sm custom-select my-0 mr-sm-2" name="Estado" id="Estado" required>
                        <option value=""> - Seleccione - </option>
                        <option value="A" <?php if( $o_DefaultBN->getEstado()==MST_ColorBN::ESTADO_ACTIVO ){ echo "selected"; } ?> > ACTIVO </option>
                        <option value="I" <?php if( $o_DefaultBN->getEstado()==MST_ColorBN::ESTADO_INACTIVO ){ echo "selected"; } ?> > INACTIVO </option>
                    </select>
                </div>
            </div>

            <div class="form-group col-14">
                <div class="dropdown-divider"></div>
            </div>
        </div>
    </div>

    <div class="form-row mx-0">
        <div class="col-md-6 mb-1">
            <button type="button" class="btn btn-danger btn-lg btn-block" onclick="parent.closeWindow()">CERRAR</button>
        </div>
        <div class="col-md-6 mb-1">
            &nbsp;
        </div>
    </div>
</form>

