
CLOSE DATABASES 
USE (m.gcdat_path + "karty")    ORDER c_karty   IN 0
USE (m.gcdat_path + "partneri") ORDER c_partner IN 0

SELECT c_dokl, c_partner, doklad, datum_dokl, pz1, pz2, kdy ;
       FROM (m.gcdat_path + "dokl_a") INTO TABLE (m.gcpri_path + "d_a")
SELECT c_dokl, c_partner, doklad, datum_dokl, pz1, pz2, kdy, SPACE(30) as partner ;
       FROM (m.gcdat_path + "doklady") INTO TABLE (m.gcpri_path + "dok")
APPEND FROM (m.gcpri_path + "d_a")
SET RELATION TO c_partner INTO partneri
REPLACE ALL partner WITH partneri.partner
INDEX on c_dokl TAG c_dokl

SELECT c_stredisk, operace, c_dokl, c_karty, serial_no, mnozstvi, cena, zustatek, "A" as archiv ;
       WHERE NOT EMPTY(serial_no) .and. operace # "PR" FROM (m.gcdat_path + "obra_a") INTO TABLE (m.gcpri_path + "o_a")
SELECT c_stredisk, operace, c_dokl, c_karty, serial_no, mnozstvi, cena, zustatek, " " as archiv, SPACE(40) as nazev ;
       WHERE NOT EMPTY(serial_no) FROM (m.gcdat_path + "obraty") INTO TABLE (m.gcpri_path + "obr")
APPEND FROM (m.gcpri_path + "o_a")
SET RELATION TO c_karty INTO karty
REPLACE ALL nazev WITH karty.nazev + " (" + ALLTRIM(STR(c_karty)) + ")", serial_no with lower(serial_no)
INDEX on c_dokl TAG c_dokl
SET RELATION TO c_dokl INTO dok

SELECT disti serial_no, nazev FROM obr INTO TABLE (m.gcpri_path + "nabidka")
DEFINE POPUP nabidka PROMPT FIELD serial_no + " | " + nazev FROM 1,22
ON SELECTION POPUP nabidka deacti popup
ACTIVATE SCREEN
ACTIVATE POPUP nabidka
DO WHILE !EMPTY(PROMPT())
    sn = LEFT(PROMPT(), 20)
    SELECT obr
    SET FILTER TO serial_no = m.sn
    BROWSE TITLE SPACE(33) + "Seriove cislo: " + m.sn ;
           FIELDS c_stredisk:6:H="Skl", operace:H="Oper", c_dokl:11, nazev:40:H="Nazev, c_karty", ;
           mnozstvi:P="9 999", zustatek:P="9 999", cena:P="999 999.9", dok.pz1, dok.pz2, dok.datum_dokl:H="Datum":11, kdy=TTOD(dok.kdy):11, dok.partner:33, archiv:H="A" ;
           NODELETE NOAPPEND NOEDIT 
    SELECT nabidka
    ACTIVATE SCREEN
    ACTIVATE POPUP nabidka
ENDDO
RELEASE POPUP nabidka

CLOSE DATABASES 