*FUNCTION otvor_navision_intdokl
PARAMETERS menofirmy, menoalias, podmienka
PRIVATE lsql, m.curschema, m.updfieldlist, m.vysledok, m.menotabulky, m.updschema, m.keyschema
lsql = 'SELECT internaldocuments.timestamp as tmsmp,'
lsql=lsql+'internaldocuments.RecordNo as rno,'
lsql=lsql+'internaldocuments.RecordType as rtyp,'
lsql=lsql+'internaldocuments.RecordState as rstat,'
lsql=lsql+'internaldocuments.JournalBatchName as batchname,'
lsql=lsql+'internaldocuments.Line_No,'
lsql=lsql+'internaldocuments.AccountNo as ucet1,'
lsql=lsql+'internaldocuments.PostingDate as postdate,'
lsql=lsql+'internaldocuments.DocumentNo as docno,'
lsql=lsql+'internaldocuments.Description as descript,'
lsql=lsql+'internaldocuments.VATPercent as dph,'
lsql=lsql+'internaldocuments.BalAccountNo as ucet2,'
lsql=lsql+'internaldocuments.AmountLCY as suma,'
lsql=lsql+'internaldocuments.GlobalDimension1Code as gdc1,'
lsql=lsql+'internaldocuments.GlobalDimension2Code as gdc2,'
lsql=lsql+'internaldocuments.VATAmount as cena_dph,'
lsql=lsql+'internaldocuments.JournalTemplateName as jname,'
lsql=lsql+'internaldocuments.CurrentState as curstat,'
lsql=lsql+'internaldocuments.HotelBillNumber as u_cis,'
lsql=lsql+'internaldocuments.ReservationNo as u_cis'
lsql=lsql+' FROM '
lsql=lsql+m.navision_databaza+'.dbo."'+menofirmy+'$COMInternalDocuments" internaldocuments'
IF !EMPTY(m.podmienka)
    lsql=lsql+' WHERE '+m.podmienka
ENDIF 

m.curschema='tmsmp m, rno i, rtyp C(2), rstat c(1), batchname c(20), line_no i, ucet1 C(20), postdate T, docno c(20), descript c(50), dph N(20,4), ucet2 c(20),'
m.curschema=m.curschema+' suma N(20,4), gdc1 c(20), gdc2 c(20), cena_dph N(20,4), jname c(10), curstat L, u_cis C(20), rezno C(20)'

m.updschema='rno '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[RecordNo],'
m.updschema=m.updschema+'tmsmp '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[timestamp],'
m.updschema=m.updschema+'rtyp '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[RecordType],'
m.updschema=m.updschema+'rstat '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[RecordState],'
m.updschema=m.updschema+'batchname '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[JournalBatchName],'
m.updschema=m.updschema+'line_no '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[Line_No],'
m.updschema=m.updschema+'ucet1 '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[AccountNo],'
m.updschema=m.updschema+'postdate '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[PostingDate],'
m.updschema=m.updschema+'docno '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[DocumentNo],'
m.updschema=m.updschema+'descript '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[Description],'
m.updschema=m.updschema+'dph '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[VATPercent],'
m.updschema=m.updschema+'ucet2 '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[BalAccountNo],'
m.updschema=m.updschema+'suma '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[AmountLCY],'
m.updschema=m.updschema+'gdc1 '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[GlobalDimension1Code],'
m.updschema=m.updschema+'gdc2 '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[GlobalDimension2Code],'
m.updschema=m.updschema+'cena_dph '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[VATAmount],'
m.updschema=m.updschema+'jname '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[JournalTemplateName],'
m.updschema=m.updschema+'curstat '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[CurrentState],'
m.updschema=m.updschema+'u_cis '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[HotelBillNumber],'
m.updschema=m.updschema+'rezno '+m.navision_databaza+'.dbo."'+m.menofirmy+'$COMInternalDocuments".[ReservationNo]'

m.updfieldlist="tmsmp, rno, rtyp, rstat, batchname, line_no, ucet1, postdate, docno, descript, dph, ucet2, suma, gdc1, gdc2, cena_dph, jname, curstat, u_cis, rezno"

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

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