    insert_edihlav()
    DO WHILE !FEOF(m.edisubor)
        txtriadok=FGETS(m.edisubor)
        DO CASE 
            CASE LEFT(m.txtriadok,3)="HDR"
                SELECT edihlav
                REPLACE c_faktury WITH alsu(4,15),dat_vyst WITH CTOD(SUBSTR(m.txtriadok,31,2)+"."+SUBSTR(m.txtriadok,29,2)+"."+SUBSTR(m.txtriadok,25,4))
                txtriadok=FGETS(m.edisubor)
                IF INLIST(alsu(324-254,15),"34152199","28234642")
                    typ_special="UTF8"
                ENDIF 
                REPLACE ico WITH alsu(324-254,15),;
                    dic WITH alsu(339-254,15), icdph WITH "", iban WITH alsu(442-254,34)
                IF LEN(m.txtriadok)=254
                    txtriadok=FGETS(m.edisubor)
                    REPLACE swift WITH alsu(546-254,10)
                ENDIF 
            CASE LEFT(m.txtriadok,3)="HDD"
                txtriadok1=FGETS(m.edisubor)
                IF INLIST(ALLTRIM(edihlav.ico),"34152199","28234642")
                    IF ALLTRIM(edihlav.ico)="34152199"
                        REPLACE partner WITH "Bidfood Slovakia s. r. o."    , ulica WITH "PieÃ¶ÄšanskÅ  2321/71" , mesto WITH "NovÅ¥ Mesto nad VÅ hom", psc WITH "91501", dic WITH "2020168359", icdph WITH "SK2020168359"
                    ELSE
                        REPLACE partner WITH "Bidfood Czech Republic s.r.o.", ulica WITH "V RÃ½Ä›ovÅ¥m Ä·dolÅª 553", mesto WITH "Kralupy nad Vltavou",  psc WITH "27801", dic WITH "", icdph WITH "CZ28234642"
                    ENDIF 
                ELSE 
                    IF LEN(m.txtriadok1)=254
                        **** V subore su povinne aj nepovinne polia
                        txtriadok=m.txtriadok1
                        SELECT edihlav
                        REPLACE partner WITH alsu(360-254,35)
                        txtriadok=FGETS(m.edisubor)
                        REPLACE ulica WITH alsu(535-508,35), ;
                            mesto WITH alsu(675-508,35), psc WITH alsu(710-508,6)
                    ELSE
                        **** V subore su len povinne polia a dufam, ze ako Bidfood pisu jedno povinne a jedno nepovinne pole z meno dodavatela a odberatela
                        SELECT edihlav
                        REPLACE partner WITH alsu(150,35)
                        REPLACE ulica WITH alsu(220,35),;
                            mesto WITH ALLTRIM(SUBSTR(m.txtriadok1,1,35)), psc WITH ALLTRIM(SUBSTR(m.txtriadok1,36,6))
                    ENDIF 
                    IF m.typ_special="UTF8"
                        REPLACE ulica WITH STRCONV(ulica,11), mesto WITH STRCONV(mesto,11), partner WITH STRCONV(partner,11)
                    ENDIF 
                ENDIF 
            CASE LEFT(m.txtriadok,3)="LIN"
                IF ALLTRIM(edihlav.ico)="28234642" OR ALLTRIM(edihlav.ico)="34152199"
                    *Bidvest
                    INSERT INTO edipol (id_edi, c_data, riadok, ean, kod_zak, mnozstvo, cena, cena_celk, dan) VALUES ;
                        (m.hladajidedi, m.cdata, VAL(SUBSTR(m.txtriadok,4,6)), alsu(10,25), alsu(35,25), VAL(STRTRAN(alsu(64,15),",",".")),;
                        VAL(STRTRAN(alsu(79,15),",",".")), VAL(STRTRAN(alsu(64,15),",","."))*VAL(STRTRAN(alsu(79,15),",",".")),;
                        VAL(STRTRAN(alsu(146,6),",",".")))
*!*    LIN     0                         139005                   Z             7.500          4.9907  0.000          0.00          4.9907         37.43  20.00kg           1.000                                                                         20170526                       515305879                             20170526IV 117086387      20170526                                FILâ€¦ PORCIE 150 G VB NW 1*7,5 KG             
*!*    HDR302894550      20180808            20180809                     884962305                     8594031170006    8594031177548    8594031170006    8594003840005    
*!*    LIN0000102009980001791            P230104                  Z                                      10.000PA                                        884962305                     RAJEC nesycenÅ  1,5 L * 6 PET                 

*!*    HDR11805780       3809  20180919201809202018091920180920                2018100442                                                              11805780                                                                         31638759       2020457230                                                        8588003663009    00685232       2020441060                                 3035620200000811805780            EURSK2020441060   SK2020457230   SK5902000000000000303562          SUBASKBX  Hotel PATRIA                                                          Hotel PATRIA                              
*!*    HDR1730491        2017040620170406    20170406                                                                                                      8586000730007                     VzdelÅ vacie a doÃ¶koÄºovacie zariadenie                                 VzdelÅ vacie a doÃ¶koÄºovacie zariadenie                                 VzdelÅ vacie a doÃ¶koÄºovacie zariadenie                                 MINERÅƒLNE VODY a.s.                                                                                                                                                                                               SlovenskÅ  9                                                           PreÃ¶ov                             081 8631711464       2020520436     ZapÅªsanÅ¼ v OR OS PreÃ¶ov,oddiel Sa,vloÄ›ka Å¤. 223 P                                                                                                   
*!*    HDRV-18000038     2018010320180103    20180103                                                   397                                                1234567890123                     FOD,(),Odberatel:COLOSEUM KORUNA s.r.o.,Dodavatel:PRAGOGASTRO s.r.o., 
*!*    123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
*!*             1         2         3         4         5         6         7         8         9         0         1         2         3         4         5         6         7         8         9         0         1         2         3         4         5         6         7         8         9         0         1         2         3         4         5         6         7         8         9         0         1         2         3         4         5         6         7         8         9         0
*!*                                                                                                    1                                                                                                   2                                                                                                   3                                                                                                   4                                                                                                 
                ELSE 
                    INSERT INTO edipol (id_edi, c_data, riadok, ean, kod_zak, mnozstvo, cena, cena_celk, dan) VALUES ;
                        (m.hladajidedi, m.cdata, VAL(SUBSTR(m.txtriadok,4,6)),alsu(10,25),alsu(35,25), valsu(63,12),;
                        valsu(106,12), valsu(118,12), valsu(130,5))
                ENDIF 
                txtriadok=FGETS(m.edisubor)
                SELECT edipol
                REPLACE nazov WITH alsu(358-254,70)
                IF LEN(ALLTRIM(ean))=1
                    REPLACE ean WITH ""
                ENDIF 
                IF m.typ_special="UTF8"
                    REPLACE nazov WITH STRCONV(nazov,11)
                ENDIF 
            CASE LEFT(m.txtriadok,3)="SUM"
                SELECT edihlav
                IF ALLTRIM(edihlav.ico)="28234642"            &&        Bidvest
                    IF m.hotel_platca_dph
                        REPLACE suma WITH valsu(19,12)
                    ELSE 
                        REPLACE suma WITH valsu(19,12) + valsu(75,12)
                    ENDIF 
                ELSE 
                    IF m.hotel_platca_dph
                        REPLACE suma WITH valsu(40,12)
                    ELSE 
                        REPLACE suma WITH valsu(40,12) + valsu(86,12)
                    ENDIF 
                ENDIF 
        ENDCASE 
    ENDDO
    SELECT edipol
    IF !m.hotel_platca_dph
        REPLACE ALL cena WITH cena*(dan/100+1), cena_celk WITH cena_celk*(dan/100+1)
        REPLACE ALL dan WITH 0
    ENDIF 
    druhy_doklad_z_minusu()
    uloz_a_zavri("SYS INVOIC")
