*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    
*    v d_televize prekopiruje karty.cena20 do obratu
*
*  vsechny ceny20 zazalohuje do cena21
*  najde receptury podle toho, ze maji polozky, oznaci si je v karty.bar_kod1 textem "RECEPTURA"
*  v obratech prepise cenu z karty.cena20 pro PR, PE, PV
*  v obratech prepise cenu_part z karty.cena20 pro VE
*  
*  po probehnuti je potreba pustit vypocet porizovacich cen a cast2
*
*   2022-02-06 
*    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    *    

IF ATC("d_televize", m.gchom_path) = 0
    WAIT "na tehle datech se to nepousti, holenku" WINDOW TIMEOUT 3
    RETURN 
ENDIF
CLOSE DATABASES 
CLOSE DATABASES 
ACTIVATE SCREEN 

SELE 0
USE         (m.gccen_path + "polozky") ALIAS polozky NOUPDATE
SELECT disti c_karty as c_karty FROM polozky INTO CURSOR receptury READWRITE 
INDEX on c_karty TAG c_karty
USE IN polozky

SELE 0
USE         (m.gccen_path + "karty")   ALIAS karty   ORDER c_karty
COPY all to (m.gccen_path + JUSTSTEM(DBF()) + STRTRAN(TTOC(DATETIME(), 3), ":", "-"))

SET RELATION TO c_karty INTO receptury
REPLACE ALL bar_kod1 WITH IIF(EMPTY(receptury.c_karty), "", "RECEPTURA"), cena21 WITH cena20


SELE 0
USE         (m.gccen_path + "obraty")   ALIAS obraty
COPY all to (m.gccen_path + JUSTSTEM(DBF()) + STRTRAN(TTOC(DATETIME(), 3), ":", "-"))

SET RELATION TO c_karty INTO karty

REPLACE FOR INLIST(operace, "PE", "PR", "PV") .and. .not. EMPTY(karty.cena20) .and. ATC("RECEPT", karty.bar_kod1) > 0 cena      WITH karty.cena20
REPLACE FOR INLIST(operace, "VE", "xx", "xx") .and. .not. EMPTY(karty.cena20)                                         cena_part WITH karty.cena20

WAIT CLEAR
