$tpl->MES_ANT = getMesNome($mes_ant, false); $tpl->ANO = $ano; } for ($i = 1; $i <= 12; $i++) { $tpl->MESREF = $i . "-" . Date('Y'); $tpl->MESANOREF = getMesNome($i) . "/" . Date('y'); $tpl->block('EACH_MESMENU'); } $sql_cont = $_SESSION['nivel'] != 1 ? "SELECT id FROM daee_contratos WHERE permissao={$nivel}" : "SELECT id FROM daee_contratos"; $query_cont = mysql_query($sql_cont); $qtd = 0; if (mysql_num_rows($query_cont) > 0) { $i = 1; while ($res = mysql_fetch_array($query_cont)) { $contrato = new Contrato($res['id']); $tpl->AUTOS = $i . " - " . $contrato->geraNome(); $ucs = $contrato->getFaltaNotas($mes_ant, $ano); if (count($ucs) > 0) { if ($ucs[0]['ucid'] != null) { foreach ($ucs as $uc) { $tpl->RGI = $uc['rgi']; $tpl->ENDERECO = $uc['endereco']; $tpl->ID = $uc['ucid']; $tpl->MES_ANO = $mes_ant . "-" . $ano; $tpl->block('EACH_FALTA'); $qtd++; } } } $tpl->block("EACH_CONTRATO"); $i++;
// SETAR PERMISSÃO DA PÁGINA $tpl = new Template('html_libs/template.html'); $tpl->addFile('SECONDMENU', 'html_libs/ger_secondMenu.html'); if (!isset($_GET['form'])) { $tpl->addFile('CONTEUDO', 'html_libs/ger_addContrato.html'); $sql = "SELECT id FROM daee_contratos WHERE ativo = 1"; $query = mysql_query($sql); while ($res = mysql_fetch_array($query)) { $tpl->CONTID = $res['id']; $cont = new Contrato($res['id']); $autos = $cont->isAutos() ? "Autos " : "Processo "; $num = $cont->isAutos() ? number_format($cont->get('numero'), 0, ',', '.') : $cont->get('numero'); $nome = $cont->get('nome'); $servico = $cont->get('empresa')->getServicos()[$cont->get('servico')]->children(); //$tpl->CONTNOME = $autos." n°".$num." - ".$nome."::".$servico; $tpl->CONTNOME = $cont->geraNome(); $tpl->CONTCONT = $cont->get('contrato'); $tpl->CONTEMP = $cont->get('empresa')->getNome(); $tpl->CONTLICIT = $cont->get('comlicit') == 1 ? "Sim" : "Não"; $de = $cont->get('data'); $ate = $cont->get('vigencia'); $tpl->CONTVIG = $de == "0000-00-00" ? "--" : $de . " a " . $ate; $tpl->CONTEM = ExplodeDateTime($cont->get('criado')); $tpl->CONTUDD = $cont->get('unidade')->getSigla(); $tpl->block('EACH_CONTRATO'); } } else { $tpl->addFile('CONTEUDO', 'html_libs/ger_addContrato-form.html'); $emp = new Empresa(); $alerta = ""; $valid = 0;
$tpl->DISABLE_DATAREF = 'disabled="disabled"'; $tpl->MES = $mes; $tpl->MESNOME = getMesNome($mes, false); $tpl->block('EACH_MESREF'); $tpl->ANO = $ano; $tpl->block('EACH_ANOREF'); $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'); $w++; } } $tpl->block('EACH_OPTGROUP');
**********************/ for ($i = 1; $i <= 12; $i++) { $tpl->MES_NUM = $i; $tpl->MES_NOME = getMesNome($i, false); $tpl->block('EACH_MES_FORM'); } for ($i = 2012; $i <= Date('Y'); $i++) { $tpl->ANO_NUM = $i; $tpl->block("EACH_ANO_FORM"); } if (getenv("REQUEST_METHOD") == "POST") { if (isset($_POST['autos'], $_POST['prov'])) { $autos = (int) $_POST['autos']; $prov = (int) $_POST['prov']; $cont = new Contrato($autos); $tpl->AUTOS = $cont->geraNome(); if (isset($_POST['mes_ref'], $_POST['ano_ref']) && $_POST['mes_ref'] != "" && $_POST['ano_ref'] != "") { $mes_post = (int) $_POST['mes_ref']; $ano_post = (int) $_POST['ano_ref']; $notas = $cont->getAllNotasforDof($prov, $mes_post, $ano_post); } else { $notas = $cont->getAllNotasforDof($prov); } if (count($notas) > 0) { if ($notas[0]['id'] != null) { foreach ($notas as $nota) { $tpl->UO = $nota['unidade']; $tpl->UC = $nota['rgi'] . " - [ <small>" . $nota['compl'] . "</small> ]"; $tpl->EMPRESA = $nota['nome']; $tpl->DATAREF = getMesNome($nota['mes_ref']) . "/" . $nota['ano_ref']; $tpl->CONSUMO = tratarValor($nota['consumo']);
$i = 0; $rel = new Relatorio(); $rel->setUdds(); $udds = $rel->udds; $cores = $rel->cores; $tipos = $rel->ucTipos; if (mysql_num_rows($query_cont) > 0) { while ($res = mysql_fetch_array($query_cont)) { $contrato = new Contrato($res['id']); $notas = $contrato->getFaltaNotas($mes, $ano); if ($notas[0]['ucid'] != null) { $qtd += count($notas); foreach ($notas as $nota) { $consTipo = $nota['tipo']; $tpl->UO = $udds[$nota['uo']]; $tpl->AUTOS = $contrato->geraNome(); $tpl->UC = "<b>" . $nota['rgi'] . "</b> - [ <small>" . $nota['endereco'] . "</small> ]"; $tpl->UC .= "<br /><small><font color='" . $cores[$consTipo] . "'>" . $tipos[$consTipo] . "</font></small>"; $tpl->VENCTO = setDateDiaMesAno($nota['vencto']); $i++; $tpl->INDEX = $i; $tpl->block('EACH_NOTAS'); } } } } $tpl->NOTAQTD = $qtd; $tpl->block("RESULT_BLOCK"); } } $fim = execucao();