<% set date ymd set century on set hours to 24 set mark to [-] expires=-1 ajaxresponse=CREATEOBJECT('empty') oJSON=NEWOBJECT('json','json.fxp') respmsg=transform(lineno())+[ started. ] m_transid=UPPER(ALLTRIM(NVL(orequest.form('m_transid'),''))) m_discount=UPPER(ALLTRIM(NVL(orequest.form('m_discount'),''))) m_desc=UPPER(ALLTRIM(NVL(orequest.form('m_desc'),''))) m_customer=UPPER(ALLTRIM(TRANSFORM(orequest.form('m_customer')))) m_customername=UPPER(ALLTRIM(TRANSFORM(orequest.form('m_customername')))) m_depositid=UPPER(ALLTRIM(TRANSFORM(orequest.form('m_depositid')))) m_depositname=UPPER(ALLTRIM(orequest.form('m_depositname'))) m_checkno=UPPER(ALLTRIM(transform(orequest.form('m_checkno')))) m_chkdate=orequest.form('m_chkdate') m_date=orequest.form('m_date') m_amount=val(transform(orequest.form('m_amount'),'999999999999.99')) m_discount=val(transform(orequest.form('m_discount'),'999999999999.99')) m_name =UPPER(ALLTRIM(orequest.form('m_name'))) isadding=orequest.form('isadding') errormessage=[] IF m_customer==m_customername && Add new vendor USEsafe([accounts]) FOR i=1 TO 9999 newvendor=[05]+PADL(ALLTRIM(TRANSFORM(i)),4,[0]) IF NOT SEEK(newvendor,[accounts],[accountid]) APPEND BLANK replace accountid WITH newvendor, name WITH m_customername exit endif endfor endif IF m_depositid==m_depositname && Add new vendor USEsafe([accounts]) FOR i=1 TO 9999 newdeposit=[01]+PADL(ALLTRIM(TRANSFORM(i)),4,[0]) IF NOT SEEK(newdeposit,[accounts],[accountid]) APPEND BLANK replace accountid WITH newdeposit, name WITH m_depositname exit endif endfor ENDIF usesafe([Payment]) if isadding='yes' if allt(m_transid)=='AUTO' m_transid=padr(allt(m_transid),len(transid)) 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+'payment.dbf'+[") order by vtr desc, ptransid desc into cursor xcursor] &tsql m_transid=ptransid ncntr=vtr SELECT [Payment] DO WHILE .t. m_transid=PADR(ALLTRIM(TRANSFORM(ncntr)),9,[ ]) =SEEK(m_transid,[Payment],[transid]) IF EOF([Payment]) EXIT ENDIF ncntr=ncntr+1 ENDDO APPEND blank else m_transid=padr(allt(m_transid),len(transid)) =SEEK(m_transid,[Payment],[transid]) if eof() APPEND blank else 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+'payment.dbf'+[") order by vtr desc, ptransid desc into cursor xcursor] &tsql m_transid=ptransid ncntr=vtr SELECT [Payment] DO WHILE .t. m_transid=PADR(ALLTRIM(TRANSFORM(ncntr)),9,[ ]) =SEEK(m_transid,[Payment],[transid]) IF EOF([Payment]) EXIT ENDIF ncntr=ncntr+1 ENDDO APPEND blank endif endif replace dtime WITH DATETIME(),transid WITH m_transid endif m_transid=PADR(ALLTRIM(TRANSFORM(m_transid)),9,[ ]) newnum=m_transid =SEEK(m_transid,[Payment],[transid]) ADDPROPERTY(ajaxresponse,'isadding',orequest.form('isadding')) ADDPROPERTY(ajaxresponse,'m_transid',m_transid) ADDPROPERTY(ajaxresponse,'m_customer',m_customer) ADDPROPERTY(ajaxresponse,'m_customername',m_customername) ADDPROPERTY(ajaxresponse,'m_depositid',m_depositid) ADDPROPERTY(ajaxresponse,'m_depositname',m_depositname) ADDPROPERTY(ajaxresponse,'m_date',m_date) ADDPROPERTY(ajaxresponse,'m_amount',m_amount) ADDPROPERTY(ajaxresponse,'m_name',m_name) replace date WITH CTOD(m_date), modified WITH DATETIME(), customer WITH m_customer,; depositid WITH m_depositid,; amount with m_amount, name with m_name,; checkno with transform(m_checkno),; chkdate with ctod(m_chkdate),; desc with m_desc,; discount with m_discount SET DATE BRITISH headertext=[] for i=1 to fcount() headertext=headertext+field(i)+[ ] endfor ADDPROPERTY(ajaxresponse,'cols',headerText) ADDPROPERTY(ajaxresponse,'tmessage',errormessage+respmsg) ********************************************* updatetransactions([Receipt], m_transid) thebackuploc=bk1loc IF NOT EMPTY(thebackuploc) USE (thebackuploc+[Payment]) IN SELECT([PaymentBK]) ALIAS [PaymentBK] AGAIN USE (thebackuploc+[acctran]) IN SELECT([acctranbk]) ALIAS [acctranbk] AGAIN SELECT [Paymentbk] SET ORDER TO transid =SEEK(newnum) DELETE while transid=newnum SELECT [Payment] SET ORDER TO transid =SEEK(newnum) DO WHILE NOT EOF() AND transid=newnum SCATTER NAME dtbk SELECT [Paymentbk] APPEND BLANK GATHER name dtbk SELECT [Payment] skip ENDDO USE IN SELECT([Paymentbk]) SELECT [acctranbk] SET ORDER TO transid =SEEK(newnum+[Receipt]) DELETE while transid=newnum AND vtype=[Receipt] SELECT [acctran] SET ORDER TO transid =SEEK(newnum+[Receipt]) DO WHILE NOT EOF() AND transid=newnum AND vtype=[Receipt] SCATTER NAME dtbk SELECT [acctranbk] APPEND BLANK gather name dtbk SELECT [acctran] skip ENDDO USE IN SELECT([acctranbk]) endif thebackuploc=bk2loc IF NOT EMPTY(thebackuploc) USE (thebackuploc+[Payment]) IN SELECT([PaymentBK]) ALIAS [PaymentBK] AGAIN USE (thebackuploc+[acctran]) IN SELECT([acctranbk]) ALIAS [acctranbk] AGAIN SELECT [Paymentbk] SET ORDER TO transid =SEEK(newnum) DELETE while transid=newnum SELECT [Payment] SET ORDER TO transid =SEEK(newnum) DO WHILE NOT EOF() AND transid=newnum SCATTER NAME dtbk SELECT [Paymentbk] APPEND BLANK GATHER name dtbk SELECT [Payment] skip ENDDO USE IN SELECT([Paymentbk]) SELECT [acctranbk] SET ORDER TO transid =SEEK(newnum+[Receipt]) DELETE while transid=newnum AND vtype=[Receipt] SELECT [acctran] SET ORDER TO transid =SEEK(newnum+[Receipt]) DO WHILE NOT EOF() AND transid=newnum AND vtype=[Receipt] SCATTER NAME dtbk SELECT [acctranbk] APPEND BLANK gather name dtbk SELECT [acctran] skip ENDDO USE IN SELECT([acctranbk]) endif TheResponse=[TRANSID:]+PADR(ALLTRIM(TRANSFORM(NewNum)),9,[ ]) ********************************************* ADDPROPERTY(ajaxresponse,'updateresponse',theresponse) oresponse.write(ojson.stringify(ajaxresponse)) oresponse.flush() %>