PRIVATE m.cosetup
DO clos_data
IF f_acc('(m.gchom_path + "FOOD_DAT") NOUPDA')
	SELE id, id_zkratka, pgm, cen_path,id_klapky,;
		UPPE(ALLTRIM(pgm_path) + PADR(ALLT(pgm), 5, "_") + "set.dbf     ") AS set_dbf1, ;
		UPPE(m.gchom_path + "s_" + PADR(ALLT(pgm), 4, "_") + ALLT(setup_skup) + SPACE(22)) AS set_dbf2 ,;
		SPACE(100) as subor;
		FROM (m.gchom_path + "food_dat") WHERE (! EMPTY(pgm + pgm_path)) ORDER BY id INTO TABLE (m.gcpri_path + "fddat")
    REPLACE FOR "\MAN__SET.DBF" $ set_dbf1 set_dbf1 WITH UPPER(m.gcpgm_path) + "MAN__SET.DBF"

	DELE FOR .NOT. FILE(set_dbf1) .OR. "*" $ pgm
	PACK
	INSERT INTO (m.gcpri_path + "fddat") (id, id_zkratka, set_dbf1, set_dbf2) VALUE ;
		("  ", jaz("Centralni setup"), UPPE(m.gcpgm_path + "food_set.dbf"), m.gchom_path + "FOOD_SET")
	INSERT INTO (m.gcpri_path + "fddat") (id, id_zkratka, set_dbf1, set_dbf2) VALUE ;
		("  ", "FOOD_DAT", "FOOD_DAT", m.gchom_path + "FOOD_DAT")
	INSERT INTO (m.gcpri_path + "fddat") (id, id_zkratka, set_dbf1, set_dbf2) VALUE ;
		("  ", jaz("Seznam tiskaren"), "Seznam tiskaren", m.gchom_path + "PRN_DEF")
	INSERT INTO (m.gcpri_path + "fddat") (id, id_zkratka, set_dbf1, set_dbf2) VALUE ;
		("  ", jaz("Kursy cizích měn"), "Kursy cizích měn", m.gchom_path + "KURSY")

	SELE id, id_zkratka, pgm, setup_skup,cen_path,id_klapky,;
		UPPE(allt(dat_path)) + "HRAS_SET.DBF" AS set_dbf2 ;
		FROM (m.gchom_path + "food_dat") WHERE upper(left(pgm, 3)) $ "KAS K32" and "MAST" $ pgm_param INTO TABLE (m.gcpri_path + "kasset")
	SCAN 
		SCATTER MEMVAR 
		IF FILE(m.gchom_path+"s_"+ALLTRIM(pgm)+"_"+ALLTRIM(setup_skup)+".dbf")
			SELECT 0
			USE (m.gchom_path+"s_"+ALLTRIM(pgm)+"_"+ALLTRIM(setup_skup)+".dbf") ALIAS setfile
			m.typ_hotel=1
			SCAN FOR ALLTRIM(LOWER(var_name))="typ_hotel"
				m.typ_hotel=VAL(ALLTRIM(var_value))
			ENDSCAN 
			USE IN setfile
			SELECT kasset
			IF kasset.pgm="K32"
				DO CASE 
					CASE m.typ_hotel=1
					* Hores
					* HRAS_SET
					CASE m.typ_hotel=2
					* Domino
					* HRAS_SET
					CASE m.typ_hotel=4
					* Hores Win
					* HRAS_SET
					CASE m.typ_hotel=5
					* CLS
					* HRAS_SET
					CASE m.typ_hotel=6
					* Fidelio
					* FRAS_SET
						REPLACE set_dbf2 WITH STRTRAN(LOWER(set_dbf2),"hras_set","fras_set")
						SCATTER MEMVAR FIELDS set_dbf2
					CASE (m.typ_hotel=7).or.(m.typ_hotel=11)
					* H2000,LIBRA
					* HRAS_SET
					CASE m.typ_hotel=8
					* ComArr
					* HRAS_SET
					CASE m.typ_hotel=9
					* Horec
					* HOR_SET
						REPLACE set_dbf2 WITH STRTRAN(LOWER(set_dbf2),"hras_set","hor_set")
						SCATTER MEMVAR FIELDS set_dbf2
					CASE m.typ_hotel=12
					* Front
					* HOR_SET
						REPLACE set_dbf2 WITH STRTRAN(LOWER(set_dbf2),"hras_set","frontset")
						SCATTER MEMVAR FIELDS set_dbf2
				ENDCASE
			ELSE
				DO CASE 
					CASE m.typ_hotel=1
					* Hores
					* HRAS_SET
					CASE m.typ_hotel=2
					* Domino
					* HRAS_SET
					CASE m.typ_hotel=4
					* Hores Win
					* HRAS_SET
					CASE m.typ_hotel=5
					* Hores
					* HRAS_SET
					CASE m.typ_hotel=6
					* Horec
					* HOR_SET
						REPLACE set_dbf2 WITH STRTRAN(LOWER(set_dbf2),"hras_set","hor_set")
						SCATTER MEMVAR FIELDS set_dbf2
					CASE (m.typ_hotel=7)
					* Fidelio
					* FRAS_SET
						REPLACE set_dbf2 WITH STRTRAN(LOWER(set_dbf2),"hras_set","fras_set")
						SCATTER MEMVAR FIELDS set_dbf2
				ENDCASE
			ENDIF 
		ENDIF 	
		IF FILE(ALLTRIM(m.set_dbf2))
			INSERT INTO (m.gcpri_path + "fddat") (id,   id_zkratka,   set_dbf2,cen_path, id_klapky) ;
				VALUE (m.id, m.id_zkratka, m.set_dbf2,m.cen_path,m.id_klapky)
		ENDIF 
	ENDSCAN 
	DO clos_data
	USE (m.gcpri_path + "fddat")
	REPLACE id_klapky WITH id FOR EMPTY(id_klapky)
	REPLACE ALL subor WITH 	id + " | " + id_zkratka + " | " + set_dbf2
	DO WHILE .T.
		DO FORM dajdruh WITH "","fddat","subor",600 TO m.nazevx
       	IF EMPTY(m.nazevx)
			EXIT 
   	    ELSE
       		SELECT fddat
       		LOCATE FOR ALLTRIM(subor)=ALLTRIM(m.nazevx)
			DO CASE
				CASE "FOOD_DAT" $ UPPER(fddat.set_dbf2)
					IF f_acc('(m.gchom_path + "food_dat") ORDER id')
						DEFI WIND brw FROM 0,0 TO 44, 95
						ON KEY LABEL F10 KEYB "{Ctrl+W}"
						BROW WIND brw NORMAL LOCK 1
                        REPL pgm_path WITH UPPE(ALLT(pgm_path) + IIF(RIGHT(ALLT(pgm_path),1)="\", "", "\")), ;
                             dat_path WITH UPPE(ALLT(dat_path) + IIF(RIGHT(ALLT(dat_path),1)="\", "", "\")), ;
                             cen_path WITH UPPE(ALLT(cen_path) + IIF(RIGHT(ALLT(cen_path),1)="\", "", "\"))
						ON KEY LABEL F10
						RELE WIND brw
						USE
					ELSE
						WAIT jaz("prg_dbf_neprist_skuste_pozdeji") WIND TIME 2
					ENDIF
				CASE "KURSY" $ UPPER(fddat.set_dbf2)
					IF f_acc('(m.gchom_path + "kursy")')
						DEFI WIND brw FROM 0,0 TO 44, 95
						ON KEY LABEL F10 KEYB "{Ctrl+W}"
						BROW field stat:R, mena:R, pocet, kurs, kurs_nak WIND brw NORMAL for mena<>"EUX"
						ON KEY LABEL F10
						RELE WIND brw
						USE
					ELSE
						WAIT jaz("prg_dbf_neprist_skuste_pozdeji") WIND TIME 2
					ENDIF
				CASE ("HRAS" $ UPPER(fddat.set_dbf2)) .or. ("FRAS" $ UPPER(fddat.set_dbf2)) .or. ("HOR_" $ UPPER(fddat.set_dbf2))
					m.cosetup=allt(fddat.set_dbf2)
					IF f_acc('(m.cosetup) alias setdbf2 order druh')
						IF FILE(ALLTRIM(fddat.cen_path)+"cen"+ALLTRIM(fddat.id_klapky)+".dbf")
							SELECT 0
							USE (ALLTRIM(fddat.cen_path)+"cen"+ALLTRIM(fddat.id_klapky)+".dbf") ALIAS cenxx
							SELECT DISTINCT druh FROM cenxx INTO TABLE (m.gcpri_path+"druhyxx")
							USE IN cenxx
							SELECT druhyxx
							SET RELATION TO druh INTO setdbf2
							COPY TO (m.gcpri_path+"novexx") FOR EMPTY(setdbf2.druh)
							USE IN druhyxx
							SELECT setdbf2
							APPEND FROM (m.gcpri_path+"novexx")
						ELSE
							m.setidklapky=fddat.id_klapky
							IF FILE(ALLTRIM(fddat.cen_path)+"umisteni.dbf")
								SELECT 0
								USE (ALLTRIM(fddat.cen_path)+"umisteni.dbf") ALIAS cenxx
								SELECT DISTINCT druh_kalk as druh FROM cenxx INTO TABLE (m.gcpri_path+"druhyxx") WHERE cenxx.id_kas=m.setidklapky
								USE IN cenxx
								SELECT druhyxx
								SET RELATION TO druh INTO setdbf2
								COPY TO (m.gcpri_path+"novexx") FOR EMPTY(setdbf2.druh)
								USE IN druhyxx
								SELECT setdbf2
								APPEND FROM (m.gcpri_path+"novexx")
							ENDIF 
						ENDIF 
						DEFI WIND brw FROM 0,0 TO 44, 95
						ON KEY LABEL F10 KEYB "{Ctrl+W}"
						IF FSIZE("RASTR1") > 0
							BROW field druh:w=.f., rastr, rastr1, rastr2, rastr3, rastr4, rastr5, kdy:w=.f., kdo:w=.f. WIND brw NORMAL NODELE NOAPPE title ALLTRIM(fddat.set_dbf2)
						ELSE
							BROW freez rastr WIND brw NORMAL NODELE NOAPPE title ALLTRIM(fddat.set_dbf2)
						ENDIF
						ON KEY LABEL F10
						
						RELE WIND brw
						REPLACE kdo WITH m.gcuser_id FOR EMPTY(kdy)
						REPLACE kdy WITH DTOS(DATE())+" "+TIME() FOR EMPTY(kdy)
						USE
					ELSE
						WAIT jaz("prg_dbf_neprist_skuste_pozdeji") WIND TIME 2
					ENDIF
				CASE "PRN_DEF" $ UPPER(set_dbf2)
					IF f_acc('(m.gchom_path + "prn_def")')
						INDEX ON prn_no TO (m.gcpri_path + "p")
						SET CARRY ON
						DEFI WIND brw FROM 0,0 TO 44, 95
						ON KEY LABEL F10 KEYB "{Ctrl+W}"
						BROW WIND brw NORMAL LOCK 1
						ON KEY LABEL F10
						RELE WIND brw
						SET CARRY OFF
						USE
					ELSE
						WAIT jaz("prg_dbf_neprist_skuste_pozdeji") WIND TIME 2
					ENDIF
				OTHERWISE
                
					set_dbf1 = ALLT(set_dbf1)
					set_dbf2 = ALLT(set_dbf2) + ".dbf"
					IF FILE(m.set_dbf2)
						=f_acc('(m.set_dbf1) ALIAS set_dbf1 NOUPDA')
						=f_acc('(m.set_dbf2) ALIAS set_dbf2')
						SELECT * FROM (m.set_dbf1) INTO TABLE (m.gcpri_path + "pom") ;
							WHERE var_name NOT IN (SELECT var_name FROM (m.set_dbf2))
						SELE set_dbf2
						IF FILE (m.gcpri_path + "pom.dbf")
							APPEND FROM (m.gcpri_path + "pom")
						ENDIF
					ELSE
						=f_acc('(m.set_dbf1) ALIAS set_dbf1 NOUPDA')
						COPY ALL FIELDS var_name, var_value TO (m.set_dbf2)
						=f_acc('(m.set_dbf2) ALIAS set_dbf2')
					ENDIF
					SELE set_dbf1
					INDEX ON padr(var_name, 20) TO (m.gcpri_path + "var_name")
					IF FSIZE("var_ponuka")=0
						SELE set_dbf2
						SET RELA TO padr(var_name, 20) INTO set_dbf1
*						DELE FOR EMPT(set_dbf1.var_name)
						INDEX ON var_name TO (m.gcpri_path + "pom")
						DEFI WIND brw FROM -2,0 TO 40, 100
						ON KEY LABEL f10 KEYBOARD "{Ctrl+W}"
        	
						**** L.L. (16.8.2005) Ak nie je prihlasny sup, aby nezobrazovalo zakazany parametre
						IF upper(gcuser_id) # "SUP"
							SET FILTER TO !set_dbf1.supervisor
						ENDIF
						**** L.L. (16.8.2005) ************************
			
						BROW FIELD t = var_name + "  " + set_dbf1.var_typ :H="Polozka" :14, ;
							var_value:v=v_value() :24 :H="Hodnota", set_dbf1.comment FREEZ var_value ;
							WINDOW brw NORMAL NODELE NOAPPE TITLE DBF()
						ON KEY LABEL f10
						RELE WIND brw
					ELSE
						USE IN set_dbf1
						USE IN set_dbf2
						DO FORM set_set WITH m.set_dbf2
					ENDIF 
			ENDCASE
			DO pozavirej WITH "set_dbf1, set_dbf2, machines"
		ENDIF
		SELE fddat
	ENDDO
	DO clos_data
ELSE
	WAIT jaz("form food_dat nepris") WIND TIME 1
ENDIF

*!*****************************************************************************
PROCEDURE v_value
RETURN (TYPE(var_value) = UPPER(set_dbf1.var_typ))
