1)    sDocI            ; ($_POST[.]!='')   ; "a.sDoc>='".$_POST[.]."'" 
   sDocF            ; ($_POST[.]!='')   ; "a.sDoc<='".$_POST[.]."'" 
   pPIdDe           ; ($_POST[.]>0)     ; "a.pPId >= ".$_POST[.]
   pPIdAte          ; ($_POST[.]>0)     ; "a.pPId <= ".$_POST[.]
   pCedente         ; ($_POST[.]>0)     ; "a.pCedente = ".$_POST[.]
   pSacado          ; ($_POST[.]>0)     ; "a.pSacado  = ".$_POST[.]
   pTOper           ; ($_POST[.]>0)     ; "a.pTOper   = ".$_POST[.]
   pCC              ; ($_POST[.]>0)     ; "a.pCC      = ".$_POST[.]
   pTipoCob         ; ($_POST[.]>0)     ; "a.pTipoCob = ".$_POST[.]
   iIde_nNFDe       ; ($_POST[.]>0)     ; "a.iIde_nNF  >= ".$_POST[.]
   iIde_nNFAte      ; ($_POST[.]>0)     ; "a.iIde_nNF  <= ".$_POST[.]
   iIdIFCDe         ; ($_POST[.]>0)     ; "a.pIFC_Order  >= ".$_POST[.]
   iIdIFCAte        ; ($_POST[.]>0)     ; "a.pIFC_Order  <= ".$_POST[.]
   sNrIFCDe         ; ($_POST[.]!='')     ; "a.pIFC_Order in (select pPId from IFC_Order where sOrderId='$_POST[.]' and iVer=iVAt)"
   pForGrupo        ; ($_POST[.]>0)     ; "b.pCliGrupo   = ".$_POST[.]
   pCliGrupo        ; ($_POST[.]>0)     ; "c.pCliGrupo   = ".$_POST[.]
   dVenc1           ; ($_POST[.]!='')   ; "cast(a.tVenc as date)>= '".$_POST[.]."'"
   dVenc2           ; ($_POST[.]!='')   ; "cast(a.tVenc as date)<= '".$_POST[.]."'"
   dPgmto1          ; ($_POST[.]!='')   ; "cast(a.tPgmto as date)>= '".$_POST[.]."'"
   dPgmto2          ; ($_POST[.]!='')   ; "cast(a.tPgmto as date)<= '".$_POST[.]."'"
   dAgend1          ; ($_POST[.]!='')   ; "cast(a.tAgend as date)>= '".$_POST[.]."'"
   dAgend2          ; ($_POST[.]!='')   ; "cast(a.tAgend as date)<= '".$_POST[.]."'"
   dEmissao1        ; ($_POST[.]!='')   ; "cast(a.tEmissao as date)>= '".$_POST[.]."'"
   dEmissao2        ; ($_POST[.]!='')   ; "cast(a.tEmissao as date)<= '".$_POST[.]."'"
   dIde_Emi1        ; ($_POST[.]!='')   ; "cast(a.tIde_Emi as date)>= '".$_POST[.]."'"
   dIde_Emi2        ; ($_POST[.]!='')   ; "cast(a.tIde_Emi as date)<= '".$_POST[.]."'"
   sIncd1           ; ($_POST[.]!='')   ; "a.tInc>= '".$_POST[.]."'"
   sIncd2           ; ($_POST[.]!='')   ; "a.tInc<= '".$_POST[.]."'"
   sDescricao       ; ($_POST[.]!='')   ; "a.sDescricao = '".$_POST[.]."'" 
   jTipo2           ; ($_POST[.]==0)    ; "a.tPgmto is not null" 
   jTipo2           ; ($_POST[.]==1)    ; "a.tPgmto is     null"
   jOrcNA           ; ($_POST[.]==1)    ; "a.lOrcNA = 1" 
   jOrcNA           ; ($_POST[.]==2)    ; "a.lOrcNA = 0"
   jIFC             ; ($_POST[.]==1)    ; "a.lIFC = 1" 
   jIFC             ; ($_POST[.]==2)    ; "a.lIFC = 0"
   jTM              ; ($_POST[.]==1)    ; "a.lTM = 1" 
   jTM              ; ($_POST[.]==2)    ; "a.lTM = 0"
   jCanc            ; ($_POST[.]==0)    ; "a.tCanc is     null" 
   jCanc            ; ($_POST[.]==1)    ; "a.tCanc is not null"
   jProrrog         ; ($_POST[.]==1)    ; "a.tVenc  <> a.tVenc0" 
   jProrrog         ; ($_POST[.]==2)    ; "a.tVenc  =  a.tVenc0"
   jPrevisao        ; ($_POST[.]==0)    ; "a.lPrevisao=0" 
   jPrevisao        ; ($_POST[.]==1)    ; "a.lPrevisao=1"
   jPrevisao        ; ($_POST[.]==2)    ; "a.lPrevisao in (0,1)"
   jOri             ; ($_POST[.]==0)    ; "a.jOri=0" 
   jOri             ; ($_POST[.]==1)    ; "a.jOri=1"
   pCCusto          ; ($_POST[.]>0)     ; "a.pPId in (select pTFin from FIN_Titulos_CCusto where pCCusto=$_POST[.] and iVer=iVAt)"
   pCPla            ; ($_POST[.]>0)     ; "a.pPId in (select pTFin from FIN_Titulos_CContabil where pCPla=$_POST[.] and iVer=iVAt and lExc=0)" 
   pPreNFDe         ; ($_POST[.]>0)     ; "a.pPreNF >= ".$_POST[.]
   pPreNFAte        ; ($_POST[.]>0)     ; "a.pPreNF <= ".$_POST[.]
   pOrdemDe         ; ($_POST[.]>0)     ; "a.pOrdem >= ".$_POST[.]
   pOrdemAte        ; ($_POST[.]>0)     ; "a.pOrdem <= ".$_POST[.]
   jGerBol          ; ($_POST[.]==1)    ; "a.tEnvBol is not null" 
   jGerBol          ; ($_POST[.]==2)    ; "a.tEnvBol is null"
   jGerRem          ; ($_POST[.]==1)    ; "a.tEnvCnab is not null" 
   jGerRem          ; ($_POST[.]==2)    ; "a.tEnvCnab is null"
   jGerRemAlt       ; ($_POST[.]==1)    ; "(a.jRemCodOco>0 and a.tRemEnvAltTit is not null)"
   jGerRemAlt       ; ($_POST[.]==2)    ; "(a.jRemCodOco>0 and a.tRemEnvAltTit is null)"
   pVerbaDe         ; ($_POST[.]>0)     ; "a.pVerba >= ".$_POST[.]
   pVerbaAte        ; ($_POST[.]>0)     ; "a.pVerba <= ".$_POST[.]
   sRaizCNPJ        ; ($_POST[.]>0)     ; "substring(c.sCNPJ from 1 for 8) = '".$_POST[.]."'"
   lIndef           ; ($_POST[.]>0)     ; "a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
   lBol             ; ($_POST[.]>0)     ; "a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
   lCred            ; ($_POST[.]>0)     ; "a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
   lTribCB          ; ($_POST[.]>0)     ; "a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
   lTribSB          ; ($_POST[.]>0)     ; "a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")" 
   lCon             ; ($_POST[.]>0)     ; "a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
   pAut3            ; ($_POST[.]>0)     ; "a.pAut3=".$_POST[.]
   jCCDefault       ; ($_POST[.]==1)    ; "a.jCCDefault=0"
   jCCDefault       ; ($_POST[.]==2)    ; "a.jCCDefault=1"
2)    select a.sDoc,
          a.tIn0,
          a.jTipo,
          a.pCedente,
          a.pSacado,
          a.tEmissao,
          a.tEnvCnab,
          a.tEnvBol,
          a.tRestr,
          a.tLibRestr,
          b.sCoringa sCedente,
          b.sCNPJ    sCNPJCedente,
          b.sCPF     sCPFCedente,
          b.sAgencia    sAgenciaCedente,
          b.lAgencia    lAgenciaCedente,
          c.sCoringa sSacado,
          c.sCNPJ    sCNPJSacado,
          c.sCPF     sCPFSacado, 
          c.sAgencia    sAgenciaSacado,
          c.lAgencia    lAgenciaSacado,
          a.pCapa,
          a.lCapa,
          a.tVenc,
          a.tVenc0,
          a.nVenc,
          a.jOri,
          a.tCanc  dCanc,
          a.tPgmto,
          a.nPgmto,
          a.lPrevisao,
          a.iIde_nNF,
          a.pOrdem,
          a.pNFe,
          a.pPreNF,
          a.pTransf,
          a.pContr,
          a.iPrest,
          a.iNrPrest,
          a.tAgend,
          a.pTOper,
          d.sDescricao sTOper,
          d.sCodigo    sCodTOper,
          a.iNfNFs,
          a.pTipoCob,
          e.sDescricao  sTipoCob,
          e.sCodigo     sCodTipoCob,
          a.fTipoCob,
          g.sCC        sCC,
          g.sDac       sDac,
          h.sAgencia   sAgeNr,
          h.sCoringa   sAge,
          h.pBanco     pBanco,
          h.fBanco     fBanco,
          i.sCodigo    sCodBanco,
          i.sDescricao sDesBanco, 
          a.pCC,
          c.pCliGrupo,
          l.sGrupo sCliGrupo,
          b.pForGrupo,
          j.sGrupo sForGrupo,
          r.tConf      tOrdemConf,
          a.pTFinOrig,
          a.lOrcNA,
          a.pPId 
   from FIN_Titulos a left join TOper           d on a.pTOper    = d.pPId and d.iVer = d.iVAt
                       left join CC             g on a.pCC       = g.pPId and g.iVer = g.iVAt
                       left join CUP            h on g.pAgencia  = h.pPId and h.iVer = h.iVAt
                       left join Banco          i on h.pBanco    = i.pPId and i.iVer = i.iVAt
                       left join Tipo_Cobrancas e on a.pTipoCob  = e.pPId and e.iVer = e.iVAt
                       left join Ordens         r on a.pOrdem    = r.pPId and r.iVer = r.iVAt and r.tCanc is null and r.tLibCom is not null and r.lExc=0
                       left join CUP            b on a.pCedente  = b.pPId and b.iVer = b.iVAt
                       left join GrupoCUP       j on b.pForGrupo = j.pPId and j.iVer = j.iVAt
                       left join CUP            c on a.pSacado   = c.pPId and c.iVer = c.iVAt
                       left join GrupoCUP       l on c.pCliGrupo = l.pPId and l.iVer = l.iVAt
 where a.iVer = a.iVAt
     and a.lExc = 0
     and a.jTipo = 0
     and {VarsRange}
   order by  a.iIde_nNF,a.pOrdem
faVRange - incio, psDSN=127.0.0.1:/qtux/database/tq/gps_01.gdb
1
2
3-sEl=sDocI            ; ($_POST[.]!='')   ; "a.sDoc>='".$_POST[.]."'"
3-sExp="a.sDoc>='".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[sDocI]!='');
eCondX=$lRet=(''!='');
2
3-sEl=sDocF            ; ($_POST[.]!='')   ; "a.sDoc<='".$_POST[.]."'"
3-sExp="a.sDoc<='".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[sDocF]!='');
eCondX=$lRet=(''!='');
2
3-sEl=pPIdDe           ; ($_POST[.]>0)     ; "a.pPId >= ".$_POST[.]
3-sExp="a.pPId >= ".$_POST[.]
6
7-eCond=$lRet=($_POST[pPIdDe]>0);
eCondX=$lRet=('4654009'>0);
eWhere=$sWhere="a.pPId >= ".$_POST[pPIdDe];
eWhereX=$sWhere="a.pPId >= ".'4654009';
2
3-sEl=pPIdAte          ; ($_POST[.]>0)     ; "a.pPId <= ".$_POST[.]
3-sExp="a.pPId <= ".$_POST[.]
6
7-eCond=$lRet=($_POST[pPIdAte]>0);
eCondX=$lRet=('4654009'>0);
eWhere=$sWhere="a.pPId <= ".$_POST[pPIdAte];
eWhereX=$sWhere="a.pPId <= ".'4654009';
2
3-sEl=pCedente         ; ($_POST[.]>0)     ; "a.pCedente = ".$_POST[.]
3-sExp="a.pCedente = ".$_POST[.]
6
7-eCond=$lRet=($_POST[pCedente]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=pSacado          ; ($_POST[.]>0)     ; "a.pSacado  = ".$_POST[.]
3-sExp="a.pSacado  = ".$_POST[.]
6
7-eCond=$lRet=($_POST[pSacado]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=pTOper           ; ($_POST[.]>0)     ; "a.pTOper   = ".$_POST[.]
3-sExp="a.pTOper   = ".$_POST[.]
6
7-eCond=$lRet=($_POST[pTOper]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=pCC              ; ($_POST[.]>0)     ; "a.pCC      = ".$_POST[.]
3-sExp="a.pCC      = ".$_POST[.]
6
7-eCond=$lRet=($_POST[pCC]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=pTipoCob         ; ($_POST[.]>0)     ; "a.pTipoCob = ".$_POST[.]
3-sExp="a.pTipoCob = ".$_POST[.]
6
7-eCond=$lRet=($_POST[pTipoCob]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=iIde_nNFDe       ; ($_POST[.]>0)     ; "a.iIde_nNF  >= ".$_POST[.]
3-sExp="a.iIde_nNF  >= ".$_POST[.]
6
7-eCond=$lRet=($_POST[iIde_nNFDe]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=iIde_nNFAte      ; ($_POST[.]>0)     ; "a.iIde_nNF  <= ".$_POST[.]
3-sExp="a.iIde_nNF  <= ".$_POST[.]
6
7-eCond=$lRet=($_POST[iIde_nNFAte]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=iIdIFCDe         ; ($_POST[.]>0)     ; "a.pIFC_Order  >= ".$_POST[.]
3-sExp="a.pIFC_Order  >= ".$_POST[.]
6
7-eCond=$lRet=($_POST[iIdIFCDe]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=iIdIFCAte        ; ($_POST[.]>0)     ; "a.pIFC_Order  <= ".$_POST[.]
3-sExp="a.pIFC_Order  <= ".$_POST[.]
6
7-eCond=$lRet=($_POST[iIdIFCAte]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=sNrIFCDe         ; ($_POST[.]!='')     ; "a.pIFC_Order in (select pPId from IFC_Order where sOrderId='$_POST[.]' and iVer=iVAt)"
3-sExp="a.pIFC_Order in (select pPId from IFC_Order where sOrderId='$_POST[.]' and iVer=iVAt)"
6
7-eCond=$lRet=($_POST[sNrIFCDe]!='');
eCondX=$lRet=(''!='');
2
3-sEl=pForGrupo        ; ($_POST[.]>0)     ; "b.pCliGrupo   = ".$_POST[.]
3-sExp="b.pCliGrupo   = ".$_POST[.]
6
7-eCond=$lRet=($_POST[pForGrupo]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=pCliGrupo        ; ($_POST[.]>0)     ; "c.pCliGrupo   = ".$_POST[.]
3-sExp="c.pCliGrupo   = ".$_POST[.]
6
7-eCond=$lRet=($_POST[pCliGrupo]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=dVenc1           ; ($_POST[.]!='')   ; "cast(a.tVenc as date)>= '".$_POST[.]."'"
3-sExp="cast(a.tVenc as date)>= '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[dVenc1]!='');
eCondX=$lRet=(''!='');
2
3-sEl=dVenc2           ; ($_POST[.]!='')   ; "cast(a.tVenc as date)<= '".$_POST[.]."'"
3-sExp="cast(a.tVenc as date)<= '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[dVenc2]!='');
eCondX=$lRet=(''!='');
2
3-sEl=dPgmto1          ; ($_POST[.]!='')   ; "cast(a.tPgmto as date)>= '".$_POST[.]."'"
3-sExp="cast(a.tPgmto as date)>= '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[dPgmto1]!='');
eCondX=$lRet=(''!='');
2
3-sEl=dPgmto2          ; ($_POST[.]!='')   ; "cast(a.tPgmto as date)<= '".$_POST[.]."'"
3-sExp="cast(a.tPgmto as date)<= '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[dPgmto2]!='');
eCondX=$lRet=(''!='');
2
3-sEl=dAgend1          ; ($_POST[.]!='')   ; "cast(a.tAgend as date)>= '".$_POST[.]."'"
3-sExp="cast(a.tAgend as date)>= '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[dAgend1]!='');
eCondX=$lRet=(''!='');
2
3-sEl=dAgend2          ; ($_POST[.]!='')   ; "cast(a.tAgend as date)<= '".$_POST[.]."'"
3-sExp="cast(a.tAgend as date)<= '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[dAgend2]!='');
eCondX=$lRet=(''!='');
2
3-sEl=dEmissao1        ; ($_POST[.]!='')   ; "cast(a.tEmissao as date)>= '".$_POST[.]."'"
3-sExp="cast(a.tEmissao as date)>= '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[dEmissao1]!='');
eCondX=$lRet=(''!='');
2
3-sEl=dEmissao2        ; ($_POST[.]!='')   ; "cast(a.tEmissao as date)<= '".$_POST[.]."'"
3-sExp="cast(a.tEmissao as date)<= '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[dEmissao2]!='');
eCondX=$lRet=(''!='');
2
3-sEl=dIde_Emi1        ; ($_POST[.]!='')   ; "cast(a.tIde_Emi as date)>= '".$_POST[.]."'"
3-sExp="cast(a.tIde_Emi as date)>= '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[dIde_Emi1]!='');
eCondX=$lRet=(''!='');
2
3-sEl=dIde_Emi2        ; ($_POST[.]!='')   ; "cast(a.tIde_Emi as date)<= '".$_POST[.]."'"
3-sExp="cast(a.tIde_Emi as date)<= '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[dIde_Emi2]!='');
eCondX=$lRet=(''!='');
2
3-sEl=sIncd1           ; ($_POST[.]!='')   ; "a.tInc>= '".$_POST[.]."'"
3-sExp="a.tInc>= '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[sIncd1]!='');
eCondX=$lRet=(''!='');
2
3-sEl=sIncd2           ; ($_POST[.]!='')   ; "a.tInc<= '".$_POST[.]."'"
3-sExp="a.tInc<= '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[sIncd2]!='');
eCondX=$lRet=(''!='');
2
3-sEl=sDescricao       ; ($_POST[.]!='')   ; "a.sDescricao = '".$_POST[.]."'"
3-sExp="a.sDescricao = '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[sDescricao]!='');
eCondX=$lRet=(''!='');
2
3-sEl=jTipo2           ; ($_POST[.]==0)    ; "a.tPgmto is not null"
3-sExp="a.tPgmto is not null"
6
7-eCond=$lRet=($_POST[jTipo2]==0);
eCondX=$lRet=('2'==0);
2
3-sEl=jTipo2           ; ($_POST[.]==1)    ; "a.tPgmto is     null"
3-sExp="a.tPgmto is     null"
6
7-eCond=$lRet=($_POST[jTipo2]==1);
eCondX=$lRet=('2'==1);
2
3-sEl=jOrcNA           ; ($_POST[.]==1)    ; "a.lOrcNA = 1"
3-sExp="a.lOrcNA = 1"
6
7-eCond=$lRet=($_POST[jOrcNA]==1);
eCondX=$lRet=('0'==1);
2
3-sEl=jOrcNA           ; ($_POST[.]==2)    ; "a.lOrcNA = 0"
3-sExp="a.lOrcNA = 0"
6
7-eCond=$lRet=($_POST[jOrcNA]==2);
eCondX=$lRet=('0'==2);
2
3-sEl=jIFC             ; ($_POST[.]==1)    ; "a.lIFC = 1"
3-sExp="a.lIFC = 1"
6
7-eCond=$lRet=($_POST[jIFC]==1);
eCondX=$lRet=('0'==1);
2
3-sEl=jIFC             ; ($_POST[.]==2)    ; "a.lIFC = 0"
3-sExp="a.lIFC = 0"
6
7-eCond=$lRet=($_POST[jIFC]==2);
eCondX=$lRet=('0'==2);
2
3-sEl=jTM              ; ($_POST[.]==1)    ; "a.lTM = 1"
3-sExp="a.lTM = 1"
6
7-eCond=$lRet=($_POST[jTM]==1);
eCondX=$lRet=('0'==1);
2
3-sEl=jTM              ; ($_POST[.]==2)    ; "a.lTM = 0"
3-sExp="a.lTM = 0"
6
7-eCond=$lRet=($_POST[jTM]==2);
eCondX=$lRet=('0'==2);
2
3-sEl=jCanc            ; ($_POST[.]==0)    ; "a.tCanc is     null"
3-sExp="a.tCanc is     null"
6
7-eCond=$lRet=($_POST[jCanc]==0);
eCondX=$lRet=('2'==0);
2
3-sEl=jCanc            ; ($_POST[.]==1)    ; "a.tCanc is not null"
3-sExp="a.tCanc is not null"
6
7-eCond=$lRet=($_POST[jCanc]==1);
eCondX=$lRet=('2'==1);
2
3-sEl=jProrrog         ; ($_POST[.]==1)    ; "a.tVenc  <> a.tVenc0"
3-sExp="a.tVenc  <> a.tVenc0"
6
7-eCond=$lRet=($_POST[jProrrog]==1);
eCondX=$lRet=('0'==1);
2
3-sEl=jProrrog         ; ($_POST[.]==2)    ; "a.tVenc  =  a.tVenc0"
3-sExp="a.tVenc  =  a.tVenc0"
6
7-eCond=$lRet=($_POST[jProrrog]==2);
eCondX=$lRet=('0'==2);
2
3-sEl=jPrevisao        ; ($_POST[.]==0)    ; "a.lPrevisao=0"
3-sExp="a.lPrevisao=0"
6
7-eCond=$lRet=($_POST[jPrevisao]==0);
eCondX=$lRet=('2'==0);
2
3-sEl=jPrevisao        ; ($_POST[.]==1)    ; "a.lPrevisao=1"
3-sExp="a.lPrevisao=1"
6
7-eCond=$lRet=($_POST[jPrevisao]==1);
eCondX=$lRet=('2'==1);
2
3-sEl=jPrevisao        ; ($_POST[.]==2)    ; "a.lPrevisao in (0,1)"
3-sExp="a.lPrevisao in (0,1)"
6
7-eCond=$lRet=($_POST[jPrevisao]==2);
eCondX=$lRet=('2'==2);
eWhere=$sWhere="a.lPrevisao in (0,1)";
eWhereX=$sWhere="a.lPrevisao in (0,1)";
2
3-sEl=jOri             ; ($_POST[.]==0)    ; "a.jOri=0"
3-sExp="a.jOri=0"
6
7-eCond=$lRet=($_POST[jOri]==0);
eCondX=$lRet=('2'==0);
2
3-sEl=jOri             ; ($_POST[.]==1)    ; "a.jOri=1"
3-sExp="a.jOri=1"
6
7-eCond=$lRet=($_POST[jOri]==1);
eCondX=$lRet=('2'==1);
2
3-sEl=pCCusto          ; ($_POST[.]>0)     ; "a.pPId in (select pTFin from FIN_Titulos_CCusto where pCCusto=$_POST[.] and iVer=iVAt)"
3-sExp="a.pPId in (select pTFin from FIN_Titulos_CCusto where pCCusto=$_POST[.] and iVer=iVAt)"
6
7-eCond=$lRet=($_POST[pCCusto]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=pCPla            ; ($_POST[.]>0)     ; "a.pPId in (select pTFin from FIN_Titulos_CContabil where pCPla=$_POST[.] and iVer=iVAt and lExc=0)"
3-sExp="a.pPId in (select pTFin from FIN_Titulos_CContabil where pCPla=$_POST[.] and iVer=iVAt and lExc=0)"
6
7-eCond=$lRet=($_POST[pCPla]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=pPreNFDe         ; ($_POST[.]>0)     ; "a.pPreNF >= ".$_POST[.]
3-sExp="a.pPreNF >= ".$_POST[.]
6
7-eCond=$lRet=($_POST[pPreNFDe]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=pPreNFAte        ; ($_POST[.]>0)     ; "a.pPreNF <= ".$_POST[.]
3-sExp="a.pPreNF <= ".$_POST[.]
6
7-eCond=$lRet=($_POST[pPreNFAte]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=pOrdemDe         ; ($_POST[.]>0)     ; "a.pOrdem >= ".$_POST[.]
3-sExp="a.pOrdem >= ".$_POST[.]
6
7-eCond=$lRet=($_POST[pOrdemDe]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=pOrdemAte        ; ($_POST[.]>0)     ; "a.pOrdem <= ".$_POST[.]
3-sExp="a.pOrdem <= ".$_POST[.]
6
7-eCond=$lRet=($_POST[pOrdemAte]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=jGerBol          ; ($_POST[.]==1)    ; "a.tEnvBol is not null"
3-sExp="a.tEnvBol is not null"
6
7-eCond=$lRet=($_POST[jGerBol]==1);
eCondX=$lRet=('0'==1);
2
3-sEl=jGerBol          ; ($_POST[.]==2)    ; "a.tEnvBol is null"
3-sExp="a.tEnvBol is null"
6
7-eCond=$lRet=($_POST[jGerBol]==2);
eCondX=$lRet=('0'==2);
2
3-sEl=jGerRem          ; ($_POST[.]==1)    ; "a.tEnvCnab is not null"
3-sExp="a.tEnvCnab is not null"
6
7-eCond=$lRet=($_POST[jGerRem]==1);
eCondX=$lRet=('0'==1);
2
3-sEl=jGerRem          ; ($_POST[.]==2)    ; "a.tEnvCnab is null"
3-sExp="a.tEnvCnab is null"
6
7-eCond=$lRet=($_POST[jGerRem]==2);
eCondX=$lRet=('0'==2);
2
3-sEl=jGerRemAlt       ; ($_POST[.]==1)    ; "(a.jRemCodOco>0 and a.tRemEnvAltTit is not null)"
3-sExp="(a.jRemCodOco>0 and a.tRemEnvAltTit is not null)"
6
7-eCond=$lRet=($_POST[jGerRemAlt]==1);
eCondX=$lRet=('0'==1);
2
3-sEl=jGerRemAlt       ; ($_POST[.]==2)    ; "(a.jRemCodOco>0 and a.tRemEnvAltTit is null)"
3-sExp="(a.jRemCodOco>0 and a.tRemEnvAltTit is null)"
6
7-eCond=$lRet=($_POST[jGerRemAlt]==2);
eCondX=$lRet=('0'==2);
2
3-sEl=pVerbaDe         ; ($_POST[.]>0)     ; "a.pVerba >= ".$_POST[.]
3-sExp="a.pVerba >= ".$_POST[.]
6
7-eCond=$lRet=($_POST[pVerbaDe]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=pVerbaAte        ; ($_POST[.]>0)     ; "a.pVerba <= ".$_POST[.]
3-sExp="a.pVerba <= ".$_POST[.]
6
7-eCond=$lRet=($_POST[pVerbaAte]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=sRaizCNPJ        ; ($_POST[.]>0)     ; "substring(c.sCNPJ from 1 for 8) = '".$_POST[.]."'"
3-sExp="substring(c.sCNPJ from 1 for 8) = '".$_POST[.]."'"
6
7-eCond=$lRet=($_POST[sRaizCNPJ]>0);
eCondX=$lRet=(''>0);
2
3-sEl=lIndef           ; ($_POST[.]>0)     ; "a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
3-sExp="a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
6
7-eCond=$lRet=($_POST[lIndef]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=lBol             ; ($_POST[.]>0)     ; "a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
3-sExp="a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
6
7-eCond=$lRet=($_POST[lBol]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=lCred            ; ($_POST[.]>0)     ; "a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
3-sExp="a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
6
7-eCond=$lRet=($_POST[lCred]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=lTribCB          ; ($_POST[.]>0)     ; "a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
3-sExp="a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
6
7-eCond=$lRet=($_POST[lTribCB]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=lTribSB          ; ($_POST[.]>0)     ; "a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
3-sExp="a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
6
7-eCond=$lRet=($_POST[lTribSB]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=lCon             ; ($_POST[.]>0)     ; "a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
3-sExp="a.jOperEDIFIN in (".($_POST['lIndef']==1?0:-1).",".($_POST['lBol']==1?1:-1).",".($_POST['lCred']==1?2:-1).",".($_POST['lTribCB']==1?3:-1).",".($_POST['lTribSB']==1?4:-1).",".($_POST['lCon']==1?5:-1).")"
6
7-eCond=$lRet=($_POST[lCon]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=pAut3            ; ($_POST[.]>0)     ; "a.pAut3=".$_POST[.]
3-sExp="a.pAut3=".$_POST[.]
6
7-eCond=$lRet=($_POST[pAut3]>0);
eCondX=$lRet=('0'>0);
2
3-sEl=jCCDefault       ; ($_POST[.]==1)    ; "a.jCCDefault=0"
3-sExp="a.jCCDefault=0"
6
7-eCond=$lRet=($_POST[jCCDefault]==1);
eCondX=$lRet=('0'==1);
2
3-sEl=jCCDefault       ; ($_POST[.]==2)    ; "a.jCCDefault=1"
3-sExp="a.jCCDefault=1"
6
7-eCond=$lRet=($_POST[jCCDefault]==2);
eCondX=$lRet=('0'==2);
sQry=   select a.sDoc,
          a.tIn0,
          a.jTipo,
          a.pCedente,
          a.pSacado,
          a.tEmissao,
          a.tEnvCnab,
          a.tEnvBol,
          a.tRestr,
          a.tLibRestr,
          b.sCoringa sCedente,
          b.sCNPJ    sCNPJCedente,
          b.sCPF     sCPFCedente,
          b.sAgencia    sAgenciaCedente,
          b.lAgencia    lAgenciaCedente,
          c.sCoringa sSacado,
          c.sCNPJ    sCNPJSacado,
          c.sCPF     sCPFSacado, 
          c.sAgencia    sAgenciaSacado,
          c.lAgencia    lAgenciaSacado,
          a.pCapa,
          a.lCapa,
          a.tVenc,
          a.tVenc0,
          a.nVenc,
          a.jOri,
          a.tCanc  dCanc,
          a.tPgmto,
          a.nPgmto,
          a.lPrevisao,
          a.iIde_nNF,
          a.pOrdem,
          a.pNFe,
          a.pPreNF,
          a.pTransf,
          a.pContr,
          a.iPrest,
          a.iNrPrest,
          a.tAgend,
          a.pTOper,
          d.sDescricao sTOper,
          d.sCodigo    sCodTOper,
          a.iNfNFs,
          a.pTipoCob,
          e.sDescricao  sTipoCob,
          e.sCodigo     sCodTipoCob,
          a.fTipoCob,
          g.sCC        sCC,
          g.sDac       sDac,
          h.sAgencia   sAgeNr,
          h.sCoringa   sAge,
          h.pBanco     pBanco,
          h.fBanco     fBanco,
          i.sCodigo    sCodBanco,
          i.sDescricao sDesBanco, 
          a.pCC,
          c.pCliGrupo,
          l.sGrupo sCliGrupo,
          b.pForGrupo,
          j.sGrupo sForGrupo,
          r.tConf      tOrdemConf,
          a.pTFinOrig,
          a.lOrcNA,
          a.pPId 
   from FIN_Titulos a left join TOper           d on a.pTOper    = d.pPId and d.iVer = d.iVAt
                       left join CC             g on a.pCC       = g.pPId and g.iVer = g.iVAt
                       left join CUP            h on g.pAgencia  = h.pPId and h.iVer = h.iVAt
                       left join Banco          i on h.pBanco    = i.pPId and i.iVer = i.iVAt
                       left join Tipo_Cobrancas e on a.pTipoCob  = e.pPId and e.iVer = e.iVAt
                       left join Ordens         r on a.pOrdem    = r.pPId and r.iVer = r.iVAt and r.tCanc is null and r.tLibCom is not null and r.lExc=0
                       left join CUP            b on a.pCedente  = b.pPId and b.iVer = b.iVAt
                       left join GrupoCUP       j on b.pForGrupo = j.pPId and j.iVer = j.iVAt
                       left join CUP            c on a.pSacado   = c.pPId and c.iVer = c.iVAt
                       left join GrupoCUP       l on c.pCliGrupo = l.pPId and l.iVer = l.iVAt
 where a.iVer = a.iVAt
     and a.lExc = 0
     and a.jTipo = 0
     and a.pPId >= 4654009 and a.pPId <= 4654009 and a.lPrevisao in (0,1)
   order by  a.iIde_nNF,a.pOrdem
sAnd=a.pPId >= 4654009 and a.pPId <= 4654009 and a.lPrevisao in (0,1)
faVRange - fim
3)    select a.sDoc,
          a.tIn0,
          a.jTipo,
          a.pCedente,
          a.pSacado,
          a.tEmissao,
          a.tEnvCnab,
          a.tEnvBol,
          a.tRestr,
          a.tLibRestr,
          b.sCoringa sCedente,
          b.sCNPJ    sCNPJCedente,
          b.sCPF     sCPFCedente,
          b.sAgencia    sAgenciaCedente,
          b.lAgencia    lAgenciaCedente,
          c.sCoringa sSacado,
          c.sCNPJ    sCNPJSacado,
          c.sCPF     sCPFSacado, 
          c.sAgencia    sAgenciaSacado,
          c.lAgencia    lAgenciaSacado,
          a.pCapa,
          a.lCapa,
          a.tVenc,
          a.tVenc0,
          a.nVenc,
          a.jOri,
          a.tCanc  dCanc,
          a.tPgmto,
          a.nPgmto,
          a.lPrevisao,
          a.iIde_nNF,
          a.pOrdem,
          a.pNFe,
          a.pPreNF,
          a.pTransf,
          a.pContr,
          a.iPrest,
          a.iNrPrest,
          a.tAgend,
          a.pTOper,
          d.sDescricao sTOper,
          d.sCodigo    sCodTOper,
          a.iNfNFs,
          a.pTipoCob,
          e.sDescricao  sTipoCob,
          e.sCodigo     sCodTipoCob,
          a.fTipoCob,
          g.sCC        sCC,
          g.sDac       sDac,
          h.sAgencia   sAgeNr,
          h.sCoringa   sAge,
          h.pBanco     pBanco,
          h.fBanco     fBanco,
          i.sCodigo    sCodBanco,
          i.sDescricao sDesBanco, 
          a.pCC,
          c.pCliGrupo,
          l.sGrupo sCliGrupo,
          b.pForGrupo,
          j.sGrupo sForGrupo,
          r.tConf      tOrdemConf,
          a.pTFinOrig,
          a.lOrcNA,
          a.pPId 
   from FIN_Titulos a left join TOper           d on a.pTOper    = d.pPId and d.iVer = d.iVAt
                       left join CC             g on a.pCC       = g.pPId and g.iVer = g.iVAt
                       left join CUP            h on g.pAgencia  = h.pPId and h.iVer = h.iVAt
                       left join Banco          i on h.pBanco    = i.pPId and i.iVer = i.iVAt
                       left join Tipo_Cobrancas e on a.pTipoCob  = e.pPId and e.iVer = e.iVAt
                       left join Ordens         r on a.pOrdem    = r.pPId and r.iVer = r.iVAt and r.tCanc is null and r.tLibCom is not null and r.lExc=0
                       left join CUP            b on a.pCedente  = b.pPId and b.iVer = b.iVAt
                       left join GrupoCUP       j on b.pForGrupo = j.pPId and j.iVer = j.iVAt
                       left join CUP            c on a.pSacado   = c.pPId and c.iVer = c.iVAt
                       left join GrupoCUP       l on c.pCliGrupo = l.pPId and l.iVer = l.iVAt
 where a.iVer = a.iVAt
     and a.lExc = 0
     and a.jTipo = 0
     and a.pPId >= 4654009 and a.pPId <= 4654009 and a.lPrevisao in (0,1)
   order by  a.iIde_nNF,a.pOrdem
4)    sDocI
   sDocF
   pPIdDe
   pPIdAte
   pTOper 
   pCC
   pPreNFDe
   pPreNFAte
   pOrdemDe
   pOrdemAte
   jOri
   jTipo2
   jCanc
   jProrrog
   jPrevisao
   jOrcNA
   jIFC
   jTM
   pCedente
   pSacado
   pCliGrupo 
   pForGrupo 
   dEmissao1
   dEmissao2
   dIde_Emi1
   dIde_Emi2
   dVenc1
   dVenc2
   dPgmto1
   dPgmto2
   dAgend1
   dAgend2
   sIncd1  = dIncd1!='' ? dIncd1.split('-').reverse().join('-')+' 00:00:00' : ''
   sIncd2  = dIncd2!='' ? dIncd2.split('-').reverse().join('-')+' 23:59:59' : ''
   sDescricao
   pCCusto
   pCPla
   iIde_nNFDe
   iIde_nNFAte
   jGerBol 
   jGerRem 
   jGerRemAlt
   pTipoCob
   pVerbaDe
   pVerbaAte
   sRaizCNPJ
   iIdIFCDe 
   iIdIFCAte
   sNrIFCDe
   lIndef
   lBol
   lCred
   lTribCB
   lTribSB
   lCon
   pAut3
   jCCDefault
5) sRet=   select a.sDoc,
          a.tIn0,
          a.jTipo,
          a.pCedente,
          a.pSacado,
          a.tEmissao,
          a.tEnvCnab,
          a.tEnvBol,
          a.tRestr,
          a.tLibRestr,
          b.sCoringa sCedente,
          b.sCNPJ    sCNPJCedente,
          b.sCPF     sCPFCedente,
          b.sAgencia    sAgenciaCedente,
          b.lAgencia    lAgenciaCedente,
          c.sCoringa sSacado,
          c.sCNPJ    sCNPJSacado,
          c.sCPF     sCPFSacado, 
          c.sAgencia    sAgenciaSacado,
          c.lAgencia    lAgenciaSacado,
          a.pCapa,
          a.lCapa,
          a.tVenc,
          a.tVenc0,
          a.nVenc,
          a.jOri,
          a.tCanc  dCanc,
          a.tPgmto,
          a.nPgmto,
          a.lPrevisao,
          a.iIde_nNF,
          a.pOrdem,
          a.pNFe,
          a.pPreNF,
          a.pTransf,
          a.pContr,
          a.iPrest,
          a.iNrPrest,
          a.tAgend,
          a.pTOper,
          d.sDescricao sTOper,
          d.sCodigo    sCodTOper,
          a.iNfNFs,
          a.pTipoCob,
          e.sDescricao  sTipoCob,
          e.sCodigo     sCodTipoCob,
          a.fTipoCob,
          g.sCC        sCC,
          g.sDac       sDac,
          h.sAgencia   sAgeNr,
          h.sCoringa   sAge,
          h.pBanco     pBanco,
          h.fBanco     fBanco,
          i.sCodigo    sCodBanco,
          i.sDescricao sDesBanco, 
          a.pCC,
          c.pCliGrupo,
          l.sGrupo sCliGrupo,
          b.pForGrupo,
          j.sGrupo sForGrupo,
          r.tConf      tOrdemConf,
          a.pTFinOrig,
          a.lOrcNA,
          a.pPId 
   from FIN_Titulos a left join TOper           d on a.pTOper    = d.pPId and d.iVer = d.iVAt
                       left join CC             g on a.pCC       = g.pPId and g.iVer = g.iVAt
                       left join CUP            h on g.pAgencia  = h.pPId and h.iVer = h.iVAt
                       left join Banco          i on h.pBanco    = i.pPId and i.iVer = i.iVAt
                       left join Tipo_Cobrancas e on a.pTipoCob  = e.pPId and e.iVer = e.iVAt
                       left join Ordens         r on a.pOrdem    = r.pPId and r.iVer = r.iVAt and r.tCanc is null and r.tLibCom is not null and r.lExc=0
                       left join CUP            b on a.pCedente  = b.pPId and b.iVer = b.iVAt
                       left join GrupoCUP       j on b.pForGrupo = j.pPId and j.iVer = j.iVAt
                       left join CUP            c on a.pSacado   = c.pPId and c.iVer = c.iVAt
                       left join GrupoCUP       l on c.pCliGrupo = l.pPId and l.iVer = l.iVAt
 where a.iVer = a.iVAt
     and a.lExc = 0
     and a.jTipo = 0
     and a.pPId >= 4654009 and a.pPId <= 4654009 and a.lPrevisao in (0,1)
   order by  a.iIde_nNF,a.pOrdem
6) sRetVR=a.pPId >= 4654009 and a.pPId <= 4654009 and a.lPrevisao in (0,1)
Antes do echo : sMsgToClient=0   select a.sDoc,
          a.tIn0,
          a.jTipo,
          a.pCedente,
          a.pSacado,
          a.tEmissao,
          a.tEnvCnab,
          a.tEnvBol,
          a.tRestr,
          a.tLibRestr,
          b.sCoringa sCedente,
          b.sCNPJ    sCNPJCedente,
          b.sCPF     sCPFCedente,
          b.sAgencia    sAgenciaCedente,
          b.lAgencia    lAgenciaCedente,
          c.sCoringa sSacado,
          c.sCNPJ    sCNPJSacado,
          c.sCPF     sCPFSacado, 
          c.sAgencia    sAgenciaSacado,
          c.lAgencia    lAgenciaSacado,
          a.pCapa,
          a.lCapa,
          a.tVenc,
          a.tVenc0,
          a.nVenc,
          a.jOri,
          a.tCanc  dCanc,
          a.tPgmto,
          a.nPgmto,
          a.lPrevisao,
          a.iIde_nNF,
          a.pOrdem,
          a.pNFe,
          a.pPreNF,
          a.pTransf,
          a.pContr,
          a.iPrest,
          a.iNrPrest,
          a.tAgend,
          a.pTOper,
          d.sDescricao sTOper,
          d.sCodigo    sCodTOper,
          a.iNfNFs,
          a.pTipoCob,
          e.sDescricao  sTipoCob,
          e.sCodigo     sCodTipoCob,
          a.fTipoCob,
          g.sCC        sCC,
          g.sDac       sDac,
          h.sAgencia   sAgeNr,
          h.sCoringa   sAge,
          h.pBanco     pBanco,
          h.fBanco     fBanco,
          i.sCodigo    sCodBanco,
          i.sDescricao sDesBanco, 
          a.pCC,
          c.pCliGrupo,
          l.sGrupo sCliGrupo,
          b.pForGrupo,
          j.sGrupo sForGrupo,
          r.tConf      tOrdemConf,
          a.pTFinOrig,
          a.lOrcNA,
          a.pPId 
   from FIN_Titulos a left join TOper           d on a.pTOper    = d.pPId and d.iVer = d.iVAt
                       left join CC             g on a.pCC       = g.pPId and g.iVer = g.iVAt
                       left join CUP            h on g.pAgencia  = h.pPId and h.iVer = h.iVAt
                       left join Banco          i on h.pBanco    = i.pPId and i.iVer = i.iVAt
                       left join Tipo_Cobrancas e on a.pTipoCob  = e.pPId and e.iVer = e.iVAt
                       left join Ordens         r on a.pOrdem    = r.pPId and r.iVer = r.iVAt and r.tCanc is null and r.tLibCom is not null and r.lExc=0
                       left join CUP            b on a.pCedente  = b.pPId and b.iVer = b.iVAt
                       left join GrupoCUP       j on b.pForGrupo = j.pPId and j.iVer = j.iVAt
                       left join CUP            c on a.pSacado   = c.pPId and c.iVer = c.iVAt
                       left join GrupoCUP       l on c.pCliGrupo = l.pPId and l.iVer = l.iVAt
 where a.iVer = a.iVAt
     and a.lExc = 0
     and a.jTipo = 0
     and a.pPId >= 4654009 and a.pPId <= 4654009 and a.lPrevisao in (0,1)
   order by  a.iIde_nNF,a.pOrdem~a.pPId >= 4654009 and a.pPId <= 4654009 and a.lPrevisao in (0,1)