1.go to http://localhost:2001/manage and add
Z SQL Method which is named zsqltest
argument:
user_name
date1
date2
select * from user_assets where user_name=<dtml-sqlvar user_name type="string">
and date>=to_date(<dtml-sqlvar date1 type="string">,'yyyy-MM-dd')
and date<to_date(<dtml-sqlvar date2 type="string">,'yyyy-MM-dd')+1
2.add Script (Python)
from Products.PythonScripts.standard import html_quote
request = container.REQUEST
RESPONSE = request.RESPONSE
p_date = context.REQUEST.get('Dd_reachdate', '')
p_date_e = context.REQUEST.get('Dd_reachdate_e', '')
myusername = context.REQUEST.get('username', '')
RESPONSE.setHeader("Cache-Control","no-store");
RESPONSE.setHeader("Content-Type","text/html;charset=utf-8");
from DateTime import DateTime
now = DateTime()
today=now.strftime('%Y-%m-%d')
yday=(now-3).strftime('%Y-%m-%d')
if p_date=='':
p_date=yday
if p_date_e=='':
p_date_e=today
print "<html><head><meta http-equiv=/"Content-Type/" content=/"text/html;charset=utf-8/" />"
print "</head><body bgColor=#F3FAFF>"
print "<form name=form2 action=selectzc.py>"
print "<input type=/"hidden/" name=/"username/" value=/""+myusername+"/" >"
print "begin time :<input type=/"text/" name=/"Dd_reachdate/" value=/""+p_date+"/" ><br>"
print "end time :<input type=/"text/" name=/"Dd_reachdate_e/" value=/""+p_date_e+"/" > "
print "<p><input type=/"submit/" value=/"search/"></p>"
print "</form>"
selectzcsql=container['selectzc.sql']
print "<table border=1> <tr><td>f1</td><td>f2</td><td>f3</td><td>f4</td><td>f5</td><td>f6</td><td>f7</td><td> f8</td> </tr>"
for f in selectzcsql(user_name=myusername,date1=p_date,date2=p_date_e):
print " <tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" % (f['user_name'],f['date'],f['beginning'],f['stock'],f['bond'],f['warrant'],f['present'],f['profit_and_loss'])
print "</table>"
print "</body></html>"
return printed
argument:
user_name
date1
date2
select * from user_assets where user_name=<dtml-sqlvar user_name type="string">
and date>=to_date(<dtml-sqlvar date1 type="string">,'yyyy-MM-dd')
and date<to_date(<dtml-sqlvar date2 type="string">,'yyyy-MM-dd')+1
2.add Script (Python)
from Products.PythonScripts.standard import html_quote
request = container.REQUEST
RESPONSE = request.RESPONSE
p_date = context.REQUEST.get('Dd_reachdate', '')
p_date_e = context.REQUEST.get('Dd_reachdate_e', '')
myusername = context.REQUEST.get('username', '')
RESPONSE.setHeader("Cache-Control","no-store");
RESPONSE.setHeader("Content-Type","text/html;charset=utf-8");
from DateTime import DateTime
now = DateTime()
today=now.strftime('%Y-%m-%d')
yday=(now-3).strftime('%Y-%m-%d')
if p_date=='':
p_date=yday
if p_date_e=='':
p_date_e=today
print "<html><head><meta http-equiv=/"Content-Type/" content=/"text/html;charset=utf-8/" />"
print "</head><body bgColor=#F3FAFF>"
print "<form name=form2 action=selectzc.py>"
print "<input type=/"hidden/" name=/"username/" value=/""+myusername+"/" >"
print "begin time :<input type=/"text/" name=/"Dd_reachdate/" value=/""+p_date+"/" ><br>"
print "end time :<input type=/"text/" name=/"Dd_reachdate_e/" value=/""+p_date_e+"/" > "
print "<p><input type=/"submit/" value=/"search/"></p>"
print "</form>"
selectzcsql=container['selectzc.sql']
print "<table border=1> <tr><td>f1</td><td>f2</td><td>f3</td><td>f4</td><td>f5</td><td>f6</td><td>f7</td><td> f8</td> </tr>"
for f in selectzcsql(user_name=myusername,date1=p_date,date2=p_date_e):
print " <tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" % (f['user_name'],f['date'],f['beginning'],f['stock'],f['bond'],f['warrant'],f['present'],f['profit_and_loss'])
print "</table>"
print "</body></html>"
return printed