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

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

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

<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"> Lista de Precios de Encofrado</h4>
        </div>
        	<div class="form-row mx-1">
                
                <input type="button" class="btn btn-primary btn-lg btn-block" value="Nuevo" onclick="location.href='<?=buildUrl( "listpreciosenc/addedit", "s_TipoProc=nvo" )?>';" >
        	</div>
        </div>
</div>

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

<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">
                <div class="form-row mx-0">
                    <div class="col-md-6 mb-1">
                        <label class="col-form-label" for="IdSucursal">Sucursal</label>
                        <?=crearCombo( array( "name"=>"IdSucursal", "ParamId"=>"getIdSucursal", "ParamDesc"=>"getDescripcion" ), $a_GSS_Sucursal ) ?>
                    </div>
                    <div class="col-md-6 mb-1">
                        <label class="col-form-label" for="Estado">Estado</label>
                        <?=crearSelect( array( "Estado", "Llave", "Valor" ), array( array( "Llave" => "A", "Valor" => "ACTIVO" ), array( "Llave" => "I", "Valor" => "INACTIVO" ) ) )?>
                    </div>
                </div>
                <div class="text-center mt-2">
                    <button class="btn btn-primary text-center" type="button" onclick="findControl();" >Buscar</button>
                    <a data-toggle="collapse" href="#collapseThree" class="text-info" onclick="changeIcon( $('#cotent_a_collapse')[0],'collapseThree');" style="background: none;">
                        Contraer <i class="fas fa-angle-up"></i>
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

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

<script>
$( document ).bind
(
    'keyup', 
    function( e ) 
    {
        if( e.which == 13 ) //ENTER
        {
            findControl();
        }
        if( e.which == 107 || e.which == 27 || e.which == 109 ) //tecla + | ESC | -
        {
            $( "#cotent_a_collapse" ).trigger( "click" );
        }        
    }
);
</script>