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

include("include/dbcommon.php");
include("classes/searchclause.php");

add_nocache_headers();

include("include/informacoes_gerais_variables.php");

if(!isLogged())
{ 
	$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];
	header("Location: login.php?message=expired"); 
	return;
}
if(CheckPermissionsEvent($strTableName, 'P') && !CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Export"))
{
	echo "<p>"."Você não tem permissão para acessar esta tabela"."<a href=\"login.php\">"."Voltar à página de Login"."</a></p>";
	return;
}

$layout = new TLayout("print","BreezeAqua1","MobileAqua1");
$layout->blocks["center"] = array();
$layout->containers["grid"] = array();

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


$layout->skins["grid"] = "empty";
$layout->blocks["center"][] = "grid";$layout->blocks["top"] = array();
$layout->skins["master"] = "empty";
$layout->blocks["top"][] = "master";
$layout->skins["pdf"] = "empty";
$layout->blocks["top"][] = "pdf";$page_layouts["informacoes_gerais_print"] = $layout;


include('include/xtempl.php');
include('classes/runnerpage.php');

$cipherer = new RunnerCipherer($strTableName);

$xt = new Xtempl();
$id = postvalue("id") != "" ? postvalue("id") : 1;
$all = postvalue("all");
$pageName = "print.php";

//array of params for classes
$params = array("id" => $id,
				"tName" => $strTableName,
				"pageType" => PAGE_PRINT);
$params["xt"] = &$xt;
			
$pageObject = new RunnerPage($params);

// add button events if exist
$pageObject->addButtonHandlers();

// Modify query: remove blob fields from fieldlist.
// Blob fields on a print page are shown using imager.php (for example).
// They don't need to be selected from DB in print.php itself.
$noBlobReplace = false;
if(!postvalue("pdf") && !$noBlobReplace)
	$gQuery->ReplaceFieldsWithDummies($pageObject->pSet->getBinaryFieldsIndices());

//	Before Process event
if($eventObj->exists("BeforeProcessPrint"))
	$eventObj->BeforeProcessPrint($conn, $pageObject);

$strWhereClause="";
$strHavingClause="";
$strSearchCriteria="and";

$selected_recs=array();
if (@$_REQUEST["a"]!="") 
{
	$sWhere = "1=0";	
	
//	process selection
	if (@$_REQUEST["mdelete"])
	{
		foreach(@$_REQUEST["mdelete"] as $ind)
		{
			$keys=array();
			$keys["id"]=refine($_REQUEST["mdelete1"][mdeleteIndex($ind)]);
			$selected_recs[]=$keys;
		}
	}
	elseif(@$_REQUEST["selection"])
	{
		foreach(@$_REQUEST["selection"] as $keyblock)
		{
			$arr=explode("&",refine($keyblock));
			if(count($arr)<1)
				continue;
			$keys=array();
			$keys["id"]=urldecode($arr[0]);
			$selected_recs[]=$keys;
		}
	}

	foreach($selected_recs as $keys)
	{
		$sWhere = $sWhere . " or ";
		$sWhere.=KeyWhere($keys);
	}
	$strSQL = $gQuery->gSQLWhere($sWhere);
	$strWhereClause=$sWhere;
}
else
{
	$strWhereClause=@$_SESSION[$strTableName."_where"];
	$strHavingClause=@$_SESSION[$strTableName."_having"];
	$strSearchCriteria=@$_SESSION[$strTableName."_criteria"];
	$strSQL = $gQuery->gSQLWhere($strWhereClause, $strHavingClause, $strSearchCriteria);
}
if(postvalue("pdf"))
	$strWhereClause = @$_SESSION[$strTableName."_pdfwhere"];

$_SESSION[$strTableName."_pdfwhere"] = $strWhereClause;


$strOrderBy = $_SESSION[$strTableName."_order"];
if(!$strOrderBy)
	$strOrderBy=$gstrOrderBy;
$strSQL.=" ".trim($strOrderBy);

$strSQLbak = $strSQL;
if($eventObj->exists("BeforeQueryPrint"))
	$eventObj->BeforeQueryPrint($strSQL,$strWhereClause,$strOrderBy, $pageObject);

//	Rebuild SQL if needed

if($strSQL!=$strSQLbak)
{
//	changed $strSQL - old style	
	$numrows=GetRowCount($strSQL);
}
else
{
	$strSQL = $gQuery->gSQLWhere($strWhereClause, $strHavingClause, $strSearchCriteria);
	$strSQL.=" ".trim($strOrderBy);
	
	$rowcount=false;
	if($eventObj->exists("ListGetRowCount"))
	{
		$masterKeysReq=array();
		for($i = 0; $i < count($pageObject->detailKeysByM); $i ++)
			$masterKeysReq[]=$_SESSION[$strTableName."_masterkey".($i + 1)];
			$rowcount=$eventObj->ListGetRowCount($pageObject->searchClauseObj,$_SESSION[$strTableName."_mastertable"],$masterKeysReq,$selected_recs, $pageObject);
	}
	if($rowcount!==false)
		$numrows=$rowcount;
	else
	{
		$numrows = $gQuery->gSQLRowCount($strWhereClause, $strHavingClause, $strSearchCriteria);
	}
}

LogInfo($strSQL);

$mypage=(integer)$_SESSION[$strTableName."_pagenumber"];
if(!$mypage)
	$mypage=1;

//	page size
$PageSize=(integer)$_SESSION[$strTableName."_pagesize"];
if(!$PageSize)
	$PageSize = $pageObject->pSet->getInitialPageSize();

if($PageSize<0)
	$all = 1;	
	
$recno = 1;
$records = 0;	
$maxpages = 1;
$pageindex = 1;
$pageno=1;

// build arrays for sort (to support old code in user-defined events)
if($eventObj->exists("ListQuery"))
{
	$arrFieldForSort = array();
	$arrHowFieldSort = array();
	require_once getabspath('classes/orderclause.php');
	$fieldList = unserialize($_SESSION[$strTableName."_orderFieldsList"]);
	for($i = 0; $i < count($fieldList); $i++)
	{
		$arrFieldForSort[] = $fieldList[$i]->fieldIndex; 
		$arrHowFieldSort[] = $fieldList[$i]->orderDirection; 
	}
}

if(!$all)
{	
	if($numrows)
	{
		$maxRecords = $numrows;
		$maxpages = ceil($maxRecords/$PageSize);
					
		if($mypage > $maxpages)
			$mypage = $maxpages;
		
		if($mypage < 1) 
			$mypage = 1;
		
		$maxrecs = $PageSize;
	}
	$listarray = false;
	if($eventObj->exists("ListQuery"))
		$listarray = $eventObj->ListQuery($pageObject->searchClauseObj, $arrFieldForSort, $arrHowFieldSort, 
			$_SESSION[$strTableName."_mastertable"], $masterKeysReq, $selected_recs, $PageSize, $mypage, $pageObject);
	if($listarray!==false)
		$rs = $listarray;
	else
	{
			if($numrows)
		{
			$strSQL.=" limit ".(($mypage-1)*$PageSize).",".$PageSize;
		}
		$rs = db_query($strSQL,$conn);
	}
	
	//	hide colunm headers if needed
	$recordsonpage = $numrows-($mypage-1)*$PageSize;
	if($recordsonpage>$PageSize)
		$recordsonpage = $PageSize;
		
	$xt->assign("page_number",true);
	$xt->assign("maxpages",$maxpages);
	$xt->assign("pageno",$mypage);
}
else
{
	$listarray = false;
	if($eventObj->exists("ListQuery"))
		$listarray=$eventObj->ListQuery($pageObject->searchClauseObj, $arrFieldForSort, $arrHowFieldSort,
			$_SESSION[$strTableName."_mastertable"], $masterKeysReq, $selected_recs, $PageSize, $mypage, $pageObject);
	if($listarray!==false)
		$rs = $listarray;
	else
		$rs = db_query($strSQL,$conn);
	$recordsonpage = $numrows;
	$maxpages = ceil($recordsonpage/30);
	$xt->assign("page_number",true);
	$xt->assign("maxpages",$maxpages);
}


$fieldsArr = array();
$arr = array();
$arr['fName'] = "login";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("login");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "nome";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("nome");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "responsavel";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("responsavel");
$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'] = "regional";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("regional");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "tipo";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("tipo");
$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'] = "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'] = "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'] = "min_presenca_professor";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("min_presenca_professor");
$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;
$arr = array();
$arr['fName'] = "data_ultimo_score";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("data_ultimo_score");
$fieldsArr[] = $arr;
$arr = array();
$arr['fName'] = "ultimo_score";
$arr['viewFormat'] = $pageObject->pSet->getViewFormat("ultimo_score");
$fieldsArr[] = $arr;
$pageObject->setGoogleMapsParams($fieldsArr);

$colsonpage=1;
if($colsonpage>$recordsonpage)
	$colsonpage=$recordsonpage;
if($colsonpage<1)
	$colsonpage=1;


//	fill $rowinfo array
	$pages = array();
	$rowinfo = array();
	$rowinfo["data"] = array();
	if($eventObj->exists("ListFetchArray"))
		$data = $eventObj->ListFetchArray($rs, $pageObject);
	else
		$data = $cipherer->DecryptFetchedArray($rs);

	while($data)
	{
		if($eventObj->exists("BeforeProcessRowPrint"))
		{
			if(!$eventObj->BeforeProcessRowPrint($data, $pageObject))
			{
				if($eventObj->exists("ListFetchArray"))
					$data = $eventObj->ListFetchArray($rs, $pageObject);
				else
					$data = $cipherer->DecryptFetchedArray($rs);
				continue;
			}
		}
		break;
	}
	
	while($data && ($all || $recno<=$PageSize))
	{
		$row = array();
		$row["grid_record"] = array();
		$row["grid_record"]["data"] = array();
		for($col=1;$data && ($all || $recno<=$PageSize) && $col<=1;$col++)
		{
			$record = array();
			$recno++;
			$records++;
			$keylink="";
			$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["id"]));

//	nome - 
			$record["nome_value"] = $pageObject->showDBValue("nome", $data, $keylink);
			$record["nome_class"] = $pageObject->fieldClass("nome");
//	login - 
			$record["login_value"] = $pageObject->showDBValue("login", $data, $keylink);
			$record["login_class"] = $pageObject->fieldClass("login");
//	endereco - 
			$record["endereco_value"] = $pageObject->showDBValue("endereco", $data, $keylink);
			$record["endereco_class"] = $pageObject->fieldClass("endereco");
//	cep - 
			$record["cep_value"] = $pageObject->showDBValue("cep", $data, $keylink);
			$record["cep_class"] = $pageObject->fieldClass("cep");
//	estado - 
			$record["estado_value"] = $pageObject->showDBValue("estado", $data, $keylink);
			$record["estado_class"] = $pageObject->fieldClass("estado");
//	cidade - 
			$record["cidade_value"] = $pageObject->showDBValue("cidade", $data, $keylink);
			$record["cidade_class"] = $pageObject->fieldClass("cidade");
//	regional - 
			$record["regional_value"] = $pageObject->showDBValue("regional", $data, $keylink);
			$record["regional_class"] = $pageObject->fieldClass("regional");
//	tipo - 
			$record["tipo_value"] = $pageObject->showDBValue("tipo", $data, $keylink);
			$record["tipo_class"] = $pageObject->fieldClass("tipo");
//	data_inicio - Short Date
			$record["data_inicio_value"] = $pageObject->showDBValue("data_inicio", $data, $keylink);
			$record["data_inicio_class"] = $pageObject->fieldClass("data_inicio");
//	observacao - 
			$record["observacao_value"] = $pageObject->showDBValue("observacao", $data, $keylink);
			$record["observacao_class"] = $pageObject->fieldClass("observacao");
//	prepara_para - 
			$record["prepara_para_value"] = $pageObject->showDBValue("prepara_para", $data, $keylink);
			$record["prepara_para_class"] = $pageObject->fieldClass("prepara_para");
//	funciona_em - 
			$record["funciona_em_value"] = $pageObject->showDBValue("funciona_em", $data, $keylink);
			$record["funciona_em_class"] = $pageObject->fieldClass("funciona_em");
//	ativo - Checkbox
			$record["ativo_value"] = $pageObject->showDBValue("ativo", $data, $keylink);
			$record["ativo_class"] = $pageObject->fieldClass("ativo");
//	motivo - 
			$record["motivo_value"] = $pageObject->showDBValue("motivo", $data, $keylink);
			$record["motivo_class"] = $pageObject->fieldClass("motivo");
//	responsavel - 
			$record["responsavel_value"] = $pageObject->showDBValue("responsavel", $data, $keylink);
			$record["responsavel_class"] = $pageObject->fieldClass("responsavel");
//	site - 
			$record["site_value"] = $pageObject->showDBValue("site", $data, $keylink);
			$record["site_class"] = $pageObject->fieldClass("site");
//	email - 
			$record["email_value"] = $pageObject->showDBValue("email", $data, $keylink);
			$record["email_class"] = $pageObject->fieldClass("email");
//	telefone - 
			$record["telefone_value"] = $pageObject->showDBValue("telefone", $data, $keylink);
			$record["telefone_class"] = $pageObject->fieldClass("telefone");
//	celular - 
			$record["celular_value"] = $pageObject->showDBValue("celular", $data, $keylink);
			$record["celular_class"] = $pageObject->fieldClass("celular");
//	operadora - 
			$record["operadora_value"] = $pageObject->showDBValue("operadora", $data, $keylink);
			$record["operadora_class"] = $pageObject->fieldClass("operadora");
//	meta_funcionamento - 
			$record["meta_funcionamento_value"] = $pageObject->showDBValue("meta_funcionamento", $data, $keylink);
			$record["meta_funcionamento_class"] = $pageObject->fieldClass("meta_funcionamento");
//	meta_alunos - 
			$record["meta_alunos_value"] = $pageObject->showDBValue("meta_alunos", $data, $keylink);
			$record["meta_alunos_class"] = $pageObject->fieldClass("meta_alunos");
//	limite_alunos_por_coordenador - 
			$record["limite_alunos_por_coordenador_value"] = $pageObject->showDBValue("limite_alunos_por_coordenador", $data, $keylink);
			$record["limite_alunos_por_coordenador_class"] = $pageObject->fieldClass("limite_alunos_por_coordenador");
//	min_presenca_coordenador - 
			$record["min_presenca_coordenador_value"] = $pageObject->showDBValue("min_presenca_coordenador", $data, $keylink);
			$record["min_presenca_coordenador_class"] = $pageObject->fieldClass("min_presenca_coordenador");
//	data_ultimo_score - Short Date
			$record["data_ultimo_score_value"] = $pageObject->showDBValue("data_ultimo_score", $data, $keylink);
			$record["data_ultimo_score_class"] = $pageObject->fieldClass("data_ultimo_score");
//	min_presenca_professor - 
			$record["min_presenca_professor_value"] = $pageObject->showDBValue("min_presenca_professor", $data, $keylink);
			$record["min_presenca_professor_class"] = $pageObject->fieldClass("min_presenca_professor");
//	ultimo_score - 
			$record["ultimo_score_value"] = $pageObject->showDBValue("ultimo_score", $data, $keylink);
			$record["ultimo_score_class"] = $pageObject->fieldClass("ultimo_score");
//	min_presenca_aluno - 
			$record["min_presenca_aluno_value"] = $pageObject->showDBValue("min_presenca_aluno", $data, $keylink);
			$record["min_presenca_aluno_class"] = $pageObject->fieldClass("min_presenca_aluno");
//	min_atividades - 
			$record["min_atividades_value"] = $pageObject->showDBValue("min_atividades", $data, $keylink);
			$record["min_atividades_class"] = $pageObject->fieldClass("min_atividades");
			if($col<$colsonpage)
				$record["endrecord_block"] = true;
			$record["grid_recordheader"] = true;
			$record["grid_vrecord"] = true;
			
			if($eventObj->exists("BeforeMoveNextPrint"))
				$eventObj->BeforeMoveNextPrint($data,$row,$record, $pageObject);
				
			$row["grid_record"]["data"][] = $record;
			
			if($eventObj->exists("ListFetchArray"))
				$data = $eventObj->ListFetchArray($rs, $pageObject);
			else
				$data = $cipherer->DecryptFetchedArray($rs);
				
			while($data)
			{
				if($eventObj->exists("BeforeProcessRowPrint"))
				{
					if(!$eventObj->BeforeProcessRowPrint($data, $pageObject))
					{
						if($eventObj->exists("ListFetchArray"))
							$data = $eventObj->ListFetchArray($rs, $pageObject);
						else
							$data = $cipherer->DecryptFetchedArray($rs);
						continue;
					}
				}
				break;
			}
		}
		if($col <= $colsonpage)
		{
			$row["grid_record"]["data"][count($row["grid_record"]["data"])-1]["endrecord_block"] = false;
		}
		$row["grid_rowspace"]=true;
		$row["grid_recordspace"] = array("data"=>array());
		for($i=0;$i<$colsonpage*2-1;$i++)
			$row["grid_recordspace"]["data"][]=true;
		
		$rowinfo["data"][]=$row;
		
		if($all && $records>=30)
		{
			$page=array("grid_row" =>$rowinfo);
			$page["pageno"]=$pageindex;
			$pageindex++;
			$pages[] = $page;
			$records=0;
			$rowinfo=array();
		}
		
	}
	if(count($rowinfo))
	{
		$page=array("grid_row" =>$rowinfo);
		if($all)
			$page["pageno"]=$pageindex;
		$pages[] = $page;
	}
	
	for($i=0;$i<count($pages);$i++)
	{
	 	if($i<count($pages)-1)
			$pages[$i]["begin"]="<div name=page class=printpage>";
		else
		    $pages[$i]["begin"]="<div name=page>";
			
		$pages[$i]["end"]="</div>";
	}

	$page = array();
	$page["data"] = &$pages;
	$xt->assignbyref("page",$page);

	

$strSQL = $_SESSION[$strTableName."_sql"];

$isPdfView = false;
$hasEvents = true;
if ($pageObject->pSet->isUsebuttonHandlers() || $isPdfView || $hasEvents)
{
	$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->fillSetCntrlMaps();
	$pageObject->body['end'] .= '<script>';
	$pageObject->body['end'] .= "window.controlsMap = ".my_json_encode($pageObject->controlsHTMLMap).";";
	$pageObject->body['end'] .= "window.viewControlsMap = ".my_json_encode($pageObject->viewControlsHTMLMap).";";
	$pageObject->body['end'] .= "window.settings = ".my_json_encode($pageObject->jsSettings).";";
	$pageObject->body['end'] .= '</script>';
		$pageObject->body["end"] .= "<script language=\"JavaScript\" src=\"include/runnerJS/RunnerAll.js\"></script>\r\n";
	$pageObject->addCommonJs();
}


if ($pageObject->pSet->isUsebuttonHandlers() || $isPdfView || $hasEvents)
	$pageObject->body["end"] .= "<script>".$pageObject->PrepareJS()."</script>";

$xt->assignbyref("body",$pageObject->body);
$xt->assign("grid_block",true);

$xt->assign("nome_fieldheadercolumn",true);
$xt->assign("nome_fieldheader",true);
$xt->assign("nome_fieldcolumn",true);
$xt->assign("nome_fieldfootercolumn",true);
$xt->assign("login_fieldheadercolumn",true);
$xt->assign("login_fieldheader",true);
$xt->assign("login_fieldcolumn",true);
$xt->assign("login_fieldfootercolumn",true);
$xt->assign("endereco_fieldheadercolumn",true);
$xt->assign("endereco_fieldheader",true);
$xt->assign("endereco_fieldcolumn",true);
$xt->assign("endereco_fieldfootercolumn",true);
$xt->assign("cep_fieldheadercolumn",true);
$xt->assign("cep_fieldheader",true);
$xt->assign("cep_fieldcolumn",true);
$xt->assign("cep_fieldfootercolumn",true);
$xt->assign("estado_fieldheadercolumn",true);
$xt->assign("estado_fieldheader",true);
$xt->assign("estado_fieldcolumn",true);
$xt->assign("estado_fieldfootercolumn",true);
$xt->assign("cidade_fieldheadercolumn",true);
$xt->assign("cidade_fieldheader",true);
$xt->assign("cidade_fieldcolumn",true);
$xt->assign("cidade_fieldfootercolumn",true);
$xt->assign("regional_fieldheadercolumn",true);
$xt->assign("regional_fieldheader",true);
$xt->assign("regional_fieldcolumn",true);
$xt->assign("regional_fieldfootercolumn",true);
$xt->assign("tipo_fieldheadercolumn",true);
$xt->assign("tipo_fieldheader",true);
$xt->assign("tipo_fieldcolumn",true);
$xt->assign("tipo_fieldfootercolumn",true);
$xt->assign("data_inicio_fieldheadercolumn",true);
$xt->assign("data_inicio_fieldheader",true);
$xt->assign("data_inicio_fieldcolumn",true);
$xt->assign("data_inicio_fieldfootercolumn",true);
$xt->assign("observacao_fieldheadercolumn",true);
$xt->assign("observacao_fieldheader",true);
$xt->assign("observacao_fieldcolumn",true);
$xt->assign("observacao_fieldfootercolumn",true);
$xt->assign("prepara_para_fieldheadercolumn",true);
$xt->assign("prepara_para_fieldheader",true);
$xt->assign("prepara_para_fieldcolumn",true);
$xt->assign("prepara_para_fieldfootercolumn",true);
$xt->assign("funciona_em_fieldheadercolumn",true);
$xt->assign("funciona_em_fieldheader",true);
$xt->assign("funciona_em_fieldcolumn",true);
$xt->assign("funciona_em_fieldfootercolumn",true);
$xt->assign("ativo_fieldheadercolumn",true);
$xt->assign("ativo_fieldheader",true);
$xt->assign("ativo_fieldcolumn",true);
$xt->assign("ativo_fieldfootercolumn",true);
$xt->assign("motivo_fieldheadercolumn",true);
$xt->assign("motivo_fieldheader",true);
$xt->assign("motivo_fieldcolumn",true);
$xt->assign("motivo_fieldfootercolumn",true);
$xt->assign("responsavel_fieldheadercolumn",true);
$xt->assign("responsavel_fieldheader",true);
$xt->assign("responsavel_fieldcolumn",true);
$xt->assign("responsavel_fieldfootercolumn",true);
$xt->assign("site_fieldheadercolumn",true);
$xt->assign("site_fieldheader",true);
$xt->assign("site_fieldcolumn",true);
$xt->assign("site_fieldfootercolumn",true);
$xt->assign("email_fieldheadercolumn",true);
$xt->assign("email_fieldheader",true);
$xt->assign("email_fieldcolumn",true);
$xt->assign("email_fieldfootercolumn",true);
$xt->assign("telefone_fieldheadercolumn",true);
$xt->assign("telefone_fieldheader",true);
$xt->assign("telefone_fieldcolumn",true);
$xt->assign("telefone_fieldfootercolumn",true);
$xt->assign("celular_fieldheadercolumn",true);
$xt->assign("celular_fieldheader",true);
$xt->assign("celular_fieldcolumn",true);
$xt->assign("celular_fieldfootercolumn",true);
$xt->assign("operadora_fieldheadercolumn",true);
$xt->assign("operadora_fieldheader",true);
$xt->assign("operadora_fieldcolumn",true);
$xt->assign("operadora_fieldfootercolumn",true);
$xt->assign("meta_funcionamento_fieldheadercolumn",true);
$xt->assign("meta_funcionamento_fieldheader",true);
$xt->assign("meta_funcionamento_fieldcolumn",true);
$xt->assign("meta_funcionamento_fieldfootercolumn",true);
$xt->assign("meta_alunos_fieldheadercolumn",true);
$xt->assign("meta_alunos_fieldheader",true);
$xt->assign("meta_alunos_fieldcolumn",true);
$xt->assign("meta_alunos_fieldfootercolumn",true);
$xt->assign("limite_alunos_por_coordenador_fieldheadercolumn",true);
$xt->assign("limite_alunos_por_coordenador_fieldheader",true);
$xt->assign("limite_alunos_por_coordenador_fieldcolumn",true);
$xt->assign("limite_alunos_por_coordenador_fieldfootercolumn",true);
$xt->assign("min_presenca_coordenador_fieldheadercolumn",true);
$xt->assign("min_presenca_coordenador_fieldheader",true);
$xt->assign("min_presenca_coordenador_fieldcolumn",true);
$xt->assign("min_presenca_coordenador_fieldfootercolumn",true);
$xt->assign("data_ultimo_score_fieldheadercolumn",true);
$xt->assign("data_ultimo_score_fieldheader",true);
$xt->assign("data_ultimo_score_fieldcolumn",true);
$xt->assign("data_ultimo_score_fieldfootercolumn",true);
$xt->assign("min_presenca_professor_fieldheadercolumn",true);
$xt->assign("min_presenca_professor_fieldheader",true);
$xt->assign("min_presenca_professor_fieldcolumn",true);
$xt->assign("min_presenca_professor_fieldfootercolumn",true);
$xt->assign("ultimo_score_fieldheadercolumn",true);
$xt->assign("ultimo_score_fieldheader",true);
$xt->assign("ultimo_score_fieldcolumn",true);
$xt->assign("ultimo_score_fieldfootercolumn",true);
$xt->assign("min_presenca_aluno_fieldheadercolumn",true);
$xt->assign("min_presenca_aluno_fieldheader",true);
$xt->assign("min_presenca_aluno_fieldcolumn",true);
$xt->assign("min_presenca_aluno_fieldfootercolumn",true);
$xt->assign("min_atividades_fieldheadercolumn",true);
$xt->assign("min_atividades_fieldheader",true);
$xt->assign("min_atividades_fieldcolumn",true);
$xt->assign("min_atividades_fieldfootercolumn",true);

	$record_header=array("data"=>array());
	$record_footer=array("data"=>array());
	for($i=0;$i<$colsonpage;$i++)
	{
		$rheader=array();
		$rfooter=array();
		if($i<$colsonpage-1)
		{
			$rheader["endrecordheader_block"]=true;
			$rfooter["endrecordheader_block"]=true;
		}
		$record_header["data"][]=$rheader;
		$record_footer["data"][]=$rfooter;
	}
	$xt->assignbyref("record_header",$record_header);
	$xt->assignbyref("record_footer",$record_footer);
	$xt->assign("grid_header",true);
	$xt->assign("grid_footer",true);

if($eventObj->exists("BeforeShowPrint"))
	$eventObj->BeforeShowPrint($xt,$pageObject->templatefile, $pageObject);

if(!postvalue("pdf"))
	$xt->display($pageObject->templatefile);
else
{
	$xt->load_template($pageObject->templatefile);
	$page = $xt->fetch_loaded();
	$pagewidth=postvalue("width")*1.05;
	$pageheight=postvalue("height")*1.05;
	$landscape=false;
		if($pagewidth>$pageheight)
		{
			$landscape=true;
			if($pagewidth/$pageheight<297/210)
				$pagewidth = 297/210*$pageheight;
		}
		else
		{
			if($pagewidth/$pageheight<210/297)
				$pagewidth = 210/297*$pageheight;
		}
}
?>
