Beispiel #1
0
   def run(self,var) :
     # double check (under semaphore) that reservation is not already changed to STAY
     resName = var["resename"]
     R = util.RESFORM(var)
     ROP = util.RESOP(var)
     CUST = util.CUSTOMERLIST(var)
     r = R.findElem(resName)
     if not var["isstay"] and util.resStatus(r) == 1 :
       var["JERROR_MESSAGE"] = M("ALREADYCHECKEDINMESS")
       var["JMESSAGE_TITLE"] = M("ALREADYCHECKEDINTITLE")
       return
     a = cutil.createArrayList()
     for custo in var["JLIST_MAP"][CHECKINLIST] :
           if cutil.allEmpty(custo,cust.getCustFieldIdWithout()) : continue
           cid = custo["name"]
           if cid == None : c = cust.newCustomer(var)
           else : c = CUST.findElem(cid)
           cust.customerDataFromVar(c,custo)
           if cid == None : cid = CUST.addElem(c).getName()
           else : CUST.changeElem(c)
           cust.saveDefaCustomer(custo)
           rGuest = util.newResGuest(var)
           rGuest.setGuestName(cid)
           rid = custo["roomid"]
           rGuest.setRoomName(rid)
           a.add(rGuest)
     ROP.setResGuestList(resName,a)
     if var["isstay"] : cutil.JOURNAL(var).addJournalElem(util.JOURNAL_CHANGELISTOFGUEST,None,resName)

     var["JCLOSE_DIALOG"] = True   
def dialogaction(action, var):
    cutil.printVar("dialog1", action, var)

    if action == "modif":
        print "aaa"
        pe = __createHotelPerson(var, False)
        pe.setName("person")
        A = sec.ObjectAdmin(__getI(var))
        A.addOrModifPerson(pe, cutil.createArrayList())
        ho = __createHotelPerson(var, True)
        perm = cutil.createArrayList()
        #      role = HotelRoles(pe)
        role = sec.createObjectRoles(pe)
        role.getRoles().add("man")
        perm.add(role)
        A.addOrModifObject(ho, perm)
def dialogaction(action,var) :
  cutil.printVar("dialog1",action,var)  
    
  if action == "modif" :
      print "aaa"
      pe = __createHotelPerson(var,False)
      pe.setName("person")
      A = sec.ObjectAdmin(__getI(var))
      A.addOrModifPerson(pe,cutil.createArrayList())
      ho = __createHotelPerson(var,True)
      perm = cutil.createArrayList()
#      role = HotelRoles(pe)
      role = sec.createObjectRoles(pe)
      role.getRoles().add("man")
      perm.add(role)
      A.addOrModifObject(ho,perm)
Beispiel #4
0
def getReservForDay(var, room, day):
    R = util.RESOP(var)
    #   room = var["JDATELINE_LINE"]
    #   day = var["JDATELINE_DATE"]
    query = cutil.createArrayList()
    q = createResQueryElem(room, day, day)
    query.add(q)
    res = R.queryReservation(query)
    return res
Beispiel #5
0
def _createResData(var,new):
  service = var["roomservice"]
  if cutil.emptyS(service) : return None
  pricelist = var["roompricelist"]
  if cutil.emptyS(pricelist) : return None
  roomname = var["name"]
  date = var["datecol"]
  resdays = var["resdays"]
  dl = datetime.timedelta(1)
  dt = date
  sum = util.SUMBDECIMAL()
  if new :
    list = []
  else :
    list = var["JLIST_MAP"][RESLIST]
    sum.add(var["JFOOTER_reslist_rlist_pricetotal"])
  resnop = var["resnop"]
  perperson = var["serviceperperson"]
  priceroom = var["respriceperroom"]
  priceperson = var["respriceperson"]
  pricechildren = None
  priceextra = None
  resnoc = var["resnochildren"]
  if resnoc : pricechildren = var["respricechildren"]
  resextra = var["resnoextrabeds"]
  if resextra : priceextra = var["respriceextrabeds"]
    
  price = rutil.calculatePrice(perperson,resnop,resnoc,resextra,priceperson,pricechildren,priceextra,priceroom)
  
  query = cutil.createArrayList()
  RES = util.RESOP(var)
  qelem = rutil.createResQueryElem(roomname,date,con.incDays(date,resdays))
  query.add(qelem)
  rList = RES.queryReservation(query)
  allavail = True
  
  resename = rutil.getReseName(var)

  for i in range(resdays) :
#      price = pPrice.getPrice()
      avail = True
      for re in rList :
          rdata = re.getResDate()
          if con.eqDate(dt,rdata) : 
            if resename == None or resename != re.getResId() : 
              avail = allavail = False
      
      map = { "avail" : avail, "resroomname" : roomname, "resday" : dt, "rlist_pricetotal" : price, "rline_nop" : resnop,"rlist_priceperson" : priceperson,
              "rlist_noc" : resnoc, "rlist_pricechildren" : pricechildren, "rlist_noe" : resextra, "rlist_priceextra" : priceextra,              
              "rlist_serviceperperson" : perperson, "rlist_roomservice" : service, "rlist_roompricelist" : pricelist}
      list.append(map)
      dt = dt + dl
      sum.add(price)
    
  return [list,sum.sum,allavail]    
Beispiel #6
0
    def prepareRoles(self):
        l = cutil.createArrayList()
        if not self.var.has_key("JCHECK_MAP"): return l
        map = self.var["JCHECK_MAP"][PERM]

        for row in map.keys():
            ho = sec.createObjectOrPerson(not self.hotel, row, None)
            role = sec.createObjectRoles(ho)
            seq = map[row]
            for r in seq:
                name = r["id"]
                if r["val"]: role.getRoles().add(name)
            l.add(role)
        return l
Beispiel #7
0
def checkReseAvailibity(var, list, avail, resday, resroomname):
    """ Validate reservation
  Args:
    var
    list : List of reservations
    avail : If not none field with 'available' information
    resday : Field with reservation day
    resroomname : Field with room name to reserve
  Returns: 
    None Reservation OK
    (date,roomname) Not valid and position of error
  """

    # check if reservation not doubled
    b = sets.Set()
    for p in list:
        dat = p[resday]
        roomname = p[resroomname]
        if (dat, roomname) in b:
            _setDuplicatedReservation(var, dat, roomname)
            return (dat, roomname)
        b.add((dat, roomname))

    RES = util.RESOP(var)
    query = cutil.createArrayList()
    for p in list:
        dat = p[resday]
        roomname = p[resroomname]
        if avail != None and not p[avail]:
            setAlreadyReservedNotAvailable(var)
            return (dat, roomname)
        qelem = createResQueryElem(roomname, dat, dat)
        query.add(qelem)
    rList = RES.queryReservation(query)
    # analize if other reservation
    resename = getReseName(var)
    alreadyres = len(rList)
    dat = None
    roomname = None
    if resename:
        alreadyres = 0
        for r in rList:
            if r.getResId() != resename:
                dat = r.getResDate()
                roomname = r.getRoomName()
                alreadyres = alreadyres + 1
    if alreadyres:
        setAlreadyReserved(var)
        return (dat, roomname)
    return None
 def readQuery(self) :
    var = self.var
    R = util.RESOP(var)
    RFORM = util.RESFORM(var)
    name = var["name"]
    year = var["year"]
    (self.dstart,self.dend) = con.getPeriod(year,1,year,12)
    query=cutil.createArrayList()
    q = rutil.createResQueryElem(self.roomname,self.dstart,self.dend)
    query.add(q)
    res = R.queryReservation(query)
    resid = None
    rese = None
    for r in res :
      presid = r.getResId()
      if presid != resid :
        rese = RFORM.findElem(presid)
        resid = presid
      self.seq.append((rese,r))
def _constructPriceElemList(var):
    if var["JCHECK_MAP"].has_key(PRICEOTHERS) :
      values = cutil.concatDict(var["JCHECK_MAP"][_PRICES],var["JCHECK_MAP"][PRICEOTHERS])
    else : values = var["JCHECK_MAP"][_PRICES]  
    seq = util.SERVICES(var).getList() 
    a = cutil.createArrayList()
    for s in seq :
        id = s.getName()
        if values.has_key(id) :
            p = HotelPriceElem()
            p.setService(id)
            notnull = False
            for v in values[id] :
                if v["val"] == None : continue
                if v["id"] == _PRICE : p.setPrice(con.toB(v["val"]))
                if v["id"] == _PRICECHILDREN : p.setChildrenPrice(con.toB(v["val"]))
                if v["id"] == _PRICEEXTRABDEDS : p.setExtrabedsPrice(con.toB(v["val"]))
                notnull = True
            if notnull : a.add(p)
    return a        
Beispiel #10
0
def _constructPriceElemList(var):
    if var["JCHECK_MAP"].has_key(PRICEOTHERS):
        values = cutil.concatDict(var["JCHECK_MAP"][_PRICES],
                                  var["JCHECK_MAP"][PRICEOTHERS])
    else:
        values = var["JCHECK_MAP"][_PRICES]
    seq = util.SERVICES(var).getList()
    a = cutil.createArrayList()
    for s in seq:
        id = s.getName()
        if values.has_key(id):
            p = HotelPriceElem()
            p.setService(id)
            notnull = False
            for v in values[id]:
                if v["val"] == None: continue
                if v["id"] == _PRICE: p.setPrice(con.toB(v["val"]))
                if v["id"] == _PRICECHILDREN:
                    p.setChildrenPrice(con.toB(v["val"]))
                if v["id"] == _PRICEEXTRABDEDS:
                    p.setExtrabedsPrice(con.toB(v["val"]))
                notnull = True
            if notnull: a.add(p)
    return a
Beispiel #11
0
def createAttachList(aList,realM,bKey,filename):
    if aList == None : aList = cutil.createArrayList()
    elem = AttachElem(realM,bKey,filename)
    aList.add(elem)
    return aList    
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}}
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}}
Beispiel #14
0
def _getServiceList(var) :
    a = cutil.createArrayList()
    seq = var["JLIST_MAP"][SERVLIST]
    for s in seq :
      if s["check"] : a.add(s["service"])
    return a  
Beispiel #15
0
def createAttachList(aList, realM, bKey, filename):
    if aList == None: aList = cutil.createArrayList()
    elem = AttachElem(realM, bKey, filename)
    aList.add(elem)
    return aList
def showstay(action,var):
   cutil.printVar("show stay",action,var)
   
   if action == "before" :
     rbefore.setvarBefore(var)
     # after 
     _listOfPayments(var)
     _ListOfBills(var)
     _setChangedFalse(var)
     PA = reseparam.RESPARAM(rutil.getReseName(var))
     PA.setParam(var)
     PA.copyParam(var)

   
   if var["billlistwaschanged"] :
    _setChangedFalse(var)   
    _ListOfBills(var)
     
   if action == "crud_readlist" and var["JLIST_NAME"] == BILLIST :
     _ListOfBills(var)     
     
   if action == "afterbill" and var["JUPDIALOG_BUTTON"] == "acceptdocument" :
     _ListOfBills(var)
     
   if action == "payerdetail" :
      cust.showCustomerDetails(var,var["payer_name"])
     
   if action == "changetoreserv" and var["JYESANSWER"] :
     res = getReservForDay(var)
     resname = res[0].getResId()
     R = util.RESOP(var)
     R.changeStatusToReserv(resname)
     a = cutil.createArrayList()
     R.setResGuestList(resname,a)
     var["JCLOSE_DIALOG"] = True
     var["JREFRESH_DATELINE_reservation"] = ""
     
   if action == "addpayment" :
      var["JUP_DIALOG"]="?addpayment.xml" 
      var["JAFTERDIALOG_ACTION"] = "afteraddpayment" 
      
   if action == "paymentslist" :
      assert var["billname"] != None
      var["JUP_DIALOG"]="?listofpayment.xml" 
      var["JAFTERDIALOG_ACTION"] = "afterlistpayments"
      var["JUPDIALOG_START"] = var["billname"]
      
   if action == "printbill" and var[BILLIST + "_lineset"] :
      var["JUP_DIALOG"]="?billprint.xml" 
      var["JUPDIALOG_START"] = var["billname"]
      
   if action == "afteraddpayment" and var["JUPDIALOG_BUTTON"] == "addpayment" :
     _listOfPayments(var)
        
   if action == "guestdesc" :
       var["JAFTERDIALOG_ACTION"] = "acceptdetails" 
       cust.showCustomerDetailstoActive(var,var[CUST+"name"])
       
   if action == "acceptdetails" and var["JUPDIALOG_BUTTON"] == "acceptask" :
        xml = var["JUPDIALOG_RES"]
        util.xmlToVar(var,xml,cust.getCustFieldIdAll(),CUST)
        cutil.setCopy(var,cust.getCustFieldIdAll(),None,CUST)
        name = var[CUST+"name"]
        resename = rutil.getReseName(var)          
        util.RESFORM(var).changeCustName(resename,name)
              
   if action == "guestdetail" :
       cust.showCustomerDetails(var,var["guest_name"])
       
   if action == "listpdf" and var[BILLIST + "_lineset"] :
      var["JUP_DIALOG"]="?pdflist.xml" 
      var["JUPDIALOG_START"] = var["billname"]
def showstay(action, var):
    cutil.printVar("show stay", action, var)

    if action == "before":
        rbefore.setvarBefore(var)
        # after
        _listOfPayments(var)
        _ListOfBills(var)
        _setChangedFalse(var)
        PA = reseparam.RESPARAM(rutil.getReseName(var))
        PA.setParam(var)
        PA.copyParam(var)

    if var["billlistwaschanged"]:
        _setChangedFalse(var)
        _ListOfBills(var)

    if action == "crud_readlist" and var["JLIST_NAME"] == BILLIST:
        _ListOfBills(var)

    if action == "afterbill" and var["JUPDIALOG_BUTTON"] == "acceptdocument":
        _ListOfBills(var)

    if action == "payerdetail":
        cust.showCustomerDetails(var, var["payer_name"])

    if action == "changetoreserv" and var["JYESANSWER"]:
        res = getReservForDay(var)
        resname = res[0].getResId()
        R = util.RESOP(var)
        R.changeStatusToReserv(resname)
        a = cutil.createArrayList()
        R.setResGuestList(resname, a)
        var["JCLOSE_DIALOG"] = True
        var["JREFRESH_DATELINE_reservation"] = ""

    if action == "addpayment":
        var["JUP_DIALOG"] = "?addpayment.xml"
        var["JAFTERDIALOG_ACTION"] = "afteraddpayment"

    if action == "paymentslist":
        assert var["billname"] != None
        var["JUP_DIALOG"] = "?listofpayment.xml"
        var["JAFTERDIALOG_ACTION"] = "afterlistpayments"
        var["JUPDIALOG_START"] = var["billname"]

    if action == "printbill" and var[BILLIST + "_lineset"]:
        var["JUP_DIALOG"] = "?billprint.xml"
        var["JUPDIALOG_START"] = var["billname"]

    if action == "afteraddpayment" and var["JUPDIALOG_BUTTON"] == "addpayment":
        _listOfPayments(var)

    if action == "guestdesc":
        var["JAFTERDIALOG_ACTION"] = "acceptdetails"
        cust.showCustomerDetailstoActive(var, var[CUST + "name"])

    if action == "acceptdetails" and var["JUPDIALOG_BUTTON"] == "acceptask":
        xml = var["JUPDIALOG_RES"]
        util.xmlToVar(var, xml, cust.getCustFieldIdAll(), CUST)
        cutil.setCopy(var, cust.getCustFieldIdAll(), None, CUST)
        name = var[CUST + "name"]
        resename = rutil.getReseName(var)
        util.RESFORM(var).changeCustName(resename, name)

    if action == "guestdetail":
        cust.showCustomerDetails(var, var["guest_name"])

    if action == "listpdf" and var[BILLIST + "_lineset"]:
        var["JUP_DIALOG"] = "?pdflist.xml"
        var["JUPDIALOG_START"] = var["billname"]