insert_edihlav()
  
DO WHILE !FEOF(m.edisubor)
    lastline = "xx"
    txtriadok=FGETS(m.edisubor,8192)
    DO CASE 
    CASE EMPT(m.txtriadok)
        * nic

    CASE LEFT(m.txtriadok,3)="HDR"
        lastline="HDR"
        SELECT edihlav
*                                                                                                  100                                                                                                 200                                                                                                 300                                                                                                 400                         
*          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      
*123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
*HDR911009689      2019062520190625    20190625    KURIER                                         51888602         51888602         51888602         8588003882004    PALACE HOTEL PEZINOK, s.r.o. spilak manager +421904720022             51888602                 CORNER SK spol. s r.o.             31377971       SK2120845991   Okresn脙陆 s脙潞d Bratislava I, oddiel Sro, vlo脜戮ka 脛聧. 7477/B                
*HDR13200          20220518                                                        798            8706174          8593085022804                     12486329                          Provoz Pr╤onice                                                                                              Josef Ma躤k                        12486329       
*HDR37760          20230306                                                        2591           08706735         8593085029001                     41150601                          Provoz And瀕                                                                                                  Ji軺 籩kal                         41150601       
*HDR25717/23       20230515                                                                       29037077         HOTEL                             27205967                                                                                                                                        SANDERA s.r.o.                     27205967       


        REPLACE c_faktury WITH alsu(4,15),dat_vyst WITH DATE(valsu(19,4), valsu(23,2), valsu(25,2)), edi_stred WITH alsu(115,17)

        PRIVATE hladajico
        hladajico = alsu(149,14)
        DO CASE
        CASE hladajico = alsu(328,14)
            REPLACE partner WITH alsu(293,35), ico WITH m.hladajico

        CASE EMPTY(m.hladajico)
            REPLACE partner WITH alsu(293,35), ico WITH alsu(328,14)

        OTHERWISE 
            REPLACE ico WITH m.hladajico
            REPLACE ulica WITH alsu(293,35)      && zaznamenam, pokud se ve volnem poli vyskytuje nazev dodavatele
            SELECT 0
            IF m.issql
                USE (m.sqlprefix+"rpartnerico") ALIAS rpart
            ELSE
                IF !USED("partneri")
                    USE (m.fn_partneri) IN 0 ALIAS partneri
                ENDIF 
                USE vpartnerico ALIAS rpart IN 0
            ENDIF 
            IF RECCOUNT("rpart")>0
                SELECT rpart
                GO TOP 
                SELECT edihlav
                REPLACE partner WITH rpart.partner
            ELSE
                USE IN rpart
                IF m.issql
                    USE (m.sqlprefix+"rpartner_edikod") ALIAS rpart
                ELSE
                    USE vpartner_edikod ALIAS rpart IN 0
                ENDIF 
                IF RECCOUNT("rpart")>0
                    SELECT rpart
                    GO TOP 
                    SELECT edihlav
                    REPLACE partner WITH rpart.partner, ico  WITH rpart.ico
                ENDIF 
            ENDIF 
            DO pozavirej WITH "partneri, rpart"
        ENDCASE 
*        SELECT edihlav

    CASE LEFT(m.txtriadok,3)="LIN"
        INSERT INTO edipol (id_edi, c_data, riadok, ean, kod_zak, mnozstvo, cena, cena_celk, dan, nazov) VALUES ;
                (m.hladajidedi, m.cdata, 400+valsu(4,6), alsu(10,25), alsu(35,25), valsu(93,12), valsu(76,12), valsu(76,12) * valsu(93,12), valsu(88,5), alsu(177,45))

    CASE LEFT(m.txtriadok,3)="SUM"
        SELECT edihlav
        IF m.hotel_platca_dph
            REPLACE suma WITH valsu(40,12)
        ELSE 
            REPLACE suma WITH valsu(40,12) + valsu(74,12)
        ENDIF 
        txtriadok=FGETS(m.edisubor)

     OTHERWISE 
        IF lastline="HDR"
            SELECT edihlav
            REPLACE ico WITH alsu(328,14), partner WITH alsu(293,35)
        ENDIF 
    ENDCASE 
ENDDO
druhy_doklad_z_minusu_a_suma()
uloz_a_zavri("SYS E hotel_edikod")
