示例#1
0
def dashboard():
    total_inventories = len(InventoryModel.fetch_all())
    total_products = len(
        InventoryModel.query.filter_by(inventory_type="product").all())
    total_services = len(
        InventoryModel.query.filter_by(inventory_type="service").all())

    pie_chart = pygal.Pie()
    pie_chart.title = 'Products vs Services Inventory'
    pie_chart.add('Products', total_products)
    pie_chart.add('Services', total_services)
    pie = pie_chart.render_data_uri()
    return render_template('dashboard.html',
                           total_inventories=total_inventories,
                           total_products=total_products,
                           total_services=total_services,
                           chart=pie)
示例#2
0
def inventories():

    inventories = InventoryModel.fetch_all()
    if request.method == 'POST':
        name = request.form['name']
        inventory_type = request.form['inventory_type']
        buying_price = request.form['buying_price']
        selling_price = request.form['selling_price']

        record = InventoryModel(name=name,
                                inventory_type=inventory_type,
                                buying_price=buying_price,
                                selling_price=selling_price)
        record.create_record()
        flash("Record has been successifully created", "success")

        return redirect(url_for('inventories'))

    return render_template('inventories.html', all_inventories=inventories)
示例#3
0
def inventories():

    inventories = InventoryModel.fetch_all()
    print(inventories)

    if request.method == 'POST':
        name = request.form['name']
        type = request.form['type']
        buying_price = request.form['bp']
        sp = request.form['sp']

        # insert record into the databases
        # cur.execute('INSERT INTO inventories (name, type, bp, sp) VALUES (%s,%s,%s,%s)', (name,type,buying_price,sp))
        # conn.commit()

        record = InventoryModel(name=name, type=type, bp=buying_price, sp=sp)
        db.session.add(record)
        db.session.commit()

        print("record has successfully been created")
        return redirect(url_for('inventories'))

    return render_template('inventories.html', all_inventories=inventories)
示例#4
0
def inventory():
    inve = InventoryModel.fetch_all()
    for each in inve:
        print(each.name)
    return render_template('inventory.html',inventory=inve)