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

<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>
ejecutarActualizar = function( status )
{
	mostrarCargaImg();
	var strFormSerialize = $( 'form' ).serialize();
    strFormSerialize += "&status=" + status;
    executeAjaxJson( 
                        "<?php echo buildUrl( 'aprobacion/saveProcess' ) ?>", 
                        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?>">
                <table class="" width="100%" style="">
                    <tr>
                        <td valign="top">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">                                
                            	<tr>
                                    <td>
                                        <table id="tabShowScan" cellpadding="0" cellspacing="0" class="mnuElement">
                                            <tr>
                                                <td class="mnuActivoIzq"><img src="<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif" width="0" /></td>
                                                <td class="mnuActivoTxt" nowrap="nowrap" onclick="location.href='<?=buildUrl( 'aprobacion/process', "s_TipoProc=".$s_TipoProc."&i_Id=".$i_Id )?>';">General</td>
                                                <td class="mnuActivoDer"><img src="<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif" width="1" /></td>
                                                <?php if( $o_COM_OrdenCompraCabeceraBN->getIdOrdenCompra() ){ ?>
                                                <td class="mnuInactivoIzq"><img src="<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif" width="0" /></td>
                                                <td class="mnuInactivoTxt" nowrap="nowrap" onclick="location.href='<?=buildUrl( 'oc/detail', "noedit=1&action=aprobacion_process&s_TipoProc=".$s_TipoProc."&i_Id=".$i_Id )?>';">Detalle</td>
                                                <td class="mnuInactivoDer"><img src="<?=Constantes::ROOT_DIR_IMG?>common/spacer.gif" width="1" /></td>
                                                <?php } ?>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="marco marcoTitle">
                                        <table class="" width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                                <td width="100%" valign="top">

                                                    <input type="hidden" name="i_Id" id="i_Id" value="<?=$o_COM_OrdenCompraCabeceraBN->getIdOrdenCompraConcat()?>">
                                                                                                        
                                                    <?php include_partial( 
                                                                            "addedit", 
                                                                            array( 
                                                                                    "o_COM_OrdenCompraCabeceraBN"  => $o_COM_OrdenCompraCabeceraBN, 
                                                                                    "a_GSS_Compania"               => $a_GSS_Compania, 
                                                                                    "a_COM_OrdenItemClasificacion" => $a_COM_OrdenItemClasificacion, 
                                                                                    "o_ALM_AlmacenMastBN"          => $o_ALM_AlmacenMastBN, 
                                                                                    "a_GSS_MonedaMast"             => $a_GSS_MonedaMast,
                                                                                    "a_ALM_AlmacenMast"            => $a_ALM_AlmacenMast
                                                                                 ),
                                                                            array( "Module" => "oc" )
                                                                         ); ?>
                                                    <script> $( "#form1 input:text, select, textarea" ).prop( "disabled", true ); </script>
                                                    <script> $( "#form1 input:checkbox" ).attr( "disabled", true ); </script>
                                                    
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <table width="100%" border="0" style="margin-top: 10px;">
                                            <tr>
                                                <td align="right" width="65%">
                                                    <input type="button" class="button" value="Cerrar" onclick="parent.$( '#dialog' ).dialog( 'close' );">
                                                    <input type="button" class="button" value="Aprobar" onclick="executeProcess( 'AP' );">
                                                    <input type="button" class="button" value="Rechazar" onclick="executeProcess( 'RE' );">
                                                </td>
                                                <td width="35%">
                                                    <div id="s_ImagenLoad" style="display: none;"><img src="<?php echo Constantes::ROOT_DIR_APP ?>/web<?=Constantes::ROOT_DIR_IMG?>progress.gif" border="0"/>&nbsp;<label class="laber req">Grabando...</label></div>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </form>
        </td>
    </tr>
</table>

<script>
executeProcess = function( status )
{
    x = confirm( "Se procedera en actualizar el estado?" )
    if( x )
    {
        ejecutarActualizar( status );
    }
}
</script>