import cgitb
import sqlite3
import os
+import re
import datetime
cgitb.enable()
path=str(os.path.dirname(os.path.abspath(__file__)))+"/"
chopt=chopt+"<option value="+chtxt+">"+display+"</option>\n "
db.close()
return chopt
+def edit_date(id):
+ db=sqlite3.connect(dbpath)
+ ret={}
+ for idt,typet,chtxt,title,btime,etime,deltatime,opt,deltaday in db.execute("SELECT id,type,chtxt,title,btime,etime,deltatime,opt,deltaday From rectime WHERE id ="+id):
+ ret['id']=idt
+ ret['type']=typet
+ ret['chtxt']=chtxt
+ ret['title']=title
+ ret['btime']=btime
+ ret['etime']=etime
+ try:
+ ret['deltatime']=deltatime
+ except:
+ ret['deltatime']=""
+ ret['opt']=opt
+ try:
+ ret['deltaday']=daltaday
+ except:
+ ret['deltaday']=""
+ db.close()
+ return ret
+
def reserv_recday(keyword,chtxt,btime,etime,deltatime,opt,deltaday,day):
"""
dayは月曜日を1日曜日を7とした数字
rett="over"
db.close()
return rett
+def change_reserv(id,type,keyword,chtxt,btime,etime,deltatime,opt,deltaday):
+ """
+ idはテキスト
+ """
+ MaxT=2
+ MaxS=2
+ db=sqlite3.connect(dbpath)
+ bt="\'"+btime+"\'"
+ et="\'"+etime+"\'"
+ idn=int(id)
+ dbexe="SELECT id,type,chdata.bctype,rectime.chtxt,rectime.title FROM rectime INNER JOIN chdata ON rectime.chtxt=chdata.chtxt"
+ #dbexe="SELECT bctype,chtxt,title FROM rectime INNER JOIN chdata ON rectime.chtxt=chdata.chtxt"
+
+ dbexe=dbexe+" WHERE NOT( ( rectime.etime <= "+bt+" ) OR ( rectime.btime >= "+et+" ) )"
+ for idt,typet,bctypet, chtxtt, titlet in db.execute(dbexe):
+ if idt != idn:
+ if (typet=="rec") or (typet=="res") or (typet=="key") or (typet=="keyevery"):
+ if bctypet.find("cs")>-1:
+ MaxS=MaxS-1
+ elif bctypet.find("bs")>-1:
+ MaxS=MaxS-1
+ elif bctypet.find("te")>-1:
+ MaxT=MaxT-1
+ bctype=""
+ rett=""
+ for bctypet, chtxtt in db.execute("SELECT bctype,chtxt FROM chdata WHERE chtxt=\'"+chtxt+"\'"):
+ bctype=bctypet
+ if (type=="rec") or (type=="res") or (type=="key") or (type=="keyevery"):
+ if bctype.find("cs")>-1:
+ MaxS=MaxS-1
+ elif bctype.find("bs")>-1:
+ MaxS=MaxS-1
+ elif bctype.find("te")>-1:
+ MaxT=MaxT-1
+ if MaxS>-1 and MaxT>-1:
+ db.execute('delete from rectime where id='+id)
+ recline="\""+type+"\",\""+chtxt+"\",\""+keyword+"\",datetime(\""+btime+"\"),datetime(\""+etime+"\"),\""+deltatime+"\",\""+opt+"\",\""+deltaday+"\""
+ #print recline
+ db.execute('insert into rectime ("type","chtxt","title","btime","etime","deltatime","opt","deltaday") values ('+recline+')')
+ db.commit()
+ else:
+ rett="over"
+ db.close()
+ return rett
def station2chtxt(station):
db=sqlite3.connect(dbpath)
ret=""
ret=f.read()
f.close()
return ret
+def readHtmlEdit():
+ f = open(path+'rswi_edit.htm')
+ ret=f.read()
+ f.close()
+ return ret
def readRecFinisSimple():
f = open(path+'fin.htm')
htmdate= readHtmlSrcSimple()
htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
-
htmdate=htmdate.replace("<!--btime-value//-->",btime)
htmdate=htmdate.replace("<!--etime-value//-->",etime)
htmdate=htmdate.replace("<!--type-value//-->",type)
htmdate=readRecFinisOver()
exect=""
#
+if (chtxt != "")and(title != "")and(btime!="")and(etime!="")and(opts!="")and(re.search('edit-exec:',exect)):
+ editnum=exect.replace("edit-exec:","")
+ restxt=change_reserv(editnum,type, title, chtxt, btime, etime, deltahour, opts, deltaday)
+ if restxt=="":
+ htmdate=readRecFinisSimple()
+ elif restxt=="over":
+ htmdate=readRecFinisOver()
+ exect=""
if exect=="schedule":
htmdate=readRecSchedule()
+if re.search('edit:',exect):
+ editnum=exect.replace("edit:","")
+ htmdate= readHtmlEdit()
+ iddata=edit_date(editnum)
+ htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
+ htmdate=htmdate.replace("<!--ch-value//-->",iddata["chtxt"])
+ htmdate=htmdate.replace("<!--btime-value//-->",iddata["btime"])
+ htmdate=htmdate.replace("<!--etime-value//-->",iddata["etime"])
+ htmdate=htmdate.replace("<!--type-value//-->",iddata["type"])
+ htmdate=htmdate.replace("<!--ch-value//-->",iddata["chtxt"])
+ htmdate=htmdate.replace("<!--title-value//-->",iddata["title"])
+ htmdate=htmdate.replace("<!--size-value//-->",size)
+ htmdate=htmdate.replace("<!--opts-value//-->",iddata["opt"])
+ htmdate=htmdate.replace("<!--exec-value//-->","edit-exec:"+editnum)
+
print htmdate