#include "hwgui.ch"
STATIC Thisform

FUNCTION dlgnotas( p1, p2, p3, p4 )
 RETURN _dlgnotas( p1, p2 ,p3 ,p4)

FUNCTION _dlgnotas

 LOCAL vCheck1 := .F., vCheck3 := .F., vRadiogroup1 := 1, zProxNfe := "", zProxNFC := ""
 LOCAL oContainerNFCNFE, oContainerNFE, oIcon9, oIcon7, oIcon13, oIcon10, oIcon2 ;
        , oIcon11, oIcon8, oIcon4, oIcon3, oIcon12, oIcon6, oIcon5, oIcon14 ;
        , oIcon1, oButtonex10, oButtonex2, oButtonex6, oButtonex13, oButtonex23, oButtonex14, oButtonex5 ;
        , oButtonex25, oBtnFecharOs, oBtnOs, oButtonex37, oButtonex29, oButtonex39, oButtonex43, oButtonex38 ;
        , oButtonex40, oButtonex9, oButtonex16, oButtonex33, oButtonex34, oButtonex32, buttonsair, oButtonex7 ;
        , oBtnFatNFC, oBtnFatNFE, oButtonex24, oButtonex35, oButtonex27, oButtonex26, oButtonex12, oButtonex11 ;
        , oButtonex17, oButtonex19, oButtonex20, oButtonex21, oButtonex22, oBtnOutraS, oBtnOutraE, oButtonex15 ;
        , oButtonex28, oButtonex31, oButtonex30, oButtonex18, oBtnVenda, oButtonex8, oCheck1, oCheck3 ;
        , oRadiogroup1, oRadiobutton1, oRadiobutton2, oGroup1, oGroup6, oGroup4, oLabel6, oLabel7 ;
        , oBtnFecharOs2, oBtnOs2, oLabel1, oProxNFe, oProxNFC, oGroup3

  INIT DIALOG dlgNotas TITLE "Emissao de NFe" ;
        COLOR 16777215 BACKGROUND BITMAP HBitmap():AddFile('icon\tela.jpg')  ;
    AT 338,29 SIZE 1024,678 CLIPPER  NOEXIT  ;
     STYLE WS_POPUP+WS_CAPTION+WS_SIZEBOX+DS_CENTER  ;
     ON INIT {|| onDlgInit(  ) }
    Thisform := dlgNotas

   @ 552,8 CONTAINER oContainerNFCNFE SIZE 173,330 ;
        STYLE 3  
   @ 376,8 CONTAINER oContainerNFE SIZE 173,330 ;
        STYLE 3  
   @ 472,520 BUTTONEX oButtonex10 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\BtnCadCep.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial Unicode MS',0,-11,400,,,); 
        TOOLTIP 'Cadastro de Logradouros do Brasil, emitido pela empresa Correios e Telegrafos do Brasil' ;
        ON CLICK {|| CiBrow("LOGRA") }
   @ 385,520 BUTTONEX oButtonex2 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\BtnCadIbge.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial Unicode MS',0,-11,400,,,); 
        TOOLTIP 'Cadastro de Cidades no IBGE' ;
        ON CLICK {|| CiBrow("vb_munic") }
   @ 646,520 BUTTONEX oButtonex6 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\BtnCadTrn.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial Unicode MS',0,-11,400,,,); 
        TOOLTIP 'Cadastro de Transportadores da NFe' ;
        ON CLICK {|| CiBrow("SF_TRN") }
   @ 911,432 BUTTONEX oButtonex13 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\BtnCadCfopES.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial Unicode MS',0,-11,400,,,); 
        TOOLTIP 'Define as CFOPs padroes a ser usadas nas Vendas, Compras, Transferencias, etc... de acordo com a categoria fiscal do produto...' ;
        ON CLICK {|| CiBrow("nftipoit") }
   @ 733,432 BUTTONEX oButtonex23 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\BtnCadEmit.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial Unicode MS',0,-11,400,,,); 
        TOOLTIP 'Cadastra dados do Emitente, da Empresa Usuaria do sistema' ; 
        ON CLICK {|| oButtonex23_onClick(  ) }
   @ 822,432 BUTTONEX oButtonex14 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\BtnCadRegime.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial Unicode MS',0,-11,400,,,); 
        TOOLTIP 'Define as Taxas Tributarias e CSTs ICMS, PIS, COFINS, IPI, etc...' ;
        ON CLICK {|| NfeDefaults('CONFIGURA') }
   @ 472,432 BUTTONEX oButtonex5 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\BtnRelGer.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Calibri',0,-16,700,,,); 
        TOOLTIP 'Relacao geral de NF-e,  NFC-e,  NFS-e' ;
        ON CLICK {|| vb_ut1('BROW_VENDAS_DO_PERIODO') }
   @ 385,432 BUTTONEX oButtonex25 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\BtnRelPreN.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Calibri',0,-16,700,,,); 
        TOOLTIP 'Relacao geral de Prenotas, Pedidos, Orcamentos, OS, Pendentes ou Processados, etc...' ;
        ON CLICK {|| BrowNfePn("SF_PN") }
   @ 911,520 BUTTONEX oBtnFecharOs CAPTION "&F"   TRANSPARENT SIZE 80,80 ;
        STYLE WS_TABSTOP ;
         COLOR 4194304   ;
        BITMAP (HBitmap():AddFile('icon\BtnFecharOS.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Calibri',0,-1,400,,,) ; 
        ON CLICK {|| oBtnFecharOs_onClick(  ) }
   @ 822,520 BUTTONEX oBtnOs CAPTION "&E"   TRANSPARENT SIZE 80,80 ;
        STYLE WS_TABSTOP ;
         COLOR 4194304   ;
        BITMAP (HBitmap():AddFile('icon\BtnAbrirOS.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Calibri',0,-1,400,,,) ; 
        ON CLICK {|| oBtnOs_onClick(  ) }
   @ 735,90 BUTTONEX oButtonex37 CAPTION ""   TRANSPARENT SIZE 82,82 ;
        STYLE WS_TABSTOP   ;
        BITMAP (HBitmap():AddFile('icon\BtnMDFe.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Calibri',0,-21,400,,,); 
        TOOLTIP 'Gerenciamento de Manifesto Eletrônico de Documentos Fiscais (MDFe)' ;
        ON CLICK {|| ci_mdfe() }
        oButtonex37:Anchor := 9 
   @ 911,345 BUTTONEX oButtonex29 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\SyncNfeNfce.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial Unicode MS',0,-11,400,,,); 
        TOOLTIP 'Sincroniza XMLs com site da Receita Federal' ;
        ON CLICK {|| Sync_NFE() }
   @ 559,432 BUTTONEX oButtonex39 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\BtnCadProd.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial Unicode MS',0,-11,400,,,); 
        TOOLTIP 'Cadastra dados do Emitente, da Empresa Usuaria do sistema' ;
        ON CLICK {|| Cibrow("SE_PROD") }
        oButtonex39:Anchor := 9 
   @ 646,432 BUTTONEX oButtonex43 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\BtnCadCli.JPG')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial Unicode MS',0,-11,400,,,); 
        TOOLTIP 'Cadastra dados do Emitente, da Empresa Usuaria do sistema' ;
        ON CLICK {|| Cibrow("SCCRCLI") }
        oButtonex43:Anchor := 9 
   @ 559,520 BUTTONEX oButtonex38 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\BtnCadFor.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial Unicode MS',0,-11,400,,,); 
        TOOLTIP 'Cadastra dados do Emitente, da Empresa Usuaria do sistema' ;
        ON CLICK {|| Cibrow("SCCPFOR") }
        oButtonex38:Anchor := 9 
   @ 733,520 BUTTONEX oButtonex40 CAPTION ""   TRANSPARENT SIZE 80,80 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 10485760   ;
        BITMAP (HBitmap():AddFile('icon\BtnCadCfop.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial Unicode MS',0,-11,400,,,); 
        TOOLTIP 'Exibe e Edita o Cadastro de CFOPs' ;
        ON CLICK {|| CiBrow("SF_CODOP") }
        oButtonex40:Anchor := 9 
   @ 609,640 BUTTONEX oButtonex9 CAPTION "&XMLs p/ CONTADOR"   TRANSPARENT SIZE 180,31 ;
        STYLE WS_TABSTOP ;
         COLOR 4194304   ;
        FONT HFont():Add( 'Arial',0,-12,700,,,); 
        TOOLTIP 'Envia XMLs para Email do Contador' ;
        ON CLICK {|| hrb_enviaXmlContador() }
   @ 738,345 BUTTONEX oButtonex16 CAPTION "&W - Conferente NFe por DATAS"   SIZE 136,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 8388608   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,); 
        TOOLTIP 'Emite conferente das emissoes de NFE / NFC' ;
        ON CLICK {|| Relat('Lst_Exec("c100_conf_saidt_fr3")','NB',,"X") }
   @ 951,647 BUTTONEX buttonsair CAPTION "Esc - Sair"  ID IDCANCEL  SIZE 69,26 ;
        STYLE WS_TABSTOP   ;
        FONT HFont():Add( 'Arimo',0,-12,400,,255,); 
        TOOLTIP 'Fecha Tela' ;
        ON CLICK {|| keyb_event( 27 ) }
   @ 949,23 BUTTONEX oButtonex7 CAPTION ""   SIZE 67,67 ;
        STYLE WS_TABSTOP ;
         COLOR 4194304   ;
        BITMAP (HBitmap():AddFile('icon\BtnConfig.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial',0,-13,400,,,); 
        TOOLTIP 'Parametros da Impressao/Geracao da NFE' ;
        ON CLICK {|| ExecutaXML("dlgconfig_nfe") }
   @ 995,552 BUTTONEX oBtnFatNFC CAPTION "&G"   SIZE 24,22 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 4194304   ;
        FONT HFont():Add( 'Arimo',0,-13,400,,,) ;
        ON CLICK {|| NfcRefCupons() }
   @ 995,578 BUTTONEX oBtnFatNFE CAPTION "&H"   SIZE 24,22 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 4194304   ;
        FONT HFont():Add( 'Arimo',0,-13,400,,,) ;
        ON CLICK {|| NfcRefCupons('55') }
   @ 509,353 BUTTONEX oButtonex24 CAPTION ""   SIZE 24,24 ;
        STYLE WS_TABSTOP ;
         COLOR 4194304   ;
        BITMAP (HBitmap():AddFile('icon\ico_marcar.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial',0,-13,400,,,); 
        TOOLTIP 'Redefine NUMERO DA PROXIMA NFE' ; 
        ON CLICK {|| oButtonex24_onClick(  ) }
        oButtonex24:Anchor := 9 
   @ 689,353 BUTTONEX oButtonex35 CAPTION ""   SIZE 24,24 ;
        STYLE WS_TABSTOP ;
         COLOR 4194304   ;
        BITMAP (HBitmap():AddFile('icon\ico_marcar.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial',0,-13,400,,,); 
        TOOLTIP 'Redefine Numero da PROXIMA NFC' ; 
        ON CLICK {|| oButtonex35_onClick(  ) }
        oButtonex35:Anchor := 9 
   @ 565,14 BUTTONEX oButtonex27 CAPTION ""   TRANSPARENT SIZE 148,148 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        BITMAP (HBitmap():AddFile('icon\logonfce_nc.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial',0,-21,700,,,); 
        TOOLTIP 'Cria, Assina e Valida, Transmite e Imprime XML de NFc' ; 
        ON CLICK {|| oButtonex27_onClick(  ) }
   @ 387,14 BUTTONEX oButtonex12 CAPTION ""   TRANSPARENT SIZE 148,148 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        BITMAP (HBitmap():AddFile('icon\logonfe_nc.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial',0,-21,700,,,); 
        TOOLTIP 'Cria, Assina e Valida, Transmite e Imprime XML de NFe' ; 
        ON CLICK {|| oButtonex12_onClick(  ) }
   @ 733,36 GET CHECKBOX oCheck1 VAR vCheck1  CAPTION "Transmite NFe Apos Digitacao" CONTROLSOURCE   TRANSPARENT SIZE 201,21 ;
        STYLE BS_MULTILINE      ;
        FONT HFont():Add( 'Arial',0,-13,400,,,); 
        TOOLTIP 'Transmite automaticamente as NFE modelo 55 apos a digitacao das mesmas' ;
        ON CLICK {|| xSetEnv("NFE_TRANSMITE_APOS_DIGITACAO", IF(vCheck1,"S","N") ) } ; 
        ON INIT {|| oCheck1_onInit(  ) }
   @ 733,14 GET CHECKBOX oCheck3 VAR vCheck3  CAPTION "Ativar Modo de Contingencia" CONTROLSOURCE   TRANSPARENT SIZE 201,22 ;
        STYLE BS_MULTILINE      ;
        FONT HFont():Add( 'Arial',0,-13,400,,,); 
        TOOLTIP 'ATENCAO: O modo de Contingencia ( SCAN ) so devera ser usado se o Portal da NFe estiver fora do AR.' ; 
        ON CLICK {|| oCheck3_onClick(  ) }
   @ 385,629 GROUPBOX "Ambiente da NFe"  TRANSPARENT SIZE 212,44    ;
        FONT HFont():Add( 'Arial',0,-13,400,,,)
  GET RADIOGROUP oRadiogroup1 VAR vRadiogroup1 CONTROLSOURCE  
   @ 392,645 RADIOBUTTON oRadiobutton1 CAPTION "Producao" SIZE 84,22    ;
        FONT HFont():Add( 'Arimo',0,-13,400,,,)
   @ 479,645 RADIOBUTTON oRadiobutton2 CAPTION "Homologacao" SIZE 110,22    ;
        FONT HFont():Add( 'Arimo',0,-13,400,,,)
  END RADIOGROUP oRadiogroup1 SELECTED 1

   @ 12,117 BUTTONEX oButtonex17 CAPTION "&3. Devolução de Várias NFe ao Fornecedor"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,) ; 
        ON CLICK {|| oButtonex17_onClick(  ) }
   @ 12,530 BUTTONEX oButtonex19 CAPTION "&B. Nota Fiscal de Entrada Avulsa"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,) ; 
        ON CLICK {|| oButtonex19_onClick(  ) }
   @ 12,484 BUTTONEX oButtonex20 CAPTION "&A. Entrada Referente Devolução de Cliente"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,) ; 
        ON CLICK {|| oButtonex20_onClick(  ) }
   @ 12,162 BUTTONEX oButtonex21 CAPTION "&4. NFe Referente a Um Cupom Fiscal  (NFCe)"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,) ; 
        ON CLICK {|| oButtonex21_onClick(  ) }
   @ 12,208 BUTTONEX oButtonex22 CAPTION "&5. NFe Referente a Vários Cupons Fiscal"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,) ; 
        ON CLICK {|| oButtonex22_onClick(  ) }
   @ 12,576 BUTTONEX oBtnOutraS CAPTION "&C. Nota Fiscal de Outras Saidas"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,) ; 
        ON CLICK {|| oBtnOutraS_onClick(  ) }
   @ 12,622 BUTTONEX oBtnOutraE CAPTION "&D. Nota Fiscal de Outras Entradas"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,) ; 
        ON CLICK {|| oBtnOutraE_onClick(  ) }
   @ 12,300 BUTTONEX oButtonex15 CAPTION "&7. Remessa a Venda Dentro do Estado"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,) ; 
        ON CLICK {|| oButtonex15_onClick(  ) }
   @ 12,346 BUTTONEX oButtonex28 CAPTION "&8. Remessa a Venda para Fora do Estado"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,) ; 
        ON CLICK {|| oButtonex28_onClick(  ) }
   @ 12,392 BUTTONEX oButtonex31 CAPTION "&9. Nota Fiscal Complementar"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,); 
        TOOLTIP 'Emite Nota Complementar' ; 
        ON CLICK {|| oButtonex31_onClick(  ) }
   @ 12,438 BUTTONEX oButtonex30 CAPTION "&0. Entrada Ref. a Cancelamento Fora do Prazo"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,); 
        TOOLTIP 'Gera NFe de ajuste' ; 
        ON CLICK {|| oButtonex30_onClick(  ) }
   @ 12,254 BUTTONEX oButtonex18 CAPTION "&6. Transferencia Entre Lojas (Matriz/Filial)"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,) ; 
        ON CLICK {|| oButtonex18_onClick(  ) }
   @ 12,20 BUTTONEX oBtnVenda CAPTION "&1. NFe de Produtos ou Serviços"  OF oGroup1  TRANSPARENT SIZE 355,48 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 4210688   ;
        FONT HFont():Add( 'Calibri',0,-19,700,,,); 
        TOOLTIP 'Efetua Venda de Produtos e/ou Servicos' ; 
        ON CLICK {|| oBtnVenda_onClick(  ) }
   @ 12,72 BUTTONEX oButtonex8 CAPTION "&2. Nota Fiscal de Devolução ao Fornecedor"  OF oGroup1  TRANSPARENT SIZE 355,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,) ; 
        ON CLICK {|| oButtonex8_onClick(  ) }

   @ 3,0 GROUPBOX oGroup1 CAPTION "Geracao de Nota Fiscal Eletrônica (DANFE)"  TRANSPARENT SIZE 371,674  ;
         COLOR 8404992   ;
        FONT HFont():Add( 'Verdana',0,-13,700,,255,)
   @ 565,177 BUTTONEX oButtonex26 CAPTION ""  OF oGroup6  TRANSPARENT SIZE 148,148 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        BITMAP (HBitmap():AddFile('icon\logonfce.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial',0,-21,700,,,); 
        TOOLTIP 'Exibe Notas Fiscais de NFCs' ; 
        ON CLICK {|| oButtonex26_onClick(  ) }

   @ 557,160 GROUPBOX oGroup6 CAPTION ""  TRANSPARENT SIZE 164,174  ;
         COLOR 4194304   ;
        FONT HFont():Add( 'Arial',0,-13,400,,,)
   @ 387,177 BUTTONEX oButtonex11 CAPTION ""  OF oGroup4  TRANSPARENT SIZE 148,148 ;
        STYLE BS_MULTILINE+WS_TABSTOP   ;
        BITMAP (HBitmap():AddFile('icon\logonfe.jpg')):handle  ;
        BSTYLE 1 ;
        FONT HFont():Add( 'Arial',0,-21,700,,,); 
        TOOLTIP 'Cria, Assina, Valida ou Transmite NFes ainda nao transmitidas... ReImprime, Consulta, Cancela, Inutiliza NFEs' ; 
        ON CLICK {|| oButtonex11_onClick(  ) }

   @ 381,160 GROUPBOX oGroup4 CAPTION ""  TRANSPARENT SIZE 164,174  ;
         COLOR 4194304   ;
        FONT HFont():Add( 'Arial',0,-13,400,,,)
   @ 405,339 SAY oLabel6 CAPTION "Proxima NFe"  TRANSPARENT SIZE 100,19 ;
        STYLE SS_RIGHT    ;
        FONT HFont():Add( 'Arimo',0,-12,400,,,)
   @ 587,339 SAY oLabel7 CAPTION "Proxima NFCe"  TRANSPARENT SIZE 100,19 ;
        STYLE SS_RIGHT    ;
        FONT HFont():Add( 'Arimo',0,-12,400,,,) ; 
        ON INIT {|| oLabel7_onInit(  ) }
   @ 912,601 SAY oBtnFecharOs2 CAPTION "F. Fechar OS"  TRANSPARENT SIZE 80,22 ;
        STYLE SS_CENTER    ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,)
   @ 822,601 SAY oBtnOs2 CAPTION "E. Abrir OS"  TRANSPARENT SIZE 80,22 ;
        STYLE SS_CENTER    ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,)
   @ 822,94 SAY oLabel1 CAPTION "Gerenciamento de Manifesto Eletrônico de Documentos Fiscais (MDFe)"  TRANSPARENT SIZE 190,76    ;
        FONT HFont():Add( 'Trebuchet MS',0,-15,400,,,)
   @ 427,355 GET oProxNFe VAR zProxNfe CONTROLSOURCE  SIZE 77,23   PICTURE '999999999' MAXLENGTH 9   NOBORDER  ;
        FONT HFont():Add( 'Arial Unicode MS',0,-13,700,,,); 
        TOOLTIP "" ;
        WHEN  {|| .F. }
   @ 612,355 GET oProxNFC VAR zProxNFC CONTROLSOURCE  SIZE 73,23   PICTURE '999999999' MAXLENGTH 9   NOBORDER  ;
        FONT HFont():Add( 'Arial Unicode MS',0,-13,700,,,); 
        TOOLTIP "" ;
        VALID  {|| ExecutaXML("dlgconfig_nfe") } ;
        WHEN  {|| .F. }
   @ 736,236 BUTTONEX oButtonex33 CAPTION "&N - Nota Fiscal de Entrada por Data Chegada"  OF oGroup3  SIZE 276,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 8388608   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,) ;
        ON CLICK {|| Relat('Lst_Exec("NFE06_FATF_fr3")','NB',,"X") }
   @ 736,282 BUTTONEX oButtonex34 CAPTION "&O - Conferente de NFe/NFCe Emitidas"  OF oGroup3  SIZE 276,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 8388608   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,); 
        TOOLTIP 'Emite conferente das emissoes de NFE / NFC' ; 
        ON CLICK {|| oButtonex34_onClick(  ) }
   @ 736,190 BUTTONEX oButtonex32 CAPTION "&M - NF-e / NFC-e de SAIDA por Data Emissão"  OF oGroup3  SIZE 276,43 ;
        STYLE BS_MULTILINE+WS_TABSTOP ;
         COLOR 8388608   ;
        FONT HFont():Add( 'Arial Narrow',0,-13,700,,,); 
        TOOLTIP 'Emite conferente das emissoes de NFE / NFC' ;
        ON CLICK {|| Relat('Lst_Exec("c100_saidas_fr3")','NB',,"X") }

   @ 730,172 GROUPBOX oGroup3 CAPTION "Relatórios"  TRANSPARENT SIZE 289,162  ;
         COLOR 10485760   ;
        FONT HFont():Add( 'Verdana',0,-12,400,,255,)

   ACTIVATE DIALOG dlgNotas 


RETURN dlgNotas:lresult

STATIC FUNCTION onDlgInit
//skel variavel zProxNFe:=0
//skel variavel zProxNFC:=0

//skel variavel zFgPeriodo:=.t.
//skel variavel zDe:=s_Datual
//skel variavel zAte:=s_dAtual
//skel VARIAVEL zFileFat:='mem:_fatnf'
//skel variavel zwSomaFat:=0
//skel variavel zwfValES:=0
//skel variavel zwfValCV:=0
//skel variavel zwfValCT:=0
//skel variavel zwQtdPedidos:=0
//skel variavel zwSomaCanc:=0
//skel variavel zwQtdCanc:=0

//skel variavel zbProximosNumeros:={|| zProxNFe:=SiSemaf("CAPTE_PROXIMO_NUMERO", "/NFE/"), zProxNFc:=SiSemaf("CAPTE_PROXIMO_NUMERO", "/NFC/") , oProxNFE:Refresh(), oProxNFC:Refresh() }
////MoveWindow(oDlg:Handle, 0,0,1019,547)

IF .not. sFgNFC
   oContainerNFCNFE:Hide() 
ENDIF
if xGetEnv("FATURA_SERVICOS")<>"S"
   oBtnOs:Hide()
   oBtnOs2:Hide()
   oBtnFecharOs:Hide()
   oBtnFecharOs2:Hide()
   oBtnFatNFE:Hide()
   oBtnFatNFC:Hide()
   oBtnOutraS:Move( ,,oBtnVenda:nWidth, )
   oBtnOutraE:Move( ,,oBtnVenda:nWidth, )
ELSE
   IF LEFT(sys_segmento,2)<>'os'
      oBtnOs:SetText("Criar Orcamento")
      oBtnFecharOs:SetText("Fechar Orcamento")
   ENDIF
ENDIF

eVal(zbProximosNumeros)

zFgPeriodo:=.t.
RETURN Nil

STATIC FUNCTION oButtonex23_onClick
IdUsuarioPaf('Gravar')
CiBrow("ef_s10")
CiBrow("ef_s11")
CiBrow("ef_s8805")
RETURN Nil

STATIC FUNCTION oBtnFecharOs_onClick
vb_venda("S",,,,,"/FECHAPN/")
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oBtnOs_onClick
vb_venda("S",,,,,"/PN/")
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex34_onClick
Relat('Lst_Exec("c100_conf_sai_fr3")','NB',,"X")

//Relat('Lst_Exec("NFE06_SF_FATNF")','NB')

//Relat('Lst_Exec("NFE06_SF_FATNF")','NB',,"X")
RETURN Nil

STATIC FUNCTION oButtonex24_onClick
zProxNfe:=Nfe_SetProximoNumero(.t.,'/NFE/')
RefreshGetlist()

RETURN Nil

STATIC FUNCTION oButtonex35_onClick
zProxNfc:=Nfe_SetProximoNumero(.t.,'/NFC/')
RefreshGetlist()
RETURN Nil

STATIC FUNCTION oButtonex27_onClick
BrowNfePN(,'65')
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex26_onClick
BrowNfe(,'65')
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex12_onClick
BrowNfePN(,'55')
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex11_onClick
BrowNfe(,'55')
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex17_onClick
vb_venda("MD2",,,,,"/PN/")
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex19_onClick
vb_venda("ME1",,.t.,,,"/PN/")
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex20_onClick
vb_venda("ME2",,.t.,,,"/PN/")
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex21_onClick
wFgVaiGerarNFE:=(xGetEnv("NFE_TRANSMITE_APOS_DIGITACAO")="S")
vb_venda("MN1",,,,,"/PN/")
wFgVaiGerarNFE:=.f.
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex22_onClick
vb_venda("MN2",,,,,"/PN/")
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oBtnOutraS_onClick
vb_venda("MO1",,,,,"/PN/")
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oBtnOutraE_onClick
vb_venda("MO2",,,,,"/PN/")
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex15_onClick
vb_venda("MR1",,,,,"/PN/")
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex28_onClick
vb_venda("MR2",,,,,"/PN/")
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex31_onClick
wFgVaiGerarNFEcomplementar:=.t.
wFgVaiGerarNFE:=(xGetEnv("NFE_TRANSMITE_APOS_DIGITACAO")="S")
vb_venda("MV",,,,,"/PN/")
wFgVaiGerarNFE:=.f.
wFgVaiGerarNFEcomplementar:=.f.

eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex30_onClick
wFgVaiGerarNFErefCancelamento:=.t.
wFgVaiGerarNFE:=(xGetEnv("NFE_TRANSMITE_APOS_DIGITACAO")="S")
vb_venda("ME3",,,,,"/PN/")
wFgVaiGerarNFE:=.f.

eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex18_onClick
vb_venda("MT",,,,,"/PN/")
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oBtnVenda_onClick
wFgVaiGerarNFE:=(xGetEnv("NFE_TRANSMITE_APOS_DIGITACAO")="S")
vb_venda("MV",,,,,"/PN/")
wFgVaiGerarNFE:=.f.

eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oButtonex8_onClick
vb_venda("MD1",,,,,"/PN/")
eVal(zbProximosNumeros)
RETURN Nil

STATIC FUNCTION oCheck1_onInit
vCheck1:=(xGetEnv("NFE_TRANSMITE_APOS_DIGITACAO")="S")
oCheck1:Refresh()
RETURN Nil

STATIC FUNCTION oCheck3_onClick
IF vCheck3
   s_nf_serie:=val(xGetEnv("NF_SERIE"))
ELSE
   s_nf_serie:=900
ENDIF
ALERT('O Modo de Contingencia SCAN foi '+IF(vCheck3,'DES','')+';;A Serie das notas foi modificada para '+LTRIM(STR(s_nf_serie,3))+'!;')

RETURN Nil

STATIC FUNCTION oLabel7_onInit
//skel variavel zProxNFe:=0
//skel variavel zProxNFC:=0
//skel variavel zProxNFs:=0
//skel variavel zbProximosNumeros:={||#TEXTO_FONTE
//skel 

zProxNFe := SiSemaf("CAPTE_PROXIMO_NUMERO", "/NFE/")
zProxNFc := SiSemaf("CAPTE_PROXIMO_NUMERO", "/NFC/") 



//MoveWindow(oDlg:Handle, 0,0,1019,547)
IF .not. sFgNFC
   oContainerNFCNFE:Hide() 
ENDIF
if xGetEnv("FATURA_SERVICOS")<>"S"
   oBtnOs:Hide()
   oBtnFecharOs:Hide()
   oBtnFatNFE:Hide()
   oBtnFatNFC:Hide()
   oBtnOutraS:Move( ,,oBtnVenda:nWidth, )   
   oBtnOutraE:Move( ,,oBtnVenda:nWidth, )   
ELSE
   IF LEFT(sys_segmento,2)<>'os'
      oBtnOs:SetText("Criar Orcamento")
      oBtnFecharOs:SetText("Fechar Orcamento")
   ENDIF
ENDIF
RETURN Nil

