<% 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_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=orequest.form('m_discount') 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([Transfer]) 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+'Transfer.dbf'+[") order by vtr desc, ptransid desc into cursor xcursor] &tsql m_transid=ptransid ncntr=vtr SELECT [Transfer] DO WHILE .t. m_transid=PADR(ALLTRIM(TRANSFORM(ncntr)),9,[ ]) =SEEK(m_transid,[Transfer],[transid]) IF EOF([Transfer]) EXIT ENDIF ncntr=ncntr+1 ENDDO APPEND blank else m_transid=padr(allt(m_transid),len(transid)) =SEEK(m_transid,[Transfer],[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+'Transfer.dbf'+[") order by vtr desc, ptransid desc into cursor xcursor] &tsql m_transid=ptransid ncntr=vtr SELECT [Transfer] DO WHILE .t. m_transid=PADR(ALLTRIM(TRANSFORM(ncntr)),9,[ ]) =SEEK(m_transid,[Transfer],[transid]) IF EOF([Transfer]) 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,[Transfer],[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(), creditor WITH m_customer,; debitor WITH m_depositid,; amount with m_amount,; memo with m_desc SET DATE BRITISH headertext=[] for i=1 to fcount() headertext=headertext+field(i)+[ ] endfor ADDPROPERTY(ajaxresponse,'cols',headerText) ADDPROPERTY(ajaxresponse,'tmessage',errormessage+respmsg) ********************************************* updatetransactions([Transfer], m_transid) thebackuploc=bk1loc IF NOT EMPTY(thebackuploc) USE (thebackuploc+[Transfer]) IN SELECT([TransferBK]) ALIAS [TransferBK] AGAIN USE (thebackuploc+[acctran]) IN SELECT([acctranbk]) ALIAS [acctranbk] AGAIN SELECT [Transferbk] SET ORDER TO transid =SEEK(newnum) DELETE while transid=newnum SELECT [Transfer] SET ORDER TO transid =SEEK(newnum) DO WHILE NOT EOF() AND transid=newnum SCATTER NAME dtbk SELECT [Transferbk] APPEND BLANK GATHER name dtbk SELECT [Transfer] skip ENDDO USE IN SELECT([Transferbk]) SELECT [acctranbk] SET ORDER TO transid =SEEK(newnum+[Transfer]) DELETE while transid=newnum AND vtype=[Transfer] SELECT [acctran] SET ORDER TO transid =SEEK(newnum+[Transfer]) DO WHILE NOT EOF() AND transid=newnum AND vtype=[Transfer] 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+[Transfer]) IN SELECT([TransferBK]) ALIAS [TransferBK] AGAIN USE (thebackuploc+[acctran]) IN SELECT([acctranbk]) ALIAS [acctranbk] AGAIN SELECT [Transferbk] SET ORDER TO transid =SEEK(newnum) DELETE while transid=newnum SELECT [Transfer] SET ORDER TO transid =SEEK(newnum) DO WHILE NOT EOF() AND transid=newnum SCATTER NAME dtbk SELECT [Transferbk] APPEND BLANK GATHER name dtbk SELECT [Transfer] skip ENDDO USE IN SELECT([Transferbk]) SELECT [acctranbk] SET ORDER TO transid =SEEK(newnum+[Transfer]) DELETE while transid=newnum AND vtype=[Transfer] SELECT [acctran] SET ORDER TO transid =SEEK(newnum+[Transfer]) DO WHILE NOT EOF() AND transid=newnum AND vtype=[Transfer] 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() %>