?>
 <table width="300" align="center" border="0" bordercolor="#cccccc" cellpadding="2" cellspacing="0" class="texto">
  <tr height="220">
   <td align="center">
    <img src="imagens/atencao.gif"><br>
    Para acessar suas informações, efetue login.
   </td>
  </tr>
 </table>
<?php 
} elseif ($w13_permfornsemlog == "t") {
    //verifica se está logado
    if (@$codigo_cgm != "" || @$_COOKIE["cookie_codigo_cgm"] != "") {
        $usuario = $codigo_cgm == "" ? $_COOKIE["cookie_codigo_cgm"] : $codigo_cgm;
        // die($clcgm->sql_query("","cgm.z01_cgccpf, cgm.z01_nome, cgm.z01_numcgm","","cgm.z01_numcgm = $usuario"));
        $result = $clcgm->sql_record($clcgm->sql_query("", "cgm.z01_cgccpf, cgm.z01_nome, cgm.z01_numcgm", "", "cgm.z01_numcgm = {$usuario}"));
        $linhas = $clcgm->numrows;
        if ($linhas != 0) {
            db_fieldsmemory($result, $x);
            //11 14
            if (strlen($z01_cgccpf) > 11) {
                $cgc = $z01_cgccpf;
                $cpf = "";
            } else {
                $cgc = "";
                $cpf = $z01_cgccpf;
            }
            db_redireciona("digitafornecedor.php?id_usuario={$z01_numcgm}&cpf={$cpf}&cgc={$cgc}");
        }
    } else {
        ?>
if (@$_COOKIE["cookie_codigo_cgm"] == "") {
    // issbase
    if (@$inscricaow != "") {
        @($result = $clissbase->sql_record($clissbase->sql_query("", "cgm.z01_numcgm,cgm.z01_nome", "", "issbase.q02_inscr = {$inscricaow} and trim(cgm.z01_cgccpf) = '{$cgccpf}'")));
        @($linhas1 = $clissbase->numrows);
    } else {
        if (!empty($codigo_cgm) || !empty($cgc) || !empty($cpf)) {
            //CGM
            if (!empty($codigo_cgm)) {
                $condicao = "cgm.z01_numcgm = {$codigo_cgm}";
            } else {
                if (!empty($cgccpf)) {
                    $condicao = "trim(cgm.z01_cgccpf) = '{$cgccpf}'";
                }
            }
            @($result = $clcgm->sql_record($clcgm->sql_query("", "cgm.z01_numcgm,cgm.z01_nome", "", $condicao)));
            @($linhas2 = $clcgm->numrows);
        } else {
            if (@$matricula1 != "") {
                //Matricula
                $sql_exe = " select cgm.*\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   ";
                $sql_exe .= "   from fc_busca_envolvidos(false,{$db21_regracgmiptu},'M',{$matricula1}) ";
                $sql_exe .= "\t\t inner join cgm on z01_numcgm = rinumcgm\t\t\t\t           ";
                $sql_exe .= "  where rimatric = {$matricula1}\t\t \t\t\t\t\t\t\t\t   ";
                if ($sConfig["w13_exigecpfcnpjmatricula"] == "t") {
                    $sql_exe .= " and trim(z01_cgccpf) = '{$cgccpf}' ";
                }
                $result = db_query($sql_exe);
                $linhas3 = pg_num_rows($result);
            }
        }
$Letra = 'arial';
$pdf->SetFont($Letra, 'B', 8);
$pdf->Open();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFillColor(235);
$sSql = "select * \n            from db_config \n           where codigo = " . db_getsession('DB_instit');
$rsSql = pg_query($sSql);
if (pg_numrows($rsSql) > 0) {
    db_fieldsmemory($rsSql, 0);
}
$total = 0;
if ($cllistainscr->numrows > 0) {
    db_fieldsmemory($result, 0);
    $result1 = $clcgm->sql_record($clcgm->sql_query($p11_numcgm));
    db_fieldsmemory($result1, 0);
    $pdf->MultiCell(190, 4, "" . $z01_nome . ", vem pela presente requerer habilitação e/ou desabilitação de acesso via internet do Cadastro Fiscal do Município de " . @$munic . " ( " . @$url . "/dbpref) dos contribuintes a seguir relacionados conforme o tipo de lançamento:", 0, "J", 0, 15);
    $pdf->ln(5);
    $posicao = $pdf->getY();
    $pdf->SetFont($Letra, 'B', 7);
    $pdf->SetFillColor(235);
    $pdf->Cell(25, 4, "INSCRIÇÃO ", 1, 0, "C", 1);
    $pdf->Cell(35, 4, "CNPJ / CPF", 1, 0, "C", 1);
    $pdf->Cell(26, 4, "TELEFONE ", 1, 0, "C", 1);
    $pdf->Cell(70, 4, "NOME ", 1, 0, "C", 1);
    $pdf->Cell(34, 4, "TIPO LANÇAMENTO ", 1, 1, "C", 1);
    $pdf->SetFillColor(255);
    for ($x = 0; $x < $numrows; $x++) {
        $total += $i;
        db_fieldsmemory($result, $x);
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td height="60" align="<?php 
    echo $DB_align1;
    ?>
">
                    <?php 
    echo $DB_mens1;
    ?>
                  </td>
                </tr>
                <tr> 
                  <td align="center" valign="top">
                  <?php 
    $clcgm = new cl_cgm();
    $result = $clcgm->sql_record($clcgm->sql_query($z01_numcgm));
    //die($clcgm->sql_query($z01_numcgm));
    if ($clcgm->numrows > 0) {
        db_fieldsmemory($result, 0);
        echo "<p><font size='2'><strong>Escritório Contábil</strong> " . @$z01_nome . "</font></p>";
        $sqllista = "select * from listainscrcab where p11_numcgm={$z01_numcgm}";
        // die($sqllista);
        $result = pg_query($sqllista);
        $linhas = pg_num_rows($result);
        if ($linhas > 0) {
            // se existir lista ... verificar se tem lista em aberto
            $sql = "select * from listainscrcab where p11_numcgm={$z01_numcgm} and p11_fechado is false and p11_processado is false";
            $result = pg_query($sql);
            $linhas2 = pg_num_rows($result);
            //db_fieldsmemory($result,0);
            if ($linhas == 0) {
}
$db_verificaip = db_verifica_ip();
mens_help();
$dblink = "atualizaendereco.php";
db_logs("", "", 0, "Atualiza endereço CGM.");
db_mensagem("endereco_cab", "endereco_rod");
if ($db_verificaip == "0") {
    $onsubmit = "onsubmit=\"return js_verificaCGCCPF((this.cgc.value==''?'':this.cgc),'');\"";
} else {
    $onsubmit = "";
}
parse_str(base64_decode($HTTP_SERVER_VARS["QUERY_STRING"]));
if ($cgmlogin == "") {
    db_redireciona("centro_pref.php");
} else {
    $result = $cl_cgm->sql_record($cl_cgm->sql_query("", "*", "", "cgm.z01_numcgm = {$cgmlogin}"));
    if ($cl_cgm->numrows != 0) {
        db_fieldsmemory($result, 0);
        $w11_cgccpf = $z01_cgccpf;
    }
}
////gravar
if (isset($incluir)) {
    @($result2 = $cldb_cgmatualiza->sql_record($cldb_cgmatualiza->sql_query("", "*", "", "w11_numcgm = {$cgmlogin}")));
    db_inicio_transacao();
    if ($cldb_cgmatualiza->numrows == 0) {
        //insert
        $cldb_cgmatualiza->incluir(null);
        //cgmatualizaliga se cgm não for novo
        if ($w11_cgmnovo == "f") {
            $cldb_cgmatualizaliga->w12_cgmatualiza = $cldb_cgmatualiza->w11_sequencial;
                    }
                    if (!isset($z01_numcgm)) {
                        $z01_numcgm = $q02_numcgm;
                    }
                }
            }
        }
    }
}
db_fim_transacao(false);
/**
 * GERA PDF
 */
$cl_cgm = new cl_cgm();
if (isset($z01_numcgm) || @$z01_numcgm != null || @$z01_numcgm != '') {
    $sSqlIdent = $cl_cgm->sql_query("", "*", "", "z01_numcgm = {$z01_numcgm}");
} else {
    $sSqlIdent = $cl_cgm->sql_query("", "*", "", "z01_cgccpf = '{$z01_cgccpf}'");
}
//die($sSqlIdent);
$rsIdent = $cl_cgm->sql_record($sSqlIdent);
if ($cl_cgm->numrows > 0) {
    db_fieldsmemory($rsIdent, 0);
}
$z01_cgmpri = $z01_numcgm;
$sqlDbconfig = "select * from db_config where codigo = " . db_getsession('DB_instit');
$rsDbconfig = db_query($sqlDbconfig);
db_fieldsmemory($rsDbconfig, 0);
/**
 *  Criada este select apenas para corrigir o nome na identificação do contribuinte
 *  de acordo com a configuração encontrada no campo (db21_regracgmiptu) na tabela db_config