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

include("include/dbcommon.php");
include("include/senuc_nucleo_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_nucleo_view"] = $layout;


$layout = new TLayout("viewtab","BreezeAqua1","MobileAqua1");
$layout->blocks["bare"] = array();
$layout->containers["1"] = array();

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


$layout->skins["1"] = "fields";
$layout->blocks["bare"][] = "1";$page_layouts["senuc_nucleo_view_Informa__es_Gerais1"] = $layout;

$layout = new TLayout("viewtab","BreezeAqua1","MobileAqua1");
$layout->blocks["bare"] = array();
$layout->containers["1"] = array();

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


$layout->skins["1"] = "fields";
$layout->blocks["bare"][] = "1";$page_layouts["senuc_nucleo_view_Informa__es_de_Contato1"] = $layout;

$layout = new TLayout("viewtab","BreezeAqua1","MobileAqua1");
$layout->blocks["bare"] = array();
$layout->containers["1"] = array();

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


$layout->skins["1"] = "fields";
$layout->blocks["bare"][] = "1";$page_layouts["senuc_nucleo_view_Configura__es1"] = $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_nucleo_list.php?a=return");
	exit();
}

$out = "";
$first = true;
$fieldsArr = array();
$arr = array();
$arr['fName'] = "nome";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("nome");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "login";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("login");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "endereco";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("endereco");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "cep";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("cep");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "estado";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("estado");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "cidade";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("cidade");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "tipo";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("tipo");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "data_inicio";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("data_inicio");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "observacao";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("observacao");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "prepara_para";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("prepara_para");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "funciona_em";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("funciona_em");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "ativo";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("ativo");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "motivo";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("motivo");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "responsavel";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("responsavel");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "site";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("site");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "email";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("email");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "telefone";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("telefone");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "celular";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("celular");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "operadora";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("operadora");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "meta_funcionamento";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("meta_funcionamento");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "meta_alunos";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("meta_alunos");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "limite_alunos_por_coordenador";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("limite_alunos_por_coordenador");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "min_presenca_coordenador";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("min_presenca_coordenador");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "data_ultimo_score";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("data_ultimo_score");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "min_presenca_professor";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("min_presenca_professor");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "ultimo_score";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("ultimo_score");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "min_presenca_aluno";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("min_presenca_aluno");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "min_atividades";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("min_atividades");
$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"]));

////////////////////////////////////////////
//nome - 
	
	$value = $pageObject->showDBValue("nome", $data, $keylink);
	if($mainTableOwnerID=="nome")
		$ownerIdValue=$value;
	$xt->assign("nome_value",$value);
	if(!$pageObject->isAppearOnTabs("nome"))
		$xt->assign("nome_fieldblock",true);
	else
		$xt->assign("nome_tabfieldblock",true);
////////////////////////////////////////////
//login - 
	
	$value = $pageObject->showDBValue("login", $data, $keylink);
	if($mainTableOwnerID=="login")
		$ownerIdValue=$value;
	$xt->assign("login_value",$value);
	if(!$pageObject->isAppearOnTabs("login"))
		$xt->assign("login_fieldblock",true);
	else
		$xt->assign("login_tabfieldblock",true);
////////////////////////////////////////////
//endereco - 
	
	$value = $pageObject->showDBValue("endereco", $data, $keylink);
	if($mainTableOwnerID=="endereco")
		$ownerIdValue=$value;
	$xt->assign("endereco_value",$value);
	if(!$pageObject->isAppearOnTabs("endereco"))
		$xt->assign("endereco_fieldblock",true);
	else
		$xt->assign("endereco_tabfieldblock",true);
////////////////////////////////////////////
//cep - 
	
	$value = $pageObject->showDBValue("cep", $data, $keylink);
	if($mainTableOwnerID=="cep")
		$ownerIdValue=$value;
	$xt->assign("cep_value",$value);
	if(!$pageObject->isAppearOnTabs("cep"))
		$xt->assign("cep_fieldblock",true);
	else
		$xt->assign("cep_tabfieldblock",true);
////////////////////////////////////////////
//estado - 
	
	$value = $pageObject->showDBValue("estado", $data, $keylink);
	if($mainTableOwnerID=="estado")
		$ownerIdValue=$value;
	$xt->assign("estado_value",$value);
	if(!$pageObject->isAppearOnTabs("estado"))
		$xt->assign("estado_fieldblock",true);
	else
		$xt->assign("estado_tabfieldblock",true);
////////////////////////////////////////////
//cidade - 
	
	$value = $pageObject->showDBValue("cidade", $data, $keylink);
	if($mainTableOwnerID=="cidade")
		$ownerIdValue=$value;
	$xt->assign("cidade_value",$value);
	if(!$pageObject->isAppearOnTabs("cidade"))
		$xt->assign("cidade_fieldblock",true);
	else
		$xt->assign("cidade_tabfieldblock",true);
////////////////////////////////////////////
//tipo - 
	
	$value = $pageObject->showDBValue("tipo", $data, $keylink);
	if($mainTableOwnerID=="tipo")
		$ownerIdValue=$value;
	$xt->assign("tipo_value",$value);
	if(!$pageObject->isAppearOnTabs("tipo"))
		$xt->assign("tipo_fieldblock",true);
	else
		$xt->assign("tipo_tabfieldblock",true);
////////////////////////////////////////////
//data_inicio - Short Date
	
	$value = $pageObject->showDBValue("data_inicio", $data, $keylink);
	if($mainTableOwnerID=="data_inicio")
		$ownerIdValue=$value;
	$xt->assign("data_inicio_value",$value);
	if(!$pageObject->isAppearOnTabs("data_inicio"))
		$xt->assign("data_inicio_fieldblock",true);
	else
		$xt->assign("data_inicio_tabfieldblock",true);
////////////////////////////////////////////
//observacao - 
	
	$value = $pageObject->showDBValue("observacao", $data, $keylink);
	if($mainTableOwnerID=="observacao")
		$ownerIdValue=$value;
	$xt->assign("observacao_value",$value);
	if(!$pageObject->isAppearOnTabs("observacao"))
		$xt->assign("observacao_fieldblock",true);
	else
		$xt->assign("observacao_tabfieldblock",true);
////////////////////////////////////////////
//prepara_para - 
	
	$value = $pageObject->showDBValue("prepara_para", $data, $keylink);
	if($mainTableOwnerID=="prepara_para")
		$ownerIdValue=$value;
	$xt->assign("prepara_para_value",$value);
	if(!$pageObject->isAppearOnTabs("prepara_para"))
		$xt->assign("prepara_para_fieldblock",true);
	else
		$xt->assign("prepara_para_tabfieldblock",true);
////////////////////////////////////////////
//funciona_em - 
	
	$value = $pageObject->showDBValue("funciona_em", $data, $keylink);
	if($mainTableOwnerID=="funciona_em")
		$ownerIdValue=$value;
	$xt->assign("funciona_em_value",$value);
	if(!$pageObject->isAppearOnTabs("funciona_em"))
		$xt->assign("funciona_em_fieldblock",true);
	else
		$xt->assign("funciona_em_tabfieldblock",true);
////////////////////////////////////////////
//ativo - Checkbox
	
	$value = $pageObject->showDBValue("ativo", $data, $keylink);
	if($mainTableOwnerID=="ativo")
		$ownerIdValue=$value;
	$xt->assign("ativo_value",$value);
	if(!$pageObject->isAppearOnTabs("ativo"))
		$xt->assign("ativo_fieldblock",true);
	else
		$xt->assign("ativo_tabfieldblock",true);
////////////////////////////////////////////
//motivo - 
	
	$value = $pageObject->showDBValue("motivo", $data, $keylink);
	if($mainTableOwnerID=="motivo")
		$ownerIdValue=$value;
	$xt->assign("motivo_value",$value);
	if(!$pageObject->isAppearOnTabs("motivo"))
		$xt->assign("motivo_fieldblock",true);
	else
		$xt->assign("motivo_tabfieldblock",true);
////////////////////////////////////////////
//responsavel - 
	
	$value = $pageObject->showDBValue("responsavel", $data, $keylink);
	if($mainTableOwnerID=="responsavel")
		$ownerIdValue=$value;
	$xt->assign("responsavel_value",$value);
	if(!$pageObject->isAppearOnTabs("responsavel"))
		$xt->assign("responsavel_fieldblock",true);
	else
		$xt->assign("responsavel_tabfieldblock",true);
////////////////////////////////////////////
//site - 
	
	$value = $pageObject->showDBValue("site", $data, $keylink);
	if($mainTableOwnerID=="site")
		$ownerIdValue=$value;
	$xt->assign("site_value",$value);
	if(!$pageObject->isAppearOnTabs("site"))
		$xt->assign("site_fieldblock",true);
	else
		$xt->assign("site_tabfieldblock",true);
////////////////////////////////////////////
//email - 
	
	$value = $pageObject->showDBValue("email", $data, $keylink);
	if($mainTableOwnerID=="email")
		$ownerIdValue=$value;
	$xt->assign("email_value",$value);
	if(!$pageObject->isAppearOnTabs("email"))
		$xt->assign("email_fieldblock",true);
	else
		$xt->assign("email_tabfieldblock",true);
////////////////////////////////////////////
//telefone - 
	
	$value = $pageObject->showDBValue("telefone", $data, $keylink);
	if($mainTableOwnerID=="telefone")
		$ownerIdValue=$value;
	$xt->assign("telefone_value",$value);
	if(!$pageObject->isAppearOnTabs("telefone"))
		$xt->assign("telefone_fieldblock",true);
	else
		$xt->assign("telefone_tabfieldblock",true);
////////////////////////////////////////////
//celular - 
	
	$value = $pageObject->showDBValue("celular", $data, $keylink);
	if($mainTableOwnerID=="celular")
		$ownerIdValue=$value;
	$xt->assign("celular_value",$value);
	if(!$pageObject->isAppearOnTabs("celular"))
		$xt->assign("celular_fieldblock",true);
	else
		$xt->assign("celular_tabfieldblock",true);
////////////////////////////////////////////
//operadora - 
	
	$value = $pageObject->showDBValue("operadora", $data, $keylink);
	if($mainTableOwnerID=="operadora")
		$ownerIdValue=$value;
	$xt->assign("operadora_value",$value);
	if(!$pageObject->isAppearOnTabs("operadora"))
		$xt->assign("operadora_fieldblock",true);
	else
		$xt->assign("operadora_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);
////////////////////////////////////////////
//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);
////////////////////////////////////////////
//limite_alunos_por_coordenador - 
	
	$value = $pageObject->showDBValue("limite_alunos_por_coordenador", $data, $keylink);
	if($mainTableOwnerID=="limite_alunos_por_coordenador")
		$ownerIdValue=$value;
	$xt->assign("limite_alunos_por_coordenador_value",$value);
	if(!$pageObject->isAppearOnTabs("limite_alunos_por_coordenador"))
		$xt->assign("limite_alunos_por_coordenador_fieldblock",true);
	else
		$xt->assign("limite_alunos_por_coordenador_tabfieldblock",true);
////////////////////////////////////////////
//min_presenca_coordenador - 
	
	$value = $pageObject->showDBValue("min_presenca_coordenador", $data, $keylink);
	if($mainTableOwnerID=="min_presenca_coordenador")
		$ownerIdValue=$value;
	$xt->assign("min_presenca_coordenador_value",$value);
	if(!$pageObject->isAppearOnTabs("min_presenca_coordenador"))
		$xt->assign("min_presenca_coordenador_fieldblock",true);
	else
		$xt->assign("min_presenca_coordenador_tabfieldblock",true);
////////////////////////////////////////////
//data_ultimo_score - Short Date
	
	$value = $pageObject->showDBValue("data_ultimo_score", $data, $keylink);
	if($mainTableOwnerID=="data_ultimo_score")
		$ownerIdValue=$value;
	$xt->assign("data_ultimo_score_value",$value);
	if(!$pageObject->isAppearOnTabs("data_ultimo_score"))
		$xt->assign("data_ultimo_score_fieldblock",true);
	else
		$xt->assign("data_ultimo_score_tabfieldblock",true);
////////////////////////////////////////////
//min_presenca_professor - 
	
	$value = $pageObject->showDBValue("min_presenca_professor", $data, $keylink);
	if($mainTableOwnerID=="min_presenca_professor")
		$ownerIdValue=$value;
	$xt->assign("min_presenca_professor_value",$value);
	if(!$pageObject->isAppearOnTabs("min_presenca_professor"))
		$xt->assign("min_presenca_professor_fieldblock",true);
	else
		$xt->assign("min_presenca_professor_tabfieldblock",true);
////////////////////////////////////////////
//ultimo_score - 
	
	$value = $pageObject->showDBValue("ultimo_score", $data, $keylink);
	if($mainTableOwnerID=="ultimo_score")
		$ownerIdValue=$value;
	$xt->assign("ultimo_score_value",$value);
	if(!$pageObject->isAppearOnTabs("ultimo_score"))
		$xt->assign("ultimo_score_fieldblock",true);
	else
		$xt->assign("ultimo_score_tabfieldblock",true);
////////////////////////////////////////////
//min_presenca_aluno - 
	
	$value = $pageObject->showDBValue("min_presenca_aluno", $data, $keylink);
	if($mainTableOwnerID=="min_presenca_aluno")
		$ownerIdValue=$value;
	$xt->assign("min_presenca_aluno_value",$value);
	if(!$pageObject->isAppearOnTabs("min_presenca_aluno"))
		$xt->assign("min_presenca_aluno_fieldblock",true);
	else
		$xt->assign("min_presenca_aluno_tabfieldblock",true);
////////////////////////////////////////////
//min_atividades - 
	
	$value = $pageObject->showDBValue("min_atividades", $data, $keylink);
	if($mainTableOwnerID=="min_atividades")
		$ownerIdValue=$value;
	$xt->assign("min_atividades_value",$value);
	if(!$pageObject->isAppearOnTabs("min_atividades"))
		$xt->assign("min_atividades_fieldblock",true);
	else
		$xt->assign("min_atividades_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_nucleo";
		$options['firstTime'] = 1;
		
		$strTableName = $dpParams['strTableNames'][$d];
		include_once("include/".GetTableURL($strTableName)."_settings.php");
		if(!CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Search"))
		{
			$strTableName = "senuc_nucleo";
			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_nucleo";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//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_nucleo_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;
}
}


?>
