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

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

//$strSQL = "SELECT  id,  idregional,  login,  senha,  nome,  responsavel,  endereco,  cep,  estado,  cidade,  tipo,  site,  email,  telefone,  celular,  operadora,  data_inicio,  observacao,  prepara_para,  funciona_em,  ativo,  motivo,  id_mdl,  meta_funcionamento,  meta_alunos,  limite_alunos_por_coordenador,  min_presenca_coordenador,  min_presenca_professor,  min_presenca_aluno,  min_atividades,  data_ultimo_score,  ultimo_score  FROM senuc_nucleo  ORDER BY ativo 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_nucleo_masterprint"] = $layout;


$showKeys = "";
if($detailtable=="senuc_aluno")
{
		$where.= GetFullFieldName("id", "", false)."=".$cipherer->MakeDBValue("id",$keys[1-1], "", "", true);
	$showKeys .= " "."Id".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
	
}
if($detailtable=="senuc_coordenador")
{
		$where.= GetFullFieldName("id", "", false)."=".$cipherer->MakeDBValue("id",$keys[1-1], "", "", true);
	$showKeys .= " "."Id".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
	
}
if($detailtable=="senuc_professores")
{
		$where.= GetFullFieldName("id", "", false)."=".$cipherer->MakeDBValue("id",$keys[1-1], "", "", true);
	$showKeys .= " "."Id".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
	
}
if($detailtable=="senuc_login")
{
		$where.= GetFullFieldName("id", "", false)."=".$cipherer->MakeDBValue("id",$keys[1-1], "", "", true);
	$showKeys .= " "."Id".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
	
}
if($detailtable=="senuc_score")
{
		$where.= GetFullFieldName("id", "", false)."=".$cipherer->MakeDBValue("id",$keys[1-1], "", "", true);
	$showKeys .= " "."Id".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
	
}
if($detailtable=="senuc_atividades")
{
		$where.= GetFullFieldName("id", "", false)."=".$cipherer->MakeDBValue("id",$keys[1-1], "", "", true);
	$showKeys .= " "."Id".": ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
	
}
if($detailtable=="senuc_plantoes")
{
		$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_turmas")
{
		$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"]));
	

//	login - 
			$xt->assign("login_mastervalue", $viewControls->showDBValue("login", $data, $keylink));

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

//	responsavel - 
			$xt->assign("responsavel_mastervalue", $viewControls->showDBValue("responsavel", $data, $keylink));

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

//	cep - 
			$xt->assign("cep_mastervalue", $viewControls->showDBValue("cep", $data, $keylink));

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

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

//	tipo - 
			$xt->assign("tipo_mastervalue", $viewControls->showDBValue("tipo", $data, $keylink));

//	site - 
			$xt->assign("site_mastervalue", $viewControls->showDBValue("site", $data, $keylink));

//	email - 
			$xt->assign("email_mastervalue", $viewControls->showDBValue("email", $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));

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

//	observacao - 
			$xt->assign("observacao_mastervalue", $viewControls->showDBValue("observacao", $data, $keylink));

//	prepara_para - 
			$xt->assign("prepara_para_mastervalue", $viewControls->showDBValue("prepara_para", $data, $keylink));

//	funciona_em - 
			$xt->assign("funciona_em_mastervalue", $viewControls->showDBValue("funciona_em", $data, $keylink));

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

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

//	meta_funcionamento - 
			$xt->assign("meta_funcionamento_mastervalue", $viewControls->showDBValue("meta_funcionamento", $data, $keylink));

//	meta_alunos - 
			$xt->assign("meta_alunos_mastervalue", $viewControls->showDBValue("meta_alunos", $data, $keylink));

//	limite_alunos_por_coordenador - 
			$xt->assign("limite_alunos_por_coordenador_mastervalue", $viewControls->showDBValue("limite_alunos_por_coordenador", $data, $keylink));

//	min_presenca_coordenador - 
			$xt->assign("min_presenca_coordenador_mastervalue", $viewControls->showDBValue("min_presenca_coordenador", $data, $keylink));

//	min_presenca_professor - 
			$xt->assign("min_presenca_professor_mastervalue", $viewControls->showDBValue("min_presenca_professor", $data, $keylink));

//	min_presenca_aluno - 
			$xt->assign("min_presenca_aluno_mastervalue", $viewControls->showDBValue("min_presenca_aluno", $data, $keylink));

//	min_atividades - 
			$xt->assign("min_atividades_mastervalue", $viewControls->showDBValue("min_atividades", $data, $keylink));

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

//	ultimo_score - 
			$xt->assign("ultimo_score_mastervalue", $viewControls->showDBValue("ultimo_score", $data, $keylink));
	$xt->display("senuc_nucleo_masterprint.htm");
	$strTableName=$oldTableName;

}

?>