******************************************************************************
*
* Procedure file: HK_FIRMY2HOT_KRED
*
*   doplni vzorove stravniky pro nove pridane firmy ve faurecii
*   firmam se stringem "/EXE" v nazvu, coz jsou lidi v exekuci, se nastavi limit 0.0
*
******************************************************************************
param sk_path
sk_path = sk_path + IIF(RIGHT(m.sk_path,1)="\", "", "\")

vysledek = " . . v.2020-10-25: " + m.crlf
RAND(-1)

IF FILE(m.sk_path + "hk_firmy.dbf") .and. FILE(m.sk_path + "hot_kred.dbf")
   USE (m.sk_path + "hot_kred")
   SELECT 0
   USE (m.sk_path + "hk_firmy")
   SCAN 
      SCATTER FIELDS firma memv
      firma2 = STRTRAN(m.firma, " ", "")
      SELECT hot_kred
      LOCATE FOR firma = m.firma
      IF .not. FOUND()
          INSERT INTO hot_kred (datum         ,    cas             , cis_kred       ,   firma,   jmeno ,  typ,   exp_date  , limit, c_hlad, typ_slevy, krestjm, prijmeni, pltyp_slev, plc_hlad, chipcode       , autor) ;
                   values (ttoc(DATETIME(), 1), ttoc(DATETIME(), 2), generuj_cislo(), m.firma, m.firma2,  "1", "2055/12/12", -3333,  "1"  ,      2   , "VZOR" , m.firma ,     2,        "1"   , generuj_cislo(), "Ftp")
          vysledek = m.vysledek + m.firma2 + "  "
      ENDIF 
   ENDSCAN 

   SELECT hot_kred
   REPLACE FOR ATC("/EXE", firma) > 0 limit WITH 0
   vysledek = m.vysledek + " ... OK"
ENDIF 


******************************************************************************
PROCEDURE generuj_cislo
WAIT m.firma WINDOW TIMEOUT .22
RETURN "X" + ALLTRIM(STR(INT(RAND() * 99999999 + RAND()*999999 + RAND() * 9999 + RAND() * 99 + SECONDS() * 99), 12))
