<?php
include_once(getabspath("include/senuc_aluno_settings.php"));

function DisplayMasterTableInfo_senuc_aluno($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	
	$oldTableName=$strTableName;
	$strTableName="senuc_aluno";

//$strSQL = "SELECT  id,  idnucleo,  nome,  endereco,  email,  cpf,  rg,  telefone,  celular,  operadora,  cidade,  estado,  etnia,  nascimento,  nota_cidadania,  renda,  escolaridade,  preparar_para,  ingresso_nucleo,  acoes_afirmativas,  ativo,  motivo,  id_mdl,  idregional,  ultimo_score,  data_ultimo_score,  score,  id_turma,  data_atualiza AS data_atualiza  FROM senuc_aluno  ORDER BY ativo DESC, nome, data_atualiza DESC  ";

	$cipherer = new RunnerCipherer($strTableName);
	$settings = new ProjectSettings($strTableName, PAGE_PRINT);
	
	$masterQuery = $settings->getSQLQuery();
	$viewControls = new ViewControlsContainer($settings, PAGE_PRINT);

$where="";

global $pageObject, $page_styles, $page_layouts, $page_layout_names, $container_styles;
$layout = new TLayout("masterprint","BreezeAqua1","MobileAqua1");
$layout->blocks["bare"] = array();
$layout->containers["0"] = array();

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


$layout->skins["0"] = "empty";
$layout->blocks["bare"][] = "0";
$layout->containers["mastergrid"] = array();

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


$layout->skins["mastergrid"] = "grid";
$layout->blocks["bare"][] = "mastergrid";$page_layouts["senuc_aluno_masterprint"] = $layout;


$showKeys = "";
if($detailtable=="senuc_frequencias")
{
		$where.= GetFullFieldName("cpf", "", false)."=".$cipherer->MakeDBValue("cpf",$keys[1-1], "", "", true);
	$showKeys .= " "."Cpf".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
	
}
if($detailtable=="senuc_atividades_aluno")
{
		$where.= GetFullFieldName("id", "", false)."=".$cipherer->MakeDBValue("id",$keys[1-1], "", "", true);
	$showKeys .= " "."Id".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
	
}
if($detailtable=="senuc_plantoes_aluno")
{
		$where.= GetFullFieldName("id", "", false)."=".$cipherer->MakeDBValue("id",$keys[1-1], "", "", true);
	$showKeys .= " "."Id".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
	
}
if($detailtable=="senuc_contribuicoes")
{
		$where.= GetFullFieldName("id", "", false)."=".$cipherer->MakeDBValue("id",$keys[1-1], "", "", true);
	$showKeys .= " "."Id".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
	
}
if($detailtable=="senuc_descomplica")
{
		$where.= GetFullFieldName("id", "", false)."=".$cipherer->MakeDBValue("id",$keys[1-1], "", "", true);
	$showKeys .= " "."Id".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
	
}
if(!$where)
{
	$strTableName=$oldTableName;
	return;
}
	$str = SecuritySQL("Export");
	if(strlen($str))
		$where.=" and ".$str;
	
	$strWhere = whereAdd($masterQuery->m_where->toSql($masterQuery),$where);
	if(strlen($strWhere))
		$strWhere=" where ".$strWhere." ";
	$strSQL = $masterQuery->HeadToSql().' '.$masterQuery->FromToSql().$strWhere.$masterQuery->TailToSql();

//	$strSQL=AddWhere($strSQL,$where);

	LogInfo($strSQL);
	$rs=db_query($strSQL,$conn);
	$data = $cipherer->DecryptFetchedArray($rs);
	if(!$data)
	{
		$strTableName=$oldTableName;
		return;
	}
	$keylink="";
	$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["id"]));
	

//	id - 
			$xt->assign("id_mastervalue", $viewControls->showDBValue("id", $data, $keylink));

//	idnucleo - 
			$xt->assign("idnucleo_mastervalue", $viewControls->showDBValue("idnucleo", $data, $keylink));

//	nome - 
			$xt->assign("nome_mastervalue", $viewControls->showDBValue("nome", $data, $keylink));

//	endereco - 
			$xt->assign("endereco_mastervalue", $viewControls->showDBValue("endereco", $data, $keylink));

//	email - 
			$xt->assign("email_mastervalue", $viewControls->showDBValue("email", $data, $keylink));

//	cpf - Custom
			$xt->assign("cpf_mastervalue", $viewControls->showDBValue("cpf", $data, $keylink));

//	telefone - 
			$xt->assign("telefone_mastervalue", $viewControls->showDBValue("telefone", $data, $keylink));

//	celular - 
			$xt->assign("celular_mastervalue", $viewControls->showDBValue("celular", $data, $keylink));

//	operadora - 
			$xt->assign("operadora_mastervalue", $viewControls->showDBValue("operadora", $data, $keylink));

//	cidade - 
			$xt->assign("cidade_mastervalue", $viewControls->showDBValue("cidade", $data, $keylink));

//	estado - 
			$xt->assign("estado_mastervalue", $viewControls->showDBValue("estado", $data, $keylink));

//	etnia - 
			$xt->assign("etnia_mastervalue", $viewControls->showDBValue("etnia", $data, $keylink));

//	nascimento - Custom
			$xt->assign("nascimento_mastervalue", $viewControls->showDBValue("nascimento", $data, $keylink));

//	nota_cidadania - 
			$xt->assign("nota_cidadania_mastervalue", $viewControls->showDBValue("nota_cidadania", $data, $keylink));

//	renda - 
			$xt->assign("renda_mastervalue", $viewControls->showDBValue("renda", $data, $keylink));

//	escolaridade - 
			$xt->assign("escolaridade_mastervalue", $viewControls->showDBValue("escolaridade", $data, $keylink));

//	preparar_para - 
			$xt->assign("preparar_para_mastervalue", $viewControls->showDBValue("preparar_para", $data, $keylink));

//	ingresso_nucleo - Short Date
			$xt->assign("ingresso_nucleo_mastervalue", $viewControls->showDBValue("ingresso_nucleo", $data, $keylink));

//	acoes_afirmativas - 
			$xt->assign("acoes_afirmativas_mastervalue", $viewControls->showDBValue("acoes_afirmativas", $data, $keylink));

//	ativo - Checkbox
			$xt->assign("ativo_mastervalue", $viewControls->showDBValue("ativo", $data, $keylink));

//	motivo - Custom
			$xt->assign("motivo_mastervalue", $viewControls->showDBValue("motivo", $data, $keylink));

//	id_mdl - 
			$xt->assign("id_mdl_mastervalue", $viewControls->showDBValue("id_mdl", $data, $keylink));

//	idregional - 
			$xt->assign("idregional_mastervalue", $viewControls->showDBValue("idregional", $data, $keylink));

//	ultimo_score - Custom
			$xt->assign("ultimo_score_mastervalue", $viewControls->showDBValue("ultimo_score", $data, $keylink));

//	data_ultimo_score - Custom
			$xt->assign("data_ultimo_score_mastervalue", $viewControls->showDBValue("data_ultimo_score", $data, $keylink));

//	score - 
			$xt->assign("score_mastervalue", $viewControls->showDBValue("score", $data, $keylink));

//	id_turma - 
			$xt->assign("id_turma_mastervalue", $viewControls->showDBValue("id_turma", $data, $keylink));

//	data_atualiza - Short Date
			$xt->assign("data_atualiza_mastervalue", $viewControls->showDBValue("data_atualiza", $data, $keylink));
	$xt->display("senuc_aluno_masterprint.htm");
	$strTableName=$oldTableName;

}

?>