def getPO_Data(iID): """Retrieve purchase order data accordingly its ID""" poData = {} db = MySQLdb.connect(passwd=db_password, db=db_name, user='******') MySQL_c = db.cursor() MySQL_c.execute("""SELECT author_id, supplier_id, sent, s_author_id FROM invoices WHERE id=%s""", (iID,)) author_id, supplier_id, sent, s_author_id = MySQL_c.fetchone() db.commit() db.close() poData['buyer'] = session['username'] poData['email'] = users.get(session['username']).get('email') poData['phoneNo'] = users.get(session['username']).get('phoneNo') poData['No'] = int(iID) * 3 + 140121 # PO No obfuscator return poData
def getPO_Data(iID): """Retrieve purchase order data accordingly its ID""" poData = {} db = MySQLdb.connect(passwd=db_password, db=db_name, user='******') MySQL_c = db.cursor() MySQL_c.execute( """SELECT author_id, supplier_id, sent, s_author_id FROM invoices WHERE id=%s""", (iID, )) author_id, supplier_id, sent, s_author_id = MySQL_c.fetchone() db.commit() db.close() poData['buyer'] = session['username'] poData['email'] = users.get(session['username']).get('email') poData['phoneNo'] = users.get(session['username']).get('phoneNo') poData['No'] = int(iID) * 3 + 140121 # PO No obfuscator return poData
def index(): """Composes operator dashboard""" if 'username' in session: user = session['username'] logo = users.get(user).get('img') else: return redirect(url_for('login')) if 'active_tab' not in session: # active tab defining session['active_tab'] = 'orders' # <-- initial value o_dataset, pii_data = fetch_pending_orders_data() # compose otl = checkOTLock() agg_products = fetch_products_data(pii_data) # tabs supp_tab_data = fetch_suppliers_data() p_invoices_tab_data = fetch_invoices_data('pending') sent_PO_tab_data = fetch_invoices_data('sent') heldP_tab_data = fetch_held_products() a_tab = setActiveTab(session['active_tab']) return render_template('index.htm', user=user, logo=logo, orders=o_dataset, o_t_lock=otl, orders_agg=agg_products, agg_products_qty=len(agg_products), active=a_tab, supp_data=supp_tab_data, pItab=p_invoices_tab_data, sItab=sent_PO_tab_data, hTd=heldP_tab_data)
def login(): """A primitive authentication feature""" if request.method == 'POST': input_username = request.form['username'] input_password = request.form['password'] if (input_username in users and users.get(input_username).get('password') == input_password): session['username'] = input_username session['userID'] = get_user_id(input_username) return redirect(url_for('index')) return render_template('login.htm')
def index(): """Composes operator dashboard""" if 'username' in session: user = session['username'] logo = users.get(user).get('img') else: return redirect(url_for('login')) if 'active_tab' not in session: # active tab defining session['active_tab'] = 'orders' # <-- initial value o_dataset, pii_data = fetch_pending_orders_data() # compose otl = checkOTLock() agg_products = fetch_products_data(pii_data) # tabs supp_tab_data = fetch_suppliers_data() p_invoices_tab_data = fetch_invoices_data('pending') sent_PO_tab_data = fetch_invoices_data('sent') heldP_tab_data = fetch_held_products() a_tab = setActiveTab(session['active_tab']) return render_template( 'index.htm', user=user, logo=logo, orders=o_dataset, o_t_lock=otl, orders_agg=agg_products, agg_products_qty=len(agg_products), active=a_tab, supp_data=supp_tab_data, pItab=p_invoices_tab_data, sItab = sent_PO_tab_data, hTd = heldP_tab_data )