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

<script>
mostrarCargaImg = function(){ $('#s_ImagenLoad')[0].style.display = 'inline'; }
ocultarCargaImg = function(){ $('#s_ImagenLoad')[0].style.display = 'none'; }

mostrarMensajeError = function( s_MensajeError )
{
    $( "#resultContent" ).html( '<div id="mensaje_error_content" class="error">' + s_MensajeError + '</div>' );
    setTimeout( function(){ $( "#mensaje_error_content" ).fadeOut( 800 ).fadeIn( 800 ).fadeOut( 500 ).fadeIn( 500 ).fadeOut( 300 ); }, 4000 );
}
</script>
<script>
ejecutarGuardar = function()
{
	mostrarCargaImg();
	var strFormSerialize = $( 'form' ).serialize();
    executeAjaxJson( 
                        "<?php echo buildUrl( 'addemp/saveUniProd', "block=001" ) ?>", 
                        strFormSerialize,
                        function( o_json )
                        {
                            if( o_json.error )
                            {
                                ocultarCargaImg();
                                mostrarMensajeError( o_json.mensaje_error );
                                return false;
                            }
                            parent.findControl();
                            parent.$( '#dialog' ).dialog( 'close' );
                            return true;
                        } 
                   );
}
</script>
<table class="cuerpo" width="97%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td valign="top">
            <form id="form1" name="form1" method="POST" onsubmit=""  enctype="multipart/form-data">
                <input type="hidden" name="s_TipoProc" id="s_TipoProc" value="<?=$s_TipoProc?>">
                <input type="hidden" name="i_Id" id="i_Id" value="<?=$i_Id?>">
                <input type="hidden" name="i_IdDet" id="i_IdDet" value="<?=$i_IdDet?>">
                <table class="" width="100%" style="">
                    <tr>
                        <td valign="top">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">                                
                                <tr>
                                    <td class="marco marcoTitle">
                                        <table class="" width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                                <td width="100%" valign="top">
                                                
                                                    <table width="100%">
                                                        <tr>
                                                            <td width="50%" valign="top" >
                                                            
                                                                <div id="resultContent" style=""></div>
                                                                
                                                                <?php include_partial( "infohead", array( "o_GSS_CompaniaBN" => $o_GSS_CompaniaBN ) ); ?>
                                                            
                                                                <fieldset class="formGen" style="margin-top:0px">
                                                                    <!--<legend class="fielsettex">Datos Generales</legend> -->
                                                                    
                                                                    <?php include_partial
                                                                            ( 
                                                                                "addeditsucu", 
                                                                                array
                                                                                (
                                                                                    "o_DefaultBN" => $o_DefaultBN, 
                                                                                    "a_ALM_AlmacenMast" => $a_ALM_AlmacenMast
                                                                                ) 
                                                                            ); ?>
                                                                    
                                                                </fieldset>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <table width="100%" border="0" style="margin-top: 10px;">
                                            <tr>
                                                <td align="center" width="100%">
                                                    <input type="button" class="button" value="Cancelar" onclick="parent.$( '#dialog' ).dialog( 'close' );">
                                                    <input type="submit" class="button" value="Grabar" onclick="">
                                                    <div id="s_ImagenLoad" style="display: none;"><img src="<?php echo Constantes::ROOT_DIR_APP ?>web/images/progress.gif" border="0"/>&nbsp;<label class="laber req">Grabando...</label></div>
                                                    &nbsp;
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </form>
        </td>
    </tr>
    
    
</table>

<script>
$.validator.setDefaults
(
    {
        submitHandler: function( form ) 
        {
            ejecutarGuardar();
        }
    }
);
$( "#form1" ).validate();
</script>