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

include("include/dbcommon.php");
include("include/List_Management_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["Contact Details"] = GetMasterKeysByDetailTable("Contact Details", $strTableName);
	$dpParams['strTableNames'][] = "Contact Details";
	$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["idCL"]=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"];
		$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'] = "idCL";
$arr['viewFormat'] = ViewFormat("idCL", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Customer Name";
$arr['viewFormat'] = ViewFormat("Customer Name", $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'] = "Web address";
$arr['viewFormat'] = ViewFormat("Web address", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Area";
$arr['viewFormat'] = ViewFormat("Area", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Customer_Category";
$arr['viewFormat'] = ViewFormat("Customer_Category", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Breif About the Company";
$arr['viewFormat'] = ViewFormat("Breif About the Company", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Existing Setup";
$arr['viewFormat'] = ViewFormat("Existing Setup", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Interaction Summary";
$arr['viewFormat'] = ViewFormat("Interaction Summary", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Commercial Summary";
$arr['viewFormat'] = ViewFormat("Commercial Summary", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Customer Status";
$arr['viewFormat'] = ViewFormat("Customer Status", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Region";
$arr['viewFormat'] = ViewFormat("Region", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Last Updated on";
$arr['viewFormat'] = ViewFormat("Last Updated on", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "LU-Month";
$arr['viewFormat'] = ViewFormat("LU-Month", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "LU-Year";
$arr['viewFormat'] = ViewFormat("LU-Year", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Created on";
$arr['viewFormat'] = ViewFormat("Created on", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Assigned Executive";
$arr['viewFormat'] = ViewFormat("Assigned Executive", $strTableName);
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "Assigned Date";
$arr['viewFormat'] = ViewFormat("Assigned Date", $strTableName);
$fieldsArr[] = $arr;

$pageObject->setGoogleMapsParams($fieldsArr);

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

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

////////////////////////////////////////////
//idCL - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"idCL", ""),"","",MODE_VIEW);
	$xt->assign("idCL_value",$value);
	if(!$pageObject->isAppearOnTabs("idCL"))
		$xt->assign("idCL_fieldblock",true);
	else
		$xt->assign("idCL_tabfieldblock",true);
////////////////////////////////////////////
//Customer Name - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Customer Name", ""),"","",MODE_VIEW);
	$xt->assign("Customer_Name_value",$value);
	if(!$pageObject->isAppearOnTabs("Customer Name"))
		$xt->assign("Customer_Name_fieldblock",true);
	else
		$xt->assign("Customer_Name_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);
////////////////////////////////////////////
//Web address - Hyperlink
	
	$value="";
	$value = GetData($data,"Web address", "Hyperlink");
	$xt->assign("Web_address_value",$value);
	if(!$pageObject->isAppearOnTabs("Web address"))
		$xt->assign("Web_address_fieldblock",true);
	else
		$xt->assign("Web_address_tabfieldblock",true);
////////////////////////////////////////////
//Area - 
	
	$value="";
	$value=DisplayLookupWizard("Area",$data["Area"],$data,$keylink,MODE_VIEW);
	$xt->assign("Area_value",$value);
	if(!$pageObject->isAppearOnTabs("Area"))
		$xt->assign("Area_fieldblock",true);
	else
		$xt->assign("Area_tabfieldblock",true);
////////////////////////////////////////////
//Customer_Category - 
	
	$value="";
	$value=DisplayLookupWizard("Customer_Category",$data["Customer_Category"],$data,$keylink,MODE_VIEW);
	$xt->assign("Customer_Category_value",$value);
	if(!$pageObject->isAppearOnTabs("Customer_Category"))
		$xt->assign("Customer_Category_fieldblock",true);
	else
		$xt->assign("Customer_Category_tabfieldblock",true);
////////////////////////////////////////////
//Breif About the Company - HTML
	
	$value="";
	$value = GetData($data,"Breif About the Company", "HTML");
	$xt->assign("Breif_About_the_Company_value",$value);
	if(!$pageObject->isAppearOnTabs("Breif About the Company"))
		$xt->assign("Breif_About_the_Company_fieldblock",true);
	else
		$xt->assign("Breif_About_the_Company_tabfieldblock",true);
////////////////////////////////////////////
//Existing Setup - HTML
	
	$value="";
	$value = GetData($data,"Existing Setup", "HTML");
	$xt->assign("Existing_Setup_value",$value);
	if(!$pageObject->isAppearOnTabs("Existing Setup"))
		$xt->assign("Existing_Setup_fieldblock",true);
	else
		$xt->assign("Existing_Setup_tabfieldblock",true);
////////////////////////////////////////////
//Interaction Summary - HTML
	
	$value="";
	$value = GetData($data,"Interaction Summary", "HTML");
	$xt->assign("Interaction_Summary_value",$value);
	if(!$pageObject->isAppearOnTabs("Interaction Summary"))
		$xt->assign("Interaction_Summary_fieldblock",true);
	else
		$xt->assign("Interaction_Summary_tabfieldblock",true);
////////////////////////////////////////////
//Commercial Summary - HTML
	
	$value="";
	$value = GetData($data,"Commercial Summary", "HTML");
	$xt->assign("Commercial_Summary_value",$value);
	if(!$pageObject->isAppearOnTabs("Commercial Summary"))
		$xt->assign("Commercial_Summary_fieldblock",true);
	else
		$xt->assign("Commercial_Summary_tabfieldblock",true);
////////////////////////////////////////////
//Customer Status - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Customer Status", ""),"","",MODE_VIEW);
	$xt->assign("Customer_Status_value",$value);
	if(!$pageObject->isAppearOnTabs("Customer Status"))
		$xt->assign("Customer_Status_fieldblock",true);
	else
		$xt->assign("Customer_Status_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);
////////////////////////////////////////////
//Last Updated on - Short Date
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Last Updated on", "Short Date"),"","",MODE_VIEW);
	$xt->assign("Last_Updated_on_value",$value);
	if(!$pageObject->isAppearOnTabs("Last Updated on"))
		$xt->assign("Last_Updated_on_fieldblock",true);
	else
		$xt->assign("Last_Updated_on_tabfieldblock",true);
////////////////////////////////////////////
//LU-Month - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"LU-Month", ""),"","",MODE_VIEW);
	$xt->assign("LU_Month_value",$value);
	if(!$pageObject->isAppearOnTabs("LU-Month"))
		$xt->assign("LU_Month_fieldblock",true);
	else
		$xt->assign("LU_Month_tabfieldblock",true);
////////////////////////////////////////////
//LU-Year - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"LU-Year", ""),"","",MODE_VIEW);
	$xt->assign("LU_Year_value",$value);
	if(!$pageObject->isAppearOnTabs("LU-Year"))
		$xt->assign("LU_Year_fieldblock",true);
	else
		$xt->assign("LU_Year_tabfieldblock",true);
////////////////////////////////////////////
//Created on - Short Date
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Created on", "Short Date"),"","",MODE_VIEW);
	$xt->assign("Created_on_value",$value);
	if(!$pageObject->isAppearOnTabs("Created on"))
		$xt->assign("Created_on_fieldblock",true);
	else
		$xt->assign("Created_on_tabfieldblock",true);
////////////////////////////////////////////
//Assigned Executive - 
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Assigned Executive", ""),"","",MODE_VIEW);
	$xt->assign("Assigned_Executive_value",$value);
	if(!$pageObject->isAppearOnTabs("Assigned Executive"))
		$xt->assign("Assigned_Executive_fieldblock",true);
	else
		$xt->assign("Assigned_Executive_tabfieldblock",true);
////////////////////////////////////////////
//Assigned Date - Short Date
	
	$value="";
	$value = ProcessLargeText(GetData($data,"Assigned Date", "Short Date"),"","",MODE_VIEW);
	$xt->assign("Assigned_Date_value",$value);
	if(!$pageObject->isAppearOnTabs("Assigned Date"))
		$xt->assign("Assigned_Date_fieldblock",true);
	else
		$xt->assign("Assigned_Date_tabfieldblock",true);

$jsKeysObj = 'window.recKeysObj = {';
	$jsKeysObj .= "'".jsreplace("idCL")."': '".(jsreplace(@$data["idCL"]))."', ";
$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 = "List Management";		
			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 = "List Management";		
	$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='List_Management_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='List_Management_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 = "List_Management_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;
}
}


?>
