Ejemplo n.º 1
0
#!/python26/python.exe
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
import cgi
from myutils import c,cursor,sql, printHeader, printFooter, gotoButton,centsToString

cgitb.enable()

form = cgi.FieldStorage()

printHeader('Edit expense')

if not form.has_key('expenseId'):
    print '<p class=error>Sorry, page called with no expense to edit</p>'
else:
    expenseId = form['expenseId'].value

    cursor.execute('SELECT expDate,description,amount FROM expense WHERE expenseId = ?',(expenseId,))
    (expDate,description,amount) = cursor.fetchone()

    print '''
<div class=addthing>
<FORM ACTION=expenses.py>
<H2>Edit expense</H2>
<table>
<tr><td align=right>Date:</td><td><INPUT TYPE=TEXT NAME=date ID=date SIZE=20 VALUE="%s" /> Format: YYYY-MM-DD</td></tr>
<tr><td align=right>Description:</td><td><INPUT TYPE=TEXT NAME=description ID=description SIZE=70 VALUE="%s" /></td></tr>
<tr><td align=right>Amount:</td><td><INPUT TYPE=TEXT NAME=amount ID=amount VALUE="%s" SIZE=5 onBlur='moneyFormat(event.target)'/>Enter negative amount for a credit</td></tr>
<INPUT TYPE=hidden NAME=edit VALUE=%s />
Ejemplo n.º 2
0
#!/python26/python.exe
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
import cgi
import sys
import urllib
from myutils import c,cursor,sql, printHeader, printFooter, gotoButton, centsToDollarString, dollarStringToCents, cell, moneyCell, getItemName

cgitb.enable()

form = cgi.FieldStorage()

printHeader('Link Ebay title to kit')

if not form.has_key('title'):
    print "No ebay listing title specified"
    sys.exit()

title = form['title'].value

print "<p>Please select a kit to link to ebay listing item <b>%s</b></p>"%title

# Get a list of all items
cursor.execute("SELECT kitId,name FROM Kit ORDER BY name")
itemOptions = []
for (itemId,name) in cursor:
    itemOptions.append('<OPTION VALUE=%s>%s</OPTION>'%(itemId,name))
print '<FORM ACTION=ebayListing.py>'
print '<SELECT NAME=kitid>'
Ejemplo n.º 3
0
#!/python26/python.exe
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
import cgi
from myutils import c,cursor,sql, printHeader, printFooter, printOptions, centsToDollarString, cell, getItemName,sortLists

cgitb.enable()

form = cgi.FieldStorage()

printHeader('Bin list')

itemId = form['itemId'].value
binId = form['binId'].value

##################################
# Get the details of what we're transferring from
cursor.execute('''
SELECT
    binId,itemId,Bin.name,Item.manufacturer,Item.brand,Item.name,quantity
FROM
    Bin
    INNER JOIN BinItems using (binId)
    INNER JOIN Item USING (itemId)
    WHERE itemId = ? AND binId = ?
''',(itemId,binId))

quantities = []
total = 0
Ejemplo n.º 4
0
#!/python26/python.exe
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
import cgi
from myutils import c,cursor,sql, printHeader, printFooter, printOptions, centsToDollarString, getTranType, getItemName

cgitb.enable()

form = cgi.FieldStorage()

printHeader('Stock detail')

itemId = form['itemId'].value

cursor.execute('SELECT manufacturer,brand,name FROM item WHERE itemId = ?',(itemId,))
(manufacturer,brand,name) = cursor.fetchone()
print "<b>Item transactions for %s</b>"%getItemName(manufacturer,brand,name)

cursor.execute('''
SELECT
    TransItem.quantity,
    TransItem.pricePerItem,
    tranDate,
    type,
    direction,
    description,
    shipping*priceperitem/(SELECT SUM(quantity*priceperitem) FROM transitem WHERE tranid = trans.tranid)
FROM
    transItem
Ejemplo n.º 5
0
#!/python26/python.exe

# enable debugging
import cgitb
import cgi
from myutils import c,cursor,sql, printHeader, printFooter, printOptions, centsToDollarString, getItemName, gotoButton, db_removeFromBin, db_addToBin
import sys

cgitb.enable()

form = cgi.FieldStorage()

printHeader('History')

# Read in the bin names and the item names - we're going to need them later
cursor.execute('SELECT binId,name FROM Bin')
binName = {}
for (thisId,thisName) in cursor: binName[thisId] = thisName

cursor.execute('SELECT itemId,manufacturer,brand,name FROM Item')
itemName = {}
for (thisId,thisMfr,thisBrand,thisName) in cursor:
    thisLongName = getItemName(thisMfr,thisBrand,thisName)
    itemName[thisId] = thisLongName

###############################################################################
if form.has_key('undo'):
    try:
        undo = int(form['undo'].value)

        cursor.execute('BEGIN IMMEDIATE TRANSACTION')
Ejemplo n.º 6
0
#!/python26/python.exe
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
import cgi
from myutils import c, cursor, sql, printHeader, printFooter, gotoButton
import sqlite3

cgitb.enable()

form = cgi.FieldStorage()

printHeader("Item Management")

####################
# Add form
print """
<div class=addthing>
<FORM>
<H2>Add new item type</H2>
<table>
<tr><td align=right>Manufacturer:</td><td><INPUT TYPE=TEXT NAME=manufacturer ID=addItemMfr SIZE=70></INPUT></td></tr>
<tr><td align=right>Brand:</td><td><INPUT TYPE=TEXT NAME=brand ID=brand SIZE=70></INPUT></td></tr>
<tr><td align=right>Name:</td><td><INPUT TYPE=TEXT NAME=name ID=name SIZE=70></INPUT></td></tr>
<INPUT TYPE=hidden NAME=add VALUE=1/>
</table>
<INPUT TYPE=SUBMIT VALUE='Add new item type' onClick='return validateForm();' />
</FORM>
</div>
Ejemplo n.º 7
0
#!/python26/python.exe
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
import cgi
from myutils import c,cursor,sql, printHeader, printFooter, gotoButton, centsToDollarString,cell,moneyCell,getTranType,getItemName

cgitb.enable()

form = cgi.FieldStorage()

printHeader('Purchase Details')

tranId = form['tranId'].value

cursor.execute('SELECT type,direction,tranDate,description,shipping FROM Trans where tranId = ?',(tranId,))
(type,direction,tranDate,description,shipping) = cursor.fetchone()

mytype = getTranType(type,direction)

print '<H2>Details for %s: %s</H2>'%(mytype,description)
print '<p>Date: %s</p>'%tranDate

sql = '''
SELECT
    manufacturer,
    brand,
    name,
    quantity,
    pricePerItem,
Ejemplo n.º 8
0
    # Already got first page, so start at page 2
    for pageNo in (range(2,totalNumberOfPages+1)):
        getPage(connection,pageNo,pageSize,itemList)

    # Clean up the table
    cursor.execute("DELETE FROM ebayList")
    
    # Add the new data to the table    
    for (title,itemId,quantity) in itemList:
        cursor.execute("INSERT INTO ebayList (title,itemId,quantity) VALUES (?,?,?)",(title,itemId,quantity))

    c.commit()        

###########################################################################
# Main program
printHeader('Ebay Listings')


###########################################################################
# Import data
if form.has_key('import'):
    try:
        loadFromEbay()
    except Exception,e:
        c.rollback()
        print "<p class=error>Problem importing data:</p><pre>",sys.exc_info(),"</pre>"

print gotoButton('Import listings from Ebay','ebaylisting.py?import=1')

###########################################################################
# Add link
Ejemplo n.º 9
0
#!/python26/python.exe
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
import cgi
import sqlite3
from myutils import c,cursor,sql, printHeader, printFooter

cgitb.enable()

form = cgi.FieldStorage()

printHeader('Bin Management')

################
# Add form
print "<div class=addthing>"
print "<H2>Add new bin</H2>"
print "<FORM>"
print "<table>"
print "<tr><td align=right>Bin name:</td><td><INPUT TYPE=TEXT NAME=name ID=addBinName></INPUT></td></tr>"
print "<tr><td align=right>Number of slots:</td>"
print "<td>"
print "<INPUT name=slots SIZE=5 MAXLENGTH=5 onKeyPress='return numbersonly(this,event)' VALUE=6>"
print " 0 for unlimited</td>"
print "</tr>"
#print "<tr><td align=right>Number of slots:</td><td><SELECT name=slots>"
#print "<OPTION VALUE=0 DEFAULT>Unlimited</OPTION>"
#print "<OPTION VALUE=6 DEFAULT>6</OPTION>"
#print "<OPTION VALUE=17 DEFAULT>17</OPTION>"
Ejemplo n.º 10
0
#!/python26/python.exe

# enable debugging
import cgitb
import cgi
import sys
from myutils import c,cursor,sql, printHeader, printFooter, printOptions, centsToDollarString, getItemName, gotoButton
from ebayLib import ebayFindItem
cgitb.enable()
from datetime import datetime    # Used to timestamp events

form = cgi.FieldStorage()

printHeader('Stock list')

###############################################################################
# AJAX code
print '''
<script type="text/javascript">
function dumpProps(obj, parent) {
   // Go through all the properties of the passed-in object
   for (var i in obj) {
      // if a parent (2nd parameter) was passed in, then use that to
      // build the message. Message includes i (the object's property name)
      // then the object's property value on a new line
      if (parent) { var msg = parent + "." + i + "\\n" + obj[i]; } else { var msg = i + "\\n" + obj[i]; }
      // Display the message. If the user clicks "OK", then continue. If they
      // click "CANCEL" then quit this level of recursion
      if (!confirm(msg)) { return; }
      // If this property (i) is an object, then recursively process the object
      if (typeof obj[i] == "object") {
Ejemplo n.º 11
0
#!/python26/python.exe
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
from myutils import sql,printHeader,printFooter

cgitb.enable()

printHeader("Stock Management")

print "<p><A HREF=stockList.py>Stock list</A>: Manage stock</p>"
print "<p><A HREF=binList.py>Bin list</A>: List bins and their contents</p>"
print "<p><A HREF=purchases.py>Purchases</A>: List purchases, add new purchases</p>"
print "<p><A HREF=sales.py>Sales</A>: List sales and add new sales</p>"
print "<H2>Admin stuff</H2>"
print "<p><A HREF=bins.py>bins</A>: manage the set of bins</p>"
print "<p><A HREF=items.py>items</A>: manage the item manufacturers and descriptions</p>"
printFooter()
Ejemplo n.º 12
0
#!/python26/python.exe
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
import cgi
import sys
import urllib
from myutils import c,cursor,sql, printHeader, printFooter, gotoButton, centsToDollarString, dollarStringToCents, cell, moneyCell, getItemName

cgitb.enable()

form = cgi.FieldStorage()

printHeader('Link Ebay title to stock item')

if not form.has_key('title'):
    print "No ebay listing title specified"
    sys.exit()

title = form['title'].value

print "<p>Please select a stock item to link to ebay listing item <b>%s</b></p>"%title

# Get a list of all items
cursor.execute("SELECT itemId,manufacturer,brand,name FROM item ORDER BY manufacturer,brand,name")
itemOptions = []
for (itemId,manufacturer,brand,name) in cursor:
    itemOptions.append('<OPTION VALUE=%s>%s</OPTION>'%(itemId,getItemName(manufacturer,brand,name)))
print '<FORM ACTION=ebayListing.py>'
print '<SELECT NAME=itemid>'
Ejemplo n.º 13
0
#!/python26/python.exe
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
import cgi
from myutils import c,cursor,sql, printHeader, printFooter, gotoButton

cgitb.enable()

form = cgi.FieldStorage()

printHeader('Edit item')

if not form.has_key('itemId'):
    print '<p class=error>Sorry, page called with no item to edit</p>'
else:
    itemId = form['itemId'].value

    cursor.execute('SELECT manufacturer,brand,name FROM item WHERE itemId = ?',(itemId,))
    (manufacturer,brand,name) = cursor.fetchone()
    if not brand: brand = ''

    print '''
<div class=addthing>
<FORM ACTION=items.py>
<H2>Edit item type</H2>
<table>
<tr><td align=right>Manufacturer:</td><td><INPUT TYPE=TEXT NAME=manufacturer ID=mfr SIZE=70 VALUE="%s" /></td></tr>
<tr><td align=right>Brand:</td><td><INPUT TYPE=TEXT NAME=brand ID=brand SIZE=70 VALUE="%s" /></td></tr>
<tr><td align=right>Name:</td><td><INPUT TYPE=TEXT NAME=name ID=name SIZE=70 VALUE="%s" /></td></tr>
Ejemplo n.º 14
0
#!/python26/python.exe

# enable debugging
import cgitb
import cgi
from myutils import c,cursor,sql, printHeader, printFooter, printOptions, centsToDollarString, getItemName, gotoButton, db_removeFromBin, db_addToBin
import sys

cgitb.enable()

form = cgi.FieldStorage()

printHeader('Monthly Report')

###############################################################################
# Get the earliest transaction date
cursor.execute('SELECT tranDate FROM trans ORDER BY trandate LIMIT 1')
(earliest,) = cursor.fetchone()
(earliestYear,earliestMonth,earliestDay) = earliest.split('-')
earliestYear = int(earliestYear)
earliestMonth = int(earliestMonth)

# Get the latest transaction date
cursor.execute('SELECT tranDate FROM trans ORDER BY trandate DESC LIMIT 1')
(latest,) = cursor.fetchone()
(latestYear,latestMonth,latestDay) = latest.split('-')
latestYear = int(latestYear)
latestMonth = int(latestMonth)

# Generate the list of year/date starting & ending points
year = earliestYear
Ejemplo n.º 15
0
#!/python26/python.exe

# enable debugging
import cgitb
import cgi
import sys
from myutils import c,cursor,sql, printHeader, printFooter, gotoButton, centsToDollarString, dollarStringToCents, cell, moneyCell, getItemName

cgitb.enable()

form = cgi.FieldStorage()

printHeader('New sale details')

if not form.has_key('AddSale'):
    print '<p class=error>Sorry - missing input fields; please use the navigation buttons to go to another page</p>'

buyer = form['buyer'].value
shipping = form['shipping'].value
if form.has_key('reconcile'):
    tranType = 'RECONCILE'
else:
    tranType = 'REAL'
maxItemIdx = form['addLastItem'].value

print '<H2>Select items to fill shipment</H2>'

print '<FORM ACTION=sales.py>'
print '<INPUT TYPE=HIDDEN NAME=addSale VALUE=1>'
print '<INPUT TYPE=HIDDEN NAME=buyer VALUE="%s" />'%buyer
print '<INPUT TYPE=HIDDEN NAME=shipping VALUE="%s" />'%shipping