LPARAMETERS pcalias, pcsoubor, pcvzordocplus,llformatovat,lcjazyk, ajceny, ajnakup
LOCAL lcvzordoc, lnvzortyp, lcpoznmem, lnselect
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")
oheaderstyle = odoc.styles.ADD("Limit_Hlavicka", 1)
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
	.basestyle = IIF(oword.LANGUAGE=1033,odoc.styles("Heading 1"),odoc.styles("Nadpis 1"))
	.FONT.NAME = "Times New Roman"
	.FONT.SIZE = 20
	.paragraphformat.spacebefore = 12
	TRY 
		.font.kerning=0
		.font.spacing=0
	CATCH 
	ENDTRY 	
	DO CASE
		CASE INLIST(lnvzortyp, 1)
			.paragraphformat.tabstops.ADD(314, 2)
			.paragraphformat.tabstops.ADD(540, 2)
			IF  .NOT. llformatovat
				.FONT.SIZE = 14
				.FONT.bold = .F.
			ELSE
				.FONT.SIZE = 20
				.FONT.bold = .T.
			ENDIF
		CASE INLIST(lnvzortyp, 2, 4, 5)
			IF  .NOT. llformatovat
				.FONT.SIZE = 20
				.FONT.bold = .T.
			ELSE
				.FONT.SIZE = 20
				.FONT.bold = .T.
			ENDIF
		CASE INLIST(lnvzortyp, 0, 3)
			.paragraphformat.tabstops.ADD(314, 2)
			.paragraphformat.tabstops.ADD(540, 2)
			IF  .NOT. llformatovat
				.FONT.SIZE = 14
				.FONT.bold = .F.
			ELSE
				.FONT.SIZE = 20
				.FONT.bold = .T.
			ENDIF
		CASE INLIST(lnvzortyp, 6)
			.FONT.NAME = "Calibri"
			TRY 
				.font.kerning=0
				.font.spacing=0
			CATCH 
			ENDTRY 	
			IF  .NOT. llformatovat
				.FONT.SIZE = 14
				.FONT.bold = .F.
			ELSE
				.FONT.SIZE = 20
				.FONT.bold = .T.
			ENDIF
	ENDCASE
ENDWITH
oheaderstyle2 = odoc.styles.ADD("Limit_Hlavicka2", 1)
WITH oheaderstyle2
	.basestyle = IIF(oword.LANGUAGE=1033,odoc.styles("Normal"),IIF(oword.LANGUAGE=1029,odoc.styles("Normální"),odoc.styles("Normálny")))
	.FONT.NAME = "Times New Roman"
	TRY 
		.font.kerning=0
		.font.spacing=0
	CATCH 
	ENDTRY 	
	DO CASE
		CASE INLIST(lnvzortyp, 1)
			IF  .NOT. llformatovat
				.FONT.SIZE = 14
				.FONT.bold = .F.
			ELSE
				.FONT.SIZE = 16
				.FONT.bold = .F.
			ENDIF
			.paragraphformat.tabstops.ADD(130, 0)
		CASE INLIST(lnvzortyp, 2, 4, 5)
			IF  .NOT. llformatovat
				.FONT.SIZE = 14
				.FONT.bold = .F.
			ELSE
				.FONT.SIZE = 14
				.FONT.bold = .T.
			ENDIF
		CASE INLIST(lnvzortyp, 0, 3)
			IF  .NOT. llformatovat
				.FONT.SIZE = 14
				.FONT.bold = .F.
			ELSE
				.FONT.SIZE = 16
				.FONT.bold = .F.
			ENDIF
			.paragraphformat.tabstops.ADD(130, 0)
		CASE INLIST(lnvzortyp, 6)
			.FONT.NAME = "Calibri"
			TRY 
				.font.kerning=0
				.font.spacing=0
			CATCH 
			ENDTRY 	
			IF  .NOT. llformatovat
				.FONT.SIZE = 14
				.FONT.bold = .F.
			ELSE
				.FONT.SIZE = 16
				.FONT.bold = .F.
			ENDIF
	ENDCASE
ENDWITH
otitlestyle = odoc.styles.ADD("Limit_Druhy", 1)
WITH otitlestyle
	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"
	TRY 
		.font.kerning=0
		.font.spacing=0
	CATCH 
	ENDTRY 	
	DO CASE
		CASE INLIST(lnvzortyp, 1)
			IF  .NOT. llformatovat
				.FONT.italic = .F.
				.FONT.bold = .F.
			ELSE
				.FONT.italic = .T.
				.FONT.bold = .T.
			ENDIF
		CASE INLIST(lnvzortyp, 2, 4, 5)
			.FONT.italic = .F.
			IF  .NOT. llformatovat
				.FONT.bold = .F.
			ELSE
				.FONT.bold = .T.
			ENDIF
		CASE INLIST(lnvzortyp, 0, 3)
			IF  .NOT. llformatovat
				.FONT.italic = .F.
				.FONT.bold = .F.
			ELSE
				.FONT.italic = .T.
				.FONT.bold = .T.
			ENDIF
		CASE INLIST(lnvzortyp, 6)
			.FONT.NAME = "Calibri"
			TRY 
				.font.kerning=0
				.font.spacing=0
			CATCH 
			ENDTRY 	
			IF  .NOT. llformatovat
				.FONT.italic = .F.
				.FONT.bold = .F.
			ELSE
				.FONT.italic = .T.
				.FONT.bold = .T.
			ENDIF
	ENDCASE
ENDWITH
obodystyle = odoc.styles.ADD("Limit_Polozky", 1)
WITH obodystyle
	.basestyle = IIF(oword.LANGUAGE=1033,odoc.styles("Normal"),IIF(oword.LANGUAGE=1029,odoc.styles("Normální"),odoc.styles("Normálny")))
	.FONT.SIZE = 14
	.FONT.NAME = "Times New Roman"
	TRY 
		.font.kerning=0
		.font.spacing=0
	CATCH 
	ENDTRY 	
	.FONT.bold = .F.
	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)
			.FONT.NAME = "Calibri"
			TRY 
				.font.kerning=0
				.font.spacing=0
			CATCH 
			ENDTRY 	
			.paragraphformat.tabstops.ADD(315, 2)
			.paragraphformat.tabstops.ADD(375, 2)
			.paragraphformat.tabstops.ADD(395, 2)
			.paragraphformat.tabstops.ADD(445, 2)
	ENDCASE
ENDWITH
ototalstyle = odoc.styles.ADD("Limit_Sucty_Bold", 1)
WITH ototalstyle
	.basestyle = IIF(oword.LANGUAGE=1033,odoc.styles("Normal"),IIF(oword.LANGUAGE=1029,odoc.styles("Normální"),odoc.styles("Normálny")))
	.FONT.NAME = "Times New Roman"
	TRY 
		.font.kerning=0
		.font.spacing=0
	CATCH 
	ENDTRY 	
	DO CASE
		CASE INLIST(lnvzortyp, 1)
			.FONT.SIZE = 14
			IF  .NOT. llformatovat
				.FONT.bold = .F.
			ELSE
				.FONT.bold = .T.
			ENDIF
			.paragraphformat.tabstops.ADD(209, 0)
			.paragraphformat.tabstops.ADD(472, 3)
			.paragraphformat.tabstops.ADD(495, 0)
		CASE INLIST(lnvzortyp, 2, 4, 5)
			.FONT.SIZE = 14
			IF  .NOT. llformatovat
				.FONT.bold = .F.
			ELSE
				.FONT.bold = .T.
			ENDIF
			.paragraphformat.tabstops.ADD(171, 0)
			.paragraphformat.tabstops.ADD(320, 2)
		CASE INLIST(lnvzortyp, 0, 3)
			IF  .NOT. llformatovat
				.FONT.bold = .F.
				.FONT.SIZE = 14
			ELSE
				.FONT.bold = .T.
				.FONT.SIZE = 16
			ENDIF
			.paragraphformat.tabstops.ADD(200, 0)
			.paragraphformat.tabstops.ADD(350, 2)
		CASE INLIST(lnvzortyp, 6)
			.FONT.NAME = "Calibri"
			TRY 
				.font.kerning=0
				.font.spacing=0
			CATCH 
			ENDTRY 	
			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)
	ENDCASE
ENDWITH
ototalstyle2 = odoc.styles.ADD("Limit_Sucty_BezBoldu", 1)
WITH ototalstyle2
	.basestyle = IIF(oword.LANGUAGE=1033,odoc.styles("Normal"),IIF(oword.LANGUAGE=1029,odoc.styles("Normální"),odoc.styles("Normálny")))
	.FONT.NAME = "Times New Roman"
	TRY 
		.font.kerning=0
		.font.spacing=0
	CATCH 
	ENDTRY 	
	DO CASE
		CASE INLIST(lnvzortyp, 1)
			.FONT.SIZE = 14
			IF  .NOT. llformatovat
				.FONT.bold = .F.
			ELSE
				.FONT.bold = .F.
			ENDIF
			.paragraphformat.tabstops.ADD(209, 0)
			.paragraphformat.tabstops.ADD(472, 3)
			.paragraphformat.tabstops.ADD(495, 0)
		CASE INLIST(lnvzortyp, 2, 4, 5)
			.FONT.SIZE = 14
			IF  .NOT. llformatovat
				.FONT.bold = .F.
			ELSE
				.FONT.bold = .F.
			ENDIF
			.paragraphformat.tabstops.ADD(171, 0)
			.paragraphformat.tabstops.ADD(320, 2)
		CASE INLIST(lnvzortyp, 0, 3)
			IF  .NOT. llformatovat
				.FONT.bold = .F.
				.FONT.SIZE = 14
			ELSE
				.FONT.bold = .F.
				.FONT.SIZE = 16
			ENDIF
			.paragraphformat.tabstops.ADD(200, 0)
			.paragraphformat.tabstops.ADD(350, 2)
		CASE INLIST(lnvzortyp, 6)
			.FONT.NAME = "Calibri"
			TRY 
				.font.kerning=0
				.font.spacing=0
			CATCH 
			ENDTRY 	
			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)
	ENDCASE
ENDWITH
SELECT llist
REPLACE dan WITH 1 FOR dan=0
SUM ALL cena TO m.lncena0
SUM ALL cena/dan TO m.lncena4
SELECT (pcalias)
GOTO TOP
lcpoznmem = limit_hl.pozn_host
lnprira = MTON(limit_hl.zlava)
lnprirb = limit_hl.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.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		
		
pozn1=IIF(EMPTY(limit_hl.txt1),limit_hl.limit,limit_hl.txt1)
pozn2=limit_hl.txt2
pozn4=0
rok=YEAR(llist.datum)
SELECT DISTINCT llist.id_limit, llist.limit, llist.datum, llist.rov, llist.limit1, llist.limit2, llist.limit3, llist.pocet1, llist.pocet2, llist.pocet3, limit_hl.text1, limit_hl.text2, limit_hl.text3 FROM llist LEFT JOIN limit_hl ON llist.id_limit=limit_hl.id_limit INTO CURSOR aaasss ORDER BY datum, rov, id_man
orange = odoc.RANGE()
SCAN ALL
	SCATTER MEMVAR FIELDS id_limit, limit, datum, rov
	DO CASE
		CASE aaasss.rov=1
			str_nazev=ALLTRIM(aaasss.text1)
			poc_osob=ROUND(MTON(aaasss.pocet1),0)
			pozn4=MTON(aaasss.limit1)
		CASE aaasss.rov=2
			str_nazev=ALLTRIM(aaasss.text2)
			poc_osob=ROUND(MTON(aaasss.pocet2),0)
			pozn4=MTON(aaasss.limit2)
		CASE aaasss.rov=3
			str_nazev=ALLTRIM(aaasss.text3)
			poc_osob=ROUND(MTON(aaasss.pocet3),0)
			pozn4=MTON(aaasss.limit3)
		OTHERWISE
			str_nazev=ALLTRIM(aaasss.text1)
			poc_osob=ROUND(MTON(aaasss.pocet1),0)
			pozn4=MTON(aaasss.limit1)
	ENDCASE
	WITH orange
		IF USED("strediska")
			USE IN strediska
		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)+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, 6)
				.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)+DTOC(m.datum)+CHR(13))
				.collapse(0)
		ENDCASE
		DO CASE
			CASE INLIST(lnvzortyp, 1)
				DO CASE
					CASE lcjazyk=='A'
						.insertafter("Place:"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
						.insertafter("Date:"+CHR(9)+TRANSFORM(aaasss.datum)+CHR(13))
						.insertafter("Number:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
						IF  .NOT. EMPTY(pozn4)
							.insertafter("Limit:"+CHR(9)+ALLTRIM(TRANSFORM(pozn4))+CHR(13))
						ENDIF
					CASE lcjazyk=='N'
						.insertafter("Platz:"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
						.insertafter("Tag:"+CHR(9)+TRANSFORM(aaasss.datum)+CHR(13))
						.insertafter("Nummer:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
						IF  .NOT. EMPTY(pozn4)
							.insertafter("Limit:"+CHR(9)+ALLTRIM(TRANSFORM(pozn4))+CHR(13))
						ENDIF
					OTHERWISE
						.insertafter(jaz("word_miesto")+":"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
						.insertafter(jaz("form datum")+":"+CHR(9)+DTOC(m.datum)+CHR(13))
						.insertafter("Počet:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
						IF  .NOT. EMPTY(pozn4)
							.insertafter("Limit:"+CHR(9)+ALLTRIM(TRANSFORM(pozn4))+CHR(13))
						ENDIF
				ENDCASE
			CASE INLIST(lnvzortyp, 2, 4, 5, 6)
				DO CASE
					CASE lcjazyk=='A'
						.insertafter(TRANSFORM(aaasss.datum)+CHR(13))
						.insertafter(TRANSFORM(poc_osob)+"  person"+CHR(13))
					CASE lcjazyk=='N'
						.insertafter(TRANSFORM(aaasss.datum)+CHR(13))
						.insertafter(TRANSFORM(poc_osob)+"  personenzahl"+CHR(13))
					OTHERWISE
						.insertafter(TRANSFORM(aaasss.datum)+CHR(13))
						IF m.slovenskaverzia
							.insertafter(TRANSFORM(poc_osob)+"  osôb"+CHR(13))
						ELSE
							.insertafter(TRANSFORM(poc_osob)+"  osob"+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(aaasss.datum)+CHR(13))
						.insertafter("Number:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
					CASE lcjazyk=='N'
						.insertafter("Platz:"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
						.insertafter("Tag:"+CHR(9)+TRANSFORM(aaasss.datum)+CHR(13))
						.insertafter("Nummer:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
					OTHERWISE
						.insertafter(jaz("word_miesto")+":"+CHR(9)+ALLTRIM(pozn2)+CHR(13))
						.insertafter(jaz("form datum")+":"+CHR(9)+TRANSFORM(aaasss.datum)+CHR(13))
						.insertafter("Počet:"+CHR(9)+TRANSFORM(poc_osob)+CHR(13))
				ENDCASE
		ENDCASE
		.insertafter(CHR(13))
		.STYLE = oheaderstyle2
		.collapse(0)
	ENDWITH
	LOCAL m.lcdruh
	m.lcdruh = "QQQQQQQQQQQQQQQQQQQQQ"
	SELECT llist
	SCAN FOR id_limit=m.id_limit .AND. datum=m.datum .AND. rov=m.rov &&.AND. id_man=m.id_man
		IF  llist.druh<>m.lcdruh
			WITH orange
				IF  .NOT. llformatovat
					.insertafter(CHR(13))
				ENDIF
				.insertafter(ALLTRIM(llist.druh)+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=llist.druh
		ENDIF
		DO CASE
			CASE INLIST(lnvzortyp, 1)
				orange.insertafter(CHR(9)+IIF(MTON(llist.mnozstvi)=INT(MTON(llist.mnozstvi)), TRANSFORM(MTON(llist.mnozstvi))+" x", STR(MTON(llist.mnozstvi), 7, 2))+CHR(9)+RTRIM(meno)+CHR(9)+IIF(m.ajceny,"á"+CHR(9)+ALLTRIM(STR(llist.pc/llist.mnozstvi,12,2))+CHR(9)+"="+CHR(9)+ALLTRIM(STR(llist.pc,12,2)),"")+CHR(13))
			CASE INLIST(lnvzortyp, 2, 4, 5, 6)
				orange.insertafter(RTRIM(meno)+CHR(9)+IIF(m.ajceny,"á"+CHR(9)+ALLTRIM(STR(llist.pc/llist.mnozstvi,12,2))+CHR(9)+""+CHR(9)+ALLTRIM(STR(llist.pc,12,2)),"")+CHR(13))
			CASE INLIST(lnvzortyp, 0, 3)
				orange.insertafter(CHR(9)+IIF(MTON(llist.mnozstvi)=INT(MTON(llist.mnozstvi)), TRANSFORM(MTON(llist.mnozstvi))+" x", STR(MTON(llist.mnozstvi), 7, 2))+CHR(9)+RTRIM(meno)+CHR(9)+IIF(m.ajceny,"á"+CHR(9)+ALLTRIM(STR(llist.pc/llist.mnozstvi,12,2))+CHR(9)+"="+CHR(9)+ALLTRIM(STR(llist.pc,12,2)),"")+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(llist.c_mena,3)+CHR(13)+CHR(13))
					IF lnprira<0
						.insertafter("Surcharge"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira>0
						.insertafter("Discount"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.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(llist.c_mena,3)+CHR(13)+CHR(13))
					IF lnprira<0
						.insertafter("Aufpreis"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira>0
						.insertafter("Preisermäßigung"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.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(llist.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(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.c_mena,3)+CHR(13))
					.insertafter("Cena bez DPH"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena3, 2), "999 999 999.99")+" "+en__meny(llist.c_mena,3)+CHR(13))
			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(llist.c_mena,3)+CHR(13))
					IF lnprira<0
						.insertafter("Surcharge"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira>0
						.insertafter("Discount"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.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(llist.c_mena,3)+CHR(13))
					IF lnprira<0
						.insertafter("Aufpreis"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira>0
						.insertafter("Preisermäßigung"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.c_mena,3)+CHR(13))
					.insertafter("Preis mit MWSt."+CHR(13))
				OTHERWISE
					.STYLE = ototalstyle
					.insertafter(jaz("word_celkom_bez_zlavy")+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena0, 2), "999 999 999.99")+" "+en__meny(llist.c_mena,3)+CHR(13))
					IF lnprira<0
						.insertafter(jaz("word_prirazka")+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira<>0
						.insertafter(CHR(13))
					ENDIF
					.insertafter("Cena bez DPH"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena3, 2), "999 999 999.99")+" "+en__meny(llist.c_mena,3)+CHR(13))
					.STYLE = ototalstyle2
					.insertafter("Cena s DPH"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena2, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.c_mena,3)+CHR(13)+CHR(13))
					IF lnprira<0
						.insertafter("Surcharge"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.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(llist.c_mena,3)+CHR(13)+CHR(13))
					IF lnprira<0
						.insertafter("Aufpreis"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira>0
						.insertafter("Preisermäßigung"+CHR(9)+IIF(lnprirb="P", TRANSFORM(lnprira)+" %",TRANSFORM(lnsl_p)+" "+en__meny(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.c_mena,3)+CHR(13))
					.insertafter("Preis mit MWSt."+CHR(13))
				OTHERWISE
					.insertafter(jaz("word_celkom_bez_zlavy")+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena0, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.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(llist.c_mena,3))+CHR(9)+TRANSFORM(ROUND(lnsl_p, 2), "999 999 999.99")+" "+en__meny(llist.c_mena,3)+CHR(13))
					ENDIF
					IF lnprira<>0 
						.insertafter(CHR(13))
					ENDIF
					.insertafter("Cena bez DPH"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena3, 2), "999 999 999.99")+" "+en__meny(llist.c_mena,3)+CHR(13))
					.insertafter("Cena s DPH"+CHR(9)+CHR(9)+TRANSFORM(ROUND(lncena2, 2), "999 999 999.99")+" "+en__meny(llist.c_mena,3)+CHR(13))
			ENDCASE
	ENDCASE
*	.STYLE = ototalstyle
	.collapse(0)
ENDWITH
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
**
