educar_pagamento_multa_cad.php
9.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @author Prefeitura Municipal de Itajaí *
* @updated 29/03/2007 *
* Pacote: i-PLB Software Público Livre e Brasileiro *
* *
* Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí *
* ctima@itajai.sc.gov.br *
* *
* Este programa é software livre, você pode redistribuí-lo e/ou *
* modificá-lo sob os termos da Licença Pública Geral GNU, conforme *
* publicada pela Free Software Foundation, tanto a versão 2 da *
* Licença como (a seu critério) qualquer versão mais nova. *
* *
* Este programa é distribuído na expectativa de ser útil, mas SEM *
* QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- *
* ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- *
* sulte a Licença Pública Geral GNU para obter mais detalhes. *
* *
* Você deve ter recebido uma cópia da Licença Pública Geral GNU *
* junto com este programa. Se não, escreva para a Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *
* 02111-1307, USA. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* @author Adriano Erik Weiguert Nagasava
*/
require_once ("include/clsBase.inc.php");
require_once ("include/clsCadastro.inc.php");
require_once ("include/clsBanco.inc.php");
require_once( "include/pmieducar/geral.inc.php" );
class clsIndexBase extends clsBase
{
function Formular()
{
$this->SetTitulo( "{$this->_instituicao} i-Educar - Pagamento Multa" );
$this->processoAp = "622";
$this->addEstilo('localizacaoSistema');
}
}
class indice extends clsCadastro
{
/**
* Referencia pega da session para o idpes do usuario atual
*
* @var int
*/
var $pessoa_logada;
var $cod_pagamento_multa;
var $ref_usuario_cad;
var $ref_cod_cliente;
var $nm_pessoa;
var $ref_idpes;
var $valor_pago_bib;
var $valor_divida;
var $valor_divida_bib;
var $valor_pagamento;
var $data_cadastro;
var $ref_cod_biblioteca;
function Inicializar()
{
$retorno = "Novo";
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
$this->ref_cod_cliente = $_GET["cod_cliente"];
$this->ref_cod_biblioteca = $_GET["cod_biblioteca"];
if(!$this->ref_cod_cliente || !$this->ref_cod_biblioteca)
header("Location: educar_pagamento_multa_lst.php");
$obj_permissoes = new clsPermissoes();
$obj_permissoes->permissao_cadastra( 622, $this->pessoa_logada, 11, "educar_pagamento_multa_lst.php" );
if ( is_numeric( $this->ref_cod_cliente ) ) {
$obj_exemplar_emprestimo = new clsPmieducarExemplarEmprestimo();
$lst_exemplar_emprestimo = $obj_exemplar_emprestimo->listaDividaPagamentoCliente( $this->ref_cod_cliente, null, $this->ref_cod_cliente_tipo, $this->pessoa_logada, $this->ref_cod_biblioteca, $this->ref_cod_escola, $this->ref_cod_instituicao );
if ( $lst_exemplar_emprestimo ) {
foreach ( $lst_exemplar_emprestimo as $registro ) {
if ( is_numeric( $registro["valor_multa"] ) )
$this->valor_divida_bib = $registro["valor_multa"];
else
$this->valor_divida_bib = 0;
if ( is_numeric( $registro["valor_pago"] ) )
$this->valor_pago_bib = $registro["valor_pago"];
else
$this->valor_pago_bib = 0;
}
}
$obj_cliente = new clsPmieducarCliente( $this->ref_cod_cliente );
$det_cliente = $obj_cliente->detalhe();
if ( $det_cliente ) {
$this->ref_idpes = $det_cliente["ref_idpes"];
$obj_pessoa = new clsPessoa_( $this->ref_idpes );
$det_pessoa = $obj_pessoa->detalhe();
if ( $det_pessoa )
$this->nm_pessoa = $det_pessoa["nome"];
$obj_divida = new clsPmieducarExemplarEmprestimo( null, null, null, $this->ref_cod_cliente );
$det_divida = $obj_divida->clienteDividaTotal( $this->ref_idpes, $this->ref_cod_cliente );
if ( $det_divida ) {
foreach ( $det_divida as $divida )
$this->valor_divida = $divida["valor_multa"];
}
}
}
$this->url_cancelar = ($retorno == "Editar") ? "educar_pagamento_multa_det.php?cod_cliente={$this->ref_cod_cliente}" : "educar_pagamento_multa_lst.php";
$this->nome_url_cancelar = "Cancelar";
$this->nome_url_sucesso = "Pagar";
$this->acao_enviar = "validaValor()";
$localizacao = new LocalizacaoSistema();
$localizacao->entradaCaminhos( array(
$_SERVER['SERVER_NAME']."/intranet" => "Início",
"educar_biblioteca_index.php" => "i-Educar - Biblioteca",
"" => "Pagamendo da dívida"
));
$this->enviaLocalizacao($localizacao->montar());
return $retorno;
}
function Gerar()
{
$this->campoOculto( "ref_cod_cliente", $this->ref_cod_cliente );
$this->campoOculto( "ref_cod_biblioteca", $this->ref_cod_biblioteca );
$this->campoRotulo( "nm_cliente", "Cliente", $this->nm_pessoa );
$this->campoMonetario( "valor_divida", "Total da Dívida", $this->valor_divida, 11, 11, false, "", "", "onChange", true );
$this->campoMonetario( "valor_divida_bib", "Total da Dívida (Biblioteca)", $this->valor_divida_bib, 11, 11, false, "", "", "onChange", true );
$this->campoMonetario( "valor_pago_bib", "Valor Pago (Biblioteca)", $this->valor_pago_bib, 11, 11, false, "", "", "onChange", true );
$this->campoMonetario( "valor_pagamento", "Valor do Pagamento", $this->valor_pagamento, 11, 11, true );
}
function Novo()
{
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
$obj_permissoes = new clsPermissoes();
$obj_permissoes->permissao_cadastra( 622, $this->pessoa_logada, 11, "educar_pagamento_multa_lst.php" );
$this->valor_pagamento = str_replace( ",", ".", $this->valor_pagamento );
$obj = new clsPmieducarPagamentoMulta( null, $this->pessoa_logada, $this->ref_cod_cliente, $this->valor_pagamento, null, $this->ref_cod_biblioteca );
$cadastrou = $obj->cadastra();
if( $cadastrou )
{
$this->mensagem .= "Cadastro efetuado com sucesso.<br>";
header( "Location: educar_pagamento_multa_lst.php" );
die();
return true;
}
$this->mensagem = "Cadastro não realizado.<br>";
echo "<!--\nErro ao cadastrar clsPmieducarPagamentoMulta\nvalores obrigatorios\nis_numeric( $this->ref_usuario_cad ) && is_numeric( $this->ref_cod_cliente ) && is_numeric( $this->valor_pago )\n-->";
return false;
}
function Editar()
{
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
$obj_permissoes = new clsPermissoes();
$obj_permissoes->permissao_cadastra( 622, $this->pessoa_logada, 11, "educar_pagamento_multa_lst.php" );
$obj = new clsPmieducarPagamentoMulta( $this->cod_pagamento_multa, null, $this->ref_cod_cliente, $this->valor_pago, null, $this->ref_cod_biblioteca );
$editou = $obj->edita();
if( $editou )
{
$this->mensagem .= "Edição efetuada com sucesso.<br>";
header( "Location: educar_pagamento_multa_lst.php" );
die();
return true;
}
$this->mensagem = "Edição não realizada.<br>";
echo "<!--\nErro ao editar clsPmieducarPagamentoMulta\nvalores obrigatorios\nif( is_numeric( $this->cod_pagamento_multa ) )\n-->";
return false;
}
function Excluir()
{
@session_start();
$this->pessoa_logada = $_SESSION['id_pessoa'];
@session_write_close();
$obj_permissoes = new clsPermissoes();
$obj_permissoes->permissao_excluir( 622, $this->pessoa_logada, 11, "educar_pagamento_multa_lst.php" );
$obj = new clsPmieducarPagamentoMulta( $this->cod_pagamento_multa, null, $this->ref_cod_cliente, $this->valor_pago, null, $this->ref_cod_biblioteca );
$excluiu = $obj->excluir();
if( $excluiu )
{
$this->mensagem .= "Exclusão efetuada com sucesso.<br>";
header( "Location: educar_pagamento_multa_lst.php" );
die();
return true;
}
$this->mensagem = "Exclusão não realizada.<br>";
echo "<!--\nErro ao excluir clsPmieducarPagamentoMulta\nvalores obrigatorios\nif( is_numeric( $this->cod_pagamento_multa ) )\n-->";
return false;
}
}
// cria uma extensao da classe base
$pagina = new clsIndexBase();
// cria o conteudo
$miolo = new indice();
// adiciona o conteudo na clsBase
$pagina->addForm( $miolo );
// gera o html
$pagina->MakeAll();
?>
<script>
function validaValor()
{
var valor_divida_bib;
var valor_pago_bib;
var valor_pagamento;
if ( document.getElementById('valor_divida_bib') )
valor_divida_bib = document.getElementById('valor_divida_bib').value;
if ( document.getElementById('valor_pago_bib') )
valor_pago_bib = document.getElementById('valor_pago_bib').value;
if ( document.getElementById('valor_pagamento') )
valor_pagamento = document.getElementById('valor_pagamento').value;
if ( ( valor_divida_bib.replace(",", ".") - valor_pago_bib.replace(",", ".") ) < valor_pagamento.replace(",", ".") ) {
alert( "O valor de pagamento deve ser inferior ou igual ao valor devido na respectiva biblioteca." );
valor_pagamento = document.getElementById('valor_pagamento').value = "";
return;
}
else
{
document.formcadastro.submit();
}
}
</script>