Example #1
0
def employee():
    id = request.args["id"]
    employee = employees.get_employee(id)
    restaurant = restaurants.get_restaurant(employee[3])
    return render_template("employee.html",
                           employee=employee,
                           restaurant=restaurant)
Example #2
0
def update_shift():
    if request.method == "GET":
        id = request.args.get("id")
        restaurantID = request.args["restaurantID"]
        restaurant = restaurants.get_restaurant(restaurantID)
        shift = restaurants.get_shift(id)
        return render_template("update_shift.html",
                               shift=shift,
                               restaurant=restaurant)

    if request.method == "POST":
        id = request.form["id"]
        new_name = request.form["new_name"]
        new_role = request.form["new_role"]
        new_date = request.form["new_date"]
        new_start_time = request.form["new_start_time"]
        new_duration = request.form["new_duration"]
        restaurantID = request.form["restaurantID"]
        keep_employee = request.form["keep_employee"]
        if restaurants.update_shift(id, new_name, new_role, new_date,
                                    new_start_time, new_duration,
                                    keep_employee):
            flash("Työvuoron päivitys onnistui!")
            return redirect(url_for('restaurant', id=restaurantID))
        else:
            return render_template("error.html",
                                   message="Työvuoron muokkaus epäonnistui")
Example #3
0
def restaurant(id):
    restaurant = restaurants.get_restaurant(id)
    shifts = restaurants.get_shifts(id)
    all_employees = employees.get_employees(id)
    return render_template("restaurant.html",
                           restaurant=restaurant,
                           shifts=shifts,
                           employees=all_employees)
Example #4
0
def staff_strength_calendar():
    week = request.args["week"]
    restaurantID = request.args["restaurantID"]
    calendar = restaurants.create_staff_strength_calendar(week, restaurantID)
    restaurant = restaurants.get_restaurant(restaurantID)
    return render_template("staff_strength_calendar.html",
                           calendar=calendar,
                           week=week,
                           restaurant=restaurant)
Example #5
0
def restaurant_dayview():
    id = request.args["id"]
    date = request.args["date"]
    restaurant = restaurants.get_restaurant(id)
    shifts = restaurants.get_shifts_by_date(id, date)
    return render_template('restaurant_dayview.html',
                           restaurant=restaurant,
                           shifts=shifts,
                           date=date)
Example #6
0
def personal_schedule():
    week = request.args["week"]
    employeeID = request.args["employeeID"]
    restaurantID = request.args["restaurantID"]
    restaurant = restaurants.get_restaurant(restaurantID)
    employee = employees.get_employee(employeeID)
    schedule = employees.own_shifts(employeeID, week)
    return render_template("personal_schedule.html",
                           schedule=schedule,
                           week=week,
                           employee=employee,
                           restaurant=restaurant)
Example #7
0
def work_report():
    week = request.args["week"]
    employeeID = request.args["employeeID"]
    restaurantID = request.args["restaurantID"]
    restaurant = restaurants.get_restaurant(restaurantID)
    employee = employees.get_employee(employeeID)
    hours = employees.work_report(restaurantID, employeeID, week)
    return render_template("workreport.html",
                           hours=hours,
                           week=week,
                           employee=employee,
                           restaurant=restaurant)
Example #8
0
def roster():
    week = request.args["week"]
    restaurantID = request.args["restaurantID"]
    restaurant = restaurants.get_restaurant(restaurantID)
    (roster, unused_hours, assigned_shifts,
     not_assigned) = restaurants.create_roster(week, restaurant.id)
    return render_template("roster.html",
                           roster=roster,
                           unused_hours=unused_hours,
                           week=week,
                           restaurant=restaurant,
                           assigned_shifts=assigned_shifts,
                           not_assigned=not_assigned)
Example #9
0
def update_restaurant():
    if request.method == "GET":
        restaurantID = request.args["restaurantID"]
        restaurant = restaurants.get_restaurant(restaurantID)
        return render_template("update_restaurant.html", restaurant=restaurant)
    if request.method == "POST":
        id = request.form["id"]
        new_name = request.form["new_name"]
        if restaurants.update_restaurant(id, new_name):
            flash("Ravintolan päivitys onnistui!")
            return redirect(url_for('restaurant', id=id))
        else:
            return render_template("error.html",
                                   message="Ravintolan muokkaus epäonnistui")
Example #10
0
def remove_restaurant():
    if request.method == "GET":
        restaurantID = request.args["restaurantID"]
        restaurant = restaurants.get_restaurant(restaurantID)
        return render_template("remove_restaurant.html",
                               id=id,
                               restaurant=restaurant)
    if request.method == "POST":
        id = request.form["id"]
        if restaurants.remove_restaurant(id):
            flash("Ravintolan poisto onnistui!")
            return redirect("/")
        else:
            return render_template("error.html",
                                   message="Ravintolan poisto epäonnistui")
Example #11
0
def own_shifts(employeeID, week):
    employee = get_employee(employeeID)
    restaurant = restaurants.get_restaurant(employee[3])
    shifts = restaurants.get_shifts_by_employee_and_week(
        restaurant[0], employeeID, week)
    date = datetime.strptime(week + '-1', "%G-W%V-%u").strftime("%Y-%m-%d")
    schedule = [[]] * 7
    # For each day this week, add shifts to schedule which will be returned
    for i in range(7):
        schedule[i] = (i, None)
        for shift in shifts:
            if str(shift.date) == date:
                schedule[i] = (i, shift)
        modified_date = datetime.strptime(date, "%Y-%m-%d") + timedelta(days=1)
        date = modified_date.strftime("%Y-%m-%d")
    return schedule
Example #12
0
def remove_employee():
    if request.method == "GET":
        id = request.args.get("id")
        restaurantID = request.args["restaurantID"]
        restaurant = restaurants.get_restaurant(restaurantID)
        employee = employees.get_employee(id)
        return render_template("remove_employee.html",
                               employee=employee,
                               restaurant=restaurant)
    if request.method == "POST":
        id = request.form["id"]
        if employees.remove_employee(id):
            flash("Työntekijän poisto onnistui!")
            return redirect("/")
        else:
            return render_template("error.html",
                                   message="Työntekijän poisto epäonnistui")
Example #13
0
def remove_dayoff():
    if request.method == "GET":
        employeeID = request.args.get("id")
        employee = employees.get_employee(employeeID)
        restaurant = restaurants.get_restaurant(employee[3])
        return render_template("remove_dayoff.html",
                               employee=employee,
                               restaurant=restaurant)
    if request.method == "POST":
        date = request.form["date"]
        employeeID = request.form["employeeID"]
        restaurantID = request.form["restaurantID"]
        if employees.remove_dayoff(employeeID, date):
            flash("Sisäänkirjautuminen onnistui!")
            return redirect("/")
        else:
            return render_template("error.html",
                                   message="Vapaapäivän poisto epäonnistui")
Example #14
0
def add_dayoff():
    if request.method == "GET":
        id = request.args.get("id")
        employee = employees.get_employee(id)
        restaurant = restaurants.get_restaurant(employee[3])
        return render_template("add_dayoff.html",
                               employee=employee,
                               restaurant=restaurant)
    if request.method == "POST":
        date = request.form["date"]
        reason = request.form["reason"]
        employeeID = request.form["employeeID"]
        restaurantID = request.form["restaurantID"]
        if employees.add_dayoff(employeeID, date, reason):
            flash("Vapaapäivän lisääminen onnistui!")
            return redirect(url_for("restaurant", id=restaurantID))
        else:
            return render_template("error.html",
                                   message="Vapaapäivän lisäys epäonnistui")
Example #15
0
def add_employee():
    if request.method == "GET":
        restaurantID = request.args["restaurantID"]
        restaurant = restaurants.get_restaurant(restaurantID)
        return render_template("add_employee.html", restaurant=restaurant)

    if request.method == "POST":
        firstname = request.form["firstname"]
        lastname = request.form["lastname"]
        restaurantID = request.form["restaurantID"]
        role = request.form["role"]
        max_hours = request.form["max_hours"]

        if employees.add_employee(firstname, lastname, restaurantID, role,
                                  max_hours):
            flash("Työntekijän lisäys onnistui!")
            return redirect(url_for("restaurant", id=restaurantID))
        else:
            return render_template("error.html",
                                   message="Työntekijän lisäys epäonnistui")
Example #16
0
def add_shift():
    if request.method == "GET":
        restaurantID = request.args["restaurantID"]
        restaurant = restaurants.get_restaurant(restaurantID)
        return render_template("add_shift.html", restaurant=restaurant)

    if request.method == "POST":
        name = request.form["name"]
        restaurantID = request.form["restaurantID"]
        role = request.form["role"]
        date = request.form["date"]
        start_time = request.form["start_time"]
        duration = request.form["duration"]
        reps = request.form["reps"]
        repetition = request.form["repetition"]
        if restaurants.add_shift(name, restaurantID, role, date, start_time,
                                 duration, reps, repetition):
            flash("Työvuoron lisäys onnistui!")
            return redirect(url_for("restaurant", id=restaurantID))
        else:
            return render_template("error.html",
                                   message="Työvuoron lisäys epäonnistui")
Example #17
0
def update_employee():
    if request.method == "GET":
        id = request.args.get("id")
        restaurantID = request.args["restaurantID"]
        restaurant = restaurants.get_restaurant(restaurantID)
        employee = employees.get_employee(id)
        return render_template("update_employee.html",
                               employee=employee,
                               restaurant=restaurant)

    if request.method == "POST":
        id = request.form["id"]
        new_firstname = request.form["new_firstname"]
        new_lastname = request.form["new_lastname"]
        new_role = request.form["new_role"]
        new_max_hours = request.form["new_max_hours"]
        restaurantID = request.form["restaurantID"]
        if employees.update_employee(id, new_firstname, new_lastname, new_role,
                                     new_max_hours):
            flash("Työntekijän päivitys onnistui!")
            return redirect("/")
        else:
            return render_template("error.html",
                                   message="Työntekijän muokkaus epäonnistui")