<% set date ymd set century on set hours to 24 set mark to [-] *=SYS(3101,1256) =SYS(3101,65001) expires=-1 the_action=orequest.form('action') the_transid=orequest.form('m_transid') filenumber=the_transid the_sponname=orequest.form('sponname') the_sponadr=orequest.form('sponadr') the_visadt=orequest.form('visadt') the_embassy=orequest.form('embassy') *return the_action+the_transid+the_sponname+the_sponadr+the_visadt+the_embassy ajaxresponse=CREATEOBJECT('empty') oJSON=NEWOBJECT('json','json.fxp') jsondata=orequest.form('data-area') STRTOFILE(jsondata,addbs(oprop.appstartpath)+[temp\jsondata.json]) set procedure to (addbs(oprop.appstartpath)+'json_new.fxp') additive jsonObject=json_decode(jsondata) headerText=[] if NOT type([jsonObject._1])=[O] ADDPROPERTY(ajaxresponse,'tmessage','Can not save empty list') ADDPROPERTY(ajaxresponse,'terror','true') oresponse.write(ojson.stringify(ajaxresponse)) oresponse.flush() RETURN '' ENDIF tcounter=0 respmsg=[] if type([jsonObject._1])=[O] do while .t. tcounter=tcounter+1 c_param=[jsonObject._]+allt(transform(tcounter)) IF type(c_param)<>[O] exit endif with &c_param theCompany=allt(upper(.get(1))) theSR=val(ALLTRIM(upper(.get(2)))) theProf=.get(3) theCategory=.get(4) theQuantity=val(transform(.get(5))) theCurrency=.get(6) theSalary=val(transform(.get(7))) theSkill=.get(8) theSkill=icase(theskill='Unskilled', 1, theskill='Semi Skilled', 2, theskill='Skilled', 3, theskill='Highly Skilled',4, theskill='Highly Qualified',5, 1) theYear=val(.get(9)) theMonth=val(.get(10)) theApplicant=allt(upper(.get(11))) isAdd=.get(12) ENDWITH tsql=[ use (']+dbclocation+[works\visainfo') in select('visainfo')] &tsql select [visainfo] locate for sr=thesr and allt(reffid)==the_transid replace category with thecategory, qty with thequantity, skill with theskill, ; salary with thesalary, year with theyear, month with themonth, choose with iif(IsAdd='Add',.t.,.f.) ,choosetext with isAdd *respmsg=respmsg+theCurrency enddo tsql=[ use (']+dbclocation+[works\visainfo') in select('visainfo')] &tsql select [visainfo] select * from dbf() where allt(reffid)==the_transid and choose into cursor proplist if _tally=0 return [{"terror":"true","tmessage":"No visas were choosen"}] *else *return [{"terror":"false","tmessage":"A total of ]+transform(_tally)+[ visas were updated!"}] endif *From here we will add the new visas ************* use (dbclocation+[details]) in select([details]) select [details] calculate CNT() TO oldvisas FOR allt(reffid)==allt(filenumber) use (dbclocation+[category]) in select([category]) use (dbclocation+[fileref]) in select([fileref]) SELECT [proplist] scan thiscateg=ALLTRIM(category) SELECT [details] CALCULATE CNT() TO oldcateg FOR ALLTRIM(reffid)==ALLTRIM(filenumber) AND ALLTRIM(category)==thiscateg SELECT [visainfo] CALCULATE cnt() TO categqty FOR ALLTRIM(category)==thiscateg AND ALLTRIM(reffid)==ALLTRIM(filenumber) and choose LOCATE FOR ALLTRIM(category)==thiscateg Scatter Name VVISAS IF oldcateg