Commit de6fdef11963fa516a3c36dc5abc8a9d23490bd9

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

Refactoring para coding standards

ieducar/intranet/educar_servidor_substituicao_cad.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,21 +19,13 @@ @@ -19,21 +19,13 @@
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 - * Formulário de substituição de servidor  
26 - *  
27 - * Interface administrativa para a substituição de horário de um servidor por  
28 - * outro. As classes deste arquivo extendem as classes básicas de interface  
29 - * com o usuário.  
30 * 22 *
31 - * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>  
32 - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL  
33 - * @package Core  
34 - * @subpackage Servidor  
35 - * @since Disponível desde a versão 1.0.0  
36 - * @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$
37 */ 29 */
38 30
39 require_once 'include/clsBase.inc.php'; 31 require_once 'include/clsBase.inc.php';
@@ -41,44 +33,59 @@ require_once &#39;include/clsCadastro.inc.php&#39;; @@ -41,44 +33,59 @@ require_once &#39;include/clsCadastro.inc.php&#39;;
41 require_once 'include/clsBanco.inc.php'; 33 require_once 'include/clsBanco.inc.php';
42 require_once 'include/pmieducar/geral.inc.php'; 34 require_once 'include/pmieducar/geral.inc.php';
43 35
  36 +/**
  37 + * clsIndexBase class.
  38 + *
  39 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  40 + * @category i-Educar
  41 + * @license @@license@@
  42 + * @package iEd_Pmieducar
  43 + * @since Classe disponível desde a versão 1.0.0
  44 + * @version @@package_version@@
  45 + */
44 class clsIndexBase extends clsBase 46 class clsIndexBase extends clsBase
45 { 47 {
46 - function Formular()  
47 - {  
48 - $this->SetTitulo( "{$this->_instituicao} i-Educar - Servidor Substitui&ccedil;&atilde;o" );  
49 - $this->processoAp = "635";  
50 - } 48 + function Formular()
  49 + {
  50 + $this->SetTitulo($this->_instituicao . ' i-Educar - Servidor Substituição');
  51 + $this->processoAp = 635;
  52 + }
51 } 53 }
52 54
  55 +/**
  56 + * indice class.
  57 + *
  58 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  59 + * @category i-Educar
  60 + * @license @@license@@
  61 + * @package iEd_Pmieducar
  62 + * @since Classe disponível desde a versão 1.0.0
  63 + * @version @@package_version@@
  64 + */
53 class indice extends clsCadastro 65 class indice extends clsCadastro
54 { 66 {
55 - /**  
56 - * Referencia pega da session para o idpes do usuario atual  
57 - *  
58 - * @var int  
59 - */  
60 - var $pessoa_logada;  
61 -  
62 - var $cod_servidor_alocacao;  
63 - var $ref_ref_cod_instituicao;  
64 - var $ref_usuario_exc;  
65 - var $ref_usuario_cad;  
66 - var $ref_cod_escola;  
67 - var $ref_cod_servidor;  
68 - var $dia_semana;  
69 - var $hora_inicial;  
70 - var $hora_final;  
71 - var $data_cadastro;  
72 - var $data_exclusao;  
73 - var $ativo;  
74 -  
75 - var $todos;  
76 -  
77 - var $alocacao_array = array();  
78 - var $professor;  
79 - //var $dias_da_semana = array( '' => 'Selecione', 1 => 'Domingo', 2 => 'Segunda', 3 => 'Ter&ccedil;a', 4 => 'Quarta', 5 => 'Quinta', 6 => 'Sexta', 7 => 'S&aacute;bado' );  
80 -  
81 - public function Inicializar() { 67 + var $pessoa_logada;
  68 +
  69 + var $cod_servidor_alocacao;
  70 + var $ref_ref_cod_instituicao;
  71 + var $ref_usuario_exc;
  72 + var $ref_usuario_cad;
  73 + var $ref_cod_escola;
  74 + var $ref_cod_servidor;
  75 + var $dia_semana;
  76 + var $hora_inicial;
  77 + var $hora_final;
  78 + var $data_cadastro;
  79 + var $data_exclusao;
  80 + var $ativo;
  81 +
  82 + var $todos;
  83 +
  84 + var $alocacao_array = array();
  85 + var $professor;
  86 +
  87 + function Inicializar()
  88 + {
82 $retorno = 'Novo'; 89 $retorno = 'Novo';
83 session_start(); 90 session_start();
84 $this->pessoa_logada = $_SESSION['id_pessoa']; 91 $this->pessoa_logada = $_SESSION['id_pessoa'];
@@ -88,7 +95,8 @@ class indice extends clsCadastro @@ -88,7 +95,8 @@ class indice extends clsCadastro
88 $this->ref_ref_cod_instituicao = $_GET['ref_cod_instituicao']; 95 $this->ref_ref_cod_instituicao = $_GET['ref_cod_instituicao'];
89 96
90 $obj_permissoes = new clsPermissoes(); 97 $obj_permissoes = new clsPermissoes();
91 - $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 3, 'educar_servidor_lst.php'); 98 + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 3,
  99 + 'educar_servidor_lst.php');
92 100
93 if (is_numeric($this->ref_cod_servidor) && is_numeric($this->ref_ref_cod_instituicao)) { 101 if (is_numeric($this->ref_cod_servidor) && is_numeric($this->ref_ref_cod_instituicao)) {
94 $retorno = 'Novo'; 102 $retorno = 'Novo';
@@ -121,7 +129,7 @@ class indice extends clsCadastro @@ -121,7 +129,7 @@ class indice extends clsCadastro
121 $this->alocacao_array[] = $temp; 129 $this->alocacao_array[] = $temp;
122 } 130 }
123 131
124 - $retorno = "Novo"; 132 + $retorno = 'Novo';
125 } 133 }
126 134
127 $this->carga_horaria = $det_servidor['carga_horaria']; 135 $this->carga_horaria = $det_servidor['carga_horaria'];
@@ -131,23 +139,24 @@ class indice extends clsCadastro @@ -131,23 +139,24 @@ class indice extends clsCadastro
131 die; 139 die;
132 } 140 }
133 141
134 - $this->url_cancelar = "educar_servidor_det.php?cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_ref_cod_instituicao}";  
135 - $this->nome_url_cancelar = "Cancelar"; 142 + $this->url_cancelar = sprintf(
  143 + 'educar_servidor_det.php?cod_servidor=%d&ref_cod_instituicao=%d',
  144 + $this->ref_cod_servidor, $this->ref_ref_cod_instituicao);
  145 + $this->nome_url_cancelar = 'Cancelar';
136 146
137 return $retorno; 147 return $retorno;
138 } 148 }
139 149
140 -  
141 -  
142 - public function Gerar() { 150 + function Gerar()
  151 + {
143 $obj_inst = new clsPmieducarInstituicao($this->ref_ref_cod_instituicao); 152 $obj_inst = new clsPmieducarInstituicao($this->ref_ref_cod_instituicao);
144 $inst_det = $obj_inst->detalhe(); 153 $inst_det = $obj_inst->detalhe();
145 154
146 - $this->campoRotulo("nm_instituicao", "Institui&ccedil;&atilde;o", $inst_det['nm_instituicao']);  
147 - $this->campoOculto("ref_ref_cod_instituicao", $this->ref_ref_cod_instituicao); 155 + $this->campoRotulo('nm_instituicao', 'Instituição', $inst_det['nm_instituicao']);
  156 + $this->campoOculto('ref_ref_cod_instituicao', $this->ref_ref_cod_instituicao);
148 157
149 - $opcoes = array("" => "Selecione");  
150 - if (class_exists("clsPmieducarServidor")) { 158 + $opcoes = array('' => 'Selecione');
  159 + if (class_exists('clsPmieducarServidor')) {
151 $objTemp = new clsPmieducarServidor($this->ref_cod_servidor); 160 $objTemp = new clsPmieducarServidor($this->ref_cod_servidor);
152 $det = $objTemp->detalhe(); 161 $det = $objTemp->detalhe();
153 if ($det) { 162 if ($det) {
@@ -164,22 +173,32 @@ class indice extends clsCadastro @@ -164,22 +173,32 @@ class indice extends clsCadastro
164 } 173 }
165 } 174 }
166 175
167 - $this->campoRotulo("nm_servidor", "Servidor", $nm_servidor); 176 + $this->campoRotulo('nm_servidor', 'Servidor', $nm_servidor);
168 177
169 - $this->campoOculto("ref_cod_servidor", $this->ref_cod_servidor);  
170 - $this->campoOculto("professor",$this->professor); 178 + $this->campoOculto('ref_cod_servidor', $this->ref_cod_servidor);
  179 + $this->campoOculto('professor',$this->professor);
171 180
172 - $this->campoTextoInv("ref_cod_servidor_todos_", "Substituir por:", "",  
173 - 30, 255, TRUE, FALSE, FALSE, "", "<img border='0' onclick=\"pesquisa_valores_popless('educar_pesquisa_servidor_lst.php?campo1=ref_cod_servidor_todos&campo2=ref_cod_servidor_todos_&ref_cod_instituicao={$this->ref_ref_cod_instituicao}&ref_cod_servidor={$this->ref_cod_servidor}&tipo=livre&professor={$this->professor}', 'nome')\" src=\"imagens/lupa.png\">","","","" );  
174 - $this->campoOculto("ref_cod_servidor_todos", ""); 181 + $url = sprintf(
  182 + 'educar_pesquisa_servidor_lst.php?campo1=ref_cod_servidor_todos&campo2=ref_cod_servidor_todos_&ref_cod_instituicao=%d&ref_cod_servidor=%d&tipo=livre&professor=%d',
  183 + $this->ref_ref_cod_instituicao, $this->ref_cod_servidor, $this->professor
  184 + );
175 185
176 - $this->campoOculto("alocacao_array", serialize($this->alocacao_array));  
177 - $this->acao_enviar = 'acao2()';  
178 - } 186 + $img = sprintf(
  187 + '<img border="0" onclick="pesquisa_valores_popless(\'%s\', \'nome\')" src="imagens/lupa.png">',
  188 + $url
  189 + );
179 190
  191 + $this->campoTextoInv('ref_cod_servidor_todos_', 'Substituir por:', '',
  192 + 30, 255, TRUE, FALSE, FALSE, '', $img,
  193 + '', '', '');
  194 + $this->campoOculto('ref_cod_servidor_todos', '');
180 195
  196 + $this->campoOculto('alocacao_array', serialize($this->alocacao_array));
  197 + $this->acao_enviar = 'acao2()';
  198 + }
181 199
182 - public function Novo() { 200 + function Novo()
  201 + {
183 session_start(); 202 session_start();
184 $this->pessoa_logada = $_SESSION['id_pessoa']; 203 $this->pessoa_logada = $_SESSION['id_pessoa'];
185 session_write_close(); 204 session_write_close();
@@ -188,7 +207,8 @@ class indice extends clsCadastro @@ -188,7 +207,8 @@ class indice extends clsCadastro
188 $substituto = isset($_POST['ref_cod_servidor_todos']) ? $_POST['ref_cod_servidor_todos'] : NULL; 207 $substituto = isset($_POST['ref_cod_servidor_todos']) ? $_POST['ref_cod_servidor_todos'] : NULL;
189 208
190 $permissoes = new clsPermissoes(); 209 $permissoes = new clsPermissoes();
191 - $permissoes->permissao_cadastra(635, $this->pessoa_logada, 3, 'educar_servidor_alocacao_lst.php'); 210 + $permissoes->permissao_cadastra(635, $this->pessoa_logada, 3,
  211 + 'educar_servidor_alocacao_lst.php');
192 212
193 $this->alocacao_array = array(); 213 $this->alocacao_array = array();
194 if ($_POST['alocacao_array']) { 214 if ($_POST['alocacao_array']) {
@@ -218,7 +238,7 @@ class indice extends clsCadastro @@ -218,7 +238,7 @@ class indice extends clsCadastro
218 } 238 }
219 239
220 // Substituição do servidor no quadro de horários (caso seja professor) 240 // Substituição do servidor no quadro de horários (caso seja professor)
221 - if('true' == $professor) { 241 + if ('true' == $professor) {
222 $quadroHorarios = new clsPmieducarQuadroHorarioHorarios(NULL, NULL, NULL, 242 $quadroHorarios = new clsPmieducarQuadroHorarioHorarios(NULL, NULL, NULL,
223 NULL, NULL, NULL, $this->ref_ref_cod_instituicao, NULL, $this->ref_cod_servidor, 243 NULL, NULL, NULL, $this->ref_ref_cod_instituicao, NULL, $this->ref_cod_servidor,
224 NULL, NULL, NULL, NULL, 1, NULL, NULL); 244 NULL, NULL, NULL, NULL, 1, NULL, NULL);
@@ -234,115 +254,37 @@ class indice extends clsCadastro @@ -234,115 +254,37 @@ class indice extends clsCadastro
234 die(); 254 die();
235 } 255 }
236 256
  257 + function Editar()
  258 + {
  259 + return FALSE;
  260 + }
237 261
238 -  
239 - function Editar()  
240 - {  
241 - /*@session_start();  
242 - $this->pessoa_logada = $_SESSION['id_pessoa'];  
243 - @session_write_close();  
244 -  
245 - $obj_permissoes = new clsPermissoes();  
246 - $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 3, "educar_servidor_alocacao_lst.php" );  
247 -  
248 -  
249 - $obj = new clsPmieducarServidorAlocacao($this->cod_servidor_alocacao, $this->ref_ref_cod_instituicao, $this->pessoa_logada, $this->pessoa_logada, $this->ref_cod_escola, $this->ref_cod_servidor, $this->dia_semana, $this->hora_inicial, $this->hora_final, $this->data_cadastro, $this->data_exclusao, $this->ativo);  
250 - $editou = $obj->edita();  
251 - if( $editou )  
252 - {  
253 - $this->mensagem .= "Edi&ccedil;&atilde;o efetuada com sucesso.<br>";  
254 - header( "Location: educar_servidor_alocacao_lst.php" );  
255 - die();  
256 - return true;  
257 - }  
258 -  
259 - $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>";  
260 - echo "<!--\nErro ao editar clsPmieducarServidorAlocacao\nvalores obrigatorios\nif( is_numeric( $this->cod_servidor_alocacao ) && is_numeric( $this->ref_usuario_exc ) )\n-->";  
261 - */  
262 - return false;  
263 - }  
264 -  
265 - function Excluir()  
266 - {  
267 - /* @session_start();  
268 - $this->pessoa_logada = $_SESSION['id_pessoa'];  
269 - @session_write_close();  
270 -  
271 - $obj_permissoes = new clsPermissoes();  
272 - $obj_permissoes->permissao_excluir( 635, $this->pessoa_logada, 3, "educar_servidor_alocacao_lst.php" );  
273 -  
274 -  
275 - $obj = new clsPmieducarServidorAlocacao($this->cod_servidor_alocacao, $this->ref_ref_cod_instituicao, $this->pessoa_logada, $this->pessoa_logada, $this->ref_cod_escola, $this->ref_cod_servidor, $this->dia_semana, $this->hora_inicial, $this->hora_final, $this->data_cadastro, $this->data_exclusao, 0);  
276 - $excluiu = $obj->excluir();  
277 - if( $excluiu )  
278 - {  
279 - $this->mensagem .= "Exclus&atilde;o efetuada com sucesso.<br>";  
280 - header( "Location: educar_servidor_alocacao_lst.php" );  
281 - die();  
282 - return true;  
283 - }  
284 -  
285 - $this->mensagem = "Exclus&atilde;o n&atilde;o realizada.<br>";  
286 - echo "<!--\nErro ao excluir clsPmieducarServidorAlocacao\nvalores obrigatorios\nif( is_numeric( $this->cod_servidor_alocacao ) && is_numeric( $this->ref_usuario_exc ) )\n-->";  
287 - */  
288 - return false;  
289 -  
290 - } 262 + function Excluir()
  263 + {
  264 + return FALSE;
  265 + }
291 } 266 }
292 267
293 -// cria uma extensao da classe base 268 +// Instancia objeto de página
294 $pagina = new clsIndexBase(); 269 $pagina = new clsIndexBase();
295 -// cria o conteudo 270 +
  271 +// Instancia objeto de conteúdo
296 $miolo = new indice(); 272 $miolo = new indice();
297 -// adiciona o conteudo na clsBase  
298 -$pagina->addForm( $miolo );  
299 -// gera o html 273 +
  274 +// Atribui o conteúdo à página
  275 +$pagina->addForm($miolo);
  276 +
  277 +// Gera o código HTML
300 $pagina->MakeAll(); 278 $pagina->MakeAll();
301 ?> 279 ?>
302 -<script>  
303 -//setVisibility('tr_ref_cod_servidor_todos_',false);  
304 -  
305 -function trocaDisplay(id) 280 +<script type="text/javascript">
  281 +function acao2()
306 { 282 {
307 - if(getVisibility(id)){  
308 - setVisibility(id,false);  
309 - setAll('ref_cod_servidor_substituto',true);  
310 - document.getElementById('todos').value='false';  
311 - document.getElementById('trocar').src = 'imagens/i-educar/bot_subt_todos.gif';  
312 - document.getElementById('trocar').blur();  
313 - }  
314 - else{  
315 - setVisibility(id,true);  
316 - setAll('ref_cod_servidor_substituto',false);  
317 - document.getElementById('todos').value='true';  
318 - document.getElementById('trocar').src = image.src;  
319 - document.getElementById('trocar').blur();  
320 -  
321 - }  
322 -}  
323 -  
324 -function setAll(field,visibility){  
325 - var elements = window.parent.document.getElementsByName(field);  
326 -  
327 - for(var ct =0;ct < elements.length;ct++)  
328 - {  
329 - setVisibility(elements[ct].id,visibility);  
330 - }  
331 -}  
332 -  
333 -function acao2(){  
334 - //if( document.getElementById('todos').value == "true"){  
335 - if( document.getElementById('ref_cod_servidor_todos').value == ''){  
336 - alert("Selecione um servidor substituto!");  
337 - return false;  
338 - } 283 + if (document.getElementById('ref_cod_servidor_todos').value == ''){
  284 + alert("Selecione um servidor substituto!");
  285 + return false;
  286 + }
339 287
340 -// }  
341 - acao(); 288 + acao();
342 } 289 }
343 -  
344 -//var image = new Image();  
345 -//image.src = 'imagens/i-educar/bot_subt_horario.gif';  
346 -  
347 -  
348 </script> 290 </script>
349 \ No newline at end of file 291 \ No newline at end of file