Esempio n. 1
0
    def addtodb(self):
        if session["user"] != "admin":
            return

        import datetime

        if request.params['value']:
            f = float(request.params['value'])
        else:
            f = 0.0

        r = round(f, 2)
        newvalue = int(r*100)

        newitem = Item(rep=int(request.params['rep']),
                       customer=request.params['customer'].upper()[:30],
                       value=newvalue,
                       costcentre=request.params['costcentre'].upper()[:20],
                       ordernum=request.params['ordernum'].upper()[:20],
                       make=request.params['make'].upper()[:30],
                       model=request.params['model'].upper()[:50],
                       part=request.params['part'].upper()[:30],
                       serial=request.params['serial'].upper()[:30],
                       asset=request.params['asset'].upper()[:30],
                       warranty=request.params['warranty'].upper()[:30],
                       issue=request.params['issue'].upper()[:300],
                       state=request.params['state'].upper()[:300],
                       location=request.params['location'].upper()[:300],
                       comment=request.params['comment'].upper()[:300])
        if request.params.get('fujitsuowned') == 'yes':
            newitem.fujitsuowned = True
        else:
            newitem.fujitsuowned = False

        newitem.initials = "AF";
        now = datetime.datetime.now()
        newitem.datein = "%s%s%s" % (now.year, now.month, now.day)
        Session.add(newitem)
        Session.commit()

        fields = ("rep", "datein", "kind", "initials", "customer", "value",
                  "costcentre", "ordernum", "make", "model", "part", "serial",
                  "asset", "warranty", "location", "issue", "state", "solution",
                  "grn", "sap", "rtsdate", "folio", "comment")

        return dict((field, getattr(newitem, field)) for field in fields)
Esempio n. 2
0
    def addtodb(self):
        if session["user"] != "admin":
            return

        import datetime

        if request.params["value"]:
            f = float(request.params["value"])
        else:
            f = 0.0

        r = round(f, 2)
        newvalue = int(r * 100)

        newitem = Item(
            rep=int(request.params["rep"]),
            customer=request.params["customer"].upper()[:30],
            value=newvalue,
            costcentre=request.params["costcentre"].upper()[:20],
            ordernum=request.params["ordernum"].upper()[:20],
            make=request.params["make"].upper()[:30],
            model=request.params["model"].upper()[:50],
            part=request.params["part"].upper()[:30],
            serial=request.params["serial"].upper()[:30],
            asset=request.params["asset"].upper()[:30],
            warranty=request.params["warranty"].upper()[:30],
            issue=request.params["issue"].upper()[:300],
            state=request.params["state"].upper()[:300],
            location=request.params["location"].upper()[:300],
            comment=request.params["comment"].upper()[:300],
        )
        if request.params.get("fujitsuowned") == "yes":
            newitem.fujitsuowned = True
        else:
            newitem.fujitsuowned = False

        newitem.initials = "AF"
        now = datetime.datetime.now()
        newitem.datein = "%s/%s/%s" % (now.day, now.month, now.year)
        Session.add(newitem)
        Session.commit()

        fields = (
            "rep",
            "datein",
            "kind",
            "initials",
            "customer",
            "value",
            "costcentre",
            "ordernum",
            "make",
            "model",
            "part",
            "serial",
            "asset",
            "warranty",
            "location",
            "issue",
            "state",
            "solution",
            "grn",
            "sap",
            "rtsdate",
            "folio",
            "comment",
        )

        return dict((field, getattr(newitem, field)) for field in fields)