<?php
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
    die ( 'Not A Valid Entry Point' );

// require_once('modules/EcmGroupSales/HeaderMenu.php');

global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings;

require_once ('modules/EcmNewServices/EcmNewService.php');
require_once ('include/time.php');
require_once ('include/json_config.php');

// add jquery
echo '<link rel="stylesheet" type="text/css" href="include/jQuery/jquery-table/jquery.appendGrid-1.3.1.css"/>';
echo '<link rel="stylesheet" type="text/css" href="include/jQuery/jquery-ui/themes/base/jquery-ui.css"/>';
echo '<script type="text/javascript"
src="include/jQuery/jquery-2.1.0.min.js"></script>';
echo '<script type="text/javascript"
src="include/jQuery/jquery-table/jquery.appendGrid-1.3.1.js"></script>';
echo '<script type="text/javascript"
src="include/jQuery/jquery-ui/ui/jquery-ui.js"></script>';

$json_config = new json_config ();
$json = getJSONobj ();
$focus = new EcmReturn ();

if (isset ( $_REQUEST ['ecmreturn_id'] )) {
    $focus->retrieve ( $_REQUEST ['ecmreturn_id'] );
    $focus->format_all_fields ();
    $items = $json->decode ( $_SESSION [$_REQUEST ['sess_id']] );
    if (sizeof ( $items ) == 0 || ! isset ( $focus->document_no ))
        die ( 'Error!' );
   $ret= $focus->saveCorrect($items);
}

header('Location: index.php?module=EcmInvoiceOuts&action=DetailView&record='.$ret) ;

?>