function renderHTML()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     $obj_permissoes = new clsPermissoes();
     if ($obj_permissoes->nivel_acesso($this->pessoa_logada) > 7) {
         $retorno .= '
     <table width="100%" height="40%" cellspacing="1" cellpadding="2" border="0" class="tablelistagem">
       <tbody>
         <tr>
           <td colspan="2" valig="center" height="50">
             <center class="formdktd">Usuário sem permissão para acessar esta página</center>
           </td>
         </tr>
       </tbody>
     </table>';
         return $retorno;
     }
     $retorno .= '
   <table width="100%" cellspacing="1" cellpadding="2" border="0" class="tablelistagem">
     <tbody>';
     if ($_POST) {
         $this->ref_cod_turma = $_POST['ref_cod_turma'] ? $_POST['ref_cod_turma'] : NULL;
         $this->ref_cod_serie = $_POST['ref_cod_serie'] ? $_POST['ref_cod_serie'] : NULL;
         $this->ref_cod_curso = $_POST['ref_cod_curso'] ? $_POST['ref_cod_curso'] : NULL;
         $this->ref_cod_escola = $_POST['ref_cod_escola'] ? $_POST['ref_cod_escola'] : NULL;
         $this->ref_cod_instituicao = $_POST['ref_cod_instituicao'] ? $_POST['ref_cod_instituicao'] : NULL;
         $this->busca = $_GET['busca'] ? $_GET['busca'] : NULL;
     } else {
         if ($_GET) {
             // Passa todos os valores obtidos no GET para atributos do objeto
             foreach ($_GET as $var => $val) {
                 $this->{$var} = $val === '' ? NULL : $val;
             }
         }
     }
     $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada);
     if (!$this->ref_cod_escola) {
         $this->ref_cod_escola = $obj_permissoes->getEscola($this->pessoa_logada);
     }
     if (!is_numeric($this->ref_cod_instituicao)) {
         $this->ref_cod_instituicao = $obj_permissoes->getInstituicao($this->pessoa_logada);
     }
     // Componente curricular
     $componenteMapper = new ComponenteCurricular_Model_ComponenteDataMapper();
     $obrigatorio = FALSE;
     $get_instituicao = TRUE;
     $get_escola = TRUE;
     $get_curso = TRUE;
     $get_serie = TRUE;
     $get_turma = TRUE;
     include 'educar_quadro_horarios_pesquisas.php';
     if ($this->busca == 'S') {
         if (is_numeric($this->ref_cod_turma)) {
             $obj_turma = new clsPmieducarTurma($this->ref_cod_turma);
             $det_turma = $obj_turma->detalhe();
             $obj_quadro = new clsPmieducarQuadroHorario(NULL, NULL, NULL, $this->ref_cod_turma, NULL, NULL, 1);
             $det_quadro = $obj_quadro->detalhe();
             if (is_array($det_quadro)) {
                 $quadro_horario = "<table class='calendar' cellspacing='0' cellpadding='0' border='0'><tr><td class='cal_esq' >&nbsp;</td><td background='imagens/i-educar/cal_bg.gif' width='100%' class='mes'>{$det_turma["nm_turma"]}</td><td align='right' class='cal_dir'>&nbsp;</td></tr><tr><td colspan='3' class='bordaM' style='border-bottom: 1px solid #8A959B;'  align='center'><table cellspacing='0' cellpadding='0'  border='0' ><tr class='header'><td style='border-right: 1px dotted #FFFFFF;width: 100px;'>DOM</td><td style='border-right: 1px dotted #FFFFFF;width: 100px;'>SEG</td><td style='border-right: 1px dotted #FFFFFF;width: 100px;'>TER</td><td style='border-right: 1px dotted #FFFFFF;width: 100px;'>QUA</td><td style='border-right: 1px dotted #FFFFFF;width: 100px;'>QUI</td><td style='border-right: 1px dotted #FFFFFF;width: 100px;'>SEX</td><td style='width: 100px;'>SAB</td></tr>";
                 $texto = '<tr>';
                 for ($c = 1; $c <= 7; $c++) {
                     $obj_horarios = new clsPmieducarQuadroHorarioHorarios();
                     $resultado = $obj_horarios->retornaHorario($this->ref_cod_instituicao, $this->ref_cod_escola, $this->ref_cod_serie, $this->ref_cod_turma, $c);
                     $texto .= "<td valign=top align='center' width='100' style='cursor: pointer; ' onclick='envia( this, {$this->ref_cod_turma}, {$this->ref_cod_serie}, {$this->ref_cod_curso}, {$this->ref_cod_escola}, {$this->ref_cod_instituicao}, {$det_quadro["cod_quadro_horario"]}, {$c} );'>";
                     if (is_array($resultado)) {
                         foreach ($resultado as $registro) {
                             // Componente curricular
                             $componente = $componenteMapper->find($registro['ref_cod_disciplina']);
                             // Servidor
                             $obj_servidor = new clsPmieducarServidor();
                             $det_servidor = array_shift($obj_servidor->lista($registro['ref_servidor'], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,  NULL, NULL, NULL, NULL, NULL, TRUE));
                             $det_servidor['nome'] = array_shift(explode(' ', $det_servidor['nome']));
                             //$texto .= "<div  style='text-align: center;background-color: #F6F6F6;font-size: 11px; width: 100px; margin: 3px; border: 1px solid #CCCCCC; padding:5px; '>". substr($registro['hora_inicial'], 0, 5) . ' - ' . substr($registro['hora_final'], 0, 5) . " <br> {$componente->abreviatura} <br> {$det_servidor["nome"]}</div>";
                             $detalhes = sprintf("%s - %s<br />%s<br />%s", substr($registro['hora_inicial'], 0, 5), substr($registro['hora_final'], 0, 5), $componente->abreviatura, $det_servidor['nome']);
                             $texto .= sprintf('<div style="text-align: center; background-color: #F6F6F6; font-size: 11px; width: 100px; margin: 3px; border: 1px solid #CCCCCC; padding:5px;">%s</div>', $detalhes);
                         }
                     } else {
                         $texto .= "<div  style='text-align: center;background-color: #F6F6F6;font-size: 11px; width: 100px; margin: 3px; border: 1px solid #CCCCCC; padding:5px; height: 85%;'></div>";
                     }
                     $texto .= '</td>';
                 }
                 $texto .= '<tr><td colspan="7">&nbsp;</td></tr>';
                 $quadro_horario .= $texto;
                 $quadro_horario .= '</table></td></tr></table>';
                 $retorno .= "<tr><td colspan='2' ><center><b></b>{$quadro_horario}</center></td></tr>";
             } else {
                 $retorno .= "<tr><td colspan='2' ><b><center>N&atilde;o existe nenhum quadro de hor&aacute;rio cadastrado para esta turma.</center></b></td></tr>";
             }
         }
     }
     if ($obj_permissoes->permissao_cadastra(641, $this->pessoa_logada, 7)) {
         $retorno .= "<tr><td>&nbsp;</td></tr><tr>\n            <td align=\"center\" colspan=\"2\">";
         if (!$det_quadro) {
             $retorno .= "<input type=\"button\" value=\"Novo Quadro de Hor&aacute;rios\" onclick=\"window.location='educar_quadro_horario_cad.php?ref_cod_turma={$this->ref_cod_turma}&ref_cod_serie={$this->ref_cod_serie}&ref_cod_curso={$this->ref_cod_curso}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao};'\" class=\"botaolistagem\"/>";
         } else {
             if ($obj_permissoes->permissao_excluir(641, $this->pessoa_logada, 7)) {
                 $retorno .= "<input type=\"button\" value=\"Excluir Quadro de Hor&aacute;rios\" onclick=\"window.location='educar_quadro_horario_cad.php?ref_cod_turma={$this->ref_cod_turma}&ref_cod_serie={$this->ref_cod_serie}&ref_cod_curso={$this->ref_cod_curso}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao}&ref_cod_quadro_horario={$det_quadro["cod_quadro_horario"]}'\" class=\"botaolistagem\"/>";
             }
         }
         $retorno .= "</td>\n            </tr>";
     }
     $retorno .= '</tbody>
   </table>';
     return $retorno;
 }
 function Gerar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     $this->titulo = 'Servidor - Listagem';
     // passa todos os valores obtidos no GET para atributos do objeto
     foreach ($_GET as $var => $val) {
         $this->{$var} = $val === '' ? NULL : $val;
     }
     $this->addCabecalhos(array('Nome do Servidor', 'Matrícula', 'Instituição'));
     $get_escola = TRUE;
     $obrigatorio = TRUE;
     $exibe_nm_escola = TRUE;
     include 'include/pmieducar/educar_campo_lista.php';
     $opcoes = array('' => 'Pesquise o funcionario clicando na lupa ao lado');
     if ($this->cod_servidor) {
         $objTemp = new clsFuncionario($this->cod_servidor);
         $detalhe = $objTemp->detalhe();
         $detalhe = $detalhe['idpes']->detalhe();
         $opcoes[$detalhe['idpes']] = $detalhe['nome'];
     }
     $parametros = new clsParametrosPesquisas();
     $parametros->setSubmit(0);
     $parametros->adicionaCampoSelect('cod_servidor', 'ref_cod_pessoa_fj', 'nome');
     $this->campoListaPesq('cod_servidor', 'Servidor', $opcoes, $this->cod_servidor, 'pesquisa_funcionario_lst.php', '', FALSE, '', '', NULL, NULL, '', FALSE, $parametros->serializaCampos() . '&com_matricula=false', TRUE);
     // Paginador
     $this->limite = 20;
     $this->offset = $_GET['pagina_' . $this->nome] ? $_GET['pagina_' . $this->nome] * $this->limite - $this->limite : 0;
     $obj_servidor = new clsPmieducarServidor();
     $obj_servidor->setOrderby('carga_horaria ASC');
     $obj_servidor->setLimite($this->limite, $this->offset);
     $lista = $obj_servidor->lista($this->cod_servidor, $this->ref_cod_deficiencia, $this->ref_idesco, $this->carga_horaria, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao, NULL, NULL, NULL, NULL, NULL, NULL, TRUE, NULL, NULL, NULL, NULL, !isset($_GET['busca']) ? $this->ref_cod_escola : NULL, NULL, NULL, NULL, NULL, !isset($_GET['busca']) ? 1 : NULL);
     $total = $obj_servidor->_total;
     // UrlHelper
     $url = CoreExt_View_Helper_UrlHelper::getInstance();
     // Monta a lista
     if (is_array($lista) && count($lista)) {
         foreach ($lista as $registro) {
             // Pega detalhes de foreign_keys
             if (class_exists('clsPmieducarInstituicao')) {
                 $obj_ref_cod_instituicao = new clsPmieducarInstituicao($registro['ref_cod_instituicao']);
                 $det_ref_cod_instituicao = $obj_ref_cod_instituicao->detalhe();
                 $registro['ref_cod_instituicao'] = $det_ref_cod_instituicao['nm_instituicao'];
             } else {
                 $registro['ref_cod_instituicao'] = 'Erro na geração';
             }
             if (class_exists('clsFuncionario')) {
                 $obj_cod_servidor = new clsFuncionario($registro['cod_servidor']);
                 $det_cod_servidor = $obj_cod_servidor->detalhe();
                 $registro['matricula'] = $det_cod_servidor['matricula'];
                 $det_cod_servidor = $det_cod_servidor['idpes']->detalhe();
                 $registro['nome'] = $det_cod_servidor['nome'];
             } else {
                 $registro['cod_servidor'] = 'Erro na geracao';
             }
             $path = 'educar_servidor_det.php';
             $options = array('query' => array('cod_servidor' => $registro['cod_servidor'], 'ref_cod_instituicao' => $det_ref_cod_instituicao['cod_instituicao']));
             $this->addLinhas(array($url->l($registro['nome'], $path, $options), $url->l($registro['matricula'], $path, $options), $url->l($registro['ref_cod_instituicao'], $path, $options)));
         }
     }
     $this->addPaginador2('educar_servidor_lst.php', $total, $_GET, $this->nome, $this->limite);
     $obj_permissoes = new clsPermissoes();
     if ($obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7)) {
         $this->acao = 'go("educar_servidor_cad.php")';
         $this->nome_acao = 'Novo';
     }
     $this->largura = '100%';
     $localizacao = new LocalizacaoSistema();
     $localizacao->entradaCaminhos(array($_SERVER['SERVER_NAME'] . "/intranet" => "In&iacute;cio", "educar_index.php" => "i-Educar - Escola", "" => "Listagem de servidores"));
     $this->enviaLocalizacao($localizacao->montar());
 }
 function Gerar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     $_SESSION['campo1'] = $_GET['campo1'] ? $_GET['campo1'] : $_SESSION['campo1'];
     $_SESSION['campo2'] = $_GET['campo2'] ? $_GET['campo2'] : $_SESSION['campo2'];
     $_SESSION['dia_semana'] = isset($_GET['dia_semana']) ? $_GET['dia_semana'] : $_SESSION['dia_semana'];
     $_SESSION['hora_inicial'] = $_GET['hora_inicial'] ? $_GET['hora_inicial'] : $_SESSION['hora_inicial'];
     $_SESSION['hora_final'] = $_GET['hora_final'] ? $_GET['hora_final'] : $_SESSION['hora_final'];
     $_SESSION['professor'] = $_GET['professor'] ? $_GET['professor'] : $_SESSION['professor'];
     $_SESSION['horario'] = $_GET['horario'] ? $_GET['horario'] : $_SESSION['horario'];
     $_SESSION['ref_cod_escola'] = $_GET['ref_cod_escola'] ? $_GET['ref_cod_escola'] : $_SESSION['ref_cod_escola'];
     $_SESSION['min_mat'] = $_GET['min_mat'] ? $_GET['min_mat'] : $_SESSION['min_mat'];
     $_SESSION['min_ves'] = $_GET['min_ves'] ? $_GET['min_ves'] : $_SESSION['min_ves'];
     $_SESSION['min_not'] = $_GET['min_not'] ? $_GET['min_not'] : $_SESSION['min_not'];
     $_SESSION['ref_cod_disciplina'] = $_GET['ref_cod_disciplina'] ? $_GET['ref_cod_disciplina'] : $_SESSION['ref_cod_disciplina'];
     $_SESSION['ref_cod_curso'] = $_GET['ref_cod_curso'] ? $_GET['ref_cod_curso'] : $_SESSION['ref_cod_curso'];
     /**
      * Controle para cálculo de horas
      */
     $_SESSION['identificador'] = $_GET['identificador'] ? $_GET['identificador'] : $_SESSION['identificador'];
     if (isset($_GET['lst_matriculas'])) {
         $_SESSION['lst_matriculas'] = $_GET['lst_matriculas'] ? $_GET['lst_matriculas'] : $_SESSION['lst_matriculas'];
     }
     if (!isset($_GET['tipo'])) {
         $_SESSION['setAllField1'] = $_SESSION['setAllField2'] = $_SESSION['tipo'] = '';
     }
     $this->ref_cod_instituicao = $_SESSION['ref_cod_instituicao'] = $_GET['ref_cod_instituicao'] ? $_GET['ref_cod_instituicao'] : $_SESSION['ref_cod_instituicao'];
     $this->ref_cod_servidor = $_SESSION['ref_cod_servidor'] = $_GET['ref_cod_servidor'] ? $_GET['ref_cod_servidor'] : $_SESSION['ref_cod_servidor'];
     $this->professor = $_SESSION['professor'] = $_GET['professor'] ? $_GET['professor'] : $_SESSION['professor'];
     $this->horario = $_SESSION['horario'] = $_GET['horario'] ? $_GET['horario'] : $_SESSION['horario'];
     $this->ref_cod_escola = $_GET['ref_cod_escola'] ? $_GET['ref_cod_escola'] : $_SESSION['ref_cod_escola'];
     $this->min_mat = $_SESSION['min_mat'] = $_GET['min_mat'] ? $_GET['min_mat'] : $_SESSION['min_mat'];
     $this->min_ves = $_SESSION['min_ves'] = $_GET['min_ves'] ? $_GET['min_ves'] : $_SESSION['min_ves'];
     $this->min_not = $_SESSION['min_not'] = $_GET['min_not'] ? $_GET['min_not'] : $_SESSION['min_not'];
     $this->ref_cod_disciplina = $_SESSION['ref_cod_disciplina'] = $_GET['ref_cod_disciplina'] ? $_GET['ref_cod_disciplina'] : $_SESSION['ref_cod_disciplina'];
     $this->ref_cod_curso = $_SESSION['ref_cod_curso'] = $_GET['ref_cod_curso'] ? $_GET['ref_cod_curso'] : $_SESSION['ref_cod_curso'];
     $this->identificador = $_SESSION['identificador'] = $_GET['identificador'] ? $_GET['identificador'] : $_SESSION['identificador'];
     if (isset($_GET['lst_matriculas']) && isset($_SESSION['lst_matriculas'])) {
         $this->lst_matriculas = $_GET['lst_matriculas'] ? $_GET['lst_matriculas'] : $_SESSION['lst_matriculas'];
     }
     $_SESSION['tipo'] = $_GET['tipo'] ? $_GET['tipo'] : $_SESSION['tipo'];
     session_write_close();
     $this->titulo = 'Servidores P&uacute;blicos - Listagem';
     // Passa todos os valores obtidos no GET para atributos do objeto
     foreach ($_GET as $var => $val) {
         $this->{$var} = $val === '' ? NULL : $val;
     }
     if (isset($this->lst_matriculas)) {
         $this->lst_matriculas = urldecode($this->lst_matriculas);
     }
     $string1 = $this->min_mat - floor($this->min_mat / 60) * 60;
     $string1 = str_repeat(0, 2 - strlen($string1)) . $string1;
     $string2 = floor($this->min_mat / 60);
     $string2 = str_repeat(0, 2 - strlen($string2)) . $string2;
     $hr_mat = $string2 . ':' . $string1;
     $string1 = $this->min_ves - floor($this->min_ves / 60) * 60;
     $string1 = str_repeat(0, 2 - strlen($string1)) . $string1;
     $string2 = floor($this->min_ves / 60);
     $string2 = str_repeat(0, 2 - strlen($string2)) . $string2;
     $hr_ves = $string2 . ':' . $string1;
     $string1 = $this->min_not - floor($this->min_not / 60) * 60;
     $string1 = str_repeat(0, 2 - strlen($string1)) . $string1;
     $string2 = floor($this->min_not / 60);
     $string2 = str_repeat(0, 2 - strlen($string2)) . $string2;
     $hr_not = $string2 . ':' . $string1;
     $hora_inicial_ = explode(':', $_SESSION['hora_inicial']);
     $hora_final_ = explode(':', $_SESSION['hora_final']);
     $horas_ini = sprintf('%02d', (int) abs($hora_final_[0]) - abs($hora_inicial_[0]));
     $minutos_ini = sprintf('%02d', (int) abs($hora_final_[1]) - abs($hora_inicial_[1]));
     $h_m_ini = $hora_inicial_[0] * 60 + $hora_inicial_[1];
     $h_m_fim = $hora_final_[0] * 60 + $hora_final_[1];
     if ($h_m_ini >= 480 && $h_m_ini <= 720) {
         $this->matutino = TRUE;
         if ($h_m_fim >= 721 && $h_m_fim <= 1080) {
             $this->vespertino = TRUE;
         } elseif ($h_m_fim >= 1801 && $h_m_fim <= 1439 || $h_m_fim == 0) {
             $this->noturno = TRUE;
         }
     } elseif ($h_m_ini >= 721 && $h_m_ini <= 1080) {
         $this->vespertino = TRUE;
         if ($h_m_fim >= 1081 && $h_m_fim <= 1439) {
             $this->noturno = TRUE;
         }
     } elseif ($h_m_ini >= 1081 && $h_m_ini <= 1439 || $h_m_ini == 0) {
         $this->noturno = TRUE;
     }
     $this->addCabecalhos(array('Nome do Servidor', 'Matr&iacute;cula', 'Institui&ccedil;&atilde;o'));
     $this->campoTexto('nome_servidor', 'Nome Servidor', $this->nome_servidor, 30, 255, FALSE);
     $this->campoOculto('tipo', $_GET['tipo']);
     // Paginador
     $this->limite = 20;
     $this->offset = $_GET['pagina_{$this->nome}'] ? $_GET['pagina_{$this->nome}'] * $this->limite - $this->limite : 0;
     $obj_servidor = new clsPmieducarServidor();
     $obj_servidor->setOrderby('carga_horaria ASC');
     $obj_servidor->setLimite($this->limite, $this->offset);
     if ($_SESSION['dia_semana'] && $_SESSION['hora_inicial'] && $_SESSION['hora_final']) {
         $array_hora = array($_SESSION['dia_semana'], $_SESSION['hora_inicial'], $_SESSION['hora_final']);
     }
     // Marca a disciplina como NULL se não for informada, restringindo a busca
     // aos professores e não selecionar aqueles em que o curso não seja
     // globalizado e sem disciplinas cadastradas
     $this->ref_cod_disciplina = $this->ref_cod_disciplina ? $this->ref_cod_disciplina : NULL;
     // Passa NULL para $alocacao_escola_instituicao senão o seu filtro anula
     // um anterior (referente a selecionar somente servidores não alocados),
     // selecionando apenas servidores alocados na instituição
     $lista = $obj_servidor->lista(NULL, $this->ref_cod_deficiencia, $this->ref_idesco, $this->carga_horaria, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao, $_SESSION['tipo'], $array_hora, $this->ref_cod_servidor, $this->nome_servidor, $this->professor, $this->horario, FALSE, $this->lst_matriculas, $this->matutino, $this->vespertino, $this->noturno, $this->ref_cod_escola, $hr_mat, $hr_ves, $hr_not, $_SESSION['dia_semana'], $this->ref_cod_escola, $this->identificador, $this->ref_cod_curso, $this->ref_cod_disciplina);
     // Se for uma listagem de professores, recupera as disciplinas dadas para
     // comparação com a de outros professores (somente quando a busca é para
     // substituição de servidores)
     $disciplinas = array();
     if ('true' == $this->professor) {
         $disciplinas = $obj_servidor->getServidorDisciplinasQuadroHorarioHorarios($this->ref_cod_servidor, $this->ref_cod_instituicao);
     }
     $total = $obj_servidor->_total;
     // pega detalhes de foreign_keys
     if (class_exists('clsPmieducarInstituicao')) {
         $obj_ref_cod_instituicao = new clsPmieducarInstituicao($lista[0]["ref_cod_instituicao"]);
         $det_ref_cod_instituicao = $obj_ref_cod_instituicao->detalhe();
         $nm_instituicao = $det_ref_cod_instituicao["nm_instituicao"];
     }
     // monta a lista
     if (is_array($lista) && count($lista)) {
         foreach ($lista as $registro) {
             if (class_exists('clsFuncionario')) {
                 $obj_cod_servidor = new clsFuncionario($registro['cod_servidor']);
                 $det_cod_servidor = $obj_cod_servidor->detalhe();
                 $registro['matricula'] = $det_cod_servidor['matricula'];
                 // Se servidor for professor, verifica se possui as mesmas
                 // disciplinas do servidor a ser substituido (este passo somente é
                 // executado ao buscar um servidor substituto)
                 if ($this->professor == 'true') {
                     $disciplinasSubstituto = clsPmieducarServidor::getServidorDisciplinas($registro['cod_servidor'], $this->ref_cod_instituicao);
                     // Se os arrays diferirem, passa para o próximo resultado
                     if ($disciplinasSubstituto != $disciplinas) {
                         continue;
                     }
                 }
             } else {
                 $registro["cod_servidor"] = "Erro na geracao";
                 echo "<!--\nErro\nClasse nao existente: clsFuncionario\n-->";
             }
             if ($_SESSION['tipo']) {
                 if (is_string($_SESSION['campo1']) && is_string($_SESSION['campo2'])) {
                     if (is_string($_SESSION['horario'])) {
                         $script = " onclick=\"addVal1('{$_SESSION['campo1']}','{$registro['nome']}','{$registro['cod_servidor']}'); addVal1('{$_SESSION['campo2']}','{$registro['cod_servidor']}','{$registro['nome']}'); {$setAll} fecha();\"";
                     } else {
                         $script = " onclick=\"addVal1('{$_SESSION['campo1']}','{$registro['cod_servidor']}', null); addVal1('{$_SESSION['campo2']}','{$registro['nome']}', null); {$setAll} fecha();\"";
                     }
                 } elseif (is_string($_SESSION['campo1'])) {
                     $script = " onclick=\"addVal1('{$_SESSION['campo1']}','{$registro['cod_servidor']}','{$registro['nome']}'); {$setAll} fecha();\"";
                 }
             } else {
                 if (is_string($_SESSION['campo1']) && is_string($_SESSION['campo2'])) {
                     $script = " onclick=\"addVal1('{$_SESSION['campo1']}','{$registro['cod_servidor']}','{$registro['nome']}'); addVal1('{$_SESSION['campo2']}','{$registro['nome']}','{$registro['cod_servidor']}'); {$setAll} fecha();\"";
                 } elseif (is_string($_SESSION['campo2'])) {
                     $script = " onclick=\"addVal1('{$_SESSION['campo2']}','{$registro['cod_servidor']}','{$registro['nome']}'); {$setAll} fecha();\"";
                 } elseif (is_string($_SESSION['campo1'])) {
                     $script = " onclick=\"addVal1('{$_SESSION['campo1']}','{$registro['cod_servidor']}','{$registro['nome']}'); {$setAll} fecha();\"";
                 }
             }
             $this->addLinhas(array("<a href=\"javascript:void(0);\" {$script}>{$registro["nome"]}</a>", "<a href=\"javascript:void(0);\" {$script}>{$registro["matricula"]}</a>", "<a href=\"javascript:void(0);\" {$script}>{$nm_instituicao}</a>"));
         }
     }
     $this->addPaginador2('educar_pesquisa_servidor_lst.php', $total, $_GET, $this->nome, $this->limite);
     $obj_permissoes = new clsPermissoes();
     $this->largura = '100%';
 }
 function renderHTML()
 {
     if ($_POST) {
         foreach ($_POST as $key => $value) {
             $this->{$key} = $value;
         }
     }
     if ($this->ref_ref_cod_serie) {
         $this->ref_cod_serie = $this->ref_ref_cod_serie;
     }
     if ($this->ref_cod_escola) {
         $obj_escola = new clsPmieducarEscola($this->ref_cod_escola);
         $det_escola = $obj_escola->detalhe();
         $this->nm_escola = $det_escola['nome'];
     }
     $obj_instituicao = new clsPmieducarInstituicao($this->ref_cod_instituicao);
     $det_instituicao = $obj_instituicao->detalhe();
     $this->nm_instituicao = $det_instituicao['nm_instituicao'];
     $fonte = 'arial';
     $corTexto = '#000000';
     $obj_curso = new clsPmieducarCurso();
     $obj_curso->setOrderby('nm_curso');
     $lst_curso = $obj_curso->lista($this->ref_cod_curso, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, $this->ref_cod_instituicao);
     if ($lst_curso) {
         foreach ($lst_curso as $curso) {
             $obj_serie = new clsPmieducarSerie();
             $obj_serie->setOrderby('nm_serie');
             $lst_serie = $obj_serie->lista($this->ref_cod_serie, NULL, NULL, $curso['cod_curso'], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao, NULL, NULL, NULL, $this->ref_cod_escola);
             $quadro_horario = 0;
             if ($lst_serie) {
                 foreach ($lst_serie as $serie) {
                     $obj_turma = new clsPmieducarTurma();
                     $obj_turma->setOrderby('nm_turma');
                     $lst_turma = $obj_turma->lista($this->ref_cod_turma, NULL, NULL, $serie['cod_serie'], $this->ref_cod_escola, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $curso['cod_curso'], $this->ref_cod_instituicao);
                     if ($lst_turma) {
                         foreach ($lst_turma as $turma) {
                             $obj_quadro = new clsPmieducarQuadroHorario(NULL, NULL, NULL, $turma['cod_turma'], NULL, NULL, 1);
                             $det_quadro = $obj_quadro->detalhe();
                             if ($det_quadro) {
                                 if (!$this->pdf) {
                                     $this->pdf = new clsPDF('Quadro Horarios', 'Quadro Horarios', 'A4', '', FALSE, FALSE);
                                 }
                                 if ($quadro_horario % 3 == 0) {
                                     $this->page_y = 15;
                                     $this->pdf->OpenPage();
                                     $this->addCabecalho();
                                     $quadro_horario = 0;
                                 }
                                 $this->pdf->escreve_relativo($turma['nm_turma'] . ' -  ' . $serie['nm_serie'], 20, $this->page_y - 7, 550, 20, $fonte, 11, $corTexto, 'center');
                                 $this->page_y += 10;
                                 $this->pdf->quadrado_relativo(35, $this->page_y, 525, 20, 0.3, '#777777', '#777777');
                                 $inicio_x = 35;
                                 for ($dia_semana = 1; $dia_semana <= 7; $dia_semana++) {
                                     $this->pdf->linha_relativa($inicio_x, $this->page_y, 0, 20);
                                     $this->pdf->escreve_relativo($this->array_dias_semana[$dia_semana], $inicio_x, $this->page_y + 3, 75, 20, $fonte, 11, $corTexto, 'center');
                                     $inicio_x += 75;
                                 }
                                 $this->page_y += 20;
                                 $inicio_y = $this->page_y;
                                 $inicio_x = 35;
                                 $this->pdf->quadrado_relativo($inicio_x, $this->page_y, 525, 200, 0.3);
                                 for ($dia_semana = 1; $dia_semana <= 7; $dia_semana++) {
                                     $obj_horarios = new clsPmieducarQuadroHorarioHorarios();
                                     $resultado = $obj_horarios->retornaHorario($this->ref_cod_instituicao, $this->ref_cod_escola, $serie['cod_serie'], $turma['cod_turma'], $dia_semana);
                                     if (is_array($resultado)) {
                                         foreach ($resultado as $registro) {
                                             $this->pdf->quadrado_relativo($inicio_x, $this->page_y, 75, 50, 0.3);
                                             $componenteMapper = new ComponenteCurricular_Model_ComponenteDataMapper();
                                             $componente = $componenteMapper->find($registro['ref_cod_disciplina']);
                                             $obj_servidor = new clsPmieducarServidor();
                                             $det_servidor = array_shift($obj_servidor->lista($registro['ref_servidor'], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TRUE));
                                             $det_servidor['nome'] = array_shift(explode(' ', $det_servidor['nome']));
                                             $texto = sprintf("%s - %s\n%s\n%s", substr($registro['hora_inicial'], 0, 5), substr($registro["hora_final"], 0, 5), $componente->abreviatura, $det_servidor['nome']);
                                             $this->pdf->escreve_relativo($texto, $inicio_x, $this->page_y + 12, 75, 50, $fonte, 10, $corTexto, 'center');
                                             $this->page_y += 50;
                                         }
                                     }
                                     $inicio_x += 75;
                                     $this->page_y = $inicio_y;
                                 }
                                 $this->page_y += 220;
                             }
                             $quadro_horario++;
                         }
                     }
                 }
             }
         }
     }
     if ($this->pdf) {
         $this->pdf->CloseFile();
         $this->get_link = $this->pdf->GetLink();
     } else {
         echo '
     <script>
       alert("A(s) turma(s) não possui(em) quadro de horário(s).");
       window.parent.fechaExpansivel("div_dinamico_" + (window.parent.DOM_divs.length-1));
     </script>';
         return;
     }
     echo sprintf('
   <script>
     window.onload=function()
     {
       parent.EscondeDiv("LoadImprimir");
       window.location="download.php?filename=%s"
     }
   </script>', $this->get_link);
     echo sprintf('
   <html>
     <center>Se o download não iniciar automaticamente <br />
     <a target="blank" href="%s" style="font-size: 16px; color: #000000; text-decoration: underline;">clique aqui!</a><br /><br />
     <span style="font-size: 10px;">Para visualizar os arquivos PDF, é necessário instalar o Adobe Acrobat Reader.<br />
       Clique na Imagem para Baixar o instalador<br /><br />
       <a href="http://www.adobe.com.br/products/acrobat/readstep2.html" target="new"><br><img src="imagens/acrobat.gif" width="88" height="31" border="0"></a>
     </span>
   </center>', $this->get_link);
 }