$tpl->ALERTA = "Houve um erro: " . mysql_error();
            }
        }
    } else {
        $tpl->ALERTA = "Número de Alertas: " . 1 . "<br />Algum campo obrigatório não foi preenchido. " . $_POST['rgi'] . $_POST['nota'] . $_POST['mes_ref'] . $_POST['ano_ref'] . $_POST['emissao'] . $_POST['vencto'] . $_POST['valor'] . "--";
    }
}
/***************************************************
	  MOSTRAR TODOS OS RGI OU DESABILITAR COM APENAS UM
	***************************************************/
$sql_verif;
if (isset($_GET['dataref']) && count(explode('-', $_GET['dataref'])) == 2 || isset($_SESSION['data_ref'])) {
    $data_ref = isset($_GET['dataref']) ? explode('-', $_GET['dataref']) : explode('-', $_SESSION['data_ref']);
    $mes = $data_ref[0] > 0 && $data_ref[0] < 13 ? (int) $data_ref[0] : 1;
    $ano = $data_ref[1] > 2000 ? (int) $data_ref[1] : date('Y');
    $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');