Commit c8cbb8364442cf60d6ac77058e2304caa2eabd8f

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

Refactoring para coding standards

ieducar/intranet/educar_falta_atraso_cad.php
1 1 <?php
  2 +
2 3 /**
  4 + * i-Educar - Sistema de gestão escolar
3 5 *
4   - * @author Prefeitura Municipal de Itajaí
5   - * @version SVN: $Id$
6   - *
7   - * Pacote: i-PLB Software Público Livre e Brasileiro
  6 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  7 + * <ctima@itajai.sc.gov.br>
8 8 *
9   - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí
10   - * ctima@itajai.sc.gov.br
  9 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  10 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  11 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  12 + * qualquer versão posterior.
11 13 *
12   - * Este programa é software livre, você pode redistribuí-lo e/ou
13   - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme
14   - * publicada pela Free Software Foundation, tanto a versão 2 da
15   - * Licença como (a seu critério) qualquer versão mais nova.
  14 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  15 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  16 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  17 + * do GNU para mais detalhes.
16 18 *
17   - * Este programa é distribuído na expectativa de ser útil, mas SEM
18   - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI-
19   - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con-
20   - * sulte a Licença Pública Geral GNU para obter mais detalhes.
21   - *
22   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU
23   - * junto com este programa. Se não, escreva para a Free Software
24   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25   - * 02111-1307, USA.
  19 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  20 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  21 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
26 22 *
  23 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  24 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package iEd_Pmieducar
  27 + * @since Arquivo disponível desde a versão 1.0.0
  28 + * @version $Id$
27 29 */
28 30  
29 31 require_once 'include/clsBase.inc.php';
... ... @@ -31,220 +33,279 @@ require_once &#39;include/clsCadastro.inc.php&#39;;
31 33 require_once 'include/clsBanco.inc.php';
32 34 require_once 'include/pmieducar/geral.inc.php';
33 35  
  36 +/**
  37 + * clsIndexBase class.
  38 + *
  39 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  40 + * @category i-Educar
  41 + * @license @@license@@
  42 + * @package iEd_Pmieducar
  43 + * @since Classe disponível desde a versão 1.0.0
  44 + * @version @@package_version@@
  45 + */
34 46 class clsIndexBase extends clsBase
35 47 {
36   - function Formular()
37   - {
38   - $this->SetTitulo( "{$this->_instituicao} i-Educar - Falta Atraso" );
39   - $this->processoAp = "635";
40   - }
  48 + function Formular()
  49 + {
  50 + $this->SetTitulo($this->_instituicao . ' i-Educar - Falta Atraso');
  51 + $this->processoAp = 635;
  52 + }
41 53 }
42 54  
  55 +/**
  56 + * indice class.
  57 + *
  58 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  59 + * @category i-Educar
  60 + * @license @@license@@
  61 + * @package iEd_Pmieducar
  62 + * @since Classe disponível desde a versão 1.0.0
  63 + * @version @@package_version@@
  64 + */
43 65 class indice extends clsCadastro
44 66 {
45   - /**
46   - * Referencia pega da session para o idpes do usuario atual
47   - *
48   - * @var int
49   - */
50   - var $pessoa_logada;
51   -
52   - var $cod_falta_atraso;
53   - var $ref_cod_escola;
54   - var $ref_cod_instituicao;
55   - var $ref_usuario_exc;
56   - var $ref_usuario_cad;
57   - var $ref_cod_servidor;
58   - var $tipo;
59   - var $data_falta_atraso;
60   - var $qtd_horas;
61   - var $qtd_min;
62   - var $justificada;
63   - var $data_cadastro;
64   - var $data_exclusao;
65   - var $ativo;
66   -
67   - function Inicializar()
68   - {
69   - $retorno = "Novo";
70   - @session_start();
71   - $this->pessoa_logada = $_SESSION['id_pessoa'];
72   - @session_write_close();
73   -
74   - $this->cod_falta_atraso = $_GET["cod_falta_atraso"];
75   - $this->ref_cod_servidor = $_GET["ref_cod_servidor"];
76   - $this->ref_cod_escola = $_GET["ref_cod_escola"];
77   - $this->ref_cod_instituicao = $_GET["ref_cod_instituicao"];
78   -
79   - $obj_permissoes = new clsPermissoes();
80   - $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 7, "educar_falta_atraso_lst.php" );
81   -
82   - if( is_numeric( $this->cod_falta_atraso ) )
83   - {
84   -
85   - $obj = new clsPmieducarFaltaAtraso( $this->cod_falta_atraso );
86   - $registro = $obj->detalhe();
87   - if( $registro )
88   - {
89   - foreach( $registro AS $campo => $val ) // passa todos os valores obtidos no registro para atributos do objeto
90   - $this->$campo = $val;
91   - $this->data_falta_atraso = dataFromPgToBr( $this->data_falta_atraso );
92   -
93   - $obj_permissoes = new clsPermissoes();
94   - if( $obj_permissoes->permissao_excluir( 635, $this->pessoa_logada, 7 ) )
95   - {
96   - $this->fexcluir = true;
97   - }
98   -
99   - $retorno = "Editar";
100   - }
101   - }
102   - $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}";
103   - $this->nome_url_cancelar = "Cancelar";
104   - return $retorno;
105   - }
106   -
107   - function Gerar()
108   - {
109   - // primary keys
110   - $this->campoOculto( "cod_falta_atraso", $this->cod_falta_atraso );
111   - $this->campoOculto( "ref_cod_servidor", $this->ref_cod_servidor );
112   -
113   - // foreign keys
114   - $obrigatorio = true;
115   - $get_instituicao = true;
116   - $get_escola = true;
117   - include("include/pmieducar/educar_campo_lista.php");
118   -
119   - // text
120   - $opcoes = array( "" => "Selecione", "1" => "Atraso", "2" => "Falta" );
121   - $this->campoLista( "tipo", "Tipo", $opcoes, $this->tipo );
122   -
123   - $this->campoNumero( "qtd_horas", "Quantidade de Horas", $this->qtd_horas, 30, 255, false );
124   - $this->campoNumero( "qtd_min", "Quantidade de Minutos", $this->qtd_min, 30, 255, false );
125   -
126   - $opcoes = array( "" => "Selecione", "0" => "Sim", "1" => "Não" );
127   - $this->campoLista( "justificada", "Justificada", $opcoes, $this->justificada );
128   -
129   - // data
130   - $this->campoData( "data_falta_atraso", "Dia", $this->data_falta_atraso, true );
131   - }
132   -
133   - function Novo()
134   - {
135   - @session_start();
136   - $this->pessoa_logada = $_SESSION['id_pessoa'];
137   - @session_write_close();
138   -
139   - $obj_permissoes = new clsPermissoes();
140   - $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}" );
141   -
142   - if ( $this->tipo == 1 )
143   - $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 );
144   - elseif ( $this->tipo == 2 )
145   - {
146   - $db = new clsBanco();
147   - $dia_semana = $db->CampoUnico( "SELECT EXTRACT ( DOW FROM ( date '".dataToBanco( $this->data_falta_atraso )."' ) + 1 )" );
148   -
149   - $obj_ser = new clsPmieducarServidor();
150   - $horas = $obj_ser->qtdhoras( $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao, $dia_semana );
151   - if ( $horas )
152   - {
153   - $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 );
154   - }
155   - }
156   - $cadastrou = $obj->cadastra();
157   - if( $cadastrou )
158   - {
159   - $this->mensagem .= "Cadastro efetuado com sucesso.<br>";
160   - header( "Location: educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" );
161   - die();
162   - return true;
163   - }
164   -
165   - $this->mensagem = "Cadastro n&atilde;o realizado.<br>";
166   - echo "<!--\nErro ao cadastrar clsPmieducarFaltaAtraso\nvalores obrigatorios\nis_numeric( $this->ref_cod_escola ) && is_numeric( $this->ref_ref_cod_instituicao ) && is_numeric( $this->ref_usuario_exc ) && 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 )\n-->";
167   - return false;
168   - }
169   -
170   - function Editar()
171   - {
172   - @session_start();
173   - $this->pessoa_logada = $_SESSION['id_pessoa'];
174   - @session_write_close();
175   -
176   - $obj_permissoes = new clsPermissoes();
177   - $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}" );
178   -
179   - if ( $this->tipo == 1 ) {
180   - $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 );
181   - }
182   - elseif ( $this->tipo == 2 ) {
183   - $obj_ser = new clsPmieducarServidor( $this->ref_cod_servidor, null, null, null, null, null, 1, $this->ref_cod_instituicao );
184   - $det_ser = $obj_ser->detalhe();
185   - $horas = floor( $det_ser["carga_horaria"] );
186   - $minutos = ( $det_ser["carga_horaria"] - $horas ) * 60;
187   - $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 );
188   - }
189   - $editou = $obj->edita();
190   - if( $editou )
191   - {
192   - $this->mensagem .= "Edi&ccedil;&atilde;o efetuada com sucesso.<br>";
193   - header( "Location: educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" );
194   - die();
195   - return true;
196   - }
197   -
198   - $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>";
199   - echo "<!--\nErro ao editar clsPmieducarFaltaAtraso\nvalores obrigatorios\nif( is_numeric( $this->cod_falta_atraso ) && is_numeric( $this->ref_usuario_exc ) )\n-->";
200   - return false;
201   - }
202   -
203   - function Excluir()
204   - {
205   - @session_start();
206   - $this->pessoa_logada = $_SESSION['id_pessoa'];
207   - @session_write_close();
208   -
209   - $obj_permissoes = new clsPermissoes();
210   - $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}" );
211   -
212   -
213   - $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);
214   - $excluiu = $obj->excluir();
215   - if( $excluiu )
216   - {
217   - $this->mensagem .= "Exclus&atilde;o efetuada com sucesso.<br>";
218   - header( "Location: educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}" );
219   - die();
220   - return true;
221   - }
222   -
223   - $this->mensagem = "Exclus&atilde;o n&atilde;o realizada.<br>";
224   - echo "<!--\nErro ao excluir clsPmieducarFaltaAtraso\nvalores obrigatorios\nif( is_numeric( $this->cod_falta_atraso ) && is_numeric( $this->ref_usuario_exc ) )\n-->";
225   - return false;
226   - }
  67 + var $pessoa_logada;
  68 +
  69 + var $cod_falta_atraso;
  70 + var $ref_cod_escola;
  71 + var $ref_cod_instituicao;
  72 + var $ref_usuario_exc;
  73 + var $ref_usuario_cad;
  74 + var $ref_cod_servidor;
  75 + var $tipo;
  76 + var $data_falta_atraso;
  77 + var $qtd_horas;
  78 + var $qtd_min;
  79 + var $justificada;
  80 + var $data_cadastro;
  81 + var $data_exclusao;
  82 + var $ativo;
  83 +
  84 + function Inicializar()
  85 + {
  86 + $retorno = 'Novo';
  87 + @session_start();
  88 + $this->pessoa_logada = $_SESSION['id_pessoa'];
  89 + @session_write_close();
  90 +
  91 + $this->cod_falta_atraso = $_GET['cod_falta_atraso'];
  92 + $this->ref_cod_servidor = $_GET['ref_cod_servidor'];
  93 + $this->ref_cod_escola = $_GET['ref_cod_escola'];
  94 + $this->ref_cod_instituicao = $_GET['ref_cod_instituicao'];
  95 +
  96 + $obj_permissoes = new clsPermissoes();
  97 + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7,
  98 + 'educar_falta_atraso_lst.php');
  99 +
  100 + if (is_numeric($this->cod_falta_atraso)) {
  101 + $obj = new clsPmieducarFaltaAtraso($this->cod_falta_atraso);
  102 + $registro = $obj->detalhe();
  103 +
  104 + if ($registro) {
  105 + // passa todos os valores obtidos no registro para atributos do objeto
  106 + foreach ($registro as $campo => $val) {
  107 + $this->$campo = $val;
  108 + }
  109 +
  110 + $this->data_falta_atraso = dataFromPgToBr($this->data_falta_atraso);
  111 +
  112 + $obj_permissoes = new clsPermissoes();
  113 +
  114 + if ($obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 7)) {
  115 + $this->fexcluir = TRUE;
  116 + }
  117 +
  118 + $retorno = 'Editar';
  119 + }
  120 + }
  121 +
  122 + $this->url_cancelar = $retorno == 'Editar' ?
  123 + sprintf('educar_falta_atraso_det.php?cod_falta_atraso=%d', $registro['cod_falta_atraso']) :
  124 + sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d', $this->ref_cod_servidor, $this->ref_cod_instituicao);
  125 +
  126 + $this->nome_url_cancelar = 'Cancelar';
  127 + return $retorno;
  128 + }
  129 +
  130 + function Gerar()
  131 + {
  132 + // Primary keys
  133 + $this->campoOculto('cod_falta_atraso', $this->cod_falta_atraso);
  134 + $this->campoOculto('ref_cod_servidor', $this->ref_cod_servidor);
  135 +
  136 + // Foreign keys
  137 + $obrigatorio = true;
  138 + $get_instituicao = true;
  139 + $get_escola = true;
  140 + include 'include/pmieducar/educar_campo_lista.php';
  141 +
  142 + // Text
  143 + // @todo CoreExt_Enum
  144 + $opcoes = array(
  145 + '' => 'Selecione',
  146 + 1 => 'Atraso',
  147 + 2 => 'Falta'
  148 + );
  149 +
  150 + $this->campoLista('tipo', 'Tipo', $opcoes, $this->tipo);
  151 +
  152 + $this->campoNumero('qtd_horas', 'Quantidade de Horas', $this->qtd_horas, 30, 255, FALSE);
  153 + $this->campoNumero('qtd_min', 'Quantidade de Minutos', $this->qtd_min, 30, 255, FALSE);
  154 +
  155 + $opcoes = array(
  156 + '' => 'Selecione',
  157 + 0 => 'Sim',
  158 + 1 => 'Não'
  159 + );
  160 +
  161 + $this->campoLista('justificada', 'Justificada', $opcoes, $this->justificada);
  162 +
  163 + // Data
  164 + $this->campoData('data_falta_atraso', 'Dia', $this->data_falta_atraso, TRUE);
  165 + }
  166 +
  167 + function Novo()
  168 + {
  169 + @session_start();
  170 + $this->pessoa_logada = $_SESSION['id_pessoa'];
  171 + @session_write_close();
  172 +
  173 + $obj_permissoes = new clsPermissoes();
  174 + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7,
  175 + sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d',
  176 + $this->ref_cod_servidor, $this->ref_cod_instituicao));
  177 +
  178 + if ($this->tipo == 1) {
  179 + $obj = new clsPmieducarFaltaAtraso(NULL, $this->ref_cod_escola,
  180 + $this->ref_cod_instituicao, NULL, $this->pessoa_logada,
  181 + $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso,
  182 + $this->qtd_horas, $this->qtd_min, $this->justificada, NULL, NULL, 1);
  183 + }
  184 + elseif ($this->tipo == 2) {
  185 + $db = new clsBanco();
  186 + $dia_semana = $db->CampoUnico(sprintf('SELECT EXTRACT (DOW FROM (date "%s") + 1 )', dataToBanco($this->data_falta_atraso)));
  187 +
  188 + $obj_ser = new clsPmieducarServidor();
  189 + $horas = $obj_ser->qtdhoras( $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao, $dia_semana );
  190 +
  191 + if ($horas) {
  192 + $obj = new clsPmieducarFaltaAtraso(NULL, $this->ref_cod_escola,
  193 + $this->ref_cod_instituicao, NULL, $this->pessoa_logada,
  194 + $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso,
  195 + $horas['hora'], $horas['min'], $this->justificada, NULL, NULL, 1);
  196 + }
  197 + }
  198 +
  199 + $cadastrou = $obj->cadastra();
  200 +
  201 + if ($cadastrou) {
  202 + $this->mensagem .= 'Cadastro efetuado com sucesso.<br />';
  203 + header('Location: ' . sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d',
  204 + $this->ref_cod_servidor, $this->ref_cod_instituicao));
  205 + die();
  206 + }
  207 +
  208 + $this->mensagem = 'Cadastro não realizado.<br />';
  209 + echo "<!--\nErro ao cadastrar clsPmieducarFaltaAtraso\nvalores obrigatórios\nis_numeric( $this->ref_cod_escola ) && is_numeric($this->ref_ref_cod_instituicao) && is_numeric($this->ref_usuario_exc) && 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)\n-->";
  210 + return FALSE;
  211 + }
  212 +
  213 + function Editar()
  214 + {
  215 + @session_start();
  216 + $this->pessoa_logada = $_SESSION['id_pessoa'];
  217 + @session_write_close();
  218 +
  219 + $obj_permissoes = new clsPermissoes();
  220 + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7,
  221 + sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d',
  222 + $this->ref_cod_servidor, $this->ref_cod_instituicao));
  223 +
  224 + if ($this->tipo == 1) {
  225 + $obj = new clsPmieducarFaltaAtraso(NULL, $this->ref_cod_escola,
  226 + $this->ref_cod_instituicao, $this->pessoa_logada, NULL,
  227 + $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso,
  228 + $this->qtd_horas, $this->qtd_min, $this->justificada, NULL, NULL, 1);
  229 + }
  230 + elseif ($this->tipo == 2) {
  231 + $obj_ser = new clsPmieducarServidor($this->ref_cod_servidor, NULL, NULL,
  232 + NULL, NULL, NULL, 1, $this->ref_cod_instituicao);
  233 +
  234 + $det_ser = $obj_ser->detalhe();
  235 + $horas = floor($det_ser['carga_horaria']);
  236 + $minutos = ($det_ser['carga_horaria'] - $horas) * 60;
  237 + $obj = new clsPmieducarFaltaAtraso(NULL, $this->ref_cod_escola,
  238 + $this->ref_cod_instituicao, $this->pessoa_logada, NULL,
  239 + $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, $horas,
  240 + $minutos, $this->justificada, NULL, NULL, 1);
  241 + }
  242 +
  243 + $editou = $obj->edita();
  244 + if ($editou) {
  245 + $this->mensagem .= 'Edição efetuada com sucesso.<br />';
  246 + header('Location: ' . sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d',
  247 + $this->ref_cod_servidor, $this->ref_cod_instituicao));
  248 + die();
  249 + }
  250 +
  251 + $this->mensagem = 'Edição não realizada.<br />';
  252 + echo "<!--\nErro ao editar clsPmieducarFaltaAtraso\nvalores obrigatórios\nif(is_numeric($this->cod_falta_atraso) && is_numeric($this->ref_usuario_exc))\n-->";
  253 + return FALSE;
  254 + }
  255 +
  256 + function Excluir()
  257 + {
  258 + @session_start();
  259 + $this->pessoa_logada = $_SESSION['id_pessoa'];
  260 + @session_write_close();
  261 +
  262 + $obj_permissoes = new clsPermissoes();
  263 + $obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 7,
  264 + sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d',
  265 + $this->ref_cod_servidor, $this->ref_cod_instituicao));
  266 +
  267 + $obj = new clsPmieducarFaltaAtraso($this->cod_falta_atraso, $this->ref_cod_escola,
  268 + $this->ref_ref_cod_instituicao, $this->pessoa_logada, $this->pessoa_logada,
  269 + $this->ref_cod_servidor, $this->tipo, $this->data_falta_atraso, $this->qtd_horas,
  270 + $this->qtd_min, $this->justificada, $this->data_cadastro, $this->data_exclusao, 0);
  271 + $excluiu = $obj->excluir();
  272 + if ($excluiu) {
  273 + $this->mensagem .= 'Exclusão efetuada com sucesso.<br />';
  274 + header('Location: ' . sprintf('educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d',
  275 + $this->ref_cod_servidor, $this->ref_cod_instituicao));
  276 + die();
  277 + }
  278 +
  279 + $this->mensagem = "Exclusão não realizada.<br>";
  280 + echo "<!--\nErro ao excluir clsPmieducarFaltaAtraso\nvalores obrigatórios\nif( is_numeric( $this->cod_falta_atraso ) && is_numeric( $this->ref_usuario_exc ) )\n-->";
  281 + return FALSE;
  282 + }
227 283 }
228 284  
229   -// cria uma extensao da classe base
  285 +// Instancia objeto de página
230 286 $pagina = new clsIndexBase();
231   -// cria o conteudo
  287 +
  288 +// Instancia objeto de conteúdo
232 289 $miolo = new indice();
233   -// adiciona o conteudo na clsBase
234   -$pagina->addForm( $miolo );
235   -// gera o html
  290 +
  291 +// Atribui o conteúdo à página
  292 +$pagina->addForm($miolo);
  293 +
  294 +// Gera o código HTML
236 295 $pagina->MakeAll();
237 296 ?>
238   -<script>
239   - var obj_tipo = document.getElementById( 'tipo' );
240   - obj_tipo.onchange = function() {
241   - if ( document.getElementById( 'tipo' ).value == 1 ) {
242   - setVisibility( 'tr_qtd_horas', true );
243   - setVisibility( 'tr_qtd_min', true );
244   - }
245   - else if ( document.getElementById( 'tipo' ).value == 2 ) {
246   - setVisibility( 'tr_qtd_horas', false );
247   - setVisibility( 'tr_qtd_min', false );
248   - }
249   - }
  297 +<script type="text/javascript">
  298 +var obj_tipo = document.getElementById('tipo');
  299 +
  300 +obj_tipo.onchange = function()
  301 +{
  302 + if (document.getElementById('tipo').value == 1) {
  303 + setVisibility('tr_qtd_horas', true);
  304 + setVisibility('tr_qtd_min', true);
  305 + }
  306 + else if (document.getElementById( 'tipo' ).value == 2) {
  307 + setVisibility('tr_qtd_horas', false);
  308 + setVisibility('tr_qtd_min', false);
  309 + }
  310 +}
250 311 </script>
251 312 \ No newline at end of file
... ...
ieducar/intranet/educar_falta_atraso_compensado_cad.php
1 1 <?php
2   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3   - * *
4   - * @author Prefeitura Municipal de Itajaí *
5   - * @updated 29/03/2007 *
6   - * Pacote: i-PLB Software Público Livre e Brasileiro *
7   - * *
8   - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí *
9   - * ctima@itajai.sc.gov.br *
10   - * *
11   - * Este programa é software livre, você pode redistribuí-lo e/ou *
12   - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme *
13   - * publicada pela Free Software Foundation, tanto a versão 2 da *
14   - * Licença como (a seu critério) qualquer versão mais nova. *
15   - * *
16   - * Este programa é distribuído na expectativa de ser útil, mas SEM *
17   - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- *
18   - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- *
19   - * sulte a Licença Pública Geral GNU para obter mais detalhes. *
20   - * *
21   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU *
22   - * junto com este programa. Se não, escreva para a Free Software *
23   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *
24   - * 02111-1307, USA. *
25   - * *
26   - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  2 +
27 3 /**
28   - * @author Adriano Erik Weiguert Nagasava
  4 + * i-Educar - Sistema de gestão escolar
  5 + *
  6 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  7 + * <ctima@itajai.sc.gov.br>
  8 + *
  9 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  10 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  11 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  12 + * qualquer versão posterior.
  13 + *
  14 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  15 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  16 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  17 + * do GNU para mais detalhes.
  18 + *
  19 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  20 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  21 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  22 + *
  23 + * @author Adriano Erik Weiguert Nagasava <ctima@itajai.sc.gov.br>
  24 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package iEd_Pmieducar
  27 + * @since Arquivo disponível desde a versão 1.0.0
  28 + * @version $Id$
29 29 */
30   -require_once ("include/clsBase.inc.php");
31   -require_once ("include/clsCadastro.inc.php");
32   -require_once ("include/clsBanco.inc.php");
33   -require_once( "include/pmieducar/geral.inc.php" );
34 30  
  31 +require_once 'include/clsBase.inc.php';
  32 +require_once 'include/clsCadastro.inc.php';
  33 +require_once 'include/clsBanco.inc.php';
  34 +require_once 'include/pmieducar/geral.inc.php';
  35 +
  36 +/**
  37 + * clsIndexBase class.
  38 + *
  39 + * @author Adriano Erik Weiguert Nagasava <ctima@itajai.sc.gov.br>
  40 + * @category i-Educar
  41 + * @license @@license@@
  42 + * @package iEd_Pmieducar
  43 + * @since Classe disponível desde a versão 1.0.0
  44 + * @version @@package_version@@
  45 + */
35 46 class clsIndexBase extends clsBase
36 47 {
37   - function Formular()
38   - {
39   - $this->SetTitulo( "{$this->_instituicao} i-Educar - Falta Atraso Compensado" );
40   - $this->processoAp = "635";
41   - }
  48 + function Formular()
  49 + {
  50 + $this->SetTitulo($this->_instituicao . ' i-Educar - Falta Atraso Compensado');
  51 + $this->processoAp = 635;
  52 + }
42 53 }
43 54  
  55 +/**
  56 + * clsIndexBase class.
  57 + *
  58 + * @author Adriano Erik Weiguert Nagasava <ctima@itajai.sc.gov.br>
  59 + * @category i-Educar
  60 + * @license @@license@@
  61 + * @package iEd_Pmieducar
  62 + * @since Classe disponível desde a versão 1.0.0
  63 + * @version @@package_version@@
  64 + */
44 65 class indice extends clsCadastro
45 66 {
46   - /**
47   - * Referencia pega da session para o idpes do usuario atual
48   - *
49   - * @var int
50   - */
51   - var $pessoa_logada;
52   -
53   - var $cod_compensado;
54   - var $ref_cod_escola;
55   - var $ref_cod_instituicao;
56   - var $ref_cod_servidor;
57   - var $ref_usuario_exc;
58   - var $ref_usuario_cad;
59   - var $data_inicio;
60   - var $data_fim;
61   - var $data_cadastro;
62   - var $data_exclusao;
63   - var $ativo;
64   -
65   - function Inicializar()
66   - {
67   - $retorno = "Novo";
68   - @session_start();
69   - $this->pessoa_logada = $_SESSION['id_pessoa'];
70   - @session_write_close();
71   -
72   - $this->cod_compensado = $_GET["cod_compensado"];
73   - $this->ref_cod_servidor = $_GET["ref_cod_servidor"];
74   - $this->ref_cod_escola = $_GET["ref_cod_escola"];
75   - $this->ref_cod_instituicao = $_GET["ref_cod_instituicao"];
76   -
77   - $obj_permissoes = new clsPermissoes();
78   - $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}" );
79   -
80   - if( is_numeric( $this->cod_compensado ) )
81   - {
82   -
83   - $obj = new clsPmieducarFaltaAtrasoCompensado( $this->cod_compensado );
84   - $registro = $obj->detalhe();
85   - if( $registro )
86   - {
87   - foreach( $registro AS $campo => $val ) // passa todos os valores obtidos no registro para atributos do objeto
88   - $this->$campo = $val;
89   - $this->data_inicio = dataFromPgToBr( $this->data_inicio );
90   - $this->data_fim = dataFromPgToBr( $this->data_fim );
91   - $this->data_cadastro = dataFromPgToBr( $this->data_cadastro );
92   - $this->data_exclusao = dataFromPgToBr( $this->data_exclusao );
93   -
94   - $obj_permissoes = new clsPermissoes();
95   - if( $obj_permissoes->permissao_excluir( 635, $this->pessoa_logada, 7 ) )
96   - {
97   - $this->fexcluir = true;
98   - }
99   -
100   - $retorno = "Editar";
101   - }
102   - }
103   - $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}";
104   - $this->nome_url_cancelar = "Cancelar";
105   - return $retorno;
106   - }
107   -
108   - function Gerar()
109   - {
110   - // primary keys
111   - $this->campoOculto( "cod_compensado", $this->cod_compensado );
112   - $this->campoOculto( "ref_cod_servidor", $this->ref_cod_servidor );
113   -
114   - // foreign keys
115   - $obrigatorio = true;
116   - $get_instituicao = true;
117   - $get_escola = true;
118   - include("include/pmieducar/educar_campo_lista.php");
119   -
120   - // data
121   - $this->campoData( "data_inicio", "Data Inicio", $this->data_inicio, true );
122   - $this->campoData( "data_fim", "Data Fim", $this->data_fim, true );
123   -
124   - }
125   -
126   - function Novo()
127   - {
128   - @session_start();
129   - $this->pessoa_logada = $_SESSION['id_pessoa'];
130   - @session_write_close();
131   -
132   - $obj_permissoes = new clsPermissoes();
133   - $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}" );
134   -
135   - $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 );
136   - $cadastrou = $obj->cadastra();
137   - if( $cadastrou )
138   - {
139   - $this->mensagem .= "Cadastro efetuado com sucesso.<br>";
140   - 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}" );
141   - die();
142   - return true;
143   - }
144   -
145   - $this->mensagem = "Cadastro n&atilde;o realizado.<br>";
146   - echo "<!--\nErro ao cadastrar clsPmieducarFaltaAtrasoCompensado\nvalores obrigatorios\nis_numeric( $this->ref_cod_escola ) && is_numeric( $this->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 )\n-->";
147   - return false;
148   - }
149   -
150   - function Editar()
151   - {
152   - @session_start();
153   - $this->pessoa_logada = $_SESSION['id_pessoa'];
154   - @session_write_close();
155   -
156   - $obj_permissoes = new clsPermissoes();
157   - $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}" );
158   -
159   -
160   - $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);
161   - $editou = $obj->edita();
162   - if( $editou )
163   - {
164   - $this->mensagem .= "Edi&ccedil;&atilde;o efetuada com sucesso.<br>";
165   - 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}" );
166   - die();
167   - return true;
168   - }
169   -
170   - $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>";
171   - echo "<!--\nErro ao editar clsPmieducarFaltaAtrasoCompensado\nvalores obrigatorios\nif( is_numeric( $this->cod_compensado ) && is_numeric( $this->ref_usuario_exc ) )\n-->";
172   - return false;
173   - }
174   -
175   - function Excluir()
176   - {
177   - @session_start();
178   - $this->pessoa_logada = $_SESSION['id_pessoa'];
179   - @session_write_close();
180   -
181   - $obj_permissoes = new clsPermissoes();
182   - $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}" );
183   -
184   -
185   - $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);
186   - $excluiu = $obj->excluir();
187   - if( $excluiu )
188   - {
189   - $this->mensagem .= "Exclus&atilde;o efetuada com sucesso.<br>";
190   - 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}" );
191   - die();
192   - return true;
193   - }
194   -
195   - $this->mensagem = "Exclus&atilde;o n&atilde;o realizada.<br>";
196   - echo "<!--\nErro ao excluir clsPmieducarFaltaAtrasoCompensado\nvalores obrigatorios\nif( is_numeric( $this->cod_compensado ) && is_numeric( $this->ref_usuario_exc ) )\n-->";
197   - return false;
198   - }
  67 + var $pessoa_logada;
  68 +
  69 + var $cod_compensado;
  70 + var $ref_cod_escola;
  71 + var $ref_cod_instituicao;
  72 + var $ref_cod_servidor;
  73 + var $ref_usuario_exc;
  74 + var $ref_usuario_cad;
  75 + var $data_inicio;
  76 + var $data_fim;
  77 + var $data_cadastro;
  78 + var $data_exclusao;
  79 + var $ativo;
  80 +
  81 + function Inicializar()
  82 + {
  83 + $retorno = 'Novo';
  84 + @session_start();
  85 + $this->pessoa_logada = $_SESSION['id_pessoa'];
  86 + @session_write_close();
  87 +
  88 + $this->cod_compensado = $_GET['cod_compensado'];
  89 + $this->ref_cod_servidor = $_GET['ref_cod_servidor'];
  90 + $this->ref_cod_escola = $_GET['ref_cod_escola'];
  91 + $this->ref_cod_instituicao = $_GET['ref_cod_instituicao'];
  92 +
  93 + $obj_permissoes = new clsPermissoes();
  94 + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7,
  95 + sprintf('educar_falta_atraso_det.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d',
  96 + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao));
  97 +
  98 + if (is_numeric($this->cod_compensado)) {
  99 + $obj = new clsPmieducarFaltaAtrasoCompensado($this->cod_compensado);
  100 + $registro = $obj->detalhe();
  101 +
  102 + if ($registro) {
  103 + // passa todos os valores obtidos no registro para atributos do objeto
  104 + foreach ($registro as $campo => $val) {
  105 + $this->$campo = $val;
  106 + }
  107 +
  108 + $this->data_inicio = dataFromPgToBr($this->data_inicio);
  109 + $this->data_fim = dataFromPgToBr($this->data_fim);
  110 + $this->data_cadastro = dataFromPgToBr($this->data_cadastro);
  111 + $this->data_exclusao = dataFromPgToBr($this->data_exclusao);
  112 +
  113 + $obj_permissoes = new clsPermissoes();
  114 + if ($obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 7)) {
  115 + $this->fexcluir = TRUE;
  116 + }
  117 +
  118 + $retorno = 'Editar';
  119 + }
  120 + }
  121 +
  122 + $this->url_cancelar = sprintf('educar_falta_atraso_det.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d',
  123 + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao);
  124 +
  125 + $this->nome_url_cancelar = 'Cancelar';
  126 + return $retorno;
  127 + }
  128 +
  129 + function Gerar()
  130 + {
  131 + // Primary keys
  132 + $this->campoOculto('cod_compensado', $this->cod_compensado);
  133 + $this->campoOculto('ref_cod_servidor', $this->ref_cod_servidor);
  134 +
  135 + // Foreign keys
  136 + $obrigatorio = TRUE;
  137 + $get_instituicao = TRUE;
  138 + $get_escola = TRUE;
  139 + include 'include/pmieducar/educar_campo_lista.php';
  140 +
  141 + // Data
  142 + $this->campoData('data_inicio', 'Data Inicio', $this->data_inicio, TRUE);
  143 + $this->campoData('data_fim', 'Data Fim', $this->data_fim, TRUE);
  144 + }
  145 +
  146 + function Novo()
  147 + {
  148 + @session_start();
  149 + $this->pessoa_logada = $_SESSION['id_pessoa'];
  150 + @session_write_close();
  151 +
  152 + $obj_permissoes = new clsPermissoes();
  153 + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7,
  154 + "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}");
  155 +
  156 + //
  157 + $this->data_inicio = dataToBanco($this->data_inicio);
  158 + $this->data_fim = dataToBanco($this->data_fim);
  159 +
  160 + $obj = new clsPmieducarFaltaAtrasoCompensado(NULL, $this->ref_cod_escola,
  161 + $this->ref_cod_instituicao, $this->ref_cod_servidor, $this->pessoa_logada,
  162 + $this->pessoa_logada, $this->data_inicio, $this->data_fim, NULL, NULL, 1);
  163 +
  164 + $cadastrou = $obj->cadastra();
  165 +
  166 + if ($cadastrou) {
  167 + $this->mensagem .= 'Cadastro efetuado com sucesso.<br />';
  168 + header('Location: ' . sprintf('educar_falta_atraso_det.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d',
  169 + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao));
  170 + die();
  171 + }
  172 +
  173 + $this->mensagem = 'Cadastro não realizado.<br />';
  174 + echo "<!--\nErro ao cadastrar clsPmieducarFaltaAtrasoCompensado\nvalores obrigatorios\nis_numeric( $this->ref_cod_escola ) && is_numeric( $this->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 )\n-->";
  175 + return FALSE;
  176 + }
  177 +
  178 + function Editar()
  179 + {
  180 + @session_start();
  181 + $this->pessoa_logada = $_SESSION['id_pessoa'];
  182 + @session_write_close();
  183 +
  184 + $obj_permissoes = new clsPermissoes();
  185 + $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7,
  186 + sprintf('educar_falta_atraso_det.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d',
  187 + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao));
  188 +
  189 + $obj = new clsPmieducarFaltaAtrasoCompensado($this->cod_compensado,
  190 + $this->ref_cod_escola, $this->ref_cod_instituicao, $this->ref_cod_servidor,
  191 + $this->pessoa_logada, $this->pessoa_logada, $this->data_inicio,
  192 + $this->data_fim, $this->data_cadastro, $this->data_exclusao, $this->ativo);
  193 +
  194 + $editou = $obj->edita();
  195 +
  196 + if ($editou) {
  197 + $this->mensagem .= 'Edição efetuada com sucesso.<br />';
  198 + header('Location: ' . sprintf('educar_falta_atraso_det.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d',
  199 + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao));
  200 + die();
  201 + }
  202 +
  203 + $this->mensagem = 'Edição não realizada.<br />';
  204 + echo "<!--\nErro ao editar clsPmieducarFaltaAtrasoCompensado\nvalores obrigatorios\nif( is_numeric( $this->cod_compensado ) && is_numeric( $this->ref_usuario_exc ) )\n-->";
  205 + return FALSE;
  206 + }
  207 +
  208 + function Excluir()
  209 + {
  210 + @session_start();
  211 + $this->pessoa_logada = $_SESSION['id_pessoa'];
  212 + @session_write_close();
  213 +
  214 + $obj_permissoes = new clsPermissoes();
  215 + $obj_permissoes->permissao_excluir(635, $this->pessoa_logada, 7,
  216 + sprintf('educar_falta_atraso_det.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d',
  217 + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_cod_instituicao));
  218 +
  219 + $obj = new clsPmieducarFaltaAtrasoCompensado($this->cod_compensado,
  220 + $this->ref_cod_escola, $this->ref_cod_instituicao, $this->ref_cod_servidor,
  221 + $this->pessoa_logada, $this->pessoa_logada, $this->data_inicio,
  222 + $this->data_fim, $this->data_cadastro, $this->data_exclusao, 0);
  223 +
  224 + $excluiu = $obj->excluir();
  225 +
  226 + if ($excluiu) {
  227 + $this->mensagem .= 'Exclusão efetuada com sucesso.<br />';
  228 + 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}");
  229 + die();
  230 + }
  231 +
  232 + $this->mensagem = 'Exclusão não realizada.<br />';
  233 + echo "<!--\nErro ao excluir clsPmieducarFaltaAtrasoCompensado\nvalores obrigatorios\nif( is_numeric( $this->cod_compensado ) && is_numeric( $this->ref_usuario_exc ) )\n-->";
  234 + return FALSE;
  235 + }
199 236 }
200 237  
201   -// cria uma extensao da classe base
  238 +// Instancia objeto de página
202 239 $pagina = new clsIndexBase();
203   -// cria o conteudo
  240 +
  241 +// Instancia objeto de conteúdo
204 242 $miolo = new indice();
205   -// adiciona o conteudo na clsBase
206   -$pagina->addForm( $miolo );
207   -// gera o html
208   -$pagina->MakeAll();
209   -?>
210 243 \ No newline at end of file
  244 +
  245 +// Atribui o conteúdo à página
  246 +$pagina->addForm($miolo);
  247 +
  248 +// Gera o código HTML
  249 +$pagina->MakeAll();
211 250 \ No newline at end of file
... ...
ieducar/intranet/educar_falta_atraso_det.php
1 1 <?php
2   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3   - * *
4   - * @author Prefeitura Municipal de Itajaí *
5   - * @updated 29/03/2007 *
6   - * Pacote: i-PLB Software Público Livre e Brasileiro *
7   - * *
8   - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí *
9   - * ctima@itajai.sc.gov.br *
10   - * *
11   - * Este programa é software livre, você pode redistribuí-lo e/ou *
12   - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme *
13   - * publicada pela Free Software Foundation, tanto a versão 2 da *
14   - * Licença como (a seu critério) qualquer versão mais nova. *
15   - * *
16   - * Este programa é distribuído na expectativa de ser útil, mas SEM *
17   - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- *
18   - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- *
19   - * sulte a Licença Pública Geral GNU para obter mais detalhes. *
20   - * *
21   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU *
22   - * junto com este programa. Se não, escreva para a Free Software *
23   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *
24   - * 02111-1307, USA. *
25   - * *
26   - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  2 +
27 3 /**
28   - * @author Adriano Erik Weiguert Nagasava
  4 + * i-Educar - Sistema de gestão escolar
  5 + *
  6 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  7 + * <ctima@itajai.sc.gov.br>
  8 + *
  9 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  10 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  11 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  12 + * qualquer versão posterior.
  13 + *
  14 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  15 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  16 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  17 + * do GNU para mais detalhes.
  18 + *
  19 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  20 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  21 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  22 + *
  23 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  24 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package iEd_Pmieducar
  27 + * @since Arquivo disponível desde a versão 1.0.0
  28 + * @version $Id$
29 29 */
30   -require_once ("include/clsBase.inc.php");
31   -require_once ("include/clsDetalhe.inc.php");
32   -require_once ("include/clsBanco.inc.php");
33   -require_once( "include/pmieducar/geral.inc.php" );
34 30  
  31 +require_once 'include/clsBase.inc.php';
  32 +require_once 'include/clsDetalhe.inc.php';
  33 +require_once 'include/clsBanco.inc.php';
  34 +require_once 'include/pmieducar/geral.inc.php';
  35 +
  36 +/**
  37 + * clsIndexBase class.
  38 + *
  39 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  40 + * @category i-Educar
  41 + * @license @@license@@
  42 + * @package iEd_Pmieducar
  43 + * @since Classe disponível desde a versão 1.0.0
  44 + * @version @@package_version@@
  45 + */
35 46 class clsIndexBase extends clsBase
36 47 {
37   - function Formular()
38   - {
39   - $this->SetTitulo( "{$this->_instituicao} i-Educar - Falta Atraso" );
40   - $this->processoAp = "635";
41   - }
  48 + function Formular()
  49 + {
  50 + $this->SetTitulo($this->_instituicao . ' i-Educar - Falta Atraso');
  51 + $this->processoAp = 635;
  52 + }
42 53 }
43 54  
  55 +/**
  56 + * indice class.
  57 + *
  58 + * @author Adriano Erik Weiguert Nagasava <ctima@itajai.sc.gov.br>
  59 + * @category i-Educar
  60 + * @license @@license@@
  61 + * @package iEd_Pmieducar
  62 + * @since Classe disponível desde a versão 1.0.0
  63 + * @version @@package_version@@
  64 + */
44 65 class indice extends clsDetalhe
45 66 {
46   - /**
47   - * Titulo no topo da pagina
48   - *
49   - * @var int
50   - */
51   - var $titulo;
52   -
53   - var $cod_falta_atraso;
54   - var $ref_cod_escola;
55   - var $ref_ref_cod_instituicao;
56   - var $ref_usuario_exc;
57   - var $ref_usuario_cad;
58   - var $ref_cod_servidor;
59   - var $tipo;
60   - var $data_falta_atraso;
61   - var $qtd_horas;
62   - var $qtd_min;
63   - var $justificada;
64   - var $data_cadastro;
65   - var $data_exclusao;
66   - var $ativo;
67   -
68   - function Gerar()
69   - {
70   - @session_start();
71   - $this->pessoa_logada = $_SESSION['id_pessoa'];
72   - session_write_close();
73   -
74   - $this->titulo = "Falta Atraso - Detalhe";
75   - $this->addBanner( "imagens/nvp_top_intranet.jpg", "imagens/nvp_vert_intranet.jpg", "Intranet" );
76   -
77   - $this->ref_cod_servidor = $_GET["ref_cod_servidor"];
78   - $this->ref_cod_escola = $_GET["ref_cod_escola"];
79   - $this->ref_ref_cod_instituicao = $_GET["ref_cod_instituicao"];
80   -
81   - $tmp_obj = new clsPmieducarFaltaAtraso();
82   - $tmp_obj->setOrderby( "data_falta_atraso DESC" );
83   - //$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 );
84   - //$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 );
85   - $this->cod_falta_atraso = $_GET['cod_falta_atraso'];
86   - $registro = $tmp_obj->lista($this->cod_falta_atraso);
87   -
88   - if( !$registro )
89   - {
90   - header( "location: educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_ref_cod_instituicao}" );
91   - die();
92   - }
93   - else {
94   - $tabela = "<TABLE>
95   - <TR align=center>
96   - <TD bgcolor=#A1B3BD><B>Dia</B></TD>
97   - <TD bgcolor=#A1B3BD><B>Tipo</B></TD>
98   - <TD bgcolor=#A1B3BD><B>Qtd. Horas</B></TD>
99   - <TD bgcolor=#A1B3BD><B>Qtd. Minutos</B></TD>
100   - <TD bgcolor=#A1B3BD><B>Escola</B></TD>
101   - <TD bgcolor=#A1B3BD><B>Institui&ccedil;&atilde;o</B></TD>
102   - </TR>";
103   - $cont = 0;
104   - $total = 0;
105   - foreach ( $registro as $falta ) {
106   - //$total += $divida["valor_multa"];
107   - if ( ($cont % 2) == 0 )
108   - $color = " bgcolor=#E4E9ED ";
109   - else
110   - $color = " bgcolor=#FFFFFF ";
111   - $obj_esc = new clsPmieducarEscolaComplemento( $falta["ref_cod_escola"] );
112   - $det_esc = $obj_esc->detalhe();
113   - $obj_ins = new clsPmieducarInstituicao( $falta["ref_ref_cod_instituicao"] );
114   - $det_ins = $obj_ins->detalhe();
115   - $corpo .= "<TR>
116   - <TD {$color} align=left>".dataFromPgToBr( $falta["data_falta_atraso"] )."</TD>
117   - <TD {$color} align=left>".( ( $falta["tipo"] == 1 ) ? "Atraso" : "Falta" )."</TD>
118   - <TD {$color} align=right>".$falta["qtd_horas"]."</TD>
119   - <TD {$color} align=right>".$falta["qtd_min"]."</TD>
120   - <TD {$color} align=left>".$det_esc["nm_escola"]."</TD>
121   - <TD {$color} align=left>".$det_ins["nm_instituicao"]."</TD>
122   - </TR>";
123   - $cont++;
124   - }
125   - $tabela .= $corpo;
126   - $tabela .= "</TABLE>";
127   - if ( $tabela )
128   - $this->addDetalhe( array( "Faltas/Atrasos", "{$tabela}") );
129   - }
130   -
131   - $obj_permissoes = new clsPermissoes();
132   - if( $obj_permissoes->permissao_cadastra( 635, $this->pessoa_logada, 7 ) )
133   - {
134   - $this->caption_novo = "Compensar";
135   - $this->url_editar = false;
136   - $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}";
137   - }
138   - $this->url_cancelar = "educar_falta_atraso_lst.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_ref_cod_instituicao}";
139   - $this->largura = "100%";
140   - }
  67 + var $titulo;
  68 +
  69 + var $cod_falta_atraso;
  70 + var $ref_cod_escola;
  71 + var $ref_ref_cod_instituicao;
  72 + var $ref_usuario_exc;
  73 + var $ref_usuario_cad;
  74 + var $ref_cod_servidor;
  75 + var $tipo;
  76 + var $data_falta_atraso;
  77 + var $qtd_horas;
  78 + var $qtd_min;
  79 + var $justificada;
  80 + var $data_cadastro;
  81 + var $data_exclusao;
  82 + var $ativo;
  83 +
  84 + function Gerar()
  85 + {
  86 + @session_start();
  87 + $this->pessoa_logada = $_SESSION['id_pessoa'];
  88 + session_write_close();
  89 +
  90 + $this->titulo = 'Falta Atraso - Detalhe';
  91 + $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg', 'Intranet');
  92 +
  93 + $this->ref_cod_servidor = $_GET['ref_cod_servidor'];
  94 + $this->ref_cod_escola = $_GET['ref_cod_escola'];
  95 + $this->ref_ref_cod_instituicao = $_GET['ref_cod_instituicao'];
  96 +
  97 + $tmp_obj = new clsPmieducarFaltaAtraso();
  98 + $tmp_obj->setOrderby('data_falta_atraso DESC');
  99 + $this->cod_falta_atraso = $_GET['cod_falta_atraso'];
  100 + $registro = $tmp_obj->lista($this->cod_falta_atraso);
  101 +
  102 + if (!$registro) {
  103 + header('Location: ' . sprintf(
  104 + 'educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d',
  105 + $this->ref_cod_servidor, $this->ref_ref_cod_instituicao));
  106 + die();
  107 + }
  108 + else {
  109 + $tabela = '<table>
  110 + <tr align=center>
  111 + <td bgcolor="#a1b3bd"><b>Dia</b></td>
  112 + <td bgcolor="#a1b3bd"><b>Tipo</b></td>
  113 + <td bgcolor="#a1b3bd"><b>Qtd. Horas</b></td>
  114 + <td bgcolor="#a1b3bd"><b>Qtd. Minutos</b></td>
  115 + <td bgcolor="#a1b3bd"><b>Escola</b></td>
  116 + <td bgcolor="#a1b3bd"><b>Instituição</b></td>
  117 + </tr>';
  118 +
  119 + $cont = 0;
  120 + $total = 0;
  121 +
  122 + foreach ($registro as $falta) {
  123 + if (($cont % 2) == 0) {
  124 + $color = ' bgcolor="#E4E9ED" ';
  125 + }
  126 + else {
  127 + $color = ' bgcolor="#FFFFFF" ';
  128 + }
  129 +
  130 + $obj_esc = new clsPmieducarEscolaComplemento($falta['ref_cod_escola']);
  131 + $det_esc = $obj_esc->detalhe();
  132 + $obj_ins = new clsPmieducarInstituicao($falta['ref_ref_cod_instituicao']);
  133 + $det_ins = $obj_ins->detalhe();
  134 +
  135 + $corpo .= sprintf('
  136 + <tr>
  137 + <td %s align="left">%s</td>
  138 + <td %s align="left">%s</td>
  139 + <td %s align="right">%s</td>
  140 + <td %s align="right">%s</td>
  141 + <td %s align="left">%s</td>
  142 + <td %s align="left">%s</td>
  143 + </tr>',
  144 + $color, dataFromPgToBr($falta['data_falta_atraso']),
  145 + $color, $falta['tipo'] == 1 ? 'Atraso' : 'Falta',
  146 + $color, $falta['qtd_horas'],
  147 + $color, $falta['qtd_min'],
  148 + $color, $det_esc['nm_escola'],
  149 + $color, $det_ins['nm_instituicao']);
  150 +
  151 + $cont++;
  152 + }
  153 +
  154 + $tabela .= $corpo;
  155 + $tabela .= "</table>";
  156 +
  157 + if ($tabela) {
  158 + $this->addDetalhe(array('Faltas/Atrasos', $tabela));
  159 + }
  160 + }
  161 +
  162 + $obj_permissoes = new clsPermissoes();
  163 +
  164 + if ($obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7)) {
  165 + $this->caption_novo = 'Compensar';
  166 + $this->url_editar = FALSE;
  167 + $this->url_novo = sprintf(
  168 + 'educar_falta_atraso_compensado_cad.php?ref_cod_servidor=%d&ref_cod_escola=%d&ref_cod_instituicao=%d',
  169 + $this->ref_cod_servidor, $this->ref_cod_escola, $this->ref_ref_cod_instituicao
  170 + );
  171 + }
  172 +
  173 + $this->url_cancelar = sprintf(
  174 + "educar_falta_atraso_lst.php?ref_cod_servidor=%d&ref_cod_instituicao=%d",
  175 + $this->ref_cod_servidor, $this->ref_ref_cod_instituicao
  176 + );
  177 +
  178 + $this->largura = '100%';
  179 + }
141 180 }
142 181  
143   -// cria uma extensao da classe base
  182 +// Instancia objeto de página
144 183 $pagina = new clsIndexBase();
145   -// cria o conteudo
  184 +
  185 +// Instancia objeto de conteúdo
146 186 $miolo = new indice();
147   -// adiciona o conteudo na clsBase
148   -$pagina->addForm( $miolo );
149   -// gera o html
150   -$pagina->MakeAll();
151   -?>
152 187 \ No newline at end of file
  188 +
  189 +// Atribui o conteúdo à página
  190 +$pagina->addForm($miolo);
  191 +
  192 +// Gera o código HTML
  193 +$pagina->MakeAll();
153 194 \ No newline at end of file
... ...
ieducar/intranet/educar_falta_atraso_lst.php
1 1 <?php
  2 +
2 3 /**
  4 + * i-Educar - Sistema de gestão escolar
3 5 *
4   - * @author Prefeitura Municipal de Itajaí
5   - * @version $Id$
6   - *
7   - * Pacote: i-PLB Software Público Livre e Brasileiro
  6 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  7 + * <ctima@itajai.sc.gov.br>
8 8 *
9   - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí
10   - * ctima@itajai.sc.gov.br
  9 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  10 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  11 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  12 + * qualquer versão posterior.
11 13 *
12   - * Este programa é software livre, você pode redistribuí-lo e/ou
13   - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme
14   - * publicada pela Free Software Foundation, tanto a versão 2 da
15   - * Licença como (a seu critério) qualquer versão mais nova.
  14 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  15 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  16 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  17 + * do GNU para mais detalhes.
16 18 *
17   - * Este programa é distribuído na expectativa de ser útil, mas SEM
18   - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI-
19   - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con-
20   - * sulte a Licença Pública Geral GNU para obter mais detalhes.
21   - *
22   - * Você deve ter recebido uma cópia da Licença Pública Geral GNU
23   - * junto com este programa. Se não, escreva para a Free Software
24   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25   - * 02111-1307, USA.
  19 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  20 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  21 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
26 22 *
  23 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  24 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package iEd_Pmieducar
  27 + * @since Arquivo disponível desde a versão 1.0.0
  28 + * @version $Id$
27 29 */
28 30  
29 31 require_once 'include/clsBase.inc.php';
... ... @@ -31,85 +33,77 @@ require_once &#39;include/clsListagem.inc.php&#39;;
31 33 require_once 'include/clsBanco.inc.php';
32 34 require_once 'include/pmieducar/geral.inc.php';
33 35  
34   -class clsIndexBase extends clsBase {
35   -
36   - public function Formular() {
37   - $this->SetTitulo( "{$this->_instituicao} i-Educar - Falta Atraso" );
38   - $this->processoAp = "635";
  36 +/**
  37 + * clsIndexBase class.
  38 + *
  39 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  40 + * @category i-Educar
  41 + * @license @@license@@
  42 + * @package iEd_Pmieducar
  43 + * @since Classe disponível desde a versão 1.0.0
  44 + * @version @@package_version@@
  45 + */
  46 +class clsIndexBase extends clsBase
  47 +{
  48 + public function Formular()
  49 + {
  50 + $this->SetTitulo($this->_instituicao . ' i-Educar - Falta Atraso');
  51 + $this->processoAp = 635;
39 52 }
40   -
41 53 }
42 54  
43   -
  55 +/**
  56 + * indice class.
  57 + *
  58 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  59 + * @category i-Educar
  60 + * @license @@license@@
  61 + * @package iEd_Pmieducar
  62 + * @since Classe disponível desde a versão 1.0.0
  63 + * @version @@package_version@@
  64 + */
44 65 class indice extends clsListagem
45 66 {
46   - /**
47   - * Referencia pega da session para o idpes do usuario atual
48   - *
49   - * @var int
50   - */
51   - public $pessoa_logada = 0;
52   -
53   - /**
54   - * Titulo no topo da pagina
55   - *
56   - * @var int
57   - */
58   - public $titulo = '';
59   -
60   - /**
61   - * Quantidade de registros a ser apresentada em cada pagina
62   - *
63   - * @var int
64   - */
65   - public $limite = 0;
66   -
67   - /**
68   - * Inicio dos registros a serem exibidos (limit)
69   - *
70   - * @var int
71   - */
72   - public $offset = 0;
73   -
74   - public
75   - $cod_falta_atraso = NULL,
76   - $ref_cod_escola = NULL,
77   - $ref_ref_cod_instituicao = NULL,
78   - $ref_usuario_exc = NULL,
79   - $ref_usuario_cad = NULL,
80   - $ref_cod_servidor = NULL,
81   - $tipo = NULL,
82   - $data_falta_atraso = NULL,
83   - $qtd_horas = NULL,
84   - $qtd_min = NULL,
85   - $justificada = NULL,
86   - $data_cadastro = NULL,
87   - $data_exclusao = NULL,
88   - $ativo = NULL;
89   -
90   -
91   -
92   - public function Gerar() {
  67 + var $pessoa_logada;
  68 + var $titulo;
  69 + var $limite;
  70 + var $offset;
  71 +
  72 + var $cod_falta_atraso = NULL;
  73 + var $ref_cod_escola = NULL;
  74 + var $ref_ref_cod_instituicao = NULL;
  75 + var $ref_usuario_exc = NULL;
  76 + var $ref_usuario_cad = NULL;
  77 + var $ref_cod_servidor = NULL;
  78 + var $tipo = NULL;
  79 + var $data_falta_atraso = NULL;
  80 + var $qtd_horas = NULL;
  81 + var $qtd_min = NULL;
  82 + var $justificada = NULL;
  83 + var $data_cadastro = NULL;
  84 + var $data_exclusao = NULL;
  85 + var $ativo = NULL;
  86 +
  87 + function Gerar()
  88 + {
93 89 session_start();
94 90 $this->pessoa_logada = $_SESSION['id_pessoa'];
95 91 session_write_close();
96 92  
97   - $this->ref_cod_servidor = isset($_GET['ref_cod_servidor']) ?
98   - $_GET['ref_cod_servidor'] : NULL;
99   - $this->ref_ref_cod_instituicao = isset($_GET['ref_cod_instituicao']) ?
100   - $_GET['ref_cod_instituicao'] : NULL;
  93 + $this->ref_cod_servidor = $_GET['ref_cod_servidor'];
  94 + $this->ref_ref_cod_instituicao = $_GET['ref_cod_instituicao'];
101 95  
102 96 $this->titulo = 'Faltas e atrasos - Listagem';
103 97  
104 98 foreach ($_GET as $var => $val) {
105   - $this->$var = ($val === "") ? NULL : $val;
  99 + $this->$var = ($val === '') ? NULL : $val;
106 100 }
107 101  
108 102 $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg', 'Intranet');
109 103  
110 104 $this->addCabecalhos(array(
111 105 'Escola',
112   - 'Instituic&atilde;o',
  106 + 'Instituição',
113 107 'Tipo',
114 108 'Horas',
115 109 'Minutos'
... ... @@ -192,29 +186,39 @@ class indice extends clsListagem
192 186 }
193 187 }
194 188  
195   - $this->addPaginador2('educar_falta_atraso_lst.php', $total, $_GET, $this->nome, $this->limite);
  189 + $this->addPaginador2('educar_falta_atraso_lst.php', $total, $_GET,
  190 + $this->nome, $this->limite);
196 191 $obj_permissoes = new clsPermissoes();
197 192  
198 193 if ($obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7)) {
199   - $this->array_botao[] = 'Novo';
200   - $this->array_botao_url[] = "educar_falta_atraso_cad.php?ref_cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_ref_cod_instituicao}";
  194 + $this->array_botao[] = 'Novo';
  195 +
  196 + $this->array_botao_url[] = sprintf(
  197 + 'educar_falta_atraso_cad.php?ref_cod_servidor=%d&ref_cod_instituicao=%d',
  198 + $this->ref_cod_servidor, $this->ref_ref_cod_instituicao
  199 + );
201 200 }
202 201  
203   - $this->array_botao[] = 'Voltar';
204   - $this->array_botao_url[] = "educar_servidor_det.php?cod_servidor={$this->ref_cod_servidor}&ref_cod_instituicao={$this->ref_cod_instituicao}";
205   - $this->largura = "100%";
  202 + $this->array_botao[] = 'Voltar';
  203 +
  204 + $this->array_botao_url[] = sprintf(
  205 + 'educar_servidor_det.php?cod_servidor=%d&ref_cod_instituicao=%d',
  206 + $this->ref_cod_servidor, $this->ref_cod_instituicao
  207 + );
  208 +
  209 + $this->largura = '100%';
206 210 }
207 211  
208 212 }
209 213  
210   -// cria uma extensao da classe base
  214 +// Instancia objeto de página
211 215 $pagina = new clsIndexBase();
212 216  
213   -// cria o conteudo
  217 +// Instancia objeto de conteúdo
214 218 $miolo = new indice();
215 219  
216   -// adiciona o conteudo na clsBase
217   -$pagina->addForm( $miolo );
  220 +// Atribui o conteúdo à página
  221 +$pagina->addForm($miolo);
218 222  
219   -// gera o html
  223 +// Gera o código HTML
220 224 $pagina->MakeAll();
221 225 \ No newline at end of file
... ...
ieducar/intranet/include/pmieducar/clsPmieducarFaltaAtraso.inc.php
1 1 <?php
2   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3   -* *
4   -* @author Prefeitura Municipal de Itajaí *
5   -* @updated 29/03/2007 *
6   -* Pacote: i-PLB Software Público Livre e Brasileiro *
7   -* *
8   -* Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí *
9   -* ctima@itajai.sc.gov.br *
10   -* *
11   -* Este programa é software livre, você pode redistribuí-lo e/ou *
12   -* modificá-lo sob os termos da Licença Pública Geral GNU, conforme *
13   -* publicada pela Free Software Foundation, tanto a versão 2 da *
14   -* Licença como (a seu critério) qualquer versão mais nova. *
15   -* *
16   -* Este programa é distribuído na expectativa de ser útil, mas SEM *
17   -* QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- *
18   -* ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- *
19   -* sulte a Licença Pública Geral GNU para obter mais detalhes. *
20   -* *
21   -* Você deve ter recebido uma cópia da Licença Pública Geral GNU *
22   -* junto com este programa. Se não, escreva para a Free Software *
23   -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *
24   -* 02111-1307, USA. *
25   -* *
26   -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27   -/**
28   -* @author Prefeitura Municipal de Itajaí
29   -*
30   -* Criado em 07/08/2006 14:45 pelo gerador automatico de classes
31   -*/
32 2  
33   -require_once( "include/pmieducar/geral.inc.php" );
  3 +/**
  4 + * i-Educar - Sistema de gestão escolar
  5 + *
  6 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  7 + * <ctima@itajai.sc.gov.br>
  8 + *
  9 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  10 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  11 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  12 + * qualquer versão posterior.
  13 + *
  14 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  15 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  16 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  17 + * do GNU para mais detalhes.
  18 + *
  19 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  20 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  21 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  22 + *
  23 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  24 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package iEd_Pmieducar
  27 + * @since Arquivo disponível desde a versão 1.0.0
  28 + * @version $Id$
  29 + */
  30 +
  31 +require_once 'include/pmieducar/geral.inc.php';
34 32  
  33 +/**
  34 + * clsPmieducarFaltaAtraso class.
  35 + *
  36 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  37 + * @category i-Educar
  38 + * @license @@license@@
  39 + * @package iEd_Pmieducar
  40 + * @since Classe disponível desde a versão 1.0.0
  41 + * @version @@package_version@@
  42 + */
35 43 class clsPmieducarFaltaAtraso
36 44 {
37   - var $cod_falta_atraso;
38   - var $ref_cod_escola;
39   - var $ref_ref_cod_instituicao;
40   - var $ref_usuario_exc;
41   - var $ref_usuario_cad;
42   - var $ref_cod_servidor;
43   - var $tipo;
44   - var $data_falta_atraso;
45   - var $qtd_horas;
46   - var $qtd_min;
47   - var $justificada;
48   - var $data_cadastro;
49   - var $data_exclusao;
50   - var $ativo;
51   -
52   - // propriedades padrao
53   -
54   - /**
55   - * Armazena o total de resultados obtidos na ultima chamada ao metodo lista
56   - *
57   - * @var int
58   - */
59   - var $_total;
60   -
61   - /**
62   - * Nome do schema
63   - *
64   - * @var string
65   - */
66   - var $_schema;
67   -
68   - /**
69   - * Nome da tabela
70   - *
71   - * @var string
72   - */
73   - var $_tabela;
74   -
75   - /**
76   - * Lista separada por virgula, com os campos que devem ser selecionados na proxima chamado ao metodo lista
77   - *
78   - * @var string
79   - */
80   - var $_campos_lista;
81   -
82   - /**
83   - * Lista com todos os campos da tabela separados por virgula, padrao para selecao no metodo lista
84   - *
85   - * @var string
86   - */
87   - var $_todos_campos;
88   -
89   - /**
90   - * Valor que define a quantidade de registros a ser retornada pelo metodo lista
91   - *
92   - * @var int
93   - */
94   - var $_limite_quantidade;
95   -
96   - /**
97   - * Define o valor de offset no retorno dos registros no metodo lista
98   - *
99   - * @var int
100   - */
101   - var $_limite_offset;
102   -
103   - /**
104   - * Define o campo padrao para ser usado como padrao de ordenacao no metodo lista
105   - *
106   - * @var string
107   - */
108   - var $_campo_order_by;
109   -
110   -
111   - /**
112   - * Construtor (PHP 4)
113   - *
114   - * @return object
115   - */
116   - 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 )
117   - {
118   - $db = new clsBanco();
119   - $this->_schema = "pmieducar.";
120   - $this->_tabela = "{$this->_schema}falta_atraso";
121   -
122   - $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";
123   -
124   - if( is_numeric( $ref_cod_escola ) )
125   - {
126   - if( class_exists( "clsPmieducarEscola" ) )
127   - {
128   - $tmp_obj = new clsPmieducarEscola( $ref_cod_escola );
129   - if( method_exists( $tmp_obj, "existe") )
130   - {
131   - if( $tmp_obj->existe() )
132   - {
133   - $this->ref_cod_escola = $ref_cod_escola;
134   - }
135   - }
136   - else if( method_exists( $tmp_obj, "detalhe") )
137   - {
138   - if( $tmp_obj->detalhe() )
139   - {
140   - $this->ref_cod_escola = $ref_cod_escola;
141   - }
142   - }
143   - }
144   - else
145   - {
146   - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.escola WHERE cod_escola = '{$ref_cod_escola}'" ) )
147   - {
148   - $this->ref_cod_escola = $ref_cod_escola;
149   - }
150   - }
151   - }
152   - if( is_numeric( $ref_usuario_cad ) )
153   - {
154   - if( class_exists( "clsPmieducarUsuario" ) )
155   - {
156   - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_cad );
157   - if( method_exists( $tmp_obj, "existe") )
158   - {
159   - if( $tmp_obj->existe() )
160   - {
161   - $this->ref_usuario_cad = $ref_usuario_cad;
162   - }
163   - }
164   - else if( method_exists( $tmp_obj, "detalhe") )
165   - {
166   - if( $tmp_obj->detalhe() )
167   - {
168   - $this->ref_usuario_cad = $ref_usuario_cad;
169   - }
170   - }
171   - }
172   - else
173   - {
174   - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'" ) )
175   - {
176   - $this->ref_usuario_cad = $ref_usuario_cad;
177   - }
178   - }
179   - }
180   - if( is_numeric( $ref_usuario_exc ) )
181   - {
182   - if( class_exists( "clsPmieducarUsuario" ) )
183   - {
184   - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_exc );
185   - if( method_exists( $tmp_obj, "existe") )
186   - {
187   - if( $tmp_obj->existe() )
188   - {
189   - $this->ref_usuario_exc = $ref_usuario_exc;
190   - }
191   - }
192   - else if( method_exists( $tmp_obj, "detalhe") )
193   - {
194   - if( $tmp_obj->detalhe() )
195   - {
196   - $this->ref_usuario_exc = $ref_usuario_exc;
197   - }
198   - }
199   - }
200   - else
201   - {
202   - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'" ) )
203   - {
204   - $this->ref_usuario_exc = $ref_usuario_exc;
205   - }
206   - }
207   - }
208   - if( is_numeric( $ref_cod_servidor ) && is_numeric( $ref_ref_cod_instituicao ) )
209   - {
210   - if( class_exists( "clsPmieducarServidor" ) )
211   - {
212   - $tmp_obj = new clsPmieducarServidor( $ref_cod_servidor, null, null, null, null, null, null, null, $ref_ref_cod_instituicao );
213   - if( method_exists( $tmp_obj, "existe") )
214   - {
215   - if( $tmp_obj->existe() )
216   - {
217   - $this->ref_cod_servidor = $ref_cod_servidor;
218   - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
219   - }
220   - }
221   - else if( method_exists( $tmp_obj, "detalhe") )
222   - {
223   - if( $tmp_obj->detalhe() )
224   - {
225   - $this->ref_cod_servidor = $ref_cod_servidor;
226   - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
227   - }
228   - }
229   - $this->ref_cod_servidor = $ref_cod_servidor;
230   - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
231   - }
232   - else
233   - {
234   - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_cod_servidor}' AND ref_cod_instituicao = '{$ref_ref_cod_instituicao}'" ) )
235   - {
236   - $this->ref_cod_servidor = $ref_cod_servidor;
237   - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
238   - }
239   - }
240   - }
241   -
242   -
243   - if( is_numeric( $cod_falta_atraso ) )
244   - {
245   - $this->cod_falta_atraso = $cod_falta_atraso;
246   - }
247   - if( is_numeric( $tipo ) )
248   - {
249   - $this->tipo = $tipo;
250   - }
251   - if( is_string( $data_falta_atraso ) )
252   - {
253   - $this->data_falta_atraso = $data_falta_atraso;
254   - }
255   - if( is_numeric( $qtd_horas ) )
256   - {
257   - $this->qtd_horas = $qtd_horas;
258   - }
259   - if( is_numeric( $qtd_min ) )
260   - {
261   - $this->qtd_min = $qtd_min;
262   - }
263   - if( is_numeric( $justificada ) )
264   - {
265   - $this->justificada = $justificada;
266   - }
267   - if( is_string( $data_cadastro ) )
268   - {
269   - $this->data_cadastro = $data_cadastro;
270   - }
271   - if( is_string( $data_exclusao ) )
272   - {
273   - $this->data_exclusao = $data_exclusao;
274   - }
275   - if( is_numeric( $ativo ) )
276   - {
277   - $this->ativo = $ativo;
278   - }
279   -
280   - }
281   -
282   - /**
283   - * Cria um novo registro
284   - *
285   - * @return bool
286   - */
287   - function cadastra()
288   - {
289   - 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 ) )
290   - {
291   - $db = new clsBanco();
292   -
293   - $campos = "";
294   - $valores = "";
295   - $gruda = "";
296   -
297   - if( is_numeric( $this->ref_cod_escola ) )
298   - {
299   - $campos .= "{$gruda}ref_cod_escola";
300   - $valores .= "{$gruda}'{$this->ref_cod_escola}'";
301   - $gruda = ", ";
302   - }
303   - if( is_numeric( $this->ref_ref_cod_instituicao ) )
304   - {
305   - $campos .= "{$gruda}ref_ref_cod_instituicao";
306   - $valores .= "{$gruda}'{$this->ref_ref_cod_instituicao}'";
307   - $gruda = ", ";
308   - }
309   - if( is_numeric( $this->ref_usuario_cad ) )
310   - {
311   - $campos .= "{$gruda}ref_usuario_cad";
312   - $valores .= "{$gruda}'{$this->ref_usuario_cad}'";
313   - $gruda = ", ";
314   - }
315   - if( is_numeric( $this->ref_cod_servidor ) )
316   - {
317   - $campos .= "{$gruda}ref_cod_servidor";
318   - $valores .= "{$gruda}'{$this->ref_cod_servidor}'";
319   - $gruda = ", ";
320   - }
321   - if( is_numeric( $this->tipo ) )
322   - {
323   - $campos .= "{$gruda}tipo";
324   - $valores .= "{$gruda}'{$this->tipo}'";
325   - $gruda = ", ";
326   - }
327   - if( is_string( $this->data_falta_atraso ) )
328   - {
329   - $campos .= "{$gruda}data_falta_atraso";
330   - $valores .= "{$gruda}'{$this->data_falta_atraso}'";
331   - $gruda = ", ";
332   - }
333   - if( is_numeric( $this->qtd_horas ) )
334   - {
335   - $campos .= "{$gruda}qtd_horas";
336   - $valores .= "{$gruda}'{$this->qtd_horas}'";
337   - $gruda = ", ";
338   - }
339   - if( is_numeric( $this->qtd_min ) )
340   - {
341   - $campos .= "{$gruda}qtd_min";
342   - $valores .= "{$gruda}'{$this->qtd_min}'";
343   - $gruda = ", ";
344   - }
345   - if( is_numeric( $this->justificada ) )
346   - {
347   - $campos .= "{$gruda}justificada";
348   - $valores .= "{$gruda}'{$this->justificada}'";
349   - $gruda = ", ";
350   - }
351   - $campos .= "{$gruda}data_cadastro";
352   - $valores .= "{$gruda}NOW()";
353   - $gruda = ", ";
354   - $campos .= "{$gruda}ativo";
355   - $valores .= "{$gruda}'1'";
356   - $gruda = ", ";
357   -
358   -
359   - $db->Consulta( "INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )" );
360   - return $db->InsertId( "{$this->_tabela}_cod_falta_atraso_seq");
361   - }
362   - return false;
363   - }
364   -
365   - /**
366   - * Edita os dados de um registro
367   - *
368   - * @return bool
369   - */
370   - function edita()
371   - {
372   - if( is_numeric( $this->cod_falta_atraso ) && is_numeric( $this->ref_usuario_exc ) )
373   - {
374   -
375   - $db = new clsBanco();
376   - $set = "";
377   -
378   - if( is_numeric( $this->ref_cod_escola ) )
379   - {
380   - $set .= "{$gruda}ref_cod_escola = '{$this->ref_cod_escola}'";
381   - $gruda = ", ";
382   - }
383   - if( is_numeric( $this->ref_ref_cod_instituicao ) )
384   - {
385   - $set .= "{$gruda}ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}'";
386   - $gruda = ", ";
387   - }
388   - if( is_numeric( $this->ref_usuario_exc ) )
389   - {
390   - $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'";
391   - $gruda = ", ";
392   - }
393   - if( is_numeric( $this->ref_usuario_cad ) )
394   - {
395   - $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'";
396   - $gruda = ", ";
397   - }
398   - if( is_numeric( $this->ref_cod_servidor ) )
399   - {
400   - $set .= "{$gruda}ref_cod_servidor = '{$this->ref_cod_servidor}'";
401   - $gruda = ", ";
402   - }
403   - if( is_numeric( $this->tipo ) )
404   - {
405   - $set .= "{$gruda}tipo = '{$this->tipo}'";
406   - $gruda = ", ";
407   - }
408   - if( is_string( $this->data_falta_atraso ) )
409   - {
410   - $set .= "{$gruda}data_falta_atraso = '{$this->data_falta_atraso}'";
411   - $gruda = ", ";
412   - }
413   - if( is_numeric( $this->qtd_horas ) )
414   - {
415   - $set .= "{$gruda}qtd_horas = '{$this->qtd_horas}'";
416   - $gruda = ", ";
417   - }
418   - if( is_numeric( $this->qtd_min ) )
419   - {
420   - $set .= "{$gruda}qtd_min = '{$this->qtd_min}'";
421   - $gruda = ", ";
422   - }
423   - if( is_numeric( $this->justificada ) )
424   - {
425   - $set .= "{$gruda}justificada = '{$this->justificada}'";
426   - $gruda = ", ";
427   - }
428   - if( is_string( $this->data_cadastro ) )
429   - {
430   - $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'";
431   - $gruda = ", ";
432   - }
433   - $set .= "{$gruda}data_exclusao = NOW()";
434   - $gruda = ", ";
435   - if( is_numeric( $this->ativo ) )
436   - {
437   - $set .= "{$gruda}ativo = '{$this->ativo}'";
438   - $gruda = ", ";
439   - }
440   -
441   -
442   - if( $set )
443   - {
444   - $db->Consulta( "UPDATE {$this->_tabela} SET $set WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'" );
445   - return true;
446   - }
447   - }
448   - return false;
449   - }
450   -
451   - /**
452   - * Retorna uma lista filtrados de acordo com os parametros
453   - *
454   - * @return array
455   - */
456   - 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 )
457   - {
458   - $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}";
459   - $filtros = "";
460   -
461   - $whereAnd = " WHERE ";
462   -
463   - if( is_numeric( $int_cod_falta_atraso ) )
464   - {
465   - $filtros .= "{$whereAnd} cod_falta_atraso = '{$int_cod_falta_atraso}'";
466   - $whereAnd = " AND ";
467   - }
468   - if( is_numeric( $int_ref_cod_escola ) )
469   - {
470   - $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'";
471   - $whereAnd = " AND ";
472   - }
473   - if( is_numeric( $int_ref_ref_cod_instituicao ) )
474   - {
475   - $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'";
476   - $whereAnd = " AND ";
477   - }
478   - if( is_numeric( $int_ref_usuario_exc ) )
479   - {
480   - $filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'";
481   - $whereAnd = " AND ";
482   - }
483   - if( is_numeric( $int_ref_usuario_cad ) )
484   - {
485   - $filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'";
486   - $whereAnd = " AND ";
487   - }
488   - if( is_numeric( $int_ref_cod_servidor ) )
489   - {
490   - $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'";
491   - $whereAnd = " AND ";
492   - }
493   - if( is_numeric( $int_tipo ) )
494   - {
495   - $filtros .= "{$whereAnd} tipo = '{$int_tipo}'";
496   - $whereAnd = " AND ";
497   - }
498   - if( is_string( $date_data_falta_atraso_ini ) )
499   - {
500   - $filtros .= "{$whereAnd} data_falta_atraso >= '{$date_data_falta_atraso_ini}'";
501   - $whereAnd = " AND ";
502   - }
503   - if( is_string( $date_data_falta_atraso_fim ) )
504   - {
505   - $filtros .= "{$whereAnd} data_falta_atraso <= '{$date_data_falta_atraso_fim}'";
506   - $whereAnd = " AND ";
507   - }
508   - if( is_numeric( $int_qtd_horas ) )
509   - {
510   - $filtros .= "{$whereAnd} qtd_horas = '{$int_qtd_horas}'";
511   - $whereAnd = " AND ";
512   - }
513   - if( is_numeric( $int_qtd_min ) )
514   - {
515   - $filtros .= "{$whereAnd} qtd_min = '{$int_qtd_min}'";
516   - $whereAnd = " AND ";
517   - }
518   - if( is_numeric( $int_justificada ) )
519   - {
520   - $filtros .= "{$whereAnd} justificada = '{$int_justificada}'";
521   - $whereAnd = " AND ";
522   - }
523   - if( is_string( $date_data_cadastro_ini ) )
524   - {
525   - $filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'";
526   - $whereAnd = " AND ";
527   - }
528   - if( is_string( $date_data_cadastro_fim ) )
529   - {
530   - $filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'";
531   - $whereAnd = " AND ";
532   - }
533   - if( is_string( $date_data_exclusao_ini ) )
534   - {
535   - $filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'";
536   - $whereAnd = " AND ";
537   - }
538   - if( is_string( $date_data_exclusao_fim ) )
539   - {
540   - $filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'";
541   - $whereAnd = " AND ";
542   - }
543   - if( is_null( $int_ativo ) || $int_ativo )
544   - {
545   - $filtros .= "{$whereAnd} ativo = '1'";
546   - $whereAnd = " AND ";
547   - }
548   - else
549   - {
550   - $filtros .= "{$whereAnd} ativo = '0'";
551   - $whereAnd = " AND ";
552   - }
553   -
554   -
555   - $db = new clsBanco();
556   - $countCampos = count( explode( ",", $this->_campos_lista ) );
557   - $resultado = array();
558   -
559   - $sql .= $filtros . $this->getOrderby() . $this->getLimite();
560   -
561   - $this->_total = $db->CampoUnico( "SELECT COUNT(0) FROM {$this->_tabela} {$filtros}" );
562   -
563   - $db->Consulta( $sql );
564   -
565   - if( $countCampos > 1 )
566   - {
567   - while ( $db->ProximoRegistro() )
568   - {
569   - $tupla = $db->Tupla();
570   -
571   - $tupla["_total"] = $this->_total;
572   - $resultado[] = $tupla;
573   - }
574   - }
575   - else
576   - {
577   - while ( $db->ProximoRegistro() )
578   - {
579   - $tupla = $db->Tupla();
580   - $resultado[] = $tupla[$this->_campos_lista];
581   - }
582   - }
583   - if( count( $resultado ) )
584   - {
585   - return $resultado;
586   - }
587   - return false;
588   - }
589   -
590   - /**
591   - * Retorna um array com os dados de um registro
592   - *
593   - * @return array
594   - */
595   - function detalhe()
596   - {
597   - if( is_numeric( $this->cod_falta_atraso ) )
598   - {
599   -
600   - $db = new clsBanco();
601   - $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'" );
602   - $db->ProximoRegistro();
603   - return $db->Tupla();
604   - }
605   - return false;
606   - }
607   -
608   - /**
609   - * Retorna um array com os dados de um registro
610   - *
611   - * @return array
612   - */
613   - function existe()
614   - {
615   - if( is_numeric( $this->cod_falta_atraso ) )
616   - {
617   -
618   - $db = new clsBanco();
619   - $db->Consulta( "SELECT 1 FROM {$this->_tabela} WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'" );
620   - $db->ProximoRegistro();
621   - return $db->Tupla();
622   - }
623   - return false;
624   - }
625   -
626   - /**
627   - * Exclui um registro
628   - *
629   - * @return bool
630   - */
631   - function excluir()
632   - {
633   - if( is_numeric( $this->cod_falta_atraso ) && is_numeric( $this->ref_usuario_exc ) )
634   - {
635   -
636   - /*
637   - delete
638   - $db = new clsBanco();
639   - $db->Consulta( "DELETE FROM {$this->_tabela} WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'" );
640   - return true;
641   - */
642   -
643   - $this->ativo = 0;
644   - return $this->edita();
645   - }
646   - return false;
647   - }
648   -
649   - /**
650   - * Define quais campos da tabela serao selecionados na invocacao do metodo lista
651   - *
652   - * @return null
653   - */
654   - function setCamposLista( $str_campos )
655   - {
656   - $this->_campos_lista = $str_campos;
657   - }
658   -
659   - /**
660   - * Define que o metodo Lista devera retornoar todos os campos da tabela
661   - *
662   - * @return null
663   - */
664   - function resetCamposLista()
665   - {
666   - $this->_campos_lista = $this->_todos_campos;
667   - }
668   -
669   - /**
670   - * Define limites de retorno para o metodo lista
671   - *
672   - * @return null
673   - */
674   - function setLimite( $intLimiteQtd, $intLimiteOffset = null )
675   - {
676   - $this->_limite_quantidade = $intLimiteQtd;
677   - $this->_limite_offset = $intLimiteOffset;
678   - }
679   -
680   - /**
681   - * Retorna a string com o trecho da query resposavel pelo Limite de registros
682   - *
683   - * @return string
684   - */
685   - function getLimite()
686   - {
687   - if( is_numeric( $this->_limite_quantidade ) )
688   - {
689   - $retorno = " LIMIT {$this->_limite_quantidade}";
690   - if( is_numeric( $this->_limite_offset ) )
691   - {
692   - $retorno .= " OFFSET {$this->_limite_offset} ";
693   - }
694   - return $retorno;
695   - }
696   - return "";
697   - }
698   -
699   - /**
700   - * Define campo para ser utilizado como ordenacao no metolo lista
701   - *
702   - * @return null
703   - */
704   - function setOrderby( $strNomeCampo )
705   - {
706   - // limpa a string de possiveis erros (delete, insert, etc)
707   - //$strNomeCampo = eregi_replace();
708   -
709   - if( is_string( $strNomeCampo ) && $strNomeCampo )
710   - {
711   - $this->_campo_order_by = $strNomeCampo;
712   - }
713   - }
714   -
715   - /**
716   - * Retorna a string com o trecho da query resposavel pela Ordenacao dos registros
717   - *
718   - * @return string
719   - */
720   - function getOrderby()
721   - {
722   - if( is_string( $this->_campo_order_by ) )
723   - {
724   - return " ORDER BY {$this->_campo_order_by} ";
725   - }
726   - return "";
727   - }
728   -
729   - /**
730   - * Retorna uma lista filtrados de acordo com os parametros
731   - *
732   - * @return array
733   - */
734   - function listaHorasEscola( $int_ref_cod_servidor = null, $int_ref_ref_cod_instituicao = null, $int_ref_cod_escola = null )
735   - {
736   - $sql = "SELECT sum( qtd_horas ) AS horas,
737   - sum( qtd_min ) AS minutos,
738   - ref_cod_escola,
739   - ref_ref_cod_instituicao
740   - FROM {$this->_tabela}";
741   - $filtros = "";
742   -
743   - $whereAnd = " WHERE ";
744   -
745   - if( is_numeric( $int_ref_cod_servidor ) )
746   - {
747   - $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'";
748   - $whereAnd = " AND ";
749   - }
750   - if( is_numeric( $int_ref_cod_escola ) )
751   - {
752   - $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'";
753   - $whereAnd = " AND ";
754   - }
755   - if( is_numeric( $int_ref_ref_cod_instituicao ) )
756   - {
757   - $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'";
758   - $whereAnd = " AND ";
759   - }
760   - $filtros .= "{$whereAnd} justificada <> '0'";
761   - $whereAnd = " AND ";
762   - $filtros .= "{$whereAnd} ativo <> '0'";
763   - $whereAnd = " AND ";
764   -
765   - $groupBy = " GROUP BY ref_cod_escola, ref_ref_cod_instituicao";
766   -
767   -
768   - $db = new clsBanco();
769   - $countCampos = count( explode( ",", $this->_campos_lista ) );
770   - $resultado = array();
771   -
772   - $this->_total = $db->CampoUnico( "SELECT COUNT( 0 ) FROM ( {$sql}{$filtros}{$groupBy} ) AS countsubquery" );
773   -
774   - $sql .= $filtros . $groupBy . $this->getLimite();
775   -
776   -
777   - $db->Consulta( $sql );
778   -
779   - if( $countCampos > 1 )
780   - {
781   - while ( $db->ProximoRegistro() )
782   - {
783   - $tupla = $db->Tupla();
784   -
785   - $tupla["_total"] = $this->_total;
786   - $resultado[] = $tupla;
787   - }
788   - }
789   - else
790   - {
791   - while ( $db->ProximoRegistro() )
792   - {
793   - $tupla = $db->Tupla();
794   - $resultado[] = $tupla[$this->_campos_lista];
795   - }
796   - }
797   - if( count( $resultado ) )
798   - {
799   - return $resultado;
800   - }
801   - return false;
802   - }
803   -}
804   -?>
805 45 \ No newline at end of file
  46 + var $cod_falta_atraso;
  47 + var $ref_cod_escola;
  48 + var $ref_ref_cod_instituicao;
  49 + var $ref_usuario_exc;
  50 + var $ref_usuario_cad;
  51 + var $ref_cod_servidor;
  52 + var $tipo;
  53 + var $data_falta_atraso;
  54 + var $qtd_horas;
  55 + var $qtd_min;
  56 + var $justificada;
  57 + var $data_cadastro;
  58 + var $data_exclusao;
  59 + var $ativo;
  60 +
  61 + /**
  62 + * Armazena o total de resultados obtidos na última chamada ao método lista().
  63 + * @var int
  64 + */
  65 + var $_total;
  66 +
  67 + /**
  68 + * Nome do schema.
  69 + * @var string
  70 + */
  71 + var $_schema;
  72 +
  73 + /**
  74 + * Nome da tabela.
  75 + * @var string
  76 + */
  77 + var $_tabela;
  78 +
  79 + /**
  80 + * Lista separada por vírgula, com os campos que devem ser selecionados na
  81 + * próxima chamado ao método lista().
  82 + * @var string
  83 + */
  84 + var $_campos_lista;
  85 +
  86 + /**
  87 + * Lista com todos os campos da tabela separados por vírgula, padrão para
  88 + * seleção no método lista.
  89 + * @var string
  90 + */
  91 + var $_todos_campos;
  92 +
  93 + /**
  94 + * Valor que define a quantidade de registros a ser retornada pelo método lista().
  95 + * @var int
  96 + */
  97 + var $_limite_quantidade;
  98 +
  99 + /**
  100 + * Define o valor de offset no retorno dos registros no método lista().
  101 + * @var int
  102 + */
  103 + var $_limite_offset;
  104 +
  105 + /**
  106 + * Define o campo para ser usado como padrão de ordenação no método lista().
  107 + * @var string
  108 + */
  109 + var $_campo_order_by;
  110 +
  111 + /**
  112 + * Construtor.
  113 + */
  114 + function clsPmieducarFaltaAtraso($cod_falta_atraso = NULL, $ref_cod_escola = NULL,
  115 + $ref_ref_cod_instituicao = NULL, $ref_usuario_exc = NULL, $ref_usuario_cad = NULL,
  116 + $ref_cod_servidor = NULL, $tipo = NULL, $data_falta_atraso = NULL,
  117 + $qtd_horas = NULL, $qtd_min = NULL, $justificada = NULL, $data_cadastro = NULL,
  118 + $data_exclusao = NULL, $ativo = NULL)
  119 + {
  120 + $db = new clsBanco();
  121 + $this->_schema = 'pmieducar.';
  122 + $this->_tabela = $this->_schema . 'falta_atraso';
  123 +
  124 + $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';
  125 +
  126 + if (is_numeric($ref_cod_escola)) {
  127 + if (class_exists('clsPmieducarEscola')) {
  128 + $tmp_obj = new clsPmieducarEscola($ref_cod_escola);
  129 + if (method_exists($tmp_obj, 'existe')) {
  130 + if ($tmp_obj->existe()) {
  131 + $this->ref_cod_escola = $ref_cod_escola;
  132 + }
  133 + }
  134 + elseif (method_exists($tmp_obj, 'detalhe')) {
  135 + if ($tmp_obj->detalhe()) {
  136 + $this->ref_cod_escola = $ref_cod_escola;
  137 + }
  138 + }
  139 + }
  140 + else {
  141 + if ($db->CampoUnico("SELECT 1 FROM pmieducar.escola WHERE cod_escola = '{$ref_cod_escola}'")) {
  142 + $this->ref_cod_escola = $ref_cod_escola;
  143 + }
  144 + }
  145 + }
  146 +
  147 + if (is_numeric($ref_usuario_cad)) {
  148 + if (class_exists('clsPmieducarUsuario')) {
  149 + $tmp_obj = new clsPmieducarUsuario($ref_usuario_cad);
  150 + if (method_exists($tmp_obj, 'existe')) {
  151 + if ($tmp_obj->existe()) {
  152 + $this->ref_usuario_cad = $ref_usuario_cad;
  153 + }
  154 + }
  155 + elseif (method_exists($tmp_obj, 'detalhe')) {
  156 + if ($tmp_obj->detalhe()) {
  157 + $this->ref_usuario_cad = $ref_usuario_cad;
  158 + }
  159 + }
  160 + }
  161 + else {
  162 + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'")) {
  163 + $this->ref_usuario_cad = $ref_usuario_cad;
  164 + }
  165 + }
  166 + }
  167 +
  168 + if (is_numeric($ref_usuario_exc)) {
  169 + if (class_exists('clsPmieducarUsuario')) {
  170 + $tmp_obj = new clsPmieducarUsuario( $ref_usuario_exc );
  171 + if (method_exists( $tmp_obj, 'existe')) {
  172 + if ($tmp_obj->existe()) {
  173 + $this->ref_usuario_exc = $ref_usuario_exc;
  174 + }
  175 + }
  176 + elseif (method_exists($tmp_obj, 'detalhe')) {
  177 + if ($tmp_obj->detalhe()) {
  178 + $this->ref_usuario_exc = $ref_usuario_exc;
  179 + }
  180 + }
  181 + }
  182 + else {
  183 + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'")) {
  184 + $this->ref_usuario_exc = $ref_usuario_exc;
  185 + }
  186 + }
  187 + }
  188 +
  189 + if (is_numeric($ref_cod_servidor) && is_numeric($ref_ref_cod_instituicao)) {
  190 + if (class_exists('clsPmieducarServidor')) {
  191 + $tmp_obj = new clsPmieducarServidor($ref_cod_servidor, NULL, NULL, NULL,
  192 + NULL, NULL, NULL, NULL, $ref_ref_cod_instituicao);
  193 +
  194 + if (method_exists($tmp_obj, 'existe')) {
  195 + if ($tmp_obj->existe() ) {
  196 + $this->ref_cod_servidor = $ref_cod_servidor;
  197 + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
  198 + }
  199 + }
  200 + elseif (method_exists($tmp_obj, 'detalhe')) {
  201 + if ($tmp_obj->detalhe()) {
  202 + $this->ref_cod_servidor = $ref_cod_servidor;
  203 + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
  204 + }
  205 + }
  206 +
  207 + $this->ref_cod_servidor = $ref_cod_servidor;
  208 + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
  209 + }
  210 + else {
  211 + if ($db->CampoUnico("SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_cod_servidor}' AND ref_cod_instituicao = '{$ref_ref_cod_instituicao}'")) {
  212 + $this->ref_cod_servidor = $ref_cod_servidor;
  213 + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
  214 + }
  215 + }
  216 + }
  217 +
  218 + if (is_numeric($cod_falta_atraso)) {
  219 + $this->cod_falta_atraso = $cod_falta_atraso;
  220 + }
  221 +
  222 + if (is_numeric($tipo)) {
  223 + $this->tipo = $tipo;
  224 + }
  225 +
  226 + if (is_string($data_falta_atraso)) {
  227 + $this->data_falta_atraso = $data_falta_atraso;
  228 + }
  229 +
  230 + if (is_numeric($qtd_horas)) {
  231 + $this->qtd_horas = $qtd_horas;
  232 + }
  233 +
  234 + if (is_numeric($qtd_min)) {
  235 + $this->qtd_min = $qtd_min;
  236 + }
  237 +
  238 + if (is_numeric($justificada)) {
  239 + $this->justificada = $justificada;
  240 + }
  241 +
  242 + if (is_string($data_cadastro)) {
  243 + $this->data_cadastro = $data_cadastro;
  244 + }
  245 +
  246 + if (is_string($data_exclusao)) {
  247 + $this->data_exclusao = $data_exclusao;
  248 + }
  249 +
  250 + if (is_numeric($ativo)) {
  251 + $this->ativo = $ativo;
  252 + }
  253 + }
  254 +
  255 + /**
  256 + * Cria um novo registro.
  257 + * @return bool
  258 + */
  259 + function cadastra()
  260 + {
  261 + if (is_numeric($this->ref_cod_escola) &&
  262 + is_numeric($this->ref_ref_cod_instituicao) && is_numeric($this->ref_usuario_cad) &&
  263 + is_numeric($this->ref_cod_servidor) && is_numeric($this->tipo) &&
  264 + is_string($this->data_falta_atraso) && is_numeric($this->justificada)
  265 + ) {
  266 + $db = new clsBanco();
  267 +
  268 + $campos = '';
  269 + $valores = '';
  270 + $gruda = '';
  271 +
  272 + if (is_numeric( $this->ref_cod_escola)) {
  273 + $campos .= "{$gruda}ref_cod_escola";
  274 + $valores .= "{$gruda}'{$this->ref_cod_escola}'";
  275 + $gruda = ', ';
  276 + }
  277 +
  278 + if (is_numeric( $this->ref_ref_cod_instituicao)) {
  279 + $campos .= "{$gruda}ref_ref_cod_instituicao";
  280 + $valores .= "{$gruda}'{$this->ref_ref_cod_instituicao}'";
  281 + $gruda = ', ';
  282 + }
  283 +
  284 + if (is_numeric( $this->ref_usuario_cad)) {
  285 + $campos .= "{$gruda}ref_usuario_cad";
  286 + $valores .= "{$gruda}'{$this->ref_usuario_cad}'";
  287 + $gruda = ', ';
  288 + }
  289 +
  290 + if (is_numeric( $this->ref_cod_servidor)) {
  291 + $campos .= "{$gruda}ref_cod_servidor";
  292 + $valores .= "{$gruda}'{$this->ref_cod_servidor}'";
  293 + $gruda = ', ';
  294 + }
  295 +
  296 + if (is_numeric( $this->tipo)) {
  297 + $campos .= "{$gruda}tipo";
  298 + $valores .= "{$gruda}'{$this->tipo}'";
  299 + $gruda = ', ';
  300 + }
  301 +
  302 + if (is_string( $this->data_falta_atraso)) {
  303 + $campos .= "{$gruda}data_falta_atraso";
  304 + $valores .= "{$gruda}'{$this->data_falta_atraso}'";
  305 + $gruda = ', ';
  306 + }
  307 +
  308 + if (is_numeric( $this->qtd_horas)) {
  309 + $campos .= "{$gruda}qtd_horas";
  310 + $valores .= "{$gruda}'{$this->qtd_horas}'";
  311 + $gruda = ', ';
  312 + }
  313 +
  314 + if (is_numeric( $this->qtd_min)) {
  315 + $campos .= "{$gruda}qtd_min";
  316 + $valores .= "{$gruda}'{$this->qtd_min}'";
  317 + $gruda = ', ';
  318 + }
  319 +
  320 + if (is_numeric( $this->justificada)) {
  321 + $campos .= "{$gruda}justificada";
  322 + $valores .= "{$gruda}'{$this->justificada}'";
  323 + $gruda = ', ';
  324 + }
  325 +
  326 + $campos .= "{$gruda}data_cadastro";
  327 + $valores .= "{$gruda}NOW()";
  328 + $gruda = ', ';
  329 +
  330 + $campos .= "{$gruda}ativo";
  331 + $valores .= "{$gruda}'1'";
  332 + $gruda = ', ';
  333 +
  334 + $db->Consulta("INSERT INTO {$this->_tabela} ($campos) VALUES($valores)");
  335 + return $db->InsertId("{$this->_tabela}_cod_falta_atraso_seq");
  336 + }
  337 +
  338 + return FALSE;
  339 + }
  340 +
  341 + /**
  342 + * Edita os dados de um registro.
  343 + * @return bool
  344 + */
  345 + function edita()
  346 + {
  347 + if (is_numeric($this->cod_falta_atraso) && is_numeric($this->ref_usuario_exc)){
  348 + $db = new clsBanco();
  349 + $set = '';
  350 +
  351 + if (is_numeric($this->ref_cod_escola)) {
  352 + $set .= "{$gruda}ref_cod_escola = '{$this->ref_cod_escola}'";
  353 + $gruda = ', ';
  354 + }
  355 +
  356 + if (is_numeric($this->ref_ref_cod_instituicao)) {
  357 + $set .= "{$gruda}ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}'";
  358 + $gruda = ', ';
  359 + }
  360 +
  361 + if (is_numeric($this->ref_usuario_exc)) {
  362 + $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'";
  363 + $gruda = ', ';
  364 + }
  365 +
  366 + if (is_numeric($this->ref_usuario_cad)) {
  367 + $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'";
  368 + $gruda = ', ';
  369 + }
  370 +
  371 + if (is_numeric($this->ref_cod_servidor)) {
  372 + $set .= "{$gruda}ref_cod_servidor = '{$this->ref_cod_servidor}'";
  373 + $gruda = ', ';
  374 + }
  375 +
  376 + if (is_numeric($this->tipo)) {
  377 + $set .= "{$gruda}tipo = '{$this->tipo}'";
  378 + $gruda = ', ';
  379 + }
  380 +
  381 + if (is_string($this->data_falta_atraso)) {
  382 + $set .= "{$gruda}data_falta_atraso = '{$this->data_falta_atraso}'";
  383 + $gruda = ', ';
  384 + }
  385 +
  386 + if (is_numeric($this->qtd_horas)) {
  387 + $set .= "{$gruda}qtd_horas = '{$this->qtd_horas}'";
  388 + $gruda = ', ';
  389 + }
  390 +
  391 + if (is_numeric($this->qtd_min)) {
  392 + $set .= "{$gruda}qtd_min = '{$this->qtd_min}'";
  393 + $gruda = ', ';
  394 + }
  395 +
  396 + if (is_numeric($this->justificada)) {
  397 + $set .= "{$gruda}justificada = '{$this->justificada}'";
  398 + $gruda = ', ';
  399 + }
  400 +
  401 + if (is_string($this->data_cadastro)) {
  402 + $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'";
  403 + $gruda = ', ';
  404 + }
  405 +
  406 + $set .= "{$gruda}data_exclusao = NOW()";
  407 + $gruda = ', ';
  408 +
  409 + if (is_numeric($this->ativo)) {
  410 + $set .= "{$gruda}ativo = '{$this->ativo}'";
  411 + $gruda = ', ';
  412 + }
  413 +
  414 + if ($set) {
  415 + $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'");
  416 + return true;
  417 + }
  418 + }
  419 + return false;
  420 + }
  421 +
  422 + /**
  423 + * Retorna uma lista de registros filtrados de acordo com os parâmetros.
  424 + * @return array
  425 + */
  426 + function lista($int_cod_falta_atraso = null, $int_ref_cod_escola = null,
  427 + $int_ref_ref_cod_instituicao = null, $int_ref_usuario_exc = null,
  428 + $int_ref_usuario_cad = null, $int_ref_cod_servidor = null, $int_tipo = null,
  429 + $date_data_falta_atraso_ini = null, $date_data_falta_atraso_fim = null,
  430 + $int_qtd_horas = null, $int_qtd_min = null, $int_justificada = null,
  431 + $date_data_cadastro_ini = null, $date_data_cadastro_fim = null,
  432 + $date_data_exclusao_ini = null, $date_data_exclusao_fim = null, $int_ativo = null
  433 + ) {
  434 + $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}";
  435 + $filtros = '';
  436 +
  437 + $whereAnd = ' WHERE ';
  438 +
  439 + if (is_numeric($int_cod_falta_atraso)) {
  440 + $filtros .= "{$whereAnd} cod_falta_atraso = '{$int_cod_falta_atraso}'";
  441 + $whereAnd = ' AND ';
  442 + }
  443 +
  444 + if (is_numeric($int_ref_cod_escola)) {
  445 + $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'";
  446 + $whereAnd = ' AND ';
  447 + }
  448 +
  449 + if (is_numeric($int_ref_ref_cod_instituicao)) {
  450 + $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'";
  451 + $whereAnd = ' AND ';
  452 + }
  453 +
  454 + if (is_numeric($int_ref_usuario_exc)) {
  455 + $filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'";
  456 + $whereAnd = ' AND ';
  457 + }
  458 +
  459 + if (is_numeric($int_ref_usuario_cad)) {
  460 + $filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'";
  461 + $whereAnd = ' AND ';
  462 + }
  463 +
  464 + if (is_numeric($int_ref_cod_servidor)) {
  465 + $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'";
  466 + $whereAnd = ' AND ';
  467 + }
  468 +
  469 + if (is_numeric($int_tipo)) {
  470 + $filtros .= "{$whereAnd} tipo = '{$int_tipo}'";
  471 + $whereAnd = ' AND ';
  472 + }
  473 +
  474 + if (is_string($date_data_falta_atraso_ini)) {
  475 + $filtros .= "{$whereAnd} data_falta_atraso >= '{$date_data_falta_atraso_ini}'";
  476 + $whereAnd = ' AND ';
  477 + }
  478 +
  479 + if (is_string($date_data_falta_atraso_fim)) {
  480 + $filtros .= "{$whereAnd} data_falta_atraso <= '{$date_data_falta_atraso_fim}'";
  481 + $whereAnd = ' AND ';
  482 + }
  483 +
  484 + if (is_numeric($int_qtd_horas)) {
  485 + $filtros .= "{$whereAnd} qtd_horas = '{$int_qtd_horas}'";
  486 + $whereAnd = ' AND ';
  487 + }
  488 +
  489 + if (is_numeric($int_qtd_min)) {
  490 + $filtros .= "{$whereAnd} qtd_min = '{$int_qtd_min}'";
  491 + $whereAnd = ' AND ';
  492 + }
  493 +
  494 + if (is_numeric($int_justificada)) {
  495 + $filtros .= "{$whereAnd} justificada = '{$int_justificada}'";
  496 + $whereAnd = ' AND ';
  497 + }
  498 +
  499 + if (is_string($date_data_cadastro_ini)) {
  500 + $filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'";
  501 + $whereAnd = ' AND ';
  502 + }
  503 +
  504 + if (is_string($date_data_cadastro_fim)) {
  505 + $filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'";
  506 + $whereAnd = ' AND ';
  507 + }
  508 +
  509 + if (is_string($date_data_exclusao_ini)) {
  510 + $filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'";
  511 + $whereAnd = ' AND ';
  512 + }
  513 +
  514 + if (is_string($date_data_exclusao_fim)) {
  515 + $filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'";
  516 + $whereAnd = ' AND ';
  517 + }
  518 +
  519 + if (is_null($int_ativo) || $int_ativo) {
  520 + $filtros .= "{$whereAnd} ativo = '1'";
  521 + $whereAnd = ' AND ';
  522 + }
  523 + else {
  524 + $filtros .= "{$whereAnd} ativo = '0'";
  525 + $whereAnd = ' AND ';
  526 + }
  527 +
  528 + $db = new clsBanco();
  529 + $countCampos = count(explode(',', $this->_campos_lista));
  530 + $resultado = array();
  531 +
  532 + $sql .= $filtros . $this->getOrderby() . $this->getLimite();
  533 +
  534 + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} {$filtros}");
  535 +
  536 + $db->Consulta($sql);
  537 +
  538 + if ($countCampos > 1) {
  539 + while ($db->ProximoRegistro()) {
  540 + $tupla = $db->Tupla();
  541 +
  542 + $tupla['_total'] = $this->_total;
  543 + $resultado[] = $tupla;
  544 + }
  545 + }
  546 + else {
  547 + while ($db->ProximoRegistro()) {
  548 + $tupla = $db->Tupla();
  549 + $resultado[] = $tupla[$this->_campos_lista];
  550 + }
  551 + }
  552 +
  553 + if (count($resultado)) {
  554 + return $resultado;
  555 + }
  556 +
  557 + return FALSE;
  558 + }
  559 +
  560 + /**
  561 + * Retorna um array com os dados de um registro.
  562 + * @return array
  563 + */
  564 + function detalhe()
  565 + {
  566 + if (is_numeric($this->cod_falta_atraso)) {
  567 + $db = new clsBanco();
  568 + $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'" );
  569 + $db->ProximoRegistro();
  570 + return $db->Tupla();
  571 + }
  572 +
  573 + return FALSE;
  574 + }
  575 +
  576 + /**
  577 + * Retorna um array com os dados de um registro.
  578 + * @return array
  579 + */
  580 + function existe()
  581 + {
  582 + if (is_numeric($this->cod_falta_atraso)) {
  583 + $db = new clsBanco();
  584 + $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE cod_falta_atraso = '{$this->cod_falta_atraso}'");
  585 + $db->ProximoRegistro();
  586 + return $db->Tupla();
  587 + }
  588 +
  589 + return FALSE;
  590 + }
  591 +
  592 + /**
  593 + * Exclui um registro.
  594 + * @return bool
  595 + */
  596 + function excluir()
  597 + {
  598 + if (is_numeric($this->cod_falta_atraso) && is_numeric($this->ref_usuario_exc)) {
  599 + $this->ativo = 0;
  600 + return $this->edita();
  601 + }
  602 +
  603 + return FALSE;
  604 + }
  605 +
  606 + /**
  607 + * Retorna uma lista de registros filtrados de acordo com os parâmetros.
  608 + * @return array
  609 + * @todo Remover método (não utilizado)
  610 + */
  611 + function listaHorasEscola($int_ref_cod_servidor = null,
  612 + $int_ref_ref_cod_instituicao = null, $int_ref_cod_escola = null)
  613 + {
  614 + $sql = '
  615 + SELECT
  616 + SUM(qtd_horas) AS horas,
  617 + SUM(qtd_min) AS minutos,
  618 + ref_cod_escola,
  619 + ref_ref_cod_instituicao
  620 + FROM
  621 + ' . $this->_tabela;
  622 +
  623 + $filtros = '';
  624 +
  625 + $whereAnd = ' WHERE ';
  626 +
  627 + if (is_numeric( $int_ref_cod_servidor ) ) {
  628 + $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'";
  629 + $whereAnd = ' AND ';
  630 + }
  631 + if (is_numeric( $int_ref_cod_escola ) ) {
  632 + $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'";
  633 + $whereAnd = ' AND ';
  634 + }
  635 + if (is_numeric( $int_ref_ref_cod_instituicao ) ) {
  636 + $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'";
  637 + $whereAnd = ' AND ';
  638 + }
  639 +
  640 + $filtros .= "{$whereAnd} justificada <> '0'";
  641 + $whereAnd = ' AND ';
  642 +
  643 + $filtros .= "{$whereAnd} ativo <> '0'";
  644 + $whereAnd = ' AND ';
  645 +
  646 + $groupBy = " GROUP BY ref_cod_escola, ref_ref_cod_instituicao";
  647 +
  648 +
  649 + $db = new clsBanco();
  650 + $countCampos = count(explode(',', $this->_campos_lista));
  651 + $resultado = array();
  652 +
  653 + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM ({$sql}{$filtros}{$groupBy}) AS countsubquery");
  654 +
  655 + $sql .= $filtros . $groupBy . $this->getLimite();
  656 +
  657 + $db->Consulta($sql);
  658 +
  659 + if ($countCampos > 1) {
  660 + while ($db->ProximoRegistro()) {
  661 + $tupla = $db->Tupla();
  662 +
  663 + $tupla["_total"] = $this->_total;
  664 + $resultado[] = $tupla;
  665 + }
  666 + }
  667 + else {
  668 + while ($db->ProximoRegistro()) {
  669 + $tupla = $db->Tupla();
  670 + $resultado[] = $tupla[$this->_campos_lista];
  671 + }
  672 + }
  673 +
  674 + if (count( $resultado ) ) {
  675 + return $resultado;
  676 + }
  677 +
  678 + return FALSE;
  679 + }
  680 +
  681 + /**
  682 + * Define quais campos da tabela serão selecionados no método Lista().
  683 + */
  684 + function setCamposLista($str_campos)
  685 + {
  686 + $this->_campos_lista = $str_campos;
  687 + }
  688 +
  689 + /**
  690 + * Define que o método Lista() deverpa retornar todos os campos da tabela.
  691 + */
  692 + function resetCamposLista()
  693 + {
  694 + $this->_campos_lista = $this->_todos_campos;
  695 + }
  696 +
  697 + /**
  698 + * Define limites de retorno para o método Lista().
  699 + */
  700 + function setLimite($intLimiteQtd, $intLimiteOffset = NULL)
  701 + {
  702 + $this->_limite_quantidade = $intLimiteQtd;
  703 + $this->_limite_offset = $intLimiteOffset;
  704 + }
  705 +
  706 + /**
  707 + * Retorna a string com o trecho da query responsável pelo limite de
  708 + * registros retornados/afetados.
  709 + *
  710 + * @return string
  711 + */
  712 + function getLimite()
  713 + {
  714 + if (is_numeric($this->_limite_quantidade)) {
  715 + $retorno = " LIMIT {$this->_limite_quantidade}";
  716 + if (is_numeric($this->_limite_offset)) {
  717 + $retorno .= " OFFSET {$this->_limite_offset} ";
  718 + }
  719 + return $retorno;
  720 + }
  721 + return '';
  722 + }
  723 +
  724 + /**
  725 + * Define o campo para ser utilizado como ordenação no método Lista().
  726 + */
  727 + function setOrderby($strNomeCampo)
  728 + {
  729 + if (is_string($strNomeCampo) && $strNomeCampo ) {
  730 + $this->_campo_order_by = $strNomeCampo;
  731 + }
  732 + }
  733 +
  734 + /**
  735 + * Retorna a string com o trecho da query responsável pela Ordenação dos
  736 + * registros.
  737 + *
  738 + * @return string
  739 + */
  740 + function getOrderby()
  741 + {
  742 + if (is_string($this->_campo_order_by)) {
  743 + return " ORDER BY {$this->_campo_order_by} ";
  744 + }
  745 + return '';
  746 + }
  747 +}
806 748 \ No newline at end of file
... ...
ieducar/intranet/include/pmieducar/clsPmieducarFaltaAtrasoCompensado.inc.php
1 1 <?php
2   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3   -* *
4   -* @author Prefeitura Municipal de Itajaí *
5   -* @updated 29/03/2007 *
6   -* Pacote: i-PLB Software Público Livre e Brasileiro *
7   -* *
8   -* Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí *
9   -* ctima@itajai.sc.gov.br *
10   -* *
11   -* Este programa é software livre, você pode redistribuí-lo e/ou *
12   -* modificá-lo sob os termos da Licença Pública Geral GNU, conforme *
13   -* publicada pela Free Software Foundation, tanto a versão 2 da *
14   -* Licença como (a seu critério) qualquer versão mais nova. *
15   -* *
16   -* Este programa é distribuído na expectativa de ser útil, mas SEM *
17   -* QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- *
18   -* ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- *
19   -* sulte a Licença Pública Geral GNU para obter mais detalhes. *
20   -* *
21   -* Você deve ter recebido uma cópia da Licença Pública Geral GNU *
22   -* junto com este programa. Se não, escreva para a Free Software *
23   -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *
24   -* 02111-1307, USA. *
25   -* *
26   -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27   -/**
28   -* @author Prefeitura Municipal de Itajaí
29   -*
30   -* Criado em 07/08/2006 14:45 pelo gerador automatico de classes
31   -*/
32 2  
33   -require_once( "include/pmieducar/geral.inc.php" );
  3 +/**
  4 + * i-Educar - Sistema de gestão escolar
  5 + *
  6 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  7 + * <ctima@itajai.sc.gov.br>
  8 + *
  9 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  10 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  11 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  12 + * qualquer versão posterior.
  13 + *
  14 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  15 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  16 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  17 + * do GNU para mais detalhes.
  18 + *
  19 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  20 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  21 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  22 + *
  23 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  24 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package iEd_Pmieducar
  27 + * @since Arquivo disponível desde a versão 1.0.0
  28 + * @version $Id$
  29 + */
  30 +
  31 +require_once 'include/pmieducar/geral.inc.php';
34 32  
  33 +/**
  34 + * clsPmieducarFaltaAtrasoCompensado class.
  35 + *
  36 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  37 + * @category i-Educar
  38 + * @license @@license@@
  39 + * @package iEd_Pmieducar
  40 + * @since Classe disponível desde a versão 1.0.0
  41 + * @version @@package_version@@
  42 + */
35 43 class clsPmieducarFaltaAtrasoCompensado
36 44 {
37   - var $cod_compensado;
38   - var $ref_cod_escola;
39   - var $ref_ref_cod_instituicao;
40   - var $ref_cod_servidor;
41   - var $ref_usuario_exc;
42   - var $ref_usuario_cad;
43   - var $data_inicio;
44   - var $data_fim;
45   - var $data_cadastro;
46   - var $data_exclusao;
47   - var $ativo;
48   -
49   - // propriedades padrao
50   -
51   - /**
52   - * Armazena o total de resultados obtidos na ultima chamada ao metodo lista
53   - *
54   - * @var int
55   - */
56   - var $_total;
57   -
58   - /**
59   - * Nome do schema
60   - *
61   - * @var string
62   - */
63   - var $_schema;
64   -
65   - /**
66   - * Nome da tabela
67   - *
68   - * @var string
69   - */
70   - var $_tabela;
71   -
72   - /**
73   - * Lista separada por virgula, com os campos que devem ser selecionados na proxima chamado ao metodo lista
74   - *
75   - * @var string
76   - */
77   - var $_campos_lista;
78   -
79   - /**
80   - * Lista com todos os campos da tabela separados por virgula, padrao para selecao no metodo lista
81   - *
82   - * @var string
83   - */
84   - var $_todos_campos;
85   -
86   - /**
87   - * Valor que define a quantidade de registros a ser retornada pelo metodo lista
88   - *
89   - * @var int
90   - */
91   - var $_limite_quantidade;
92   -
93   - /**
94   - * Define o valor de offset no retorno dos registros no metodo lista
95   - *
96   - * @var int
97   - */
98   - var $_limite_offset;
99   -
100   - /**
101   - * Define o campo padrao para ser usado como padrao de ordenacao no metodo lista
102   - *
103   - * @var string
104   - */
105   - var $_campo_order_by;
106   -
107   -
108   - /**
109   - * Construtor (PHP 4)
110   - *
111   - * @return object
112   - */
113   - function 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 )
114   - {
115   - $db = new clsBanco();
116   - $this->_schema = "pmieducar.";
117   - $this->_tabela = "{$this->_schema}falta_atraso_compensado";
118   -
119   - $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";
120   -
121   - if( is_numeric( $ref_cod_escola ) )
122   - {
123   - if( class_exists( "clsPmieducarEscola" ) )
124   - {
125   - $tmp_obj = new clsPmieducarEscola( $ref_cod_escola );
126   - if( method_exists( $tmp_obj, "existe") )
127   - {
128   - if( $tmp_obj->existe() )
129   - {
130   - $this->ref_cod_escola = $ref_cod_escola;
131   - }
132   - }
133   - else if( method_exists( $tmp_obj, "detalhe") )
134   - {
135   - if( $tmp_obj->detalhe() )
136   - {
137   - $this->ref_cod_escola = $ref_cod_escola;
138   - }
139   - }
140   - }
141   - else
142   - {
143   - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.escola WHERE cod_escola = '{$ref_cod_escola}'" ) )
144   - {
145   - $this->ref_cod_escola = $ref_cod_escola;
146   - }
147   - }
148   - }
149   - if( is_numeric( $ref_cod_servidor ) && is_numeric( $ref_ref_cod_instituicao ) )
150   - {
151   - if( class_exists( "clsPmieducarServidor" ) )
152   - {
153   - $tmp_obj = new clsPmieducarServidor( $ref_cod_servidor, null, null, null, null, null, null, 1, $ref_ref_cod_instituicao );
154   - if( method_exists( $tmp_obj, "existe") )
155   - {
156   - if( $tmp_obj->existe() )
157   - {
158   - $this->ref_cod_servidor = $ref_cod_servidor;
159   - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
160   - }
161   - }
162   - else if( method_exists( $tmp_obj, "detalhe") )
163   - {
164   - if( $tmp_obj->detalhe() )
165   - {
166   - $this->ref_cod_servidor = $ref_cod_servidor;
167   - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
168   - }
169   - }
170   - }
171   - else
172   - {
173   - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_cod_servidor}' AND ref_cod_instituicao = '{$ref_ref_cod_instituicao}'" ) )
174   - {
175   - $this->ref_cod_servidor = $ref_cod_servidor;
176   - $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
177   - }
178   - }
179   - }
180   - if( is_numeric( $ref_usuario_exc ) )
181   - {
182   - if( class_exists( "clsPmieducarUsuario" ) )
183   - {
184   - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_exc );
185   - if( method_exists( $tmp_obj, "existe") )
186   - {
187   - if( $tmp_obj->existe() )
188   - {
189   - $this->ref_usuario_exc = $ref_usuario_exc;
190   - }
191   - }
192   - else if( method_exists( $tmp_obj, "detalhe") )
193   - {
194   - if( $tmp_obj->detalhe() )
195   - {
196   - $this->ref_usuario_exc = $ref_usuario_exc;
197   - }
198   - }
199   - }
200   - else
201   - {
202   - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'" ) )
203   - {
204   - $this->ref_usuario_exc = $ref_usuario_exc;
205   - }
206   - }
207   - }
208   - if( is_numeric( $ref_usuario_cad ) )
209   - {
210   - if( class_exists( "clsPmieducarUsuario" ) )
211   - {
212   - $tmp_obj = new clsPmieducarUsuario( $ref_usuario_cad );
213   - if( method_exists( $tmp_obj, "existe") )
214   - {
215   - if( $tmp_obj->existe() )
216   - {
217   - $this->ref_usuario_cad = $ref_usuario_cad;
218   - }
219   - }
220   - else if( method_exists( $tmp_obj, "detalhe") )
221   - {
222   - if( $tmp_obj->detalhe() )
223   - {
224   - $this->ref_usuario_cad = $ref_usuario_cad;
225   - }
226   - }
227   - }
228   - else
229   - {
230   - if( $db->CampoUnico( "SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'" ) )
231   - {
232   - $this->ref_usuario_cad = $ref_usuario_cad;
233   - }
234   - }
235   - }
236   -
237   - if( is_numeric( $cod_compensado ) )
238   - {
239   - $this->cod_compensado = $cod_compensado;
240   - }
241   - if( is_string( $data_inicio ) )
242   - {
243   - $this->data_inicio = $data_inicio;
244   - }
245   - if( is_string( $data_fim ) )
246   - {
247   - $this->data_fim = $data_fim;
248   - }
249   - if( is_string( $data_cadastro ) )
250   - {
251   - $this->data_cadastro = $data_cadastro;
252   - }
253   - if( is_string( $data_exclusao ) )
254   - {
255   - $this->data_exclusao = $data_exclusao;
256   - }
257   - if( is_numeric( $ativo ) )
258   - {
259   - $this->ativo = $ativo;
260   - }
261   -
262   - }
263   -
264   - /**
265   - * Cria um novo registro
266   - *
267   - * @return bool
268   - */
269   - function cadastra()
270   - {
271   - 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 ) )
272   - {
273   - $db = new clsBanco();
274   -
275   - $campos = "";
276   - $valores = "";
277   - $gruda = "";
278   -
279   - if( is_numeric( $this->ref_cod_escola ) )
280   - {
281   - $campos .= "{$gruda}ref_cod_escola";
282   - $valores .= "{$gruda}'{$this->ref_cod_escola}'";
283   - $gruda = ", ";
284   - }
285   - if( is_numeric( $this->ref_ref_cod_instituicao ) )
286   - {
287   - $campos .= "{$gruda}ref_ref_cod_instituicao";
288   - $valores .= "{$gruda}'{$this->ref_ref_cod_instituicao}'";
289   - $gruda = ", ";
290   - }
291   - if( is_numeric( $this->ref_cod_servidor ) )
292   - {
293   - $campos .= "{$gruda}ref_cod_servidor";
294   - $valores .= "{$gruda}'{$this->ref_cod_servidor}'";
295   - $gruda = ", ";
296   - }
297   - if( is_numeric( $this->ref_usuario_cad ) )
298   - {
299   - $campos .= "{$gruda}ref_usuario_cad";
300   - $valores .= "{$gruda}'{$this->ref_usuario_cad}'";
301   - $gruda = ", ";
302   - }
303   - if( is_string( $this->data_inicio ) )
304   - {
305   - $campos .= "{$gruda}data_inicio";
306   - $valores .= "{$gruda}'{$this->data_inicio}'";
307   - $gruda = ", ";
308   - }
309   - if( is_string( $this->data_fim ) )
310   - {
311   - $campos .= "{$gruda}data_fim";
312   - $valores .= "{$gruda}'{$this->data_fim}'";
313   - $gruda = ", ";
314   - }
315   - $campos .= "{$gruda}data_cadastro";
316   - $valores .= "{$gruda}NOW()";
317   - $gruda = ", ";
318   - $campos .= "{$gruda}ativo";
319   - $valores .= "{$gruda}'1'";
320   - $gruda = ", ";
321   -
322   -
323   - $db->Consulta( "INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )" );
324   - return $db->InsertId( "{$this->_tabela}_cod_compensado_seq");
325   - }
326   - return false;
327   - }
328   -
329   - /**
330   - * Edita os dados de um registro
331   - *
332   - * @return bool
333   - */
334   - function edita()
335   - {
336   - if( is_numeric( $this->cod_compensado ) && is_numeric( $this->ref_usuario_exc ) )
337   - {
338   -
339   - $db = new clsBanco();
340   - $set = "";
341   -
342   - if( is_numeric( $this->ref_cod_escola ) )
343   - {
344   - $set .= "{$gruda}ref_cod_escola = '{$this->ref_cod_escola}'";
345   - $gruda = ", ";
346   - }
347   - if( is_numeric( $this->ref_ref_cod_instituicao ) )
348   - {
349   - $set .= "{$gruda}ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}'";
350   - $gruda = ", ";
351   - }
352   - if( is_numeric( $this->ref_cod_servidor ) )
353   - {
354   - $set .= "{$gruda}ref_cod_servidor = '{$this->ref_cod_servidor}'";
355   - $gruda = ", ";
356   - }
357   - if( is_numeric( $this->ref_usuario_exc ) )
358   - {
359   - $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'";
360   - $gruda = ", ";
361   - }
362   - if( is_numeric( $this->ref_usuario_cad ) )
363   - {
364   - $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'";
365   - $gruda = ", ";
366   - }
367   - if( is_string( $this->data_inicio ) )
368   - {
369   - $set .= "{$gruda}data_inicio = '{$this->data_inicio}'";
370   - $gruda = ", ";
371   - }
372   - if( is_string( $this->data_fim ) )
373   - {
374   - $set .= "{$gruda}data_fim = '{$this->data_fim}'";
375   - $gruda = ", ";
376   - }
377   - if( is_string( $this->data_cadastro ) )
378   - {
379   - $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'";
380   - $gruda = ", ";
381   - }
382   - $set .= "{$gruda}data_exclusao = NOW()";
383   - $gruda = ", ";
384   - if( is_numeric( $this->ativo ) )
385   - {
386   - $set .= "{$gruda}ativo = '{$this->ativo}'";
387   - $gruda = ", ";
388   - }
389   -
390   -
391   - if( $set )
392   - {
393   - $db->Consulta( "UPDATE {$this->_tabela} SET $set WHERE cod_compensado = '{$this->cod_compensado}'" );
394   - return true;
395   - }
396   - }
397   - return false;
398   - }
399   -
400   - /**
401   - * Retorna uma lista filtrados de acordo com os parametros
402   - *
403   - * @return array
404   - */
405   - function lista( $int_cod_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 )
406   - {
407   - $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}";
408   - $filtros = "";
409   -
410   - $whereAnd = " WHERE ";
411   -
412   - if( is_numeric( $int_cod_compensado ) )
413   - {
414   - $filtros .= "{$whereAnd} cod_compensado = '{$int_cod_compensado}'";
415   - $whereAnd = " AND ";
416   - }
417   - if( is_numeric( $int_ref_cod_escola ) )
418   - {
419   - $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'";
420   - $whereAnd = " AND ";
421   - }
422   - if( is_numeric( $int_ref_ref_cod_instituicao ) )
423   - {
424   - $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'";
425   - $whereAnd = " AND ";
426   - }
427   - if( is_numeric( $int_ref_cod_servidor ) )
428   - {
429   - $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'";
430   - $whereAnd = " AND ";
431   - }
432   - if( is_numeric( $int_ref_usuario_exc ) )
433   - {
434   - $filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'";
435   - $whereAnd = " AND ";
436   - }
437   - if( is_numeric( $int_ref_usuario_cad ) )
438   - {
439   - $filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'";
440   - $whereAnd = " AND ";
441   - }
442   - if( is_string( $date_data_inicio_ini ) )
443   - {
444   - $filtros .= "{$whereAnd} data_inicio >= '{$date_data_inicio_ini}'";
445   - $whereAnd = " AND ";
446   - }
447   - if( is_string( $date_data_inicio_fim ) )
448   - {
449   - $filtros .= "{$whereAnd} data_inicio <= '{$date_data_inicio_fim}'";
450   - $whereAnd = " AND ";
451   - }
452   - if( is_string( $date_data_fim_ini ) )
453   - {
454   - $filtros .= "{$whereAnd} data_fim >= '{$date_data_fim_ini}'";
455   - $whereAnd = " AND ";
456   - }
457   - if( is_string( $date_data_fim_fim ) )
458   - {
459   - $filtros .= "{$whereAnd} data_fim <= '{$date_data_fim_fim}'";
460   - $whereAnd = " AND ";
461   - }
462   - if( is_string( $date_data_cadastro_ini ) )
463   - {
464   - $filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'";
465   - $whereAnd = " AND ";
466   - }
467   - if( is_string( $date_data_cadastro_fim ) )
468   - {
469   - $filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'";
470   - $whereAnd = " AND ";
471   - }
472   - if( is_string( $date_data_exclusao_ini ) )
473   - {
474   - $filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'";
475   - $whereAnd = " AND ";
476   - }
477   - if( is_string( $date_data_exclusao_fim ) )
478   - {
479   - $filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'";
480   - $whereAnd = " AND ";
481   - }
482   - if( is_null( $int_ativo ) || $int_ativo )
483   - {
484   - $filtros .= "{$whereAnd} ativo = '1'";
485   - $whereAnd = " AND ";
486   - }
487   - else
488   - {
489   - $filtros .= "{$whereAnd} ativo = '0'";
490   - $whereAnd = " AND ";
491   - }
492   -
493   -
494   - $db = new clsBanco();
495   - $countCampos = count( explode( ",", $this->_campos_lista ) );
496   - $resultado = array();
497   -
498   - $sql .= $filtros . $this->getOrderby() . $this->getLimite();
499   -
500   - $this->_total = $db->CampoUnico( "SELECT COUNT(0) FROM {$this->_tabela} {$filtros}" );
501   -
502   - $db->Consulta( $sql );
503   -
504   - if( $countCampos > 1 )
505   - {
506   - while ( $db->ProximoRegistro() )
507   - {
508   - $tupla = $db->Tupla();
509   -
510   - $tupla["_total"] = $this->_total;
511   - $resultado[] = $tupla;
512   - }
513   - }
514   - else
515   - {
516   - while ( $db->ProximoRegistro() )
517   - {
518   - $tupla = $db->Tupla();
519   - $resultado[] = $tupla[$this->_campos_lista];
520   - }
521   - }
522   - if( count( $resultado ) )
523   - {
524   - return $resultado;
525   - }
526   - return false;
527   - }
528   -
529   - /**
530   - * Retorna um array com os dados de um registro
531   - *
532   - * @return array
533   - */
534   - function detalhe()
535   - {
536   - if( is_numeric( $this->cod_compensado ) )
537   - {
538   -
539   - $db = new clsBanco();
540   - $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_compensado = '{$this->cod_compensado}'" );
541   - $db->ProximoRegistro();
542   - return $db->Tupla();
543   - }
544   - return false;
545   - }
546   -
547   - /**
548   - * Retorna um array com os dados de um registro
549   - *
550   - * @return array
551   - */
552   - function existe()
553   - {
554   - if( is_numeric( $this->cod_compensado ) )
555   - {
556   -
557   - $db = new clsBanco();
558   - $db->Consulta( "SELECT 1 FROM {$this->_tabela} WHERE cod_compensado = '{$this->cod_compensado}'" );
559   - $db->ProximoRegistro();
560   - return $db->Tupla();
561   - }
562   - return false;
563   - }
564   -
565   - /**
566   - * Exclui um registro
567   - *
568   - * @return bool
569   - */
570   - function excluir()
571   - {
572   - if( is_numeric( $this->cod_compensado ) && is_numeric( $this->ref_usuario_exc ) )
573   - {
574   -
575   - /*
576   - delete
577   - $db = new clsBanco();
578   - $db->Consulta( "DELETE FROM {$this->_tabela} WHERE cod_compensado = '{$this->cod_compensado}'" );
579   - return true;
580   - */
581   -
582   - $this->ativo = 0;
583   - return $this->edita();
584   - }
585   - return false;
586   - }
587   -
588   - /**
589   - * Define quais campos da tabela serao selecionados na invocacao do metodo lista
590   - *
591   - * @return null
592   - */
593   - function setCamposLista( $str_campos )
594   - {
595   - $this->_campos_lista = $str_campos;
596   - }
597   -
598   - /**
599   - * Define que o metodo Lista devera retornoar todos os campos da tabela
600   - *
601   - * @return null
602   - */
603   - function resetCamposLista()
604   - {
605   - $this->_campos_lista = $this->_todos_campos;
606   - }
607   -
608   - /**
609   - * Define limites de retorno para o metodo lista
610   - *
611   - * @return null
612   - */
613   - function setLimite( $intLimiteQtd, $intLimiteOffset = null )
614   - {
615   - $this->_limite_quantidade = $intLimiteQtd;
616   - $this->_limite_offset = $intLimiteOffset;
617   - }
618   -
619   - /**
620   - * Retorna a string com o trecho da query resposavel pelo Limite de registros
621   - *
622   - * @return string
623   - */
624   - function getLimite()
625   - {
626   - if( is_numeric( $this->_limite_quantidade ) )
627   - {
628   - $retorno = " LIMIT {$this->_limite_quantidade}";
629   - if( is_numeric( $this->_limite_offset ) )
630   - {
631   - $retorno .= " OFFSET {$this->_limite_offset} ";
632   - }
633   - return $retorno;
634   - }
635   - return "";
636   - }
637   -
638   - /**
639   - * Define campo para ser utilizado como ordenacao no metolo lista
640   - *
641   - * @return null
642   - */
643   - function setOrderby( $strNomeCampo )
644   - {
645   - // limpa a string de possiveis erros (delete, insert, etc)
646   - //$strNomeCampo = eregi_replace();
647   -
648   - if( is_string( $strNomeCampo ) && $strNomeCampo )
649   - {
650   - $this->_campo_order_by = $strNomeCampo;
651   - }
652   - }
653   -
654   - /**
655   - * Retorna a string com o trecho da query resposavel pela Ordenacao dos registros
656   - *
657   - * @return string
658   - */
659   - function getOrderby()
660   - {
661   - if( is_string( $this->_campo_order_by ) )
662   - {
663   - return " ORDER BY {$this->_campo_order_by} ";
664   - }
665   - return "";
666   - }
667   -
668   - /**
669   - * Retorna a quantidade de horas compensadas
670   - *
671   - * @return array
672   - */
673   - function ServidorHorasCompensadas( $int_ref_cod_servidor = null, $int_ref_cod_escola = null, $int_ref_cod_instituicao )
674   - {
675   - if( is_numeric( $int_ref_cod_servidor ) )
676   - {
677   - /*strtotime( '2006-06-06' );
678   - date( "Y-m-d", time );*/
679   - $db = new clsBanco();
680   - $db->Consulta("SELECT fac.data_inicio,
681   - fac.data_fim
682   - FROM pmieducar.falta_atraso_compensado fac
683   - WHERE fac.ref_cod_servidor = '{$int_ref_cod_servidor}'
684   - AND fac.ref_cod_escola = '{$int_ref_cod_escola}'
685   - AND fac.ref_ref_cod_instituicao = '{$int_ref_cod_instituicao}'" );
686   -
687   - while ( $db->ProximoRegistro() )
688   - {
689   - $tupla = $db->Tupla();
690   - $resultado[] = $tupla;
691   - }
692   - $horas_total = 0;
693   - $minutos_total = 0;
694   -
695   - if ($resultado)
696   - {
697   - foreach ( $resultado as $registro )
698   - {
699   - $data_atual = strtotime( $registro["data_inicio"] );
700   - $data_fim = strtotime( $registro["data_fim"] );
701   - do {
702   - $db2 = new clsBanco();
703   - $dia_semana = $db2->CampoUnico( "SELECT EXTRACT ( DOW FROM ( date '".date( "Y-m-d", $data_atual )."' ) + 1 )" );
704   - $obj_servidor = new clsPmieducarServidor();
705   - $horas = $obj_servidor->qtdhoras( $int_ref_cod_servidor, $int_ref_cod_escola, $int_ref_cod_instituicao, $dia_semana );
706   - if ( $horas )
707   - {
708   - $horas_total += $horas["hora"];
709   - $minutos_total += $horas["min"];
710   - }
711   - $data_atual += 86400;
712   - } while ( $data_atual <= $data_fim );
713   - }
714   - }
715   - $res["hora"] = $horas_total;
716   - $res["min"] = $minutos_total;
717   - return $res;
718   - }
719   - return false;
720   - }
721   -}
722   -?>
723 45 \ No newline at end of file
  46 + var $cod_compensado;
  47 + var $ref_cod_escola;
  48 + var $ref_ref_cod_instituicao;
  49 + var $ref_cod_servidor;
  50 + var $ref_usuario_exc;
  51 + var $ref_usuario_cad;
  52 + var $data_inicio;
  53 + var $data_fim;
  54 + var $data_cadastro;
  55 + var $data_exclusao;
  56 + var $ativo;
  57 +
  58 + /**
  59 + * Armazena o total de resultados obtidos na última chamada ao método lista().
  60 + * @var int
  61 + */
  62 + var $_total;
  63 +
  64 + /**
  65 + * Nome do schema.
  66 + * @var string
  67 + */
  68 + var $_schema;
  69 +
  70 + /**
  71 + * Nome da tabela.
  72 + * @var string
  73 + */
  74 + var $_tabela;
  75 +
  76 + /**
  77 + * Lista separada por vírgula, com os campos que devem ser selecionados na
  78 + * próxima chamado ao método lista().
  79 + * @var string
  80 + */
  81 + var $_campos_lista;
  82 +
  83 + /**
  84 + * Lista com todos os campos da tabela separados por vírgula, padrão para
  85 + * seleção no método lista.
  86 + * @var string
  87 + */
  88 + var $_todos_campos;
  89 +
  90 + /**
  91 + * Valor que define a quantidade de registros a ser retornada pelo método lista().
  92 + * @var int
  93 + */
  94 + var $_limite_quantidade;
  95 +
  96 + /**
  97 + * Define o valor de offset no retorno dos registros no método lista().
  98 + * @var int
  99 + */
  100 + var $_limite_offset;
  101 +
  102 + /**
  103 + * Define o campo para ser usado como padrão de ordenação no método lista().
  104 + * @var string
  105 + */
  106 + var $_campo_order_by;
  107 +
  108 + /**
  109 + * Construtor.
  110 + */
  111 + function clsPmieducarFaltaAtrasoCompensado($cod_compensado = NULL,
  112 + $ref_cod_escola = NULL, $ref_ref_cod_instituicao = NULL,
  113 + $ref_cod_servidor = NULL, $ref_usuario_exc = NULL, $ref_usuario_cad = NULL,
  114 + $data_inicio = NULL, $data_fim = NULL, $data_cadastro = NULL,
  115 + $data_exclusao = NULL, $ativo = NULL)
  116 + {
  117 + $db = new clsBanco();
  118 + $this->_schema = 'pmieducar.';
  119 + $this->_tabela = $this->_schema . 'falta_atraso_compensado';
  120 +
  121 + $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';
  122 +
  123 + if (is_numeric($ref_cod_escola)) {
  124 + if (class_exists('clsPmieducarEscola')) {
  125 + $tmp_obj = new clsPmieducarEscola($ref_cod_escola);
  126 + if (method_exists($tmp_obj, 'existe')) {
  127 + if ($tmp_obj->existe()) {
  128 + $this->ref_cod_escola = $ref_cod_escola;
  129 + }
  130 + }
  131 + elseif (method_exists($tmp_obj, 'detalhe')) {
  132 + if ($tmp_obj->detalhe()) {
  133 + $this->ref_cod_escola = $ref_cod_escola;
  134 + }
  135 + }
  136 + }
  137 + else {
  138 + if ($db->CampoUnico("SELECT 1 FROM pmieducar.escola WHERE cod_escola = '{$ref_cod_escola}'")) {
  139 + $this->ref_cod_escola = $ref_cod_escola;
  140 + }
  141 + }
  142 + }
  143 +
  144 + if (is_numeric($ref_cod_servidor) && is_numeric($ref_ref_cod_instituicao)) {
  145 + if (class_exists('clsPmieducarServidor')) {
  146 + $tmp_obj = new clsPmieducarServidor($ref_cod_servidor, NULL, NULL, NULL,
  147 + NULL, NULL, NULL, 1, $ref_ref_cod_instituicao);
  148 +
  149 + if (method_exists($tmp_obj, 'existe')) {
  150 + if ($tmp_obj->existe()) {
  151 + $this->ref_cod_servidor = $ref_cod_servidor;
  152 + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
  153 + }
  154 + }
  155 + elseif (method_exists($tmp_obj, 'detalhe')) {
  156 + if ($tmp_obj->detalhe()) {
  157 + $this->ref_cod_servidor = $ref_cod_servidor;
  158 + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
  159 + }
  160 + }
  161 + }
  162 + else {
  163 + if ($db->CampoUnico("SELECT 1 FROM pmieducar.servidor WHERE cod_servidor = '{$ref_cod_servidor}' AND ref_cod_instituicao = '{$ref_ref_cod_instituicao}'")) {
  164 + $this->ref_cod_servidor = $ref_cod_servidor;
  165 + $this->ref_ref_cod_instituicao = $ref_ref_cod_instituicao;
  166 + }
  167 + }
  168 + }
  169 +
  170 + if (is_numeric($ref_usuario_exc)) {
  171 + if (class_exists('clsPmieducarUsuario')) {
  172 + $tmp_obj = new clsPmieducarUsuario($ref_usuario_exc);
  173 + if (method_exists($tmp_obj, 'existe')) {
  174 + if ($tmp_obj->existe()) {
  175 + $this->ref_usuario_exc = $ref_usuario_exc;
  176 + }
  177 + }
  178 + elseif (method_exists($tmp_obj, 'detalhe')) {
  179 + if ($tmp_obj->detalhe()) {
  180 + $this->ref_usuario_exc = $ref_usuario_exc;
  181 + }
  182 + }
  183 + }
  184 + else {
  185 + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_exc}'")) {
  186 + $this->ref_usuario_exc = $ref_usuario_exc;
  187 + }
  188 + }
  189 + }
  190 +
  191 + if (is_numeric($ref_usuario_cad)) {
  192 + if (class_exists('clsPmieducarUsuario')) {
  193 + $tmp_obj = new clsPmieducarUsuario($ref_usuario_cad);
  194 + if (method_exists($tmp_obj, 'existe')) {
  195 + if ($tmp_obj->existe()) {
  196 + $this->ref_usuario_cad = $ref_usuario_cad;
  197 + }
  198 + }
  199 + elseif (method_exists($tmp_obj, 'detalhe')) {
  200 + if ($tmp_obj->detalhe()) {
  201 + $this->ref_usuario_cad = $ref_usuario_cad;
  202 + }
  203 + }
  204 + }
  205 + else {
  206 + if ($db->CampoUnico("SELECT 1 FROM pmieducar.usuario WHERE cod_usuario = '{$ref_usuario_cad}'")) {
  207 + $this->ref_usuario_cad = $ref_usuario_cad;
  208 + }
  209 + }
  210 + }
  211 +
  212 + if (is_numeric($cod_compensado)) {
  213 + $this->cod_compensado = $cod_compensado;
  214 + }
  215 +
  216 + if (is_string($data_inicio)) {
  217 + $this->data_inicio = $data_inicio;
  218 + }
  219 +
  220 + if (is_string($data_fim)) {
  221 + $this->data_fim = $data_fim;
  222 + }
  223 +
  224 + if (is_string($data_cadastro)) {
  225 + $this->data_cadastro = $data_cadastro;
  226 + }
  227 +
  228 + if (is_string($data_exclusao)) {
  229 + $this->data_exclusao = $data_exclusao;
  230 + }
  231 +
  232 + if (is_numeric($ativo)) {
  233 + $this->ativo = $ativo;
  234 + }
  235 + }
  236 +
  237 + /**
  238 + * Cria um novo registro.
  239 + * @return bool
  240 + */
  241 + function cadastra()
  242 + {
  243 + if (is_numeric($this->ref_cod_escola) && is_numeric($this->ref_ref_cod_instituicao) &&
  244 + is_numeric($this->ref_cod_servidor) && is_numeric($this->ref_usuario_cad) &&
  245 + is_string($this->data_inicio) && is_string($this->data_fim)
  246 + ) {
  247 + $db = new clsBanco();
  248 +
  249 + $campos = '';
  250 + $valores = '';
  251 + $gruda = '';
  252 +
  253 + if (is_numeric($this->ref_cod_escola)) {
  254 + $campos .= "{$gruda}ref_cod_escola";
  255 + $valores .= "{$gruda}'{$this->ref_cod_escola}'";
  256 + $gruda = ', ';
  257 + }
  258 +
  259 + if (is_numeric($this->ref_ref_cod_instituicao)) {
  260 + $campos .= "{$gruda}ref_ref_cod_instituicao";
  261 + $valores .= "{$gruda}'{$this->ref_ref_cod_instituicao}'";
  262 + $gruda = ', ';
  263 + }
  264 +
  265 + if (is_numeric($this->ref_cod_servidor)) {
  266 + $campos .= "{$gruda}ref_cod_servidor";
  267 + $valores .= "{$gruda}'{$this->ref_cod_servidor}'";
  268 + $gruda = ', ';
  269 + }
  270 +
  271 + if (is_numeric($this->ref_usuario_cad)) {
  272 + $campos .= "{$gruda}ref_usuario_cad";
  273 + $valores .= "{$gruda}'{$this->ref_usuario_cad}'";
  274 + $gruda = ', ';
  275 + }
  276 +
  277 + if (is_string($this->data_inicio)) {
  278 + $campos .= "{$gruda}data_inicio";
  279 + $valores .= "{$gruda}'{$this->data_inicio}'";
  280 + $gruda = ', ';
  281 + }
  282 +
  283 + if (is_string($this->data_fim)) {
  284 + $campos .= "{$gruda}data_fim";
  285 + $valores .= "{$gruda}'{$this->data_fim}'";
  286 + $gruda = ', ';
  287 + }
  288 +
  289 + $campos .= "{$gruda}data_cadastro";
  290 + $valores .= "{$gruda}NOW()";
  291 + $gruda = ', ';
  292 +
  293 + $campos .= "{$gruda}ativo";
  294 + $valores .= "{$gruda}'1'";
  295 + $gruda = ', ';
  296 +
  297 + $db->Consulta("INSERT INTO {$this->_tabela} ($campos) VALUES ($valores)");
  298 + return $db->InsertId("{$this->_tabela}_cod_compensado_seq");
  299 + }
  300 +
  301 + return FALSE;
  302 + }
  303 +
  304 + /**
  305 + * Edita os dados de um registro
  306 + *
  307 + * @return bool
  308 + */
  309 + function edita()
  310 + {
  311 + if (is_numeric($this->cod_compensado) && is_numeric($this->ref_usuario_exc)) {
  312 + $db = new clsBanco();
  313 + $set = '';
  314 +
  315 + if (is_numeric($this->ref_cod_escola)) {
  316 + $set .= "{$gruda}ref_cod_escola = '{$this->ref_cod_escola}'";
  317 + $gruda = ', ';
  318 + }
  319 +
  320 + if (is_numeric($this->ref_ref_cod_instituicao)) {
  321 + $set .= "{$gruda}ref_ref_cod_instituicao = '{$this->ref_ref_cod_instituicao}'";
  322 + $gruda = ', ';
  323 + }
  324 +
  325 + if (is_numeric($this->ref_cod_servidor)) {
  326 + $set .= "{$gruda}ref_cod_servidor = '{$this->ref_cod_servidor}'";
  327 + $gruda = ', ';
  328 + }
  329 +
  330 + if (is_numeric($this->ref_usuario_exc)) {
  331 + $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'";
  332 + $gruda = ', ';
  333 + }
  334 +
  335 + if (is_numeric($this->ref_usuario_cad)) {
  336 + $set .= "{$gruda}ref_usuario_cad = '{$this->ref_usuario_cad}'";
  337 + $gruda = ', ';
  338 + }
  339 +
  340 + if (is_string($this->data_inicio)) {
  341 + $set .= "{$gruda}data_inicio = '{$this->data_inicio}'";
  342 + $gruda = ', ';
  343 + }
  344 +
  345 + if (is_string($this->data_fim)) {
  346 + $set .= "{$gruda}data_fim = '{$this->data_fim}'";
  347 + $gruda = ', ';
  348 + }
  349 +
  350 + if (is_string($this->data_cadastro)) {
  351 + $set .= "{$gruda}data_cadastro = '{$this->data_cadastro}'";
  352 + $gruda = ', ';
  353 + }
  354 +
  355 + $set .= "{$gruda}data_exclusao = NOW()";
  356 + $gruda = ', ';
  357 +
  358 + if (is_numeric($this->ativo)) {
  359 + $set .= "{$gruda}ativo = '{$this->ativo}'";
  360 + $gruda = ', ';
  361 + }
  362 +
  363 + if ($set) {
  364 + $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE cod_compensado = '{$this->cod_compensado}'");
  365 + return TRUE;
  366 + }
  367 + }
  368 +
  369 + return FALSE;
  370 + }
  371 +
  372 + /**
  373 + * Retorna uma lista de registros filtrados de acordo com os parâmetros
  374 + * @return array
  375 + */
  376 + function lista($int_cod_compensado = NULL, $int_ref_cod_escola = NULL,
  377 + $int_ref_ref_cod_instituicao = NULL, $int_ref_cod_servidor = NULL,
  378 + $int_ref_usuario_exc = NULL, $int_ref_usuario_cad = NULL,
  379 + $date_data_inicio_ini = NULL, $date_data_inicio_fim = NULL,
  380 + $date_data_fim_ini = NULL, $date_data_fim_fim = NULL,
  381 + $date_data_cadastro_ini = NULL, $date_data_cadastro_fim = NULL,
  382 + $date_data_exclusao_ini = NULL, $date_data_exclusao_fim = NULL,
  383 + $int_ativo = NULL
  384 + ) {
  385 + $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela}";
  386 + $filtros = '';
  387 +
  388 + $whereAnd = ' WHERE ';
  389 +
  390 + if (is_numeric($int_cod_compensado)) {
  391 + $filtros .= "{$whereAnd} cod_compensado = '{$int_cod_compensado}'";
  392 + $whereAnd = ' AND ';
  393 + }
  394 +
  395 + if (is_numeric($int_ref_cod_escola)) {
  396 + $filtros .= "{$whereAnd} ref_cod_escola = '{$int_ref_cod_escola}'";
  397 + $whereAnd = ' AND ';
  398 + }
  399 +
  400 + if (is_numeric($int_ref_ref_cod_instituicao)) {
  401 + $filtros .= "{$whereAnd} ref_ref_cod_instituicao = '{$int_ref_ref_cod_instituicao}'";
  402 + $whereAnd = ' AND ';
  403 + }
  404 +
  405 + if (is_numeric($int_ref_cod_servidor)) {
  406 + $filtros .= "{$whereAnd} ref_cod_servidor = '{$int_ref_cod_servidor}'";
  407 + $whereAnd = ' AND ';
  408 + }
  409 +
  410 + if (is_numeric($int_ref_usuario_exc)) {
  411 + $filtros .= "{$whereAnd} ref_usuario_exc = '{$int_ref_usuario_exc}'";
  412 + $whereAnd = ' AND ';
  413 + }
  414 +
  415 + if (is_numeric($int_ref_usuario_cad)) {
  416 + $filtros .= "{$whereAnd} ref_usuario_cad = '{$int_ref_usuario_cad}'";
  417 + $whereAnd = ' AND ';
  418 + }
  419 +
  420 + if (is_string($date_data_inicio_ini)) {
  421 + $filtros .= "{$whereAnd} data_inicio >= '{$date_data_inicio_ini}'";
  422 + $whereAnd = ' AND ';
  423 + }
  424 +
  425 + if (is_string($date_data_inicio_fim)) {
  426 + $filtros .= "{$whereAnd} data_inicio <= '{$date_data_inicio_fim}'";
  427 + $whereAnd = ' AND ';
  428 + }
  429 +
  430 + if (is_string($date_data_fim_ini)) {
  431 + $filtros .= "{$whereAnd} data_fim >= '{$date_data_fim_ini}'";
  432 + $whereAnd = ' AND ';
  433 + }
  434 +
  435 + if (is_string($date_data_fim_fim)) {
  436 + $filtros .= "{$whereAnd} data_fim <= '{$date_data_fim_fim}'";
  437 + $whereAnd = ' AND ';
  438 + }
  439 +
  440 + if (is_string($date_data_cadastro_ini)) {
  441 + $filtros .= "{$whereAnd} data_cadastro >= '{$date_data_cadastro_ini}'";
  442 + $whereAnd = ' AND ';
  443 + }
  444 +
  445 + if (is_string($date_data_cadastro_fim)) {
  446 + $filtros .= "{$whereAnd} data_cadastro <= '{$date_data_cadastro_fim}'";
  447 + $whereAnd = ' AND ';
  448 + }
  449 +
  450 + if (is_string($date_data_exclusao_ini)) {
  451 + $filtros .= "{$whereAnd} data_exclusao >= '{$date_data_exclusao_ini}'";
  452 + $whereAnd = ' AND ';
  453 + }
  454 +
  455 + if (is_string($date_data_exclusao_fim)) {
  456 + $filtros .= "{$whereAnd} data_exclusao <= '{$date_data_exclusao_fim}'";
  457 + $whereAnd = ' AND ';
  458 + }
  459 +
  460 + if (is_NULL($int_ativo) || $int_ativo) {
  461 + $filtros .= "{$whereAnd} ativo = '1'";
  462 + $whereAnd = ' AND ';
  463 + }
  464 + else {
  465 + $filtros .= "{$whereAnd} ativo = '0'";
  466 + $whereAnd = ' AND ';
  467 + }
  468 +
  469 + $db = new clsBanco();
  470 + $countCampos = count(explode(',', $this->_campos_lista));
  471 + $resultado = array();
  472 +
  473 + $sql .= $filtros . $this->getOrderby() . $this->getLimite();
  474 +
  475 + $this->_total = $db->CampoUnico("SELECT COUNT(0) FROM {$this->_tabela} {$filtros}");
  476 +
  477 + $db->Consulta($sql);
  478 +
  479 + if ($countCampos > 1) {
  480 + while ($db->ProximoRegistro()) {
  481 + $tupla = $db->Tupla();
  482 +
  483 + $tupla['_total'] = $this->_total;
  484 + $resultado[] = $tupla;
  485 + }
  486 + }
  487 + else {
  488 + while ($db->ProximoRegistro()) {
  489 + $tupla = $db->Tupla();
  490 + $resultado[] = $tupla[$this->_campos_lista];
  491 + }
  492 + }
  493 +
  494 + if (count($resultado)) {
  495 + return $resultado;
  496 + }
  497 +
  498 + return FALSE;
  499 + }
  500 +
  501 + /**
  502 + * Retorna um array com os dados de um registro.
  503 + * @return array
  504 + */
  505 + function detalhe()
  506 + {
  507 + if (is_numeric($this->cod_compensado)) {
  508 + $db = new clsBanco();
  509 + $db->Consulta("SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE cod_compensado = '{$this->cod_compensado}'");
  510 + $db->ProximoRegistro();
  511 + return $db->Tupla();
  512 + }
  513 +
  514 + return FALSE;
  515 + }
  516 +
  517 + /**
  518 + * Retorna um array com os dados de um registro.
  519 + * @return array
  520 + */
  521 + function existe()
  522 + {
  523 + if (is_numeric($this->cod_compensado)) {
  524 + $db = new clsBanco();
  525 + $db->Consulta("SELECT 1 FROM {$this->_tabela} WHERE cod_compensado = '{$this->cod_compensado}'");
  526 + $db->ProximoRegistro();
  527 + return $db->Tupla();
  528 + }
  529 +
  530 + return FALSE;
  531 + }
  532 +
  533 + /**
  534 + * Exclui um registro.
  535 + * @return bool
  536 + */
  537 + function excluir()
  538 + {
  539 + if (is_numeric($this->cod_compensado) && is_numeric($this->ref_usuario_exc)) {
  540 + $this->ativo = 0;
  541 + return $this->edita();
  542 + }
  543 +
  544 + return FALSE;
  545 + }
  546 +
  547 + /**
  548 + * Retorna a quantidade de horas compensadas.
  549 + * @return array
  550 + */
  551 + function ServidorHorasCompensadas($int_ref_cod_servidor = NULL,
  552 + $int_ref_cod_escola = NULL, $int_ref_cod_instituicao)
  553 + {
  554 + if (is_numeric($int_ref_cod_servidor)) {
  555 + /*strtotime( '2006-06-06' );
  556 + date( "Y-m-d", time );*/
  557 + $db = new clsBanco();
  558 + $db->Consulta("
  559 + SELECT
  560 + fac.data_inicio,
  561 + fac.data_fim
  562 + FROM
  563 + pmieducar.falta_atraso_compensado fac
  564 + WHERE
  565 + fac.ref_cod_servidor = '{$int_ref_cod_servidor}'
  566 + AND fac.ref_cod_escola = '{$int_ref_cod_escola}'
  567 + AND fac.ref_ref_cod_instituicao = '{$int_ref_cod_instituicao}'");
  568 +
  569 + while ($db->ProximoRegistro()) {
  570 + $tupla = $db->Tupla();
  571 + $resultado[] = $tupla;
  572 + }
  573 +
  574 + $horas_total = 0;
  575 + $minutos_total = 0;
  576 +
  577 + if ($resultado) {
  578 + foreach ( $resultado as $registro ) {
  579 + $data_atual = strtotime($registro['data_inicio']);
  580 + $data_fim = strtotime($registro['data_fim']);
  581 +
  582 + do {
  583 + $db2 = new clsBanco();
  584 +
  585 + $dia_semana = $db2->CampoUnico("SELECT EXTRACT(DOW FROM (date '".date('Y-m-d', $data_atual)."') + 1)");
  586 + $obj_servidor = new clsPmieducarServidor();
  587 + $horas = $obj_servidor->qtdhoras($int_ref_cod_servidor,
  588 + $int_ref_cod_escola, $int_ref_cod_instituicao, $dia_semana);
  589 +
  590 + if ($horas) {
  591 + $horas_total += $horas['hora'];
  592 + $minutos_total += $horas['min'];
  593 + }
  594 +
  595 + $data_atual += 86400;
  596 + } while ($data_atual <= $data_fim);
  597 + }
  598 + }
  599 +
  600 + $res['hora'] = $horas_total;
  601 + $res['min'] = $minutos_total;
  602 +
  603 + return $res;
  604 + }
  605 +
  606 + return FALSE;
  607 + }
  608 +
  609 +/**
  610 + * Define quais campos da tabela serão selecionados no método Lista().
  611 + */
  612 + function setCamposLista($str_campos)
  613 + {
  614 + $this->_campos_lista = $str_campos;
  615 + }
  616 +
  617 + /**
  618 + * Define que o método Lista() deverpa retornar todos os campos da tabela.
  619 + */
  620 + function resetCamposLista()
  621 + {
  622 + $this->_campos_lista = $this->_todos_campos;
  623 + }
  624 +
  625 + /**
  626 + * Define limites de retorno para o método Lista().
  627 + */
  628 + function setLimite($intLimiteQtd, $intLimiteOffset = NULL)
  629 + {
  630 + $this->_limite_quantidade = $intLimiteQtd;
  631 + $this->_limite_offset = $intLimiteOffset;
  632 + }
  633 +
  634 + /**
  635 + * Retorna a string com o trecho da query responsável pelo limite de
  636 + * registros retornados/afetados.
  637 + *
  638 + * @return string
  639 + */
  640 + function getLimite()
  641 + {
  642 + if (is_numeric($this->_limite_quantidade)) {
  643 + $retorno = " LIMIT {$this->_limite_quantidade}";
  644 + if (is_numeric($this->_limite_offset)) {
  645 + $retorno .= " OFFSET {$this->_limite_offset} ";
  646 + }
  647 + return $retorno;
  648 + }
  649 + return '';
  650 + }
  651 +
  652 + /**
  653 + * Define o campo para ser utilizado como ordenação no método Lista().
  654 + */
  655 + function setOrderby($strNomeCampo)
  656 + {
  657 + if (is_string($strNomeCampo) && $strNomeCampo ) {
  658 + $this->_campo_order_by = $strNomeCampo;
  659 + }
  660 + }
  661 +
  662 + /**
  663 + * Retorna a string com o trecho da query responsável pela Ordenação dos
  664 + * registros.
  665 + *
  666 + * @return string
  667 + */
  668 + function getOrderby()
  669 + {
  670 + if (is_string($this->_campo_order_by)) {
  671 + return " ORDER BY {$this->_campo_order_by} ";
  672 + }
  673 + return '';
  674 + }
  675 +}
724 676 \ No newline at end of file
... ...