<?
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
	
global $sugar_version, $sugar_config, $current_user, $app_strings, $mod_strings, $current_user, $app_list_strings;
	

require_once('modules/EcmProductGroups/EcmProductGroup.php');
require_once('modules/EcmProductGroups/Forms.php');
require_once ('include/time.php');
require_once('include/json_config.php');

$json_config = new json_config();
	
$focus = new EcmProductGroup();   

if(isset($_REQUEST['record']))$focus->retrieve($_REQUEST['record']);
$ids = explode(",",$_REQUEST['uid']);
$p = new EcmProduct();

$p->retrieve($ids[0]);
$focus->name=$p->code;

require_once('include/MVC/View/SugarView.php');  




if(file_exists('modules/EcmProductGroups/views/view.edit.php')) {
	require_once('modules/EcmProductGroups/views/view.edit.php');
	$edit = new EcmProductGroup();
}
else{
	require_once('include/MVC/View/views/view.edit.php');
	$edit = new Viewedit();  
}



global $app_list_strings;

$file = 'modules/EcmGroupSales/EcmGroupSale.php';
if(file_exists($file)) {
	$cc = array();
	require_once($file);
	$cc = EcmGroupSale::loadSettings();
}
$OPT = array();
$OPT['row_item_height'] = $cc['row_item_height'];
$OPT['row_item_height_selected'] = $cc['row_item_height_selected'];
$OPT['rows_on_item_list'] = $cc['rows_on_item_list'];
$OPT['position_table_height'] = $OPT['row_item_height']*$OPT['rows_on_item_list']+40+$OPT['rows_on_item_list']*4;
$OPT['quick_product_item_adding'] = $cc['quick_product_item_adding'];
$scriptOpt = '
		<script language="javascript">
			var VAT = '.str_replace('&quot;','\"',$json->encode($VAT)).';
			var OPT = '.str_replace('&quot;','\"',$json->encode($OPT)).';
			var MOD = '.str_replace('&quot;','\"',$json->encode($mod_strings)).';
			var N;
		</script>';
echo $scriptOpt;

$edit->bean = $focus;
$edit->module = 'EcmProductGroups';
$edit->ss = new Sugar_Smarty();

$edit->ss->assign("OPT", $OPT);
$edit->ss->assign("productsId",$_REQUEST['uid']);


//features
//$json = getJSONobj();
//$features = $json->decode(htmlspecialchars_decode($focus->features));


$edit->ss->assign('POSITION_LIST', htmlspecialchars_decode($focus->features));

$edit->preDisplay();        
	
echo $edit->display();