*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *
*
*
*    *    *    *    *    *    *    *    *    *    *    *      #> ver. 2019-03-20 <#       *    *    *    *    *    *    *    *    *    *    *    *    *

#DEFINE ODD          ";"
#DEFINE IMPORT_PATH  "i:\food600\"

mail_domain = "@synthomer.com"

o_set_point = SET("POINT")

*HTTP_READ_ONLY_MODE = .T.

DO (LOWER(JUSTPATH(sys(16))) + "\http_ppgm") WITH "https://admin:admin@canteen-synthomer-backend.alto-production.mine.nu/"
DO (LOWER(JUSTPATH(sys(16))) + "\ppgm_klienti") WITH "logovat"

ACTIVATE SCREEN 
_screen.Cls
IF importuj_csv() > 0
    DO stahni_webovy_klienty
    SELECT stravnici_karty_web

    DO priprav_co_delat
    
    SELECT stravnici_karty_web
    REPLACE ALL  c_hlad WITH 2, limit WITH -9999

    DO posli_cloveky

ENDIF 

SET POINT TO (m.o_set_point)
oznam_hotovo()

*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *
PROCEDURE  importuj_csv

SELECT 0
USE stravnici
SCAN 
        firstname = ALLTRIM(jmeno)
        surname   = ALLTRIM(prijmeni)
        client_id = ALLTRIM(osc)
        chip_id   = ALLTRIM(chip_id)
        firma     = ALLTRIM(firma)
        limit     = -3333

        IF VAL(m.client_id) # 0
            INSERT INTO stravnici_karty FROM MEMVAR 
        ENDIF 
ENDSCAN 
RETURN 99
