def confirm(id):
    room_id = request.form['room_id']
    assigned_room = room_repository.select(room_id) 
    reservation_repository.update_room(assigned_room, id)
    room_repository.capacity_in(id)
    reservation_repository.check_in(id)
    return redirect('/reservations')
def select(id):
    reservation = None
    sql = "SELECT * FROM reservations WHERE id = %s"
    values = [id]
    result = run_sql(sql, values)[0]
    if result is not None:
        guest = guest_repository.select(result['guest_id'])
        room = room_repository.select(result['room_id'])
        reservation = Reservation(guest, room, result['arrival_date'], result['departure_date'], result['status'], result['id'])
    return reservation
def select_all():
    reservations = []
    sql = "SELECT * FROM reservations ORDER BY status ASC, arrival_date"
    results = run_sql(sql)
    for row in results:
        guest = guest_repository.select(row['guest_id'])
        room = room_repository.select(row['room_id'])
        reservation = Reservation(guest, room, row['arrival_date'], row['departure_date'], row['status'], row['id'])
        reservations.append(reservation)
    return reservations
def in_house():
    reservations = []
    sql = "SELECT * FROM reservations WHERE status = %s ORDER BY departure_date, room_id"
    values = ["Checked In"]
    results = run_sql(sql, values)
    for row in results:
        guest = guest_repository.select(row['guest_id'])
        room = room_repository.select(row['room_id'])
        reservation = Reservation(guest, room, row['arrival_date'], row['departure_date'], row['status'], row['id'])
        reservations.append(reservation)
    return reservations
def arrivals():
    reservations = []
    sql = "SELECT * FROM reservations WHERE arrival_date = %s AND status = %s ORDER BY arrival_date ASC"
    values = [datetime.date.today(), "Arrival"]
    results = run_sql(sql, values)
    for row in results:
        guest = guest_repository.select(row['guest_id'])
        room = room_repository.select(row['room_id'])
        reservation = Reservation(guest, room, row['arrival_date'], row['departure_date'], row['status'], row['id'])
        reservations.append(reservation)
    return reservations
def select_from_today(date):
    reservations = []
    sql = "SELECT * FROM reservations WHERE arrival_date >= %s ORDER BY arrival_date, status ASC"
    values = [date]
    results = run_sql(sql, values)
    for row in results:
        guest = guest_repository.select(row['guest_id'])
        room = room_repository.select(row['room_id'])
        reservation = Reservation(guest, room, row['arrival_date'], row['departure_date'], row['status'], row['id'])
        reservations.append(reservation)
    return reservations
Exemple #7
0
def select(id):
    schedule = None
    sql = "SELECT * FROM schedules WHERE id = %s"
    values = [id]
    result = run_sql(sql, values)[0]
    if result is not None:
        instructor = instructor_repository.select(result['instructor_id'])
        gym_class = gym_class_repository.select(result['class_id'])
        room = room_repository.select(result['room_id'])
        schedule = Schedule(result['class_date'], result['start_time'], result['length_mins'], instructor,
                            gym_class, room, result['id'])
    return schedule
Exemple #8
0
def select_all():
    schedules = []
    sql = "SELECT * FROM schedules ORDER BY class_date"
    results = run_sql(sql)
    for row in results:
        instructor = instructor_repository.select(row['instructor_id'])
        gym_class = gym_class_repository.select(row['class_id'])
        room = room_repository.select(row['room_id'])
        schedule = Schedule(row['class_date'], row['start_time'], row['length_mins'], instructor,
                            gym_class, room, row['id'])
        schedules.append(schedule)
    return schedules
def update_reservation(id):
    guest_id = request.form['guest_id']
    guest = guest_repository.select(guest_id)
    room_id = request.form['room_id']
    room = room_repository.select(room_id)
    arrival_date = request.form['arrival_date']
    departure_date = request.form['departure_date']
    status = request.form['status']
    updated_reservation = Reservation(guest, room, arrival_date, departure_date, status, id)
    reservation_repository.update(updated_reservation)
    reservation_repository.arrival_status()
    return redirect('/reservations')
Exemple #10
0
def add_schedule():
    class_date = request.form['class_date']
    start_time = request.form['start_time']
    length_mins = request.form['length_mins']
    instructor_id = request.form['instructor_id']
    class_id = request.form['class_id']
    room_id = request.form['room_id']
    instructor = details_repository.select(instructor_id)
    gym_class = gym_class_repository.select(class_id)
    room = room_repository.select(room_id)
    schedule = Schedule(class_date, start_time, length_mins, instructor,
                        gym_class, room, id)
    schedule_repository.save(schedule)
    return redirect('/schedule')
Exemple #11
0
def select_dates():
    schedules_list = []
    sql = "SELECT * FROM schedules WHERE class_date = %s ORDER BY start_time"
    for index in range(7):
        schedules = []
        values = [date.today() + timedelta(days=index)]
        results = run_sql(sql, values)
        if results is not None:
            for row in results:
                instructor = instructor_repository.select(row['instructor_id'])
                gym_class = gym_class_repository.select(row['class_id'])
                room = room_repository.select(row['room_id'])
                schedule = Schedule(row['class_date'],  row['start_time'], row['length_mins'], instructor,
                                    gym_class, room, row['id'])
                schedules.append(schedule)
        else:
            schedule = None
            schedules.append(schedule)
        schedules_list.append(schedules)
    return schedules_list
def delete_room(id):
    room = room_repository.select(id)
    return render_template('rooms/delete.html', room=room)
def update_room(id):
    number = request.form['number']
    cap = room_repository.select(id)
    updated_room = Room(number, cap.remaining_capacity, id)
    room_repository.update(updated_room)
    return redirect('/rooms')
def edit_room(id):
    room = room_repository.select(id)
    return render_template('rooms/edit.html', room=room)