def adicionar_quarto(user_id):
    form_reserva = VerificarDisponibilidade()
    user = User.query.filter_by(id=user_id).first()
    form = AdicionarQuarto()
    if (user.profile not in ['admin', 'gerente']):
        return '<h1>Erro! Você não pode acessar este conteúdo!</h1>'
    if (user.hotel_id is None):
        hoteis = Hotels.query.order_by(Hotels.created_at)
        form.hotel_id.choices = [(hotel.id, hotel.name) for hotel in hoteis if (hotel.user_id == user_id)]
    else:
        hoteis = Hotels.query.filter_by(id=user.hotel_id).order_by(Hotels.created_at)
        form.hotel_id.choices = [(hotel.id, hotel.name) for hotel in hoteis]
    if (request.method == 'POST'):
        if form.validate_on_submit():
            room = Rooms.query.filter_by(hotel_id=form.hotel_id.data, number=form.number.data).first()
            if (room is None):
                room = Rooms(number=form.number.data, hotel_id=form.hotel_id.data, name=form.name.data, short_description=form.short_description.data, kind=form.kind.data, phone_extension=form.phone_extension.data, price=float(form.price.data.replace('.', '').replace(',', '.')), guest_limit=form.guest_limit.data)
                db.session.add(room)
                db.session.commit()
                flash('Quarto cadastrado com sucesso!', 'success')
            else:
                flash('Quarto já existe...', 'danger')
        return redirect(url_for('ocupacao_quartos_endpoint', id=form.hotel_id.data))
    return render_template('adicionar_quartos.html', form=form, hoteis=hoteis, user=user, titulo='Adicionar quarto', form_reserva=form_reserva)
def adicionar_quarto(user_id):
    form_reserva = VerificarDisponibilidade()
    user = User.query.filter_by(id=user_id).first()
    form = AdicionarQuarto()
    if (user.profile not in ['admin', 'gerente']):
        return '<h1>Erro! Você não pode acessar este conteúdo!</h1>'
    if (user.hotel_id is None):
        hoteis = Hotels.query.order_by(Hotels.created_at)
        form.hotel_id.choices = [(hotel.id, hotel.name) for hotel in hoteis if (hotel.user_id == user_id)]
    else:
        hoteis = Hotels.query.filter_by(id=user.hotel_id).order_by(Hotels.created_at)
        form.hotel_id.choices = [(hotel.id, hotel.name) for hotel in hoteis]
    if (request.method == 'POST'):
        if form.validate_on_submit():
            room = Rooms.query.filter_by(hotel_id=form.hotel_id.data, number=form.number.data).first()
            if (room is None):
                room = Rooms(number=form.number.data, hotel_id=form.hotel_id.data, name=form.name.data, short_description=form.short_description.data, kind=form.kind.data, phone_extension=form.phone_extension.data, price=float(form.price.data.replace('.', ).replace(',', '.')), guest_limit=form.guest_limit.data)
                db.session.add(room)
                db.session.commit()
                flash('Quarto cadastrado com sucesso!', 'success')
            else:
                flash('Quarto já existe...', 'danger')
        return redirect(url_for('ocupacao_quartos_endpoint', id=form.hotel_id.data))
    return render_template('adicionar_quartos.html', form=form, hoteis=hoteis, user=user, titulo='Adicionar quarto', form_reserva=form_reserva)