speciality_komplet = left(jaz("m_ost speciality"), 2)
speciality_komplet = .not. ( left(m.speciality_komplet, 1) = "\" .and. m.speciality_komplet # "\<" )

DEFINE POPUP speciality MARGIN RELATIVE SHADOW COLOR SCHEME 4

#DEFINE NEEXISTUJE "Z-Z-Z-Z-Z-Z-Z"

kus_hom_path = UPPER(STRTRAN(SUBSTR(m.gchom_path, RAT("\", m.gchom_path,2)+1), "\", ""))
pridat_oddelovac_admina = .T.

pocet_spec = ADIR(soubory, m.gcini_path + "speciality\*.fxp")
FOR iii = 1 TO pocet_spec
   programek = LOWER(JUSTSTEM(soubory(iii, 1)))
   STORE "*" + m.programek TO cmd1, cmd2
   IF LEFT(m.programek, 1) # "_"
       seznam_cest = povolene_cesty (m.programek)

       DO CASE 
       CASE ATC("ppgm_", m.programek ) > 0
           cmd1 = "* nic - tyhle programy se nenabizi nikomu, jsou to podprogramy"
           cmd2 = "* nic - tyhle programy se nenabizi nikomu, jsou to podprogramy"

       CASE EMPTY(m.seznam_cest)    && neni-li seznam adresaru zadan, program se pousti vsem
           cmd1 = "DEFINE BAR "       + STR(m.iii, 3) + " OF speciality" + " PROMPT '" + LOWER(m.programek) + "'"
           cmd2 = "ON SELECTION BAR " + STR(m.iii, 3) + " OF speciality" + " DO exec_speciality IN priprav_speciality WITH '" + m.programek + "'"

       CASE ATC(m.kus_hom_path, m.seznam_cest) + ATC(m.wi_zakaz, m.seznam_cest) + ATC(GETENV("computername"), m.seznam_cest) > 0
           cmd1 = "DEFINE BAR "       + STR(m.iii, 3) + " OF speciality" + " PROMPT '" + UPPER(m.programek) + "'"
           cmd2 = "ON SELECTION BAR " + STR(m.iii, 3) + " OF speciality" + " DO exec_speciality IN priprav_speciality WITH '" + m.programek + "'"

       ENDCASE 
   ELSE 
      IF m.speciality_komplet .or. LEFT(m.programek, 2) = "__"
         IF m.pridat_oddelovac_admina
             DEFINE BAR (m.iii) OF speciality PROMPT "\-"
             pridat_oddelovac_admina = .F.
         ENDIF 
         cmd1 = "DEFINE BAR "       + STR(m.iii+5, 3) + " OF speciality" + " PROMPT '" + UPPER(m.programek) + "'"
         cmd2 = "ON SELECTION BAR " + STR(m.iii+5, 3) + " OF speciality" + " DO exec_speciality IN priprav_speciality WITH '" + m.programek + "'"
      ENDIF
   ENDIF 
   &cmd1
   &cmd2

ENDFOR

DEFINE BAR (m.pocet_spec+7) OF speciality PROMPT "\-"
pocet_adresaru = ADIR(soubory_adresaru, m.gcini_path + "speciality\*.", "D")
FOR iii_a = 1 TO pocet_adresaru
    podmenu = UPPER(JUSTSTEM(soubory_adresaru(iii_a, 1)))
    podmenu_popup = "special_" + alpha_digit_only(podmenu)
    IF LEN(m.podmenu) > 2
      seznam_cest = povolene_cesty (m.podmenu + "\")
      IF EMPTY(m.seznam_cest) .or. ATC(m.kus_hom_path, m.seznam_cest) + ATC(m.wi_zakaz, m.seznam_cest) + ATC(GETENV("computername"), m.seznam_cest) > 0      
      
        DEFINE POPUP (m.podmenu_popup) MARGIN RELATIVE SHADOW COLOR SCHEME 4
        DEFINE BAR (m.iii_a + m.pocet_spec+8) OF speciality PROMPT UPPER(m.podmenu)
        ON     BAR (m.iii_a + m.pocet_spec+8) OF speciality ACTI POPUP (m.podmenu_popup)

        pocet = ADIR(soubory, m.gcini_path + "speciality\" + m.podmenu + "\*.fxp")
        FOR iii = 1 TO pocet
           programek = LOWER(JUSTSTEM(soubory(iii, 1)))
           STORE "*" + m.programek TO cmd1, cmd2
           IF LEFT(m.programek, 1) # "_"
               seznam_cest = povolene_cesty (m.podmenu + "\" + m.programek)
               DO CASE 
               CASE ATC("ppgm_", m.programek ) > 0
                   cmd1 = "* nic - tyhle programy se nenabizi nikomu, jsou to podprogramy"
                   cmd2 = "* nic - tyhle programy se nenabizi nikomu, jsou to podprogramy"

               CASE EMPTY(m.seznam_cest)    && neni-li seznam adresaru zadan, program se pousti vsem
                   cmd1 = "DEFINE BAR "       + STR(m.iii, 3) + " OF " + m.podmenu_popup + " PROMPT '" + LOWER(m.programek) + "'"
                   cmd2 = "ON SELECTION BAR " + STR(m.iii, 3) + " OF " + m.podmenu_popup + " DO exec_speciality IN priprav_speciality WITH '" + m.podmenu + "\" + m.programek + "'"

               CASE ATC(m.kus_hom_path, m.seznam_cest) + ATC(m.wi_zakaz, m.seznam_cest) + ATC(GETENV("computername"), m.seznam_cest) > 0
                   cmd1 = "DEFINE BAR "       + STR(m.iii, 3) + " OF " + m.podmenu_popup + " PROMPT '" + UPPER(m.programek) + "'"
                   cmd2 = "ON SELECTION BAR " + STR(m.iii, 3) + " OF " + m.podmenu_popup + " DO exec_speciality IN priprav_speciality WITH '" + m.podmenu + "\" +  m.programek + "'"
               ENDCASE 
           ELSE 
              IF m.speciality_komplet .or. LEFT(m.programek, 2) = "__"
                 IF m.pridat_oddelovac_admina
                     DEFINE BAR (m.iii) OF speciality PROMPT "\-"
                     pridat_oddelovac_admina = .F.
                 ENDIF 
                 cmd1 = "DEFINE BAR "       + STR(m.iii+5, 3) + " OF " + m.podmenu_popup + " PROMPT '" + UPPER(m.programek) + "'"
                 cmd2 = "ON SELECTION BAR " + STR(m.iii+5, 3) + " OF " + m.podmenu_popup + " DO exec_speciality IN priprav_speciality WITH '" + m.podmenu + "\" +  m.programek + "'"
              ENDIF
           ENDIF 
           &cmd1
           &cmd2

        ENDFOR
        DEFINE BAR 998 OF (m.podmenu_popup) PROMPT "\-"
     ENDIF 
    ENDIF 
ENDFOR 

DEFINE BAR 998 OF speciality PROMPT "\-"
DEFINE BAR 999 OF speciality PROMPT "\-"


*!*****************************************************************************
FUNCTION povolene_cesty (klic)
cesticky = get_ini("speciality", m.klic, NEEXISTUJE, m.gcini_path + "speciality\speciality.ini")
IF m.cesticky = NEEXISTUJE
    cesticky = ""
    writeprivstr( "speciality", m.klic, "", m.gcini_path + "speciality\speciality.ini")
ENDIF
RETURN m.cesticky


*!*****************************************************************************
PROCEDURE exec_speciality
PARAMETERS exec_speciality_prikaz
IF FILE(m.gcini_path + "speciality\" + m.exec_speciality_prikaz + ".prg")
    ex_s_txt = FILETOSTR(m.gcini_path + "speciality\" + m.exec_speciality_prikaz + ".prg")
    zobrazit_had = (ATC("*BEZ HADA*", m.ex_s_txt ) = 0)
    ex_s_txt = SUBSTR(ex_s_txt, AT("#>", m.ex_s_txt )+2)
    ex_s_txt = jaz("Opravdu spustit program") + CHR(13) + UPPER(m.exec_speciality_prikaz) + " ?" + CHR(13) + CHR(9) + ALLTRIM(LEFT(ex_s_txt, AT("<#", m.ex_s_txt)-1))
ELSE
    ex_s_txt = jaz("Opravdu spustit program") + CHR(13) + UPPER(m.exec_speciality_prikaz) + " ?"
    zobrazit_had = .T.
ENDIF

IF EMPTY(zobrazit_had) .or. (MESSAGEBOX(m.ex_s_txt, 3+32+256, "Speciality") = 6)
    had_exespec = CREATEOBJECT("had", m.exec_speciality_prikaz)
    IF m.zobrazit_had 
        had_exespec.SHOW()
    ENDIF 
    ACTIVATE SCREEN 
    DO zurnal_log WITH "OPERA", "SPECIALITKA " + m.exec_speciality_prikaz
    DO clos_data
    DO (m.exec_speciality_prikaz)
    DO clos_data
    DO zurnal_log WITH "OPERA", "SPECIALITKA " + m.exec_speciality_prikaz + " " + had_exespec.trvalo()
    RELEASE had_exespec
ENDIF


* tohle slouzi k tomu, aby food nebyl predcasne ukoncen pri zdanlive necinnosti, kdyz si budou spoustet speciality
cas_posledni_cinnosti = TIME()
* tohle slouzi k tomu, aby food nebyl predcasne ukoncen pri zdanlive necinnosti, kdyz si budou spoustet speciality
