def get_purchases(): kitchen_purchases = KitchenStockPurchase.read(KitchenStockPurchase) kitchen_items = KitchenStock.read(KitchenStock) drink_items = Brand.read(Brand) brand_purchases = Purchase.read(Purchase) total_purchases = KitchenStockPurchase.get_total_price(KitchenStockPurchase) + Purchase.get_total_price(Purchase) return render_template("manager/purchases.html", mod=module, total_purchases=total_purchases, kitchen_purchases=kitchen_purchases, kitchen_items=kitchen_items, drink_items=drink_items, brand_purchases=brand_purchases)
def get_kitchen_stock(): all_kitchen_stock = KitchenStock.read(KitchenStock) if current_user.manager: return render_template("manager/kitchen-stock.html", mod=module, all_kitchen_stock=all_kitchen_stock) elif current_user.chef: return render_template("chef/kitchen-stock.html", mod=module, all_kitchen_stock=all_kitchen_stock)
def get_kitchen_stock_purchases(): kitchen_stock_purchases = KitchenStockPurchase.read(KitchenStockPurchase) chefs = Chef.read(Chef) kitchen_items = KitchenStock.read(KitchenStock) if current_user.manager: return render_template("manager/kitchen-stock-purchase.html", mod=module, purchases=kitchen_stock_purchases, chefs=chefs, kitchen_items=kitchen_items) elif current_user.chef: return render_template("chef/kitchen-stock-purchase.html", mod=module, purchases=kitchen_stock_purchases, chefs=chefs, kitchen_items=kitchen_items)
def filter(): if request.method == "GET": item = request.args.get("item") chef = request.args.get("chef") _from = request.args.get("from") to = request.args.get("to") if not item: item = "" if not chef: chef = "" if _from: _from = utils.convert_date_from_html(_from) else: _from = datetime.datetime(2000, 1, 1) if to: to = utils.convert_date_from_html(to) else: to = datetime.datetime(3000, 1, 1) kitchen_stock_purchases = KitchenStockPurchase.filter( KitchenStockPurchase, item, chef, _from, to) chefs = Chef.read(Chef) kitchen_items = KitchenStock.read(KitchenStock) if current_user.manager: return render_template("manager/kitchen-stock-purchase.html", mod=module, purchases=kitchen_stock_purchases, chefs=chefs, kitchen_items=kitchen_items, chef_id=chef, item_id=item, today=_from, tomorrow=to) elif current_user.chef: return render_template("chef/kitchen-stock-purchase.html", mod=module, purchases=kitchen_stock_purchases, chefs=chefs, kitchen_items=kitchen_items, chef_id=chef, item_id=item, today=_from, tomorrow=to)
def filter(): if request.method == "GET": kitchen_items = KitchenStock.read(KitchenStock) drink_items = Brand.read(Brand) kitchen_purchases = [] brand_purchases = [] item = request.args.get("item") _from = request.args.get("from") to = request.args.get("to") place = request.args.get("place") filter_kitchen, filter_bar = True, True if place == "kitchen": filter_bar = False elif place == "bar": filter_kitchen = False if _from: _from = utils.convert_date_from_html(_from) else: _from = datetime.datetime(2000, 1, 1) if to: to = utils.convert_date_from_html(to) else: to = datetime.datetime(3000, 1, 1) if item: item_type, id = item.split("-") if item_type == "kitchen": kitchen_purchases = KitchenStockPurchase.filter2(KitchenStockPurchase, id, _from, to, filter_kitchen) elif item_type == "drink": brand_purchases = Purchase.filter(Purchase, id, _from, to, filter_bar) else: kitchen_purchases = KitchenStockPurchase.filter2(KitchenStockPurchase, "", _from, to, filter_kitchen) brand_purchases = Purchase.filter(Purchase, "", _from, to, filter_bar) print(">>>>>>>>>>>>>>>>>", kitchen_purchases, brand_purchases) total_purchases = KitchenStockPurchase.get_total_price(KitchenStockPurchase, purchases=kitchen_purchases) + Purchase.get_total_price(Purchase, purchases=brand_purchases) return render_template("manager/purchases.html", mod=module, kitchen_purchases=kitchen_purchases, total_purchases=total_purchases, kitchen_items=kitchen_items, drink_items=drink_items, item_id=item, brand_purchases=brand_purchases, tomorrow=to, today=_from)