def query_orders(performDbQuery=0, onLoad=None, queryFields=None): table_data = declarations.define_tables() print "<HTML>" print "<HEAD>" ecommerce.javaScript("order_admin", 1) ecommerce.title("Order Administration") print "</HEAD>" ecommerce.bodySetup(onLoad) print '<CENTER>' print '<TABLE COLS=1 WIDTH=585>' print '<TR><TD>' ecommerce.mainHeading('Order Administration') ecommerce.subHeading('Order Listing') ecommerce.formSetup("order_admin","order_admin","return submitForm(document.order_admin)",declarations.store_info['db_name']) if form.has_key("username"): username = form["username"].value else: if form.has_key("uHidden"): username = form["uHidden"].value else: username = '' if form.has_key("password"): password = form["password"].value else: if form.has_key("pHidden"): password = form["pHidden"].value else: password = '' ecommerce.usernamePasswordDisplay(username, password) if form.has_key("performDbQuery") or performDbQuery == 1: dbResult = ecommerce.connectDB(username, password, declarations.store_info['db_name']) # could not connect to db if dbResult['status'] != 'success': ecommerce.alertsArea(form, "Can not connect to database,\n" + dbResult['message']) # connected to db ecommerce.queryFunctionButtons(0, declarations.store_info['help_file']) else: db = dbResult['result'] # check to see if a query has been performed with at least one column queryFields, whereFields = ecommerce.getQueryWhereFields(form, table_data, 'orders') if queryFields == None or queryFields == []: queryFields = [] whereFields = None queryFields.append('id') queryFields.append('customer_id') queryFields.append('creation_date') queryFields.append('shipped_date') queryFields.append('total') dbResult, queryStatement = ecommerce.executeQuery(db, table_data, 'orders', queryFields, whereFields, 'query', ecommerce.queryItemFunctionsHtml) # if query was not successful if dbResult['status'] != 'success': ecommerce.alertsArea(form, "Invalid query where clause specified,\n" + dbResult['message'] + '\nLast Query Statement: ' + queryStatement) # else orders were retrieved ok else: ecommerce.alertsArea(form, "Last Query Statement: " + queryStatement + "\n" + `len(dbResult['result'])` + " orders retrieved from database") ecommerce.queryFunctionButtons(1, declarations.store_info['help_file']) else: ecommerce.queryFunctionButtons(0, declarations.store_info['help_file']) ecommerce.queryHiddenFields(username, password) print "</FORM>" try: ecommerce.trailer(table_data, db) db.close() except NameError: pass print '</TD>' print '</TR>' print '</TABLE>' print '</CENTER>' print "</BODY>" print "</HTML>" if form.has_key("performDbQuery") or performDbQuery == 1: return dbResult else: return {'status' : 'success', 'message' : 'query successful', 'result' : 0}
def query_product_categories(performDbQuery=0, onLoad=None, queryFields=None): table_data = declarations.define_tables() print "<HTML>" print "<HEAD>" ecommerce.javaScript("product_categories_admin", 1) ecommerce.title("Product Categories Administration") print "</HEAD>" ecommerce.bodySetup(onLoad) ecommerce.mainHeading('Product Categories Administration') ecommerce.subHeading('Product Category Values') ecommerce.formSetup("product_categories_admin","product_categories_admin","return submitForm(document.product_categories_admin)",declarations.store_info['db_name']) if form.has_key("username"): username = form["username"].value else: if form.has_key("uHidden"): username = form["uHidden"].value else: username = '' if form.has_key("password"): password = form["password"].value else: if form.has_key("pHidden"): password = form["pHidden"].value else: password = '' ecommerce.usernamePasswordDisplay(username, password) if form.has_key("performDbQuery") or performDbQuery == 1: dbResult = ecommerce.connectDB(username, password, declarations.store_info['db_name']) # could not connect to db if dbResult['status'] != 'success': ecommerce.alertsArea(form, "Can not connect to database,\n" + dbResult['message']) # connected to db ecommerce.queryFunctionButtons(0, declarations.store_info['help_file']) else: db = dbResult['result'] # check to see if a query has been performed with at least one column queryFields, whereFields = ecommerce.getQueryWhereFields(form, table_data, 'product_categories') if queryFields == None or queryFields == []: queryFields = [] whereFields = None queryFields.append('category') dbResult, queryStatement = ecommerce.executeQuery(db, table_data, 'product_categories', queryFields, whereFields, 'query', ecommerce.queryItemFunctionsHtmlNoEdit, 'ORDER by category','category') # if query was not successful if dbResult['status'] != 'success': ecommerce.alertsArea(form, "Could not retrieve category values data from database,\n" + dbResult['message']); # else category values data was retrieved ok else: ecommerce.alertsArea(form, "Last Query Statement: " + queryStatement + "\n" + `len(dbResult['result'])` + " category value items retrieved from database"); ecommerce.queryFunctionButtons(1, declarations.store_info['help_file']) else: ecommerce.queryFunctionButtons(0, declarations.store_info['help_file']) ecommerce.queryHiddenFields(username, password) print "</FORM>" try: ecommerce.trailer(table_data, db) db.close() except NameError: pass print "</BODY>" print "</HTML>" if form.has_key("performDbQuery") or performDbQuery == 1: return dbResult else: return {'status' : 'success', 'message' : 'query successful', 'result' : 0}
def query_properties(performDbQuery=0, onLoad=None, queryFields=None): table_data = declarations.define_tables() print "<HTML>" print "<HEAD>" ecommerce.javaScript("view_properties", 1) ecommerce.title("Property Listing") print "</HEAD>" ecommerce.bodySetup(onLoad) print '<CENTER>' print '<TABLE COLS=1 WIDTH=585>' print '<TR><TD>' ecommerce.mainHeading('Property Listing') ecommerce.subHeading('View Properties') ecommerce.formSetup("view_properties", "view_properties", "return submitForm(document.view_properties)", declarations.store_info['db_name']) if form.has_key("performDbQuery") or performDbQuery == 1: dbResult = ecommerce.connectDB( declarations.store_info['browser_username'], declarations.store_info['browser_password'], declarations.store_info['db_name']) # could not connect to db if dbResult['status'] != 'success': ecommerce.alertsArea( form, "Can not connect to database,\n" + dbResult['message']) # connected to db ecommerce.queryFunctionButtons( 0, declarations.store_info['help_file']) else: db = dbResult['result'] queryFields, whereFields = ecommerce.getQueryWhereFields( form, table_data, 'properties') if queryFields == None or queryFields == []: queryFields = [] whereFields = None queryFields.append('town') queryFields.append('price') queryFields.append('square_footage') dbResult, queryStatement = ecommerce.executeQuery( db, table_data, 'properties', queryFields, whereFields, 'query', ecommerce.viewPropertiesFunctionsHtml, 'ORDER BY id', 'id', "display_property = 't'", ['order_id', 'customer_id', 'display_property', 'image']) # if query was not successful if dbResult['status'] != 'success': ecommerce.alertsArea( form, "Could not retrieve properties from database,\n" + dbResult['message']) # else properties were retrieved ok else: ecommerce.alertsArea( form, "Last Query Statement: " + queryStatement + "\n" + ` len(dbResult['result']) ` + " properties retrieved from database") ecommerce.viewPropertiesFunctionButtons( declarations.store_info['help_file']) else: ecommerce.viewPropertiesFunctionButtons( declarations.store_info['help_file']) ecommerce.viewPropertiesHiddenFields( declarations.store_info['browser_username'], declarations.store_info['browser_password']) print "</FORM>" try: ecommerce.trailer(table_data, db) db.close() except NameError: pass print '</TD>' print '</TR>' print '</TABLE>' print '</CENTER>' print "</BODY>" print "</HTML>" if form.has_key("performDbQuery") or performDbQuery == 1: return dbResult else: return { 'status': 'success', 'message': 'query successful', 'result': 0 }