def sendpdfmail(var,rese,cust,blobid) : ma = {} ma["resename"] = rese ma["mailtype"] = 1 ma["custname"] = cust alist = [{"blobid" : blobid} ] xml = xmlutil.toXML(ma,alist) var["JUPDIALOG_START"] = xml var["JUP_DIALOG"]="hotel/info/sendconfirmationmail.xml"
def resequeryXML(resroom,resday,resnodays,nop,roomservice,roompricelist) : m = {} m["roomname"] = resroom m["firstday"] = resday m["nodays"] = resnodays m["nop"] = nop m["roomservice"] = roomservice m["roompricelist"] = roompricelist return xmlutil.toXML(m)
def resequeryXML(resroom, resday, resnodays, nop, roomservice, roompricelist): m = {} m["roomname"] = resroom m["firstday"] = resday m["nodays"] = resnodays m["nop"] = nop m["roomservice"] = roomservice m["roompricelist"] = roompricelist return xmlutil.toXML(m)
def sendpdfmail(var, rese, cust, blobid): ma = {} ma["resename"] = rese ma["mailtype"] = 1 ma["custname"] = cust alist = [{"blobid": blobid}] xml = xmlutil.toXML(ma, alist) var["JUPDIALOG_START"] = xml var["JUP_DIALOG"] = "hotel/info/sendconfirmationmail.xml"
def toFormat(format,jsondata,jsonform,dialogname,listname): lform = miscutil.toListMap(dialogname,listname) assert lform != None listform = jsutil.toList(jsonform,LIST) jdata = jsutil.toList(jsondata,LIST,dialogname,listname) vis = _toVisMap(listform) if format == XML : li = [] for j in jdata : ma = {} for k in j.keys() : if k in vis : ma[k] = j[k] li.append(ma) return xmlutil.toXML({},li) if format == JSON : return jsondata if format == CSV : return _toCSV(jdata,lform,listform,vis) html = _toHTML(jdata,lform,listform,vis) if format == HTML : return html return pdfutil.createPDFH(html)
def diffAsXML(self, var, diff, ma=None): if ma == None: ma = cutil.DLIST(var).createNameMap() print ma li = [] for d in diff: key = d[0] prevval = d[1] newval = d[2] print key, type(key) if ma.has_key(key): descr = ma[key] else: descr = None map = { "key": key, "prevval": prevval, "newval": newval, "descr": descr } li.append(map) return xmlutil.toXML({}, li, False, True)
def dialogaction(action,var) : cutil.printVar("jaction",action,var) if action == "testmap" : l = miscutil.getMapFieldList("test85.xml") print l assert "glob1" in l assert not ("xxx" in l) if action == "testlistmap" : l = miscutil.getMapFieldList("test85.xml","reslist") print l assert "avail" in l assert len(l) == 4 assert not ("xxx" in l) if action == "testxmllist" : li = [] for i in range(1,20) : ma = {} ma["avail"] = True ma["resday"] = datetime.date(2014,2,1) ma["chooseroom"] = 'X' ma["resroomname"] = "Hello" ma["add"] = 345 li.append(ma) xml = xmlutil.toXML({},li) assert xml != None print xml (ma,li) = xmlutil.toMap(xml) print li for l in li : assert l.has_key("add") (ma,li1) = xmlutil.toMapFiltrDialL(xml,"test85.xml","reslist") print li1 assert len(li) == len(li1) for l in li1 : assert not l.has_key("add")
def saveMap(self,var,l) : R = self.__getR(var) R.putEntry(self.rentry,xmlutil.toXML(l))
def roomdaytoXML(resname,resroom,resday) : m = {} m["resname"] = resname m["roomname"] = resroom m["resday"] = resday return xmlutil.toXML(m)
def reseraction(action,var): cutil.printVar("reseraction",action,var) if action == "aftercheckin" : rutil.afterCheckIn(var) if action == "signalchange" and var["changeafterfocus"]: if var["changefield"] == "serviceperperson" : _setAfterPerPerson(var) if var["changefield"] == "roomservice" : if not _okServiceForRoom(var) : return _setAfterServiceName(var) _setAfterPriceList(var) if var["changefield"] == "roompricelist" : if not _okServiceForRoom(var) or not _okPriceList(var) : return _setAfterPriceList(var) if var["changefield"] == "advance_percent" : if not cutil.validatePercent(var,"advance_percent") : return _calculateAdvanceAmount(var,var["advance_total"]) if action=="before" : rbefore.setvarBefore(var) if not _newRese(var) : cutil.hideButton(var,"checkin",False) cust.enableCust(var,CUST,False) _setAfterPriceList(var) PA = reseparam.RESPARAM(rutil.getReseName(var)) PA.setParam(var) PA.copyParam(var) else : cutil.hideButton(var,"detailreservation",True) _setPriceAndService(var) _setAfterPriceList(var) _setAfterServiceName(var) _setAfterPerPerson(var) _createListOfDays(var,True) confirm.createC(var).setDefaToVar() reseparam.RESPARAM().copyParam(var) # -------------------- # customer # -------------------- if action == "acceptdetails" and (var["JUPDIALOG_BUTTON"] == "accept" or var["JUPDIALOG_BUTTON"] == "acceptask"): xml = var["JUPDIALOG_RES"] util.xmlToVar(var,xml,cust.getCustFieldIdAll(),CUST) cutil.setCopy(var,cust.getCustFieldIdAll(),None,CUST) if not _newRese(var) : name = var[CUST+"name"] resename = rutil.getReseName(var) util.RESFORM(var).changeCustName(resename,name) if action=="custdetails" : var["JAFTERDIALOG_ACTION"] = "acceptdetails" if _newRese(var) : cust.customerDetailsActive(var,CUST) else : cust.showCustomerDetailstoActive(var,var[CUST+"name"]) # -------------------- # -- add reservation # -------------------- if action == "checkaval" : if not _okServiceForRoom(var) or not _okPriceList(var) : return _checkRese(var) reseparam.RESPARAM().copyParam(var) # ------------------ # reservation # ------------------ if action == "askforreservation" : if not _checkCurrentRese(var) : return PA = reseparam.RESPARAM() diff = PA.diffP(var) if diff != None : xml = PA.diffAsXML(var,diff) var["JUPDIALOG_START"] = xml var["JUP_DIALOG"]="?reserchange.xml" var["JAFTERDIALOG_ACTION"] = "continuereservation" return var["JYESNO_MESSAGE"] = M("MAKERESERVATIONASK") var["JMESSAGE_TITLE"] = "" var["JAFTERDIALOG_ACTION"] = "makereservation" if (action == "makereservation" and var["JYESANSWER"]) or (action == "continuereservation" and var["JUPDIALOG_BUTTON"] == "accept") : TRAN = MAKERESE(var) TRAN.doTrans() # ----------------------- # additional reservation # ----------------------- if action == "morereservation" : l = var["JLIST_MAP"][RESLIST] xml = xmlutil.toXML({},l) var["JUPDIALOG_START"] = xml var["JUP_DIALOG"]="?searchrooms.xml" var["JAFTERDIALOG_ACTION"] = "morereservationaccept" if action == "morereservationaccept" and var["JUPDIALOG_BUTTON"] == "toresrese" : arese = var["resename"] var["JUPDIALOG_START"] = var["JUPDIALOG_RES"] rbefore.setvarBefore(var) # restore reservation name var["resename"] = arese _setAfterPriceList(var) _checkRese(var,False) reseparam.RESPARAM().copyParam(var) # ------------------------ # modify detail reservation # ------------------------ if action == "detailreservationaccept" and var["JUPDIALOG_BUTTON"] == "accept" : xml = var["JUPDIALOG_RES"] (rmap,li) = xmlutil.toMapFiltrDialL(xml,var["J_DIALOGNAME"],RESLIST) RELIST.initsum() for l in li : RELIST.addsum(l) RELIST.removePricesFromMap(l) l["avail"] = True RELIST.tofooter(var) cutil.setJMapList(var,RESLIST,li) if action == "detailreservation" : l = var["JLIST_MAP"][RESLIST] xml = xmlutil.toXML({},l) var["JUPDIALOG_START"] = xml var["JUP_DIALOG"]="?modifreservation.xml" var["JAFTERDIALOG_ACTION"] = "detailreservationaccept"
def dialogaction(action, var): cutil.printVar("modif reservation", action, var) if action == "before": xml = var["JUPDIALOG_START"] (m, li) = xmlutil.toMap(xml) prevplist = None prevpservice = None (price, pricechild, priceextra) = (None, None, None) sum = util.SUMBDECIMAL() first = True for l in li: sum.add(l["rlist_pricetotal"]) plist = l["rlist_roompricelist"] pservice = l["rlist_roomservice"] if plist != None and pservice != None: if plist != prevplist or pservice != prevpservice: (price, pricechild, priceextra) = rutil.getPriceList(var, plist, pservice) (prevplist, prevpservice) = (plist, pservice) _setPriceL(l, "rlist_priceperson", price) _setPriceL(l, "rlist_pricechildren", pricechild) _setPriceL(l, "rlist_priceextra", priceextra) if first: print l print l["rlist_priceextra"], type(l["rlist_priceextra"]) SR.saveMap(var, l) first = False cutil.setJMapList(var, LI, li) # cutil.setAddEditMode(var,LI,ELIST) cutil.setChangeEditMode(var, LI, ELIST) cutil.setFooter(var, LI, "rlist_pricetotal", sum.sum) if action == "aftereditrow": cutil.setEditRowOk(var, LI, False) if not RE.validate(var): return RE.calculatePrice(var) cutil.setEditRowOk(var, LI) if action == "editlistrowaction": if var["JLIST_EDIT_ACTION_" + LI] == "ADD" or var["JLIST_EDIT_ACTION_" + LI] == "ADDBEFORE": if not var[LI + "_lineset"]: m = SR.getMap(var) print m for k in m.keys(): var[k] = m[k] var["rlist_pricetotal"] = 0 cutil.setEditListActionOk(var, LI) cutil.setCopy(var, ELIST, LI) RE.calculatePrice(var) if var["JLIST_EDIT_ACTION_" + LI] == "REMOVE": var["JYESNO_MESSAGE"] = "@doyouwanttoremoveline" var["JAFTERDIALOG_ACTION"] = "removeyesno" if action == "removeyesno": if var["JYESANSWER"]: cutil.setEditListActionOk(var, LI) RE.calculatePriceAterRemove(var) else: cutil.setEditListActionOk(var, LI, False) if action == "roomselected" and var["JUPDIALOG_BUTTON"] == "accept": roomname = var["JUPDIALOG_RES"] if roomname != var["resroomname"]: var["resroomname"] = roomname cutil.setCopy(var, "resroomname", LI) # does not work select if action == "xxxcolumnchangeaction": RE.setPrices(var) if action == "accept": list = var["JLIST_MAP"][LI] if len(list) == 0: rutil.setAlreadyReservedNotSelected(var) return # "resroomname","resday" res = rutil.checkReseAvailibity(var, list, None, "resday", "resroomname") if res != None: return xml = xmlutil.toXML({}, list) var["JCLOSE_DIALOG"] = xml
def dialogaction(action,var): cutil.printVar("xml action",action,var) if action == "before" : ma = {} ma["id"] = "I100"; xml = xmlutil.toXML(ma) print xml var["xml"] = xml if action == "after" : xml = var["xml"] print xml (ma,li) = xmlutil.toMap(xml) assert len(ma) == 1 val = ma["id"] assert val == "I100" if action == "before1" : ma = {} ma["id"] = "I100"; ma["d"] = None xml = xmlutil.toXML(ma) var["xml"] = xml if action == "after1" : xml = var["xml"] (ma,li) = xmlutil.toMap(xml) print ma assert len(ma) == 2 assert ma["id"] == "I100" assert ma["d"] == None if action == "before2" : ma = {} ma["numb"] = 99 ma["dec"] = -45.66 xml = xmlutil.toXML(ma) var["xml"] = xml if action == "after2" : xml = var["xml"] print xml (ma,li) = xmlutil.toMap(xml) print ma l= ma["numb"] assert type(l) ==long assert l == 99 v = ma["dec"] print type(v) assert type(v) == float assert v == -45.66 if action == "before3" : ma = {} ma["numb"] = 99 ma["dec"] = -45.66 ma["ok"] = True ma["nok"] = False xml = xmlutil.toXML(ma) var["xml"] = xml if action == "after3" : xml = var["xml"] print xml (ma,li) = xmlutil.toMap(xml) print ma assert len(ma) == 4 assert type(ma["ok"]) == bool assert type(ma["nok"]) == bool assert ma["ok"] assert not ma["nok"] if action == "before4" : ma = {} ma["numb"] = 99 ma["dec"] = -45.66 ma["ok"] = True ma["today"] = datetime.date(2013,10,12) xml = xmlutil.toXML(ma) var["xml"] = xml if action == "after4" : xml = var["xml"] print xml (ma,li) = xmlutil.toMap(xml) print ma assert type(ma["today"]) == datetime.date assert ma["today"] == datetime.date(2013,10,12) if action == "before5" : li = [{"ok":True,"numb" : 5 }] xml = xmlutil.toXML({},li) print xml var["xml"] = xml if action == "after5" : xml = var["xml"] print xml (ma,li) = xmlutil.toMap(xml) print ma assert len(ma) == 0 print li assert len(li) == 1 m = li[0] assert m["numb"] == 5 assert m["ok"] if action == "before6" : li = [] for i in range(0,100) : li.append({"id" : i, "name" : "P " + str(i)}) xml = xmlutil.toXML({},li) print xml var["xml"] = xml if action == "after6" : xml = var["xml"] print xml (ma,li) = xmlutil.toMap(xml) print len(li) assert len(li) == 100
def roomdaytoXML(resname, resroom, resday): m = {} m["resname"] = resname m["roomname"] = resroom m["resday"] = resday return xmlutil.toXML(m)
def dialogaction(action,var) : cutil.printVar("modif reservation",action,var) if action == "before" : xml = var["JUPDIALOG_START"] (m,li) = xmlutil.toMap(xml) prevplist = None prevpservice = None (price,pricechild,priceextra) = (None, None,None) sum = util.SUMBDECIMAL() first = True for l in li : sum.add(l["rlist_pricetotal"]) plist = l["rlist_roompricelist"] pservice = l["rlist_roomservice"] if plist != None and pservice != None : if plist != prevplist or pservice != prevpservice : (price,pricechild,priceextra) = rutil.getPriceList(var,plist,pservice) (prevplist,prevpservice) = (plist,pservice) _setPriceL(l,"rlist_priceperson",price) _setPriceL(l,"rlist_pricechildren",pricechild) _setPriceL(l,"rlist_priceextra",priceextra) if first : print l print l["rlist_priceextra"],type(l["rlist_priceextra"]) SR.saveMap(var,l) first = False cutil.setJMapList(var, LI,li) # cutil.setAddEditMode(var,LI,ELIST) cutil.setChangeEditMode(var,LI,ELIST) cutil.setFooter(var,LI,"rlist_pricetotal",sum.sum) if action == "aftereditrow" : cutil.setEditRowOk(var,LI,False) if not RE.validate(var) : return RE.calculatePrice(var) cutil.setEditRowOk(var,LI) if action == "editlistrowaction" : if var["JLIST_EDIT_ACTION_" + LI] == "ADD" or var["JLIST_EDIT_ACTION_" + LI] == "ADDBEFORE" : if not var[LI + "_lineset"] : m = SR.getMap(var) print m for k in m.keys() : var[k] = m[k] var["rlist_pricetotal"] = 0 cutil.setEditListActionOk(var,LI) cutil.setCopy(var,ELIST,LI) RE.calculatePrice(var) if var["JLIST_EDIT_ACTION_" + LI] == "REMOVE" : var["JYESNO_MESSAGE"] = "@doyouwanttoremoveline" var["JAFTERDIALOG_ACTION"] = "removeyesno" if action == "removeyesno" : if var["JYESANSWER"] : cutil.setEditListActionOk(var,LI) RE.calculatePriceAterRemove(var) else : cutil.setEditListActionOk(var,LI,False) if action == "roomselected" and var["JUPDIALOG_BUTTON"] == "accept" : roomname = var["JUPDIALOG_RES"] if roomname != var["resroomname"] : var["resroomname"] = roomname cutil.setCopy(var,"resroomname",LI) # does not work select if action == "xxxcolumnchangeaction" : RE.setPrices(var) if action == "accept" : list = var["JLIST_MAP"][LI] if len(list) == 0 : rutil.setAlreadyReservedNotSelected(var) return # "resroomname","resday" res = rutil.checkReseAvailibity(var,list,None,"resday","resroomname") if res != None : return xml = xmlutil.toXML({},list) var["JCLOSE_DIALOG"] = xml
def doctoXML(ma, li, verify=True): xml = xmlutil.toXML(ma, li, True) # print xml if verify: cutil.verifyXML("fdocument.xsd", xml) return xml
def transformXMLFromMap(xslt, m): xml = xmlutil.toXML(m) return transformXML(xslt, xml)
def transformXMLFromMap(xslt,m) : xml = xmlutil.toXML(m) return transformXML(xslt,xml)
def doctoXML(ma,li,verify=True): xml = xmlutil.toXML(ma,li,True) # print xml if verify : cutil.verifyXML("fdocument.xsd",xml) return xml