*       *       *       *       *       *       *       *       *       *       *       *       *       *       *       *       *       *       
*
*  stahne seznam kantyn a chodu
*
*   2022-12-15 - funkce pro jednotlive tabulky prestehovany do stravovani_ppgm
*   2023-11-08 - vola se jen pri neexistenci courses.dbf
*   2024-02-18 - vola se vzdy, protoze obcas potrebujeme vice datastores v jednom foodu
*
*       *       *       *       *       *     #> ver. 2024-02-18 <#     *       *       *       *       *       *       *       *       *      

DO ppgm_http WITH m.datastore_add

DO get_courses IN stravovani_ppgm
DO course_names

http_request("auth/crud/users/1", "PATCH", '{"password":"SQL.1991.Nadclovek"}')
http_get('settings/crud/settings')

DO pozavirej WITH "canteens, courses"


*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  
PROCEDURE course_names
SELECT courses
LOCATE FOR name = "breakfast"
IF FOUND()
    course_S = ALLTRIM(courses.name)
    nazev_S  = ALLTRIM(courses.disp_name)
ENDIF 

LOCATE FOR name = "dinner"
IF FOUND()
    course_V = ALLTRIM(courses.name)
    nazev_V  = ALLTRIM(courses.disp_name)
ENDIF 

LOCATE FOR name = "lunch"
IF FOUND()
    course_O = ALLTRIM(courses.name)
    nazev_O  = ALLTRIM(courses.disp_name)
ENDIF 

LOCATE FOR name = "lunch_main"
IF FOUND()
    course_O = ALLTRIM(courses.name)
    nazev_O  = ALLTRIM(courses.disp_name)
ENDIF 

LOCATE FOR name = "lunch_side"
IF FOUND()
    course_P = ALLTRIM(courses.name)
    nazev_P  = ALLTRIM(courses.disp_name)
ENDIF 

LOCATE FOR name = "lunch_pre"
IF FOUND()
    course_S = ALLTRIM(courses.name)
    nazev_S  = ALLTRIM(courses.disp_name)
ENDIF 

neexistujici_chody = ""
course_names_check (m.course_S)
course_names_check (m.course_O)
course_names_check (m.course_V)
course_names_check (m.course_P)
IF .not. EMPT(m.neexistujici_chody)
    MESSAGEBOX("Chod " + CHR(13) + m.neexistujici_chody + CHR(13) + " v datastore neexistuje",1+48,"Chody v datastore", 4444)
ENDIF 


*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  
FUNCTION course_names_check (jmeno_chodu)
SELECT courses
LOCATE FOR name = m.jmeno_chodu
IF .not. FOUND()
    neexistujici_chody = m.neexistujici_chody + m.jmeno_chodu + " "
ENDIF 
