LPARAMETERS pcalias, pcsoubor, pcvzordocplus,llformatovat,lcjazyk, ajceny, ajnakup, skadial, ajmnozstva, ajpoznamky, cenalimitu
LOCAL lcvzordoc, lnvzortyp, lcpoznmem, lnselect
LOCAL qdatumod, qdatumdo, qtxtdatum, qsetdate, qjedenden, qriadok
LOCAL pokracuj
m.pokracuj=.t.
IF EMPTY(m.ajmnozstva)
	m.ajmnozstva=.F.
ELSE
	m.ajmnozstva=.T.
ENDIF 
IF EMPTY(m.ajpoznamky)
	m.ajpoznamky=.F.
ELSE
	m.ajpoznamky=.T.
ENDIF 
IF EMPTY(cenalimitu)
	m.cenalimitu=.f.
ELSE
	m.cenalimitu=.t.
	m.ajceny=.f.
	m.ajnakup=.f.
ENDIF 
qsetdate=SET("date")
lnselect = SELECT()
lcvzordoc = IIF(VARTYPE(pcvzordocplus)='C', ALLTRIM(pcvzordocplus), "Vzor_1")
lnvzortyp = IIF(ATC("_1", lcvzordoc)>0, 1, IIF(ATC("_2", lcvzordoc)>0, 2, IIF(ATC("_3", lcvzordoc)>0, 3, IIF(ATC("_4", lcvzordoc)>0 .OR. ATC("_CT", lcvzordoc)>0, 4, IIF(ATC("_5", lcvzordoc)>0 .OR. ATC("_CB", lcvzordoc)>0, 5, 0)))))
IF "sablona"$LOWER(m.lcvzordoc)
	m.lnvzortyp=6
ENDIF 
oword = CREATEOBJECT("Word.Application")
IF !INLIST(oword.LANGUAGE,1033,1051,1029)
	=MESSAGEBOX("Nepodporovaná jazyková mutácia Wordu",16,"")
	oword = .NULL.
	RELEASE oword
	RETURN
ENDIF
oword.VISIBLE = .T.
*!*	odoc = oword.documents.OPEN(m.gchom_path+"Doc\"+lcvzordoc+".doc")
TRY 
	odoc = oword.documents.OPEN(m.skadial+lcvzordoc+".doc")
CATCH
	m.pokracuj=.f.
ENDTRY 
IF !m.pokracuj
	=MESSAGEBOX("Nepodarilo sa otvoriť šablónu",16,"FoodMan")
	oword = .NULL.
	RELEASE oword
	RETURN
ENDIF
m.cislostylu=0
FOR m.i=1 TO odoc.styles.count()
	IF odoc.styles(m.i).namelocal="Limit_Hlavicka"
		m.cislostylu=m.i
		oheaderstyle=odoc.styles(m.i)
		EXIT
	ENDIF 
ENDFOR 
IF m.cislostylu=0
	oheaderstyle = odoc.styles.ADD("Limit_Hlavicka", 1)
	oheaderstyle.basestyle = IIF(oword.LANGUAGE=1033,odoc.styles("Heading 1"),odoc.styles("Nadpis 1"))
	oheaderstyle.FONT.NAME = "Times New Roman"
	oheaderstyle.FONT.SIZE = 20
ENDIF 
*!*	IF m.ajnakup
*!*		SELECT llist
*!*		SET RELATION TO c_karty INTO karty
*!*		REPLACE ALL nc WITH NTOM(MTON(karty.cena_prum)*en__meny(karty.c_mena_n,llist.c_mena))
*!*		SET RELATION OFF INTO karty
*!*	ENDIF 
WITH oheaderstyle
	.paragraphformat.spacebefore = 12
	TRY 
		.font.kerning=0
		.font.spacing=0
	CATCH 
	ENDTRY 	
	DO CASE
		CASE INLIST(lnvzortyp, 1)
			IF  .NOT. llformatovat
				.paragraphformat.tabstops.ADD(310, 0)
				.paragraphformat.tabstops.ADD(540, 2)
				IF m.cislostylu=0
					.FONT.SIZE = 14
					.FONT.bold = .F.
				ENDIF 
			ELSE
				.paragraphformat.tabstops.ADD(200, 0)
				.paragraphformat.tabstops.ADD(540, 2)
				IF m.cislostylu=0
					.FONT.SIZE = 18
					.FONT.bold = .T.
				ENDIF 
			ENDIF
		CASE INLIST(lnvzortyp, 2, 4, 5)
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.SIZE = 20
					.FONT.bold = .T.
				ELSE
					.FONT.SIZE = 20
					.FONT.bold = .T.
				ENDIF
			ENDIF 
		CASE INLIST(lnvzortyp, 0, 3)
			.paragraphformat.tabstops.ADD(150, 2)
			.paragraphformat.tabstops.ADD(350, 2)
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.SIZE = 14
					.FONT.bold = .F.
				ELSE
					.FONT.SIZE = 18
					.FONT.bold = .T.
				ENDIF
			ENDIF 
		CASE INLIST(lnvzortyp, 6)
			IF m.cislostylu=0
				.FONT.NAME = "Calibri"
			ENDIF 
			TRY 
				.font.kerning=0
				.font.spacing=0
			CATCH 
			ENDTRY 	
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.SIZE = 14
					.FONT.bold = .F.
				ELSE
					.FONT.SIZE = 20
					.FONT.bold = .T.
				ENDIF
				.paragraphformat.tabstops.ADD(100, 0)
			ENDIF 
	ENDCASE
ENDWITH
m.cislostylu=0
FOR m.i=1 TO odoc.styles.count()
	IF odoc.styles(m.i).namelocal="Limit_Hlavicka2"
		m.cislostylu=m.i
		oheaderstyle2=odoc.styles(m.i)
		EXIT
	ENDIF 
ENDFOR  
IF m.cislostylu=0
	oheaderstyle2 = odoc.styles.ADD("Limit_Hlavicka2", 1)
	oheaderstyle2.basestyle = IIF(oword.LANGUAGE=1033,odoc.styles("Normal"),IIF(oword.LANGUAGE=1029,odoc.styles("Normální"),odoc.styles("Normálny")))
	oheaderstyle2.FONT.NAME = "Times New Roman"
ENDIF 
WITH oheaderstyle2
	TRY 
		.font.kerning=0
		.font.spacing=0
	CATCH 
	ENDTRY 	
	DO CASE
		CASE INLIST(lnvzortyp, 1)
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.SIZE = 14
					.FONT.bold = .F.
				ELSE
					.FONT.SIZE = 16
					.FONT.bold = .F.
				ENDIF
			ENDIF 
			.paragraphformat.tabstops.ADD(130, 0)
		CASE INLIST(lnvzortyp, 2, 4, 5)
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.SIZE = 14
					.FONT.bold = .F.
				ELSE
					.FONT.SIZE = 14
					.FONT.bold = .T.
				ENDIF
			ENDIF 
		CASE INLIST(lnvzortyp, 0, 3)
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.SIZE = 14
					.FONT.bold = .F.
				ELSE
					.FONT.SIZE = 16
					.FONT.bold = .F.
				ENDIF
			ENDIF 
			.paragraphformat.tabstops.ADD(130, 0)
		CASE INLIST(lnvzortyp, 6)
			IF m.cislostylu=0
				.FONT.NAME = "Calibri"
			ENDIF 
			TRY 
				.font.kerning=0
				.font.spacing=0
			CATCH 
			ENDTRY 	
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.SIZE = 14
					.FONT.bold = .F.
				ELSE
					.FONT.SIZE = 16
					.FONT.bold = .F.
				ENDIF
				.paragraphformat.tabstops.ADD(100, 0)
			ENDIF 
	ENDCASE
ENDWITH
m.cislostylu=0
FOR m.i=1 TO odoc.styles.count()
	IF odoc.styles(m.i).namelocal="Limit_Druhy"
		m.cislostylu=m.i
		otitlestyle=odoc.styles(m.i)
		EXIT
	ENDIF 
ENDFOR 
IF m.cislostylu=0
	otitlestyle = odoc.styles.ADD("Limit_Druhy", 1)
ENDIF 
WITH otitlestyle
	IF m.cislostylu=0
		.FONT.NAME = "Times New Roman"
		IF  .NOT. llformatovat
			.basestyle = IIF(oword.LANGUAGE=1033,odoc.styles("Normal"),IIF(oword.LANGUAGE=1029,odoc.styles("Normální"),odoc.styles("Normálny")))
		ELSE
			.basestyle = IIF(oword.LANGUAGE=1033,odoc.styles("Heading 2"),odoc.styles("Nadpis 2"))
			.paragraphformat.spacebefore = 6
			.paragraphformat.spaceafter = 6
		ENDIF
		.FONT.SIZE = 14
		.FONT.NAME = "Times New Roman"
	ENDIF 
	TRY 
		.font.kerning=0
		.font.spacing=0
	CATCH 
	ENDTRY 	
	DO CASE
		CASE INLIST(lnvzortyp, 1)
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.italic = .F.
					.FONT.bold = .F.
				ELSE
					.FONT.italic = .T.
					.FONT.bold = .T.
				ENDIF
			ENDIF 
		CASE INLIST(lnvzortyp, 2, 4, 5)
			IF m.cislostylu=0
				.FONT.italic = .F.
				IF  .NOT. llformatovat
					.FONT.bold = .F.
				ELSE
					.FONT.bold = .T.
				ENDIF
			ENDIF 
		CASE INLIST(lnvzortyp, 0, 3)
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.italic = .F.
					.FONT.bold = .F.
				ELSE
					.FONT.italic = .T.
					.FONT.bold = .T.
				ENDIF
			ENDIF 
		CASE INLIST(lnvzortyp, 6)
			IF m.cislostylu=0
				.FONT.NAME = "Calibri"
			ENDIF 
			TRY 
				.font.kerning=0
				.font.spacing=0
			CATCH 
			ENDTRY 	
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.italic = .F.
					.FONT.bold = .F.
				ELSE
					.FONT.italic = .T.
					.FONT.bold = .T.
				ENDIF
			ENDIF 
	ENDCASE
ENDWITH
m.cislostylu=0
FOR m.i=1 TO odoc.styles.count()
	IF odoc.styles(m.i).namelocal="Limit_Polozky"
		m.cislostylu=m.i
		obodystyle=odoc.styles(m.i)
		EXIT
	ENDIF 
ENDFOR 
IF m.cislostylu=0
	obodystyle = odoc.styles.ADD("Limit_Polozky", 1)
	obodystyle.basestyle = IIF(oword.LANGUAGE=1033,odoc.styles("Normal"),IIF(oword.LANGUAGE=1029,odoc.styles("Normální"),odoc.styles("Normálny")))
	obodystyle.FONT.SIZE = 14
	obodystyle.FONT.NAME = "Times New Roman"
	obodystyle.FONT.bold = .F.
ENDIF 
WITH obodystyle
	TRY 
		.font.kerning=0
		.font.spacing=0
	CATCH 
	ENDTRY 	
	IF llformatovat
		.paragraphformat.linespacingrule = 4
		.paragraphformat.linespacing = 14
	ENDIF
	DO CASE
		CASE INLIST(lnvzortyp, 1)
			.paragraphformat.tabstops.ADD(86, 2)
			.paragraphformat.tabstops.ADD(100, 0)
			.paragraphformat.tabstops.ADD(410, 2)
			.paragraphformat.tabstops.ADD(470, 2)
			.paragraphformat.tabstops.ADD(490, 2)
			.paragraphformat.tabstops.ADD(540, 2)
		CASE INLIST(lnvzortyp, 2, 4, 5)
			.paragraphformat.tabstops.ADD(315, 2)
			.paragraphformat.tabstops.ADD(375, 2)
			.paragraphformat.tabstops.ADD(395, 2)
			.paragraphformat.tabstops.ADD(445, 2)
		CASE INLIST(lnvzortyp, 0, 3)
			.paragraphformat.tabstops.ADD(86, 2)
			.paragraphformat.tabstops.ADD(100, 0)
			.paragraphformat.tabstops.ADD(315, 2)
			.paragraphformat.tabstops.ADD(375, 2)
			.paragraphformat.tabstops.ADD(395, 2)
			.paragraphformat.tabstops.ADD(445, 2)
		CASE INLIST(lnvzortyp, 6)
			IF m.cislostylu=0
				.FONT.NAME = "Calibri"
			ENDIF 
			TRY 
				.font.kerning=0
				.font.spacing=0
			CATCH 
			ENDTRY 	
			IF m.cislostylu=0
*				.paragraphformat.tabstops.ADD(86, 0)
				.paragraphformat.tabstops.ADD(315, 2)
				.paragraphformat.tabstops.ADD(375, 2)
				.paragraphformat.tabstops.ADD(395, 2)
				.paragraphformat.tabstops.ADD(445, 2)
			ENDIF 
	ENDCASE
ENDWITH
m.cislostylu=0
FOR m.i=1 TO odoc.styles.count()
	IF odoc.styles(m.i).namelocal="Limit_Sucty_Bold"
		m.cislostylu=m.i
		ototalstyle=odoc.styles(m.i)
		EXIT
	ENDIF 
ENDFOR 
IF m.cislostylu=0
	ototalstyle = odoc.styles.ADD("Limit_Sucty_Bold", 1)
	ototalstyle.basestyle = IIF(oword.LANGUAGE=1033,odoc.styles("Normal"),IIF(oword.LANGUAGE=1029,odoc.styles("Normální"),odoc.styles("Normálny")))
	ototalstyle.FONT.SIZE = 14
	ototalstyle.FONT.NAME = "Times New Roman"
	ototalstyle.FONT.bold = .F.
ENDIF 
WITH ototalstyle
	TRY 
		.font.kerning=0
		.font.spacing=0
	CATCH 
	ENDTRY 	
	DO CASE
		CASE INLIST(lnvzortyp, 1)
			IF m.cislostylu=0
				.FONT.SIZE = 14
				IF  .NOT. llformatovat
					.FONT.bold = .F.
				ELSE
					.FONT.bold = .T.
				ENDIF
			ENDIF 
			.paragraphformat.tabstops.ADD(209, 0)
			.paragraphformat.tabstops.ADD(472, 3)
			.paragraphformat.tabstops.ADD(495, 0)
		CASE INLIST(lnvzortyp, 2, 4, 5)
			IF m.cislostylu=0
				.FONT.SIZE = 14
				IF  .NOT. llformatovat
					.FONT.bold = .F.
				ELSE
					.FONT.bold = .T.
				ENDIF
			ENDIF 
			.paragraphformat.tabstops.ADD(171, 0)
			.paragraphformat.tabstops.ADD(320, 2)
		CASE INLIST(lnvzortyp, 0, 3)
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.bold = .F.
					.FONT.SIZE = 14
				ELSE
					.FONT.bold = .T.
					.FONT.SIZE = 16
				ENDIF
			ENDIF 
			.paragraphformat.tabstops.ADD(200, 0)
			.paragraphformat.tabstops.ADD(350, 2)
		CASE INLIST(lnvzortyp, 6)
			IF m.cislostylu=0
				.FONT.NAME = "Calibri"
			ENDIF 
			TRY 
				.font.kerning=0
				.font.spacing=0
			CATCH 
			ENDTRY 	
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.bold = .F.
					.FONT.SIZE = 14
				ELSE
					.FONT.bold = .T.
					.FONT.SIZE = 16
				ENDIF
				.paragraphformat.tabstops.ADD(171, 0)
				.paragraphformat.tabstops.ADD(320, 2)
			ENDIF 
	ENDCASE
ENDWITH
m.cislostylu=0
FOR m.i=1 TO odoc.styles.count()
	IF odoc.styles(m.i).namelocal="Limit_Sucty_BezBoldu"
		m.cislostylu=m.i
		ototalstyle2=odoc.styles(m.i)
		EXIT
	ENDIF  
ENDFOR 
IF m.cislostylu=0
	ototalstyle2 = odoc.styles.ADD("Limit_Sucty_BezBoldu", 1)
	ototalstyle2.basestyle = IIF(oword.LANGUAGE=1033,odoc.styles("Normal"),IIF(oword.LANGUAGE=1029,odoc.styles("Normální"),odoc.styles("Normálny")))
	ototalstyle2.FONT.SIZE = 14
	ototalstyle2.FONT.NAME = "Times New Roman"
	ototalstyle2.FONT.bold = .F.
ENDIF 
WITH ototalstyle2
	TRY 
		.font.kerning=0
		.font.spacing=0
	CATCH 
	ENDTRY 	
	DO CASE
		CASE INLIST(lnvzortyp, 1)
			IF m.cislostylu=0
				.FONT.SIZE = 14
				IF  .NOT. llformatovat
					.FONT.bold = .F.
				ELSE
					.FONT.bold = .F.
				ENDIF
			ENDIF 
			.paragraphformat.tabstops.ADD(209, 0)
			.paragraphformat.tabstops.ADD(472, 3)
			.paragraphformat.tabstops.ADD(495, 0)
		CASE INLIST(lnvzortyp, 2, 4, 5)
			IF m.cislostylu=0
				.FONT.SIZE = 14
				IF  .NOT. llformatovat
					.FONT.bold = .F.
				ELSE
					.FONT.bold = .F.
				ENDIF
			ENDIF 
			.paragraphformat.tabstops.ADD(171, 0)
			.paragraphformat.tabstops.ADD(320, 2)
		CASE INLIST(lnvzortyp, 0, 3)
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.bold = .F.
					.FONT.SIZE = 14
				ELSE
					.FONT.bold = .F.
					.FONT.SIZE = 16
				ENDIF
			ENDIF 
			.paragraphformat.tabstops.ADD(200, 0)
			.paragraphformat.tabstops.ADD(350, 2)
		CASE INLIST(lnvzortyp, 6)
			IF m.cislostylu=0
				.FONT.NAME = "Calibri"
			ENDIF 
			TRY 
				.font.kerning=0
				.font.spacing=0
			CATCH 
			ENDTRY 	
			IF m.cislostylu=0
				IF  .NOT. llformatovat
					.FONT.bold = .F.
					.FONT.SIZE = 14
				ELSE
					.FONT.bold = .F.
					.FONT.SIZE = 16
				ENDIF
				.paragraphformat.tabstops.ADD(171, 0)
				.paragraphformat.tabstops.ADD(320, 2)
			ENDIF 
	ENDCASE
ENDWITH
SELECT llist5
REPLACE dan WITH 1 FOR dan=0
SUM ALL cena_prod*mnozstvi TO m.lncena0
SUM ALL cena_prod*mnozstvi/dan TO m.lncena4
SELECT (pcalias)
GOTO TOP
lcpoznmem = rlimit.poznamka
lnprira = MTON(rlimit.zlava)
lnprirb = rlimit.typ_zlavy
DO CASE
	CASE lnprirb="A"
		m.lnsl_p=lnprira
	CASE lnprirb="P"
		IF m.slovenskaverzia
			m.lnsl_p=ROUND(lnprira/100*m.lncena0,2)
		ELSE
			m.lnsl_p=ROUND(lnprira/100*m.lncena0,0)
		ENDIF		
	OTHERWISE
		m.lnprira=0
		m.lnsl_p=0
ENDCASE 
m.lnsl_p=MTON(m.lnsl_p)
lncena2 = MTON(lncena0-lnsl_p)
lncena3 = MTON(IIF(m.lncena0=0,0,m.lncena2/m.lncena0*m.lncena4))
IF !m.slovenskaverzia
	m.lncena3=ROUND(m.lncena3,0)
ENDIF		
IF m.lnvzortyp=6
	IF !EMPTY(rlimit.firma)
		pozn1=ALLTRIM(rlimit.firma)
	ELSE
		pozn1=IIF(EMPTY(rlimit.txt1),rlimit.menolimit,rlimit.txt1)
	ENDIF 
ELSE 
	pozn1=IIF(EMPTY(rlimit.txt1),rlimit.menolimit,rlimit.txt1)
ENDIF 
pozn2=rlimit.txt2
pozn4=0
m.menolimit=rlimit.menolimit
rok=YEAR(llist5.datum)
m.filt=SET("filter")
SELECT DISTINCT llist5.datum, llist5.chod, llist5.limit, llist5.pocet, llist5.por1, llist5.txt1, llist5.txt2 FROM llist5  ORDER BY datum, por1 INTO CURSOR aaasss WHERE &filt
SELECT aaasss
IF m.cenalimitu
	SUM limit*pocet TO m.lncena0
	m.lncena2=m.lncena0
	m.lncena3=m.lncena0
	m.lncena4=m.lncena0
ENDIF 
GO TOP 
m.qdatumod=aaasss.datum
GO BOTTOM 
m.qdatumdo=aaasss.datum
GO TOP 
m.qjedenden=(m.qdatumod=m.qdatumdo)

orange = odoc.RANGE()

IF m.lnvzortyp=6
	SET DATE TO SHORT 
	m.qtxtdatum=IIF(m.qjedenden,DTOC(m.qdatumod), DTOC(m.qdatumod)+" "+DTOC(m.qdatumdo))
	WITH orange
		.insertafter("Firma:"+CHR(9)+m.pozn1+CHR(13))
		DO CASE
			CASE lcjazyk=='A'
				.insertafter("Date:"+CHR(9)+m.qtxtdatum+CHR(13))
				.insertafter("Time:"+CHR(9)+"Viz níže"+CHR(13))
				.insertafter("Place:"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
				.insertafter("Persons:"+CHR(9)+TRANSFORM(aaasss.pocet)+CHR(13))
			CASE lcjazyk=='N'
				.insertafter("Tag:"+CHR(9)+m.qtxtdatum+CHR(13))
				.insertafter("Zeit:"+CHR(9)+"Viz níže"+CHR(13))
				.insertafter("Platz:"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
				.insertafter("Nummer:"+CHR(9)+TRANSFORM(aaasss.pocet)+CHR(13))
			OTHERWISE
				.insertafter(jaz("form datum")+":"+CHR(9)+m.qtxtdatum+CHR(13))
				.insertafter(jaz("rep_cas")+":"+CHR(9)+"Viz níže"+CHR(13))
				.insertafter(jaz("word_miesto")+":"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
				.insertafter(jaz("rep_pocet_osob")+":"+CHR(9)+TRANSFORM(aaasss.pocet)+CHR(13))
		ENDCASE  
		.insertafter(CHR(13))
	ENDWITH 
ENDIF 
SELECT aaasss



m.qriadok=0
SCAN ALL
	SCATTER MEMVAR FIELDS datum, chod
	m.str_nazev=ALLTRIM(aaasss.chod)
	m.poc_osob=aaasss.pocet
	m.pozn4=aaasss.limit
	WITH orange
		IF m.qriadok=0
			.insertafter(CHR(13))
			m.qriadok=1
		ELSE
			.insertafter("***************************************************************************************"+CHR(13))
			.insertafter(CHR(13))
		ENDIF 
		DO CASE
			CASE INLIST(lnvzortyp, 1)
*				.insertafter(m.str_nazev+CHR(9)+ALLTRIM(pozn1)+CHR(9)+i_zkrat(aaasss.id_man,"M")+CHR(13))
				.STYLE = oheaderstyle
				.insertafter(m.str_nazev+CHR(9)+ALLTRIM(pozn1)+CHR(9)+IIF(DTOS(m.datum)="29000101","Sumár",DTOC(m.datum))+CHR(13))
				.collapse(0)
				.insertafter(" "+CHR(13))
				.STYLE = obodystyle
				.BORDERS(-1).linestyle = 1
				.BORDERS(-1).linewidth = 12
				.collapse(0)
				.BORDERS(-1).linestyle = 0
			CASE INLIST(lnvzortyp, 2, 4, 5)
				.STYLE = oheaderstyle
				.insertafter(ALLTRIM(pozn1)+CHR(13))
				.collapse(0)
			CASE INLIST(lnvzortyp, 0, 3)
				.STYLE = oheaderstyle
				.insertafter(m.str_nazev+CHR(9)+ALLTRIM(pozn1)+CHR(9)+IIF(DTOS(m.datum)="29000101","Sumár",DTOC(m.datum))+CHR(13))
				.collapse(0)
			CASE INLIST(lnvzortyp, 6)
				.STYLE = oheaderstyle2
				.insertafter(m.str_nazev+CHR(13))
				.collapse(0)

		ENDCASE
		DO CASE
			CASE INLIST(lnvzortyp, 6)
				m.qtxtdatum=DTOC(aaasss.datum)
				DO CASE
					CASE lcjazyk=='A'
						IF !EMPTY(aaasss.txt1)
							.insertafter(ALLTRIM(aaasss.txt1)+CHR(13))
						ENDIF 
						IF !m.qjedenden
							.insertafter("Date:"+CHR(9)+m.qtxtdatum+CHR(13))
						ENDIF 
						IF !EMPTY(aaasss.txt2)
							.insertafter("Place:"+CHR(9)+ALLTRIM(aaasss.txt2)+CHR(13))
						ENDIF 
						.insertafter("Persons:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
						IF  .NOT. EMPTY(pozn4)
							.insertafter("Limit:"+CHR(9)+ALLTRIM(STR(pozn4,10,2))+CHR(13))
						ENDIF
						IF  .NOT. EMPTY(llist5.pozn_ext)
							.insertafter("Notice:"+CHR(9)+ALLTRIM(llist5.pozn_ext)+CHR(13))
						ENDIF
					CASE lcjazyk=='N'
						IF !EMPTY(aaasss.txt1)
							.insertafter(ALLTRIM(aaasss.txt1)+CHR(13))
						ENDIF 
						IF !m.qjedenden
							.insertafter("Tag:"+CHR(9)+m.qtxtdatum+CHR(13))
						ENDIF 
						IF !EMPTY(aaasss.txt2)
							.insertafter("Platz:"+CHR(9)+ALLTRIM(aaasss.txt2)+CHR(13))
						ENDIF 
						.insertafter("Nummer:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
						IF  .NOT. EMPTY(pozn4)
							.insertafter("Limit:"+CHR(9)+ALLTRIM(STR(pozn4,10,2))+CHR(13))
						ENDIF
						IF  .NOT. EMPTY(llist5.pozn_ext)
							.insertafter("Note:"+CHR(9)+ALLTRIM(llist5.pozn_ext)+CHR(13))
						ENDIF
					OTHERWISE
						IF !EMPTY(aaasss.txt1)
							.insertafter(ALLTRIM(aaasss.txt1)+CHR(13))
						ENDIF 
						IF !m.qjedenden
							.insertafter(jaz("form datum")+":"+CHR(9)+m.qtxtdatum+CHR(13))
						ENDIF 
						IF !EMPTY(aaasss.txt2)
							.insertafter(jaz("word_miesto")+":"+CHR(9)+ALLTRIM(aaasss.txt2)+CHR(13))
						ENDIF 
						.insertafter("Počet osob:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
						IF  .NOT. EMPTY(pozn4)
							.insertafter("Limit:"+CHR(9)+ALLTRIM(STR(pozn4,10,2))+CHR(13))
						ENDIF
						IF  .NOT. EMPTY(llist5.pozn_ext)
							.insertafter("Poznámka:"+CHR(9)+ALLTRIM(llist5.pozn_ext)+CHR(13))
						ENDIF
				ENDCASE
			CASE INLIST(lnvzortyp, 1)
				DO CASE
					CASE lcjazyk=='A'
						.insertafter("Place:"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
						.insertafter("Date:"+CHR(9)+TRANSFORM(IIF(DTOS(aaasss.datum)="29000101","Sumár",DTOC(aaasss.datum)))+CHR(13))
						.insertafter("Number:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
						IF  .NOT. EMPTY(pozn4)
							.insertafter("Limit:"+CHR(9)+ALLTRIM(STR(pozn4,10,2))+CHR(13))
						ENDIF
						IF  .NOT. EMPTY(llist5.pozn_ext)
							.insertafter("Notice:"+CHR(9)+ALLTRIM(llist5.pozn_ext)+CHR(13))
						ENDIF
					CASE lcjazyk=='N'
						.insertafter("Platz:"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
						.insertafter("Tag:"+CHR(9)+TRANSFORM(IIF(DTOS(aaasss.datum)="29000101","Sumár",DTOC(aaasss.datum)))+CHR(13))
						.insertafter("Nummer:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
						IF  .NOT. EMPTY(pozn4)
							.insertafter("Limit:"+CHR(9)+ALLTRIM(STR(pozn4,10,2))+CHR(13))
						ENDIF
						IF  .NOT. EMPTY(llist5.pozn_ext)
							.insertafter("Note:"+CHR(9)+ALLTRIM(llist5.pozn_ext)+CHR(13))
						ENDIF
					OTHERWISE
						.insertafter(jaz("word_miesto")+":"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
						.insertafter(jaz("form datum")+":"+CHR(9)+IIF(DTOS(aaasss.datum)="29000101","Sumár",DTOC(aaasss.datum))+CHR(13))
						.insertafter("Počet:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
						IF  .NOT. EMPTY(pozn4)
							.insertafter("Limit:"+CHR(9)+ALLTRIM(STR(pozn4,10,2))+CHR(13))
						ENDIF
						IF  .NOT. EMPTY(llist5.pozn_ext)
							.insertafter("Poznámka:"+CHR(9)+ALLTRIM(llist5.pozn_ext)+CHR(13))
						ENDIF
				ENDCASE
			CASE INLIST(lnvzortyp, 2, 4, 5)
				DO CASE
					CASE lcjazyk=='A'
						.insertafter(TRANSFORM(IIF(DTOS(aaasss.datum)="29000101","Sumár",DTOC(aaasss.datum)))+CHR(13))
						.insertafter(TRANSFORM(poc_osob)+"  person"+CHR(13))
						IF  .NOT. EMPTY(llist5.pozn_ext)
							.insertafter("Notice:"+CHR(9)+ALLTRIM(llist5.pozn_ext)+CHR(13))
						ENDIF
					CASE lcjazyk=='N'
						.insertafter(TRANSFORM(IIF(DTOS(aaasss.datum)="29000101","Sumár",DTOC(aaasss.datum)))+CHR(13))
						.insertafter(TRANSFORM(poc_osob)+"  personenzahl"+CHR(13))
						IF  .NOT. EMPTY(llist5.pozn_ext)
							.insertafter("Note:"+CHR(9)+ALLTRIM(llist5.pozn_ext)+CHR(13))
						ENDIF
					OTHERWISE
						.insertafter(TRANSFORM(IIF(DTOS(aaasss.datum)="29000101","Sumár",DTOC(aaasss.datum)))+CHR(13))
						IF m.slovenskaverzia
							.insertafter(TRANSFORM(poc_osob)+ICASE(m.poc_osob=1,"  osoba",INLIST(m.poc_osob,2,3,4),"  osoby","  osôb")+CHR(13))
						ELSE
							.insertafter(TRANSFORM(poc_osob)+ICASE(m.poc_osob=1,"  osoba",INLIST(m.poc_osob,2,3,4),"  osoby","  osob")+CHR(13))
						ENDIF 
						IF  .NOT. EMPTY(llist5.pozn_ext)
							.insertafter("Poznámka:"+CHR(9)+ALLTRIM(llist5.pozn_ext)+CHR(13))
						ENDIF
				ENDCASE
				.insertafter(m.str_nazev+CHR(13))
			CASE INLIST(lnvzortyp, 0, 3)
				DO CASE
					CASE lcjazyk=='A'
						.insertafter("Place:"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
						.insertafter("Date:"+CHR(9)+TRANSFORM(IIF(DTOS(aaasss.datum)="29000101","Sumár",DTOC(aaasss.datum)))+CHR(13))
						.insertafter("Number:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
						IF  .NOT. EMPTY(llist5.pozn_ext)
							.insertafter("Notice:"+CHR(9)+ALLTRIM(llist5.pozn_ext)+CHR(13))
						ENDIF
					CASE lcjazyk=='N'
						.insertafter("Platz:"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
						.insertafter("Tag:"+CHR(9)+TRANSFORM(IIF(DTOS(aaasss.datum)="29000101","Sumár",DTOC(aaasss.datum)))+CHR(13))
						.insertafter("Nummer:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
						IF  .NOT. EMPTY(llist5.pozn_ext)
							.insertafter("Note:"+CHR(9)+ALLTRIM(llist5.pozn_ext)+CHR(13))
						ENDIF
					OTHERWISE
						.insertafter(jaz("word_miesto")+":"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
						.insertafter(jaz("form datum")+":"+CHR(9)+TRANSFORM(IIF(DTOS(aaasss.datum)="29000101","Sumár",DTOC(aaasss.datum)))+CHR(13))
						.insertafter("Počet:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
						IF  .NOT. EMPTY(llist5.pozn_ext)
							.insertafter("Poznámka:"+CHR(9)+ALLTRIM(llist5.pozn_ext)+CHR(13))
						ENDIF
				ENDCASE
		ENDCASE
		.insertafter(CHR(13))
		.STYLE = oheaderstyle2
		.collapse(0)
	ENDWITH
	LOCAL m.lcdruh
	m.lcdruh = "QQQQQQQQQQQQQQQQQQQQQ"
	SELECT llist5
	SCAN FOR datum=m.datum .AND. chod=m.chod &&.AND. id_man=m.id_man
		IF  llist5.druhy<>m.lcdruh
			WITH orange
				IF  .NOT. llformatovat
					.insertafter(CHR(13))
				ENDIF
				.insertafter(ALLTRIM(llist5.druhy)+CHR(13))
				.STYLE = otitlestyle
				DO CASE
					CASE INLIST(lnvzortyp, 1)
						.BORDERS(-3).linestyle = 1
						.BORDERS(-3).linewidth = 4
					CASE INLIST(lnvzortyp, 2, 4, 5, 6)
					CASE INLIST(lnvzortyp, 0, 3)
						.BORDERS(-3).linestyle = 1
						.BORDERS(-3).linewidth = 4
				ENDCASE
				.collapse(0)
				.BORDERS(-3).linestyle = 0
			ENDWITH
			lcdruh=llist5.druhy
		ENDIF
		DO CASE
			CASE INLIST(lnvzortyp, 1)
				orange.insertafter(CHR(9)+IIF(!m.ajmnozstva,"",IIF(MTON(llist5.mnozstvi)=INT(MTON(llist5.mnozstvi)), STR(MTON(llist5.mnozstvi),7,0)+" x", STR(MTON(llist5.mnozstvi), 7, 2)))+CHR(9)+RTRIM(llist5.meno)+CHR(9)+IIF(m.ajceny,"á"+CHR(9)+ALLTRIM(STR(llist5.cena_prod,12,2))+CHR(9)+"="+CHR(9)+ALLTRIM(STR(llist5.cena_prod*llist5.mnozstvi,12,2)),"")+CHR(13))
			CASE INLIST(lnvzortyp, 2, 4, 5)
				orange.insertafter(RTRIM(llist5.meno)+CHR(9)+IIF(m.ajceny,"á"+CHR(9)+ALLTRIM(STR(llist5.cena_prod,12,2))+CHR(9)+""+CHR(9)+ALLTRIM(STR(llist5.cena_prod*llist5.mnozstvi,12,2)),"")+CHR(13))
			CASE INLIST(lnvzortyp, 0, 3)
				orange.insertafter(CHR(9)+IIF(!m.ajmnozstva,"",IIF(MTON(llist5.mnozstvi)=INT(MTON(llist5.mnozstvi)), STR(MTON(llist5.mnozstvi),7,0)+" x", STR(MTON(llist5.mnozstvi), 7, 2)))+CHR(9)+RTRIM(llist5.meno)+CHR(9)+IIF(m.ajceny,"á"+CHR(9)+ALLTRIM(STR(llist5.cena_prod,12,2))+CHR(9)+"="+CHR(9)+ALLTRIM(STR(llist5.cena_prod*llist5.mnozstvi,12,2)),"")+CHR(13))
			CASE INLIST(lnvzortyp, 6)
 				orange.insertafter(IIF(!m.ajmnozstva,"",IIF(MTON(llist5.mnozstvi)=INT(MTON(llist5.mnozstvi)), STR(MTON(llist5.mnozstvi),7,0)+" x ", STR(MTON(llist5.mnozstvi), 7, 2)+" x "))+RTRIM(llist5.meno)+CHR(9)+IIF(m.ajceny,"á"+CHR(9)+ALLTRIM(STR(llist5.cena_prod,12,2))+CHR(9)+"="+CHR(9)+ALLTRIM(STR(llist5.cena_prod*llist5.mnozstvi,12,2)),IIF(!m.ajpoznamky,"",IIF(EMPTY(llist5.poznamka),""," - "+ALLTRIM(llist5.poznamka))))+CHR(13))
		ENDCASE
		orange.STYLE = obodystyle
		orange.collapse(0)
	ENDSCAN
	SELECT aaasss
ENDSCAN
USE IN aaasss
WITH orange
	.insertafter(CHR(13))
	.STYLE = obodystyle
	.collapse(0)
	DO CASE
		CASE INLIST(lnvzortyp, 1)
			DO CASE
				CASE lcjazyk=='A'
					.insertafter("TOTAL"+CHR(13))
					.STYLE = ototalstyle
					.BORDERS(-3).linestyle = 1
					.BORDERS(-3).linewidth = 4
					.collapse(0)
					.BORDERS(-3).linestyle = 0
					.insertafter("Total F+B"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena0, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13)+CHR(13))
					IF lnprira<0
						.insertafter("Surcharge"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira>0
						.insertafter("Discount"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira<>0 
						.insertafter(CHR(13))
					ENDIF
					.insertafter("SALE PRICE"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena2, 0), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					.insertafter("Price incl. VAT"+CHR(13))
				CASE lcjazyk=='N'
					.insertafter("TOTAL"+CHR(13))
					.STYLE = ototalstyle
					.BORDERS(-3).linestyle = 1
					.BORDERS(-3).linewidth = 4
					.collapse(0)
					.BORDERS(-3).linestyle = 0
					.insertafter("Total F+B"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena0, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13)+CHR(13))
					IF lnprira<0
						.insertafter("Aufpreis"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira>0
						.insertafter("Preisermäßigung"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira<>0
						.insertafter(CHR(13))
					ENDIF
					.insertafter("TOTAL SUMME"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena2, 0), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					.insertafter("Preis mit MWSt."+CHR(13))
				OTHERWISE
					.insertafter(UPPER(jaz("rep_celkom"))+CHR(13))
					.STYLE = ototalstyle
					.BORDERS(-3).linestyle = 1
					.BORDERS(-3).linewidth = 4
					.collapse(0)
					.BORDERS(-3).linestyle = 0
					.insertafter(jaz("rep_celkom")+" F+B"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena0, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13)+CHR(13))
					IF lnprira<0
						.insertafter(jaz("word_prirazka")+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira>0
						.insertafter(jaz("word_poskytnuta_sleva")+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira<>0
						.insertafter(CHR(13))
					ENDIF
					.insertafter("Cena s DPH"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena2, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					IF !m.cenalimitu
						.insertafter("Cena bez DPH"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena3, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF 
			ENDCASE
		CASE INLIST(lnvzortyp, 2, 4, 5, 6)
			DO CASE
				CASE lcjazyk=='A'
					.STYLE = ototalstyle
					.insertafter("Total"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena0, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					IF lnprira<0
						.insertafter("Surcharge"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira>0
						.insertafter("Discount"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira<>0
						.insertafter(CHR(13))
					ENDIF
					.STYLE = ototalstyle2
					.insertafter("SALE PRICE"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena2, 0), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					.insertafter("Price incl. VAT"+CHR(13))
				CASE lcjazyk=='N'
					.STYLE = ototalstyle
					.insertafter("Total"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena0, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					IF lnprira<0
						.insertafter("Aufpreis"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira>0
						.insertafter("Preisermäßigung"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira<>0
						.insertafter(CHR(13))
					ENDIF
					.STYLE = ototalstyle2
					.insertafter("TOTAL SUMME"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena2, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					.insertafter("Preis mit MWSt."+CHR(13))
				OTHERWISE
					.STYLE = ototalstyle
					IF INLIST(lnprirb,"P","A")
						.insertafter(jaz("word_celkom_bez_zlavy")+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena0, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
						IF lnprira<0
							.insertafter(jaz("word_prirazka")+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
						ENDIF
						IF lnprira>0
							.insertafter(jaz("word_poskytnuta_sleva")+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
						ENDIF
						IF lnprira<>0
							.insertafter(CHR(13))
						ENDIF
					ENDIF 
					IF !m.cenalimitu
						.insertafter("Cena bez DPH"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena3, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF 
					.STYLE = ototalstyle2
					.insertafter("Cena s DPH"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena2, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
			ENDCASE
		CASE INLIST(lnvzortyp, 0, 3)
			DO CASE
				CASE lcjazyk=='A'
					.insertafter("Total"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena0, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13)+CHR(13))
					IF lnprira<0
						.insertafter("Surcharge"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira>0
						.insertafter("Discount"+CHR(9)+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira<>0 
						.insertafter(CHR(13))
					ENDIF
					.insertafter("SALE PRICE"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena2, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					.insertafter("Price incl. VAT"+CHR(13))
				CASE lcjazyk=='N'
					.insertafter("Total"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena0, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13)+CHR(13))
					IF lnprira<0
						.insertafter("Aufpreis"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira>0
						.insertafter("Preisermäßigung"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira<>0 
						.insertafter(CHR(13))
					ENDIF
					.insertafter("TOTAL SUMME"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena0-lnsl_p, 2), "999 999 999")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					.insertafter("Preis mit MWSt."+CHR(13))
				OTHERWISE
					IF INLIST(lnprirb,"P","A")
						.insertafter(jaz("word_celkom_bez_zlavy")+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena0, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13)+CHR(13))
						IF lnprira<0
							.insertafter(jaz("word_prirazka")+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
						ENDIF
						IF lnprira>0
							.insertafter(jaz("word_poskytnuta_sleva")+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist5.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
						ENDIF
						IF lnprira<>0 
							.insertafter(CHR(13))
						ENDIF
					ENDIF 
					IF !m.cenalimitu
						.insertafter("Cena bez DPH"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena3, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
					ENDIF 
					.insertafter("Cena s DPH"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena2, 2), "999 999 999.99")+" "+en__meny(llist5.c_mena,3)+CHR(13))
			ENDCASE
	ENDCASE
*	.STYLE = ototalstyle
	.collapse(0)
ENDWITH
IF m.lnvzortyp=6
	SET DATE TO (m.qsetdate)
ENDIF 
WITH orange
*	DO CASE
*		CASE INLIST(lnvzortyp, 1,6)
			IF  .NOT. EMPTY(lcpoznmem)
				.insertafter(CHR(13)+TRANSFORM(lcpoznmem)+CHR(13))
			ENDIF
*	ENDCASE
	.STYLE = obodystyle
	.collapse(0)
ENDWITH
odoc.SAVEAS(pcsoubor)
oword = .NULL.
RELEASE oword
SELECT (lnselect)
RETURN
ENDPROC
**
