function Gerar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     // Helper para url
     $urlHelper = CoreExt_View_Helper_UrlHelper::getInstance();
     $this->titulo = 'Dispensa Componente Curricular - Listagem';
     // passa todos os valores obtidos no GET para atributos do objeto
     foreach ($_GET as $var => $val) {
         $this->{$var} = $val === '' ? NULL : $val;
     }
     if (!$_GET['ref_cod_matricula']) {
         header('Location: educar_matricula_lst.php');
         die;
     }
     $this->ref_cod_matricula = $_GET['ref_cod_matricula'];
     $obj_matricula = new clsPmieducarMatricula();
     $lst_matricula = $obj_matricula->lista($this->ref_cod_matricula);
     if (is_array($lst_matricula)) {
         $det_matricula = array_shift($lst_matricula);
         $this->ref_cod_instituicao = $det_matricula['ref_cod_instituicao'];
         $this->ref_cod_escola = $det_matricula['ref_ref_cod_escola'];
         $this->ref_cod_serie = $det_matricula['ref_ref_cod_serie'];
         $obj_matricula_turma = new clsPmieducarMatriculaTurma();
         $lst_matricula_turma = $obj_matricula_turma->lista($this->ref_cod_matricula, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_serie, NULL, $this->ref_cod_escola);
         if (is_array($lst_matricula_turma)) {
             $det = array_shift($lst_matricula_turma);
             $this->ref_cod_turma = $det['ref_cod_turma'];
             $this->ref_sequencial = $det['sequencial'];
         }
     }
     $this->campoOculto('ref_cod_turma', $this->ref_cod_turma);
     $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg', 'Intranet');
     $this->addCabecalhos(array('Disciplina', 'Tipo Dispensa', 'Data Dispensa'));
     // Filtros de Foreign Keys
     $opcoes = array('' => 'Selecione');
     $objTemp = new clsPmieducarTipoDispensa();
     if ($this->ref_cod_instituicao) {
         $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao);
     } else {
         $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
     }
     if (is_array($lista) && count($lista)) {
         foreach ($lista as $registro) {
             $opcoes[$registro['cod_tipo_dispensa']] = $registro['nm_tipo'];
         }
     }
     $this->campoLista('ref_cod_tipo_dispensa', 'Motivo', $opcoes, $this->ref_cod_tipo_dispensa, '', FALSE, '', '', FALSE, FALSE);
     $this->campoOculto('ref_cod_matricula', $this->ref_cod_matricula);
     // outros Filtros
     $opcoes = array('' => 'Selecione');
     // Escola série disciplina
     $componentes = App_Model_IedFinder::getComponentesTurma($this->ref_cod_serie, $this->ref_cod_escola, $this->ref_cod_turma);
     foreach ($componentes as $componente) {
         $opcoes[$componente->id] = $componente->nome;
     }
     $this->campoLista('ref_cod_disciplina', 'Disciplina', $opcoes, $this->ref_cod_disciplina, '', FALSE, '', '', FALSE, FALSE);
     // Paginador
     $this->limite = 20;
     $this->offset = $_GET['pagina_' . $this->nome] ? $_GET['pagina_' . $this->nome] * $this->limite - $this->limite : 0;
     $obj_dispensa_disciplina = new clsPmieducarDispensaDisciplina();
     $obj_dispensa_disciplina->setOrderby('data_cadastro ASC');
     $obj_dispensa_disciplina->setLimite($this->limite, $this->offset);
     $lista = $obj_dispensa_disciplina->lista($this->ref_cod_matricula, NULL, NULL, $this->ref_cod_disciplina, NULL, NULL, $this->ref_cod_tipo_dispensa, NULL, NULL, NULL, NULL, 1);
     $total = $obj_dispensa_disciplina->_total;
     // Mapper de componente curricular
     $componenteMapper = new ComponenteCurricular_Model_ComponenteDataMapper();
     // monta a lista
     if (is_array($lista) && count($lista)) {
         foreach ($lista as $registro) {
             // muda os campos data
             $registro['data_cadastro_time'] = strtotime(substr($registro['data_cadastro'], 0, 16));
             $registro['data_cadastro_br'] = date('d/m/Y', $registro['data_cadastro_time']);
             // Tipo da dispensa
             $obj_ref_cod_tipo_dispensa = new clsPmieducarTipoDispensa($registro['ref_cod_tipo_dispensa']);
             $det_ref_cod_tipo_dispensa = $obj_ref_cod_tipo_dispensa->detalhe();
             $registro['ref_cod_tipo_dispensa'] = $det_ref_cod_tipo_dispensa['nm_tipo'];
             // Componente curricular
             $componente = $componenteMapper->find($registro['ref_cod_disciplina']);
             // Dados para a url
             $url = 'educar_dispensa_disciplina_det.php';
             $options = array('query' => array('ref_cod_matricula' => $registro['ref_cod_matricula'], 'ref_cod_serie' => $registro['ref_cod_serie'], 'ref_cod_escola' => $registro['ref_cod_escola'], 'ref_cod_disciplina' => $registro['ref_cod_disciplina']));
             $this->addLinhas(array($urlHelper->l($componente->nome, $url, $options), $urlHelper->l($registro['ref_cod_tipo_dispensa'], $url, $options), $urlHelper->l($registro['data_cadastro_br'], $url, $options)));
         }
     }
     $this->addPaginador2('educar_dispensa_disciplina_lst.php', $total, $_GET, $this->nome, $this->limite);
     $obj_permissoes = new clsPermissoes();
     if ($obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7)) {
         $this->array_botao_url[] = 'educar_dispensa_disciplina_cad.php?ref_cod_matricula=' . $this->ref_cod_matricula;
         $this->array_botao[] = 'Novo';
     }
     $this->array_botao_url[] = 'educar_matricula_det.php?cod_matricula=' . $this->ref_cod_matricula;
     $this->array_botao[] = 'Voltar';
     $this->largura = '100%';
 }
 function Gerar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     $this->titulo = "Tipo Dispensa - Listagem";
     foreach ($_GET as $var => $val) {
         // passa todos os valores obtidos no GET para atributos do objeto
         $this->{$var} = $val === "" ? null : $val;
     }
     $lista_busca = array("Tipo Dispensa");
     $obj_permissoes = new clsPermissoes();
     $nivel_usuario = $obj_permissoes->nivel_acesso($this->pessoa_logada);
     if ($nivel_usuario == 1) {
         $lista_busca[] = "Instituição";
     }
     $this->addCabecalhos($lista_busca);
     // Filtros de Foreign Keys
     include "include/pmieducar/educar_campo_lista.php";
     // outros Filtros
     $this->campoTexto("nm_tipo", "Tipo Dispensa", $this->nm_tipo, 30, 255, false);
     // Paginador
     $this->limite = 20;
     $this->offset = $_GET["pagina_{$this->nome}"] ? $_GET["pagina_{$this->nome}"] * $this->limite - $this->limite : 0;
     $obj_tipo_dispensa = new clsPmieducarTipoDispensa();
     $obj_tipo_dispensa->setOrderby("nm_tipo ASC");
     $obj_tipo_dispensa->setLimite($this->limite, $this->offset);
     $lista = $obj_tipo_dispensa->lista(null, null, null, $this->nm_tipo, null, null, null, null, null, 1, $this->ref_cod_instituicao);
     $total = $obj_tipo_dispensa->_total;
     // monta a lista
     if (is_array($lista) && count($lista)) {
         foreach ($lista as $registro) {
             if (class_exists("clsPmieducarInstituicao")) {
                 $obj_cod_instituicao = new clsPmieducarInstituicao($registro["ref_cod_instituicao"]);
                 $obj_cod_instituicao_det = $obj_cod_instituicao->detalhe();
                 $registro["ref_cod_instituicao"] = $obj_cod_instituicao_det["nm_instituicao"];
             } else {
                 $registro["ref_cod_instituicao"] = "Erro na geração";
                 echo "<!--\nErro\nClasse n&atilde;o existente: clsPmieducarInstituicao\n-->";
             }
             $lista_busca = array("<a href=\"educar_tipo_dispensa_det.php?cod_tipo_dispensa={$registro["cod_tipo_dispensa"]}\">{$registro["nm_tipo"]}</a>");
             if ($nivel_usuario == 1) {
                 $lista_busca[] = "<a href=\"educar_tipo_dispensa_det.php?cod_tipo_dispensa={$registro["cod_tipo_dispensa"]}\">{$registro["ref_cod_instituicao"]}</a>";
             }
             $this->addLinhas($lista_busca);
         }
     }
     $this->addPaginador2("educar_tipo_dispensa_lst.php", $total, $_GET, $this->nome, $this->limite);
     if ($obj_permissoes->permissao_cadastra(577, $this->pessoa_logada, 7)) {
         $this->acao = "go(\"educar_tipo_dispensa_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 tipos de dispensa"));
     $this->enviaLocalizacao($localizacao->montar());
 }
 function Gerar()
 {
     /**
      * Busca dados da matricula
      */
     $obj_ref_cod_matricula = new clsPmieducarMatricula();
     $detalhe_aluno = array_shift($obj_ref_cod_matricula->lista($this->ref_cod_matricula));
     $obj_aluno = new clsPmieducarAluno();
     $det_aluno = array_shift($det_aluno = $obj_aluno->lista($detalhe_aluno['ref_cod_aluno'], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1));
     $obj_escola = new clsPmieducarEscola($this->ref_cod_escola, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
     $det_escola = $obj_escola->detalhe();
     $this->ref_cod_instituicao = $det_escola['ref_cod_instituicao'];
     $obj_matricula_turma = new clsPmieducarMatriculaTurma();
     $lst_matricula_turma = $obj_matricula_turma->lista($this->ref_cod_matricula, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_serie, NULL, $this->ref_cod_escola);
     if (is_array($lst_matricula_turma)) {
         $det = array_shift($lst_matricula_turma);
         $this->ref_cod_turma = $det['ref_cod_turma'];
         $this->ref_sequencial = $det['sequencial'];
     }
     $this->campoRotulo('nm_aluno', 'Nome do Aluno', $det_aluno['nome_aluno']);
     if (!isset($this->ref_cod_turma)) {
         $this->mensagem = 'Para dispensar um aluno de um componente curricular, é necessário que este esteja enturmado.';
         return;
     }
     // primary keys
     $this->campoOculto('ref_cod_matricula', $this->ref_cod_matricula);
     $this->campoOculto('ref_cod_serie', $this->ref_cod_serie);
     $this->campoOculto('ref_cod_escola', $this->ref_cod_escola);
     $opcoes = array('' => 'Selecione');
     // Seleciona os componentes curriculares da turma
     try {
         $componentes = App_Model_IedFinder::getComponentesTurma($this->ref_cod_serie, $this->ref_cod_escola, $this->ref_cod_turma);
     } catch (App_Model_Exception $e) {
         $this->mensagem = $e->getMessage();
         return;
     }
     foreach ($componentes as $componente) {
         $opcoes[$componente->id] = $componente->nome;
     }
     if ($this->ref_cod_disciplina) {
         $this->campoRotulo('nm_disciplina', 'Disciplina', $opcoes[$this->ref_cod_disciplina]);
         $this->campoOculto('ref_cod_disciplina', $this->ref_cod_disciplina);
     } else {
         $this->campoLista('ref_cod_disciplina', 'Disciplina', $opcoes, $this->ref_cod_disciplina);
     }
     $opcoes = array('' => 'Selecione');
     $objTemp = new clsPmieducarTipoDispensa();
     if ($this->ref_cod_instituicao) {
         $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao);
     } else {
         $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
     }
     if (is_array($lista) && count($lista)) {
         foreach ($lista as $registro) {
             $opcoes[$registro['cod_tipo_dispensa']] = $registro['nm_tipo'];
         }
     }
     $this->campoLista('ref_cod_tipo_dispensa', 'Tipo Dispensa', $opcoes, $this->ref_cod_tipo_dispensa);
     $this->campoMemo('observacao', 'Observação', $this->observacao, 60, 10, FALSE);
 }