def customers(): if request.method == 'GET': totRec = dbtasks.totRecords() customer = {} return render_template('customers.html', totRec=totRec, customer=customer) if request.method == 'POST': source = 'post' totRec = dbtasks.totRecords() customer = request.form cusRecords = dbtasks.findCustomers(customer) return render_template('customers.html', totRec=totRec, customer=customer, cusRecords=cusRecords, source=source)
def redirect(): customer = {} totRec = dbtasks.totRecords() if request.method == 'POST' or request.method == 'GET': return render_template('addcustomer.html', customer=customer) else: return render_template('addcustomer.html', customer=customer)
def exportresult(): if request.method == 'POST': files = request.form totRec = dbtasks.totRecords() txtfile = files['export'] errorfile = 'experror.txt' status = dbtasks.export_cust(txtfile) return render_template('exportresult.html', totRec=totRec, status=status, files=files, errorfile=errorfile)
def reports(): if request.method == 'GET': source = 'GET' totRec = dbtasks.totRecords() return render_template('reports.html', source=source, totRec=totRec) if request.method == 'POST': source = 'POST' report = request.form result = dbtasks.reports(report['report']) #return render_template('reports.html', msg=msg, totRec=totRec, status=status, file=file) return render_template('reports.html', source=source, result=result)
def reports(): if request.method == 'GET': source = 'GET' report = {} totRec = dbtasks.totRecords() return render_template('reports.html', source=source, report=report, totRec=totRec) if request.method == 'POST': source = 'POST' report = request.form result = dbtasks.reports(report['report']) return render_template('reports.html', source=source, report=report, result=result)
def customers(): if request.method == 'GET': totRec = dbtasks.totRecords() #Empty customers dictionary for GET customer = {} return render_template('customers.html', totRec=totRec, customer=customer) if request.method == 'POST': # and request.value!="Add Customer": print(request) source = 'post' totRec = dbtasks.totRecords() customer = request.form cusRecords = dbtasks.findCustomers(customer) return render_template('customers.html', totRec=totRec, customer=customer, cusRecords=cusRecords, source=source) if request.method == 'POST': details = request.form cusId = details['cusId'] cusFname = details['cusFname'] cusLname = details['cusLname'] cusState = details['cusState'] cusSalesYTD = details['cusSalesYTD'] cusSalesPrev = details['cusSalesPrev'] cur = mysql.connection.cursor() cur.execute( "INSERT INTO customer(cusId, cusFname, cusLname, cusState, cusSalesYTD, cusSalesPrev) VALUES (%s, %s, %s, %s, %s, %s)", (cusId, cusFname, cusLname, cusState, cusSalesYTD, cusSalesPrev)) mysql.connection.commit() cur.close() return render_template('customer.html')
def result_fileprocess(): if request.method == 'GET': source = 'GET' report = {} totRec = dbtasks.totRecords() recProc = dbtasks.recProcessed() allRec = dbtasks.allRecords() return render_template('import_fileprocess.html', source=source, report=report, totRec=totRec, recProc=recProc, allRec=allRec) if request.method == 'POST': files = request.form txtfile = files['txtfile'] errorfile = 'input_error.txt' status = 'Success' with open(txtfile, mode='r') as customerfile: for record in customerfile: rec = record.split() msg = dbtasks.sql_insert_customer(rec, errorfile) if msg != 'Success': status = msg return render_template('import_fileprocess.html', status = status, errorfile = errorfile)
def exports(): totRec = dbtasks.totRecords() return render_template('exports.html', totRec=totRec)