<?php use_helper('UrlFunctions'); ?>
<?php use_helper( 'IncludePartial' ); ?>
<?php use_helper( 'UtilFunctions' ); ?>
<script>
ejecutarGuardar = function()
{
	x = confirm( "Esta seguro de ingresar la Promoción?" );
    if( x )
    {
    	blockContent( "content_form" );
    	var strFormSerialize = $( 'form' ).serialize();
        executeAjaxJson( 
                            "<?php echo buildUrl( 'pro/savePromoCustom' ) ?>", 
                            strFormSerialize,
                            function( o_json )
                            {
                                console.log( o_json );
                                unBlockContent( "content_form" );
                                if( o_json.error )
                                {
                                    mostrarMensajeError( o_json.mensaje_error );
                                    return false;
                                }
                                parent.$( '#dialog3' ).dialog( 'close' );
                                parent.executeFindDetail();
                            } 
                       );
    }
}
</script>
<div id="resultContent" style=""></div>
<form id="form1" name="form1" method="POST" onsubmit="return false;"  enctype="multipart/form-data">
    <input type="hidden" name="i_Id" value="<?=$i_Id?>">
    <table width="100%" id="content_form">
        <tr>
            <td width="100%" valign="top" >
                <fieldset class="formGen" style="margin-top:0px">
                    <table border="0" cellspacing="6" cellpadding="0" style="" width="100%">
                        <tr>
                            <td nowrap="nowrap" class="cabecera"><label class="label req" for="Valor" >% Descuento</label></td>
                            <td nowrap="nowrap">
                                <!--<select class="combo required" id="Valor" name="Valor">
                                    <option value=""> - Seleccione - </option>
                                    <?php for( $i=1; $i<31; $i++ ){ ?>
                                    <option value="<?=$i?>"> <?=$i?> % </option>
                                    <?php } ?>
                                </select>-->
                                <input type="text" class="text required" name="Valor" id="Valor" value="" 
                                        style="text-align:center; width:50%"
                                        onkeypress="return NumCheckDecimal( event, this );"
                                        onfocus="this.select()"/>&nbsp;%
                                <script>
                                $( "#Valor" ).keyup
                                ( 
                                    function( e ) 
                                    {
                                        //console.log( e );
                                        //console.log( e.target.id );
                                        /*if( e.which == 0 ){ return true; }
                                        if( e.which == 8 ){ return true; }
                                        if( e.which == 13 ) { findControl(); $( "#CodigoBarras" ).select(); }
                                        var regex = new RegExp( "^[a-zA-Z0-9]+$" );
                                        var str = String.fromCharCode( !e.charCode ? e.which : e.charCode );
                                        if ( regex.test( str ) ) { return true; }
                                        return false;*/
                                        $( "#DescripcionPromo" ).val( "Descuento " + $( "#" + e.target.id ).val() + " %" );
                                    }
                                );
                                </script>
                            </td>
                            <td nowrap="nowrap" class="cabecera">&nbsp;</td>
                        </tr>
                        <tr>
                            <td nowrap="nowrap" class="cabecera"><label class="label req" for="DescripcionPromo" >Descripci&oacute;n</label></td>
                            <td nowrap="nowrap">
                                <input type="text" class="text text0" readonly name="DescripcionPromo" id="DescripcionPromo" value="Descuento" style="width:80%">
                            </td>
                            <td nowrap="nowrap" class="cabecera">&nbsp;</td>
                        </tr>
                    </table>
                </fieldset>
            </td>
        </tr>
    </table>

    <table width="100%" border="0" style="margin-top: 10px;">
        <tr>
            <td align="right" width="65%">
                <input type="button" class="button" value="Cancelar" onclick="parent.$( '#dialog3' ).dialog( 'close' );">
                <input type="submit" class="button" value="Grabar" onclick="">
            </td>
            <td width="35%">
                <div id="s_ImagenLoad" style="display: none;"><img src="<?php echo Constantes::ROOT_DIR_IMG ?>common/progress.gif" border="0"/>&nbsp;<label class="laber req">Procesando...</label></div>
                &nbsp;
            </td>
        </tr>
    </table>
</form>
<script>
$.validator.setDefaults
(
    {
        submitHandler: function( form ) 
        {
            ejecutarGuardar();
        }
    }
);
$( "#form1" ).validate();
$( "#Valor" ).focus();
</script>