*FUNCTION otvor_navision_polozky
PARAMETERS menofirmy, menoalias, podmienka
PRIVATE lsql, m.curschema, m.updfieldlist, m.vysledok, m.menotabulky, m.updschema, m.keyschema
lsql = 'SELECT documentline.timestamp as tmsmp,'
lsql=lsql+'documentline.RecordNo as rno,'
lsql=lsql+'documentline.RecordType as rtyp,'
lsql=lsql+'documentline.RecordState as rstat,'
lsql=lsql+'documentline.RecordNoHeader as rno_head,'
lsql=lsql+'documentline.DocumentNo as docno,'
lsql=lsql+'documentline.Line_No, documentline.No,'
lsql=lsql+'documentline.Description as descript,'
lsql=lsql+'documentline.UnitofMeasureCode as mj,'
lsql=lsql+'documentline.Quantity as mnozstvo,'
lsql=lsql+'documentline.UnitPrice as jed_cena,'
lsql=lsql+'documentline.VATpercent as dph,'
lsql=lsql+'documentline.AmountIncludingVAT as sdph,'
lsql=lsql+'documentline.GlobalDimension1Code as gdc1,'
lsql=lsql+'documentline.GlobalDimension2Code as gdc2,'
lsql=lsql+'documentline.VATAmount as vatsuma'
lsql=lsql+' FROM '
lsql=lsql+m.navision_databaza+'.dbo."'+menofirmy+'$COMDocumentLine" documentline'
IF !EMPTY(m.podmienka)
    lsql=lsql+' WHERE '+m.podmienka
ENDIF 

m.curschema='tmsmp m, rno i, rtyp C(2), rstat c(1), rno_head i, docno c(20), line_no i, no C(20), descript c(50), mj c(10), mnozstvo N(20,4), jed_cena N(20,4), dph N(20,4), sdph N(20,4), gdc1 c(20), gdc2 c(20), vatsuma Y'

m.updschema='rno '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[RecordNo],'
m.updschema=m.updschema+'tmsmp '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[timestamp],'
m.updschema=m.updschema+'rtyp '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[RecordType],'
m.updschema=m.updschema+'rstat '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[RecordState],'
m.updschema=m.updschema+'rno_head '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[RecordNoHeader],'
m.updschema=m.updschema+'docno '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[DocumentNo],'
m.updschema=m.updschema+'line_no '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[Line_No],'
m.updschema=m.updschema+'no '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[No],'
m.updschema=m.updschema+'descript '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[Description],'
m.updschema=m.updschema+'mj '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[UnitofMeasureCode],'
m.updschema=m.updschema+'mnozstvo '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[Quantity],'
m.updschema=m.updschema+'jed_cena '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[UnitPrice],'
m.updschema=m.updschema+'dph '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[VATpercent],'
m.updschema=m.updschema+'sdph '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[AmountIncludingVAT],'
m.updschema=m.updschema+'gdc1 '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[GlobalDimension1Code],'
m.updschema=m.updschema+'gdc2 '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[GlobalDimension2Code],'
m.updschema=m.updschema+'vatsuma '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMDocumentLine".[VATAmount]'

m.updfieldlist="tmsmp, rno, rtyp, rstat, rno_head, docno, line_no, no, descript, mj, mnozstvo, jed_cena, dph, sdph, gdc1, gdc2, vatsuma"

m.tabschema=m.navision_databaza+".dbo."+CHR(34)+menofirmy+"$COMDocumentLine"+CHR(34)

m.keyschema="rno"
RETURN nav_vytvor_cursor("navision_pol",m.menoalias, m.tabschema, m.lsql, m.updfieldlist, m.updschema, m.keyschema, m.curschema)
