// Upgrade D205

h_PutLine("    Upgrade D205")

// ----------------------------------------------------------------------------
// Modificare structura Company
// se adauga nou cam RF_CIF_SUC
#IF !h_UseAlias("comp")
    Abandon("C")
#ENDIF
// campul RF_CIF_SUC nu exista, altfel nu ar fi intrat sa execute faza
sfld    := nil
xx_aStr := DbStruct()
PutMsg("MOD:comp -adaugare camp nou RF_CIF_SUC")

ic      := Ascan(xx_aStr,{|p| p[1]=="NB_UPD"})

AIns(xx_aStr,ic,{"RF_CIF_SUC", "C", 15, 0},.t.)
sfld := "RF_CIF_SUC"
h_CloseAlias()

#IF !Empty(sfld)
    xx_sfile := "comp"
    xx_ifile := fil_comp
    xx_fM    := "MANCOMP"
    #DO FUPGR.TXT
    h_PutLine("    Societate adaugat camp nou: "+sfld)
#ENDIF
h_CloseAlias()

// -----------------------------------------------------------------------------
// Comenzi generale

PutMsg("MOD:gcmd")
#IF !h_UseAlias("gcmd")
    h_PutLine("*** Eroare deschidere fisier Comenzi generale")
    #DO FUABANDN.TXT
#ENDIF

xx_sxmd := "E2_XML,E2_TXT,"
DbEval({|| DbDelete()}, {|| (gcmd->COD+",") $ xx_sxmd})
__dbApp( h_OsPath(homepath+"GENCMDS"), { }, {|| (field->COD+",") $ xx_sxmd},,,, .F. )
h_PutLine("    Adaugat/Inlocuit comanda generala (hSALAR): "+StrTran(xx_sxmd," ",""))

h_CloseAlias()

// -------------------------------------------------------------------------
//- Schimbare D205 PDF-uri
PutMsg("MOD:D205_ERR.PDF,D205_XML.PDF")
xx_decs:={;
          {"D205",h_FilePathes[fil_e2p],{"D205_ERR.PDF","D205_XML.PDF"}} ;
        }
xx_i:=1
#WHILE xx_i<=LEN(xx_decs)
    xx_decl_path:=h_AddPath(xx_decs[xx_i,1],xx_decs[xx_i,2])
    #IF (h_FDExist(xx_decl_path) = "D")
        xx_j:=1
        #WHILE xx_j<=LEN(xx_decs[xx_i,3])
            xx_sFisDep := h_AddPath(xx_decs[xx_i,3,xx_j],xx_decl_path)    
            xx_sLocFile:= homepath+xx_decs[xx_i,3,xx_j]
            //Verificare daca trebuie copiat
            lCopy:=.f.
            xx_oper    :="modificat"
            aDs   := h_Directory(xx_sLocFile)
            aDd   := h_Directory(xx_sFisDep)
            #IF Len(aDd)=0
                //Fisierul destinatie nu exista 
                xx_oper  :="adaugat"
                lCopy := .t.
            #ELSEIF (Len(aDd)=1) .AND. (DtoS(aDd[1,3])+aDd[1,4]) < (DtoS(aDs[1,3])+aDs[1,4])
                //Fisierul destinatie este mai veche decat cel de referinta 
                lCopy := .t.
            #ENDIF
            #IF (lCopy == .t.)
                #IF h_SafeErase(xx_sFisDep) .AND. h_SafeErase(StrTran(xx_sFisDep,".PDF",".pdf")) .AND. ;
                    h_CopyFile(xx_sLocFile,xx_sFisDep)
                    h_PutLine("    Fisier: "+xx_sFisDep+" "+xx_oper)
                #ELSE
                    h_PutLine("    Fisier: "+xx_sFisDep+" actualizare nereusita!")
                #ENDIF
            #ENDIF
            xx_j:=xx_j+1    
        #ENDDO 
    #ENDIF
    xx_i:=xx_i+1
#ENDDO 

// ---------------------------------------------------------------- 
#RETURN
