Exemplo n.º 1
0
 def billing_item(self, id="", **kw):
     billing_item_fields = BillingItemFields()
     widgets = billing_item_fields.declared_widgets
     data = {}
     if id != "":
         flash("editing item number " + str(id))
         item = BillingItem.get(int(id))
         widgets[6].attrs = dict(value=item.id)
         widgets[0].attrs = dict(value=item.ItemCode)
         widgets[1].default = item.ItemDescription
         widgets[2].attrs = dict(value=item.ItemUnitCost)
         widgets[3].attrs = dict(value=item.ItemType)
         widgets[4].attrs = dict(value=item.ItemDiscountMaxAllowed)
         widgets[5].attrs = dict(value=item.ItemStatus)
         widgets[7].attrs = dict(value=item.ModifyTime)
         widgets[8].attrs = dict(value=item.ModifyId)
         widgets[9].attrs = dict(value=item.CreateTime)
         widgets[10].attrs = dict(value=item.CreateId)
         widgets[11].attrs = dict(value="False")
     else:
         widgets[6].attrs = dict(value="")
         widgets[0].attrs = dict(value="")
         widgets[1].attrs = dict(text="")
         widgets[2].attrs = dict(value="")
         widgets[3].attrs = dict(value="")
         widgets[4].attrs = dict(value="")
         widgets[5].attrs = dict(value="")
         widgets[7].attrs = dict(value="")
         widgets[8].attrs = dict(value="")
         widgets[9].attrs = dict(value="")
         widgets[10].attrs = dict(value="")
         widgets[11].attrs = dict(value="True")
     form_billing_item = turbogears.widgets.TableForm(fields=billing_item_fields, submit_text="OK")
     return dict(form=form_billing_item, action="billing_item")
Exemplo n.º 2
0
    def save_item(self, **kw):

        cur_datetime = date.today()
        if kw["createtime"] == "":
            kw["createtime"] = cur_datetime
        hub.begin()
        if kw["new"]:
            item = BillingItem(
                ItemCode=kw["itemcode"],
                ItemDescription=kw["itemdescription"],
                ItemUnitCost=kw["itemunitcost"],
                ItemType=kw["itemtype"],
                ItemDiscountMaxAllowed=kw["itemdiscountmaxallowed"],
                ItemStatus=kw["itemstatus"],
                ModifyTime=cur_datetime,
                ModifyId="wesley",
                CreateTime=cur_datetime,
                CreateId="wesley",
            )
        else:
            if kw["createtime"] == "":
                createtime = cur_time
            else:
                time_strct = time.strptime(keywords["createtime"], "%Y-%m-%d %H:%M:%S")
                createtime = datetime(
                    time_strct.tm_year,
                    time_strct.tm_mon,
                    time_strct.tm_mday,
                    time_strct.tm_hour,
                    time_strct.tm_min,
                    time_strct.tm_sec,
                )
            item = BillingItem.get(kw["id"])
            item.ItemDescription = kw["itemdescription"]
            item.ItemUnitCost = kw["itemunitcost"]
            item.ItemType = kw["itemtype"]
            item.ItemDiscountMaxAllowed = kw["itemdiscountmaxallowed"]
            item.ItemStatus = kw["itemstatus"]
            item.ModifyTime = cur_datetime
            item.ModifyId = "wesley"
            item.CreateTime = kw["createtime"]
            item.CreateId = kw["createid"]

        hub.commit()
        hub.end()
        turbogears.flash("Changes saved!")
        raise cherrypy.HTTPRedirect(turbogears.url("/billing/edit_item?id=" + str(item.id)))