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

<?php
/** @var MST_ColorBN[] $a_MST_Color */
/** @var MST_CategoriaTallaBN[] $a_MST_CategoriaTalla */
/** @var String $s_Titulo */
/** @var String $idReferencia */
/** @var String $s_CodigoColor */
/** @var String $s_CatTalla */
?>
<script>
    validarCheck = function( elm, ref )
    {
        if( !$( elm ).is( ':checked' ) )
        {
            $( '[refcolor="' + ref + '"]' ).each
            (
                function ( index, domEle )
                {
                    $( domEle ).prop( "checked", false );
                }
            );
        }
    }

    guardarFormulario = function()
    {
        var b_ControlChk   = true;
        var s_MensajeError = "";

        //validacion por la selecciona de categorias
        if ( $( 'input[type^=checkbox]:checked' ).length <= 0 )
        {
            showAlertBootStrap( 'content_alert', 'alert-danger', "Debe de seleccionar Categorias" );
            b_ControlChk = false;
        }

        //validacion por valores de color
        /*if( !$( "#CodigoColor" ).val() )
        {
            showAlertBootStrap( 'content_alert', 'alert-danger', "Debe de ingresar el codigo de color." );
            b_ControlChk = false;
        }*/

        if( !$( "#DescripcionColor" ).val() )
        {
            showAlertBootStrap( 'content_alert', 'alert-danger', "Debe de ingresar la descripcion de color." );
            b_ControlChk = false;
        }

        if( b_ControlChk )
        {
            $( "#form1" ).submit();
        }
    }
</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"><?php /*=$s_Titulo*/?></h4>
        </div>
    </div>
</div>-->

<form class="needs-validation" name="form1" id="form1" method="POST" action="" onsubmit="">
    <input type="hidden" name="control" id="control" value="1">
    <input type="hidden" name="idReferencia" id="idReferencia" value="<?=$idReferencia?>">
    <div id="accordion" class="mb-2">
        <div class="card">
            <div class="card-body pb-1">
                <div class="form-row mx-0">
                    <input type="hidden" name="CodigoColor" value="">
                    <!--<div class="col-md-4 mb-1">
                        <label class="col-form-label" for="CodigoColor">Codigo Color</label>
                        <input type="text" class="form-control" name="CodigoColor" id="CodigoColor" placeholder="" autocomplete="off" value="">
                    </div>-->
                    <div class="col-md-6 mb-1">
                        <label class="col-form-label" for="CodigoColor">Descripci&oacute;n Color</label>
                        <input type="text" class="form-control" name="DescripcionColor" id="DescripcionColor" placeholder="" autocomplete="off" value="">
                    </div>
                    <div class="text-center mt-2">
                        <?php if( !$b_CtrlPopup ){ ?>
                        <button type="button" class="btn btn-primary btn-lg btn-block" onclick="guardarFormulario();">GUARDAR</button>
                        <?php } ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div id="content_alert" style=""></div>
    <div class="card">
        <div class="form-row mx-0 mt-1 mb-1">
            <div class="col-md-12">
                <div class="card" id="content_datos_cliente">
                    <h5 class="card-header">Seleccione Categoria</h5>
                    <div class="card-body" style="padding: 10px;">
                        <table class="table">
                            <tr>
                                <?php $i_Cont = 0; ?>
                            <?php foreach ( $a_MST_CategoriaTalla as $o_MST_CategoriaTallaBN ){ ?>
                                <?php
                                $s_IdCatTalla = $o_MST_CategoriaTallaBN->getIdCatTalla();
                                ?>
                                    <?php if( $i_Cont==4 ){ ?>
                                    </tr>
                                    <tr>
                                        <?php $i_Cont = 0; ?>
                                    <?php } ?>
                                    <th>
                                        <div class="custom-control custom-checkbox">
                                            <input type="checkbox" class="custom-control-input" id="catetalla_<?=$s_IdCatTalla?>" name="idCatTalla[<?=$s_IdCatTalla?>]" value="<?=$s_IdCatTalla?>"  >
                                            <label class="custom-control-label" for="catetalla_<?=$s_IdCatTalla?>"><?=$o_MST_CategoriaTallaBN->getDescripcion()?></label>
                                        </div>
                                    </th>
                                <?php $i_Cont++ ?>
                            <?php } ?>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
<?php if( $b_CtrlPopup ){ ?>
<script type="text/javascript">
parent.ocultarModal();
</script>
<?php } ?>