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

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

//$strSQL = "SELECT  id,  tipo_atividade,  materia_atividade,  id_professor,  nome_atividade,  data_atividade,  data_criacao,  id_nucleo,  atividade,  id_turma  FROM senuc_atividades  ORDER BY data_atividade 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_atividades_masterprint"] = $layout;


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

//	tipo_atividade - 
			$xt->assign("tipo_atividade_mastervalue", $viewControls->showDBValue("tipo_atividade", $data, $keylink));

//	materia_atividade - 
			$xt->assign("materia_atividade_mastervalue", $viewControls->showDBValue("materia_atividade", $data, $keylink));

//	id_professor - 
			$xt->assign("id_professor_mastervalue", $viewControls->showDBValue("id_professor", $data, $keylink));

//	nome_atividade - 
			$xt->assign("nome_atividade_mastervalue", $viewControls->showDBValue("nome_atividade", $data, $keylink));

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

//	id_nucleo - 
			$xt->assign("id_nucleo_mastervalue", $viewControls->showDBValue("id_nucleo", $data, $keylink));

//	atividade - Document Download
			$xt->assign("atividade_mastervalue", $viewControls->showDBValue("atividade", $data, $keylink));

//	id_turma - 
			$xt->assign("id_turma_mastervalue", $viewControls->showDBValue("id_turma", $data, $keylink));
	$xt->display("senuc_atividades_masterprint.htm");
	$strTableName=$oldTableName;

}

?>