Commit fc43375ef62a16e9e4a9e964a72ac6e96740fcc0

Authored by Eriksen Costa Paixão
1 parent 97850016
Exists in master

Corrigido bug na Emissão de documento de reserva de vaga que não criava o PDF (f…

…altava receber parâmetro $_GET identificador)

ieducar/intranet/educar_relatorio_solicitacao_transferencia.php
1 <?php 1 <?php
2 2
3 -/* 3 +/**
4 * i-Educar - Sistema de gestão escolar 4 * i-Educar - Sistema de gestão escolar
5 * 5 *
6 * Copyright (C) 2006 Prefeitura Municipal de Itajaí 6 * Copyright (C) 2006 Prefeitura Municipal de Itajaí
@@ -19,15 +19,12 @@ @@ -19,15 +19,12 @@
19 * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto 19 * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
20 * com este programa; se não, escreva para a Free Software Foundation, Inc., no 20 * com este programa; se não, escreva para a Free Software Foundation, Inc., no
21 * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. 21 * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
22 - */  
23 -  
24 -/**  
25 - * Reserva de vaga.  
26 * 22 *
27 * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> 23 * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
28 * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL 24 * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL
29 * @package Core 25 * @package Core
30 - * @subpackage Relatório 26 + * @subpackage Relatorio
  27 + * @subpackage ReservaVaga
31 * @since Arquivo disponível desde a versão 1.0.0 28 * @since Arquivo disponível desde a versão 1.0.0
32 * @version $Id$ 29 * @version $Id$
33 */ 30 */
@@ -41,175 +38,190 @@ require_once &#39;include/clsPDF.inc.php&#39;; @@ -41,175 +38,190 @@ require_once &#39;include/clsPDF.inc.php&#39;;
41 38
42 class clsIndexBase extends clsBase 39 class clsIndexBase extends clsBase
43 { 40 {
44 - function Formular()  
45 - {  
46 - $this->SetTitulo( "{$this->_instituicao} i-Educar - Diário de Classe - Avalia&ccedil;&otilde;es" );  
47 - $this->processoAp = "670";  
48 - $this->renderMenu = false;  
49 - $this->renderMenuSuspenso = false;  
50 - } 41 + function Formular() {
  42 + $this->SetTitulo($this->_instituicao . ' i-Educar - Diário de Classe - Avalia&ccedil;&otilde;es');
  43 + $this->processoAp = '670';
  44 + $this->renderMenu = FALSE;
  45 + $this->renderMenuSuspenso = FALSE;
  46 + }
51 } 47 }
52 48
  49 +/**
  50 + * Cria um documento PDF com o atesto de reserva de vaga.
  51 + *
  52 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  53 + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL
  54 + * @package Core
  55 + * @subpackage Relatorio
  56 + * @subpackage ReservaVaga
  57 + * @since Classe disponível desde a versão 1.0.0
  58 + * @version $Id$
  59 + */
53 class indice extends clsCadastro 60 class indice extends clsCadastro
54 { 61 {
  62 + /**
  63 + * Referência a usuário da sessão
  64 + * @var int
  65 + */
  66 + var $pessoa_logada;
  67 +
  68 + // Atributos para referências a tabelas relacionadas.
  69 + var
  70 + $ref_cod_instituicao,
  71 + $ref_cod_escola,
  72 + $ref_cod_serie,
  73 + $ref_cod_turma,
  74 + $ref_cod_matricula;
  75 +
  76 + // Atributos utilizados na criação do documento.
  77 + var
  78 + $nm_escola,
  79 + $nm_instituicao,
  80 + $ref_cod_curso,
  81 + $pdf,
  82 + $nm_turma,
  83 + $nm_serie,
  84 + $nm_aluno,
  85 + $nm_ensino,
  86 + $nm_curso,
  87 + $data_solicitacao,
  88 + $escola_municipio;
  89 +
  90 + /**
  91 + * Distância horizontal da página (eixo y).
  92 + * @var int
  93 + */
  94 + var $page_y = 139;
  95 +
  96 + /**
  97 + * Caminho para o download do arquivo.
  98 + * @var string
  99 + */
  100 + var $get_link;
  101 +
  102 + /**
  103 + * Array associativo com os meses do ano.
  104 + * @var array
  105 + */
  106 + var $meses_do_ano = array(
  107 + '1' => 'JANEIRO',
  108 + '2' => 'FEVEREIRO',
  109 + '3' => 'MAR&Ccedil;O',
  110 + '4' => 'ABRIL',
  111 + '5' => 'MAIO',
  112 + '6' => 'JUNHO',
  113 + '7' => 'JULHO',
  114 + '8' => 'AGOSTO',
  115 + '9' => 'SETEMBRO',
  116 + '10' => 'OUTUBRO',
  117 + '11' => 'NOVEMBRO',
  118 + '12' => 'DEZEMBRO'
  119 + );
  120 +
  121 + /**
  122 + * Sobrescreve clsCadastro::renderHTML().
  123 + * @see clsCadastro::renderHTML()
  124 + */
  125 + function renderHTML()
  126 + {
  127 + $ok = FALSE;
  128 + $obj_reserva_vaga = new clsPmieducarReservaVaga();
  129 + $this->cod_reserva_vaga = $_GET['cod_reserva_vaga'];
  130 + $lst_reserva_vaga = $obj_reserva_vaga->lista($this->cod_reserva_vaga);
  131 + $registro = array_shift($lst_reserva_vaga);
  132 +
  133 + if (is_numeric($_GET['cod_reserva_vaga']) && is_array($registro)) {
  134 + $this->data_solicitacao = $registro['data_cadastro'];
  135 + $ok = TRUE;
  136 + }
  137 +
  138 + if (!$ok) {
  139 + echo "<script>alert('Não é possível gerar documento para reserva de vaga para esta matrícula');window.location='educar_index.php';</script>";
  140 + die('Não é possível gerar documento para reserva de vaga para esta matrícula');
  141 + }
  142 +
  143 + // Nome do aluno
  144 + if ($registro['nm_aluno']) {
  145 + $this->nm_aluno = $registro['nm_aluno'];
  146 + }
  147 + elseif ($registro['ref_cod_aluno']) {
  148 + $obj_aluno = new clsPmieducarAluno();
  149 + $det_aluno = array_shift($obj_aluno->lista($registro['ref_cod_aluno']));
  150 + $this->nm_aluno = $det_aluno['nome_aluno'];
  151 + }
  152 +
  153 + // Nome da escola
  154 + $obj_escola = new clsPmieducarEscola($registro['ref_ref_cod_escola']);
  155 + $det_escola = $obj_escola->detalhe();
  156 + $this->nm_escola = $det_escola['nome'];
  157 +
  158 + // Cidade da escola
  159 + $escolaComplemento = new clsPmieducarEscolaComplemento($registro['ref_ref_cod_escola']);
  160 + $escolaComplemento = $escolaComplemento->detalhe();
  161 + $this->escola_municipio = $escolaComplemento['municipio'];
  162 +
  163 + // Nome da série
  164 + $obj_serie = new clsPmieducarSerie($registro['ref_ref_cod_serie']);
  165 + $det_serie = $obj_serie->detalhe();
  166 + $this->nm_serie = $det_serie['nm_serie'];
  167 +
  168 + // Nome do curso
  169 + $obj_curso = new clsPmieducarCurso($registro['ref_cod_curso']);
  170 + $det_curso = $obj_curso->detalhe();
  171 + $this->nm_curso = $det_curso['nm_curso'];
  172 +
  173 + $fonte = 'arial';
  174 + $corTexto = '#000000';
  175 +
  176 + $this->pdf = new clsPDF('Diário de Classe - '. $this->ano,
  177 + "Diário de Classe - {$this->meses_do_ano[$this->mes]} e {$this->meses_do_ano[$prox_mes]} de {$this->ano}",
  178 + 'A4', '', FALSE, FALSE);
  179 +
  180 + $this->pdf->OpenPage();
  181 + $this->addCabecalho();
  182 +
  183 + // Título
  184 + $this->pdf->escreve_relativo('Reserva de Vaga', 30, 220, 535, 80, $fonte, 16,
  185 + $corTexto, 'justify');
  186 +
  187 + $texto = "Atesto para os devidos fins que o aluno {$this->nm_aluno}, solicitou reserva de vaga na escola {$this->nm_escola}, para o curso {$this->nm_curso}, na série {$this->nm_serie} e que a mesma possui a validade de 48 horas a partir da data de solicitação da mesma, " . dataFromPgToBr($this->data_solicitacao) . ".";
  188 + $this->pdf->escreve_relativo($texto, 30, 350, 535, 80, $fonte, 14, $corTexto, 'center');
  189 +
  190 + $mes = date('n');
  191 + $mes = strtolower($this->meses_do_ano["{$mes}"]);
  192 + $data = date('d') . " de $mes de " . date('Y');
  193 + $this->pdf->escreve_relativo($this->escola_municipio . ', ' . $data, 30, 600, 535, 80, $fonte, 14, $corTexto, 'center');
  194 + $this->rodape();
  195 + $this->pdf->CloseFile();
55 196
  197 + $this->get_link = $this->pdf->GetLink();
56 198
57 - /**  
58 - * Referencia pega da session para o idpes do usuario atual  
59 - *  
60 - * @var int  
61 - */  
62 - var $pessoa_logada;  
63 -  
64 -  
65 - var $ref_cod_instituicao;  
66 - var $ref_cod_escola;  
67 - var $ref_cod_serie;  
68 - var $ref_cod_turma;  
69 - var $ref_cod_matricula;  
70 -  
71 - var $nm_escola;  
72 - var $nm_instituicao;  
73 - var $ref_cod_curso;  
74 - var $pdf;  
75 - var $nm_turma;  
76 - var $nm_serie;  
77 - var $nm_aluno;  
78 - var $nm_ensino;  
79 - var $nm_curso;  
80 - var $data_solicitacao;  
81 -  
82 - var $page_y = 139;  
83 -  
84 -  
85 - var $get_link;  
86 -  
87 -  
88 -  
89 - var $meses_do_ano = array(  
90 - "1" => "JANEIRO"  
91 - ,"2" => "FEVEREIRO"  
92 - ,"3" => "MAR&Ccedil;O"  
93 - ,"4" => "ABRIL"  
94 - ,"5" => "MAIO"  
95 - ,"6" => "JUNHO"  
96 - ,"7" => "JULHO"  
97 - ,"8" => "AGOSTO"  
98 - ,"9" => "SETEMBRO"  
99 - ,"10" => "OUTUBRO"  
100 - ,"11" => "NOVEMBRO"  
101 - ,"12" => "DEZEMBRO"  
102 - );  
103 -  
104 -  
105 - function renderHTML()  
106 - {  
107 -  
108 - $ok = false;  
109 - $obj_reserva_vaga = new clsPmieducarReservaVaga();  
110 - $lst_reserva_vaga = $obj_reserva_vaga->lista($this->cod_reserva_vaga);  
111 - $registro = array_shift($lst_reserva_vaga);  
112 - if(is_numeric($_GET['cod_reserva_vaga']) && is_array($registro))  
113 - {  
114 - $this->data_solicitacao = $registro['data_cadastro'];  
115 -  
116 - $ok = true;  
117 - }  
118 - if(!$ok)  
119 - {  
120 - echo "<script>alert('Não é possível gerar documento para reserva de vaga para esta matrícula');window.location='educar_index.php';</script>";  
121 - die('Não é possível gerar documento para reserva de vaga para esta matrícula');  
122 - }  
123 -  
124 - $obj_aluno = new clsPmieducarAluno();  
125 - $det_aluno = array_shift($obj_aluno->lista($registro['ref_cod_aluno']));  
126 - $this->nm_aluno = $det_aluno['nome_aluno'];  
127 -  
128 -  
129 - if( class_exists( "clsPmieducarEscola" ) )  
130 - {  
131 - $obj_escola = new clsPmieducarEscola( $registro["ref_ref_cod_escola"] );  
132 - $det_escola = $obj_escola->detalhe();  
133 - $this->nm_escola = $registro["ref_ref_cod_escola"] = $det_escola["nome"];  
134 - }  
135 - else  
136 - {  
137 - $registro["ref_ref_cod_escola"] = "Erro na geracao";  
138 - echo "<!--\nErro\nClasse nao existente: clsPmieducarEscola\n-->";  
139 - }  
140 - if( class_exists( "clsPmieducarSerie" ) )  
141 - {  
142 - $obj_serie = new clsPmieducarSerie( $registro["ref_ref_cod_serie"] );  
143 - $det_serie = $obj_serie->detalhe();  
144 - $this->nm_serie = $registro["ref_ref_cod_serie"] = $det_serie["nm_serie"];  
145 - }  
146 - else  
147 - {  
148 - $registro["ref_ref_cod_serie"] = "Erro na gera&ccedil;&atilde;o";  
149 - echo "<!--\nErro\nClasse n&atilde;o existente: clsPmieducarSerie\n-->";  
150 - }  
151 - if( class_exists( "clsPmieducarCurso" ) )  
152 - {  
153 - $obj_curso = new clsPmieducarCurso( $registro["ref_cod_curso"] );  
154 - $det_curso = $obj_curso->detalhe();  
155 - $this->nm_curso = $registro["ref_cod_curso"] = $det_curso["nm_curso"];  
156 - }  
157 - else  
158 - {  
159 - $registro["ref_cod_curso"] = "Erro na gera&ccedil;&atilde;o";  
160 - echo "<!--\nErro\nClasse n&atilde;o existente: clsPmieducarCurso\n-->";  
161 - }  
162 -  
163 - $fonte = 'arial';  
164 - $corTexto = '#000000';  
165 -  
166 - $this->pdf = new clsPDF("Diário de Classe - {$this->ano}", "Diário de Classe - {$this->meses_do_ano[$this->mes]} e {$this->meses_do_ano[$prox_mes]} de {$this->ano}", "A4", "", false, false);  
167 -  
168 - $this->pdf->OpenPage();  
169 - $this->addCabecalho();  
170 -  
171 -  
172 - //titulo  
173 - $this->pdf->escreve_relativo( "Reserva de Vaga", 30, 220, 535, 80, $fonte, 16, $corTexto, 'justify' );  
174 -  
175 - $texto = "Atesto para os devidos fins que o aluno {$this->nm_aluno}, solicitou reserva de vaga na escola {$this->nm_escola}, para o curso {$this->nm_curso}, na série {$this->nm_serie} e que a mesma possui a validade de 48 horas a partir da data de solicitação da mesma, ".dataFromPgToBr($this->data_solicitacao).".";  
176 - $this->pdf->escreve_relativo( $texto, 30, 350, 535, 80, $fonte, 14, $corTexto, 'center' );  
177 - $mes = date('n');  
178 - $mes = strtolower($this->meses_do_ano["{$mes}"]);  
179 - $data = date('d')." de $mes de ".date('Y');  
180 - $this->pdf->escreve_relativo( "Brasilia, $data", 30, 600, 535, 80, $fonte, 14, $corTexto, 'center' );  
181 - $this->rodape();  
182 - $this->pdf->CloseFile();  
183 -  
184 - $this->get_link = $this->pdf->GetLink();  
185 -  
186 - //$down = new download($this->get_link);  
187 - //echo "<script>window.location='$this->get_link';setTimeout('window.close();',300);</script>";  
188 - echo "<script>window.onload=function(){parent.EscondeDiv('LoadImprimir');window.location='download.php?filename=".$this->get_link."'}</script>";  
189 -  
190 - echo "<center><a target='blank' href='" . $this->get_link . "' style='font-size: 16px; color: #000000; text-decoration: underline;'>Clique aqui para visualizar o arquivo!</a><br><br>  
191 - <span style='font-size: 10px;'>Para visualizar os arquivos PDF, é necessário instalar o Adobe Acrobat Reader.<br>  
192 -  
193 - Clique na Imagem para Baixar o instalador<br><br>  
194 - <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>  
195 - </span>  
196 - </center>";  
197 -  
198 -  
199 - //echo "location:download.php?filename=".$this->get_link;die;  
200 -  
201 - return;  
202 -  
203 -  
204 - }  
205 -  
206 - function Novo()  
207 - {  
208 -  
209 - return true;  
210 - }  
211 -  
212 - public function addCabecalho() 199 + echo "<script>window.onload=function(){parent.EscondeDiv('LoadImprimir');window.location='download.php?filename=".$this->get_link."'}</script>";
  200 +
  201 + echo "
  202 + <center><a target='blank' href='" . $this->get_link . "' style='font-size: 16px; color: #000000; text-decoration: underline;'>Clique aqui para visualizar o arquivo!</a><br><br>
  203 + <span style='font-size: 10px;'>Para visualizar os arquivos PDF, é necessário instalar o Adobe Acrobat Reader.<br>
  204 + Clique na Imagem para Baixar o instalador<br><br>
  205 + <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>
  206 + </span>
  207 + </center>";
  208 +
  209 + return;
  210 + }
  211 +
  212 + /**
  213 + * Sobrescreve clsCadastro::Novo().
  214 + * @see clsCadastro::Novo()
  215 + */
  216 + function Novo()
  217 + {
  218 + return TRUE;
  219 + }
  220 +
  221 + /**
  222 + * Adiciona um cabeçalho ao documento.
  223 + */
  224 + function addCabecalho()
213 { 225 {
214 /** 226 /**
215 * Variável global com objetos do CoreExt. 227 * Variável global com objetos do CoreExt.
@@ -228,7 +240,7 @@ class indice extends clsCadastro @@ -228,7 +240,7 @@ class indice extends clsCadastro
228 // Cabeçalho 240 // Cabeçalho
229 $logo = $config->get($config->logo, 'imagens/brasao.gif'); 241 $logo = $config->get($config->logo, 'imagens/brasao.gif');
230 242
231 - $this->pdf->quadrado_relativo( 30, $altura, 535, 85 ); 243 + $this->pdf->quadrado_relativo(30, $altura, 535, 85);
232 $this->pdf->insertImageScaled('gif', $logo, 50, 95, 41); 244 $this->pdf->insertImageScaled('gif', $logo, 50, 95, 41);
233 245
234 // Título principal 246 // Título principal
@@ -243,43 +255,49 @@ class indice extends clsCadastro @@ -243,43 +255,49 @@ class indice extends clsCadastro
243 $lista_serie_curso = $obj->lista(NULL, NULL, NULL, $this->ref_cod_curso, 255 $lista_serie_curso = $obj->lista(NULL, NULL, NULL, $this->ref_cod_curso,
244 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao); 256 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao);
245 257
246 - $dataAtual = date("d/m/Y");  
247 - $this->pdf->escreve_relativo("Data: " . $dataAtual, 480, 100, 535, 80, 258 + $dataAtual = date('d/m/Y');
  259 + $this->pdf->escreve_relativo('Data: ' . $dataAtual, 480, 100, 535, 80,
248 $fonte, 10, $corTexto, 'left'); 260 $fonte, 10, $corTexto, 'left');
249 } 261 }
250 262
  263 + /**
  264 + * Adiciona uma linha para assinatura do documento.
  265 + */
  266 + function rodape()
  267 + {
  268 + $corTexto = '#000000';
  269 + $this->pdf->escreve_relativo('Assinatura do(a) secretário(a)', 398, 715,
  270 + 150, 50, $fonte, 9, $corTexto, 'left');
  271 + $this->pdf->linha_relativa(385, 710, 140, 0);
  272 + }
251 273
252 - function rodape()  
253 - {  
254 - $corTexto = '#000000';  
255 -  
256 -  
257 - $this->pdf->escreve_relativo( "Assinatura do secretário(a)", 398,715, 150, 50, $fonte, 9, $corTexto, 'left' );  
258 - $this->pdf->linha_relativa(385,710,140,0);  
259 - }  
260 -  
261 - function Editar()  
262 - {  
263 - return false;  
264 - }  
265 -  
266 - function Excluir()  
267 - {  
268 - return false;  
269 - } 274 + /**
  275 + * Sobrescreve clsCadastro::Editar().
  276 + * @see clsCadastro::Editar()
  277 + */
  278 + function Editar()
  279 + {
  280 + return FALSE;
  281 + }
270 282
  283 + /**
  284 + * Sobrescreve clsCadastro::Excluir().
  285 + * @see clsCadastro::Excluir()
  286 + */
  287 + function Excluir()
  288 + {
  289 + return FALSE;
  290 + }
271 } 291 }
272 292
273 -// cria uma extensao da classe base 293 +// Instancia objeto de página
274 $pagina = new clsIndexBase(); 294 $pagina = new clsIndexBase();
275 -// cria o conteudo  
276 -$miolo = new indice();  
277 -// adiciona o conteudo na clsBase  
278 -$pagina->addForm( $miolo );  
279 -// gera o html  
280 -  
281 -$pagina->MakeAll();  
282 295
  296 +// Instancia objeto de conteúdo
  297 +$miolo = new indice();
283 298
  299 +// Atribui o conteúdo à página
  300 +$pagina->addForm($miolo);
284 301
285 -?> 302 +// Gera o código HTML
  303 +$pagina->MakeAll();
286 \ No newline at end of file 304 \ No newline at end of file