PARAMETERS hladajcdokl, typ_obj, oprava
PRIVATE m.edicesta, otvorenyfooddat, m.hladajidediprev, m.typ_obj, m.cdata, m.hladajpz2, m.partnerico, m.poslipotvrdenie, m.partnerovekody
LOCAL m.hhotel_naz1, m.x_partner, m.x_stredisk, m.menostrediska, m.hhotel_ulica, m.hhotel_psc, m.hhotel_mesto, m.hhotel_telefon, m.hhotel_osoba, m.hhotel_mail, m.hhotel_gln
LOCAL m.menopartnera, m.mailovaadresa, m.pokecdodavatela, m.partneredikod, m.ii, m.partneredikoddodania, m.cislo_objednavky
#DEFINE CRLF CHR(13)+CHR(10)
m.otvorenydokl=.t.
m.otvorenyobr=.t.
m.otvorenyfooddat=.t.
IF EMPTY(m.gcedicesta)
	=MESSAGEBOX(jaz("form_nenastavena_cesta_edi"),16,"FoodMan")
	RETURN .f.
ELSE
	IF DIRECTORY(m.gcedicesta)
		IF "\in\"$LOWER(m.gcedicesta)
			m.edicesta=STRTRAN(LOWER(m.gcedicesta),"\in\","\out\")
		ELSE 
			m.edicesta=m.gcedicesta+IIF(RIGHT(ALLTRIM(m.gcedicesta),1)="\","","\")+"vydajky\"
		ENDIF 
		=mk_dir(m.edicesta)
		IF !DIRECTORY(m.edicesta)
			=MESSAGEBOX(jaz("form_chyba_priecinok_obj")+CHR(10)+m.edicesta,16,"FoodMan")
			RETURN .f.
		ENDIF 
	ENDIF 
ENDIF 
IF USED("dokladxx")
	USE IN dokladxx
ENDIF  
IF m.issql
	USE (m.sqlprefix+"rprnobra") IN 0 ALIAS dokladxx
ELSE
	USE vprnobra IN 0 ALIAS dokladxx
ENDIF 
IF !USED("food_edi") 
	IF m.issql
		USE (m.sqlprefix+"rfooddat_idediprev") IN 0 ALIAS food_edi
	ELSE
		USE (m.fn_food_dat) IN 0 ALIAS food_edi AGAIN 
	ENDIF 
	m.otvorenyfooddat=.f.
ENDIF 
SELECT dokladxx
GO TOP 
m.x_partner=dokladxx.c_partner
m.x_stredisk=dokladxx.c_stredisk
m.cislo_objednavky=""
IF INLIST(dokladxx.operace,"VR","VE") AND !EMPTY(dokladxx.pz1)
	m.hladajpz2=STR(dokladxx.c_dokl,15,0)
	SELECT 0
	IF m.issql
		USE (m.sqlprefix+"rdokladyziadankakvydajke") ALIAS zz1
	ELSE 
		USE vdokladyziadankakvydajke ALIAS zz1
	ENDIF 
	IF RECCOUNT("zz1")>0
		GO TOP 
		SCAN ALL 
			IF EMPTY(m.cislo_objednavky)
				m.cislo_objednavky=m.cislo_objednavky+ALLTRIM(zz1.pz1)
			ELSE 
				m.cislo_objednavky=m.cislo_objednavky+","+ALLTRIM(zz1.pz1)
			ENDIF 
		ENDSCAN 
	ENDIF 
	IF EMPTY(m.cislo_objednavky)
		m.cislo_objednavky=ALLTRIM(dokladxx.pz1)
	ENDIF 
	DO pozavirej WITH "zz1"
ENDIF 
SELECT food_edi
LOCATE FOR c_stredisk=m.x_stredisk
IF FOUND()
	m.menostrediska=food_edi.id_zkratka
	m.hladajidediprev=food_edi.id_ediprev
	m.cdata=food_edi.c_data
ELSE
	m.menostrediska=m.gcid_zkratka 
	m.hladajidediprev=0
	m.cdata=1
ENDIF 
IF m.issql
	rv("extpartneri_obj","part_ze")
ELSE
	USE vextpartneri_obj IN 0 ALIAS part_ze
ENDIF 
m.hhotel_naz1=m.hotel_naz1
m.hhotel_ulica=m.hotel_naz2
m.hhotel_psc=m.hotel_naz4
m.hhotel_mesto=m.hotel_naz3
m.hhotel_osoba=""
m.hhotel_telefon=""
m.hhotel_mail=""
m.hhotel_ico=m.hotel_ico
m.hhotel_icdph=m.hot_icdph
m.hhotel_gln=IIF(EMPTY(m.hotel_edikod), ALLTRIM(m.hotel_ico), ALLTRIM(m.hotel_edikod))
IF ATC("sushitime", m.wi_zakaz) > 0
	hladajcpartner=dokladxx.c_partner
	IF m.issql
		USE (m.sqlprefix+"rediprevpartnera") IN 0 ALIAS dodpartner
	ELSE
		USE vediprevpartnera IN 0 ALIAS dodpartner
	ENDIF 
	IF RECCOUNT("dodpartner")>0
		SELECT dodpartner
		GO TOP 
		m.hhotel_naz1=ALLTRIM(dodpartner.meno)
		m.hhotel_ulica=ALLTRIM(dodpartner.ulica)
		m.hhotel_psc=ALLTRIM(dodpartner.psc)
		m.hhotel_mesto=ALLTRIM(dodpartner.mesto)
		m.hhotel_osoba=ALLTRIM(dodpartner.osoba)
		m.hhotel_ico=ALLTRIM(dodpartner.ico)
		m.hhotel_icdph=ALLTRIM(dodpartner.ic_dph)
		IF !EMPTY(dodpartner.gln)
			m.hhotel_gln=ALLTRIM(dodpartner.gln)
		ENDIF 
		m.hhotel_telefon=ALLTRIM(dodpartner.telefon)
		m.hhotel_mail=ALLTRIM(dodpartner.mail)
	ENDIF 
	USE IN dodpartner		
ELSE 
	IF !EMPTY(m.hladajidediprev)
		SELECT 0
		USE (m.sqlprefix+"redi_prev") ALIAS edi_prev
		LOCATE FOR idriadok=m.hladajidediprev
		IF FOUND()
			m.hhotel_naz1=ALLTRIM(edi_prev.meno)
			m.hhotel_ulica=ALLTRIM(edi_prev.ulica)
			m.hhotel_psc=ALLTRIM(edi_prev.psc)
			m.hhotel_mesto=ALLTRIM(edi_prev.mesto)
			m.hhotel_osoba=ALLTRIM(edi_prev.osoba)
			m.hhotel_telefon=ALLTRIM(edi_prev.telefon)
			m.hhotel_mail=ALLTRIM(edi_prev.mail)
			m.hhotel_ico=ALLTRIM(edi_prev.ico)
			m.hhotel_icdph=ALLTRIM(edi_prev.icdph)
		ENDIF 
		USE IN edi_prev
	ENDIF 
ENDIF 
FOR m.ii=1 TO 20
	IF zoznamedikodov(m.ii,1)=m.hhotel_gln AND !EMPTY(zoznamedikodov(m.ii,2))
		IF DIRECTORY(zoznamedikodov(m.ii,2))
			IF "\in\"$LOWER(zoznamedikodov(m.ii,2))
				m.edicesta=STRTRAN(LOWER(zoznamedikodov(m.ii,2)),"\in\","\out\")
			ELSE 
				m.edicesta=zoznamedikodov(m.ii,2)+IIF(RIGHT(ALLTRIM(zoznamedikodov(m.ii,2)),1)="\","","\")+"vydajky\"
			ENDIF 
			=mk_dir(m.edicesta)
			IF !DIRECTORY(m.edicesta)
				=MESSAGEBOX(jaz("form_chyba_priecinok_obj")+CHR(10)+m.edicesta,16,"FoodMan")
				RETURN .f.
			ENDIF 
		ENDIF 
		EXIT  
	ENDIF 
ENDFOR 
		
m.menopartnera=dokladxx.partner
SELECT part_ze
LOCATE FOR c_partner=m.x_partner
IF FOUND()
	m.typ_obj=part_ze.typ_obj
	m.mailovaadresa=ALLTRIM(part_ze.email)
	m.partneredikod=IIF(EMPTY(part_ze.edi_kod), ALLTRIM(part_ze.ico), ALLTRIM(part_ze.edi_kod))
	m.partneredikoddodania=IIF(EMPTY(part_ze.edi_dodanie), m.partneredikod, ALLTRIM(part_ze.edi_dodanie))
	m.pokecdodavatela=part_ze.popis
	m.mutacia=ALLTRIM(part_ze.mutacia)
	m.partnerico=ALLTRIM(part_ze.ico)
	m.poslipotvrdenie="ordrsp"$LOWER(part_ze.funkcie)
	m.partnerovekody=part_ze.edi_mankod
ELSE
	m.typ_obj=0
	m.mailovaadresa=""
	m.partneredikod=""
	m.partneredikoddodania=""
	m.pokecdodavatela=""
	m.mutacia="1"
	m.partnerico=""
	m.poslipotvrdenie=.f.
	m.partnerovekody=.f.
ENDIF 
IF EMPTY(m.mutacia)
	m.mutacia="1"
ENDIF 
**** Nasleduje vytvorenie edi objednavky ***
DO CASE 
	CASE INLIST(m.typ_obj,1,4,5)
		m.menosuboru=m.edicesta+"DESADV_"+m.partneredikod+"_"+ALLTRIM(STR(m.hladajcdokl,10,0))+"_"+ALLTRIM(STR(dokladxx.doklad,10,0))+"_"+STRTRAN(STRTRAN(STRTRAN(TTOC(DATETIME())," ",""),".",""),":","")+"_"+SYS(2015)+".txt"
		m.menoriadok="SYS"+PADR(ALLTRIM(m.partneredikod),14)+"E"+"D  96A"+"DESADV"+"P"+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
	       DO zapis_radek_hlavicky96
		SELECT dokladxx
		m.poradie=0
		SCAN ALL 
			m.poradie=m.poradie+1
			DO zapis_radek_telicka96
		ENDSCAN
		=MESSAGEBOX(jaz("form_vytvoreny_subor")+":"+CHR(10)+m.menosuboru,64,"FoodMan",2000)
		IF FILE(m.menosuboru) AND (!EMPTY(man_email_from) OR !EMPTY(food_email_from)) AND !EMPTY(m.mailovaadresa)
			DO poslimailhocikam WITH "Dodaci list c:"+ALLTRIM(STR(dokladxx.c_dokl,10,0))+" "+m.hotel_name, "", m.menosuboru,"","",m.mailovaadresa
			IF !EMPTY(m.hhotel_mail)
				DO poslimailhocikam WITH "Dodaci list c:"+ALLTRIM(STR(dokladxx.c_dokl,10,0))+" "+m.hotel_name, "", m.menosuboru,"","",m.hhotel_mail
			ENDIF 				
		ENDIF 
	CASE INLIST(m.typ_obj,6)
		m.menosuboru=m.edicesta+"DESADV_"+m.partneredikod+"_"+ALLTRIM(STR(m.hladajcdokl,10,0))+"_"+ALLTRIM(STR(dokladxx.doklad,10,0))+"_"+STRTRAN(STRTRAN(STRTRAN(TTOC(DATETIME())," ",""),".",""),":","")+"_"+SYS(2015)+".xml"
		m.menoriadok='<?xml version="1.0" encoding="UTF-8"?>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='<orion_message>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='	<header>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		<message_type>DESADV</message_type>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		<version>3.0.0</version>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		<message_id></message_id>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		<creation_date>'+LEFT(DTOS(DATE()),4)+'-'+SUBSTR(DTOS(DATE()),5,2)+'-'+SUBSTR(DTOS(DATE()),7,2)+'-'+'</creation_date>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		<creation_time>'+LEFT(TIME(),5)+'</creation_time>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		<receiver>'+m.partneredikod+'</receiver>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		<sender>'+m.hhotel_gln+'</sender>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		<test_flag/>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='	</header>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='	<body>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		<message_header>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<doc_number>'+ALLTRIM(dokladxx.pz2)+'</doc_number>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<doc_type>351</doc_type>'+CHR(13)+CHR(10) && 351 / dodaci list
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<doc_function>'+IIF(EMPTY(m.oprava),'9','5')+'</doc_function>'+CHR(13)+CHR(10) && 9 - Originál; 1 - Zrušení; 5 - Náhrada; 7 - Duplikát; 31 - Kopie; 43 - Dodatečný přenos
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<doc_date_of_issue>'+LEFT(DTOS(dokladxx.datum_dokl),4)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),5,2)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),7,2)+'</doc_date_of_issue>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<doc_time_of_issue>'+LEFT(TIME(),5)+'</doc_time_of_issue>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<delivery_date>'+LEFT(DTOS(dokladxx.datum_dokl),4)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),5,2)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),7,2)+'</delivery_date>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<delivery_time>'+LEFT(TIME(),5)+'</delivery_time>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<collection_date>'+LEFT(DTOS(dokladxx.datum_dokl),4)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),5,2)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),7,2)+'</collection_date>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<collection_time>'+LEFT(TIME(),5)+'</collection_time>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<delivery_date_latest>'+LEFT(DTOS(dokladxx.datum_dokl),4)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),5,2)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),7,2)+'</delivery_date_latest>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<delivery_time_latest>'+LEFT(TIME(),5)+'</delivery_time_latest>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<delivery_date_earliest>'+LEFT(DTOS(dokladxx.datum_dokl),4)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),5,2)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),7,2)+'</delivery_date_earliest>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<delivery_time_earliest>'+LEFT(TIME(),5)+'</delivery_time_earliest>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<departure_date>'+LEFT(DTOS(dokladxx.datum_dokl),4)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),5,2)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),7,2)+'</departure_date>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<departure_time>'+LEFT(TIME(),5)+'</departure_time>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<country_of_origin>'+STRTRAN(m.hotel_krajina,"SVK","SK")+'</country_of_origin>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<transport_mode>30</transport_mode>'+CHR(13)+CHR(10) &&10 - Námořní doprava; 20 - Železniční; 30 - Silniční; 40 - Letecká; 60 - Kombinovaná doprava
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<transport></transport>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<vehicle_id></vehicle_id>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<free_text></free_text>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<registration></registration>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<contract_number/>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<order_number>'+m.cislo_objednavky+'</order_number>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<order_number_date></order_number_date>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<order_number_time></order_number_time>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<supplier_order_number>'+m.cislo_objednavky+'</supplier_order_number>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<supplier_order_date></supplier_order_date>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<supplier_order_time></supplier_order_time>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<despatch_advice_number></despatch_advice_number>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<despatch_advice_date></despatch_advice_date>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<despatch_advice_time></despatch_advice_time>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<promotion_number/>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_qualifier>BY</party_qualifier>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_ean>'+m.partneredikod+'</party_ean>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_description/>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_name>'+STRTRAN(m.menopartnera,"&","&amp;")+'</party_name>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<street>'+STRTRAN(ALLTRIM(dokladxx.naz1),"&","&amp;")+'</street>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<place>'+STRTRAN(ALLTRIM(dokladxx.naz2),"&","&amp;")+'</place>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<postcode>'+STRTRAN(ALLTRIM(dokladxx.naz3),"&","&amp;")+'</postcode>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<country_code></country_code>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<country_name></country_name>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<company_id>'+ALLTRIM(dokladxx.ico)+'</company_id>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<tax_id>'+ALLTRIM(dokladxx.icdph)+'</tax_id>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<vat_id>'+ALLTRIM(dokladxx.dic)+'</vat_id>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<contact_type></contact_type>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<contact_name></contact_name>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<contact_tel></contact_tel>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<contact_fax></contact_fax>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<contact_email></contact_email>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			</party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_qualifier>OB</party_qualifier>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_ean>'+m.partneredikod+'</party_ean>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			</party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_qualifier>DP</party_qualifier>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_ean>'+m.partneredikoddodania+'</party_ean>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			</party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_qualifier>IV</party_qualifier>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_ean>'+m.partneredikod+'</party_ean>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			</party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_qualifier>SN</party_qualifier>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_ean>'+m.partneredikod+'</party_ean>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			</party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_qualifier>UC</party_qualifier>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_ean>'+m.partneredikod+'</party_ean>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			</party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_qualifier>SU</party_qualifier>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_ean>'+m.hhotel_gln+'</party_ean>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_name>'+ALLTRIM(m.hhotel_naz1)+'</party_name>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<street>'+ALLTRIM(m.hhotel_ulica)+'</street>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<place>'+ALLTRIM(m.hhotel_mesto)+'</place>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<postcode>'+ALLTRIM(m.hhotel_psc)+'</postcode>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<country_code>'+STRTRAN(m.hotel_krajina,"SVK","SK")+'</country_code>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<country_name></country_name>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<company_id>'+ALLTRIM(m.hhotel_ico)+'</company_id>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<tax_id>'+ALLTRIM(m.hhotel_icdph)+'</tax_id>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<contact_type></contact_type>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<contact_name>'+ALLTRIM(m.hhotel_osoba)+'</contact_name>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<contact_tel>'+ALLTRIM(m.hhotel_telefon)+'</contact_tel>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<contact_fax></contact_fax>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<contact_email>'+m.hhotel_mail+'</contact_email>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			</party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_qualifier>SF</party_qualifier>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_ean>'+IIF(EMPTY(m.hotel_edikod), ALLTRIM(m.hotel_ico), ALLTRIM(m.hotel_edikod))+'</party_ean>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			</party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_qualifier>SE</party_qualifier>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='				<party_ean>'+IIF(EMPTY(m.hotel_edikod), ALLTRIM(m.hotel_ico), ALLTRIM(m.hotel_edikod))+'</party_ean>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			</party>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		</message_header>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		<line_items>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.poradie=0
		SELECT dokladxx
		SCAN ALL 
			m.poradie=m.poradie+1
			DO zapis_radek_telicka_orion
		ENDSCAN
		m.menoriadok='		</line_items>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		<summary>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='			<number_of_items>'+ALLTRIM(STR(m.poradie,4,0))+'</number_of_items>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='		</summary>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='	</body>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)
		m.menoriadok='</orion_message>'+CHR(13)+CHR(10)
		=STRTOFILE(m.menoriadok,m.menosuboru,1)


		=MESSAGEBOX(jaz("form_vytvoreny_subor")+":"+CHR(10)+m.menosuboru,64,"FoodMan",2000)
		IF FILE(m.menosuboru) AND (!EMPTY(man_email_from) OR !EMPTY(food_email_from)) AND !EMPTY(m.mailovaadresa)
			DO poslimailhocikam WITH "Dodaci list c:"+ALLTRIM(STR(dokladxx.c_dokl,10,0))+" "+m.hotel_name, "", m.menosuboru,"","",m.mailovaadresa
			IF !EMPTY(m.hhotel_mail)
				DO poslimailhocikam WITH "Dodaci list c:"+ALLTRIM(STR(dokladxx.c_dokl,10,0))+" "+m.hotel_name, "", m.menosuboru,"","",m.hhotel_mail
			ENDIF 				
		ENDIF 
		IF m.poslipotvrdenie
			SELECT dokladxx
			GO TOP 
			m.menosuboru=m.edicesta+"ORDRSP_"+m.partneredikod+"_"+ALLTRIM(STR(m.hladajcdokl,10,0))+"_"+ALLTRIM(STR(dokladxx.doklad,10,0))+"_"+STRTRAN(STRTRAN(STRTRAN(TTOC(DATETIME())," ",""),".",""),":","")+"_"+SYS(2015)+".xml"
			m.menoriadok='<?xml version="1.0" encoding="UTF-8"?>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='<orion_message>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='	<header>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		<message_type>ORDRSP</message_type>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		<version>3.0.0</version>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		<message_id></message_id>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		<creation_date>'+LEFT(DTOS(DATE()),4)+'-'+SUBSTR(DTOS(DATE()),5,2)+'-'+SUBSTR(DTOS(DATE()),7,2)+'-'+'</creation_date>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		<creation_time>'+LEFT(TIME(),5)+'</creation_time>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		<receiver>'+m.partneredikod+'</receiver>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		<sender>'+m.hhotel_gln+'</sender>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		<test_flag/>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='	</header>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='	<body>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		<message_header>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<doc_number>'+ALLTRIM(dokladxx.pz2)+'</doc_number>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<doc_type>231</doc_type>'+CHR(13)+CHR(10) && 351 / dodaci list
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<doc_function>'+IIF(EMPTY(m.oprava),'29','4')+'</doc_function>'+CHR(13)+CHR(10) && 4 = změna, 27 = neakceptováno, 29 = akceptováno bez výhrad
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<doc_date_of_issue>'+LEFT(DTOS(dokladxx.datum_dokl),4)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),5,2)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),7,2)+'</doc_date_of_issue>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<doc_time_of_issue>'+LEFT(TIME(),5)+'</doc_time_of_issue>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<delivery_type>2</delivery_type>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<delivery_date>'+LEFT(DTOS(dokladxx.datum_dokl),4)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),5,2)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),7,2)+'</delivery_date>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<delivery_time>'+LEFT(TIME(),5)+'</delivery_time>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<order_number>'+m.cislo_objednavky+'</order_number>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<order_number_date></order_number_date>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<order_number_time></order_number_time>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<contract_number></contract_number>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<proposal_number></proposal_number>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<promotion_number></promotion_number>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_qualifier>BY</party_qualifier>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_ean>'+m.partneredikod+'</party_ean>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_description/>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_name>'+STRTRAN(m.menopartnera,"&","&amp;")+'</party_name>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<street>'+STRTRAN(ALLTRIM(dokladxx.naz1),"&","&amp;")+'</street>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<place>'+STRTRAN(ALLTRIM(dokladxx.naz2),"&","&amp;")+'</place>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<postcode>'+STRTRAN(ALLTRIM(dokladxx.naz3),"&","&amp;")+'</postcode>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<country_code></country_code>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<country_name></country_name>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<company_id>'+ALLTRIM(dokladxx.ico)+'</company_id>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<tax_id>'+ALLTRIM(dokladxx.icdph)+'</tax_id>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<vat_id/>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<contact_type></contact_type>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<contact_name></contact_name>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<contact_tel></contact_tel>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<contact_fax></contact_fax>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<contact_email></contact_email>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			</party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_qualifier>OB</party_qualifier>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_ean>'+m.partneredikod+'</party_ean>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			</party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_qualifier>DP</party_qualifier>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_ean>'+m.partneredikoddodania+'</party_ean>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			</party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_qualifier>IV</party_qualifier>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_ean>'+m.partneredikod+'</party_ean>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			</party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_qualifier>SN</party_qualifier>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_ean>'+m.partneredikod+'</party_ean>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			</party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_qualifier>UC</party_qualifier>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_ean>'+m.partneredikod+'</party_ean>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			</party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_qualifier>SU</party_qualifier>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_ean>'+m.hhotel_gln+'</party_ean>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_name>'+ALLTRIM(m.hhotel_naz1)+'</party_name>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<street>'+ALLTRIM(m.hhotel_ulica)+'</street>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<place>'+ALLTRIM(m.hhotel_mesto)+'</place>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<postcode>'+ALLTRIM(m.hhotel_psc)+'</postcode>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<country_code>'+STRTRAN(m.hotel_krajina,"SVK","SK")+'</country_code>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<country_name></country_name>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<company_id>'+ALLTRIM(m.hhotel_ico)+'</company_id>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<tax_id>'+ALLTRIM(m.hhotel_icdph)+'</tax_id>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<contact_type></contact_type>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<contact_name>'+ALLTRIM(m.hhotel_osoba)+'</contact_name>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<contact_tel>'+ALLTRIM(m.hhotel_telefon)+'</contact_tel>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<contact_fax></contact_fax>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<contact_email>'+m.hhotel_mail+'</contact_email>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			</party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_qualifier>SF</party_qualifier>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_ean>'+IIF(EMPTY(m.hotel_edikod), ALLTRIM(m.hotel_ico), ALLTRIM(m.hotel_edikod))+'</party_ean>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			</party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_qualifier>SE</party_qualifier>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<party_ean>'+IIF(EMPTY(m.hotel_edikod), ALLTRIM(m.hotel_ico), ALLTRIM(m.hotel_edikod))+'</party_ean>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			</party>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		</message_header>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		<line_items>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<item>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<package_number>1</package_number>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<package_reference>1E</package_reference>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<sscc></sscc>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='				<articles>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.poradie=0
			SELECT dokladxx
			SCAN ALL 
				m.poradie=m.poradie+1
				DO zapis_radek_telicka_orion_ordrsp
			ENDSCAN
			m.menoriadok='				</articles>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			</item>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		</line_items>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		<summary>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='			<number_of_items>'+ALLTRIM(STR(m.poradie,4,0))+'</number_of_items>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='		</summary>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='	</body>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)
			m.menoriadok='</orion_message>'+CHR(13)+CHR(10)
			=STRTOFILE(m.menoriadok,m.menosuboru,1)


			=MESSAGEBOX(jaz("form_vytvoreny_subor")+":"+CHR(10)+m.menosuboru,64,"FoodMan",2000)
			IF FILE(m.menosuboru) AND (!EMPTY(man_email_from) OR !EMPTY(food_email_from)) AND !EMPTY(m.mailovaadresa)
				DO poslimailhocikam WITH "Dodaci list c:"+ALLTRIM(STR(dokladxx.c_dokl,10,0))+" "+m.hotel_name, "", m.menosuboru,"","",m.mailovaadresa
				IF !EMPTY(m.hhotel_mail)
					DO poslimailhocikam WITH "Dodaci list c:"+ALLTRIM(STR(dokladxx.c_dokl,10,0))+" "+m.hotel_name, "", m.menosuboru,"","",m.hhotel_mail
				ENDIF 				
			ENDIF 

		ENDIF 
ENDCASE 
IF !m.otvorenyfooddat
	DO pozavirej WITH "food_edi"
ENDIF 
DO pozavirej WITH "part_ze, dodean, dokladxx"

PROCEDURE  zapis_radek_hlavicky96
menoriadok = "HDR"                                            &&  1 C3  P
menoriadok = m.menoriadok + PADR(nx(dokladxx.c_dokl)         , 15)  &&  2 C15 P cislo dodaciho listu
menoriadok = m.menoriadok + PADR(DTOS(dokladxx.datum_dokl)   ,  8)  &&  3 C8  P datum vystaveni
menoriadok = m.menoriadok + SPACE(                             8)  &&  4 C8  N datum odjezdu dodavky  - nic 
menoriadok = m.menoriadok + SPACE(                             4)  &&  5 C4  N cas odjezdu dodavky  - nic
menoriadok = m.menoriadok + SPACE(                             8)  &&  6 C8  P datum ocekavane dodavky - nic
menoriadok = m.menoriadok + SPACE(                             4)  &&  7 C4  N cas ocekavanedodavky - nic
menoriadok = m.menoriadok + SPACE(                            17)  &&  8 C17 N doprava - nic
menoriadok = m.menoriadok + SPACE(                            15)  &&  9 C15 P cislo objednavky zakaznika  - nic
menoriadok = m.menoriadok + PADR(nx(dokladxx.doklad)         , 15)  && 10 C15 N cislo faktury

menoriadok = m.menoriadok + PADR(m.partneredikod            , 17)  && 11 C17 P ean kupujiciho - ICO
menoriadok = m.menoriadok + PADR(m.partneredikod            , 17)  && 12 C17 P ean provozovny - partneri.edikod nebo pokud je prazdny, tak partneri.ico
menoriadok = m.menoriadok + SPACE(                            17)  && 13 C17 N ean fakturacniho mista - nic
menoriadok = m.menoriadok + PADR(m.hhotel_gln				, 17)  && 14 C17 P ean dodavatele - ICO
menoriadok = m.menoriadok + SPACE(                            17)  && 15 C17 N ean distribuc.skladu dodavatele - nic
menoriadok = m.menoriadok + PADR(m.menopartnera             , 70)  && 16 C70 N nazev kupujiciho
menoriadok = m.menoriadok + SPACE(                            17)  && 17 C17 N ean objednatele - nic 
menoriadok = m.menoriadok + SPACE(                            15)  && 18 C15 N int. cislo dodavatele - nic
menoriadok = m.menoriadok + SPACE(                             8)  && 19 C8  N datum vystaveni objednavky - nic
menoriadok = m.menoriadok + PADR(m.hotel_name               , 35)  && 20 C35 N obch jmeno dodavatele
menoriadok = m.menoriadok + PADR(m.hotel_ico                , 15)  && 21 C15 N ICO dodavatele 
STRTOFILE(m.menoriadok + CRLF, m.menosuboru, 1)


*    *    *    *    *    *    *    *    *    *    *    *    *    *
PROCEDURE  zapis_radek_telicka96
PRIVATE m.serial_no, m.hladajckarty
LOCAL dlzkaica
m.hladajckarty=dokladxx.c_karty
IF USED("dodean")
	=REQUERY("dodean")
ELSE
	IF m.issql
		USE (m.sqlprefix+"reanykukarte") ALIAS dodean IN 0
	ELSE 
		USE veanykukarte ALIAS dodean IN 0
	ENDIF 
ENDIF 
SELECT dodean
IF RECCOUNT()>0
	m.dlzkaica=LEN(ALLTRIM(m.partnerico))
	IF m.dlzkaica>0
		LOCATE FOR LEFT(dodean.ean,m.dlzkaica+2)=ALLTRIM(m.partnerico)+"::"
		IF FOUND()
			m.serial_no=ALLTRIM(SUBSTR(dodean.ean,m.dlzkaica+3))
		ELSE
			IF EMPTY(dokladxx.serial_no)
				GO TOP 
				LOCATE FOR !("::"$dodean.ean)
				IF FOUND()
					m.serial_no=ALLTRIM(dodean.ean)
				ELSE
					GO TOP 
					m.serial_no=ALLTRIM(dodean.ean)
				ENDIF 
			ELSE
				m.serial_no=ALLTRIM(dokladxx.serial_no)
			ENDIF 
		ENDIF 
	ELSE
		IF EMPTY(dokladxx.serial_no)
			m.serial_no=""
		ELSE
			m.serial_no=ALLTRIM(dokladxx.serial_no)
		ENDIF 
	ENDIF 
ELSE
	IF EMPTY(dokladxx.serial_no)
		m.serial_no=""
	ELSE
		m.serial_no=ALLTRIM(dokladxx.serial_no)
	ENDIF 
ENDIF 
menoriadok = "LIN"												&&  1 C3
menoriadok = m.menoriadok + nx(m.poradie, 0, 6)				&&  2 N6    cislo radku
menoriadok = m.menoriadok + PADR(m.serial_no, 25)				&&  3 C25   EAN zbozi
menoriadok = m.menoriadok + PADR(nx(dokladxx.c_karty), 25)		&&  4 C25   cislo zbozi dodavatele
menoriadok = m.menoriadok + PADR("Z", 4)						&&  5 C4    typ polozky: Z:zbozi, O:obal
menoriadok = m.menoriadok + nx(1.0, 3, 12)						&&  6 N12,3 pocet jednotek v baleni
menoriadok = m.menoriadok + nx(dokladxx.cena_part, 2, 12)		&&  7 N12,2 cena za jednotku
menoriadok = m.menoriadok + nx(dokladxx.dan*100-100, 2,  5)	&&  8 N5,2  sazba dph
menoriadok = m.menoriadok + nx(-dokladxx.mnozstvi, 3, 12)		&&  9 N12,3 dodane mnozstvi
menoriadok = m.menoriadok + SPACE(3)							&& 10 C3    merna jednotka mnozstvi
menoriadok = m.menoriadok + SPACE(15)							&& 11 C15   cislo sarze
menoriadok = m.menoriadok + SPACE(8)							&& 12 C8    datum vyroby
menoriadok = m.menoriadok + SPACE(8)							&& 13 C8    datum trvanlivosti
menoriadok = m.menoriadok + SPACE(8)							&& 14 C8    datum pouzitelnosti
menoriadok = m.menoriadok + SPACE(15)							&& 15 C15   cislo objednavky zakaznika
menoriadok = m.menoriadok + SPACE(15)							&& 16 C15   cislo faktury
DO CASE 
	CASE m.mutacia="1"
		menoriadok = m.menoriadok + PADR(dokladxx.nazev1, 45)			&& 17 C45   specifikace
	CASE m.mutacia="2"
		menoriadok = m.menoriadok + PADR(dokladxx.nazev2, 45)			&& 17 C45   specifikace
	CASE m.mutacia="3"
		menoriadok = m.menoriadok + PADR(dokladxx.nazev3, 45)			&& 17 C45   specifikace
	CASE m.mutacia="4"
		menoriadok = m.menoriadok + PADR(dokladxx.nazev4, 45)			&& 17 C45   specifikace
	CASE m.mutacia="5"
		menoriadok = m.menoriadok + PADR(dokladxx.nazev5, 45)			&& 17 C45   specifikace
	OTHERWISE 
		menoriadok = m.menoriadok + PADR(dokladxx.nazev, 45)			&& 17 C45   specifikace
ENDCASE 
menoriadok = m.menoriadok + SPACE(18)							&& 18 C18   sscc kod palety
STRTOFILE(m.menoriadok + CRLF, m.menosuboru, 1)


PROCEDURE  zapis_radek_telicka_orion_ordrsp
PRIVATE m.serial_no, m.hladajckarty
IF !EMPTY(dokladxx.c_karty) AND !ISNULL(dokladxx.c_karty)
	LOCAL dlzkaica
	m.hladajckarty=dokladxx.c_karty
	IF USED("dodean")
		=REQUERY("dodean")
	ELSE
		IF m.issql
			USE (m.sqlprefix+"reanykukarte") ALIAS dodean IN 0
		ELSE 
			USE veanykukarte ALIAS dodean IN 0
		ENDIF 
	ENDIF 
	SELECT dodean
	IF RECCOUNT()>0
		m.dlzkaica=LEN(ALLTRIM(m.partnerico))
		IF m.dlzkaica>0
			IF m.partnerovekody
				LOCATE FOR LEFT(dodean.ean,m.dlzkaica+2)=ALLTRIM(m.partnerico)+"::"
				IF FOUND()
					m.serial_no=ALLTRIM(SUBSTR(dodean.ean,m.dlzkaica+3))
				ELSE
					IF EMPTY(dokladxx.serial_no)
						GO TOP 
						LOCATE FOR !("::"$dodean.ean)
						IF FOUND()
							m.serial_no=ALLTRIM(dodean.ean)
						ELSE
							GO TOP 
							m.serial_no=ALLTRIM(dodean.ean)
						ENDIF 
					ELSE
						m.serial_no=ALLTRIM(dokladxx.serial_no)
					ENDIF 
				ENDIF 
			ELSE
				IF EMPTY(dokladxx.serial_no)
					GO TOP 
					LOCATE FOR !("::"$dodean.ean)
					IF FOUND()
						m.serial_no=ALLTRIM(dodean.ean)
					ELSE
						GO TOP 
						m.serial_no=ALLTRIM(dodean.ean)
					ENDIF 
				ELSE
					m.serial_no=ALLTRIM(dokladxx.serial_no)
				ENDIF 
			ENDIF 
		ELSE
			IF EMPTY(dokladxx.serial_no)
				m.serial_no=""
			ELSE
				m.serial_no=ALLTRIM(dokladxx.serial_no)
			ENDIF 
		ENDIF 
	ELSE
		IF EMPTY(dokladxx.serial_no)
			m.serial_no=""
		ELSE
			m.serial_no=ALLTRIM(dokladxx.serial_no)
		ENDIF 
	ENDIF 
	m.menoriadok='					<article>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<item_number>'+ALLTRIM(STR(m.poradie,4,0))+'</item_number>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<action_code>5</action_code>'+CHR(13)+CHR(10) &&3 = změna / 5 = akceptováno / 7 = neakceptováno
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<article_gtin>'+m.serial_no+'</article_gtin>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	DO CASE 
		CASE m.mutacia="1"
			m.menoriadok='						<article_name>'+dokladxx.nazev1+'</article_name>'+CHR(13)+CHR(10) && 17 C45   specifikace
		CASE m.mutacia="2"
			m.menoriadok='						<article_name>'+dokladxx.nazev2+'</article_name>'+CHR(13)+CHR(10) && 17 C45   specifikace
		CASE m.mutacia="3"
			m.menoriadok='						<article_name>'+dokladxx.nazev3+'</article_name>'+CHR(13)+CHR(10) && 17 C45   specifikace
		CASE m.mutacia="4"
			m.menoriadok='						<article_name>'+dokladxx.nazev4+'</article_name>'+CHR(13)+CHR(10) && 17 C45   specifikace
		CASE m.mutacia="5"
			m.menoriadok='						<article_name>'+dokladxx.nazev5+'</article_name>'+CHR(13)+CHR(10) && 17 C45   specifikace
		OTHERWISE 
			m.menoriadok='						<article_name>'+dokladxx.nazev+'</article_name>'+CHR(13)+CHR(10) && 17 C45   specifikace
	ENDCASE 
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<quantity_type>21</quantity_type>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<quantity>'+nx2(-dokladxx.mnozstvi   , 3, 12)+'</quantity>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	DO CASE 
		CASE m.mutacia="1"
			m.menoriadok='						<unit>'+RIGHT(dokladxx.nazev,3)+'</unit>'+CHR(13)+CHR(10)
		OTHERWISE 
			DO CASE 
				CASE LOWER(RIGHT(dokladxx.nazev,3))="kg"
					m.menoriadok='						<unit>KGM</unit>'+CHR(13)+CHR(10)
				CASE LOWER(RIGHT(dokladxx.nazev,3))="por"
					m.menoriadok='						<unit>PCE</unit>'+CHR(13)+CHR(10)
				CASE INLIST(LOWER(RIGHT(dokladxx.nazev,3)),"lt","l")
					m.menoriadok='						<unit>LTR</unit>'+CHR(13)+CHR(10)
				OTHERWISE  
					m.menoriadok='						<unit>'+RIGHT(dokladxx.nazev,3)+'</unit>'+CHR(13)+CHR(10)
			ENDCASE 
	ENDCASE 
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<delivery_type>2</delivery_type>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<delivery_date>'++LEFT(DTOS(dokladxx.datum_dokl),4)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),5,2)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl),7,2)+'</delivery_date>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<best_before_period>'+ALLTRIM(STR(dokladxx.zaruka,4,0))+'</best_before_period>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<best_before_type>804</best_before_type>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<price>'+nx2(dokladxx.cena_part   , 2, 12)+'</price>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<total_price>'+nx2(-dokladxx.cena_part*dokladxx.mnozstvi   , 2, 12)+'</total_price>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='					</article>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
ENDIF 


PROCEDURE  zapis_radek_telicka_orion
PRIVATE m.serial_no, m.hladajckarty
IF !EMPTY(dokladxx.c_karty) AND !ISNULL(dokladxx.c_karty)
	LOCAL dlzkaica
	m.hladajckarty=dokladxx.c_karty
	IF USED("dodean")
		=REQUERY("dodean")
	ELSE
		IF m.issql
			USE (m.sqlprefix+"reanykukarte") ALIAS dodean IN 0
		ELSE 
			USE veanykukarte ALIAS dodean IN 0
		ENDIF 
	ENDIF 
	SELECT dodean
	IF RECCOUNT()>0
		m.dlzkaica=LEN(ALLTRIM(m.partnerico))
		IF m.dlzkaica>0
			IF m.partnerovekody
				LOCATE FOR LEFT(dodean.ean,m.dlzkaica+2)=ALLTRIM(m.partnerico)+"::"
				IF FOUND()
					m.serial_no=ALLTRIM(SUBSTR(dodean.ean,m.dlzkaica+3))
				ELSE
					IF EMPTY(dokladxx.serial_no)
						GO TOP 
						LOCATE FOR !("::"$dodean.ean)
						IF FOUND()
							m.serial_no=ALLTRIM(dodean.ean)
						ELSE
							GO TOP 
							m.serial_no=ALLTRIM(dodean.ean)
						ENDIF 
					ELSE
						m.serial_no=ALLTRIM(dokladxx.serial_no)
					ENDIF 
				ENDIF 
			ELSE
				IF EMPTY(dokladxx.serial_no)
					GO TOP 
					LOCATE FOR !("::"$dodean.ean)
					IF FOUND()
						m.serial_no=ALLTRIM(dodean.ean)
					ELSE
						GO TOP 
						m.serial_no=ALLTRIM(dodean.ean)
					ENDIF 
				ELSE
					m.serial_no=ALLTRIM(dokladxx.serial_no)
				ENDIF 
			ENDIF 
		ELSE
			IF EMPTY(dokladxx.serial_no)
				m.serial_no=""
			ELSE
				m.serial_no=ALLTRIM(dokladxx.serial_no)
			ENDIF 
		ENDIF 
	ELSE
		IF EMPTY(dokladxx.serial_no)
			m.serial_no=""
		ELSE
			m.serial_no=ALLTRIM(dokladxx.serial_no)
		ENDIF 
	ENDIF 
	m.menoriadok='			<item>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='				<package_number>1</package_number>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='				<package_reference>1E</package_reference>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	IF !ISNULL(dokladxx.sscc) AND !EMPTY(dokladxx.sscc)
		m.menoriadok='				<sscc>'+ALLTRIM(dokladxx.sscc)+'</sscc>'+CHR(13)+CHR(10)
	ELSE
		m.menoriadok='				<sscc></sscc>'+CHR(13)+CHR(10)
	ENDIF 
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='				<articles>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='					<article>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<item_number>'+ALLTRIM(STR(m.poradie,4,0))+'</item_number>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<article_gtin>'+m.serial_no+'</article_gtin>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<article_id_supplier>'+nx(dokladxx.c_karty)+'</article_id_supplier>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<item_type>Z</item_type>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<sscc></sscc>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	DO CASE 
		CASE m.mutacia="1"
			m.menoriadok='						<article_name>'+dokladxx.nazev1+'</article_name>'+CHR(13)+CHR(10) && 17 C45   specifikace
		CASE m.mutacia="2"
			m.menoriadok='						<article_name>'+dokladxx.nazev2+'</article_name>'+CHR(13)+CHR(10) && 17 C45   specifikace
		CASE m.mutacia="3"
			m.menoriadok='						<article_name>'+dokladxx.nazev3+'</article_name>'+CHR(13)+CHR(10) && 17 C45   specifikace
		CASE m.mutacia="4"
			m.menoriadok='						<article_name>'+dokladxx.nazev4+'</article_name>'+CHR(13)+CHR(10) && 17 C45   specifikace
		CASE m.mutacia="5"
			m.menoriadok='						<article_name>'+dokladxx.nazev5+'</article_name>'+CHR(13)+CHR(10) && 17 C45   specifikace
		OTHERWISE 
			m.menoriadok='						<article_name>'+dokladxx.nazev+'</article_name>'+CHR(13)+CHR(10) && 17 C45   specifikace
	ENDCASE 
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<quantity>'+nx2(-dokladxx.mnozstvi   , 3, 12)+'</quantity>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	DO CASE 
		CASE m.mutacia="1"
			m.menoriadok='						<unit>'+RIGHT(dokladxx.nazev,3)+'</unit>'+CHR(13)+CHR(10)
		OTHERWISE 
			DO CASE 
				CASE LOWER(RIGHT(dokladxx.nazev,3))="kg"
					m.menoriadok='						<unit>KGM</unit>'+CHR(13)+CHR(10)
				CASE LOWER(RIGHT(dokladxx.nazev,3))="por"
					m.menoriadok='						<unit>PCE</unit>'+CHR(13)+CHR(10)
				CASE INLIST(LOWER(RIGHT(dokladxx.nazev,3)),"lt","l")
					m.menoriadok='						<unit>LTR</unit>'+CHR(13)+CHR(10)
				OTHERWISE  
					m.menoriadok='						<unit>'+RIGHT(dokladxx.nazev,3)+'</unit>'+CHR(13)+CHR(10)
			ENDCASE 
	ENDCASE 
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<price>'+nx2(dokladxx.cena_part   , 2, 12)+'</price>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<vat_rate>'+nx2(dokladxx.dan*100-100 , 2,  5)+'</vat_rate>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='						<best_before_date>'+LEFT(DTOS(dokladxx.datum_dokl+dokladxx.zaruka),4)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl+dokladxx.zaruka),5,2)+'-'+SUBSTR(DTOS(dokladxx.datum_dokl+dokladxx.zaruka),7,2)+'</best_before_date>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='					</article>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='				</articles>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
	m.menoriadok='			</item>'+CHR(13)+CHR(10)
	=STRTOFILE(m.menoriadok,m.menosuboru,1)
ENDIF 
