# If we are in the last step of an action, we can update the "journal of submissions"
iflast_step==1:
ifuid_email!=""anduid_email!="guest"andrn!="":
res=run_sql("SELECT * FROM sbmSUBMISSIONS WHERE doctype=%s and action=%s and id=%s and email=%s",(doctype,act,access,uid_email,))
iflen(res)==0:
run_sql("INSERT INTO sbmSUBMISSIONS values(%s,%s,%s,'finished',%s,%s,NOW(),NOW())",(uid_email,doctype,act,access,rn,))
else:
run_sql("UPDATE sbmSUBMISSIONS SET md=NOW(),reference=%s,status='finished' WHERE doctype=%s and action=%s and id=%s and email=%s",(rn,doctype,act,access,uid_email,))
res=run_sql("SELECT * FROM sbmCATEGORIES WHERE doctype=%s ORDER BY lname",(doctype,))
iflen(res)>0:
forarrinres:
nbCateg=nbCateg+1
snameCateg.append(arr[1])
lnameCateg.append(arr[2])
#then data about the document type
res=run_sql("SELECT * FROM sbmDOCTYPE WHERE sdocname=%s",(doctype,))
iflen(res)>0:
arr=res[0]
docFullDesc=arr[0]
docShortDesc=arr[1]
description=arr[4]
else:
returnerrorMsg(_("Unable to find document type.")+str(doctype),req)
#then data about associated actions
res2=run_sql("SELECT * FROM sbmIMPLEMENT LEFT JOIN sbmACTION on sbmACTION.sactname=sbmIMPLEMENT.actname WHERE docname=%s and displayed='Y' ORDER BY sbmIMPLEMENT.buttonorder",(docShortDesc,))
forarr2inres2:
res=run_sql("SELECT * FROM sbmACTION WHERE sactname=%s",(arr2[1],))
res=run_sql("SELECT * FROM sbmIMPLEMENT WHERE docname=%s and level!='0' and level=%s and score>%s ORDER BY score",(doctype,currentlevel,action_score,))
iflen(res)>0:
actions=[]
first_score=res[0][10]
foriinrange(0,len(res)):
action=res[i]
ifaction[10]==first_score:
res2=run_sql("SELECT dir FROM sbmACTION WHERE sactname=%s",(action[1],))
nextdir=res2[0][0]
curraction={
'page':action[11],
'action':action[1],
'doctype':doctype,
'nextdir':nextdir,
'access':access,
'indir':indir,
'name':action[12],
}
actions.append(curraction)
t=websubmit_templates.tmpl_next_action(
ln=ln,
actions=actions,
)
returnt
defTest_Reload(uid_email,doctype,act,access):
res=run_sql("SELECT * FROM sbmSUBMISSIONS WHERE doctype=%s and action=%s and id=%s and email=%s and status='finished'",(doctype,act,access,uid_email,))