def clickaction(action,var) : cutil.printVar("enable",action,var) if action=="before" : var["hide"] = False cutil.setCopy(var,"hide") if action == "signalchange" and var["changefield"] == "enable" : enable = var["enable"] cutil.enableButton(var,"click",enable) if action == "signalchange" and var["changefield"] == "hide" : hide = var["hide"] cutil.hideButton(var,"click",hide) if action == "signalchange" and var["changefield"] == "enableperson" : enable = var["enableperson"] cutil.enableField(var,"custid",enable)
def dialogactionpoly(action,var) : cutil.printVar("main poly",action,var) if action == "before" : cutil.setCopy(var,"glob1") var["glob1"] = "Hello, I'm here" if action == "seterror" : cutil.setErrorField(var,"glob1","@cannotbeempty") if action == "setenable" : cutil.enableField(var,"glob1",True); if action == "setdisable" : cutil.enableField(var,"glob1",False); if action == "sethidden" : cutil.hideButton(var,"seterror") if action == "setvisible" : cutil.hideButton(var,"seterror",False)
def dialogactionpoly(action, var): cutil.printVar("main poly", action, var) if action == "before": cutil.setCopy(var, "glob1") var["glob1"] = "Hello, I'm here" if action == "seterror": cutil.setErrorField(var, "glob1", "@cannotbeempty") if action == "setenable": cutil.enableField(var, "glob1", True) if action == "setdisable": cutil.enableField(var, "glob1", False) if action == "sethidden": cutil.hideButton(var, "seterror") if action == "setvisible": cutil.hideButton(var, "seterror", False)
def dialogaction(action, var): cutil.printVar("show doc", action, var) if action == "before": xml = var["JUPDIALOG_START"] okonly = var["JUPDIALOG_STARTPAR"] == "1" if okonly: cutil.hideButton(var, ["accept", "resign"]) cutil.hideButton(var, "ok", False) reseparam.setXMLParam(var, xml) (va, li) = xmlutil.toMap(xml) for l in LI: var[l] = va[l] cutil.setCopy(var, LI) cutil.setJMapList(var, LIST, li) cutil.setFooter(var, LIST, T, va[T]) if action == "accept" and var["JYESANSWER"]: var["JCLOSE_DIALOG"] = reseparam.getXMLParam(var)
def custdetails(action, var): cutil.printVar("custdetails", action, var) if action == "before": xml = var["JUPDIALOG_START"] util.xmlToVar(var, xml, CLIST + [cust.CUSTACTION], DE) action = var[DE + cust.CUSTACTION] if action == cust.CUSTSHOWTOACTIVE or action == cust.CUSTSHOWONLY: custid = var[DE + "name"] custR = util.CUSTOMERLIST(var).findElem(custid) assert custR != None cust.customerToVar(var, custR, DE) cust.setCustVarCopy(var, DE) if action == cust.CUSTSHOWTOACTIVE: cutil.hideButton(var, ["accept", "ok"]) else: cutil.hideButton(var, ["accept", "acceptask", "resign", "find"]) cust.enableCust(var, DE, False) else: cust.setCustVarCopy(var, DE) cutil.hideButton(var, ["acceptask", "ok"]) if action == "accept": var["JCLOSE_DIALOG"] = util.mapToXML(var, CLIST, DE) if action == "acceptask" and var["JYESANSWER"]: util.CUSTOMERLIST(var).changeElem(cust.customerFromVar(var, DE)) var["JCLOSE_DIALOG"] = util.mapToXML(var, CLIST, DE) if action == "selectcustomer": c_name = var["JUPDIALOG_RES"] if c_name == None: return cust.setCustData(var, c_name, DE)
def custdetails(action,var): cutil.printVar ("custdetails", action,var) if action == "before" : xml = var["JUPDIALOG_START"] util.xmlToVar(var,xml,CLIST + [cust.CUSTACTION],DE) action = var[DE + cust.CUSTACTION] if action == cust.CUSTSHOWTOACTIVE or action == cust.CUSTSHOWONLY : custid = var[DE + "name"] custR = util.CUSTOMERLIST(var).findElem(custid) assert custR != None cust.customerToVar(var,custR,DE) cust.setCustVarCopy(var,DE) if action == cust.CUSTSHOWTOACTIVE : cutil.hideButton(var,["accept","ok"]) else : cutil.hideButton(var,["accept","acceptask","resign","find"]) cust.enableCust(var,DE,False) else: cust.setCustVarCopy(var,DE) cutil.hideButton(var,["acceptask","ok"]) if action == "accept" : var["JCLOSE_DIALOG"] = util.mapToXML(var,CLIST,DE) if action == "acceptask" and var["JYESANSWER"] : util.CUSTOMERLIST(var).changeElem(cust.customerFromVar(var,DE)) var["JCLOSE_DIALOG"] = util.mapToXML(var,CLIST,DE) if action == "selectcustomer" : c_name = var["JUPDIALOG_RES"] if c_name == None : return cust.setCustData(var,c_name,DE)
def checkinaction(action,var): cutil.printVar("checkinaction",action,var) R = util.RESFORM(var) ROOM = util.ROOMLIST(var) SE = util.SERVICES(var) ROP = util.RESOP(var) resName = var["resename"] CUST = util.CUSTOMERLIST(var) if action == "makecheckin" and var["JYESANSWER"] : TRANS = MAKECHECKIN(var) TRANS.doTrans() if action == "guestdetails" and var[CHECKINLIST+"_lineset"] : var["JAFTERDIALOG_ACTION"] = "acceptdetails" cust.customerDetailsActive(var,None) if action == "acceptdetails" and var["JUPDIALOG_BUTTON"] == "accept" : xml = var["JUPDIALOG_RES"] util.xmlToVar(var,xml,CUSTF) cutil.setCopy(var,CUSTF,CHECKINLIST) if action == "selectguestfromlist" : custid =var["JUPDIALOG_RES"] if custid == None : return __toMap(var,custid,CUST) li = ["guestselect"] + CUSTF cutil.setCopy(var,li,CHECKINLIST) if action == "selectguest" : var["JUP_DIALOG"] = "?customerselection.xml" var['JAFTERDIALOG_ACTION'] = "selectguestfromlist" if action == "before" : roomRes = {} reservation = R.findElem(resName) # list of guests gList = ROP.getResGuestList(resName) for r in reservation.getResDetail() : rname = r.getRoomName() room = ROOM.findElem(rname) servicename = r.getService() serv = SE.findElem(servicename) nop = serv.getNoPersons() if roomRes.has_key(rname) : no = roomRes[rname][0] if nop > no : roomRes[rname][0] = nop else : roomRes[rname] = (nop,room) list = [] wasGuest = False for roomname in roomRes.keys() : for i in range(roomRes[roomname][0]) : map = { "roomid" : roomname, "roomdesc" : roomRes[roomname][1].getDescription()} # add guest details no = -1 found = False for g in gList : if g.getRoomName() == roomname : no = no + 1 if no == i : found = True custid = g.getGuestName() __toMap(map,custid,CUST) found = True wasGuest = True break if not found : map["guestselect"] = "<select>" cust.setDefaCustomerNotCopy(map) list.append(map) var["JLIST_MAP"] = { CHECKINLIST : list} cutil.setChangeEditMode(var,CHECKINLIST,["surname","firstname","title","country"]) resform = R.findElem(resName) assert resform != None status = util.resStatus(resform) var["isstay"] = (status == 1) cutil.setCopy(var,"isstay") if status == 2 : cutil.hideButton(var,"acceptchange") else : cutil.hideButton(var,"accept") if status == 2 and not wasGuest : custid = resform.getCustomerName() map = list[0] __toMap(map,custid,CUST)
def dialogaction(action,var) : cutil.printVar("search for rooms",action,var) if action == "before" : var["search_from"] = con.today() var["searchby_days"] = True var["search_nop"] = 2 var["search_days"] = 1 cutil.setCopy(var,["search_from","searchby_days","search_nop","search_days"]) if var["JUPDIALOG_START"] != None : html = var["JUPDIALOG_START"] var["search_html"] = html cutil.setCopy(var,"search_html") cutil.hideButton(var,"tores",True) cutil.hideButton(var,"toresrese",False) if action=="search" : if not _validate(var) : return roo = rutil.searchForRooms(var,var["search_from"],var["search_to"]) alist = None if var["search_html"] != None : (m,alist) = xmlutil.toMap(var["search_html"]) print alist li = [] for l in roo : found = False if alist != None : for re in alist : if re["resroomname"] != l : continue da = re["resday"] if da < var["search_from"] : continue if da >= var["search_to"] : continue print found found = True break if found : continue map = {"search_roomid" : l} util.addRoom(var,l,map,"search_roomcapa","search_roomdesc") ss = util.getServicesForRoom(var,l) if ss != None: map["search_roomservice"] = ss[0][0].getName() map["search_roompricelist"] = ss[1][0] (price,pricechild,priceextra) = rutil.getPriceList(var,ss[1][0],ss[0][0].getName()) perperson = ss[0][0].isPerperson() map["search_price"] = price total= rutil.calculatePrice(perperson,var["search_nop"],0,0,price,pricechild,priceextra) map["search_priceperson"] = total map["search_pricetotal"] = con.mulIntDecimal(var["search_days"],total) li.append(map) cutil.setJMapList(var,LISTID,li) if action == "seton" and var[LISTID+"_lineset"] : _goto(var) if action == "tores" and var[LISTID+"_lineset"] : if not _validate(var) : return _goto(var) var["JCLOSE_DIALOG"] = True diallaunch.newreservation(var,var["search_roomid"],var["search_from"],var["search_days"],var["search_nop"],var["search_roomservice"],var["search_roompricelist"]) if action == "toresrese" and var[LISTID+"_lineset"] : if not _validate(var) : return _goto(var) var["JCLOSE_DIALOG"] = _setStartRes(var)
def elemserviceaction(action, var): cutil.printVar("elemserviceaction", action, var) serv = util.SERVICES(var) if action == "before": if var["JCRUD_DIALOG"] == "crud_add": var["noperson"] = D.getDataHI(10) var["noextrabeds"] = D.getDataHI(11) var["nochildren"] = D.getDataHI(12) var["vat"] = D.getDataH(14) var["perperson"] = D.getDataHB(13) cutil.setCopy( var, ["noperson", "noextrabeds", "nochildren", "vat", "perperson"]) else: cutil.hideButton(var, "showrooms", False) if action == "showrooms": l = util.listOfRoomsForService(var, var["name"]) print l for s in l: print s var["JUPDIALOG_START"] = xmlutil.listNumberToCVS(l, "-1") var["JUP_DIALOG"] = "?roomslist.xml" if action == "crud_add" and not var["JCRUD_AFTERCONF"]: if util.duplicateService(var) or _notverifyService(var): return var["JYESNO_MESSAGE"] = M("ADDNEWSERVICEASK") var["JMESSAGE_TITLE"] = "" return if action == "crud_add" and var["JCRUD_AFTERCONF"]: se = _createService(var) serv.addElem(se) var["JCLOSE_DIALOG"] = True return if action == "crud_change" and not var["JCRUD_AFTERCONF"]: if _notverifyService(var): return var["JYESNO_MESSAGE"] = M("CHANGESERVICEASK") var["JMESSAGE_TITLE"] = "" return if action == "crud_change" and var["JCRUD_AFTERCONF"]: se = _createService(var) serv.changeElem(se) var["JCLOSE_DIALOG"] = True if action == "crud_remove" and not var["JCRUD_AFTERCONF"]: l = util.listOfRoomsForService(var, var["name"]) l1 = util.RESOP(var).getReseForService(var["name"]) l2 = util.listOfPriceListForService(var, var["name"]) if len(l) > 0 or len(l1) > 0 or len(l2) > 0: var["JERROR_MESSAGE"] = M("cannotremoveservice").format( len(l), len(l2), len(l1)) return var["JYESNO_MESSAGE"] = M("DELETESERVICEASK") var["JMESSAGE_TITLE"] = "" return if action == "crud_remove" and var["JCRUD_AFTERCONF"]: se = _createService(var) serv.deleteElem(se) var["JCLOSE_DIALOG"] = True
def elemserviceaction(action,var) : cutil.printVar ("elemserviceaction", action,var) serv = util.SERVICES(var) if action == "before" : if var["JCRUD_DIALOG"] == "crud_add" : var["noperson"] = D.getDataHI(10) var["noextrabeds"] = D.getDataHI(11) var["nochildren"] = D.getDataHI(12) var["vat"] = D.getDataH(14) var["perperson"] = D.getDataHB(13) cutil.setCopy(var,["noperson","noextrabeds","nochildren","vat","perperson"]) else : cutil.hideButton(var,"showrooms",False) if action == "showrooms" : l = util.listOfRoomsForService(var,var["name"]) print l for s in l : print s var["JUPDIALOG_START"] = xmlutil.listNumberToCVS(l,"-1") var["JUP_DIALOG"] = "?roomslist.xml" if action == "crud_add" and not var["JCRUD_AFTERCONF"] : if util.duplicateService(var) or _notverifyService(var) : return var["JYESNO_MESSAGE"] = M("ADDNEWSERVICEASK") var["JMESSAGE_TITLE"] = "" return if action == "crud_add" and var["JCRUD_AFTERCONF"] : se = _createService(var) serv.addElem(se) var["JCLOSE_DIALOG"] = True return if action == "crud_change" and not var["JCRUD_AFTERCONF"] : if _notverifyService(var) : return var["JYESNO_MESSAGE"] = M("CHANGESERVICEASK") var["JMESSAGE_TITLE"] = "" return if action == "crud_change" and var["JCRUD_AFTERCONF"] : se = _createService(var) serv.changeElem(se) var["JCLOSE_DIALOG"] = True if action == "crud_remove" and not var["JCRUD_AFTERCONF"] : l = util.listOfRoomsForService(var,var["name"]) l1 = util.RESOP(var).getReseForService(var["name"]) l2 = util.listOfPriceListForService(var,var["name"]) if len(l) > 0 or len(l1) > 0 or len(l2) > 0 : var["JERROR_MESSAGE"] = M("cannotremoveservice").format(len(l),len(l2),len(l1)) return var["JYESNO_MESSAGE"] = M("DELETESERVICEASK") var["JMESSAGE_TITLE"] = "" return if action == "crud_remove" and var["JCRUD_AFTERCONF"] : se = _createService(var) serv.deleteElem(se) var["JCLOSE_DIALOG"] = True
def dialogaction(action, var): cutil.printVar("search for rooms", action, var) if action == "before": var["search_from"] = con.today() var["searchby_days"] = True var["search_nop"] = 2 var["search_days"] = 1 cutil.setCopy( var, ["search_from", "searchby_days", "search_nop", "search_days"]) if var["JUPDIALOG_START"] != None: html = var["JUPDIALOG_START"] var["search_html"] = html cutil.setCopy(var, "search_html") cutil.hideButton(var, "tores", True) cutil.hideButton(var, "toresrese", False) if action == "search": if not _validate(var): return roo = rutil.searchForRooms(var, var["search_from"], var["search_to"]) alist = None if var["search_html"] != None: (m, alist) = xmlutil.toMap(var["search_html"]) print alist li = [] for l in roo: found = False if alist != None: for re in alist: if re["resroomname"] != l: continue da = re["resday"] if da < var["search_from"]: continue if da >= var["search_to"]: continue print found found = True break if found: continue map = {"search_roomid": l} util.addRoom(var, l, map, "search_roomcapa", "search_roomdesc") ss = util.getServicesForRoom(var, l) if ss != None: map["search_roomservice"] = ss[0][0].getName() map["search_roompricelist"] = ss[1][0] (price, pricechild, priceextra) = rutil.getPriceList(var, ss[1][0], ss[0][0].getName()) perperson = ss[0][0].isPerperson() map["search_price"] = price total = rutil.calculatePrice(perperson, var["search_nop"], 0, 0, price, pricechild, priceextra) map["search_priceperson"] = total map["search_pricetotal"] = con.mulIntDecimal( var["search_days"], total) li.append(map) cutil.setJMapList(var, LISTID, li) if action == "seton" and var[LISTID + "_lineset"]: _goto(var) if action == "tores" and var[LISTID + "_lineset"]: if not _validate(var): return _goto(var) var["JCLOSE_DIALOG"] = True diallaunch.newreservation(var, var["search_roomid"], var["search_from"], var["search_days"], var["search_nop"], var["search_roomservice"], var["search_roompricelist"]) if action == "toresrese" and var[LISTID + "_lineset"]: if not _validate(var): return _goto(var) var["JCLOSE_DIALOG"] = _setStartRes(var)
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"