educar_reservas_login_cad.php
7.29 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
<?php
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\URL;
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 - Reservas" );
$this->processoAp = "609";
}
}
class indice extends clsCadastro
{
/**
* Referencia pega da session para o idpes do usuario atual
*
* @var int
*/
var $pessoa_logada;
var $ref_cod_biblioteca;
var $login_;
var $senha_;
var $ref_cod_cliente;
function Inicializar()
{
$retorno = "Novo";
Session::forget([
'reservas.cod_cliente',
'reservas.ref_cod_biblioteca',
]);
return $retorno;
}
function Gerar()
{
unset($this->login_);
unset($this->senha_);
unset($this->ref_cod_biblioteca);
$get_escola = 1;
$escola_obrigatorio = false;
$get_biblioteca = 1;
$instituicao_obrigatorio = true;
$biblioteca_obrigatorio = true;
include("include/pmieducar/educar_campo_lista.php");
// text
$this->campoNumero( "login_", "Login", $this->login_, 9, 9);
$this->campoSenha( "senha_", "Senha", $this->senha_ );
$this->campoTexto("nm_cliente1", "Cliente", $this->nm_cliente, 30, 255, false, false, false, "", "<img border=\"0\" onclick=\"pesquisa_cliente();\" id=\"ref_cod_cliente_lupa\" name=\"ref_cod_cliente_lupa\" src=\"imagens/lupa.png\"\/>","","",true );
$this->campoOculto("ref_cod_cliente", $this->ref_cod_cliente);
$this->botao_enviar = false;
$this->array_botao = array("Continuar", "Cancelar");
$this->array_botao_url_script = array("acao();","go('educar_reservas_lst.php');");
}
function Novo()
{
$obj_permissoes = new clsPermissoes();
$obj_permissoes->permissao_cadastra( 610, $this->pessoa_logada, 11, "educar_reservas_lst.php" );
if ($this->ref_cod_cliente)
{
Session::put([
'reservas.cod_cliente' => $this->ref_cod_cliente,
'reservas.ref_cod_biblioteca' => $this->ref_cod_biblioteca,
]);
throw new HttpResponseException(
new RedirectResponse(
URL::to('intranet/educar_reservas_cad.php')
)
);
}
else if($this->login_ && $this->senha_)
{
$this->senha_ = md5( $this->senha_."asnk@#*&(23" );
$obj_cliente = new clsPmieducarCliente();
$lst_cliente = $obj_cliente->lista(null,null,null,null,$this->login_,$this->senha_,null,null,null,null,1);
if( is_array( $lst_cliente ) && count( $lst_cliente ) )
{
$cliente = array_shift($lst_cliente);
$cod_cliente = $cliente["cod_cliente"];
$obj_cliente_tipo_cliente = new clsPmieducarClienteTipoCliente();
$lst_cliente_tipo_cliente = $obj_cliente_tipo_cliente->lista(null,$cod_cliente);
if( is_array( $lst_cliente_tipo_cliente ) && count( $lst_cliente_tipo_cliente ) )
{
foreach ($lst_cliente_tipo_cliente as $cliente_tipo)
{
// tipo do cliente
$cod_cliente_tipo = $cliente_tipo["ref_cod_cliente_tipo"];
$obj_cliente_tipo = new clsPmieducarClienteTipo($cod_cliente_tipo);
$det_cliente_tipo = $obj_cliente_tipo->detalhe();
$biblioteca_cliente = $det_cliente_tipo["ref_cod_biblioteca"];
if ($this->ref_cod_biblioteca == $biblioteca_cliente)
{
Session::put([
'reservas.cod_cliente' => $cod_cliente,
'reservas.ref_cod_biblioteca' => $this->ref_cod_biblioteca,
]);
throw new HttpResponseException(
new RedirectResponse(
URL::to('intranet/educar_reservas_cad.php')
)
);
}
}
echo "<script> alert('Cliente não pertence a biblioteca escolhida!'); </script>";
return true;
}
}
else
{
$this->mensagem = "Login e/ou Senha incorreto(s).<br>";
return false;
}
}
else
{
$this->mensagem = "Preencha o(s) campo(s) corretamente.<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>
document.getElementById('login_').setAttribute('autocomplete','off');
document.getElementById('login_').onkeypress = function(e)
{
//IE bug
if(!e)
e = window.event;
if(e.keyCode == 13)
document.getElementById('senha_').focus();
}
document.getElementById('senha_').onkeypress = function(e)
{
//IE bug
if(!e)
e = window.event;
if(e.keyCode == 13)
document.getElementById('btn_enviar').focus();
else if(e.keyCode == 8)
document.getElementById('senha_').value = null;
}
function pesquisa_cliente()
{
var campoBiblioteca = document.getElementById('ref_cod_biblioteca').value;
pesquisa_valores_popless('educar_pesquisa_cliente_lst.php?campo1=ref_cod_cliente&campo2=nm_cliente1&ref_cod_biblioteca='+campoBiblioteca)
}
setVisibility('tr_login_', false);
setVisibility('tr_senha_', false);
setVisibility('tr_nm_cliente', false);
function requisitaSenha(xml_tipo_regime)
{
var campoBiblioteca = document.getElementById('ref_cod_biblioteca').value;
var DOM_array = xml_tipo_regime.getElementsByTagName( "biblioteca" );
if (campoBiblioteca == '')
{
setVisibility('tr_login_', false);
setVisibility('tr_senha_', false);
setVisibility('tr_nm_cliente', false);
}
else
{
for( var i = 0; i < DOM_array.length; i++ )
{
if (DOM_array[i].getAttribute("requisita_senha") == 0)
{
setVisibility('tr_login_', false);
setVisibility('tr_senha_', false);
setVisibility('tr_nm_cliente', true);
}
else if (DOM_array[i].getAttribute("requisita_senha") == 1)
{
setVisibility('tr_nm_cliente', false);
setVisibility('tr_login_', true);
setVisibility('tr_senha_', true);
}
}
}
}
document.getElementById('ref_cod_biblioteca').onchange = function()
{
// requisitaSenha();
var campoBiblioteca = document.getElementById('ref_cod_biblioteca').value;
var xml_biblioteca = new ajax( requisitaSenha );
xml_biblioteca.envia( "educar_biblioteca_xml.php?bib="+campoBiblioteca );
}
</script>