Ejemplo n.º 1
0
 $consTotal[$x] = 0;
 $pagoTotal[$x] = 0;
 $consAnoTotal[$x] = 0;
 $pagoAnoTotal[$x] = 0;
 $ucTipo = new UnidadeConsumidora(0, null, null, null, null, null, null, null, null, null, null, $tipos['tipo']);
 $tpl->TIPO_NOME = $ucTipo->getTipoNome();
 $tpl->ANO = $anoAtual;
 $tpl->MEDIDA = $ucTipo->getTipoMedida();
 $tpl->TIPO_ID = $tipos['tipo'];
 $tpl->block("EACH_TIPOBUTTON");
 if ($tipos['tipo'] == $tipoId) {
     //FAZER APARECER UCS E SEUS RESULTADOS
     $ucqtd = 0;
     foreach ($ucTipo->getMesmoTipo() as $res) {
         //$tpl->UCID		= $res;
         $uc = new UnidadeConsumidora($res);
         $tpl->UCRGI = $uc->get('rgi');
         $tpl->UCCHAVE = sha1($uc->get('id'));
         $tpl->UCNOME = $uc->getNome();
         $tpl->UCEND = $uc->getEndereco();
         $tpl->UCCID = $uc->getCidadeNome();
         $tpl->UCSIGLA = $uc->get('uo')->getSigla();
         $tpl->EMPRESA = $uc->get('empresa')->getNome();
         $tpl->STATUS = $uc->getAtivoText();
         $totalAno = $uc->somaValorNotas($anoAtual);
         $tpl->CONSANO = tratarValor($totalAno['SUM(consumo)'], false);
         $tpl->VALANO = tratarValor($totalAno['SUM(valor)'], true);
         $consAnoTotal[$x] += $totalAno['SUM(consumo)'];
         $pagoAnoTotal[$x] += $totalAno['SUM(valor)'];
         $ucqtd++;
         $tpl->block("EACH_UC");
Ejemplo n.º 2
0
require "src/scripts/conecta.php";
require "src/scripts/restrito.php";
include "src/scripts/functions.php";
require "src/classes/Template.class.php";
include "src/classes/Users.class.php";
include "src/classes/UnidadeCons.class.php";
redirectByPermission(0);
// SETAR PERMISSÃO DA PÁGINA
$tpl = new Template('html_libs/ucResumo.html');
if (isset($_GET['chave'])) {
    $chave = mysql_real_escape_string($_GET['chave']);
    if (strlen($chave) == 40) {
        $queryVerif = mysql_query("SELECT id FROM daee_uddc WHERE SHA1(id) = '" . $_GET['chave'] . "'");
        if (mysql_num_rows($queryVerif) == 1) {
            $id = mysql_fetch_array($queryVerif)['id'];
            $uc = new UnidadeConsumidora($id);
            /*********************************
            		  MOSTRAR INFORMAÇÕES DO RELATÓRIO
            		 *********************************/
            $hasConsumo = $uc->hasConsumo();
            if ($hasConsumo) {
                $tpl->block('SHOW_HEADER_CONS');
            }
            $distinct_sql = "SELECT DISTINCT(ano_ref) FROM daee_notas WHERE uc = {$id} ORDER BY ano_ref ASC";
            $distinct_query = mysql_query($distinct_sql);
            $exArray;
            $exArrayIndex = 0;
            while ($ano = mysql_fetch_array($distinct_query)) {
                $tpl->ANO = $ano = $ano['ano_ref'];
                $exercicio = $uc->getExercicioMensal($ano);
                $tpl->MESESPG = $meses_count = count($exercicio);
Ejemplo n.º 3
0
 $totalMensal[1] = 0;
 $totalMensal[2] = 0;
 $totalMensal[3] = 0;
 $totalMensal[4] = 0;
 $totalMensal[5] = 0;
 $totalMensal[6] = 0;
 $totalMensal[7] = 0;
 $totalMensal[8] = 0;
 $totalMensal[9] = 0;
 $totalMensal[10] = 0;
 $totalMensal[11] = 0;
 $totalMensal[12] = 0;
 $totalMensal[13] = 0;
 // TOTAL DA UO
 foreach ($uoUcs as $uoUcId) {
     $uc = new UnidadeConsumidora($uoUcId);
     $tpl->RGI = $uc->get('rgi');
     $tpl->UCNOME = $uc->getNome();
     $tpl->UCSTATUS = "<br>" . $uc->getAtivoText();
     $tpl->UCTIPO = $uc->getTipoNome();
     $tpl->UCEMPRESA = $uc->get('empresa')->getNome();
     $tpl->UCCHAVE = SHA1($uc->get('id'));
     $tipo = $uc->get('tipo');
     /**********************************
     				MOSTRAR PAGAMENTOS MENSAIS
     			**********************************/
     $pagMensal = $uc->getExercicioMensal($anoAtual);
     $index = 1;
     $totalUc = 0;
     for ($i = 1; $i <= 12; $i++) {
         if (array_key_exists($index, $pagMensal) && $pagMensal[$index]['mes_ref'] == $i) {
Ejemplo n.º 4
0
    $tpl->HIDEMESREF = $mes . "-" . $ano;
    $tpl->CHECKED_DATA = 'checked="checked"';
} else {
    $conts = $user->getContratos();
    if ($conts[0]['id'] != null) {
        $qtdCont = count($conts);
        $z = 1;
        foreach ($conts as $cont) {
            $contrato = new Contrato($cont['id']);
            //$tpl->CONTNOME		= "-------- ".$contrato->geraNome(). " --------";
            $rgis = $contrato->getAllUcs(true);
            if ($rgis[0]['id'] != null) {
                $qtdRgi = count($rgis);
                $w = 1;
                foreach ($rgis as $rgi) {
                    $uc = new UnidadeConsumidora($rgi['id']);
                    $tpl->RGID = $rgi['id'];
                    $tpl->DISABLE_OPT = "";
                    $tpl->RGI = $uc->get('rgi');
                    $tpl->RGINOME = $uc->getEndereco() . " ~> " . $uc->getNome();
                    $tpl->block('EACH_RGI');
                    if ($z < $qtdCont) {
                        $tpl->MS_COMA = ",";
                    } elseif ($z == $qtdCont) {
                        $tpl->MS_COMA = $w < $qtdRgi ? "," : "";
                    }
                    $w++;
                    $tpl->block('MAGIC_SUGGEST');
                }
            }
            //$tpl->block('EACH_OPTGROUP');
Ejemplo n.º 5
0
 if ($_GET['ano'] >= 2012 && $_GET['ano'] <= Date('Y')) {
     $uoid = (int) $_GET['uo'];
     $getAno = $_GET['ano'];
     //$tpl->UCID  = $ucid;
     $tpl->GETANO = $getAno;
     $uo = new Unidade($uoid);
     $consChart = array();
     if ($uo->getSigla() != "") {
         $ucs = $uo->getAllUcs();
         $tpl->UONOME = $uo->getSigla() . " - " . $uo->getNome();
         $tpl->UOFORMNOME = $uo->getSigla() . " | " . $uo->getNome();
         $tpl->UOFORMID = $uoid;
         $tpl->block('EACHUOFORM');
         $arrayUcs;
         foreach ($ucs as $ucid) {
             $uc = new UnidadeConsumidora($ucid);
             $arrayUcs[$uc->get('tipo')][$uc->get('id')]['rgi'] = $uc->get('rgi');
             $arrayUcs[$uc->get('tipo')][$uc->get('id')]['nome'] = $uc->getNome();
             $arrayUcs[$uc->get('tipo')][$uc->get('id')]['empresa'] = $uc->get('empresa')->getNome();
             $arrayUcs[$uc->get('tipo')][$uc->get('id')]['mensal'] = $uc->getExercicioMensal($getAno);
         }
         $totalGeral[1] = 0;
         $totalGeral[2] = 0;
         $totalGeral[3] = 0;
         $totalGeral[4] = 0;
         $totalGeral[5] = 0;
         $totalGeral[6] = 0;
         $totalGeral[7] = 0;
         $totalGeral[8] = 0;
         $totalGeral[9] = 0;
         $totalGeral[10] = 0;
Ejemplo n.º 6
0
 $queryVerif = mysql_query("SELECT id FROM daee_uddc WHERE SHA1(id) = '" . $_GET['chave'] . "'");
 $tpl->CHAVE = $chave;
 if (mysql_num_rows($queryVerif)) {
     /***********************
     			 MOSTRAR MENU COM ANOS
     			***********************/
     $iMin = 2012;
     $iCalc = $anoAtual - 5;
     $iFor = $iCalc < $iMin ? $iMin : $iCalc;
     for ($i = $iFor; $i <= Date('Y'); $i++) {
         $tpl->ITEM_MENU_URL = "resumo_uc.php?chave=" . $_GET['chave'] . "&ano=" . $i;
         $tpl->ITEM_MENU_LINK = $i;
         $tpl->block('ITEM_MENU');
     }
     $id = mysql_fetch_array($queryVerif)['id'];
     $uc = new UnidadeConsumidora($id);
     $contrato = $uc->get('contrato');
     if ($_SESSION['bacia'] == $uc->get('uo')->get('id') || $_SESSION['nivel'] == 1) {
         $tpl->addFile('CONTEUDO', 'html_libs/resumo_uc.html');
         /*********************************
         		  MOSTRAR INFORMAÇÕES DO RELATÓRIO
         		 *********************************/
         $rel = new Relatorio();
         $cores = $rel->cores;
         $tpl->UCCOLOR = $cores[$uc->get('tipo')];
         $tpl->ANO = $anoAtual;
         $tpl->ANO_ANT = $anoAnterior;
         $tpl->TIPOCONS = $uc->getTipoMedida();
         $tpl->RGI = $uc->get('rgi');
         $tpl->NOME = $uc->getNome();
         $tpl->TIPONOME = $uc->getTipoNome();
Ejemplo n.º 7
0
 			**********************************/
 $uo = new Unidade($id);
 if (in_array($svc, $uo->getTiposServicos())) {
     $tpl->PERIODO = $start;
     $tpl->UOSIGLA = $uo->getSigla();
     $numMeses = 12 * (Date('Y') - $start) + Date('n');
     $ucTipo = new UnidadeConsumidora(0, null, null, null, null, null, null, null, null, null, null, $svc);
     $tpl->TIPONOME = $ucTipo->getTipoNome();
     $ucids = $ucTipo->getMesmoTipoPorUO($id);
     $tpl->UCQTD = count($ucids);
     $tpl->RGISINSTA = "";
     /*********************************
     			 MONTAR ARRAY COM TODOS OS VALORES
     			**********************************/
     foreach ($ucids as $ucid) {
         $uc = new UnidadeConsumidora($ucid);
         $tpl->RGISINSTA .= "<br />" . $uc->getAtivoText() . " - <a href='udd_ucDetalhes.php?chave=" . sha1($uc->get('id')) . "'>";
         $tpl->RGISINSTA .= $uc->get('rgi') . " - " . $uc->getNome() . "</a> ";
         //. $uc->getVariacaoDoMes(1, 2013)
         $tpl->TIPOCONS = $uc->getTipoMedida();
         $exerc_atu = $uc->getExercicioMensal($start);
         $exerc_ant = $uc->getExercicioMensal($start - 1);
         $mes_atu = Date('n');
         $tpl->ANO_ANT = $start - 1;
         $tpl->ANO = $start;
         $tpl->MED_LAB = 'Média ' . $start;
         for ($i = 1; $i <= 12; $i++) {
             if (array_key_exists($i, $exerc_ant)) {
                 $ucArray[$ucid][$start - 1]['consumo'][$i] = $exerc_ant[$i]['consumo'];
                 $ucArray[$ucid][$start - 1]['valor'][$i] = $exerc_ant[$i]['valor'];
             } else {
Ejemplo n.º 8
0
// SETAR PERMISSÃO DA PÁGINA
$inicio = execucao();
$tpl = new Template('html_libs/template.html');
$tpl->addFile('SECONDMENU', 'html_libs/udd_secondMenu.html');
$tpl->addFile('JSCRIPT', 'cssjs_libs/js_parts/js_udd_ucDetalhes.html');
$anoAtual = isset($_GET['ano']) ? $_GET['ano'] : Date('Y');
$anoAtual = $anoAtual >= 2012 ? $anoAtual : Date('Y');
if (isset($_GET['chave'])) {
    $chave = mysql_real_escape_string($_GET['chave']);
    if (strlen($chave) == 40) {
        $tpl->addFile('CONTEUDO', 'html_libs/udd_ucDetalhes.html');
        $queryVerif = mysql_query("SELECT id FROM daee_uddc WHERE SHA1(id) = '" . $_GET['chave'] . "'");
        $tpl->CHAVE = $chave;
        if (mysql_num_rows($queryVerif)) {
            $id = mysql_fetch_array($queryVerif)['id'];
            $uc = new UnidadeConsumidora($id);
            /*********************************
            		  MOSTRAR INFORMAÇÕES DO RELATÓRIO
            		 *********************************/
            $tpl->ANO = $anoAtual;
            $tpl->ANO_ANT = $anoAtual - 1;
            $tpl->TIPOCONS = $uc->getTipoMedida();
            $tpl->RGI = $uc->get('rgi');
            $tpl->NOME = $uc->getNome();
            $tpl->TIPONOME = $uc->getTipoNome();
            $tpl->EMPRESA = $uc->get('empresa')->getNome() . " CNPJ " . $uc->get('empresa')->transformCnpj($uc->get('empresa')->get('cnpj'));
            $tpl->ENDERECO = $uc->getEndereco() . " - " . $uc->getCidadeNome();
            $tpl->CONTRATO = $uc->get('contrato')->geraNome();
            $tpl->UNIDADE = $uc->get('uo')->getSigla();
            $eachMes = $uc->getExercicioMensal($anoAtual);
            //print_r($eachMes);
Ejemplo n.º 9
0
<?php

require "src/scripts/conecta.php";
require "src/scripts/functions.php";
include_once "src/classes/Users.class.php";
include_once "src/classes/Notas.class.php";
include_once "src/classes/UnidadeCons.class.php";
/**************************************************
	 ARQUIVO DE SCRIPTS DE AÇÃO RECEBIDOS POR S_POST
	**************************************************/
if (getenv("REQUEST_METHOD") == "POST") {
    if (isset($_POST['action'])) {
        switch ($_POST['action']) {
            case "verificaNota":
                $uc = new UnidadeConsumidora($_POST['ucid']);
                echo $uc->isNotaRegistered($_POST['data']);
                break;
            case "marcarPago":
                $data = getTransformDate($_POST['data']);
                $nota = new Nota($_POST['nid']);
                $nota->marcarPago($data);
                echo "<font color='red'>" . $_POST['data'] . "</font>";
                break;
            case "getProvs":
                $autos = (int) $_POST['autos'];
                $sql = "SELECT DISTINCT(provisoria) FROM daee_notas WHERE contrato = {$autos} ORDER BY provisoria DESC";
                $query = mysql_query($sql);
                if (mysql_num_rows($query) > 0) {
                    while ($prov = mysql_fetch_array($query)) {
                        $num = $prov['provisoria'];
                        if ($num == 0) {
Ejemplo n.º 10
0
// SETAR PERMISSÃO DA PÁGINA
$inicio = execucao();
$tpl = new Template('html_libs/template.html');
$tpl->addFile('SECONDMENU', 'html_libs/udd_secondMenu.html');
$tpl->addFile('CONTEUDO', 'html_libs/udd_relatorioUO.html');
$tpl->addFile('JSCRIPT', 'cssjs_libs/js_parts/js_udd_relatorioUO.html');
$anoAtual = isset($_GET['ano']) ? $_GET['ano'] : Date('Y');
$sqlTipos = "SELECT DISTINCT(tipo) FROM daee_uddc ORDER BY tipo";
$queryTipos = mysql_query($sqlTipos);
$tpl->DISTINCT_TYPE = $numtipos = mysql_num_rows($queryTipos);
$tpl->ANO = $anoAtual;
$x = 0;
$eachTotal;
$tiposArray;
while ($tipos = mysql_fetch_array($queryTipos)) {
    $ucTipo = new UnidadeConsumidora(0, null, null, null, null, null, null, null, null, null, null, $tipos['tipo']);
    $tpl->DISTINCT_NOME = $ucTipo->getTipoNome();
    $tpl->block("EACH_DISTINCT");
    $eachTotal[$x] = 0;
    $tiposArray[] = $ucTipo->getTipoNome();
    $x++;
}
$sqlUo = "SELECT id FROM daee_udds ORDER BY id";
$queryUo = mysql_query($sqlUo);
$uctotal = 0;
$eachUoByType;
// array para mostrar nos gráficos
$eachTotalPorUnidade;
// array com cada total por unidade
while ($uoArray = mysql_fetch_array($queryUo)) {
    $uo = new Unidade($uoArray['id']);
Ejemplo n.º 11
0
--SELECT sum(n.valor) FROM daee_uddc c, daee_notas n WHERE c.id = n.uc AND n.mes_ref = 7 AND n.ano_ref = 2013
*/
redirectByPermission(1);
// SETAR PERMISSÃO DA PÁGINA
$inicio = execucao();
$tpl = new Template('html_libs/template.html');
$tpl->addFile('SECONDMENU', 'html_libs/udd_secondMenu.html');
$tpl->addFile('JSCRIPT', 'cssjs_libs/js_parts/js_rel_evolServico.html');
$tpl->addFile('CONTEUDO', 'html_libs/rel_evolServico.html');
$tiposArray;
$sqlTipos = "SELECT DISTINCT(tipo) FROM daee_uddc ORDER BY tipo";
$queryTipos = mysql_query($sqlTipos);
if (mysql_num_rows($queryTipos) > 0) {
    while ($tipos = mysql_fetch_array($queryTipos)) {
        $ucTipo = new UnidadeConsumidora(0, null, null, null, null, null, null, null, null, null, null, $tipos['tipo']);
        $tpl->TIPOID = $tipos['tipo'];
        $tpl->TIPONOME = $ucTipo->getTipoNome();
        $tiposArray[$tipos['tipo']] = $ucTipo->getTipoNome();
        $tpl->block('EACH_TIPOSERV');
    }
}
if (isset($_GET['servico'])) {
    $tipoServ = $_GET['servico'];
    if (array_key_exists($tipoServ, $tiposArray)) {
        $tpl->TITULO_EVO = $tiposArray[$tipoServ];
        $tpl->block('AREA_CHART');
        $ano_x = Date('Y') - 1;
        $mesAtual = Date('n');
        $tpl->ANO_ANT = "Jan/" . $ano_x;
        $tpl->ANO_ATU = getMesNome($mesAtual) . "/" . ($ano_x + 1);
Ejemplo n.º 12
0
             $tipo = (int) $_POST['tipo'];
             $vencto = (int) $_POST['vencto'];
             $contrato = (int) $_POST['contrato'];
             $end = mysql_real_escape_string($_POST['end']);
             $num = (int) $_POST['numero'];
             $compl = mysql_real_escape_string($_POST['compl']);
             $cidade = (int) $_POST['cidade'];
             $udd = (int) $_POST['unidade'];
             $lat = $_POST['lat'];
             $long = $_POST['long'];
             $empresa = (int) $_POST['empresa'];
             if ($rgi == "" || $vencto == "" || $contrato == "" || $end == "" || $cidade == "" || $udd == "") {
                 $alerta .= "Preencha todos os campos marcados como obrigatórios. <br />";
                 $valid++;
             }
             $ver = new UnidadeConsumidora('1');
             if ($ver->verificaExiste($rgi, $contrato)) {
                 $valid++;
                 $alerta .= "Já existe uma Unidade Consumidora com o mesmo RGI/Instalação";
             }
             if ($valid < 1) {
                 $uddc = new UnidadeConsumidora('', $rgi, $end, $num, $compl, $contrato, $vencto, $udd, $cidade, $lat, $long, $tipo, $empresa);
                 $tpl->AVISO = "Unidade Consumidora criada com sucesso!" . mysql_error();
             } else {
                 $tpl->ALERTA = $alerta;
             }
         } else {
             $tpl->ALERTA = "Houve um erro ao receber os dados.";
         }
     }
 }