*   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   * 
*
* 2023-12-19 - opraveno v sql oprava konkretnich skupin
*
*


#DEFINE CRLF          CHR(13)+CHR(10)

err_h_info = "ver. 2024-01-01result"

IF DATETIME() < {^2024-01-22}

    CLOSE DATABASES 

    nastav_sazby_v_depehacka()
    CLOSE DATABASES 
ENDIF 


*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *   
PROCEDURE nastav_sazby_v_depehacka
IF m.issql
    DO open_database

    sql_select("SELECT dzmeny, koefdph FROM food600.depehacka ", "sqlresult") 
    SELECT sqlresult
    LOCATE FOR dzmeny > {^2023-12-30}
    IF .not. FOUND()

        proved("INSERT INTO food600.depehacka (dzmeny, koefdph, popis) VALUES ('2023-12-31', 1.00, 'nulova'  )")
        proved("INSERT INTO food600.depehacka (dzmeny, koefdph, popis) VALUES ('2023-12-31', 1.10, 'nizka_10')")
        proved("INSERT INTO food600.depehacka (dzmeny, koefdph, popis) VALUES ('2023-12-31', 1.12, 'snizena' )")
        proved("INSERT INTO food600.depehacka (dzmeny, koefdph, popis) VALUES ('2023-12-31', 1.15, 'nizka_15')")
        proved("INSERT INTO food600.depehacka (dzmeny, koefdph, popis) VALUES ('2023-12-31', 1.21, 'zakladni')")

    ENDIF 

ELSE 

    IF .not. FILE(m.gchom_path + "depehacka.dbf")
        CREATE TABLE (m.gchom_path + "depehacka") FREE (dzmeny D, koefdph N(7,3))
        USE 
    ENDIF 

    USE (m.gchom_path + "depehacka")
    LOCATE FOR dzmeny > {^2023-12-30}
    IF .not. FOUND()
        DO dopln_sazby WITH 1.00
        DO dopln_sazby WITH 1.10
        DO dopln_sazby WITH 1.12
        DO dopln_sazby WITH 1.15
        DO dopln_sazby WITH 1.21
    ENDIF 
ENDIF 


*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *   
PROCEDURE dopln_sazby
PARAMETERS v_value
INSERT INTO (m.gchom_path + "depehacka") (dzmeny, koefdph) VALUES ({^2023-12-31}, m.v_value)


*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    
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, "dane2024_depehacka")
WAIT CLEAR 
