示例#1
0
def print_item_history(item):
    print '''<br /> <b>30 day history for item %d (%s) </b><br />''' % (item.get_id(), item)
    total_sales,total_deliveries,total_slush,history = db.get_item_history(item.get_id(),30)
    print '<b>Total sales: %d <br />' % (total_sales,)
    print 'Total deliveries: %d <br />' % (total_deliveries,)
    print 'Total slushfunded: %d <br /></b>' % (total_slush,)
    print '''<table><thead><th>Date</th><th>+/-</th><th>Type</th></thead>'''
    for ttp in history:
        print '''<tr><td>%s</td><td>%.2f</td><td>%s</td></tr>''' % ttp
    print '''</table>'''
示例#2
0
def main():
    print_headers()
    print '''<body>'''
    print '''<form name="item" action="inventory_history.py" method="get">'''
    print '''Input an item SKU:'''
    print '''<input type="text" name="itemid" size="4" /> <input type="submit" value="Display" />'''
    print '''</form>'''
    form = cgi.FieldStorage()
    if "itemid" in form:
        itemid = int(form.getvalue("itemid"))
        item = db.get_item(itemid)
        print '''<br /> <b>30 day history for item %d (%s) </b><br />''' % (itemid, item)
        total_sales,total_deliveries,total_slush,history = db.get_item_history(itemid,30)
        print '<b>Total sales: %d <br />' % (total_sales,)
        print 'Total deliveries: %d <br />' % (total_deliveries,)
        print 'Total slushfunded: %d <br /></b>' % (total_slush,)
        print '''<table><thead><th>Date</th><th>+/-</th><th>Type</th></thead>'''
        for ttp in history:
            print '''<tr><td>%s</td><td>%.2f</td><td>%s</td></tr>''' % ttp
        print '''</table>'''
    print '''</body></html>'''