*       *       *       *       *       *       *       *       *       *       *       *       *       *       *       *       *       *       
*
*  2021-08-22 - name a descript pripravi uz editacni formular jidelaku
*  2021-10-31 - dinner se neduplikuje, to jsou ta jejich jidla po limitu
*  2022-12-30 - descript se posila "", aby se dal vyuzit pro zobrazeni poctu zbyvajicich porci u jidel po limitu
*  2023-06-08 - doplnovani jidel bez objednani prodlouzeno na 44
*  2023-11-27 - zruseno mazani fieldu description, i kdyz pocitadlo to bude premazavat pro jidla po limitu
*
*       *       *       *       *       *     #> ver. 2023-11-27 <#     *       *       *       *       *       *       *       *       *      


USE (m.gchom_path + "jidelak") IN 0

SELECT LEFT(TTOC(datum, 3), 10) as date, canteen, s_o_v2course(s_o_v) as course, cislojidla as number, cislopril, c_karty, name, descript, m.course_P + " " as add_course ;
       WHERE datum >= DATE() AND BETWEEN(cislojidla, 1, 19) FROM jidelak INTO CURSOR jidelak_local READWRITE 

SELECT * FROM jidelak_local INTO TABLE (m.gcpri_path + "jidelak_local2")
DELETE FOR course = "dinner "
REPLACE ALL course WITH ALLTRIM(course) + "2", add_course WITH ALLTRIM(add_course) + "2"

SELECT * FROM jidelak_local INTO TABLE (m.gcpri_path + "jidelak_local3")
DELETE FOR course = "dinner "
REPLACE ALL course WITH ALLTRIM(course) + "3", add_course WITH ALLTRIM(add_course) + "3"

SELECT * FROM jidelak_local INTO TABLE (m.gcpri_path + "jidelak_local4")
DELETE FOR course = "dinner "
REPLACE ALL course WITH ALLTRIM(course) + "4", add_course WITH ALLTRIM(add_course) + "4"

SELECT * FROM jidelak_local INTO TABLE (m.gcpri_path + "jidelak_local5")
DELETE FOR course = "dinner "
REPLACE ALL course WITH ALLTRIM(course) + "5", add_course WITH ALLTRIM(add_course) + "5"

SELECT jidelak_local 
APPEND FROM (m.gcpri_path + "jidelak_local2")
APPEND FROM (m.gcpri_path + "jidelak_local3")
APPEND FROM (m.gcpri_path + "jidelak_local4")
APPEND FROM (m.gcpri_path + "jidelak_local5")

*REPLACE ALL descript WITH ""
REPLACE FOR course = "dinner " descript WITH ""     && pero dinner generuje descript pocitadlo

jidelak_export_odeslani()

dopln_jidla_bez_objednani()


*       *       *       *       *       *       *       *       *       *       *       *       *       *       *       *       *       *       
PROCEDURE dopln_jidla_bez_objednani

FOR iii = 0 TO 44
     dddd = LEFT(TTOC(DATE() + m.iii, 3), 10)
     WAIT "bez objednani " + m.dddd + "  " + REPLICATE("*", m.iii) WINDOW AT 22,22 NOWAIT 

    jeden_neobjednanej_radek('"name":"M1- ", "number":21, "stock_card_number":5800')
    jeden_neobjednanej_radek('"name":"M2- ", "number":22, "stock_card_number":5802')
    jeden_neobjednanej_radek('"name":"M3- ", "number":23, "stock_card_number":5805')
    jeden_neobjednanej_radek('"name":"M4- ", "number":24, "stock_card_number":5806')
    jeden_neobjednanej_radek('"name":"M5- ", "number":25, "stock_card_number":5807')
    jeden_neobjednanej_radek('"name":"M6- ", "number":26, "stock_card_number":5808')
    jeden_neobjednanej_radek('"name":"M7- ", "number":27, "stock_card_number":5809')
    jeden_neobjednanej_radek('"name":"M8- ", "number":28, "stock_card_number":5810')
ENDFOR 
WAIT CLEAR 


*       *       *       *       *       *       *       *       *       *       *       *       *       *       *       *       *       *       
PROCEDURE jeden_neobjednanej_radek (radek_jidl)

json = http_request("canteen/crud/meals", "POST", '{"canteen":1, "course":"dinner", "date":"' + m.dddd + '", "show_on_web":false, ' +  m.radek_jidl + ' }')

