#DEFINE POCETDNI 199

IF m.issql
  IF MESSAGEBOX("Opravdu chces smazat archiv trzeb i obratu?",3+32,"mazani archivu") = 6

    DO open_database
    
    proved("TRUNCATE TABLE food600.sk__fin_a ;")
    proved("TRUNCATE TABLE food600.sk__fis_a ;")
    proved("TRUNCATE TABLE food600.sk__plt_a ;")
    proved("TRUNCATE TABLE food600.sk__pol_a ;")
    proved("TRUNCATE TABLE food600.sk__sez_a ;")
    proved("TRUNCATE TABLE food600.sk__txt_a ;")

    proved("TRUNCATE TABLE food600.obraty_a  ;")
    proved("TRUNCATE TABLE food600.doklady_a ;")
    
    posledni_datum = DATE() - POCETDNI
    posledni_cas   = LEFT(TTOC(m.posledni_datum, 3), 10)

    proved("DELETE FROM food600.zurnal  WHERE    cas  < ?posledni_cas ;")

    
  ENDIF 
ENDIF 
smaz_stare_zurnaly()


*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    
FUNCTION proved (co_udelat)
WAIT m.co_udelat WINDOW NOWAIT 
vysledek = sql_exec( m.co_udelat )
zprava_do_logu = m.co_udelat + STR(m.vysledek, 5)
IF m.vysledek < 0
    DIMENSION chybaexe(9)
    chybaexe(2) = "vsechno v poradku"
    AERROR(chybaexe)
    MESSAGEBOX("SQL Chyba" + CHR(10) + chybaexe(2),64)
    zprava_do_logu = m.zprava_do_logu + " " + chybaexe(2)
ENDIF
small_log (m.zprava_do_logu, "truncate_archivu")
WAIT CLEAR 


*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    
PROCEDURE smaz_stare_zurnaly

ddd = DATE() - POCETDNI
FOR ii = 1 TO 5
    rrmm = SUBSTR(TTOC(m.ddd, 1), 3, 4)
    mm   = SUBSTR(m.rrmm        , 3, 2) 
    cmd = "run del /S /Q " + m.gchom_path + "zu" + m.mm + ".txt " + m.gchom_path + "z*" + m.rrmm + "*.txt "
    small_log (m.cmd, "truncate_archivu")
    &cmd
    ddd  = GOMONTH(m.ddd, -1)
ENDFOR 

