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

include("include/dbcommon.php");
include("include/senuc_coordenador_regional_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_coordenador_regional_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_coordenador_regional_list.php?a=return");
	exit();
}

$out = "";
$first = true;
$fieldsArr = array();
$arr = array();
$arr['fName'] = "ultimo_score";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("ultimo_score");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "tipo_coordenador";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("tipo_coordenador");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "data_ultimo_score";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("data_ultimo_score");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "nome";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("nome");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "nome_nucleo";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("nome_nucleo");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "nome_regional";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("nome_regional");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "cpf";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("cpf");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "email";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("email");
$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'] = "endereco";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("endereco");
$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'] = "nascimento";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("nascimento");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "renda";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("renda");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "etnia";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("etnia");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "escolaridade";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("escolaridade");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "bolsista";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("bolsista");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "ingresso_nucleo";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("ingresso_nucleo");
$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;

$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"]));

////////////////////////////////////////////
//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);
////////////////////////////////////////////
//tipo_coordenador - 
	
	$value = $pageObject->showDBValue("tipo_coordenador", $data, $keylink);
	if($mainTableOwnerID=="tipo_coordenador")
		$ownerIdValue=$value;
	$xt->assign("tipo_coordenador_value",$value);
	if(!$pageObject->isAppearOnTabs("tipo_coordenador"))
		$xt->assign("tipo_coordenador_fieldblock",true);
	else
		$xt->assign("tipo_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);
////////////////////////////////////////////
//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);
////////////////////////////////////////////
//nome_nucleo - 
	
	$value = $pageObject->showDBValue("nome_nucleo", $data, $keylink);
	if($mainTableOwnerID=="nome_nucleo")
		$ownerIdValue=$value;
	$xt->assign("nome_nucleo_value",$value);
	if(!$pageObject->isAppearOnTabs("nome_nucleo"))
		$xt->assign("nome_nucleo_fieldblock",true);
	else
		$xt->assign("nome_nucleo_tabfieldblock",true);
////////////////////////////////////////////
//nome_regional - 
	
	$value = $pageObject->showDBValue("nome_regional", $data, $keylink);
	if($mainTableOwnerID=="nome_regional")
		$ownerIdValue=$value;
	$xt->assign("nome_regional_value",$value);
	if(!$pageObject->isAppearOnTabs("nome_regional"))
		$xt->assign("nome_regional_fieldblock",true);
	else
		$xt->assign("nome_regional_tabfieldblock",true);
////////////////////////////////////////////
//cpf - 
	
	$value = $pageObject->showDBValue("cpf", $data, $keylink);
	if($mainTableOwnerID=="cpf")
		$ownerIdValue=$value;
	$xt->assign("cpf_value",$value);
	if(!$pageObject->isAppearOnTabs("cpf"))
		$xt->assign("cpf_fieldblock",true);
	else
		$xt->assign("cpf_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);
////////////////////////////////////////////
//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);
////////////////////////////////////////////
//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);
////////////////////////////////////////////
//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);
////////////////////////////////////////////
//nascimento - Short Date
	
	$value = $pageObject->showDBValue("nascimento", $data, $keylink);
	if($mainTableOwnerID=="nascimento")
		$ownerIdValue=$value;
	$xt->assign("nascimento_value",$value);
	if(!$pageObject->isAppearOnTabs("nascimento"))
		$xt->assign("nascimento_fieldblock",true);
	else
		$xt->assign("nascimento_tabfieldblock",true);
////////////////////////////////////////////
//renda - 
	
	$value = $pageObject->showDBValue("renda", $data, $keylink);
	if($mainTableOwnerID=="renda")
		$ownerIdValue=$value;
	$xt->assign("renda_value",$value);
	if(!$pageObject->isAppearOnTabs("renda"))
		$xt->assign("renda_fieldblock",true);
	else
		$xt->assign("renda_tabfieldblock",true);
////////////////////////////////////////////
//etnia - 
	
	$value = $pageObject->showDBValue("etnia", $data, $keylink);
	if($mainTableOwnerID=="etnia")
		$ownerIdValue=$value;
	$xt->assign("etnia_value",$value);
	if(!$pageObject->isAppearOnTabs("etnia"))
		$xt->assign("etnia_fieldblock",true);
	else
		$xt->assign("etnia_tabfieldblock",true);
////////////////////////////////////////////
//escolaridade - 
	
	$value = $pageObject->showDBValue("escolaridade", $data, $keylink);
	if($mainTableOwnerID=="escolaridade")
		$ownerIdValue=$value;
	$xt->assign("escolaridade_value",$value);
	if(!$pageObject->isAppearOnTabs("escolaridade"))
		$xt->assign("escolaridade_fieldblock",true);
	else
		$xt->assign("escolaridade_tabfieldblock",true);
////////////////////////////////////////////
//bolsista - Checkbox
	
	$value = $pageObject->showDBValue("bolsista", $data, $keylink);
	if($mainTableOwnerID=="bolsista")
		$ownerIdValue=$value;
	$xt->assign("bolsista_value",$value);
	if(!$pageObject->isAppearOnTabs("bolsista"))
		$xt->assign("bolsista_fieldblock",true);
	else
		$xt->assign("bolsista_tabfieldblock",true);
////////////////////////////////////////////
//ingresso_nucleo - Short Date
	
	$value = $pageObject->showDBValue("ingresso_nucleo", $data, $keylink);
	if($mainTableOwnerID=="ingresso_nucleo")
		$ownerIdValue=$value;
	$xt->assign("ingresso_nucleo_value",$value);
	if(!$pageObject->isAppearOnTabs("ingresso_nucleo"))
		$xt->assign("ingresso_nucleo_fieldblock",true);
	else
		$xt->assign("ingresso_nucleo_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 - Custom
	
	$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);

/////////////////////////////////////////////////////////////
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_coordenador_regional";
		$options['firstTime'] = 1;
		
		$strTableName = $dpParams['strTableNames'][$d];
		include_once("include/".GetTableURL($strTableName)."_settings.php");
		if(!CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Search"))
		{
			$strTableName = "senuc_coordenador_regional";
			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_coordenador_regional";
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//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_coordenador_regional_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;
}
}


?>
