educar_pagamento_multa_cad.php
8.11 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
<?php
/**
* @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";
}
}
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_pagamento;
var $valor_pendente;
var $data_cadastro;
var $ref_cod_biblioteca;
var $total_divida;
function Inicializar()
{
$retorno = "Novo";
$this->ref_cod_cliente = $_GET["cod_cliente"];
$this->ref_cod_biblioteca = $_GET["cod_biblioteca"];
if(!$this->ref_cod_cliente || !$this->ref_cod_biblioteca)
$this->simpleRedirect('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_total_divida = new clsPmieducarExemplarEmprestimo();
$total_obj_divida = $obj_total_divida->totalMultaPorBiblioteca( $this->ref_cod_cliente, $this->ref_cod_biblioteca, true );
$this->total_divida = $total_obj_divida[0]['sum'];
$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, null, $this->ref_cod_biblioteca);
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()";
$this->valor_pendente = $this->total_divida - $this->valor_pago_bib;
$this->breadcrumb('Pagamento da dívida', [
url('intranet/educar_biblioteca_index.php') => 'Biblioteca',
]);
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( "total_divida", "Total de dívidas", $this->total_divida, 11, 11, false, "", "", "onChange", true );
$this->campoMonetario( "valor_pago_bib", "Total pago", $this->valor_pago_bib, 11, 11, false, "", "", "onChange", true );
$this->campoMonetario( "valor_pendente", "Total pendente", $this->valor_pendente, 11, 11, false, "", "", "onChange", true );
$this->campoMonetario( "valor_pagamento", "Valor do Pagamento", $this->valor_pagamento, 11, 11, true );
}
function Novo()
{
$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>";
$this->simpleRedirect('educar_pagamento_multa_lst.php');
}
$this->mensagem = "Cadastro não realizado.<br>";
return false;
}
function Editar()
{
$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>";
$this->simpleRedirect('educar_pagamento_multa_lst.php');
}
$this->mensagem = "Edição não realizada.<br>";
return false;
}
function Excluir()
{
$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>";
$this->simpleRedirect('educar_pagamento_multa_lst.php');
}
$this->mensagem = "Exclusão não realizada.<br>";
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_pago_bib;
var valor_pagamento;
var total_divida;
var valor_pendente;
if ( document.getElementById('total_divida') )
total_divida = document.getElementById('total_divida').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 ( document.getElementById('valor_pendente') )
valor_pendente = document.getElementById('valor_pendente').value;
if ( ( total_divida.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>