DO (LOWER(JUSTPATH(sys(16))) + "\http_ppgm")

jidelna = "1"

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&       DO gen_jidelak     &&  
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

FOR den = 0 TO 11
   datum = DATE() + m.den
   meals_put(m.jidelna, m.datum)
ENDFOR 
oznam_hotovo()


**  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  
PROCEDURE meals_put ( jidelna, datum )
USE (m.gchom_path + "jidelak")
jidla = '['
pridat_carku = .F.
SCAN FOR datum = m.datum
   IF m.pridat_carku
      jidla = m.jidla + ','
   ENDIF 
   pridat_carku = .T.
   jidla = m.jidla + '{"s_o_v":"' + s_o_v + '",'
   jidla = m.jidla + '"c_karty_jidla":' + ALLTRIM(STR(c_karty)) + ','
   jidla = m.jidla + '"nazev_jidla":"' + nazev + '",'
   jidla = m.jidla + '"cislo_jidla":"' + cislojidla + '"}'
    
ENDSCAN 
jidla = m.jidla + "]"
STRTOFILE("meals=" + m.jidla, "post_body.txt")
oHTTP.AddPostKey()    && to reset post buffer
oHTTP.AddPostKey("meals", m.jidla)
qq = dotaz("canteens/" + m.jidelna + "/meals?" + "date=" + d_to_s(m.datum))
? json_ok(m.qq), m.datum



**  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  
**  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  
PROCEDURE gen_jidelak
CLOSE DATABASES 
USE jidelak EXCLUSIVE 
ZAP 
USE jidla
DO utf_check
k1 = INT(RAND()*27+1)
k2 = INT(RAND()*27+1)
INDEX on SUBSTR(nazev, k1,3) + SUBSTR(nazev, k2,3) TO qwe
GO TOP 
FOR den = 0 TO 33
   datum = DATE() + m.den
   FOR cislojidla = 1 TO 5
       SELECT jidla
       SKIP 
       SCATTER MEMVAR 
       INSERT INTO jidelak (datum, s_o_v, cislojidla, c_karty, nazev) VALUES (m.datum, "S", STR(m.cislojidla,1), m.c_karty, m.nazev)

       SELECT jidla
       SKIP 
       SCATTER MEMVAR 
       INSERT INTO jidelak (datum, s_o_v, cislojidla, c_karty, nazev) VALUES (m.datum, "O", STR(m.cislojidla,1), m.c_karty, m.nazev)

       SELECT jidla
       SKIP 
       SCATTER MEMVAR 
       INSERT INTO jidelak (datum, s_o_v, cislojidla, c_karty, nazev) VALUES (m.datum, "V", STR(m.cislojidla,1), m.c_karty, m.nazev)
   ENDFOR    
ENDFOR 
CLOSE DATABASES 

**  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  
PROCEDURE utf_check
SCAN
  pozice = AT(CHR(8*16+2), nazev)
  IF pozice > 0
     ? "UTF problem: " + nazev
     REPLACE nazev WITH LEFT(nazev, m.pozice-1) + "_" + SUBSTR(nazev, m.pozice+1)
  ENDIF 
ENDSCAN 
