;*******************************************************************************
;* Desenvolvido: 01/10/2020 por Bruno Carvalho                                 *
;*******************************************************************************
Autolib="\\Sistemas\\Cadastro\\Bibliot,\\Sistemas\\Cadastro\\Bib_Show"

DATAM_DATA   = DateVal("31.10.2020")
DATAM_VERSAO = "2020.J"
 
DATAM_EXECUTA = "SYS_DATAM"
Play "\\Sistemas\\Cadastro\\EXEC_DAT"

If Not DATAM_EXECUTA 
   Then Exit
   Else DATAM_ROTINA  = "Cadastro, MDFE e Vendas"
        DATAM_EXECUTA = "SYS_DATAM_MENSAGEM"
        Play "\\Sistemas\\Cadastro\\EXEC_DAT"
        If Not DATAM_EXECUTA
           Then Exit
        EndIf
EndIf

;*******************************************************************************
;Rotina Corre‡Æo de Tabelas                                                    *
;*******************************************************************************
Proc Correcao_Tabelas_Cadastro()

;---- 14/10/2020 por Bruno Carvalho --------------------------------------------
If Not IsTable("\\Sistemas\\Cadastro\\DestFone")
   Then Copy "\\Base\\Sistemas\\Cadastro\\DestFone" "\\Sistemas\\Cadastro\\DestFone"  
EndIf   

EndProc ;Correcao_Tabelas_Cadastro()

;*******************************************************************************
;Rotina Corre‡Æo de Tabelas                                                    *
;*******************************************************************************
Proc Correcao_Tabelas_MDFE()
Private ty,CAMPO

;---- Em 06/10/2020 por Anivel Augusto Rodrigues  ------------------------------
If IsTable("Mdfe_c") 
   Then 
        {Modify} {Restructure} {Mdfe_c}
        Moveto [Field Name]
        Locate "IndCarregaPosterior"
        if not retval
           Then End Down
                "IndCarregaPosterior"   Enter  "A1"   Enter
        EndIf
        Do_It!
        ClearAll
        
        {Tools} {Copy} {JustFamily} TypeIn "\\Base\\Sistemas\\MDFE\\Mdfe_c" Enter TypeIn "Mdfe_c" Enter {Replace}
EndIf   

;---- EM 09/10/2020 por Bruno Carvalho -----------------------------------------
If IsTable("Mdfe_mdd") 
   Then {Modify} {Restructure} {Mdfe_mdd}
        Moveto [Field Name]
        Locate "Tipo Movimento Estoque"
        if not retval
           Then End Down
                "Tipo Movimento Estoque"   Enter  "A1"   Enter
        EndIf
        Do_It!
        ClearAll
        
        {Tools} {Copy} {JustFamily} TypeIn "\\Base\\Sistemas\\MDFE\\Mdfe_mdd" Enter TypeIn "Mdfe_mdd" Enter {Replace}
EndIf   

EndProc ;Correcao_Tabelas_MDFE()
 
;*******************************************************************************
;Rotina Corre‡Æo de Tabelas                                                    *
;*******************************************************************************
Proc Correcao_Tabelas_Vendas()

;---- Em 01/10/2020 por Bruno Carvalho -----------------------------------------
If IsTable("FaturaCC")
   Then {Modify} {Restructure} {FaturaCC}
        Moveto [Field Name]
        Locate "NIRE"
        If Not RetVal
           Then End Down
                "NIRE"   Enter  "A15"   Enter
        EndIf
        Do_It!
        ClearAll
        
        {Tools} {Copy} {JustFamily} TypeIn "\\Base\\Sistemas\\Vendas\\FaturaCC" Enter TypeIn "FaturaCC" Enter {Replace}
EndIf

If IsTable("FaturaC")
   Then {Tools} {Copy} {JustFamily} TypeIn "\\Base\\Sistemas\\Vendas\\FaturaC" Enter TypeIn "FaturaC" Enter {Replace}
EndIf

;---- Em 19/10/2020 por Bruno Carvalho -----------------------------------------
If IsTable("CondPgto") 
   Then {Modify} {Restructure} {CondPgto}
        Moveto [Field Name]
        Locate "Utiliza_Balcao"
        if Not Retval
           Then End Down
                "Utiliza_Balcao"   Enter  "A1"   Enter
                "Utiliza_NFCE"     Enter  "A1"   Enter
                "CP_Inativo"       Enter  "A1"   Enter
                
        EndIf
        Do_It!
        ClearAll
        
        {Tools} {Copy} {JustFamily} TypeIn "\\Base\\Sistemas\\Vendas\\CondPgto" Enter TypeIn "CondPgto" Enter {Replace}
EndIf      

EndProc ;Correcao_Tabelas_Vendas()
                                         
;*******************************************************************************
;Rotina Principal                                                              *
;*******************************************************************************
Aguarde("Atualizando Sistema")
Password("t01avivcl")
Password("FechaSys")

View "SysTable"
SYS_CODIGO_CLIENTE = [Codigo do Cliente]
ClearAll

;-------------------------------------------------------------------------------
DATAM_ROTINA   = "CADASTRO"
DATAM_FECHAMES = ""
DATAM_EXECUTA  = "DATAM_SETDIR"
Play "\\Sistemas\\Cadastro\\EXEC_DAT" 

DATAM_ROTINA   = "MDFE"
DATAM_FECHAMES = "FECHAMES"
DATAM_EXECUTA  = "DATAM_SETDIR"
Play "\\Sistemas\\Cadastro\\EXEC_DAT" 

DATAM_ROTINA   = "VENDAS"
DATAM_FECHAMES = ""
DATAM_EXECUTA  = "DATAM_SETDIR"
Play "\\Sistemas\\Cadastro\\EXEC_DAT" 

{Tools} {More} {Directory} {\\Sistemas\\Cadastro\\}

DATAM_EXECUTA  = "DATAM_SYSTABLE"
Play "\\Sistemas\\Cadastro\\EXEC_DAT" 

UnPassword("t01avivcl")
UnPassword("FechaSys")
LimpAguarde()
FastMsg("Fim da atualiza‡Æo !")

DATAM_EXECUTA  = "DATAM_RELEASE"
Play "\\Sistemas\\Cadastro\\EXEC_DAT"

Release Vars DATAM_EXECUTA   