<?php 
@ini_set("display_errors","1");
@ini_set("display_startup_errors","1");

include("include/dbcommon.php");
include("include/My_Home_variables.php");

add_nocache_headers();

//	check if logged in
if(!@$_SESSION["UserID"] || !CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Search"))
{ 
	$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];
	header("Location: login.php?message=expired"); 
	return;
}

include('include/xtempl.php');
include('classes/runnerpage.php');
include("classes/searchclause.php");
$xt = new Xtempl();


$query = $gQuery->Copy();

$filename = "";	
$message = "";
$key = array();
$next = array();
$prev = array();
$all = postvalue("all");
$pdf = postvalue("pdf");
$mypage = 1;

//Show view page as popUp or not
$inlineview = (postvalue("onFly") ? true : false);

//If show view as popUp, get parent Id
if($inlineview)
	$parId = postvalue("parId");
else
	$parId = 0;

//Set page id	
if(postvalue("id"))
	$id = postvalue("id");
else
	$id = 1;

//$isNeedSettings = true;//($inlineview && postvalue("isNeedSettings") == 'true') || (!$inlineview);	
	
// assign an id			
$xt->assign("id",$id);

//array of params for classes
$params = array("pageType" => PAGE_VIEW, "id" =>$id, "tName"=>$strTableName);
$params["xt"] = &$xt;
//Get array of tabs for edit page
$params['useTabsOnView'] = useTabsOnView($strTableName);
if($params['useTabsOnView'])
	$params['arrViewTabs'] = GetViewTabs($strTableName);
$pageObject = new RunnerPage($params);

// SearchClause class stuff
$pageObject->searchClauseObj->parseRequest();
$_SESSION[$strTableName.'_advsearch'] = serialize($pageObject->searchClauseObj);

// proccess big google maps

// add onload event
$onLoadJsCode = GetTableData($pageObject->tName, ".jsOnloadView", '');
$pageObject->addOnLoadJsEvent($onLoadJsCode);

// add button events if exist
$pageObject->addButtonHandlers();

//For show detail tables on master page view
$dpParams = array();
if($pageObject->isShowDetailTables)
{
	$ids = $id;
	$mKeys["My Planned Visits"] = GetMasterKeysByDetailTable("My Planned Visits", $strTableName);
	$dpParams['strTableNames'][] = "My Planned Visits";
	$dpParams['ids'][] = ++$ids;
	$mKeys["My Leads"] = GetMasterKeysByDetailTable("My Leads", $strTableName);
	$dpParams['strTableNames'][] = "My Leads";
	$dpParams['ids'][] = ++$ids;
	$mKeys["My Calls Summary"] = GetMasterKeysByDetailTable("My Calls Summary", $strTableName);
	$dpParams['strTableNames'][] = "My Calls Summary";
	$dpParams['ids'][] = ++$ids;
	$mKeys["My Visit Summary"] = GetMasterKeysByDetailTable("My Visit Summary", $strTableName);
	$dpParams['strTableNames'][] = "My Visit Summary";
	$dpParams['ids'][] = ++$ids;
	$mKeys["RO-Customer List Summary"] = GetMasterKeysByDetailTable("RO-Customer List Summary", $strTableName);
	$dpParams['strTableNames'][] = "RO-Customer List Summary";
	$dpParams['ids'][] = ++$ids;
	$pageObject->jsSettings['tableSettings'][$strTableName]['dpParams'] = array('tableNames'=>$dpParams['strTableNames'], 'ids'=>$dpParams['ids']);
	$pageObject->AddJSFile("include/detailspreview");
}


//	Before Process event
if($eventObj->exists("BeforeProcessView"))
	$eventObj->BeforeProcessView($conn);

$strWhereClause = '';
$strHavingClause = '';
if(!$all)
{
//	show one record only
	$keys=array();
	$strWhereClause="";
	$keys["username"]=postvalue("editid1");
	$strWhereClause = KeyWhere($keys);
	$strWhereClause = whereAdd($strWhereClause,SecuritySQL("Search"));
	$strSQL = gSQLWhere($strWhereClause);
}
else
{
	if ($_SESSION[$strTableName."_SelectedSQL"]!="" && @$_REQUEST["records"]=="") 
	{
		$strSQL = $_SESSION[$strTableName."_SelectedSQL"];
		$strWhereClause=@$_SESSION[$strTableName."_SelectedWhere"];
	}
	else
	{
		$strWhereClause=@$_SESSION[$strTableName."_where"];
		$strHavingClause=@$_SESSION[$strTableName."_having"];
		if($strWhereClause=="")
			$strWhereClause = whereAdd($strWhereClause,SecuritySQL("Search"));
		$strSQL=gSQLWhere($strWhereClause,$strHavingClause);
	}
//	order by
	$strOrderBy=$_SESSION[$strTableName."_order"];
	if(!$strOrderBy)
		$strOrderBy=$gstrOrderBy;
	$strSQL.=" ".trim($strOrderBy);
}

$strSQLbak = $strSQL;
if($eventObj->exists("BeforeQueryView"))
	$eventObj->BeforeQueryView($strSQL,$strWhereClause);
if($strSQLbak == $strSQL)
{
	$strSQL=gSQLWhere($strWhereClause,$strHavingClause);
	if($all)
	{
		$numrows=gSQLRowCount($strWhereClause,$strHavingClause);
		$strSQL.=" ".trim($strOrderBy);
	}
}
else
{
//	changed $strSQL - old style	
	if($all)
	{
		$numrows=GetRowCount($strSQL);
	}
}

if(!$all)
{
	LogInfo($strSQL);
	$rs=db_query($strSQL,$conn);
}
else
{
//	 Pagination:
	$nPageSize=0;
	if(@$_REQUEST["records"]=="page" && $numrows)
	{
		$mypage=(integer)@$_SESSION[$strTableName."_pagenumber"];
		$nPageSize=(integer)@$_SESSION[$strTableName."_pagesize"];
		if($numrows<=($mypage-1)*$nPageSize)
			$mypage=ceil($numrows/$nPageSize);
		if(!$nPageSize)
			$nPageSize=$gPageSize;
		if(!$mypage)
			$mypage=1;
		$strSQL.=" limit ".(($mypage-1)*$nPageSize).",".$nPageSize;
	}
	$rs=db_query($strSQL,$conn);
}

$data=db_fetch_array($rs);

if($eventObj->exists("ProcessValuesView"))
	$eventObj->ProcessValuesView($data);

$out="";
$first=true;

$templatefile="";
$fieldsArr = array();
$arr = array();
$arr['fName'] = "idemplist";
$arr['viewFormat'] = ViewFormat("idemplist", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Full Name";
$arr['viewFormat'] = ViewFormat("Full Name", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Father / Husband Name";
$arr['viewFormat'] = ViewFormat("Father / Husband Name", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Birth Date";
$arr['viewFormat'] = ViewFormat("Birth Date", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "DOJ";
$arr['viewFormat'] = ViewFormat("DOJ", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Address";
$arr['viewFormat'] = ViewFormat("Address", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "City";
$arr['viewFormat'] = ViewFormat("City", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "State";
$arr['viewFormat'] = ViewFormat("State", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Country";
$arr['viewFormat'] = ViewFormat("Country", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Postal Code";
$arr['viewFormat'] = ViewFormat("Postal Code", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Business Phone";
$arr['viewFormat'] = ViewFormat("Business Phone", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Home Phone";
$arr['viewFormat'] = ViewFormat("Home Phone", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Mobile Phone";
$arr['viewFormat'] = ViewFormat("Mobile Phone", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "E-Mail Address";
$arr['viewFormat'] = ViewFormat("E-Mail Address", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Job Title";
$arr['viewFormat'] = ViewFormat("Job Title", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Department";
$arr['viewFormat'] = ViewFormat("Department", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Region";
$arr['viewFormat'] = ViewFormat("Region", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Reporting Manager";
$arr['viewFormat'] = ViewFormat("Reporting Manager", $strTableName);
$fieldsArr[] = $arr;

$pageObject->setGoogleMapsParams($fieldsArr);

while($data)
{
	$xt->assign("show_key1", htmlspecialchars(GetData($data,"username", "")));

	$keylink="";
	$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["username"]));

////////////////////////////////////////////
//idemplist - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"idemplist", ""),"","",MODE_VIEW);
	$xt->assign("idemplist_value",$value);
	if(!$pageObject->isAppearOnTabs("idemplist"))
		$xt->assign("idemplist_fieldblock",true);
	else
		$xt->assign("idemplist_tabfieldblock",true);
////////////////////////////////////////////
//Full Name - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Full Name", ""),"","",MODE_VIEW);
	$xt->assign("Full_Name_value",$value);
	if(!$pageObject->isAppearOnTabs("Full Name"))
		$xt->assign("Full_Name_fieldblock",true);
	else
		$xt->assign("Full_Name_tabfieldblock",true);
////////////////////////////////////////////
//Father / Husband Name - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Father / Husband Name", ""),"","",MODE_VIEW);
	$xt->assign("Father___Husband_Name_value",$value);
	if(!$pageObject->isAppearOnTabs("Father / Husband Name"))
		$xt->assign("Father___Husband_Name_fieldblock",true);
	else
		$xt->assign("Father___Husband_Name_tabfieldblock",true);
////////////////////////////////////////////
//Birth Date - Short Date
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Birth Date", "Short Date"),"","",MODE_VIEW);
	$xt->assign("Birth_Date_value",$value);
	if(!$pageObject->isAppearOnTabs("Birth Date"))
		$xt->assign("Birth_Date_fieldblock",true);
	else
		$xt->assign("Birth_Date_tabfieldblock",true);
////////////////////////////////////////////
//DOJ - Short Date
	
	$value="";
	$value = ProcessLargeText(GetData($data,"DOJ", "Short Date"),"","",MODE_VIEW);
	$xt->assign("DOJ_value",$value);
	if(!$pageObject->isAppearOnTabs("DOJ"))
		$xt->assign("DOJ_fieldblock",true);
	else
		$xt->assign("DOJ_tabfieldblock",true);
////////////////////////////////////////////
//Address - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Address", ""),"","",MODE_VIEW);
	$xt->assign("Address_value",$value);
	if(!$pageObject->isAppearOnTabs("Address"))
		$xt->assign("Address_fieldblock",true);
	else
		$xt->assign("Address_tabfieldblock",true);
////////////////////////////////////////////
//City - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"City", ""),"","",MODE_VIEW);
	$xt->assign("City_value",$value);
	if(!$pageObject->isAppearOnTabs("City"))
		$xt->assign("City_fieldblock",true);
	else
		$xt->assign("City_tabfieldblock",true);
////////////////////////////////////////////
//State - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"State", ""),"","",MODE_VIEW);
	$xt->assign("State_value",$value);
	if(!$pageObject->isAppearOnTabs("State"))
		$xt->assign("State_fieldblock",true);
	else
		$xt->assign("State_tabfieldblock",true);
////////////////////////////////////////////
//Country - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Country", ""),"","",MODE_VIEW);
	$xt->assign("Country_value",$value);
	if(!$pageObject->isAppearOnTabs("Country"))
		$xt->assign("Country_fieldblock",true);
	else
		$xt->assign("Country_tabfieldblock",true);
////////////////////////////////////////////
//Postal Code - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Postal Code", ""),"","",MODE_VIEW);
	$xt->assign("Postal_Code_value",$value);
	if(!$pageObject->isAppearOnTabs("Postal Code"))
		$xt->assign("Postal_Code_fieldblock",true);
	else
		$xt->assign("Postal_Code_tabfieldblock",true);
////////////////////////////////////////////
//Business Phone - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Business Phone", ""),"","",MODE_VIEW);
	$xt->assign("Business_Phone_value",$value);
	if(!$pageObject->isAppearOnTabs("Business Phone"))
		$xt->assign("Business_Phone_fieldblock",true);
	else
		$xt->assign("Business_Phone_tabfieldblock",true);
////////////////////////////////////////////
//Home Phone - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Home Phone", ""),"","",MODE_VIEW);
	$xt->assign("Home_Phone_value",$value);
	if(!$pageObject->isAppearOnTabs("Home Phone"))
		$xt->assign("Home_Phone_fieldblock",true);
	else
		$xt->assign("Home_Phone_tabfieldblock",true);
////////////////////////////////////////////
//Mobile Phone - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Mobile Phone", ""),"","",MODE_VIEW);
	$xt->assign("Mobile_Phone_value",$value);
	if(!$pageObject->isAppearOnTabs("Mobile Phone"))
		$xt->assign("Mobile_Phone_fieldblock",true);
	else
		$xt->assign("Mobile_Phone_tabfieldblock",true);
////////////////////////////////////////////
//E-Mail Address - Email Hyperlink
	
	$value="";
	$value = GetData($data,"E-Mail Address", "Email Hyperlink");
	$xt->assign("E_Mail_Address_value",$value);
	if(!$pageObject->isAppearOnTabs("E-Mail Address"))
		$xt->assign("E_Mail_Address_fieldblock",true);
	else
		$xt->assign("E_Mail_Address_tabfieldblock",true);
////////////////////////////////////////////
//Job Title - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Job Title", ""),"","",MODE_VIEW);
	$xt->assign("Job_Title_value",$value);
	if(!$pageObject->isAppearOnTabs("Job Title"))
		$xt->assign("Job_Title_fieldblock",true);
	else
		$xt->assign("Job_Title_tabfieldblock",true);
////////////////////////////////////////////
//Department - 
	
	$value="";
	$value=DisplayLookupWizard("Department",$data["Department"],$data,$keylink,MODE_VIEW);
	$xt->assign("Department_value",$value);
	if(!$pageObject->isAppearOnTabs("Department"))
		$xt->assign("Department_fieldblock",true);
	else
		$xt->assign("Department_tabfieldblock",true);
////////////////////////////////////////////
//Region - 
	
	$value="";
	$value=DisplayLookupWizard("Region",$data["Region"],$data,$keylink,MODE_VIEW);
	$xt->assign("Region_value",$value);
	if(!$pageObject->isAppearOnTabs("Region"))
		$xt->assign("Region_fieldblock",true);
	else
		$xt->assign("Region_tabfieldblock",true);
////////////////////////////////////////////
//Reporting Manager - 
	
	$value="";
	$value=DisplayLookupWizard("Reporting Manager",$data["Reporting Manager"],$data,$keylink,MODE_VIEW);
	$xt->assign("Reporting_Manager_value",$value);
	if(!$pageObject->isAppearOnTabs("Reporting Manager"))
		$xt->assign("Reporting_Manager_fieldblock",true);
	else
		$xt->assign("Reporting_Manager_tabfieldblock",true);

$jsKeysObj = 'window.recKeysObj = {';
	$jsKeysObj .= "'".jsreplace("username")."': '".(jsreplace(@$data["username"]))."', ";
$jsKeysObj = substr($jsKeysObj, 0, strlen($jsKeysObj)-2);
$jsKeysObj .= '};';
$pageObject->AddJsCode($jsKeysObj);	

/////////////////////////////////////////////////////////////
if($pageObject->isShowDetailTables)
{
	$options = array();
	//array of params for classes
	$options["mode"] = LIST_DETAILS;
	$options["pageType"] = PAGE_LIST;
	$options["masterPageType"] = PAGE_VIEW;
	$options["mainMasterPageType"] = PAGE_VIEW;
	$options['masterTable'] = $strTableName;
	$options['firstTime'] = 1;
	
	if(count($dpParams['ids']))
	{
		$xt->assign("detail_tables",true);
		include('classes/listpage.php');
		include('classes/listpage_embed.php');
		include('classes/listpage_dpinline.php');
	}
	
	$dControlsMap = array();
	
	$flyId = $ids+1;
	for($d=0;$d<count($dpParams['ids']);$d++)
	{
		$strTableName = $dpParams['strTableNames'][$d];
		include("include/".GetTableURL($strTableName)."_settings.php");
		if(!CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Search"))
		{
			$strTableName = "My Home";		
			continue;
		}
		$options['xt'] = new Xtempl();
		$options['id'] = $dpParams['ids'][$d];
		$options['flyId'] = $flyId++;
		$mkr=1;
		foreach($mKeys[$strTableName] as $mk)
			$options['masterKeysReq'][$mkr++] = $data[$mk];

		$listPageObject = ListPage::createListPage($strTableName, $options);
		// prepare code
		$listPageObject->prepareForBuildPage();
		$flyId = $listPageObject->recId+1;
		// show page
		if(!$pdf && $listPageObject->isDispGrid())
		{
			//add detail settings to master settings
			$listPageObject->fillSetCntrlMaps();
			$pageObject->jsSettings['tableSettings'][$strTableName]	= $listPageObject->jsSettings['tableSettings'][$strTableName];				
			$dControlsMap[$strTableName]['video'] = $listPageObject->controlsHTMLMap[$strTableName][PAGE_LIST][$dpParams['ids'][$d]]['video'];
			$dControlsMap[$strTableName]['gMaps'] = $listPageObject->controlsHTMLMap[$strTableName][PAGE_LIST][$dpParams['ids'][$d]]['gMaps'];
			foreach($listPageObject->jsSettings['global']['shortTNames'] as $keySet=>$val)
			{
				if(!array_key_exists($keySet,$pageObject->settingsMap["globalSettings"]['shortTNames']))
					$pageObject->settingsMap["globalSettings"]['shortTNames'][$keySet] = $val;
			}		
			
			//Add detail's js files to master's files
			$pageObject->copyAllJSFiles($listPageObject->grabAllJSFiles());
			
			//Add detail's css files to master's files	
			$pageObject->copyAllCSSFiles($listPageObject->grabAllCSSFiles());
		}
		$xt->assign("displayDetailTable_".GoodFieldName($strTableName), array("func" => "showDetailTable","params" => array("dpObject" => $listPageObject, "dpParams" => $strTableName)));
	}	
	$strTableName = "My Home";		
	$pageObject->controlsMap['dControlsMap'] = $dControlsMap;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Begin prepare for Next Prev button
if(!@$_SESSION[$strTableName."_noNextPrev"] && !$inlineview && !$pdf)
{
	$pageObject->getNextPrevRecordKeys($data,"Search",$next,$prev);
}	
//End prepare for Next Prev button
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	
if ($pageObject->googleMapCfg['isUseGoogleMap'])
{
	$pageObject->initGmaps();
}

$pageObject->addCommonJs();

//fill tab groups name and sections name to controls
$pageObject->fillCntrlTabGroups();
	
if(!$inlineview)
{
	$pageObject->body["begin"].= "<div id=\"master_details\" onmouseover=\"RollDetailsLink.showPopup();\" onmouseout=\"RollDetailsLink.hidePopup();\"> </div>";
	$pageObject->body["begin"].="<script type=\"text/javascript\" src=\"include/jquery.js\"></script>\r\n";
	$pageObject->body["begin"].="<script language=\"JavaScript\" src=\"include/jsfunctions.js\"></script>\r\n";
	if ($pageObject->debugJSMode === true)
	{			
		/*$pageObject->body["begin"].="<script type=\"text/javascript\" src=\"include/runnerJS/Runner.js\"></script>\r\n".
			"<script type=\"text/javascript\" src=\"include/runnerJS/Util.js\"></script>\r\n".
			"<script type=\"text/javascript\" src=\"include/runnerJS/Observer.js\"></script>\r\n";*/
			$pageObject->body["begin"].="<script language=\"JavaScript\" src=\"include/runnerJS/RunnerBase.js\"></script>\r\n";	
	}
	else
	{
		$pageObject->body["begin"].="<script language=\"JavaScript\" src=\"include/runnerJS/RunnerBase.js\"></script>\r\n";
	}
		$pageObject->jsSettings['tableSettings'][$strTableName]["keys"] = $keys;
	$pageObject->jsSettings['tableSettings'][$strTableName]["prevKeys"] = $prev;
	$pageObject->jsSettings['tableSettings'][$strTableName]["nextKeys"] = $next; 
		
	$pageObject->body["end"].="<script>".$pageObject->PrepareJS()."</script>";	
	
	// assign body end
	$pageObject->body['end'] = array();
	$pageObject->body['end']["method"] = "assignBodyEnd";		
	$pageObject->body['end']["object"] = &$pageObject;	
	
	$xt->assignbyref("body",$pageObject->body);
	$xt->assign("flybody",true);
}
else
{
	$xt->assign("footer","");
	$xt->assign("flybody",$pageObject->body);
	$xt->assign("body",true);
	
	$pageObject->fillSetCntrlMaps();
	
	$returnJSON['controlsMap'] = $pageObject->controlsHTMLMap;
	$returnJSON['settings'] = $pageObject->jsSettings;	
}
$xt->assign("style_block",true);
$xt->assign("stylefiles_block",true);

if(!$pdf && !$all && !$inlineview)
{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Begin show Next Prev button
    $nextlink=$prevlink="";
	if(count($next))
    {
		$xt->assign("next_button",true);
	 		$nextlink .="editid1=".htmlspecialchars(rawurlencode($next[1]));
		$xt->assign("nextbutton_attrs","id=\"nextButton".$id."\" onclick=\"window.location.href='My_Home_view.php?".$nextlink."'\"");
	}
	else 
		$xt->assign("next_button",false);	
	if(count($prev))
	{
		$xt->assign("prev_button",true);
			$prevlink .="editid1=".htmlspecialchars(rawurlencode($prev[1]));
		$xt->assign("prevbutton_attrs","id=\"prevButton".$id."\" onclick=\"window.location.href='My_Home_view.php?".$prevlink."'\"");
	}
    else 
		$xt->assign("prev_button",false);
//End show Next Prev button
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	$xt->assign("back_button",true);
	$xt->assign("backbutton_attrs","id=\"backButton".$id."\"");
}

$oldtemplatefile=$templatefile;
$templatefile = "My_Home_view.htm";

if(!$all)
{
	if($eventObj->exists("BeforeShowView"))
		$eventObj->BeforeShowView($xt,$templatefile,$data);
	
	if(!$pdf)
	{
		if(!$inlineview)
			$xt->display($templatefile);
		else{
				$xt->load_template($templatefile);
				$returnJSON['html'] = $xt->fetch_loaded('style_block').$xt->fetch_loaded('flybody');
				if($pageObject->isShowDetailTables)
					$returnJSON['html'].= $xt->fetch_loaded('detail_tables');
				$returnJSON['idStartFrom'] = $id+1;
				echo (my_json_encode($returnJSON)); 
			}
	}	
	break;
}
}


?>
