<% =SYS(3101,1252) set hours to 24 set century on ajaxresponse=CREATEOBJECT('empty') oJSON=NEWOBJECT('json','json.fxp') fref=ALLTRIM(TRANSFORM(NVL(orequest.form('txtreffid'),''))) theaction=orequest.form('taction') thevoucher=orequest.form('vouchertype') *********************Operation if theaction='getaccountbalance' theaccount=transform(orequest.form('theaccount')) if between(left(theaccount,2),[01],[08]) tsql=[select sum(debit-credit) as balance from ("]+dbclocation+[acctran") where accountid=']+theaccount+[' into cursor xtemp ] &tsql tbalance=nvl(balance,0.00) do CASE case tbalance>0 return [DB +]+allt(transform(tbalance,'9999999999999.99')) case tbalance<0 return [CR ]+allt(transform(tbalance,'9999999999999.99')) other return [] endcase else return [] endif endif IF thevoucher='Invoice' set procedure to (addbs(oprop.appstartpath)+'prg\navigate_transaction.fxp') additive navigate_invoice() ENDIF *End of operation *completed code if thevoucher='CashSale' set procedure to (addbs(oprop.appstartpath)+'prg\navigate_transaction.fxp') additive temptext=navigate_cashsale() * return temptext endif if thevoucher=[CashBill] set procedure to (addbs(oprop.appstartpath)+'prg\navigate_transaction.fxp') additive =navigate_cashbill() endif if thevoucher='Bill' set procedure to (addbs(oprop.appstartpath)+'prg\navigate_transaction.fxp') additive =navigate_bill() endif if thevoucher='PrintToPos' set procedure to (addbs(oprop.appstartpath)+'prg\print_transaction.fxp') additive =print_cashsale() endif ****************************** if thevoucher='Receipt' set procedure to (addbs(oprop.appstartpath)+'prg\navigate_transaction.fxp') additive =navigate_receipt() endif **** if thevoucher='Payment' set procedure to (addbs(oprop.appstartpath)+'prg\navigate_transaction.fxp') additive =navigate_payment() endif if thevoucher='Transfer' set procedure to (addbs(oprop.appstartpath)+'prg\navigate_transaction.fxp') additive =navigate_transfer() endif if thevoucher="Journal" *set procedure to (addbs(oprop.appstartpath)+'prg\navigate_transaction.fxp') additive *=navigate_journal() fref=upper(ALLTRIM(TRANSFORM(NVL(orequest.form('txtreffid'),'')))) pref=padl(ALLTRIM(TRANSFORM(fref)),9) ptransid=pref theaction=upper(allt(orequest.form('taction'))) fcounter=ALLTRIM(TRANSFORM(NVL(orequest.form('counterref'),''))) ******************************************* *ajaxresponse=CREATEOBJECT('empty') ADDPROPERTY(ajaxresponse,'theaction',theaction) theresponse=[] if inlist(theaction,[TOP],[BACK],[NEXT],[NUM],[BOTT]) if theaction="BACK" vtr='' do case case len(fref)=0 case len(fref)=1 and empty(val(fref)) VTR=[ HAVING PTRANSID<']+PTRANSID+[' ] case val(fref)<>0 vtr=allt(transform(val(fref))) VTR=[ HAVING vtr<]+allt(transform(val(fref))) otherwise for tcntr=2 to len(fref) if val(subst(fref,tcntr-1))=0 and val(subst(fref,tcntr))<>0 vtr=allt(transform(val(subst(fref,tcntr)))) cPref=left(fref,tcntr-1) VTR=[ HAVING vtr<=]+allt(transform(val(subst(fref,tcntr))))+[ and ptransid<']+pref+[' ] exit endif endfor endcase ENDIF if theaction="NEXT" vtr='' do case case len(fref)=0 case len(fref)=1 and empty(val(fref)) VTR=[ HAVING PTRANSID<']+PTRANSID+[' ] case val(fref)<>0 vtr=allt(transform(val(fref))) VTR=[ HAVING vtr>=]+allt(transform(val(fref)))+[ and ptransid>']+pref+['] otherwise for tcntr=2 to len(pref) if val(subst(pref,tcntr-1))=0 and val(subst(pref,tcntr))<>0 vtr=allt(transform(val(subst(pref,tcntr)))) cPref=left(pref,tcntr-1) VTR=[ HAVING vtr>=]+allt(transform(val(subst(pref,tcntr))))+; [ and (left(ptransid,]+transform(tcntr-1)+[))>']+cpref+[' or vtr>]+allt(transform(val(subst(pref,tcntr)))) exit endif endfor endcase ENDIF tsql=[select top 1 transid,IIF(VAL(transid)=0,VAL(SUBSTR(transid,2)),VAL(transid)) AS VTR, padl(allt(transid),9) as ptransid ] tsql=tsql+[ from ("]+dbclocation+'Journal.dbf'+[") ] do case case theaction='TOP' or (theaction='PREV' and empty(fref)) tsql=tsql+[ order by vtr, ptransid ] case theaction='BOT' or (theaction='NEXT' and empty(fref)) tsql=tsql+[ order by vtr desc, ptransid desc ] CASE theaction='BACK' tsql=tsql+[ order by vtr desc, ptransid desc ] tsql=tsql+vtr CASE theaction='NEXT' tsql=tsql+[ order by vtr, ptransid ] tsql=tsql+vtr CASE THEACTION='NUM' tsql=tsql+[ having ptransid=']+pref+[' order by ptransid ] ENDCASE tsql=tsql+[ into cursor gotrecords ] &tsql if _tally=0 theresponse=[{"transid":"","cmessage":"Record not found!","cerror":"","sql":"error in sql"}] else theresponse=[{"transid":"]+transid+[","cmessage":"Record found!","cerror":"","sql":""}] endif ENDIF ADDPROPERTY(ajaxresponse,'nav',ALLTRIM(transid)) if _tally>0 thetransid=transid oJSON=NEWOBJECT('json','json.fxp') the_data_file=dbclocation+[jdata.dbf] the_ac_file=dbclocation+[accounts.dbf] tsql=[select x.sr_no, x.accountid, y.name, x.desc , x.debit, x.credit from ("]+the_data_file+[") x left join ("]+the_ac_file+[") y ] tsql=tsql+[ on (x.accountid=y.accountid) where x.transid="]+thetransid+[" order by x.sr_no into cursor childData readwrite ] haserror=.f. try &tsql scan replace name with nvl(name,'name removed') endscan catch haserror=.t. ADDPROPERTY(ajaxresponse,'sqlerror',tsql) endtry if haserror oresponse.write(tsql) *return '' endif *=changeFieldStruc() mastertablefile=addbs(oprop.appstartpath)+[temp\]+sys(3)+[.dbf] tsql=[select * from ("]+dbclocation+'Journal.dbf'+[") where transid=']+thetransid+[' into table ']+mastertablefile+[' ] &tsql masteralias=alias() ADDPROPERTY(ajaxresponse,'masterrecs',RECCOUNT(masteralias)) ADDPROPERTY(ajaxresponse,'masteralias',masteralias) ADDPROPERTY(ajaxresponse,'childrecs',RECCOUNT('childData')) oResponse.ContentType = "text/plain" select [childdata] ojson.keyforcursors='childData' theChild=oJSON.stringify('childData') select (masteralias) ojson.keyforcursors='&masteralias' theMaster=oJSON.stringify('&masteralias') galias=strextract(themaster,[{"],[":{]) theMaster=strtran(themaster,galias,'SearchResults') if RECCOUNT('childData')>0 returnstring=oJSON.AddJSONProps(theMaster,theChild) else returnstring=theMaster endif returnstring=oJSON.AddJSONProps(theresponse,returnstring) *strtofile(oJSON.addjsonprops(ojson.stringify(ajaxresponse),returnstring),addbs(oprop.appstartpath)+'temp\temp.json') oResponse.Write(oJSON.addjsonprops(ojson.stringify(ajaxresponse),returnstring)) else ADDPROPERTY(ajaxresponse,'masterrecs',0) ADDPROPERTY(ajaxresponse,'masteralias','') ADDPROPERTY(ajaxresponse,'childrecs',0) *strtofile(oJSON.addjsonprops(ojson.stringify(ajaxresponse),theresponse),addbs(oprop.appstartpath)+'temp\temp.json') oResponse.Write(oJSON.addjsonprops(ojson.stringify(ajaxresponse),theresponse)) endif return '' endif **** oresponse.flush CLOSE TABLES CLOSE DATABASES %>