Exemplo n.º 1
0
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)
Exemplo n.º 2
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   
Exemplo n.º 3
0
def dialinfo(action,var) :
  cutil.printVar("customer stat",action,var)
  
  if action == "before" :
      custid = var["JUPDIALOG_START"]
      custR = util.CUSTOMERLIST(var).findElem(custid)
      cust.customerToVar(var,custR,CUST)
      cust.setCustVarCopy(var,CUST)
      l = util.RESOP(var).getReseForCustomer(custid)
      l1 = util.RESOP(var).getReseForGuest(custid)
      l2 = util.RESOP(var).getReseForPayer(custid)      
      _createListOfRes(var,l,CLIST)
      _createListOfRes(var,l1,GLIST)
      _createListOfRes(var,l2,PLIST)
      l3 = _createListOfMail(var)

      m = {"nofcustomer" : len(l), "nofguest" : len(l1), "nofpayer" : len(l2), "nomails" : len(l3) }
      s = util.transformXMLFromMap("custinfo.xslt",m)
      var["i_custinfo"] = s      
#      var["i_custinfo"] = M("custinfo").format(len(l),len(l1),len(l2))
      cutil.setCopy(var,"i_custinfo")

      
  if action == "shownote" :
     diallaunch.showmailnote(var,var["mailname"])      
Exemplo n.º 4
0
def _getCust(var, ma):
    cust = None
    rese = ma["resename"]
    if ma.has_key("custname"): cust = ma["custname"]
    rform = util.RESFORM(var).findElem(rese)
    assert rform != None
    if cust == None: cust = rform.getCustomerName()
    C = util.CUSTOMERLIST(var).findElem(cust)
    assert C != None
    return (C, rform)
Exemplo n.º 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}
Exemplo n.º 6
0
def elemcustomeraction(action, var):
    cutil.printVar("elemcustomeraction", action, var)
    R = util.CUSTOMERLIST(var)

    if action == "before" and var["JCRUD_DIALOG"] == "crud_add":
        cust.setDefaCustomer(var)

    if action == "crud_add" and not var["JCRUD_AFTERCONF"]:
        if _duplicatedCustomerName(var): return
        var["JYESNO_MESSAGE"] = M("ADDNEWCUSTOMERASK")
        var["JMESSAGE_TITLE"] = ""
        return

    if action == "crud_add" and var["JCRUD_AFTERCONF"]:
        R.addElem(cust.customerFromVar(var))
        cust.saveDefaCustomer(var)
        var["JCLOSE_DIALOG"] = True
        return

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

    if action == "crud_change" and var["JCRUD_AFTERCONF"]:
        R.changeElem(cust.customerFromVar(var))
        cust.saveDefaCustomer(var)
        var["JCLOSE_DIALOG"] = True

    if action == "crud_remove" and not var["JCRUD_AFTERCONF"]:
        l = util.RESOP(var).getReseForCustomer(var["name"])
        l1 = util.RESOP(var).getReseForGuest(var["name"])
        l2 = util.RESOP(var).getReseForPayer(var["name"])
        if len(l) > 0 or len(l1) > 0 or len(l2) > 0:
            var["JERROR_MESSAGE"] = M("cannotremovecustomer").format(
                len(l), len(l1), len(l2))
            return
        var["JYESNO_MESSAGE"] = M("REMOVECUSTOMERASK")
        var["JMESSAGE_TITLE"] = ""
        return

    if action == "crud_remove" and var["JCRUD_AFTERCONF"]:
        R.deleteElem(cust.customerFromVar(var))
        var["JCLOSE_DIALOG"] = True
Exemplo n.º 7
0
def _listOfPayments(var):
    rese = rutil.getReseName(var)
    li = util.RESOP(var).getResAddPaymentList(rese)
    seq = []
    sum = util.SUMBDECIMAL()
    CU = util.CUSTOMERLIST(var)
    for e in li:
        g = e.getGuestName()
        customer = CU.findElem(g)
        assert customer != None
        map = {
            "roomid": e.getRoomName(),
            "total": e.getPriceTotal(),
            "price": e.getPrice(),
            "servdescr": e.getDescription(),
            "quantity": e.getQuantity()
        }
        cust.toCustomerVar(map, customer, "guest_")
        seq.append(map)
        sum.add(e.getPriceTotal())
    cutil.setJMapList(var, "paymentlist", seq)
    cutil.setFooter(var, "paymentlist", "total", sum.sum)
def dialogaction(action, var):

    cutil.printVar("reservation", action, var)

    if action == "before":
        R = util.RESFORM(var)
        C = util.CUSTOMERLIST(var)
        seq = R.getList()
        list = []
        for s in seq:
            sta = resstat.getResStatus(var, s)
            statuS = resstat.getStatusS(sta)
            (arrival, departure, roomname, rate,
             nog) = rutil.getReseDate(var, s)
            ma = {
                "name": s.getName(),
                "resdate": s.getCreationDate(),
                "checkin": arrival,
                "checkout": departure,
                "roomname": roomname,
                "resestatus": M(statuS)
            }
            cu = C.findElem(s.getCustomerName())
            cust.toCustomerVar(ma, cu, PREC, CULIST)
            list.append(ma)

        cutil.setJMapList(var, LIST, list)

    if action == "showrese":
        resename = var["name"]
        #    (room,day) = rutil.getRoomDateFromVar(var)
        diallaunch.reservationdialogaction(var, resename, var["roomname"],
                                           var["checkin"])

    if action == "showmails":
        rename = var["name"]
        diallaunch.showlistofmail(var, rename)
Exemplo n.º 9
0
def _ListOfBills(var):
    rese = rutil.getReseName(var)
    assert rese != None
    bList = util.RESOP(var).findBillsForReservation(rese)
    seq = []
    pli = rutil.getPayments(var)
    sumtotal = 0.0
    footerpayments = 0.0
    sumsell = 0.0
    CU = util.CUSTOMERLIST(var)
    for b in bList:
        C = cbill.BILLCALC(var, b)
        C.calc()
        bName = b.getName()
        assert bName != None
        payer = b.getPayer()
        customer = CU.findElem(payer)
        assert customer != None
        da = b.getIssueDate()
        tot = C.getTotal()
        sell = C.getCharge()
        paysum = C.getPayment()
        sumtotal = cutil.addDecimal(sumtotal, tot)
        footerpayments = cutil.addDecimal(footerpayments, paysum)
        sumsell = cutil.addDecimal(sumsell, sell)
        ma = {
            "billname": bName,
            "billtotal": tot,
            "payments": paysum,
            "sell": sell
        }
        cust.toCustomerVar(ma, customer, "payer_")
        seq.append(ma)
    cutil.setJMapList(var, BILLIST, seq)
    cutil.setFooter(var, BILLIST, "billtotal", sumtotal)
    cutil.setFooter(var, BILLIST, "payments", footerpayments)
    cutil.setFooter(var, BILLIST, "sell", sumsell)
Exemplo n.º 10
0
def _createX(var, rese_name, paymentmethod=None):
    print rese_name
    cu = cust.newCustomer(var)
    #    cu.setGensymbol(True);
    cu = util.CUSTOMERLIST(var).addElem(cu)
    cust_name = cu.getName()
    print cust_name
    bli = util.RESOP(var).findBillsForReservation(rese_name)
    print bli
    for l in bli:
        print l
    assert len(bli) == 0

    R = util.RESFORM(var).findElem(rese_name)

    li = []
    for l in R.getResDetail():
        li.append(l.getId())
    print li
    assert len(li) > 0
    xml = rpdf.buildXMLForStay(var, rese_name, cust_name, li)
    print xml
    S = cbill.HOTELBILLSAVE(var, rese_name, cust_name, xml, paymentmethod)
    res = S.doTransRes()
    print res
    if not res: print var["JERROR_MESSAGE"]
    assert res
    bli = util.RESOP(var).findBillsForReservation(rese_name)
    assert len(bli) == 1
    print S.getB().getName()
    print S.getTotal()

    xml = cbill.getXMLForBill(var, S.getB().getName())
    print xml
    assert xml != None
    return (S.getB(), xml)
Exemplo n.º 11
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)
Exemplo n.º 12
0
def dialogaction(action, var):
    cutil.printVar("rese mail", action, var)

    if action == "before":
        xml = var["JUPDIALOG_START"]
        (ma, alist) = xmlutil.toMap(xml)
        rese = ma["resename"]
        mtype = ma["mailtype"]
        (C, rform) = _getCust(var, ma)
        var["to"] = C.getAttr("email")
        var["from"] = cmail.MAILFROM(var).getFrom()
        var["xml"] = xml
        (arrival, departure, roomname, rate,
         non) = rutil.getReseDate(var, rform)
        xml = rpdf.buildXMLReservation(var, rese)
        if mtype == 0:
            var["subject"] = M("confirmationmailsubject").format(
                con.toS(arrival), con.toS(departure))
            var["content"] = pdfutil.xsltHtmlS("xslt/resconfirmation.xslt",
                                               xml)
        elif mtype == 1:
            var["subject"] = M("sendpdfmailsubject").format(
                con.toS(arrival), con.toS(departure))
            var["content"] = pdfutil.xsltHtmlS("xslt/sendinvoicepdf.xslt", xml)
        else:
            assert False
        cutil.setCopy(var, ["subject", "to", "from", "content", "xml"])
        seq = []
        if alist != None:
            for l in alist:
                (realm, key, filename) = cutil.splitsubmitres(l["blobid"])
                seq.append({"filename": filename, "realm": realm, "key": key})
        cutil.setJMapList(var, ALIST, seq)
        return

    if action == "sendmail" and var["JYESANSWER"]:
        H = hmail.HotelMail(var)
        xml = var["xml"]
        (ma, templ) = xmlutil.toMap(xml)
        rese = ma["resename"]
        (C, rform) = _getCust(var, ma)
        custname = C.getName()
        mtype = ma["mailtype"]
        to = var["to"]
        fromc = var["from"]
        cmail.MAILFROM(var).saveFrom(fromc)
        content = var["content"]
        subject = var["subject"]
        C.setAttr("email", to)
        util.CUSTOMERLIST(var).changeElem(C)
        attachL = None
        li = var["JLIST_MAP"][ALIST]
        attachL = None
        for l in li:
            attachL = cmail.createAttachList(attachL, l["realm"], l["key"],
                                             l["filename"])
        hh = H.sendMail(mtype, rese, custname, subject, content, to, fromc,
                        attachL)
        ressend = H.getCMail(hh.getName()).getSendResult()
        if ressend == None:
            var["JOK_MESSAGE"] = "@okmailsent"
            var["JCLOSE_DIALOG"] = True
        else:
            var["JERROR_MESSAGE"] = ressend
            var["JMESSAGE_TITLE"] = "@errormailsent"
        cutil.JOURNAL(var).addJournalElem(util.JOURNAL_SENDCONFMAIL, None,
                                          hh.getName(), rese)

    if action == "sendmail": return

    cmailaction.mailattachaction(action, var)
Exemplo n.º 13
0
def _duplicatedCustomerName(var):
    R = util.CUSTOMERLIST(var)
    return util.duplicatedName(var, R, M("DUPLICATEDCUSTOMERNAME"))
Exemplo n.º 14
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
Exemplo n.º 15
0
   def run(self,var) :     
      # validate (under transaction !)
      if not _checkAvailibity(var) : return
      A = advarese.createAdvaRese(var)
      if not A.validate() : return
      # customer firstly
      service = var["roomservice"]
      pricelist = var["roompricelist"]
      D.putDataH(30,service)
      D.putDataH(31,pricelist)
      
      custo = cust.customerFromVar(var,CUST)
      R = util.CUSTOMERLIST(var)
      name = var["cust_name"]
      if not cutil.emptyS(name) :
          custo.setName(name)
          R.changeElem(custo)
      else :
#          custo.setGensymbol(True);
          name = R.addElem(custo).getName()
      cust.saveDefaCustomer(var,CUST)               
      # --- customer added
      
      resename = rutil.getReseName(var) 
      reservation = util.newResForm(var)
      if resename : reservation.setName(resename)
#      else : reservation.setGensymbol(True);
      reservation.setCustomerName(name)
      # advance      
      A = advarese.createAdvaRese(var)
      A.setAdvaData(reservation)
      # --
      service = var["roomservice"]
      nop = var["nop"]
      reselist = reservation.getResDetail()
      rlist = var["JLIST_MAP"][RESLIST]
      for re in rlist :
        
          (listprice,listpricechild,listpriceextra) = rutil.getPriceList(var,re["rlist_roompricelist"],re["rlist_roomservice"])

          r = util.newResAddPayment()
          r.setRoomName(re["resroomname"])
          r.setService(re["rlist_roomservice"])
          r.setResDate(con.toDate(re["resday"]))
          r.setPerperson(re["rlist_serviceperperson"])
          r.setPriceListName(re["rlist_roompricelist"])
          
          r.setNoP(re["rline_nop"])
          r.setPrice(con.toB(re["rlist_priceperson"]))
          r.setPriceList(listprice)
          
          util.setIntField(re,"rlist_noc",lambda v : r.setNoChildren(v))
          r.setPriceChildren(con.toB(re["rlist_pricechildren"]))
          r.setPriceListChildren(listpricechild)
          
          util.setIntField(re,"rlist_noe",lambda v : r.setNoExtraBeds(v))
          r.setPriceExtraBeds(con.toB(re["rlist_priceextra"]))
          r.setPriceListExtraBeds(listpriceextra)
          
          r.setPriceTotal(con.toB(re["rlist_pricetotal"]))
          
          reselist.add(r)
          
      RFORM = util.RESFORM(var)
      if resename : RFORM.changeElem(reservation)
      else : resename = RFORM.addElem(reservation).getName()
      
      reseparam.RESPARAM(resename).saveParam(var)
      
      # confirmed/not confirmed
      confirm.createC(var).changeReservation(resename)
      var["JCLOSE_DIALOG"] = True
      var["JREFRESH_DATELINE_reservation"] = ""
      
      var["JUPDIALOG_START"] = resename
      var["JUP_DIALOG"]="?sentconfirmationquestion.xml"