From 1d5a441b7f63f53d507edf764e54acfc7d337abd Mon Sep 17 00:00:00 2001 From: Eriksen Costa Paixão Date: Tue, 9 Mar 2010 16:33:47 +0000 Subject: [PATCH] Refactoring para coding standards --- ieducar/intranet/educar_servidor_alocacao_cad.php | 933 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ieducar/intranet/include/pmieducar/clsPmieducarServidorAlocacao.inc.php | 1400 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 files changed, 1124 insertions(+), 1209 deletions(-) diff --git a/ieducar/intranet/educar_servidor_alocacao_cad.php b/ieducar/intranet/educar_servidor_alocacao_cad.php index a5a21e7..9c83569 100644 --- a/ieducar/intranet/educar_servidor_alocacao_cad.php +++ b/ieducar/intranet/educar_servidor_alocacao_cad.php @@ -1,487 +1,488 @@ + * + * 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 + * @author Haissam Yebahi + * @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 + * @author Haissam Yebahi + * @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 - Servidor Alocação" ); - $this->processoAp = "635"; - } + function Formular() + { + $this->SetTitulo($this->_instituicao . ' i-Educar - Servidor Alocação'); + $this->processoAp = 635; + } } +/** + * indice class. + * + * @author Adriano Erik Weiguert Nagasava + * @author Haissam Yebahi + * @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_servidor_alocacao; - var $ref_ref_cod_instituicao; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $ref_cod_escola; - var $ref_cod_servidor; - var $data_cadastro; - var $data_exclusao; - var $ativo; - var $carga_horaria_alocada; - var $carga_horaria_disponivel; - var $periodo; - - var $alocacao_array = array(); - var $alocacao_excluida_array = array(); - - function Inicializar() - { - $retorno = "Novo"; - @session_start(); - $this->pessoa_logada = $_SESSION['id_pessoa']; - @session_write_close(); - - $this->ref_cod_servidor = $_GET["ref_cod_servidor"]; - $this->ref_ref_cod_instituicao = $_GET["ref_cod_instituicao"]; - - $obj_permissoes = new clsPermissoes(); - $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 3, "educar_servidor_alocacao_lst.php" ); - - if ( is_numeric( $this->ref_cod_servidor ) && is_numeric( $this->ref_ref_cod_instituicao ) ) - { - - $obj = new clsPmieducarServidorAlocacao( ); - $lista = $obj->lista( null, $this->ref_ref_cod_instituicao, null, null, null, $this->ref_cod_servidor, null, null, null, null, 1, null, null ); - - if ( $lista ) - { - foreach ( $lista AS $campo => $val ) - { - $temp = array(); - $temp['carga_horaria_alocada'] = $val['carga_horaria']; - $temp['periodo'] = $val['periodo']; - $temp['ref_cod_escola'] = $val['ref_cod_escola']; - $temp['novo'] = 0; - - $this->alocacao_array[] = $temp; - } - $retorno = "Novo"; - } - - $obj_servidor = new clsPmieducarServidor( $this->ref_cod_servidor, null, null, null, null, null, 1, $this->ref_ref_cod_instituicao ); - $det_servidor = $obj_servidor->detalhe(); - $this->carga_horaria_disponivel = $det_servidor['carga_horaria']; - } - else - { - header( "location: educar_servidor_lst.php" ); - die; - } - - $this->url_cancelar = "educar_servidor_det.php?cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_ref_cod_instituicao}"; - $this->nome_url_cancelar = "Cancelar"; - return $retorno; - } - - function Gerar() - { - if ( $_POST ) - { - foreach ( $_POST AS $campo => $val ) - { - if ( is_string( $val ) ) - { - $val = urldecode( $val ); - } - $this->$campo = ( $this->$campo ) ? $this->$campo : $val; - } - } - - $obj_inst = new clsPmieducarInstituicao( $this->ref_ref_cod_instituicao ); - $inst_det = $obj_inst->detalhe(); - - $this->campoRotulo( "nm_instituicao", "Instituição", $inst_det['nm_instituicao'] ); - $this->campoOculto( "ref_ref_cod_instituicao", $this->ref_ref_cod_instituicao ); - - if ( class_exists( "clsPmieducarServidor" ) ) - { - $objTemp = new clsPmieducarServidor( $this->ref_cod_servidor ); - $det = $objTemp->detalhe(); - if ( $det ) - { - foreach ( $det as $key => $registro ) - { - $this->$key = $registro; - } - } - - if ( $this->ref_cod_servidor ) - { - $objTemp = new clsFuncionario( $this->ref_cod_servidor ); - $detalhe = $objTemp->detalhe(); - $detalhe = $detalhe["idpes"]->detalhe(); - $nm_servidor = $detalhe["nome"]; - } - } - else - { - echo ""; - $opcoes = array( "" => "Erro na geracao" ); - } - - $this->campoRotulo( "nm_servidor", "Servidor", $nm_servidor ); - - $this->campoOculto( "ref_cod_servidor", $this->ref_cod_servidor ); - - if ( $_POST["alocacao_array"] ) - { - $this->alocacao_array = unserialize( urldecode( $_POST["alocacao_array"] ) ); - } - - if ( $_POST["alocacao_excluida_array"] ) - { - $this->alocacao_excluida_array = unserialize( urldecode( $_POST["alocacao_excluida_array"] ) ); - } - - if ( $_POST["carga_horaria_alocada"] && $_POST["periodo"] ) - { - $aux = array(); - $aux["carga_horaria_alocada"] = $_POST["carga_horaria_alocada"]; - $aux["periodo"] = $_POST["periodo"]; - $aux["ref_cod_escola"] = $_POST["ref_cod_escola"]; - $aux['novo'] = 1; - /*$achou = false; - - foreach ( $this->alocacao_array as $alocacao ) - { - if ( $alocacao['periodo'] == $aux["periodo"] ) - { - $achou = true; - echo ""; - } - } - - if ( !$achou ) - { - $this->alocacao_array[] = $aux; - } - */ - $this->alocacao_array[] = $aux; - - unset( $this->periodo ); - unset( $this->carga_horaria_alocada ); - unset( $this->ref_cod_escola ); - } - - /** - * Exclusão - */ - if ( $this->alocacao_array ) - { - foreach ( $this->alocacao_array as $key => $alocacao ) - { - if ( is_numeric( $_POST['excluir_periodo'] ) ) - { - if ( $_POST['excluir_periodo'] == $key ) - { - $this->alocacao_excluida_array[] = $alocacao; - unset( $this->alocacao_array[$key] ); - unset( $this->excluir_periodo ); - } - } - } - } - - /** - * Carga Horaria - */ - $total_horas = sprintf( "%02d", ( int ) ( floor( $this->carga_horaria_disponivel ) ) ); - $total_horas = sprintf( "%02d", ( int ) ( floor( $this->carga_horaria_disponivel ) ) ); - $total_minutos = sprintf( "%02d", ( int ) ( ( floatval( $this->carga_horaria_disponivel ) - floatval( $total_horas ) ) * 60 ) ); - - $horas_utilizadas = 0; - $minutos_utilizados = 0; - - if ( $this->alocacao_array ) - { - foreach ( $this->alocacao_array as $alocacao ) - { - $carga_horaria_ = explode( ":", $alocacao['carga_horaria_alocada'] ); - - $horas_utilizadas += ( $carga_horaria_[0] ); - $minutos_utilizados += ( $carga_horaria_[1] ); - } - } - - $horas = sprintf( "%02d", ( int ) $horas_utilizadas ); - $minutos = sprintf( "%02d", ( int ) $minutos_utilizados ); - $str_horas_utilizadas = "{$horas}:{$minutos}"; - - $this->campoRotulo( "carga_horaria_disponivel", "Carga Horária", "{$total_horas}:{$total_minutos}" ); - $this->campoRotulo( "horas_utilizadas", "Horas Utilizadas", $str_horas_utilizadas ); - - $horas = sprintf( "%02d", ( int ) $total_horas - $horas_utilizadas ); - $minutos = sprintf( "%02d", ( int ) $total_minutos - $minutos_utilizados ); - $str_horas_restantes = "{$horas}:{$minutos}"; - - $this->campoRotulo( "horas_restantes", "Horas Restantes", $str_horas_restantes ); - $this->campoOculto( "horas_restantes_", $str_horas_restantes ); - - $this->campoQuebra(); - - $this->campoOculto( "excluir_periodo", "" ); - unset( $aux ); - -// array_multisort( $this->alocacao_array ); - - if ( class_exists( "clsPmieducarEscola" ) ) - { - $obj_escola = new clsPmieducarEscola(); - $lista_escola = $obj_escola->lista( null, null, null, $this->ref_ref_cod_instituicao, null, null, null, null, null, null, 1 ); - - if ( $lista_escola ) - { - $opcoes = array( '' => "Selecione" ); - foreach ( $lista_escola as $escola ) - { - $opcoes[$escola['cod_escola']] = $escola['nome']; - } - } - } - else - { - $registro["ref_cod_escola"] = "Erro na geracao"; - echo ""; - } - - $this->campoLista( "ref_cod_escola", "Escola", $opcoes, $this->ref_cod_escola, "", false, "", "", false, false ); - $this->campoLista( "periodo", "Período", array( "" => "Selecione", "1" => "Matutino", "2" => "Vespertino", "3" => "Noturno" ), $this->periodo, null, false, "", "", false, false ); - $this->campoHora( "carga_horaria_alocada", "Carga Horária", $this->carga_horaria_alocada, false ); - $this->campoOculto( "alocacao_array", serialize( $this->alocacao_array ) ); - $this->campoOculto( "alocacao_excluida_array", serialize( $this->alocacao_excluida_array ) ); - $this->campoRotulo( "bt_incluir_periodo", "Período", "__nome}.submit();}\">" ); - - if ( $this->alocacao_array ) - { - $excluir_ok = false; - - if ( $_POST['excluir_periodo'] || $_POST['excluir_periodo'] == "0" ) - { - $excluir_ok = true; - } - - foreach ( $this->alocacao_array as $key => $alocacao ) - { - $obj_permissoes = new clsPermissoes(); - $link_excluir = ""; - - if ( $obj_permissoes->permissao_excluir( 635, $this->pessoa_logada, 3 ) ) - { - $link_excluir = "__nome}.submit();\">"; - } - - $obj_escola = new clsPmieducarEscola( $alocacao['ref_cod_escola'] ); - $det_escola = $obj_escola->detalhe(); - $det_escola = $det_escola["nome"]; - - switch( $alocacao["periodo"] ) - { - case 1: - $nm_periodo = "Matutino"; - break; - case 2: - $nm_periodo = "Vespertino"; - break; - case 3: - $nm_periodo = "Noturno"; - break; - } - - $this->campoTextoInv( "periodo_{$key}", "", $nm_periodo, 10, 10, false, false, true, "", "", "", "", "periodo" ); - $this->campoTextoInv( "carga_horaria_alocada_{$key}", "", $alocacao['carga_horaria_alocada'], 5, 5, false, false, true, "", "", "", "", "ds_carga_horaria_" ); - $this->campoTextoInv( "ref_cod_escola_{$key}", "", $det_escola, 30, 255, false, false, false, "", "{$link_excluir}", "", "", "ref_cod_escola_" ); - } - } - $this->campoOculto( "incluir_periodo", "" ); - $this->campoQuebra(); - } - - 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, 3, "educar_servidor_alocacao_lst.php" ); - - if ( $_POST["alocacao_array"] ) - { - $this->alocacao_array = unserialize( urldecode( $_POST["alocacao_array"] ) ); - } - - if ( $_POST["alocacao_excluida_array"] ) - { - $this->alocacao_excluida_array = unserialize( urldecode( $_POST["alocacao_excluida_array"] ) ); - } - - if ( $this->alocacao_excluida_array ) - { - foreach ( $this->alocacao_excluida_array as $excluida ) - { - $obj = new clsPmieducarServidorAlocacao( null, $this->ref_ref_cod_instituicao, $this->pessoa_logada, $this->pessoa_logada, $excluida['ref_cod_escola'], $this->ref_cod_servidor, null, null, $this->ativo, $excluida['carga_horaria_alocada'], $excluida['periodo'] ); - $cadastrou = $obj->excluir_horario(); - } - } - - if ( $_POST["carga_horaria_alocada"] && $_POST["periodo"] ) - { - - $aux = array(); - $aux["periodo"] = $_POST["periodo"]; - $aux["carga_horaria_alocada"] = $_POST["carga_horaria_alocada"]; - $aux["ref_cod_escola"] = $_POST["ref_cod_escola"]; - $aux["novo"] = 1; - $achou = false; - - foreach ( $this->alocacao_array as $alocacao ) - { - if ( $alocacao['periodo'] == $aux["periodo"] ) - { - $achou = true; - } - } - if ( !$achou ) - { - $this->alocacao_array[] = $aux; - } - unset( $this->periodo ); - unset( $this->carga_horaria_alocada ); - } - - if ( $this->alocacao_array ) - { - foreach ( $this->alocacao_array as $alocacao ) - { - if ( $alocacao['novo'] ) - { - $obj = new clsPmieducarServidorAlocacao( null, $this->ref_ref_cod_instituicao, null, $this->pessoa_logada, $alocacao['ref_cod_escola'], $this->ref_cod_servidor, null, null, $this->ativo, $alocacao['carga_horaria_alocada'], $alocacao['periodo'] ); - $cadastrou = $obj->cadastra(); - - if ( !$cadastrou ) - { - $this->mensagem = "Cadastro não realizado.
"; - echo ""; - return false; - } - } - } - } - - $this->mensagem .= "Cadastro efetuado com sucesso.
"; - header( "Location: educar_servidor_det.php?cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_ref_cod_instituicao} "); - die(); - return true; - } - - function Editar() - { - return false; - } - - function Excluir() - { - return false; - - } + var $pessoa_logada; + var $cod_servidor_alocacao; + var $ref_ref_cod_instituicao; + var $ref_usuario_exc; + var $ref_usuario_cad; + var $ref_cod_escola; + var $ref_cod_servidor; + var $data_cadastro; + var $data_exclusao; + var $ativo; + var $carga_horaria_alocada; + var $carga_horaria_disponivel; + var $periodo; + + var $alocacao_array = array(); + var $alocacao_excluida_array = array(); + + function Inicializar() + { + $retorno = 'Novo'; + @session_start(); + $this->pessoa_logada = $_SESSION['id_pessoa']; + @session_write_close(); + + $this->ref_cod_servidor = $_GET['ref_cod_servidor']; + $this->ref_ref_cod_instituicao = $_GET['ref_cod_instituicao']; + + $obj_permissoes = new clsPermissoes(); + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 3, + 'educar_servidor_alocacao_lst.php'); + + if (is_numeric($this->ref_cod_servidor) && is_numeric($this->ref_ref_cod_instituicao)) { + $obj = new clsPmieducarServidorAlocacao(); + $lista = $obj->lista(NULL, $this->ref_ref_cod_instituicao, NULL, NULL, + NULL, $this->ref_cod_servidor, NULL, NULL, NULL, NULL, 1, NULL, NULL); + + if ($lista) { + foreach ($lista as $campo => $val) { + $temp = array(); + $temp['carga_horaria_alocada'] = $val['carga_horaria']; + $temp['periodo'] = $val['periodo']; + $temp['ref_cod_escola'] = $val['ref_cod_escola']; + $temp['novo'] = 0; + + $this->alocacao_array[] = $temp; + } + + $retorno = 'Novo'; + } + + $obj_servidor = new clsPmieducarServidor($this->ref_cod_servidor, NULL, + NULL, NULL, NULL, NULL, 1, $this->ref_ref_cod_instituicao); + $det_servidor = $obj_servidor->detalhe(); + + $this->carga_horaria_disponivel = $det_servidor['carga_horaria']; + } + else { + header('Location: educar_servidor_lst.php'); + die(); + } + + $this->url_cancelar = sprintf( + 'educar_servidor_det.php?cod_servidor=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_ref_cod_instituicao + ); + $this->nome_url_cancelar = 'Cancelar'; + return $retorno; + } + + function Gerar() + { + if ($_POST) { + foreach ($_POST as $campo => $val) { + if (is_string($val)) { + $val = urldecode($val); + } + + $this->$campo = ($this->$campo) ? $this->$campo : $val; + } + } + + $obj_inst = new clsPmieducarInstituicao($this->ref_ref_cod_instituicao); + $inst_det = $obj_inst->detalhe(); + + $this->campoRotulo('nm_instituicao', 'Instituição', $inst_det['nm_instituicao']); + $this->campoOculto('ref_ref_cod_instituicao', $this->ref_ref_cod_instituicao); + + if (class_exists('clsPmieducarServidor')) { + $objTemp = new clsPmieducarServidor($this->ref_cod_servidor); + $det = $objTemp->detalhe(); + + if ($det) { + foreach ($det as $key => $registro) { + $this->$key = $registro; + } + } + + if ($this->ref_cod_servidor) { + $objTemp = new clsFuncionario($this->ref_cod_servidor); + $detalhe = $objTemp->detalhe(); + $detalhe = $detalhe['idpes']->detalhe(); + $nm_servidor = $detalhe['nome']; + } + } + else { + echo ''; + $opcoes = array('' => 'Erro na geração'); + } + + $this->campoRotulo('nm_servidor', 'Servidor', $nm_servidor); + + $this->campoOculto('ref_cod_servidor', $this->ref_cod_servidor); + + if ($_POST['alocacao_array']) { + $this->alocacao_array = unserialize(urldecode($_POST['alocacao_array'])); + } + + if ($_POST['alocacao_excluida_array']) { + $this->alocacao_excluida_array = unserialize(urldecode($_POST['alocacao_excluida_array'])); + } + + if ($_POST['carga_horaria_alocada'] && $_POST['periodo']) { + $aux = array(); + $aux['carga_horaria_alocada'] = $_POST['carga_horaria_alocada']; + $aux['periodo'] = $_POST['periodo']; + $aux['ref_cod_escola'] = $_POST['ref_cod_escola']; + $aux['novo'] = 1; + + $this->alocacao_array[] = $aux; + + unset($this->periodo); + unset($this->carga_horaria_alocada); + unset($this->ref_cod_escola); + } + + /** + * Exclusão + */ + if ($this->alocacao_array) { + foreach ($this->alocacao_array as $key => $alocacao) { + if (is_numeric($_POST['excluir_periodo'])) { + if ($_POST['excluir_periodo'] == $key) { + $this->alocacao_excluida_array[] = $alocacao; + unset($this->alocacao_array[$key]); + unset($this->excluir_periodo); + } + } + } + } + + /** + * Carga Horária + */ + $total_horas = sprintf('%02d', (int) (floor($this->carga_horaria_disponivel))); + $total_horas = sprintf('%02d', (int) (floor($this->carga_horaria_disponivel))); + $total_minutos = sprintf('%02d', (int) ((floatval($this->carga_horaria_disponivel) - floatval($total_horas)) * 60)); + + $horas_utilizadas = 0; + $minutos_utilizados = 0; + + if ($this->alocacao_array) { + foreach ($this->alocacao_array as $alocacao) { + $carga_horaria_ = explode(':', $alocacao['carga_horaria_alocada']); + + $horas_utilizadas += ($carga_horaria_[0]); + $minutos_utilizados += ($carga_horaria_[1]); + } + } + + $horas = sprintf('%02d', (int) $horas_utilizadas); + $minutos = sprintf('%02d', (int) $minutos_utilizados); + $str_horas_utilizadas = sprintf('%s:%s', $horas, $minutos); + + $this->campoRotulo('carga_horaria_disponivel', 'Carga Horária', + sprintf('%s:%s', $total_horas, $total_minutos)); + + $this->campoRotulo('horas_utilizadas', 'Horas Utilizadas', $str_horas_utilizadas); + + $horas = sprintf('%02d', (int) $total_horas - $horas_utilizadas); + $minutos = sprintf('%02d', (int) $total_minutos - $minutos_utilizados); + $str_horas_restantes = sprintf('%s:%s', $horas, $minutos); + + $this->campoRotulo('horas_restantes', 'Horas Restantes', $str_horas_restantes); + $this->campoOculto('horas_restantes_', $str_horas_restantes); + + $this->campoQuebra(); + + $this->campoOculto('excluir_periodo', ''); + unset($aux); + + if (class_exists('clsPmieducarEscola')) { + $obj_escola = new clsPmieducarEscola(); + $lista_escola = $obj_escola->lista(null, null, null, + $this->ref_ref_cod_instituicao, null, null, null, null, null, null, 1); + + if ($lista_escola) { + $opcoes = array('' => 'Selecione'); + foreach ($lista_escola as $escola) { + $opcoes[$escola['cod_escola']] = $escola['nome']; + } + } + } + else { + $registro['ref_cod_escola'] = 'Erro na geração'; + echo ""; + } + + $periodo = array( + '' => 'Selecione', + 1 => 'Matutino', + 2 => 'Vespertino', + 3 => 'Noturno' + ); + + $this->campoLista('ref_cod_escola', 'Escola', $opcoes, $this->ref_cod_escola, + '', FALSE, '', '', FALSE, FALSE); + + $this->campoLista('periodo', 'Período', $periodo, $this->periodo, NULL, FALSE, + '', '', FALSE, FALSE); + + $this->campoHora('carga_horaria_alocada', 'Carga Horária', + $this->carga_horaria_alocada, FALSE); + + $this->campoOculto('alocacao_array', serialize($this->alocacao_array)); + + $this->campoOculto('alocacao_excluida_array', serialize($this->alocacao_excluida_array)); + + $this->campoRotulo('bt_incluir_periodo', 'Período', "__nome}.submit();}\">"); + + if ($this->alocacao_array) { + $excluir_ok = FALSE; + + if ($_POST['excluir_periodo'] || $_POST['excluir_periodo'] == '0') { + $excluir_ok = TRUE; + } + + foreach ($this->alocacao_array as $key => $alocacao) { + $obj_permissoes = new clsPermissoes(); + $link_excluir = ''; + + if ($obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 3)) { + $link_excluir = "__nome}.submit();\">"; + } + + $obj_escola = new clsPmieducarEscola( $alocacao['ref_cod_escola'] ); + $det_escola = $obj_escola->detalhe(); + $det_escola = $det_escola['nome']; + + // @todo CoreExt_Enum + switch ($alocacao['periodo']) { + case 1: + $nm_periodo = 'Matutino'; + break; + case 2: + $nm_periodo = 'Vespertino'; + break; + case 3: + $nm_periodo = 'Noturno'; + break; + } + + $this->campoTextoInv('periodo_' . $key, '', $nm_periodo, 10, 10, FALSE, + FALSE, TRUE, '', '', '', '', 'periodo'); + + $this->campoTextoInv('carga_horaria_alocada_' . $key, '', + $alocacao['carga_horaria_alocada'], 5, 5, FALSE, FALSE, TRUE, '', '', + '', '', 'ds_carga_horaria_'); + + $this->campoTextoInv('ref_cod_escola_' . $key, '', $det_escola, 30, 255, + FALSE, FALSE, FALSE, '', $link_excluir, '', '', 'ref_cod_escola_'); + } + } + + $this->campoOculto('incluir_periodo', ''); + $this->campoQuebra(); + } + + 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, 3, + 'educar_servidor_alocacao_lst.php'); + + if ($_POST['alocacao_array']) { + $this->alocacao_array = unserialize(urldecode($_POST['alocacao_array'])); + } + + if ($_POST['alocacao_excluida_array']) { + $this->alocacao_excluida_array = unserialize(urldecode($_POST['alocacao_excluida_array'])); + } + + if ($this->alocacao_excluida_array) { + foreach ($this->alocacao_excluida_array as $excluida) { + $obj = new clsPmieducarServidorAlocacao(NULL, $this->ref_ref_cod_instituicao, + $this->pessoa_logada, $this->pessoa_logada, $excluida['ref_cod_escola'], + $this->ref_cod_servidor, NULL, NULL, $this->ativo, + $excluida['carga_horaria_alocada'], $excluida['periodo']); + + $cadastrou = $obj->excluir_horario(); + } + } + + if ($_POST['carga_horaria_alocada'] && $_POST['periodo']) { + $aux = array(); + $aux['periodo'] = $_POST['periodo']; + $aux['carga_horaria_alocada'] = $_POST['carga_horaria_alocada']; + $aux['ref_cod_escola'] = $_POST['ref_cod_escola']; + $aux['novo'] = 1; + $achou = FALSE; + + foreach ($this->alocacao_array as $alocacao) { + if ($alocacao['periodo'] == $aux["periodo"]) { + $achou = TRUE; + } + } + + if (!$achou) { + $this->alocacao_array[] = $aux; + } + + unset($this->periodo); + unset($this->carga_horaria_alocada); + } + + if ($this->alocacao_array) { + foreach ($this->alocacao_array as $alocacao) { + if ($alocacao['novo']) { + $obj = new clsPmieducarServidorAlocacao(NULL, $this->ref_ref_cod_instituicao, + NULL, $this->pessoa_logada, $alocacao['ref_cod_escola'], + $this->ref_cod_servidor, NULL, NULL, $this->ativo, + $alocacao['carga_horaria_alocada'], $alocacao['periodo']); + + $cadastrou = $obj->cadastra(); + + if (!$cadastrou) { + $this->mensagem = 'Cadastro não realizado.
'; + echo ""; + return FALSE; + } + } + } + } + + $this->mensagem .= 'Cadastro efetuado com sucesso.
'; + header('Location: ' . sprintf('educar_servidor_det.php?cod_servidor=%d&ref_cod_instituicao=%d', + $this->ref_cod_servidor, $this->ref_ref_cod_instituicao)); + die(); + } + + function Editar() + { + return FALSE; + } + + function Excluir() + { + 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/include/pmieducar/clsPmieducarServidorAlocacao.inc.php b/ieducar/intranet/include/pmieducar/clsPmieducarServidorAlocacao.inc.php index b9abfc2..eeb30db 100644 --- a/ieducar/intranet/include/pmieducar/clsPmieducarServidorAlocacao.inc.php +++ b/ieducar/intranet/include/pmieducar/clsPmieducarServidorAlocacao.inc.php @@ -1,6 +1,6 @@ + * @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'; + /** - * ClsPmieducarServidorAlocacaoTest class + * clsPmieducarServidorAlocacao class. * - * @author Prefeitura Municipal de Itajaí - * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL - * @package Core - * @subpackage Servidor - * @since Classe disponível desde a versão 1.0.0 - * @version $Id$ + * @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@@ */ - -require_once( "include/pmieducar/geral.inc.php" ); - class clsPmieducarServidorAlocacao { - var $cod_servidor_alocacao; - var $ref_ref_cod_instituicao; - var $ref_usuario_exc; - var $ref_usuario_cad; - var $ref_cod_escola; - var $ref_cod_servidor; - var $data_cadastro; - var $data_exclusao; - var $ativo; - var $carga_horaria; - var $periodo; - - // 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; - /** - * Define o campo padrao para ser usado como padrao de ordenacao no metodo lista - * - * @var string - */ - var $_campo_group_by; - - - /** - * Construtor (PHP 4) - * - * @return object - */ - function clsPmieducarServidorAlocacao( $cod_servidor_alocacao = null, $ref_ref_cod_instituicao = null, $ref_usuario_exc = null, $ref_usuario_cad = null, $ref_cod_escola = null, $ref_cod_servidor = null, $data_cadastro = null, $data_exclusao = null, $ativo = null, $carga_horaria = null, $periodo = null ) - { - $db = new clsBanco(); - $this->_schema = "pmieducar."; - $this->_tabela = "{$this->_schema}servidor_alocacao"; - - $this->_campos_lista = $this->_todos_campos = "cod_servidor_alocacao, ref_ref_cod_instituicao, ref_usuario_exc, ref_usuario_cad, ref_cod_escola, ref_cod_servidor, data_cadastro, data_exclusao, ativo, carga_horaria, periodo"; - - 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_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, $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( $cod_servidor_alocacao ) ) - { - $this->cod_servidor_alocacao = $cod_servidor_alocacao; - } - 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; - } - if ( is_string( $carga_horaria ) ) - { - $this->carga_horaria = $carga_horaria; - } - if ( is_numeric( $periodo ) ) - { - $this->periodo = $periodo; - } - } - - /** - * Cria um novo registro - * - * @return bool - */ - function cadastra() - { - if( is_numeric( $this->ref_ref_cod_instituicao ) && is_numeric( $this->ref_usuario_cad ) && is_numeric( $this->ref_cod_escola ) && is_numeric( $this->ref_cod_servidor ) && is_string( $this->carga_horaria ) && ( $this->periodo ) ) - { - $db = new clsBanco(); - - $campos = ""; - $valores = ""; - $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_escola ) ) - { - $campos .= "{$gruda}ref_cod_escola"; - $valores .= "{$gruda}'{$this->ref_cod_escola}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_cod_servidor ) ) - { - $campos .= "{$gruda}ref_cod_servidor"; - $valores .= "{$gruda}'{$this->ref_cod_servidor}'"; - $gruda = ", "; - } - if( is_string( $this->carga_horaria ) ) - { - $campos .= "{$gruda}carga_horaria"; - $valores .= "{$gruda}'{$this->carga_horaria}'"; - $gruda = ", "; - } - if( ( $this->periodo ) ) - { - $campos .= "{$gruda}periodo"; - $valores .= "{$gruda}'{$this->periodo}'"; - $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_servidor_alocacao_seq"); - } - return false; - } - - /** - * Edita os dados de um registro - * - * @return bool - */ - function edita() - { - if( is_numeric( $this->cod_servidor_alocacao ) && is_numeric( $this->ref_usuario_exc ) ) - { - - $db = new clsBanco(); - $set = ""; - - 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_escola ) ) - { - $set .= "{$gruda}ref_cod_escola = '{$this->ref_cod_escola}'"; - $gruda = ", "; - } - if( is_numeric( $this->ref_cod_servidor ) ) - { - $set .= "{$gruda}ref_cod_servidor = '{$this->ref_cod_servidor}'"; - $gruda = ", "; - } - if( is_numeric( $this->carga_horaria ) ) - { - $set .= "{$gruda}carga_horaria = '{$this->carga_horaria}'"; - $gruda = ", "; - } - if( ( $this->periodo ) ) - { - $set .= "{$gruda}periodo = '{$this->periodo}'"; - $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_servidor_alocacao = '{$this->cod_servidor_alocacao}'" ); - return true; - } - } - return false; - } - - /** - * Retorna uma lista filtrados de acordo com os parametros - * - * @return array - */ - function lista( $int_cod_servidor_alocacao = null, $int_ref_ref_cod_instituicao = null, $int_ref_usuario_exc = null, $int_ref_usuario_cad = null, $int_ref_cod_escola = null, $int_ref_cod_servidor = null, $date_data_cadastro_ini = null, $date_data_cadastro_fim = null, $date_data_exclusao_ini = null, $date_data_exclusao_fim = null, $int_ativo = null, $int_carga_horaria = null, $int_periodo = null,$bool_busca_nome = false, $boo_professor = null ) - { - - $filtros = ""; - $whereAnd = " WHERE "; - - if(is_bool($bool_busca_nome) && $bool_busca_nome == true) - { - $join = ", cadastro.pessoa p "; - $filtros .= "{$whereAnd} sa.ref_cod_servidor = p.idpes"; - $whereAnd = " AND "; - $this->_campos_lista .= ",p.nome"; - } - - $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela} sa{$join}"; - - if( is_numeric( $int_cod_servidor_alocacao ) ) - { - $filtros .= "{$whereAnd} sa.cod_servidor_alocacao = '{$int_cod_servidor_alocacao}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_ref_cod_instituicao ) ) - { - $filtros .= "{$whereAnd} sa.ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_usuario_exc ) ) - { - $filtros .= "{$whereAnd} sa.ref_usuario_exc = '{$int_ref_usuario_exc}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_usuario_cad ) ) - { - $filtros .= "{$whereAnd} sa.ref_usuario_cad = '{$int_ref_usuario_cad}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_cod_escola ) ) - { - $filtros .= "{$whereAnd} sa.ref_cod_escola = '{$int_ref_cod_escola}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_ref_cod_servidor ) ) - { - $filtros .= "{$whereAnd} sa.ref_cod_servidor = '{$int_ref_cod_servidor}'"; - $whereAnd = " AND "; - } - if( is_numeric( $int_carga_horaria ) ) - { - $filtros .= "{$whereAnd} sa.carga_horaria = '{$int_carga_horaria}'"; - $whereAnd = " AND "; - } - if( ( $int_periodo ) ) - { - $filtros .= "{$whereAnd} sa.periodo = '{$int_periodo}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_cadastro_ini ) ) - { - $filtros .= "{$whereAnd} sa.data_cadastro >= '{$date_data_cadastro_ini}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_cadastro_fim ) ) - { - $filtros .= "{$whereAnd} sa.data_cadastro <= '{$date_data_cadastro_fim}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_exclusao_ini ) ) - { - $filtros .= "{$whereAnd} sa.data_exclusao >= '{$date_data_exclusao_ini}'"; - $whereAnd = " AND "; - } - if( is_string( $date_data_exclusao_fim ) ) - { - $filtros .= "{$whereAnd} sa.data_exclusao <= '{$date_data_exclusao_fim}'"; - $whereAnd = " AND "; - } - if( is_null( $int_ativo ) || $int_ativo ) - { - $filtros .= "{$whereAnd} sa.ativo = '1'"; - $whereAnd = " AND "; - } - else - { - $filtros .= "{$whereAnd} sa.ativo = '0'"; - $whereAnd = " AND "; - } - - if(is_bool($boo_professor)) - { - $not = $boo_professor? "=" : "!="; - $filtros .= "{$whereAnd} EXISTS( SELECT 1 FROM pmieducar.servidor_funcao,pmieducar.funcao WHERE ref_cod_funcao = cod_funcao AND ref_cod_servidor = sa.ref_cod_servidor AND sa.ref_ref_cod_instituicao = ref_ref_cod_instituicao AND professor $not 1)"; - $whereAnd = " AND "; - } - - - - $db = new clsBanco(); - $countCampos = count( explode( ",", $this->_campos_lista ) ); - $resultado = array(); - - $sql .= $filtros . $this->getGroupBy() . $this->getOrderby() . $this->getLimite(); - - $this->_total = $db->CampoUnico( "SELECT COUNT(0) FROM {$this->_tabela} sa {$join} {$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; - } - - - function listaEscolas($int_ref_ref_cod_instituicao = null) - { - - if( is_numeric( $int_ref_ref_cod_instituicao ) ) - { - - $sql = "SELECT DISTINCT ref_cod_escola FROM {$this->_tabela} WHERE ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}' AND ativo = '1'"; - - $db = new clsBanco(); - $resultado = array(); - - $db->Consulta( $sql ); - - while ( $db->ProximoRegistro() ) - { - $tupla = $db->Tupla(); - $resultado[] = $tupla; - } - - if( count( $resultado ) ) - { - return $resultado; - } - - return false; - } - return false; - } - - - /** - * Retorna um array com os dados de um registro - * - * @return array - */ - function detalhe() - { - if( is_numeric( $this->cod_servidor_alocacao ) ) - { - - $db = new clsBanco(); - $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_servidor_alocacao = '{$this->cod_servidor_alocacao}'" ); - $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_servidor_alocacao ) ) - { - - $db = new clsBanco(); - $db->Consulta( "SELECT 1 FROM {$this->_tabela} WHERE cod_servidor_alocacao = '{$this->cod_servidor_alocacao}'" ); - $db->ProximoRegistro(); - return $db->Tupla(); - } - return false; - } - - /** - * Exclui um registro - * - * @return bool - */ - function excluir() - { - if( is_numeric( $this->cod_servidor_alocacao ) && is_numeric( $this->ref_usuario_exc ) ) - { - - /* - delete - $db = new clsBanco(); - $db->Consulta( "DELETE FROM {$this->_tabela} WHERE cod_servidor_alocacao = '{$this->cod_servidor_alocacao}'" ); - return true; - */ - - $this->ativo = 0; - return $this->edita(); - } - return false; - } - - /** - * Exclui um registro passando cod_Servidor escola e horario - * - * @return bool - */ - function excluir_horario() - { -// echo "if( is_numeric( $this->ref_cod_servidor ) && is_numeric( $this->ref_ref_cod_instituicao ) && is_numeric( $this->ref_cod_escola ) && is_numeric( $this->hora_inicial ) && is_numeric( $this->hora_final ))";die; - if( is_numeric( $this->ref_cod_servidor ) && is_numeric( $this->ref_ref_cod_instituicao ) && is_numeric( $this->ref_cod_escola ) && is_numeric( $this->periodo ) ) - { - - - //delete - $db = new clsBanco(); - //echo "DELETE FROM {$this->_tabela} WHERE ref_cod_servidor = '{$this->ref_cod_servidor}' AND ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}' AND ref_cod_escola = '{$this->ref_cod_escola}' AND hora_inicial = '{$this->hora_inicial}' AND hora_final = '{$this->hora_final}' " ; - $db->Consulta( "DELETE FROM {$this->_tabela} WHERE ref_cod_servidor = '{$this->ref_cod_servidor}' AND ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}' AND ref_cod_escola = '{$this->ref_cod_escola}' AND periodo = '$this->periodo'" ); - return true; - - - //$this->ativo = 0; - // return $this->edita(); - } - return false; - } + var $cod_servidor_alocacao; + var $ref_ref_cod_instituicao; + var $ref_usuario_exc; + var $ref_usuario_cad; + var $ref_cod_escola; + var $ref_cod_servidor; + var $data_cadastro; + var $data_exclusao; + var $ativo; + var $carga_horaria; + var $periodo; + + /** + * 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; + /** + * Define o campo para ser usado como padrão de agrupamento no método lista(). + * @var string + */ + var $_campo_group_by; + + /** + * Construtor. + */ + function clsPmieducarServidorAlocacao($cod_servidor_alocacao = NULL, + $ref_ref_cod_instituicao = NULL, $ref_usuario_exc = NULL, $ref_usuario_cad = NULL, + $ref_cod_escola = NULL, $ref_cod_servidor = NULL, $data_cadastro = NULL, + $data_exclusao = NULL, $ativo = NULL, $carga_horaria = NULL, $periodo = NULL) + { + $db = new clsBanco(); + $this->_schema = 'pmieducar.'; + $this->_tabela = $this->_schema . 'servidor_alocacao'; + + $this->_campos_lista = $this->_todos_campos = 'cod_servidor_alocacao, ref_ref_cod_instituicao, ref_usuario_exc, ref_usuario_cad, ref_cod_escola, ref_cod_servidor, data_cadastro, data_exclusao, ativo, carga_horaria, periodo'; + + 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_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, $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($cod_servidor_alocacao)) { + $this->cod_servidor_alocacao = $cod_servidor_alocacao; + } + + 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; + } + + if (is_string($carga_horaria)) { + $this->carga_horaria = $carga_horaria; + } + + if (is_numeric($periodo)) { + $this->periodo = $periodo; + } + } + + /** + * Cria um novo registro. + * @return bool + */ + function cadastra() + { + if (is_numeric($this->ref_ref_cod_instituicao) && is_numeric($this->ref_usuario_cad) && + is_numeric($this->ref_cod_escola) && is_numeric($this->ref_cod_servidor) && + is_string($this->carga_horaria) && ($this->periodo) + ) { + $db = new clsBanco(); + + $campos = ''; + $valores = ''; + $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_escola)) { + $campos .= "{$gruda}ref_cod_escola"; + $valores .= "{$gruda}'{$this->ref_cod_escola}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_cod_servidor)) { + $campos .= "{$gruda}ref_cod_servidor"; + $valores .= "{$gruda}'{$this->ref_cod_servidor}'"; + $gruda = ', '; + } + + if (is_string($this->carga_horaria)) { + $campos .= "{$gruda}carga_horaria"; + $valores .= "{$gruda}'{$this->carga_horaria}'"; + $gruda = ', '; + } + + if (($this->periodo)) { + $campos .= "{$gruda}periodo"; + $valores .= "{$gruda}'{$this->periodo}'"; + $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_servidor_alocacao_seq"); + } + + return FALSE; + } + + /** + * Edita os dados de um registro. + * @return bool + */ + function edita() + { + if (is_numeric($this->cod_servidor_alocacao) && is_numeric($this->ref_usuario_exc)) { + $db = new clsBanco(); + $set = ''; + + 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_escola)) { + $set .= "{$gruda}ref_cod_escola = '{$this->ref_cod_escola}'"; + $gruda = ', '; + } + + if (is_numeric($this->ref_cod_servidor)) { + $set .= "{$gruda}ref_cod_servidor = '{$this->ref_cod_servidor}'"; + $gruda = ', '; + } + + if (is_numeric($this->carga_horaria)) { + $set .= "{$gruda}carga_horaria = '{$this->carga_horaria}'"; + $gruda = ', '; + } + + if (($this->periodo)) { + $set .= "{$gruda}periodo = '{$this->periodo}'"; + $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_servidor_alocacao = '{$this->cod_servidor_alocacao}'"); + return TRUE; + } + } + + return FALSE; + } + + /** + * Retorna uma lista de registros filtrados de acordo com os parâmetros. + * @return array + */ + function lista($int_cod_servidor_alocacao = NULL, $int_ref_ref_cod_instituicao = NULL, + $int_ref_usuario_exc = NULL, $int_ref_usuario_cad = NULL, $int_ref_cod_escola = NULL, + $int_ref_cod_servidor = NULL, $date_data_cadastro_ini = NULL, + $date_data_cadastro_fim = NULL, $date_data_exclusao_ini = NULL, + $date_data_exclusao_fim = NULL, $int_ativo = NULL, $int_carga_horaria = NULL, + $int_periodo = NULL,$bool_busca_nome = FALSE, $boo_professor = NULL) + { + $filtros = ''; + $whereAnd = ' WHERE '; + + if (is_bool($bool_busca_nome) && $bool_busca_nome == TRUE) { + $join = ', cadastro.pessoa p '; + $filtros .= $whereAnd.' sa.ref_cod_servidor = p.idpes'; + $whereAnd = ' AND '; + $this->_campos_lista .= ',p.nome'; + } + + $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela} sa{$join}"; + + if (is_numeric($int_cod_servidor_alocacao)) { + $filtros .= "{$whereAnd} sa.cod_servidor_alocacao = '{$int_cod_servidor_alocacao}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_ref_cod_instituicao)) { + $filtros .= "{$whereAnd} sa.ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_usuario_exc)) { + $filtros .= "{$whereAnd} sa.ref_usuario_exc = '{$int_ref_usuario_exc}'"; + $whereAnd = ' AND '; + } + if (is_numeric($int_ref_usuario_cad)) { + $filtros .= "{$whereAnd} sa.ref_usuario_cad = '{$int_ref_usuario_cad}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_cod_escola)) { + $filtros .= "{$whereAnd} sa.ref_cod_escola = '{$int_ref_cod_escola}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_ref_cod_servidor)) { + $filtros .= "{$whereAnd} sa.ref_cod_servidor = '{$int_ref_cod_servidor}'"; + $whereAnd = ' AND '; + } + + if (is_numeric($int_carga_horaria)) { + $filtros .= "{$whereAnd} sa.carga_horaria = '{$int_carga_horaria}'"; + $whereAnd = ' AND '; + } + + if (($int_periodo)) { + $filtros .= "{$whereAnd} sa.periodo = '{$int_periodo}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_cadastro_ini)) { + $filtros .= "{$whereAnd} sa.data_cadastro >= '{$date_data_cadastro_ini}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_cadastro_fim)) { + $filtros .= "{$whereAnd} sa.data_cadastro <= '{$date_data_cadastro_fim}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_exclusao_ini)) { + $filtros .= "{$whereAnd} sa.data_exclusao >= '{$date_data_exclusao_ini}'"; + $whereAnd = ' AND '; + } + + if (is_string($date_data_exclusao_fim)) { + $filtros .= "{$whereAnd} sa.data_exclusao <= '{$date_data_exclusao_fim}'"; + $whereAnd = ' AND '; + } + + if (is_null($int_ativo) || $int_ativo) { + $filtros .= "{$whereAnd} sa.ativo = '1'"; + $whereAnd = ' AND '; + } + else { + $filtros .= "{$whereAnd} sa.ativo = '0'"; + $whereAnd = ' AND '; + } + + if (is_bool($boo_professor)) { + $not = $boo_professor? "=" : "!="; + $filtros .= "{$whereAnd} EXISTS(SELECT 1 FROM pmieducar.servidor_funcao,pmieducar.funcao WHERE ref_cod_funcao = cod_funcao AND ref_cod_servidor = sa.ref_cod_servidor AND sa.ref_ref_cod_instituicao = ref_ref_cod_instituicao AND professor $not 1)"; + $whereAnd = ' AND '; + } + + $db = new clsBanco(); + $countCampos = count(explode(',', $this->_campos_lista)); + $resultado = array(); + + $sql .= $filtros . $this->getGroupBy() . $this->getOrderby() . $this->getLimite(); + + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} sa {$join} {$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; + } + + + function listaEscolas($int_ref_ref_cod_instituicao = NULL) + { + if (is_numeric($int_ref_ref_cod_instituicao)) { + $sql = "SELECT DISTINCT ref_cod_escola FROM {$this->_tabela} WHERE ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}' AND ativo = '1'"; + + $db = new clsBanco(); + $resultado = array(); + + $db->Consulta($sql); + + while ($db->ProximoRegistro()) { + $tupla = $db->Tupla(); + $resultado[] = $tupla; + } + + if (count($resultado)) { + return $resultado; + } + + return FALSE; + } + + return FALSE; + } + + /** + * Retorna um array com os dados de um registro. + * @return array + */ + function detalhe() + { + if (is_numeric($this->cod_servidor_alocacao)) { + $db = new clsBanco(); + $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_servidor_alocacao = '{$this->cod_servidor_alocacao}'" ); + $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_servidor_alocacao)) { + $db = new clsBanco(); + $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE cod_servidor_alocacao = '{$this->cod_servidor_alocacao}'"); + $db->ProximoRegistro(); + return $db->Tupla(); + } + + return FALSE; + } + + /** + * Exclui um registro. + * @return bool + */ + function excluir() + { + if (is_numeric($this->cod_servidor_alocacao) && is_numeric($this->ref_usuario_exc)) { + $this->ativo = 0; + return $this->edita(); + } + + return FALSE; + } + + /** + * Exclui um registro baseado no período da alocação. + * @return bool + */ + function excluir_horario() + { + if (is_numeric($this->ref_cod_servidor) && is_numeric($this->ref_ref_cod_instituicao) && + is_numeric($this->ref_cod_escola) && is_numeric($this->periodo) + ) { + $db = new clsBanco(); + $db->Consulta("DELETE FROM {$this->_tabela} WHERE ref_cod_servidor = '{$this->ref_cod_servidor}' AND ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}' AND ref_cod_escola = '{$this->ref_cod_escola}' AND periodo = '$this->periodo'"); + return TRUE; + } + + return FALSE; + } /** * Substitui a alocação entre servidores @@ -665,13 +597,14 @@ class clsPmieducarServidorAlocacao * método, um objeto desta classe precisa estar instanciado com os atributos * do servidor a ser substituido. * - * @param int $int_ref_cod_servidor_substituto Código do servidor que substituirá o atual - * @return bool TRUE em caso de sucesso, FALSE caso contrário + * @param int $int_ref_cod_servidor_substituto Código do servidor que substituirá o atual + * @return bool TRUE em caso de sucesso, FALSE caso contrário */ - public function substituir_servidor($int_ref_cod_servidor_substituto) { + function substituir_servidor($int_ref_cod_servidor_substituto) + { if (is_numeric($int_ref_cod_servidor_substituto) && - is_numeric($this->ref_ref_cod_instituicao)) { - + is_numeric($this->ref_ref_cod_instituicao) + ) { $servidor = new clsPmieducarServidor($int_ref_cod_servidor_substituto, NULL, NULL, NULL, NULL, NULL, NULL, $this->ref_ref_cod_instituicao); @@ -682,8 +615,8 @@ class clsPmieducarServidorAlocacao if (is_numeric($this->ref_cod_servidor) && is_numeric($this->ref_ref_cod_instituicao) && is_numeric($this->ref_cod_escola) && is_numeric($this->periodo) && - is_string($this->carga_horaria)) { - + is_string($this->carga_horaria) + ) { $sql = "UPDATE %s SET ref_cod_servidor='%d' WHERE ref_cod_servidor = '%d' "; $sql .= "AND ref_ref_cod_instituicao = '%d' AND ref_cod_escola = '%d' AND "; $sql .= "carga_horaria = '%s' AND periodo = '%d'"; @@ -701,113 +634,94 @@ class clsPmieducarServidorAlocacao 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; + } + } - /** - * 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 ""; - } - - /** - * Define campo para ser utilizado na clause group by - * - * @return null - */ - function setGroupBy( $strNomeCampo ) - { - if( is_string( $strNomeCampo ) && $strNomeCampo ) - { - $this->_campo_group_by = $strNomeCampo; - } - } - - /** - * Retorna a string com o trecho da query resposavel pelo group by - * - * @return string - */ - function getGroupBy() - { - if( is_string( $this->_campo_group_by ) ) - { - return " GROUP BY {$this->_campo_group_by} "; - } - return ""; - } -} -?> \ No newline at end of file + /** + * 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 ''; + } + + /** + * Define o campo para ser utilizado na agrupação no método Lista(). + */ + function setGroupby($strNomeCampo) + { + if (is_string($strNomeCampo) && $strNomeCampo ) { + $this->_campo_group_by = $strNomeCampo; + } + } + + /** + * Retorna a string com o trecho da query responsável pelo Agrupamento dos + * registros. + * + * @return string + */ + function getGroupBy() + { + if (is_string($this->_campo_group_by)) { + return " GROUP BY {$this->_campo_group_by} "; + } + return ''; + } +} \ No newline at end of file -- libgit2 0.21.2