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)  
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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)
Exemplo n.º 6
0
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)
Exemplo n.º 8
0
def exports():
    totRec = dbtasks.totRecords()
    return render_template('exports.html', totRec=totRec)