* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
*
*   2019-08-21 - posila i food_* spolecne s errorsama v jednom zipu
*   2019-09-18 - pridan "\" k gchom_path, pokud chybi
*   2019-09-25 - zvladne i sql verzi, kde chybi food_set a uz se neda zurnalovat do postgresu
*   2020-08-13 - v sql zredukovan errors
*   2020-09-18 - v masce souboru pro zipovani omezeno food_???
*   2024-01-01 - nehlasi se "ponovu" podle dph_styl
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 


IF DIRECTORY(m.gchom_path)
     adresar_k_odesilani = m.gchom_path
ELSE
     adresar_k_odesilani = ".\"
ENDIF 


IF m.issql
*    chyba_pri_otevirani = .F.
    DO open_database
    rv("errors", "errorsr")
    TRY
        SELECT * FROM "errorsr" WHERE cas > DATE()-55 INTO TABLE (m.adresar_k_odesilani + "errors_sql")
        USE IN errors_sql
    CATCH 
    ENDTRY 

    TRY 
        SELECT * FROM (m.sqlprefix + "rfooddat") INTO TABLE (m.adresar_k_odesilani + "food_dat_sql")
        USE IN food_dat_sql
    CATCH 
    ENDTRY 
ENDIF 

TRY
    backslash( @m.adresar_k_odesilani )

    zmensi_errors()
    zip_soubor = m.gcpri_path + "hlaseni.7z"
    ERASE (m.zip_soubor)
    ERASE (m.adresar_k_odesilani + "food_log.*")
    cmd = "run " + m.gcini_path + "7za a " + m.zip_soubor + " " + m.adresar_k_odesilani + "err*.dbf " + m.adresar_k_odesilani + "food_???.* " + m.adresar_k_odesilani + "d*.ver "
    &cmd
    DO poslimaildoalta WITH " HLASENI CHYB " + m.hotel_name + "-" + m.gchom_path + m.gcverze + " v " + m.machine  + "-" + m.gchom_path, "", ;
                            m.zip_soubor, "", "", "evzen@altopraha.cz"

CATCH TO xx_oErr 
    text_do_logu = ALLTRIM(STR(xx_oErr.ErrorNo)) + " " + xx_oErr.Message + " Line:" + ALLTRIM(STR(xx_oErr.LineNo))
    IF m.issql
        STRTOFILE("AUTOEXEC-z22 " + m.text_do_logu, m.adresar_k_odesilani + "z22_report.err" + CHR(13)+CHR(10), 1)
    ELSE 
        DO zurnal_log WITH "AUTOEXEC", "z22 ", m.text_do_logu
    ENDIF 
ENDTRY


* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
PROCEDURE zmensi_errors
TRY
    USE (m.adresar_k_odesilani + "errors") EXCLUSIVE 
    DELETE FOR cas < DATE() - 99 .and. ATC("V*E*R*Z*E instalovana", line_txt) = 0    
    DELETE FOR cas < DATE() - 33 .and. ATC("zapomenutej SUSPEND"  , line_txt) > 0
    DELETE FOR cas < DATE() - 33 .and. ATC("Při přenosu se nepodařilo připojit k serveru", line_txt) > 0
    PACK 
CATCH
ENDTRY 

TRY
    USE (m.adresar_k_odesilani + "err_log") EXCLUSIVE 
    pocet_radku = RECCOUNT()
    DELETE FOR RECNO() < m.pocet_radku - 222
    PACK 
CATCH
ENDTRY 

