Commit d43a94ffafe0add8249f69a23fce40d00cea3062

Authored by Carlos Montezano Lopes
2 parents 81a19363 57f7bbca
Exists in master and in 1 other branch dev

Merge branch 'master' of softwarepublico.gov.br:i-educar/i-educar into dev

Showing 34 changed files with 1417 additions and 286 deletions   Show diff stats
.gitignore
1 1 # Vagrant
2 2 /.vagrant
3   -
  3 +Vagrantfile
... ...
Vagrantfile
... ... @@ -4,6 +4,7 @@ VAGRANTFILE_API_VERSION = "2"
4 4 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
5 5 config.vm.box = "ieducar"
6 6 config.vm.box_url = "https://s3-us-west-2.amazonaws.com/portabilis2/public/ieducar/ieducar.box"
  7 + config.vm.box_download_insecure = "https://s3-us-west-2.amazonaws.com/portabilis2/public/ieducar/ieducar.box"
7 8  
8 9 #Compartilhando portas
9 10 config.vm.network "forwarded_port", guest: 80, host: 8080
... ...
ieducar/configuration/ieducar.ini
... ... @@ -150,10 +150,6 @@ app.recaptcha.options.secure = true
150 150 app.recaptcha.options.lang = pt
151 151 app.recaptcha.options.theme = white
152 152  
153   -; por padrao o sistema efetua a rematricula automatica de alunos ao inicializar um novo ano letivo,
154   -; esta configuracao permite desativar este comportamento.
155   -;app.regras_negocio.desativar_rematricula_automatica = false
156   -
157 153 ; Ativa obrigatoriedade de utilização de endereço normalizado no cadastro de pessoas
158 154 app.obriga_endereco_normalizado_pf = true
159 155  
... ... @@ -163,8 +159,6 @@ app.matricula.multiplas_matriculas = 0
163 159 [development : production]
164 160 ; Herda configurações de banco de dados
165 161  
166   -
167   -
168 162 [testing : development]
169 163 ; Herda todas as configurações de desenvolvimento
170 164  
... ...
ieducar/intranet/atendidos_cad.php
... ... @@ -110,6 +110,9 @@ class indice extends clsCadastro
110 110 var $cor_raca;
111 111 var $sus;
112 112 var $nis_pis_pasep;
  113 + var $municipio_id;
  114 + var $bairro_id;
  115 + var $logradouro_id;
113 116  
114 117 var $caminho_det;
115 118 var $caminho_lst;
... ... @@ -642,7 +645,45 @@ class indice extends clsCadastro
642 645  
643 646  
644 647 // Detalhes do Endereço
  648 + if ($this->idlog){
645 649  
  650 + $objLogradouro = new clsLogradouro($this->idlog);
  651 + $detalheLogradouro = $objLogradouro->detalhe();
  652 + if ($detalheLogradouro)
  653 + $this->municipio_id = $detalheLogradouro['idmun'];
  654 +
  655 + // Caso seja um endereço externo, tentamos então recuperar a cidade pelo cep
  656 + }elseif($this->cep){
  657 +
  658 + $numCep = idFederal2int($this->cep);
  659 +
  660 + $sql = "SELECT idmun, count(idmun) as count_mun FROM public.logradouro l, urbano.cep_logradouro cl
  661 + WHERE cl.idlog = l.idlog AND cl.cep = '{$numCep}' group by idmun order by count_mun desc limit 1";
  662 +
  663 + $options = array('return_only' => 'first-field');
  664 + $result = Portabilis_Utils_Database::fetchPreparedQuery($sql, $options);
  665 +
  666 + if ($result)
  667 + $this->municipio_id = $result;
  668 +
  669 + }
  670 + if ($this->cod_pessoa_fj){
  671 +
  672 + $objPE = new clsPessoaEndereco($this->cod_pessoa_fj);
  673 + $det = $objPE->detalhe();
  674 +
  675 + if($det){
  676 +
  677 + $this->bairro_id = $det['idbai'];
  678 + $this->logradouro_id = $det['idlog'];
  679 + }
  680 + }
  681 +
  682 + if (!($this->bairro_id && $this->municipio_id && $this->logradouro_id)){
  683 + $this->bairro_id = null;
  684 + $this->municipio_id = null;
  685 + $this->logradouro_id = null;
  686 + }
646 687 $this->campoOculto('idbai', $this->idbai);
647 688 $this->campoOculto('idlog', $this->idlog);
648 689 $this->campoOculto('cep', $this->cep);
... ... @@ -651,14 +692,13 @@ class indice extends clsCadastro
651 692 $this->campoOculto('id_cidade', $this->cidade);
652 693  
653 694  
654   - // o endereçamento é opcional ao cadastrar pai ou mãe.
655   - $enderecamentoObrigatorio = empty($parentType);
  695 + // o endereçamento é opcional
  696 + $enderecamentoObrigatorio = false;
656 697  
  698 + // Caso o cep já esteja definido, os campos já vem desbloqueados inicialmente
  699 + $desativarCamposDefinidosViaCep = empty($this->cep);
657 700  
658   - // considera como endereço localizado por CEP quando alguma das variaveis de instancia
659   - // idbai (bairro) ou idlog (logradouro) estão definidas, neste caso desabilita a edição
660   - // dos campos definidos via CEP.
661   - $desativarCamposDefinidosViaCep = ((bool)$GLOBALS['coreExt']['Config']->app->obriga_endereco_normalizado_pf) || ($this->idbai || $this->idlog);
  701 + $this->campoRotulo('','<b> Endereçamento</b>', '', '', 'Digite um CEP ou clique na lupa para<br/> busca avançada para começar');
662 702  
663 703 $this->campoCep(
664 704 'cep_',
... ... @@ -666,46 +706,25 @@ class indice extends clsCadastro
666 706 $this->cep,
667 707 $enderecamentoObrigatorio,
668 708 '-',
669   - "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel(500, 550, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=sigla_uf&campo12=idtlog&campo13=id_cidade&campo14=zona_localizacao\'></iframe>');\">",
670   - $desativarCamposDefinidosViaCep
  709 + "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel(500, 550, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro2.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=municipio_municipio&campo12=idtlog&campo13=municipio_id&campo14=zona_localizacao\'></iframe>');\">",
  710 + false
671 711 );
672 712  
  713 + $options = array('label' => Portabilis_String_Utils::toLatin1('Município'), 'required' => $enderecamentoObrigatorio, 'disabled' => $desativarCamposDefinidosViaCep);
673 714  
674   - // estado
  715 + $helperOptions = array('objectName' => 'municipio',
  716 + 'hiddenInputOptions' => array('options' => array('value' => $this->municipio_id)));
675 717  
676   - $options = array(
677   - 'label' => 'Estado / Cidade',
678   - 'value' => $this->sigla_uf,
679   - 'disabled' => $desativarCamposDefinidosViaCep,
680   - 'inline' => true,
681   - 'required' => $enderecamentoObrigatorio
682   - );
  718 + $this->inputsHelper()->simpleSearchMunicipio('municipio', $options, $helperOptions);
683 719  
684   - $helperOptions = array(
685   - 'attrName' => 'sigla_uf'
686   - );
687   -
688   - $this->inputsHelper()->uf($options, $helperOptions);
689   -
690   -
691   - // cidade
692   -
693   - $options = array(
694   - 'label' => '',
695   - 'placeholder' => 'Cidade',
696   - 'value' => $this->cidade,
697   - 'max_length' => 60,
698   - 'disabled' => $desativarCamposDefinidosViaCep,
699   - 'required' => $enderecamentoObrigatorio
700   - );
701   -
702   - $this->inputsHelper()->text('cidade', $options);
  720 + $helperOptions = array('hiddenInputOptions' => array('options' => array('value' => $this->bairro_id)));
703 721  
  722 + $options = array( 'label' => Portabilis_String_Utils::toLatin1('Bairro / Zona de Localização - <b>Buscar</b>'), 'required' => $enderecamentoObrigatorio, 'disabled' => $desativarCamposDefinidosViaCep);
704 723  
705   - // bairro
  724 + $this->inputsHelper()->simpleSearchBairro('bairro', $options, $helperOptions);
706 725  
707 726 $options = array(
708   - 'label' => 'Bairro / Zona localização',
  727 + 'label' => 'Bairro / Zona de Localização - <b>Cadastrar</b>',
709 728 'placeholder' => 'Bairro',
710 729 'value' => $this->bairro,
711 730 'max_length' => 40,
... ... @@ -725,7 +744,7 @@ class indice extends clsCadastro
725 744  
726 745 $options = array(
727 746 'label' => '',
728   - 'placeholder' => 'Zona localização',
  747 + 'placeholder' => 'Zona localização ',
729 748 'value' => $this->zona_localizacao,
730 749 'disabled' => $desativarCamposDefinidosViaCep,
731 750 'resources' => $zonas,
... ... @@ -734,11 +753,16 @@ class indice extends clsCadastro
734 753  
735 754 $this->inputsHelper()->select('zona_localizacao', $options);
736 755  
  756 + $helperOptions = array('hiddenInputOptions' => array('options' => array('value' => $this->logradouro_id)));
  757 +
  758 + $options = array('label' => 'Tipo / Logradouro - <b>Buscar</b>', 'required' => $enderecamentoObrigatorio, 'disabled' => $desativarCamposDefinidosViaCep);
  759 +
  760 + $this->inputsHelper()->simpleSearchLogradouro('logradouro', $options, $helperOptions);
737 761  
738 762 // tipo logradouro
739 763  
740 764 $options = array(
741   - 'label' => 'Tipo / Logradouro',
  765 + 'label' => 'Tipo / Logradouro - <b>Cadastrar</b>',
742 766 'value' => $this->idtlog,
743 767 'disabled' => $desativarCamposDefinidosViaCep,
744 768 'inline' => true,
... ... @@ -871,8 +895,19 @@ class indice extends clsCadastro
871 895  
872 896 Portabilis_View_Helper_Application::loadStylesheet($this, $styles);
873 897  
874   - $script = '/modules/Cadastro/Assets/Javascripts/PessoaFisica.js';
  898 + $script = array('/modules/Cadastro/Assets/Javascripts/PessoaFisica.js',
  899 + '/modules/Cadastro/Assets/Javascripts/Endereco.js');
875 900 Portabilis_View_Helper_Application::loadJavascript($this, $script);
  901 +
  902 + $this->campoCep(
  903 + 'cep_',
  904 + 'CEP',
  905 + $this->cep,
  906 + $enderecamentoObrigatorio,
  907 + '-',
  908 + "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel(500, 550, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro2.php?campo1=bairro_bairro&campo2=bairro_id&campo3=cep&campo4=logradouro_logradouro&campo5=logradouro_id&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=municipio_municipio&campo12=idtlog&campo13=municipio_id&campo14=zona_localizacao\'></iframe>');\">",
  909 + false
  910 + );
876 911 }
877 912  
878 913 function Novo() {
... ... @@ -1183,11 +1218,29 @@ class indice extends clsCadastro
1183 1218 }
1184 1219  
1185 1220 protected function _createOrUpdatePessoaEndereco($pessoaId) {
  1221 +
  1222 + $cep = idFederal2Int($this->cep_);
  1223 +
  1224 + $objCepLogradouro = new ClsCepLogradouro($cep, $this->logradouro_id);
  1225 +
  1226 + if (! $objCepLogradouro->existe())
  1227 + $objCepLogradouro->cadastra();
  1228 +
  1229 + $objCepLogradouroBairro = new ClsCepLogradouroBairro();
  1230 + $objCepLogradouroBairro->cep = $cep;
  1231 + $objCepLogradouroBairro->idbai = $this->bairro_id;
  1232 + $objCepLogradouroBairro->idlog = $this->logradouro_id;
  1233 +
  1234 +
  1235 + if (! $objCepLogradouroBairro->existe())
  1236 + $objCepLogradouroBairro->cadastra();
  1237 +
  1238 + #die("Morram <br> $cep <br> {$this->bairro_id} <br> {$this->logradouro_id}");
1186 1239 $endereco = new clsPessoaEndereco(
1187 1240 $pessoaId,
1188   - idFederal2Int($this->cep),
1189   - $this->idlog,
1190   - $this->idbai,
  1241 + $cep,
  1242 + $this->logradouro_id,
  1243 + $this->bairro_id,
1191 1244 $this->numero,
1192 1245 addslashes($this->complemento),
1193 1246 FALSE,
... ... @@ -1232,13 +1285,53 @@ class indice extends clsCadastro
1232 1285 }
1233 1286  
1234 1287 protected function createOrUpdateEndereco($pessoaId) {
1235   - $enderecoExterno = ! empty($this->cep_);
1236 1288  
1237   - if (! $enderecoExterno && $this->cep && $this->idbai && $this->idlog)
  1289 + if ($this->cep_ && is_numeric($this->bairro_id) && is_numeric($this->logradouro_id))
  1290 + $this->_createOrUpdatePessoaEndereco($pessoaId);
  1291 + else if($this->cep_ && is_numeric($this->municipio_id)){
  1292 +
  1293 + if (!is_numeric($this->bairro_id)){
  1294 + if ($this->canCreateBairro())
  1295 + $this->bairro_id = $this->createBairro();
  1296 + else
  1297 + return;
  1298 + }
  1299 +
  1300 + if (!is_numeric($this->logradouro_id)){
  1301 + if($this->canCreateLogradouro())
  1302 + $this->logradouro_id = $this->createLogradouro();
  1303 + else
  1304 + return;
  1305 + }
  1306 +
1238 1307 $this->_createOrUpdatePessoaEndereco($pessoaId);
1239 1308  
1240   - elseif($enderecoExterno)
1241   - $this->_createOrUpdateEnderecoExterno($pessoaId);
  1309 + }else{
  1310 + $endereco = new clsPessoaEndereco($pessoaId);
  1311 + $endereco->exclui();
  1312 + }
  1313 +
  1314 + }
  1315 +
  1316 + protected function canCreateBairro(){
  1317 + return !empty($this->bairro) && !empty($this->zona_localizacao);
  1318 + }
  1319 +
  1320 + protected function canCreateLogradouro(){
  1321 + return !empty($this->logradouro) && !empty($this->idtlog);
  1322 + }
  1323 +
  1324 + protected function createBairro(){
  1325 + $objBairro = new clsBairro(null,$this->municipio_id,null,addslashes($this->bairro), $this->currentUserId());
  1326 + $objBairro->zona_localizacao = $this->zona_localizacao;
  1327 +
  1328 + return $objBairro->cadastra();
  1329 + }
  1330 +
  1331 + protected function createLogradouro(){
  1332 + $objLogradouro = new clsLogradouro(null,$this->idtlog, $this->logradouro, $this->municipio_id,
  1333 + null, 'S', $this->currentUserId());
  1334 + return $objLogradouro->cadastra();
1242 1335 }
1243 1336  
1244 1337 protected function createOrUpdateTelefones($pessoaId) {
... ...
ieducar/intranet/educar_aluno_det.php
... ... @@ -61,7 +61,6 @@ class clsIndexBase extends clsBase
61 61 {
62 62 $this->SetTitulo($this->_instituicao . ' i-Educar - Aluno');
63 63 $this->processoAp = 578;
64   - $this->addEstilo("localizacaoSistema");
65 64 }
66 65 }
67 66  
... ... @@ -844,14 +843,6 @@ class indice extends clsDetalhe
844 843 $this->url_cancelar = 'educar_aluno_lst.php';
845 844 $this->largura = '100%';
846 845  
847   - $localizacao = new LocalizacaoSistema();
848   - $localizacao->entradaCaminhos( array(
849   - $_SERVER['SERVER_NAME']."/intranet" => "In&iacute;cio",
850   - "educar_index.php" => "i-Educar - Escola",
851   - "" => "Detalhe do aluno"
852   - ));
853   - $this->enviaLocalizacao($localizacao->montar());
854   -
855 846 $this->addDetalhe("<input type='hidden' id='escola_id' name='aluno_id' value='{$registro['ref_cod_escola']}' />");
856 847 $this->addDetalhe("<input type='hidden' id='aluno_id' name='aluno_id' value='{$registro['cod_aluno']}' />");
857 848  
... ... @@ -861,8 +852,8 @@ class indice extends clsDetalhe
861 852  
862 853 $scripts = array(
863 854 '/modules/Portabilis/Assets/Javascripts/Utils.js',
864   - '/modules/Portabilis/Assets/Javascripts/ClientApi.js',
865   - '/modules/Cadastro/Assets/Javascripts/AlunoShow.js'
  855 + '/modules/Portabilis/Assets/Javascripts/ClientApi.js',
  856 + '/modules/Cadastro/Assets/Javascripts/AlunoShow.js?version=3'
866 857 );
867 858  
868 859 Portabilis_View_Helper_Application::loadJavascript($this, $scripts);
... ...
ieducar/intranet/educar_iniciar_ano_letivo.php
... ... @@ -156,23 +156,20 @@ class indice extends clsCadastro
156 156 */
157 157  
158 158 $obj_ano_letivo = new clsPmieducarEscolaAnoLetivo($this->ref_cod_escola,$this->ano,$this->pessoa_logada,$this->pessoa_logada,1,null,null,1);
159   -
160   - if(! $obj_ano_letivo->edita()) {
161   - die("<script>
  159 + if(!$obj_ano_letivo->edita())
  160 + {
  161 + echo "<script>
162 162 alert('Erro ao finalizar o ano letivo!');
163 163 window.location = 'educar_escola_det.php?cod_escola={$this->ref_cod_escola}#ano_letivo';
164   - </script>");
  164 + </script>";
165 165 }
166   -
167   - if (! $GLOBALS['coreExt']['Config']->app->regras_negocio->desativar_rematricula_automatica) {
168   - $this->rematricularAlunosAprovados();
169   - $this->rematricularAlunosReprovados();
  166 + else
  167 + {
  168 + echo "<script>
  169 + alert('Ano letivo inicializado com sucesso!');
  170 + window.location = 'educar_escola_det.php?cod_escola={$this->ref_cod_escola}#ano_letivo';
  171 + </script>";
170 172 }
171   -
172   - die("<script>
173   - alert('Ano letivo inicializado com sucesso!');
174   - window.location = 'educar_escola_det.php?cod_escola={$this->ref_cod_escola}#ano_letivo';
175   - </script>");
176 173 }
177 174  
178 175 function finalizarAnoLetivo()
... ... @@ -227,69 +224,7 @@ class indice extends clsCadastro
227 224 }
228 225 }
229 226  
230   - function rematricularAlunosAprovados() {
231   - $obj_matricula = new clsPmieducarMatricula();
232   - $lst_matricula = $obj_matricula->lista( null,null,$this->ref_cod_escola,null,null,null,null,1,null,null,null,null,1,$this->ano-1,null,null,1 );
233   -
234   - if (! is_array($lst_matricula))
235   - return;
236   -
237   - foreach ($lst_matricula AS $key => $matricula) {
238   - $obj_sequencia = new clsPmieducarSequenciaSerie();
239   - $lst_sequencia = $obj_sequencia->lista( $matricula['ref_ref_cod_serie'],null,null,null,null,null,null,null,1 );
240   -
241   - if ( is_array($lst_sequencia) && (count($lst_sequencia) == 1) ) {
242   - $det_sequencia = array_shift($lst_sequencia);
243   - $serie_destino = $det_sequencia["ref_serie_destino"];
244   -
245   - $obj_serie = new clsPmieducarSerie( $serie_destino );
246   - $det_serie = $obj_serie->detalhe();
247   -
248   - $obj_escola_curso = new clsPmieducarEscolaCurso($this->ref_cod_escola, $det_serie["ref_cod_curso"]);
249   -
250   - if (is_array($obj_escola_curso->detalhe())) {
251   - $obj = new clsPmieducarMatricula( $matricula['cod_matricula'],null,null,null,$this->pessoa_logada,null,null,null,null,null,1,null,0 );
252   - $editou = $obj->edita();
253   - if( $editou ) {
254   - $obj = new clsPmieducarMatricula( null,null,$this->ref_cod_escola,$serie_destino,null,$this->pessoa_logada,$matricula['ref_cod_aluno'],3,null,null,1,$this->ano,1,null,null,null,null,$det_serie["ref_cod_curso"] );
255   - $cadastra = $obj->cadastra();
256   - if( !$cadastra ) {
257   - echo "<script>
258   - alert('Erro ao matricular os alunos da Escola!');
259   - window.location = 'educar_escola_det.php?cod_escola={$this->ref_cod_escola}#ano_letivo';
260   - </script>";
261   - }
262   - }
263   - }
264   - }
265   - }
266   - }
267   -
268   - function rematricularAlunosReprovados() {
269   - $obj_matricula = new clsPmieducarMatricula();
270   - $lst_matricula = $obj_matricula->lista( null,null,$this->ref_cod_escola,null,null,null,null,2,null,null,null,null,1,$this->ano-1,null,null,1 );
271   -
272   - if (! is_array($lst_matricula) )
273   - return;
274   -
275   - foreach ($lst_matricula AS $key => $matricula) {
276   - $obj_serie = new clsPmieducarSerie( $matricula['ref_ref_cod_serie'] );
277   - $det_serie = $obj_serie->detalhe();
278 227  
279   - $obj = new clsPmieducarMatricula( $matricula['cod_matricula'],null,null,null,$this->pessoa_logada,null,null,null,null,null,1,null,0 );
280   - $editou1 = $obj->edita();
281   - if( $editou1 ) {
282   - $obj = new clsPmieducarMatricula( null,null,$this->ref_cod_escola,$matricula['ref_ref_cod_serie'],null,$this->pessoa_logada,$matricula['ref_cod_aluno'],3,null,null,1,$this->ano,1,null,null,null,null,$det_serie["ref_cod_curso"] );
283   - $cadastra1 = $obj->cadastra();
284   - if( !$cadastra1 ) {
285   - echo "<script>
286   - alert('Erro ao matricular os alunos da Escola!');
287   - window.location = 'educar_escola_det.php?cod_escola={$this->ref_cod_escola}#ano_letivo';
288   - </script>";
289   - }
290   - }
291   - }
292   - }
293 228 }
294 229  
295 230 // cria uma extensao da classe base
... ...
ieducar/intranet/educar_pesquisa_cep_log_bairro.php
... ... @@ -407,4 +407,5 @@ function liberaCamposOuvidoria()
407 407  
408 408 window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1));
409 409 }
  410 +
410 411 </script>
411 412 \ No newline at end of file
... ...
ieducar/intranet/educar_pesquisa_cep_log_bairro2.php 0 → 100644
... ... @@ -0,0 +1,346 @@
  1 +<?php
  2 +/**
  3 + * i-Educar - Sistema de gestão escolar
  4 + *
  5 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  6 + * <ctima@itajai.sc.gov.br>
  7 + *
  8 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  9 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  10 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  11 + * qualquer versão posterior.
  12 + *
  13 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  14 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  15 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  16 + * do GNU para mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  19 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  20 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  21 + *
  22 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  23 + * @category i-Educar
  24 + * @license @@license@@
  25 + * @package iEd_Pmieducar
  26 + * @since Arquivo disponível desde a versão 1.0.0
  27 + * @version $Id$
  28 + */
  29 +require_once 'include/clsBase.inc.php';
  30 +require_once 'include/clsListagem.inc.php';
  31 +/**
  32 + * clsIndex class.
  33 + *
  34 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  35 + * @category i-Educar
  36 + * @license @@license@@
  37 + * @package iEd_Pmieducar
  38 + * @since Classe disponível desde a versão 1.0.0
  39 + * @version @@package_version@@
  40 + */
  41 +class clsIndex extends clsBase
  42 +{
  43 + function Formular()
  44 + {
  45 + $this->SetTitulo($this->_instituicao . ' i-Educar - Listagem de Ruas');
  46 + $this->processoAp = 0;
  47 + $this->renderMenu = FALSE;
  48 + $this->renderMenuSuspenso = FALSE;
  49 + }
  50 +}
  51 +/**
  52 + * miolo1 class.
  53 + *
  54 + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br>
  55 + * @category i-Educar
  56 + * @license @@license@@
  57 + * @package iEd_Pmieducar
  58 + * @since Classe disponível desde a versão 1.0.0
  59 + * @version @@package_version@@
  60 + */
  61 +class miolo1 extends clsListagem
  62 +{
  63 + var $funcao_js = 'cv_libera_campos(\'cep_\', \'ref_sigla_uf_\', \'cidade\', \'nm_bairro\', \'ref_idtlog\', \'nm_logradouro\', \'isEnderecoExterno\', \'zona_localizacao\')';
  64 + function Gerar()
  65 + {
  66 + global $coreExt;
  67 + @session_start();
  68 + $_SESSION['campo1'] = $_GET['campo1'] ? $_GET['campo1'] : $_SESSION['campo1'];
  69 + $_SESSION['campo2'] = $_GET['campo2'] ? $_GET['campo2'] : $_SESSION['campo2'];
  70 + $_SESSION['campo3'] = $_GET['campo3'] ? $_GET['campo3'] : $_SESSION['campo3'];
  71 + $_SESSION['campo4'] = $_GET['campo4'] ? $_GET['campo4'] : $_SESSION['campo4'];
  72 + $_SESSION['campo5'] = $_GET['campo5'] ? $_GET['campo5'] : $_SESSION['campo5'];
  73 + $_SESSION['campo6'] = $_GET['campo6'] ? $_GET['campo6'] : $_SESSION['campo6'];
  74 + $_SESSION['campo7'] = $_GET['campo7'] ? $_GET['campo7'] : $_SESSION['campo7'];
  75 + $_SESSION['campo8'] = $_GET['campo8'] ? $_GET['campo8'] : $_SESSION['campo8'];
  76 + $_SESSION['campo9'] = $_GET['campo9'] ? $_GET['campo9'] : $_SESSION['campo9'];
  77 + $_SESSION['campo10'] = $_GET['campo10'] ? $_GET['campo10'] : $_SESSION['campo10'];
  78 + $_SESSION['campo11'] = $_GET['campo11'] ? $_GET['campo11'] : $_SESSION['campo11'];
  79 + $_SESSION['campo12'] = $_GET['campo12'] ? $_GET['campo12'] : $_SESSION['campo12'];
  80 + $_SESSION['campo13'] = $_GET['campo13'] ? $_GET['campo13'] : $_SESSION['campo13'];
  81 + $_SESSION['campo14'] = $_GET['campo14'] ? $_GET['campo14'] : $_SESSION['campo14'];
  82 + $this->nome = 'form1';
  83 + $this->funcao_js = sprintf(
  84 + 'cv_libera_campos(\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')',
  85 + $_SESSION['campo10'], $_SESSION['campo11'], $_SESSION['campo7'],
  86 + $_SESSION['campo1'], $_SESSION['campo12'], $_SESSION['campo4'],
  87 + $_SESSION['campo9'], $_SESSION['campo14']
  88 + );
  89 + $this->titulo = 'Endereço';
  90 + // Paginador
  91 + $limite = 7;
  92 + $iniciolimit = $_GET['pagina_' . $this->nome] ?
  93 + ($_GET['pagina_' . $this->nome] * $limite - $limite) : 0;
  94 + // Filtros
  95 + $this->campoTexto('nm_bairro', 'Bairro', $_GET['nm_bairro'], 40, 255);
  96 + $this->campoCep('nr_cep', 'CEP', $_GET['nr_cep']);
  97 + $this->campoTexto('nm_logradouro', 'Logradouro', $_GET['nm_logradouro'], 50, 255);
  98 + $this->campoTexto('cidade', 'Cidade', $_GET['cidade'], 60, 60);
  99 + // uf
  100 + $defaultProvince = isset($_GET['ref_sigla_uf']) ? $_GET['ref_sigla_uf'] : $coreExt['Config']->app->locale->province;
  101 + $options = array(
  102 + 'required' => false,
  103 + 'label' => 'Estado',
  104 + 'value' => $defaultProvince
  105 + );
  106 + $helperOptions = array(
  107 + 'attrName' => 'ref_sigla_uf'
  108 + );
  109 + $this->inputsHelper()->uf($options, $helperOptions);
  110 + $this->addCabecalhos(array('Bairro', 'CEP', 'Logradouro', 'UF', 'Cidade'));
  111 + // consulta dados
  112 + $pre_select = '
  113 + SELECT
  114 + c.idlog, c.cep, c.idbai, u.sigla_uf, m.nome, t.idtlog, m.idmun, b.zona_localizacao, t.descricao ';
  115 +
  116 + $select = '
  117 + FROM
  118 + urbano.cep_logradouro_bairro c, public.bairro b, public.logradouro l,
  119 + public.municipio m, public.uf u, urbano.tipo_logradouro t
  120 + WHERE
  121 + c.idlog = l.idlog AND
  122 + c.idbai = b.idbai AND
  123 + l.idmun = b.idmun AND
  124 + l.idmun = m.idmun AND
  125 + l.idtlog = t.idtlog AND
  126 + m.sigla_uf = u.sigla_uf';
  127 + $params = array();
  128 + if (isset($_GET['nr_cep']))
  129 + $params['c.cep'] = idFederal2int($_GET['nr_cep']);
  130 + if (isset($_GET['nm_bairro']))
  131 + $params['b.nome'] = $_GET['nm_bairro'];
  132 + if (isset($_GET['nm_logradouro']))
  133 + $params['l.nome'] = $_GET['nm_logradouro'];
  134 + if (isset($_GET['ref_sigla_uf']))
  135 + $params['u.sigla_uf'] = $_GET['ref_sigla_uf'];
  136 + if (isset($_GET['cidade']))
  137 + $params['m.nome'] = $_GET['cidade'];
  138 + $paramCount = 1;
  139 + foreach ($params as $name => $value) {
  140 + $select .= " AND $name ILIKE '%'||\$$paramCount||'%'";
  141 + $paramCount++;
  142 + }
  143 + $total = Portabilis_Utils_Database::selectField(' SELECT COUNT(0) '.$select, array('params' => array_values($params)));
  144 + $select .= sprintf(' LIMIT %s OFFSET %s', $limite, $iniciolimit);
  145 + $result = Portabilis_Utils_Database::fetchPreparedQuery($pre_select.$select, array('params' => array_values($params)));
  146 +
  147 + foreach ($result as $record) {
  148 + list($idlog, $cep, $idbai, $uf, $cidade, $tipoLogradouroId, $id_mun, $zona, $descricao) = $record;
  149 + $cidade = addslashes($cidade);
  150 + $logradouro = new clsLogradouro($idlog);
  151 + $logradouro = $logradouro->detalhe();
  152 + $logradouro = addslashes($logradouro['nome']);
  153 + $bairro = new clsBairro($idbai);
  154 + $bairro = $bairro->detalhe();
  155 + $bairro = addslashes($bairro['nome']);
  156 + $cep2 = int2CEP($cep);
  157 + $s_end = '0';
  158 + $url = sprintf(
  159 + '<a href="javascript:void(0);" onclick="cv_set_campo(\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\');liberaCampos();parent.fixUpPlaceholderEndereco();">%%s</a>',
  160 + $_SESSION['campo1'], $bairro.' / Zona'.$zona, $_SESSION['campo2'],
  161 + $idbai, $_SESSION['campo3'], $cep,
  162 + $_SESSION['campo4'], $descricao." ".$logradouro,
  163 + $_SESSION['campo5'], $idlog,
  164 + '', '', '', '',
  165 + '', '', '', '',
  166 + $_SESSION['campo10'], $cep2, $_SESSION['campo11'], $id_mun.' - '.$cidade.' ('.$uf.')',
  167 + $_SESSION['campo12'], $_SESSION['campo13'], $id_mun,
  168 + '', ''
  169 + );
  170 + $this->addLinhas(array(
  171 + sprintf($url, $bairro),
  172 + sprintf($url, $cep2),
  173 + sprintf($url, $logradouro),
  174 + sprintf($url, $uf),
  175 + sprintf($url, $cidade)
  176 + ));
  177 + }
  178 + $this->largura = '100%';
  179 + $this->addPaginador2('educar_pesquisa_cep_log_bairro.php', $total, $_GET,
  180 + $this->nome, $limite);
  181 +
  182 +/*
  183 + if ($_GET['param']) {
  184 + $this->rodape = '
  185 + <table border="0" cellspacing="0" cellpadding="0" width="100%" align="center">
  186 + <tr width="100%">
  187 + <td>
  188 + <div align="center">[ <a href="javascript:void(0);" onclick="liberaCamposOuvidoria()">Cadastrar Novo Endereço</a> ]</div>
  189 + </td>
  190 + </tr>
  191 + </table>';
  192 + }
  193 + else {
  194 + $this->rodape = sprintf('
  195 + <table border="0" cellspacing="0" cellpadding="0" width="100%%" align="center">
  196 + <tr width="100%%">
  197 + <td>
  198 + <div align="center">[ <a href="javascript:void(0);" onclick="%s">Cadastrar Novo Endereço</a> ]</div>
  199 + </td>
  200 + </tr>
  201 + </table>',
  202 + $this->funcao_js
  203 + );
  204 + }*/
  205 + @session_write_close();
  206 + }
  207 +}
  208 +// Instancia objeto de página
  209 +$pagina = new clsIndex();
  210 +// Instancia objeto de conteúdo
  211 +$miolo = new miolo1();
  212 +// Atribui o conteúdo à página
  213 +$pagina->addForm($miolo);
  214 +// Gera o código HTML
  215 +$pagina->MakeAll();
  216 +?>
  217 +<script type="text/javascript">
  218 +function setFiltro()
  219 +{
  220 + alert('filtro');
  221 +}
  222 +// Função específica para ouvidoria
  223 +function setaCamposOuvidoria(valor1, valor2, valor3, valor4, valor5, valor6,
  224 + valor7, valor8, valor9, valor10, valor11, valor12)
  225 +{
  226 + // Campo oculto flag atualiza
  227 + parent.document.getElementById('atualiza').value = 'false';
  228 + parent.document.getElementById('nendereco').value = 'false';
  229 + // Campo oculto cep
  230 + obj1 = parent.document.getElementById('cep');
  231 + obj1.value = valor1;
  232 + // Campo visível cep
  233 + obj2 = parent.document.getElementById('cep_');
  234 + obj2.value = valor2;
  235 + obj2.disabled = true;
  236 + // Campo oculto sigla_uf
  237 + obj3 = parent.document.getElementById('sigla_uf');
  238 + obj3.value = valor3;
  239 + // Campo visível sigla_uf
  240 + obj4 = parent.document.getElementById('sigla_uf_');
  241 + obj4.value = valor4;
  242 + obj4.disabled = true;
  243 + // Campo oculto cidade
  244 + obj5 = parent.document.getElementById('cidade');
  245 + obj5.value = valor5;
  246 + // Campo visível cidade
  247 + obj6 = parent.document.getElementById('cidade_');
  248 + obj6.value = valor6;
  249 + obj6.disabled = true;
  250 + // Campo oculto nmCidade
  251 + obj14 = parent.document.getElementById('nmCidade');
  252 + obj14.value = valor6;
  253 + // Campo oculto Bairro
  254 + obj7 = parent.document.getElementById('idbai');
  255 + obj7.value = valor7;
  256 + // Campo visível Bairro
  257 + obj8 = parent.document.getElementById('bairro_');
  258 + obj8.value = valor8;
  259 + obj8.disabled = true;
  260 + obj13 = parent.document.getElementById('bairro');
  261 + obj13.value = valor8;
  262 + // Campo oculto idtlog ("tipo logradouro")
  263 + obj9 = parent.document.getElementById('idtlog');
  264 + obj9.value = valor9;
  265 + // Campo visível idtlog_ ("tipo logradouro")
  266 + obj10 = parent.document.getElementById('idtlog_');
  267 + obj10.value = valor10;
  268 + obj10.disabled = true;
  269 + // Campo oculto logradouro
  270 + obj11 = parent.document.getElementById('idlog');
  271 + obj11.value = valor11;
  272 + // Campo visível logradouro
  273 + obj12 = parent.document.getElementById('logradouro_');
  274 + obj12.value = valor12;
  275 + obj12.disabled = true;
  276 + obj14 = parent.document.getElementById('logradouro');
  277 + obj14.value = valor12;
  278 + window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1));
  279 +}
  280 +function liberaCamposOuvidoria()
  281 +{
  282 + parent.document.getElementById('atualiza').value = 'false';
  283 + parent.document.getElementById('nendereco').value = 'true';
  284 + // Campo oculto cep
  285 + obj1 = parent.document.getElementById('cep');
  286 + obj1.value = null;
  287 + // Campo visível cep
  288 + obj2 = parent.document.getElementById('cep_');
  289 + obj2.value = null;
  290 + obj2.disabled = false;
  291 + // Campo oculto sigla_uf
  292 + obj3 = parent.document.getElementById('sigla_uf');
  293 + obj3.value = null;
  294 + // Campo visível sigla_uf
  295 + obj4 = parent.document.getElementById('sigla_uf_');
  296 + obj4.value = null;
  297 + obj4.disabled = false;
  298 + // Campo oculto cidade
  299 + obj5 = parent.document.getElementById('cidade');
  300 + obj5.value = null;
  301 + // Campo visível cidade
  302 + obj6 = parent.document.getElementById('cidade_');
  303 + obj6.value = null;
  304 + obj6.disabled = false;
  305 + // Campo oculto bairro
  306 + obj7 = parent.document.getElementById('idbai');
  307 + obj7.value = null;
  308 + // Campo visível bairro
  309 + obj8 = parent.document.getElementById('bairro_');
  310 + obj8.value = null;
  311 + obj8.disabled = false;
  312 + obj13 = parent.document.getElementById('bairro');
  313 + obj13.value = null;
  314 + // Campo oculto idtlog ("tipo logradouro")
  315 + obj9 = parent.document.getElementById('idtlog');
  316 + obj9.value = null;
  317 + // Campo visível itlog_ ("tipo logradouro")
  318 + obj10 = parent.document.getElementById('idtlog_');
  319 + obj10.value = null;
  320 + obj10.disabled = false;
  321 + // Campo oculto logradouro
  322 + obj11 = parent.document.getElementById('idlog');
  323 + obj11.value = null;
  324 + // Campo visível logradouro_
  325 + obj12 = parent.document.getElementById('logradouro_');
  326 + obj12.value = null;
  327 + obj12.disabled = false;
  328 + obj14 = parent.document.getElementById('logradouro');
  329 + obj14.value = null;
  330 + window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1));
  331 +}
  332 +function liberaCampos(){
  333 +
  334 + parent.document.getElementById('municipio_municipio').disabled = false;
  335 + parent.document.getElementById('bairro_bairro').disabled = false;
  336 + parent.document.getElementById('logradouro_logradouro').disabled = false;
  337 + parent.document.getElementById('logradouro').disabled = false;
  338 + parent.document.getElementById('bairro').disabled = false;
  339 + parent.document.getElementById('idtlog').disabled = false;
  340 + parent.document.getElementById('zona_localizacao').disabled = false;
  341 + parent.document.getElementById('logradouro').value = '';
  342 + parent.document.getElementById('bairro').value = '';
  343 + parent.document.getElementById('idtlog').value = '';
  344 + parent.document.getElementById('zona_localizacao').value = '';
  345 +}
  346 +</script>
0 347 \ No newline at end of file
... ...
ieducar/intranet/include/pessoa/clsBairro.inc.php
... ... @@ -41,6 +41,7 @@ class clsBairro
41 41 var $operacao;
42 42 var $idsis_cad;
43 43 var $idsis_rev;
  44 + var $zona_localizacao;
44 45  
45 46 var $tabela;
46 47 var $schema = "public";
... ... @@ -50,7 +51,7 @@ class clsBairro
50 51 *
51 52 * @return Object:clsBairro
52 53 */
53   - function clsBairro( $int_idbai = false, $int_idmun=false, $str_geom=false, $str_nome=false , $int_idpes_cad = false, $int_idpes_rev = false, $str_origem_gravacao = false, $str_operacao=false, $int_idsis_cad=false, $int_idsis_rev=false )
  54 + function clsBairro( $int_idbai = false, $int_idmun=false, $str_geom=false, $str_nome=false , $int_idpes_cad = false, $int_idpes_rev = false, $str_origem_gravacao = false, $str_operacao=false, $int_idsis_cad=false, $int_idsis_rev=false, $zona_localizacao = null )
54 55 {
55 56 $this->idbai = $int_idbai;
56 57  
... ... @@ -70,6 +71,7 @@ class clsBairro
70 71 $this->idsis_rev = $int_idsis_rev;
71 72 $this->operacao = $str_operacao;
72 73 $this->origem_gravacao = $str_origem_gravacao;
  74 + $this->zona_localizacao = $zona_localizacao;
73 75  
74 76 $this->tabela = "bairro";
75 77 }
... ... @@ -113,9 +115,14 @@ class clsBairro
113 115 $campos .= ", origem_gravacao";
114 116 $values .= ", '{$this->origem_gravacao}'";
115 117 }
116   - $db->Consulta( "INSERT INTO {$this->schema}.{$this->tabela} ( idmun, nome, data_cad$campos ) VALUES ( '{$this->idmun}', '{$this->nome}', NOW()$values )" );
  118 + if( is_numeric( $this->zona_localizacao) )
  119 + {
  120 + $campos .= ", zona_localizacao";
  121 + $values .= ", '{$this->zona_localizacao}' ";
  122 + }
  123 + $db->Consulta( "INSERT INTO {$this->schema}.{$this->tabela} ( idmun, origem_gravacao, operacao, idsis_cad, nome, data_cad$campos ) VALUES ( '{$this->idmun}', 'U', 'I', '9', '{$this->nome}', NOW()$values )" );
117 124  
118   - return true;
  125 + return $db->InsertId("{$this->schema}.seq_bairro");
119 126 }
120 127 return false;
121 128 }
... ...
ieducar/intranet/include/pessoa/clsCepLogradouro.inc.php
... ... @@ -82,7 +82,7 @@ class clsCepLogradouro
82 82 $valores .= ", '$this->nrofin' ";
83 83 }
84 84  
85   - $db->Consulta( "INSERT INTO {$this->schema}.{$this->tabela} (cep, idlog $campos) VALUES ( '{$this->cep}', '{$this->idlog}' $values )" );
  85 + $db->Consulta( "INSERT INTO {$this->schema}.{$this->tabela} (cep, idlog, origem_gravacao, data_cad, operacao, idsis_Cad $campos) VALUES ( '{$this->cep}', '{$this->idlog}','U', NOW(), 'I', '9' $values )" );
86 86  
87 87 }
88 88 return false;
... ... @@ -130,7 +130,23 @@ class clsCepLogradouro
130 130 }
131 131 return false;
132 132 }
133   -
  133 +
  134 + /**
  135 + * Retorna um array com os dados de um registro.
  136 + * @return array
  137 + */
  138 + function existe()
  139 + {
  140 + if (is_numeric($this->cep) && is_numeric($this->idlog)) {
  141 + $db = new clsBanco();
  142 + $db->Consulta("SELECT 1 FROM {$this->schema}.{$this->tabela} WHERE cep = '{$this->cep}' AND idlog = '{$this->idlog}' ");
  143 + $db->ProximoRegistro();
  144 + return $db->Tupla();
  145 + }
  146 +
  147 + return FALSE;
  148 + }
  149 +
134 150 /**
135 151 * Remove o registro atual
136 152 *
... ... @@ -184,7 +200,7 @@ class clsCepLogradouro
184 200 $limit = "";
185 201 if(is_numeric($int_limite_ini) && is_numeric($int_limite_qtd))
186 202 {
187   - $limit = " LIMIT $int_limite_ini,$int_limite_qtd";
  203 + $limit = " LIMIT $int_limite_qtd OFFSET $int_limite_ini";
188 204 }
189 205  
190 206 $db = new clsBanco();
... ...
ieducar/intranet/include/pessoa/clsCepLogradouroBairro.inc.php
... ... @@ -76,7 +76,7 @@ class clsCepLogradouroBairro
76 76 // verificacoes de campos obrigatorios para insercao
77 77 if( is_numeric($this->idlog) && is_numeric($this->cep) && is_numeric($this->idbai))
78 78 {
79   - $db->Consulta( "INSERT INTO {$this->schema}.{$this->tabela} ($campos) VALUES ($values)" );
  79 + $db->Consulta( "INSERT INTO {$this->schema}.{$this->tabela} (cep,idlog,idbai, origem_gravacao, data_cad, operacao, idsis_cad ) VALUES ('{$this->cep}', '{$this->idlog}', '{$this->idbai}', 'U', NOW(), 'I', '9' )" );
80 80  
81 81 }
82 82 return false;
... ... @@ -198,5 +198,21 @@ class clsCepLogradouroBairro
198 198 }
199 199 return false;
200 200 }
  201 +
  202 + /**
  203 + * Retorna um array com os dados de um registro.
  204 + * @return array
  205 + */
  206 + function existe()
  207 + {
  208 + if (is_numeric($this->cep) && is_numeric($this->idlog) && is_numeric($this->idbai)) {
  209 + $db = new clsBanco();
  210 + $db->Consulta("SELECT 1 FROM {$this->schema}.{$this->tabela} WHERE cep = '{$this->cep}' AND idlog = '{$this->idlog}' AND idbai = '{$this->idbai}' ");
  211 + $db->ProximoRegistro();
  212 + return $db->Tupla();
  213 + }
  214 +
  215 + return FALSE;
  216 + }
201 217 }
202 218 ?>
203 219 \ No newline at end of file
... ...
ieducar/intranet/include/pessoa/clsEnderecoPessoa.inc.php
... ... @@ -346,11 +346,11 @@ class clsPessoaEndereco
346 346 $cep = $tupla['cep'];
347 347  
348 348 $tupla['cep'] = new clsCepLogradouro($cep, $tupla['idlog']);
349   - $tupla['idlog'] = new clsCepLogradouro($cep, $tupla['idlog']);
  349 + #$tupla['idlog'] = new clsCepLogradouro($cep, $tupla['idlog']);
350 350  
351   - $tupla['idbai'] = new clsPublicBairro(NULL, NULL, $tupla['idbai']);
  351 + #$tupla['idbai'] = new clsPublicBairro(NULL, NULL, $tupla['idbai']);
352 352  
353   - $bairro = $tupla['idbai']->detalhe();
  353 + #$bairro = $tupla['idbai']->detalhe();
354 354  
355 355 $tupla['zona_localizacao'] = $bairro['zona_localizacao'];
356 356  
... ...
ieducar/intranet/include/pessoa/clsLogradouro.inc.php
... ... @@ -32,9 +32,10 @@ class clsLogradouro
32 32 var $idlog;
33 33 var $idtlog;
34 34 var $nome;
35   - var $idnum;
  35 + var $idmun;
36 36 var $geom;
37 37 var $ident_oficial;
  38 + var $idpes_cad;
38 39  
39 40 var $tabela;
40 41 var $schema = "public";
... ... @@ -44,7 +45,7 @@ class clsLogradouro
44 45 *
45 46 * @return Object:clsLogradouro
46 47 */
47   - function clsLogradouro( $int_idlog = false, $str_idtlog=false, $str_nome=false, $int_idnum=false, $str_geom=false, $str_ident_oficial=false )
  48 + function clsLogradouro( $int_idlog = false, $str_idtlog=false, $str_nome=false, $int_idmun=false, $str_geom=false, $str_ident_oficial=false, $idpes_cad = null)
48 49 {
49 50 $this->idlog = $int_idlog;
50 51  
... ... @@ -55,9 +56,10 @@ class clsLogradouro
55 56 }
56 57  
57 58 $this->nome = $str_nome;
58   - $this->idnum = $int_idnum;
  59 + $this->idmun = $int_idmun;
59 60 $this->geom = $str_geom;
60 61 $this->ident_oficial = $str_ident_oficial;
  62 + $this->idpes_cad = $idpes_cad;
61 63  
62 64 $this->tabela = "logradouro";
63 65 }
... ... @@ -71,7 +73,7 @@ class clsLogradouro
71 73 {
72 74 $db = new clsBanco();
73 75 // verificacoes de campos obrigatorios para insercao
74   - if( is_string( $this->idtlog ) && is_string( $this->nome ) && is_numeric( $this->idnum ) && is_string($this->ident_oficial) )
  76 + if( is_string( $this->idtlog ) && is_string( $this->nome ) && is_numeric( $this->idmun ) && is_string($this->ident_oficial) )
75 77 {
76 78 $campos = "";
77 79 $values = "";
... ... @@ -82,9 +84,15 @@ class clsLogradouro
82 84 $values .= ", '{$this->geom}'";
83 85 }
84 86  
85   - $db->Consulta( "INSERT INTO {$this->schema}.{$this->tabela} ( idtlog, nome, idnum, ident_oficial$campos ) VALUES ( '{$this->idtlog}', '{$this->nome}', '{$this->idnum}'$values )" );
86   -
87   - return true;
  87 + if( is_string( $this->idpes_cad ) )
  88 + {
  89 + $campos .= ", idpes_cad";
  90 + $values .= ", '{$this->idpes_cad}'";
  91 + }
  92 +
  93 + $db->Consulta( "INSERT INTO {$this->schema}.{$this->tabela} ( idtlog, nome, idmun, origem_gravacao, ident_oficial,data_cad, OPERACAO, idsis_cad$campos ) VALUES ( '{$this->idtlog}', '{$this->nome}', '{$this->idmun}', 'U', '{$this->ident_oficial}', NOW(), 'I', '9' $values )" );
  94 +
  95 + return $db->InsertId("{$this->schema}.seq_logradouro");
88 96 }
89 97 return false;
90 98 }
... ... @@ -97,9 +105,9 @@ class clsLogradouro
97 105 function edita()
98 106 {
99 107 // verifica campos obrigatorios para edicao
100   - if( is_numeric( $this->idlog ) && is_string( $this->idtlog ) && is_string( $this->nome ) && is_numeric( $this->idnum ) && is_string($this->ident_oficial) )
  108 + if( is_numeric( $this->idlog ) && is_string( $this->idtlog ) && is_string( $this->nome ) && is_numeric( $this->idmun ) && is_string($this->ident_oficial) )
101 109 {
102   - $set = "SET idtlog = '{$this->idtlog}', nome = '{$this->nome}', idnum = '{$this->idnum}', ident_oficial = '{$this->ident_oficial}'";
  110 + $set = "SET idtlog = '{$this->idtlog}', nome = '{$this->nome}', idmun = '{$this->idmun}', ident_oficial = '{$this->ident_oficial}'";
103 111  
104 112 if( is_string( $this->geom ) )
105 113 {
... ... @@ -172,79 +180,6 @@ class clsLogradouro
172 180 $where .= "{$whereAnd}fcn_upper_nrm( nome ) ILIKE '%$str_nome%'";
173 181 $whereAnd = " AND ";
174 182 }
175   - if( is_numeric( $int_idnum ) )
176   - {
177   - $where .= "{$whereAnd}idmun = '$int_idnum'";
178   - $whereAnd = " AND ";
179   - }
180   - if( is_string( $str_geom ) )
181   - {
182   - $where .= "{$whereAnd}geom LIKE '%$str_geom%'";
183   - $whereAnd = " AND ";
184   - }
185   -
186   - if( is_string( $str_ident_oficial ) )
187   - {
188   - $where .= "{$whereAnd}ident_oficial LIKE '%$str_ident_oficial%'";
189   - $whereAnd = " AND ";
190   - }
191   -
192   - if($str_orderBy)
193   - {
194   - $orderBy = "ORDER BY $str_orderBy";
195   - }
196   -
197   - $limit = "";
198   - if( is_numeric( $int_limite_ini ) && is_numeric( $int_limite_qtd ) )
199   - {
200   - $limit = " LIMIT $int_limite_qtd OFFSET $int_limite_ini";
201   - }
202   -
203   - $db = new clsBanco();
204   - $db->Consulta( "SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} $where" );
205   - $db->ProximoRegistro();
206   - $total = $db->Campo( "total" );
207   -
208   - $db->Consulta( "SELECT idlog, idtlog, nome, idmun, geom, ident_oficial FROM {$this->schema}.{$this->tabela} $where $orderBy $limit" );
209   - $resultado = array();
210   - while ( $db->ProximoRegistro() )
211   - {
212   - $tupla = $db->Tupla();
213   - $tupla["idtlog"] = new clsTipoLogradouro( $tupla["idtlog"] );
214   -
215   - $tupla["total"] = $total;
216   - $resultado[] = $tupla;
217   - }
218   - if( count( $resultado ) )
219   - {
220   - return $resultado;
221   - }
222   - return false;
223   - }
224   -/**
225   - * Exibe uma lista baseada nos parametros de filtragem passados incluindo id municipio
226   - *
227   - * @return Array
228   - */
229   - function listamun( $str_idtlog=false, $str_nome=false, $int_idnum=false, $int_idmun=false, $str_geom=false, $str_ident_oficial=false, $int_limite_ini=0, $int_limite_qtd=20, $str_orderBy = false )
230   - {
231   - // verificacoes de filtros a serem usados
232   - $whereAnd = "WHERE ";
233   - if( is_string( $str_idtlog ) )
234   - {
235   - $where .= "{$whereAnd}idtlog LIKE '%$str_idtlog%'";
236   - $whereAnd = " AND ";
237   - }
238   - if( is_string( $str_nome ) )
239   - {
240   - $where .= "{$whereAnd}nome LIKE '%$str_nome%'";
241   - $whereAnd = " AND ";
242   - }
243   - if( is_numeric( $int_idnum ) )
244   - {
245   - $where .= "{$whereAnd}idnum = '$int_idnum'";
246   - $whereAnd = " AND ";
247   - }
248 183 if( is_numeric( $int_idmun ) )
249 184 {
250 185 $where .= "{$whereAnd}idmun = '$int_idmun'";
... ... @@ -270,14 +205,14 @@ class clsLogradouro
270 205 $limit = "";
271 206 if( is_numeric( $int_limite_ini ) && is_numeric( $int_limite_qtd ) )
272 207 {
273   - $limit = " LIMIT $int_limite_ini,$int_limite_qtd";
  208 + $limit = " LIMIT $int_limite_qtd OFFSET $int_limite_ini";
274 209 }
275 210  
276 211 $db = new clsBanco();
277 212 $db->Consulta( "SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} $where" );
278 213 $db->ProximoRegistro();
279 214 $total = $db->Campo( "total" );
280   -
  215 +
281 216 $db->Consulta( "SELECT idlog, idtlog, nome, idmun, geom, ident_oficial FROM {$this->schema}.{$this->tabela} $where $orderBy $limit" );
282 217 $resultado = array();
283 218 while ( $db->ProximoRegistro() )
... ... @@ -293,7 +228,7 @@ class clsLogradouro
293 228 return $resultado;
294 229 }
295 230 return false;
296   - }
  231 + }
297 232 /**
298 233 * Retorna um array com os detalhes do objeto
299 234 *
... ... @@ -311,7 +246,7 @@ class clsLogradouro
311 246 $this->idlog = $tupla["idlog"];
312 247 $this->idtlog = $tupla["idtlog"];
313 248 $this->nome = $tupla["nome"];
314   - $this->idnum = $tupla["idnum"];
  249 + $this->idmun = $tupla["idmun"];
315 250 $this->geom = $tupla["geom"];
316 251 $this->ident_oficial = $tupla["ident_oficial"];
317 252  
... ...
ieducar/intranet/scripts/padrao.js
... ... @@ -734,50 +734,66 @@ function cv_set_campo(campo1, valor1, campo2, valor2, campo3, valor3, campo4,
734 734 valor9, campo10, valor10, campo11, valor11, campo12, campo13, valor13,
735 735 campo14, valor14)
736 736 {
737   - obj1 = parent.document.getElementById(campo1);
738   - obj1.value = valor1;
739   - obj1.disabled = true;
  737 + obj1 = parent.document.getElementById(campo1);
  738 + if (obj1){
  739 + obj1.value = valor1;
  740 + }
740 741  
741   - obj2 = parent.document.getElementById(campo2);
742   - obj2.value = valor2;
  742 + obj2 = parent.document.getElementById(campo2);
  743 + if (obj2){
  744 + obj2.value = valor2;
  745 + }
743 746  
744   - obj3 = parent.document.getElementById(campo3);
745   - obj3.value = valor3;
  747 + obj3 = parent.document.getElementById(campo3);
  748 + if (obj3){
  749 + obj3.value = valor3;
  750 + }
746 751  
747   - obj4 = parent.document.getElementById(campo4);
748   - obj4.value = valor4;
749   - obj4.disabled = true;
  752 + obj4 = parent.document.getElementById(campo4);
  753 + if (obj4){
  754 + obj4.value = valor4;
  755 + }
750 756  
751   - obj5 = parent.document.getElementById(campo5);
752   - obj5.value = valor5;
  757 + obj5 = parent.document.getElementById(campo5);
  758 + if (obj5){
  759 + obj5.value = valor5;
  760 + }
753 761  
754   - obj6 = parent.document.getElementById(campo6);
755   - obj6.value = valor6;
  762 + obj6 = parent.document.getElementById(campo6);
  763 + if (obj6){
  764 + obj6.value = valor6;
  765 + }
756 766  
757   - obj7 = parent.document.getElementById(campo7);
758   - obj7.value = valor7;
759   - obj7.disabled = true;
  767 + obj7 = parent.document.getElementById(campo7);
  768 + if (obj7){
  769 + obj7.value = valor7;
  770 + }
760 771  
761   - obj8 = parent.document.getElementById(campo8);
762   - obj8.value = valor8;
  772 + obj8 = parent.document.getElementById(campo8);
  773 + if (obj8){
  774 + obj8.value = valor8;
  775 + }
763 776  
764 777 obj9 = parent.document.getElementById(campo9);
765   -
766 778 if (obj9) {
767 779 obj9.value = valor9;
768 780 }
769 781  
770   - obj10 = parent.document.getElementById(campo10);
771   - obj10.value = valor10;
772   - obj10.disabled = true;
  782 + obj10 = parent.document.getElementById(campo10);
  783 + if (obj10){
  784 + obj10.value = valor10;
  785 + }
773 786  
774   - obj11 = parent.document.getElementById(campo11);
775   - obj11.value = valor11;
776   - obj11.disabled = true;
  787 + obj11 = parent.document.getElementById(campo11);
  788 + if (obj11) {
  789 + obj11.value = valor11;
  790 + }
777 791  
778   - obj12 = parent.document.getElementById(campo12);
779   - obj12.value = valor8;
780   - obj12.disabled = true;
  792 + obj12 = parent.document.getElementById(campo12);
  793 + if (obj12) {
  794 + obj12.value = valor8;
  795 + obj12.disabled = true;
  796 + }
781 797  
782 798 if (parent.document.getElementById(campo13)) {
783 799 obj13 = parent.document.getElementById(campo13);
... ...
ieducar/intranet/templates/nvp_htmlloginintranet.tpl
... ... @@ -98,8 +98,6 @@
98 98 <tr>
99 99 <td>
100 100 <p class="forget-password"><a class="light small" href="/module/Usuario/RedefinirSenha">Esqueceu sua senha?</a></p>
101   -
102   - <p><a target="_blank" class="light small" href="http://educacao.portabilis.com.br/">Acesso professores, pais e alunos.</a> <a target="_blank" class="decorated light small" href="http://www.portabilis.com.br/produto/educacao-19#destaques">Saiba mais</a>
103 101 </p>
104 102 </td>
105 103 </tr>
... ...
ieducar/lib/Core/Controller/Page/ViewController.php
... ... @@ -31,7 +31,7 @@
31 31 require_once 'Core/View/Tabulable.php';
32 32 require_once 'include/clsDetalhe.inc.php';
33 33 require_once 'CoreExt/View/Helper/UrlHelper.php';
34   -//require_once 'Portabilis/View/Helper/Application.php';
  34 +require_once 'Portabilis/View/Helper/Application.php';
35 35  
36 36 /**
37 37 * Core_Controller_Page_ViewController abstract class.
... ...
ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchBairro.php 0 → 100644
... ... @@ -0,0 +1,71 @@
  1 +<?php
  2 +#error_reporting(E_ALL);
  3 +#ini_set("display_errors", 1);
  4 +/**
  5 + * i-Educar - Sistema de gestão escolar
  6 + *
  7 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  8 + * <ctima@itajai.sc.gov.br>
  9 + *
  10 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  11 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  12 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  13 + * qualquer versão posterior.
  14 + *
  15 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  16 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  17 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  18 + * do GNU para mais detalhes.
  19 + *
  20 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  21 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  22 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  23 + *
  24 + * @author Lucas Schmoeller da Silva <lucas@portabilis.com.br>
  25 + * @category i-Educar
  26 + * @license @@license@@
  27 + * @package Portabilis
  28 + * @since Arquivo disponível desde a versão ?
  29 + * @version $Id$
  30 + */
  31 +require_once 'lib/Portabilis/View/Helper/Input/SimpleSearch.php';
  32 +require_once 'lib/Portabilis/Utils/Database.php';
  33 +require_once 'lib/Portabilis/String/Utils.php';
  34 +/**
  35 + * Portabilis_View_Helper_Input_SimpleSearchBairro class.
  36 + *
  37 + * @author Lucas Schmoeller da Silva <lucasdavila@portabilis.com.br>
  38 + * @category i-Educar
  39 + * @license @@license@@
  40 + * @package Portabilis
  41 + * @since Classe disponível desde a versão ?
  42 + * @version @@package_version@@
  43 + */
  44 +class Portabilis_View_Helper_Input_Resource_SimpleSearchBairro extends Portabilis_View_Helper_Input_SimpleSearch {
  45 + public function simpleSearchBairro($attrName, $options = array()) {
  46 + $defaultOptions = array('objectName' => 'bairro',
  47 + 'apiController' => 'Bairro',
  48 + 'apiResource' => 'bairro-search',
  49 + 'showIdOnValue' => false);
  50 + $options = $this->mergeOptions($options, $defaultOptions);
  51 + parent::simpleSearch($options['objectName'], $attrName, $options);
  52 + }
  53 + protected function resourceValue($id) {
  54 + if ($id) {
  55 + $sql = "select nome, zona_localizacao from public.bairro where idbai = $1";
  56 + $options = array('params' => $id, 'return_only' => 'first-row');
  57 + $municipio = Portabilis_Utils_Database::fetchPreparedQuery($sql, $options);
  58 + $nome = $municipio['nome'];
  59 + $zona = ($municipio['zona_localizacao'] == 1 ? 'Urbana' : 'Rural');
  60 + return Portabilis_String_Utils::toLatin1($nome, array('transform' => true, 'escape' => false)) . " / Zona $zona";
  61 + }
  62 + }
  63 + protected function inputPlaceholder($inputOptions) {
  64 + return 'Informe o nome do bairro';
  65 + }
  66 +
  67 + protected function loadAssets() {
  68 + $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/Resource/SimpleSearchBairro.js';
  69 + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile);
  70 + }
  71 +}
0 72 \ No newline at end of file
... ...
ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchLogradouro.php 0 → 100644
... ... @@ -0,0 +1,74 @@
  1 +<?php
  2 +#error_reporting(E_ALL);
  3 +#ini_set("display_errors", 1);
  4 +/**
  5 + * i-Educar - Sistema de gestão escolar
  6 + *
  7 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  8 + * <ctima@itajai.sc.gov.br>
  9 + *
  10 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  11 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  12 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  13 + * qualquer versão posterior.
  14 + *
  15 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  16 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  17 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  18 + * do GNU para mais detalhes.
  19 + *
  20 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  21 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  22 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  23 + *
  24 + * @author Lucas Schmoeller da Silva <lucas@portabilis.com.br>
  25 + * @category i-Educar
  26 + * @license @@license@@
  27 + * @package Portabilis
  28 + * @since Arquivo disponível desde a versão ?
  29 + * @version $Id$
  30 + */
  31 +require_once 'lib/Portabilis/View/Helper/Input/SimpleSearch.php';
  32 +require_once 'lib/Portabilis/Utils/Database.php';
  33 +require_once 'lib/Portabilis/String/Utils.php';
  34 +/**
  35 + * Portabilis_View_Helper_Input_SimpleSearchLogradouro class.
  36 + *
  37 + * @author Lucas Schmoeller da Silva <lucasdavila@portabilis.com.br>
  38 + * @category i-Educar
  39 + * @license @@license@@
  40 + * @package Portabilis
  41 + * @since Classe disponível desde a versão ?
  42 + * @version @@package_version@@
  43 + */
  44 +class Portabilis_View_Helper_Input_Resource_SimpleSearchLogradouro extends Portabilis_View_Helper_Input_SimpleSearch {
  45 + public function simpleSearchLogradouro($attrName, $options = array()) {
  46 + $defaultOptions = array('objectName' => 'logradouro',
  47 + 'apiController' => 'Logradouro',
  48 + 'apiResource' => 'logradouro-search',
  49 + 'showIdOnValue' => false);
  50 + $options = $this->mergeOptions($options, $defaultOptions);
  51 + parent::simpleSearch($options['objectName'], $attrName, $options);
  52 + }
  53 +
  54 + protected function resourceValue($id) {
  55 + if ($id) {
  56 + $sql = "select nome, descricao as tipo_logradouro from
  57 + public.logradouro l left join urbano.tipo_logradouro tl on (l.idtlog = tl.idtlog)
  58 + where idlog = $1";
  59 + $options = array('params' => $id, 'return_only' => 'first-row');
  60 + $resource = Portabilis_Utils_Database::fetchPreparedQuery($sql, $options);
  61 + $tipo = Portabilis_String_Utils::toUtf8($resource['tipo_logradouro']);
  62 + $nome = Portabilis_String_Utils::toUtf8($resource['nome']);
  63 +
  64 + return Portabilis_String_Utils::toLatin1($tipo.' '.$nome, array('transform' => true, 'escape' => false));
  65 + }
  66 + }
  67 + protected function inputPlaceholder($inputOptions) {
  68 + return 'Informe o nome do logradouro';
  69 + }
  70 + protected function loadAssets() {
  71 + $jsFile = '/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/Resource/SimpleSearchLogradouro.js';
  72 + Portabilis_View_Helper_Application::loadJavascript($this->viewInstance, $jsFile);
  73 + }
  74 +}
0 75 \ No newline at end of file
... ...
ieducar/lib/Portabilis/View/Helper/Input/SimpleSearch.php
... ... @@ -56,7 +56,8 @@ class Portabilis_View_Helper_Input_SimpleSearch extends Portabilis_View_Helper_I
56 56 'apiResource' => $objectName . '-search',
57 57 'searchPath' => '',
58 58 'addHiddenInput' => true,
59   - 'hiddenInputOptions' => array());
  59 + 'hiddenInputOptions' => array(),
  60 + 'showIdOnValue' => true);
60 61  
61 62 $options = $this->mergeOptions($options, $defaultOptions);
62 63  
... ... @@ -68,8 +69,12 @@ class Portabilis_View_Helper_Input_SimpleSearch extends Portabilis_View_Helper_I
68 69 // load value if received an resource id
69 70 $resourceId = $options['hiddenInputOptions']['options']['value'];
70 71  
71   - if ($resourceId && ! $options['options']['value'])
72   - $options['options']['value'] = $resourceId . " - ". $this->resourceValue($resourceId);
  72 + if ($resourceId && ! $options['options']['value']){
  73 + if ($options['showIdOnValue'])
  74 + $options['options']['value'] = $resourceId . " - ". $this->resourceValue($resourceId);
  75 + else
  76 + $options['options']['value'] = $this->resourceValue($resourceId);
  77 + }
73 78  
74 79 $this->hiddenInput($objectName, $attrName, $options);
75 80 $this->textInput($objectName, $attrName, $options);
... ...
ieducar/lib/Portabilis/View/Helper/Inputs.php
... ... @@ -201,6 +201,18 @@ class Portabilis_View_Helper_Inputs {
201 201  
202 202 }
203 203  
  204 + public function simpleSearchBairro($attrName, $inputOptions = array(), $helperOptions = array()) {
  205 +
  206 + $this->simpleSearchResourceInput('simpleSearchBairro', $attrName, $inputOptions, $helperOptions);
  207 +
  208 + }
  209 +
  210 + public function simpleSearchLogradouro($attrName, $inputOptions = array(), $helperOptions = array()) {
  211 +
  212 + $this->simpleSearchResourceInput('simpleSearchLogradouro', $attrName, $inputOptions, $helperOptions);
  213 +
  214 + }
  215 +
204 216 // multiple search resource input helper
205 217  
206 218  
... ...
ieducar/misc/database/deltas/portabilis/75_adiciona_coluna_secao_area_conhecimento.sql 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 + -- //
  2 +
  3 + --
  4 + -- Adiciona coluna seção a área de conhecimento
  5 + --
  6 + -- @author Lucas Schmoeller da Silva <lucas@portabilis.com.br>
  7 + -- @license @@license@@
  8 + -- @version $Id$
  9 +
  10 + ALTER TABLE modules.area_conhecimento ADD COLUMN secao CHARACTER VARYING(50);
  11 +
  12 + -- //@UNDO
  13 +
  14 + ALTER TABLE modules.area_conhecimento DROP COLUMN secao;
  15 +
  16 + -- //
0 17 \ No newline at end of file
... ...
ieducar/misc/database/migrations/20151201161741_coluna_secao_area_conhecimento.php 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +<?php
  2 +
  3 +use Phinx\Migration\AbstractMigration;
  4 +
  5 +class ColunaSecaoAreaConhecimento extends AbstractMigration
  6 +{
  7 + public function up()
  8 + {
  9 + $count = $this->execute("ALTER TABLE modules.area_conhecimento ADD COLUMN secao CHARACTER VARYING(50);");
  10 + }
  11 +
  12 + public function down()
  13 + {
  14 + $count = $this->execute("ALTER TABLE modules.area_conhecimento DROP COLUMN secao;");
  15 + }
  16 +}
... ...
ieducar/modules/Api/Views/BairroController.php 0 → 100644
... ... @@ -0,0 +1,62 @@
  1 +<?php
  2 +/**
  3 + * i-Educar - Sistema de gestão escolar
  4 + *
  5 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  6 + * <ctima@itajai.sc.gov.br>
  7 + *
  8 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  9 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  10 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  11 + * qualquer versão posterior.
  12 + *
  13 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  14 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  15 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  16 + * do GNU para mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  19 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  20 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  21 + *
  22 + * @author Lucas Schmoeller da Silva <lucas@portabilis.com.br>
  23 + * @category i-Educar
  24 + * @license @@license@@
  25 + * @package Api
  26 + * @subpackage Modules
  27 + * @since Arquivo disponível desde a versão ?
  28 + * @version $Id$
  29 + */
  30 +require_once 'lib/Portabilis/Controller/ApiCoreController.php';
  31 +require_once 'lib/Portabilis/Array/Utils.php';
  32 +require_once 'intranet/include/clsBanco.inc.php';
  33 +class BairroController extends ApiCoreController
  34 +{
  35 + protected function searchOptions() {
  36 + $municipioId = $this->getRequest()->municipio_id ? $this->getRequest()->municipio_id : 0;
  37 + return array('sqlParams' => array($municipioId), 'selectFields' => array('zona_localizacao'));
  38 +
  39 + }
  40 + protected function formatResourceValue($resource) {
  41 + $zona = $resource['zona_localizacao'] == 1 ? 'Urbana' : 'Rural';
  42 + $nome = $this->toUtf8($resource['name'], array('transform' => true));
  43 + return "$nome / Zona $zona ";
  44 + }
  45 + protected function sqlsForNumericSearch() {
  46 +
  47 + $sqls[] = "select idbai as id, nome as name, zona_localizacao from
  48 + public.bairro where idbai like $1||'%' and idmun = $2 ";
  49 + return $sqls;
  50 + }
  51 + protected function sqlsForStringSearch() {
  52 + $sqls[] = "select idbai as id, nome as name, zona_localizacao from
  53 + public.bairro where lower(to_ascii(nome)) like '%'||lower(to_ascii($1))||'%' and idmun = $2 ";
  54 + return $sqls;
  55 + }
  56 + public function Gerar() {
  57 + if ($this->isRequestFor('get', 'bairro-search'))
  58 + $this->appendResponse($this->search());
  59 + else
  60 + $this->notImplementedOperationError();
  61 + }
  62 +}
0 63 \ No newline at end of file
... ...
ieducar/modules/Api/Views/EnderecoController.php 0 → 100644
... ... @@ -0,0 +1,75 @@
  1 +<?php
  2 +/**
  3 + * i-Educar - Sistema de gestão escolar
  4 + *
  5 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  6 + * <ctima@itajai.sc.gov.br>
  7 + *
  8 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  9 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  10 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  11 + * qualquer versão posterior.
  12 + *
  13 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  14 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  15 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  16 + * do GNU para mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  19 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  20 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  21 + *
  22 + * @author Lucas Schmoeller da Silva <lucas@portabilis.com.br>
  23 + * @category i-Educar
  24 + * @license @@license@@
  25 + * @package Api
  26 + * @subpackage Modules
  27 + * @since Arquivo disponível desde a versão ?
  28 + * @version $Id$
  29 + */
  30 +require_once 'lib/Portabilis/Controller/ApiCoreController.php';
  31 +require_once 'lib/Portabilis/Array/Utils.php';
  32 +require_once 'lib/Portabilis/String/Utils.php';
  33 +require_once 'intranet/include/clsBanco.inc.php';
  34 +require_once 'intranet/include/funcoes.inc.php';
  35 +class EnderecoController extends ApiCoreController
  36 +{
  37 + protected function getPrimeiroEnderecoCep() {
  38 +
  39 + $cep = idFederal2int($this->getRequest()->cep);
  40 +
  41 + // consulta dados
  42 + $select = "
  43 + SELECT
  44 + c.idlog, c.cep, c.idbai, b.nome as nome_bairro, l.nome as nome_logradouro, u.sigla_uf, m.nome, t.idtlog, t.descricao as tipo_logradouro, m.idmun, b.zona_localizacao
  45 +
  46 + FROM
  47 + urbano.cep_logradouro_bairro c, public.bairro b, public.logradouro l,
  48 + public.municipio m, public.uf u, urbano.tipo_logradouro t
  49 + WHERE
  50 + c.idlog = l.idlog AND
  51 + c.idbai = b.idbai AND
  52 + l.idmun = b.idmun AND
  53 + l.idmun = m.idmun AND
  54 + l.idtlog = t.idtlog AND
  55 + m.sigla_uf = u.sigla_uf AND
  56 + c.cep = {$cep} LIMIT 1";
  57 +
  58 + $result = Portabilis_Utils_Database::fetchPreparedQuery($select, array('return_only' => 'first-line'));
  59 + $return;
  60 + if (is_array($result)){
  61 + $return = array();
  62 + foreach ($result as $name => $value) {
  63 + $return[$name] = Portabilis_String_Utils::toUtf8($value);
  64 + }
  65 + }
  66 +
  67 + return $return;
  68 + }
  69 + public function Gerar() {
  70 + if ($this->isRequestFor('get', 'primeiro_endereco_cep'))
  71 + $this->appendResponse($this->getPrimeiroEnderecoCep());
  72 + else
  73 + $this->notImplementedOperationError();
  74 + }
  75 +}
0 76 \ No newline at end of file
... ...
ieducar/modules/Api/Views/LogradouroController.php 0 → 100644
... ... @@ -0,0 +1,65 @@
  1 +<?php
  2 +/**
  3 + * i-Educar - Sistema de gestão escolar
  4 + *
  5 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  6 + * <ctima@itajai.sc.gov.br>
  7 + *
  8 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  9 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  10 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  11 + * qualquer versão posterior.
  12 + *
  13 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  14 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  15 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  16 + * do GNU para mais detalhes.
  17 + *
  18 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  19 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  20 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  21 + *
  22 + * @author Lucas Schmoeller da Silva <lucas@portabilis.com.br>
  23 + * @category i-Educar
  24 + * @license @@license@@
  25 + * @package Api
  26 + * @subpackage Modules
  27 + * @since Arquivo disponível desde a versão ?
  28 + * @version $Id$
  29 + */
  30 +require_once 'lib/Portabilis/Controller/ApiCoreController.php';
  31 +require_once 'lib/Portabilis/Array/Utils.php';
  32 +require_once 'intranet/include/clsBanco.inc.php';
  33 +class LogradouroController extends ApiCoreController
  34 +{
  35 + protected function searchOptions() {
  36 + $municipioId = $this->getRequest()->municipio_id ? $this->getRequest()->municipio_id : 0;
  37 + return array('sqlParams' => array($municipioId), 'selectFields' => array('tipo_logradouro'));
  38 +
  39 + }
  40 + protected function sqlsForNumericSearch() {
  41 + $sqls[] = "select distinct idlog as id, nome as name, descricao as tipo_logradouro from
  42 + public.logradouro l left join urbano.tipo_logradouro tl on (l.idtlog = tl.idtlog)
  43 + where idlog like $1||'%' and idmun = $2 ";
  44 + return $sqls;
  45 + }
  46 + protected function sqlsForStringSearch() {
  47 + $sqls[] = "select distinct idlog as id, nome as name, descricao as tipo_logradouro from
  48 + public.logradouro l left join urbano.tipo_logradouro tl on (l.idtlog = tl.idtlog)
  49 + where (lower(to_ascii(nome)) like '%'||lower(to_ascii($1))||'%'
  50 + OR lower(to_ascii(descricao))|| ' ' ||lower(to_ascii(nome)) like '%'||lower(to_ascii($1))||'%')
  51 + and idmun = $2 ";
  52 + return $sqls;
  53 + }
  54 + protected function formatResourceValue($resource) {
  55 + $tipo = $resource['tipo_logradouro'];
  56 + $nome = $this->toUtf8($resource['name'], array('transform' => true));
  57 + return "$tipo $nome";
  58 + }
  59 + public function Gerar() {
  60 + if ($this->isRequestFor('get', 'logradouro-search'))
  61 + $this->appendResponse($this->search());
  62 + else
  63 + $this->notImplementedOperationError();
  64 + }
  65 +}
0 66 \ No newline at end of file
... ...
ieducar/modules/AreaConhecimento/Model/Area.php
... ... @@ -48,6 +48,7 @@ class AreaConhecimento_Model_Area extends CoreExt_Entity
48 48 protected $_data = array(
49 49 'instituicao' => NULL,
50 50 'nome' => NULL,
  51 + 'secao' => NULL
51 52 );
52 53  
53 54 public function getDefaultValidatorCollection()
... ... @@ -56,7 +57,8 @@ class AreaConhecimento_Model_Area extends CoreExt_Entity
56 57  
57 58 return array(
58 59 'instituicao' => new CoreExt_Validate_Choice(array('choices' => $instituicoes)),
59   - 'nome' => new CoreExt_Validate_String(array('min' => 5, 'max' => 60))
  60 + 'nome' => new CoreExt_Validate_String(array('min' => 5, 'max' => 60)),
  61 + 'secao' => new CoreExt_Validate_String(array('min' => 0, 'max' => 50))
60 62 );
61 63 }
62 64  
... ...
ieducar/modules/AreaConhecimento/Views/EditController.php
... ... @@ -61,12 +61,17 @@ class EditController extends Core_Controller_Page_EditController
61 61 'label' => 'Nome',
62 62 'help' => 'O nome da área de conhecimento. Exemplo: "<em>Ciências da natureza</em>".',
63 63 'entity' => 'nome'
  64 + ),
  65 + 'secao' => array(
  66 + 'label' => 'Seção',
  67 + 'help' => 'A seção que abrange a área de conhecimento. Exemplo: "<em>Lógico Matemático</em>".',
  68 + 'entity' => 'secao'
64 69 )
65 70 );
66 71  
67 72 protected function _preRender()
68 73 {
69   - parent::_preRender();
  74 + parent::_preRender();
70 75  
71 76 Portabilis_View_Helper_Application::loadStylesheet($this, 'intranet/styles/localizacaoSistema.css');
72 77  
... ... @@ -75,10 +80,10 @@ class EditController extends Core_Controller_Page_EditController
75 80 $localizacao->entradaCaminhos( array(
76 81 $_SERVER['SERVER_NAME']."/intranet" => "In&iacute;cio",
77 82 "educar_index.php" => "i-Educar - Escola",
78   - "" => "$nomeMenu &aacute;rea de conhecimento"
  83 + "" => "$nomeMenu &aacute;rea de conhecimento"
79 84 ));
80   - $this->enviaLocalizacao($localizacao->montar());
81   - }
  85 + $this->enviaLocalizacao($localizacao->montar());
  86 + }
82 87  
83 88 /**
84 89 * @see clsCadastro#Gerar()
... ... @@ -95,5 +100,9 @@ class EditController extends Core_Controller_Page_EditController
95 100 // Nome
96 101 $this->campoTexto('nome', $this->_getLabel('nome'), $this->getEntity()->nome,
97 102 60, 60, TRUE, FALSE, FALSE, $this->_getHelp('nome'));
  103 +
  104 + // Seção
  105 + $this->campoTexto('secao', $this->_getLabel('secao'), $this->getEntity()->secao,
  106 + 50, 50, FALSE, FALSE, FALSE, $this->_getHelp('secao'));
98 107 }
99 108 }
100 109 \ No newline at end of file
... ...
ieducar/modules/AreaConhecimento/Views/IndexController.php
... ... @@ -49,7 +49,8 @@ class IndexController extends Core_Controller_Page_ListController
49 49 protected $_titulo = 'Listagem de áreas de conhecimento';
50 50 protected $_processoAp = 945;
51 51 protected $_tableMap = array(
52   - 'Nome' => 'nome'
  52 + 'Nome' => 'nome',
  53 + 'Seção' => 'secao'
53 54 );
54 55  
55 56 protected function _preRender(){
... ... @@ -63,8 +64,8 @@ class IndexController extends Core_Controller_Page_ListController
63 64 $localizacao->entradaCaminhos( array(
64 65 $_SERVER['SERVER_NAME']."/intranet" => "In&iacute;cio",
65 66 "educar_index.php" => "i-Educar - Escola",
66   - "" => "Listagem de &aacute;reas de conhecimento"
  67 + "" => "Listagem de &aacute;reas de conhecimento"
67 68 ));
68   - $this->enviaLocalizacao($localizacao->montar());
69   - }
  69 + $this->enviaLocalizacao($localizacao->montar());
  70 + }
70 71 }
71 72 \ No newline at end of file
... ...
ieducar/modules/AreaConhecimento/Views/ViewController.php
... ... @@ -49,7 +49,8 @@ class ViewController extends Core_Controller_Page_ViewController
49 49 protected $_titulo = 'Detalhes de área de conhecimento';
50 50 protected $_processoAp = 945;
51 51 protected $_tableMap = array(
52   - 'Nome' => 'nome'
  52 + 'Nome' => 'nome',
  53 + 'Seção' => 'secao'
53 54 );
54 55  
55 56  
... ... @@ -64,8 +65,8 @@ class ViewController extends Core_Controller_Page_ViewController
64 65 $localizacao->entradaCaminhos( array(
65 66 $_SERVER['SERVER_NAME']."/intranet" => "In&iacute;cio",
66 67 "educar_index.php" => "i-Educar - Escola",
67   - "" => "Detalhe da &aacute;rea de conhecimento"
  68 + "" => "Detalhe da &aacute;rea de conhecimento"
68 69 ));
69   - $this->enviaLocalizacao($localizacao->montar());
70   - }
  70 + $this->enviaLocalizacao($localizacao->montar());
  71 + }
71 72 }
72 73 \ No newline at end of file
... ...
ieducar/modules/Cadastro/Assets/Javascripts/Endereco.js 0 → 100644
... ... @@ -0,0 +1,330 @@
  1 +// --------------------------------- SCRIPTS ENDEREÇAMENTO ---------------------------------------- //
  2 +
  3 + $j('<a>') .html('N&atilde;o sei meu CEP')
  4 + .attr('target', '_blank')
  5 + .css('color', 'blue')
  6 + .css('margin-left', '10px')
  7 + .attr('href', 'http://www.buscacep.correios.com.br/servicos/dnec/menuAction.do?Metodo=menuLogradouro')
  8 + .appendTo($j('#cep_').closest('td'));
  9 +
  10 +function hideEnderecoFields(){
  11 + if($j('#cep_').val()){
  12 +
  13 + if ($j('#bairro_id').val())
  14 + bloqueiaCadastroBairro();
  15 + else
  16 + bloqueiaBuscaBairro();
  17 +
  18 + if ($j('#logradouro_id').val())
  19 + bloqueiaCadastroLogradouro();
  20 + else
  21 + bloqueiaBuscaLogradouro();
  22 +
  23 + }else{
  24 +
  25 + $j('#bairro').closest('tr').hide();
  26 + $j('#logradouro').closest('tr').hide();
  27 + }
  28 +}
  29 +
  30 +function preenchaCampoCepPrimeiro(){
  31 + messageUtils.error('Digite um CEP primeiro...');
  32 +}
  33 +
  34 +
  35 +// Campo CEP
  36 +
  37 +var handleGetCep = function(dataResponse) {
  38 +
  39 + if (dataResponse['cep']){
  40 + $j('#municipio_id').val(dataResponse['idmun']);
  41 + $j('#municipio_municipio').val(dataResponse['idmun'] + ' - ' + dataResponse['nome'] + ' (' + dataResponse['sigla_uf'] + ')');
  42 + $j('#bairro_id').val(dataResponse['idbai']);
  43 + $j('#bairro_bairro').val(dataResponse['nome_bairro']+' / Zona '+(dataResponse['zona_localizacao'] == 1 ? 'Urbana' : 'Rural'));
  44 + $j('#logradouro_id').val(dataResponse['idlog']);
  45 + $j('#logradouro_logradouro').val(dataResponse['tipo_logradouro']+' '+dataResponse['nome_logradouro']);
  46 +
  47 + }else{
  48 + $j('#municipio_id').val('');
  49 + $j('#municipio_municipio').val('');
  50 + $j('#bairro_id').val('');
  51 + $j('#bairro_bairro').val('');
  52 + $j('#logradouro_id').val('');
  53 + $j('#logradouro_logradouro').val('');
  54 + }
  55 +
  56 + $j('#municipio_municipio').removeAttr('disabled');
  57 + $j('#bairro_bairro').removeAttr('disabled');
  58 + $j('#logradouro_logradouro').removeAttr('disabled');
  59 + $j('#bairro').removeAttr('disabled');
  60 + $j('#zona_localizacao').removeAttr('disabled');
  61 + $j('#idtlog').removeAttr('disabled');
  62 + $j('#logradouro').removeAttr('disabled');
  63 + bloqueiaCadastroBairro();
  64 + bloqueiaCadastroLogradouro();
  65 + fixUpPlaceholderEndereco();
  66 +}
  67 +
  68 +// Caso cep seja válido dispara ajax para recuperar dados do primeiro cep encontrado
  69 +var searchCep = function() {
  70 +
  71 + var cep = $j('#cep_').val();
  72 +
  73 + if (checkCepFields(cep)) {
  74 +
  75 + var additionalVars = {
  76 + cep : cep,
  77 + };
  78 +
  79 + var options = {
  80 + url : getResourceUrlBuilder.buildUrl('/module/Api/endereco', 'primeiro_endereco_cep', additionalVars),
  81 + dataType : 'json',
  82 + data : {},
  83 + success : handleGetCep
  84 + };
  85 +
  86 + getResource(options);
  87 + }else
  88 + clearEnderecoFields();
  89 +
  90 +}
  91 +// Ao digitar um cep inválido todos os campos de endereçamento são bloqueados e limpados
  92 +function clearEnderecoFields(){
  93 + $j('#bairro').attr('disabled','disabled');
  94 + $j('#zona_localizacao').attr('disabled','disabled');
  95 + $j('#bairro_bairro').attr('disabled','disabled');
  96 + $j('#logradouro_logradouro').attr('disabled','disabled');
  97 + $j('#idtlog').attr('disabled','disabled');
  98 + $j('#logradouro').attr('disabled','disabled');
  99 + $j('#municipio_municipio').attr('disabled','disabled');
  100 + $j('#bairro').val('');
  101 + $j('#zona_localizacao').val('');
  102 + $j('#bairro_bairro').val('');
  103 + $j('#logradouro_logradouro').val('');
  104 + $j('#idtlog').val('');
  105 + $j('#logradouro').val('');
  106 + $j('#bairro_id').val('');
  107 + $j('#logradouro_id').val('');
  108 + $j('#municipio_municipio').val('');
  109 + $j('#municipio_id').val('');
  110 +}
  111 +// Verifica se o formato do cep é válido
  112 +function checkCepFields(cep) {
  113 + var regexp = /[0-9]{5}\-[0-9]{3}/;
  114 + var valid = regexp.test(cep);
  115 + return valid;
  116 +}
  117 +
  118 +// Eventos que escondem//apagam campos não usados na alternância entre cadastro/busca
  119 +function bloqueiaCadastroBairro(){
  120 + if (checkCepFields($j('#cep_').val())){
  121 + $j('#bairro').closest('tr').hide();
  122 + $j('#bairro_bairro').closest('tr').show();
  123 + $j('#zona_localizacao').val('');
  124 + $j('#bairro').val('');
  125 + }
  126 + else
  127 + preenchaCampoCepPrimeiro();
  128 +}
  129 +
  130 +function bloqueiaBuscaBairro(){
  131 + if (checkCepFields($j('#cep_').val())){
  132 + $j('#bairro_bairro').closest('tr').hide();
  133 + $j('#bairro').closest('tr').show();
  134 + $j('#bairro').val($j('#bairro_bairro').val());
  135 + $j('#bairro_bairro').val('');
  136 + $j('#bairro_id').val('');
  137 + }
  138 + else
  139 + preenchaCampoCepPrimeiro();
  140 +}
  141 +
  142 +function bloqueiaCadastroLogradouro(){
  143 + if (checkCepFields($j('#cep_').val())){
  144 + $j('#idtlog').closest('tr').hide();
  145 + $j('#logradouro_logradouro').closest('tr').show();
  146 + $j('#idtlog').val('');
  147 + $j('#logradouro').val('');
  148 + }else
  149 + preenchaCampoCepPrimeiro();
  150 +}
  151 +
  152 +function bloqueiaBuscaLogradouro(){
  153 + if (checkCepFields($j('#cep_').val())){
  154 + $j('#logradouro_logradouro').closest('tr').hide();
  155 + $j('#idtlog').closest('tr').show();
  156 + $j('#logradouro').val($j('#logradouro_logradouro').val());
  157 + $j('#logradouro_logradouro').val('');
  158 + $j('#logradouro_id').val('');
  159 + }else{
  160 + preenchaCampoCepPrimeiro();
  161 + }
  162 +}
  163 +
  164 +// Dispara evento para buscar CEP quando o mesmo for preenchido sem utilizar a lupa
  165 +$j('#cep_').keyup(searchCep);
  166 +$j('#cep_').change(searchCep);
  167 +
  168 +// Limpa campos logradouro e bairro simpleSearch
  169 +function clearLogradouroAndBairroFields(){
  170 + $j('#logradouro_logradouro').val('');
  171 + $j('#logradouro_id').val('');
  172 + $j('#bairro_bairro').val('');
  173 + $j('#bairro_id').val('');
  174 +}
  175 +
  176 +// Adiciona links para Informar/Atualizar troca entre cadastro ou busca
  177 +function addLinksEnderecamento(){
  178 + $j('<span>') .html('ou cadastre um novo bairro')
  179 + .attr('id', 'span-busca-bairro')
  180 + .css('color','blue')
  181 + .css('margin-left','5px')
  182 + .css('cursor','pointer')
  183 + .addClass('decorated')
  184 + .appendTo($j('#bairro_bairro').closest('td'));
  185 +
  186 + $j('<span>').html('ou busque um bairro existente')
  187 + .attr('id', 'span-cad-bairro')
  188 + .css('color','blue')
  189 + .css('margin-left','5px')
  190 + .css('cursor','pointer')
  191 + .addClass('decorated')
  192 + .appendTo($j('#zona_localizacao').closest('td'));
  193 +
  194 + $j('<span>').html('ou cadastre um novo logradouro')
  195 + .attr('id', 'span-busca-logradouro')
  196 + .css('color','blue')
  197 + .css('margin-left','5px')
  198 + .css('cursor','pointer')
  199 + .addClass('decorated')
  200 + .appendTo($j('#logradouro_logradouro').closest('td'));
  201 +
  202 + $j('<span>').html('ou busque logradouro existente')
  203 + .attr('id', 'span-cad-logradouro')
  204 + .css('color','blue')
  205 + .css('margin-left','5px')
  206 + .css('cursor','pointer')
  207 + .addClass('decorated')
  208 + .appendTo($j('#idtlog').closest('td'));
  209 +}
  210 +
  211 +addLinksEnderecamento();
  212 +
  213 +function desativaAutoComplete(){
  214 +
  215 + $j('#logradouro').attr('autocomplete', 'off');
  216 + $j('#bairro').attr('autocomplete', 'off');
  217 + $j('#cep_').attr('autocomplete', 'off');
  218 +
  219 +}
  220 +
  221 +desativaAutoComplete();
  222 +
  223 +// Dispara evento para alterar entre Cadastro/Busca
  224 +$j('#span-busca-bairro').click(bloqueiaBuscaBairro);
  225 +$j('#span-cad-bairro').click(bloqueiaCadastroBairro);
  226 +$j('#span-busca-logradouro').click(bloqueiaBuscaLogradouro);
  227 +$j('#span-cad-logradouro').click(bloqueiaCadastroLogradouro);
  228 +
  229 +// Altera zebrado para não interferir quando for trocado entre cadastro/busca de bairro/logradouro
  230 +function alteraZebradoEnderacamento(){
  231 + if ($j('#bairro').closest('td').hasClass('formmdtd'))
  232 + $j('#bairro').closest('tr').find('td').toggleClass('formmdtd formlttd');
  233 + else
  234 + $j('#bairro').closest('tr').find('td').toggleClass('formlttd formmdtd');
  235 +
  236 + if ($j('#logradouro_logradouro').closest('td').hasClass('formmdtd'))
  237 + $j('#logradouro_logradouro').closest('tr').find('td').toggleClass('formmdtd formlttd');
  238 + else
  239 + $j('#logradouro_logradouro').closest('tr').find('td').toggleClass('formlttd formmdtd');
  240 +}
  241 +
  242 +alteraZebradoEnderacamento();
  243 +
  244 +// Correções para apagarem o valor do campo ID quando for deletado o valor do simpleSearch
  245 +$j('#municipio_municipio').keyup( function(){
  246 + if ($j('#municipio_municipio').val() == '')
  247 + $j('#municipio_id').val('').trigger('change');
  248 +});
  249 +
  250 +$j('#bairro_bairro').focusout( function(){
  251 + if ($j('#bairro_bairro').val() == '')
  252 + $j('#bairro_id').val('');
  253 +});
  254 +
  255 +$j('#logradouro_logradouro').focusout( function(){
  256 + if ($j('#logradouro_logradouro').val() == '')
  257 + $j('#logradouro_id').val('');
  258 +});
  259 +
  260 +/* Como os campos SimpleSearchBairro e SimpleSearchLogradouro dependem do valor do municipio_id,
  261 + quando o mesmo for alterado dispara um evento para apagar esses campos dependentes */
  262 +$j('#municipio_id').change(clearLogradouroAndBairroFields);
  263 +
  264 +function fixUpPlaceholderEndereco(){
  265 + $j('#municipio_municipio').attr('placeholder' , 'Digite o nome de um munic\u00edpio para buscar');
  266 + $j('#bairro_bairro').attr('placeholder' , 'Digite o nome de um bairro para buscar');
  267 + $j('#logradouro_logradouro').attr('placeholder' , 'Digite o nome de um logradouro para buscar');
  268 + $j('#bairro').attr('placeholder' , 'Digite o nome do novo bairro');
  269 + $j('#logradouro').attr('placeholder' , 'Digite o nome do novo logradouro');
  270 +}
  271 +
  272 +function validateEndereco(){
  273 +
  274 + var err = false;
  275 +
  276 + if (!$j('#municipio_id').val()){
  277 + $j('#municipio_municipio').addClass('error');
  278 + $j('#municipio_id').addClass('error');
  279 + messageUtils.error('Selecione um município corretamente');
  280 + err = true;
  281 + }
  282 +
  283 + if ($j('#logradouro_logradouro').closest('tr').is(':visible')){
  284 +
  285 + if (!$j('#logradouro_id').val()){
  286 + $j('#logradouro_logradouro').addClass('error');
  287 + $j('#logradouro_id').addClass('error');
  288 + messageUtils.error('Selecione um logradouro ou utilize a opção ao lado para cadastrar um novo.');
  289 + err = true;
  290 + }
  291 + }else{
  292 + if (!$j('#logradouro').val()){
  293 + $j('#logradouro').addClass('error');
  294 + messageUtils.error('Digite o nome do logradouro.');
  295 + err = true;
  296 + }
  297 + if (!$j('#idtlog').val()){
  298 + $j('#idtlog').addClass('error');
  299 + messageUtils.error('Selecione o tipo do logradouro.');
  300 + err = true;
  301 + }
  302 + }
  303 + if ($j('#bairro_bairro').closest('tr').is(':visible')){
  304 + if (!$j('#bairro_id').val()){
  305 + $j('#bairro_bairro').addClass('error');
  306 + $j('#bairro_id').addClass('error');
  307 + messageUtils.error('Selecione um bairro ou utilize a opção ao lado para cadastrar um novo.');
  308 + err = true;
  309 + }
  310 +
  311 + }else{
  312 +
  313 + if (!$j('#bairro').val()){
  314 + $j('#bairro').addClass('error');
  315 + messageUtils.error('Digite o nome do bairro.');
  316 + err = true;
  317 + }
  318 +
  319 + if (!$j('#zona_localizacao').val()){
  320 + $j('#zona_localizacao').addClass('error');
  321 + messageUtils.error('Selecione a zona de localização.');
  322 + err = true;
  323 + }
  324 + }
  325 +
  326 + return !err;
  327 +
  328 +}
  329 +
  330 +// --------------------------------- FIM SCRIPTS ENDEREÇAMENTO ---------------------------------------- //
0 331 \ No newline at end of file
... ...
ieducar/modules/Cadastro/Assets/Javascripts/PessoaFisica.js
1   -
2 1 // before page is ready
3 2  
4 3 function hrefToCreateParent(parentType) {
... ... @@ -164,6 +163,11 @@ var validatesUniquenessOfCpf = function() {
164 163  
165 164  
166 165 var submitForm = function(event) {
  166 + if ($j('#cep_').val()){
  167 + if (!validateEndereco()){
  168 + return;
  169 + }
  170 + }
167 171 if ($cpfField.val()) {
168 172 $j(document).data('submit_form_after_ajax_validation', true);
169 173 validatesUniquenessOfCpf();
... ... @@ -213,6 +217,9 @@ $j(document).ready(function() {
213 217 $submitButton.removeAttr('onclick');
214 218 $submitButton.click(submitForm);
215 219  
  220 + hideEnderecoFields();
  221 + fixUpPlaceholderEndereco();
  222 +
216 223 }); // ready
217 224  
218 225  
... ...
ieducar/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/Resource/SimpleSearchBairro.js 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +var simpleSearchBairroOptions = {
  2 +
  3 + params : {
  4 + municipio_id : function() {
  5 + return $j('#municipio_id').val()
  6 + }
  7 + },
  8 +
  9 + canSearch : function() {
  10 +
  11 + if (! $j('#municipio_id').val()) {
  12 + alert('Selecione um munic\u00edpio.');
  13 + return false;
  14 + }
  15 +
  16 + return true;
  17 + }
  18 +};
0 19 \ No newline at end of file
... ...
ieducar/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/Resource/SimpleSearchLogradouro.js 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +var simpleSearchLogradouroOptions = {
  2 +
  3 + params : {
  4 + municipio_id : function() {
  5 + return $j('#municipio_id').val()
  6 + }
  7 + },
  8 +
  9 + canSearch : function() {
  10 +
  11 + if (! $j('#municipio_id').val()) {
  12 + alert('Selecione um munic\u00edpio.');
  13 + return false;
  14 + }
  15 +
  16 + return true;
  17 + }
  18 +};
0 19 \ No newline at end of file
... ...
ieducar/modules/Portabilis/Assets/Version.php
... ... @@ -5,7 +5,7 @@
5 5  
6 6 class Portabilis_Assets_Version {
7 7  
8   - const VERSION = '11';
  8 + const VERSION = '12';
9 9  
10 10 }
11 11 ?>
... ...