/**
  * Retorna o array de indicadores pela localidade ID (municipio ou uf ou total da CGR).
  * nos formatos  0=array, 1=html, 2=csv, 3=json
  *
  */
 public function findDadosByLocsAndIndics($arrLocs, $arrIndics, $formato = 0)
 {
     $conn = $this->pdo->getConnection($this->mode);
     $indics = implode(',', $arrIndics);
     $locs = implode(',', $arrLocs);
     #$sql   = " SELECT mun_cod, mun_desc,grupo_desc,drs_desc,colegiado_desc,{$indics} ";
     $sql = " SELECT {$indics} ";
     $sql .= " FROM tb_dado ";
     $sql .= " WHERE mun_cod in ({$locs})";
     $sql .= " ORDER BY mun_desc ASC";
     #echo "<b>{$sql}</b>";
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     #echo "formato=".$formato;
     $resConsulta = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     switch ($formato) {
         case 0:
             //array
             $result = $resConsulta;
             break;
         case 1:
             // xls
         // xls
         case 4:
             // html
             $oIdao = new IndicadorBusiness();
             $arrDescFields = $oIdao->findDescIndicadoresByArrId($arrIndics);
             #$arrHeader = array('CÓDIGO','Município','Grupo','drs','colegiado');
             $arrTroca = array(-1001 => 'não se aplica', -1002 => 'inexistente');
             $arrAlinhamento = array('drs_cod', 'gve_cod', 'mun_cod', 'colegiado_desc', 'grupo_desc', 'drs_desc', 'macroreg_desc', 'mun_desc');
             //cabeçalho da tabela
             $header = "<thead><tr>";
             /*foreach ($arrHeader as $indice => $desc){
                   $header.= "<th><h3 align='center'>&nbsp;&nbsp;{$desc}&nbsp;&nbsp;</h3></th>";
               }*/
             foreach ($arrIndics as $indice => $indicadorId) {
                 $header .= "<th align='right'><h3 align='left'>&nbsp;{$arrDescFields[$indicadorId]}&nbsp;</h3></th>\r\n";
             }
             $header .= "</tr></thead><tbody>";
             //inicio do corpo da tabela
             $tabela = '<table cellpadding="0" cellspacing="0" border="0" id="table" class="sortable">';
             $tabela .= $header;
             foreach ($resConsulta as $indice => $tabelas) {
                 $tabela .= "<tr>";
                 //foreach do marcio
                 foreach ($tabelas as $campo => $valor) {
                     if (in_array($campo, $arrAlinhamento)) {
                         $tabela .= "\t<td align='left'>";
                     } else {
                         $tabela .= "\t<td align='right'>";
                     }
                     //não se aplica ou não disponível
                     if ($valor == '-1001' or $valor == '-1002') {
                         $valor = 'NA';
                     }
                     if (is_numeric($valor) && stripos($valor, ".")) {
                         if ($valor) {
                             if (stripos($valor, "0.00") === 0) {
                                 $tabela .= number_format($valor, 5, ',', '');
                             } else {
                                 $tabela .= number_format($valor, 2, ',', '');
                             }
                         } else {
                             $tabela .= "-";
                         }
                     } else {
                         if (!in_array($campo, $arrAlinhamento)) {
                             $tabela .= $valor ? number_format($valor, 0, '', '') : (!is_numeric($valor) ? '-' : $valor);
                         } else {
                             $tabela .= $valor ? $valor : (!is_numeric($valor) ? '-' : $valor);
                         }
                     }
                     $tabela .= stripos($valor, "0.00") . "</td>\r\n";
                 }
                 //fim foreach marcio
                 //
                 //   foreach($tabelas as $campo => $valor){
                 //       $tabela .= "\t<td>".($valor?$valor:'-')."</td>\r\n";
                 //   }
                 $tabela .= "</tr>";
             }
             $tabela .= "</tbody></table>";
             $result = $tabela;
             break;
         case 2:
             // CSV
             $oIdao = new IndicadorBusiness();
             $arrDescFields = $oIdao->findDescIndicadoresByArrId($arrIndics);
             #$arrHeader = array('CÓDIGO','Tipo Localidade','UF','CGR','Município');
             $arrHeader = array('drs_cod', 'gve_cod', 'mun_cod', 'colegiado_desc', 'grupo_desc', 'drs_desc', 'macroreg_desc', 'mun_desc');
             $arrTroca = array(-1001 => 'não se aplica', -1002 => 'inexistente');
             $arrAlinhamento = array('drs_cod', 'gve_cod', 'mun_cod', 'colegiado_desc', 'grupo_desc', 'drs_desc', 'macroreg_desc', 'mun_desc');
             //cabeçalho da tabela
             $headerCSV = implode(";", $arrHeader);
             $headerCSV .= ";";
             foreach ($arrIndics as $indice => $indicadorId) {
                 $headerCSV = $arrDescFields[$indicadorId] . ";";
             }
             $headerCSV .= "\r\n";
             foreach ($resConsulta as $indice => $tabelas) {
                 foreach ($tabelas as $campo => $valor) {
                     if (is_numeric($valor) && stripos($valor, ".")) {
                         if ($valor) {
                             if (stripos($valor, "0.00") === 0) {
                                 $tabelaCSV .= number_format($valor, 5, ',', '.');
                             } else {
                                 $tabelaCSV .= number_format($valor, 2, ',', '.');
                             }
                         } else {
                             $tabelaCSV .= "-";
                         }
                     } else {
                         if (!in_array($campo, $arrAlinhamento)) {
                             $tabelaCSV .= $valor ? number_format($valor, 0, '', '.') : (!is_numeric($valor) ? '-' : $valor);
                         } else {
                             $tabelaCSV .= $valor ? $valor : (!is_numeric($valor) ? '-' : $valor);
                         }
                     }
                     $tabelaCSV .= stripos($valor, "0.00") . ";";
                 }
                 $tabelaCSV = substr($tabelaCSV, 0, strlen($tabelaCSV) - 1);
                 //retira a último ponte-e-virgula do registro ";"
                 $tabelaCSV .= "\r\n";
                 //pula linha
             }
             $result = $headerCSV . $tabelaCSV;
             break;
         case 3:
             //json
             $json = json_encode($resConsulta);
             $result = $json;
             break;
     }
     return $result;
 }
<?php

header('Content-Type: text/html; charset=iso-8859-1');
require_once "../business/indicador_business_class.php";
require_once "../business/eixo_business_class.php";
include 'incs/cabecalho.php';
if (isset($_REQUEST['eixo'])) {
    $eixoCod = $_REQUEST['eixo'];
} else {
    $eixoCod = 2;
}
$oIdao = new IndicadorBusiness();
$arrIndics = $oIdao->findIndicadorslistByEixoCod($eixoCod);
$oEdao = new EixoBusiness();
?>
<div id="wrapper">
	<div id="menu"><br />
        <?php 
include 'incs/menu.php';
?>
    </div>   
<div id="conteudo"><br />
       <p class="tit">Sobre os Indicadores</p>
       <p class="textos">
       <div id="ListaInd">
       <p>Componente: <b><?php 
echo $oEdao->findEixoByCod($eixoCod)->getEixoNome();
?>
</b></p>
       <ul class="ficha">
       <?php 
Beispiel #3
0

            <div id="indSelected" style="width:100%; display:table;float:left;">
                
                <form id="frmIndSel" name="frmIndSel" action="<?php 
echo $_SERVER['PHP_SELF'];
?>
" method="post">
                        
<table cellpadding="0" cellspacing="0" border="0" width="96%" style="margin-left:15px;">
<tr><td width="75%">
<div id="textos_ind" style="color:#666;margin-left:0;margin-right:0;"> Indicadores selecionados:</div>
<select name="lstIndic[]" multiple id="lstIndic" size="8" style="font-size:12px;color:#666;width:100%;background:#efefef;border:1px solid #cccccc;margin:0px;">
                           <?php 
//popula o box com de indicadores selecionados
$oIdao = new IndicadorBusiness();
$arrObjListInd = $oIdao->findIndicadoresByArrId($_SESSION['indicadores']);
foreach ($arrObjListInd as $indice => $objListInd) {
    echo "<option value=\"{$objListInd->getIndicadorId()}\">{$objListInd->getIndicadorNome()}</option>";
}
?>
                        </select></td>
			<td valign="middle" align="center"><br />
                        <input type="button" name="btnAdd" id="btnAdd" value="Adicionar a lista" ><br /><br />
                        <input type="submit" name="btnRem" id="btnRem" value="Remover da lista">
                        </td>
</tr></table>
               </form>
           </div>
           <br /><br />
           <div id="botao">
 /**
  * Retorna o array de indicadores pela localidade ID (municipio ou uf ou total da CGR).
  * nos formatos  0=array, 1=html, 2=csv, 3=json
  *
  */
 public function findDadosByLocsAndIndics($arrLocs, $arrIndics, $formato = 0, $painel, $where, $page, $limit, $sidx, $sord)
 {
     $conn = $this->pdo->getConnection($this->mode);
     //query para contagem
     $sqlPaginacao = " SELECT count(*) from tb_dado where 1=1 {$where}";
     $stmt1 = $conn->prepare($sqlPaginacao);
     $stmt1->execute();
     //qtde de registros retornados
     $count = $stmt1->fetchColumn();
     if ($count > 0) {
         $total_pages = ceil($count / $limit);
     } else {
         $total_pages = 0;
     }
     if ($page > $total_pages) {
         $page = $total_pages;
     }
     $start = $limit * $page - $limit;
     if ($start < 0) {
         $start = 0;
     }
     //fim da contagem
     $indics = implode(',', $arrIndics);
     //1- painel
     if ($painel != 1) {
         $sql = " SELECT  mun_cod, mun_desc,{$indics} ";
         $arrHeader = array('Código', 'Município');
     } else {
         $sql = " SELECT  macroreg_desc,drs_desc,gve_desc,colegiado_desc,mun_cod, mun_desc,grupo_desc,{$indics} ";
         $arrHeader = array('Macro-região', 'DRS', 'GVE', 'Colegiado', 'Código', 'Município', 'Grupo');
     }
     $sql .= " FROM tb_dado ";
     if (is_array($arrLocs)) {
         $locs = implode(',', $arrLocs);
         $sql .= " WHERE mun_cod in ({$locs}) {$where}";
     } else {
         $sql .= " WHERE 1=1  {$where}";
     }
     $sql .= " ORDER BY {$sidx} {$sord} limit {$start},{$limit}";
     #echo "<b>{$sql}</b>";
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     $resConsulta = $stmt->fetchAll(PDO::FETCH_ASSOC);
     switch ($formato) {
         case 0:
             //array
             $result = $resConsulta;
             break;
         case EXCEL:
             // xls
         // xls
         case HTML:
             // html
             $oIdao = new IndicadorBusiness();
             $arrDescFields = $oIdao->findDescIndicadoresByArrId($arrIndics);
             $arrTroca = array(-1001 => 'não se aplica', -1002 => 'inexistente');
             $arrAlinhamento = array('drs_cod', 'gve_desc', 'mun_cod', 'colegiado_desc', 'grupo_desc', 'drs_desc', 'macroreg_desc', 'mun_desc', 'var090');
             //cabeçalho da tabela
             $header = "<thead><tr>";
             foreach ($arrHeader as $indice => $desc) {
                 $header .= "<th>{$desc}</th>";
             }
             foreach ($arrIndics as $indice => $indicadorId) {
                 $header .= "<th align='right'>{$arrDescFields[$indicadorId]}</th>\r\n";
             }
             $header .= "</tr></thead><tbody>";
             //inicio do corpo da tabela
             $tabela = '<table cellpadding="0" cellspacing="0" border="0" class="geral" width="55%" id="table">';
             $tabela .= $header;
             foreach ($resConsulta as $indice => $tabelas) {
                 $tabela .= "<tr>";
                 foreach ($tabelas as $campo => $valor) {
                     if (in_array($campo, $arrAlinhamento)) {
                         $tabela .= "\t<td align='left'>";
                     } else {
                         $tabela .= "\t<td align='right'>";
                     }
                     $tabela .= str_replace(".", ",", $valor) . "</td>\r\n";
                 }
                 $tabela .= "</tr>";
             }
             $tabela .= "</tbody></table>";
             $result = $tabela;
             break;
         case CSV:
             // CSV
             $oIdao = new IndicadorBusiness();
             $arrDescFields = $oIdao->findDescIndicadoresByArrId($arrIndics);
             #$arrHeader = array('CÓDIGO','MUNICÍPIO');
             //$arrHeader = array('drs_cod','gve_cod','mun_cod','colegiado_desc','grupo_desc','drs_desc','macroreg_desc','mun_desc');
             $arrTroca = array(-1001 => 'não se aplica', -1002 => 'inexistente');
             $arrAlinhamento = array('drs_cod', 'gve_desc', 'mun_cod', 'colegiado_desc', 'grupo_desc', 'drs_desc', 'macroreg_desc', 'mun_desc');
             //cabeçalho da tabela
             $headerCSV = implode(";", $arrHeader);
             $headerCSV .= ";";
             foreach ($arrIndics as $indice => $indicadorId) {
                 $headerCSV .= $arrDescFields[$indicadorId] . ";";
             }
             $headerCSV .= "\r\n";
             foreach ($resConsulta as $indice => $tabelas) {
                 foreach ($tabelas as $campo => $valor) {
                     $tabelaCSV .= str_replace(".", ",", $valor) . ";";
                 }
                 $tabelaCSV = substr($tabelaCSV, 0, strlen($tabelaCSV) - 1);
                 //retira a último ponte-e-virgula do registro ";"
                 $tabelaCSV .= "\r\n";
                 //pula linha
             }
             $result = $headerCSV . $tabelaCSV;
             break;
         case JSON:
             //json
             $arrSaltar = array("mun_cod");
             $s = "{";
             $s .= "\"page\":\"{$page}\",";
             $s .= "\"total\":\"{$total_pages}\",";
             $s .= "\"records\":\"{$count}\",";
             $s .= "\"rows\":[";
             foreach ($resConsulta as $indice => $tabelas) {
                 $s .= "{\"id\":\"" . $tabelas['mun_cod'] . "\",";
                 $s .= "\"cell\":[";
                 foreach ($tabelas as $campo => $valor) {
                     //if(!in_array($campo,$arrSaltar))
                     $s .= "\"" . $valor . "\",";
                 }
                 $s = substr($s, 0, strlen($s) - 1);
                 $s .= "]},";
             }
             $s = substr($s, 0, strlen($s) - 1);
             $s .= "]";
             //rows
             $s .= "}";
             $result = $s;
             break;
         case XML:
             //xml
             $s = "<?xml version='1.0' encoding='iso-8859-1'?>";
             $s .= "<rows>";
             $s .= "<page>" . $page . "</page>";
             $s .= "<total>" . $total_pages . "</total>";
             $s .= "<records>" . $count . "</records>";
             // textos em CDATA
             foreach ($resConsulta as $indice => $tabelas) {
                 $s .= "<row id='" . $tabelas['mun_cod'] . "'>";
                 foreach ($tabelas as $campo => $valor) {
                     if (is_numeric($valor)) {
                         $s .= "<cell>" . $valor . "</cell>";
                     } else {
                         $s .= "<cell><![CDATA[" . $valor . "]]></cell>";
                     }
                 }
                 $s .= "</row>";
             }
             $s .= "</rows>";
             $result = $s;
             break;
     }
     return $result;
 }
Beispiel #5
0
<?php

header('Content-Type: text/html; charset=iso-8859-1');
require_once "../business/grupo_business_class.php";
require_once "../business/indicador_business_class.php";
$idIndicador = $_GET['ind'];
$oBIndicador = new IndicadorBusiness();
$indicador = $oBIndicador->findIndicadorById($idIndicador);
echo "<b>{$indicador->getIndicadorNome()}</b>";
Beispiel #6
0
<?php

header("Content-Type: text/html; charset=iso-8859-1");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
require_once "../business/indicador_business_class.php";
require_once "../business/eixo_business_class.php";
session_start();
$arrIndicFields = $_SESSION['indicadores'];
$arrCamposTexto = array('mun_desc', 'grupo_desc', 'gve_desc', 'drs_desc', 'colegiado_desc', 'macroreg_desc');
$oIdao = new IndicadorBusiness();
$arrAtributos = $oIdao->listAtributosIndicadorsByArrCod($arrIndicFields);
//reordenado o array da sessao
foreach ($arrAtributos as $field => $obj) {
    $lista[] = $obj['campo'];
}
$_SESSION['indicadores'] = $lista;
$titCols = null;
$colModelNames = null;
$toolTip = null;
$cabecFull = null;
$cabecLight = null;
foreach ($arrAtributos as $campo => $ind) {
    $alinhamento = in_array($ind['campo'], $arrCamposTexto) ? 'left' : 'right';
    $titCols .= "{$ind['nome_curto']}','";
    $colModelNames .= "{name:'{$ind['campo']}', index:'{$ind['campo']}', width:{$ind['tamanho']}, align:'{$alinhamento}', formatter:'{$ind['formato']}'},";
    $toolTip .= " jQuery(\"#list\").jqGrid ('setLabel', '{$ind['campo']}','','textalign',{'title':'{$ind['nome']}'});\r\n";
    $cabecLight .= " jQuery(\"#list\").jqGrid ('setLabel', '{$ind['campo']}','{$ind['nome_curto']}','textalign',{'title':'{$ind['nome']}'});\r\n";
    $cabecFull .= " jQuery(\"#list\").jqGrid ('setLabel', '{$ind['campo']}','{$ind['nome']}','textalign',{'title':'{$ind['nome']}'});\r\n";
}
Beispiel #7
0
<?php

header('Content-Type: text/html; charset=iso-8859-1');
require_once "../business/indicador_business_class.php";
if (isset($_REQUEST['indCod'])) {
    $indCod = $_REQUEST['indCod'];
} else {
    $indCod = 9;
}
$oIdao = new IndicadorBusiness();
$fichaSobre = $oIdao->fichaByIndicadorId($indCod);
?>
        <table cellpadding="2" cellspacing="2" border="0" width="95%" align="center">
        	<tr>
            	<td class="tit">Nome</td>
            </tr>
        	<tr>
            	<td class="texto"><b><?php 
echo $fichaSobre->getIndicadorNome();
?>
</b></td>
            </tr>
        	<tr>
            	<td class="tit">Conceito</td>
            </tr>
        	<tr>
            	<td class="texto"><?php 
echo $fichaSobre->getIndicadorDescricao();
?>
</td>
            </tr>
Beispiel #8
0
header("Content-Type: text/html; charset=iso-8859-1");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
require_once "../business/indicador_business_class.php";
require_once "../business/eixo_business_class.php";
if (isset($_REQUEST['eixo'])) {
    $eixo = $_REQUEST['eixo'];
} else {
    $eixo = 8;
}
$oEdao = new EixoBusiness();
$eixoNome = $oEdao->findEixoByCod($eixo);
$lstEixos = $oEdao->listEixos();
$oIdao = new IndicadorBusiness();
$arrAtributos = $oIdao->listAtributosIndicadorsByEixoCod($eixo);
$titCols = null;
$colModelNames = null;
$toolTip = null;
$cabecFull = null;
$cabecLight = null;
foreach ($arrAtributos as $campo => $ind) {
    $titCols .= "{$ind['nome_curto']}','";
    $colModelNames .= "{name:'{$ind['campo']}', index:'{$ind['campo']}', width:{$ind['tamanho']}, align:'right', formatter:'{$ind['formato']}'},";
    $toolTip .= " jQuery(\"#list\").jqGrid ('setLabel', '{$ind['campo']}','','textalign',{'title':'{$ind['nome']}'});\r\n";
    $cabecLight .= " jQuery(\"#list\").jqGrid ('setLabel', '{$ind['campo']}','{$ind['nome_curto']}','textalign',{'title':'{$ind['nome']}'});\r\n";
    $cabecFull .= " jQuery(\"#list\").jqGrid ('setLabel', '{$ind['campo']}','{$ind['nome']}','textalign',{'title':'{$ind['nome']}'});\r\n";
}
$titCols = "'" . substr($titCols, 0, strlen($titCols) - 2);
$colModelNames = substr($colModelNames, 0, strlen($colModelNames) - 1);