Commit 00101e5d4d3f7503c636342eb2b8a58b1bf603ff

Authored by Lucas D'Avila
1 parent e9e4b6ed
Exists in master

Corrigido / aplicado melhorias no modulo deprecado biblioteca, adicionado /modul…

…es/Biblioteca com emprestimo reescrito.
Showing 34 changed files with 2294 additions and 866 deletions   Show diff stats
ieducar/intranet/educar_acervo_assunto_cad.php
@@ -56,7 +56,7 @@ class indice extends clsCadastro @@ -56,7 +56,7 @@ class indice extends clsCadastro
56 var $data_exclusao; 56 var $data_exclusao;
57 var $ativo; 57 var $ativo;
58 var $ref_cod_biblioteca; 58 var $ref_cod_biblioteca;
59 - 59 +
60 function Inicializar() 60 function Inicializar()
61 { 61 {
62 $retorno = "Novo"; 62 $retorno = "Novo";
@@ -98,35 +98,12 @@ class indice extends clsCadastro @@ -98,35 +98,12 @@ class indice extends clsCadastro
98 // primary keys 98 // primary keys
99 $this->campoOculto( "cod_acervo_assunto", $this->cod_acervo_assunto ); 99 $this->campoOculto( "cod_acervo_assunto", $this->cod_acervo_assunto );
100 100
101 - // foreign keys  
102 - /*$obj_pessoa_bib = new clsPmieducarBibliotecaUsuario();  
103 - $lst_pessoa_bib = $obj_pessoa_bib->lista(null, $this->pessoa_logada);  
104 -  
105 - $opcoes = array("" => "Selecione");  
106 - if(is_array($lst_pessoa_bib))  
107 - {  
108 - foreach ($lst_pessoa_bib as $bib)  
109 - {  
110 - $obj_biblioteca = new clsPmieducarBiblioteca($bib['ref_cod_biblioteca']);  
111 - $det_biblioteca = $obj_biblioteca->detalhe();  
112 -  
113 - $opcoes[$det_biblioteca['cod_biblioteca']] = $det_biblioteca['nm_biblioteca'];  
114 - }  
115 - }  
116 - $this->campoLista("ref_cod_biblioteca", "Biblioteca", $opcoes, $this->ref_cod_biblioteca);*/  
117 -  
118 - $get_escola = 1;  
119 - $escola_obrigatorio = false;  
120 - $get_biblioteca = 1;  
121 - $instituicao_obrigatorio = true;  
122 - $biblioteca_obrigatorio = true;  
123 - include("include/pmieducar/educar_campo_lista.php"); 101 + //foreign keys
  102 + $this->inputsHelper()->dynamic(array('instituicao', 'escola', 'biblioteca'));
124 103
125 // text 104 // text
126 $this->campoTexto( "nm_assunto", "Assunto", $this->nm_assunto, 30, 255, true ); 105 $this->campoTexto( "nm_assunto", "Assunto", $this->nm_assunto, 30, 255, true );
127 $this->campoMemo( "descricao", "Descrição", $this->descricao, 60, 5, false ); 106 $this->campoMemo( "descricao", "Descrição", $this->descricao, 60, 5, false );
128 -  
129 -  
130 } 107 }
131 108
132 function Novo() 109 function Novo()
@@ -213,4 +190,4 @@ $miolo = new indice(); @@ -213,4 +190,4 @@ $miolo = new indice();
213 $pagina->addForm( $miolo ); 190 $pagina->addForm( $miolo );
214 // gera o html 191 // gera o html
215 $pagina->MakeAll(); 192 $pagina->MakeAll();
216 -?>  
217 \ No newline at end of file 193 \ No newline at end of file
  194 +?>
ieducar/intranet/educar_acervo_cad.php
1 <?php 1 <?php
  2 +
2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 3 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3 * * 4 * *
4 * @author Prefeitura Municipal de Itajaí * 5 * @author Prefeitura Municipal de Itajaí *
@@ -24,10 +25,10 @@ @@ -24,10 +25,10 @@
24 * 02111-1307, USA. * 25 * 02111-1307, USA. *
25 * * 26 * *
26 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 27 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 -require_once ("include/clsBase.inc.php");  
28 -require_once ("include/clsCadastro.inc.php");  
29 -require_once ("include/clsBanco.inc.php");  
30 -require_once( "include/pmieducar/geral.inc.php" ); 28 +require_once "include/clsBase.inc.php";
  29 +require_once "include/clsCadastro.inc.php";
  30 +require_once "include/clsBanco.inc.php";
  31 +require_once "include/pmieducar/geral.inc.php";
31 32
32 class clsIndexBase extends clsBase 33 class clsIndexBase extends clsBase
33 { 34 {
@@ -85,6 +86,11 @@ class indice extends clsCadastro @@ -85,6 +86,11 @@ class indice extends clsCadastro
85 var $idioma; 86 var $idioma;
86 var $autor; 87 var $autor;
87 88
  89 + protected function setSelectionFields()
  90 + {
  91 +
  92 + }
  93 +
88 function Inicializar() 94 function Inicializar()
89 { 95 {
90 $retorno = "Novo"; 96 $retorno = "Novo";
@@ -159,51 +165,9 @@ class indice extends clsCadastro @@ -159,51 +165,9 @@ class indice extends clsCadastro
159 $this->campoOculto( "idioma", "" ); 165 $this->campoOculto( "idioma", "" );
160 $this->campoOculto( "autor", "" ); 166 $this->campoOculto( "autor", "" );
161 167
162 - $get_escola = 1;  
163 - $escola_obrigatorio = false;  
164 - $get_biblioteca = 1;  
165 - $instituicao_obrigatorio = true;  
166 - $biblioteca_obrigatorio = true;  
167 - include("include/pmieducar/educar_campo_lista.php");  
168 -  
169 - // foreign keys  
170 - /*$opcoes = array( "" => "Selecione" );  
171 - if( class_exists( "clsPmieducarExemplarTipo" ) )  
172 - {  
173 - $objTemp = new clsPmieducarExemplarTipo();  
174 - $lista = $objTemp->lista(null,null);  
175 - if ( is_array( $lista ) && count( $lista ) )  
176 - {  
177 - $tipos = "tipos = new Array();\n";  
178 - foreach ( $lista as $registro )  
179 - {  
180 - $tipos .= "tipos[tipos.length] = new Array( {$registro["cod_exemplar_tipo"]}, '{$registro['nm_tipo']}', {$registro['ref_cod_biblioteca']});\n";  
181 -  
182 - }  
183 - echo "<script>{$tipos}</script>";  
184 - }  
185 - }  
186 - else  
187 - {  
188 - echo "<!--\nErro\nClasse clsPmieducarExemplarTipo nao encontrada\n-->";  
189 - }*/  
190 - $opcoes = array( "NULL" => "Selecione" );  
191 -  
192 - if( $this->ref_cod_biblioteca )  
193 - {  
194 - $objTemp = new clsPmieducarExemplarTipo();  
195 - $lista = $objTemp->lista(null,$this->ref_cod_biblioteca);  
196 - if ( is_array( $lista ) && count( $lista ) )  
197 - {  
198 - foreach ( $lista as $registro )  
199 - {  
200 - $opcoes["{$registro['cod_exemplar_tipo']}"] = "{$registro['nm_tipo']}";  
201 - }  
202 - }  
203 - }  
204 -  
205 - $this->campoLista( "ref_cod_exemplar_tipo", "Exemplar Tipo", $opcoes, $this->ref_cod_exemplar_tipo ); 168 + $this->inputsHelper()->dynamic(array('instituicao', 'escola', 'biblioteca', 'bibliotecaTipoExemplar'));
206 169
  170 + // Obra referência
207 $opcoes = array( "NULL" => "Selecione" ); 171 $opcoes = array( "NULL" => "Selecione" );
208 172
209 if( $this->ref_cod_acervo && $this->ref_cod_acervo != "NULL") 173 if( $this->ref_cod_acervo && $this->ref_cod_acervo != "NULL")
@@ -216,9 +180,9 @@ class indice extends clsCadastro @@ -216,9 +180,9 @@ class indice extends clsCadastro
216 } 180 }
217 } 181 }
218 182
219 - //campoListaPesq( $nome, $campo, $valor, $default, $caminho="", $acao = "" , $duplo=false, $descricao="", $descricao2="", $flag=null, $pag_cadastro = null, $disabled = "", $div = false, $serializedcampos = false, $obrigatorio = false )  
220 -// $this->campoListaPesq( "ref_cod_acervo", "Obra Refer&ecirc;ncia", $opcoes, $this->ref_cod_acervo,"educar_pesquisa_acervo_lst.php?campo1=ref_cod_acervo","","","","","","","",true );  
221 $this->campoLista("ref_cod_acervo","Obra Refer&ecirc;ncia",$opcoes,$this->ref_cod_acervo,"",false,"","<img border=\"0\" onclick=\"pesquisa();\" id=\"ref_cod_acervo_lupa\" name=\"ref_cod_acervo_lupa\" src=\"imagens/lupa.png\"\/>",false,false); 183 $this->campoLista("ref_cod_acervo","Obra Refer&ecirc;ncia",$opcoes,$this->ref_cod_acervo,"",false,"","<img border=\"0\" onclick=\"pesquisa();\" id=\"ref_cod_acervo_lupa\" name=\"ref_cod_acervo_lupa\" src=\"imagens/lupa.png\"\/>",false,false);
  184 +
  185 + // Coleção
222 $opcoes = array( "" => "Selecione" ); 186 $opcoes = array( "" => "Selecione" );
223 if( class_exists( "clsPmieducarAcervoColecao" ) ) 187 if( class_exists( "clsPmieducarAcervoColecao" ) )
224 { 188 {
@@ -238,8 +202,8 @@ class indice extends clsCadastro @@ -238,8 +202,8 @@ class indice extends clsCadastro
238 $opcoes = array( "" => "Erro na geracao" ); 202 $opcoes = array( "" => "Erro na geracao" );
239 } 203 }
240 $this->campoLista( "ref_cod_acervo_colecao", "Cole&ccedil;&atilde;o", $opcoes, $this->ref_cod_acervo_colecao,"",false,"","<img id='img_colecao' src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"showExpansivelImprimir(500, 200,'educar_acervo_colecao_cad_pop.php',[], 'Coleção')\" />",false,false ); 204 $this->campoLista( "ref_cod_acervo_colecao", "Cole&ccedil;&atilde;o", $opcoes, $this->ref_cod_acervo_colecao,"",false,"","<img id='img_colecao' src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"showExpansivelImprimir(500, 200,'educar_acervo_colecao_cad_pop.php',[], 'Coleção')\" />",false,false );
241 - //"<img id='imgLupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"pesquisa_valores_popless( 'pesquisa_funcionario_lst.php?campos=".$parametros->serializaCampos()."&importa_cpf=true&chave_campo='+/[0-9]+/.exec(this.previousSibling.previousSibling.id)[0], this.previousSibling.previousSibling.id ); \" />  
242 205
  206 + // Idioma
243 $opcoes = array( "" => "Selecione" ); 207 $opcoes = array( "" => "Selecione" );
244 if( class_exists( "clsPmieducarAcervoIdioma" ) ) 208 if( class_exists( "clsPmieducarAcervoIdioma" ) )
245 { 209 {
@@ -363,7 +327,7 @@ class indice extends clsCadastro @@ -363,7 +327,7 @@ class indice extends clsCadastro
363 $det_acervo_autor = $obj_acervo_autor->detalhe(); 327 $det_acervo_autor = $obj_acervo_autor->detalhe();
364 $nm_autor = $det_acervo_autor["nm_autor"]; 328 $nm_autor = $det_acervo_autor["nm_autor"];
365 $this->campoTextoInv( "ref_cod_exemplar_tipo_{$autor["ref_cod_acervo_autor_"]}", "", $nm_autor, 30, 255, false, false, true ); 329 $this->campoTextoInv( "ref_cod_exemplar_tipo_{$autor["ref_cod_acervo_autor_"]}", "", $nm_autor, 30, 255, false, false, true );
366 - $this->campoCheck( "principal_{$autor["ref_cod_acervo_autor_"]}", "", $autor['principal_'], "<a href='#' onclick=\"getElementById('excluir_autor').value = '{$autor["ref_cod_acervo_autor_"]}'; getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bola_xis.gif' title='Excluir' border=0></a>", false,false,true ); 330 + $this->campoCheck( "principal_{$autor["ref_cod_acervo_autor_"]}", "", $autor['principal_'], "<a href='#' onclick=\"getElementById('excluir_autor').value = '{$autor["ref_cod_acervo_autor_"]}'; getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bola_xis.gif' title='Excluir' border=0></a>", false, false, false );
367 $aux["ref_cod_acervo_autor_"] = $autor["ref_cod_acervo_autor_"]; 331 $aux["ref_cod_acervo_autor_"] = $autor["ref_cod_acervo_autor_"];
368 $aux["principal_"] = $autor['principal_']; 332 $aux["principal_"] = $autor['principal_'];
369 } 333 }
@@ -399,18 +363,14 @@ class indice extends clsCadastro @@ -399,18 +363,14 @@ class indice extends clsCadastro
399 { 363 {
400 // die("1"); 364 // die("1");
401 $this->campoLista( "ref_cod_acervo_autor", "Autor", $opcoes, $this->ref_cod_acervo_autor,null,true,"","",false,true ); 365 $this->campoLista( "ref_cod_acervo_autor", "Autor", $opcoes, $this->ref_cod_acervo_autor,null,true,"","",false,true );
402 - $this->campoCheck( "principal", "&nbsp;&nbsp;<img id='img_autor' src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"showExpansivelImprimir(500, 250,'educar_acervo_autor_cad_pop.php',[], 'Autor')\" /> Principal", $this->principal,"<a href='#' onclick=\"getElementById('incluir_autor').value = 'S'; getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bot_adiciona.gif' title='Incluir' border=0></a>" ); 366 +
  367 + $this->campoCheck( "principal", "&nbsp;&nbsp;<img id='img_autor' src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"showExpansivelImprimir(500, 250,'educar_acervo_autor_cad_pop.php',[], 'Autor')\" />", $this->principal,"<a href='#' onclick=\"getElementById('incluir_autor').value = 'S'; getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bot_adiciona.gif' title='Incluir' border=0></a>" );
403 } 368 }
404 // não existe um autor principal, mas existe um autor 369 // não existe um autor principal, mas existe um autor
405 else if ( ($this->checked != 1) && ($qtd_autor > 0) ) 370 else if ( ($this->checked != 1) && ($qtd_autor > 0) )
406 { 371 {
407 -// echo "principal ".$this->checked;  
408 -// echo "is_array($this->acervo_autor)";  
409 -// print_r($this->acervo_autor);  
410 -//  
411 -// die("2");  
412 $this->campoLista( "ref_cod_acervo_autor", "Autor", $opcoes, $this->ref_cod_acervo_autor,null,true,null, null,null,false); 372 $this->campoLista( "ref_cod_acervo_autor", "Autor", $opcoes, $this->ref_cod_acervo_autor,null,true,null, null,null,false);
413 - $this->campoCheck( "principal", "&nbsp;&nbsp;<img src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"pesquisa_valores_popless( 'educar_acervo_autor_cad_pop.php' )\" /> Principal", $this->principal,"<a href='#' onclick=\"getElementById('incluir_autor').value = 'S'; getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bot_adiciona.gif' title='Incluir' border=0></a>" ); 373 + $this->campoCheck( "principal", "&nbsp;&nbsp;<img src='imagens/banco_imagens/escreve.gif' style='cursor:hand; cursor:pointer;' border='0' onclick=\"pesquisa_valores_popless( 'educar_acervo_autor_cad_pop.php' )\" />", $this->principal,"<a href='#' onclick=\"getElementById('incluir_autor').value = 'S'; getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bot_adiciona.gif' title='Incluir' border=0></a>" );
414 } 374 }
415 // existe um autor principal 375 // existe um autor principal
416 else 376 else
@@ -420,7 +380,6 @@ class indice extends clsCadastro @@ -420,7 +380,6 @@ class indice extends clsCadastro
420 } 380 }
421 381
422 $this->campoOculto( "incluir_autor", "" ); 382 $this->campoOculto( "incluir_autor", "" );
423 -// $this->campoRotulo( "bt_incluir_autor", "Autor", "<a href='#' onclick=\"getElementById('incluir_autor').value = 'S'; getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bot_incluir2.gif' title='Incluir' border=0></a>" );  
424 383
425 $this->campoQuebra(); 384 $this->campoQuebra();
426 //-----------------------FIM AUTOR------------------------// 385 //-----------------------FIM AUTOR------------------------//
@@ -428,13 +387,15 @@ class indice extends clsCadastro @@ -428,13 +387,15 @@ class indice extends clsCadastro
428 // text 387 // text
429 $this->campoTexto( "titulo", "T&iacute;tulo", $this->titulo, 40, 255, true ); 388 $this->campoTexto( "titulo", "T&iacute;tulo", $this->titulo, 40, 255, true );
430 $this->campoTexto( "sub_titulo", "Subt&iacute;tulo", $this->sub_titulo, 40, 255, false ); 389 $this->campoTexto( "sub_titulo", "Subt&iacute;tulo", $this->sub_titulo, 40, 255, false );
431 - $this->campoTexto( "cdu", "Cdu", $this->cdu, 20, 15, false ); 390 + $this->campoTexto( "estante", "Estante", $this->estante, 20, 15, false );
  391 + $this->campoTexto( "cdd", "CDD", $this->cdd, 20, 15, false );
  392 + $this->campoTexto( "cdu", "CDU", $this->cdu, 20, 15, false );
432 $this->campoTexto( "cutter", "Cutter", $this->cutter, 20, 15, false ); 393 $this->campoTexto( "cutter", "Cutter", $this->cutter, 20, 15, false );
433 $this->campoNumero( "volume", "Volume", $this->volume, 20, 255, true ); 394 $this->campoNumero( "volume", "Volume", $this->volume, 20, 255, true );
434 $this->campoNumero( "num_edicao", "N&uacute;mero Edic&atilde;o", $this->num_edicao, 20, 255, true ); 395 $this->campoNumero( "num_edicao", "N&uacute;mero Edic&atilde;o", $this->num_edicao, 20, 255, true );
435 $this->campoNumero( "ano", "Ano", $this->ano, 5, 4, true ); 396 $this->campoNumero( "ano", "Ano", $this->ano, 5, 4, true );
436 $this->campoNumero( "num_paginas", "N&uacute;mero P&aacute;ginas", $this->num_paginas, 5, 255, true ); 397 $this->campoNumero( "num_paginas", "N&uacute;mero P&aacute;ginas", $this->num_paginas, 5, 255, true );
437 - $this->campoNumero( "isbn", "ISBN", $this->isbn, 20, 255, true ); 398 + $this->campoNumero( "isbn", "ISBN", $this->isbn, 20, 13, true );
438 } 399 }
439 400
440 function Novo() 401 function Novo()
@@ -448,17 +409,16 @@ class indice extends clsCadastro @@ -448,17 +409,16 @@ class indice extends clsCadastro
448 $this->acervo_autor = unserialize( urldecode( $this->acervo_autor ) ); 409 $this->acervo_autor = unserialize( urldecode( $this->acervo_autor ) );
449 if ($this->acervo_autor) 410 if ($this->acervo_autor)
450 { 411 {
451 - $obj = new clsPmieducarAcervo( null, $this->ref_cod_exemplar_tipo, $this->ref_cod_acervo, null, $this->pessoa_logada, $this->ref_cod_acervo_colecao, $this->ref_cod_acervo_idioma, $this->ref_cod_acervo_editora, $this->titulo, $this->sub_titulo, $this->cdu, $this->cutter, $this->volume, $this->num_edicao, $this->ano, $this->num_paginas, $this->isbn, null, null, 1, $this->ref_cod_biblioteca ); 412 + $obj = new clsPmieducarAcervo( null, $this->ref_cod_exemplar_tipo, $this->ref_cod_acervo, null, $this->pessoa_logada, $this->ref_cod_acervo_colecao, $this->ref_cod_acervo_idioma, $this->ref_cod_acervo_editora, $this->titulo, $this->sub_titulo, $this->cdu, $this->cutter, $this->volume, $this->num_edicao, $this->ano, $this->num_paginas, $this->isbn, null, null, 1, $this->ref_cod_biblioteca, $this->cdd, $this->estante );
452 $cadastrou = $obj->cadastra(); 413 $cadastrou = $obj->cadastra();
453 if( $cadastrou ) 414 if( $cadastrou )
454 { 415 {
455 //-----------------------CADASTRA AUTOR------------------------// 416 //-----------------------CADASTRA AUTOR------------------------//
456 foreach ( $this->acervo_autor AS $autor ) 417 foreach ( $this->acervo_autor AS $autor )
457 { 418 {
458 - if ($autor["principal_"] == 'on')  
459 - $autor["principal_"] = 1;  
460 - else  
461 - $autor["principal_"] = 0; 419 + $autorPrincipal = $_POST["principal_{$autor['ref_cod_acervo_autor_']}"];
  420 + $autor["principal_"] = is_null($autorPrincipal) ? 0 : 1;
  421 +
462 $obj = new clsPmieducarAcervoAcervoAutor( $autor["ref_cod_acervo_autor_"], $cadastrou, $autor["principal_"] ); 422 $obj = new clsPmieducarAcervoAcervoAutor( $autor["ref_cod_acervo_autor_"], $cadastrou, $autor["principal_"] );
463 $cadastrou2 = $obj->cadastra(); 423 $cadastrou2 = $obj->cadastra();
464 if ( !$cadastrou2 ) 424 if ( !$cadastrou2 )
@@ -495,21 +455,21 @@ class indice extends clsCadastro @@ -495,21 +455,21 @@ class indice extends clsCadastro
495 $this->acervo_autor = unserialize( urldecode( $this->acervo_autor ) ); 455 $this->acervo_autor = unserialize( urldecode( $this->acervo_autor ) );
496 if ($this->acervo_autor) 456 if ($this->acervo_autor)
497 { 457 {
498 - $obj = new clsPmieducarAcervo($this->cod_acervo, $this->ref_cod_exemplar_tipo, $this->ref_cod_acervo, $this->pessoa_logada, null, $this->ref_cod_acervo_colecao, $this->ref_cod_acervo_idioma, $this->ref_cod_acervo_editora, $this->titulo, $this->sub_titulo, $this->cdu, $this->cutter, $this->volume, $this->num_edicao, $this->ano, $this->num_paginas, $this->isbn, null, null, 1, $this->ref_cod_biblioteca); 458 + $obj = new clsPmieducarAcervo($this->cod_acervo, $this->ref_cod_exemplar_tipo, $this->ref_cod_acervo, $this->pessoa_logada, null, $this->ref_cod_acervo_colecao, $this->ref_cod_acervo_idioma, $this->ref_cod_acervo_editora, $this->titulo, $this->sub_titulo, $this->cdu, $this->cutter, $this->volume, $this->num_edicao, $this->ano, $this->num_paginas, $this->isbn, null, null, 1, $this->ref_cod_biblioteca, $this->cdd, $this->estante);
499 $editou = $obj->edita(); 459 $editou = $obj->edita();
500 if( $editou ) 460 if( $editou )
501 { 461 {
502 //-----------------------EDITA AUTOR------------------------// 462 //-----------------------EDITA AUTOR------------------------//
  463 +
503 $obj = new clsPmieducarAcervoAcervoAutor( null, $this->cod_acervo ); 464 $obj = new clsPmieducarAcervoAcervoAutor( null, $this->cod_acervo );
504 $excluiu = $obj->excluirTodos(); 465 $excluiu = $obj->excluirTodos();
505 if ( $excluiu ) 466 if ( $excluiu )
506 { 467 {
507 foreach ( $this->acervo_autor AS $autor ) 468 foreach ( $this->acervo_autor AS $autor )
508 { 469 {
509 - if ($autor["principal_"] == 'on')  
510 - $autor["principal_"] = 1;  
511 - else  
512 - $autor["principal_"] = 0; 470 + $autorPrincipal = $_POST["principal_{$autor['ref_cod_acervo_autor_']}"];
  471 + $autor["principal_"] = is_null($autorPrincipal) ? 0 : 1;
  472 +
513 $obj = new clsPmieducarAcervoAcervoAutor( $autor["ref_cod_acervo_autor_"], $this->cod_acervo, $autor["principal_"] ); 473 $obj = new clsPmieducarAcervoAcervoAutor( $autor["ref_cod_acervo_autor_"], $this->cod_acervo, $autor["principal_"] );
514 $cadastrou2 = $obj->cadastra(); 474 $cadastrou2 = $obj->cadastra();
515 if ( !$cadastrou2 ) 475 if ( !$cadastrou2 )
@@ -572,8 +532,6 @@ $pagina-&gt;MakeAll(); @@ -572,8 +532,6 @@ $pagina-&gt;MakeAll();
572 ?> 532 ?>
573 533
574 <script> 534 <script>
575 -document.getElementById('ref_cod_exemplar_tipo').disabled = true;  
576 -document.getElementById('ref_cod_exemplar_tipo').options[0].text = 'Selecione uma biblioteca';  
577 535
578 document.getElementById('ref_cod_acervo_colecao').disabled = true; 536 document.getElementById('ref_cod_acervo_colecao').disabled = true;
579 document.getElementById('ref_cod_acervo_colecao').options[0].text = 'Selecione uma biblioteca'; 537 document.getElementById('ref_cod_acervo_colecao').options[0].text = 'Selecione uma biblioteca';
@@ -595,7 +553,7 @@ if(document.getElementById(&#39;ref_cod_biblioteca&#39;).value == &quot;&quot;) @@ -595,7 +553,7 @@ if(document.getElementById(&#39;ref_cod_biblioteca&#39;).value == &quot;&quot;)
595 setVisibility(document.getElementById('img_editora'), false); 553 setVisibility(document.getElementById('img_editora'), false);
596 setVisibility(document.getElementById('img_idioma'), false); 554 setVisibility(document.getElementById('img_idioma'), false);
597 setVisibility(document.getElementById('img_autor'), false); 555 setVisibility(document.getElementById('img_autor'), false);
598 - tempExemplarTipo = null; 556 + //tempExemplarTipo = null;
599 tempColecao = null; 557 tempColecao = null;
600 tempIdioma = null; 558 tempIdioma = null;
601 tempEditora = null; 559 tempEditora = null;
@@ -605,37 +563,6 @@ else @@ -605,37 +563,6 @@ else
605 ajaxBiblioteca('novo'); 563 ajaxBiblioteca('novo');
606 } 564 }
607 565
608 -function getTipoExemplar(xml_exemplar_tipo)  
609 -{  
610 - var campoExemplarTipo = document.getElementById('ref_cod_exemplar_tipo');  
611 - var DOM_array = xml_exemplar_tipo.getElementsByTagName( "exemplar_tipo" );  
612 -  
613 - if(DOM_array.length)  
614 - {  
615 - campoExemplarTipo.length = 1;  
616 - campoExemplarTipo.options[0].text = 'Selecione um tipo de exemplar';  
617 - campoExemplarTipo.disabled = false;  
618 -  
619 - for( var i = 0; i < DOM_array.length; i++ )  
620 - {  
621 - campoExemplarTipo.options[campoExemplarTipo.options.length] = new Option( DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_exemplar_tipo"),false,false);  
622 - }  
623 - if(tempExemplarTipo != null)  
624 - campoExemplarTipo.value = tempExemplarTipo;  
625 - }  
626 - else  
627 - {  
628 - if(document.getElementById('ref_cod_biblioteca').value == "")  
629 - {  
630 - campoExemplarTipo.options[0].text = 'Selecione uma biblioteca';  
631 - }  
632 - else  
633 - {  
634 - campoExemplarTipo.options[0].text = 'A biblioteca não possui tipo de exemplar';  
635 - }  
636 - }  
637 -}  
638 -  
639 function getColecao( xml_acervo_colecao ) 566 function getColecao( xml_acervo_colecao )
640 { 567 {
641 var campoColecao = document.getElementById('ref_cod_acervo_colecao'); 568 var campoColecao = document.getElementById('ref_cod_acervo_colecao');
@@ -646,7 +573,7 @@ function getColecao( xml_acervo_colecao ) @@ -646,7 +573,7 @@ function getColecao( xml_acervo_colecao )
646 campoColecao.length = 1; 573 campoColecao.length = 1;
647 campoColecao.options[0].text = 'Selecione uma coleção'; 574 campoColecao.options[0].text = 'Selecione uma coleção';
648 campoColecao.disabled = false; 575 campoColecao.disabled = false;
649 - 576 +
650 for( var i=0; i<DOM_array.length; i++) 577 for( var i=0; i<DOM_array.length; i++)
651 { 578 {
652 campoColecao.options[campoColecao.options.length] = new Option(DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_colecao"), false, false); 579 campoColecao.options[campoColecao.options.length] = new Option(DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_colecao"), false, false);
@@ -680,7 +607,7 @@ function getEditora( xml_acervo_editora ) @@ -680,7 +607,7 @@ function getEditora( xml_acervo_editora )
680 campoEditora.length = 1; 607 campoEditora.length = 1;
681 campoEditora.options[0].text = 'Selecione uma editora'; 608 campoEditora.options[0].text = 'Selecione uma editora';
682 campoEditora.disabled = false; 609 campoEditora.disabled = false;
683 - 610 +
684 for( var i=0; i<DOM_array.length; i++) 611 for( var i=0; i<DOM_array.length; i++)
685 { 612 {
686 campoEditora.options[campoEditora.options.length] = new Option(DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_editora"), false, false); 613 campoEditora.options[campoEditora.options.length] = new Option(DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_editora"), false, false);
@@ -714,7 +641,7 @@ function getIdioma( xml_acervo_idioma ) @@ -714,7 +641,7 @@ function getIdioma( xml_acervo_idioma )
714 campoIdioma.length = 1; 641 campoIdioma.length = 1;
715 campoIdioma.options[0].text = 'Selecione uma idioma'; 642 campoIdioma.options[0].text = 'Selecione uma idioma';
716 campoIdioma.disabled = false; 643 campoIdioma.disabled = false;
717 - 644 +
718 for( var i=0; i<DOM_array.length; i++) 645 for( var i=0; i<DOM_array.length; i++)
719 { 646 {
720 campoIdioma.options[campoIdioma.options.length] = new Option(DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_idioma"), false, false); 647 campoIdioma.options[campoIdioma.options.length] = new Option(DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_idioma"), false, false);
@@ -752,16 +679,6 @@ function ajaxBiblioteca(acao) @@ -752,16 +679,6 @@ function ajaxBiblioteca(acao)
752 var campoBiblioteca = document.getElementById('ref_cod_biblioteca').value; 679 var campoBiblioteca = document.getElementById('ref_cod_biblioteca').value;
753 680
754 var campoExemplarTipo = document.getElementById('ref_cod_exemplar_tipo'); 681 var campoExemplarTipo = document.getElementById('ref_cod_exemplar_tipo');
755 - if(acao == 'novo')  
756 - {  
757 - tempExemplarTipo = campoExemplarTipo.value;  
758 - }  
759 - campoExemplarTipo.length = 1;  
760 - campoExemplarTipo.disabled = true;  
761 - campoExemplarTipo.options[0].text = 'Carregando tipo de exemplar';  
762 -  
763 - var xml_exemplar_tipo = new ajax( getTipoExemplar );  
764 - xml_exemplar_tipo.envia( "educar_exemplar_tipo_xml.php?bib="+campoBiblioteca );  
765 682
766 var campoColecao = document.getElementById('ref_cod_acervo_colecao'); 683 var campoColecao = document.getElementById('ref_cod_acervo_colecao');
767 if(acao == 'novo') 684 if(acao == 'novo')
@@ -773,8 +690,8 @@ function ajaxBiblioteca(acao) @@ -773,8 +690,8 @@ function ajaxBiblioteca(acao)
773 campoColecao.options[0].text = 'Carregando coleções'; 690 campoColecao.options[0].text = 'Carregando coleções';
774 691
775 var xml_colecao = new ajax( getColecao ); 692 var xml_colecao = new ajax( getColecao );
776 - xml_colecao.envia( "educar_colecao_xml.php?bib="+campoBiblioteca );  
777 - 693 + xml_colecao.envia( "educar_colecao_xml.php?bib="+campoBiblioteca );
  694 +
778 var campoEditora = document.getElementById('ref_cod_acervo_editora'); 695 var campoEditora = document.getElementById('ref_cod_acervo_editora');
779 if(acao == 'novo') 696 if(acao == 'novo')
780 { 697 {
@@ -785,8 +702,8 @@ function ajaxBiblioteca(acao) @@ -785,8 +702,8 @@ function ajaxBiblioteca(acao)
785 campoEditora.options[0].text = 'Carregando editoras'; 702 campoEditora.options[0].text = 'Carregando editoras';
786 703
787 var xml_editora = new ajax( getEditora ); 704 var xml_editora = new ajax( getEditora );
788 - xml_editora.envia( "educar_editora_xml.php?bib="+campoBiblioteca );  
789 - 705 + xml_editora.envia( "educar_editora_xml.php?bib="+campoBiblioteca );
  706 +
790 var campoIdioma = document.getElementById('ref_cod_acervo_idioma'); 707 var campoIdioma = document.getElementById('ref_cod_acervo_idioma');
791 if(acao == 'novo') 708 if(acao == 'novo')
792 { 709 {
@@ -798,7 +715,7 @@ function ajaxBiblioteca(acao) @@ -798,7 +715,7 @@ function ajaxBiblioteca(acao)
798 715
799 var xml_idioma = new ajax( getIdioma ); 716 var xml_idioma = new ajax( getIdioma );
800 xml_idioma.envia( "educar_idioma_xml.php?bib="+campoBiblioteca ); 717 xml_idioma.envia( "educar_idioma_xml.php?bib="+campoBiblioteca );
801 - 718 +
802 } 719 }
803 720
804 function pesquisa() 721 function pesquisa()
@@ -812,5 +729,17 @@ function pesquisa() @@ -812,5 +729,17 @@ function pesquisa()
812 pesquisa_valores_popless('educar_pesquisa_acervo_lst.php?campo1=ref_cod_acervo&ref_cod_biblioteca=' + biblioteca , 'ref_cod_acervo') 729 pesquisa_valores_popless('educar_pesquisa_acervo_lst.php?campo1=ref_cod_acervo&ref_cod_biblioteca=' + biblioteca , 'ref_cod_acervo')
813 } 730 }
814 731
815 -//pesquisa_valores_popless('educar_pesquisa_acervo_lst.php?campo1=ref_cod_acervo', 'ref_cod_acervo') 732 +
  733 +function fixupPrincipalCheckboxes() {
  734 + $j('#principal').hide();
  735 +
  736 + var $checkboxes = $j("input[type='checkbox']").filter("input[id^='principal_']");
  737 +
  738 + $checkboxes.change(function(){
  739 + $checkboxes.not(this).removeAttr('checked');
  740 + });
  741 +}
  742 +
  743 +fixupPrincipalCheckboxes();
  744 +
816 </script> 745 </script>
ieducar/intranet/educar_acervo_det.php
@@ -280,6 +280,13 @@ class indice extends clsDetalhe @@ -280,6 +280,13 @@ class indice extends clsDetalhe
280 { 280 {
281 $this->addDetalhe( array( "Autor", "{$tabela}") ); 281 $this->addDetalhe( array( "Autor", "{$tabela}") );
282 } 282 }
  283 +
  284 + if($registro["estante"])
  285 + $this->addDetalhe( array( "Estante", "{$registro["estante"]}") );
  286 +
  287 + if($registro["cdd"])
  288 + $this->addDetalhe( array( "Cdd", "{$registro["cdd"]}") );
  289 +
283 if( $registro["cdu"] ) 290 if( $registro["cdu"] )
284 { 291 {
285 $this->addDetalhe( array( "Cdu", "{$registro["cdu"]}") ); 292 $this->addDetalhe( array( "Cdu", "{$registro["cdu"]}") );
@@ -329,4 +336,4 @@ $miolo = new indice(); @@ -329,4 +336,4 @@ $miolo = new indice();
329 $pagina->addForm( $miolo ); 336 $pagina->addForm( $miolo );
330 // gera o html 337 // gera o html
331 $pagina->MakeAll(); 338 $pagina->MakeAll();
332 -?>  
333 \ No newline at end of file 339 \ No newline at end of file
  340 +?>
ieducar/intranet/educar_acervo_editora_cad.php
@@ -105,30 +105,9 @@ class indice extends clsCadastro @@ -105,30 +105,9 @@ class indice extends clsCadastro
105 // primary keys 105 // primary keys
106 $this->campoOculto( "cod_acervo_editora", $this->cod_acervo_editora ); 106 $this->campoOculto( "cod_acervo_editora", $this->cod_acervo_editora );
107 107
108 - /*$obj_pessoa_bib = new clsPmieducarBibliotecaUsuario();  
109 - $lst_pessoa_bib = $obj_pessoa_bib->lista(null, $this->pessoa_logada); 108 + //foreign keys
  109 + $this->inputsHelper()->dynamic(array('instituicao', 'escola', 'biblioteca'));
110 110
111 - $opcoes = array("" => "Selecione");  
112 - if(is_array($lst_pessoa_bib))  
113 - {  
114 - foreach ($lst_pessoa_bib as $bib)  
115 - {  
116 - $obj_biblioteca = new clsPmieducarBiblioteca($bib['ref_cod_biblioteca']);  
117 - $det_biblioteca = $obj_biblioteca->detalhe();  
118 -  
119 - $opcoes[$det_biblioteca['cod_biblioteca']] = $det_biblioteca['nm_biblioteca'];  
120 - }  
121 - }  
122 - $this->campoLista("ref_cod_biblioteca", "Biblioteca", $opcoes, $this->ref_cod_biblioteca);  
123 - */  
124 -  
125 - $get_escola = 1;  
126 - $escola_obrigatorio = false;  
127 - $get_biblioteca = 1;  
128 - $instituicao_obrigatorio = true;  
129 - $biblioteca_obrigatorio = true;  
130 - include("include/pmieducar/educar_campo_lista.php");  
131 -  
132 //text 111 //text
133 $this->campoTexto( "nm_editora", "Editora", $this->nm_editora, 30, 255, true ); 112 $this->campoTexto( "nm_editora", "Editora", $this->nm_editora, 30, 255, true );
134 113
@@ -138,7 +117,7 @@ class indice extends clsCadastro @@ -138,7 +117,7 @@ class indice extends clsCadastro
138 $this->cep = int2CEP($this->cep); 117 $this->cep = int2CEP($this->cep);
139 } 118 }
140 119
141 - $this->campoCep( "cep", "CEP", $this->cep, true ); 120 + $this->campoCep( "cep", "CEP", $this->cep, false );
142 121
143 $opcoes = array( "" => "Selecione" ); 122 $opcoes = array( "" => "Selecione" );
144 if( class_exists( "clsUf" ) ) 123 if( class_exists( "clsUf" ) )
@@ -158,10 +137,10 @@ class indice extends clsCadastro @@ -158,10 +137,10 @@ class indice extends clsCadastro
158 echo "<!--\nErro\nClasse clsUf nao encontrada\n-->"; 137 echo "<!--\nErro\nClasse clsUf nao encontrada\n-->";
159 $opcoes = array( "" => "Erro na geracao" ); 138 $opcoes = array( "" => "Erro na geracao" );
160 } 139 }
161 - $this->campoLista( "ref_sigla_uf", "Estado", $opcoes, $this->ref_sigla_uf ); 140 + $this->campoLista( "ref_sigla_uf", "Estado", $opcoes, $this->ref_sigla_uf, '', false, '', '', false, false );
162 141
163 - $this->campoTexto( "cidade", "Cidade", $this->cidade, 30, 60, true );  
164 - $this->campoTexto( "bairro", "Bairro", $this->bairro, 30, 60, true ); 142 + $this->campoTexto( "cidade", "Cidade", $this->cidade, 30, 60, false );
  143 + $this->campoTexto( "bairro", "Bairro", $this->bairro, 30, 60, false );
165 144
166 $opcoes = array( "" => "Selecione" ); 145 $opcoes = array( "" => "Selecione" );
167 if( class_exists( "clsTipoLogradouro" ) ) 146 if( class_exists( "clsTipoLogradouro" ) )
@@ -181,9 +160,9 @@ class indice extends clsCadastro @@ -181,9 +160,9 @@ class indice extends clsCadastro
181 echo "<!--\nErro\nClasse clsUrbanoTipoLogradouro nao encontrada\n-->"; 160 echo "<!--\nErro\nClasse clsUrbanoTipoLogradouro nao encontrada\n-->";
182 $opcoes = array( "" => "Erro na geracao" ); 161 $opcoes = array( "" => "Erro na geracao" );
183 } 162 }
184 - $this->campoLista( "ref_idtlog", "Tipo Logradouro", $opcoes, $this->ref_idtlog ); 163 + $this->campoLista( "ref_idtlog", "Tipo Logradouro", $opcoes, $this->ref_idtlog, '', false, '', '', false, false );
185 164
186 - $this->campoTexto( "logradouro", "Logradouro", $this->logradouro, 30, 255, true ); 165 + $this->campoTexto( "logradouro", "Logradouro", $this->logradouro, 30, 255, false );
187 166
188 $this->campoNumero( "numero", "N&uacute;mero", $this->numero, 6, 6 ); 167 $this->campoNumero( "numero", "N&uacute;mero", $this->numero, 6, 6 );
189 168
@@ -280,4 +259,4 @@ $miolo = new indice(); @@ -280,4 +259,4 @@ $miolo = new indice();
280 $pagina->addForm( $miolo ); 259 $pagina->addForm( $miolo );
281 // gera o html 260 // gera o html
282 $pagina->MakeAll(); 261 $pagina->MakeAll();
283 -?>  
284 \ No newline at end of file 262 \ No newline at end of file
  263 +?>
ieducar/intranet/educar_acervo_editora_cad_pop.php
@@ -93,7 +93,7 @@ class indice extends clsCadastro @@ -93,7 +93,7 @@ class indice extends clsCadastro
93 $this->cep = int2CEP($this->cep); 93 $this->cep = int2CEP($this->cep);
94 } 94 }
95 95
96 - $this->campoCep( "cep", "CEP", $this->cep, true ); 96 + $this->campoCep( "cep", "CEP", $this->cep, false );
97 97
98 $opcoes = array( "" => "Selecione" ); 98 $opcoes = array( "" => "Selecione" );
99 if( class_exists( "clsUf" ) ) 99 if( class_exists( "clsUf" ) )
@@ -113,10 +113,10 @@ class indice extends clsCadastro @@ -113,10 +113,10 @@ class indice extends clsCadastro
113 echo "<!--\nErro\nClasse clsUf nao encontrada\n-->"; 113 echo "<!--\nErro\nClasse clsUf nao encontrada\n-->";
114 $opcoes = array( "" => "Erro na geracao" ); 114 $opcoes = array( "" => "Erro na geracao" );
115 } 115 }
116 - $this->campoLista( "ref_sigla_uf", "Estado", $opcoes, $this->ref_sigla_uf ); 116 + $this->campoLista( "ref_sigla_uf", "Estado", $opcoes, $this->ref_sigla_uf, '', false, '', '', false, false );
117 117
118 - $this->campoTexto( "cidade", "Cidade", $this->cidade, 30, 60, true );  
119 - $this->campoTexto( "bairro", "Bairro", $this->bairro, 30, 60, true ); 118 + $this->campoTexto( "cidade", "Cidade", $this->cidade, 30, 60, false );
  119 + $this->campoTexto( "bairro", "Bairro", $this->bairro, 30, 60, false );
120 120
121 $opcoes = array( "" => "Selecione" ); 121 $opcoes = array( "" => "Selecione" );
122 if( class_exists( "clsTipoLogradouro" ) ) 122 if( class_exists( "clsTipoLogradouro" ) )
@@ -136,9 +136,9 @@ class indice extends clsCadastro @@ -136,9 +136,9 @@ class indice extends clsCadastro
136 echo "<!--\nErro\nClasse clsUrbanoTipoLogradouro nao encontrada\n-->"; 136 echo "<!--\nErro\nClasse clsUrbanoTipoLogradouro nao encontrada\n-->";
137 $opcoes = array( "" => "Erro na geracao" ); 137 $opcoes = array( "" => "Erro na geracao" );
138 } 138 }
139 - $this->campoLista( "ref_idtlog", "Tipo Logradouro", $opcoes, $this->ref_idtlog ); 139 + $this->campoLista( "ref_idtlog", "Tipo Logradouro", $opcoes, $this->ref_idtlog, '', false, '', '', false, false );
140 140
141 - $this->campoTexto( "logradouro", "Logradouro", $this->logradouro, 30, 255, true ); 141 + $this->campoTexto( "logradouro", "Logradouro", $this->logradouro, 30, 255, false );
142 142
143 $this->campoNumero( "numero", "N&uacute;mero", $this->numero, 6, 6 ); 143 $this->campoNumero( "numero", "N&uacute;mero", $this->numero, 6, 6 );
144 144
@@ -201,4 +201,4 @@ $pagina-&gt;MakeAll(); @@ -201,4 +201,4 @@ $pagina-&gt;MakeAll();
201 ?> 201 ?>
202 <script> 202 <script>
203 document.getElementById('ref_cod_biblioteca').value = parent.document.getElementById('ref_cod_biblioteca').value; 203 document.getElementById('ref_cod_biblioteca').value = parent.document.getElementById('ref_cod_biblioteca').value;
204 -</script>  
205 \ No newline at end of file 204 \ No newline at end of file
  205 +</script>
ieducar/intranet/educar_acervo_idioma_cad.php
@@ -99,36 +99,11 @@ class indice extends clsCadastro @@ -99,36 +99,11 @@ class indice extends clsCadastro
99 // primary keys 99 // primary keys
100 $this->campoOculto( "cod_acervo_idioma", $this->cod_acervo_idioma ); 100 $this->campoOculto( "cod_acervo_idioma", $this->cod_acervo_idioma );
101 101
102 - // foreign keys  
103 - /*$obj_pessoa_bib = new clsPmieducarBibliotecaUsuario();  
104 - $lst_pessoa_bib = $obj_pessoa_bib->lista(null, $this->pessoa_logada); 102 + //foreign keys
  103 + $this->inputsHelper()->dynamic(array('instituicao', 'escola', 'biblioteca'));
105 104
106 - $opcoes = array("" => "Selecione");  
107 - if(is_array($lst_pessoa_bib))  
108 - {  
109 - foreach ($lst_pessoa_bib as $bib)  
110 - {  
111 - $obj_biblioteca = new clsPmieducarBiblioteca($bib['ref_cod_biblioteca']);  
112 - $det_biblioteca = $obj_biblioteca->detalhe();  
113 -  
114 - $opcoes[$det_biblioteca['cod_biblioteca']] = $det_biblioteca['nm_biblioteca'];  
115 - }  
116 - }  
117 - $this->campoLista("ref_cod_biblioteca", "Biblioteca", $opcoes, $this->ref_cod_biblioteca);  
118 - */  
119 - $get_escola = 1;  
120 - $escola_obrigatorio = false;  
121 - $get_biblioteca = 1;  
122 - $instituicao_obrigatorio = true;  
123 - $biblioteca_obrigatorio = true;  
124 - include("include/pmieducar/educar_campo_lista.php");  
125 -  
126 -  
127 // text 105 // text
128 $this->campoTexto( "nm_idioma", "Idioma", $this->nm_idioma, 30, 255, true ); 106 $this->campoTexto( "nm_idioma", "Idioma", $this->nm_idioma, 30, 255, true );
129 -  
130 - // data  
131 -  
132 } 107 }
133 108
134 function Novo() 109 function Novo()
@@ -215,4 +190,4 @@ $miolo = new indice(); @@ -215,4 +190,4 @@ $miolo = new indice();
215 $pagina->addForm( $miolo ); 190 $pagina->addForm( $miolo );
216 // gera o html 191 // gera o html
217 $pagina->MakeAll(); 192 $pagina->MakeAll();
218 -?>  
219 \ No newline at end of file 193 \ No newline at end of file
  194 +?>
ieducar/intranet/educar_biblioteca_dados_cad.php
@@ -71,7 +71,7 @@ class indice extends clsCadastro @@ -71,7 +71,7 @@ class indice extends clsCadastro
71 var $biblioteca_feriado; 71 var $biblioteca_feriado;
72 var $incluir_feriado; 72 var $incluir_feriado;
73 var $excluir_feriado; 73 var $excluir_feriado;
74 - 74 +
75 var $tombo_automatico; 75 var $tombo_automatico;
76 76
77 function Inicializar() 77 function Inicializar()
@@ -148,10 +148,10 @@ class indice extends clsCadastro @@ -148,10 +148,10 @@ class indice extends clsCadastro
148 // $this->campoLista( "requisita_senha", "Requisita Senha", $opcoes, $this->requisita_senha ); 148 // $this->campoLista( "requisita_senha", "Requisita Senha", $opcoes, $this->requisita_senha );
149 $this->campoCheck( "requisita_senha", "Requisita Senha", $this->requisita_senha ); 149 $this->campoCheck( "requisita_senha", "Requisita Senha", $this->requisita_senha );
150 $this->campoNumero( "dias_espera", "Dias Espera", $this->dias_espera, 2, 2, true ); 150 $this->campoNumero( "dias_espera", "Dias Espera", $this->dias_espera, 2, 2, true );
151 - 151 +
152 if ($this->tombo_automatico) 152 if ($this->tombo_automatico)
153 $this->campoBoolLista("tombo_automatico", "Biblioteca possui tombo automático", $this->tombo_automatico); 153 $this->campoBoolLista("tombo_automatico", "Biblioteca possui tombo automático", $this->tombo_automatico);
154 - else 154 + else
155 $this->campoBoolLista("tombo_automatico", "Biblioteca possui tombo automático", "t"); 155 $this->campoBoolLista("tombo_automatico", "Biblioteca possui tombo automático", "t");
156 156
157 //-----------------------INCLUI DIA SEMANA------------------------// 157 //-----------------------INCLUI DIA SEMANA------------------------//
@@ -300,10 +300,7 @@ class indice extends clsCadastro @@ -300,10 +300,7 @@ class indice extends clsCadastro
300 $this->valor_maximo_multa = str_replace(".","",$this->valor_maximo_multa); 300 $this->valor_maximo_multa = str_replace(".","",$this->valor_maximo_multa);
301 $this->valor_maximo_multa = str_replace(",",".",$this->valor_maximo_multa); 301 $this->valor_maximo_multa = str_replace(",",".",$this->valor_maximo_multa);
302 302
303 - if ($this->requisita_senha == 'on')  
304 - $this->requisita_senha = 1;  
305 - else  
306 - $this->requisita_senha = 0; 303 + $this->requisita_senha = is_null($this->requisita_senha) ? 0 : 1;
307 304
308 $obj = new clsPmieducarBiblioteca( $this->cod_biblioteca, null, null, null, $this->valor_multa, $this->max_emprestimo, $this->valor_maximo_multa, null, null, $this->requisita_senha, 1, $this->dias_espera, $this->tombo_automatico ); 305 $obj = new clsPmieducarBiblioteca( $this->cod_biblioteca, null, null, null, $this->valor_multa, $this->max_emprestimo, $this->valor_maximo_multa, null, null, $this->requisita_senha, 1, $this->dias_espera, $this->tombo_automatico );
309 $editou = $obj->edita(); 306 $editou = $obj->edita();
@@ -413,4 +410,4 @@ $miolo = new indice(); @@ -413,4 +410,4 @@ $miolo = new indice();
413 $pagina->addForm( $miolo ); 410 $pagina->addForm( $miolo );
414 // gera o html 411 // gera o html
415 $pagina->MakeAll(); 412 $pagina->MakeAll();
416 -?>  
417 \ No newline at end of file 413 \ No newline at end of file
  414 +?>
ieducar/intranet/educar_biblioteca_index.php
@@ -44,7 +44,7 @@ class indice @@ -44,7 +44,7 @@ class indice
44 { 44 {
45 return " 45 return "
46 <table width='100%' height='100%'> 46 <table width='100%' height='100%'>
47 - <tr align=center valign='top'><td><img src='imagens/i-educar/splashscreen_bibl.jpg' style='padding-top: 50px'></td></tr> 47 + <tr align=center valign='top'><td></td></tr>
48 </table> 48 </table>
49 "; 49 ";
50 } 50 }
@@ -58,4 +58,4 @@ $pagina-&gt;addForm( $miolo ); @@ -58,4 +58,4 @@ $pagina-&gt;addForm( $miolo );
58 58
59 $pagina->MakeAll(); 59 $pagina->MakeAll();
60 60
61 -?>  
62 \ No newline at end of file 61 \ No newline at end of file
  62 +?>
ieducar/intranet/educar_cliente_cad.php
@@ -128,7 +128,7 @@ class indice extends clsCadastro @@ -128,7 +128,7 @@ class indice extends clsCadastro
128 $parametros->adicionaCampoSelect('ref_idpes', 'idpes', 'nome'); 128 $parametros->adicionaCampoSelect('ref_idpes', 'idpes', 'nome');
129 $parametros->setPessoa('F'); 129 $parametros->setPessoa('F');
130 $parametros->setPessoaCPF('N'); 130 $parametros->setPessoaCPF('N');
131 - $parametros->setCodSistema(1); 131 + $parametros->setCodSistema(null);
132 $parametros->setPessoaNovo('S'); 132 $parametros->setPessoaNovo('S');
133 $parametros->setPessoaTela('frame'); 133 $parametros->setPessoaTela('frame');
134 134
@@ -144,22 +144,6 @@ class indice extends clsCadastro @@ -144,22 +144,6 @@ class indice extends clsCadastro
144 $this->campoNumero( "login", "Login", $this->login_, 9, 9, false ); 144 $this->campoNumero( "login", "Login", $this->login_, 9, 9, false );
145 $this->campoSenha( "senha", "Senha", $this->senha_, false ); 145 $this->campoSenha( "senha", "Senha", $this->senha_, false );
146 146
147 - $get_escola = 1;  
148 - $get_biblioteca = 1;  
149 - $instituicao_obrigatorio = true;  
150 - $escola_obrigatorio = false;  
151 - $biblioteca_obrigatorio = true;  
152 - include("include/pmieducar/educar_campo_lista.php");  
153 -  
154 - //$instituicao_obrigatorio = true;  
155 - //$escola_obrigatorio = false;  
156 - //$biblioteca_obrigatorio = true;  
157 - $cliente_tipo_obrigatorio = true;  
158 - $get_instituicao = true;  
159 - $get_escola = true;  
160 - //$get_biblioteca = true;  
161 - $get_cliente_tipo = true;  
162 -  
163 if($this->cod_cliente && $this->ref_cod_biblioteca) 147 if($this->cod_cliente && $this->ref_cod_biblioteca)
164 { 148 {
165 $db = new clsBanco(); 149 $db = new clsBanco();
@@ -168,12 +152,13 @@ class indice extends clsCadastro @@ -168,12 +152,13 @@ class indice extends clsCadastro
168 $this->ref_cod_biblioteca_atual = $this->ref_cod_biblioteca; 152 $this->ref_cod_biblioteca_atual = $this->ref_cod_biblioteca;
169 $this->campoOculto("ref_cod_biblioteca_atual", $this->ref_cod_biblioteca_atual); 153 $this->campoOculto("ref_cod_biblioteca_atual", $this->ref_cod_biblioteca_atual);
170 154
171 - $this->ref_cod_instituicao = $db->CampoUnico("SELECT ref_cod_instituicao FROM pmieducar.biblioteca, pmieducar.cliente_tipo_cliente ctc, pmieducar.cliente_tipo ct WHERE ref_cod_cliente = '$this->cod_cliente' AND ref_cod_cliente_tipo = cod_cliente_tipo AND ct.ref_cod_biblioteca = cod_biblioteca AND ctc.ref_cod_biblioteca = {$this->ref_cod_biblioteca}");  
172 - $this->ref_cod_escola = $db->CampoUnico("SELECT ref_cod_escola FROM pmieducar.biblioteca, pmieducar.cliente_tipo_cliente ctc, pmieducar.cliente_tipo ct WHERE ref_cod_cliente = '$this->cod_cliente' AND ref_cod_cliente_tipo = cod_cliente_tipo AND ct.ref_cod_biblioteca = cod_biblioteca AND ctc.ref_cod_biblioteca = {$this->ref_cod_biblioteca}");  
173 - $this->ref_cod_biblioteca = $db->CampoUnico("SELECT cod_biblioteca FROM pmieducar.biblioteca, pmieducar.cliente_tipo_cliente ctc, pmieducar.cliente_tipo ct WHERE ref_cod_cliente = '$this->cod_cliente' AND ref_cod_cliente_tipo = cod_cliente_tipo AND ct.ref_cod_biblioteca = cod_biblioteca AND ctc.ref_cod_biblioteca = {$this->ref_cod_biblioteca}");  
174 - $this->ref_cod_cliente_tipo = $db->CampoUnico("SELECT ref_cod_cliente_tipo FROM pmieducar.cliente_tipo_cliente WHERE ref_cod_cliente = '$this->cod_cliente'");// AND ref_cod_cliente_tipo IN (SELECT cod_cliente_tipo FROM pmieducar.cliente_tipo WHERE ref_cod_biblioteca = )");//IN (SELECT ref_cod_biblioteca FROM pmieducar.biblioteca_usuario WHERE ref_cod_usuario = '$this->pessoa_logada'))"); 155 + //$this->ref_cod_biblioteca = $db->CampoUnico("SELECT cod_biblioteca FROM pmieducar.biblioteca, pmieducar.cliente_tipo_cliente ctc, pmieducar.cliente_tipo ct WHERE ref_cod_cliente = '$this->cod_cliente' AND ref_cod_cliente_tipo = cod_cliente_tipo AND ct.ref_cod_biblioteca = cod_biblioteca AND ctc.ref_cod_biblioteca = {$this->ref_cod_biblioteca}");
  156 +
  157 + // obtem o codigo do tipo de cliente, apartir da tabela cliente_tipo_cliente
  158 + $this->ref_cod_cliente_tipo = $db->CampoUnico("SELECT ref_cod_cliente_tipo FROM pmieducar.cliente_tipo_cliente WHERE ref_cod_cliente = '$this->cod_cliente'");
175 } 159 }
176 - include( "include/pmieducar/educar_campo_lista.php" ); 160 +
  161 + $this->inputsHelper()->dynamic(array('instituicao', 'escola', 'biblioteca', 'bibliotecaTipoCliente'));
177 } 162 }
178 163
179 164
@@ -369,35 +354,6 @@ $pagina-&gt;addForm( $miolo ); @@ -369,35 +354,6 @@ $pagina-&gt;addForm( $miolo );
369 $pagina->MakeAll(); 354 $pagina->MakeAll();
370 ?> 355 ?>
371 <script> 356 <script>
372 -/*  
373 -if(document.getElementById('ref_cod_biblioteca').type == 'select-one')  
374 -{  
375 - var campoTipo = document.getElementById('ref_cod_cliente_tipo');  
376 - campoTipo.length = 1;  
377 - campoTipo.options[0].text = 'Selecione uma biblioteca';  
378 - campoTipo.disabled = true;  
379 -}*/  
380 -  
381 -function getClienteTipo(xml_cliente_tipo)  
382 -{  
383 - var campoTipo = document.getElementById('ref_cod_cliente_tipo');  
384 - var DOM_array = xml_cliente_tipo.getElementsByTagName( "cliente_tipo" );  
385 -  
386 - if(DOM_array.length)  
387 - {  
388 - campoTipo.length = 1;  
389 - campoTipo.options[0].text = 'Selecione um tipo';  
390 - campoTipo.disabled = false;  
391 -  
392 - for( var i = 0; i < DOM_array.length; i++ )  
393 - {  
394 - campoTipo.options[campoTipo.options.length] = new Option( DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_cliente_tipo"),false,false);  
395 - }  
396 - }  
397 - else  
398 - campoTipo.options[0].text = 'A biblioteca não possui tipos';  
399 -}  
400 -  
401 document.getElementById('ref_cod_biblioteca').onchange = function() 357 document.getElementById('ref_cod_biblioteca').onchange = function()
402 { 358 {
403 ajaxBiblioteca(); 359 ajaxBiblioteca();
@@ -407,18 +363,10 @@ if(document.getElementById(&#39;ref_cod_biblioteca&#39;).value != &#39;&#39;) @@ -407,18 +363,10 @@ if(document.getElementById(&#39;ref_cod_biblioteca&#39;).value != &#39;&#39;)
407 { 363 {
408 ajaxBiblioteca(); 364 ajaxBiblioteca();
409 } 365 }
  366 +
410 function ajaxBiblioteca() 367 function ajaxBiblioteca()
411 { 368 {
412 var campoBiblioteca = document.getElementById('ref_cod_biblioteca').value; 369 var campoBiblioteca = document.getElementById('ref_cod_biblioteca').value;
413 - var campoTipo = document.getElementById('ref_cod_cliente_tipo');  
414 -  
415 - campoTipo.length = 1;  
416 - campoTipo.disabled = true;  
417 - campoTipo.options[0].text = 'Carregando situação';  
418 -  
419 - var xml_cliente_tipo = new ajax( getClienteTipo );  
420 - xml_cliente_tipo.envia( "educar_cliente_tipo_xml.php?bib="+campoBiblioteca );  
421 -  
422 var xml_biblioteca = new ajax( requisitaSenha ); 370 var xml_biblioteca = new ajax( requisitaSenha );
423 xml_biblioteca.envia( "educar_biblioteca_xml.php?bib="+campoBiblioteca ); 371 xml_biblioteca.envia( "educar_biblioteca_xml.php?bib="+campoBiblioteca );
424 } 372 }
ieducar/intranet/educar_cliente_tipo_cad.php
@@ -267,15 +267,20 @@ class indice extends clsCadastro @@ -267,15 +267,20 @@ class indice extends clsCadastro
267 foreach ( $array_tipos AS $exemplar_tipo => $dias_emprestimo ) 267 foreach ( $array_tipos AS $exemplar_tipo => $dias_emprestimo )
268 { 268 {
269 $obj = new clsPmieducarClienteTipoExemplarTipo( $this->cod_cliente_tipo, $exemplar_tipo, $dias_emprestimo ); 269 $obj = new clsPmieducarClienteTipoExemplarTipo( $this->cod_cliente_tipo, $exemplar_tipo, $dias_emprestimo );
270 - $editou2 = $obj->edita();  
271 - if ( !$editou2 ) 270 +
  271 + if($obj->existe() == false)
  272 + $result = $obj->cadastra();
  273 + else
  274 + $result = $obj->edita();
  275 +
  276 + if (! $result)
272 { 277 {
273 - $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>";  
274 - echo "<!--\nErro ao editar clsPmieducarClienteTipoExemplarTipo\nvalores obrigat&oacute;rios\nis_numeric( $this->cod_cliente_tipo ) && is_numeric( {$this->pessoa_logada} )\n-->"; 278 + $this->mensagem = "Aparentemente ocorreu um erro ao gravar os dias de emprestimo.<br>";
275 return false; 279 return false;
276 } 280 }
277 } 281 }
278 } 282 }
  283 +
279 //-----------------------FIM EDITA EXEMPLAR TIPO------------------------// 284 //-----------------------FIM EDITA EXEMPLAR TIPO------------------------//
280 285
281 $this->mensagem .= "Edi&ccedil;&atilde;o efetuada com sucesso.<br>"; 286 $this->mensagem .= "Edi&ccedil;&atilde;o efetuada com sucesso.<br>";
@@ -388,7 +393,7 @@ function getExemplarTipo_XML(xml) @@ -388,7 +393,7 @@ function getExemplarTipo_XML(xml)
388 dias_tipo_exemplar.setAttribute( 'value', tipo_exemplar[j].getAttribute("dias_emprestimo")); 393 dias_tipo_exemplar.setAttribute( 'value', tipo_exemplar[j].getAttribute("dias_emprestimo"));
389 else 394 else
390 dias_tipo_exemplar.setAttribute( 'value', ''); 395 dias_tipo_exemplar.setAttribute( 'value', '');
391 - 396 +
392 dias_tipo_exemplar.setAttribute( 'class', 'obrigatorio' ); 397 dias_tipo_exemplar.setAttribute( 'class', 'obrigatorio' );
393 398
394 exemplares.innerHTML += aux; 399 exemplares.innerHTML += aux;
@@ -448,4 +453,4 @@ if(editar_) @@ -448,4 +453,4 @@ if(editar_)
448 { 453 {
449 padding: 6px; 454 padding: 6px;
450 } 455 }
451 -</style>  
452 \ No newline at end of file 456 \ No newline at end of file
  457 +</style>
ieducar/intranet/educar_cliente_tipo_xml.php
@@ -37,9 +37,14 @@ Portabilis_Utils_DeprecatedXmlApi::returnEmptyQueryUnlessUserIsLoggedIn(); @@ -37,9 +37,14 @@ Portabilis_Utils_DeprecatedXmlApi::returnEmptyQueryUnlessUserIsLoggedIn();
37 print '<?xml version="1.0" encoding="iso-8859-1"?>' . PHP_EOL; 37 print '<?xml version="1.0" encoding="iso-8859-1"?>' . PHP_EOL;
38 print '<query xmlns="sugestoes">' . PHP_EOL; 38 print '<query xmlns="sugestoes">' . PHP_EOL;
39 39
40 -if (is_numeric($_GET['bib']))  
41 -{ 40 +if (is_numeric($_GET['bib'])) {
42 $db = new clsBanco(); 41 $db = new clsBanco();
  42 +
  43 + if (is_numeric($_GET['exemplar_tipo_id']))
  44 + $filtroTipoExemplar = "ref_cod_exemplar_tipo = {$_GET['exemplar_tipo_id']} AND";
  45 + else
  46 + $filtroTipoExemplar = '';
  47 +
43 $sql = " 48 $sql = "
44 SELECT 49 SELECT
45 DISTINCT(cod_cliente_tipo), 50 DISTINCT(cod_cliente_tipo),
@@ -49,11 +54,12 @@ if (is_numeric($_GET[&#39;bib&#39;])) @@ -49,11 +54,12 @@ if (is_numeric($_GET[&#39;bib&#39;]))
49 pmieducar.cliente_tipo LEFT JOIN pmieducar.cliente_tipo_exemplar_tipo ON (cod_cliente_tipo = ref_cod_cliente_tipo) 54 pmieducar.cliente_tipo LEFT JOIN pmieducar.cliente_tipo_exemplar_tipo ON (cod_cliente_tipo = ref_cod_cliente_tipo)
50 WHERE 55 WHERE
51 ref_cod_biblioteca = %s AND 56 ref_cod_biblioteca = %s AND
  57 + %s
52 ativo = 1 58 ativo = 1
53 ORDER BY 59 ORDER BY
54 nm_tipo ASC"; 60 nm_tipo ASC";
55 61
56 - $sql = sprintf($sql, $_GET['bib']); 62 + $sql = sprintf($sql, $_GET['bib'], $filtroTipoExemplar);
57 $db->Consulta($sql); 63 $db->Consulta($sql);
58 64
59 // Array com os códigos do resultado do SELECT 65 // Array com os códigos do resultado do SELECT
@@ -63,6 +69,10 @@ if (is_numeric($_GET[&#39;bib&#39;])) @@ -63,6 +69,10 @@ if (is_numeric($_GET[&#39;bib&#39;]))
63 { 69 {
64 list($cod, $nome, $dias_emprestimo) = $db->Tupla(); 70 list($cod, $nome, $dias_emprestimo) = $db->Tupla();
65 71
  72 + // Evita trazer dias emprestimo de outros cadastros, no cadastro novo tipo de exemplar
  73 + if (! is_numeric($_GET['exemplar_tipo_id']))
  74 + $dias_emprestimo = '';
  75 +
66 // Se o código já foi utilizado, vai para o próximo resultado 76 // Se o código já foi utilizado, vai para o próximo resultado
67 if (isset($codigos[$cod])) 77 if (isset($codigos[$cod]))
68 continue; 78 continue;
ieducar/intranet/educar_exemplar_cad.php
1 <?php 1 <?php
  2 +
  3 +#error_reporting(E_ALL);
  4 +#ini_set("display_errors", 1);
  5 +
2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 6 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3 * * 7 * *
4 * @author Prefeitura Municipal de Itajaí * 8 * @author Prefeitura Municipal de Itajaí *
@@ -24,10 +28,10 @@ @@ -24,10 +28,10 @@
24 * 02111-1307, USA. * 28 * 02111-1307, USA. *
25 * * 29 * *
26 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 30 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
27 -require_once ("include/clsBase.inc.php");  
28 -require_once ("include/clsCadastro.inc.php");  
29 -require_once ("include/clsBanco.inc.php");  
30 -require_once( "include/pmieducar/geral.inc.php" ); 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';
31 35
32 class clsIndexBase extends clsBase 36 class clsIndexBase extends clsBase
33 { 37 {
@@ -64,11 +68,9 @@ class indice extends clsCadastro @@ -64,11 +68,9 @@ class indice extends clsCadastro
64 var $ref_cod_instituicao; 68 var $ref_cod_instituicao;
65 var $ref_cod_escola; 69 var $ref_cod_escola;
66 var $ref_cod_biblioteca; 70 var $ref_cod_biblioteca;
67 -  
68 - var $tombo_automarico;  
69 - var $combo_manual; 71 +
  72 + var $tombo;
70 var $qtd_livros; 73 var $qtd_livros;
71 - var $eh_manual;  
72 74
73 function Inicializar() 75 function Inicializar()
74 { 76 {
@@ -112,9 +114,8 @@ class indice extends clsCadastro @@ -112,9 +114,8 @@ class indice extends clsCadastro
112 114
113 $retorno = "Editar"; 115 $retorno = "Editar";
114 } 116 }
115 - } else {  
116 - $this->acao_enviar = "acao2()";  
117 } 117 }
  118 +
118 $this->url_cancelar = ($retorno == "Editar") ? "educar_exemplar_det.php?cod_exemplar={$registro["cod_exemplar"]}" : "educar_exemplar_lst.php"; 119 $this->url_cancelar = ($retorno == "Editar") ? "educar_exemplar_det.php?cod_exemplar={$registro["cod_exemplar"]}" : "educar_exemplar_lst.php";
119 $this->nome_url_cancelar = "Cancelar"; 120 $this->nome_url_cancelar = "Cancelar";
120 return $retorno; 121 return $retorno;
@@ -122,161 +123,29 @@ class indice extends clsCadastro @@ -122,161 +123,29 @@ class indice extends clsCadastro
122 123
123 function Gerar() 124 function Gerar()
124 { 125 {
125 - // primary keys  
126 $this->campoOculto( "cod_exemplar", $this->cod_exemplar ); 126 $this->campoOculto( "cod_exemplar", $this->cod_exemplar );
127 127
128 - $get_escola = 1;  
129 - $escola_obrigatorio = false;  
130 - $get_biblioteca = 1;  
131 - $instituicao_obrigatorio = true;  
132 - $biblioteca_obrigatorio = true;  
133 - include("include/pmieducar/educar_campo_lista.php");  
134 -  
135 - // foreign keys  
136 - $opcoes = array( "" => "Selecione" );  
137 - if( class_exists( "clsPmieducarFonte" ) )  
138 - {  
139 - $objTemp = new clsPmieducarFonte();  
140 - $lista = $objTemp->lista( null,null,null,null,null,null,null,null,null,1 );  
141 - if ( is_array( $lista ) && count( $lista ) )  
142 - {  
143 - foreach ( $lista as $registro )  
144 - {  
145 - $opcoes["{$registro['cod_fonte']}"] = "{$registro['nm_fonte']}";  
146 - }  
147 - }  
148 - }  
149 - else  
150 - {  
151 - echo "<!--\nErro\nClasse clsPmieducarFonte nao encontrada\n-->";  
152 - $opcoes = array( "" => "Erro na geracao" );  
153 - }  
154 - $this->campoLista( "ref_cod_fonte", "Fonte", $opcoes, $this->ref_cod_fonte );  
155 -  
156 - /*$opcoes = array( "" => "Selecione" );  
157 - if( class_exists( "clsPmieducarMotivoBaixa" ) )  
158 - {  
159 - $objTemp = new clsPmieducarMotivoBaixa();  
160 - $lista = $objTemp->lista();  
161 - if ( is_array( $lista ) && count( $lista ) )  
162 - {  
163 - foreach ( $lista as $registro )  
164 - {  
165 - $opcoes["{$registro['cod_motivo_baixa']}"] = "{$registro['nm_motivo_baixa']}";  
166 - }  
167 - }  
168 - }  
169 - else  
170 - {  
171 - echo "<!--\nErro\nClasse clsPmieducarMotivoBaixa nao encontrada\n-->";  
172 - $opcoes = array( "" => "Erro na geracao" );  
173 - }  
174 - $this->campoLista( "ref_cod_motivo_baixa", "Motivo Baixa", $opcoes, $this->ref_cod_motivo_baixa );  
175 - */  
176 -  
177 -  
178 - $opcoes = array();  
179 - if( $this->ref_cod_acervo && $this->ref_cod_acervo != "NULL")  
180 - {  
181 - $objTemp = new clsPmieducarAcervo($this->ref_cod_acervo);  
182 - $detalhe = $objTemp->detalhe();  
183 - if ( $detalhe )  
184 - {  
185 - $opcoes["{$detalhe['cod_acervo']}"] = "{$detalhe['titulo']}";  
186 - }  
187 - }else{  
188 - $opcoes = array( "" => "Selecione" );  
189 - } 128 + $selectInputs = array('instituicao', 'escola', 'biblioteca', 'bibliotecaSituacao', 'bibliotecaFonte');
  129 + $this->inputsHelper()->dynamic($selectInputs);
190 130
191 - //campoListaPesq( $nome, $campo, $valor, $default, $caminho="", $acao = "" , $duplo=false, $descricao="", $descricao2="", $flag=null, $pag_cadastro = null, $disabled = "", $div = false, $serializedcampos = false, $obrigatorio = false )  
192 -// $this->campoListaPesq( "ref_cod_acervo", "Obra Refer&ecirc;ncia", $opcoes, $this->ref_cod_acervo,"educar_pesquisa_acervo_lst.php?campo1=ref_cod_acervo","","","","","","","",true );  
193 - $this->campoLista("ref_cod_acervo","Obra",$opcoes,$this->ref_cod_acervo,"",false,"","<img border=\"0\" onclick=\"pesquisa();\" id=\"ref_cod_acervo_lupa\" name=\"ref_cod_acervo_lupa\" src=\"imagens/lupa.png\"\/>",false,true);  
194 -  
195 - /* $opcoes = array( "" => "Selecione" );  
196 - if( class_exists( "clsPmieducarAcervo" ) )  
197 - {  
198 - $objTemp = new clsPmieducarAcervo();  
199 - $lista = $objTemp->lista();  
200 - if ( is_array( $lista ) && count( $lista ) )  
201 - {  
202 - foreach ( $lista as $registro )  
203 - {  
204 - $opcoes["{$registro['cod_acervo']}"] = "{$registro['titulo']}";  
205 - }  
206 - }  
207 - }  
208 - else  
209 - {  
210 - echo "<!--\nErro\nClasse clsPmieducarAcervo nao encontrada\n-->";  
211 - $opcoes = array( "" => "Erro na geracao" );  
212 - }  
213 - $this->campoLista( "ref_cod_acervo", "Acervo", $opcoes, $this->ref_cod_acervo );  
214 -*/  
215 -  
216 - /*if( class_exists( "clsPmieducarSituacao" ) )  
217 - {  
218 - $objTemp = new clsPmieducarSituacao();  
219 - $lista = $objTemp->lista();  
220 - if ( is_array( $lista ) && count( $lista ) )  
221 - {  
222 - $situacao = "situacao = new Array();\n";  
223 - foreach ( $lista as $registro )  
224 - {  
225 - //$opcoes["{$registro['cod_situacao']}"] = "{$registro['nm_situacao']}";  
226 - $situacao .= "situacao[situacao.length] = new Array( {$registro["cod_situacao"]}, '{$registro['nm_situacao']}', {$registro['ref_cod_biblioteca']});\n";  
227 - }  
228 -  
229 - echo "<script>{$situacao}</script>";  
230 - }  
231 - }  
232 - else  
233 - {  
234 - echo "<!--\nErro\nClasse clsPmieducarSituacao nao encontrada\n-->";  
235 - $opcoes = array( "" => "Erro na geracao" );  
236 - }*/  
237 -  
238 - $opcoes = array( "" => "Selecione" );  
239 - if($this->ref_cod_biblioteca)  
240 - {  
241 - if( class_exists( "clsPmieducarSituacao" ) )  
242 - {  
243 - $objTemp = new clsPmieducarSituacao();  
244 - $lista = $objTemp->lista(null,null,null,null,null,null,null,null,null,null,null,null,null,$this->ref_cod_biblioteca);  
245 - if ( is_array( $lista ) && count( $lista ) )  
246 - {  
247 - foreach ( $lista as $registro )  
248 - {  
249 - $opcoes["{$registro['cod_situacao']}"] = "{$registro['nm_situacao']}";  
250 - }  
251 - }  
252 - }  
253 - else  
254 - {  
255 - echo "<!--\nErro\nClasse clsPmieducarSituacao nao encontrada\n-->";  
256 - $opcoes = array( "" => "Erro na geracao" );  
257 - }  
258 - }  
259 - $this->campoLista( "ref_cod_situacao", "Situac&atilde;o", $opcoes, $this->ref_cod_situacao );  
260 -  
261 -  
262 - // text  
263 $opcoes = array( "" => "Selecione", "2" => "Sim", "1" => "N&atilde;o" ); 131 $opcoes = array( "" => "Selecione", "2" => "Sim", "1" => "N&atilde;o" );
264 $this->campoLista( "permite_emprestimo", "Permite Emprestimo", $opcoes, $this->permite_emprestimo ); 132 $this->campoLista( "permite_emprestimo", "Permite Emprestimo", $opcoes, $this->permite_emprestimo );
265 - //$this->campoTexto( "permite_emprestimo", "Permite Emprestimo", $this->permite_emprestimo, 30, 255, true ); 133 +
266 $this->preco = is_numeric($this->preco) ? number_format($this->preco, 2, ",", ".") : ""; 134 $this->preco = is_numeric($this->preco) ? number_format($this->preco, 2, ",", ".") : "";
267 $this->campoMonetario( "preco", "Preco", $this->preco, 10, 20, true ); 135 $this->campoMonetario( "preco", "Preco", $this->preco, 10, 20, true );
268 136
  137 + $this->inputsHelper()->dynamic('bibliotecaPesquisaObra', array('required' => true));
  138 +
269 // data 139 // data
270 if(!$this->data_aquisicao) 140 if(!$this->data_aquisicao)
271 $this->data_aquisicao = date("d/m/Y"); 141 $this->data_aquisicao = date("d/m/Y");
272 - $this->campoData( "data_aquisicao", "Data Aquisic&atilde;o", $this->data_aquisicao, false ); 142 +
  143 + $this->campoData( "data_aquisicao", "Data Aquisic&atilde;o", $this->data_aquisicao, true );
  144 +
  145 + $this->campoNumero("tombo", "Tombo", $this->tombo, 10, 10, false);
  146 +
273 if (!is_numeric($this->cod_exemplar)) 147 if (!is_numeric($this->cod_exemplar))
274 - {  
275 $this->campoNumero("qtd_livros", "Quantidade de Livros", 1, 5, 5, true); 148 $this->campoNumero("qtd_livros", "Quantidade de Livros", 1, 5, 5, true);
276 -// $this->campoBoolLista("tombo_automarico", "Tombo Automático", "t");  
277 - $this->campoNumero("combo_manual", "Combo", "", 5, 5, false);  
278 - $this->campoOculto("eh_manual", 0);  
279 - }  
280 } 149 }
281 150
282 function Novo() 151 function Novo()
@@ -290,33 +159,27 @@ class indice extends clsCadastro @@ -290,33 +159,27 @@ class indice extends clsCadastro
290 159
291 $this->preco = str_replace(".","",$this->preco); 160 $this->preco = str_replace(".","",$this->preco);
292 $this->preco = str_replace(",",".",$this->preco); 161 $this->preco = str_replace(",",".",$this->preco);
293 - if (!$this->combo_manual)  
294 - {  
295 - $obj_exemplar = new clsPmieducarExemplar();  
296 - $max_tombo = $obj_exemplar->retorna_tombo_maximo() + 1;  
297 - }  
298 - else  
299 - {  
300 - $max_tombo = $this->combo_manual;  
301 - }  
302 - for ($i = 0; $i < $this->qtd_livros; $i++) 162 +
  163 + $this->data_aquisicao = dataToBanco($this->data_aquisicao);
  164 +
  165 + for ($i = 0; $i < $this->qtd_livros; $i++)
303 { 166 {
304 - $obj = new clsPmieducarExemplar( $this->cod_exemplar, $this->ref_cod_fonte, $this->ref_cod_motivo_baixa, $this->ref_cod_acervo, $this->ref_cod_situacao, $this->pessoa_logada, $this->pessoa_logada, $this->permite_emprestimo, $this->preco, $this->data_cadastro, $this->data_exclusao, $this->ativo, $this->data_aquisicao, $max_tombo ); 167 + $obj = new clsPmieducarExemplar($this->cod_exemplar, $this->ref_cod_fonte, $this->ref_cod_motivo_baixa, $this->ref_cod_acervo, $this->ref_cod_situacao, $this->pessoa_logada, $this->pessoa_logada, $this->permite_emprestimo, $this->preco, $this->data_cadastro, $this->data_exclusao, $this->ativo, $this->data_aquisicao, $this->getTombo());
305 $cadastrou = $obj->cadastra(); 168 $cadastrou = $obj->cadastra();
306 - if (!$cadastrou) 169 + if (!$cadastrou)
307 { 170 {
308 $this->mensagem = "Cadastro n&atilde;o realizado.<br>"; 171 $this->mensagem = "Cadastro n&atilde;o realizado.<br>";
309 echo "<!--\nErro ao cadastrar clsPmieducarExemplar\nvalores obrigatorios\nis_numeric( $this->ref_cod_fonte ) && is_numeric( $this->ref_cod_acervo ) && is_numeric( $this->ref_cod_situacao ) && is_numeric( $this->ref_usuario_cad ) && is_numeric( $this->permite_emprestimo ) && is_numeric( $this->preco )\n-->"; 172 echo "<!--\nErro ao cadastrar clsPmieducarExemplar\nvalores obrigatorios\nis_numeric( $this->ref_cod_fonte ) && is_numeric( $this->ref_cod_acervo ) && is_numeric( $this->ref_cod_situacao ) && is_numeric( $this->ref_usuario_cad ) && is_numeric( $this->permite_emprestimo ) && is_numeric( $this->preco )\n-->";
310 return false; 173 return false;
311 } 174 }
312 - $max_tombo++;  
313 - } 175 + }
314 $this->mensagem .= "Cadastro efetuado com sucesso.<br>"; 176 $this->mensagem .= "Cadastro efetuado com sucesso.<br>";
315 header( "Location: educar_exemplar_lst.php" ); 177 header( "Location: educar_exemplar_lst.php" );
316 die(); 178 die();
317 return true; 179 return true;
318 } 180 }
319 181
  182 +
320 function Editar() 183 function Editar()
321 { 184 {
322 @session_start(); 185 @session_start();
@@ -330,7 +193,9 @@ class indice extends clsCadastro @@ -330,7 +193,9 @@ class indice extends clsCadastro
330 $this->preco = str_replace(".","",$this->preco); 193 $this->preco = str_replace(".","",$this->preco);
331 $this->preco = str_replace(",",".",$this->preco); 194 $this->preco = str_replace(",",".",$this->preco);
332 195
333 - $obj = new clsPmieducarExemplar($this->cod_exemplar, $this->ref_cod_fonte, $this->ref_cod_motivo_baixa, $this->ref_cod_acervo, $this->ref_cod_situacao, $this->pessoa_logada, $this->pessoa_logada, $this->permite_emprestimo, $this->preco, $this->data_cadastro, $this->data_exclusao, $this->ativo, $this->data_aquisicao); 196 + $this->data_aquisicao = dataToBanco($this->data_aquisicao);
  197 +
  198 + $obj = new clsPmieducarExemplar($this->cod_exemplar, $this->ref_cod_fonte, $this->ref_cod_motivo_baixa, $this->ref_cod_acervo, $this->ref_cod_situacao, $this->pessoa_logada, $this->pessoa_logada, $this->permite_emprestimo, $this->preco, $this->data_cadastro, $this->data_exclusao, $this->ativo, $this->data_aquisicao, $this->getTombo());
334 $editou = $obj->edita(); 199 $editou = $obj->edita();
335 if( $editou ) 200 if( $editou )
336 { 201 {
@@ -369,6 +234,21 @@ class indice extends clsCadastro @@ -369,6 +234,21 @@ class indice extends clsCadastro
369 echo "<!--\nErro ao excluir clsPmieducarExemplar\nvalores obrigatorios\nif( is_numeric( $this->cod_exemplar ) && is_numeric( $this->ref_usuario_exc ) )\n-->"; 234 echo "<!--\nErro ao excluir clsPmieducarExemplar\nvalores obrigatorios\nif( is_numeric( $this->cod_exemplar ) && is_numeric( $this->ref_usuario_exc ) )\n-->";
370 return false; 235 return false;
371 } 236 }
  237 +
  238 + protected function getTombo(){
  239 + if (! $this->tombo) {
  240 + $exemplar = new clsPmieducarExemplar();
  241 + $tombo = $exemplar->retorna_tombo_maximo($this->ref_cod_biblioteca, $this->cod_exemplar) + 1;
  242 + }
  243 + else {
  244 + // após obter tombo reseta para na proxima chamada de getTombo buscar o proximo no banco
  245 + $tombo = $this->tombo;
  246 + $this->tombo = null;
  247 + }
  248 +
  249 + return $tombo;
  250 + }
  251 +
372 } 252 }
373 253
374 // cria uma extensao da classe base 254 // cria uma extensao da classe base
@@ -380,144 +260,3 @@ $pagina-&gt;addForm( $miolo ); @@ -380,144 +260,3 @@ $pagina-&gt;addForm( $miolo );
380 // gera o html 260 // gera o html
381 $pagina->MakeAll(); 261 $pagina->MakeAll();
382 ?> 262 ?>
383 -<script>  
384 -/*  
385 -var before_getSituacao = function(){}  
386 -var after_getSituacao = function(){}  
387 -*/  
388 -  
389 -Event.observe(window, 'load', Init, false);  
390 -  
391 -function Init() {  
392 - $('tr_combo_manual').style.display = 'none;';  
393 -}  
394 -  
395 -var tempFonte;  
396 -var tempSitueacao;  
397 -if(document.getElementById('ref_cod_biblioteca').value != '')  
398 -{  
399 - ajaxBiblioteca('novo');  
400 - tempFonte = null;  
401 - tempSituacao = null;  
402 -}  
403 -  
404 -function getSituacao(xml_situacao)  
405 -{  
406 - var campoSituacao = document.getElementById('ref_cod_situacao');  
407 - var DOM_array = xml_situacao.getElementsByTagName( "situacao" );  
408 -  
409 - if(DOM_array.length)  
410 - {  
411 - campoSituacao.length = 1;  
412 - campoSituacao.options[0].text = 'Selecione uma situação';  
413 - campoSituacao.disabled = false;  
414 -  
415 - for( var i = 0; i < DOM_array.length; i++ )  
416 - {  
417 - campoSituacao.options[campoSituacao.options.length] = new Option( DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_situacao"),false,false);  
418 - }  
419 - if(tempSituacao != null)  
420 - campoSituacao.value = tempSituacao;  
421 - }  
422 - else  
423 - campoSituacao.options[0].text = 'A biblioteca não possui nenhuma situação';  
424 -}  
425 -  
426 -function getFonte(xml_fonte)  
427 -{  
428 - var campoFonte = document.getElementById('ref_cod_fonte');  
429 - var DOM_array = xml_fonte.getElementsByTagName( "fonte" );  
430 -  
431 - if(DOM_array.length)  
432 - {  
433 - campoFonte.length = 1;  
434 - campoFonte.options[0].text = 'Selecione uma fonte';  
435 - campoFonte.disabled = false;  
436 -  
437 - for( var i = 0; i < DOM_array.length; i++ )  
438 - {  
439 - campoFonte.options[campoFonte.options.length] = new Option( DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_fonte"),false,false);  
440 - }  
441 - if(tempFonte != null)  
442 - campoFonte.value = tempFonte;  
443 - }  
444 - else  
445 - campoFonte.options[0].text = 'A biblioteca não possui fonte';  
446 -}  
447 -  
448 -document.getElementById('ref_cod_biblioteca').onchange = function()  
449 -{  
450 - ajaxBiblioteca();  
451 - ajaxTomboAutomatico();  
452 -};  
453 -  
454 -  
455 -function ajaxTomboAutomatico()  
456 -{  
457 - var pars = 'biblioteca='+$F('ref_cod_biblioteca');  
458 - new Ajax.Request("educar_tombo_automatico.ajax.php", {method: 'get', parameters: pars,  
459 - onComplete: function(resp) {  
460 - if (resp.responseText == 1) {  
461 - $('tr_combo_manual').style.display = 'none;';  
462 - $('eh_manual').value = 0;  
463 - } else {  
464 - $('tr_combo_manual').style.display = '';  
465 - $('eh_manual').value = 1;  
466 - }  
467 - }  
468 - });  
469 -}  
470 -  
471 -function ajaxBiblioteca(acao)  
472 -{  
473 - var campoBiblioteca = document.getElementById('ref_cod_biblioteca').value;  
474 - var campoSituacao = document.getElementById('ref_cod_situacao');  
475 - if(acao == 'novo')  
476 - {  
477 - tempSituacao = campoSituacao.value;  
478 - }  
479 - campoSituacao.length = 1;  
480 - campoSituacao.disabled = true;  
481 - campoSituacao.options[0].text = 'Carregando situação';  
482 -  
483 - var xml_situacao = new ajax( getSituacao );  
484 - xml_situacao.envia( "educar_situacao_xml.php?bib="+campoBiblioteca );  
485 -  
486 - var campoFonte = document.getElementById('ref_cod_fonte');  
487 - if(acao == 'novo')  
488 - {  
489 - tempFonte = campoFonte.value;  
490 - }  
491 - campoFonte.length = 1;  
492 - campoFonte.disabled = true;  
493 - campoFonte.options[0].text = 'Carregando fontes';  
494 -  
495 - var xml_fonte = new ajax( getFonte );  
496 - xml_fonte.envia( "educar_fonte_xml.php?bib="+campoBiblioteca );  
497 -}  
498 -  
499 -function pesquisa()  
500 -{  
501 - var biblioteca = document.getElementById('ref_cod_biblioteca').value;  
502 - if(!biblioteca)  
503 - {  
504 - alert('Por favor,\nselecione uma biblioteca!');  
505 - return;  
506 - }  
507 - pesquisa_valores_popless('educar_pesquisa_acervo_lst.php?campo1=ref_cod_acervo&ref_cod_biblioteca=' + biblioteca , 'ref_cod_acervo');  
508 -}  
509 -  
510 -function acao2()  
511 -{  
512 - if ($('eh_manual').value = 0 && $F('combo_manual') == '')  
513 - {  
514 - alert('Favor preencher o campo combo corretamente');  
515 - }  
516 - else  
517 - {  
518 - acao();  
519 - }  
520 -}  
521 -  
522 -//pesquisa_valores_popless('educar_pesquisa_acervo_lst.php?campo1=ref_cod_acervo', 'ref_cod_acervo')  
523 -</script>  
524 \ No newline at end of file 263 \ No newline at end of file
ieducar/intranet/educar_exemplar_det.php
@@ -129,11 +129,9 @@ class indice extends clsDetalhe @@ -129,11 +129,9 @@ class indice extends clsDetalhe
129 echo "<!--\nErro\nClasse nao existente: clsPmieducarSituacao\n-->"; 129 echo "<!--\nErro\nClasse nao existente: clsPmieducarSituacao\n-->";
130 } 130 }
131 131
  132 + $this->addDetalhe(array("Código", "{$registro["cod_exemplar"]}"));
  133 + $this->addDetalhe(array("Tombo", "{$registro["tombo"]}"));
132 134
133 - if( $registro["cod_exemplar"] )  
134 - {  
135 - $this->addDetalhe( array( "Tombo", "{$registro["cod_exemplar"]}") );  
136 - }  
137 if( $registro["ref_cod_acervo"] ) 135 if( $registro["ref_cod_acervo"] )
138 { 136 {
139 $this->addDetalhe( array( "Obra Refer&eacute;ncia", "{$registro["ref_cod_acervo"]}") ); 137 $this->addDetalhe( array( "Obra Refer&eacute;ncia", "{$registro["ref_cod_acervo"]}") );
@@ -193,4 +191,4 @@ $miolo = new indice(); @@ -193,4 +191,4 @@ $miolo = new indice();
193 $pagina->addForm( $miolo ); 191 $pagina->addForm( $miolo );
194 // gera o html 192 // gera o html
195 $pagina->MakeAll(); 193 $pagina->MakeAll();
196 -?>  
197 \ No newline at end of file 194 \ No newline at end of file
  195 +?>
ieducar/intranet/educar_exemplar_devolucao_det.php
@@ -187,10 +187,10 @@ class indice extends clsDetalhe @@ -187,10 +187,10 @@ class indice extends clsDetalhe
187 { 187 {
188 $this->addDetalhe( array( "Obra", "{$titulo_exemplar}") ); 188 $this->addDetalhe( array( "Obra", "{$titulo_exemplar}") );
189 } 189 }
190 - if( $registro["ref_cod_exemplar"] )  
191 - {  
192 - $this->addDetalhe( array( "Tombo", "{$registro["ref_cod_exemplar"]}") );  
193 - } 190 +
  191 + $this->addDetalhe( array( "Código exemplar", "{$registro["ref_cod_exemplar"]}") );
  192 + $this->addDetalhe( array( "Tombo", "{$det_ref_cod_exemplar["tombo"]}") );
  193 +
194 if( $registro["data_retirada"] ) 194 if( $registro["data_retirada"] )
195 { 195 {
196 $this->addDetalhe( array( "Data Retirada", dataFromPgToBr( $registro["data_retirada"], "d/m/Y" ) ) ); 196 $this->addDetalhe( array( "Data Retirada", dataFromPgToBr( $registro["data_retirada"], "d/m/Y" ) ) );
@@ -219,4 +219,4 @@ $miolo = new indice(); @@ -219,4 +219,4 @@ $miolo = new indice();
219 $pagina->addForm( $miolo ); 219 $pagina->addForm( $miolo );
220 // gera o html 220 // gera o html
221 $pagina->MakeAll(); 221 $pagina->MakeAll();
222 -?>  
223 \ No newline at end of file 222 \ No newline at end of file
  223 +?>
ieducar/intranet/educar_exemplar_devolucao_lst.php
@@ -100,6 +100,7 @@ class indice extends clsListagem @@ -100,6 +100,7 @@ class indice extends clsListagem
100 100
101 $lista_busca = array( 101 $lista_busca = array(
102 "Cliente", 102 "Cliente",
  103 + "Código exemplar",
103 "Tombo", 104 "Tombo",
104 "Exemplar", 105 "Exemplar",
105 "Data Retirada" 106 "Data Retirada"
@@ -120,7 +121,8 @@ class indice extends clsListagem @@ -120,7 +121,8 @@ class indice extends clsListagem
120 $this->campoTexto("nm_obra","Obra", $this->nm_obra, 30, 255, false, false, false, "", "<img border=\"0\" onclick=\"pesquisa_obra();\" id=\"ref_cod_exemplar_lupa\" name=\"ref_cod_exemplar_lupa\" src=\"imagens/lupa.png\"\/>"); 121 $this->campoTexto("nm_obra","Obra", $this->nm_obra, 30, 255, false, false, false, "", "<img border=\"0\" onclick=\"pesquisa_obra();\" id=\"ref_cod_exemplar_lupa\" name=\"ref_cod_exemplar_lupa\" src=\"imagens/lupa.png\"\/>");
121 $this->campoOculto("ref_cod_acervo", $this->ref_cod_acervo); 122 $this->campoOculto("ref_cod_acervo", $this->ref_cod_acervo);
122 123
123 - $this->campoNumero("ref_cod_exemplar","Tombo", $this->ref_cod_exemplar, 15, 50); 124 + $this->campoNumero("ref_cod_exemplar","Código exemplar", $this->ref_cod_exemplar, 15, 10);
  125 + $this->campoNumero("tombo","Tombo", $this->tombo, 15, 10);
124 126
125 if ($this->ref_cod_biblioteca) 127 if ($this->ref_cod_biblioteca)
126 { 128 {
@@ -227,6 +229,7 @@ class indice extends clsListagem @@ -227,6 +229,7 @@ class indice extends clsListagem
227 $lista_busca = array( 229 $lista_busca = array(
228 "<a href=\"educar_exemplar_devolucao_det.php?cod_emprestimo={$registro["cod_emprestimo"]}\">{$registro["ref_cod_cliente"]}</a>", 230 "<a href=\"educar_exemplar_devolucao_det.php?cod_emprestimo={$registro["cod_emprestimo"]}\">{$registro["ref_cod_cliente"]}</a>",
229 "<a href=\"educar_exemplar_devolucao_det.php?cod_emprestimo={$registro["cod_emprestimo"]}\">{$registro["ref_cod_exemplar"]}</a>", 231 "<a href=\"educar_exemplar_devolucao_det.php?cod_emprestimo={$registro["cod_emprestimo"]}\">{$registro["ref_cod_exemplar"]}</a>",
  232 + "<a href=\"educar_exemplar_devolucao_det.php?cod_emprestimo={$registro["cod_emprestimo"]}\">{$det_exemplar["tombo"]}</a>",
230 "<a href=\"educar_exemplar_devolucao_det.php?cod_emprestimo={$registro["cod_emprestimo"]}\">{$registro["titulo"]}</a>", 233 "<a href=\"educar_exemplar_devolucao_det.php?cod_emprestimo={$registro["cod_emprestimo"]}\">{$registro["titulo"]}</a>",
231 "<a href=\"educar_exemplar_devolucao_det.php?cod_emprestimo={$registro["cod_emprestimo"]}\">{$registro["data_retirada_br"]}</a>" 234 "<a href=\"educar_exemplar_devolucao_det.php?cod_emprestimo={$registro["cod_emprestimo"]}\">{$registro["data_retirada_br"]}</a>"
232 ); 235 );
@@ -271,4 +274,4 @@ function pesquisa_obra() @@ -271,4 +274,4 @@ function pesquisa_obra()
271 pesquisa_valores_popless('educar_pesquisa_obra_lst.php?campo1=ref_cod_acervo&campo2=nm_obra&campo3='+campoBiblioteca) 274 pesquisa_valores_popless('educar_pesquisa_obra_lst.php?campo1=ref_cod_acervo&campo2=nm_obra&campo3='+campoBiblioteca)
272 } 275 }
273 276
274 -</script>  
275 \ No newline at end of file 277 \ No newline at end of file
  278 +</script>
ieducar/intranet/educar_exemplar_tipo_cad.php
@@ -334,8 +334,11 @@ setVisibility (&#39;tr_div_clientes&#39;, false); @@ -334,8 +334,11 @@ setVisibility (&#39;tr_div_clientes&#39;, false);
334 function getClienteTipo() 334 function getClienteTipo()
335 { 335 {
336 var campoBiblioteca = document.getElementById('ref_cod_biblioteca').value; 336 var campoBiblioteca = document.getElementById('ref_cod_biblioteca').value;
  337 + var exemplarTipoId = document.getElementById('cod_exemplar_tipo').value;
  338 +
337 var xml1 = new ajax(getClienteTipo_XML); 339 var xml1 = new ajax(getClienteTipo_XML);
338 - strURL = "educar_cliente_tipo_xml.php?bib="+campoBiblioteca; 340 +
  341 + strURL = "educar_cliente_tipo_xml.php?bib="+campoBiblioteca+"&exemplar_tipo_id="+exemplarTipoId;
339 xml1.envia(strURL); 342 xml1.envia(strURL);
340 } 343 }
341 344
@@ -378,7 +381,7 @@ function getClienteTipo_XML(xml) @@ -378,7 +381,7 @@ function getClienteTipo_XML(xml)
378 nm_tipo_cliente.setAttribute( 'style', 'margin: 2px;' ); 381 nm_tipo_cliente.setAttribute( 'style', 'margin: 2px;' );
379 // nm_tipo_cliente.setAttribute( 'value', tipo_cliente[j][1] ); 382 // nm_tipo_cliente.setAttribute( 'value', tipo_cliente[j][1] );
380 nm_tipo_cliente.setAttribute( 'value', tipo_cliente[j].firstChild.data ); 383 nm_tipo_cliente.setAttribute( 'value', tipo_cliente[j].firstChild.data );
381 - 384 +
382 dias_tipo_cliente.setAttribute( "id", "tipo_"+tipo_cliente[j].getAttribute("cod_cliente_tipo") ); 385 dias_tipo_cliente.setAttribute( "id", "tipo_"+tipo_cliente[j].getAttribute("cod_cliente_tipo") );
383 dias_tipo_cliente.setAttribute( 'type', 'text' ); 386 dias_tipo_cliente.setAttribute( 'type', 'text' );
384 dias_tipo_cliente.setAttribute( 'size', '3' ); 387 dias_tipo_cliente.setAttribute( 'size', '3' );
@@ -444,4 +447,4 @@ if(editar_) @@ -444,4 +447,4 @@ if(editar_)
444 { 447 {
445 padding: 6px; 448 padding: 6px;
446 } 449 }
447 -</style>  
448 \ No newline at end of file 450 \ No newline at end of file
  451 +</style>
ieducar/intranet/educar_fonte_cad.php
@@ -99,35 +99,11 @@ class indice extends clsCadastro @@ -99,35 +99,11 @@ class indice extends clsCadastro
99 $this->campoOculto( "cod_fonte", $this->cod_fonte ); 99 $this->campoOculto( "cod_fonte", $this->cod_fonte );
100 100
101 // foreign keys 101 // foreign keys
102 -/* $obj_pessoa_bib = new clsPmieducarBibliotecaUsuario();  
103 - $lst_pessoa_bib = $obj_pessoa_bib->lista(null, $this->pessoa_logada);  
104 -  
105 - $opcoes = array("" => "Selecione");  
106 - if(is_array($lst_pessoa_bib))  
107 - {  
108 - foreach ($lst_pessoa_bib as $bib)  
109 - {  
110 - $obj_biblioteca = new clsPmieducarBiblioteca($bib['ref_cod_biblioteca']);  
111 - $det_biblioteca = $obj_biblioteca->detalhe();  
112 -  
113 - $opcoes[$det_biblioteca['cod_biblioteca']] = $det_biblioteca['nm_biblioteca'];  
114 - }  
115 - }  
116 - $this->campoLista("ref_cod_biblioteca", "Biblioteca", $opcoes, $this->ref_cod_biblioteca);*/  
117 -  
118 - $get_escola = 1;  
119 - $escola_obrigatorio = false;  
120 - $get_biblioteca = 1;  
121 - $instituicao_obrigatorio = true;  
122 - $biblioteca_obrigatorio = true;  
123 - include("include/pmieducar/educar_campo_lista.php"); 102 + $this->inputsHelper()->dynamic(array('instituicao', 'escola', 'biblioteca'));
124 103
125 // text 104 // text
126 $this->campoTexto( "nm_fonte", "Fonte", $this->nm_fonte, 30, 255, true ); 105 $this->campoTexto( "nm_fonte", "Fonte", $this->nm_fonte, 30, 255, true );
127 $this->campoMemo( "descricao", "Descri&ccedil;&atilde;o", $this->descricao, 60, 5, false ); 106 $this->campoMemo( "descricao", "Descri&ccedil;&atilde;o", $this->descricao, 60, 5, false );
128 -  
129 - // data  
130 -  
131 } 107 }
132 108
133 function Novo() 109 function Novo()
@@ -214,4 +190,4 @@ $miolo = new indice(); @@ -214,4 +190,4 @@ $miolo = new indice();
214 $pagina->addForm( $miolo ); 190 $pagina->addForm( $miolo );
215 // gera o html 191 // gera o html
216 $pagina->MakeAll(); 192 $pagina->MakeAll();
217 -?>  
218 \ No newline at end of file 193 \ No newline at end of file
  194 +?>
ieducar/intranet/educar_motivo_baixa_cad.php
@@ -97,28 +97,9 @@ class indice extends clsCadastro @@ -97,28 +97,9 @@ class indice extends clsCadastro
97 // primary keys 97 // primary keys
98 $this->campoOculto( "cod_motivo_baixa", $this->cod_motivo_baixa ); 98 $this->campoOculto( "cod_motivo_baixa", $this->cod_motivo_baixa );
99 99
100 - /*$obj_pessoa_bib = new clsPmieducarBibliotecaUsuario();  
101 - $lst_pessoa_bib = $obj_pessoa_bib->lista(null, $this->pessoa_logada); 100 + //foreign keys
  101 + $this->inputsHelper()->dynamic(array('instituicao', 'escola', 'biblioteca'));
102 102
103 - $opcoes = array("" => "Selecione");  
104 - if(is_array($lst_pessoa_bib))  
105 - {  
106 - foreach ($lst_pessoa_bib as $bib)  
107 - {  
108 - $obj_biblioteca = new clsPmieducarBiblioteca($bib['ref_cod_biblioteca']);  
109 - $det_biblioteca = $obj_biblioteca->detalhe();  
110 -  
111 - $opcoes[$det_biblioteca['cod_biblioteca']] = $det_biblioteca['nm_biblioteca'];  
112 - }  
113 - }  
114 - $this->campoLista("ref_cod_biblioteca", "Biblioteca", $opcoes, $this->ref_cod_biblioteca);  
115 -*/  
116 - $get_escola = 1;  
117 - $escola_obrigatorio = false;  
118 - $get_biblioteca = 1;  
119 - $instituicao_obrigatorio = true;  
120 - $biblioteca_obrigatorio = true;  
121 - include("include/pmieducar/educar_campo_lista.php");  
122 // text 103 // text
123 $this->campoTexto( "nm_motivo_baixa", "Motivo Baixa", $this->nm_motivo_baixa, 30, 255, true ); 104 $this->campoTexto( "nm_motivo_baixa", "Motivo Baixa", $this->nm_motivo_baixa, 30, 255, true );
124 $this->campoMemo( "descricao", "Descri&ccedil;&atilde;o", $this->descricao, 60, 5, false ); 105 $this->campoMemo( "descricao", "Descri&ccedil;&atilde;o", $this->descricao, 60, 5, false );
@@ -208,4 +189,4 @@ $miolo = new indice(); @@ -208,4 +189,4 @@ $miolo = new indice();
208 $pagina->addForm( $miolo ); 189 $pagina->addForm( $miolo );
209 // gera o html 190 // gera o html
210 $pagina->MakeAll(); 191 $pagina->MakeAll();
211 -?>  
212 \ No newline at end of file 192 \ No newline at end of file
  193 +?>
ieducar/intranet/educar_motivo_suspensao_cad.php
@@ -95,30 +95,10 @@ class indice extends clsCadastro @@ -95,30 +95,10 @@ class indice extends clsCadastro
95 { 95 {
96 // primary keys 96 // primary keys
97 $this->campoOculto( "cod_motivo_suspensao", $this->cod_motivo_suspensao ); 97 $this->campoOculto( "cod_motivo_suspensao", $this->cod_motivo_suspensao );
98 -  
99 - /*$obj_pessoa_bib = new clsPmieducarBibliotecaUsuario();  
100 - $lst_pessoa_bib = $obj_pessoa_bib->lista(null, $this->pessoa_logada);  
101 98
102 - $opcoes = array("" => "Selecione");  
103 - if(is_array($lst_pessoa_bib))  
104 - {  
105 - foreach ($lst_pessoa_bib as $bib)  
106 - {  
107 - $obj_biblioteca = new clsPmieducarBiblioteca($bib['ref_cod_biblioteca']);  
108 - $det_biblioteca = $obj_biblioteca->detalhe();  
109 -  
110 - $opcoes[$det_biblioteca['cod_biblioteca']] = $det_biblioteca['nm_biblioteca'];  
111 - }  
112 - }  
113 - $this->campoLista("ref_cod_biblioteca", "Biblioteca", $opcoes, $this->ref_cod_biblioteca);*/  
114 -  
115 - $get_escola = 1;  
116 - $escola_obrigatorio = false;  
117 - $get_biblioteca = 1;  
118 - $instituicao_obrigatorio = true;  
119 - $biblioteca_obrigatorio = true;  
120 - include("include/pmieducar/educar_campo_lista.php");  
121 - 99 + //foreign keys
  100 + $this->inputsHelper()->dynamic(array('instituicao', 'escola', 'biblioteca'));
  101 +
122 // text 102 // text
123 $this->campoTexto( "nm_motivo", "Motivo Suspens&atilde;o", $this->nm_motivo, 30, 255, true ); 103 $this->campoTexto( "nm_motivo", "Motivo Suspens&atilde;o", $this->nm_motivo, 30, 255, true );
124 $this->campoMemo( "descricao", "Descri&ccedil;&atilde;o", $this->descricao, 60, 5, false ); 104 $this->campoMemo( "descricao", "Descri&ccedil;&atilde;o", $this->descricao, 60, 5, false );
@@ -208,4 +188,4 @@ $miolo = new indice(); @@ -208,4 +188,4 @@ $miolo = new indice();
208 $pagina->addForm( $miolo ); 188 $pagina->addForm( $miolo );
209 // gera o html 189 // gera o html
210 $pagina->MakeAll(); 190 $pagina->MakeAll();
211 -?>  
212 \ No newline at end of file 191 \ No newline at end of file
  192 +?>
ieducar/intranet/educar_situacao_cad.php
@@ -216,15 +216,8 @@ class indice extends clsCadastro @@ -216,15 +216,8 @@ class indice extends clsCadastro
216 $obj_permissoes = new clsPermissoes(); 216 $obj_permissoes = new clsPermissoes();
217 $obj_permissoes->permissao_cadastra( 602, $this->pessoa_logada, 11, "educar_situacao_lst.php" ); 217 $obj_permissoes->permissao_cadastra( 602, $this->pessoa_logada, 11, "educar_situacao_lst.php" );
218 218
219 - if ($this->situacao_padrao == 'on')  
220 - $this->situacao_padrao = 1;  
221 - else  
222 - $this->situacao_padrao = 0;  
223 -  
224 - if ($this->situacao_emprestada == 'on')  
225 - $this->situacao_emprestada = 1;  
226 - else  
227 - $this->situacao_emprestada = 0; 219 + $this->situacao_padrao = is_null($this->situacao_padrao) ? 0 : 1;
  220 + $this->situacao_emprestada = is_null($this->situacao_emprestada) ? 0 : 1;
228 221
229 $obj = new clsPmieducarSituacao( null, null, $this->pessoa_logada, $this->nm_situacao, $this->permite_emprestimo, $this->descricao, $this->situacao_padrao, $this->situacao_emprestada, null, null, 1, $this->ref_cod_biblioteca ); 222 $obj = new clsPmieducarSituacao( null, null, $this->pessoa_logada, $this->nm_situacao, $this->permite_emprestimo, $this->descricao, $this->situacao_padrao, $this->situacao_emprestada, null, null, 1, $this->ref_cod_biblioteca );
230 $cadastrou = $obj->cadastra(); 223 $cadastrou = $obj->cadastra();
@@ -250,15 +243,8 @@ class indice extends clsCadastro @@ -250,15 +243,8 @@ class indice extends clsCadastro
250 $obj_permissoes = new clsPermissoes(); 243 $obj_permissoes = new clsPermissoes();
251 $obj_permissoes->permissao_cadastra( 602, $this->pessoa_logada, 11, "educar_situacao_lst.php" ); 244 $obj_permissoes->permissao_cadastra( 602, $this->pessoa_logada, 11, "educar_situacao_lst.php" );
252 245
253 - if ($this->situacao_padrao == 'on')  
254 - $this->situacao_padrao = 1;  
255 - else  
256 - $this->situacao_padrao = 0;  
257 -  
258 - if ($this->situacao_emprestada == 'on')  
259 - $this->situacao_emprestada = 1;  
260 - else  
261 - $this->situacao_emprestada = 0; 246 + $this->situacao_padrao = is_null($this->situacao_padrao) ? 0 : 1;
  247 + $this->situacao_emprestada = is_null($this->situacao_emprestada) ? 0 : 1;
262 248
263 $obj = new clsPmieducarSituacao($this->cod_situacao, $this->pessoa_logada, null, $this->nm_situacao, $this->permite_emprestimo, $this->descricao, $this->situacao_padrao, $this->situacao_emprestada, null, null, 1, $this->ref_cod_biblioteca); 249 $obj = new clsPmieducarSituacao($this->cod_situacao, $this->pessoa_logada, null, $this->nm_situacao, $this->permite_emprestimo, $this->descricao, $this->situacao_padrao, $this->situacao_emprestada, null, null, 1, $this->ref_cod_biblioteca);
264 $editou = $obj->edita(); 250 $editou = $obj->edita();
@@ -375,4 +361,4 @@ function valida() @@ -375,4 +361,4 @@ function valida()
375 document.forms[0].submit(); 361 document.forms[0].submit();
376 } 362 }
377 363
378 -</script>  
379 \ No newline at end of file 364 \ No newline at end of file
  365 +</script>
ieducar/intranet/include/pmieducar/clsPmieducarAcervo.inc.php
@@ -120,13 +120,13 @@ class clsPmieducarAcervo @@ -120,13 +120,13 @@ class clsPmieducarAcervo
120 * 120 *
121 * @return object 121 * @return object
122 */ 122 */
123 - function clsPmieducarAcervo( $cod_acervo = null, $ref_cod_exemplar_tipo = null, $ref_cod_acervo = null, $ref_usuario_exc = null, $ref_usuario_cad = null, $ref_cod_acervo_colecao = null, $ref_cod_acervo_idioma = null, $ref_cod_acervo_editora = null, $titulo = null, $sub_titulo = null, $cdu = null, $cutter = null, $volume = null, $num_edicao = null, $ano = null, $num_paginas = null, $isbn = null, $data_cadastro = null, $data_exclusao = null, $ativo = null, $ref_cod_biblioteca = null ) 123 + function clsPmieducarAcervo( $cod_acervo = null, $ref_cod_exemplar_tipo = null, $ref_cod_acervo = null, $ref_usuario_exc = null, $ref_usuario_cad = null, $ref_cod_acervo_colecao = null, $ref_cod_acervo_idioma = null, $ref_cod_acervo_editora = null, $titulo = null, $sub_titulo = null, $cdu = null, $cutter = null, $volume = null, $num_edicao = null, $ano = null, $num_paginas = null, $isbn = null, $data_cadastro = null, $data_exclusao = null, $ativo = null, $ref_cod_biblioteca = null, $cdd = null, $estante = null )
124 { 124 {
125 $db = new clsBanco(); 125 $db = new clsBanco();
126 $this->_schema = "pmieducar."; 126 $this->_schema = "pmieducar.";
127 $this->_tabela = "{$this->_schema}acervo"; 127 $this->_tabela = "{$this->_schema}acervo";
128 128
129 - $this->_campos_lista = $this->_todos_campos = "a.cod_acervo, a.ref_cod_exemplar_tipo, a.ref_cod_acervo, a.ref_usuario_exc, a.ref_usuario_cad, a.ref_cod_acervo_colecao, a.ref_cod_acervo_idioma, a.ref_cod_acervo_editora, a.titulo, a.sub_titulo, a.cdu, a.cutter, a.volume, a.num_edicao, a.ano, a.num_paginas, a.isbn, a.data_cadastro, a.data_exclusao, a.ativo, a.ref_cod_biblioteca"; 129 + $this->_campos_lista = $this->_todos_campos = "a.cod_acervo, a.ref_cod_exemplar_tipo, a.ref_cod_acervo, a.ref_usuario_exc, a.ref_usuario_cad, a.ref_cod_acervo_colecao, a.ref_cod_acervo_idioma, a.ref_cod_acervo_editora, a.titulo, a.sub_titulo, a.cdu, a.cutter, a.volume, a.num_edicao, a.ano, a.num_paginas, a.isbn, a.data_cadastro, a.data_exclusao, a.ativo, a.ref_cod_biblioteca, a.cdd, a.estante";
130 130
131 if( is_numeric( $ref_cod_biblioteca ) ) 131 if( is_numeric( $ref_cod_biblioteca ) )
132 { 132 {
@@ -411,6 +411,8 @@ class clsPmieducarAcervo @@ -411,6 +411,8 @@ class clsPmieducarAcervo
411 $this->ativo = $ativo; 411 $this->ativo = $ativo;
412 } 412 }
413 413
  414 + $this->cdd = $cdd;
  415 + $this->estante = $estante;
414 } 416 }
415 417
416 /** 418 /**
@@ -524,6 +526,7 @@ class clsPmieducarAcervo @@ -524,6 +526,7 @@ class clsPmieducarAcervo
524 $campos .= "{$gruda}ativo"; 526 $campos .= "{$gruda}ativo";
525 $valores .= "{$gruda}'1'"; 527 $valores .= "{$gruda}'1'";
526 $gruda = ", "; 528 $gruda = ", ";
  529 +
527 if( is_numeric( $this->ref_cod_biblioteca ) ) 530 if( is_numeric( $this->ref_cod_biblioteca ) )
528 { 531 {
529 $campos .= "{$gruda}ref_cod_biblioteca"; 532 $campos .= "{$gruda}ref_cod_biblioteca";
@@ -531,6 +534,19 @@ class clsPmieducarAcervo @@ -531,6 +534,19 @@ class clsPmieducarAcervo
531 $gruda = ", "; 534 $gruda = ", ";
532 } 535 }
533 536
  537 + if( is_string( $this->cdd ) )
  538 + {
  539 + $campos .= "{$gruda}cdd";
  540 + $valores .= "{$gruda}'{$this->cdd}'";
  541 + $gruda = ", ";
  542 + }
  543 +
  544 + if( is_string( $this->estante ) )
  545 + {
  546 + $campos .= "{$gruda}estante";
  547 + $valores .= "{$gruda}'{$this->estante}'";
  548 + $gruda = ", ";
  549 + }
534 550
535 $db->Consulta( "INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )" ); 551 $db->Consulta( "INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )" );
536 return $db->InsertId( "{$this->_tabela}_cod_acervo_seq"); 552 return $db->InsertId( "{$this->_tabela}_cod_acervo_seq");
@@ -649,6 +665,17 @@ class clsPmieducarAcervo @@ -649,6 +665,17 @@ class clsPmieducarAcervo
649 $gruda = ", "; 665 $gruda = ", ";
650 } 666 }
651 667
  668 + if( is_string( $this->cdd ) )
  669 + {
  670 + $set .= "{$gruda}cdd = '{$this->cdd}'";
  671 + $gruda = ", ";
  672 + }
  673 +
  674 + if( is_string( $this->estante ) )
  675 + {
  676 + $set .= "{$gruda}estante = '{$this->estante}'";
  677 + $gruda = ", ";
  678 + }
652 679
653 if( $set ) 680 if( $set )
654 { 681 {
@@ -853,7 +880,7 @@ class clsPmieducarAcervo @@ -853,7 +880,7 @@ class clsPmieducarAcervo
853 return false; 880 return false;
854 } 881 }
855 882
856 - 883 +
857 function listaAcervoBiblioteca($int_ref_cod_biblioteca = null, $str_titulo = null, $ativo = null, $int_ref_cod_acervo_colecao = null, $int_ref_cod_exemplar_tipo = null, $int_ref_cod_acervo_editora = null) 884 function listaAcervoBiblioteca($int_ref_cod_biblioteca = null, $str_titulo = null, $ativo = null, $int_ref_cod_acervo_colecao = null, $int_ref_cod_exemplar_tipo = null, $int_ref_cod_acervo_editora = null)
858 { 885 {
859 $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela} a"; 886 $sql = "SELECT {$this->_campos_lista} FROM {$this->_tabela} a";
@@ -870,7 +897,7 @@ class clsPmieducarAcervo @@ -870,7 +897,7 @@ class clsPmieducarAcervo
870 $filtros .= "{$whereAnd} ref_cod_biblioteca = '{$int_ref_cod_biblioteca}'"; 897 $filtros .= "{$whereAnd} ref_cod_biblioteca = '{$int_ref_cod_biblioteca}'";
871 $whereAnd = " AND "; 898 $whereAnd = " AND ";
872 } 899 }
873 - 900 +
874 if(is_string($str_titulo)) 901 if(is_string($str_titulo))
875 { 902 {
876 $filtros .= "{$whereAnd} titulo LIKE '%{$str_titulo}%'"; 903 $filtros .= "{$whereAnd} titulo LIKE '%{$str_titulo}%'";
@@ -896,11 +923,11 @@ class clsPmieducarAcervo @@ -896,11 +923,11 @@ class clsPmieducarAcervo
896 $filtros .= "{$whereAnd} ref_cod_acervo_editora = {$int_ref_cod_acervo_editora}"; 923 $filtros .= "{$whereAnd} ref_cod_acervo_editora = {$int_ref_cod_acervo_editora}";
897 $whereAnd = " AND "; 924 $whereAnd = " AND ";
898 } 925 }
899 - 926 +
900 $sql .= $filtros . $this->getOrderby() . $this->getLimite(); 927 $sql .= $filtros . $this->getOrderby() . $this->getLimite();
901 $db = new clsBanco(); 928 $db = new clsBanco();
902 $this->_total = $db->CampoUnico( "SELECT COUNT(0) FROM {$this->_tabela} a {$filtros}" ); 929 $this->_total = $db->CampoUnico( "SELECT COUNT(0) FROM {$this->_tabela} a {$filtros}" );
903 - 930 +
904 $db->Consulta( $sql ); 931 $db->Consulta( $sql );
905 $countCampos = count( explode( ",", $this->_campos_lista ) ); 932 $countCampos = count( explode( ",", $this->_campos_lista ) );
906 $resultado = array(); 933 $resultado = array();
@@ -929,7 +956,7 @@ class clsPmieducarAcervo @@ -929,7 +956,7 @@ class clsPmieducarAcervo
929 } 956 }
930 return false; 957 return false;
931 } 958 }
932 - 959 +
933 /** 960 /**
934 * Retorna um array com os dados de um registro 961 * Retorna um array com os dados de um registro
935 * 962 *
@@ -940,7 +967,7 @@ class clsPmieducarAcervo @@ -940,7 +967,7 @@ class clsPmieducarAcervo
940 if( is_numeric( $this->cod_acervo ) ) 967 if( is_numeric( $this->cod_acervo ) )
941 { 968 {
942 $db = new clsBanco(); 969 $db = new clsBanco();
943 - $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} a WHERE a.cod_acervo = '{$this->cod_acervo}'" ); 970 + $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} a WHERE a.cod_acervo = '{$this->cod_acervo}'" );
944 $db->ProximoRegistro(); 971 $db->ProximoRegistro();
945 return $db->Tupla(); 972 return $db->Tupla();
946 } 973 }
@@ -1069,4 +1096,4 @@ class clsPmieducarAcervo @@ -1069,4 +1096,4 @@ class clsPmieducarAcervo
1069 } 1096 }
1070 1097
1071 } 1098 }
1072 -?>  
1073 \ No newline at end of file 1099 \ No newline at end of file
  1100 +?>
ieducar/intranet/include/pmieducar/clsPmieducarAcervoEditora.inc.php
@@ -208,6 +208,7 @@ class clsPmieducarAcervoEditora @@ -208,6 +208,7 @@ class clsPmieducarAcervoEditora
208 } 208 }
209 } 209 }
210 } 210 }
  211 +
211 if( is_string( $ref_sigla_uf ) ) 212 if( is_string( $ref_sigla_uf ) )
212 { 213 {
213 if( class_exists( "clsUf" ) ) 214 if( class_exists( "clsUf" ) )
@@ -298,10 +299,8 @@ class clsPmieducarAcervoEditora @@ -298,10 +299,8 @@ class clsPmieducarAcervoEditora
298 * 299 *
299 * @return bool 300 * @return bool
300 */ 301 */
301 - function cadastra()  
302 - {  
303 - if( is_numeric( $this->ref_usuario_cad ) && is_string( $this->ref_idtlog ) && is_string( $this->ref_sigla_uf ) && is_string( $this->nm_editora ) && is_numeric( $this->cep ) && is_string( $this->cidade ) && is_string( $this->bairro ) && is_string( $this->logradouro ) && is_numeric($this->ref_cod_biblioteca) )  
304 - { 302 + function cadastra() {
  303 + if(is_numeric($this->ref_usuario_cad ) && is_string( $this->nm_editora ) && is_numeric($this->ref_cod_biblioteca)) {
305 $db = new clsBanco(); 304 $db = new clsBanco();
306 305
307 $campos = ""; 306 $campos = "";
@@ -417,16 +416,25 @@ class clsPmieducarAcervoEditora @@ -417,16 +416,25 @@ class clsPmieducarAcervoEditora
417 $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'"; 416 $set .= "{$gruda}ref_usuario_exc = '{$this->ref_usuario_exc}'";
418 $gruda = ", "; 417 $gruda = ", ";
419 } 418 }
420 - if( is_string( $this->ref_idtlog ) )  
421 - {  
422 - $set .= "{$gruda}ref_idtlog = '{$this->ref_idtlog}'";  
423 - $gruda = ", ";  
424 - }  
425 - if( is_string( $this->ref_sigla_uf ) )  
426 - {  
427 - $set .= "{$gruda}ref_sigla_uf = '{$this->ref_sigla_uf}'";  
428 - $gruda = ", ";  
429 - } 419 +
  420 + if(is_string($this->ref_idtlog )){
  421 + $set .= "{$gruda}ref_idtlog = '{$this->ref_idtlog}'";
  422 + $gruda = ", ";
  423 + }
  424 + else {
  425 + $set .= "{$gruda}ref_idtlog = null";
  426 + $gruda = ", ";
  427 + }
  428 +
  429 + if(is_string($this->ref_sigla_uf)){
  430 + $set .= "{$gruda}ref_sigla_uf = '{$this->ref_sigla_uf}'";
  431 + $gruda = ", ";
  432 + }
  433 + else {
  434 + $set .= "{$gruda}ref_sigla_uf = null";
  435 + $gruda = ", ";
  436 + }
  437 +
430 if( is_string( $this->nm_editora ) ) 438 if( is_string( $this->nm_editora ) )
431 { 439 {
432 $set .= "{$gruda}nm_editora = '{$this->nm_editora}'"; 440 $set .= "{$gruda}nm_editora = '{$this->nm_editora}'";
@@ -790,4 +798,4 @@ class clsPmieducarAcervoEditora @@ -790,4 +798,4 @@ class clsPmieducarAcervoEditora
790 } 798 }
791 799
792 } 800 }
793 -?>  
794 \ No newline at end of file 801 \ No newline at end of file
  802 +?>
ieducar/intranet/include/pmieducar/clsPmieducarCliente.inc.php
@@ -478,6 +478,7 @@ class clsPmieducarCliente @@ -478,6 +478,7 @@ class clsPmieducarCliente
478 $resultado[] = $tupla[$this->_campos_lista]; 478 $resultado[] = $tupla[$this->_campos_lista];
479 } 479 }
480 } 480 }
  481 +
481 if( count( $resultado ) ) 482 if( count( $resultado ) )
482 { 483 {
483 return $resultado; 484 return $resultado;
@@ -499,99 +500,8 @@ class clsPmieducarCliente @@ -499,99 +500,8 @@ class clsPmieducarCliente
499 $int_cod_cliente_tipo = NULL, $int_cod_escola = NULL, $int_cod_biblioteca = NULL, 500 $int_cod_cliente_tipo = NULL, $int_cod_escola = NULL, $int_cod_biblioteca = NULL,
500 $int_cod_instituicao = NULL) { 501 $int_cod_instituicao = NULL) {
501 502
502 - $tab_adicional = '';  
503 - $condicao = '';  
504 - $camp_adicional = '';  
505 -  
506 - // Executa filtragem por clientes suspensos somente quando houver registros na tabela  
507 - $clienteSuspenso = new clsPmieducarClienteSuspensao();  
508 $db = new clsBanco(); 503 $db = new clsBanco();
509 504
510 - // Se suspenso não for nulo e existirem cliente suspensos, seleciona-os  
511 - // quando ainda estiverem no prazo de suspensão  
512 - if ($db->doCountFromObj($clienteSuspenso) > 0) {  
513 - if (!is_null($str_suspenso)) {  
514 - $camp_adicional .= ', pmieducar.cliente_suspensao cs ';  
515 - $condicao .= ' AND c.cod_cliente = cs.ref_cod_cliente AND  
516 - (cs.data_suspensao < current_date - cs.dias)';  
517 - }  
518 - else {  
519 - $camp_adicional .= ', pmieducar.cliente_suspensao cs ';  
520 - $condicao .= ' AND (c.cod_cliente <> cs.ref_cod_cliente OR  
521 - (cs.data_suspensao > current_date - cs.dias))';  
522 - }  
523 - }  
524 -  
525 - $sql1 = "  
526 - SELECT  
527 - c.cod_cliente,  
528 - c.ref_idpes,  
529 - c.ref_usuario_cad,  
530 - c.login,  
531 - p.nome,  
532 - ct.nm_tipo,  
533 - ct.cod_cliente_tipo,  
534 - b.nm_biblioteca,  
535 - b.cod_biblioteca,  
536 - e.cod_escola as cod_escola,  
537 - i.cod_instituicao,  
538 - (SELECT 'S'::text  
539 - FROM pmieducar.cliente_suspensao cs  
540 - WHERE cs.ref_cod_cliente = c.cod_cliente  
541 - AND cs.data_liberacao IS NULL) AS id_suspensao  
542 - FROM  
543 - pmieducar.cliente c,  
544 - pmieducar.cliente_tipo_cliente ctc,  
545 - pmieducar.cliente_tipo ct,  
546 - pmieducar.biblioteca b,  
547 - pmieducar.escola e,  
548 - pmieducar.instituicao i,  
549 - cadastro.pessoa p{$camp_adicional}  
550 - WHERE  
551 - c.cod_cliente = ctc.ref_cod_cliente  
552 - AND ct.cod_cliente_tipo = ctc.ref_cod_cliente_tipo  
553 - AND b.cod_biblioteca = ct.ref_cod_biblioteca  
554 - AND e.cod_escola = b.ref_cod_escola  
555 - AND i.cod_instituicao = b.ref_cod_instituicao  
556 - AND e.ref_cod_instituicao = i.cod_instituicao{$condicao}  
557 - AND p.idpes = c.ref_idpes  
558 - AND c.ativo = '{$int_ativo}'  
559 - AND ctc.ativo = '{$int_ativo}'";  
560 -  
561 - $sql2 = "  
562 - SELECT  
563 - c.cod_cliente,  
564 - c.ref_idpes,  
565 - c.ref_usuario_cad,  
566 - c.login,  
567 - p.nome,  
568 - ct.nm_tipo,  
569 - ct.cod_cliente_tipo,  
570 - b.nm_biblioteca,  
571 - b.cod_biblioteca,  
572 - null as cod_escola,  
573 - i.cod_instituicao,  
574 - (SELECT 'S'::text  
575 - FROM pmieducar.cliente_suspensao cs  
576 - WHERE cs.ref_cod_cliente = c.cod_cliente  
577 - AND cs.data_liberacao IS NULL) AS id_suspensao  
578 - FROM  
579 - pmieducar.cliente c,  
580 - pmieducar.cliente_tipo_cliente ctc,  
581 - pmieducar.cliente_tipo ct,  
582 - pmieducar.biblioteca b,  
583 - pmieducar.instituicao i,  
584 - cadastro.pessoa p{$camp_adicional}  
585 - WHERE c.cod_cliente = ctc.ref_cod_cliente  
586 - AND ct.cod_cliente_tipo = ctc.ref_cod_cliente_tipo  
587 - AND b.cod_biblioteca = ct.ref_cod_biblioteca  
588 - AND i.cod_instituicao = b.ref_cod_instituicao  
589 - AND b.ref_cod_escola IS NULL  
590 - AND ct.ref_cod_biblioteca = b.cod_biblioteca{$condicao}  
591 - AND p.idpes = c.ref_idpes  
592 - AND c.ativo = '{$int_ativo}'  
593 - AND ctc.ativo = '{$int_ativo}'";  
594 -  
595 $filtros = ''; 505 $filtros = '';
596 $whereAnd = ' AND '; 506 $whereAnd = ' AND ';
597 507
@@ -685,46 +595,65 @@ class clsPmieducarCliente @@ -685,46 +595,65 @@ class clsPmieducarCliente
685 $whereAnd = " AND "; 595 $whereAnd = " AND ";
686 } 596 }
687 597
688 - if (is_string($str_suspenso)) {  
689 - $filtros .= "{$whereAnd} cs.data_liberacao IS NULL";  
690 - $whereAnd = " AND "; 598 + // se S(suspenso) ou R(egular), filtra por tal situacao
  599 + if(in_array($str_suspenso, array('S', 'R'))) {
  600 + $existencia = $str_suspenso == 'R' ? 'not' : '';
  601 + $condicaoSuspenso = " AND $existencia exists (select 1 from pmieducar.cliente_suspensao where ref_cod_cliente = c.cod_cliente and data_liberacao is null and data_suspensao + (dias||' day')::interval >= now())";
691 } 602 }
692 603
693 $db = new clsBanco(); 604 $db = new clsBanco();
694 $resultado = array(); 605 $resultado = array();
695 606
696 - $sql1 .= $filtros;  
697 - $sql2 .= $filtros;  
698 -  
699 - if (is_numeric($int_cod_escola)) {  
700 - $this->_total = $db->CampoUnico("SELECT count(0) FROM ({$sql1}) AS SUBQUERY");  
701 - }  
702 - else {  
703 - $this->_total = $db->CampoUnico("SELECT count(0) FROM (" . $sql1 . " UNION " . $sql2 . ") AS SUBQUERY");  
704 - }  
705 -  
706 - // Aplica ordenação e limite  
707 - $sql2 .= $this->getOrderby() . $this->getLimite();  
708 -  
709 - if (is_numeric($int_cod_escola)) {  
710 - $sql = $sql1;  
711 - }  
712 - else {  
713 - $sql = $sql1 . ' UNION ' . $sql2;  
714 - } 607 + $sql = "
  608 + SELECT
  609 + c.cod_cliente,
  610 + c.ref_idpes,
  611 + c.ref_usuario_cad,
  612 + c.login,
  613 + p.nome,
  614 + ct.nm_tipo,
  615 + ct.cod_cliente_tipo,
  616 + b.nm_biblioteca,
  617 + b.cod_biblioteca,
  618 + e.cod_escola as cod_escola,
  619 + i.cod_instituicao,
  620 + (SELECT 'S'::text
  621 + FROM pmieducar.cliente_suspensao cs
  622 + WHERE cs.ref_cod_cliente = c.cod_cliente
  623 + AND cs.data_liberacao IS NULL) AS id_suspensao
  624 + FROM
  625 + pmieducar.cliente c,
  626 + pmieducar.cliente_tipo_cliente ctc,
  627 + pmieducar.cliente_tipo ct,
  628 + pmieducar.biblioteca b,
  629 + pmieducar.escola e,
  630 + pmieducar.instituicao i,
  631 + cadastro.pessoa p
  632 + WHERE
  633 + c.cod_cliente = ctc.ref_cod_cliente
  634 + AND ct.cod_cliente_tipo = ctc.ref_cod_cliente_tipo
  635 + AND b.cod_biblioteca = ct.ref_cod_biblioteca
  636 + AND e.cod_escola = b.ref_cod_escola
  637 + AND i.cod_instituicao = b.ref_cod_instituicao
  638 + AND e.ref_cod_instituicao = i.cod_instituicao{$condicaoSuspenso}
  639 + AND p.idpes = c.ref_idpes
  640 + AND c.ativo = '{$int_ativo}'
  641 + AND ctc.ativo = '{$int_ativo}'
  642 + $filtros";
715 643
  644 + $sql .= $this->getOrderby() . $this->getLimite();
716 $db->Consulta($sql); 645 $db->Consulta($sql);
717 646
  647 + $this->_total = 0;
  648 +
718 while ($db->ProximoRegistro()) { 649 while ($db->ProximoRegistro()) {
719 $tupla = $db->Tupla(); 650 $tupla = $db->Tupla();
720 -  
721 - $tupla["_total"] = $this->_total;  
722 $resultado[] = $tupla; 651 $resultado[] = $tupla;
  652 + $this->_total += 1;
723 } 653 }
724 654
725 - if (count($resultado) > 0) { 655 + if (count($resultado) > 0)
726 return $resultado; 656 return $resultado;
727 - }  
728 657
729 return FALSE; 658 return FALSE;
730 } 659 }
@@ -1020,4 +949,4 @@ class clsPmieducarCliente @@ -1020,4 +949,4 @@ class clsPmieducarCliente
1020 return false; 949 return false;
1021 } 950 }
1022 951
1023 -}  
1024 \ No newline at end of file 952 \ No newline at end of file
  953 +}
ieducar/intranet/include/pmieducar/clsPmieducarExemplar.inc.php
@@ -480,6 +480,11 @@ class clsPmieducarExemplar @@ -480,6 +480,11 @@ class clsPmieducarExemplar
480 $gruda = ", "; 480 $gruda = ", ";
481 } 481 }
482 482
  483 + if(is_numeric($this->tombo))
  484 + {
  485 + $set .= "{$gruda}tombo = '{$this->tombo}'";
  486 + $gruda = ", ";
  487 + }
483 488
484 if( $set ) 489 if( $set )
485 { 490 {
@@ -673,18 +678,28 @@ class clsPmieducarExemplar @@ -673,18 +678,28 @@ class clsPmieducarExemplar
673 } 678 }
674 return false; 679 return false;
675 } 680 }
676 -  
677 - function retorna_tombo_maximo() {  
678 - $sql = "SELECT MAX(tombo) as tombo_max FROM pmieducar.exemplar WHERE ativo = 1"; 681 +
  682 + function retorna_tombo_maximo($bibliotecaId, $exceptExemplarId = null) {
  683 + if (empty($bibliotecaId))
  684 + throw new Exception("Deve ser enviado um argumento '\$bibliotecaId' ao método 'retorna_tombo_maximo'");
  685 +
  686 + // sem esta regra ao editar o ultimo exemplar sem informar o tombo, seria pego o proprio tombo.
  687 + if (! empty($exceptExemplarId))
  688 + $exceptExemplar = " and exemplar.cod_exemplar != $exceptExemplarId";
  689 + else
  690 + $exceptExemplar = '';
  691 +
  692 + $sql = "SELECT MAX(tombo) as tombo_max FROM pmieducar.exemplar, pmieducar.acervo WHERE exemplar.ativo = 1 and exemplar.ref_cod_acervo = acervo.cod_acervo and acervo.ref_cod_biblioteca = $bibliotecaId $exceptExemplar";
  693 +
679 $db = new clsBanco(); 694 $db = new clsBanco();
680 return $db->CampoUnico($sql); 695 return $db->CampoUnico($sql);
681 } 696 }
682 - 697 +
683 /** 698 /**
684 * Retorna uma lista filtrados de acordo com os parametros 699 * Retorna uma lista filtrados de acordo com os parametros
685 * 700 *
686 * @return array 701 * @return array
687 - */ 702 + */
688 function lista_com_acervos( $int_cod_exemplar = null, $int_ref_cod_fonte = null, $int_ref_cod_motivo_baixa = null, $int_ref_cod_acervo = null, $int_ref_cod_situacao = null, $int_ref_usuario_exc = null, $int_ref_usuario_cad = null, $int_permite_emprestimo = null, $int_preco = null, $date_data_cadastro_ini = null, $date_data_cadastro_fim = null, $date_data_exclusao_ini = null, $date_data_exclusao_fim = null, $int_ativo = null, $date_data_aquisicao_ini = null, $date_data_aquisicao_fim = null, $int_ref_exemplar_tipo = null, $str_titulo_livro = null,$int_ref_cod_biblioteca = null, $str_titulo = null, $int_ref_cod_instituicao = null, $int_ref_cod_escola = null, $int_ref_cod_acervo_colecao = null, $int_ref_cod_acervo_editora = null) { 703 function lista_com_acervos( $int_cod_exemplar = null, $int_ref_cod_fonte = null, $int_ref_cod_motivo_baixa = null, $int_ref_cod_acervo = null, $int_ref_cod_situacao = null, $int_ref_usuario_exc = null, $int_ref_usuario_cad = null, $int_permite_emprestimo = null, $int_preco = null, $date_data_cadastro_ini = null, $date_data_cadastro_fim = null, $date_data_exclusao_ini = null, $date_data_exclusao_fim = null, $int_ativo = null, $date_data_aquisicao_ini = null, $date_data_aquisicao_fim = null, $int_ref_exemplar_tipo = null, $str_titulo_livro = null,$int_ref_cod_biblioteca = null, $str_titulo = null, $int_ref_cod_instituicao = null, $int_ref_cod_escola = null, $int_ref_cod_acervo_colecao = null, $int_ref_cod_acervo_editora = null) {
689 $sql = "SELECT {$this->_campos_lista}, a.ref_cod_biblioteca, a.titulo FROM {$this->_tabela} e, {$this->_schema}acervo a, {$this->_schema}biblioteca b"; 704 $sql = "SELECT {$this->_campos_lista}, a.ref_cod_biblioteca, a.titulo FROM {$this->_tabela} e, {$this->_schema}acervo a, {$this->_schema}biblioteca b";
690 705
@@ -1009,4 +1024,4 @@ class clsPmieducarExemplar @@ -1009,4 +1024,4 @@ class clsPmieducarExemplar
1009 } 1024 }
1010 1025
1011 } 1026 }
1012 -?>  
1013 \ No newline at end of file 1027 \ No newline at end of file
  1028 +?>
ieducar/intranet/include/pmieducar/clsPmieducarMotivoSuspensao.inc.php
@@ -433,16 +433,15 @@ class clsPmieducarMotivoSuspensao @@ -433,16 +433,15 @@ class clsPmieducarMotivoSuspensao
433 } 433 }
434 return false; 434 return false;
435 } 435 }
436 - 436 +
437 function listaClienteBiblioteca($int_cod_cliente) 437 function listaClienteBiblioteca($int_cod_cliente)
438 { 438 {
439 if(is_numeric($int_cod_cliente)) 439 if(is_numeric($int_cod_cliente))
440 { 440 {
441 $db = new clsBanco(); 441 $db = new clsBanco();
442 $db->Consulta(" 442 $db->Consulta("
443 - SELECT  
444 - cod_motivo_suspensao  
445 - , nm_motivo 443 + SELECT
  444 + cod_motivo_suspensao, nm_motivo, descricao
446 FROM 445 FROM
447 pmieducar.motivo_suspensao 446 pmieducar.motivo_suspensao
448 WHERE 447 WHERE
@@ -605,4 +604,4 @@ class clsPmieducarMotivoSuspensao @@ -605,4 +604,4 @@ class clsPmieducarMotivoSuspensao
605 } 604 }
606 605
607 } 606 }
608 -?>  
609 \ No newline at end of file 607 \ No newline at end of file
  608 +?>
ieducar/intranet/include/pmieducar/clsPmieducarReservas.inc.php
@@ -390,7 +390,7 @@ class clsPmieducarReservas @@ -390,7 +390,7 @@ class clsPmieducarReservas
390 * 390 *
391 * @return array 391 * @return array
392 */ 392 */
393 - function lista( $int_cod_reserva = null, $int_ref_usuario_libera = null, $int_ref_usuario_cad = null, $int_ref_cod_cliente = null, $date_data_reserva_ini = null, $date_data_reserva_fim = null, $date_data_prevista_disponivel_ini = null, $date_data_prevista_disponivel_fim = null, $date_data_retirada_ini = null, $date_data_retirada_fim = null, $int_ref_cod_exemplar = null, $int_ativo = null, $int_ref_cod_biblioteca = null, $int_ref_cod_instituicao = null, $int_ref_cod_escola = null ) 393 + function lista( $int_cod_reserva = null, $int_ref_usuario_libera = null, $int_ref_usuario_cad = null, $int_ref_cod_cliente = null, $date_data_reserva_ini = null, $date_data_reserva_fim = null, $date_data_prevista_disponivel_ini = null, $date_data_prevista_disponivel_fim = null, $date_data_retirada_ini = null, $date_data_retirada_fim = null, $int_ref_cod_exemplar = null, $int_ativo = null, $int_ref_cod_biblioteca = null, $int_ref_cod_instituicao = null, $int_ref_cod_escola = null, $data_retirada_null = false )
394 { 394 {
395 $sql = "SELECT {$this->_campos_lista}, a.ref_cod_biblioteca, b.ref_cod_instituicao, b.ref_cod_escola FROM {$this->_tabela} r, {$this->_schema}exemplar e, {$this->_schema}acervo a, {$this->_schema}biblioteca b"; 395 $sql = "SELECT {$this->_campos_lista}, a.ref_cod_biblioteca, b.ref_cod_instituicao, b.ref_cod_escola FROM {$this->_tabela} r, {$this->_schema}exemplar e, {$this->_schema}acervo a, {$this->_schema}biblioteca b";
396 396
@@ -478,6 +478,11 @@ class clsPmieducarReservas @@ -478,6 +478,11 @@ class clsPmieducarReservas
478 $whereAnd = " AND "; 478 $whereAnd = " AND ";
479 } 479 }
480 480
  481 + if($data_retirada_null)
  482 + {
  483 + $filtros .= "{$whereAnd} r.data_retirada is null";
  484 + $whereAnd = " AND ";
  485 + }
481 486
482 $db = new clsBanco(); 487 $db = new clsBanco();
483 $countCampos = count( explode( ",", $this->_campos_lista ) ); 488 $countCampos = count( explode( ",", $this->_campos_lista ) );
@@ -713,4 +718,4 @@ class clsPmieducarReservas @@ -713,4 +718,4 @@ class clsPmieducarReservas
713 return false; 718 return false;
714 } 719 }
715 } 720 }
716 -?>  
717 \ No newline at end of file 721 \ No newline at end of file
  722 +?>
ieducar/modules/Biblioteca/Assets/Javascripts/Emprestimo.js 0 → 100644
@@ -0,0 +1,208 @@ @@ -0,0 +1,208 @@
  1 +var PAGE_URL_BASE = 'emprestimo';
  2 +var API_URL_BASE = 'emprestimoApi';
  3 +var RESOURCE_NAME = 'exemplar';
  4 +var RESOURCES_NAME = 'exemplares';
  5 +var POST_LABEL = 'Emprestar';
  6 +var DELETE_LABEL = 'Devolver';
  7 +var SEARCH_ORIENTATION = '';
  8 +
  9 +var onClickSelectAllEvent = false;
  10 +var onClickDeleteEvent = false;
  11 +
  12 +var onClickActionEvent = function(event){
  13 + var $this = $j(this)
  14 + var $firstChecked = getFirstCheckboxChecked($this);
  15 +
  16 + if ($firstChecked){
  17 + $j('.disable-on-apply-changes').attr('disabled', 'disabled');
  18 + $this.val('Aguarde emprestando exemplar...');
  19 + postEmprestimo($firstChecked);
  20 + }
  21 +};
  22 +
  23 +var postDevolucao = function ($resourceCheckbox) {
  24 + var options = {
  25 + url : postResourceUrlBuilder.buildUrl(API_URL_BASE, 'devolucao'),
  26 + dataType : 'json',
  27 + data : {
  28 + instituicao_id : $j('#instituicao_id').val(),
  29 + escola_id : $j('#escola_id').val(),
  30 + biblioteca_id : $j('#biblioteca_id').val(),
  31 + cliente_id : $j('#cliente_id').val(),
  32 + exemplar_id : $resourceCheckbox.data('exemplar_id'),
  33 + tombo_exemplar : $j('#tombo_exemplar').val()
  34 + },
  35 +
  36 + success : function(dataResponse){
  37 + afterChangeResource($resourceCheckbox);
  38 + handlePost(dataResponse);
  39 + }
  40 + };
  41 +
  42 + beforeChangeResource($resourceCheckbox);
  43 + postResource(options);
  44 +};
  45 +
  46 +var postEmprestimo = function ($resourceCheckbox) {
  47 + var options = {
  48 + url : postResourceUrlBuilder.buildUrl(API_URL_BASE, 'emprestimo'),
  49 + dataType : 'json',
  50 + data : {
  51 + instituicao_id : $j('#instituicao_id').val(),
  52 + escola_id : $j('#escola_id').val(),
  53 + biblioteca_id : $j('#biblioteca_id').val(),
  54 + cliente_id : $j('#cliente_id').val(),
  55 + exemplar_id : $resourceCheckbox.data('exemplar_id'),
  56 + tombo_exemplar : $j('#tombo_exemplar').val()
  57 + },
  58 +
  59 + success : function(dataResponse){
  60 + afterChangeResource($resourceCheckbox);
  61 + handlePost(dataResponse);
  62 + }
  63 + };
  64 +
  65 + beforeChangeResource($resourceCheckbox);
  66 + postResource(options);
  67 +};
  68 +
  69 +var handlePost = function(dataResponse){
  70 + if (dataResponse.exemplar)
  71 + var $targetElement = $j('#exemplar-' + dataResponse.exemplar.id).closest('tr').first();
  72 + else
  73 + var $targetElement = undefined;
  74 +
  75 + handleMessages(dataResponse.msgs, $targetElement);
  76 + updateResourceRow(dataResponse.exemplar);
  77 +};
  78 +
  79 +
  80 +function setTableSearchDetails($tableSearchDetails, dataDetails){
  81 + $j('<caption />').html('<strong>Emprestimo exemplares</strong>').appendTo($tableSearchDetails);
  82 +
  83 + //set headers table
  84 + var $linha = $j('<tr />');
  85 + $j('<th />').html('Cliente').appendTo($linha);
  86 + $j('<th />').html('Obra').appendTo($linha);
  87 + $j('<th />').html('Tombo exemplar').appendTo($linha);
  88 + $j('<th />').html('Biblioteca').appendTo($linha);
  89 +
  90 + $linha.appendTo($tableSearchDetails);
  91 +
  92 + var $linha = $j('<tr />').addClass('even');
  93 +
  94 + $j('<td />').html($j('#nome_cliente').val()).appendTo($linha);
  95 + $j('<td />').html('').attr('id', 'titulo_obra').appendTo($linha);
  96 + $j('<td />').html($j('#tombo_exemplar').val()).appendTo($linha);
  97 +
  98 + var $htmlBibliotecaField = $j('#biblioteca_id').children("[selected='selected']").html() ||
  99 + $j('#tr_biblioteca_nome span:last').html();
  100 +
  101 + $j('<td />').html(safeToUpperCase($htmlBibliotecaField)).appendTo($linha);
  102 +
  103 + $linha.appendTo($tableSearchDetails);
  104 + $tableSearchDetails.show();
  105 +
  106 + $tableSearchDetails.data('details', dataDetails);
  107 +}
  108 +
  109 +
  110 +function handleSearch($resultTable, dataResponse) {
  111 + var $linha = $j('<tr />');
  112 + $j('<th />').html('Selecionar').addClass('center').appendTo($linha);
  113 + $j('<th />').html('Id').addClass('center').appendTo($linha);
  114 + $j('<th />').html('Situa&#231;&#227;o').addClass('center').appendTo($linha);
  115 + $j('<th />').html('Cliente').appendTo($linha);
  116 + $j('<th />').html('Data emprestimo').addClass('center').appendTo($linha);
  117 + $j('<th />').html('Data prevista devolu&#231;&#227;o').addClass('center').appendTo($linha);
  118 + //$j('<th />').html('A&#231;&#227;o').addClass('center').appendTo($linha);
  119 + $linha.appendTo($resultTable);
  120 +
  121 + var setTituloObra = true;
  122 +
  123 + //set rows
  124 + $j.each(dataResponse[RESOURCES_NAME], function(index, value){
  125 +
  126 + if(setTituloObra)
  127 + $j('#titulo_obra').html(value.acervo.titulo);
  128 +
  129 + var $checkbox = $j('<input />')
  130 + .attr('type', 'checkbox')
  131 + .attr('name', 'exemplar')
  132 + .attr('value', 'sim')
  133 + .attr('id', 'exemplar-' + value.id)
  134 + .attr('class', 'exemplar disable-on-apply-changes')
  135 + .data('exemplar_id', value.id);
  136 +
  137 + var situacoesEmprestimoPermitida = ['disponivel', 'emprestado', 'reservado', 'emprestado_e_reservado'];
  138 +
  139 + if ($j.inArray(value.situacao.flag, situacoesEmprestimoPermitida) < 0)
  140 + $checkbox.attr('disabled', 'disabled').removeClass('disable-on-apply-changes');
  141 +
  142 + var $linha = $j('<tr />');
  143 + $j('<td />').html($checkbox).addClass('center').appendTo($linha);
  144 + $j('<td />').html(value.id).addClass('center').appendTo($linha);
  145 +
  146 + var $colSituacoes = $j('<td />').attr('id', 'situacoes-' + value.id).addClass('situacoes center');
  147 + var $colClientes = $j('<td />').attr('id', 'clientes-' + value.id);
  148 + var $colDatas = $j('<td />').attr('id', 'datas-' + value.id).addClass('center');
  149 + var $colDatasPrevistaDisponivel = $j('<td />').attr('id', 'datas-prevista-disponivel-' + value.id).addClass('center');
  150 + //var $colAcoes = $j('<td />').attr('id', 'acoes-' + value.id).addClass('center');
  151 +
  152 + $colSituacoes.appendTo($linha);
  153 + $colClientes.appendTo($linha);
  154 + $colDatas.appendTo($linha);
  155 + $colDatasPrevistaDisponivel.appendTo($linha);
  156 + //$colAcoes.appendTo($linha);
  157 +
  158 + $linha.appendTo($resultTable);
  159 + updateResourceRow(value);
  160 + });// each
  161 +
  162 + $resultTable.find('tr:even').addClass('even');
  163 + $resultTable.addClass('styled').find('checkbox:first').focus();
  164 +
  165 + var $checkboxes = $resultTable.find("input[type='checkbox']");
  166 + $checkboxes.change(function(){
  167 + $checkboxes.not(this).removeAttr('checked');
  168 + });
  169 +}
  170 +
  171 +
  172 +function updateResourceRow(exemplar){
  173 + var $colSituacoes = $j('#situacoes-' + exemplar.id).html('');
  174 + var $colClientes = $j('#clientes-' + exemplar.id).html('');
  175 + var $colDatas = $j('#datas-' + exemplar.id).html('');
  176 + var $colDatasPrevistaDisponivel = $j('#datas-prevista-disponivel-' + exemplar.id).html('');
  177 + var $colAcoes = $j('#acoes-' + exemplar.id).html('');
  178 +
  179 + if ($j.isArray(exemplar.pendencias)) {
  180 + $j.each(exemplar.pendencias, function(index, value){
  181 + $j('<p />').html(value.situacao.label || '-').appendTo($colSituacoes);
  182 + $j('<p />').html(value.nome_cliente || '-').appendTo($colClientes);
  183 + $j('<p />').html(value.data || '-').appendTo($colDatas);
  184 + $j('<p />').html(value.data_prevista_disponivel || '-').appendTo($colDatasPrevistaDisponivel);
  185 +
  186 + if (value.situacao.flag == 'emprestimodo' && value.cliente && value.cliente.id == $j('#cliente_id').val()) {
  187 + var $linkToDelete = $j("<a href='#' class='disable-on-apply-changes'>Cancelar emprestimo</a>").click(onClickCancelEvent).data('exemplar_id', exemplar.id).data('emprestimo_id', value.emprestimo_id);
  188 + $j('<p />').html($linkToDelete).appendTo($colAcoes);
  189 + }
  190 + else
  191 + $j('<p />').html('-').appendTo($colAcoes);
  192 + });
  193 +
  194 + if (exemplar.pendencias.length < 1)
  195 + $j('<p />').html(exemplar.situacao.label || '-').appendTo($colSituacoes);
  196 + }
  197 +
  198 + $colSituacoes.data('situacao', exemplar.situacao_exemplar);
  199 +}
  200 +
  201 +function canSearch() {
  202 + if ($j('#nome_cliente').val() == '') {
  203 + alert('Selecione um cliente para continuar.');
  204 + return false;
  205 + }
  206 +
  207 + return true;
  208 +}
0 \ No newline at end of file 209 \ No newline at end of file
ieducar/modules/Biblioteca/Assets/Javascripts/Reserva.js 0 → 100644
@@ -0,0 +1,221 @@ @@ -0,0 +1,221 @@
  1 +var PAGE_URL_BASE = 'reserva';
  2 +var API_URL_BASE = 'reservaApi';
  3 +var RESOURCE_NAME = 'exemplar';
  4 +var RESOURCES_NAME = 'exemplares';
  5 +var POST_LABEL = 'Reservar';
  6 +var DELETE_LABEL = 'Cancelar';
  7 +var SEARCH_ORIENTATION = '';
  8 +
  9 +var onClickSelectAllEvent = false;
  10 +var onClickDeleteEvent = false;
  11 +
  12 +var onClickActionEvent = function(event){
  13 + var $this = $j(this);
  14 + var $firstChecked = $j('input.exemplar:checked:first');
  15 +
  16 + if ($firstChecked.length < 1)
  17 + handleMessages([{type : 'error', msg : 'Selecione algum exemplar.'}], $this, true);
  18 + else{
  19 + $j('.disable-on-apply-changes').attr('disabled', 'disabled');
  20 + $this.val('Aguarde reservando...');
  21 + postReserva($firstChecked);
  22 + }
  23 +};
  24 +
  25 +var postReserva = function ($resourceCheckbox) {
  26 + var options = {
  27 + url : postResourceUrlBuilder.buildUrl(API_URL_BASE, 'reserva'),
  28 + dataType : 'json',
  29 + data : {
  30 + ref_cod_instituicao : $j('#ref_cod_instituicao').val(),
  31 + ref_cod_escola : $j('#ref_cod_escola').val(),
  32 + ref_cod_biblioteca : $j('#ref_cod_biblioteca').val(),
  33 + ref_cod_cliente : $j('#ref_cod_cliente').val(),
  34 + ref_cod_acervo : $j('#ref_cod_acervo').val(),
  35 + exemplar_id : $resourceCheckbox.data('exemplar_id')
  36 + },
  37 +
  38 + success : function(dataResponse){
  39 + afterChangeResource($resourceCheckbox);
  40 + handlePost(dataResponse);
  41 + }
  42 + };
  43 +
  44 + beforeChangeResource($resourceCheckbox);
  45 + postResource(options);
  46 +};
  47 +
  48 +var handlePost = function(dataResponse){
  49 + var $targetElement = $j('#exemplar-'+dataResponse.id).closest('tr').first();
  50 + handleMessages(dataResponse.msgs, $targetElement);
  51 + updateResourceRow(dataResponse);
  52 +};
  53 +
  54 +var onClickCancelEvent = function(event) {
  55 + if (confirm("Confirma cancelamento da reserva?")) {
  56 + var $this = $j(this);
  57 +
  58 + //var $checkbox = $this.closest('tr').find("input[type='checkbox']").first();
  59 + deleteReserva($this);
  60 + }
  61 +}
  62 +
  63 +var deleteReserva = function($deleteLink) {
  64 + var options = {
  65 + url : deleteResourceUrlBuilder.buildUrl(API_URL_BASE, 'reserva', {
  66 + ref_cod_instituicao : $j('#ref_cod_instituicao').val(),
  67 + ref_cod_escola : $j('#ref_cod_escola').val(),
  68 + ref_cod_biblioteca : $j('#ref_cod_biblioteca').val(),
  69 + ref_cod_cliente : $j('#ref_cod_cliente').val(),
  70 + ref_cod_acervo : $j('#ref_cod_acervo').val(),
  71 + exemplar_id : $deleteLink.data('exemplar_id'),
  72 + reserva_id : $deleteLink.data('reserva_id')
  73 + }),
  74 + dataType : 'json',
  75 + data : {
  76 + },
  77 + success : function(dataResponse){
  78 + afterChangeResource($deleteLink);
  79 + handleDeleteReserva(dataResponse);
  80 + }
  81 + };
  82 +
  83 + beforeChangeResource($deleteLink);
  84 + deleteResource(options);
  85 +}
  86 +
  87 +var handleDeleteReserva = function(dataResponse) {
  88 + safeLog(dataResponse);
  89 +
  90 + //try{
  91 + var $targetElement = $j('#exemplar-' + dataResponse.id).closest('tr').first();
  92 + handleMessages(dataResponse.msgs, $targetElement);
  93 + updateResourceRow(dataResponse);
  94 + //}
  95 + //catch(error){
  96 + //showNewSearchButton();
  97 + //handleMessages([{type : 'error', msg : 'Ocorreu um erro ao remover o recurso, por favor tente novamente, detalhes: ' + error}], '');
  98 +
  99 + //safeLog(dataResponse);
  100 + //}
  101 +}
  102 +
  103 +function setTableSearchDetails($tableSearchDetails, dataDetails){
  104 + $j('<caption />').html('<strong>Reserva exemplares</strong>').appendTo($tableSearchDetails);
  105 +
  106 + //set headers table
  107 + var $linha = $j('<tr />');
  108 + $j('<th />').html('Cliente').appendTo($linha);
  109 + $j('<th />').html('Obra').appendTo($linha);
  110 + $j('<th />').html('Biblioteca').appendTo($linha);
  111 + $j('<th />').html('Escola').appendTo($linha);
  112 +
  113 + $linha.appendTo($tableSearchDetails);
  114 +
  115 + var $linha = $j('<tr />').addClass('even');
  116 +
  117 + $j('<td />').html($j('#nome_cliente').val()).appendTo($linha);
  118 + $j('<td />').html($j('#titulo_obra').val()).appendTo($linha);
  119 +
  120 + //field biblioteca pode ser diferente de select caso usuario comum
  121 + var $htmlBibliotecaField = $j('#ref_cod_biblioteca').children("[selected='selected']").html() ||
  122 + $j('#tr_nm_biblioteca span:last').html();
  123 + $j('<td />').html(safeToUpperCase($htmlBibliotecaField)).appendTo($linha);
  124 +
  125 + //field escola pode ser diferente de select caso usuario comum
  126 + var $htmlEscolaField = $j('#ref_cod_escola').children("[selected='selected']").html() ||
  127 + $j('#tr_nm_escola span:last').html();
  128 + $j('<td />').html(safeToUpperCase($htmlEscolaField)).appendTo($linha);
  129 +
  130 + $linha.appendTo($tableSearchDetails);
  131 + $tableSearchDetails.show();
  132 +
  133 + $tableSearchDetails.data('details', dataDetails);
  134 +}
  135 +
  136 +
  137 +function handleSearch($resultTable, dataResponse) {
  138 + var $linha = $j('<tr />');
  139 + $j('<th />').html('Selecionar').addClass('center').appendTo($linha);
  140 + $j('<th />').html('Id').addClass('center').appendTo($linha);
  141 + $j('<th />').html('Situa&#231;&#227;o').addClass('center').appendTo($linha);
  142 + $j('<th />').html('Cliente').appendTo($linha);
  143 + $j('<th />').html('Data').addClass('center').appendTo($linha);
  144 + $j('<th />').html('Data prevista dispon&iacute;vel').addClass('center').appendTo($linha);
  145 + $j('<th />').html('A&#231;&#227;o').addClass('center').appendTo($linha);
  146 + $linha.appendTo($resultTable);
  147 +
  148 + //set rows
  149 + $j.each(dataResponse[RESOURCES_NAME], function(index, value){
  150 +
  151 + var $checkbox = $j('<input />')
  152 + .attr('type', 'checkbox')
  153 + .attr('name', 'reservar-exempar')
  154 + .attr('value', 'sim')
  155 + .attr('id', 'exemplar-' + value.id)
  156 + .attr('class', 'exemplar disable-on-apply-changes')
  157 + .data('exemplar_id', value.id);
  158 +
  159 + var situacoesReservaPermitida = ['disponivel', 'emprestado', 'reservado', 'emprestado_e_reservado'];
  160 +
  161 + if ($j.inArray(value.situacao.flag, situacoesReservaPermitida) < 0)
  162 + $checkbox.attr('disabled', 'disabled').removeClass('disable-on-apply-changes');
  163 +
  164 + var $linha = $j('<tr />');
  165 + $j('<td />').html($checkbox).addClass('center').appendTo($linha);
  166 + $j('<td />').html(value.id).addClass('center').appendTo($linha);
  167 +
  168 + var $colSituacoes = $j('<td />').attr('id', 'situacoes-' + value.id).addClass('situacoes center');
  169 + var $colClientes = $j('<td />').attr('id', 'clientes-' + value.id);
  170 + var $colDatas = $j('<td />').attr('id', 'datas-' + value.id).addClass('center');
  171 + var $colDatasPrevistaDisponivel = $j('<td />').attr('id', 'datas-prevista-disponivel-' + value.id).addClass('center');
  172 + var $colAcoes = $j('<td />').attr('id', 'acoes-' + value.id).addClass('center');
  173 +
  174 + $colSituacoes.appendTo($linha);
  175 + $colClientes.appendTo($linha);
  176 + $colDatas.appendTo($linha);
  177 + $colDatasPrevistaDisponivel.appendTo($linha);
  178 + $colAcoes.appendTo($linha);
  179 +
  180 + $linha.appendTo($resultTable);
  181 + updateResourceRow(value);
  182 + });// each
  183 +
  184 + $resultTable.find('tr:even').addClass('even');
  185 + $resultTable.addClass('styled').find('checkbox:first').focus();
  186 +
  187 + var $checkboxes = $resultTable.find("input[type='checkbox']");
  188 + $checkboxes.change(function(){
  189 + $checkboxes.not(this).removeAttr('checked');
  190 + });
  191 +}
  192 +
  193 +
  194 +function updateResourceRow(exemplar){
  195 + var $colSituacoes = $j('#situacoes-' + exemplar.id).html('');
  196 + var $colClientes = $j('#clientes-' + exemplar.id).html('');
  197 + var $colDatas = $j('#datas-' + exemplar.id).html('');
  198 + var $colDatasPrevistaDisponivel = $j('#datas-prevista-disponivel-' + exemplar.id).html('');
  199 + var $colAcoes = $j('#acoes-' + exemplar.id).html('');
  200 +
  201 + if ($j.isArray(exemplar.pendencias)) {
  202 + $j.each(exemplar.pendencias, function(index, value){
  203 + $j('<p />').html(value.situacao.label || '-').appendTo($colSituacoes);
  204 + $j('<p />').html(value.nome_cliente || '-').appendTo($colClientes);
  205 + $j('<p />').html(value.data || '-').appendTo($colDatas);
  206 + $j('<p />').html(value.data_prevista_disponivel || '-').appendTo($colDatasPrevistaDisponivel);
  207 +
  208 + if (value.situacao.flag == 'reservado' && value.cliente && value.cliente.id == $j('#ref_cod_cliente').val()) {
  209 + var $linkToDelete = $j("<a href='#' class='disable-on-apply-changes'>Cancelar reserva</a>").click(onClickCancelEvent).data('exemplar_id', exemplar.id).data('reserva_id', value.reserva_id);
  210 + $j('<p />').html($linkToDelete).appendTo($colAcoes);
  211 + }
  212 + else
  213 + $j('<p />').html('-').appendTo($colAcoes);
  214 + });
  215 +
  216 + if (exemplar.pendencias.length < 1)
  217 + $j('<p />').html(exemplar.situacao.label || '-').appendTo($colSituacoes);
  218 + }
  219 +
  220 + $colSituacoes.data('situacao', exemplar.situacao_exemplar);
  221 +}
ieducar/modules/Biblioteca/Model/TipoExemplar.php 0 → 100644
@@ -0,0 +1,96 @@ @@ -0,0 +1,96 @@
  1 +<?php
  2 +
  3 +#error_reporting(E_ALL);
  4 +#ini_set("display_errors", 1);
  5 +
  6 +/**
  7 + * i-Educar - Sistema de gestão escolar
  8 + *
  9 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  10 + * <ctima@itajai.sc.gov.br>
  11 + *
  12 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  13 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  14 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  15 + * qualquer versão posterior.
  16 + *
  17 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  18 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  19 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  20 + * do GNU para mais detalhes.
  21 + *
  22 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  23 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  24 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  25 + *
  26 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  27 + * @category i-Educar
  28 + * @license @@license@@
  29 + * @package ComponenteCurricular
  30 + * @subpackage Modules
  31 + * @since Arquivo disponível desde a versão 1.1.0
  32 + * @version $Id$
  33 + */
  34 +
  35 +require_once 'CoreExt/Entity.php';
  36 +require_once 'App/Model/IedFinder.php';
  37 +require_once 'CoreExt/Validate/Email.php';
  38 +
  39 +/**
  40 + * ComponenteCurricular_Model_Componente class.
  41 + *
  42 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  43 + * @category i-Educar
  44 + * @license @@license@@
  45 + * @package ComponenteCurricular
  46 + * @subpackage Modules
  47 + * @since Classe disponível desde a versão 1.1.0
  48 + * @version @@package_version@@
  49 + */
  50 +class Biblioteca_Model_TipoExemplar extends CoreExt_Entity
  51 +{
  52 + protected $_data = array(
  53 + 'cod_exemplar_tipo' => NULL,
  54 + 'ref_cod_biblioteca' => NULL,
  55 + 'ref_usuario_exc' => NULL,
  56 + 'ref_usuario_cad' => NULL,
  57 + 'nm_tipo' => NULL,
  58 + 'descricao' => NULL,
  59 + 'data_cadastro' => NULL,
  60 + 'data_exclusao' => NULL,
  61 + 'ativo' => NULL
  62 + );
  63 +
  64 +
  65 + protected $_dataTypes = array(
  66 + 'nm_tipo' => 'string'
  67 + );
  68 +
  69 +
  70 + protected $_references = array(
  71 + );
  72 +
  73 +
  74 + public function getDataMapper()
  75 + {
  76 + if (is_null($this->_dataMapper)) {
  77 + require_once 'Biblioteca/Model/TipoExemplarDataMapper.php';
  78 + $this->setDataMapper(new Biblioteca_Model_TipoExemplarDataMapper());
  79 + }
  80 + return parent::getDataMapper();
  81 + }
  82 +
  83 +
  84 + public function getDefaultValidatorCollection()
  85 + {
  86 + return array();
  87 + }
  88 +
  89 +
  90 + protected function _createIdentityField()
  91 + {
  92 + $id = array('cod_exemplar_tipo' => NULL);
  93 + $this->_data = array_merge($id, $this->_data);
  94 + return $this;
  95 + }
  96 +}
ieducar/modules/Biblioteca/Model/TipoExemplarDataMapper.php 0 → 100644
@@ -0,0 +1,79 @@ @@ -0,0 +1,79 @@
  1 +<?php
  2 +
  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 Lucas D'Avila <lucasdavila@portabilis.com.br>
  24 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package Usuario
  27 + * @subpackage Modules
  28 + * @since Arquivo disponível desde a versão 1.1.0
  29 + * @version $Id$
  30 + */
  31 +
  32 +require_once 'CoreExt/DataMapper.php';
  33 +require_once 'Biblioteca/Model/TipoExemplar.php';
  34 +
  35 +/**
  36 + * Usuario_Model_TipoExemplarDataMapper class.
  37 + *
  38 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  39 + * @category i-Educar
  40 + * @license @@license@@
  41 + * @package Usuario
  42 + * @subpackage Modules
  43 + * @since Classe disponível desde a versão 1.1.0
  44 + * @version @@package_version@@
  45 + */
  46 +class Biblioteca_Model_TipoExemplarDataMapper extends CoreExt_DataMapper
  47 +{
  48 + protected $_entityClass = 'Biblioteca_Model_TipoExemplar';
  49 + protected $_tableName = 'exemplar_tipo';
  50 + protected $_tableSchema = 'pmieducar';
  51 +
  52 +
  53 + protected $_attributeMap = array(
  54 + 'cod_exemplar_tipo' => 'cod_exemplar_tipo',
  55 + 'ref_cod_biblioteca' => 'ref_cod_biblioteca',
  56 + 'ref_usuario_exc' => 'ref_usuario_exc',
  57 + 'ref_usuario_cad' => 'ref_usuario_cad',
  58 + 'nm_tipo' => 'nm_tipo',
  59 + 'descricao' => 'descricao',
  60 + 'data_cadastro' => 'data_cadastro',
  61 + 'data_exclusao' => 'data_exclusao',
  62 + 'ativo' => 'ativo'
  63 + );
  64 +
  65 +
  66 + protected $_notPersistable = array();
  67 +
  68 +
  69 + protected $_primaryKey = array('cod_exemplar_tipo');
  70 +
  71 +
  72 + protected function _getFindStatment($pkey)
  73 + {
  74 + if (!is_array($pkey))
  75 + $pkey = array("cod_exemplar_tipo" => $pkey);
  76 +
  77 + return parent::_getFindStatment($pkey);
  78 + }
  79 +}
ieducar/modules/Biblioteca/Views/EmprestimoApiController.php 0 → 100644
@@ -0,0 +1,640 @@ @@ -0,0 +1,640 @@
  1 +<?php
  2 +
  3 +#error_reporting(E_ALL);
  4 +#ini_set("display_errors", 1);
  5 +
  6 +/**
  7 + * i-Educar - Sistema de gestão escolar
  8 + *
  9 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  10 + * <ctima@itajai.sc.gov.br>
  11 + *
  12 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  13 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  14 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  15 + * qualquer versão posterior.
  16 + *
  17 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  18 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  19 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  20 + * do GNU para mais detalhes.
  21 + *
  22 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  23 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  24 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  25 + *
  26 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  27 + * @category i-Educar
  28 + * @license @@license@@
  29 + * @package Biblioteca
  30 + * @subpackage Modules
  31 + * @since Arquivo disponível desde a versão ?
  32 + * @version $Id$
  33 + */
  34 +
  35 +require_once 'lib/Portabilis/Controller/ApiCoreController.php';
  36 +require_once 'include/pmieducar/clsPmieducarExemplar.inc.php';
  37 +require_once 'lib/Portabilis/Array/Utils.php';
  38 +
  39 +class EmprestimoApiController extends ApiCoreController
  40 +{
  41 + protected $_nivelAcessoOption = App_Model_NivelAcesso::SOMENTE_BIBLIOTECA;
  42 +
  43 + // validadores regras negócio
  44 +
  45 + protected function validatesExistenceOfExemplar() {
  46 + $valid = true;
  47 +
  48 + $exemplares = $this->loadExemplar($reload = true);
  49 +
  50 + if (! is_array($exemplares) || count($exemplares) < 1) {
  51 + $id = $this->getRequest()->exemplar_id;
  52 + $tombo = $this->getRequest()->tombo_exemplar;
  53 +
  54 + $this->messenger->append("Aparentemente não existe um exemplar com id $id e/ou tombo $tombo, para a biblioteca informada.");
  55 + $valid = false;
  56 + }
  57 +
  58 + return $valid;
  59 + }
  60 +
  61 +
  62 + protected function validatesExistenceOfCliente() {
  63 + $valid = true;
  64 +
  65 + if (! $this->loadCliente()) {
  66 + $this->messenger->append("Não existe um cliente com id '{$this->getRequest()->cliente_id}'.");
  67 + $valid = false;
  68 + }
  69 +
  70 + return $valid;
  71 + }
  72 +
  73 +
  74 + protected function validatesClienteIsNotSuspenso() {
  75 + $cliente = $this->loadCliente();
  76 +
  77 + if($cliente['suspenso']) {
  78 + $this->messenger->append("Operação não pode ser realizada, pois o cliente esta suspenso.", 'error');
  79 + return false;
  80 + }
  81 +
  82 + return true;
  83 + }
  84 +
  85 +
  86 + protected function validatesSituacaoExemplarIsIn($expectedSituacoes) {
  87 + if (! is_array($expectedSituacoes))
  88 + $expectedSituacoes = array($expectedSituacoes);
  89 +
  90 + $situacao = $this->getSituacaoExemplar();
  91 + $situacao = $situacao['flag'];
  92 + $msg = "Operação não realizada, pois a situação atual do exemplar é $situacao quando deveria ser " . implode(' ou ', $expectedSituacoes) . ".";
  93 +
  94 + return $this->validator->validatesValueInSetOf($situacao, $expectedSituacoes, 'situação', false, $msg);
  95 + }
  96 +
  97 +
  98 + protected function canAcceptRequest() {
  99 + return parent::canAcceptRequest()
  100 +
  101 + && $this->validatesPresenceOf(array('instituicao_id',
  102 + 'escola_id',
  103 + 'biblioteca_id',
  104 + 'cliente_id',
  105 + 'tombo_exemplar'))
  106 +
  107 + && $this->validatesIsNumeric('tombo_exemplar')
  108 + && $this->validatesExistenceOfExemplar()
  109 + && $this->validatesExistenceOfCliente();
  110 + }
  111 +
  112 +
  113 + protected function canPostEmprestimo() {
  114 + return $this->validatesPresenceOf(array('exemplar_id'))
  115 + && $this->validatesExistenceOfExemplar()
  116 + && $this->validatesClienteIsNotSuspenso()
  117 + && $this->validatesSituacaoExemplarIsIn('disponivel');
  118 +
  119 + /*
  120 + #TODO validar:
  121 + qtd emprestimos em aberto do cliente <= limite biblioteca
  122 + valor R$ multas em aberto do cliente <= limite biblioteca
  123 +
  124 + não existe outro exemplar mesma obra emprestado para cliente
  125 + validates situacao exemplar is disponivel or is reservado cliente
  126 + */
  127 + }
  128 +
  129 +
  130 + protected function canPostDevolucao() {
  131 + return $this->validatesPresenceOf(array('exemplar_id'))
  132 + && $this->validatesExistenceOfExemplar()
  133 + && $this->validatesSituacaoExemplarIsIn(array('emprestado', 'emprestado_e_reservado'));
  134 + }
  135 +
  136 +
  137 + /* metódos auxiliares resposta operação / recurso
  138 + metódos iniciados com load consultam informação no banco de dados
  139 + metódos iniciados com get consultam informação em objetos
  140 + */
  141 +
  142 + protected function loadCliente($id = null) {
  143 + if (! $id)
  144 + $id = $this->getRequest()->cliente_id;
  145 +
  146 + // load cliente
  147 + $cliente = new clsPmieducarCliente($id);
  148 + $cliente = $cliente->detalhe();
  149 +
  150 + if ($cliente) {
  151 + $cliente = Portabilis_Array_Utils::filter($cliente, array('cod_cliente' => 'id',
  152 + 'ref_idpes' => 'pessoa_id'));
  153 +
  154 + // load pessoa
  155 + $pessoa = new clsPessoa_($cliente['pessoa_id']);
  156 + $pessoa = $pessoa->detalhe();
  157 + $cliente['nome'] = $this->toUtf8($pessoa["nome"]);
  158 +
  159 + // load suspensao
  160 + $sql = "select 1 from pmieducar.cliente_suspensao where ref_cod_cliente = $1 and data_liberacao is null and data_suspensao + (dias||' day')::interval >= now()";
  161 + $suspenso = $this->fetchPreparedQuery($sql, $params = array($id), true, 'first-field');
  162 +
  163 + $cliente['suspenso'] = $suspenso == '1';
  164 + }
  165 +
  166 + return $cliente;
  167 + }
  168 +
  169 +
  170 + protected function loadQtdDiasEmprestimoForExemplar($exemplar = null) {
  171 + $acervo = $this->loadAcervo($exemplar['acervo']['id']);
  172 + $exemplarTipoId = $acervo['exemplar_tipo_id'];
  173 +
  174 + // obtem id tipo de cliente
  175 + $clienteTipoCliente = new clsPmieducarClienteTipoCliente();
  176 + $clienteTipoCliente = $clienteTipoCliente->lista(null,
  177 + $this->getRequest()->cliente_id,
  178 + null,
  179 + null,
  180 + null,
  181 + null,
  182 + null,
  183 + null,
  184 + $this->getRequest()->biblioteca_id);
  185 +
  186 + $clienteTipoId = $clienteTipoCliente[0]['ref_cod_cliente_tipo'];
  187 +
  188 + // obtem quantidade dias emprestimo
  189 + $clienteTipoExemplarTipo = new clsPmieducarClienteTipoExemplarTipo($clienteTipoId, $exemplarTipoId);
  190 + $clienteTipoExemplarTipo = $clienteTipoExemplarTipo->detalhe();
  191 +
  192 + if (! $clienteTipoExemplarTipo || ! is_numeric($clienteTipoExemplarTipo["dias_emprestimo"]))
  193 + throw new CoreExt_Exception("Aparentemente não foi definido a quantidade de dias de emprestimo para o tipo de cliente '$clienteTipoId' e tipo de exemplar '$exemplarTipoId'.");
  194 +
  195 + return $clienteTipoExemplarTipo["dias_emprestimo"];
  196 + }
  197 +
  198 +
  199 + protected function getDataPrevistaDisponivelForExemplar($exemplar, $dataInicio, $format = 'd/m/Y') {
  200 + $qtdDiasEmprestimo = $this->loadQtdDiasEmprestimoForExemplar($exemplar);
  201 +
  202 + // reformada data dd/mm/aaaa => mm/dd/aaaa
  203 + $_format = explode('/', $format);
  204 +
  205 + if (count($_format) > 0 && $_format[0] == 'd') {
  206 + list($diaInicio, $mesInicio, $anoInicio) = explode("/", $dataInicio);
  207 + $dataInicio = "$mesInicio/$diaInicio/$anoInicio";
  208 + }
  209 +
  210 +
  211 + // #TODO se data cair em feriado ou dia de não trabalho somar +1 dia ?
  212 + // soma dias emprestimo
  213 + $date = date($format, strtotime("+$qtdDiasEmprestimo days", strtotime($dataInicio)));
  214 +
  215 + return $date;
  216 + }
  217 +
  218 +
  219 + protected function loadReservasForExemplar($exemplar, $clienteId = null, $reload = false) {
  220 + if ($reload || ! isset($this->_reservas)) {
  221 + $reservas = new clsPmieducarReservas();
  222 + $reservas = $reservas->lista(null,
  223 + null,
  224 + null,
  225 + $clienteId,
  226 + null,
  227 + null,
  228 + null,
  229 + null,
  230 + null,
  231 + null,
  232 + $exemplar['cod_exemplar'],
  233 + 1,
  234 + $this->getRequest()->biblioteca_id,
  235 + $this->getRequest()->instituicao_id,
  236 + $this->getRequest()->escola_id,
  237 + $data_retirada_null = true);
  238 +
  239 + if($reservas) {
  240 + $reservas = Portabilis_Array_Utils::filterSet($reservas, array('cod_reserva' => 'id',
  241 + 'data_reserva' => 'data',
  242 + 'ref_cod_cliente' => 'cliente_id',
  243 + 'data_prevista_disponivel'));
  244 +
  245 + // adicionada informaçoes adicionais a cada reserva
  246 + foreach($reservas as $index => $reserva) {
  247 + $cliente = $this->loadCliente($reserva["cliente_id"]);
  248 +
  249 + $reserva['cliente'] = $cliente;
  250 + $reserva['nome_cliente'] = $cliente['id'] . ' - ' . $cliente['nome'];
  251 + $reserva['data'] = date('d/m/Y', strtotime($reserva['data']));
  252 + $reserva['situacao'] = $this->getSituacaoForFlag('reservado');
  253 +
  254 + /* para o cliente da reserva: considera a data prevista disponivel gravada na reserva.
  255 + para outros considera a data prevista disponivel da reserva + a quantidade de dias de emprestimo do exemplar
  256 + */
  257 + if ($this->getRequest()->cliente_id == $cliente['id'])
  258 + $reserva['data_prevista_disponivel'] = date('d/m/Y', strtotime($reserva['data_prevista_disponivel']));
  259 +
  260 + else
  261 + $reserva['data_prevista_disponivel'] = $this->getDataPrevistaDisponivelForExemplar($exemplar, $reserva['data_prevista_disponivel'], 'd/m/Y');
  262 + } //fim for each
  263 + }
  264 +
  265 + $this->_reservas = $reservas;
  266 + }
  267 +
  268 + return $this->_reservas;
  269 + }
  270 +
  271 +
  272 + protected function loadEmprestimoForExemplar($exemplar = null) {
  273 + if(is_null($exemplar))
  274 + $exemplar = $this->loadExemplar();
  275 +
  276 + $emprestimo = new clsPmieducarExemplarEmprestimo();
  277 +
  278 + $emprestimo = $emprestimo->lista(null,
  279 + null,
  280 + null,
  281 + null,
  282 + $exemplar['id'],
  283 + null,
  284 + null,
  285 + null,
  286 + null,
  287 + null,
  288 + $devolvido = false,
  289 + $this->getRequest()->biblioteca_id,
  290 + null,
  291 + $this->getRequest()->instituicao_id,
  292 + $this->getRequest()->escola_id);
  293 +
  294 + if($emprestimo) {
  295 + $emprestimo = array_shift($emprestimo);
  296 + $emprestimo = Portabilis_Array_Utils::filter($emprestimo, array('cod_emprestimo' => 'id',
  297 + 'data_retirada' => 'data',
  298 + 'ref_cod_cliente' => 'cliente_id'));
  299 + // adiciona informações adicionais ao emprestimo
  300 + $cliente = $this->loadCliente($emprestimo["cliente_id"]);
  301 +
  302 + $emprestimo['cliente'] = $cliente;
  303 + $emprestimo['nome_cliente'] = $cliente['id'] . ' - ' . $cliente['nome'];
  304 + $emprestimo['situacao'] = $this->getSituacaoForFlag('emprestado');
  305 +
  306 + $emprestimo['data'] = date('d/m/Y', strtotime($emprestimo['data']));
  307 + $emprestimo['data_prevista_disponivel'] = $this->getDataPrevistaDisponivelForExemplar($exemplar, $emprestimo['data'], 'd/m/Y');
  308 + }
  309 +
  310 + return $emprestimo;
  311 + }
  312 +
  313 +
  314 + protected function existsReservaForExemplar($exemplar = null, $clienteId = null) {
  315 + $reservas = $this->loadReservasForExemplar($exemplar, $clienteId, $reload = true);
  316 + return is_array($reservas) && count($reservas) > 0;
  317 + }
  318 +
  319 +
  320 + protected function getSituacaoForFlag($flag) {
  321 + $situacoes = array(
  322 + 'indisponivel' => array('flag' => 'indisponivel', 'label' => 'Indisponível'),
  323 + 'disponivel' => array('flag' => 'disponivel' , 'label' => 'Disponível' ),
  324 + 'emprestado' => array('flag' => 'emprestado' , 'label' => 'Emprestado' ),
  325 + 'reservado' => array('flag' => 'reservado' , 'label' => 'Reservado' ),
  326 + 'emprestado_e_reservado' => array('flag' => 'emprestado_e_reservado',
  327 + 'label' => 'Emprestado e reservado' ),
  328 + 'invalida' => array('flag' => 'invalida' , 'label' => 'Inválida' )
  329 + );
  330 +
  331 + return $situacoes[$flag];
  332 + }
  333 +
  334 +
  335 + protected function loadSituacaoForExemplar($exemplar) {
  336 +
  337 + $situacao = new clsPmieducarSituacao($exemplar["situacao_id"]);
  338 + $situacao = $situacao->detalhe();
  339 +
  340 + $reservado = $this->existsReservaForExemplar($exemplar);
  341 + $emprestado = $situacao["situacao_emprestada"] == 1;
  342 +
  343 + $situacaoPermiteEmprestimo = $situacao["permite_emprestimo"] == 2;
  344 + $exemplarPermiteEmprestimo = $exemplar["permite_emprestimo"] == 2;
  345 +
  346 + if ($emprestado && $reservado)
  347 + $flagSituacaoExemplar = 'emprestado_e_reservado';
  348 + elseif ($emprestado)
  349 + $flagSituacaoExemplar = 'emprestado';
  350 + elseif ($reservado)
  351 + $flagSituacaoExemplar = 'reservado';
  352 + elseif ($situacaoPermiteEmprestimo && $exemplarPermiteEmprestimo)
  353 + $flagSituacaoExemplar = 'disponivel';
  354 + elseif (! $situacaoPermiteEmprestimo || ! $exemplarPermiteEmprestimo)
  355 + $flagSituacaoExemplar = 'indisponivel';
  356 + else
  357 + $flagSituacaoExemplar = 'invalida';
  358 +
  359 + return $this->getSituacaoForFlag($flagSituacaoExemplar);
  360 + }
  361 +
  362 +
  363 + protected function getSituacaoExemplar($exemplar = null) {
  364 + if (is_null($exemplar))
  365 + $exemplar = $this->loadExemplar();
  366 +
  367 + return $exemplar['situacao'];
  368 + }
  369 +
  370 +
  371 + protected function getPendenciasForExemplar($exemplar) {
  372 + if (! isset($exemplar['situacao']))
  373 + throw new CoreExt_Exception("Exemplar deve possuir uma chave 'situacao' para getPendenciasForExemplar.");
  374 +
  375 + $situacaoExemplar = $exemplar['situacao'];
  376 + $pendencias = array();
  377 +
  378 + // get emprestimo
  379 + if (strpos($situacaoExemplar['flag'], 'emprestado') > -1) {
  380 + $emprestimo = $this->loadEmprestimoForExemplar($exemplar);
  381 +
  382 + if($emprestimo != false)
  383 + $pendencias[] = $emprestimo;
  384 + }
  385 +
  386 + // get reservas
  387 + if (strpos($situacaoExemplar['flag'], 'reservado') > -1) {
  388 + $reservas = $this->loadReservasForExemplar($exemplar);
  389 +
  390 + if ($reservas != false)
  391 + $pendencias = array_merge($pendencias, $reservas);
  392 + }
  393 +
  394 + return $pendencias;
  395 + }
  396 +
  397 +
  398 + protected function loadAcervo($id = '', $reload = false) {
  399 + if (empty($id))
  400 + $id = $this->getRequest()->acervo_id;
  401 +
  402 + if ($reload || ! isset($this->_acervos))
  403 + $this->_acervos = array();
  404 +
  405 + if (! isset($this->_acervos[$id])) {
  406 + $acervo = new clsPmieducarAcervo($id);
  407 + $acervo = $acervo->detalhe();
  408 +
  409 + if ($acervo) {
  410 + $acervo = Portabilis_Array_Utils::filter($acervo, array('cod_acervo' => 'id',
  411 + 'ref_cod_exemplar_tipo' => 'exemplar_tipo_id',
  412 + 'ref_cod_acervo' => 'acervo_referencia_id',
  413 + 'ref_cod_acervo_colecao' => 'colecao_id',
  414 + 'ref_cod_acervo_idioma' => 'idioma_id',
  415 + 'ref_cod_acervo_editora' => 'editora_id',
  416 + 'ref_cod_biblioteca' => 'biblioteca_id',
  417 + 'titulo',
  418 + 'sub_titulo',
  419 + 'cdu',
  420 + 'cutter',
  421 + 'volume',
  422 + 'num_edicao',
  423 + 'ano',
  424 + 'num_paginas',
  425 + 'isbn',
  426 + 'data_cadastro'));
  427 + }
  428 +
  429 +
  430 + $this->_acervos[$id] = $acervo;
  431 + }
  432 +
  433 + return $this->_acervos[$id];
  434 + }
  435 +
  436 +
  437 + protected function loadExemplares($reload = false, $id = null) {
  438 + if ($reload || ! isset($this->_exemplares)) {
  439 + $exemplares = new clsPmieducarExemplar();
  440 +
  441 + // filtra por acervo_id e/ou tombo_exemplar (caso tenha recebido tais parametros)
  442 + $exemplares = $exemplares->lista($id,
  443 + null,
  444 + null,
  445 + $this->getRequest()->acervo_id,
  446 + null,
  447 + null,
  448 + null,
  449 + null,
  450 + null,
  451 + null,
  452 + null,
  453 + null,
  454 + null,
  455 + 1,
  456 + null,
  457 + null,
  458 + null,
  459 + null,
  460 + $this->getRequest()->biblioteca_id,
  461 + null,
  462 + $this->getRequest()->instituicao_id,
  463 + $this->getRequest()->escola_id,
  464 + $this->getRequest()->tombo_exemplar);
  465 +
  466 + if ($exemplares) {
  467 + $exemplares = Portabilis_Array_Utils::filterSet($exemplares, array('cod_exemplar' => 'id',
  468 + 'ref_cod_fonte' => 'fonte_id',
  469 + 'ref_cod_motivo_baixa' => 'motivo_baixa_id',
  470 + 'ref_cod_acervo' => 'acervo_id',
  471 + 'ref_cod_biblioteca' => 'biblioteca_id',
  472 + 'ref_cod_situacao' => 'situacao_id',
  473 + 'permite_emprestimo',
  474 + 'tombo'));
  475 + // adiciona situacao e pendencias de cada exemplar
  476 + foreach($exemplares as $index => $exemplar) {
  477 + $acervo = $this->loadAcervo($exemplar['acervo_id']);
  478 + $exemplares[$index]['acervo'] = array();
  479 + $exemplares[$index]['acervo']['id'] = $exemplar['acervo_id'];
  480 + $exemplares[$index]['acervo']['titulo'] = $acervo['titulo'];
  481 + $exemplares[$index]['acervo']['exemplar_tipo_id'] = $acervo['exemplar_tipo_id'];
  482 +
  483 + $exemplares[$index]['exemplar_tipo_id'] = $acervo['exemplar_tipo_id'];
  484 +
  485 + $exemplares[$index]['situacao'] = $this->loadSituacaoForExemplar($exemplares[$index]);
  486 + $exemplares[$index]['pendencias'] = $this->getPendenciasForExemplar($exemplares[$index]);
  487 + }
  488 + }
  489 +
  490 + $this->_exemplares = $exemplares;
  491 + }
  492 +
  493 + return $this->_exemplares;
  494 + }
  495 +
  496 +
  497 + protected function loadExemplar($reload = false, $id = null) {
  498 + if (! $id)
  499 + $id = $this->getRequest()->exemplar_id;
  500 +
  501 + return array_shift($this->loadExemplares($reload, $id));
  502 + }
  503 +
  504 +
  505 + /* metódos resposta operação / recurso
  506 + metódos nomeados no padrão operaçãoRecurso */
  507 +
  508 + protected function getExemplares() {
  509 + $this->appendResponse('exemplares', $this->loadExemplares($reload = true));
  510 + }
  511 +
  512 +
  513 + protected function loadSituacaoExemplar($permiteEmprestimo = true, $padrao = true, $emprestada = false){
  514 + $permiteEmprestimo = $permiteEmprestimo == true ? 2 : 1;
  515 + $emprestada = $emprestada == true ? 1 : 0;
  516 +
  517 + if (! is_null($padrao))
  518 + $padrao = $padrao == true ? 1 : 0;
  519 +
  520 + $situacao = new clsPmieducarSituacao();
  521 + $situacao = $situacao->lista(null,
  522 + null,
  523 + null,
  524 + null,
  525 + $permiteEmprestimo,
  526 + null,
  527 + $padrao,
  528 + $emprestada,
  529 + null,
  530 + null,
  531 + null,
  532 + null,
  533 + 1,
  534 + $this->getRequest()->biblioteca_id,
  535 + $this->getRequest()->instituicao_id,
  536 + $this->getRequest()->escola_id);
  537 +
  538 + if ($situacao) {
  539 + $situacao = Portabilis_Array_Utils::filter($situacao[0], array('cod_situacao' => 'id',
  540 + 'ref_cod_biblioteca' => 'biblioteca_id',
  541 + 'nm_situacao' => 'label',
  542 + 'situacao_padrao' => 'padrao',
  543 + 'situacao_emprestada' => 'emprestada',
  544 + 'permite_emprestimo',
  545 + 'descricao'));
  546 + }
  547 +
  548 + return $situacao;
  549 + }
  550 +
  551 +
  552 + protected function updateSituacaoExemplar($newSituacao){
  553 + if (! $newSituacao)
  554 + throw new CoreExt_Exception('$newSituacao não pode ser falso em updateSituacaoExemplar.');
  555 +
  556 + $exemplar = new clsPmieducarExemplar();
  557 + $exemplar->cod_exemplar = $this->getRequest()->exemplar_id;
  558 + $exemplar->ref_cod_acervo = $this->getRequest()->acervo_id;
  559 + $exemplar->ref_cod_situacao = $newSituacao['id'];
  560 + $exemplar->ref_usuario_exc = $this->getSession()->id_pessoa;
  561 +
  562 + return $exemplar->edita();
  563 + }
  564 +
  565 +
  566 + protected function postEmprestimo() {
  567 + if ($this->canPostEmprestimo()) {
  568 + // altera situacao exemplar para emprestado
  569 + $situacaoEmprestimo = $this->loadSituacaoExemplar($permiteEmprestimo = false, $padrao = null, $emprestada = true);
  570 +
  571 + if($situacaoEmprestimo && ! $this->updateSituacaoExemplar($situacaoEmprestimo))
  572 + $this->messenger->append("Aparentemente a situação do exemplar não foi alterada para emprestado.", 'error');
  573 + elseif(! $situacaoEmprestimo)
  574 + $this->messenger->append("Não foi encontrado uma situação cadastrada para emprestimo.", 'error');
  575 +
  576 + // grava emprestimo
  577 + if(! $this->messenger->hasMsgWithType('error')) {
  578 + $emprestimo = new clsPmieducarExemplarEmprestimo();
  579 + $emprestimo->ref_usuario_cad = $this->getSession()->id_pessoa;
  580 + $emprestimo->ref_cod_cliente = $this->getRequest()->cliente_id;
  581 + $emprestimo->ref_cod_exemplar = $this->getRequest()->exemplar_id;
  582 +
  583 + if ($emprestimo->cadastra())
  584 + $this->messenger->append("Emprestimo realizado com sucesso.", 'success');
  585 + else
  586 + $this->messenger->append("Aparentemente o realizado não foi cadastrado, por favor, tente novamente.", 'error');
  587 + }
  588 + }
  589 +
  590 + $this->appendResponse('exemplar', $this->loadExemplar($reload = true));
  591 + }
  592 +
  593 +
  594 + protected function postDevolucao() {
  595 +
  596 + if ($this->canPostDevolucao()) {
  597 + // altera situacao exemplar para disponivel
  598 + $situacaoDisponivel = $this->loadSituacaoExemplar($permiteEmprestimo = true, $padrao = true, $emprestada = false);
  599 +
  600 + if($situacaoDisponivel && ! $this->updateSituacaoExemplar($situacaoDisponivel))
  601 + $this->messenger->append("Aparentemente a situação do exemplar não foi alterada para disponivel.", 'error');
  602 + elseif(! $situacaoDisponivel)
  603 + $this->messenger->append("Não foi encontrado uma situação padrão cadastrada para exemplar disponivel.", 'error');
  604 +
  605 + // grava emprestimo
  606 + if(! $this->messenger->hasMsgWithType('error')) {
  607 +
  608 + $_emprestimo = $this->loadEmprestimoForExemplar();
  609 + $emprestimo = new clsPmieducarExemplarEmprestimo();
  610 + $emprestimo->cod_emprestimo = $_emprestimo['id'];
  611 + $emprestimo->ref_usuario_devolucao = $this->getSession()->id_pessoa;
  612 + $emprestimo->data_devolucao = date("Y-m-d");
  613 +
  614 + // TODO calcular / setar valor multa (se) devolução atrasada?
  615 +
  616 + if ($emprestimo->edita())
  617 + $this->messenger->append("Devolução realizada com sucesso.", 'success');
  618 + else
  619 + $this->messenger->append("Aparentemente a devolução não foi cadastrada, por favor, tente novamente.", 'error');
  620 + }
  621 + }
  622 +
  623 + $this->appendResponse('exemplar', $this->loadExemplar($reload = true));
  624 + }
  625 +
  626 +
  627 + public function Gerar() {
  628 + if ($this->isRequestFor('get', 'exemplares'))
  629 + $this->getExemplares();
  630 +
  631 + elseif ($this->isRequestFor('post', 'emprestimo'))
  632 + $this->postEmprestimo();
  633 +
  634 + elseif ($this->isRequestFor('post', 'devolucao'))
  635 + $this->postDevolucao();
  636 +
  637 + else
  638 + $this->notImplementedOperationError();
  639 + }
  640 +}
ieducar/modules/Biblioteca/Views/EmprestimoController.php 0 → 100644
@@ -0,0 +1,58 @@ @@ -0,0 +1,58 @@
  1 +<?php
  2 +
  3 +#error_reporting(E_ALL);
  4 +#ini_set("display_errors", 1);
  5 +
  6 +/**
  7 + * i-Educar - Sistema de gestão escolar
  8 + *
  9 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  10 + * <ctima@itajai.sc.gov.br>
  11 + *
  12 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  13 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  14 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  15 + * qualquer versão posterior.
  16 + *
  17 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  18 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  19 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  20 + * do GNU para mais detalhes.
  21 + *
  22 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  23 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  24 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  25 + *
  26 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  27 + * @category i-Educar
  28 + * @license @@license@@
  29 + * @package Biblioteca
  30 + * @subpackage Modules
  31 + * @since Arquivo disponível desde a versão ?
  32 + * @version $Id$
  33 + */
  34 +
  35 +require_once 'Portabilis/Controller/Page/ListController.php';
  36 +
  37 +class EmprestimoController extends Portabilis_Controller_Page_ListController
  38 +{
  39 + protected $_dataMapper = '';
  40 + protected $_titulo = 'Emprestimo';
  41 + protected $_formMap = array();
  42 + protected $_processoAp = 610;
  43 +
  44 + public function Gerar() {
  45 + // inputs
  46 + $this->inputsHelper()->dynamic('instituicao', array('id' => 'instituicao_id'));
  47 + $this->inputsHelper()->dynamic('escola', array('id' => 'escola_id'));
  48 + $this->inputsHelper()->dynamic('biblioteca', array('id' => 'biblioteca_id'));
  49 + $this->campoNumero('tombo_exemplar', 'Tombo exemplar', '', 13, 13, true);
  50 +
  51 + $helperOptions = array('hiddenInputOptions' => array('id' => 'cliente_id'));
  52 + $this->inputsHelper()->dynamic('bibliotecaPesquisaCliente', array(), $helperOptions);
  53 +
  54 + // assets
  55 + $this->loadResourceAssets($this->getDispatcher());
  56 + }
  57 +}
  58 +?>
ieducar/modules/Biblioteca/Views/ReservaApiController.php 0 → 100644
@@ -0,0 +1,597 @@ @@ -0,0 +1,597 @@
  1 +<?php
  2 +
  3 +#error_reporting(E_ALL);
  4 +#ini_set("display_errors", 1);
  5 +
  6 +/**
  7 + * i-Educar - Sistema de gestão escolar
  8 + *
  9 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  10 + * <ctima@itajai.sc.gov.br>
  11 + *
  12 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  13 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  14 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  15 + * qualquer versão posterior.
  16 + *
  17 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  18 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  19 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  20 + * do GNU para mais detalhes.
  21 + *
  22 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  23 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  24 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  25 + *
  26 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  27 + * @category i-Educar
  28 + * @license @@license@@
  29 + * @package Biblioteca
  30 + * @subpackage Modules
  31 + * @since Arquivo disponível desde a versão ?
  32 + * @version $Id$
  33 + */
  34 +
  35 +require_once 'lib/Portabilis/Controller/ApiCoreController.php';
  36 +require_once 'include/pmieducar/clsPmieducarExemplar.inc.php';
  37 +
  38 +// TODO migrar novo padrao api controller
  39 +
  40 +class ReservaApiController extends ApiCoreController
  41 +{
  42 + protected $_nivelAcessoOption = App_Model_NivelAcesso::SOMENTE_BIBLIOTECA;
  43 +
  44 + // validadores especificos reserva
  45 +
  46 + protected function validatesPresenceOfRefCodInstituicao(){
  47 + return $this->validator->validatesPresenceOf($this->getRequest()->ref_cod_instituicao, 'ref_cod_instituicao');
  48 + }
  49 +
  50 +
  51 + protected function validatesPresenceOfRefCodEscola(){
  52 + return $this->validator->validatesPresenceOf($this->getRequest()->ref_cod_escola, 'ref_cod_escola');
  53 + }
  54 +
  55 +
  56 + protected function validatesPresenceOfRefCodBiblioteca(){
  57 + return $this->validator->validatesPresenceOf($this->getRequest()->ref_cod_biblioteca, 'ref_cod_biblioteca');
  58 + }
  59 +
  60 +
  61 + protected function validatesPresenceOfRefCodCliente(){
  62 + return $this->validator->validatesPresenceOf($this->getRequest()->ref_cod_cliente, 'ref_cod_cliente');
  63 + }
  64 +
  65 +
  66 + protected function validatesPresenceOfRefCodAcervo(){
  67 + return $this->validator->validatesPresenceOf($this->getRequest()->ref_cod_acervo, 'ref_cod_acervo');
  68 + }
  69 +
  70 +
  71 + protected function validatesPresenceOfExemplarId(){
  72 + return $this->validator->validatesPresenceOf($this->getRequest()->exemplar_id, 'exemplar_id');
  73 + }
  74 +
  75 + protected function validatesPresenceOfReservaId(){
  76 + return $this->validator->validatesPresenceOf($this->getRequest()->reserva_id, 'reserva_id');
  77 + }
  78 +
  79 +
  80 + // validações negócio
  81 +
  82 + protected function canAcceptRequest() {
  83 + return parent::canAcceptRequest() &&
  84 + $this->validatesPresenceOfRefCodInstituicao() &&
  85 + $this->validatesPresenceOfRefCodEscola() &&
  86 + $this->validatesPresenceOfRefCodBiblioteca() &&
  87 + $this->validatesPresenceOfRefCodCliente() &&
  88 + $this->validatesPresenceOfRefCodAcervo();
  89 + // TODO validar se cliente da biblioteca
  90 + }
  91 +
  92 +
  93 + protected function canPostReserva() {
  94 + return $this->validatesClienteIsNotSuspenso() &&
  95 + $this->validatesPresenceOfExemplarId() &&
  96 +
  97 + $this->validatesSituacaoExemplarIsIn(array('disponivel',
  98 + 'emprestado',
  99 + 'reservado',
  100 + 'emprestado_e_reservado')) &&
  101 +
  102 + $this->validatesNotExistsReservaEmAbertoForCliente();
  103 +
  104 + // TODO validar ?
  105 + // qtd reservas em aberto do cliente <= limite biblioteca
  106 + // valor R$ multas em aberto do cliente <= limite biblioteca
  107 + }
  108 +
  109 +
  110 + protected function canDeleteReserva() {
  111 + return $this->validatesPresenceOfExemplarId() &&
  112 + $this->validatesPresenceOfReservaId() &&
  113 +
  114 + $this->validatesSituacaoExemplarIsIn(array('reservado',
  115 + 'emprestado_e_reservado')) &&
  116 +
  117 + $this->validatesExistsReservaEmAbertoForCliente();
  118 + }
  119 +
  120 +
  121 + protected function validatesSituacaoExemplarIsIn($situacoes) {
  122 + if (! is_array($situacoes))
  123 + $situacoes = array($situacoes);
  124 +
  125 + $situacaoAtual = $this->getSituacaoExemplar();
  126 + $situacaoAtual = $situacaoAtual['flag'];
  127 + $msg = "Situação do exemplar deve estar em (" . implode(', ', $situacoes) . ") porem atualmente é $situacaoAtual.";
  128 +
  129 + return $this->validator->validatesValueInSetOf($situacaoAtual, $situacoes, 'situação', false, $msg);
  130 + }
  131 +
  132 +
  133 + protected function validatesClienteIsNotSuspenso() {
  134 + $cliente = $this->loadCliente();
  135 +
  136 + if($cliente['suspenso']) {
  137 + $this->messenger->append("O cliente esta suspenso", 'error');
  138 + return false;
  139 + }
  140 +
  141 + return true;
  142 + }
  143 +
  144 +
  145 + protected function validatesNotExistsReservaEmAbertoForCliente() {
  146 + if ($this->existsReservaEmAbertoForCliente()) {
  147 + $this->messenger->append("Este cliente já possui uma reserva em aberto para um exemplar desta obra.", 'error');
  148 + return false;
  149 + }
  150 +
  151 + return true;
  152 + }
  153 +
  154 +
  155 + protected function validatesExistsReservaEmAbertoForCliente() {
  156 + if (! $this->existsReservaEmAbertoForCliente()) {
  157 + $this->messenger->append("O cliente não possui reserva em aberto para este exemplar.", 'error');
  158 + return false;
  159 + }
  160 +
  161 + return true;
  162 + }
  163 +
  164 +
  165 + // subscreve metódo super classe
  166 +
  167 + protected function getAvailableOperationsForResources() {
  168 + return array('exemplares' => array('get'),
  169 + 'reserva' => array('post')
  170 + );
  171 + }
  172 +
  173 +
  174 + /* metódos auxiliares resposta operação / recurso
  175 + metódos iniciados com load consultam informação no banco de dados
  176 + metódos iniciados com get consultam informação em objetos
  177 + */
  178 +
  179 + protected function loadExemplar($id = '', $reload = false) {
  180 + if ($reload || ! isset($this->_exemplar)) {
  181 +
  182 + if (empty($id))
  183 + $id = $this->getRequest()->exemplar_id;
  184 +
  185 + $exemplar = new clsPmieducarExemplar($id);
  186 + $exemplar = $exemplar->detalhe();
  187 +
  188 + $situacaoExemplar = $this->loadSituacaoForExemplar($exemplar);
  189 + $this->_exemplar = array('id' => $exemplar['cod_exemplar'],
  190 + 'situacao' => $situacaoExemplar,
  191 + 'pendencias' => $this->getPendenciasForExemplar($exemplar, $situacaoExemplar)
  192 + );
  193 + }
  194 +
  195 + return $this->_exemplar;
  196 + }
  197 +
  198 +
  199 + protected function getPendenciasForExemplar($exemplar, $situacaoExemplar = '') {
  200 + if (empty($situacaoExemplar))
  201 + $situacaoExemplar = $exemplar['situacao'];
  202 +
  203 + $pendencias = array();
  204 +
  205 + if (strpos($situacaoExemplar['flag'], 'emprestado') > -1)
  206 + $pendencias[] = $this->loadEmprestimoForExemplar($exemplar);
  207 +
  208 + if (strpos($situacaoExemplar['flag'], 'reservado') > -1)
  209 + $pendencias = array_merge($pendencias, $this->loadReservasForExemplar($exemplar));
  210 +
  211 + return $pendencias;
  212 + }
  213 +
  214 +
  215 + protected function loadSituacaoForExemplar($exemplar) {
  216 + $situacao = new clsPmieducarSituacao($exemplar["ref_cod_situacao"]);
  217 + $situacao = $situacao->detalhe();
  218 +
  219 + $reservado = $this->existsReservaForExemplar($exemplar);
  220 + $emprestado = $situacao["situacao_emprestada"] == 1;
  221 +
  222 + $situacaoPermiteEmprestimo = $situacao["permite_emprestimo"] == 2;
  223 + $exemplarPermiteEmprestimo = $exemplar["permite_emprestimo"] == 2;
  224 +
  225 + if ($emprestado && $reservado)
  226 + $flagSituacaoExemplar = 'emprestado_e_reservado';
  227 + elseif ($emprestado)
  228 + $flagSituacaoExemplar = 'emprestado';
  229 + elseif ($reservado)
  230 + $flagSituacaoExemplar = 'reservado';
  231 + elseif ($situacaoPermiteEmprestimo && $exemplarPermiteEmprestimo)
  232 + $flagSituacaoExemplar = 'disponivel';
  233 + elseif (! $situacaoPermiteEmprestimo || ! $exemplarPermiteEmprestimo)
  234 + $flagSituacaoExemplar = 'indisponivel';
  235 + else
  236 + $flagSituacaoExemplar = 'invalida';
  237 +
  238 + return $this->getSituacaoForFlag($flagSituacaoExemplar);
  239 + }
  240 +
  241 +
  242 + protected function getSituacaoForFlag($flag) {
  243 + $situacoes = array(
  244 + 'indisponivel' => array('flag' => 'indisponivel', 'label' => 'Indisponível'),
  245 + 'disponivel' => array('flag' => 'disponivel' , 'label' => 'Disponível' ),
  246 + 'emprestado' => array('flag' => 'emprestado' , 'label' => 'Emprestado' ),
  247 + 'reservado' => array('flag' => 'reservado' , 'label' => 'Reservado' ),
  248 + 'emprestado_e_reservado' => array('flag' => 'emprestado_e_reservado',
  249 + 'label' => 'Emprestado e reservado' ),
  250 + 'invalida' => array('flag' => 'invalida' , 'label' => 'Inválida' )
  251 + );
  252 +
  253 + return $situacoes[$flag];
  254 + }
  255 +
  256 +
  257 + protected function getSituacaoExemplar($exemplar = null) {
  258 + if (is_null($exemplar))
  259 + $exemplar = $this->loadExemplar();
  260 +
  261 + return $exemplar['situacao'];
  262 + }
  263 +
  264 +
  265 + protected function getAcervo($id = '') {
  266 + if (empty($id))
  267 + $id = $this->getRequest()->ref_cod_acervo;
  268 +
  269 + $acervo = new clsPmieducarAcervo($id);
  270 + return $acervo->detalhe();
  271 + }
  272 +
  273 +
  274 + protected function loadEmprestimoForExemplar($exemplar = null) {
  275 + if (is_null($exemplar))
  276 + $exemplar = $this->loadExemplar();
  277 +
  278 + $_emprestimo = array('cliente' => null,
  279 + 'nome_cliente' => '',
  280 + 'data' => '',
  281 + 'data_prevista_disponivel' => '',
  282 + 'exists' => false,
  283 + 'situacao' => $this->getSituacaoForFlag('emprestado')
  284 + );
  285 +
  286 + $emprestimo = new clsPmieducarExemplarEmprestimo();
  287 +
  288 + $emprestimo = $emprestimo->lista(null,
  289 + null,
  290 + null,
  291 + null,
  292 + $exemplar['cod_exemplar'],
  293 + null,
  294 + null,
  295 + null,
  296 + null,
  297 + null,
  298 + $devolvido = false,
  299 + $this->getRequest()->ref_cod_biblioteca,
  300 + null,
  301 + $this->getRequest()->ref_cod_instituicao,
  302 + $this->getRequest()->ref_cod_escola);
  303 +
  304 + if(is_array($emprestimo) && ! empty($emprestimo)) {
  305 + $emprestimo = array_shift($emprestimo);
  306 + $cliente = $this->loadCliente($emprestimo["ref_cod_cliente"]);
  307 +
  308 + $_emprestimo['exists'] = true;
  309 + $_emprestimo['data'] = date('d/m/Y', strtotime($emprestimo['data_retirada']));
  310 +
  311 + $_emprestimo['data_prevista_disponivel'] = $this->getDataPrevistaDisponivelForExemplar($emprestimo['data_retirada'], 'd/m/Y', $exemplar);
  312 + $_emprestimo['cliente'] = $cliente;
  313 + $_emprestimo['nome_cliente'] = $cliente['id'] . ' - ' . $cliente['nome'];
  314 + }
  315 +
  316 + return $_emprestimo;
  317 + }
  318 +
  319 +
  320 + protected function existsReservaForExemplar($exemplar = null, $clienteId = null) {
  321 + $reservas = $this->loadReservasForExemplar($exemplar, $clienteId, $reload = true);
  322 + return ! empty($reservas) && $reservas[0]['exists'];
  323 + }
  324 +
  325 + protected function existsReservaEmAbertoForCliente() {
  326 + $clienteId = $this->getRequest()->ref_cod_cliente;
  327 + $exemplares = $this->loadExemplares();
  328 +
  329 + foreach($exemplares as $exemplar) {
  330 + if ($this->existsReservaForExemplar($exemplar, $clienteId))
  331 + return true;
  332 + }
  333 +
  334 + return false;
  335 + }
  336 +
  337 + protected function loadReservasForExemplar($exemplar = null, $clienteId = null, $reload = false) {
  338 +
  339 + if ($reload || ! isset($this->_reservas)) {
  340 + if (is_null($exemplar))
  341 + $exemplar = $this->loadExemplar();
  342 +
  343 + $this->_reservas = array();
  344 +
  345 + $reservas = new clsPmieducarReservas();
  346 + $reservas = $reservas->lista(null,
  347 + null,
  348 + null,
  349 + $clienteId,
  350 + null,
  351 + null,
  352 + null,
  353 + null,
  354 + null,
  355 + null,
  356 + $exemplar['cod_exemplar'],
  357 + 1,
  358 + $this->getRequest()->ref_cod_biblioteca,
  359 + $this->getRequest()->ref_cod_instituicao,
  360 + $this->getRequest()->ref_cod_escola,
  361 + $data_retirada_null = true);
  362 +
  363 + foreach ($reservas as $reserva) {
  364 + $_reserva = array();
  365 + $cliente = $this->loadCliente($reserva["ref_cod_cliente"]);
  366 +
  367 + $_reserva['exists'] = true;
  368 + $_reserva['reserva_id'] = $reserva['cod_reserva'];
  369 + $_reserva['data'] = date('d/m/Y', strtotime($reserva['data_reserva']));
  370 +
  371 + /* caso seja o mesmo cliente da reserva: considera a data prevista disponivel gravada na reserva
  372 + senão considera a data prevista disponivel da reserva + a quantidade de dias de emprestimo do exemplar */
  373 + if ($this->getRequest()->ref_cod_escola == $cliente['id'])
  374 + $_reserva['data_prevista_disponivel'] = date('d/m/Y', strtotime($reserva['data_prevista_disponivel']));
  375 + else
  376 + $_reserva['data_prevista_disponivel'] = $this->getDataPrevistaDisponivelForExemplar($reserva['data_prevista_disponivel'], 'd/m/Y', $exemplar);
  377 +
  378 + $_reserva['cliente'] = $cliente;
  379 + $_reserva['nome_cliente'] = $cliente['id'] . ' - ' . $cliente['nome'];
  380 + $_reserva['situacao'] = $this->getSituacaoForFlag('reservado');
  381 +
  382 + $this->_reservas[] = $_reserva;
  383 + }
  384 + }
  385 +
  386 + return $this->_reservas;
  387 + }
  388 +
  389 +
  390 + protected function loadCliente($id = '') {
  391 +
  392 + if (empty($id))
  393 + $id = $this->getRequest()->ref_cod_cliente;
  394 +
  395 + $_cliente = array('id' => $id);
  396 +
  397 + $cliente = new clsPmieducarCliente($id);
  398 + $cliente = $cliente->detalhe();
  399 +
  400 + $_cliente['pessoaId'] = $cliente["ref_idpes"];
  401 +
  402 + $pessoa = new clsPessoa_($_cliente['pessoaId']);
  403 + $pessoa = $pessoa->detalhe();
  404 +
  405 + $_cliente['nome'] = $pessoa["nome"];
  406 +
  407 + $sql = "select 1 from pmieducar.cliente_suspensao where ref_cod_cliente = $1 and data_liberacao is null and data_suspensao + (dias||' day')::interval >= now()";
  408 + $suspenso = $this->fetchPreparedQuery($sql, $params = array($id), true, 'first-field');
  409 +
  410 + $_cliente['suspenso'] = $suspenso == '1';
  411 +
  412 + return $_cliente;
  413 + }
  414 +
  415 +
  416 + protected function getDataPrevistaDisponivelForExemplar($dataInicio, $format = 'd/m/Y', $exemplar = null) {
  417 + if (is_null($exemplar))
  418 + $exemplar = $this->loadExemplar();
  419 +
  420 + $qtdDiasEmprestimo = $this->loadQtdDiasEmprestimoForExemplar($exemplar);
  421 + $date = date($format, strtotime("+$qtdDiasEmprestimo days", strtotime($dataInicio)));
  422 +
  423 + // #TODO se data cair em feriado ou dia de não trabalho somar +1 dia ?
  424 +
  425 + return $date;
  426 + }
  427 +
  428 +
  429 + protected function loadQtdDiasEmprestimoForExemplar($exemplar = null) {
  430 + if (is_null($exemplar))
  431 + $exemplar = $this->loadExemplar();
  432 +
  433 + $acervo = $this->getAcervo($exemplar['ref_cod_acervo']);
  434 + $exemplarTipoId = $acervo['ref_cod_exemplar_tipo'];
  435 +
  436 + $clienteTipoCliente = new clsPmieducarClienteTipoCliente();
  437 +
  438 + $clienteTipoCliente = $clienteTipoCliente->lista(null,
  439 + $this->getRequest()->ref_cod_cliente,
  440 + null,
  441 + null,
  442 + null,
  443 + null,
  444 + null,
  445 + null,
  446 + $this->getRequest()->ref_cod_biblioteca,
  447 + 1);
  448 +
  449 + $clienteTipoId = $clienteTipoCliente[0]['ref_cod_cliente_tipo'];
  450 +
  451 + $clienteTipoExemplarTipo = new clsPmieducarClienteTipoExemplarTipo($clienteTipoId,
  452 + $exemplarTipoId);
  453 +
  454 + $clienteTipoExemplarTipo = $clienteTipoExemplarTipo->detalhe();
  455 +
  456 + return $clienteTipoExemplarTipo["dias_emprestimo"];
  457 + }
  458 +
  459 +
  460 + protected function getDataPrevistaDisponivelForExemplarAfterLastPendencia($exemplar = null) {
  461 + if (is_null($exemplar))
  462 + $exemplar = $this->loadExemplar();
  463 +
  464 + if (! empty($exemplar['pendencias'])) {
  465 + $lastPendencia = end($exemplar['pendencias']);
  466 + $dataPrevistaDisponivel = $this->getDataPrevistaDisponivelForExemplar($lastPendencia['data_prevista_disponivel'], 'Y-m-d', $exemplar);
  467 + }
  468 + else
  469 + $dataPrevistaDisponivel = date("Y-m-d");
  470 +
  471 + return $dataPrevistaDisponivel;
  472 + }
  473 +
  474 +
  475 + protected function loadExemplares($reload = false) {
  476 + if ($reload || ! isset($this->_exemplares)) {
  477 + $this->_exemplares = new clsPmieducarExemplar();
  478 + $this->_exemplares = $this->_exemplares->lista(null,
  479 + null,
  480 + null,
  481 + $this->getRequest()->ref_cod_acervo,
  482 + null,
  483 + null,
  484 + null,
  485 + null,
  486 + null,
  487 + null,
  488 + null,
  489 + null,
  490 + null,
  491 + 1,
  492 + null,
  493 + null,
  494 + null,
  495 + null,
  496 + $this->getRequest()->ref_cod_biblioteca,
  497 + null,
  498 + $this->getRequest()->ref_cod_instituicao,
  499 + $this->getRequest()->ref_cod_escola);
  500 + }
  501 +
  502 + return $this->_exemplares;
  503 + }
  504 +
  505 + /* metódos resposta operação / recurso
  506 + metódos nomeados no padrão operaçãoRecurso */
  507 +
  508 + protected function getExemplares() {
  509 + $exemplares = $this->loadExemplares();
  510 + $_exemplares = array();
  511 +
  512 + foreach($exemplares as $exemplar) {
  513 + $_exemplares[] = $this->loadExemplar($exemplar['cod_exemplar'], $reload = true);
  514 + }
  515 +
  516 + return $_exemplares;
  517 + }
  518 +
  519 +
  520 + protected function postReserva() {
  521 + if ($this->canPostReserva()) {
  522 + $exemplar = $this->loadExemplar();
  523 + $dataPrevistaDisponivel = $this->getDataPrevistaDisponivelForExemplarAfterLastPendencia($exemplar);
  524 +
  525 + $reserva = new clsPmieducarReservas(null,
  526 + null,
  527 + $this->getSession()->id_pessoa,
  528 + $this->getRequest()->ref_cod_cliente,
  529 + null,
  530 + $dataPrevistaDisponivel,
  531 + null,
  532 + $this->getRequest()->exemplar_id,
  533 + 1);
  534 +
  535 + if($reserva->cadastra())
  536 + $this->messenger->append("Reserva realizada com sucesso.", 'success');
  537 + else
  538 + $this->messenger->append("Aparentemente a reserva não foi cadastrada, por favor, tente novamente.", 'error');
  539 + }
  540 +
  541 + $this->appendResponse($this->loadExemplar($this->getRequest()->exemplar_id, $reload = true));
  542 + }
  543 +
  544 + protected function deleteReserva() {
  545 +
  546 + if ($this->canDeleteReserva()) {
  547 + $exemplar = $this->loadExemplar();
  548 +
  549 + // chamado list para assegurar que esta excluindo a reserva do cliente, biblioteca, instituicao e escola
  550 + $reservas = new clsPmieducarReservas();
  551 + $reservas = $reservas->lista($this->getRequest()->reserva_id,
  552 + null,
  553 + null,
  554 + $this->getRequest()->ref_cod_cliente,
  555 + null,
  556 + null,
  557 + null,
  558 + null,
  559 + null,
  560 + null,
  561 + $this->getRequest()->exemplar_id,
  562 + 1,
  563 + $this->getRequest()->ref_cod_biblioteca,
  564 + $this->getRequest()->ref_cod_instituicao,
  565 + $this->getRequest()->ref_cod_escola,
  566 + $data_retirada_null = true);
  567 +
  568 + foreach ($reservas as $reserva) {
  569 + $_reserva = new clsPmieducarReservas($this->getRequest()->reserva_id);
  570 +
  571 + if($_reserva->excluir())
  572 + $this->messenger->append("Reserva cancelada com sucesso.", 'success');
  573 + else
  574 + $this->messenger->append("Aparentemente a reserva não foi cancelada, por favor, tente novamente.", 'error');
  575 + }
  576 +
  577 + if(empty($reservas))
  578 + $this->messenger->append("Não foi encontrado uma reserva com os parâmetros recebidos.", 'error');
  579 + }
  580 +
  581 + $this->appendResponse($this->loadExemplar($this->getRequest()->exemplar_id, $reload = true));
  582 + }
  583 +
  584 + public function Gerar() {
  585 + if ($this->isRequestFor('get', 'exemplares'))
  586 + $this->appendResponse('exemplares', $this->getExemplares());
  587 +
  588 + elseif ($this->isRequestFor('post', 'reserva'))
  589 + $this->postReserva();
  590 +
  591 + elseif ($this->isRequestFor('delete', 'reserva'))
  592 + $this->deleteReserva();
  593 +
  594 + else
  595 + $this->notImplementedOperationError();
  596 + }
  597 +}
ieducar/modules/Biblioteca/Views/ReservaController.php 0 → 100644
@@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
  1 +<?php
  2 +
  3 +#error_reporting(E_ALL);
  4 +#ini_set("display_errors", 1);
  5 +
  6 +/**
  7 + * i-Educar - Sistema de gestão escolar
  8 + *
  9 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  10 + * <ctima@itajai.sc.gov.br>
  11 + *
  12 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  13 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  14 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  15 + * qualquer versão posterior.
  16 + *
  17 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  18 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  19 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  20 + * do GNU para mais detalhes.
  21 + *
  22 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  23 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  24 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  25 + *
  26 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  27 + * @category i-Educar
  28 + * @license @@license@@
  29 + * @package Biblioteca
  30 + * @subpackage Modules
  31 + * @since Arquivo disponível desde a versão ?
  32 + * @version $Id$
  33 + */
  34 +
  35 +require_once 'Portabilis/Controller/Page/ListController.php';
  36 +
  37 +class ReservaController extends Portabilis_Controller_Page_ListController
  38 +{
  39 + protected $_dataMapper = ''; #Avaliacao_Model_NotaAlunoDataMapper';
  40 + protected $_titulo = 'Reserva';
  41 + protected $_formMap = array();
  42 + protected $_processoAp = 609;
  43 +
  44 + public function Gerar() {
  45 + // inputs
  46 + $inputs = array('instituicao', 'escola', 'biblioteca', 'bibliotecaPesquisaCliente', 'bibliotecaPesquisaObra');
  47 + $this->inputsHelper()->dynamic($inputs);
  48 +
  49 + // assets
  50 + $this->loadResourceAssets($this->getDispatcher());
  51 + }
  52 +}
  53 +?>