Ejemplo n.º 1
0
def detailed_report(id):
    if current_user.role == 'admin':
        hostel = Hostel.query.filter_by(
            hostel_id=current_user.hostel_id).first()
        if (id == "totRooms"):
            table = TotalRoomReport(hostel.rooms)
            return render_template('detailed_reports.html', table=table)
        if (id == 'totStu'):
            table = TotalStudentsReport(
                db.engine.execute(
                    "select * from Users where room_id not null and users.hostel_id == "
                    + str(hostel.hostel_id)))
            return render_template('detailed_reports.html', table=table)
        if (id == 'totStuPaid'):
            table = TotalFullPaidStudentsReport(
                db.engine.execute(
                    "SELECT Users.firstname, Users.lastname,Users.email,Users.number,Payments.amount_paid,Payments.amount_remaining"
                    +
                    " FROM Users INNER JOIN Payments ON Payments.user_id = Users.id where Payments.amount_remaining <= 0 and Users.hostel_id == "
                    + str(hostel.hostel_id)))
            return render_template('detailed_reports.html', table=table)
        if (id == 'totNotFullPaid'):
            table = TotalFullPaidStudentsReport(
                db.engine.execute(
                    "SELECT Users.firstname, Users.lastname,Users.email,Users.number,Payments.amount_paid,Payments.amount_remaining"
                    +
                    " FROM Users INNER JOIN Payments ON Payments.user_id = Users.id where Payments.amount_remaining > 0 and Users.hostel_id == "
                    + str(hostel.hostel_id)))
            return render_template('detailed_reports.html', table=table)
        if (id == 'totFullRooms'):
            table = TotalRoomReport(
                db.engine.execute(
                    "Select * from rooms where rooms.beds = (select count(*) from Users where users.room_id == rooms.room_num) and rooms.hostel_id == "
                    + str(hostel.hostel_id)))
            return render_template('detailed_reports.html', table=table)
        if (id == 'totNotFullRooms'):
            table = TotalRoomReport(
                db.engine.execute(
                    "Select * from rooms where rooms.beds != (select count(*) from Users where users.room_id == rooms.room_num) and rooms.hostel_id == "
                    + str(hostel.hostel_id)))
            return render_template('detailed_reports.html', table=table)
        if (id == 'totMaleStu'):
            table = TotalStudentsReport(
                db.engine.execute(
                    "select * from Users where gender == 'M' and room_id not null and hostel_id == "
                    + str(hostel.hostel_id)))
            return render_template('detailed_reports.html', table=table)
        if (id == 'totFemStu'):
            table = TotalStudentsReport(
                db.engine.execute(
                    "select * from Users where gender == 'F' and room_id not null and hostel_id == "
                    + str(hostel.hostel_id)))
            return render_template('detailed_reports.html', table=table)
    else:
        return render_template('logInError.html')
Ejemplo n.º 2
0
def default_roomview(id):
    if current_user.role == 'admin':

        room = Room.query.filter_by(room_num=id).first()
        table = TotalStudentsReport(room.occupants)
        return render_template('default_roomview.html', room=room, table=table)
    else:
        return render_template('logInError.html')
Ejemplo n.º 3
0
def student_viewroom():
    if current_user.role == 'student':
        user = User.query.filter_by(id=current_user.id).first()
        room = Room.query.filter_by(room_num=current_user.room_id).first()
        table = TotalStudentsReport(room.occupants)
        return render_template('student_viewroom.html',
                               table=table,
                               room=room,
                               user=user)
    else:
        return render_template('logInStudentError.html')
Ejemplo n.º 4
0
def occupants_details():
    if current_user.role == 'admin':

        hostel = Hostel.query.filter_by(
            hostel_id=current_user.hostel_id).first()
        table = TotalStudentsReport(
            db.engine.execute(
                "select * from Users where room_id not null and hostel_id == "
                + str(hostel.hostel_id)))
        return render_template('occupants_details.html',
                               title='Occupants Details',
                               table=table)
    else:
        return render_template('logInError.html')
Ejemplo n.º 5
0
def room_details(id):
    global table
    if current_user.role == 'admin':

        form = EditRoomForm()
        room = Room.query.filter_by(room_num=id).first()
        hostel_id = current_user.hostel_id
        hostel_name = Hostel.query.filter_by(hostel_id=hostel_id).first()
        hostel_name = hostel_name.hostel_name.lower()

        if form.validate_on_submit():
            room.room_num = form.room_num.data
            room.beds = form.beds.data
            beds = room.beds
            bed = f'{hostel_name}{beds}'
            price = Beds.query.filter_by(beds_id=bed).first()
            room.price = price.price
            room_gen = form.gender.data
            room.room_gen = room_gen
            db.session.commit()
            form.room_num.data = room.room_num
            form.beds.data = int(room.beds)
            flash('Room Sucessfully Updated!', 'success')
            return redirect(url_for('room_details', id=room.room_num))
        elif request.method == 'GET':
            form.room_num.data = room.room_num
            form.beds.data = int(room.beds)
            form.gender.data = str(room.room_gen[0])
            table = TotalStudentsReport(room.occupants)
        return render_template('room_details.html',
                               legend='Edit Room',
                               form=form,
                               table=table,
                               room=room)
    else:
        return render_template('logInError.html')