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

<style type="text/css">
    .ui-dialog .ui-dialog-titlebar-close
    {
        position: absolute;
        right: .3em;
        top: 50%;
        width: 20px;
        margin: -10px 0 0 0;
        padding: 1px;
        height: 20px;
        background-position: -96px -128px;
        /*background-image: url("images/ui-icons_056b93_256x240.png");*/
        background-image: url("<?=Constantes::ROOT_DIR_APP?>web/css/jquery/themes/start_1.12.1/images/ui-icons_056b93_256x240.png");
    }
</style>

<style type="text/css">
    .table td, .table th {
        padding: .2rem;
        vertical-align: top;
        border-top: 1px solid #dee2e6;
    }
</style>

<script type="text/javascript">
    changeIcon = function( elm, name )
    {
        var elms    = $( elm ).find( "svg" );
        var elm_sel = elms.first();

        if( $( "#" + name ).is( ":visible" ) )
        {
            $( elm_sel ).removeClass( "fa-angle-down" );
            $( elm_sel ).addClass( "fa-angle-right" );
        }
        else
        {
            $( elm_sel ).removeClass( "fa-angle-right" );
            $( elm_sel ).addClass( "fa-angle-down" );
        }
    }
</script>

<?php
/** @var MST_ReferenciaProductoBN $o_DefaultBN */
/** @var MST_ReferenciaProductoBN[] $a_MST_ReferenciaProducto */
/** @var MST_ColorBN[] $a_MST_Color */
/** @var MST_CategoriaTallaBN[] $a_MST_CategoriaTalla */
/** @var MST_TallaBN[] $a_MST_Talla */
?>

<div id="accordion" class="mb-2">
    <div class="card">
        <div class="card-header">
            <a data-toggle="collapse" href="#collapseThree" aria-expanded="true" aria-controls="collapse1" class="text-info" onclick="changeIcon(this,'collapseThree');" id="cotent_a_collapse">
                <h5 class="mb-0"> Filtro <i class="fas fa-angle-right pull-right"></i></h5>
            </a>
        </div>
        <div id="collapseThree" class="collapse" data-parent="#accordion">
            <div class="card-body pb-1">

                <form class="" name="form1" id="form1" method="POST" action="">
                    <input type="hidden" name="IdProveedor" id="IdProveedor" value="<?=$IdProveedor?>">
                    <div class="form-row mx-0">
                        <div class="col-md-11 mb-1">
                            <div class="form-row mx-0">
                                <!--<div class="col-md-3 mb-1">
                                    <label class="col-form-label" for="idProveedor">Proveedor</label>
                                    <select class="form-control" name="idProveedor" id="idProveedor">
                                        <option value=""> - Seleccione - </option>
                                        <?php foreach( $a_MST_PersonaMast  as $o_MST_PersonaMastBN ){ ?>
                                            <option value="<?=$o_MST_PersonaMastBN->getIdPersona()?>"> <?=$o_MST_PersonaMastBN->getNombreCompletoLLeno()?> </option>
                                        <?php } ?>
                                    </select>
                                </div>-->
                                <div class="col-md-3 mb-1">
                                    <label class="col-form-label" for="IdReferencia">Referencia</label>
                                    <select class="form-control" name="IdReferencia" id="IdReferencia">
                                        <option value=""> - Seleccione - </option>
                                        <?php foreach( $a_MST_ReferenciaProducto  as $o_MST_ReferenciaProductoBN ){ ?>
                                            <option value="<?=$o_MST_ReferenciaProductoBN->getIdReferencia()?>"> <?=$o_MST_ReferenciaProductoBN->getDescripcion()?> </option>
                                        <?php } ?>
                                    </select>
                                </div>
                                <div class="col-md-3 mb-1">
                                    <label class="col-form-label" for="IdColor">Color</label>
                                    <select class="form-control" name="IdColor" id="IdColor">
                                        <option value=""> - Seleccione - </option>
                                        <?php foreach( $a_MST_Color  as $o_MST_ColorBN ){ ?>
                                            <option value="<?=$o_MST_ColorBN->getIdColor()?>"> <?=$o_MST_ColorBN->getCodigo()?> - <?=$o_MST_ColorBN->getDescripcion()?>  </option>
                                        <?php } ?>
                                    </select>
                                </div>
                                <div class="col-md-3 mb-1">
                                    <label class="col-form-label" for="IdCatTalla">Categoria</label>
                                    <select class="form-control" name="IdCatTalla" id="IdCatTalla">
                                        <option value=""> - Seleccione - </option>
                                        <?php foreach( $a_MST_CategoriaTalla  as $o_MST_CategoriaTallaBN ){ ?>
                                            <option value="<?=$o_MST_CategoriaTallaBN->getIdCatTalla()?>"> <?=$o_MST_CategoriaTallaBN->getDescripcion()?>  </option>
                                        <?php } ?>
                                    </select>
                                </div>
                                <div class="col-md-3 mb-1">
                                    <label class="col-form-label" for="IdTalla">Talla</label>
                                    <input type="text" class="form-control form-control-sm" name="IdTalla" id="IdTalla" onfocus="this.select();" autocomplete="off">
                                    <!--<select class="form-control" name="IdTalla" id="IdTalla">
                                        <option value=""> - Seleccione - </option>
                                        <?php foreach( $a_MST_Talla  as $o_MST_TallaBN ){ ?>
                                            <option value="<?=$o_MST_TallaBN->getIdTalla()?>"> <?=$o_MST_TallaBN->getDescripcion()?>  </option>
                                        <?php } ?>
                                    </select>-->
                                </div>
                            </div>
                        </div>
                        <div class="col-md-1 mb-1">
                            <button type="button" class="btn btn-primary btn-sm btn-block text-nowrap" onclick="findControl();">Buscar</button>
                            <button type="button" class="btn btn-primary btn-sm btn-block text-nowrap" onclick="agregarCodigos();">Seleccionar</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
</script>

<?php include_partial( "itemGridRefe" ); ?>

<script>
    //ESCAPE, DETECTA EL F5, CTRL+F5
    $( document ).bind
    (
        'keyup',
        function( e )
        {
            //console.log( e.which );
            if( e.which === 13 ) //+
            {
                findControl();
            }
            if( e.which === 27 ) //ESCAPE
            {
                parent.closeWindow();
            }

        }
    );
</script>