Esempio n. 1
0
    def addMap(self, var):
        id = var[self.__id]
        if id == None: return
        k = str(id)
        R = self.__getR()
        RR = self.__getRR(k)
        self.__removeEntries(RR)

        for id in self.__map.keys():
            ttype = self.__map[id]
            if var.has_key(id):
                val = var[id]
                if val == None: vals = None
                else:
                    if ttype == LONG:
                        vals = str(val)
                    elif ttype == DATE:
                        vals = self.__tostr(val)
                    elif ttype == DECIMAL:
                        vals = con.toS(val)
                    else:
                        vals = val
                RR.putEntry(id, vals)

        R.putEntry(k, "")
Esempio n. 2
0
def _toHTML(jjdata,lform,listform,vis):
    styleborder = "border: 1px solid black;border-collapse: collapse"
    builder = XMLBuilder.create("table").a("style",styleborder)
#    builder = XMLBuilder.create("table")
    padding = "padding: 5px"
    
    # header
    builder = builder.e("tr")
    for l in listform : 
        if l[FID] in vis : builder = builder.e("th").a("style",styleborder+";" +padding).t(l[FCOLUMNNAME]).up()

    builder = builder.up()
    # content
    for d in jjdata :
        builder = builder.e("tr")
        for j in listform :
            id = j[FID]
            (ttype,tafter) = miscutil.getColumnDescr(lform,id)
#            print id,d[id],d,type(d[id])
            if not id in vis : continue
            if ttype == cutil.DECIMAL : val = con.fToSDisp(d[id],tafter)
            elif ttype == cutil.BOOL : val = con.toS(d[id])
            else: val = con.toS(d[id])
            if val == None : val = ""
            
            align = "left"
            if ttype == cutil.DATE : align = "center"
            elif ttype == cutil.DECIMAL or ttype == cutil.INT : align = "right"
            
            builder = builder.e("td").a("style",styleborder + ";" + padding + ";text-align: " + align).t(val).up()
        builder = builder.up()
    
    builder = builder.up()
    outputProperties = Properties()
    outputProperties.put(INDENT, "yes")
    return builder.root().asString(outputProperties)              
Esempio n. 3
0
def _toHTML(jjdata,lform,listform,vis):
    styleborder = "border: 1px solid black;border-collapse: collapse"
    builder = XMLBuilder.create("table").a("style",styleborder)
#    builder = XMLBuilder.create("table")
    padding = "padding: 5px"
    
    # header
    builder = builder.e("tr")
    for l in listform : 
        if l[FID] in vis : builder = builder.e("th").a("style",styleborder+";" +padding).t(l[FCOLUMNNAME]).up()

    builder = builder.up()
    # content
    for d in jjdata :
        builder = builder.e("tr")
        for j in listform :
            id = j[FID]
            (ttype,tafter) = miscutil.getColumnDescr(lform,id)
#            print id,d[id],d,type(d[id])
            if not id in vis : continue
            if ttype == cutil.DECIMAL : val = con.fToSDisp(d[id],tafter)
            elif ttype == cutil.BOOL : val = con.toS(d[id])
            else: val = con.toS(d[id])
            if val == None : val = ""
            
            align = "left"
            if ttype == cutil.DATE : align = "center"
            elif ttype == cutil.DECIMAL or ttype == cutil.LONG : align = "right"
            
            builder = builder.e("td").a("style",styleborder + ";" + padding + ";text-align: " + align).t(val).up()
        builder = builder.up()
    
    builder = builder.up()
    outputProperties = Properties()
    outputProperties.put(INDENT, "yes")
    return builder.root().asString(outputProperties)              
Esempio n. 4
0
def _toCSV(jdata,lform,listform,vis):
    li = []
    for j in jdata :
        l = None
        for f in listform :
            id = f[FID]
            if not id in vis : continue
            val = con.toS(j[id])
            if val == None : val = ""
#            print val
#            print l
            if l == None : l = val
            else : l = l + "," + val
        li.append(l)
    
    line = None
    for l in li :
        if line == None : line = l
        else : line = line + "\n" + l
        
    return line
Esempio n. 5
0
def _toCSV(jdata,lform,listform,vis):
    li = []
    for j in jdata :
        l = None
        for f in listform :
            id = f[FID]
            if not id in vis : continue
            val = con.toS(j[id])
            if val == None : val = ""
#            print val
#            print l
            if l == None : l = val
            else : l = l + "," + val
        li.append(l)
    
    line = None
    for l in li :
        if line == None : line = l
        else : line = line + "\n" + l
        
    return line
Esempio n. 6
0
    def addMap(self, var): 
        id = var[self.__id]
        if id == None : return
        k = str(id)
        R = self.__getR()
        RR = self.__getRR(k)
        self.__removeEntries(RR)
            
        for id in self.__map.keys() :
            ttype = self.__map[id]
            if var.has_key(id) :
                val = var[id]
                if val == None : vals = None
                else :
                  if ttype == LONG :                
                      vals = str(val)
                  elif ttype == DATE :
                      vals = self.__tostr(val)
                  elif ttype == DECIMAL :
                      vals = con.toS(val)    
                  else : vals = val
                RR.putEntry(id, vals)

        R.putEntry(k, "")
Esempio n. 7
0
def printVar(name, action, var):
    clog.info("==============", name)
    clog.info("action = ", action)
    for k in var.keys():
        clog.info(k, "=", con.toS(var[k]))
Esempio n. 8
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)
Esempio n. 9
0
def printVar(name, action, var):
  clog.info("==============", name)
  clog.info("action = ", action)
  for k in var.keys() :
      clog.info(k, "=", con.toS(var[k]))
Esempio n. 10
0
def dialogaction(action, var):

    cutil.printVar("stay calculation", action, var)

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

    if action == "before":
        resename = var["JUPDIALOG_START"]
        var["resename"] = resename
        cutil.setCopy(var, ["resename", "balanceat", "status"])
        R = util.RESFORM(var).findElem(resename)
        assert R != None
        (sta, ROZL) = resstat.getResStatusRese(var, R)
        var["status"] = M(resstat.getStatusS(sta))
        var["balanceat"] = ROZL.forday

        seq = []
        st = _toS("servicesatday", ROZL)
        _addElem(seq, st, ROZL.sumcost, None)
        if ROZL.sumcostafter != None: after = ROZL.sumcostafter
        else: after = 0
        _addElem(seq, _toS("servicesafter", ROZL), after, None)

        blist = util.RESOP(var).findBillsForReservation(resename)
        V = vat.CalcVat()
        for b in blist:
            bname = b.getName()
            CC = cbill.BILLCALC(var, b)
            CC.calc()
            s = M("billinfo").format(bname, con.toS(CC.getIssueDate()))
            _addElem(seq, s, CC.getCharge(), None)
            for l in CC.getLines():
                V.addVatLineC(dutil.getGrossValueLine(l),
                              dutil.getNettoValueLine(l),
                              dutil.getTaxValueLine(l), dutil.getVatLine(l))
        vl = V.calculateVat()
        for v in vl:
            (netto, vatt, gross, level, vats) = v
            s = M("vatvalueinfo").format(vats)
            _addElem(seq, s, vatt, None)

        _addElem(seq, M("paymentsum"), None, ROZL.sumpay)
        if ROZL.advancepayment != None:
            _addElem(seq, M("advanceincluded"), None, ROZL.advancepayment)

        st = _toS("balanceatf", ROZL)
        _addElem(seq, st, *calcBalance(ROZL.sumcost, ROZL.sumpay))

        cutil.setJMapList(var, LISTID, seq)

        L1 = cbill.BILLPOSADD(var, COSTS)
        for r in ROZL.costlist:
            idp = r.getId()
            L1.addMa({}, r, idp)
        L1.close()

        L2 = cbill.BILLPOSADD(var, FUTURECOSTS)
        for r in ROZL.costlistafter:
            idp = r.getId()
            L2.addMa({}, r, idp)
        L2.close()
Esempio n. 11
0
def _toS(id, ROZL):
    return M(id).format(con.toS(ROZL.forday))
Esempio 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)