educar_exemplar_lst.php
16.7 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
<?php
require_once ("include/clsBase.inc.php");
require_once ("include/clsListagem.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 - Exemplar" );
$this->processoAp = "606";
}
}
class indice extends clsListagem
{
/**
* Referencia pega da session para o idpes do usuario atual
*
* @var int
*/
var $pessoa_logada;
/**
* Titulo no topo da pagina
*
* @var int
*/
var $titulo;
/**
* Quantidade de registros a ser apresentada em cada pagina
*
* @var int
*/
var $limite;
/**
* Inicio dos registros a serem exibidos (limit)
*
* @var int
*/
var $offset;
var $cod_exemplar;
var $ref_cod_fonte;
var $ref_cod_motivo_baixa;
var $ref_cod_acervo;
var $ref_cod_situacao;
var $ref_usuario_exc;
var $ref_usuario_cad;
var $permite_emprestimo;
var $preco;
var $data_cadastro;
var $data_exclusao;
var $ativo;
var $data_aquisicao;
var $ref_cod_biblioteca;
var $ref_cod_instituicao;
var $ref_cod_escola;
var $ref_cod_acervo_colecao;
var $ref_cod_acervo_editora;
var $titulo_livro;
function Gerar()
{
$this->titulo = "Exemplar - Listagem";
foreach( $_GET AS $var => $val ) // passa todos os valores obtidos no GET para atributos do objeto
$this->$var = ( $val === "" ) ? null: $val;
$lista_busca = array(
"Tombo",
"Obra",
"Tipo"
);
// Filtros de Foreign Keys
$get_escola = true;
$get_biblioteca = true;
$get_cabecalho = "lista_busca";
include("include/pmieducar/educar_campo_lista.php");
$this->addCabecalhos($lista_busca);
$opcoes = array( "" => "Selecione" );
$opcoes_colecao = array();
$opcoes_colecao[""] = "Selecione";
$opcoes_editora = array();
$opcoes_editora[""] = "Selecione";
$opcoes_fonte = array();
$opcoes_fonte[""] = "Selecione";
if( $this->ref_cod_biblioteca )
{
$objTemp = new clsPmieducarExemplarTipo();
$lista = $objTemp->lista(null,$this->ref_cod_biblioteca);
if ( is_array( $lista ) && count( $lista ) )
{
foreach ( $lista as $registro )
{
$opcoes["{$registro['cod_exemplar_tipo']}"] = "{$registro['nm_tipo']}";
}
}
$obj_colecao = new clsPmieducarAcervoColecao();
$obj_colecao->setOrderby("nm_colecao ASC");
$obj_colecao->setCamposLista("cod_acervo_colecao, nm_colecao");
$lst_colecao = $obj_colecao->lista(null, null, null, null, null, null, null, null, null, 1, $this->ref_cod_biblioteca);
if (is_array($lst_colecao))
{
foreach ($lst_colecao as $colecao)
{
$opcoes_colecao[$colecao["cod_acervo_colecao"]] = $colecao["nm_colecao"];
}
}
$obj_editora = new clsPmieducarAcervoEditora();
$obj_editora->setCamposLista("cod_acervo_editora, nm_editora");
$obj_editora->setOrderby("nm_editora ASC");
$lst_editora = $obj_editora->lista(null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, 1, $this->ref_cod_biblioteca);
if (is_array($lst_editora))
{
foreach ($lst_editora as $editora)
{
$opcoes_editora[$editora["cod_acervo_editora"]] = $editora["nm_editora"];
}
}
$obj_fonte = new clsPmieducarFonte();
$obj_fonte->setOrderby("nm_fonte ASC");
$obj_fonte->setCamposLista("cod_fonte, nm_fonte");
$lst_fonte = $obj_fonte->lista(null, null, null, null, null, null, null, null, null, 1, $this->ref_cod_biblioteca);
if (is_array($lst_fonte))
{
foreach ($lst_fonte as $fonte)
{
$opcoes_fonte[$fonte["cod_fonte"]] = $fonte["nm_fonte"];
}
}
}
$this->campoLista( "ref_cod_exemplar_tipo", "Exemplar Tipo", $opcoes, $this->ref_cod_exemplar_tipo,null,null,null,null,null,false );
$this->campoLista("ref_cod_acervo_colecao", "Acervo Coleção", $opcoes_colecao, $this->ref_cod_acervo_colecao, "", false, "", "", false, false);
$this->campoLista("ref_cod_acervo_editora", "Editora", $opcoes_editora, $this->ref_cod_acervo_editora, "", false, "", "", false, false);
$this->campoLista("ref_cod_fonte", "Fonte", $opcoes_fonte, $this->ref_cod_fonte, "", false, "", "", false, false);
$this->campoTexto("titulo_livro","Título da Obra",$this->titulo_livro,25,255,false);
$this->campoNumero("cod_exemplar","Tombo",$this->cod_exemplar,10,50,false);
$opcoes = array( "NULL" => "Selecione" );
if( $this->ref_cod_acervo && $this->ref_cod_acervo != "NULL")
{
$objTemp = new clsPmieducarAcervo($this->ref_cod_acervo);
$detalhe = $objTemp->detalhe();
if ( $detalhe )
{
$opcoes["{$detalhe['cod_acervo']}"] = "{$detalhe['titulo']}";
}
}
// Paginador
$this->limite = 20;
$this->offset = ( $_GET["pagina_{$this->nome}"] ) ? $_GET["pagina_{$this->nome}"]*$this->limite-$this->limite: 0;
$obj_exemplar = new clsPmieducarExemplar();
if (App_Model_IedFinder::usuarioNivelBibliotecaEscolar($this->pessoa_logada)) {
$obj_exemplar->codUsuario = $this->pessoa_logada;
}
$obj_exemplar->setOrderby( "tombo ASC" );
$obj_exemplar->setLimite( $this->limite, $this->offset );
$lista = $obj_exemplar->lista_com_acervos(
null,
$this->ref_cod_fonte,
null,
null,
null,
null,
null,
null,
null,
null,
null,
1,
null,
null,
null,
null,
$this->ref_cod_exemplar_tipo,
$this->titulo_livro,
$this->ref_cod_biblioteca,
$this->ref_cod_instituicao,
$this->ref_cod_escola,
$this->ref_cod_acervo_colecao,
$this->ref_cod_acervo_editora,
$this->cod_exemplar
);
$total = $obj_exemplar->_total;
// monta a lista
if( is_array( $lista ) && count( $lista ) )
{
foreach ( $lista AS $registro )
{
// muda os campos data
$registro["data_aquisicao_time"] = strtotime( substr( $registro["data_aquisicao"], 0, 16 ) );
$registro["data_aquisicao_br"] = date( "d/m/Y H:i", $registro["data_aquisicao_time"] );
$obj_ref_cod_fonte = new clsPmieducarFonte( $registro["ref_cod_fonte"] );
$det_ref_cod_fonte = $obj_ref_cod_fonte->detalhe();
$registro["ref_cod_fonte"] = $det_ref_cod_fonte["nm_fonte"];
$obj_ref_cod_motivo_baixa = new clsPmieducarMotivoBaixa( $registro["ref_cod_motivo_baixa"] );
$det_ref_cod_motivo_baixa = $obj_ref_cod_motivo_baixa->detalhe();
$registro["ref_cod_motivo_baixa"] = $det_ref_cod_motivo_baixa["nm_motivo_baixa"];
$obj_ref_cod_acervo = new clsPmieducarAcervo( $registro["ref_cod_acervo"] );
$det_ref_cod_acervo = $obj_ref_cod_acervo->detalhe();
$registro["ref_cod_acervo"] = $det_ref_cod_acervo["titulo"] . " " . $det_ref_cod_acervo["sub_titulo"];
$obj_ref_cod_tipo = new clsPmieducarExemplarTipo( $det_ref_cod_acervo["ref_cod_exemplar_tipo"] );
$det_ref_cod_tipo = $obj_ref_cod_tipo->detalhe();
$registro["ref_cod_tipo"] = $det_ref_cod_tipo["nm_tipo"];
$obj_ref_cod_situacao = new clsPmieducarSituacao( $registro["ref_cod_situacao"] );
$det_ref_cod_situacao = $obj_ref_cod_situacao->detalhe();
$registro["ref_cod_situacao"] = $det_ref_cod_situacao["nm_situacao"];
$obj_ref_cod_biblioteca = new clsPmieducarBiblioteca( $registro["ref_cod_biblioteca"] );
$det_ref_cod_biblioteca = $obj_ref_cod_biblioteca->detalhe();
$registro["ref_cod_biblioteca"] = $det_ref_cod_biblioteca["nm_biblioteca"];
$registro["ref_cod_instituicao"] = $det_ref_cod_biblioteca["ref_cod_instituicao"];
$registro["ref_cod_escola"] = $det_ref_cod_biblioteca["ref_cod_escola"];
if( $registro["ref_cod_instituicao"] )
{
$obj_ref_cod_instituicao = new clsPmieducarInstituicao( $registro["ref_cod_instituicao"] );
$det_ref_cod_instituicao = $obj_ref_cod_instituicao->detalhe();
$registro["ref_cod_instituicao"] = $det_ref_cod_instituicao["nm_instituicao"];
}
if( $registro["ref_cod_escola"] )
{
$obj_ref_cod_escola = new clsPmieducarEscola();
$det_ref_cod_escola = array_shift($obj_ref_cod_escola->lista($registro["ref_cod_escola"]));
$registro["ref_cod_escola"] = $det_ref_cod_escola["nome"];
}
$lista_busca = array(
"<a href=\"educar_exemplar_det.php?cod_exemplar={$registro["cod_exemplar"]}\">{$registro["tombo"]}</a>",
"<a href=\"educar_exemplar_det.php?cod_exemplar={$registro["cod_exemplar"]}\">{$registro["ref_cod_acervo"]}</a>",
"<a href=\"educar_exemplar_det.php?cod_exemplar={$registro["cod_exemplar"]}\">{$registro["ref_cod_tipo"]}</a>"
);
if ($qtd_bibliotecas > 1 && ($nivel_usuario == 4 || $nivel_usuario == 8))
$lista_busca[] = "<a href=\"educar_exemplar_det.php?cod_exemplar={$registro["cod_exemplar"]}\">{$registro["ref_cod_biblioteca"]}</a>";
else if ($nivel_usuario == 1 || $nivel_usuario == 2 || $nivel_usuario == 4)
$lista_busca[] = "<a href=\"educar_exemplar_det.php?cod_exemplar={$registro["cod_exemplar"]}\">{$registro["ref_cod_biblioteca"]}</a>";
if ($nivel_usuario == 1 || $nivel_usuario == 2)
$lista_busca[] = "<a href=\"educar_exemplar_det.php?cod_exemplar={$registro["cod_exemplar"]}\">{$registro["ref_cod_escola"]}</a>";
if ($nivel_usuario == 1)
$lista_busca[] = "<a href=\"educar_exemplar_det.php?cod_exemplar={$registro["cod_exemplar"]}\">{$registro["ref_cod_instituicao"]}</a>";
$this->addLinhas($lista_busca);
}
}
$this->addPaginador2( "educar_exemplar_lst.php", $total, $_GET, $this->nome, $this->limite );
$obj_permissoes = new clsPermissoes();
if( $obj_permissoes->permissao_cadastra( 606, $this->pessoa_logada, 11 ) )
{
$this->acao = "go(\"educar_exemplar_cad.php\")";
$this->nome_acao = "Novo";
}
$this->largura = "100%";
$this->breadcrumb('Listagem de exemplares', [
url('intranet/educar_biblioteca_index.php') => 'Biblioteca',
]);
}
}
// 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>
/*
var before_getTipo = function(){}
var after_getTipo = function(){}
*/
function getExemplarTipo(xml_exemplar_tipo)
{
/*
before_getTipo();
var campoTipo = document.getElementById('ref_cod_exemplar_tipo');
var campoBiblioteca = document.getElementById('ref_cod_biblioteca');
campoTipo.length = 1;
for (var j = 0; j < tipos.length; j++)
{
if (tipos[j][2] == campoBiblioteca.value)
{
campoTipo.options[campoTipo.options.length] = new Option( tipos[j][1], tipos[j][0],false,false);
}
}
after_getTipo();
*/
var campoTipo = document.getElementById('ref_cod_exemplar_tipo');
var DOM_array = xml_exemplar_tipo.getElementsByTagName( "exemplar_tipo" );
if(DOM_array.length)
{
campoTipo.length = 1;
campoTipo.options[0].text = 'Selecione um tipo de exemplar';
campoTipo.disabled = false;
for( var i = 0; i < DOM_array.length; i++ )
{
campoTipo.options[campoTipo.options.length] = new Option( DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_exemplar_tipo"),false,false);
}
}
else
campoTipo.options[0].text = 'A biblioteca não possui nenhum tipo de exemplar';
}
function getAcervoColecao(xml_acervo_colecao)
{
var campoColecao = document.getElementById('ref_cod_acervo_colecao');
var DOM_array = xml_acervo_colecao.getElementsByTagName( "acervo_colecao" );
if(DOM_array.length)
{
campoColecao.length = 1;
campoColecao.options[0].text = 'Selecione uma coleção';
campoColecao.disabled = false;
for( var i = 0; i < DOM_array.length; i++ )
{
campoColecao.options[campoColecao.options.length] = new Option( DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_acervo_colecao"),false,false);
}
}
else
campoColecao.options[0].text = 'A biblioteca não possui nenhuma coleção';
}
function getAcervoEditora(xml_acervo_editora)
{
var campoEditora = document.getElementById('ref_cod_acervo_editora');
var DOM_array = xml_acervo_editora.getElementsByTagName( "acervo_editora" );
if(DOM_array.length)
{
campoEditora.length = 1;
campoEditora.options[0].text = 'Selecione uma editora';
campoEditora.disabled = false;
for( var i = 0; i < DOM_array.length; i++ )
{
campoEditora.options[campoEditora.options.length] = new Option( DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_acervo_editora"),false,false);
}
}
else
campoEditora.options[0].text = 'A biblioteca não possui nenhuma editora';
}
function getFonte(xml_fonte)
{
var campoFonte = document.getElementById('ref_cod_fonte');
var DOM_array = xml_fonte.getElementsByTagName( "fonte" );
if(DOM_array.length)
{
campoFonte.length = 1;
campoFonte.options[0].text = 'Selecione uma fonte';
campoFonte.disabled = false;
for( var i = 0; i < DOM_array.length; i++ )
{
campoFonte.options[campoFonte.options.length] = new Option( DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_acervo_editora"),false,false);
}
}
else
campoFonte.options[0].text = 'A biblioteca não possui nenhuma editora';
}
document.getElementById('ref_cod_biblioteca').onchange = function()
{
// getTipo();
var campoBiblioteca = document.getElementById('ref_cod_biblioteca').value;
var campoTipo = document.getElementById('ref_cod_exemplar_tipo');
campoTipo.length = 1;
campoTipo.disabled = true;
campoTipo.options[0].text = 'Carregando tipo de exemplar';
var xml_exemplar_tipo = new ajax( getExemplarTipo );
xml_exemplar_tipo.envia( "educar_exemplar_tipo_xml.php?bib="+campoBiblioteca );
var campoColecao = document.getElementById('ref_cod_acervo_colecao');
campoColecao.length = 1;
campoColecao.disabled = true;
campoColecao.options[0].text = 'Carregando coleção';
var xml_acervo_colecao = new ajax(getAcervoColecao);
xml_acervo_colecao.envia("educar_acervo_colecao_xml.php?bib="+campoBiblioteca);
var campoEditora = document.getElementById('ref_cod_acervo_editora');
campoEditora.length = 1;
campoEditora.disabled = true;
campoEditora.options[0].text = 'Carregando editora';
var xml_acervo_editora = new ajax(getAcervoEditora);
xml_acervo_editora.envia("educar_acervo_editora_xml.php?bib="+campoBiblioteca);
var campoFonte = document.getElementById('ref_cod_fonte');
campoFonte.length = 1;
campoFonte.disabled = true;
campoFonte.options[0].text = 'Carregando fonte';
var xml_acervo_fonte = new ajax(getFonte);
xml_acervo_fonte.envia("educar_fonte_xml.php?bib="+campoBiblioteca);
};
function pesquisa()
{
var biblioteca = document.getElementById('ref_cod_biblioteca').value;
if(!biblioteca)
{
alert('Por favor,\nselecione uma biblioteca!');
return;
}
pesquisa_valores_popless('educar_pesquisa_acervo_lst.php?campo1=ref_cod_acervo&ref_cod_bilioteca=' + biblioteca , 'ref_cod_acervo')
}
//pesquisa_valores_popless('educar_pesquisa_acervo_lst.php?campo1=ref_cod_acervo', 'ref_cod_acervo')
</script>