*
* Dogenerovani chybejicich zaznamu hkredobr. POZOR! Pouzivat jen na Citrixu nebo kdyz nebezi kasy!!!
*
PARAMETERS crd_path, sk_path, p_dnu
*
m.fn_hkobr = m.crd_path+"hkredobr"
m.sDatumOd = DTOS(DATE() - m.p_dnu)
m.uzavOd   = SUBSTR(DTOS(DATE() - m.p_dnu), 3) + " 01:00"
CLOSE ALL
clos data
CLEAR WINDOW
set Safety Off
*m.crlf=CHR(13)+CHR(10)
vysledek = CHR(13)+CHR(10)
*
sk_path = sk_path + IIF(RIGHT(m.sk_path,1)="\", "", "\")
crd_path = crd_path + IIF(RIGHT(m.crd_path,1)="\", "", "\")
*
SELECT 0
USE (m.crd_path+"hkredobr")
SET ORDER TO TAG u_cis
*
IF FILE(m.crd_path+"_tmhkobr.dbf")
  SELECT 0
  USE (m.crd_path + "_tmhkobr")
  DELETE FOR u_cis = "PRENOS"
  USE 
  SELECT hkredobr
  APPEND FROM (m.crd_path + "_tmhkobr")
  ERASE (m.crd_path + "_tmhkobr.dbf")
  ERASE (m.crd_path + "_tmhkobr.cdx")
ENDIF   
SELECT hkredobr
SET FILTER TO hkredobr.datum >= m.sDatumOd
m.lnckred = FSIZE("cis_kred","hkredobr")
SELECT 0
USE (m.sk_path+"sk_plt")
SET ORDER TO TAG u_cis
SET FILTER TO (uzaverka > m.uzavOd) AND;
 ((INLIST(druh_pl,"K_HOTEL", "K_HOTEL2", "K_CLUB", "K_HOT_SL", "N_VIP", "K_ZAVOD", "K_BUDVAR","K_EXTFIR","HotoDuch","HotoStre") OR AT("_KK", druh_pl) # 0))
SELECT 0
USE (m.sk_path+"sk_fin")
SET ORDER TO TAG u_cis
SET FILTER TO (uzaverka > m.uzavOd)
SELECT 0
USE (m.sk_path+"sk_txt")
SELECT txt, SPACE(m.lnckred) as cis_kred, DTOS(DATE()) as datum, LEFT(TIME(), 8) as cas, u_cis, 000000000.00 as castka, .t. as zapsano, "Dogenerovano" as poznamka;
 FROM (m.sk_path+"sk_txt") INTO TABLE (m.crd_path+"gentmhk");
 WHERE (uzaverka > m.uzavOd) AND !EMPTY(txt) AND (!EMPTY(akce) OR !EMPTY(dic))
REPLACE cis_kred WITH ALLTRIM(txt) FOR AT('/', txt) = 0
REPLACE cis_kred WITH LEFT(TXT, AT('/', txt)-1) FOR AT('/', txt) > 0
SET RELATION TO u_cis INTO sk_plt
DELETE FOR EMPTY(sk_plt.u_cis)		&& smazani nekreditovych zaznamu
PACK
REPLACE castka WITH sk_plt.cena_pl ALL 
SET RELATION TO 
SELECT gentmhk
SET RELATION TO u_cis INTO hkredobr
DELETE FOR !EMPTY(hkredobr.u_cis)		&& smazani jiz existujicich zaznamu
PACK
IF RECCOUNT() > 0
  m.vysledek = vysledek + "[2#R]POZOR! Dogenerovany chybejici zaznamy do HKREDOBR!"+CHR(13)+CHR(10)
  SET RELATION TO u_cis INTO sk_fin
  REPLACE FOR !EMPTY(sk_fin.u_cis) datum WITH LEFT(sk_fin.u_cas,8), cas WITH SUBSTR(sk_fin.u_cas,10)
  SELECT hkredobr
  APPEND FROM (m.crd_path+"gentmhk")
ELSE
  m.vysledek = vysledek + "[1#G]Kontrola zaznamu hkredobr OK"+CHR(13)+CHR(10)
ENDIF 
*
CLOSE DATABASES 
