Exemplo n.º 1
0
 function Gerar()
 {
     $this->campoOculto("id_item", $this->id_item);
     $lista = array();
     $lista[2] = "Intranet";
     $categoria = array();
     $db = new clsBanco();
     $db->Consulta("SELECT cod_menu_menu, nm_menu FROM menu_menu ORDER BY nm_menu ASC");
     while ($db->ProximoRegistro()) {
         $categoria[$db->Campo("cod_menu_menu")] = $db->Campo("nm_menu");
     }
     $this->campoLista("id_menupai", "Categoria", $categoria, $this->id_menupai);
     $this->campoLista("id_sistema", "Sistema", $lista, $this->id_sistema);
     $this->campoTexto("nome_", "Nome", $this->nome_, "50", "100", true);
     $this->campoTexto("arquivo", "Arquivo", $this->arquivo, "50", "100", true);
     $opcoes = array(1 => "Público", 2 => "Registrados", 3 => "Particular");
     $this->permissao = $this->permissao ? $this->permissao : '3';
     $this->campoLista("permissao", "Permissão", $opcoes, $this->permissao);
     $this->campoMemo("alt", "Descrição", $this->alt, "47", "2", false);
 }
Exemplo n.º 2
0
 function Gerar()
 {
     $this->titulo = "Agendas";
     $cod_agenda = @$_GET['cod_agenda'];
     $db = new clsBanco();
     $db2 = new clsBanco();
     $db->Consulta("SELECT cod_agenda, nm_agenda, publica, envia_alerta, ref_ref_cod_pessoa_cad, data_cad, ref_ref_cod_pessoa_own FROM portal.agenda WHERE cod_agenda = '{$cod_agenda}'");
     if ($db->ProximoRegistro()) {
         list($cod_agenda, $nm_agenda, $publica, $envia_alerta, $pessoa_cad, $data_cad, $pessoa_own) = $db->Tupla();
         $objPessoa = new clsPessoaFisica();
         list($nome) = $objPessoa->queryRapida($pessoa_cad, "nome");
         $objPessoa_ = new clsPessoaFisica();
         list($nm_pessoa_own) = $objPessoa_->queryRapida($pessoa_own, "nome");
         $this->addDetalhe(array("Código da Agenda", $cod_agenda));
         $this->addDetalhe(array("Agenda", $nm_agenda));
         $this->addDetalhe(array("Pública", $publica == 0 ? $publica = 'Não' : ($pubica = 'Sim')));
         $this->addDetalhe(array("Envia Alerta", $envia_alerta == 0 ? $envia_alerta = 'Não' : ($envia_alerta = 'Sim')));
         $this->addDetalhe(array("Quem Cadastrou", $nome));
         $this->addDetalhe(array("Data do Cadastro", date("d/m/Y H:m:s", strtotime(substr($data_cad, 0, 19)))));
         $this->addDetalhe(array("Dono da Agenda", $nm_pessoa_own));
         $editores = "";
         if ($nm_pessoa_own) {
             $editores .= "<b>{$nm_pessoa_own}</b><br>";
         }
         $edit_array = array();
         $db2->Consulta("SELECT ref_ref_cod_pessoa_fj FROM agenda_responsavel WHERE ref_cod_agenda = '{$cod_agenda}'");
         while ($db2->ProximoRegistro()) {
             list($nome) = $objPessoa->queryRapida($db2->Campo("ref_ref_cod_pessoa_fj"), "nome");
             $edit_array[] = $nome;
         }
         if (!count($edit_array)) {
             if (!$nm_pessoa_own) {
                 $editores .= "Nenhum editor cadastrado";
             }
         } else {
             asort($edit_array);
             reset($edit_array);
             $editores .= implode("<br>", $edit_array);
         }
         $this->addDetalhe(array("Editores autorizados", $editores));
     } else {
         $this->addDetalhe(array("Erro", "Codigo de agenda inválido"));
     }
     $this->url_editar = "agenda_admin_cad.php?cod_agenda={$cod_agenda}";
     $this->url_novo = "agenda_admin_cad.php";
     $this->url_cancelar = "agenda_admin_lst.php";
     $this->largura = "100%";
     $localizacao = new LocalizacaoSistema();
     $localizacao->entradaCaminhos(array($_SERVER['SERVER_NAME'] . "/intranet" => "In&iacute;cio", "" => "Detalhe da agenda"));
     $this->enviaLocalizacao($localizacao->montar());
 }
Exemplo n.º 3
0
 /**
  * Exibe uma lista baseada nos parametros de filtragem passados
  *
  * @return Array
  */
 function lista($int_rg = false, $str_data_exp_rg = false, $str_sigla_uf_exp_rg = false, $int_tipo_cert_civil = false, $int_num_termo = false, $int_num_livro = false, $int_num_folha = false, $str_data_emissao_cert_civil = false, $str_sigla_uf_cert_civil = false, $str_cartorio_cert_civil = false, $int_num_cart_trabalho = false, $int_serie_cart_trabalho = false, $str_data_emissao_cart_trabalho = false, $str_sigla_uf_cart_trabalho = false, $int_num_tit_eleitor = false, $int_zona_tit_eleitor = false, $int_secao_tit_eleitor = false, $int_idorg_exp_rg = false, $int_limite_ini = 0, $int_limite_qtd = 20, $str_orderBy = false, $int_idpes = false)
 {
     // verificacoes de filtros a serem usados
     $whereAnd = "WHERE ";
     if (is_string($int_idpes)) {
         $where .= "{$whereAnd}idpes IN ({$int_idpes})";
         $whereAnd = " AND ";
     }
     if (is_numeric($this->rg)) {
         $where .= "{$whereAnd}rg = '{$int_rg}'";
         $whereAnd = " AND ";
     }
     if (is_string($this->data_exp_rg)) {
         $where .= "{$whereAnd}data_exp_rg LIKE '%{$str_data_exp_rg}%'";
         $whereAnd = " AND ";
     }
     if (is_string($this->sigla_uf_exp_rg)) {
         $where .= "{$whereAnd}sigla_uf_exp_rg LIKE '%{$str_sigla_uf_exp_rg}%'";
         $whereAnd = " AND ";
     }
     if (is_string($this->tipo_cert_civil)) {
         $where .= "{$whereAnd}tipo_cert_civil LIKE '%{$str_tipo_cert_civil}%'";
         $whereAnd = " AND ";
     }
     if (is_numeric($this->num_termo)) {
         $where .= "{$whereAnd}num_termo = '{$int_num_termo}'";
         $whereAnd = " AND ";
     }
     if (is_string($this->num_livro)) {
         $where .= "{$whereAnd}num_livro = '{$int_num_livro}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($this->num_folha)) {
         $where .= "{$whereAnd}num_folha = '{$intnum_folha}'";
         $whereAnd = " AND ";
     }
     if (is_string($this->data_emissao_cert_civil)) {
         $where .= "{$whereAnd}data_emissao_cert_civil LIKE '{$str_data_emissao_cert_civil}'";
         $whereAnd = " AND ";
     }
     if (is_string($this->sigla_uf_cert_civil)) {
         $where .= "{$whereAnd}sigla_uf_cert_civil LIKE '{$str_sigla_uf_cert_civil}'";
         $whereAnd = " AND ";
     }
     if (is_string($this->cartorio_cert_civil)) {
         $where .= "{$whereAnd}cartorio_cert_civil LIKE '{$str_cartorio_cert_civil}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($this->num_cart_trabalho)) {
         $where .= "{$whereAnd}num_cart_trabalho = '{$int_num_cart_trabalho}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($this->serie_cart_trabalho)) {
         $where .= "{$whereAnd}serie_cart_trabalho = '{$int_serie_cart_trabalho}'";
         $whereAnd = " AND ";
     }
     if (is_string($this->data_emissao_cart_trabalho)) {
         $where .= "{$whereAnd}data_emissao_cart_trabalho LIKE '{$str_data_emissao_cart_trabalho}'";
         $whereAnd = " AND ";
     }
     if (is_string($this->sigla_uf_cart_trabalho)) {
         $where .= "{$whereAnd}sigla_uf_cart_trabalho LIKE '{$str_sigla_uf_cart_trabalho}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($this->num_tit_eleitor)) {
         $where .= "{$whereAnd}num_tit_eleitor = '{$int_num_tit_eleitor}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($this->zona_tit_eleitor)) {
         $where .= "{$whereAnd}zona_tit_eleitor = '{$int_zona_tit_eleitor}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($this->secao_tit_eleitor)) {
         $where .= "{$whereAnd}secao_tit_eleitor = '{$int_secao_tit_eleitor}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($this->idorg_exp_rg)) {
         $where .= "{$whereAnd}idorg_exp_rg = '{$int_idorg_exp_rg}'";
         $whereAnd = " AND ";
     }
     if ($str_orderBy) {
         $orderBy = "ORDER BY {$str_orderBy}";
     }
     $limit = "";
     if (is_numeric($int_limite_ini) && is_numeric($int_limite_qtd)) {
         $limit = " LIMIT {$int_limite_ini},{$int_limite_qtd}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo("total");
     $db->Consulta("SELECT * FROM {$this->schema}.{$this->tabela} {$where} {$orderBy} {$limit}");
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla["idpes"] = $tupla["idpes"];
         $tupla["idorg_exp_rg"] = $tupla["idorg_exp_rg"];
         $tupla["sigla_uf_cart_trabalho"] = $tupla["sigla_uf_cart_trabalho"];
         $tupla["sigla_uf_cert_civil"] = $tupla["sigla_uf_cert_civil"];
         $tupla["sigla_uf_exp_rg"] = $tupla["sigla_uf_exp_rg"];
         $tupla["total"] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado)) {
         return $resultado;
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  * Exibe uma lista baseada nos parametros de filtragem passados
  *
  * @return Array
  */
 function lista($int_idpes = false, $data_data_nasc = false, $str_sexo = false, $int_idpes_mae = false, $int_idpes_pai = false, $int_idpes_responsavel = false, $int_idesco = false, $int_ideciv = false, $int_idpes_con = false, $data_data_uniao = false, $data_data_obito = false, $int_nacionalidade = false, $int_idpais_estrangeiro = false, $data_data_chagada_brasil = false, $int_idmun_nascimento = false, $str_ultima_empresa = false, $int_idocup = false, $str_nome_mae = false, $str_nome_pai = false, $str_nome_conjuge = false, $str_nome_responsavel = false, $str_justificativa_provisorio = false, $str_ordenacao = false, $int_limite_ini = 0, $int_limite_qtd = 20, $arrayint_idisin = false, $arrayint_idnotin = false, $str_data_nasc_ini = false, $str_data_nasc_fim = false, $int_mes_aniversario = false, $int_ref_cod_sistema = false, $int_cpf = false)
 {
     // verificacoes de filtros a serem usados
     $whereAnd = "WHERE ";
     if (is_numeric($int_idpes)) {
         $where .= "{$whereAnd}idpes = '{$int_idpes}'";
         $whereAnd = " AND ";
     } elseif (is_string($int_idpes)) {
         $where .= "{$whereAnd}idpes IN ({$int_idpes})";
         $whereAnd = " AND ";
     }
     if (is_string($data_data_nasc)) {
         $where .= "{$whereAnd}data_nasc = '{$data_data_nasc}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_mes_aniversario)) {
         $where .= "{$whereAnd} EXTRACT (MONTH FROM data_nasc) = '{$int_mes_aniversario}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_sexo)) {
         $where .= "{$whereAnd}sexo = '{$str_sexo}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idpes_mae)) {
         $where .= "{$whereAnd}idpes_mae =  '{$int_idpes_mae}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idpes_pai)) {
         $where .= "{$whereAnd}idpes_pai =  '{$int_idpes_pai}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idpes_responsavel)) {
         $where .= "{$whereAnd}idpes_responsavel =  '{$int_idpes_responsavel}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idesco)) {
         $where .= "{$whereAnd}idesco =  '{$int_idesco}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_ideciv)) {
         $where .= "{$whereAnd}ideciv =  '{$int_ideciv}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idpes_con)) {
         $where .= "{$whereAnd}idpes_con =  '{$int_idpes_con}'";
         $whereAnd = " AND ";
     }
     if (is_string($data_data_uniao)) {
         $where .= "{$whereAnd}data_uniao =  '{$data_data}-uniao'";
         $whereAnd = " AND ";
     }
     if (is_string($data_data_obito)) {
         $where .= "{$whereAnd}data_obito =  '{$data_data_obito}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_nacionalidade)) {
         $where .= "{$whereAnd}nacionalidade =  '{$int_nacionalidade}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idpais_estrangeiro)) {
         $where .= "{$whereAnd}idpais_strangeiro =  '{$int_idpais_strangeiro}'";
         $whereAnd = " AND ";
     }
     if (is_string($data_data_chegada_brasil)) {
         $where .= "{$whereAnd}data_chegada_brasil =  '{$data_data_chegada_brasil}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idmun_nascimento)) {
         $where .= "{$whereAnd}idmun_nascimento =  '{$int_idmun_nascimento}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_ultima_empresa)) {
         $where .= "{$whereAnd}ultima_empresa =  '{$str_ultima_empresa}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idocup)) {
         $where .= "{$whereAnd}idocup = '{$int_idocup}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_nome_mae)) {
         $where .= "{$whereAnd}nome_mae = '{$str_nome_mae}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_nome_pai)) {
         $where .= "{$whereAnd}nome_pai = '{$str_nome_pai}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_nome_conjuge)) {
         $where .= "{$whereAnd}nome_conjuge = '{$str_nome_conjuge}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_nome_responsavel)) {
         $where .= "{$whereAnd}nome_responsavel = '{$str_nome_responsavel}'";
         $whereAnd = " AND ";
     }
     if (is_string($int_ref_cod_sistema)) {
         $where .= "{$whereAnd}ref_cod_sistema = '{$int_ref_cod_sistema}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_justificativa_provisorio)) {
         $where .= "{$whereAnd}justificativa_provisorio = '{$str_justificativa_provisorio}'";
     }
     $int_cpf = idFederal2int($int_cpf);
     if (is_numeric($int_cpf)) {
         $where .= "{$whereAnd}cpf like '%{$int_cpf}%'";
     }
     if (is_array($arrayint_idisin)) {
         $ok = true;
         foreach ($arrayint_idisin as $val) {
             if (!is_numeric($val)) {
                 $ok = false;
             }
         }
         if ($ok) {
             $where .= "{$whereAnd}idpes IN ( " . implode(",", $arrayint_idisin) . " )";
             $whereAnd = " AND ";
         }
     }
     if (is_array($arrayint_idnotin)) {
         $ok = true;
         foreach ($arrayint_idnotin as $val) {
             if (!is_numeric($val)) {
                 $ok = false;
             }
         }
         if ($ok) {
             $where .= "{$whereAnd}idpes NOT IN ( " . implode(",", $arrayint_idnotin) . " )";
             $whereAnd = " AND ";
         }
     }
     if (is_string($str_data_nasc_ini)) {
         $dia = substr($str_data_nasc_ini, 8, 2);
         $mes = substr($str_data_nasc_ini, 5, 2);
         $ano = substr($str_data_nasc_ini, 0, 4);
         $operador = $str_data_nasc_fim ? ">=" : "=";
         if ($dia != "" && $dia != "00") {
             $where .= "{$whereAnd}EXTRACT(DAY FROM data_nasc) {$operador} '{$dia}'";
             $whereAnd = " AND ";
         }
         if ($mes != "" && $mes != "00") {
             $where .= "{$whereAnd}EXTRACT(MONTH FROM data_nasc) {$operador} '{$mes}'";
             $whereAnd = " AND ";
         }
         if ($ano != "" && $ano != "0000") {
             $where .= "{$whereAnd}EXTRACT(YEAR FROM data_nasc) {$operador} '{$ano}'";
             $whereAnd = " AND ";
         }
     }
     if (is_string($str_data_nasc_fim)) {
         $dia = substr($str_data_nasc_fim, 8, 2);
         $mes = substr($str_data_nasc_fim, 5, 2);
         $ano = substr($str_data_nasc_fim, 0, 4);
         if ($dia != "" && $dia != "00") {
             $where .= "{$whereAnd}EXTRACT(DAY FROM data_nasc) <= '{$dia}'";
             $whereAnd = " AND ";
         }
         if ($mes != "" && $mes != "00") {
             $where .= "{$whereAnd}EXTRACT(MONTH FROM data_nasc) <= '{$mes}'";
             $whereAnd = " AND ";
         }
         if ($ano != "" && $ano != "0000") {
             $where .= "{$whereAnd}EXTRACT(YEAR FROM data_nasc) <= '{$ano}'";
             $whereAnd = " AND ";
         }
     }
     $orderBy = "";
     if (is_string($str_ordenacao)) {
         $orderBy = "ORDER BY {$str_ordenacao}";
     }
     $limit = "";
     if (is_numeric($int_limite_ini) && is_numeric($int_limite_qtd)) {
         $limit = " LIMIT {$int_limite_ini},{$int_limite_qtd}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo("total");
     $db->Consulta("SELECT idpes, data_nasc, sexo, idpes_mae, idpes_pai, idpes_responsavel, idesco, ideciv, idpes_con, data_uniao, data_obito, nacionalidade, idpais_estrangeiro, data_chegada_brasil, idmun_nascimento, ultima_empresa, idocup, nome_mae, nome_pai, nome_conjuge, nome_responsavel, justificativa_provisorio, ref_cod_religiao FROM {$this->schema}.{$this->tabela} {$where} {$orderBy} {$limit}");
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla["idesco"] = $tupla["idesco"];
         $tupla["ideciv"] = new clsEstadoCivil($tupla["ideciv"]);
         $tupla["idpais_estrangeiro"] = new clsPais($tupla["idpais_estrangeiro"]);
         $tupla["idmun_nascimento"] = new clsMunicipio($tupla["idmun_nascimento"]);
         $tupla["idocup"] = new clsOcupacao($tupla["idocup"]);
         $tupla["total"] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado)) {
         return $resultado;
     }
     return false;
 }
 function Novo()
 {
     $totais = array();
     $legenda = array();
     $dataInicio01 = "{$this->ano}/{$this->mes}/01 00:00:00";
     $dataInicio02 = "{$this->ano}/{$this->mes}/07 00:00:00";
     $dataInicio03 = "{$this->ano}/{$this->mes}/14 00:00:00";
     $dataInicio04 = "{$this->ano}/{$this->mes}/21 00:00:00";
     if ($this->mes < 12) {
         $dataInicio05 = $this->ano . "/" . ($this->mes + 1) . "/01 00:00:00";
     } else {
         $dataInicio05 = $this->ano + 1 . "/01/01 00:00:00";
     }
     $arr = array();
     $meses = array('', 'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
     // gera a lista de pecas utilizadas no intervalo de tempo definido
     $db1 = new clsBanco();
     $db1->Consulta("SELECT COUNT( ref_cod_mailling_email ) AS total FROM mailling_historico, mailling_grupo_email WHERE data_hora >= '{$dataInicio01}' AND data_hora <= '{$dataInicio02}' AND mailling_grupo_email.ref_cod_mailling_grupo = mailling_historico.ref_cod_mailling_grupo");
     $db1->ProximoRegistro();
     $semana1 = $db1->Campo("total");
     $arr["Semana 1"] = $semana1;
     $db2 = new clsBanco();
     $db2->Consulta("SELECT COUNT( ref_cod_mailling_email ) AS total FROM mailling_historico, mailling_grupo_email WHERE data_hora >= '{$dataInicio02}' AND data_hora <= '{$dataInicio03}' AND mailling_grupo_email.ref_cod_mailling_grupo = mailling_historico.ref_cod_mailling_grupo");
     $db2->ProximoRegistro();
     $semana2 = $db2->Campo("total");
     $arr["Semana 2"] = $semana2;
     $db3 = new clsBanco();
     $db3->Consulta("SELECT COUNT( ref_cod_mailling_email ) AS total FROM mailling_historico, mailling_grupo_email WHERE data_hora >= '{$dataInicio03}' AND data_hora <= '{$dataInicio04}' AND mailling_grupo_email.ref_cod_mailling_grupo = mailling_historico.ref_cod_mailling_grupo");
     $db3->ProximoRegistro();
     $semana3 = $db3->Campo("total");
     $arr["Semana 3"] = $semana3;
     $db4 = new clsBanco();
     $db4->Consulta("SELECT COUNT( ref_cod_mailling_email ) AS total FROM mailling_historico, mailling_grupo_email WHERE data_hora >= '{$dataInicio04}' AND data_hora <= '{$dataInicio05}' AND mailling_grupo_email.ref_cod_mailling_grupo = mailling_historico.ref_cod_mailling_grupo");
     $db4->ProximoRegistro();
     $semana4 = $db4->Campo("total");
     $arr["Semana 4"] = $semana4;
     if (count($arr)) {
         $titulo = "Gráfico de Mailling Semanal - {$meses[$this->mes]} de {$this->ano}";
         $grafico = new clsGrafico($arr, $titulo, 500);
         $grafico->setAlign("left");
         die($grafico->graficoBarraHor());
     } else {
         $this->campoRotulo("alerta", "Alerta", "Nenhum resultado foi encontrado com este filtro");
     }
     $this->largura = "100%";
     return true;
 }
Exemplo n.º 6
0
 /**
  * Exibe uma lista baseada nos parametros de filtragem passados incluindo id municipio
  *
  * @return Array
  */
 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)
 {
     // verificacoes de filtros a serem usados
     $whereAnd = "WHERE ";
     if (is_string($str_idtlog)) {
         $where .= "{$whereAnd}idtlog LIKE '%{$str_idtlog}%'";
         $whereAnd = " AND ";
     }
     if (is_string($str_nome)) {
         $where .= "{$whereAnd}nome LIKE '%{$str_nome}%'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idnum)) {
         $where .= "{$whereAnd}idnum = '{$int_idnum}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idmun)) {
         $where .= "{$whereAnd}idmun = '{$int_idmun}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_geom)) {
         $where .= "{$whereAnd}geom LIKE '%{$str_geom}%'";
         $whereAnd = " AND ";
     }
     if (is_string($str_ident_oficial)) {
         $where .= "{$whereAnd}ident_oficial LIKE '%{$str_ident_oficial}%'";
         $whereAnd = " AND ";
     }
     if ($str_orderBy) {
         $orderBy = "ORDER BY {$str_orderBy}";
     }
     $limit = "";
     if (is_numeric($int_limite_ini) && is_numeric($int_limite_qtd)) {
         $limit = " LIMIT {$int_limite_ini},{$int_limite_qtd}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo("total");
     $db->Consulta("SELECT idlog, idtlog, nome, idmun, geom, ident_oficial FROM {$this->schema}.{$this->tabela} {$where} {$orderBy} {$limit}");
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla["idtlog"] = new clsTipoLogradouro($tupla["idtlog"]);
         $tupla["total"] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado)) {
         return $resultado;
     }
     return false;
 }
Exemplo n.º 7
0
 /**
  * Retorna uma lista de registros filtrados de acordo com os parâmetros.
  * @return array
  */
 function lista($str_idtlog = FALSE, $str_logradouro = FALSE, $int_numero = FALSE, $str_letra = FALSE, $str_complemento = FALSE, $str_bairro = FALSE, $int_cep = FALSE, $str_cidade = FALSE, $sigla_uf = FALSE, $str_reside_desde = FALSE, $str_bloco = FALSE, $int_apartamento = FALSE, $int_andar = FALSE, $int_limite_ini = 0, $int_limite_qtd = 20, $str_orderBy = FALSE, $int_idpes = FALSE, $zona_localizacao = NULL)
 {
     $whereAnd = ' WHERE ';
     if (is_string($int_idpes)) {
         $where .= "{$whereAnd}idpes IN ({$int_idpes})";
         $whereAnd = ' AND ';
     }
     if (is_string($str_idtlog)) {
         $where .= "{$whereAnd}idtlog LIKE '%{$str_idtlog}%'";
         $whereAnd = ' AND ';
     }
     if (is_string($str_logradouro)) {
         $where .= "{$whereAnd}logradouro LIKE '%{$str_logradouro}%'";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_numero)) {
         $where .= "{$whereAnd}numero = '{$int_numero}'";
         $whereAnd = ' AND ';
     }
     if (is_string($str_letra)) {
         $where .= "{$whereAnd}letra LIKE '%{$str_letra}%'";
         $whereAnd = ' AND ';
     }
     if (is_string($str_complemento)) {
         $where .= "{$whereAnd}complemento LIKE '%{$str_complemento}%'";
         $whereAnd = ' AND ';
     }
     if (is_string($str_bairro)) {
         $where .= "{$whereAnd}bairro LIKE '%{$str_bairro}%'";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_cep)) {
         $where .= "{$whereAnd}cep = '{$int_cep}'";
         $whereAnd = ' AND ';
     }
     if (is_string($str_cidade)) {
         $where .= "{$whereAnd}cidade LIKE '%{$str_cidade}%'";
         $whereAnd = ' AND ';
     }
     if (is_string($sigla_uf)) {
         $where .= "{$whereAnd}sigla_uf LIKE '%{$sigla_uf}%'";
         $whereAnd = ' AND ';
     }
     if (is_string($str_reside_desde)) {
         $where .= "{$whereAnd}reside_desde LIKE '%{$str_reside_desde}%'";
         $whereAnd = ' AND ';
     }
     if (is_string($str_bloco)) {
         $where .= "{$whereAnd}bloco = '{$str_bloco}'";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_apartamento)) {
         $where .= "{$whereAnd}apartamento = '{$int_apartamento}'";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_andar)) {
         $where .= "{$whereAnd}andar = '{$int_andar}'";
         $whereAnd = ' AND ';
     }
     if (is_numeric($zona_localizacao)) {
         $where .= "{$whereAnd}zona_localizacao = '{$zona_localizacao}'";
         $whereAnd = ' AND ';
     }
     if ($str_orderBy) {
         $orderBy = "ORDER BY {$str_orderBy}";
     }
     $limit = '';
     if (is_numeric($int_limite_ini) && is_numeric($int_limite_qtd)) {
         $limit = " LIMIT {$int_limite_ini}, {$int_limite_qtd}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo('total');
     $sql = sprintf('SELECT idpes, tipo, idtlog, logradouro, numero, letra, complemento, ' . 'bairro, cep, cidade, sigla_uf, reside_desde, bloco, apartamento, ' . 'andar, zona_localizacao FROM %s.%s %s %s %s', $this->schema, $this->tabela, $where, $orderBy, $limit);
     $db->Consulta($sql);
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla['idpes'] = new clsPessoa_($tupla["idpes"]);
         $tupla['idtlog'] = new clsTipoLogradouro($tupla['idtlog']);
         $tupla['sigla_uf'] = new clsUf($tupla['sigla_uf']);
         $tupla['total'] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado)) {
         return $resultado;
     }
     return FALSE;
 }
Exemplo n.º 8
0
 /**
  * Exibe uma lista baseada nos parametros de filtragem passados
  *
  * @return Array
  */
 function lista($int_idmun = false, $str_geom = false, $str_nome = false, $int_limite_ini = false, $int_limite_qtd = false, $str_orderBy = false, $array_idbai_notin = false, $id_bairro = false)
 {
     // verificacoes de filtros a serem usados
     $whereAnd = "WHERE ";
     if (is_numeric($int_idmun)) {
         $where .= "{$whereAnd}idmun = '{$int_idmun}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_geom)) {
         $where .= "{$whereAnd}geom LIKE '%{$str_geom}%'";
         $whereAnd = " AND ";
     }
     if (is_string($str_nome)) {
         $where .= "{$whereAnd}nome LIKE '%{$str_nome}%'";
         $whereAnd = " AND ";
     }
     if (is_array($array_idbai_notin)) {
         $implode = implode(",", $array_idbai_notin);
         $where .= "{$whereAnd}idbai NOT IN ({$implode})";
         $whereAnd = " AND ";
     }
     if (is_numeric($id_bairro)) {
         $where .= "{$whereAnd}idbai = '{$id_bairro}'";
         $whereAnd = " AND ";
     }
     if ($str_orderBy) {
         $orderBy = "ORDER BY {$str_orderBy}";
     }
     $limit = "";
     if (is_numeric($int_limite_ini) && is_numeric($int_limite_qtd)) {
         $limit = " LIMIT {$int_limite_ini},{$int_limite_qtd}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo("total");
     $db->Consulta("SELECT idbai,idmun, geom, nome FROM {$this->schema}.{$this->tabela} {$where} {$orderBy} {$limit}");
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla["idmun"] = new clsMunicipio($tupla["idmun"]);
         $tupla["total"] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado)) {
         return $resultado;
     }
     return false;
 }
Exemplo n.º 9
0
 /**
  * Exibe uma lista baseada nos parametros de filtragem passados
  *
  * @return Array
  */
 function lista($int_cod_pessoa = false, $str_ip_interno = false, $str_ip_externo = false, $date_inicio = false, $date_fim = false, $str_obs = false, $str_order_by = "data_hora DESC", $int_limit_ini = 0, $int_limit_qtd = 20, $sucesso = null)
 {
     // verificacoes de filtros a serem usados
     $whereAnd = "WHERE ";
     $where = "";
     if (is_array($int_cod_pessoa)) {
         foreach ($int_cod_pessoa as $cod) {
             if ($cod) {
                 $where .= "{$whereAnd}cod_pessoa = '{$cod}'";
                 $whereAnd = " OR ";
             }
         }
     } elseif (is_numeric($int_cod_pessoa)) {
         $where .= "{$whereAnd}cod_pessoa = '{$int_cod_pessoa}'";
         $whereAnd = " AND ";
     }
     if ($whereAnd == " OR ") {
         $whereAnd = " AND ";
     }
     if (is_string($str_ip_interno)) {
         $where .= "{$whereAnd}ip_interno = '{$str_ip_interno}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_ip_externo)) {
         $where .= "{$whereAnd}ip_externo = '{$str_ip_externo}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_obs)) {
         $where .= "{$whereAnd}obs = '{$str_obs}'";
         $whereAnd = " AND ";
     }
     if (is_string($date_fim)) {
         $where .= "{$whereAnd}data_cadastro <= '{$date_fim}'";
         $whereAnd = " AND ";
     }
     if (is_string($date_inicio)) {
         $where .= "{$whereAnd}data_cadastro >= '{$date_inicio}'";
         $whereAnd = " AND ";
     }
     if (!is_null($sucesso)) {
         if ($sucesso) {
             $where .= "{$whereAnd}sucesso = 't'";
         } else {
             $where .= "{$whereAnd}sucesso = 'f'";
         }
         $whereAnd = " AND ";
     }
     $limit = "";
     if (is_numeric($int_limit_ini) && is_numeric($int_limit_qtd)) {
         $limit = "LIMIT {$int_limit_ini},{$int_limit_qtd}";
     }
     $orderBy = "";
     if (is_string($str_order_by)) {
         $orderBy = "ORDER BY {$str_order_by}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->tabela} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo("total");
     $db->Consulta("SELECT cod_acesso, ip_interno, ip_externo, data_hora, obs, cod_pessoa, sucesso FROM {$this->tabela} {$where} {$orderBy} {$limit}");
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla["total"] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado)) {
         return $resultado;
     }
     return false;
 }
Exemplo n.º 10
0
 /**
  * Retorna um array com os registros da tabela public.uf
  * @return array
  */
 public function lista($str_nome = FALSE, $str_geom = FALSE, $int_idpais = FALSE, $int_limite_ini = FALSE, $int_limite_qtd = FALSE, $str_orderBy = 'sigla_uf ASC')
 {
     $whereAnd = 'WHERE ';
     if (is_string($str_nome)) {
         $where .= "{$whereAnd}nome LIKE '%{$str_nome}%'";
         $whereAnd = ' AND ';
     }
     if (is_string($str_geom)) {
         $where .= "{$whereAnd}geom LIKE '%{$str_geom}%'";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_idpais)) {
         $where .= "{$whereAnd}idpais = '{$int_idpais}'";
         $whereAnd = ' AND ';
     } else {
         $idpais = $this->config->app->locale->country;
         $where .= "{$whereAnd}idpais = '{$idpais}'";
         $whereAnd = ' AND ';
     }
     if ($str_orderBy) {
         $orderBy = "ORDER BY {$str_orderBy}";
     }
     $limit = '';
     if (is_numeric($int_limite_ini) && is_numeric($int_limite_qtd)) {
         $limit = " LIMIT {$int_limite_ini},{$int_limite_qtd}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo('total');
     $db->Consulta("SELECT sigla_uf, nome, geom, idpais FROM {$this->schema}.{$this->tabela} {$where} {$orderBy} {$limit}");
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla['idpais'] = new clsPais($tupla['idpais']);
         $tupla['total'] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado)) {
         return $resultado;
     }
     return FALSE;
 }
Exemplo n.º 11
0
 /**
  * Exibe uma lista baseada nos parametros de filtragem passados
  *
  * @return Array
  */
 function lista($str_fantasia = false, $str_insc_estadual = false, $int_cnpj = false, $str_ordenacao = false, $int_limite_ini = false, $int_limite_qtd = false, $arrayint_idisin = false, $arrayint_idnotin = false, $int_idpes = false)
 {
     // verificacoes de filtros a serem usados
     $whereAnd = "WHERE ";
     $join = "";
     if (is_string($str_fantasia)) {
         $where .= "{$whereAnd} (fcn_upper_nrm(fantasia) LIKE fcn_upper_nrm('%{$str_fantasia}%') OR fcn_upper_nrm(nome) LIKE fcn_upper_nrm('%{$str_fantasia}%'))";
         $whereAnd = " AND ";
     }
     if (is_string($str_insc_estadual)) {
         $where .= "{$whereAnd}insc_estadual ILIKE  '%{$str_insc_estadual}%'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idpes)) {
         $where .= "{$whereAnd}idpes = '{$int_idpes}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_cnpj)) {
         $i = 0;
         while (substr($int_cnpj, $i, 1) == 0) {
             $i++;
         }
         if ($i > 0) {
             $int_cnpj = substr($int_cnpj, $i);
         }
         $where .= "{$whereAnd} cnpj ILIKE  '%{$int_cnpj}%' ";
         $whereAnd = " AND ";
     }
     if (is_array($arrayint_idisin)) {
         $ok = true;
         foreach ($arrayint_idisin as $val) {
             if (!is_numeric($val)) {
                 $ok = false;
             }
         }
         if ($ok) {
             $where .= "{$whereAnd}idpes IN ( " . implode(",", $arrayint_idisin) . " )";
             $whereAnd = " AND ";
         }
     }
     if (is_array($arrayint_idnotin)) {
         $ok = true;
         foreach ($arrayint_idnotin as $val) {
             if (!is_numeric($val)) {
                 $ok = false;
             }
         }
         if ($ok) {
             $where .= "{$whereAnd}idpes NOT IN ( " . implode(",", $arrayint_idnotin) . " )";
             $whereAnd = " AND ";
         }
     }
     $orderBy = "";
     if (is_string($str_ordenacao)) {
         $orderBy = "ORDER BY {$str_ordenacao}";
     }
     $limit = "";
     if ($int_limite_ini !== false && $int_limite_qtd !== false) {
         $limit = " LIMIT {$int_limite_ini},{$int_limite_qtd}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.v_pessoa_juridica {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo("total");
     $db->Consulta("SELECT idpes, cnpj, fantasia, insc_estadual, capital_social FROM {$this->schema}.v_pessoa_juridica {$where} {$orderBy} {$limit}");
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla["total"] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado)) {
         return $resultado;
     }
     return false;
 }
 /**
  * Exibe uma lista baseada nos parametros de filtragem passados
  *
  * @return Array
  */
 function lista($int_idlog = false, $int_cep = false, $int_idbai = false, $str_ordenacao = "idlog", $int_limite_ini = 0, $int_limite_qtd = 20)
 {
     // verificacoes de filtros a serem usados
     $whereAnd = "WHERE ";
     if (is_numeric($int_idlog)) {
         $where .= "{$whereAnd}idlog = '{$int_idlog}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_cep)) {
         $where .= "{$whereAnd}cep LIKE '%{$int_cep}%'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idbai)) {
         $where .= "{$whereAnd}idbai =  '{$int_idbai}'";
     }
     $orderBy = "";
     if (is_string($str_ordenacao)) {
         $orderBy = "ORDER BY {$str_ordenacao}";
     }
     $limit = "";
     if (is_numeric($int_limite_ini) && is_numeric($int_limite_qtd)) {
         $limit = " LIMIT {$int_limite_ini},{$int_limite_qtd}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo("total");
     $db->Consulta("SELECT idlog, cep, idbai FROM {$this->schema}.{$this->tabela} {$where} {$orderBy} {$limit}");
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $idlog = $tupla["idlog"];
         $tupla["idlog"] = new clsCepLogradouro($tupla["cep"], $tupla["idlog"]);
         $tupla["cep"] = new clsCepLogradouro($tupla["cep"], $idlog);
         $tupla["idbai"] = new clsBairro($tupla["idbai"]);
         $tupla["total"] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado)) {
         return $resultado;
     }
     return false;
 }
Exemplo n.º 13
0
 /**
  * Exibe uma lista baseada nos parametros de filtragem passados
  *
  * @return Array
  */
 function lista($ref_cod_regiao = false, $int_limite_ini = false, $int_limite_qtd = false, $str_orderBy = false)
 {
     // verificacoes de filtros a serem usados
     $whereAnd = "WHERE ";
     if (is_numeric($ref_cod_regiao)) {
         $where .= "{$whereAnd}ref_cod_regiao = '{$ref_cod_regiao}' ";
         $whereAnd = " AND ";
     }
     if ($str_orderBy) {
         $orderBy = "ORDER BY {$str_orderBy}";
     }
     $limit = "";
     if (is_numeric($int_limite_ini) && is_numeric($int_limite_qtd)) {
         $limit = " LIMIT {$int_limite_ini},{$int_limite_qtd}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo("total");
     $db->Consulta("SELECT {$this->campos_lista} FROM {$this->schema}.{$this->tabela} {$where} {$orderBy} {$limit}");
     $resultado = array();
     $countCampos = count(explode(",", $this->campos_lista));
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         if ($countCampos > 1) {
             $tupla["total"] = $total;
             $resultado[] = $tupla;
         } else {
             $resultado[] = $tupla["{$this->campos_lista}"];
         }
     }
     if (count($resultado)) {
         return $resultado;
     }
     return false;
 }
Exemplo n.º 14
0
 /**
  * Exibe uma lista baseada nos parametros de filtragem passados
  *
  * @return Array
  */
 function lista($int_idesco = false, $str_descricao = false, $str_ordenacao = "descricao", $int_limite_ini = 0, $int_limite_qtd = 30)
 {
     // verificacoes de filtros a serem usados
     $whereAnd = "WHERE ";
     if (is_numeric($int_idesco)) {
         $where .= "{$whereAnd}idesco = '{$int_idesco}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_descricao)) {
         $where .= "{$whereAnd}descricao ILIKE  '%{$str_descricao}%'";
     }
     $orderBy = "";
     if (is_string($str_ordenacao)) {
         $orderBy = "ORDER BY {$str_ordenacao}";
     }
     $limit = "";
     if (is_numeric($int_limite_ini) && is_numeric($int_limite_qtd)) {
         $limit = " LIMIT {$int_limite_ini},{$int_limite_qtd}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo("total");
     $db->Consulta("SELECT idesco, descricao FROM {$this->schema}.{$this->tabela} {$where} {$orderBy} {$limit}");
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla["total"] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado)) {
         return $resultado;
     }
     return false;
 }
Exemplo n.º 15
0
 function lista($int_idpes = FALSE, $str_ordenacao = FALSE, $int_inicio_limite = FALSE, $int_qtd_limite = FALSE, $int_cep = FALSE, $int_idlog = FALSE, $int_idbai = FALSE, $int_numero = FALSE, $str_bloco = FALSE, $int_apartamento = FALSE, $int_andar = FALSE, $str_letra = FALSE, $str_complemento = FALSE)
 {
     $whereAnd = ' AND ';
     $where = '';
     if (is_numeric($int_idpes)) {
         $where .= "{$whereAnd}idpes = '{$int_idpes}' ";
         $whereAnd = ' AND ';
     } elseif (is_string($int_idpes)) {
         $where .= "{$whereAnd}idpes IN ({$int_idpes}) ";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_cep)) {
         $where .= "{$whereAnd}cep = '{$int_cep}' ";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_idlog)) {
         $where .= "{$whereAnd}idlog = '{$int_idlog}' ";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_idbai)) {
         $where .= "{$whereAnd}idbai = '{$int_idbai}' ";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_numero)) {
         $where .= "{$whereAnd}numero = '{$int_numero}' ";
         $whereAnd = ' AND ';
     }
     if ($str_bloco) {
         $where .= "{$whereAnd}bloco = '{$str_bloco}' ";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_apartamento)) {
         $where .= "{$whereAnd}apartamento = '{$int_apartamento}' ";
         $whereAnd = ' AND ';
     }
     if (is_numeric($int_andar)) {
         $where .= "{$whereAnd}andar = '{$int_andar}' ";
         $whereAnd = ' AND ';
     }
     if (is_string($str_letra)) {
         $where .= "{$whereAnd}letra = '{$str_letra}' ";
         $whereAnd = ' AND ';
     }
     if (is_string($str_complemento)) {
         $where .= "{$whereAnd}complemento ILIKE '%{$str_complemento}%' ";
         $whereAnd = ' AND ';
     }
     if ($inicio_limite !== FALSE && $qtd_registros) {
         $limite = "LIMIT {$qtd_registros} OFFSET {$inicio_limite} ";
     }
     if ($str_orderBy) {
         $orderBy .= " ORDER BY {$str_orderBy} ";
     }
     $db = new clsBanco();
     $sql = sprintf('SELECT COUNT(0) AS total FROM %s.%s WHERE tipo = 1 %s', $this->schema_cadastro, $this->tabela, $where);
     $db->Consulta($sql);
     $db->ProximoRegistro();
     $total = $db->Campo('total');
     $db = new clsBanco($this->banco);
     $sql = sprintf('SELECT idpes, tipo, cep, idlog, numero, letra, complemento, reside_desde, ' . 'idbai, bloco, apartamento, andar FROM %s.%s WHERE tipo = 1 %s %s %s', $this->schema_cadastro, $this->tabela, $where, $orderBy, $limite);
     $db->Consulta($sql);
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla['cep'] = new clsCepLogradouro($tupla['cep'], $tupla['idlog']);
         $tupla['idlog'] = new clsCepLogradouro($tupla['cep'], $tupla['idlog']);
         $tupla['idbai'] = new clsPublicBairro(NULL, NULL, $tupla['idbai']);
         $bairro = $tupla['idbai']->detalhe();
         $tupla['zona_localizacao'] = $bairro['zona_localizacao'];
         $tupla['total'] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado) > 0) {
         return $resultado;
     }
     return FALSE;
 }
Exemplo n.º 16
0
 /**
  * Exibe uma lista baseada nos parametros de filtragem passados
  *
  * @return Array
  */
 function lista($str_nome = false, $str_sigla_uf = false, $int_area_km2 = false, $int_idmreg = false, $int_idasmun = false, $int_cod_ibge = false, $str_geom = false, $str_tipo = false, $int_idmun_pai = false, $int_limite_ini = false, $int_limite_qtd = false, $str_orderBy = false)
 {
     // verificacoes de filtros a serem usados
     $whereAnd = "WHERE ";
     if (is_string($str_nome)) {
         $where .= "{$whereAnd}nome LIKE '%{$str_nome}%'";
         $whereAnd = " AND ";
     }
     if (is_string($str_sigla_uf)) {
         $where .= "{$whereAnd}sigla_uf LIKE '%{$str_sigla_uf}%'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_area_km2)) {
         $where .= "{$whereAnd}area_km2 = '{$int_area_km2}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idmreg)) {
         $where .= "{$whereAnd}idmreg = '{$int_area_km2}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idasmun)) {
         $where .= "{$whereAnd}idasmun = '{$int_idasmun}'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_cod_ibge)) {
         $where .= "{$whereAnd}cod_ibge = '{$int_cod_ibge}'";
         $whereAnd = " AND ";
     }
     if (is_string($str_geom)) {
         $where .= "{$whereAnd}geom LIKE '%{$str_geom}%'";
         $whereAnd = " AND ";
     }
     if (is_string($str_tipo)) {
         $where .= "{$whereAnd}tipo LIKE '%{$str_geom}%'";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_idmun_pai)) {
         $where .= "{$whereAnd}idmun_pai = '{$int_idmun_pai}'";
         $whereAnd = " AND ";
     }
     if ($str_orderBy) {
         $orderBy = "ORDER BY {$str_orderBy}";
     }
     $limit = "";
     if (is_numeric($int_limite_ini) && is_numeric($int_limite_qtd)) {
         $limit = " LIMIT {$int_limite_ini},{$int_limite_qtd}";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema}.{$this->tabela} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo("total");
     $db->Consulta("SELECT idmun, nome, sigla_uf, area_km2, idmreg, idasmun, cod_ibge, geom , tipo, idmun_pai FROM {$this->schema}.{$this->tabela} {$where} {$orderBy} {$limit}");
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla["sigla_uf"] = new clsUf($tupla["sigla_uf"]);
         $tupla["idasmun"] = new clsUf($tupla["idasmun"]);
         $tupla["idmun_pai"] = new clsUf($tupla["idamun_pai"]);
         $tupla["total"] = $total;
         $this->_total = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado)) {
         return $resultado;
     }
     return false;
 }
 function lista($int_idpes = false, $str_ordenacao = false, $int_inicio_limite = false, $int_qtd_registros = false, $int_ddd = false, $int_fone = false)
 {
     $whereAnd = "WHERE ";
     $where = "";
     if (is_numeric($int_idpes)) {
         $where .= "{$whereAnd}idpes = '{$int_idpes}'";
         $whereAnd = " AND ";
     } elseif (is_string($int_idpes)) {
         $where .= "{$whereAnd}idpes IN ({$int_idpes})";
         $whereAnd = " AND ";
     }
     if (is_string($str_tipo_pessoa)) {
         $where .= "{$whereAnd}tipo = '{$str_tipo_pessoa}' ";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_ddd)) {
         $where .= "{$whereAnd}ddd = '{$int_ddd}' ";
         $whereAnd = " AND ";
     }
     if (is_numeric($int_fone)) {
         $where .= "{$whereAnd}fone = '{$int_fone}' ";
         $whereAnd = " AND ";
     }
     if ($int_inicio_limite !== false && $int_qtd_registros) {
         $limite = "LIMIT {$int_qtd_registros} OFFSET {$int_inicio_limite} ";
     }
     if ($str_orderBy) {
         $orderBy = " ORDERY BY {$str_orderBy} ";
     }
     $db = new clsBanco();
     $db->Consulta("SELECT COUNT(0) AS total FROM {$this->schema_cadastro}.{$this->tabela_telefone} {$where}");
     $db->ProximoRegistro();
     $total = $db->Campo("total");
     $db = new clsBanco($this->banco);
     $db = new clsBanco();
     $db->Consulta("SELECT idpes, tipo, ddd, fone FROM {$this->schema_cadastro}.{$this->tabela_telefone} {$where} {$orderBy} {$limite}");
     $resultado = array();
     while ($db->ProximoRegistro()) {
         $tupla = $db->Tupla();
         $tupla["total"] = $total;
         $resultado[] = $tupla;
     }
     if (count($resultado) > 0) {
         return $resultado;
     }
     return false;
 }