예제 #1
0
def _createServicesList(var):
    S = util.SERVICES(var)
    R = util.ROOMLIST(var)
    
    slist = []
    if var["JCRUD_DIALOG"] == "crud_change" :
      getN = None
      slist = R.getRoomServices(var["name"])
    else :
      ss = D.getDataH(20)
      if ss == None : slist = []
      else : slist = ss.split(',')
      getN = lambda s : s
      var["noperson"] = D.getDataHI(21)
      var["nochildren"] = D.getDataHI(22)
      var["noextrabeds"] = D.getDataHI(23)
      cutil.setCopy(var,["noperson","nochildren","noextrabeds"])
      
    seq = S.getRoomServices()
    list = []
    for s in seq :
      check = util.findElemInSeq(s.getName(),slist, getN) != None
      map = {"check" : check ,"service" : s.getName(), "servdescr" : s.getDescription(), "perperson" : s.isPerperson()}
      _setNumb(map,s)
      list.append( map )
      
    cutil.setJMapList(var,SERVLIST,list)
예제 #2
0
def _duplicatedRoomName(var):    
    R = util.ROOMLIST(var)
    seq = R.getList()
    if util.findElemInSeq(var["name"],seq) != None :
      var["JERROR_name"] = M("DUPLICATEDROOMNAME")
      return True
    return False
예제 #3
0
def _getList(var):
    R = util.ROOMLIST(var)
    seq = R.getList()
    list = []

    for s in seq:
        list.append({
            "name": s.getName(),
            "descr": s.getDescription(),
            "noperson": s.getNoPersons()
        })
    return list
예제 #4
0
def elemroomaction(action,var) :
    
  cutil.printVar("elemroomaction",action, var)  
  R = util.ROOMLIST(var)

  if action == "columnchangeaction" :
    if not var["check"] : return
    serv = util.SERVICES(var).findElem(var["service"])
    assert serv != None
    _setNumb(var,serv)
    cutil.setCopy(var,["noperson","nochildren","noextrabeds"])    

  if action == "before" :
      _createServicesList(var)
      if var["JCRUD_DIALOG"] == "crud_add" or var["JCRUD_DIALOG"] == "crud_change" : cutil.setChangeEditMode(var,SERVLIST,"check")
    
  if action == "crud_add"  and not var["JCRUD_AFTERCONF"] :
      if _duplicatedRoomName(var) or _notValidRoomDesc(var): return
      var["JYESNO_MESSAGE"] = M("ADDNEWROOMASK")
      var["JMESSAGE_TITLE"] = ""  
      return
      
  if action == "crud_add"  and var["JCRUD_AFTERCONF"] :
      a = _getServiceList(var)
      R.addElem(_createRoom(var,a))
      R.setRoomServices(var["name"],a)
      var["JCLOSE_DIALOG"] = True
      return

  if action == "crud_change"  and not var["JCRUD_AFTERCONF"] :
      if _notValidRoomDesc(var): return
      var["JYESNO_MESSAGE"] = M("CHANGEROOMASK")
      var["JMESSAGE_TITLE"] = ""  
      return

  if action == "crud_change"  and var["JCRUD_AFTERCONF"] :
      a = _getServiceList(var)
      R.changeElem(_createRoom(var,a))
      R.setRoomServices(var["name"],a)
      var["JCLOSE_DIALOG"] = True

  if action == "crud_remove"  and not var["JCRUD_AFTERCONF"] :    
      l = util.RESOP(var).getReseForRoom(var["name"])
      if len(l) > 0 :
         var["JERROR_MESSAGE"] = M("cannotremoveroom").format(len(l))
         return
      var["JYESNO_MESSAGE"] = M("REMOVEROOMASK")
      var["JMESSAGE_TITLE"] = ""  
      return
  
  if action == "crud_remove"  and var["JCRUD_AFTERCONF"] :
      R.deleteElem(_createRoom(var))
      var["JCLOSE_DIALOG"] = True 
예제 #5
0
def _createList(var):
    resName = var["resename"]
    ROOM = util.ROOMLIST(var)
    ROP = util.RESOP(var)
    CU = util.CUSTOMERLIST(var)
    list = []
    gList = ROP.getResGuestList(resName)
    for g in gList:
        room = g.getRoomName()
        guest = g.getGuestName()
        rdescr = ROOM.findElem(room).getDescription()
        c = CU.findElem(guest)
        map = {"roomid": room, "roomdesc": rdescr}
        cust.toCustomerVar(map, c, "guest_")
        list.append(map)
    var["JLIST_MAP"] = {RLIST: list}
예제 #6
0
def _createList(var):
    fList = var["filterlist"]
    li = []
    if fList != None :
      li = xmlutil.CVSToListNumber(fList)
    R = util.ROOMLIST(var)
    seq = R.getList()
    list = []
    
    for s in seq : 
       if len(li) > 0 :
          fS = util.findElemInSeq(s.getId(),li,lambda x : x)
          if fS == None : continue
       map = {"name" : s.getName(), "descr" : s.getDescription()}
       _setNumb(map,s)
       list.append(map )
       
    cutil.setJMapList(var,RLIST,list)
예제 #7
0
def setvarBefore(var,custo=RCUST):
    xml = var["JUPDIALOG_START"]
    (roomname,resday,resdays,nop,roomservice,roompricelist) = rparam.XMLtoresquery(xml)
    if roomservice != None and roompricelist != None : rutil.setServicePriceList(var,roomservice,roompricelist)      
      
    R = util.ROOMLIST(var)
    room = R.findElem(roomname)
    assert room != None
    if nop == None : nop = room.getNoPersons()
    var["name"] = roomname
    var["desc"] = room.getDescription()
    var["nop"] = nop
    var["noextrabeds"] = util.getIntField(room.getNoExtraBeds())
    var["nochildren"] = util.getIntField(room.getNoChildren())
    var["resnop"] = util.getIntField(nop)
    util.setCopy(var,["resename","name","datecol","desc","resdays","noextrabeds","nochildren","nop","serviceperperson","resnop"])
#    util.setCopy(var,["resnochildren","respricechildren","resnoextrabeds","respriceextrabeds","respriceperroom","resnop"])
    res = rutil.getReservForDay(var,roomname,resday)
    if len(res) == 0 :
      var["datecol"] = resday
      var["resdays"] = resdays
      var["resename"] = None
      cust.setDefaCustomer(var,custo)
      return
  
    assert len(res) == 1
    resname = res[0].getResId()
    assert resname != None
    RFORM = util.RESFORM(var)
    reservation = RFORM.findElem(resname)
    assert reservation != None
    custname = reservation.getCustomerName()
    assert custname != None
    rutil.setReseName(var,resname)
        
    cust.setCustData(var,custname,custo)
    
    perperson = True    
    list = []
    S = util.SERVICES(var)
    mindate = None
    for r in reservation.getResDetail() :
                 
         map = { "avail" : True, "resroomname" : r.getRoomName(), "resday" : r.getResDate(), "rlist_pricetotal" : con.BigDecimalToDecimal(r.getPriceTotal()), 
              "rline_nop" : r.getNoP(),"rlist_priceperson" : con.BigDecimalToDecimal(r.getPrice()),
              "rlist_noc" : util.getIntField(r.getNoChildren()), "rlist_pricechildren" : con.BigDecimalToDecimal(r.getPriceChildren()),
              "rlist_noe" : util.getIntField(r.getNoExtraBeds()), "rlist_priceextra" : con.BigDecimalToDecimal(r.getPriceExtraBeds()),
              "rlist_serviceperperson" : r.isPerperson(), 
              "rlist_roomservice" : r.getService(), "rlist_roompricelist" : r.getPriceListName()}

         if not r.isPerperson() : perperson = False
         if mindate == None : mindate = r.getResDate()
         elif mindate > r.getResDate() : mindate = r.getResDate()
         roomservice = cutil.ifnull(roomservice,r.getService())
         roompricelist = cutil.ifnull(roompricelist,r.getPriceListName())

         list.append(map)

    var["serviceperperson"] = perperson
    # restores default data previously saved
    reseparam.RESPARAM(resname).setParam(var)    
    rutil.setServicePriceList(var,roomservice,roompricelist)
    var["datecol"] = mindate
    var["resdays"] = len(reservation.getResDetail())
    
    # advance payment

    SUM = advarese.CALCULATE()
    SUM.calc(reservation)
    A = advarese.createAdvaRese(var)
    A.setVal(reservation,SUM.getTotal())
    A.setCopy()
    
    confirm.createC(var).setReservationToVar(reservation)
    
    cutil.setJMapList(var,RLIST,list)
    cutil.setFooter(var,RLIST,"rlist_pricetotal",SUM.getTotal())        
예제 #8
0
def reservationaction(action, var):
    cutil.printVar("reservation", action, var)

    if action == "before":
        list = _getList(var)
        var["JDATELINE_MAP"] = {"reservation": {"linedef": list}}

    if action == "datelineaction":
        (room, day) = rutil.getRoomDateFromVar(var)
        R = util.RESOP(var)
        RO = util.ROOMLIST(var)
        RFORM = util.RESFORM(var)
        services = RO.getRoomServices(room)
        if len(services) == 0:
            var['JERROR_MESSAGE'] = "@noserviceassigned"
            var['JMESSAGE_TITLE'] = "@incompleteconfiguration"
            return
        li = util.getServicesForRoom(var, room)
        if li == None:
            var['JERROR_MESSAGE'] = "@nopricelistforthisservice"
            var['JMESSAGE_TITLE'] = "@incompleteconfiguration"
            return

        res = rutil.getReservForDay(var, room, day)

        if res.isEmpty():
            diallaunch.newreservation(var, room, day, 1, 1)
        else:
            ares = res.get(0)
            resid = ares.getResId()
            (room, day) = rutil.getRoomDateFromVar(var)
            diallaunch.reservationdialogaction(var, resid, room, day)

    if action == "datelinevalues":
        seq = var["JDATELINE_QUERYLIST"]
        vals = []
        query = cutil.createArrayList()
        R = util.RESOP(var)
        RFORM = util.RESFORM(var)
        for s in seq:
            dfrom = s["JDATELINE_FROM"]
            dto = s["JDATELINE_TO"]
            name = s["name"]
            q = rutil.createResQueryElem(name, dfrom, dto)
            query.add(q)

        resList = R.queryReservation(query)
        vals = []

        dl = datetime.timedelta(1)
        for s in seq:
            dfrom = s["JDATELINE_FROM"]
            dto = s["JDATELINE_TO"]
            name = s["name"]
            dt = dfrom
            prevres = None
            prevmap = None
            while dt <= dto:
                resid = None
                for ans in resList:
                    aname = ans.getRoomName()
                    dres = ans.getResDate()
                    if con.eqDate(dt, dres) and aname == name:
                        resid = ans.getResId()
                        break

                if resid != None:
                    if resid == prevres:
                        prevmap["colspan"] = prevmap["colspan"] + 1
                    else:
                        if prevmap: vals.append(prevmap)
                        rform = RFORM.findElem(resid)
                        sta = resstat.getResStatus(var, rform)
                        form = "resroom"
                        map = {
                            "name": name,
                            "datecol": dt,
                            "colspan": 1,
                            "form": form,
                            "0": _resInfo(var, resid),
                            "1": resstat.COLORS[sta],
                            "hint": "@" + resstat.getStatusS(sta)
                        }
                        prevmap = map
                        prevres = resid
                dt = dt + dl
            if prevmap: vals.append(prevmap)

        var["JDATELINE_MAP"] = {"reservation": {"values": vals}}
예제 #9
0
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)
예제 #10
0
def allroomsenum(action, var):
    li = util.ROOMLIST(var).getList()
    f = lambda elem: [elem.getName(), elem.getName()]
    cutil.setJMapList(var, "allroomslist", util.createEnumFromList(li, f))
예제 #11
0
def dialogaction(action, var):
    cutil.printVar("testresemail", action, var)

    if action == "createxml":
        R = util.ROOMLIST(var)
        C = util.CUSTOMERLIST(var)
        RES = util.RESFORM(var)

        E = util.newHotelRoom()
        E.setName("R01")
        R.addElem(E)
        CC = cust.newCustomer(var)
        CC.setDescription("I'm the customer")
        CC = C.addElem(CC)
        print CC.getName()
        dt = datetime.date(2014, 1, 2)
        dl = datetime.timedelta(1)
        #        dto = datetime.date(2010,1,5)
        #        q = rutil.createResQueryElem("R01",dfrom,dto)
        #        print q
        re = util.newResForm(var)
        re.setCustomerName(CC.getName())
        for i in range(10):
            r = util.newResAddPayment()
            r.setNoP(2)
            r.setPrice(con.toB(100.0))
            r.setPriceTotal(con.toB(100.0))
            r.setPriceList(con.toB(200.0))
            r.setRoomName("R01")
            r.setVat("7%")
            r.setResDate(con.toDate(dt))
            dt = dt + dl
            re.getResDetail().add(r)

        re = RES.addElem(re)
        print re.getName()
        s = rpdf.buildXMLReservation(var, re.getName())
        print s
        tt = pdfutil.xsltHtmlS("mailxslt/reseconfirmation.xslt", s)
        print tt
        H = hmail.HotelMail(var)
        #        H.    def sendMail(self,mtype,resname,custname,subject,content,to,froma,attachList=None,text=True):
        hh = H.sendMail(0, re.getName(), CC.getName(), "Reservation", tt,
                        "*****@*****.**", "hotel")
        assert hh != None
        var["OK"] = True

    if action == "listxml":
        H = hmail.HotelMail(var)
        li = H.getList()
        assert len(li) == 1
        for l in li:
            print l
            print l.getName()
            print l.getReseName()
        var["OK"] = True

    if action == "testfailed":
        H = hmail.HotelMail(var)
        li = H.getList()
        h = li[0]
        # should fail because to space in 'from' address
        hh = H.sendMail(0, h.getReseName(), h.getCustomerName(), "Reservation",
                        "Hi Hi - good joke", "*****@*****.**",
                        "Java hotel")
        assert hh != None
        mailName = hh.getName()
        print mailName
        M = H.getCMail(mailName)
        assert M != None
        res = M.getSendResult()
        print res
        assert res != None
        var["OK"] = True