Beispiel #1
0
def restaurant_home():
    res_name = insert_db.get_g_res_name()
    res_id = insert_db.get_g_res_id()

    res_data = insert_db.retrieve_restaurant_data_from_id(res_id)
    order_data = insert_db.retrieve_order_res(res_id)
    menu_data = insert_db.retrieve_menu(res_id)
    res_rname = insert_db.retrieve_restaurant_rname(res_id)
    address = insert_db.retrieve_address_from_res_id(res_id)

    if request.method == 'POST':
        if 'logout' in request.form:
            return redirect(url_for('login'))
        if 'add_item' in request.form:
            insert_db.insert_menu_item(request.form['item_name'],
                                       request.form['price'], res_id)
            return redirect(url_for('restaurant_home'))
        if "save_changes" in request.form:
            resname = request.form['res_name']
            #print resname
            email = request.form['email']
            phone = request.form['phone_no']
            start = request.form['start']
            end = request.form['end']
            category = request.form['category']
            insert_db.modify_res_details(res_id, resname, email, phone, start,
                                         end, category)
            return redirect(url_for('restaurant_home'))

        if "logout" in request.form:
            return redirect(url_for('login'))

        for i, d in menu_data.iteritems():
            temp = "delete_item" + str(d[2])
            if temp in request.form:
                insert_db.delete_menu_item(d[2])
                return redirect(url_for('restaurant_home'))

        for i, d in order_data.iteritems():
            name = "name" + str(d[0])
            temp1 = "save_item" + str(d[0])
            temp2 = "cancel_item" + str(d[0])
            if temp1 in request.form:
                insert_db.modify_status_update(d[0], request.form[name])
                return redirect(url_for('restaurant_home'))

            if temp2 in request.form:
                insert_db.remove_order(d[0])
                return redirect(url_for('restaurant_home'))

    return render_template('restaurant_home.html',
                           res_name=res_rname,
                           order_data=order_data,
                           menu_data=menu_data,
                           address=address,
                           phone_number=res_data['phone_number'],
                           email_id=res_data['email_id'],
                           start=res_data['start_time'],
                           end=res_data['end_time'],
                           category=res_data['category'])
Beispiel #2
0
def menu():
    res_name = insert_db.get_g_res_name()
    res_id = insert_db.get_g_res_id()
    menu_data = insert_db.set_menu(res_id)
    user_name = insert_db.get_g_user_name()
    if request.method == 'POST':
        if "place_order" in request.form:
            order_list = []
            for i, d in menu_data.iteritems():
                temp = []
                check_string = "check" + str(i)
                quan_string = "quan" + str(i)
                if request.form.get(check_string):
                    temp.append(d[0])
                    temp.append(int(request.form[quan_string]))
                    order_list.append(temp)

                    # print request.form[quan_string]
            order_id = insert_db.insert_order_list(order_list)
            insert_db.set_g_order_id(order_id)
            return redirect(url_for('bill'))

        if "logout" in request.form:
            return redirect(url_for('login'))

    return render_template('menu.html',
                           menu_data=menu_data,
                           username=user_name)