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

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

require_once ('modules/EcmReturns/EcmReturn.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 ();

$focus = new EcmReturn ();

if (isset ( $_REQUEST ['record'] )) {
    $focus->retrieve ( $_REQUEST ['record'] );
    $focus->format_all_fields ();
    $positions = $focus->getPositionList(true);
    $pos = $focus->searchProductsToCorrectList($positions);
    $position_list=$pos['items'];
    $errors = $pos['errors'];
    $sess_id = create_guid();
    $json = getJSONobj();
    
    session_start();
    
    $_SESSION[$sess_id] = $json->encode($position_list);
} else die('error');

$edit->ss = new Sugar_Smarty ();
$edit->module = 'EcmReturns';

$edit->ss->assign ( "CREATED_BY_NAME", $focus->created_by_name );
$edit->ss->assign ( "MODIFIED_BY_NAME", $focus->modified_by_name );
$edit->ss->assign ( 'FOCUS', $focus);
$edit->ss->assign ('SESS_ID',$sess_id);
$edit->ss->assign ( 'POSITION_LIST', $position_list);
$edit->ss->assign ( 'ERRORS', $errors);
$edit->ss->assign ( 'MOD', $mod_strings);
$edit->ss-> display('modules/EcmReturns/tpls/searchProductsToCorrect.tpl'); //4
?>