From c8cbb8364442cf60d6ac77058e2304caa2eabd8f Mon Sep 17 00:00:00 2001 From: Eriksen Costa Paixão Date: Wed, 10 Mar 2010 19:51:54 +0000 Subject: [PATCH] Refactoring para coding standards --- ieducar/intranet/educar_falta_atraso_cad.php | 507 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ieducar/intranet/educar_falta_atraso_compensado_cad.php | 429 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ieducar/intranet/educar_falta_atraso_det.php | 315 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------- ieducar/intranet/educar_falta_atraso_lst.php | 184 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------ ieducar/intranet/include/pmieducar/clsPmieducarFaltaAtraso.inc.php | 1540 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ieducar/intranet/include/pmieducar/clsPmieducarFaltaAtrasoCompensado.inc.php | 1386 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 6 files changed, 2200 insertions(+), 2161 deletions(-) diff --git a/ieducar/intranet/educar_falta_atraso_cad.php b/ieducar/intranet/educar_falta_atraso_cad.php index eea6aca..7c99e54 100644 --- a/ieducar/intranet/educar_falta_atraso_cad.php +++ b/ieducar/intranet/educar_falta_atraso_cad.php @@ -1,29 +1,31 @@ * - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí - * ctima@itajai.sc.gov.br + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. * - * Este programa é software livre, você pode redistribuí-lo e/ou - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme - * publicada pela Free Software Foundation, tanto a versão 2 da - * Licença como (a seu critério) qualquer versão mais nova. + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. * - * Este programa é distribuído na expectativa de ser útil, mas SEM - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- - * sulte a Licença Pública Geral GNU para obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU - * junto com este programa. Se não, escreva para a Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307, USA. + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Arquivo disponível desde a versão 1.0.0 + * @version $Id$ */ require_once 'include/clsBase.inc.php'; @@ -31,220 +33,279 @@ require_once 'include/clsCadastro.inc.php'; require_once 'include/clsBanco.inc.php'; require_once 'include/pmieducar/geral.inc.php'; +/** + * clsIndexBase class. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Classe disponível desde a versão 1.0.0 + * @version @@package_version@@ + */ class clsIndexBase extends clsBase { - function Formular() - { - $this->SetTitulo( "{$this->_instituicao} i-Educar - Falta Atraso" ); - $this->processoAp = "635"; - } + function Formular() + { + $this->SetTitulo($this->_instituicao . ' i-Educar - Falta Atraso'); + $this->processoAp = 635; + } } +/** + * indice class. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Classe disponível desde a versão 1.0.0 + * @version @@package_version@@ + */ class indice extends clsCadastro { - /** - * Referencia pega da session para o idpes do usuario atual - * - * @var int - */ - var $pessoa_logada; - - var $cod_falta_atraso; - var $ref_cod_escola; - var $ref_cod_instituicao; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $ref_cod_servidor; - var $tipo; - var $data_falta_atraso; - var $qtd_horas; - var $qtd_min; - var $justificada; - var $data_cadastro; - var $data_exclusao; - var $ativo; - - function Inicializar() - { - $retorno = "Novo"; - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $this->cod_falta_atraso = $_GET["cod_falta_atraso"]; - $this->ref_cod_servidor = $_GET["ref_cod_servidor"]; - $this->ref_cod_escola = $_GET["ref_cod_escola"]; - $this->ref_cod_instituicao = $_GET["ref_cod_instituicao"]; - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 7, "educar_falta_atraso_lst.php" ); - - if( is_numeric( $this->cod_falta_atraso ) ) - { - - $obj = new clsPmieducarFaltaAtraso( $this->cod_falta_atraso ); - $registro = $obj->detalhe(); - if( $registro ) - { - foreach( $registro AS $campo => $val ) // passa todos os valores obtidos no registro para atributos do objeto - $this->$campo = $val; - $this->data_falta_atraso = dataFromPgToBr( $this->data_falta_atraso ); - - $obj_permissoes = new clsPermissoes(); - if( $obj_permissoes->permissao_excluir( 635, $this->pessoa_logada, 7 ) ) - { - $this->fexcluir = true; - } - - $retorno = "Editar"; - } - } - $this->url_cancelar = ($retorno == "Editar") ? "educar_falta_atraso_det.php?cod_falta_atraso={$registro["cod_falta_atraso"]}" : "educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}"; - $this->nome_url_cancelar = "Cancelar"; - return $retorno; - } - - function Gerar() - { - // primary keys - $this->campoOculto( "cod_falta_atraso", $this->cod_falta_atraso ); - $this->campoOculto( "ref_cod_servidor", $this->ref_cod_servidor ); - - // foreign keys - $obrigatorio = true; - $get_instituicao = true; - $get_escola = true; - include("include/pmieducar/educar_campo_lista.php"); - - // text - $opcoes = array( "" => "Selecione", "1" => "Atraso", "2" => "Falta" ); - $this->campoLista( "tipo", "Tipo", $opcoes, $this->tipo ); - - $this->campoNumero( "qtd_horas", "Quantidade de Horas", $this->qtd_horas, 30, 255, false ); - $this->campoNumero( "qtd_min", "Quantidade de Minutos", $this->qtd_min, 30, 255, false ); - - $opcoes = array( "" => "Selecione", "0" => "Sim", "1" => "Não" ); - $this->campoLista( "justificada", "Justificada", $opcoes, $this->justificada ); - - // data - $this->campoData( "data_falta_atraso", "Dia", $this->data_falta_atraso, true ); - } - - function Novo() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 7, "educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - - if ( $this->tipo == 1 ) - $obj = new clsPmieducarFaltaAtraso( null, $this->ref_cod_escola, $this->ref_cod_instituicao, null, $this->pessoa_logada, $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, $this->qtd_horas, $this->qtd_min, $this->justificada, null, null, 1 ); - elseif ( $this->tipo == 2 ) - { - $db = new clsBanco(); - $dia_semana = $db->CampoUnico( "SELECT EXTRACT ( DOW FROM ( date '".dataToBanco( $this->data_falta_atraso )."' ) + 1 )" ); - - $obj_ser = new clsPmieducarServidor(); - $horas = $obj_ser->qtdhoras( $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao, $dia_semana ); - if ( $horas ) - { - $obj = new clsPmieducarFaltaAtraso( null, $this->ref_cod_escola, $this->ref_cod_instituicao, null, $this->pessoa_logada, $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, $horas["hora"], $horas["min"], $this->justificada, null, null, 1 ); - } - } - $cadastrou = $obj->cadastra(); - if( $cadastrou ) - { - $this->mensagem .= "Cadastro efetuado com sucesso.
"; - header( "Location: educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - die(); - return true; - } - - $this->mensagem = "Cadastro não realizado.
"; - echo ""; - return false; - } - - function Editar() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 7, "educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - - if ( $this->tipo == 1 ) { - $obj = new clsPmieducarFaltaAtraso( null, $this->ref_cod_escola, $this->ref_cod_instituicao, $this->pessoa_logada, null, $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, $this->qtd_horas, $this->qtd_min, $this->justificada, null, null, 1 ); - } - elseif ( $this->tipo == 2 ) { - $obj_ser = new clsPmieducarServidor( $this->ref_cod_servidor, null, null, null, null, null, 1, $this->ref_cod_instituicao ); - $det_ser = $obj_ser->detalhe(); - $horas = floor( $det_ser["carga_horaria"] ); - $minutos = ( $det_ser["carga_horaria"] - $horas ) * 60; - $obj = new clsPmieducarFaltaAtraso( null, $this->ref_cod_escola, $this->ref_cod_instituicao, $this->pessoa_logada, null, $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, $horas, $minutos, $this->justificada, null, null, 1 ); - } - $editou = $obj->edita(); - if( $editou ) - { - $this->mensagem .= "Edição efetuada com sucesso.
"; - header( "Location: educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - die(); - return true; - } - - $this->mensagem = "Edição não realizada.
"; - echo ""; - return false; - } - - function Excluir() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_excluir( 635, $this->pessoa_logada, 7, "educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - - - $obj = new clsPmieducarFaltaAtraso($this->cod_falta_atraso, $this->ref_cod_escola, $this->ref_ref_cod_instituicao, $this->pessoa_logada, $this->pessoa_logada, $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, $this->qtd_horas, $this->qtd_min, $this->justificada, $this->data_cadastro, $this->data_exclusao, 0); - $excluiu = $obj->excluir(); - if( $excluiu ) - { - $this->mensagem .= "Exclusão efetuada com sucesso.
"; - header( "Location: educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - die(); - return true; - } - - $this->mensagem = "Exclusão não realizada.
"; - echo ""; - return false; - } + var $pessoa_logada; + + var $cod_falta_atraso; + var $ref_cod_escola; + var $ref_cod_instituicao; + var $ref_usuario_exc; + var $ref_usuario_cad; + var $ref_cod_servidor; + var $tipo; + var $data_falta_atraso; + var $qtd_horas; + var $qtd_min; + var $justificada; + var $data_cadastro; + var $data_exclusao; + var $ativo; + + function Inicializar() + { + $retorno = 'Novo'; + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $this->cod_falta_atraso = $_GET['cod_falta_atraso']; + $this->ref_cod_servidor = $_GET['ref_cod_servidor']; + $this->ref_cod_escola = $_GET['ref_cod_escola']; + $this->ref_cod_instituicao = $_GET['ref_cod_instituicao']; + + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7, + 'educar_falta_atraso_lst.php'); + + if (is_numeric($this->cod_falta_atraso)) { + $obj = new clsPmieducarFaltaAtraso($this->cod_falta_atraso); + $registro = $obj->detalhe(); + + if ($registro) { + // passa todos os valores obtidos no registro para atributos do objeto + foreach ($registro as $campo => $val) { + $this->$campo = $val; + } + + $this->data_falta_atraso = dataFromPgToBr($this->data_falta_atraso); + + $obj_permissoes = new clsPermissoes(); + + if ($obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 7)) { + $this->fexcluir = TRUE; + } + + $retorno = 'Editar'; + } + } + + $this->url_cancelar = $retorno == 'Editar' ? + sprintf('educar_falta_atraso_det.php?cod_falta_atraso=%d', $registro['cod_falta_atraso']) : + sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d', $this->ref_cod_servidor, $this->ref_cod_instituicao); + + $this->nome_url_cancelar = 'Cancelar'; + return $retorno; + } + + function Gerar() + { + // Primary keys + $this->campoOculto('cod_falta_atraso', $this->cod_falta_atraso); + $this->campoOculto('ref_cod_servidor', $this->ref_cod_servidor); + + // Foreign keys + $obrigatorio = true; + $get_instituicao = true; + $get_escola = true; + include 'include/pmieducar/educar_campo_lista.php'; + + // Text + // @todo CoreExt_Enum + $opcoes = array( + '' => 'Selecione', + 1 => 'Atraso', + 2 => 'Falta' + ); + + $this->campoLista('tipo', 'Tipo', $opcoes, $this->tipo); + + $this->campoNumero('qtd_horas', 'Quantidade de Horas', $this->qtd_horas, 30, 255, FALSE); + $this->campoNumero('qtd_min', 'Quantidade de Minutos', $this->qtd_min, 30, 255, FALSE); + + $opcoes = array( + '' => 'Selecione', + 0 => 'Sim', + 1 => 'Não' + ); + + $this->campoLista('justificada', 'Justificada', $opcoes, $this->justificada); + + // Data + $this->campoData('data_falta_atraso', 'Dia', $this->data_falta_atraso, TRUE); + } + + function Novo() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7, + sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_instituicao)); + + if ($this->tipo == 1) { + $obj = new clsPmieducarFaltaAtraso(NULL, $this->ref_cod_escola, + $this->ref_cod_instituicao, NULL, $this->pessoa_logada, + $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, + $this->qtd_horas, $this->qtd_min, $this->justificada, NULL, NULL, 1); + } + elseif ($this->tipo == 2) { + $db = new clsBanco(); + $dia_semana = $db->CampoUnico(sprintf('SELECT EXTRACT (DOW FROM (date "%s") + 1 )', dataToBanco($this->data_falta_atraso))); + + $obj_ser = new clsPmieducarServidor(); + $horas = $obj_ser->qtdhoras( $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao, $dia_semana ); + + if ($horas) { + $obj = new clsPmieducarFaltaAtraso(NULL, $this->ref_cod_escola, + $this->ref_cod_instituicao, NULL, $this->pessoa_logada, + $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, + $horas['hora'], $horas['min'], $this->justificada, NULL, NULL, 1); + } + } + + $cadastrou = $obj->cadastra(); + + if ($cadastrou) { + $this->mensagem .= 'Cadastro efetuado com sucesso.
'; + header('Location: ' . sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_instituicao)); + die(); + } + + $this->mensagem = 'Cadastro não realizado.
'; + echo ""; + return FALSE; + } + + function Editar() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7, + sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_instituicao)); + + if ($this->tipo == 1) { + $obj = new clsPmieducarFaltaAtraso(NULL, $this->ref_cod_escola, + $this->ref_cod_instituicao, $this->pessoa_logada, NULL, + $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, + $this->qtd_horas, $this->qtd_min, $this->justificada, NULL, NULL, 1); + } + elseif ($this->tipo == 2) { + $obj_ser = new clsPmieducarServidor($this->ref_cod_servidor, NULL, NULL, + NULL, NULL, NULL, 1, $this->ref_cod_instituicao); + + $det_ser = $obj_ser->detalhe(); + $horas = floor($det_ser['carga_horaria']); + $minutos = ($det_ser['carga_horaria'] - $horas) * 60; + $obj = new clsPmieducarFaltaAtraso(NULL, $this->ref_cod_escola, + $this->ref_cod_instituicao, $this->pessoa_logada, NULL, + $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, $horas, + $minutos, $this->justificada, NULL, NULL, 1); + } + + $editou = $obj->edita(); + if ($editou) { + $this->mensagem .= 'Edição efetuada com sucesso.
'; + header('Location: ' . sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_instituicao)); + die(); + } + + $this->mensagem = 'Edição não realizada.
'; + echo ""; + return FALSE; + } + + function Excluir() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 7, + sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_instituicao)); + + $obj = new clsPmieducarFaltaAtraso($this->cod_falta_atraso, $this->ref_cod_escola, + $this->ref_ref_cod_instituicao, $this->pessoa_logada, $this->pessoa_logada, + $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, $this->qtd_horas, + $this->qtd_min, $this->justificada, $this->data_cadastro, $this->data_exclusao, 0); + $excluiu = $obj->excluir(); + if ($excluiu) { + $this->mensagem .= 'Exclusão efetuada com sucesso.
'; + header('Location: ' . sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_instituicao)); + die(); + } + + $this->mensagem = "Exclusão não realizada.
"; + echo ""; + return FALSE; + } } -// cria uma extensao da classe base +// Instancia objeto de página $pagina = new clsIndexBase(); -// cria o conteudo + +// Instancia objeto de conteúdo $miolo = new indice(); -// adiciona o conteudo na clsBase -$pagina->addForm( $miolo ); -// gera o html + +// Atribui o conteúdo à página +$pagina->addForm($miolo); + +// Gera o código HTML $pagina->MakeAll(); ?> - \ No newline at end of file diff --git a/ieducar/intranet/educar_falta_atraso_compensado_cad.php b/ieducar/intranet/educar_falta_atraso_compensado_cad.php index a81117d..a380dc3 100644 --- a/ieducar/intranet/educar_falta_atraso_compensado_cad.php +++ b/ieducar/intranet/educar_falta_atraso_compensado_cad.php @@ -1,209 +1,248 @@ + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Adriano Erik Weiguert Nagasava + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Arquivo disponível desde a versão 1.0.0 + * @version $Id$ */ -require_once ("include/clsBase.inc.php"); -require_once ("include/clsCadastro.inc.php"); -require_once ("include/clsBanco.inc.php"); -require_once( "include/pmieducar/geral.inc.php" ); +require_once 'include/clsBase.inc.php'; +require_once 'include/clsCadastro.inc.php'; +require_once 'include/clsBanco.inc.php'; +require_once 'include/pmieducar/geral.inc.php'; + +/** + * clsIndexBase class. + * + * @author Adriano Erik Weiguert Nagasava + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Classe disponível desde a versão 1.0.0 + * @version @@package_version@@ + */ class clsIndexBase extends clsBase { - function Formular() - { - $this->SetTitulo( "{$this->_instituicao} i-Educar - Falta Atraso Compensado" ); - $this->processoAp = "635"; - } + function Formular() + { + $this->SetTitulo($this->_instituicao . ' i-Educar - Falta Atraso Compensado'); + $this->processoAp = 635; + } } +/** + * clsIndexBase class. + * + * @author Adriano Erik Weiguert Nagasava + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Classe disponível desde a versão 1.0.0 + * @version @@package_version@@ + */ class indice extends clsCadastro { - /** - * Referencia pega da session para o idpes do usuario atual - * - * @var int - */ - var $pessoa_logada; - - var $cod_compensado; - var $ref_cod_escola; - var $ref_cod_instituicao; - var $ref_cod_servidor; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $data_inicio; - var $data_fim; - var $data_cadastro; - var $data_exclusao; - var $ativo; - - function Inicializar() - { - $retorno = "Novo"; - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $this->cod_compensado = $_GET["cod_compensado"]; - $this->ref_cod_servidor = $_GET["ref_cod_servidor"]; - $this->ref_cod_escola = $_GET["ref_cod_escola"]; - $this->ref_cod_instituicao = $_GET["ref_cod_instituicao"]; - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 7, "educar_falta_atraso_det.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - - if( is_numeric( $this->cod_compensado ) ) - { - - $obj = new clsPmieducarFaltaAtrasoCompensado( $this->cod_compensado ); - $registro = $obj->detalhe(); - if( $registro ) - { - foreach( $registro AS $campo => $val ) // passa todos os valores obtidos no registro para atributos do objeto - $this->$campo = $val; - $this->data_inicio = dataFromPgToBr( $this->data_inicio ); - $this->data_fim = dataFromPgToBr( $this->data_fim ); - $this->data_cadastro = dataFromPgToBr( $this->data_cadastro ); - $this->data_exclusao = dataFromPgToBr( $this->data_exclusao ); - - $obj_permissoes = new clsPermissoes(); - if( $obj_permissoes->permissao_excluir( 635, $this->pessoa_logada, 7 ) ) - { - $this->fexcluir = true; - } - - $retorno = "Editar"; - } - } - $this->url_cancelar = ($retorno == "Editar") ? "educar_falta_atraso_det.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao}" : "educar_falta_atraso_det.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao}"; - $this->nome_url_cancelar = "Cancelar"; - return $retorno; - } - - function Gerar() - { - // primary keys - $this->campoOculto( "cod_compensado", $this->cod_compensado ); - $this->campoOculto( "ref_cod_servidor", $this->ref_cod_servidor ); - - // foreign keys - $obrigatorio = true; - $get_instituicao = true; - $get_escola = true; - include("include/pmieducar/educar_campo_lista.php"); - - // data - $this->campoData( "data_inicio", "Data Inicio", $this->data_inicio, true ); - $this->campoData( "data_fim", "Data Fim", $this->data_fim, true ); - - } - - function Novo() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 7, "educar_falta_atraso_det.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - - $obj = new clsPmieducarFaltaAtrasoCompensado( null, $this->ref_cod_escola, $this->ref_cod_instituicao, $this->ref_cod_servidor, $this->pessoa_logada, $this->pessoa_logada, $this->data_inicio, $this->data_fim, null, null, 1 ); - $cadastrou = $obj->cadastra(); - if( $cadastrou ) - { - $this->mensagem .= "Cadastro efetuado com sucesso.
"; - header( "Location: educar_falta_atraso_det.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - die(); - return true; - } - - $this->mensagem = "Cadastro não realizado.
"; - echo ""; - return false; - } - - function Editar() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 7, "educar_falta_atraso_det.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - - - $obj = new clsPmieducarFaltaAtrasoCompensado($this->cod_compensado, $this->ref_cod_escola, $this->ref_cod_instituicao, $this->ref_cod_servidor, $this->pessoa_logada, $this->pessoa_logada, $this->data_inicio, $this->data_fim, $this->data_cadastro, $this->data_exclusao, $this->ativo); - $editou = $obj->edita(); - if( $editou ) - { - $this->mensagem .= "Edição efetuada com sucesso.
"; - header( "Location: educar_falta_atraso_det.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - die(); - return true; - } - - $this->mensagem = "Edição não realizada.
"; - echo ""; - return false; - } - - function Excluir() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_excluir( 635, $this->pessoa_logada, 7, "educar_falta_atraso_det.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - - - $obj = new clsPmieducarFaltaAtrasoCompensado($this->cod_compensado, $this->ref_cod_escola, $this->ref_cod_instituicao, $this->ref_cod_servidor, $this->pessoa_logada, $this->pessoa_logada, $this->data_inicio, $this->data_fim, $this->data_cadastro, $this->data_exclusao, 0); - $excluiu = $obj->excluir(); - if( $excluiu ) - { - $this->mensagem .= "Exclusão efetuada com sucesso.
"; - header( "Location: educar_falta_atraso_det.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao}" ); - die(); - return true; - } - - $this->mensagem = "Exclusão não realizada.
"; - echo ""; - return false; - } + var $pessoa_logada; + + var $cod_compensado; + var $ref_cod_escola; + var $ref_cod_instituicao; + var $ref_cod_servidor; + var $ref_usuario_exc; + var $ref_usuario_cad; + var $data_inicio; + var $data_fim; + var $data_cadastro; + var $data_exclusao; + var $ativo; + + function Inicializar() + { + $retorno = 'Novo'; + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $this->cod_compensado = $_GET['cod_compensado']; + $this->ref_cod_servidor = $_GET['ref_cod_servidor']; + $this->ref_cod_escola = $_GET['ref_cod_escola']; + $this->ref_cod_instituicao = $_GET['ref_cod_instituicao']; + + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7, + sprintf('educar_falta_atraso_det.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao)); + + if (is_numeric($this->cod_compensado)) { + $obj = new clsPmieducarFaltaAtrasoCompensado($this->cod_compensado); + $registro = $obj->detalhe(); + + if ($registro) { + // passa todos os valores obtidos no registro para atributos do objeto + foreach ($registro as $campo => $val) { + $this->$campo = $val; + } + + $this->data_inicio = dataFromPgToBr($this->data_inicio); + $this->data_fim = dataFromPgToBr($this->data_fim); + $this->data_cadastro = dataFromPgToBr($this->data_cadastro); + $this->data_exclusao = dataFromPgToBr($this->data_exclusao); + + $obj_permissoes = new clsPermissoes(); + if ($obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 7)) { + $this->fexcluir = TRUE; + } + + $retorno = 'Editar'; + } + } + + $this->url_cancelar = sprintf('educar_falta_atraso_det.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao); + + $this->nome_url_cancelar = 'Cancelar'; + return $retorno; + } + + function Gerar() + { + // Primary keys + $this->campoOculto('cod_compensado', $this->cod_compensado); + $this->campoOculto('ref_cod_servidor', $this->ref_cod_servidor); + + // Foreign keys + $obrigatorio = TRUE; + $get_instituicao = TRUE; + $get_escola = TRUE; + include 'include/pmieducar/educar_campo_lista.php'; + + // Data + $this->campoData('data_inicio', 'Data Inicio', $this->data_inicio, TRUE); + $this->campoData('data_fim', 'Data Fim', $this->data_fim, TRUE); + } + + function Novo() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7, + "educar_falta_atraso_det.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao}"); + + // + $this->data_inicio = dataToBanco($this->data_inicio); + $this->data_fim = dataToBanco($this->data_fim); + + $obj = new clsPmieducarFaltaAtrasoCompensado(NULL, $this->ref_cod_escola, + $this->ref_cod_instituicao, $this->ref_cod_servidor, $this->pessoa_logada, + $this->pessoa_logada, $this->data_inicio, $this->data_fim, NULL, NULL, 1); + + $cadastrou = $obj->cadastra(); + + if ($cadastrou) { + $this->mensagem .= 'Cadastro efetuado com sucesso.
'; + header('Location: ' . sprintf('educar_falta_atraso_det.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao)); + die(); + } + + $this->mensagem = 'Cadastro não realizado.
'; + echo ""; + return FALSE; + } + + function Editar() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7, + sprintf('educar_falta_atraso_det.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao)); + + $obj = new clsPmieducarFaltaAtrasoCompensado($this->cod_compensado, + $this->ref_cod_escola, $this->ref_cod_instituicao, $this->ref_cod_servidor, + $this->pessoa_logada, $this->pessoa_logada, $this->data_inicio, + $this->data_fim, $this->data_cadastro, $this->data_exclusao, $this->ativo); + + $editou = $obj->edita(); + + if ($editou) { + $this->mensagem .= 'Edição efetuada com sucesso.
'; + header('Location: ' . sprintf('educar_falta_atraso_det.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao)); + die(); + } + + $this->mensagem = 'Edição não realizada.
'; + echo ""; + return FALSE; + } + + function Excluir() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 7, + sprintf('educar_falta_atraso_det.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao)); + + $obj = new clsPmieducarFaltaAtrasoCompensado($this->cod_compensado, + $this->ref_cod_escola, $this->ref_cod_instituicao, $this->ref_cod_servidor, + $this->pessoa_logada, $this->pessoa_logada, $this->data_inicio, + $this->data_fim, $this->data_cadastro, $this->data_exclusao, 0); + + $excluiu = $obj->excluir(); + + if ($excluiu) { + $this->mensagem .= 'Exclusão efetuada com sucesso.
'; + header("Location: educar_falta_atraso_det.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_cod_instituicao}"); + die(); + } + + $this->mensagem = 'Exclusão não realizada.
'; + echo ""; + return FALSE; + } } -// cria uma extensao da classe base +// Instancia objeto de página $pagina = new clsIndexBase(); -// cria o conteudo + +// Instancia objeto de conteúdo $miolo = new indice(); -// adiciona o conteudo na clsBase -$pagina->addForm( $miolo ); -// gera o html -$pagina->MakeAll(); -?> \ No newline at end of file + +// Atribui o conteúdo à página +$pagina->addForm($miolo); + +// Gera o código HTML +$pagina->MakeAll(); \ No newline at end of file diff --git a/ieducar/intranet/educar_falta_atraso_det.php b/ieducar/intranet/educar_falta_atraso_det.php index edf51cb..90ffcdb 100644 --- a/ieducar/intranet/educar_falta_atraso_det.php +++ b/ieducar/intranet/educar_falta_atraso_det.php @@ -1,151 +1,192 @@ + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Arquivo disponível desde a versão 1.0.0 + * @version $Id$ */ -require_once ("include/clsBase.inc.php"); -require_once ("include/clsDetalhe.inc.php"); -require_once ("include/clsBanco.inc.php"); -require_once( "include/pmieducar/geral.inc.php" ); +require_once 'include/clsBase.inc.php'; +require_once 'include/clsDetalhe.inc.php'; +require_once 'include/clsBanco.inc.php'; +require_once 'include/pmieducar/geral.inc.php'; + +/** + * clsIndexBase class. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Classe disponível desde a versão 1.0.0 + * @version @@package_version@@ + */ class clsIndexBase extends clsBase { - function Formular() - { - $this->SetTitulo( "{$this->_instituicao} i-Educar - Falta Atraso" ); - $this->processoAp = "635"; - } + function Formular() + { + $this->SetTitulo($this->_instituicao . ' i-Educar - Falta Atraso'); + $this->processoAp = 635; + } } +/** + * indice class. + * + * @author Adriano Erik Weiguert Nagasava + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Classe disponível desde a versão 1.0.0 + * @version @@package_version@@ + */ class indice extends clsDetalhe { - /** - * Titulo no topo da pagina - * - * @var int - */ - var $titulo; - - var $cod_falta_atraso; - var $ref_cod_escola; - var $ref_ref_cod_instituicao; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $ref_cod_servidor; - var $tipo; - var $data_falta_atraso; - var $qtd_horas; - var $qtd_min; - var $justificada; - var $data_cadastro; - var $data_exclusao; - var $ativo; - - function Gerar() - { - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - session_write_close(); - - $this->titulo = "Falta Atraso - Detalhe"; - $this->addBanner( "imagens/nvp_top_intranet.jpg", "imagens/nvp_vert_intranet.jpg", "Intranet" ); - - $this->ref_cod_servidor = $_GET["ref_cod_servidor"]; - $this->ref_cod_escola = $_GET["ref_cod_escola"]; - $this->ref_ref_cod_instituicao = $_GET["ref_cod_instituicao"]; - - $tmp_obj = new clsPmieducarFaltaAtraso(); - $tmp_obj->setOrderby( "data_falta_atraso DESC" ); - //$registro = $tmp_obj->lista( null, $this->ref_cod_escola, $this->ref_ref_cod_instituicao, null, null, $this->ref_cod_servidor, null, null, null, null, null, 1, null, null, null, null, 1 ); - //$registro = $tmp_obj->lista( null, $this->ref_cod_escola, $this->ref_ref_cod_instituicao, null, null, $this->ref_cod_servidor, null, null, null, null, null, null, null, null, null, null, 1 ); - $this->cod_falta_atraso = $_GET['cod_falta_atraso']; - $registro = $tmp_obj->lista($this->cod_falta_atraso); - - if( !$registro ) - { - header( "location: educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_ref_cod_instituicao}" ); - die(); - } - else { - $tabela = " - - - - - - - - "; - $cont = 0; - $total = 0; - foreach ( $registro as $falta ) { - //$total += $divida["valor_multa"]; - if ( ($cont % 2) == 0 ) - $color = " bgcolor=#E4E9ED "; - else - $color = " bgcolor=#FFFFFF "; - $obj_esc = new clsPmieducarEscolaComplemento( $falta["ref_cod_escola"] ); - $det_esc = $obj_esc->detalhe(); - $obj_ins = new clsPmieducarInstituicao( $falta["ref_ref_cod_instituicao"] ); - $det_ins = $obj_ins->detalhe(); - $corpo .= " - - - - - - - "; - $cont++; - } - $tabela .= $corpo; - $tabela .= "
DiaTipoQtd. HorasQtd. MinutosEscolaInstituição
".dataFromPgToBr( $falta["data_falta_atraso"] )."".( ( $falta["tipo"] == 1 ) ? "Atraso" : "Falta" )."".$falta["qtd_horas"]."".$falta["qtd_min"]."".$det_esc["nm_escola"]."".$det_ins["nm_instituicao"]."
"; - if ( $tabela ) - $this->addDetalhe( array( "Faltas/Atrasos", "{$tabela}") ); - } - - $obj_permissoes = new clsPermissoes(); - if( $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 7 ) ) - { - $this->caption_novo = "Compensar"; - $this->url_editar = false; - $this->url_novo = "educar_falta_atraso_compensado_cad.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_escola={$this->ref_cod_escola}&ref_cod_instituicao={$this->ref_ref_cod_instituicao}"; - } - $this->url_cancelar = "educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_ref_cod_instituicao}"; - $this->largura = "100%"; - } + var $titulo; + + var $cod_falta_atraso; + var $ref_cod_escola; + var $ref_ref_cod_instituicao; + var $ref_usuario_exc; + var $ref_usuario_cad; + var $ref_cod_servidor; + var $tipo; + var $data_falta_atraso; + var $qtd_horas; + var $qtd_min; + var $justificada; + var $data_cadastro; + var $data_exclusao; + var $ativo; + + function Gerar() + { + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + session_write_close(); + + $this->titulo = 'Falta Atraso - Detalhe'; + $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg', 'Intranet'); + + $this->ref_cod_servidor = $_GET['ref_cod_servidor']; + $this->ref_cod_escola = $_GET['ref_cod_escola']; + $this->ref_ref_cod_instituicao = $_GET['ref_cod_instituicao']; + + $tmp_obj = new clsPmieducarFaltaAtraso(); + $tmp_obj->setOrderby('data_falta_atraso DESC'); + $this->cod_falta_atraso = $_GET['cod_falta_atraso']; + $registro = $tmp_obj->lista($this->cod_falta_atraso); + + if (!$registro) { + header('Location: ' . sprintf( + 'educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_ref_cod_instituicao)); + die(); + } + else { + $tabela = ' + + + + + + + + '; + + $cont = 0; + $total = 0; + + foreach ($registro as $falta) { + if (($cont % 2) == 0) { + $color = ' bgcolor="#E4E9ED" '; + } + else { + $color = ' bgcolor="#FFFFFF" '; + } + + $obj_esc = new clsPmieducarEscolaComplemento($falta['ref_cod_escola']); + $det_esc = $obj_esc->detalhe(); + $obj_ins = new clsPmieducarInstituicao($falta['ref_ref_cod_instituicao']); + $det_ins = $obj_ins->detalhe(); + + $corpo .= sprintf(' + + + + + + + + ', + $color, dataFromPgToBr($falta['data_falta_atraso']), + $color, $falta['tipo'] == 1 ? 'Atraso' : 'Falta', + $color, $falta['qtd_horas'], + $color, $falta['qtd_min'], + $color, $det_esc['nm_escola'], + $color, $det_ins['nm_instituicao']); + + $cont++; + } + + $tabela .= $corpo; + $tabela .= "
DiaTipoQtd. HorasQtd. MinutosEscolaInstituição
%s%s%s%s%s%s
"; + + if ($tabela) { + $this->addDetalhe(array('Faltas/Atrasos', $tabela)); + } + } + + $obj_permissoes = new clsPermissoes(); + + if ($obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7)) { + $this->caption_novo = 'Compensar'; + $this->url_editar = FALSE; + $this->url_novo = sprintf( + 'educar_falta_atraso_compensado_cad.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_ref_cod_instituicao + ); + } + + $this->url_cancelar = sprintf( + "educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d", + $this->ref_cod_servidor, $this->ref_ref_cod_instituicao + ); + + $this->largura = '100%'; + } } -// cria uma extensao da classe base +// Instancia objeto de página $pagina = new clsIndexBase(); -// cria o conteudo + +// Instancia objeto de conteúdo $miolo = new indice(); -// adiciona o conteudo na clsBase -$pagina->addForm( $miolo ); -// gera o html -$pagina->MakeAll(); -?> \ No newline at end of file + +// Atribui o conteúdo à página +$pagina->addForm($miolo); + +// Gera o código HTML +$pagina->MakeAll(); \ No newline at end of file diff --git a/ieducar/intranet/educar_falta_atraso_lst.php b/ieducar/intranet/educar_falta_atraso_lst.php index ea452e0..5c6206c 100644 --- a/ieducar/intranet/educar_falta_atraso_lst.php +++ b/ieducar/intranet/educar_falta_atraso_lst.php @@ -1,29 +1,31 @@ * - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí - * ctima@itajai.sc.gov.br + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. * - * Este programa é software livre, você pode redistribuí-lo e/ou - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme - * publicada pela Free Software Foundation, tanto a versão 2 da - * Licença como (a seu critério) qualquer versão mais nova. + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. * - * Este programa é distribuído na expectativa de ser útil, mas SEM - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- - * sulte a Licença Pública Geral GNU para obter mais detalhes. - * - * Você deve ter recebido uma cópia da Licença Pública Geral GNU - * junto com este programa. Se não, escreva para a Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307, USA. + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Arquivo disponível desde a versão 1.0.0 + * @version $Id$ */ require_once 'include/clsBase.inc.php'; @@ -31,85 +33,77 @@ require_once 'include/clsListagem.inc.php'; require_once 'include/clsBanco.inc.php'; require_once 'include/pmieducar/geral.inc.php'; -class clsIndexBase extends clsBase { - - public function Formular() { - $this->SetTitulo( "{$this->_instituicao} i-Educar - Falta Atraso" ); - $this->processoAp = "635"; +/** + * clsIndexBase class. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Classe disponível desde a versão 1.0.0 + * @version @@package_version@@ + */ +class clsIndexBase extends clsBase +{ + public function Formular() + { + $this->SetTitulo($this->_instituicao . ' i-Educar - Falta Atraso'); + $this->processoAp = 635; } - } - +/** + * indice class. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Classe disponível desde a versão 1.0.0 + * @version @@package_version@@ + */ class indice extends clsListagem { - /** - * Referencia pega da session para o idpes do usuario atual - * - * @var int - */ - public $pessoa_logada = 0; - - /** - * Titulo no topo da pagina - * - * @var int - */ - public $titulo = ''; - - /** - * Quantidade de registros a ser apresentada em cada pagina - * - * @var int - */ - public $limite = 0; - - /** - * Inicio dos registros a serem exibidos (limit) - * - * @var int - */ - public $offset = 0; - - public - $cod_falta_atraso = NULL, - $ref_cod_escola = NULL, - $ref_ref_cod_instituicao = NULL, - $ref_usuario_exc = NULL, - $ref_usuario_cad = NULL, - $ref_cod_servidor = NULL, - $tipo = NULL, - $data_falta_atraso = NULL, - $qtd_horas = NULL, - $qtd_min = NULL, - $justificada = NULL, - $data_cadastro = NULL, - $data_exclusao = NULL, - $ativo = NULL; - - - - public function Gerar() { + var $pessoa_logada; + var $titulo; + var $limite; + var $offset; + + var $cod_falta_atraso = NULL; + var $ref_cod_escola = NULL; + var $ref_ref_cod_instituicao = NULL; + var $ref_usuario_exc = NULL; + var $ref_usuario_cad = NULL; + var $ref_cod_servidor = NULL; + var $tipo = NULL; + var $data_falta_atraso = NULL; + var $qtd_horas = NULL; + var $qtd_min = NULL; + var $justificada = NULL; + var $data_cadastro = NULL; + var $data_exclusao = NULL; + var $ativo = NULL; + + function Gerar() + { session_start(); $this->pessoa_logada = $_SESSION['id_pessoa']; session_write_close(); - $this->ref_cod_servidor = isset($_GET['ref_cod_servidor']) ? - $_GET['ref_cod_servidor'] : NULL; - $this->ref_ref_cod_instituicao = isset($_GET['ref_cod_instituicao']) ? - $_GET['ref_cod_instituicao'] : NULL; + $this->ref_cod_servidor = $_GET['ref_cod_servidor']; + $this->ref_ref_cod_instituicao = $_GET['ref_cod_instituicao']; $this->titulo = 'Faltas e atrasos - Listagem'; foreach ($_GET as $var => $val) { - $this->$var = ($val === "") ? NULL : $val; + $this->$var = ($val === '') ? NULL : $val; } $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg', 'Intranet'); $this->addCabecalhos(array( 'Escola', - 'Instituicão', + 'Instituição', 'Tipo', 'Horas', 'Minutos' @@ -192,29 +186,39 @@ class indice extends clsListagem } } - $this->addPaginador2('educar_falta_atraso_lst.php', $total, $_GET, $this->nome, $this->limite); + $this->addPaginador2('educar_falta_atraso_lst.php', $total, $_GET, + $this->nome, $this->limite); $obj_permissoes = new clsPermissoes(); if ($obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7)) { - $this->array_botao[] = 'Novo'; - $this->array_botao_url[] = "educar_falta_atraso_cad.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_ref_cod_instituicao}"; + $this->array_botao[] = 'Novo'; + + $this->array_botao_url[] = sprintf( + 'educar_falta_atraso_cad.php?ref_cod_servidor=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_ref_cod_instituicao + ); } - $this->array_botao[] = 'Voltar'; - $this->array_botao_url[] = "educar_servidor_det.php?cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}"; - $this->largura = "100%"; + $this->array_botao[] = 'Voltar'; + + $this->array_botao_url[] = sprintf( + 'educar_servidor_det.php?cod_servidor=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_cod_instituicao + ); + + $this->largura = '100%'; } } -// cria uma extensao da classe base +// Instancia objeto de página $pagina = new clsIndexBase(); -// cria o conteudo +// Instancia objeto de conteúdo $miolo = new indice(); -// adiciona o conteudo na clsBase -$pagina->addForm( $miolo ); +// Atribui o conteúdo à página +$pagina->addForm($miolo); -// gera o html +// Gera o código HTML $pagina->MakeAll(); \ No newline at end of file diff --git a/ieducar/intranet/include/pmieducar/clsPmieducarFaltaAtraso.inc.php b/ieducar/intranet/include/pmieducar/clsPmieducarFaltaAtraso.inc.php index 69e4744..e3286df 100644 --- a/ieducar/intranet/include/pmieducar/clsPmieducarFaltaAtraso.inc.php +++ b/ieducar/intranet/include/pmieducar/clsPmieducarFaltaAtraso.inc.php @@ -1,804 +1,746 @@ + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Arquivo disponível desde a versão 1.0.0 + * @version $Id$ + */ + +require_once 'include/pmieducar/geral.inc.php'; +/** + * clsPmieducarFaltaAtraso class. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Classe disponível desde a versão 1.0.0 + * @version @@package_version@@ + */ class clsPmieducarFaltaAtraso { - var $cod_falta_atraso; - var $ref_cod_escola; - var $ref_ref_cod_instituicao; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $ref_cod_servidor; - var $tipo; - var $data_falta_atraso; - var $qtd_horas; - var $qtd_min; - var $justificada; - var $data_cadastro; - var $data_exclusao; - var $ativo; - - // propriedades padrao - - /** - * Armazena o total de resultados obtidos na ultima chamada ao metodo lista - * - * @var int - */ - var $_total; - - /** - * Nome do schema - * - * @var string - */ - var $_schema; - - /** - * Nome da tabela - * - * @var string - */ - var $_tabela; - - /** - * Lista separada por virgula, com os campos que devem ser selecionados na proxima chamado ao metodo lista - * - * @var string - */ - var $_campos_lista; - - /** - * Lista com todos os campos da tabela separados por virgula, padrao para selecao no metodo lista - * - * @var string - */ - var $_todos_campos; - - /** - * Valor que define a quantidade de registros a ser retornada pelo metodo lista - * - * @var int - */ - var $_limite_quantidade; - - /** - * Define o valor de offset no retorno dos registros no metodo lista - * - * @var int - */ - var $_limite_offset; - - /** - * Define o campo padrao para ser usado como padrao de ordenacao no metodo lista - * - * @var string - */ - var $_campo_order_by; - - - /** - * Construtor (PHP 4) - * - * @return object - */ - function clsPmieducarFaltaAtraso( $cod_falta_atraso = null, $ref_cod_escola = null, $ref_ref_cod_instituicao = null, $ref_usuario_exc = null, $ref_usuario_cad = null, $ref_cod_servidor = null, $tipo = null, $data_falta_atraso = null, $qtd_horas = null, $qtd_min = null, $justificada = null, $data_cadastro = null, $data_exclusao = null, $ativo = null ) - { - $db = new clsBanco(); - $this->_schema = "pmieducar."; - $this->_tabela = "{$this->_schema}falta_atraso"; - - $this->_campos_lista = $this->_todos_campos = "cod_falta_atraso, ref_cod_escola, ref_ref_cod_instituicao, ref_usuario_exc, ref_usuario_cad, ref_cod_servidor, tipo, data_falta_atraso, qtd_horas, qtd_min, justificada, data_cadastro, data_exclusao, ativo"; - - if( is_numeric( $ref_cod_escola ) ) - { - if( class_exists( "clsPmieducarEscola" ) ) - { - $tmp_obj = new clsPmieducarEscola( $ref_cod_escola ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { - $this->ref_cod_escola = $ref_cod_escola; - } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { - $this->ref_cod_escola = $ref_cod_escola; - } - } - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.escola WHERE cod_escola = '{$ref_cod_escola}'" ) ) - { - $this->ref_cod_escola = $ref_cod_escola; - } - } - } - if( is_numeric( $ref_usuario_cad ) ) - { - if( class_exists( "clsPmieducarUsuario" ) ) - { - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_cad ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { - $this->ref_usuario_cad = $ref_usuario_cad; - } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { - $this->ref_usuario_cad = $ref_usuario_cad; - } - } - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'" ) ) - { - $this->ref_usuario_cad = $ref_usuario_cad; - } - } - } - if( is_numeric( $ref_usuario_exc ) ) - { - if( class_exists( "clsPmieducarUsuario" ) ) - { - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_exc ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { - $this->ref_usuario_exc = $ref_usuario_exc; - } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { - $this->ref_usuario_exc = $ref_usuario_exc; - } - } - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'" ) ) - { - $this->ref_usuario_exc = $ref_usuario_exc; - } - } - } - if( is_numeric( $ref_cod_servidor ) && is_numeric( $ref_ref_cod_instituicao ) ) - { - if( class_exists( "clsPmieducarServidor" ) ) - { - $tmp_obj = new clsPmieducarServidor( $ref_cod_servidor, null, null, null, null, null, null, null, $ref_ref_cod_instituicao ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { - $this->ref_cod_servidor = $ref_cod_servidor; - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; - } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { - $this->ref_cod_servidor = $ref_cod_servidor; - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; - } - } - $this->ref_cod_servidor = $ref_cod_servidor; - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_cod_servidor}' AND ref_cod_instituicao = '{$ref_ref_cod_instituicao}'" ) ) - { - $this->ref_cod_servidor = $ref_cod_servidor; - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; - } - } - } - - - if( is_numeric( $cod_falta_atraso ) ) - { - $this->cod_falta_atraso = $cod_falta_atraso; - } - if( is_numeric( $tipo ) ) - { - $this->tipo = $tipo; - } - if( is_string( $data_falta_atraso ) ) - { - $this->data_falta_atraso = $data_falta_atraso; - } - if( is_numeric( $qtd_horas ) ) - { - $this->qtd_horas = $qtd_horas; - } - if( is_numeric( $qtd_min ) ) - { - $this->qtd_min = $qtd_min; - } - if( is_numeric( $justificada ) ) - { - $this->justificada = $justificada; - } - if( is_string( $data_cadastro ) ) - { - $this->data_cadastro = $data_cadastro; - } - if( is_string( $data_exclusao ) ) - { - $this->data_exclusao = $data_exclusao; - } - if( is_numeric( $ativo ) ) - { - $this->ativo = $ativo; - } - - } - - /** - * Cria um novo registro - * - * @return bool - */ - function cadastra() - { - if( is_numeric( $this->ref_cod_escola ) && is_numeric( $this->ref_ref_cod_instituicao ) && is_numeric( $this->ref_usuario_cad ) && is_numeric( $this->ref_cod_servidor ) && is_numeric( $this->tipo ) && is_string( $this->data_falta_atraso ) && is_numeric( $this->justificada ) ) - { - $db = new clsBanco(); - - $campos = ""; - $valores = ""; - $gruda = ""; - - if( is_numeric( $this->ref_cod_escola ) ) - { - $campos .= "{$gruda}ref_cod_escola"; - $valores .= "{$gruda}'{$this->ref_cod_escola}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_ref_cod_instituicao ) ) - { - $campos .= "{$gruda}ref_ref_cod_instituicao"; - $valores .= "{$gruda}'{$this->ref_ref_cod_instituicao}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_usuario_cad ) ) - { - $campos .= "{$gruda}ref_usuario_cad"; - $valores .= "{$gruda}'{$this->ref_usuario_cad}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_cod_servidor ) ) - { - $campos .= "{$gruda}ref_cod_servidor"; - $valores .= "{$gruda}'{$this->ref_cod_servidor}'"; - $gruda = ", "; - } - if( is_numeric( $this->tipo ) ) - { - $campos .= "{$gruda}tipo"; - $valores .= "{$gruda}'{$this->tipo}'"; - $gruda = ", "; - } - if( is_string( $this->data_falta_atraso ) ) - { - $campos .= "{$gruda}data_falta_atraso"; - $valores .= "{$gruda}'{$this->data_falta_atraso}'"; - $gruda = ", "; - } - if( is_numeric( $this->qtd_horas ) ) - { - $campos .= "{$gruda}qtd_horas"; - $valores .= "{$gruda}'{$this->qtd_horas}'"; - $gruda = ", "; - } - if( is_numeric( $this->qtd_min ) ) - { - $campos .= "{$gruda}qtd_min"; - $valores .= "{$gruda}'{$this->qtd_min}'"; - $gruda = ", "; - } - if( is_numeric( $this->justificada ) ) - { - $campos .= "{$gruda}justificada"; - $valores .= "{$gruda}'{$this->justificada}'"; - $gruda = ", "; - } - $campos .= "{$gruda}data_cadastro"; - $valores .= "{$gruda}NOW()"; - $gruda = ", "; - $campos .= "{$gruda}ativo"; - $valores .= "{$gruda}'1'"; - $gruda = ", "; - - - $db->Consulta( "INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )" ); - return $db->InsertId( "{$this->_tabela}_cod_falta_atraso_seq"); - } - return false; - } - - /** - * Edita os dados de um registro - * - * @return bool - */ - function edita() - { - if( is_numeric( $this->cod_falta_atraso ) && is_numeric( $this->ref_usuario_exc ) ) - { - - $db = new clsBanco(); - $set = ""; - - if( is_numeric( $this->ref_cod_escola ) ) - { - $set .= "{$gruda}ref_cod_escola = '{$this->ref_cod_escola}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_ref_cod_instituicao ) ) - { - $set .= "{$gruda}ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_usuario_exc ) ) - { - $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_usuario_cad ) ) - { - $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_cod_servidor ) ) - { - $set .= "{$gruda}ref_cod_servidor = '{$this->ref_cod_servidor}'"; - $gruda = ", "; - } - if( is_numeric( $this->tipo ) ) - { - $set .= "{$gruda}tipo = '{$this->tipo}'"; - $gruda = ", "; - } - if( is_string( $this->data_falta_atraso ) ) - { - $set .= "{$gruda}data_falta_atraso = '{$this->data_falta_atraso}'"; - $gruda = ", "; - } - if( is_numeric( $this->qtd_horas ) ) - { - $set .= "{$gruda}qtd_horas = '{$this->qtd_horas}'"; - $gruda = ", "; - } - if( is_numeric( $this->qtd_min ) ) - { - $set .= "{$gruda}qtd_min = '{$this->qtd_min}'"; - $gruda = ", "; - } - if( is_numeric( $this->justificada ) ) - { - $set .= "{$gruda}justificada = '{$this->justificada}'"; - $gruda = ", "; - } - if( is_string( $this->data_cadastro ) ) - { - $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'"; - $gruda = ", "; - } - $set .= "{$gruda}data_exclusao = NOW()"; - $gruda = ", "; - if( is_numeric( $this->ativo ) ) - { - $set .= "{$gruda}ativo = '{$this->ativo}'"; - $gruda = ", "; - } - - - if( $set ) - { - $db->Consulta( "UPDATE {$this->_tabela} SET $set WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'" ); - return true; - } - } - return false; - } - - /** - * Retorna uma lista filtrados de acordo com os parametros - * - * @return array - */ - function lista( $int_cod_falta_atraso = null, $int_ref_cod_escola = null, $int_ref_ref_cod_instituicao = null, $int_ref_usuario_exc = null, $int_ref_usuario_cad = null, $int_ref_cod_servidor = null, $int_tipo = null, $date_data_falta_atraso_ini = null, $date_data_falta_atraso_fim = null, $int_qtd_horas = null, $int_qtd_min = null, $int_justificada = null, $date_data_cadastro_ini = null, $date_data_cadastro_fim = null, $date_data_exclusao_ini = null, $date_data_exclusao_fim = null, $int_ativo = null ) - { - $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}"; - $filtros = ""; - - $whereAnd = " WHERE "; - - if( is_numeric( $int_cod_falta_atraso ) ) - { - $filtros .= "{$whereAnd} cod_falta_atraso = '{$int_cod_falta_atraso}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_cod_escola ) ) - { - $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_ref_cod_instituicao ) ) - { - $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_usuario_exc ) ) - { - $filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_usuario_cad ) ) - { - $filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_cod_servidor ) ) - { - $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_tipo ) ) - { - $filtros .= "{$whereAnd} tipo = '{$int_tipo}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_falta_atraso_ini ) ) - { - $filtros .= "{$whereAnd} data_falta_atraso >= '{$date_data_falta_atraso_ini}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_falta_atraso_fim ) ) - { - $filtros .= "{$whereAnd} data_falta_atraso <= '{$date_data_falta_atraso_fim}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_qtd_horas ) ) - { - $filtros .= "{$whereAnd} qtd_horas = '{$int_qtd_horas}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_qtd_min ) ) - { - $filtros .= "{$whereAnd} qtd_min = '{$int_qtd_min}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_justificada ) ) - { - $filtros .= "{$whereAnd} justificada = '{$int_justificada}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_cadastro_ini ) ) - { - $filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_cadastro_fim ) ) - { - $filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_exclusao_ini ) ) - { - $filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_exclusao_fim ) ) - { - $filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'"; - $whereAnd = " AND "; - } - if( is_null( $int_ativo ) || $int_ativo ) - { - $filtros .= "{$whereAnd} ativo = '1'"; - $whereAnd = " AND "; - } - else - { - $filtros .= "{$whereAnd} ativo = '0'"; - $whereAnd = " AND "; - } - - - $db = new clsBanco(); - $countCampos = count( explode( ",", $this->_campos_lista ) ); - $resultado = array(); - - $sql .= $filtros . $this->getOrderby() . $this->getLimite(); - - $this->_total = $db->CampoUnico( "SELECT COUNT(0) FROM {$this->_tabela} {$filtros}" ); - - $db->Consulta( $sql ); - - if( $countCampos > 1 ) - { - while ( $db->ProximoRegistro() ) - { - $tupla = $db->Tupla(); - - $tupla["_total"] = $this->_total; - $resultado[] = $tupla; - } - } - else - { - while ( $db->ProximoRegistro() ) - { - $tupla = $db->Tupla(); - $resultado[] = $tupla[$this->_campos_lista]; - } - } - if( count( $resultado ) ) - { - return $resultado; - } - return false; - } - - /** - * Retorna um array com os dados de um registro - * - * @return array - */ - function detalhe() - { - if( is_numeric( $this->cod_falta_atraso ) ) - { - - $db = new clsBanco(); - $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'" ); - $db->ProximoRegistro(); - return $db->Tupla(); - } - return false; - } - - /** - * Retorna um array com os dados de um registro - * - * @return array - */ - function existe() - { - if( is_numeric( $this->cod_falta_atraso ) ) - { - - $db = new clsBanco(); - $db->Consulta( "SELECT 1 FROM {$this->_tabela} WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'" ); - $db->ProximoRegistro(); - return $db->Tupla(); - } - return false; - } - - /** - * Exclui um registro - * - * @return bool - */ - function excluir() - { - if( is_numeric( $this->cod_falta_atraso ) && is_numeric( $this->ref_usuario_exc ) ) - { - - /* - delete - $db = new clsBanco(); - $db->Consulta( "DELETE FROM {$this->_tabela} WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'" ); - return true; - */ - - $this->ativo = 0; - return $this->edita(); - } - return false; - } - - /** - * Define quais campos da tabela serao selecionados na invocacao do metodo lista - * - * @return null - */ - function setCamposLista( $str_campos ) - { - $this->_campos_lista = $str_campos; - } - - /** - * Define que o metodo Lista devera retornoar todos os campos da tabela - * - * @return null - */ - function resetCamposLista() - { - $this->_campos_lista = $this->_todos_campos; - } - - /** - * Define limites de retorno para o metodo lista - * - * @return null - */ - function setLimite( $intLimiteQtd, $intLimiteOffset = null ) - { - $this->_limite_quantidade = $intLimiteQtd; - $this->_limite_offset = $intLimiteOffset; - } - - /** - * Retorna a string com o trecho da query resposavel pelo Limite de registros - * - * @return string - */ - function getLimite() - { - if( is_numeric( $this->_limite_quantidade ) ) - { - $retorno = " LIMIT {$this->_limite_quantidade}"; - if( is_numeric( $this->_limite_offset ) ) - { - $retorno .= " OFFSET {$this->_limite_offset} "; - } - return $retorno; - } - return ""; - } - - /** - * Define campo para ser utilizado como ordenacao no metolo lista - * - * @return null - */ - function setOrderby( $strNomeCampo ) - { - // limpa a string de possiveis erros (delete, insert, etc) - //$strNomeCampo = eregi_replace(); - - if( is_string( $strNomeCampo ) && $strNomeCampo ) - { - $this->_campo_order_by = $strNomeCampo; - } - } - - /** - * Retorna a string com o trecho da query resposavel pela Ordenacao dos registros - * - * @return string - */ - function getOrderby() - { - if( is_string( $this->_campo_order_by ) ) - { - return " ORDER BY {$this->_campo_order_by} "; - } - return ""; - } - - /** - * Retorna uma lista filtrados de acordo com os parametros - * - * @return array - */ - function listaHorasEscola( $int_ref_cod_servidor = null, $int_ref_ref_cod_instituicao = null, $int_ref_cod_escola = null ) - { - $sql = "SELECT sum( qtd_horas ) AS horas, - sum( qtd_min ) AS minutos, - ref_cod_escola, - ref_ref_cod_instituicao - FROM {$this->_tabela}"; - $filtros = ""; - - $whereAnd = " WHERE "; - - if( is_numeric( $int_ref_cod_servidor ) ) - { - $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_cod_escola ) ) - { - $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_ref_cod_instituicao ) ) - { - $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'"; - $whereAnd = " AND "; - } - $filtros .= "{$whereAnd} justificada <> '0'"; - $whereAnd = " AND "; - $filtros .= "{$whereAnd} ativo <> '0'"; - $whereAnd = " AND "; - - $groupBy = " GROUP BY ref_cod_escola, ref_ref_cod_instituicao"; - - - $db = new clsBanco(); - $countCampos = count( explode( ",", $this->_campos_lista ) ); - $resultado = array(); - - $this->_total = $db->CampoUnico( "SELECT COUNT( 0 ) FROM ( {$sql}{$filtros}{$groupBy} ) AS countsubquery" ); - - $sql .= $filtros . $groupBy . $this->getLimite(); - - - $db->Consulta( $sql ); - - if( $countCampos > 1 ) - { - while ( $db->ProximoRegistro() ) - { - $tupla = $db->Tupla(); - - $tupla["_total"] = $this->_total; - $resultado[] = $tupla; - } - } - else - { - while ( $db->ProximoRegistro() ) - { - $tupla = $db->Tupla(); - $resultado[] = $tupla[$this->_campos_lista]; - } - } - if( count( $resultado ) ) - { - return $resultado; - } - return false; - } -} -?> \ No newline at end of file + var $cod_falta_atraso; + var $ref_cod_escola; + var $ref_ref_cod_instituicao; + var $ref_usuario_exc; + var $ref_usuario_cad; + var $ref_cod_servidor; + var $tipo; + var $data_falta_atraso; + var $qtd_horas; + var $qtd_min; + var $justificada; + var $data_cadastro; + var $data_exclusao; + var $ativo; + + /** + * Armazena o total de resultados obtidos na última chamada ao método lista(). + * @var int + */ + var $_total; + + /** + * Nome do schema. + * @var string + */ + var $_schema; + + /** + * Nome da tabela. + * @var string + */ + var $_tabela; + + /** + * Lista separada por vírgula, com os campos que devem ser selecionados na + * próxima chamado ao método lista(). + * @var string + */ + var $_campos_lista; + + /** + * Lista com todos os campos da tabela separados por vírgula, padrão para + * seleção no método lista. + * @var string + */ + var $_todos_campos; + + /** + * Valor que define a quantidade de registros a ser retornada pelo método lista(). + * @var int + */ + var $_limite_quantidade; + + /** + * Define o valor de offset no retorno dos registros no método lista(). + * @var int + */ + var $_limite_offset; + + /** + * Define o campo para ser usado como padrão de ordenação no método lista(). + * @var string + */ + var $_campo_order_by; + + /** + * Construtor. + */ + function clsPmieducarFaltaAtraso($cod_falta_atraso = NULL, $ref_cod_escola = NULL, + $ref_ref_cod_instituicao = NULL, $ref_usuario_exc = NULL, $ref_usuario_cad = NULL, + $ref_cod_servidor = NULL, $tipo = NULL, $data_falta_atraso = NULL, + $qtd_horas = NULL, $qtd_min = NULL, $justificada = NULL, $data_cadastro = NULL, + $data_exclusao = NULL, $ativo = NULL) + { + $db = new clsBanco(); + $this->_schema = 'pmieducar.'; + $this->_tabela = $this->_schema . 'falta_atraso'; + + $this->_campos_lista = $this->_todos_campos = 'cod_falta_atraso, ref_cod_escola, ref_ref_cod_instituicao, ref_usuario_exc, ref_usuario_cad, ref_cod_servidor, tipo, data_falta_atraso, qtd_horas, qtd_min, justificada, data_cadastro, data_exclusao, ativo'; + + if (is_numeric($ref_cod_escola)) { + if (class_exists('clsPmieducarEscola')) { + $tmp_obj = new clsPmieducarEscola($ref_cod_escola); + if (method_exists($tmp_obj, 'existe')) { + if ($tmp_obj->existe()) { + $this->ref_cod_escola = $ref_cod_escola; + } + } + elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { + $this->ref_cod_escola = $ref_cod_escola; + } + } + } + else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.escola WHERE cod_escola = '{$ref_cod_escola}'")) { + $this->ref_cod_escola = $ref_cod_escola; + } + } + } + + if (is_numeric($ref_usuario_cad)) { + if (class_exists('clsPmieducarUsuario')) { + $tmp_obj = new clsPmieducarUsuario($ref_usuario_cad); + if (method_exists($tmp_obj, 'existe')) { + if ($tmp_obj->existe()) { + $this->ref_usuario_cad = $ref_usuario_cad; + } + } + elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { + $this->ref_usuario_cad = $ref_usuario_cad; + } + } + } + else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'")) { + $this->ref_usuario_cad = $ref_usuario_cad; + } + } + } + + if (is_numeric($ref_usuario_exc)) { + if (class_exists('clsPmieducarUsuario')) { + $tmp_obj = new clsPmieducarUsuario( $ref_usuario_exc ); + if (method_exists( $tmp_obj, 'existe')) { + if ($tmp_obj->existe()) { + $this->ref_usuario_exc = $ref_usuario_exc; + } + } + elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { + $this->ref_usuario_exc = $ref_usuario_exc; + } + } + } + else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'")) { + $this->ref_usuario_exc = $ref_usuario_exc; + } + } + } + + if (is_numeric($ref_cod_servidor) && is_numeric($ref_ref_cod_instituicao)) { + if (class_exists('clsPmieducarServidor')) { + $tmp_obj = new clsPmieducarServidor($ref_cod_servidor, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, $ref_ref_cod_instituicao); + + if (method_exists($tmp_obj, 'existe')) { + if ($tmp_obj->existe() ) { + $this->ref_cod_servidor = $ref_cod_servidor; + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; + } + } + elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { + $this->ref_cod_servidor = $ref_cod_servidor; + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; + } + } + + $this->ref_cod_servidor = $ref_cod_servidor; + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; + } + else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_cod_servidor}' AND ref_cod_instituicao = '{$ref_ref_cod_instituicao}'")) { + $this->ref_cod_servidor = $ref_cod_servidor; + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; + } + } + } + + if (is_numeric($cod_falta_atraso)) { + $this->cod_falta_atraso = $cod_falta_atraso; + } + + if (is_numeric($tipo)) { + $this->tipo = $tipo; + } + + if (is_string($data_falta_atraso)) { + $this->data_falta_atraso = $data_falta_atraso; + } + + if (is_numeric($qtd_horas)) { + $this->qtd_horas = $qtd_horas; + } + + if (is_numeric($qtd_min)) { + $this->qtd_min = $qtd_min; + } + + if (is_numeric($justificada)) { + $this->justificada = $justificada; + } + + if (is_string($data_cadastro)) { + $this->data_cadastro = $data_cadastro; + } + + if (is_string($data_exclusao)) { + $this->data_exclusao = $data_exclusao; + } + + if (is_numeric($ativo)) { + $this->ativo = $ativo; + } + } + + /** + * Cria um novo registro. + * @return bool + */ + function cadastra() + { + if (is_numeric($this->ref_cod_escola) && + is_numeric($this->ref_ref_cod_instituicao) && is_numeric($this->ref_usuario_cad) && + is_numeric($this->ref_cod_servidor) && is_numeric($this->tipo) && + is_string($this->data_falta_atraso) && is_numeric($this->justificada) + ) { + $db = new clsBanco(); + + $campos = ''; + $valores = ''; + $gruda = ''; + + if (is_numeric( $this->ref_cod_escola)) { + $campos .= "{$gruda}ref_cod_escola"; + $valores .= "{$gruda}'{$this->ref_cod_escola}'"; + $gruda = ', '; + } + + if (is_numeric( $this->ref_ref_cod_instituicao)) { + $campos .= "{$gruda}ref_ref_cod_instituicao"; + $valores .= "{$gruda}'{$this->ref_ref_cod_instituicao}'"; + $gruda = ', '; + } + + if (is_numeric( $this->ref_usuario_cad)) { + $campos .= "{$gruda}ref_usuario_cad"; + $valores .= "{$gruda}'{$this->ref_usuario_cad}'"; + $gruda = ', '; + } + + if (is_numeric( $this->ref_cod_servidor)) { + $campos .= "{$gruda}ref_cod_servidor"; + $valores .= "{$gruda}'{$this->ref_cod_servidor}'"; + $gruda = ', '; + } + + if (is_numeric( $this->tipo)) { + $campos .= "{$gruda}tipo"; + $valores .= "{$gruda}'{$this->tipo}'"; + $gruda = ', '; + } + + if (is_string( $this->data_falta_atraso)) { + $campos .= "{$gruda}data_falta_atraso"; + $valores .= "{$gruda}'{$this->data_falta_atraso}'"; + $gruda = ', '; + } + + if (is_numeric( $this->qtd_horas)) { + $campos .= "{$gruda}qtd_horas"; + $valores .= "{$gruda}'{$this->qtd_horas}'"; + $gruda = ', '; + } + + if (is_numeric( $this->qtd_min)) { + $campos .= "{$gruda}qtd_min"; + $valores .= "{$gruda}'{$this->qtd_min}'"; + $gruda = ', '; + } + + if (is_numeric( $this->justificada)) { + $campos .= "{$gruda}justificada"; + $valores .= "{$gruda}'{$this->justificada}'"; + $gruda = ', '; + } + + $campos .= "{$gruda}data_cadastro"; + $valores .= "{$gruda}NOW()"; + $gruda = ', '; + + $campos .= "{$gruda}ativo"; + $valores .= "{$gruda}'1'"; + $gruda = ', '; + + $db->Consulta("INSERT INTO {$this->_tabela} ($campos) VALUES($valores)"); + return $db->InsertId("{$this->_tabela}_cod_falta_atraso_seq"); + } + + return FALSE; + } + + /** + * Edita os dados de um registro. + * @return bool + */ + function edita() + { + if (is_numeric($this->cod_falta_atraso) && is_numeric($this->ref_usuario_exc)){ + $db = new clsBanco(); + $set = ''; + + if (is_numeric($this->ref_cod_escola)) { + $set .= "{$gruda}ref_cod_escola = '{$this->ref_cod_escola}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_ref_cod_instituicao)) { + $set .= "{$gruda}ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_usuario_exc)) { + $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_usuario_cad)) { + $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_cod_servidor)) { + $set .= "{$gruda}ref_cod_servidor = '{$this->ref_cod_servidor}'"; + $gruda = ', '; + } + + if (is_numeric($this->tipo)) { + $set .= "{$gruda}tipo = '{$this->tipo}'"; + $gruda = ', '; + } + + if (is_string($this->data_falta_atraso)) { + $set .= "{$gruda}data_falta_atraso = '{$this->data_falta_atraso}'"; + $gruda = ', '; + } + + if (is_numeric($this->qtd_horas)) { + $set .= "{$gruda}qtd_horas = '{$this->qtd_horas}'"; + $gruda = ', '; + } + + if (is_numeric($this->qtd_min)) { + $set .= "{$gruda}qtd_min = '{$this->qtd_min}'"; + $gruda = ', '; + } + + if (is_numeric($this->justificada)) { + $set .= "{$gruda}justificada = '{$this->justificada}'"; + $gruda = ', '; + } + + if (is_string($this->data_cadastro)) { + $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'"; + $gruda = ', '; + } + + $set .= "{$gruda}data_exclusao = NOW()"; + $gruda = ', '; + + if (is_numeric($this->ativo)) { + $set .= "{$gruda}ativo = '{$this->ativo}'"; + $gruda = ', '; + } + + if ($set) { + $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'"); + return true; + } + } + return false; + } + + /** + * Retorna uma lista de registros filtrados de acordo com os parâmetros. + * @return array + */ + function lista($int_cod_falta_atraso = null, $int_ref_cod_escola = null, + $int_ref_ref_cod_instituicao = null, $int_ref_usuario_exc = null, + $int_ref_usuario_cad = null, $int_ref_cod_servidor = null, $int_tipo = null, + $date_data_falta_atraso_ini = null, $date_data_falta_atraso_fim = null, + $int_qtd_horas = null, $int_qtd_min = null, $int_justificada = null, + $date_data_cadastro_ini = null, $date_data_cadastro_fim = null, + $date_data_exclusao_ini = null, $date_data_exclusao_fim = null, $int_ativo = null + ) { + $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}"; + $filtros = ''; + + $whereAnd = ' WHERE '; + + if (is_numeric($int_cod_falta_atraso)) { + $filtros .= "{$whereAnd} cod_falta_atraso = '{$int_cod_falta_atraso}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_cod_escola)) { + $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_ref_cod_instituicao)) { + $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_usuario_exc)) { + $filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_usuario_cad)) { + $filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_cod_servidor)) { + $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_tipo)) { + $filtros .= "{$whereAnd} tipo = '{$int_tipo}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_falta_atraso_ini)) { + $filtros .= "{$whereAnd} data_falta_atraso >= '{$date_data_falta_atraso_ini}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_falta_atraso_fim)) { + $filtros .= "{$whereAnd} data_falta_atraso <= '{$date_data_falta_atraso_fim}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_qtd_horas)) { + $filtros .= "{$whereAnd} qtd_horas = '{$int_qtd_horas}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_qtd_min)) { + $filtros .= "{$whereAnd} qtd_min = '{$int_qtd_min}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_justificada)) { + $filtros .= "{$whereAnd} justificada = '{$int_justificada}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_cadastro_ini)) { + $filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_cadastro_fim)) { + $filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_exclusao_ini)) { + $filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_exclusao_fim)) { + $filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'"; + $whereAnd = ' AND '; + } + + if (is_null($int_ativo) || $int_ativo) { + $filtros .= "{$whereAnd} ativo = '1'"; + $whereAnd = ' AND '; + } + else { + $filtros .= "{$whereAnd} ativo = '0'"; + $whereAnd = ' AND '; + } + + $db = new clsBanco(); + $countCampos = count(explode(',', $this->_campos_lista)); + $resultado = array(); + + $sql .= $filtros . $this->getOrderby() . $this->getLimite(); + + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} {$filtros}"); + + $db->Consulta($sql); + + if ($countCampos > 1) { + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + + $tupla['_total'] = $this->_total; + $resultado[] = $tupla; + } + } + else { + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + $resultado[] = $tupla[$this->_campos_lista]; + } + } + + if (count($resultado)) { + return $resultado; + } + + return FALSE; + } + + /** + * Retorna um array com os dados de um registro. + * @return array + */ + function detalhe() + { + if (is_numeric($this->cod_falta_atraso)) { + $db = new clsBanco(); + $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'" ); + $db->ProximoRegistro(); + return $db->Tupla(); + } + + return FALSE; + } + + /** + * Retorna um array com os dados de um registro. + * @return array + */ + function existe() + { + if (is_numeric($this->cod_falta_atraso)) { + $db = new clsBanco(); + $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'"); + $db->ProximoRegistro(); + return $db->Tupla(); + } + + return FALSE; + } + + /** + * Exclui um registro. + * @return bool + */ + function excluir() + { + if (is_numeric($this->cod_falta_atraso) && is_numeric($this->ref_usuario_exc)) { + $this->ativo = 0; + return $this->edita(); + } + + return FALSE; + } + + /** + * Retorna uma lista de registros filtrados de acordo com os parâmetros. + * @return array + * @todo Remover método (não utilizado) + */ + function listaHorasEscola($int_ref_cod_servidor = null, + $int_ref_ref_cod_instituicao = null, $int_ref_cod_escola = null) + { + $sql = ' + SELECT + SUM(qtd_horas) AS horas, + SUM(qtd_min) AS minutos, + ref_cod_escola, + ref_ref_cod_instituicao + FROM + ' . $this->_tabela; + + $filtros = ''; + + $whereAnd = ' WHERE '; + + if (is_numeric( $int_ref_cod_servidor ) ) { + $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'"; + $whereAnd = ' AND '; + } + if (is_numeric( $int_ref_cod_escola ) ) { + $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'"; + $whereAnd = ' AND '; + } + if (is_numeric( $int_ref_ref_cod_instituicao ) ) { + $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'"; + $whereAnd = ' AND '; + } + + $filtros .= "{$whereAnd} justificada <> '0'"; + $whereAnd = ' AND '; + + $filtros .= "{$whereAnd} ativo <> '0'"; + $whereAnd = ' AND '; + + $groupBy = " GROUP BY ref_cod_escola, ref_ref_cod_instituicao"; + + + $db = new clsBanco(); + $countCampos = count(explode(',', $this->_campos_lista)); + $resultado = array(); + + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM ({$sql}{$filtros}{$groupBy}) AS countsubquery"); + + $sql .= $filtros . $groupBy . $this->getLimite(); + + $db->Consulta($sql); + + if ($countCampos > 1) { + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + + $tupla["_total"] = $this->_total; + $resultado[] = $tupla; + } + } + else { + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + $resultado[] = $tupla[$this->_campos_lista]; + } + } + + if (count( $resultado ) ) { + return $resultado; + } + + return FALSE; + } + + /** + * Define quais campos da tabela serão selecionados no método Lista(). + */ + function setCamposLista($str_campos) + { + $this->_campos_lista = $str_campos; + } + + /** + * Define que o método Lista() deverpa retornar todos os campos da tabela. + */ + function resetCamposLista() + { + $this->_campos_lista = $this->_todos_campos; + } + + /** + * Define limites de retorno para o método Lista(). + */ + function setLimite($intLimiteQtd, $intLimiteOffset = NULL) + { + $this->_limite_quantidade = $intLimiteQtd; + $this->_limite_offset = $intLimiteOffset; + } + + /** + * Retorna a string com o trecho da query responsável pelo limite de + * registros retornados/afetados. + * + * @return string + */ + function getLimite() + { + if (is_numeric($this->_limite_quantidade)) { + $retorno = " LIMIT {$this->_limite_quantidade}"; + if (is_numeric($this->_limite_offset)) { + $retorno .= " OFFSET {$this->_limite_offset} "; + } + return $retorno; + } + return ''; + } + + /** + * Define o campo para ser utilizado como ordenação no método Lista(). + */ + function setOrderby($strNomeCampo) + { + if (is_string($strNomeCampo) && $strNomeCampo ) { + $this->_campo_order_by = $strNomeCampo; + } + } + + /** + * Retorna a string com o trecho da query responsável pela Ordenação dos + * registros. + * + * @return string + */ + function getOrderby() + { + if (is_string($this->_campo_order_by)) { + return " ORDER BY {$this->_campo_order_by} "; + } + return ''; + } +} \ No newline at end of file diff --git a/ieducar/intranet/include/pmieducar/clsPmieducarFaltaAtrasoCompensado.inc.php b/ieducar/intranet/include/pmieducar/clsPmieducarFaltaAtrasoCompensado.inc.php index f0c2623..5ddc652 100644 --- a/ieducar/intranet/include/pmieducar/clsPmieducarFaltaAtrasoCompensado.inc.php +++ b/ieducar/intranet/include/pmieducar/clsPmieducarFaltaAtrasoCompensado.inc.php @@ -1,722 +1,674 @@ + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Arquivo disponível desde a versão 1.0.0 + * @version $Id$ + */ + +require_once 'include/pmieducar/geral.inc.php'; +/** + * clsPmieducarFaltaAtrasoCompensado class. + * + * @author Prefeitura Municipal de Itajaí + * @category i-Educar + * @license @@license@@ + * @package iEd_Pmieducar + * @since Classe disponível desde a versão 1.0.0 + * @version @@package_version@@ + */ class clsPmieducarFaltaAtrasoCompensado { - var $cod_compensado; - var $ref_cod_escola; - var $ref_ref_cod_instituicao; - var $ref_cod_servidor; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $data_inicio; - var $data_fim; - var $data_cadastro; - var $data_exclusao; - var $ativo; - - // propriedades padrao - - /** - * Armazena o total de resultados obtidos na ultima chamada ao metodo lista - * - * @var int - */ - var $_total; - - /** - * Nome do schema - * - * @var string - */ - var $_schema; - - /** - * Nome da tabela - * - * @var string - */ - var $_tabela; - - /** - * Lista separada por virgula, com os campos que devem ser selecionados na proxima chamado ao metodo lista - * - * @var string - */ - var $_campos_lista; - - /** - * Lista com todos os campos da tabela separados por virgula, padrao para selecao no metodo lista - * - * @var string - */ - var $_todos_campos; - - /** - * Valor que define a quantidade de registros a ser retornada pelo metodo lista - * - * @var int - */ - var $_limite_quantidade; - - /** - * Define o valor de offset no retorno dos registros no metodo lista - * - * @var int - */ - var $_limite_offset; - - /** - * Define o campo padrao para ser usado como padrao de ordenacao no metodo lista - * - * @var string - */ - var $_campo_order_by; - - - /** - * Construtor (PHP 4) - * - * @return object - */ - function clsPmieducarFaltaAtrasoCompensado( $cod_compensado = null, $ref_cod_escola = null, $ref_ref_cod_instituicao = null, $ref_cod_servidor = null, $ref_usuario_exc = null, $ref_usuario_cad = null, $data_inicio = null, $data_fim = null, $data_cadastro = null, $data_exclusao = null, $ativo = null ) - { - $db = new clsBanco(); - $this->_schema = "pmieducar."; - $this->_tabela = "{$this->_schema}falta_atraso_compensado"; - - $this->_campos_lista = $this->_todos_campos = "cod_compensado, ref_cod_escola, ref_ref_cod_instituicao, ref_cod_servidor, ref_usuario_exc, ref_usuario_cad, data_inicio, data_fim, data_cadastro, data_exclusao, ativo"; - - if( is_numeric( $ref_cod_escola ) ) - { - if( class_exists( "clsPmieducarEscola" ) ) - { - $tmp_obj = new clsPmieducarEscola( $ref_cod_escola ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { - $this->ref_cod_escola = $ref_cod_escola; - } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { - $this->ref_cod_escola = $ref_cod_escola; - } - } - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.escola WHERE cod_escola = '{$ref_cod_escola}'" ) ) - { - $this->ref_cod_escola = $ref_cod_escola; - } - } - } - if( is_numeric( $ref_cod_servidor ) && is_numeric( $ref_ref_cod_instituicao ) ) - { - if( class_exists( "clsPmieducarServidor" ) ) - { - $tmp_obj = new clsPmieducarServidor( $ref_cod_servidor, null, null, null, null, null, null, 1, $ref_ref_cod_instituicao ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { - $this->ref_cod_servidor = $ref_cod_servidor; - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; - } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { - $this->ref_cod_servidor = $ref_cod_servidor; - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; - } - } - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_cod_servidor}' AND ref_cod_instituicao = '{$ref_ref_cod_instituicao}'" ) ) - { - $this->ref_cod_servidor = $ref_cod_servidor; - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; - } - } - } - if( is_numeric( $ref_usuario_exc ) ) - { - if( class_exists( "clsPmieducarUsuario" ) ) - { - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_exc ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { - $this->ref_usuario_exc = $ref_usuario_exc; - } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { - $this->ref_usuario_exc = $ref_usuario_exc; - } - } - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'" ) ) - { - $this->ref_usuario_exc = $ref_usuario_exc; - } - } - } - if( is_numeric( $ref_usuario_cad ) ) - { - if( class_exists( "clsPmieducarUsuario" ) ) - { - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_cad ); - if( method_exists( $tmp_obj, "existe") ) - { - if( $tmp_obj->existe() ) - { - $this->ref_usuario_cad = $ref_usuario_cad; - } - } - else if( method_exists( $tmp_obj, "detalhe") ) - { - if( $tmp_obj->detalhe() ) - { - $this->ref_usuario_cad = $ref_usuario_cad; - } - } - } - else - { - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'" ) ) - { - $this->ref_usuario_cad = $ref_usuario_cad; - } - } - } - - if( is_numeric( $cod_compensado ) ) - { - $this->cod_compensado = $cod_compensado; - } - if( is_string( $data_inicio ) ) - { - $this->data_inicio = $data_inicio; - } - if( is_string( $data_fim ) ) - { - $this->data_fim = $data_fim; - } - if( is_string( $data_cadastro ) ) - { - $this->data_cadastro = $data_cadastro; - } - if( is_string( $data_exclusao ) ) - { - $this->data_exclusao = $data_exclusao; - } - if( is_numeric( $ativo ) ) - { - $this->ativo = $ativo; - } - - } - - /** - * Cria um novo registro - * - * @return bool - */ - function cadastra() - { - if( is_numeric( $this->ref_cod_escola ) && is_numeric( $this->ref_ref_cod_instituicao ) && is_numeric( $this->ref_cod_servidor ) && is_numeric( $this->ref_usuario_cad ) && is_string( $this->data_inicio ) && is_string( $this->data_fim ) ) - { - $db = new clsBanco(); - - $campos = ""; - $valores = ""; - $gruda = ""; - - if( is_numeric( $this->ref_cod_escola ) ) - { - $campos .= "{$gruda}ref_cod_escola"; - $valores .= "{$gruda}'{$this->ref_cod_escola}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_ref_cod_instituicao ) ) - { - $campos .= "{$gruda}ref_ref_cod_instituicao"; - $valores .= "{$gruda}'{$this->ref_ref_cod_instituicao}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_cod_servidor ) ) - { - $campos .= "{$gruda}ref_cod_servidor"; - $valores .= "{$gruda}'{$this->ref_cod_servidor}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_usuario_cad ) ) - { - $campos .= "{$gruda}ref_usuario_cad"; - $valores .= "{$gruda}'{$this->ref_usuario_cad}'"; - $gruda = ", "; - } - if( is_string( $this->data_inicio ) ) - { - $campos .= "{$gruda}data_inicio"; - $valores .= "{$gruda}'{$this->data_inicio}'"; - $gruda = ", "; - } - if( is_string( $this->data_fim ) ) - { - $campos .= "{$gruda}data_fim"; - $valores .= "{$gruda}'{$this->data_fim}'"; - $gruda = ", "; - } - $campos .= "{$gruda}data_cadastro"; - $valores .= "{$gruda}NOW()"; - $gruda = ", "; - $campos .= "{$gruda}ativo"; - $valores .= "{$gruda}'1'"; - $gruda = ", "; - - - $db->Consulta( "INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )" ); - return $db->InsertId( "{$this->_tabela}_cod_compensado_seq"); - } - return false; - } - - /** - * Edita os dados de um registro - * - * @return bool - */ - function edita() - { - if( is_numeric( $this->cod_compensado ) && is_numeric( $this->ref_usuario_exc ) ) - { - - $db = new clsBanco(); - $set = ""; - - if( is_numeric( $this->ref_cod_escola ) ) - { - $set .= "{$gruda}ref_cod_escola = '{$this->ref_cod_escola}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_ref_cod_instituicao ) ) - { - $set .= "{$gruda}ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_cod_servidor ) ) - { - $set .= "{$gruda}ref_cod_servidor = '{$this->ref_cod_servidor}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_usuario_exc ) ) - { - $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_usuario_cad ) ) - { - $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'"; - $gruda = ", "; - } - if( is_string( $this->data_inicio ) ) - { - $set .= "{$gruda}data_inicio = '{$this->data_inicio}'"; - $gruda = ", "; - } - if( is_string( $this->data_fim ) ) - { - $set .= "{$gruda}data_fim = '{$this->data_fim}'"; - $gruda = ", "; - } - if( is_string( $this->data_cadastro ) ) - { - $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'"; - $gruda = ", "; - } - $set .= "{$gruda}data_exclusao = NOW()"; - $gruda = ", "; - if( is_numeric( $this->ativo ) ) - { - $set .= "{$gruda}ativo = '{$this->ativo}'"; - $gruda = ", "; - } - - - if( $set ) - { - $db->Consulta( "UPDATE {$this->_tabela} SET $set WHERE cod_compensado = '{$this->cod_compensado}'" ); - return true; - } - } - return false; - } - - /** - * Retorna uma lista filtrados de acordo com os parametros - * - * @return array - */ - function lista( $int_cod_compensado = null, $int_ref_cod_escola = null, $int_ref_ref_cod_instituicao = null, $int_ref_cod_servidor = null, $int_ref_usuario_exc = null, $int_ref_usuario_cad = null, $date_data_inicio_ini = null, $date_data_inicio_fim = null, $date_data_fim_ini = null, $date_data_fim_fim = null, $date_data_cadastro_ini = null, $date_data_cadastro_fim = null, $date_data_exclusao_ini = null, $date_data_exclusao_fim = null, $int_ativo = null ) - { - $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}"; - $filtros = ""; - - $whereAnd = " WHERE "; - - if( is_numeric( $int_cod_compensado ) ) - { - $filtros .= "{$whereAnd} cod_compensado = '{$int_cod_compensado}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_cod_escola ) ) - { - $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_ref_cod_instituicao ) ) - { - $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_cod_servidor ) ) - { - $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_usuario_exc ) ) - { - $filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_usuario_cad ) ) - { - $filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_inicio_ini ) ) - { - $filtros .= "{$whereAnd} data_inicio >= '{$date_data_inicio_ini}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_inicio_fim ) ) - { - $filtros .= "{$whereAnd} data_inicio <= '{$date_data_inicio_fim}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_fim_ini ) ) - { - $filtros .= "{$whereAnd} data_fim >= '{$date_data_fim_ini}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_fim_fim ) ) - { - $filtros .= "{$whereAnd} data_fim <= '{$date_data_fim_fim}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_cadastro_ini ) ) - { - $filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_cadastro_fim ) ) - { - $filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_exclusao_ini ) ) - { - $filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_exclusao_fim ) ) - { - $filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'"; - $whereAnd = " AND "; - } - if( is_null( $int_ativo ) || $int_ativo ) - { - $filtros .= "{$whereAnd} ativo = '1'"; - $whereAnd = " AND "; - } - else - { - $filtros .= "{$whereAnd} ativo = '0'"; - $whereAnd = " AND "; - } - - - $db = new clsBanco(); - $countCampos = count( explode( ",", $this->_campos_lista ) ); - $resultado = array(); - - $sql .= $filtros . $this->getOrderby() . $this->getLimite(); - - $this->_total = $db->CampoUnico( "SELECT COUNT(0) FROM {$this->_tabela} {$filtros}" ); - - $db->Consulta( $sql ); - - if( $countCampos > 1 ) - { - while ( $db->ProximoRegistro() ) - { - $tupla = $db->Tupla(); - - $tupla["_total"] = $this->_total; - $resultado[] = $tupla; - } - } - else - { - while ( $db->ProximoRegistro() ) - { - $tupla = $db->Tupla(); - $resultado[] = $tupla[$this->_campos_lista]; - } - } - if( count( $resultado ) ) - { - return $resultado; - } - return false; - } - - /** - * Retorna um array com os dados de um registro - * - * @return array - */ - function detalhe() - { - if( is_numeric( $this->cod_compensado ) ) - { - - $db = new clsBanco(); - $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_compensado = '{$this->cod_compensado}'" ); - $db->ProximoRegistro(); - return $db->Tupla(); - } - return false; - } - - /** - * Retorna um array com os dados de um registro - * - * @return array - */ - function existe() - { - if( is_numeric( $this->cod_compensado ) ) - { - - $db = new clsBanco(); - $db->Consulta( "SELECT 1 FROM {$this->_tabela} WHERE cod_compensado = '{$this->cod_compensado}'" ); - $db->ProximoRegistro(); - return $db->Tupla(); - } - return false; - } - - /** - * Exclui um registro - * - * @return bool - */ - function excluir() - { - if( is_numeric( $this->cod_compensado ) && is_numeric( $this->ref_usuario_exc ) ) - { - - /* - delete - $db = new clsBanco(); - $db->Consulta( "DELETE FROM {$this->_tabela} WHERE cod_compensado = '{$this->cod_compensado}'" ); - return true; - */ - - $this->ativo = 0; - return $this->edita(); - } - return false; - } - - /** - * Define quais campos da tabela serao selecionados na invocacao do metodo lista - * - * @return null - */ - function setCamposLista( $str_campos ) - { - $this->_campos_lista = $str_campos; - } - - /** - * Define que o metodo Lista devera retornoar todos os campos da tabela - * - * @return null - */ - function resetCamposLista() - { - $this->_campos_lista = $this->_todos_campos; - } - - /** - * Define limites de retorno para o metodo lista - * - * @return null - */ - function setLimite( $intLimiteQtd, $intLimiteOffset = null ) - { - $this->_limite_quantidade = $intLimiteQtd; - $this->_limite_offset = $intLimiteOffset; - } - - /** - * Retorna a string com o trecho da query resposavel pelo Limite de registros - * - * @return string - */ - function getLimite() - { - if( is_numeric( $this->_limite_quantidade ) ) - { - $retorno = " LIMIT {$this->_limite_quantidade}"; - if( is_numeric( $this->_limite_offset ) ) - { - $retorno .= " OFFSET {$this->_limite_offset} "; - } - return $retorno; - } - return ""; - } - - /** - * Define campo para ser utilizado como ordenacao no metolo lista - * - * @return null - */ - function setOrderby( $strNomeCampo ) - { - // limpa a string de possiveis erros (delete, insert, etc) - //$strNomeCampo = eregi_replace(); - - if( is_string( $strNomeCampo ) && $strNomeCampo ) - { - $this->_campo_order_by = $strNomeCampo; - } - } - - /** - * Retorna a string com o trecho da query resposavel pela Ordenacao dos registros - * - * @return string - */ - function getOrderby() - { - if( is_string( $this->_campo_order_by ) ) - { - return " ORDER BY {$this->_campo_order_by} "; - } - return ""; - } - - /** - * Retorna a quantidade de horas compensadas - * - * @return array - */ - function ServidorHorasCompensadas( $int_ref_cod_servidor = null, $int_ref_cod_escola = null, $int_ref_cod_instituicao ) - { - if( is_numeric( $int_ref_cod_servidor ) ) - { - /*strtotime( '2006-06-06' ); - date( "Y-m-d", time );*/ - $db = new clsBanco(); - $db->Consulta("SELECT fac.data_inicio, - fac.data_fim - FROM pmieducar.falta_atraso_compensado fac - WHERE fac.ref_cod_servidor = '{$int_ref_cod_servidor}' - AND fac.ref_cod_escola = '{$int_ref_cod_escola}' - AND fac.ref_ref_cod_instituicao = '{$int_ref_cod_instituicao}'" ); - - while ( $db->ProximoRegistro() ) - { - $tupla = $db->Tupla(); - $resultado[] = $tupla; - } - $horas_total = 0; - $minutos_total = 0; - - if ($resultado) - { - foreach ( $resultado as $registro ) - { - $data_atual = strtotime( $registro["data_inicio"] ); - $data_fim = strtotime( $registro["data_fim"] ); - do { - $db2 = new clsBanco(); - $dia_semana = $db2->CampoUnico( "SELECT EXTRACT ( DOW FROM ( date '".date( "Y-m-d", $data_atual )."' ) + 1 )" ); - $obj_servidor = new clsPmieducarServidor(); - $horas = $obj_servidor->qtdhoras( $int_ref_cod_servidor, $int_ref_cod_escola, $int_ref_cod_instituicao, $dia_semana ); - if ( $horas ) - { - $horas_total += $horas["hora"]; - $minutos_total += $horas["min"]; - } - $data_atual += 86400; - } while ( $data_atual <= $data_fim ); - } - } - $res["hora"] = $horas_total; - $res["min"] = $minutos_total; - return $res; - } - return false; - } -} -?> \ No newline at end of file + var $cod_compensado; + var $ref_cod_escola; + var $ref_ref_cod_instituicao; + var $ref_cod_servidor; + var $ref_usuario_exc; + var $ref_usuario_cad; + var $data_inicio; + var $data_fim; + var $data_cadastro; + var $data_exclusao; + var $ativo; + + /** + * Armazena o total de resultados obtidos na última chamada ao método lista(). + * @var int + */ + var $_total; + + /** + * Nome do schema. + * @var string + */ + var $_schema; + + /** + * Nome da tabela. + * @var string + */ + var $_tabela; + + /** + * Lista separada por vírgula, com os campos que devem ser selecionados na + * próxima chamado ao método lista(). + * @var string + */ + var $_campos_lista; + + /** + * Lista com todos os campos da tabela separados por vírgula, padrão para + * seleção no método lista. + * @var string + */ + var $_todos_campos; + + /** + * Valor que define a quantidade de registros a ser retornada pelo método lista(). + * @var int + */ + var $_limite_quantidade; + + /** + * Define o valor de offset no retorno dos registros no método lista(). + * @var int + */ + var $_limite_offset; + + /** + * Define o campo para ser usado como padrão de ordenação no método lista(). + * @var string + */ + var $_campo_order_by; + + /** + * Construtor. + */ + function clsPmieducarFaltaAtrasoCompensado($cod_compensado = NULL, + $ref_cod_escola = NULL, $ref_ref_cod_instituicao = NULL, + $ref_cod_servidor = NULL, $ref_usuario_exc = NULL, $ref_usuario_cad = NULL, + $data_inicio = NULL, $data_fim = NULL, $data_cadastro = NULL, + $data_exclusao = NULL, $ativo = NULL) + { + $db = new clsBanco(); + $this->_schema = 'pmieducar.'; + $this->_tabela = $this->_schema . 'falta_atraso_compensado'; + + $this->_campos_lista = $this->_todos_campos = 'cod_compensado, ref_cod_escola, ref_ref_cod_instituicao, ref_cod_servidor, ref_usuario_exc, ref_usuario_cad, data_inicio, data_fim, data_cadastro, data_exclusao, ativo'; + + if (is_numeric($ref_cod_escola)) { + if (class_exists('clsPmieducarEscola')) { + $tmp_obj = new clsPmieducarEscola($ref_cod_escola); + if (method_exists($tmp_obj, 'existe')) { + if ($tmp_obj->existe()) { + $this->ref_cod_escola = $ref_cod_escola; + } + } + elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { + $this->ref_cod_escola = $ref_cod_escola; + } + } + } + else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.escola WHERE cod_escola = '{$ref_cod_escola}'")) { + $this->ref_cod_escola = $ref_cod_escola; + } + } + } + + if (is_numeric($ref_cod_servidor) && is_numeric($ref_ref_cod_instituicao)) { + if (class_exists('clsPmieducarServidor')) { + $tmp_obj = new clsPmieducarServidor($ref_cod_servidor, NULL, NULL, NULL, + NULL, NULL, NULL, 1, $ref_ref_cod_instituicao); + + if (method_exists($tmp_obj, 'existe')) { + if ($tmp_obj->existe()) { + $this->ref_cod_servidor = $ref_cod_servidor; + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; + } + } + elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { + $this->ref_cod_servidor = $ref_cod_servidor; + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; + } + } + } + else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_cod_servidor}' AND ref_cod_instituicao = '{$ref_ref_cod_instituicao}'")) { + $this->ref_cod_servidor = $ref_cod_servidor; + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao; + } + } + } + + if (is_numeric($ref_usuario_exc)) { + if (class_exists('clsPmieducarUsuario')) { + $tmp_obj = new clsPmieducarUsuario($ref_usuario_exc); + if (method_exists($tmp_obj, 'existe')) { + if ($tmp_obj->existe()) { + $this->ref_usuario_exc = $ref_usuario_exc; + } + } + elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { + $this->ref_usuario_exc = $ref_usuario_exc; + } + } + } + else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'")) { + $this->ref_usuario_exc = $ref_usuario_exc; + } + } + } + + if (is_numeric($ref_usuario_cad)) { + if (class_exists('clsPmieducarUsuario')) { + $tmp_obj = new clsPmieducarUsuario($ref_usuario_cad); + if (method_exists($tmp_obj, 'existe')) { + if ($tmp_obj->existe()) { + $this->ref_usuario_cad = $ref_usuario_cad; + } + } + elseif (method_exists($tmp_obj, 'detalhe')) { + if ($tmp_obj->detalhe()) { + $this->ref_usuario_cad = $ref_usuario_cad; + } + } + } + else { + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'")) { + $this->ref_usuario_cad = $ref_usuario_cad; + } + } + } + + if (is_numeric($cod_compensado)) { + $this->cod_compensado = $cod_compensado; + } + + if (is_string($data_inicio)) { + $this->data_inicio = $data_inicio; + } + + if (is_string($data_fim)) { + $this->data_fim = $data_fim; + } + + if (is_string($data_cadastro)) { + $this->data_cadastro = $data_cadastro; + } + + if (is_string($data_exclusao)) { + $this->data_exclusao = $data_exclusao; + } + + if (is_numeric($ativo)) { + $this->ativo = $ativo; + } + } + + /** + * Cria um novo registro. + * @return bool + */ + function cadastra() + { + if (is_numeric($this->ref_cod_escola) && is_numeric($this->ref_ref_cod_instituicao) && + is_numeric($this->ref_cod_servidor) && is_numeric($this->ref_usuario_cad) && + is_string($this->data_inicio) && is_string($this->data_fim) + ) { + $db = new clsBanco(); + + $campos = ''; + $valores = ''; + $gruda = ''; + + if (is_numeric($this->ref_cod_escola)) { + $campos .= "{$gruda}ref_cod_escola"; + $valores .= "{$gruda}'{$this->ref_cod_escola}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_ref_cod_instituicao)) { + $campos .= "{$gruda}ref_ref_cod_instituicao"; + $valores .= "{$gruda}'{$this->ref_ref_cod_instituicao}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_cod_servidor)) { + $campos .= "{$gruda}ref_cod_servidor"; + $valores .= "{$gruda}'{$this->ref_cod_servidor}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_usuario_cad)) { + $campos .= "{$gruda}ref_usuario_cad"; + $valores .= "{$gruda}'{$this->ref_usuario_cad}'"; + $gruda = ', '; + } + + if (is_string($this->data_inicio)) { + $campos .= "{$gruda}data_inicio"; + $valores .= "{$gruda}'{$this->data_inicio}'"; + $gruda = ', '; + } + + if (is_string($this->data_fim)) { + $campos .= "{$gruda}data_fim"; + $valores .= "{$gruda}'{$this->data_fim}'"; + $gruda = ', '; + } + + $campos .= "{$gruda}data_cadastro"; + $valores .= "{$gruda}NOW()"; + $gruda = ', '; + + $campos .= "{$gruda}ativo"; + $valores .= "{$gruda}'1'"; + $gruda = ', '; + + $db->Consulta("INSERT INTO {$this->_tabela} ($campos) VALUES ($valores)"); + return $db->InsertId("{$this->_tabela}_cod_compensado_seq"); + } + + return FALSE; + } + + /** + * Edita os dados de um registro + * + * @return bool + */ + function edita() + { + if (is_numeric($this->cod_compensado) && is_numeric($this->ref_usuario_exc)) { + $db = new clsBanco(); + $set = ''; + + if (is_numeric($this->ref_cod_escola)) { + $set .= "{$gruda}ref_cod_escola = '{$this->ref_cod_escola}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_ref_cod_instituicao)) { + $set .= "{$gruda}ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_cod_servidor)) { + $set .= "{$gruda}ref_cod_servidor = '{$this->ref_cod_servidor}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_usuario_exc)) { + $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_usuario_cad)) { + $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'"; + $gruda = ', '; + } + + if (is_string($this->data_inicio)) { + $set .= "{$gruda}data_inicio = '{$this->data_inicio}'"; + $gruda = ', '; + } + + if (is_string($this->data_fim)) { + $set .= "{$gruda}data_fim = '{$this->data_fim}'"; + $gruda = ', '; + } + + if (is_string($this->data_cadastro)) { + $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'"; + $gruda = ', '; + } + + $set .= "{$gruda}data_exclusao = NOW()"; + $gruda = ', '; + + if (is_numeric($this->ativo)) { + $set .= "{$gruda}ativo = '{$this->ativo}'"; + $gruda = ', '; + } + + if ($set) { + $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE cod_compensado = '{$this->cod_compensado}'"); + return TRUE; + } + } + + return FALSE; + } + + /** + * Retorna uma lista de registros filtrados de acordo com os parâmetros + * @return array + */ + function lista($int_cod_compensado = NULL, $int_ref_cod_escola = NULL, + $int_ref_ref_cod_instituicao = NULL, $int_ref_cod_servidor = NULL, + $int_ref_usuario_exc = NULL, $int_ref_usuario_cad = NULL, + $date_data_inicio_ini = NULL, $date_data_inicio_fim = NULL, + $date_data_fim_ini = NULL, $date_data_fim_fim = NULL, + $date_data_cadastro_ini = NULL, $date_data_cadastro_fim = NULL, + $date_data_exclusao_ini = NULL, $date_data_exclusao_fim = NULL, + $int_ativo = NULL + ) { + $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}"; + $filtros = ''; + + $whereAnd = ' WHERE '; + + if (is_numeric($int_cod_compensado)) { + $filtros .= "{$whereAnd} cod_compensado = '{$int_cod_compensado}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_cod_escola)) { + $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_ref_cod_instituicao)) { + $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_cod_servidor)) { + $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_usuario_exc)) { + $filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_usuario_cad)) { + $filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_inicio_ini)) { + $filtros .= "{$whereAnd} data_inicio >= '{$date_data_inicio_ini}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_inicio_fim)) { + $filtros .= "{$whereAnd} data_inicio <= '{$date_data_inicio_fim}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_fim_ini)) { + $filtros .= "{$whereAnd} data_fim >= '{$date_data_fim_ini}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_fim_fim)) { + $filtros .= "{$whereAnd} data_fim <= '{$date_data_fim_fim}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_cadastro_ini)) { + $filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_cadastro_fim)) { + $filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_exclusao_ini)) { + $filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_exclusao_fim)) { + $filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'"; + $whereAnd = ' AND '; + } + + if (is_NULL($int_ativo) || $int_ativo) { + $filtros .= "{$whereAnd} ativo = '1'"; + $whereAnd = ' AND '; + } + else { + $filtros .= "{$whereAnd} ativo = '0'"; + $whereAnd = ' AND '; + } + + $db = new clsBanco(); + $countCampos = count(explode(',', $this->_campos_lista)); + $resultado = array(); + + $sql .= $filtros . $this->getOrderby() . $this->getLimite(); + + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} {$filtros}"); + + $db->Consulta($sql); + + if ($countCampos > 1) { + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + + $tupla['_total'] = $this->_total; + $resultado[] = $tupla; + } + } + else { + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + $resultado[] = $tupla[$this->_campos_lista]; + } + } + + if (count($resultado)) { + return $resultado; + } + + return FALSE; + } + + /** + * Retorna um array com os dados de um registro. + * @return array + */ + function detalhe() + { + if (is_numeric($this->cod_compensado)) { + $db = new clsBanco(); + $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_compensado = '{$this->cod_compensado}'"); + $db->ProximoRegistro(); + return $db->Tupla(); + } + + return FALSE; + } + + /** + * Retorna um array com os dados de um registro. + * @return array + */ + function existe() + { + if (is_numeric($this->cod_compensado)) { + $db = new clsBanco(); + $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE cod_compensado = '{$this->cod_compensado}'"); + $db->ProximoRegistro(); + return $db->Tupla(); + } + + return FALSE; + } + + /** + * Exclui um registro. + * @return bool + */ + function excluir() + { + if (is_numeric($this->cod_compensado) && is_numeric($this->ref_usuario_exc)) { + $this->ativo = 0; + return $this->edita(); + } + + return FALSE; + } + + /** + * Retorna a quantidade de horas compensadas. + * @return array + */ + function ServidorHorasCompensadas($int_ref_cod_servidor = NULL, + $int_ref_cod_escola = NULL, $int_ref_cod_instituicao) + { + if (is_numeric($int_ref_cod_servidor)) { + /*strtotime( '2006-06-06' ); + date( "Y-m-d", time );*/ + $db = new clsBanco(); + $db->Consulta(" + SELECT + fac.data_inicio, + fac.data_fim + FROM + pmieducar.falta_atraso_compensado fac + WHERE + fac.ref_cod_servidor = '{$int_ref_cod_servidor}' + AND fac.ref_cod_escola = '{$int_ref_cod_escola}' + AND fac.ref_ref_cod_instituicao = '{$int_ref_cod_instituicao}'"); + + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + $resultado[] = $tupla; + } + + $horas_total = 0; + $minutos_total = 0; + + if ($resultado) { + foreach ( $resultado as $registro ) { + $data_atual = strtotime($registro['data_inicio']); + $data_fim = strtotime($registro['data_fim']); + + do { + $db2 = new clsBanco(); + + $dia_semana = $db2->CampoUnico("SELECT EXTRACT(DOW FROM (date '".date('Y-m-d', $data_atual)."') + 1)"); + $obj_servidor = new clsPmieducarServidor(); + $horas = $obj_servidor->qtdhoras($int_ref_cod_servidor, + $int_ref_cod_escola, $int_ref_cod_instituicao, $dia_semana); + + if ($horas) { + $horas_total += $horas['hora']; + $minutos_total += $horas['min']; + } + + $data_atual += 86400; + } while ($data_atual <= $data_fim); + } + } + + $res['hora'] = $horas_total; + $res['min'] = $minutos_total; + + return $res; + } + + return FALSE; + } + +/** + * Define quais campos da tabela serão selecionados no método Lista(). + */ + function setCamposLista($str_campos) + { + $this->_campos_lista = $str_campos; + } + + /** + * Define que o método Lista() deverpa retornar todos os campos da tabela. + */ + function resetCamposLista() + { + $this->_campos_lista = $this->_todos_campos; + } + + /** + * Define limites de retorno para o método Lista(). + */ + function setLimite($intLimiteQtd, $intLimiteOffset = NULL) + { + $this->_limite_quantidade = $intLimiteQtd; + $this->_limite_offset = $intLimiteOffset; + } + + /** + * Retorna a string com o trecho da query responsável pelo limite de + * registros retornados/afetados. + * + * @return string + */ + function getLimite() + { + if (is_numeric($this->_limite_quantidade)) { + $retorno = " LIMIT {$this->_limite_quantidade}"; + if (is_numeric($this->_limite_offset)) { + $retorno .= " OFFSET {$this->_limite_offset} "; + } + return $retorno; + } + return ''; + } + + /** + * Define o campo para ser utilizado como ordenação no método Lista(). + */ + function setOrderby($strNomeCampo) + { + if (is_string($strNomeCampo) && $strNomeCampo ) { + $this->_campo_order_by = $strNomeCampo; + } + } + + /** + * Retorna a string com o trecho da query responsável pela Ordenação dos + * registros. + * + * @return string + */ + function getOrderby() + { + if (is_string($this->_campo_order_by)) { + return " ORDER BY {$this->_campo_order_by} "; + } + return ''; + } +} \ No newline at end of file -- libgit2 0.21.2