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

include("include/dbcommon.php");
include("include/senuc_score_variables.php");
include('include/xtempl.php');
include('classes/viewpage.php');
include("classes/searchclause.php");

add_nocache_headers();

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

$layout = new TLayout("view2","BreezeAqua1","MobileAqua1");
$layout->blocks["top"] = array();
$layout->skins["pdf"] = "empty";
$layout->blocks["top"][] = "pdf";
$layout->containers["view"] = array();

$layout->containers["view"][] = array("name"=>"viewheader","block"=>"","substyle"=>2);


$layout->containers["view"][] = array("name"=>"wrapper","block"=>"","substyle"=>1, "container"=>"fields");


$layout->containers["fields"] = array();

$layout->containers["fields"][] = array("name"=>"viewfields","block"=>"","substyle"=>1);


$layout->containers["fields"][] = array("name"=>"viewbuttons","block"=>"","substyle"=>2);


$layout->skins["fields"] = "fields";

$layout->skins["view"] = "1";
$layout->blocks["top"][] = "view";
$layout->skins["details"] = "empty";
$layout->blocks["top"][] = "details";$page_layouts["senuc_score_view"] = $layout;




//$cipherer = new RunnerCipherer($strTableName);
	
$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;
$params["all"] = $all;

//Get array of tabs for edit page
$params['useTabsOnView'] = $gSettings->useTabsOnView();
if($params['useTabsOnView'])
	$params['arrViewTabs'] = $gSettings->getViewTabs();
$pageObject = new ViewPage($params);

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

// proccess big google maps

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

//For show detail tables on master page view
$dpParams = array();
if($pageObject->isShowDetailTables && !isMobile())
{
	$ids = $id;
	$pageObject->jsSettings['tableSettings'][$strTableName]['dpParams'] = array();
}

//	Before Process event
if($eventObj->exists("BeforeProcessView"))
	$eventObj->BeforeProcessView($conn, $pageObject);
	
//	read current values from the database
$data = $pageObject->getCurrentRecordInternal();

if (!sizeof($data)) {
	header("Location: senuc_score_list.php?a=return");
	exit();
}

$out = "";
$first = true;
$fieldsArr = array();
$arr = array();
$arr['fName'] = "tipo_nucleo";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("tipo_nucleo");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "ano";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("ano");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "mes";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("mes");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "coordenadores";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("coordenadores");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "professores";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("professores");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "alunos";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("alunos");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "meta_alunos";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("meta_alunos");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "dias_funcionamento";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("dias_funcionamento");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "meta_funcionamento";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("meta_funcionamento");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "alunos_por_coordenador";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("alunos_por_coordenador");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "meta_alunos_por_coordenador";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("meta_alunos_por_coordenador");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "freq_media_coordenador";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("freq_media_coordenador");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "min_freq_coordenador";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("min_freq_coordenador");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "freq_media_aluno";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("freq_media_aluno");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "min_freq_aluno";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("min_freq_aluno");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "freq_media_professor";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("freq_media_professor");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "min_freq_professor";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("min_freq_professor");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "meta_atividades";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("meta_atividades");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "atividades_elaboradas";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("atividades_elaboradas");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "atividades_realizadas";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("atividades_realizadas");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "score";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("score");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "operador";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("operador");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "data_insercao";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("data_insercao");
$fieldsArr[] = $arr;

$mainTableOwnerID = $pageObject->pSet->getTableOwnerIdField();
$ownerIdValue="";

$pageObject->setGoogleMapsParams($fieldsArr);

while($data)
{
	$xt->assign("show_key1", htmlspecialchars($pageObject->showDBValue("id", $data)));

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

////////////////////////////////////////////
//tipo_nucleo - 
	
	$value = $pageObject->showDBValue("tipo_nucleo", $data, $keylink);
	if($mainTableOwnerID=="tipo_nucleo")
		$ownerIdValue=$value;
	$xt->assign("tipo_nucleo_value",$value);
	if(!$pageObject->isAppearOnTabs("tipo_nucleo"))
		$xt->assign("tipo_nucleo_fieldblock",true);
	else
		$xt->assign("tipo_nucleo_tabfieldblock",true);
////////////////////////////////////////////
//ano - 
	
	$value = $pageObject->showDBValue("ano", $data, $keylink);
	if($mainTableOwnerID=="ano")
		$ownerIdValue=$value;
	$xt->assign("ano_value",$value);
	if(!$pageObject->isAppearOnTabs("ano"))
		$xt->assign("ano_fieldblock",true);
	else
		$xt->assign("ano_tabfieldblock",true);
////////////////////////////////////////////
//mes - 
	
	$value = $pageObject->showDBValue("mes", $data, $keylink);
	if($mainTableOwnerID=="mes")
		$ownerIdValue=$value;
	$xt->assign("mes_value",$value);
	if(!$pageObject->isAppearOnTabs("mes"))
		$xt->assign("mes_fieldblock",true);
	else
		$xt->assign("mes_tabfieldblock",true);
////////////////////////////////////////////
//coordenadores - 
	
	$value = $pageObject->showDBValue("coordenadores", $data, $keylink);
	if($mainTableOwnerID=="coordenadores")
		$ownerIdValue=$value;
	$xt->assign("coordenadores_value",$value);
	if(!$pageObject->isAppearOnTabs("coordenadores"))
		$xt->assign("coordenadores_fieldblock",true);
	else
		$xt->assign("coordenadores_tabfieldblock",true);
////////////////////////////////////////////
//professores - 
	
	$value = $pageObject->showDBValue("professores", $data, $keylink);
	if($mainTableOwnerID=="professores")
		$ownerIdValue=$value;
	$xt->assign("professores_value",$value);
	if(!$pageObject->isAppearOnTabs("professores"))
		$xt->assign("professores_fieldblock",true);
	else
		$xt->assign("professores_tabfieldblock",true);
////////////////////////////////////////////
//alunos - 
	
	$value = $pageObject->showDBValue("alunos", $data, $keylink);
	if($mainTableOwnerID=="alunos")
		$ownerIdValue=$value;
	$xt->assign("alunos_value",$value);
	if(!$pageObject->isAppearOnTabs("alunos"))
		$xt->assign("alunos_fieldblock",true);
	else
		$xt->assign("alunos_tabfieldblock",true);
////////////////////////////////////////////
//meta_alunos - 
	
	$value = $pageObject->showDBValue("meta_alunos", $data, $keylink);
	if($mainTableOwnerID=="meta_alunos")
		$ownerIdValue=$value;
	$xt->assign("meta_alunos_value",$value);
	if(!$pageObject->isAppearOnTabs("meta_alunos"))
		$xt->assign("meta_alunos_fieldblock",true);
	else
		$xt->assign("meta_alunos_tabfieldblock",true);
////////////////////////////////////////////
//dias_funcionamento - 
	
	$value = $pageObject->showDBValue("dias_funcionamento", $data, $keylink);
	if($mainTableOwnerID=="dias_funcionamento")
		$ownerIdValue=$value;
	$xt->assign("dias_funcionamento_value",$value);
	if(!$pageObject->isAppearOnTabs("dias_funcionamento"))
		$xt->assign("dias_funcionamento_fieldblock",true);
	else
		$xt->assign("dias_funcionamento_tabfieldblock",true);
////////////////////////////////////////////
//meta_funcionamento - 
	
	$value = $pageObject->showDBValue("meta_funcionamento", $data, $keylink);
	if($mainTableOwnerID=="meta_funcionamento")
		$ownerIdValue=$value;
	$xt->assign("meta_funcionamento_value",$value);
	if(!$pageObject->isAppearOnTabs("meta_funcionamento"))
		$xt->assign("meta_funcionamento_fieldblock",true);
	else
		$xt->assign("meta_funcionamento_tabfieldblock",true);
////////////////////////////////////////////
//alunos_por_coordenador - 
	
	$value = $pageObject->showDBValue("alunos_por_coordenador", $data, $keylink);
	if($mainTableOwnerID=="alunos_por_coordenador")
		$ownerIdValue=$value;
	$xt->assign("alunos_por_coordenador_value",$value);
	if(!$pageObject->isAppearOnTabs("alunos_por_coordenador"))
		$xt->assign("alunos_por_coordenador_fieldblock",true);
	else
		$xt->assign("alunos_por_coordenador_tabfieldblock",true);
////////////////////////////////////////////
//meta_alunos_por_coordenador - 
	
	$value = $pageObject->showDBValue("meta_alunos_por_coordenador", $data, $keylink);
	if($mainTableOwnerID=="meta_alunos_por_coordenador")
		$ownerIdValue=$value;
	$xt->assign("meta_alunos_por_coordenador_value",$value);
	if(!$pageObject->isAppearOnTabs("meta_alunos_por_coordenador"))
		$xt->assign("meta_alunos_por_coordenador_fieldblock",true);
	else
		$xt->assign("meta_alunos_por_coordenador_tabfieldblock",true);
////////////////////////////////////////////
//freq_media_coordenador - 
	
	$value = $pageObject->showDBValue("freq_media_coordenador", $data, $keylink);
	if($mainTableOwnerID=="freq_media_coordenador")
		$ownerIdValue=$value;
	$xt->assign("freq_media_coordenador_value",$value);
	if(!$pageObject->isAppearOnTabs("freq_media_coordenador"))
		$xt->assign("freq_media_coordenador_fieldblock",true);
	else
		$xt->assign("freq_media_coordenador_tabfieldblock",true);
////////////////////////////////////////////
//min_freq_coordenador - 
	
	$value = $pageObject->showDBValue("min_freq_coordenador", $data, $keylink);
	if($mainTableOwnerID=="min_freq_coordenador")
		$ownerIdValue=$value;
	$xt->assign("min_freq_coordenador_value",$value);
	if(!$pageObject->isAppearOnTabs("min_freq_coordenador"))
		$xt->assign("min_freq_coordenador_fieldblock",true);
	else
		$xt->assign("min_freq_coordenador_tabfieldblock",true);
////////////////////////////////////////////
//freq_media_aluno - 
	
	$value = $pageObject->showDBValue("freq_media_aluno", $data, $keylink);
	if($mainTableOwnerID=="freq_media_aluno")
		$ownerIdValue=$value;
	$xt->assign("freq_media_aluno_value",$value);
	if(!$pageObject->isAppearOnTabs("freq_media_aluno"))
		$xt->assign("freq_media_aluno_fieldblock",true);
	else
		$xt->assign("freq_media_aluno_tabfieldblock",true);
////////////////////////////////////////////
//min_freq_aluno - 
	
	$value = $pageObject->showDBValue("min_freq_aluno", $data, $keylink);
	if($mainTableOwnerID=="min_freq_aluno")
		$ownerIdValue=$value;
	$xt->assign("min_freq_aluno_value",$value);
	if(!$pageObject->isAppearOnTabs("min_freq_aluno"))
		$xt->assign("min_freq_aluno_fieldblock",true);
	else
		$xt->assign("min_freq_aluno_tabfieldblock",true);
////////////////////////////////////////////
//freq_media_professor - 
	
	$value = $pageObject->showDBValue("freq_media_professor", $data, $keylink);
	if($mainTableOwnerID=="freq_media_professor")
		$ownerIdValue=$value;
	$xt->assign("freq_media_professor_value",$value);
	if(!$pageObject->isAppearOnTabs("freq_media_professor"))
		$xt->assign("freq_media_professor_fieldblock",true);
	else
		$xt->assign("freq_media_professor_tabfieldblock",true);
////////////////////////////////////////////
//min_freq_professor - 
	
	$value = $pageObject->showDBValue("min_freq_professor", $data, $keylink);
	if($mainTableOwnerID=="min_freq_professor")
		$ownerIdValue=$value;
	$xt->assign("min_freq_professor_value",$value);
	if(!$pageObject->isAppearOnTabs("min_freq_professor"))
		$xt->assign("min_freq_professor_fieldblock",true);
	else
		$xt->assign("min_freq_professor_tabfieldblock",true);
////////////////////////////////////////////
//meta_atividades - 
	
	$value = $pageObject->showDBValue("meta_atividades", $data, $keylink);
	if($mainTableOwnerID=="meta_atividades")
		$ownerIdValue=$value;
	$xt->assign("meta_atividades_value",$value);
	if(!$pageObject->isAppearOnTabs("meta_atividades"))
		$xt->assign("meta_atividades_fieldblock",true);
	else
		$xt->assign("meta_atividades_tabfieldblock",true);
////////////////////////////////////////////
//atividades_elaboradas - 
	
	$value = $pageObject->showDBValue("atividades_elaboradas", $data, $keylink);
	if($mainTableOwnerID=="atividades_elaboradas")
		$ownerIdValue=$value;
	$xt->assign("atividades_elaboradas_value",$value);
	if(!$pageObject->isAppearOnTabs("atividades_elaboradas"))
		$xt->assign("atividades_elaboradas_fieldblock",true);
	else
		$xt->assign("atividades_elaboradas_tabfieldblock",true);
////////////////////////////////////////////
//atividades_realizadas - 
	
	$value = $pageObject->showDBValue("atividades_realizadas", $data, $keylink);
	if($mainTableOwnerID=="atividades_realizadas")
		$ownerIdValue=$value;
	$xt->assign("atividades_realizadas_value",$value);
	if(!$pageObject->isAppearOnTabs("atividades_realizadas"))
		$xt->assign("atividades_realizadas_fieldblock",true);
	else
		$xt->assign("atividades_realizadas_tabfieldblock",true);
////////////////////////////////////////////
//score - 
	
	$value = $pageObject->showDBValue("score", $data, $keylink);
	if($mainTableOwnerID=="score")
		$ownerIdValue=$value;
	$xt->assign("score_value",$value);
	if(!$pageObject->isAppearOnTabs("score"))
		$xt->assign("score_fieldblock",true);
	else
		$xt->assign("score_tabfieldblock",true);
////////////////////////////////////////////
//operador - 
	
	$value = $pageObject->showDBValue("operador", $data, $keylink);
	if($mainTableOwnerID=="operador")
		$ownerIdValue=$value;
	$xt->assign("operador_value",$value);
	if(!$pageObject->isAppearOnTabs("operador"))
		$xt->assign("operador_fieldblock",true);
	else
		$xt->assign("operador_tabfieldblock",true);
////////////////////////////////////////////
//data_insercao - Short Date
	
	$value = $pageObject->showDBValue("data_insercao", $data, $keylink);
	if($mainTableOwnerID=="data_insercao")
		$ownerIdValue=$value;
	$xt->assign("data_insercao_value",$value);
	if(!$pageObject->isAppearOnTabs("data_insercao"))
		$xt->assign("data_insercao_fieldblock",true);
	else
		$xt->assign("data_insercao_tabfieldblock",true);

/////////////////////////////////////////////////////////////
if($pageObject->isShowDetailTables && !isMobile())
{
	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();
	$dViewControlsMap = array();
	
	for($d=0;$d<count($dpParams['ids']);$d++)
	{
		$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'] = "senuc_score";
		$options['firstTime'] = 1;
		
		$strTableName = $dpParams['strTableNames'][$d];
		include_once("include/".GetTableURL($strTableName)."_settings.php");
		if(!CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Search"))
		{
			$strTableName = "senuc_score";
			continue;
		}
		
		$layout = GetPageLayout(GoodFieldName($strTableName), PAGE_LIST);
		if($layout)
		{
			$rtl = $xt->getReadingOrder() == 'RTL' ? 'RTL' : '';
			$xt->cssFiles[] = array("stylepath" => "styles/".$layout->style.'/style'.$rtl.".css"
				, "pagestylepath" => "pagestyles/".$layout->name.$rtl.".css");
			$xt->IEcssFiles[] = array("stylepathIE" => "styles/".$layout->style.'/styleIE'.".css");
		}
		
		$options['xt'] = new Xtempl();
		$options['id'] = $dpParams['ids'][$d];
		$options['flyId'] = $pageObject->genId()+1;
		$mkr = 1;
		foreach($mKeys[$strTableName] as $mk)
			$options['masterKeysReq'][$mkr++] = $data[$mk];

		$listPageObject = ListPage::createListPage($strTableName, $options);
		
		// prepare code
		$listPageObject->prepareForBuildPage();
		
		// show page
		if($listPageObject->permis[$strTableName]['search'] && $listPageObject->rowsFound)
		{
			//set page events
			foreach($listPageObject->eventsObject->events as $event => $name)
				$listPageObject->xt->assign_event($event, $listPageObject->eventsObject, $event, array());
			
			//add detail settings to master settings
			$listPageObject->addControlsJSAndCSS();
			$listPageObject->fillSetCntrlMaps();
			$pageObject->jsSettings['tableSettings'][$strTableName]	= $listPageObject->jsSettings['tableSettings'][$strTableName];
			$dControlsMap[$strTableName] = $listPageObject->controlsMap;
			$dViewControlsMap[$strTableName] = $listPageObject->viewControlsMap;
			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());
		
			$xtParams = array("method"=>'showPage', "params"=> false);
			$xtParams['object'] = $listPageObject;
			$xt->assign("displayDetailTable_".GoodFieldName($listPageObject->tName), $xtParams);
		
			$pageObject->controlsMap['dpTablesParams'][] = array('tName'=>$strTableName, 'id'=>$options['id']);
		}
	}
	$pageObject->controlsMap['dControlsMap'] = $dControlsMap;
	$pageObject->viewControlsMap['dViewControlsMap'] = $dViewControlsMap; 
	$strTableName = "senuc_score";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//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"].="<script type=\"text/javascript\" src=\"include/loadfirst.js\"></script>\r\n";
		$pageObject->body["begin"].= "<script type=\"text/javascript\" src=\"include/lang/".getLangFileName(mlang_getcurrentlang()).".js\"></script>";		
	
	$pageObject->jsSettings['tableSettings'][$strTableName]["keys"] = $pageObject->jsKeys;
	$pageObject->jsSettings['tableSettings'][$strTableName]['keyFields'] = $pageObject->keyFields;
	$pageObject->jsSettings['tableSettings'][$strTableName]["prevKeys"] = $prev;
	$pageObject->jsSettings['tableSettings'][$strTableName]["nextKeys"] = $next; 
	
	// assign body end
	$pageObject->body['end'] = array();
	$pageObject->body['end']["method"] = "assignBodyEnd";
	$pageObject->body['end']["object"] = &$pageObject;
	
	$xt->assign("body",$pageObject->body);
	$xt->assign("flybody",true);
}
else
{
	$xt->assign("footer",false);
	$xt->assign("header",false);
	$xt->assign("flybody",$pageObject->body);
	$xt->assign("body",true);
	$xt->assign("pdflink_block",false);
	
	$pageObject->fillSetCntrlMaps();
	
	$returnJSON['controlsMap'] = $pageObject->controlsHTMLMap;
	$returnJSON['viewControlsMap'] = $pageObject->viewControlsHTMLMap;
	$returnJSON['settings'] = $pageObject->jsSettings;
}
$xt->assign("style_block",true);
$xt->assign("stylefiles_block",true);

$editlink="";
$editkeys=array();
	$editkeys["editid1"]=postvalue("editid1");
foreach($editkeys as $key=>$val)
{
	if($editlink)
		$editlink.="&";
	$editlink.=$key."=".$val;
}
$xt->assign("editlink_attrs","id=\"editLink".$id."\" name=\"editLink".$id."\" onclick=\"window.location.href='senuc_score_edit.php?".$editlink."'\"");

$strPerm = GetUserPermissions($strTableName);
if(CheckSecurity($ownerIdValue,"Edit") && !$inlineview && strpos($strPerm, "E")!==false)
	$xt->assign("edit_button",true);
else
	$xt->assign("edit_button",false);

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-1]));
		$xt->assign("nextbutton_attrs","id=\"nextButton".$id."\"");
	}
	else 
		$xt->assign("next_button",false);
	if(count($prev))
	{
		$xt->assign("prev_button",true);
			$prevlink .="editid1=".htmlspecialchars(rawurlencode($prev[1-1]));
		$xt->assign("prevbutton_attrs","id=\"prevButton".$id."\"");
	}
	else 
		$xt->assign("prev_button",false);
//End show Next Prev button
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	$xt->assign("back_button",true);
	$xt->assign("backbutton_attrs","id=\"backButton".$id."\"");
}

$oldtemplatefile = $pageObject->templatefile;

if(!$all)
{
	if($eventObj->exists("BeforeShowView"))
	{
		$templatefile = $pageObject->templatefile;
		$eventObj->BeforeShowView($xt,$templatefile,$data, $pageObject);
		$pageObject->templatefile = $templatefile;
	}
	if(!$pdf)
	{
		if(!$inlineview)
			$xt->display($pageObject->templatefile);
		else{
				$xt->load_template($pageObject->templatefile);
				$returnJSON['html'] = $xt->fetch_loaded('style_block').$xt->fetch_loaded('body');
				if(count($pageObject->includes_css))
					$returnJSON['CSSFiles'] = array_unique($pageObject->includes_css);
				if(count($pageObject->includes_cssIE))
					$returnJSON['CSSFilesIE'] = array_unique($pageObject->includes_cssIE);				
				$returnJSON['idStartFrom'] = $id+1;
				$returnJSON["additionalJS"] = $pageObject->grabAllJsFiles();
				echo (my_json_encode($returnJSON)); 
			}
	}
	break;
}
}


?>
