Commit 1d95e57dd7a73c7206fad7ee7aad6ad91cbd33bf
1 parent
fc43375e
Exists in
master
Refactoring para coding standards
Showing
3 changed files
with
1052 additions
and
1079 deletions
Show diff stats
ieducar/intranet/educar_reserva_vaga_cad.php
| 1 | 1 | <?php |
| 2 | -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
| 3 | - * * | |
| 4 | - * @author Prefeitura Municipal de Itajaí * | |
| 5 | - * @updated 29/03/2007 * | |
| 6 | - * Pacote: i-PLB Software Público Livre e Brasileiro * | |
| 7 | - * * | |
| 8 | - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí * | |
| 9 | - * ctima@itajai.sc.gov.br * | |
| 10 | - * * | |
| 11 | - * Este programa é software livre, você pode redistribuí-lo e/ou * | |
| 12 | - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme * | |
| 13 | - * publicada pela Free Software Foundation, tanto a versão 2 da * | |
| 14 | - * Licença como (a seu critério) qualquer versão mais nova. * | |
| 15 | - * * | |
| 16 | - * Este programa é distribuído na expectativa de ser útil, mas SEM * | |
| 17 | - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- * | |
| 18 | - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- * | |
| 19 | - * sulte a Licença Pública Geral GNU para obter mais detalhes. * | |
| 20 | - * * | |
| 21 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU * | |
| 22 | - * junto com este programa. Se não, escreva para a Free Software * | |
| 23 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * | |
| 24 | - * 02111-1307, USA. * | |
| 25 | - * * | |
| 26 | - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
| 27 | -require_once ("include/clsBase.inc.php"); | |
| 28 | -require_once ("include/clsCadastro.inc.php"); | |
| 29 | -require_once ("include/clsBanco.inc.php"); | |
| 30 | -require_once( "include/pmieducar/geral.inc.php" ); | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * i-Educar - Sistema de gestão escolar | |
| 5 | + * | |
| 6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
| 7 | + * <ctima@itajai.sc.gov.br> | |
| 8 | + * | |
| 9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
| 10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
| 11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
| 12 | + * qualquer versão posterior. | |
| 13 | + * | |
| 14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
| 15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
| 16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
| 17 | + * do GNU para mais detalhes. | |
| 18 | + * | |
| 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 | |
| 21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
| 22 | + * | |
| 23 | + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> | |
| 24 | + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | |
| 25 | + * @package Core | |
| 26 | + * @subpackage ReservaVaga | |
| 27 | + * @since Arquivo disponível desde a versão 1.0.0 | |
| 28 | + * @version $Id$ | |
| 29 | + */ | |
| 30 | + | |
| 31 | +require_once 'include/clsBase.inc.php'; | |
| 32 | +require_once 'include/clsCadastro.inc.php'; | |
| 33 | +require_once 'include/clsBanco.inc.php'; | |
| 34 | +require_once 'include/pmieducar/geral.inc.php'; | |
| 31 | 35 | |
| 32 | 36 | class clsIndexBase extends clsBase |
| 33 | 37 | { |
| 34 | - function Formular() | |
| 35 | - { | |
| 36 | - $this->SetTitulo( "{$this->_instituicao} i-Educar - Reserva Vaga" ); | |
| 37 | - $this->processoAp = "639"; | |
| 38 | - } | |
| 38 | + function Formular() { | |
| 39 | + $this->SetTitulo($this->_instituicao . ' i-Educar - Reserva Vaga'); | |
| 40 | + $this->processoAp = '639'; | |
| 41 | + } | |
| 39 | 42 | } |
| 40 | 43 | |
| 41 | 44 | class indice extends clsCadastro |
| 42 | 45 | { |
| 43 | - /** | |
| 44 | - * Referencia pega da session para o idpes do usuario atual | |
| 45 | - * | |
| 46 | - * @var int | |
| 47 | - */ | |
| 48 | - var $pessoa_logada; | |
| 49 | - | |
| 50 | - var $ref_cod_escola; | |
| 51 | - var $ref_cod_serie; | |
| 52 | - var $ref_cod_aluno; | |
| 53 | - var $nm_aluno; | |
| 54 | - var $nm_aluno_; | |
| 55 | - | |
| 56 | - var $ref_cod_instituicao; | |
| 57 | - var $ref_cod_curso; | |
| 58 | - | |
| 59 | - var $passo; | |
| 60 | - | |
| 61 | - var $nm_aluno_ext; | |
| 62 | - var $cpf_responsavel; | |
| 63 | - var $tipo_aluno; | |
| 64 | - | |
| 65 | - function Inicializar() | |
| 66 | - { | |
| 67 | - $retorno = "Novo"; | |
| 68 | - @session_start(); | |
| 69 | - $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 70 | - @session_write_close(); | |
| 71 | - | |
| 72 | - $this->ref_cod_serie=$_GET["ref_cod_serie"]; | |
| 73 | - $this->ref_cod_escola=$_GET["ref_cod_escola"]; | |
| 74 | - | |
| 75 | - $obj_permissoes = new clsPermissoes(); | |
| 76 | - $obj_permissoes->permissao_cadastra( 639, $this->pessoa_logada, 7, "educar_reserva_vaga_lst.php" ); | |
| 77 | - | |
| 78 | -// $this->url_cancelar = "educar_reserva_vaga_lst.php"; | |
| 79 | -// $this->nome_url_cancelar = "Cancelar"; | |
| 80 | - return $retorno; | |
| 81 | - } | |
| 82 | - | |
| 83 | - function Gerar() | |
| 84 | - { | |
| 85 | - if ($this->ref_cod_aluno) | |
| 86 | - { | |
| 87 | - $obj_reserva_vaga = new clsPmieducarReservaVaga(); | |
| 88 | - $lst_reserva_vaga = $obj_reserva_vaga->lista( null,null,null,null,null,$this->ref_cod_aluno,null,null,null,null,1 ); | |
| 89 | - // verifica se o aluno já possui reserva alguma reserva ativa no sistema | |
| 90 | - if ( is_array($lst_reserva_vaga) ) | |
| 91 | - { | |
| 92 | - echo "<script> alert('Aluno já possui reserva de vaga!\\nNão é possivel realizar a reserva.'); window.location = 'educar_reserva_vaga_lst.php';</script>"; | |
| 93 | - die(); | |
| 94 | - } | |
| 95 | - echo "<script> alert('A reserva do aluno permanecerá ativa por apenas 2 dias!');</script>"; | |
| 96 | - } | |
| 97 | - $this->campoOculto("ref_cod_serie", $this->ref_cod_serie); | |
| 98 | - $this->campoOculto("ref_cod_escola", $this->ref_cod_escola); | |
| 99 | - | |
| 100 | -// $this->nm_aluno = $_POST["nm_aluno"]; | |
| 101 | - $this->nm_aluno = $this->nm_aluno_; | |
| 102 | - | |
| 103 | - $this->campoTexto("nm_aluno", "Aluno", $this->nm_aluno, 30, 255, false, false, false, "", "<img border=\"0\" onclick=\"pesquisa_aluno();\" id=\"ref_cod_aluno_lupa\" name=\"ref_cod_aluno_lupa\" src=\"imagens/lupa.png\"\/><span style='padding-left:20px;'><input type='button' value='Aluno externo' onclick='showAlunoExt(true);' class='botaolistagem'></span>","","",true); | |
| 104 | - | |
| 105 | - $this->campoOculto("nm_aluno_", $this->nm_aluno_); | |
| 106 | - $this->campoOculto("ref_cod_aluno", $this->ref_cod_aluno); | |
| 107 | - | |
| 108 | - $this->campoOculto("tipo_aluno", "i"); | |
| 109 | - | |
| 110 | - $this->campoTexto("nm_aluno_ext","Nome aluno", $this->nm_aluno_ext,50,255,false); | |
| 111 | - $this->campoCpf("cpf_responsavel","CPF responsável", $this->cpf_responsavel,false,"<span style='padding-left:20px;'><input type='button' value='Aluno interno' onclick='showAlunoExt(false);' class='botaolistagem'></span>"); | |
| 112 | - | |
| 113 | - $this->campoOculto("passo",1); | |
| 114 | - | |
| 115 | - $this->acao_enviar = 'acao2()'; | |
| 116 | - | |
| 117 | - $this->url_cancelar = "educar_reserva_vaga_lst.php"; | |
| 118 | - $this->nome_url_cancelar = "Cancelar"; | |
| 119 | - } | |
| 120 | - | |
| 121 | - function Novo() | |
| 122 | - { | |
| 123 | - @session_start(); | |
| 124 | - $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 125 | - @session_write_close(); | |
| 126 | - | |
| 127 | - if ($this->passo == 2) | |
| 128 | - return true; | |
| 129 | - | |
| 130 | - | |
| 131 | - $obj_reserva_vaga = new clsPmieducarReservaVaga( null,$this->ref_cod_escola,$this->ref_cod_serie,null,$this->pessoa_logada,$this->ref_cod_aluno,null,null,1, $this->nm_aluno_ext, idFederal2int($this->cpf_responsavel) ); | |
| 132 | - $cadastrou = $obj_reserva_vaga->cadastra(); | |
| 133 | - if( $cadastrou ) | |
| 134 | - { | |
| 135 | - $this->mensagem .= "Reserva de Vaga efetuada com sucesso.<br>"; | |
| 136 | - header( "Location: educar_reservada_vaga_det.php?cod_reserva_vaga={$cadastrou}" ); | |
| 137 | - die(); | |
| 138 | - return true; | |
| 139 | - } | |
| 140 | - | |
| 141 | - $this->mensagem = "Reserva de Vaga não realizada.<br>"; | |
| 142 | - return false; | |
| 143 | - } | |
| 46 | + /** | |
| 47 | + * Referência a usuário da sessão | |
| 48 | + * @var int | |
| 49 | + */ | |
| 50 | + var $pessoa_logada = NULL; | |
| 51 | + | |
| 52 | + var $ref_cod_escola; | |
| 53 | + var $ref_cod_serie; | |
| 54 | + var $ref_cod_aluno; | |
| 55 | + var $nm_aluno; | |
| 56 | + var $nm_aluno_; | |
| 57 | + | |
| 58 | + var $ref_cod_instituicao; | |
| 59 | + var $ref_cod_curso; | |
| 60 | + | |
| 61 | + var $passo; | |
| 62 | + | |
| 63 | + var $nm_aluno_ext; | |
| 64 | + var $cpf_responsavel; | |
| 65 | + var $tipo_aluno; | |
| 66 | + | |
| 67 | + function Inicializar() | |
| 68 | + { | |
| 69 | + $retorno = 'Novo'; | |
| 70 | + session_start(); | |
| 71 | + $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 72 | + session_write_close(); | |
| 73 | + | |
| 74 | + $this->ref_cod_serie = $_GET['ref_cod_serie']; | |
| 75 | + $this->ref_cod_escola = $_GET['ref_cod_escola']; | |
| 76 | + | |
| 77 | + $obj_permissoes = new clsPermissoes(); | |
| 78 | + $obj_permissoes->permissao_cadastra(639, $this->pessoa_logada, 7, | |
| 79 | + 'educar_reserva_vaga_lst.php'); | |
| 80 | + | |
| 81 | + return $retorno; | |
| 82 | + } | |
| 83 | + | |
| 84 | + function Gerar() | |
| 85 | + { | |
| 86 | + if ($this->ref_cod_aluno) { | |
| 87 | + $obj_reserva_vaga = new clsPmieducarReservaVaga(); | |
| 88 | + $lst_reserva_vaga = $obj_reserva_vaga->lista(NULL, NULL, NULL, NULL, NULL, | |
| 89 | + $this->ref_cod_aluno, NULL, NULL, NULL, NULL, 1); | |
| 90 | + | |
| 91 | + // Verifica se o aluno já possui reserva alguma reserva ativa no sistema | |
| 92 | + if (is_array($lst_reserva_vaga)) { | |
| 93 | + echo " | |
| 94 | + <script type='text/javascript'> | |
| 95 | + alert('Aluno já possui reserva de vaga!\\nNão é possivel realizar a reserva.'); | |
| 96 | + window.location = 'educar_reserva_vaga_lst.php'; | |
| 97 | + </script>"; | |
| 98 | + die(); | |
| 99 | + } | |
| 100 | + | |
| 101 | + echo " | |
| 102 | + <script type='text/javascript'> | |
| 103 | + alert('A reserva do aluno permanecerá ativa por apenas 2 dias!'); | |
| 104 | + </script>"; | |
| 105 | + } | |
| 106 | + | |
| 107 | + $this->campoOculto('ref_cod_serie', $this->ref_cod_serie); | |
| 108 | + $this->campoOculto('ref_cod_escola', $this->ref_cod_escola); | |
| 109 | + | |
| 110 | + $this->nm_aluno = $this->nm_aluno_; | |
| 111 | + | |
| 112 | + $this->campoTexto('nm_aluno', 'Aluno', $this->nm_aluno, 30, 255, FALSE, | |
| 113 | + FALSE, FALSE, '', "<img border=\"0\" onclick=\"pesquisa_aluno();\" id=\"ref_cod_aluno_lupa\" name=\"ref_cod_aluno_lupa\" src=\"imagens/lupa.png\"\/><span style='padding-left:20px;'><input type='button' value='Aluno externo' onclick='showAlunoExt(true);' class='botaolistagem'></span>", | |
| 114 | + '', '', TRUE); | |
| 115 | + | |
| 116 | + $this->campoOculto('nm_aluno_', $this->nm_aluno_); | |
| 117 | + $this->campoOculto('ref_cod_aluno', $this->ref_cod_aluno); | |
| 118 | + | |
| 119 | + $this->campoOculto('tipo_aluno', 'i'); | |
| 120 | + | |
| 121 | + $this->campoTexto('nm_aluno_ext', 'Nome aluno', $this->nm_aluno_ext, 50, 255, FALSE); | |
| 122 | + $this->campoCpf('cpf_responsavel', 'CPF responsável', | |
| 123 | + $this->cpf_responsavel, FALSE, "<span style='padding-left:20px;'><input type='button' value='Aluno interno' onclick='showAlunoExt(false);' class='botaolistagem'></span>"); | |
| 124 | + | |
| 125 | + $this->campoOculto('passo', 1); | |
| 126 | + | |
| 127 | + $this->acao_enviar = 'acao2()'; | |
| 128 | + | |
| 129 | + $this->url_cancelar = 'educar_reserva_vaga_lst.php'; | |
| 130 | + $this->nome_url_cancelar = 'Cancelar'; | |
| 131 | + } | |
| 132 | + | |
| 133 | + function Novo() | |
| 134 | + { | |
| 135 | + session_start(); | |
| 136 | + $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 137 | + session_write_close(); | |
| 138 | + | |
| 139 | + if ($this->passo == 2) { | |
| 140 | + return true; | |
| 141 | + } | |
| 142 | + | |
| 143 | + $obj_reserva_vaga = new clsPmieducarReservaVaga(NULL, $this->ref_cod_escola, | |
| 144 | + $this->ref_cod_serie, NULL, $this->pessoa_logada, $this->ref_cod_aluno, NULL, | |
| 145 | + NULL, 1, $this->nm_aluno_ext, idFederal2int($this->cpf_responsavel)); | |
| 146 | + | |
| 147 | + $cadastrou = $obj_reserva_vaga->cadastra(); | |
| 148 | + | |
| 149 | + if ($cadastrou) { | |
| 150 | + $this->mensagem .= 'Reserva de Vaga efetuada com sucesso.<br>'; | |
| 151 | + header('Location: educar_reservada_vaga_det.php?cod_reserva_vaga=' . $cadastrou); | |
| 152 | + die(); | |
| 153 | + } | |
| 154 | + | |
| 155 | + $this->mensagem = 'Reserva de Vaga não realizada.<br>'; | |
| 156 | + return FALSE; | |
| 157 | + } | |
| 144 | 158 | } |
| 145 | 159 | |
| 146 | -// cria uma extensao da classe base | |
| 160 | +// Instancia objeto de página | |
| 147 | 161 | $pagina = new clsIndexBase(); |
| 148 | -// cria o conteudo | |
| 162 | + | |
| 163 | +// Instancia objeto de conteúdo | |
| 149 | 164 | $miolo = new indice(); |
| 150 | -// adiciona o conteudo na clsBase | |
| 151 | -$pagina->addForm( $miolo ); | |
| 152 | -// gera o html | |
| 165 | + | |
| 166 | +// Atribui o conteúdo à página | |
| 167 | +$pagina->addForm($miolo); | |
| 168 | + | |
| 169 | +// Gera o código HTML | |
| 153 | 170 | $pagina->MakeAll(); |
| 154 | 171 | ?> |
| 155 | -<script> | |
| 156 | 172 | |
| 157 | -function pesquisa_aluno() | |
| 158 | -{ | |
| 159 | - pesquisa_valores_popless('educar_pesquisa_aluno.php') | |
| 173 | +<script type='text/javascript'> | |
| 174 | +function pesquisa_aluno() { | |
| 175 | + pesquisa_valores_popless('educar_pesquisa_aluno.php') | |
| 160 | 176 | } |
| 161 | 177 | |
| 162 | -function showAlunoExt(acao) | |
| 163 | -{ | |
| 164 | - | |
| 165 | - setVisibility('tr_nm_aluno_ext',acao); | |
| 166 | - setVisibility('tr_cpf_responsavel',acao); | |
| 167 | - setVisibility('tr_nm_aluno',!acao); | |
| 168 | - | |
| 169 | - document.getElementById('nm_aluno_ext').disabled = !acao; | |
| 170 | - document.getElementById('cpf_responsavel').disabled = !acao; | |
| 178 | +function showAlunoExt(acao) { | |
| 179 | + setVisibility('tr_nm_aluno_ext',acao); | |
| 180 | + setVisibility('tr_cpf_responsavel',acao); | |
| 181 | + setVisibility('tr_nm_aluno',!acao); | |
| 171 | 182 | |
| 172 | - document.getElementById('tipo_aluno').value = (acao == true ? 'e' : 'i'); | |
| 183 | + document.getElementById('nm_aluno_ext').disabled = !acao; | |
| 184 | + document.getElementById('cpf_responsavel').disabled = !acao; | |
| 173 | 185 | |
| 186 | + document.getElementById('tipo_aluno').value = (acao == true ? 'e' : 'i'); | |
| 174 | 187 | } |
| 175 | 188 | |
| 176 | - | |
| 177 | -setVisibility('tr_nm_aluno_ext',false); | |
| 178 | -setVisibility('tr_cpf_responsavel',false); | |
| 179 | - | |
| 180 | -function acao2() | |
| 181 | -{ | |
| 182 | - if(document.getElementById('tipo_aluno').value == 'e') | |
| 183 | - { | |
| 184 | - if(document.getElementById('nm_aluno_ext').value == '') | |
| 185 | - { | |
| 186 | - alert('Preencha o campo \'Nome aluno\' Corretamente'); | |
| 187 | - return false; | |
| 188 | - } | |
| 189 | - | |
| 190 | - if (! (/[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}/.test(document.formcadastro.cpf_responsavel.value) )) | |
| 191 | - { | |
| 192 | - alert('Preencha o campo \'CPF responsável\' Corretamente'); | |
| 193 | - return false; | |
| 194 | - } | |
| 195 | - else | |
| 196 | - { | |
| 197 | - if(! DvCpfOk( document.formcadastro.cpf_responsavel) ) | |
| 198 | - return false; | |
| 199 | - } | |
| 200 | - | |
| 201 | - document.getElementById('nm_aluno_').value = ''; | |
| 202 | - document.getElementById('ref_cod_aluno').value = ''; | |
| 203 | - | |
| 204 | - document.formcadastro.submit(); | |
| 205 | - } | |
| 206 | - else | |
| 207 | - { | |
| 208 | - document.getElementById('nm_aluno_ext').value = ''; | |
| 209 | - document.getElementById('cpf_responsavel').value = ''; | |
| 210 | - } | |
| 211 | - acao(); | |
| 212 | - | |
| 189 | +setVisibility('tr_nm_aluno_ext', false); | |
| 190 | +setVisibility('tr_cpf_responsavel', false); | |
| 191 | + | |
| 192 | +function acao2() { | |
| 193 | + if (document.getElementById('tipo_aluno').value == 'e') { | |
| 194 | + if (document.getElementById('nm_aluno_ext').value == '') { | |
| 195 | + alert('Preencha o campo \'Nome aluno\' Corretamente'); | |
| 196 | + return false; | |
| 197 | + } | |
| 198 | + | |
| 199 | + if (! (/[0-9]{3}\.[0-9]{3}\.[0-9]{3}-[0-9]{2}/.test(document.formcadastro.cpf_responsavel.value))) { | |
| 200 | + alert('Preencha o campo \'CPF responsável\' Corretamente'); | |
| 201 | + return false; | |
| 202 | + } | |
| 203 | + else { | |
| 204 | + if(! DvCpfOk( document.formcadastro.cpf_responsavel) ) | |
| 205 | + return false; | |
| 206 | + } | |
| 207 | + | |
| 208 | + document.getElementById('nm_aluno_').value = ''; | |
| 209 | + document.getElementById('ref_cod_aluno').value = ''; | |
| 210 | + | |
| 211 | + document.formcadastro.submit(); | |
| 212 | + } | |
| 213 | + else { | |
| 214 | + document.getElementById('nm_aluno_ext').value = ''; | |
| 215 | + document.getElementById('cpf_responsavel').value = ''; | |
| 216 | + } | |
| 217 | + acao(); | |
| 213 | 218 | } |
| 214 | 219 | </script> |
| 215 | 220 | \ No newline at end of file | ... | ... |
ieducar/intranet/educar_reserva_vaga_lst.php
| 1 | 1 | <?php |
| 2 | -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
| 3 | - * * | |
| 4 | - * @author Prefeitura Municipal de Itajaí * | |
| 5 | - * @updated 29/03/2007 * | |
| 6 | - * Pacote: i-PLB Software Público Livre e Brasileiro * | |
| 7 | - * * | |
| 8 | - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí * | |
| 9 | - * ctima@itajai.sc.gov.br * | |
| 10 | - * * | |
| 11 | - * Este programa é software livre, você pode redistribuí-lo e/ou * | |
| 12 | - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme * | |
| 13 | - * publicada pela Free Software Foundation, tanto a versão 2 da * | |
| 14 | - * Licença como (a seu critério) qualquer versão mais nova. * | |
| 15 | - * * | |
| 16 | - * Este programa é distribuído na expectativa de ser útil, mas SEM * | |
| 17 | - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- * | |
| 18 | - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- * | |
| 19 | - * sulte a Licença Pública Geral GNU para obter mais detalhes. * | |
| 20 | - * * | |
| 21 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU * | |
| 22 | - * junto com este programa. Se não, escreva para a Free Software * | |
| 23 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * | |
| 24 | - * 02111-1307, USA. * | |
| 25 | - * * | |
| 26 | - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
| 27 | -require_once ("include/clsBase.inc.php"); | |
| 28 | -require_once ("include/clsListagem.inc.php"); | |
| 29 | -require_once ("include/clsBanco.inc.php"); | |
| 30 | -require_once( "include/pmieducar/geral.inc.php" ); | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * i-Educar - Sistema de gestão escolar | |
| 5 | + * | |
| 6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
| 7 | + * <ctima@itajai.sc.gov.br> | |
| 8 | + * | |
| 9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
| 10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
| 11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
| 12 | + * qualquer versão posterior. | |
| 13 | + * | |
| 14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
| 15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
| 16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
| 17 | + * do GNU para mais detalhes. | |
| 18 | + * | |
| 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 | |
| 21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
| 22 | + * | |
| 23 | + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> | |
| 24 | + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | |
| 25 | + * @package Core | |
| 26 | + * @subpackage ReservaVaga | |
| 27 | + * @since Arquivo disponível desde a versão 1.0.0 | |
| 28 | + * @version $Id$ | |
| 29 | + */ | |
| 30 | + | |
| 31 | +require_once 'include/clsBase.inc.php'; | |
| 32 | +require_once 'include/clsListagem.inc.php'; | |
| 33 | +require_once 'include/clsBanco.inc.php'; | |
| 34 | +require_once 'include/pmieducar/geral.inc.php'; | |
| 31 | 35 | |
| 32 | 36 | class clsIndexBase extends clsBase |
| 33 | 37 | { |
| 34 | - function Formular() | |
| 35 | - { | |
| 36 | - $this->SetTitulo( "{$this->_instituicao} i-Educar - Reserva Vaga" ); | |
| 37 | - $this->processoAp = "639"; | |
| 38 | - } | |
| 38 | + public function Formular() { | |
| 39 | + $this->SetTitulo($this->_instituicao . ' i-Educar - Reserva Vaga'); | |
| 40 | + $this->processoAp = '639'; | |
| 41 | + } | |
| 39 | 42 | } |
| 40 | 43 | |
| 41 | 44 | class indice extends clsListagem |
| 42 | 45 | { |
| 43 | - /** | |
| 44 | - * Referencia pega da session para o idpes do usuario atual | |
| 45 | - * | |
| 46 | - * @var int | |
| 47 | - */ | |
| 48 | - var $pessoa_logada; | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * Titulo no topo da pagina | |
| 52 | - * | |
| 53 | - * @var int | |
| 54 | - */ | |
| 55 | - var $titulo; | |
| 56 | - | |
| 57 | - /** | |
| 58 | - * Quantidade de registros a ser apresentada em cada pagina | |
| 59 | - * | |
| 60 | - * @var int | |
| 61 | - */ | |
| 62 | - var $limite; | |
| 63 | - | |
| 64 | - /** | |
| 65 | - * Inicio dos registros a serem exibidos (limit) | |
| 66 | - * | |
| 67 | - * @var int | |
| 68 | - */ | |
| 69 | - var $offset; | |
| 70 | - | |
| 71 | - var $ref_cod_escola; | |
| 72 | - var $ref_cod_serie; | |
| 73 | - var $ref_usuario_exc; | |
| 74 | - var $ref_usuario_cad; | |
| 75 | - var $data_cadastro; | |
| 76 | - var $data_exclusao; | |
| 77 | - var $ativo; | |
| 78 | - var $ref_ref_cod_serie; | |
| 79 | - var $ref_cod_curso; | |
| 80 | - var $ref_cod_instituicao; | |
| 81 | - | |
| 82 | - function Gerar() | |
| 83 | - { | |
| 84 | - @session_start(); | |
| 85 | - $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 86 | - session_write_close(); | |
| 87 | - | |
| 88 | - $this->titulo = "Reserva Vaga - Listagem"; | |
| 89 | - | |
| 90 | - foreach( $_GET AS $var => $val ) // passa todos os valores obtidos no GET para atributos do objeto | |
| 91 | - $this->$var = ( $val === "" ) ? null: $val; | |
| 92 | - | |
| 93 | - $this->addBanner( "imagens/nvp_top_intranet.jpg", "imagens/nvp_vert_intranet.jpg", "Intranet" ); | |
| 94 | - | |
| 95 | - $lista_busca = array( | |
| 96 | - "Série", | |
| 97 | - "Curso" | |
| 98 | - ); | |
| 99 | - | |
| 100 | - $obj_permissao = new clsPermissoes(); | |
| 101 | - $nivel_usuario = $obj_permissao->nivel_acesso($this->pessoa_logada); | |
| 102 | - if ($nivel_usuario == 1) | |
| 103 | - { | |
| 104 | - $lista_busca[] = "Escola"; | |
| 105 | - $lista_busca[] = "Instituição"; | |
| 106 | - } | |
| 107 | - else if ($nivel_usuario == 2) | |
| 108 | - { | |
| 109 | - $lista_busca[] = "Escola"; | |
| 110 | - } | |
| 111 | - $this->addCabecalhos($lista_busca); | |
| 112 | - | |
| 113 | - $get_escola = true; | |
| 114 | -// $get_escola_curso = true; | |
| 115 | - $get_curso = true; | |
| 116 | - $get_escola_curso_serie = true; | |
| 117 | - include("include/pmieducar/educar_campo_lista.php"); | |
| 118 | - | |
| 119 | - // Paginador | |
| 120 | - $this->limite = 20; | |
| 121 | - $this->offset = ( $_GET["pagina_{$this->nome}"] ) ? $_GET["pagina_{$this->nome}"]*$this->limite-$this->limite: 0; | |
| 122 | - | |
| 123 | - $obj_escola_serie = new clsPmieducarEscolaSerie(); | |
| 124 | -// $obj_escola_serie->setOrderby( "hora_inicial ASC" ); | |
| 125 | - $obj_escola_serie->setLimite( $this->limite, $this->offset ); | |
| 126 | - | |
| 127 | - $lista = $obj_escola_serie->lista( | |
| 128 | - $this->ref_cod_escola, | |
| 129 | - $this->ref_ref_cod_serie, | |
| 130 | - null, | |
| 131 | - null, | |
| 132 | - null, | |
| 133 | - null, | |
| 134 | - null, | |
| 135 | - null, | |
| 136 | - null, | |
| 137 | - null, | |
| 138 | - null, | |
| 139 | - null, | |
| 140 | - 1, | |
| 141 | - null, | |
| 142 | - null, | |
| 143 | - null, | |
| 144 | - null, | |
| 145 | - $this->ref_cod_instituicao, | |
| 146 | - $this->ref_cod_curso | |
| 147 | - ); | |
| 148 | - | |
| 149 | - $total = $obj_escola_serie->_total; | |
| 150 | - | |
| 151 | - // monta a lista | |
| 152 | - if( is_array( $lista ) && count( $lista ) ) | |
| 153 | - { | |
| 154 | - foreach ( $lista AS $registro ) | |
| 155 | - { | |
| 156 | - if( class_exists( "clsPmieducarSerie" ) ) | |
| 157 | - { | |
| 158 | - $obj_ref_cod_serie = new clsPmieducarSerie( $registro["ref_cod_serie"] ); | |
| 159 | - $det_ref_cod_serie = $obj_ref_cod_serie->detalhe(); | |
| 160 | - $nm_serie = $det_ref_cod_serie["nm_serie"]; | |
| 161 | - } | |
| 162 | - else | |
| 163 | - { | |
| 164 | - $registro["ref_cod_serie"] = "Erro na geração"; | |
| 165 | - echo "<!--\nErro\nClasse não existente: clsPmieducarSerie\n-->"; | |
| 166 | - } | |
| 167 | - if( class_exists( "clsPmieducarCurso" ) ) | |
| 168 | - { | |
| 169 | - $obj_curso = new clsPmieducarCurso( $registro["ref_cod_curso"] ); | |
| 170 | - $det_curso = $obj_curso->detalhe(); | |
| 171 | - $registro["ref_cod_curso"] = $det_curso["nm_curso"]; | |
| 172 | - } | |
| 173 | - else | |
| 174 | - { | |
| 175 | - $registro["ref_cod_serie"] = "Erro na geração"; | |
| 176 | - echo "<!--\nErro\nClasse não existente: clsPmieducarSerie\n-->"; | |
| 177 | - } | |
| 178 | - if( class_exists( "clsPmieducarEscola" ) ) | |
| 179 | - { | |
| 180 | - $obj_ref_cod_escola = new clsPmieducarEscola( $registro["ref_cod_escola"] ); | |
| 181 | - $det_ref_cod_escola = $obj_ref_cod_escola->detalhe(); | |
| 182 | - $nm_escola = $det_ref_cod_escola["nome"]; | |
| 183 | - } | |
| 184 | - else | |
| 185 | - { | |
| 186 | - $registro["ref_cod_escola"] = "Erro na geração"; | |
| 187 | - echo "<!--\nErro\nClasse não existente: clsPmieducarEscola\n-->"; | |
| 188 | - } | |
| 189 | - if( class_exists( "clsPmieducarInstituicao" ) ) | |
| 190 | - { | |
| 191 | - $obj_ref_cod_instituicao = new clsPmieducarInstituicao( $registro["ref_cod_instituicao"] ); | |
| 192 | - $det_ref_cod_instituicao = $obj_ref_cod_instituicao->detalhe(); | |
| 193 | - $registro["ref_cod_instituicao"] = $det_ref_cod_instituicao["nm_instituicao"]; | |
| 194 | - } | |
| 195 | - else | |
| 196 | - { | |
| 197 | - $registro["ref_cod_escola"] = "Erro na geração"; | |
| 198 | - echo "<!--\nErro\nClasse não existente: clsPmieducarEscola\n-->"; | |
| 199 | - } | |
| 200 | - | |
| 201 | - $lista_busca = array( | |
| 202 | - "<a href=\"educar_reserva_vaga_det.php?ref_cod_escola={$registro["ref_cod_escola"]}&ref_cod_serie={$registro["ref_cod_serie"]}\">{$nm_serie}</a>", | |
| 203 | - "<a href=\"educar_reserva_vaga_det.php?ref_cod_escola={$registro["ref_cod_escola"]}&ref_cod_serie={$registro["ref_cod_serie"]}\">{$registro["ref_cod_curso"]}</a>" | |
| 204 | - ); | |
| 205 | - | |
| 206 | - if ($nivel_usuario == 1) | |
| 207 | - { | |
| 208 | - $lista_busca[] = "<a href=\"educar_reserva_vaga_det.php?ref_cod_escola={$registro["ref_cod_escola"]}&ref_cod_serie={$registro["ref_cod_serie"]}\">{$nm_escola}</a>"; | |
| 209 | - $lista_busca[] = "<a href=\"educar_reserva_vaga_det.php?ref_cod_escola={$registro["ref_cod_escola"]}&ref_cod_serie={$registro["ref_cod_serie"]}\">{$registro["ref_cod_instituicao"]}</a>"; | |
| 210 | - } | |
| 211 | - else if ($nivel_usuario == 2) | |
| 212 | - { | |
| 213 | - $lista_busca[] = "<a href=\"educar_reserva_vaga_det.php?ref_cod_escola={$registro["ref_cod_escola"]}&ref_cod_serie={$registro["ref_cod_serie"]}\">{$nm_escola}</a>"; | |
| 214 | - } | |
| 215 | - $this->addLinhas($lista_busca); | |
| 216 | - } | |
| 217 | - } | |
| 218 | - $this->addPaginador2( "educar_reserva_vaga_lst.php", $total, $_GET, $this->nome, $this->limite ); | |
| 219 | - $this->largura = "100%"; | |
| 220 | - } | |
| 46 | + /** | |
| 47 | + * Referência a usuário da sessão | |
| 48 | + * @var int | |
| 49 | + */ | |
| 50 | + var $pessoa_logada = NULL; | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Título no topo da página | |
| 54 | + * @var string | |
| 55 | + */ | |
| 56 | + var $titulo = ''; | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * Limite de registros por página | |
| 60 | + * @var int | |
| 61 | + */ | |
| 62 | + var $limite = 0; | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * Início dos registros a serem exibidos (limit) | |
| 66 | + * @var int | |
| 67 | + */ | |
| 68 | + var $offset = 0; | |
| 69 | + | |
| 70 | + var $ref_cod_escola; | |
| 71 | + var $ref_cod_serie; | |
| 72 | + var $ref_usuario_exc; | |
| 73 | + var $ref_usuario_cad; | |
| 74 | + var $data_cadastro; | |
| 75 | + var $data_exclusao; | |
| 76 | + var $ativo; | |
| 77 | + var $ref_ref_cod_serie; | |
| 78 | + var $ref_cod_curso; | |
| 79 | + var $ref_cod_instituicao; | |
| 80 | + | |
| 81 | + function Gerar() | |
| 82 | + { | |
| 83 | + @session_start(); | |
| 84 | + $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 85 | + session_write_close(); | |
| 86 | + | |
| 87 | + $this->titulo = "Reserva Vaga - Listagem"; | |
| 88 | + | |
| 89 | + foreach ($_GET as $var => $val) // passa todos os valores obtidos no GET para atributos do objeto | |
| 90 | + $this->$var = ($val === '') ? NULL : $val; | |
| 91 | + | |
| 92 | + $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg', 'Intranet'); | |
| 93 | + | |
| 94 | + $lista_busca = array( | |
| 95 | + "Série", | |
| 96 | + "Curso" | |
| 97 | + ); | |
| 98 | + | |
| 99 | + $obj_permissao = new clsPermissoes(); | |
| 100 | + $nivel_usuario = $obj_permissao->nivel_acesso($this->pessoa_logada); | |
| 101 | + if ($nivel_usuario == 1) { | |
| 102 | + $lista_busca[] = 'Escola'; | |
| 103 | + $lista_busca[] = 'Instituição'; | |
| 104 | + } | |
| 105 | + elseif ($nivel_usuario == 2) { | |
| 106 | + $lista_busca[] = "Escola"; | |
| 107 | + } | |
| 108 | + $this->addCabecalhos($lista_busca); | |
| 109 | + | |
| 110 | + $get_escola = TRUE; | |
| 111 | + $get_curso = TRUE; | |
| 112 | + $get_escola_curso_serie = TRUE; | |
| 113 | + include 'include/pmieducar/educar_campo_lista.php'; | |
| 114 | + | |
| 115 | + // Paginador | |
| 116 | + $this->limite = 20; | |
| 117 | + $this->offset = $_GET['pagina_' . $this->nome] ? | |
| 118 | + $_GET['pagina_' . $this->nome] * $this->limite - $this->limite : | |
| 119 | + 0; | |
| 120 | + | |
| 121 | + $obj_escola_serie = new clsPmieducarEscolaSerie(); | |
| 122 | + $obj_escola_serie->setLimite($this->limite, $this->offset); | |
| 123 | + | |
| 124 | + $lista = $obj_escola_serie->lista( | |
| 125 | + $this->ref_cod_escola, | |
| 126 | + $this->ref_ref_cod_serie, | |
| 127 | + NULL, | |
| 128 | + NULL, | |
| 129 | + NULL, | |
| 130 | + NULL, | |
| 131 | + NULL, | |
| 132 | + NULL, | |
| 133 | + NULL, | |
| 134 | + NULL, | |
| 135 | + NULL, | |
| 136 | + NULL, | |
| 137 | + 1, | |
| 138 | + NULL, | |
| 139 | + NULL, | |
| 140 | + NULL, | |
| 141 | + NULL, | |
| 142 | + $this->ref_cod_instituicao, | |
| 143 | + $this->ref_cod_curso | |
| 144 | + ); | |
| 145 | + | |
| 146 | + $total = $obj_escola_serie->_total; | |
| 147 | + | |
| 148 | + // monta a lista | |
| 149 | + if (is_array($lista) && count($lista)) { | |
| 150 | + foreach ($lista as $registro) { | |
| 151 | + if (class_exists('clsPmieducarSerie')) { | |
| 152 | + $obj_ref_cod_serie = new clsPmieducarSerie($registro['ref_cod_serie']); | |
| 153 | + $det_ref_cod_serie = $obj_ref_cod_serie->detalhe(); | |
| 154 | + $nm_serie = $det_ref_cod_serie['nm_serie']; | |
| 155 | + } | |
| 156 | + else { | |
| 157 | + $registro['ref_cod_serie'] = "Erro na geração"; | |
| 158 | + echo "<!--\nErro\nClasse não existente: clsPmieducarSerie\n-->"; | |
| 159 | + } | |
| 160 | + | |
| 161 | + if (class_exists('clsPmieducarCurso')) { | |
| 162 | + $obj_curso = new clsPmieducarCurso( $registro["ref_cod_curso"] ); | |
| 163 | + $det_curso = $obj_curso->detalhe(); | |
| 164 | + $registro["ref_cod_curso"] = $det_curso["nm_curso"]; | |
| 165 | + } | |
| 166 | + else { | |
| 167 | + $registro["ref_cod_serie"] = "Erro na geração"; | |
| 168 | + echo "<!--\nErro\nClasse não existente: clsPmieducarSerie\n-->"; | |
| 169 | + } | |
| 170 | + | |
| 171 | + if (class_exists('clsPmieducarEscola')) { | |
| 172 | + $obj_ref_cod_escola = new clsPmieducarEscola( $registro["ref_cod_escola"] ); | |
| 173 | + $det_ref_cod_escola = $obj_ref_cod_escola->detalhe(); | |
| 174 | + $nm_escola = $det_ref_cod_escola["nome"]; | |
| 175 | + } | |
| 176 | + else { | |
| 177 | + $registro["ref_cod_escola"] = "Erro na geração"; | |
| 178 | + echo "<!--\nErro\nClasse não existente: clsPmieducarEscola\n-->"; | |
| 179 | + } | |
| 180 | + | |
| 181 | + if (class_exists('clsPmieducarInstituicao')) { | |
| 182 | + $obj_ref_cod_instituicao = new clsPmieducarInstituicao( $registro["ref_cod_instituicao"] ); | |
| 183 | + $det_ref_cod_instituicao = $obj_ref_cod_instituicao->detalhe(); | |
| 184 | + $registro["ref_cod_instituicao"] = $det_ref_cod_instituicao["nm_instituicao"]; | |
| 185 | + } | |
| 186 | + else { | |
| 187 | + $registro["ref_cod_escola"] = "Erro na geração"; | |
| 188 | + echo "<!--\nErro\nClasse não existente: clsPmieducarEscola\n-->"; | |
| 189 | + } | |
| 190 | + | |
| 191 | + $lista_busca = array( | |
| 192 | + "<a href=\"educar_reserva_vaga_det.php?ref_cod_escola={$registro["ref_cod_escola"]}&ref_cod_serie={$registro["ref_cod_serie"]}\">{$nm_serie}</a>", | |
| 193 | + "<a href=\"educar_reserva_vaga_det.php?ref_cod_escola={$registro["ref_cod_escola"]}&ref_cod_serie={$registro["ref_cod_serie"]}\">{$registro["ref_cod_curso"]}</a>" | |
| 194 | + ); | |
| 195 | + | |
| 196 | + if ($nivel_usuario == 1) { | |
| 197 | + $lista_busca[] = "<a href=\"educar_reserva_vaga_det.php?ref_cod_escola={$registro["ref_cod_escola"]}&ref_cod_serie={$registro["ref_cod_serie"]}\">{$nm_escola}</a>"; | |
| 198 | + $lista_busca[] = "<a href=\"educar_reserva_vaga_det.php?ref_cod_escola={$registro["ref_cod_escola"]}&ref_cod_serie={$registro["ref_cod_serie"]}\">{$registro["ref_cod_instituicao"]}</a>"; | |
| 199 | + } | |
| 200 | + else if ($nivel_usuario == 2) { | |
| 201 | + $lista_busca[] = "<a href=\"educar_reserva_vaga_det.php?ref_cod_escola={$registro["ref_cod_escola"]}&ref_cod_serie={$registro["ref_cod_serie"]}\">{$nm_escola}</a>"; | |
| 202 | + } | |
| 203 | + $this->addLinhas($lista_busca); | |
| 204 | + } | |
| 205 | + } | |
| 206 | + | |
| 207 | + $this->addPaginador2('educar_reserva_vaga_lst.php', $total, $_GET, $this->nome, $this->limite); | |
| 208 | + $this->largura = "100%"; | |
| 209 | + } | |
| 221 | 210 | } |
| 222 | -// cria uma extensao da classe base | |
| 211 | + | |
| 212 | +// Instancia objeto de página | |
| 223 | 213 | $pagina = new clsIndexBase(); |
| 224 | -// cria o conteudo | |
| 214 | + | |
| 215 | +// Instancia objeto de conteúdo | |
| 225 | 216 | $miolo = new indice(); |
| 226 | -// adiciona o conteudo na clsBase | |
| 227 | -$pagina->addForm( $miolo ); | |
| 228 | -// gera o html | |
| 217 | + | |
| 218 | +// Atribui o conteúdo à página | |
| 219 | +$pagina->addForm($miolo); | |
| 220 | + | |
| 221 | +// Gera o código HTML | |
| 229 | 222 | $pagina->MakeAll(); |
| 230 | 223 | ?> |
| 231 | -<script> | |
| 232 | 224 | |
| 233 | -document.getElementById('ref_cod_escola').onchange = function() | |
| 234 | -{ | |
| 235 | - getEscolaCurso(); | |
| 225 | +<script type='text/javascript'> | |
| 226 | +document.getElementById('ref_cod_escola').onchange = function() { | |
| 227 | + getEscolaCurso(); | |
| 236 | 228 | } |
| 237 | 229 | |
| 238 | -document.getElementById('ref_cod_curso').onchange = function() | |
| 239 | -{ | |
| 240 | - getEscolaCursoSerie(); | |
| 230 | +document.getElementById('ref_cod_curso').onchange = function() { | |
| 231 | + getEscolaCursoSerie(); | |
| 241 | 232 | } |
| 242 | - | |
| 243 | 233 | </script> |
| 244 | 234 | \ No newline at end of file | ... | ... |
ieducar/intranet/include/pmieducar/clsPmieducarReservaVaga.inc.php
| 1 | 1 | <?php |
| 2 | -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
| 3 | -* * | |
| 4 | -* @author Prefeitura Municipal de Itajaí * | |
| 5 | -* @updated 29/03/2007 * | |
| 6 | -* Pacote: i-PLB Software Público Livre e Brasileiro * | |
| 7 | -* * | |
| 8 | -* Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí * | |
| 9 | -* ctima@itajai.sc.gov.br * | |
| 10 | -* * | |
| 11 | -* Este programa é software livre, você pode redistribuí-lo e/ou * | |
| 12 | -* modificá-lo sob os termos da Licença Pública Geral GNU, conforme * | |
| 13 | -* publicada pela Free Software Foundation, tanto a versão 2 da * | |
| 14 | -* Licença como (a seu critério) qualquer versão mais nova. * | |
| 15 | -* * | |
| 16 | -* Este programa é distribuído na expectativa de ser útil, mas SEM * | |
| 17 | -* QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- * | |
| 18 | -* ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- * | |
| 19 | -* sulte a Licença Pública Geral GNU para obter mais detalhes. * | |
| 20 | -* * | |
| 21 | -* Você deve ter recebido uma cópia da Licença Pública Geral GNU * | |
| 22 | -* junto com este programa. Se não, escreva para a Free Software * | |
| 23 | -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * | |
| 24 | -* 02111-1307, USA. * | |
| 25 | -* * | |
| 26 | -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
| 27 | -/** | |
| 28 | -* @author Prefeitura Municipal de Itajaí | |
| 29 | -* | |
| 30 | -* Criado em 26/06/2006 16:19 pelo gerador automatico de classes | |
| 31 | -*/ | |
| 32 | 2 | |
| 33 | -require_once( "include/pmieducar/geral.inc.php" ); | |
| 3 | +/** | |
| 4 | + * i-Educar - Sistema de gestão escolar | |
| 5 | + * | |
| 6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
| 7 | + * <ctima@itajai.sc.gov.br> | |
| 8 | + * | |
| 9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
| 10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
| 11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
| 12 | + * qualquer versão posterior. | |
| 13 | + * | |
| 14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
| 15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
| 16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
| 17 | + * do GNU para mais detalhes. | |
| 18 | + * | |
| 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 | |
| 21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
| 22 | + * | |
| 23 | + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> | |
| 24 | + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | |
| 25 | + * @package Core | |
| 26 | + * @subpackage pmieducar | |
| 27 | + * @subpackage ReservaVaga | |
| 28 | + * @since Arquivo disponível desde a versão 1.0.0 | |
| 29 | + * @version $Id$ | |
| 30 | + */ | |
| 31 | + | |
| 32 | +require_once 'include/pmieducar/geral.inc.php'; | |
| 34 | 33 | |
| 34 | +/** | |
| 35 | + * clsPmieducarReservaVaga class. | |
| 36 | + * | |
| 37 | + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> | |
| 38 | + * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL | |
| 39 | + * @package Core | |
| 40 | + * @subpackage pmieducar | |
| 41 | + * @subpackage ReservaVaga | |
| 42 | + * @since Classe disponível desde a versão 1.0.0 | |
| 43 | + * @version $Id$ | |
| 44 | + */ | |
| 35 | 45 | class clsPmieducarReservaVaga |
| 36 | 46 | { |
| 37 | - var $cod_reserva_vaga; | |
| 38 | - var $ref_ref_cod_escola; | |
| 39 | - var $ref_ref_cod_serie; | |
| 40 | - var $ref_usuario_exc; | |
| 41 | - var $ref_usuario_cad; | |
| 42 | - var $ref_cod_aluno; | |
| 43 | - var $data_cadastro; | |
| 44 | - var $data_exclusao; | |
| 45 | - var $ativo; | |
| 46 | - var $nm_aluno; | |
| 47 | - var $cpf_responsavel; | |
| 48 | - | |
| 49 | - // propriedades padrao | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * Armazena o total de resultados obtidos na ultima chamada ao metodo lista | |
| 53 | - * | |
| 54 | - * @var int | |
| 55 | - */ | |
| 56 | - var $_total; | |
| 57 | - | |
| 58 | - /** | |
| 59 | - * Nome do schema | |
| 60 | - * | |
| 61 | - * @var string | |
| 62 | - */ | |
| 63 | - var $_schema; | |
| 64 | - | |
| 65 | - /** | |
| 66 | - * Nome da tabela | |
| 67 | - * | |
| 68 | - * @var string | |
| 69 | - */ | |
| 70 | - var $_tabela; | |
| 71 | - | |
| 72 | - /** | |
| 73 | - * Lista separada por virgula, com os campos que devem ser selecionados na proxima chamado ao metodo lista | |
| 74 | - * | |
| 75 | - * @var string | |
| 76 | - */ | |
| 77 | - var $_campos_lista; | |
| 78 | - | |
| 79 | - /** | |
| 80 | - * Lista com todos os campos da tabela separados por virgula, padrao para selecao no metodo lista | |
| 81 | - * | |
| 82 | - * @var string | |
| 83 | - */ | |
| 84 | - var $_todos_campos; | |
| 85 | - | |
| 86 | - /** | |
| 87 | - * Valor que define a quantidade de registros a ser retornada pelo metodo lista | |
| 88 | - * | |
| 89 | - * @var int | |
| 90 | - */ | |
| 91 | - var $_limite_quantidade; | |
| 92 | - | |
| 93 | - /** | |
| 94 | - * Define o valor de offset no retorno dos registros no metodo lista | |
| 95 | - * | |
| 96 | - * @var int | |
| 97 | - */ | |
| 98 | - var $_limite_offset; | |
| 99 | - | |
| 100 | - /** | |
| 101 | - * Define o campo padrao para ser usado como padrao de ordenacao no metodo lista | |
| 102 | - * | |
| 103 | - * @var string | |
| 104 | - */ | |
| 105 | - var $_campo_order_by; | |
| 106 | - | |
| 107 | - | |
| 108 | - /** | |
| 109 | - * Construtor (PHP 4) | |
| 110 | - * | |
| 111 | - * @return object | |
| 112 | - */ | |
| 113 | - function clsPmieducarReservaVaga( $cod_reserva_vaga = null, $ref_ref_cod_escola = null, $ref_ref_cod_serie = null, $ref_usuario_exc = null, $ref_usuario_cad = null, $ref_cod_aluno = null, $data_cadastro = null, $data_exclusao = null, $ativo = null, $nm_aluno = null, $cpf_responsavel = null ) | |
| 114 | - { | |
| 115 | - $db = new clsBanco(); | |
| 116 | - $this->_schema = "pmieducar."; | |
| 117 | - $this->_tabela = "{$this->_schema}reserva_vaga"; | |
| 118 | - | |
| 119 | - $this->_campos_lista = $this->_todos_campos = "rv.cod_reserva_vaga, rv.ref_ref_cod_escola, rv.ref_ref_cod_serie, rv.ref_usuario_exc, rv.ref_usuario_cad, rv.ref_cod_aluno, rv.data_cadastro, rv.data_exclusao, rv.ativo, rv.nm_aluno, rv.cpf_responsavel"; | |
| 120 | - | |
| 121 | - if( is_numeric( $ref_ref_cod_serie ) && is_numeric( $ref_ref_cod_escola ) ) | |
| 122 | - { | |
| 123 | - if( class_exists( "clsPmieducarEscolaSerie" ) ) | |
| 124 | - { | |
| 125 | - $tmp_obj = new clsPmieducarEscolaSerie( $ref_ref_cod_escola, $ref_ref_cod_serie ); | |
| 126 | - if( method_exists( $tmp_obj, "existe") ) | |
| 127 | - { | |
| 128 | - if( $tmp_obj->existe() ) | |
| 129 | - { | |
| 130 | - $this->ref_ref_cod_serie = $ref_ref_cod_serie; | |
| 131 | - $this->ref_ref_cod_escola = $ref_ref_cod_escola; | |
| 132 | - } | |
| 133 | - } | |
| 134 | - else if( method_exists( $tmp_obj, "detalhe") ) | |
| 135 | - { | |
| 136 | - if( $tmp_obj->detalhe() ) | |
| 137 | - { | |
| 138 | - $this->ref_ref_cod_serie = $ref_ref_cod_serie; | |
| 139 | - $this->ref_ref_cod_escola = $ref_ref_cod_escola; | |
| 140 | - } | |
| 141 | - } | |
| 142 | - } | |
| 143 | - else | |
| 144 | - { | |
| 145 | - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.escola_serie WHERE ref_cod_serie = '{$ref_ref_cod_serie}' AND ref_cod_escola = '{$ref_ref_cod_escola}'" ) ) | |
| 146 | - { | |
| 147 | - $this->ref_ref_cod_serie = $ref_ref_cod_serie; | |
| 148 | - $this->ref_ref_cod_escola = $ref_ref_cod_escola; | |
| 149 | - } | |
| 150 | - } | |
| 151 | - } | |
| 152 | - if( is_numeric( $ref_usuario_exc ) ) | |
| 153 | - { | |
| 154 | - if( class_exists( "clsPmieducarUsuario" ) ) | |
| 155 | - { | |
| 156 | - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_exc ); | |
| 157 | - if( method_exists( $tmp_obj, "existe") ) | |
| 158 | - { | |
| 159 | - if( $tmp_obj->existe() ) | |
| 160 | - { | |
| 161 | - $this->ref_usuario_exc = $ref_usuario_exc; | |
| 162 | - } | |
| 163 | - } | |
| 164 | - else if( method_exists( $tmp_obj, "detalhe") ) | |
| 165 | - { | |
| 166 | - if( $tmp_obj->detalhe() ) | |
| 167 | - { | |
| 168 | - $this->ref_usuario_exc = $ref_usuario_exc; | |
| 169 | - } | |
| 170 | - } | |
| 171 | - } | |
| 172 | - else | |
| 173 | - { | |
| 174 | - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'" ) ) | |
| 175 | - { | |
| 176 | - $this->ref_usuario_exc = $ref_usuario_exc; | |
| 177 | - } | |
| 178 | - } | |
| 179 | - } | |
| 180 | - if( is_numeric( $ref_usuario_cad ) ) | |
| 181 | - { | |
| 182 | - if( class_exists( "clsPmieducarUsuario" ) ) | |
| 183 | - { | |
| 184 | - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_cad ); | |
| 185 | - if( method_exists( $tmp_obj, "existe") ) | |
| 186 | - { | |
| 187 | - if( $tmp_obj->existe() ) | |
| 188 | - { | |
| 189 | - $this->ref_usuario_cad = $ref_usuario_cad; | |
| 190 | - } | |
| 191 | - } | |
| 192 | - else if( method_exists( $tmp_obj, "detalhe") ) | |
| 193 | - { | |
| 194 | - if( $tmp_obj->detalhe() ) | |
| 195 | - { | |
| 196 | - $this->ref_usuario_cad = $ref_usuario_cad; | |
| 197 | - } | |
| 198 | - } | |
| 199 | - } | |
| 200 | - else | |
| 201 | - { | |
| 202 | - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'" ) ) | |
| 203 | - { | |
| 204 | - $this->ref_usuario_cad = $ref_usuario_cad; | |
| 205 | - } | |
| 206 | - } | |
| 207 | - } | |
| 208 | - if( is_numeric( $ref_cod_aluno ) ) | |
| 209 | - { | |
| 210 | - if( class_exists( "clsPmieducarAluno" ) ) | |
| 211 | - { | |
| 212 | - $tmp_obj = new clsPmieducarAluno( $ref_cod_aluno ); | |
| 213 | - if( method_exists( $tmp_obj, "existe") ) | |
| 214 | - { | |
| 215 | - if( $tmp_obj->existe() ) | |
| 216 | - { | |
| 217 | - $this->ref_cod_aluno = $ref_cod_aluno; | |
| 218 | - } | |
| 219 | - } | |
| 220 | - else if( method_exists( $tmp_obj, "detalhe") ) | |
| 221 | - { | |
| 222 | - if( $tmp_obj->detalhe() ) | |
| 223 | - { | |
| 224 | - $this->ref_cod_aluno = $ref_cod_aluno; | |
| 225 | - } | |
| 226 | - } | |
| 227 | - } | |
| 228 | - else | |
| 229 | - { | |
| 230 | - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.aluno WHERE cod_aluno = '{$ref_cod_aluno}'" ) ) | |
| 231 | - { | |
| 232 | - $this->ref_cod_aluno = $ref_cod_aluno; | |
| 233 | - } | |
| 234 | - } | |
| 235 | - } | |
| 236 | - | |
| 237 | - | |
| 238 | - if( is_numeric( $cod_reserva_vaga ) ) | |
| 239 | - { | |
| 240 | - $this->cod_reserva_vaga = $cod_reserva_vaga; | |
| 241 | - } | |
| 242 | - if( is_string( $data_cadastro ) ) | |
| 243 | - { | |
| 244 | - $this->data_cadastro = $data_cadastro; | |
| 245 | - } | |
| 246 | - if( is_string( $data_exclusao ) ) | |
| 247 | - { | |
| 248 | - $this->data_exclusao = $data_exclusao; | |
| 249 | - } | |
| 250 | - if( is_numeric( $ativo ) ) | |
| 251 | - { | |
| 252 | - $this->ativo = $ativo; | |
| 253 | - } | |
| 254 | - if( is_string( $nm_aluno ) ) | |
| 255 | - { | |
| 256 | - $this->nm_aluno = $nm_aluno; | |
| 257 | - } | |
| 258 | - | |
| 259 | - if( is_numeric( $cpf_responsavel ) ) | |
| 260 | - { | |
| 261 | - $this->cpf_responsavel = $cpf_responsavel; | |
| 262 | - } | |
| 263 | - | |
| 264 | - } | |
| 265 | - | |
| 266 | - /** | |
| 267 | - * Cria um novo registro | |
| 268 | - * | |
| 269 | - * @return bool | |
| 270 | - */ | |
| 271 | - function cadastra() | |
| 272 | - { | |
| 273 | - if( is_numeric( $this->ref_ref_cod_escola ) && is_numeric( $this->ref_ref_cod_serie ) && is_numeric( $this->ref_usuario_cad ) && (is_numeric( $this->ref_cod_aluno ) || ( is_numeric($this->cpf_responsavel) && is_string($this->nm_aluno)))) | |
| 274 | - { | |
| 275 | - $db = new clsBanco(); | |
| 276 | - | |
| 277 | - $campos = ""; | |
| 278 | - $valores = ""; | |
| 279 | - $gruda = ""; | |
| 280 | - | |
| 281 | - if( is_numeric( $this->ref_ref_cod_escola ) ) | |
| 282 | - { | |
| 283 | - $campos .= "{$gruda}ref_ref_cod_escola"; | |
| 284 | - $valores .= "{$gruda}'{$this->ref_ref_cod_escola}'"; | |
| 285 | - $gruda = ", "; | |
| 286 | - } | |
| 287 | - if( is_numeric( $this->ref_ref_cod_serie ) ) | |
| 288 | - { | |
| 289 | - $campos .= "{$gruda}ref_ref_cod_serie"; | |
| 290 | - $valores .= "{$gruda}'{$this->ref_ref_cod_serie}'"; | |
| 291 | - $gruda = ", "; | |
| 292 | - } | |
| 293 | - if( is_numeric( $this->ref_usuario_cad ) ) | |
| 294 | - { | |
| 295 | - $campos .= "{$gruda}ref_usuario_cad"; | |
| 296 | - $valores .= "{$gruda}'{$this->ref_usuario_cad}'"; | |
| 297 | - $gruda = ", "; | |
| 298 | - } | |
| 299 | - if( is_numeric( $this->ref_cod_aluno ) ) | |
| 300 | - { | |
| 301 | - $campos .= "{$gruda}ref_cod_aluno"; | |
| 302 | - $valores .= "{$gruda}'{$this->ref_cod_aluno}'"; | |
| 303 | - $gruda = ", "; | |
| 304 | - } | |
| 305 | - if( is_string( $this->nm_aluno ) ) | |
| 306 | - { | |
| 307 | - $campos .= "{$gruda}nm_aluno"; | |
| 308 | - $valores .= "{$gruda}'{$this->nm_aluno}'"; | |
| 309 | - $gruda = ", "; | |
| 310 | - } | |
| 311 | - if( is_numeric( $this->cpf_responsavel ) ) | |
| 312 | - { | |
| 313 | - $campos .= "{$gruda}cpf_responsavel"; | |
| 314 | - $valores .= "{$gruda}'{$this->cpf_responsavel}'"; | |
| 315 | - $gruda = ", "; | |
| 316 | - } | |
| 317 | - | |
| 318 | - $campos .= "{$gruda}data_cadastro"; | |
| 319 | - $valores .= "{$gruda}NOW()"; | |
| 320 | - $gruda = ", "; | |
| 321 | - $campos .= "{$gruda}ativo"; | |
| 322 | - $valores .= "{$gruda}'1'"; | |
| 323 | - $gruda = ", "; | |
| 324 | - | |
| 325 | - $db->Consulta( "INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )" ); | |
| 326 | - return $db->InsertId( "{$this->_tabela}_cod_reserva_vaga_seq"); | |
| 327 | - } | |
| 328 | - return false; | |
| 329 | - } | |
| 330 | - | |
| 331 | - /** | |
| 332 | - * Edita os dados de um registro | |
| 333 | - * | |
| 334 | - * @return bool | |
| 335 | - */ | |
| 336 | - function edita() | |
| 337 | - { | |
| 338 | - if( is_numeric( $this->cod_reserva_vaga ) /*&& is_numeric( $this->ref_usuario_exc )*/ ) | |
| 339 | - { | |
| 340 | - | |
| 341 | - $db = new clsBanco(); | |
| 342 | - $set = ""; | |
| 343 | - | |
| 344 | - if( is_numeric( $this->ref_ref_cod_escola ) ) | |
| 345 | - { | |
| 346 | - $set .= "{$gruda}ref_ref_cod_escola = '{$this->ref_ref_cod_escola}'"; | |
| 347 | - $gruda = ", "; | |
| 348 | - } | |
| 349 | - if( is_numeric( $this->ref_ref_cod_serie ) ) | |
| 350 | - { | |
| 351 | - $set .= "{$gruda}ref_ref_cod_serie = '{$this->ref_ref_cod_serie}'"; | |
| 352 | - $gruda = ", "; | |
| 353 | - } | |
| 354 | - if( is_numeric( $this->ref_usuario_exc ) ) | |
| 355 | - { | |
| 356 | - $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; | |
| 357 | - $gruda = ", "; | |
| 358 | - } | |
| 359 | - if( is_numeric( $this->ref_usuario_cad ) ) | |
| 360 | - { | |
| 361 | - $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'"; | |
| 362 | - $gruda = ", "; | |
| 363 | - } | |
| 364 | - if( is_numeric( $this->ref_cod_aluno ) ) | |
| 365 | - { | |
| 366 | - $set .= "{$gruda}ref_cod_aluno = '{$this->ref_cod_aluno}'"; | |
| 367 | - $gruda = ", "; | |
| 368 | - } | |
| 369 | - if( is_string( $this->data_cadastro ) ) | |
| 370 | - { | |
| 371 | - $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'"; | |
| 372 | - $gruda = ", "; | |
| 373 | - } | |
| 374 | - $set .= "{$gruda}data_exclusao = NOW()"; | |
| 375 | - $gruda = ", "; | |
| 376 | - if( is_numeric( $this->ativo ) ) | |
| 377 | - { | |
| 378 | - $set .= "{$gruda}ativo = '{$this->ativo}'"; | |
| 379 | - $gruda = ", "; | |
| 380 | - } | |
| 381 | - if( is_string( $this->nm_aluno ) ) | |
| 382 | - { | |
| 383 | - $set .= "{$gruda}nm_aluno = '{$this->nm_aluno}'"; | |
| 384 | - $gruda = ", "; | |
| 385 | - } | |
| 386 | - if( is_numeric( $this->cpf_responsavel ) ) | |
| 387 | - { | |
| 388 | - $set .= "{$gruda}cpf_responsavel = '{$this->cpf_responsavel}'"; | |
| 389 | - $gruda = ", "; | |
| 390 | - } | |
| 391 | - if( $set ) | |
| 392 | - { | |
| 393 | - $db->Consulta( "UPDATE {$this->_tabela} SET $set WHERE cod_reserva_vaga = '{$this->cod_reserva_vaga}'" ); | |
| 394 | - return true; | |
| 395 | - } | |
| 396 | - } | |
| 397 | - return false; | |
| 398 | - } | |
| 399 | - | |
| 400 | - /** | |
| 401 | - * Retorna uma lista filtrados de acordo com os parametros | |
| 402 | - * | |
| 403 | - * @return array | |
| 404 | - */ | |
| 405 | - function lista( $int_cod_reserva_vaga = null, $int_ref_ref_cod_escola = null, $int_ref_ref_cod_serie = null, $int_ref_usuario_exc = null, $int_ref_usuario_cad = null, $int_ref_cod_aluno = null, $date_data_cadastro_ini = null, $date_data_cadastro_fim = null, $date_data_exclusao_ini = null, $date_data_exclusao_fim = null, $int_ativo = null, $int_ref_cod_instituicao = null, $int_ref_cod_curso = null, $str_nm_aluno = null, $int_cpf_responsavel = null ) | |
| 406 | - { | |
| 407 | - $sql = "SELECT {$this->_campos_lista}, c.ref_cod_instituicao, s.ref_cod_curso FROM {$this->_tabela} rv, {$this->_schema}serie s, {$this->_schema}curso c"; | |
| 408 | - | |
| 409 | - $whereAnd = " AND "; | |
| 410 | - $filtros = " WHERE rv.ref_ref_cod_serie = s.cod_serie AND s.ref_cod_curso = c.cod_curso "; | |
| 411 | - | |
| 412 | - if( is_numeric( $int_cod_reserva_vaga ) ) | |
| 413 | - { | |
| 414 | - $filtros .= "{$whereAnd} rv.cod_reserva_vaga = '{$int_cod_reserva_vaga}'"; | |
| 415 | - $whereAnd = " AND "; | |
| 416 | - } | |
| 417 | - if( is_numeric( $int_ref_ref_cod_escola ) ) | |
| 418 | - { | |
| 419 | - $filtros .= "{$whereAnd} rv.ref_ref_cod_escola = '{$int_ref_ref_cod_escola}'"; | |
| 420 | - $whereAnd = " AND "; | |
| 421 | - } | |
| 422 | - if( is_numeric( $int_ref_ref_cod_serie ) ) | |
| 423 | - { | |
| 424 | - $filtros .= "{$whereAnd} rv.ref_ref_cod_serie = '{$int_ref_ref_cod_serie}'"; | |
| 425 | - $whereAnd = " AND "; | |
| 426 | - } | |
| 427 | - if( is_numeric( $int_ref_usuario_exc ) ) | |
| 428 | - { | |
| 429 | - $filtros .= "{$whereAnd} rv.ref_usuario_exc = '{$int_ref_usuario_exc}'"; | |
| 430 | - $whereAnd = " AND "; | |
| 431 | - } | |
| 432 | - if( is_numeric( $int_ref_usuario_cad ) ) | |
| 433 | - { | |
| 434 | - $filtros .= "{$whereAnd} rv.ref_usuario_cad = '{$int_ref_usuario_cad}'"; | |
| 435 | - $whereAnd = " AND "; | |
| 436 | - } | |
| 437 | - if( is_numeric( $int_ref_cod_aluno ) ) | |
| 438 | - { | |
| 439 | - $filtros .= "{$whereAnd} rv.ref_cod_aluno = '{$int_ref_cod_aluno}'"; | |
| 440 | - $whereAnd = " AND "; | |
| 441 | - } | |
| 442 | - if( is_string( $date_data_cadastro_ini ) ) | |
| 443 | - { | |
| 444 | - $filtros .= "{$whereAnd} rv.data_cadastro >= '{$date_data_cadastro_ini}'"; | |
| 445 | - $whereAnd = " AND "; | |
| 446 | - } | |
| 447 | - if( is_string( $date_data_cadastro_fim ) ) | |
| 448 | - { | |
| 449 | - $filtros .= "{$whereAnd} rv.data_cadastro <= '{$date_data_cadastro_fim}'"; | |
| 450 | - $whereAnd = " AND "; | |
| 451 | - } | |
| 452 | - if( is_string( $date_data_exclusao_ini ) ) | |
| 453 | - { | |
| 454 | - $filtros .= "{$whereAnd} rv.data_exclusao >= '{$date_data_exclusao_ini}'"; | |
| 455 | - $whereAnd = " AND "; | |
| 456 | - } | |
| 457 | - if( is_string( $date_data_exclusao_fim ) ) | |
| 458 | - { | |
| 459 | - $filtros .= "{$whereAnd} rv.data_exclusao <= '{$date_data_exclusao_fim}'"; | |
| 460 | - $whereAnd = " AND "; | |
| 461 | - } | |
| 462 | - if( is_null( $int_ativo ) || $int_ativo ) | |
| 463 | - { | |
| 464 | - $filtros .= "{$whereAnd} rv.ativo = '1'"; | |
| 465 | - $whereAnd = " AND "; | |
| 466 | - } | |
| 467 | - else | |
| 468 | - { | |
| 469 | - $filtros .= "{$whereAnd} rv.ativo = '0'"; | |
| 470 | - $whereAnd = " AND "; | |
| 471 | - } | |
| 472 | - if( is_numeric( $int_ref_cod_instituicao ) ) | |
| 473 | - { | |
| 474 | - $filtros .= "{$whereAnd} c.ref_cod_instituicao = '{$int_ref_cod_instituicao}'"; | |
| 475 | - $whereAnd = " AND "; | |
| 476 | - } | |
| 477 | - if( is_numeric( $int_ref_cod_curso ) ) | |
| 478 | - { | |
| 479 | - $filtros .= "{$whereAnd} s.ref_cod_curso = '{$int_ref_cod_curso}'"; | |
| 480 | - $whereAnd = " AND "; | |
| 481 | - } | |
| 482 | - if( is_string( $str_nm_aluno ) ) | |
| 483 | - { | |
| 484 | - $filtros .= "{$whereAnd} rv.nm_aluno ilike '%{$str_nm_aluno}%'"; | |
| 485 | - $whereAnd = " AND "; | |
| 486 | - } | |
| 487 | - if( is_numeric( $int_cpf_responsavel ) ) | |
| 488 | - { | |
| 489 | - $filtros .= "{$whereAnd} rv.cpf_responsavel like '%{$int_cpf_responsavel}%'"; | |
| 490 | - $whereAnd = " AND "; | |
| 491 | - } | |
| 492 | - | |
| 493 | - $db = new clsBanco(); | |
| 494 | - $countCampos = count( explode( ",", $this->_campos_lista ) ); | |
| 495 | - $resultado = array(); | |
| 496 | - | |
| 497 | - $sql .= $filtros . $this->getOrderby() . $this->getLimite(); | |
| 498 | - | |
| 499 | - $this->_total = $db->CampoUnico( "SELECT COUNT(0) FROM {$this->_tabela} rv, {$this->_schema}serie s, {$this->_schema}curso c {$filtros}" ); | |
| 500 | - | |
| 501 | - $db->Consulta( $sql ); | |
| 502 | - | |
| 503 | - if( $countCampos > 1 ) | |
| 504 | - { | |
| 505 | - while ( $db->ProximoRegistro() ) | |
| 506 | - { | |
| 507 | - $tupla = $db->Tupla(); | |
| 508 | - | |
| 509 | - $tupla["_total"] = $this->_total; | |
| 510 | - $resultado[] = $tupla; | |
| 511 | - } | |
| 512 | - } | |
| 513 | - else | |
| 514 | - { | |
| 515 | - while ( $db->ProximoRegistro() ) | |
| 516 | - { | |
| 517 | - $tupla = $db->Tupla(); | |
| 518 | - $resultado[] = $tupla[$this->_campos_lista]; | |
| 519 | - } | |
| 520 | - } | |
| 521 | - if( count( $resultado ) ) | |
| 522 | - { | |
| 523 | - return $resultado; | |
| 524 | - } | |
| 525 | - return false; | |
| 526 | - } | |
| 527 | - | |
| 528 | - /** | |
| 529 | - * Retorna um array com os dados de um registro | |
| 530 | - * | |
| 531 | - * @return array | |
| 532 | - */ | |
| 533 | - function detalhe() | |
| 534 | - { | |
| 535 | - if( is_numeric( $this->cod_reserva_vaga ) ) | |
| 536 | - { | |
| 537 | - | |
| 538 | - $db = new clsBanco(); | |
| 539 | - $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} rv WHERE rv.cod_reserva_vaga = '{$this->cod_reserva_vaga}'" ); | |
| 540 | - $db->ProximoRegistro(); | |
| 541 | - return $db->Tupla(); | |
| 542 | - } | |
| 543 | - return false; | |
| 544 | - } | |
| 545 | - | |
| 546 | - /** | |
| 547 | - * Retorna um array com os dados de um registro | |
| 548 | - * | |
| 549 | - * @return array | |
| 550 | - */ | |
| 551 | - function existe() | |
| 552 | - { | |
| 553 | - if( is_numeric( $this->cod_reserva_vaga ) ) | |
| 554 | - { | |
| 555 | - | |
| 556 | - $db = new clsBanco(); | |
| 557 | - $db->Consulta( "SELECT 1 FROM {$this->_tabela} WHERE cod_reserva_vaga = '{$this->cod_reserva_vaga}'" ); | |
| 558 | - $db->ProximoRegistro(); | |
| 559 | - return $db->Tupla(); | |
| 560 | - } | |
| 561 | - return false; | |
| 562 | - } | |
| 563 | - | |
| 564 | - /** | |
| 565 | - * Exclui um registro | |
| 566 | - * | |
| 567 | - * @return bool | |
| 568 | - */ | |
| 569 | - function excluir() | |
| 570 | - { | |
| 571 | - if( is_numeric( $this->cod_reserva_vaga ) /*&& is_numeric( $this->ref_usuario_exc )*/ ) | |
| 572 | - { | |
| 573 | - | |
| 574 | - /* | |
| 575 | - delete | |
| 576 | - $db = new clsBanco(); | |
| 577 | - $db->Consulta( "DELETE FROM {$this->_tabela} WHERE cod_reserva_vaga = '{$this->cod_reserva_vaga}'" ); | |
| 578 | - return true; | |
| 579 | - */ | |
| 580 | - | |
| 581 | - $this->ativo = 0; | |
| 582 | - return $this->edita(); | |
| 583 | - } | |
| 584 | - return false; | |
| 585 | - } | |
| 586 | - | |
| 587 | - /** | |
| 588 | - * Define quais campos da tabela serao selecionados na invocacao do metodo lista | |
| 589 | - * | |
| 590 | - * @return null | |
| 591 | - */ | |
| 592 | - function setCamposLista( $str_campos ) | |
| 593 | - { | |
| 594 | - $this->_campos_lista = $str_campos; | |
| 595 | - } | |
| 596 | - | |
| 597 | - /** | |
| 598 | - * Define que o metodo Lista devera retornoar todos os campos da tabela | |
| 599 | - * | |
| 600 | - * @return null | |
| 601 | - */ | |
| 602 | - function resetCamposLista() | |
| 603 | - { | |
| 604 | - $this->_campos_lista = $this->_todos_campos; | |
| 605 | - } | |
| 606 | - | |
| 607 | - /** | |
| 608 | - * Define limites de retorno para o metodo lista | |
| 609 | - * | |
| 610 | - * @return null | |
| 611 | - */ | |
| 612 | - function setLimite( $intLimiteQtd, $intLimiteOffset = null ) | |
| 613 | - { | |
| 614 | - $this->_limite_quantidade = $intLimiteQtd; | |
| 615 | - $this->_limite_offset = $intLimiteOffset; | |
| 616 | - } | |
| 617 | - | |
| 618 | - /** | |
| 619 | - * Retorna a string com o trecho da query resposavel pelo Limite de registros | |
| 620 | - * | |
| 621 | - * @return string | |
| 622 | - */ | |
| 623 | - function getLimite() | |
| 624 | - { | |
| 625 | - if( is_numeric( $this->_limite_quantidade ) ) | |
| 626 | - { | |
| 627 | - $retorno = " LIMIT {$this->_limite_quantidade}"; | |
| 628 | - if( is_numeric( $this->_limite_offset ) ) | |
| 629 | - { | |
| 630 | - $retorno .= " OFFSET {$this->_limite_offset} "; | |
| 631 | - } | |
| 632 | - return $retorno; | |
| 633 | - } | |
| 634 | - return ""; | |
| 635 | - } | |
| 636 | - | |
| 637 | - /** | |
| 638 | - * Define campo para ser utilizado como ordenacao no metolo lista | |
| 639 | - * | |
| 640 | - * @return null | |
| 641 | - */ | |
| 642 | - function setOrderby( $strNomeCampo ) | |
| 643 | - { | |
| 644 | - // limpa a string de possiveis erros (delete, insert, etc) | |
| 645 | - //$strNomeCampo = eregi_replace(); | |
| 646 | - | |
| 647 | - if( is_string( $strNomeCampo ) && $strNomeCampo ) | |
| 648 | - { | |
| 649 | - $this->_campo_order_by = $strNomeCampo; | |
| 650 | - } | |
| 651 | - } | |
| 652 | - | |
| 653 | - /** | |
| 654 | - * Retorna a string com o trecho da query resposavel pela Ordenacao dos registros | |
| 655 | - * | |
| 656 | - * @return string | |
| 657 | - */ | |
| 658 | - function getOrderby() | |
| 659 | - { | |
| 660 | - if( is_string( $this->_campo_order_by ) ) | |
| 661 | - { | |
| 662 | - return " ORDER BY {$this->_campo_order_by} "; | |
| 663 | - } | |
| 664 | - return ""; | |
| 665 | - } | |
| 666 | - | |
| 667 | -} | |
| 668 | -?> | |
| 669 | 47 | \ No newline at end of file |
| 48 | + var $cod_reserva_vaga; | |
| 49 | + var $ref_ref_cod_escola; | |
| 50 | + var $ref_ref_cod_serie; | |
| 51 | + var $ref_usuario_exc; | |
| 52 | + var $ref_usuario_cad; | |
| 53 | + var $ref_cod_aluno; | |
| 54 | + var $data_cadastro; | |
| 55 | + var $data_exclusao; | |
| 56 | + var $ativo; | |
| 57 | + var $nm_aluno; | |
| 58 | + var $cpf_responsavel; | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Armazena o total de resultados obtidos na ultima chamada ao metodo lista. | |
| 62 | + * @var int | |
| 63 | + */ | |
| 64 | + var $_total; | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * Nome do schema. | |
| 68 | + * @var string | |
| 69 | + */ | |
| 70 | + var $_schema; | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * Nome da tabela. | |
| 74 | + * @var string | |
| 75 | + */ | |
| 76 | + var $_tabela; | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * Lista separada por vírgula, com os campos que devem ser selecionados na | |
| 80 | + * próxima chamado ao metodo lista. | |
| 81 | + * @var string | |
| 82 | + */ | |
| 83 | + var $_campos_lista; | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * Lista com todos os campos da tabela separados por vírgula, padrão para | |
| 87 | + * seleçã no método lista. | |
| 88 | + * @var string | |
| 89 | + */ | |
| 90 | + var $_todos_campos; | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * Valor que define a quantidade de registros a ser retornada pelo método lista. | |
| 94 | + * @var int | |
| 95 | + */ | |
| 96 | + var $_limite_quantidade; | |
| 97 | + | |
| 98 | + /** | |
| 99 | + * Define o valor de offset no retorno dos registros no método lista. | |
| 100 | + * @var int | |
| 101 | + */ | |
| 102 | + var $_limite_offset; | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * Define o campo padrao para ser usado como padrão de ordenação no método lista. | |
| 106 | + * @var string | |
| 107 | + */ | |
| 108 | + var $_campo_order_by; | |
| 109 | + | |
| 110 | + /** | |
| 111 | + * Construtor. | |
| 112 | + * | |
| 113 | + * @param int $cod_reserva_vaga | |
| 114 | + * @param int $ref_ref_cod_escola | |
| 115 | + * @param int $ref_ref_cod_serie | |
| 116 | + * @param int $ref_usuario_exc | |
| 117 | + * @param int $ref_usuario_cad | |
| 118 | + * @param int $ref_cod_aluno | |
| 119 | + * @param string $data_cadastro | |
| 120 | + * @param string $data_exclusao | |
| 121 | + * @param int $ativo | |
| 122 | + * @param string $nm_aluno | |
| 123 | + * @param int $cpf_responsavel | |
| 124 | + */ | |
| 125 | + function clsPmieducarReservaVaga($cod_reserva_vaga = NULL, | |
| 126 | + $ref_ref_cod_escola = NULL, $ref_ref_cod_serie = NULL, $ref_usuario_exc = NULL, | |
| 127 | + $ref_usuario_cad = NULL, $ref_cod_aluno = NULL, $data_cadastro = NULL, | |
| 128 | + $data_exclusao = NULL, $ativo = NULL, $nm_aluno = NULL, $cpf_responsavel = NULL) | |
| 129 | + { | |
| 130 | + | |
| 131 | + $db = new clsBanco(); | |
| 132 | + $this->_schema = 'pmieducar.'; | |
| 133 | + $this->_tabela = $this->_schema . 'reserva_vaga'; | |
| 134 | + | |
| 135 | + $this->_campos_lista = $this->_todos_campos = "rv.cod_reserva_vaga, rv.ref_ref_cod_escola, rv.ref_ref_cod_serie, rv.ref_usuario_exc, rv.ref_usuario_cad, rv.ref_cod_aluno, rv.data_cadastro, rv.data_exclusao, rv.ativo, rv.nm_aluno, rv.cpf_responsavel"; | |
| 136 | + | |
| 137 | + if (is_numeric($ref_ref_cod_serie) && is_numeric($ref_ref_cod_escola)) { | |
| 138 | + if (class_exists("clsPmieducarEscolaSerie")) { | |
| 139 | + $tmp_obj = new clsPmieducarEscolaSerie($ref_ref_cod_escola, $ref_ref_cod_serie); | |
| 140 | + | |
| 141 | + if (method_exists($tmp_obj, 'existe')) { | |
| 142 | + if ($tmp_obj->existe()) { | |
| 143 | + $this->ref_ref_cod_serie = $ref_ref_cod_serie; | |
| 144 | + $this->ref_ref_cod_escola = $ref_ref_cod_escola; | |
| 145 | + } | |
| 146 | + } | |
| 147 | + elseif (method_exists($tmp_obj, 'detalhe')) { | |
| 148 | + if ($tmp_obj->detalhe()) { | |
| 149 | + $this->ref_ref_cod_serie = $ref_ref_cod_serie; | |
| 150 | + $this->ref_ref_cod_escola = $ref_ref_cod_escola; | |
| 151 | + } | |
| 152 | + } | |
| 153 | + } | |
| 154 | + else { | |
| 155 | + if($db->CampoUnico("SELECT 1 FROM pmieducar.escola_serie WHERE ref_cod_serie = '{$ref_ref_cod_serie}' AND ref_cod_escola = '{$ref_ref_cod_escola}'")) { | |
| 156 | + $this->ref_ref_cod_serie = $ref_ref_cod_serie; | |
| 157 | + $this->ref_ref_cod_escola = $ref_ref_cod_escola; | |
| 158 | + } | |
| 159 | + } | |
| 160 | + } | |
| 161 | + | |
| 162 | + if (is_numeric($ref_usuario_exc)) { | |
| 163 | + if (class_exists('clsPmieducarUsuario')) { | |
| 164 | + $tmp_obj = new clsPmieducarUsuario($ref_usuario_exc); | |
| 165 | + | |
| 166 | + if (method_exists($tmp_obj, 'existe')) { | |
| 167 | + if ($tmp_obj->existe()) { | |
| 168 | + $this->ref_usuario_exc = $ref_usuario_exc; | |
| 169 | + } | |
| 170 | + } | |
| 171 | + elseif (method_exists($tmp_obj, 'detalhe')) { | |
| 172 | + if ($tmp_obj->detalhe()) { | |
| 173 | + $this->ref_usuario_exc = $ref_usuario_exc; | |
| 174 | + } | |
| 175 | + } | |
| 176 | + } | |
| 177 | + else { | |
| 178 | + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'")) { | |
| 179 | + $this->ref_usuario_exc = $ref_usuario_exc; | |
| 180 | + } | |
| 181 | + } | |
| 182 | + } | |
| 183 | + | |
| 184 | + if (is_numeric($ref_usuario_cad)) { | |
| 185 | + if (class_exists('clsPmieducarUsuario')) { | |
| 186 | + $tmp_obj = new clsPmieducarUsuario( $ref_usuario_cad ); | |
| 187 | + | |
| 188 | + if (method_exists($tmp_obj, 'existe')) { | |
| 189 | + if ($tmp_obj->existe()) { | |
| 190 | + $this->ref_usuario_cad = $ref_usuario_cad; | |
| 191 | + } | |
| 192 | + } | |
| 193 | + elseif (method_exists($tmp_obj, 'detalhe')) { | |
| 194 | + if ($tmp_obj->detalhe()) { | |
| 195 | + $this->ref_usuario_cad = $ref_usuario_cad; | |
| 196 | + } | |
| 197 | + } | |
| 198 | + } | |
| 199 | + else { | |
| 200 | + if ($db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'")) { | |
| 201 | + $this->ref_usuario_cad = $ref_usuario_cad; | |
| 202 | + } | |
| 203 | + } | |
| 204 | + } | |
| 205 | + | |
| 206 | + if (is_numeric($ref_cod_aluno)) { | |
| 207 | + if (class_exists('clsPmieducarAluno')) { | |
| 208 | + $tmp_obj = new clsPmieducarAluno( $ref_cod_aluno ); | |
| 209 | + if (method_exists($tmp_obj, 'existe')) { | |
| 210 | + if ($tmp_obj->existe()) { | |
| 211 | + $this->ref_cod_aluno = $ref_cod_aluno; | |
| 212 | + } | |
| 213 | + } | |
| 214 | + elseif (method_exists($tmp_obj, 'detalhe')) { | |
| 215 | + if ($tmp_obj->detalhe()) { | |
| 216 | + $this->ref_cod_aluno = $ref_cod_aluno; | |
| 217 | + } | |
| 218 | + } | |
| 219 | + } | |
| 220 | + else { | |
| 221 | + if ($db->CampoUnico("SELECT 1 FROM pmieducar.aluno WHERE cod_aluno = '{$ref_cod_aluno}'")) { | |
| 222 | + $this->ref_cod_aluno = $ref_cod_aluno; | |
| 223 | + } | |
| 224 | + } | |
| 225 | + } | |
| 226 | + | |
| 227 | + if (is_numeric($cod_reserva_vaga)) { | |
| 228 | + $this->cod_reserva_vaga = $cod_reserva_vaga; | |
| 229 | + } | |
| 230 | + | |
| 231 | + if (is_string($data_cadastro)) { | |
| 232 | + $this->data_cadastro = $data_cadastro; | |
| 233 | + } | |
| 234 | + | |
| 235 | + if (is_string($data_exclusao)) { | |
| 236 | + $this->data_exclusao = $data_exclusao; | |
| 237 | + } | |
| 238 | + | |
| 239 | + if (is_numeric($ativo)) { | |
| 240 | + $this->ativo = $ativo; | |
| 241 | + } | |
| 242 | + | |
| 243 | + if (is_string($nm_aluno)) { | |
| 244 | + $this->nm_aluno = $nm_aluno; | |
| 245 | + } | |
| 246 | + | |
| 247 | + if (is_numeric($cpf_responsavel)) { | |
| 248 | + $this->cpf_responsavel = $cpf_responsavel; | |
| 249 | + } | |
| 250 | + } | |
| 251 | + | |
| 252 | + /** | |
| 253 | + * Cria um novo registro. | |
| 254 | + * @return int|bool Retorna o valor da sequence ou FALSE em caso de erro. | |
| 255 | + */ | |
| 256 | + function cadastra() | |
| 257 | + { | |
| 258 | + if (is_numeric($this->ref_ref_cod_escola) && | |
| 259 | + is_numeric($this->ref_ref_cod_serie) && is_numeric($this->ref_usuario_cad) && | |
| 260 | + (is_numeric($this->ref_cod_aluno) || (is_numeric($this->cpf_responsavel) && is_string($this->nm_aluno)))) | |
| 261 | + { | |
| 262 | + $db = new clsBanco(); | |
| 263 | + | |
| 264 | + $campos = ""; | |
| 265 | + $valores = ""; | |
| 266 | + $gruda = ""; | |
| 267 | + | |
| 268 | + if (is_numeric($this->ref_ref_cod_escola)) { | |
| 269 | + $campos .= "{$gruda}ref_ref_cod_escola"; | |
| 270 | + $valores .= "{$gruda}'{$this->ref_ref_cod_escola}'"; | |
| 271 | + $gruda = ", "; | |
| 272 | + } | |
| 273 | + | |
| 274 | + if (is_numeric($this->ref_ref_cod_serie)) { | |
| 275 | + $campos .= "{$gruda}ref_ref_cod_serie"; | |
| 276 | + $valores .= "{$gruda}'{$this->ref_ref_cod_serie}'"; | |
| 277 | + $gruda = ", "; | |
| 278 | + } | |
| 279 | + | |
| 280 | + if (is_numeric($this->ref_usuario_cad)) { | |
| 281 | + $campos .= "{$gruda}ref_usuario_cad"; | |
| 282 | + $valores .= "{$gruda}'{$this->ref_usuario_cad}'"; | |
| 283 | + $gruda = ", "; | |
| 284 | + } | |
| 285 | + | |
| 286 | + if (is_numeric($this->ref_cod_aluno)) { | |
| 287 | + $campos .= "{$gruda}ref_cod_aluno"; | |
| 288 | + $valores .= "{$gruda}'{$this->ref_cod_aluno}'"; | |
| 289 | + $gruda = ", "; | |
| 290 | + } | |
| 291 | + | |
| 292 | + if (is_string($this->nm_aluno)) { | |
| 293 | + $campos .= "{$gruda}nm_aluno"; | |
| 294 | + $valores .= "{$gruda}'{$this->nm_aluno}'"; | |
| 295 | + $gruda = ", "; | |
| 296 | + } | |
| 297 | + | |
| 298 | + if (is_numeric($this->cpf_responsavel)) { | |
| 299 | + $campos .= "{$gruda}cpf_responsavel"; | |
| 300 | + $valores .= "{$gruda}'{$this->cpf_responsavel}'"; | |
| 301 | + $gruda = ", "; | |
| 302 | + } | |
| 303 | + | |
| 304 | + $campos .= "{$gruda}data_cadastro"; | |
| 305 | + $valores .= "{$gruda}NOW()"; | |
| 306 | + $gruda = ", "; | |
| 307 | + | |
| 308 | + $campos .= "{$gruda}ativo"; | |
| 309 | + $valores .= "{$gruda}'1'"; | |
| 310 | + $gruda = ", "; | |
| 311 | + | |
| 312 | + $db->Consulta("INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )"); | |
| 313 | + return $db->InsertId("{$this->_tabela}_cod_reserva_vaga_seq"); | |
| 314 | + } | |
| 315 | + | |
| 316 | + return FALSE; | |
| 317 | + } | |
| 318 | + | |
| 319 | + /** | |
| 320 | + * Atualiza os dados de um registro. | |
| 321 | + * @return bool | |
| 322 | + */ | |
| 323 | + function edita() | |
| 324 | + { | |
| 325 | + if (is_numeric($this->cod_reserva_vaga)) { | |
| 326 | + $db = new clsBanco(); | |
| 327 | + $set = ""; | |
| 328 | + | |
| 329 | + if (is_numeric($this->ref_ref_cod_escola)) { | |
| 330 | + $set .= "{$gruda}ref_ref_cod_escola = '{$this->ref_ref_cod_escola}'"; | |
| 331 | + $gruda = ", "; | |
| 332 | + } | |
| 333 | + | |
| 334 | + if (is_numeric($this->ref_ref_cod_serie)) { | |
| 335 | + $set .= "{$gruda}ref_ref_cod_serie = '{$this->ref_ref_cod_serie}'"; | |
| 336 | + $gruda = ", "; | |
| 337 | + } | |
| 338 | + | |
| 339 | + if (is_numeric($this->ref_usuario_exc)) { | |
| 340 | + $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; | |
| 341 | + $gruda = ", "; | |
| 342 | + } | |
| 343 | + | |
| 344 | + if (is_numeric($this->ref_usuario_cad)) { | |
| 345 | + $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'"; | |
| 346 | + $gruda = ", "; | |
| 347 | + } | |
| 348 | + | |
| 349 | + if (is_numeric($this->ref_cod_aluno)) { | |
| 350 | + $set .= "{$gruda}ref_cod_aluno = '{$this->ref_cod_aluno}'"; | |
| 351 | + $gruda = ", "; | |
| 352 | + } | |
| 353 | + | |
| 354 | + if (is_string($this->data_cadastro)) { | |
| 355 | + $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'"; | |
| 356 | + $gruda = ", "; | |
| 357 | + } | |
| 358 | + | |
| 359 | + $set .= "{$gruda}data_exclusao = NOW()"; | |
| 360 | + $gruda = ", "; | |
| 361 | + | |
| 362 | + if (is_numeric($this->ativo)) { | |
| 363 | + $set .= "{$gruda}ativo = '{$this->ativo}'"; | |
| 364 | + $gruda = ", "; | |
| 365 | + } | |
| 366 | + | |
| 367 | + if (is_string($this->nm_aluno)) { | |
| 368 | + $set .= "{$gruda}nm_aluno = '{$this->nm_aluno}'"; | |
| 369 | + $gruda = ", "; | |
| 370 | + } | |
| 371 | + | |
| 372 | + if (is_numeric($this->cpf_responsavel)) { | |
| 373 | + $set .= "{$gruda}cpf_responsavel = '{$this->cpf_responsavel}'"; | |
| 374 | + $gruda = ", "; | |
| 375 | + } | |
| 376 | + | |
| 377 | + if ($set) { | |
| 378 | + $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE cod_reserva_vaga = '{$this->cod_reserva_vaga}'"); | |
| 379 | + return TRUE; | |
| 380 | + } | |
| 381 | + } | |
| 382 | + | |
| 383 | + return FALSE; | |
| 384 | + } | |
| 385 | + | |
| 386 | + /** | |
| 387 | + * Retorna uma lista de registros filtrados de acordo com os parâmetros. | |
| 388 | + * | |
| 389 | + * @var int $int_cod_reserva_vaga | |
| 390 | + * @var int $int_ref_ref_cod_escola | |
| 391 | + * @var int $int_ref_ref_cod_serie | |
| 392 | + * @var int $int_ref_usuario_exc | |
| 393 | + * @var int $int_ref_usuario_cad | |
| 394 | + * @var int $int_ref_cod_aluno | |
| 395 | + * @var string $date_data_cadastro_ini | |
| 396 | + * @var string $date_data_cadastro_fim | |
| 397 | + * @var string $date_data_exclusao_ini | |
| 398 | + * @var string $date_data_exclusao_fim | |
| 399 | + * @var int $int_ativo | |
| 400 | + * @var int $int_ref_cod_instituicao | |
| 401 | + * @var int $int_ref_cod_curso | |
| 402 | + * @var string $str_nm_aluno | |
| 403 | + * @var int $int_cpf_responsavel | |
| 404 | + * @return array|bool Retorna um array com registro(s) ou FALSE em caso de erro. | |
| 405 | + */ | |
| 406 | + function lista($int_cod_reserva_vaga = NULL, $int_ref_ref_cod_escola = NULL, | |
| 407 | + $int_ref_ref_cod_serie = NULL, $int_ref_usuario_exc = NULL, | |
| 408 | + $int_ref_usuario_cad = NULL, $int_ref_cod_aluno = NULL, | |
| 409 | + $date_data_cadastro_ini = NULL, $date_data_cadastro_fim = NULL, | |
| 410 | + $date_data_exclusao_ini = NULL, $date_data_exclusao_fim = NULL, | |
| 411 | + $int_ativo = NULL, $int_ref_cod_instituicao = NULL, $int_ref_cod_curso = NULL, | |
| 412 | + $str_nm_aluno = NULL, $int_cpf_responsavel = NULL) | |
| 413 | + { | |
| 414 | + $sql = "SELECT {$this->_campos_lista}, c.ref_cod_instituicao, s.ref_cod_curso FROM {$this->_tabela} rv, {$this->_schema}serie s, {$this->_schema}curso c"; | |
| 415 | + | |
| 416 | + $whereAnd = " AND "; | |
| 417 | + $filtros = " WHERE rv.ref_ref_cod_serie = s.cod_serie AND s.ref_cod_curso = c.cod_curso "; | |
| 418 | + | |
| 419 | + if (is_numeric($int_cod_reserva_vaga)) { | |
| 420 | + $filtros .= "{$whereAnd} rv.cod_reserva_vaga = '{$int_cod_reserva_vaga}'"; | |
| 421 | + $whereAnd = " AND "; | |
| 422 | + } | |
| 423 | + | |
| 424 | + if (is_numeric($int_ref_ref_cod_escola)) { | |
| 425 | + $filtros .= "{$whereAnd} rv.ref_ref_cod_escola = '{$int_ref_ref_cod_escola}'"; | |
| 426 | + $whereAnd = " AND "; | |
| 427 | + } | |
| 428 | + | |
| 429 | + if (is_numeric($int_ref_ref_cod_serie)) { | |
| 430 | + $filtros .= "{$whereAnd} rv.ref_ref_cod_serie = '{$int_ref_ref_cod_serie}'"; | |
| 431 | + $whereAnd = " AND "; | |
| 432 | + } | |
| 433 | + | |
| 434 | + if (is_numeric($int_ref_usuario_exc)) { | |
| 435 | + $filtros .= "{$whereAnd} rv.ref_usuario_exc = '{$int_ref_usuario_exc}'"; | |
| 436 | + $whereAnd = " AND "; | |
| 437 | + } | |
| 438 | + | |
| 439 | + if (is_numeric($int_ref_usuario_cad)) { | |
| 440 | + $filtros .= "{$whereAnd} rv.ref_usuario_cad = '{$int_ref_usuario_cad}'"; | |
| 441 | + $whereAnd = " AND "; | |
| 442 | + } | |
| 443 | + | |
| 444 | + if (is_numeric($int_ref_cod_aluno)) { | |
| 445 | + $filtros .= "{$whereAnd} rv.ref_cod_aluno = '{$int_ref_cod_aluno}'"; | |
| 446 | + $whereAnd = " AND "; | |
| 447 | + } | |
| 448 | + | |
| 449 | + if (is_string($date_data_cadastro_ini)) { | |
| 450 | + $filtros .= "{$whereAnd} rv.data_cadastro >= '{$date_data_cadastro_ini}'"; | |
| 451 | + $whereAnd = " AND "; | |
| 452 | + } | |
| 453 | + | |
| 454 | + if (is_string($date_data_cadastro_fim)) { | |
| 455 | + $filtros .= "{$whereAnd} rv.data_cadastro <= '{$date_data_cadastro_fim}'"; | |
| 456 | + $whereAnd = " AND "; | |
| 457 | + } | |
| 458 | + | |
| 459 | + if (is_string($date_data_exclusao_ini)) { | |
| 460 | + $filtros .= "{$whereAnd} rv.data_exclusao >= '{$date_data_exclusao_ini}'"; | |
| 461 | + $whereAnd = " AND "; | |
| 462 | + } | |
| 463 | + | |
| 464 | + if (is_string($date_data_exclusao_fim)) { | |
| 465 | + $filtros .= "{$whereAnd} rv.data_exclusao <= '{$date_data_exclusao_fim}'"; | |
| 466 | + $whereAnd = " AND "; | |
| 467 | + } | |
| 468 | + | |
| 469 | + if (is_null($int_ativo) || $int_ativo) { | |
| 470 | + $filtros .= "{$whereAnd} rv.ativo = '1'"; | |
| 471 | + $whereAnd = " AND "; | |
| 472 | + } | |
| 473 | + else { | |
| 474 | + $filtros .= "{$whereAnd} rv.ativo = '0'"; | |
| 475 | + $whereAnd = " AND "; | |
| 476 | + } | |
| 477 | + | |
| 478 | + if (is_numeric($int_ref_cod_instituicao)) { | |
| 479 | + $filtros .= "{$whereAnd} c.ref_cod_instituicao = '{$int_ref_cod_instituicao}'"; | |
| 480 | + $whereAnd = " AND "; | |
| 481 | + } | |
| 482 | + | |
| 483 | + if (is_numeric($int_ref_cod_curso)) { | |
| 484 | + $filtros .= "{$whereAnd} s.ref_cod_curso = '{$int_ref_cod_curso}'"; | |
| 485 | + $whereAnd = " AND "; | |
| 486 | + } | |
| 487 | + | |
| 488 | + if (is_string($str_nm_aluno)) { | |
| 489 | + $filtros .= "{$whereAnd} rv.nm_aluno ilike '%{$str_nm_aluno}%'"; | |
| 490 | + $whereAnd = " AND "; | |
| 491 | + } | |
| 492 | + | |
| 493 | + if (is_numeric($int_cpf_responsavel)) { | |
| 494 | + $filtros .= "{$whereAnd} rv.cpf_responsavel like '%{$int_cpf_responsavel}%'"; | |
| 495 | + $whereAnd = " AND "; | |
| 496 | + } | |
| 497 | + | |
| 498 | + $db = new clsBanco(); | |
| 499 | + $countCampos = count(explode(',', $this->_campos_lista)); | |
| 500 | + $resultado = array(); | |
| 501 | + | |
| 502 | + $sql .= $filtros . $this->getOrderby() . $this->getLimite(); | |
| 503 | + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} rv, {$this->_schema}serie s, {$this->_schema}curso c {$filtros}"); | |
| 504 | + | |
| 505 | + $db->Consulta($sql); | |
| 506 | + | |
| 507 | + if ($countCampos > 1) { | |
| 508 | + while ($db->ProximoRegistro()) { | |
| 509 | + $tupla = $db->Tupla(); | |
| 510 | + | |
| 511 | + $tupla["_total"] = $this->_total; | |
| 512 | + $resultado[] = $tupla; | |
| 513 | + } | |
| 514 | + } | |
| 515 | + else { | |
| 516 | + while ($db->ProximoRegistro()) { | |
| 517 | + $tupla = $db->Tupla(); | |
| 518 | + $resultado[] = $tupla[$this->_campos_lista]; | |
| 519 | + } | |
| 520 | + } | |
| 521 | + | |
| 522 | + if (count($resultado)) { | |
| 523 | + return $resultado; | |
| 524 | + } | |
| 525 | + | |
| 526 | + return FALSE; | |
| 527 | + } | |
| 528 | + | |
| 529 | + /** | |
| 530 | + * Retorna um array com os dados de um registro | |
| 531 | + * @return array|bool | |
| 532 | + */ | |
| 533 | + function detalhe() | |
| 534 | + { | |
| 535 | + if (is_numeric($this->cod_reserva_vaga)) { | |
| 536 | + $db = new clsBanco(); | |
| 537 | + $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} rv WHERE rv.cod_reserva_vaga = '{$this->cod_reserva_vaga}'"); | |
| 538 | + $db->ProximoRegistro(); | |
| 539 | + | |
| 540 | + return $db->Tupla(); | |
| 541 | + } | |
| 542 | + | |
| 543 | + return FALSE; | |
| 544 | + } | |
| 545 | + | |
| 546 | + /** | |
| 547 | + * Retorna um array com os dados de um registro | |
| 548 | + * @return array|bool | |
| 549 | + */ | |
| 550 | + function existe() | |
| 551 | + { | |
| 552 | + if (is_numeric($this->cod_reserva_vaga)) { | |
| 553 | + $db = new clsBanco(); | |
| 554 | + $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE cod_reserva_vaga = '{$this->cod_reserva_vaga}'"); | |
| 555 | + $db->ProximoRegistro(); | |
| 556 | + | |
| 557 | + return $db->Tupla(); | |
| 558 | + } | |
| 559 | + | |
| 560 | + return FALSE; | |
| 561 | + } | |
| 562 | + | |
| 563 | + /** | |
| 564 | + * Exclui um registro | |
| 565 | + * | |
| 566 | + * @return bool | |
| 567 | + */ | |
| 568 | + function excluir() | |
| 569 | + { | |
| 570 | + if (is_numeric($this->cod_reserva_vaga)) { | |
| 571 | + $this->ativo = 0; | |
| 572 | + return $this->edita(); | |
| 573 | + } | |
| 574 | + | |
| 575 | + return FALSE; | |
| 576 | + } | |
| 577 | + | |
| 578 | + /** | |
| 579 | + * Define quais campos da tabela serão selecionados na invocação do método lista. | |
| 580 | + * @param string $str_campos | |
| 581 | + */ | |
| 582 | + function setCamposLista($str_campos) { | |
| 583 | + $this->_campos_lista = $str_campos; | |
| 584 | + } | |
| 585 | + | |
| 586 | + /** | |
| 587 | + * Define que o método lista deverá retornar todos os campos da tabela. | |
| 588 | + */ | |
| 589 | + function resetCamposLista() { | |
| 590 | + $this->_campos_lista = $this->_todos_campos; | |
| 591 | + } | |
| 592 | + | |
| 593 | + /** | |
| 594 | + * Define limites de retorno para o método lista. | |
| 595 | + * @param int $intLimiteQtd | |
| 596 | + * @param int $intLimiteOffset | |
| 597 | + */ | |
| 598 | + function setLimite($intLimiteQtd, $intLimiteOffset = NULL) | |
| 599 | + { | |
| 600 | + $this->_limite_quantidade = $intLimiteQtd; | |
| 601 | + $this->_limite_offset = $intLimiteOffset; | |
| 602 | + } | |
| 603 | + | |
| 604 | + /** | |
| 605 | + * Retorna a string com o trecho da query resposável pelo limite de registros. | |
| 606 | + * @return string | |
| 607 | + */ | |
| 608 | + function getLimite() | |
| 609 | + { | |
| 610 | + if (is_numeric($this->_limite_quantidade)) { | |
| 611 | + $retorno = ' LIMIT ' . $this->_limite_quantidade; | |
| 612 | + if (is_numeric($this->_limite_offset)) { | |
| 613 | + $retorno .= ' OFFSET ' . $this->_limite_offset; | |
| 614 | + } | |
| 615 | + | |
| 616 | + return $retorno; | |
| 617 | + } | |
| 618 | + | |
| 619 | + return ''; | |
| 620 | + } | |
| 621 | + | |
| 622 | + /** | |
| 623 | + * Define campo para ser utilizado como ordenação no método lista. | |
| 624 | + * @param string $strNomeCampo | |
| 625 | + */ | |
| 626 | + function setOrderby($strNomeCampo) | |
| 627 | + { | |
| 628 | + if (is_string($strNomeCampo) && $strNomeCampo) { | |
| 629 | + $this->_campo_order_by = $strNomeCampo; | |
| 630 | + } | |
| 631 | + } | |
| 632 | + | |
| 633 | + /** | |
| 634 | + * Retorna a string com o trecho da query resposável pela ordenação dos registros. | |
| 635 | + * @return string | |
| 636 | + */ | |
| 637 | + function getOrderby() | |
| 638 | + { | |
| 639 | + if( is_string( $this->_campo_order_by ) ) | |
| 640 | + { | |
| 641 | + return ' ORDER BY ' . $this->_campo_order_by; | |
| 642 | + } | |
| 643 | + | |
| 644 | + return ''; | |
| 645 | + } | |
| 646 | + | |
| 647 | +} | |
| 670 | 648 | \ No newline at end of file | ... | ... |