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

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

<form action="" method="post" name="form1" id="form1">
    <input type="hidden" name="moneda_cod" id="moneda_cod" value="<?=$moneda_cod?>" >
    <input type="hidden" name="IdAlmacen" id="IdAlmacen" value="<?=$IdAlmacen?>" >

    <div class="form-row mx-0 mb-1">

        <!-- <div class="col-sm-10 mb-1"> -->

            <div class="table-responsive">
                <table  class="table table-borderless border" style="margin-bottom: 0;">
                    <tr>
                        <td  nowrap="nowrap" align="right" scope="row"><label for="DescripcionCompleta">Descripci&oacute;n :</label></td>
                        <td nowrap="nowrap" ><input type="text" class="form-control form-control-sm" name="DescripcionCompleta" id="DescripcionCompleta" style="width: 150px;" onfocus="this.select();" autocomplete="off"></td>
                        <td  nowrap="nowrap" align="right" scope="row"><label for="IdLinea">Linea :</label></td>
                        <td nowrap="nowrap">
        					<select class="form-control form-control-sm" id="IdLinea" name="IdLinea" style="width: 150px;"
                                        onchange="pr( '123' ); $('#IdFamilia')[0].options.length = 1;
                                        publicForSelectAjaxJSON('<?php echo buildUrlComplet( 'mst.php/item/request' ) ?>', $( 'form' ).serialize() + '&TipoProc=Familia', 'IdFamilia');
                                        findControl();
                                    ">
        						<option value=""> - Seleccione - </option>
        						<?php foreach ( $a_MST_ClaseLinea as $i_Key => $o_MST_ClaseLineaBN ){ ?>
        						<option value="<?=$o_MST_ClaseLineaBN->getIdLinea()?>" > <?=$o_MST_ClaseLineaBN->getDescripcion()?> </option>
        						<?php } ?>
        					</select>
                        </td>
                        <td  nowrap="nowrap" align="right" scope="row"><label for="IdColor">Color :</label></td>
                        <td nowrap="nowrap">
                            <select class="form-control form-control-sm" id="IdColor" name="IdColor" style="width: 150px;" onchange="findControl();">
                                <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>
                        </td>
                        <td  nowrap="nowrap" align="right" scope="row"><label for="ConStock">Con Stock</label></td>
                        <td nowrap="nowrap"> <input class="" type="checkbox" name="ConStock" id="ConStock" value="1" onclick="findControl();" > </td>
                    </tr>
                    <tr>
                        <td  nowrap="nowrap" align="right" scope="row"><label for="IdItem">C&oacute;digo :</label></td>
                        <td nowrap="nowrap"><input type="text" class="form-control form-control-sm" name="IdItem" id="IdItem"  style="width: 150px;" onfocus="this.select();" autocomplete="off"></td>
                        <td  nowrap="nowrap" align="right"><label for="IdFamilia">Familia :</label></td>
                        <td nowrap="nowrap">
        					<select class="form-control form-control-sm" id="IdFamilia" name="IdFamilia" style="width: 150px;" onchange="findControl();">
        						<option value=""> - Seleccione - </option>
        					</select>
                        </td>
                        <td  nowrap="nowrap" align="right" scope="row"><label for="IdCatTalla">Categoria :</label></td>
                        <td nowrap="nowrap">
                            <select class="form-control form-control-sm" id="IdCatTalla" name="IdCatTalla" style="width: 150px;" onchange="findControl();">
                                <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>
                        </td>
                        <td  nowrap="nowrap" align="right" scope="row"><label for="IdTalla">Talla :</label></td>
                        <td nowrap="nowrap">
                            <input type="text" class="form-control form-control-sm" name="IdTalla" id="IdTalla" style="width: 150px;" onfocus="this.select();" autocomplete="off">
                        </td>
                        <!--<td  nowrap="nowrap" align="right" scope="row"><label for="IdMarca">Marca :</label></td>
                        <td nowrap="nowrap">
                            <select class="form-control form-control-sm" id="IdMarca" name="IdMarca" style="width: 150px;" onchange="findControl();">
                                <option value=""> - Seleccione - </option>
                                <?php foreach ( $a_ALM_Marca as $i_Key => $a_ALM_MarcaBN ){ ?>
                                <option value="<?=$a_ALM_MarcaBN->getIdMarca()?>" > <?=$a_ALM_MarcaBN->getDescripcionLocal()?> </option>
                                <?php } ?>
                            </select>
                        </td>-->
                    </tr>
                </table>
            </div>
        <!-- </div> -->
        <!-- <div class="col-sm-2 mb-1 ">
            <button type="button" class="btn btn-primary btn-block" onclick="findControl();">Buscar</button>
            <button type="button" class="btn btn-primary btn-block" onclick="location.reload();">Recargar</button>
        </div> -->
    </div>

</form>

<!--<input type="button" onclick="findControl();" value="Buscar" class="button">
<input type="button" onclick="location.reload();" value="Actualizar" class="button">-->


<?php include_partial( "itemGrid", array( "i_Id" => $i_Id, "IdAlmacen" => $IdAlmacen, "moneda_cod" => $moneda_cod, "module" => $module, "controler" => $controler, "id_adicional" => $id_adicional ) ); ?>

<script>
/*
pr( parent.prod_final_tipo );
if( parent.prod_final_tipo != "" )
{
    $( "#IdLinea" ).val( 3 );
    $( "#IdLinea" ).trigger( "change" );
    if( parent.prod_final_tipo == 1 ) //encofrado
    {
        setTimeout
        (
            function()
            {
                $( "#IdFamilia" ).val( 31 );
                $( "#IdFamilia" ).trigger( "change" );
            },
            1000 
        );
    }
    if( parent.prod_final_tipo == 2 ) //andamio
    {
        setTimeout
        (
            function()
            {
                $( "#IdFamilia" ).val( 32 );
                $( "#IdFamilia" ).trigger( "change" );
            },
            1000 
        );
    }
}
*/
$( "#DescripcionCompleta,#IdItem" ).keyup
(
    function( e ) 
    {
        findControl();
    }
);
</script>
<script>
//ESCAPE, DETECTA EL F5, CTRL+F5
$( document ).bind
(
    'keyup', 
    function( e ) 
    {
    	//pr( e.which );
        if( e.which === 13 ) 
        {
            findControl();
        }
    }
);
</script>