Commit 362ea36cbdf4979489d966ad1792f80c76b06013

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

Refactoring para coding standards

ieducar/intranet/educar_relatorio_quadro_horario_proc.php
1 1 <?php
2 2  
3   -/*
  3 +/**
4 4 * i-Educar - Sistema de gestão escolar
5 5 *
6 6 * Copyright (C) 2006 Prefeitura Municipal de Itajaí
... ... @@ -19,17 +19,13 @@
19 19 * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
20 20 * com este programa; se não, escreva para a Free Software Foundation, Inc., no
21 21 * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
22   - */
23   -
24   -/**
25   - * Quadro de horários.
26 22 *
27   - * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
28   - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL
29   - * @package Core
30   - * @subpackage Relatório
31   - * @since Arquivo disponível desde a versão 1.0.0
32   - * @version $Id$
  23 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  24 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package iEd_Pmieducar
  27 + * @since Arquivo disponível desde a versão 1.0.0
  28 + * @version $Id$
33 29 */
34 30  
35 31 require_once 'include/clsBase.inc.php';
... ... @@ -38,7 +34,16 @@ require_once &#39;include/clsBanco.inc.php&#39;;
38 34 require_once 'include/pmieducar/geral.inc.php';
39 35 require_once 'include/clsPDF.inc.php';
40 36  
41   -
  37 +/**
  38 + * clsIndexBase class.
  39 + *
  40 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  41 + * @category i-Educar
  42 + * @license @@license@@
  43 + * @package iEd_Pmieducar
  44 + * @since Classe disponível desde a versão 1.0.0
  45 + * @version @@package_version@@
  46 + */
42 47 class clsIndexBase extends clsBase
43 48 {
44 49 function Formular()
... ... @@ -50,15 +55,18 @@ class clsIndexBase extends clsBase
50 55 }
51 56 }
52 57  
  58 +/**
  59 + * indice class.
  60 + *
  61 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  62 + * @category i-Educar
  63 + * @license @@license@@
  64 + * @package iEd_Pmieducar
  65 + * @since Classe disponível desde a versão 1.0.0
  66 + * @version @@package_version@@
  67 + */
53 68 class indice extends clsCadastro
54 69 {
55   -
56   -
57   - /**
58   - * Referencia pega da session para o idpes do usuario atual
59   - *
60   - * @var int
61   - */
62 70 var $pessoa_logada;
63 71  
64 72 var $ref_cod_instituicao;
... ... @@ -77,58 +85,36 @@ class indice extends clsCadastro
77 85 var $nm_serie;
78 86 var $nm_disciplina;
79 87  
80   - var $get_link = false;
81   -
82   - var $pdf = false;
83   -
84   - var $page_y = 15;
85   -
86   - var $meses_do_ano = array(
87   - "1" => "JANEIRO"
88   - ,"2" => "FEVEREIRO"
89   - ,"3" => "MAR&Ccedil;O"
90   - ,"4" => "ABRIL"
91   - ,"5" => "MAIO"
92   - ,"6" => "JUNHO"
93   - ,"7" => "JULHO"
94   - ,"8" => "AGOSTO"
95   - ,"9" => "SETEMBRO"
96   - ,"10" => "OUTUBRO"
97   - ,"11" => "NOVEMBRO"
98   - ,"12" => "DEZEMBRO"
99   - );
  88 + var $get_link = FALSE;
  89 + var $pdf = FALSE;
  90 + var $page_y = 15;
100 91  
101 92 var $array_dias_semana = array(
102   - "1" => "Domingo"
103   - ,"2" => "Segunda"
104   - ,"3" => "Terça"
105   - ,"4" => "Quarta"
106   - ,"5" => "Quinta"
107   - ,"6" => "Sexta"
108   - ,"7" => "Sábado"
109   - );
110   -
111   -
  93 + 1 => 'Domingo',
  94 + 2 => 'Segunda',
  95 + 3 => 'Terça',
  96 + 4 => 'Quarta',
  97 + 5 => 'Quinta',
  98 + 6 => 'Sexta',
  99 + 7 => 'Sábado'
  100 + );
112 101  
113 102 function renderHTML()
114 103 {
115   -
116   - if($_POST){
  104 + if ($_POST){
117 105 foreach ($_POST as $key => $value) {
118 106 $this->$key = $value;
119   -
120 107 }
121 108 }
122 109  
123   - if($this->ref_ref_cod_serie)
  110 + if ($this->ref_ref_cod_serie) {
124 111 $this->ref_cod_serie = $this->ref_ref_cod_serie;
  112 + }
125 113  
126   - if($this->ref_cod_escola){
127   -
  114 + if ($this->ref_cod_escola) {
128 115 $obj_escola = new clsPmieducarEscola($this->ref_cod_escola);
129 116 $det_escola = $obj_escola->detalhe();
130 117 $this->nm_escola = $det_escola['nome'];
131   -
132 118 }
133 119  
134 120 $obj_instituicao = new clsPmieducarInstituicao($this->ref_cod_instituicao);
... ... @@ -140,67 +126,63 @@ class indice extends clsCadastro
140 126  
141 127 $obj_curso = new clsPmieducarCurso();
142 128 $obj_curso->setOrderby("nm_curso");
143   - $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);
144   -
  129 + $lst_curso = $obj_curso->lista($this->ref_cod_curso, NULL, NULL, NULL, NULL,
  130 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  131 + NULL, NULL, NULL, NULL, NULL, 1, NULL, $this->ref_cod_instituicao);
145 132  
146   - if($lst_curso)
147   - {
148   -
149   - foreach ($lst_curso as $curso)
150   - {
  133 + if ($lst_curso) {
  134 + foreach ($lst_curso as $curso) {
151 135 $obj_serie = new clsPmieducarSerie();
152 136 $obj_serie->setOrderby("nm_serie");
153   - $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);
  137 + $lst_serie = $obj_serie->lista($this->ref_cod_serie, NULL, NULL,
  138 + $curso['cod_curso'], NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  139 + 1, $this->ref_cod_instituicao, NULL, NULL, NULL, $this->ref_cod_escola);
154 140  
155 141 $quadro_horario = 0;
156   - if($lst_serie)
157   - {
158   - foreach ($lst_serie as $serie)
159   - {
160   -
  142 + if ($lst_serie) {
  143 + foreach ($lst_serie as $serie) {
161 144 $obj_turma = new clsPmieducarTurma();
162   - $obj_turma->setOrderby("nm_turma");
163   - $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);
164   -
165   - if($lst_turma)
166   - {
167   - foreach ($lst_turma as $turma)
168   - {
169   -
170   - $obj_quadro = new clsPmieducarQuadroHorario( null, null, null, $turma['cod_turma'], null, null, 1 );
  145 + $obj_turma->setOrderby('nm_turma');
  146 + $lst_turma = $obj_turma->lista($this->ref_cod_turma, NULL, NULL,
  147 + $serie['cod_serie'], $this->ref_cod_escola, NULL, NULL, NULL, NULL,
  148 + NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL,
  149 + NULL, NULL, NULL, NULL, $curso['cod_curso'], $this->ref_cod_instituicao);
  150 +
  151 + if ($lst_turma) {
  152 + foreach ($lst_turma as $turma) {
  153 + $obj_quadro = new clsPmieducarQuadroHorario(NULL, NULL, NULL,
  154 + $turma['cod_turma'], NULL, NULL, 1);
171 155 $det_quadro = $obj_quadro->detalhe();
172 156  
173   - if($det_quadro)
174   - {
175   - if(!$this->pdf)
176   - {
177   - $this->pdf = new clsPDF("Quadro Horarios", "Quadro Horarios", "A4", "", false, false);
  157 + if ($det_quadro) {
  158 + if (!$this->pdf) {
  159 + $this->pdf = new clsPDF('Quadro Horarios', 'Quadro Horarios',
  160 + 'A4', '', FALSE, FALSE);
178 161 }
179 162  
180   - if($quadro_horario % 3 == 0)
181   - {
182   - //$this->pdf->largura = 842.0;
183   - //$this->pdf->altura = 595.0;
184   - $this->page_y = 15;
185   - $this->pdf->OpenPage();
186   - $this->addCabecalho();
187   - $quadro_horario = 0;
  163 + if ($quadro_horario % 3 == 0) {
  164 + $this->page_y = 15;
  165 + $this->pdf->OpenPage();
  166 + $this->addCabecalho();
  167 + $quadro_horario = 0;
188 168 }
189 169  
  170 + $this->pdf->escreve_relativo($turma['nm_turma'] . ' - ' . $serie['nm_serie'],
  171 + 20, $this->page_y - 7, 550, 20, $fonte, 11, $corTexto, 'center');
190 172  
191   -
192   -
193   - $this->pdf->escreve_relativo("{$turma['nm_turma']} - {$serie['nm_serie']}",20 ,$this->page_y - 7,550,20,$fonte,11,$corTexto,'center');
194 173 $this->page_y +=10;
195 174  
196   - $this->pdf->quadrado_relativo(35,$this->page_y,525,20,0.3,"#777777","#777777");
  175 + $this->pdf->quadrado_relativo(35, $this->page_y, 525, 20, 0.3,
  176 + '#777777', '#777777');
197 177 $inicio_x = 35;
198 178  
199   - for ($dia_semana = 1;$dia_semana <= 7;$dia_semana++)
200   - {
201   - $this->pdf->linha_relativa($inicio_x,$this->page_y,0,20);
202   - $this->pdf->escreve_relativo($this->array_dias_semana[$dia_semana],$inicio_x ,$this->page_y+3,75,20,$fonte,11,$corTexto,'center');
203   - $inicio_x+=75;
  179 + for ($dia_semana = 1; $dia_semana <= 7; $dia_semana++) {
  180 + $this->pdf->linha_relativa($inicio_x, $this->page_y, 0, 20);
  181 + $this->pdf->escreve_relativo($this->array_dias_semana[$dia_semana],
  182 + $inicio_x, $this->page_y + 3, 75, 20, $fonte, 11, $corTexto,
  183 + 'center');
  184 +
  185 + $inicio_x += 75;
204 186 }
205 187  
206 188 $this->page_y += 20;
... ... @@ -208,42 +190,49 @@ class indice extends clsCadastro
208 190 $inicio_y = $this->page_y;
209 191  
210 192 $inicio_x = 35;
211   - $this->pdf->quadrado_relativo($inicio_x,$this->page_y,525,200,0.3);
212   - for ($dia_semana = 1;$dia_semana <= 7;$dia_semana++)
213   - {
214   -
  193 + $this->pdf->quadrado_relativo($inicio_x, $this->page_y, 525, 200, 0.3);
  194 + for ($dia_semana = 1; $dia_semana <= 7; $dia_semana++) {
215 195 $obj_horarios = new clsPmieducarQuadroHorarioHorarios();
216   - $resultado = $obj_horarios->retornaHorario( $this->ref_cod_instituicao, $this->ref_cod_escola, $serie['cod_serie'], $turma['cod_turma'], $dia_semana );
217   -
218   - if ( is_array( $resultado ) )
219   - {
220   - foreach ( $resultado as $registro )
221   - {
222   - $this->pdf->quadrado_relativo($inicio_x,$this->page_y,75,50,0.3);
223   - $obj_disciplina = new clsPmieducarDisciplina( $registro["ref_cod_disciplina"] );
  196 + $resultado = $obj_horarios->retornaHorario(
  197 + $this->ref_cod_instituicao, $this->ref_cod_escola,
  198 + $serie['cod_serie'], $turma['cod_turma'], $dia_semana);
  199 +
  200 + if (is_array($resultado)) {
  201 + foreach ($resultado as $registro) {
  202 + $this->pdf->quadrado_relativo($inicio_x, $this->page_y,
  203 + 75, 50, 0.3);
  204 +
  205 + $obj_disciplina = new clsPmieducarDisciplina($registro['ref_cod_disciplina']);
224 206 $det_disciplina = $obj_disciplina->detalhe();
225 207 $obj_servidor = new clsPmieducarServidor();
226   - $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));
227   - $det_servidor['nome'] = array_shift(explode(' ',$det_servidor['nome']));
  208 + $det_servidor = array_shift($obj_servidor->lista(
  209 + $registro['ref_servidor'], NULL, NULL, NULL, NULL,
  210 + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  211 + NULL, NULL, TRUE));
  212 +
  213 + $det_servidor['nome'] = array_shift(explode(' ', $det_servidor['nome']));
228 214  
229   - $this->pdf->escreve_relativo(substr( $registro["hora_inicial"], 0, 5 )." - ".substr( $registro["hora_final"], 0, 5 )." \n {$det_disciplina["abreviatura"]} \n {$det_servidor["nome"]}",$inicio_x,$this->page_y+12,75,50,$fonte,10,$corTexto,'center');
  215 + //$texto = substr($registro['hora_inicial'], 0, 5 )." - ".substr( $registro["hora_final"], 0, 5 )." \n {$det_disciplina["abreviatura"]} \n {$det_servidor["nome"]}"
  216 + $texto = sprintf("%s - %s\n%s\n%s",
  217 + substr($registro['hora_inicial'], 0, 5),
  218 + substr($registro["hora_final"], 0, 5),
  219 + $det_disciplina['abreviatura'],
  220 + $det_servidor['nome']
  221 + );
  222 +
  223 + $this->pdf->escreve_relativo(
  224 + $texto,//substr($registro['hora_inicial'], 0, 5 )." - ".substr( $registro["hora_final"], 0, 5 )." \n {$det_disciplina["abreviatura"]} \n {$det_servidor["nome"]}",
  225 + $inicio_x, $this->page_y + 12, 75, 50, $fonte, 10, $corTexto, 'center');
230 226  
231   - //substr( $registro["hora_inicial"], 0, 5 )." - ".substr( $registro["hora_final"], 0, 5 )." <br> {$det_disciplina["abreviatura"]} <br> {$det_servidor["nome"]}
232 227 $this->page_y += 50;
233 228 }
234 229 }
235 230  
236   - //$this->pdf->linha_relativa($inicio_x,$this->page_y,0,20);
237   - //$this->pdf->escreve_relativo($this->array_dias_semana[$dia_semana],$inicio_x ,$this->page_y+3,75,20,$fonte,11,$corTexto,'center');
238   -
239 231 $inicio_x+=75;
240   -
241 232 $this->page_y = $inicio_y;
242   -
243 233 }
244 234  
245 235 $this->page_y += 220;
246   -
247 236 }
248 237  
249 238 $quadro_horario++;
... ... @@ -254,38 +243,41 @@ class indice extends clsCadastro
254 243 }
255 244 }
256 245  
257   - if ($this->pdf)
258   - {
259   -
  246 + if ($this->pdf) {
260 247 $this->pdf->CloseFile();
261 248 $this->get_link = $this->pdf->GetLink();
262   -
263 249 }
264   - else
265   - {
266   -
267   - echo '<script>
268   - alert("As turmas não possuem matrículas no ano selecionado");
269   - window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1));
270   - </script>';
271   -
272   - return;
273   -
  250 + else {
  251 + echo '
  252 + <script>
  253 + alert("As turmas não possuem matrículas no ano selecionado");
  254 + window.parent.fechaExpansivel("div_dinamico_" + (window.parent.DOM_divs.length-1));
  255 + </script>';
  256 +
  257 + return;
274 258 }
275 259  
276   -
277   - echo "<script>window.onload=function(){parent.EscondeDiv('LoadImprimir');window.location='download.php?filename=".$this->get_link."'}</script>";
278   -
279   - echo "<html><center>Se o download não iniciar automaticamente <br /><a target='blank' href='" . $this->get_link . "' style='font-size: 16px; color: #000000; text-decoration: underline;'>clique aqui!</a><br><br>
280   - <span style='font-size: 10px;'>Para visualizar os arquivos PDF, é necessário instalar o Adobe Acrobat Reader.<br>
281   -
282   - Clique na Imagem para Baixar o instalador<br><br>
283   - <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>
284   - </span>
285   - </center>";
  260 + echo sprintf('
  261 + <script>
  262 + window.onload=function()
  263 + {
  264 + parent.EscondeDiv("LoadImprimir");
  265 + window.location="download.php?filename=%s"
  266 + }
  267 + </script>', $this->get_link);
  268 +
  269 + echo sprintf('
  270 + <html>
  271 + <center>Se o download não iniciar automaticamente <br />
  272 + <a target="blank" href="%s" style="font-size: 16px; color: #000000; text-decoration: underline;">clique aqui!</a><br /><br />
  273 + <span style="font-size: 10px;">Para visualizar os arquivos PDF, é necessário instalar o Adobe Acrobat Reader.<br />
  274 + Clique na Imagem para Baixar o instalador<br /><br />
  275 + <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>
  276 + </span>
  277 + </center>', $this->get_link);
286 278 }
287 279  
288   - public function addCabecalho()
  280 + function addCabecalho()
289 281 {
290 282 /**
291 283 * Variável global com objetos do CoreExt.
... ... @@ -314,57 +306,61 @@ class indice extends clsCadastro
314 306 $fonte, 18, $corTexto, 'center');
315 307  
316 308 // Dados escola
317   - $this->pdf->escreve_relativo("Instituição: $this->nm_instituicao", 110,
  309 + $this->pdf->escreve_relativo('Instituição: ' . $this->nm_instituicao, 110,
318 310 $this->page_y + 38, 400, 80, $fonte, 10, $corTexto, 'left');
319 311  
320 312 $this->nm_escola ?
321   - $this->pdf->escreve_relativo( "Escola: {$this->nm_escola}", 127, $this->page_y + 48, 300, 80, $fonte, 10, $corTexto, 'left')
  313 + $this->pdf->escreve_relativo('Escola: ' . $this->nm_escola, 127, $this->page_y + 48, 300, 80, $fonte, 10, $corTexto, 'left')
322 314 :
323 315 NULL;
324 316  
325 317 // Título
326   - $this->pdf->escreve_relativo("Quadro de Horários - $this->ano", 30,
  318 + $this->pdf->escreve_relativo('Quadro de Horários - ' . $this->ano, 30,
327 319 $this->page_y + 23, 535, 80, $fonte, 12, $corTexto, 'center');
328 320  
329   - $this->pdf->escreve_relativo("Data de Emissão: ".date("d/m/Y"), 700,
  321 + $this->pdf->escreve_relativo('Data de Emissão: ' . date('d/m/Y'), 700,
330 322 $this->page_y + 50, 535, 80, $fonte, 8, $corTexto, 'left');
331 323  
332 324 $this->page_y += 80;
333 325 }
334 326  
335   -
336 327 function rodape()
337 328 {
338   - $corTexto = '#000000';
339   - $fonte = 'arial';
340   - $dataAtual = date("d/m/Y");
341   - $this->pdf->escreve_relativo( "Data: $dataAtual", 36,$this->page_y + 2, 100, 50, $fonte, 7, $corTexto, 'left' );
  329 + $corTexto = '#000000';
  330 + $fonte = 'arial';
  331 + $dataAtual = date('d/m/Y');
  332 + $this->pdf->escreve_relativo('Data: ' . $dataAtual, 36, $this->page_y + 2,
  333 + 100, 50, $fonte, 7, $corTexto, 'left');
342 334  
343   - $this->pdf->escreve_relativo( "Estou ciente do aproveitamento de ".str2upper($this->nm_aluno).", matrícula nº: $this->ref_cod_matricula.", 68,$this->page_y +12, 600, 50, $fonte, 9, $corTexto, 'left' );
344   - $this->pdf->escreve_relativo( "Assinatura do Responsável(a)", 677,$this->page_y +18, 200, 50, $fonte, 7, $corTexto, 'left' );
345   - $this->pdf->linha_relativa(660,$this->page_y+18,130,0,0.4);
  335 + $this->pdf->escreve_relativo('Estou ciente do aproveitamento de ' .
  336 + str2upper($this->nm_aluno) . ', matrícula nº: ' . $this->ref_cod_matricula, 68,
  337 + $this->page_y +12, 600, 50, $fonte, 9, $corTexto, 'left');
  338 +
  339 + $this->pdf->escreve_relativo('Assinatura do Responsável(a)', 677,
  340 + $this->page_y + 18, 200, 50, $fonte, 7, $corTexto, 'left');
  341 +
  342 + $this->pdf->linha_relativa(660, $this->page_y + 18, 130, 0, 0.4);
346 343 }
347 344  
348 345 function Editar()
349 346 {
350   - return false;
  347 + return FALSE;
351 348 }
352 349  
353 350 function Excluir()
354 351 {
355   - return false;
  352 + return FALSE;
356 353 }
357 354 }
358 355  
359   -// cria uma extensao da classe base
  356 +// Instancia objeto de página
360 357 $pagina = new clsIndexBase();
361   -// cria o conteudo
  358 +
  359 +// Instancia objeto de conteúdo
362 360 $miolo = new indice();
363   -// adiciona o conteudo na clsBase
364   -$pagina->addForm( $miolo );
365   -// gera o html
366   -$pagina->MakeAll();
367 361  
  362 +// Atribui o conteúdo à  página
  363 +$pagina->addForm($miolo);
368 364  
369   -?>
370   -<script>
  365 +// Gera o código HTML
  366 +$pagina->MakeAll();
371 367 \ No newline at end of file
... ...