Exemplo n.º 1
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]    
Exemplo n.º 2
0
def dialogaction(action, var):
    cutil.printVar("send mail list", action, var)

    if action == "before" or action == "crud_readlist":
        M = cmail.CMAIL(var)
        li = M.getList()
        seq = []
        for l in li:
            fromm = l.getFrom()
            recipient = l.getRecipient()
            subject = l.getDescription()
            content = l.getContent()
            res = l.getSendResult()
            noa = None
            if cutil.emptyS(res): res = None
            if len(l.getaList()) > 0: noa = len(l.getaList())
            seq.append({
                "subject": subject,
                "to": recipient,
                "from": fromm,
                "content": content,
                "res": res,
                "name": l.getName(),
                "noattach": noa
            })
        cutil.setJMapList(var, LI, seq)

    if action == "attachlist":
        M = cmail.CMAIL(var)
        note = M.findElem(var["name"])
        l = note.getaList()
        if len(l) == 0:
            var["JOK_MESSAGE"] = "@noattachmentsmessage"
            return
        var["JUP_DIALOG"] = "?mailattachments.xml"
Exemplo n.º 3
0
def rescustInfo(var, res):
    custName = res.getCustomerName()
    cust = util.CUSTOMERLIST(var).findElem(custName)
    assert cust != None
    dName = getAttrS(cust, "surname") + " " + getAttrS(cust, "firstname")
    if cutil.emptyS(dName): dName = cust.getName()
    return dName + " , " + getAttrS(cust, "country")
Exemplo n.º 4
0
def dialogaction(action,var) :
    cutil.printVar("send mail list",action,var)
    
    if action == "before" or action == "crud_readlist" :
      M = cmail.CMAIL(var)
      li = M.getList()
      seq = []
      for l in li :
        fromm = l.getFrom()
        recipient = l.getRecipient()
        subject = l.getDescription()
        content = l.getContent()
        res = l.getSendResult()
        noa = None
        if cutil.emptyS(res) : res = None
        if len(l.getaList()) > 0 : noa = len(l.getaList())
        seq.append({ "subject" : subject,"to" : recipient, "from" : fromm, "content": content, "res" : res, "name" : l.getName(), "noattach" : noa })
      cutil.setJMapList(var,LI,seq)  
      
    if action == "attachlist" :
        M = cmail.CMAIL(var)
        note = M.findElem(var["name"])
        l = note.getaList()
        if len(l) == 0 :
    	  var["JOK_MESSAGE"] = "@noattachmentsmessage"
          return
        var["JUP_DIALOG"] = "?mailattachments.xml"
Exemplo n.º 5
0
def createEnumFromList(li, f = lambda elem : [elem.getName(), elem.getDescription()]):
    seq= []
    for elem in li :
        e = f(elem)
        id = e[0]
        name = e[1]
        if cutil.emptyS(name): name = id
        seq.append({"id" : id, "displayname" : name })
    return seq
Exemplo n.º 6
0
def createMailSeq(var,li) :
   H = HotelMail(var)
   seq = []
   for l in li :
     mm = H.getCMail(l.getName())
     res = mm.getSendResult()
     if cutil.emptyS(res) : res = None
     seq.append({ "mailname" : l.getName(),"custname" : l.getCustomerName(), "resename" : l.getReseName(),"datesend" : mm.getCreationDate(), "subject" : mm.getDescription(), "res" : res })
   return seq     
Exemplo n.º 7
0
def createEnumFromList(
        li,
        f=lambda elem: [elem.getName(), elem.getDescription()]):
    seq = []
    for elem in li:
        e = f(elem)
        id = e[0]
        name = e[1]
        if cutil.emptyS(name): name = id
        seq.append({"id": id, "displayname": name})
    return seq
Exemplo n.º 8
0
def dialogaction(action,var) :
  
  cutil.printVar("send mail",action,var)
  
  if action == "send" and var['JYESANSWER'] :       
    if var["attach"] :
       res = cmail.sendMailSingleAttach(var["subject"],var["content"],var["to"],var["from"],var["realm"],var["blobkey"],var["attach"])
    else :
       res = cmail.sendMail(var["subject"],var["content"],var["to"],var["from"])
    print res
    if cutil.emptyS(res) : var["JOK_MESSAGE"] = "Note was sent (but does not mean that will get through)"
    else : 
      var["JERROR_MESSAGE"] = res
      var["JMESSAGE_TITTLE"] = "Not was not sent"
Exemplo n.º 9
0
def dialogaction(action, var):

    cutil.printVar("send mail", action, var)

    if action == "send" and var['JYESANSWER']:
        if var["attach"]:
            res = cmail.sendMailSingleAttach(var["subject"], var["content"],
                                             var["to"], var["from"],
                                             var["realm"], var["blobkey"],
                                             var["attach"])
        else:
            res = cmail.sendMail(var["subject"], var["content"], var["to"],
                                 var["from"])
        print res
        if cutil.emptyS(res):
            var["JOK_MESSAGE"] = "Note was sent (but does not mean that will get through)"
        else:
            var["JERROR_MESSAGE"] = res
            var["JMESSAGE_TITTLE"] = "Not was not sent"
Exemplo n.º 10
0
def dialogaction(action, var):
    cutil.printVar("testmail", action, var)

    if action == "sendmail":
        C = cmail.CMAIL(var)
        res = C.sendMail("Mail from hotel", "What do you think about us ?",
                         "*****@*****.**", "Jython")
        print res.getSendResult()
        assert res.getSendResult() == None
        assert res.getName() != None
        var["OK"] = True

    if action == "checkmail":
        C = cmail.CMAIL(var)
        li = C.getList()
        print li
        for l in li:
            print l.getDescription(), l.getContent()
        assert len(li) == 1
        var["OK"] = True

    if action == "sendmailattach":
        C = cmail.CMAIL(var)
        li = C.getList()
        for l in li:
            C.removeElem(l)
        li = C.getList()
        assert len(li) == 0
        s = "Attachment"
        key = ADDBLOB.addNewBlob(cutil.PDFTEMPORARY, "TESTJ",
                                 StringUtil.toBytes(s))
        aList = cmail.createAttachList(None, cutil.PDFTEMPORARY, key,
                                       "attach.txt")
        res = C.sendMail("Mail from hotel with attachment",
                         "Nothing interesting ",
                         "*****@*****.**", "Jython", aList)
        print res.getSendResult()
        assert res.getSendResult() == None
        var["OK"] = True

    if action == "checkmailattach":
        B = SHolder.getBlobHandler()
        C = cmail.CMAIL(var)
        li = C.getList()
        assert len(li) == 1
        l = li[0]
        att = l.getaList()
        assert len(att) == 1
        for a in att:
            print a.getFileName(), a.getRealm(), a.getBlobKey()
            va = B.findBlob(a.getRealm(), a.getBlobKey())
            assert va != None
            ss = StringUtil.fromBytes(va)
            print ss
            assert ss == "Attachment"
        var["OK"] = True

    if action == "sendmultiattach":
        C = cmail.CMAIL(var)
        li = C.getList()
        for l in li:
            C.removeElem(l)
        li = C.getList()
        assert len(li) == 0

        aList = None
        for i in range(20):
            s = "Attachment content" + str(i)
            key = ADDBLOB.addNewBlob(cutil.PDFTEMPORARY, "TESTJ",
                                     StringUtil.toBytes(s))
            aList = cmail.createAttachList(aList, cutil.PDFTEMPORARY, key,
                                           "attach" + str(i) + ".txt")

        res = C.sendMail("Mail from hotel with 20 attachment",
                         "Nothing interesting inside ",
                         "*****@*****.**", "Jython", aList)
        print res.getSendResult()
        assert res.getSendResult() == None
        var["OK"] = True

    if action == "checkmultiattach":
        B = SHolder.getBlobHandler()
        C = cmail.CMAIL(var)
        li = C.getList()
        assert len(li) == 1
        l = li[0]
        att = l.getaList()
        assert len(att) == 20
        for a in att:
            print a.getFileName(), a.getRealm(), a.getBlobKey()
            va = B.findBlob(a.getRealm(), a.getBlobKey())
            assert va != None
            ss = StringUtil.fromBytes(va)
            print ss
            assert not cutil.emptyS(ss)
        var["OK"] = True
Exemplo n.º 11
0
def dialogaction(action,var):
    cutil.printVar("testmail",action,var)
    
    if action == "sendmail" :
        C = cmail.CMAIL(var)
        res = C.sendMail("Mail from hotel","What do you think about us ?","*****@*****.**","Jython")
        print res.getSendResult()
        assert res.getSendResult() == None
        assert res.getName() != None
        var["OK"] = True
        
    if action == "checkmail":    
        C = cmail.CMAIL(var)
        li = C.getList()
        print li
        for l in li :
            print l.getDescription(),l.getContent()
        assert len(li) == 1
        var["OK"] = True
        
    if action == "sendmailattach" :
        C = cmail.CMAIL(var)
        li = C.getList()
        for l in li :
            C.removeElem(l)
        li = C.getList()
        assert len(li) == 0
        s = "Attachment"
        key = ADDBLOB.addNewBlob(cutil.PDFTEMPORARY,"TESTJ",StringUtil.toBytes(s))
        aList = cmail.createAttachList(None,cutil.PDFTEMPORARY,key,"attach.txt")
        res = C.sendMail("Mail from hotel with attachment","Nothing interesting ","*****@*****.**","Jython",aList)
        print res.getSendResult()
        assert res.getSendResult() == None
        var["OK"] = True
        
    if action == "checkmailattach" :
        B = SHolder.getBlobHandler()   
        C = cmail.CMAIL(var)
        li = C.getList()
        assert len(li) == 1
        l = li[0]
        att = l.getaList()
        assert len(att) == 1
        for a in att :
            print a.getFileName(),a.getRealm(),a.getBlobKey()
            va = B.findBlob(a.getRealm(),a.getBlobKey())
            assert va != None
            ss = StringUtil.fromBytes(va)
            print ss
            assert ss ==  "Attachment"
        var["OK"] = True    
        
    if action == "sendmultiattach" :
        C = cmail.CMAIL(var)
        li = C.getList()
        for l in li :
            C.removeElem(l)
        li = C.getList()
        assert len(li) == 0
    
        aList = None    
        for i in range(20) :
          s = "Attachment content" + str(i)
          key = ADDBLOB.addNewBlob(cutil.PDFTEMPORARY,"TESTJ",StringUtil.toBytes(s))
          aList = cmail.createAttachList(aList,cutil.PDFTEMPORARY,key,"attach" + str(i) + ".txt")
          
        res = C.sendMail("Mail from hotel with 20 attachment","Nothing interesting inside ","*****@*****.**","Jython",aList)
        print res.getSendResult()
        assert res.getSendResult() == None
        var["OK"] = True

    if action == "checkmultiattach" :
        B = SHolder.getBlobHandler()   
        C = cmail.CMAIL(var)
        li = C.getList()
        assert len(li) == 1
        l = li[0]
        att = l.getaList()
        assert len(att) == 20
        for a in att :
            print a.getFileName(),a.getRealm(),a.getBlobKey()
            va = B.findBlob(a.getRealm(),a.getBlobKey())
            assert va != None
            ss = StringUtil.fromBytes(va)
            print ss
            assert not cutil.emptyS(ss)
        var["OK"] = True    
Exemplo n.º 12
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"