Commit 828cd977d209090116c34d7cc83711290e71b294
1 parent
8758ae42
Exists in
master
and in
7 other branches
--no commit message
Showing
1 changed file
with
17 additions
and
6 deletions
Show diff stats
ferramentas/saiku/esquemaxml.php
... | ... | @@ -630,8 +630,14 @@ function dimensoesTabelas(){ |
630 | 630 | |
631 | 631 | $xml .= "<Cube cache='false' name='Tabela: {$c["esquemadb"]}{$c["tabela"]}'>"; |
632 | 632 | $incluirChaves = array("tabelamedida{$c["id_medida_variavel"]}.*"); |
633 | - if($c["colunavalor"] == ""){ | |
634 | - $incluirChaves[] = "'1'::numeric as contagem"; | |
633 | + //colunas quando o nome da coluna com os valores for vazia | |
634 | + foreach($tb as $mdd){ | |
635 | + if($mdd["colunavalor"] == "" && $mdd["filtro"] == ""){ | |
636 | + $incluirChaves[] = "'1'::numeric as contagem".$mdd["id_medida_variavel"]; | |
637 | + } | |
638 | + if($mdd["colunavalor"] == "" && $mdd["filtro"] != ""){ | |
639 | + $incluirChaves[] = "CASE WHEN {$mdd["filtro"]} THEN 1 ELSE 0 END as contagem".$mdd["id_medida_variavel"]; | |
640 | + } | |
635 | 641 | } |
636 | 642 | if(count($parComposto) > 0){ |
637 | 643 | //$sql = "select *,".implode("||'-'||",$parComposto)."::text as ".implode("_",$parComposto)."_ from {$c["esquemadb"]}.{$c["tabela"]}"; |
... | ... | @@ -660,9 +666,14 @@ function dimensoesTabelas(){ |
660 | 666 | ON tabela{$r["codigo_tipo_regiao"]}.{$r["identificador"]}::text = tabelamedida{$c["id_medida_variavel"]}.{$c["colunaidgeo"]}::text |
661 | 667 | "; |
662 | 668 | $sql .= $dimRegioes[$c["codigo_tipo_regiao"]]["juncoes"]; |
663 | - | |
664 | - if($c["filtro"] != ""){ | |
665 | - $sql .= " WHERE ".str_replace('"',"'",$c["filtro"]); | |
669 | + $f = array(); | |
670 | + foreach($tb as $mdd){ | |
671 | + if($medida["filtro"] != ""){ | |
672 | + $f[] = str_replace('"',"'",$mdd["filtro"]); | |
673 | + } | |
674 | + } | |
675 | + if(count($f) > 0){ | |
676 | + $sql .= " WHERE ".implode(" OR ",$f); | |
666 | 677 | } |
667 | 678 | |
668 | 679 | $xml .= " |
... | ... | @@ -697,7 +708,7 @@ function dimensoesTabelas(){ |
697 | 708 | $agregador = "count"; |
698 | 709 | } |
699 | 710 | if($medida["colunavalor"] == ""){ |
700 | - $nomeColunaValor = "contagem"; | |
711 | + $nomeColunaValor = "contagem".$medida["id_medida_variavel"]; | |
701 | 712 | } |
702 | 713 | else{ |
703 | 714 | $nomeColunaValor = $medida["colunavalor"]; | ... | ... |