Пример #1
0
def register_customer():
    msg = ''
    if request.method == 'POST':
        custname = request.form['custname']
        custadr = request.form['custadr']
        custcont = request.form['custcont']
        custmail = request.form['custmail']
        custaccno = request.form['custaccno']
        custpass = request.form['custpass']
        dbcust = Customer.query.filter(Customer.name == custname).first()
        dblogin = Login.query.filter_by(username=custname).first()
        if dbcust:
            if dbcust.id == int(request.form['id']):
                dbcust.address = custadr
                dbcust.contact = custcont
                dbcust.email = custmail
                dblogin.password = custpass
                if custaccno:
                    dbcust.accno = custaccno
                db.session.commit()
                msg = "Customer Data Updated Successfully..!"
                return render_template('customer_register.html',
                                        resp=msg,
                                        cust=Customer.dummy_cust(),
                                        acclist=remaining_accounts())
            msg = "Username Already Exist...!"
            return render_template('customer_register.html',
                                   resp=msg,
                                   cust=Customer.dummy_cust(),
                                   acclist=remaining_accounts())

        else:
            if custname and custadr and custcont and custmail and custpass:
                dbcust = Customer(name=custname, address=custadr, contact=custcont, email=custmail)
                dbcustomer = Login(username=custname, password=custpass)
                if custaccno:
                    dbcust.accno = custaccno
                db.session.add_all([dbcust,dbcustomer])
                db.session.commit()
                msg = "Registration Successfully...!"
                return render_template('customer_register.html',
                                   resp=msg,
                                   cust=Customer.dummy_cust(),
                                   acclist=remaining_accounts())
            msg = 'Invalid credentials'

    return render_template('customer_register.html',resp=msg,
                           cust=Customer.dummy_cust(),
                           acclist=remaining_accounts())
Пример #2
0
def toggle_room_type(val):
    if 'userinfo' in session:
        global FLAG
        msg = ''
        allrooms = Room.query.all()
        if FLAG:
            if val == 'rid':
                allrooms.sort(key=lambda room: room.id, reverse=True)
            elif val == 'rtype':
                allrooms.sort(key=lambda room: room.type)
            elif val == 'rcharge':
                allrooms.sort(key=lambda room: room.charge)
            elif val == 'rstatus':
                allrooms.sort(key=lambda room: room.status)
            FLAG = False
        else:
            FLAG = True
        return render_template('dashboard.html',
                               resp='addroom',
                               msg=msg,
                               user=session['userinfo'],
                               hotellist=Hotel.query.all(),
                               hotel=Hotel.dummy_hotel(),
                               acclist=remaining_accounts(),
                               room=allrooms,
                               roomlist=allrooms,
                               menu=Menu.dummy_menu(),
                               menulist=Menu.query.all(),
                               account=Account.dummy_account(),
                               acclist2=Account.query.all())
    return render_template('login.html', resp='')
Пример #3
0
def edit_customer_info(user):
    if 'userinfo' in session:
        cust = Customer.query.filter(Customer.name==user).first()
        if cust:
            return render_template('customer_register.html',
                                   cust=cust,
                                   acclist=remaining_accounts())
    return render_template('login.html', resp='')
Пример #4
0
def register_customer():
    msg = ''
    if request.method == 'POST':
        custid = int(request.form['custid'])
        custname = request.form['custname']
        custadr = request.form['custadr']
        custcont = request.form['custcont']
        custmail = request.form['custmail']
        custaccno = request.form['custaccno']
        username = Login.query.filter_by(username=request.form['custname']).first()
        dbcust = Customer.query.filter_by(id=custid).first()
        if dbcust:
            dbcust.id = custid
            dbcust.name = custname
            dbcust.address = custadr
            dbcust.contact = custcont
            dbcust.email = custmail
            username.username = custname
            username.password = request.form['custpass']
            if custaccno:
                dbcust.accno = custaccno
            db.session.commit()
            msg = "Customer Data Updated Successfully..!"
            return redirect(url_for('hotel_booking'))

        else:
            dbcust = Customer(id=custid, name=custname, address=custadr, contact=custcont, email=custmail)
            dbcustomer = Login(username=request.form['custname'], password=request.form['custpass'])
            if username:
                msg = "Username Already Exit...!"
                return render_template('customer.html',
                                       resp=msg,
                                       cust=dbcust,
                                       acclist=remaining_accounts())
            if custaccno:
                dbcust.accno = custaccno
            db.session.add_all([dbcust,dbcustomer])
            db.session.commit()
            msg = "Registration Successfully...!"
            return render_template('login.html',resp=msg)

    return render_template('customer.html',
                           resp=msg,
                           cust=Customer.get_dummy_customer(),
                           acclist=remaining_accounts())
Пример #5
0
def dashboard_page():
    if 'userinfo' in session:
        if session['userinfo'] == 'admin':
            return render_template('dashboard.html',resp='', user=session['userinfo'],hotellist = Hotel.query.all(),
                               hotel = Hotel.dummy_hotel(),
                               acclist = remaining_accounts(),room = Room.dummy_room(),
                               roomlist = Room.query.all(),menu = Menu.dummy_menu(),
                               menulist = Menu.query.all(),account = Account.dummy_account(),
                               acclist2 = Account.query.all())
    return render_template('login.html', resp='')
Пример #6
0
def edit_menu_info(menuid):
    if 'userinfo' in session:
        msg = ''
        menu = Menu.query.filter_by(id=menuid).first()
        return render_template('dashboard.html', resp='editmenu', msg=msg, user=session['userinfo'],
                               hotellist=Hotel.query.all(),
                               hotel=Hotel.dummy_hotel(),
                               acclist=remaining_accounts(), room=Room.dummy_room(),
                               roomlist=Room.query.all(), menu=menu,
                               menulist=Menu.query.all(), account=Account.dummy_account(),
                               acclist2=Account.query.all())
    return render_template('login.html', resp='')
Пример #7
0
def delete_menu_info(menuid):
    if 'userinfo' in session:
        msg = ''
        dbmenu = Menu.query.filter_by(id=menuid).first()
        if dbmenu:
            db.session.delete(dbmenu)
            db.session.commit()
            msg = "Menu Removed Successfully..!"
        return render_template('dashboard.html', resp='deletemenu', msg=msg, user=session['userinfo'],
                               hotellist=Hotel.query.all(),
                               hotel=Hotel.dummy_hotel(),
                               acclist=remaining_accounts(), room=Room.dummy_room(),
                               roomlist=Room.query.all(), menu=Menu.dummy_menu(),
                               menulist=Menu.query.all(), account=Account.dummy_account(),
                               acclist2=Account.query.all())
    return render_template('login.html', resp='')
Пример #8
0
def save_or_update_rooms():
    if 'userinfo' in session:
        msg = ''
        if request.method == 'POST':
            rid = int(request.form['rid'])
            type = request.form['rtype']
            charge = request.form['rcharge']
            status = request.form['rstatus']
            qty = request.form['rqty']
            hotelids = request.form.getlist('hotelid')
            dbroom = Room.query.filter_by(id=rid).first()
            if dbroom:
                # dbroom.id = rid
                dbroom.type = type
                dbroom.charge = charge
                dbroom.status = status
                dbroom.qty = qty
                hotellist = []
                for hotel in hotelids:
                    hotellist.append(Hotel.query.filter_by(id=hotel).first())
                dbroom.rhotelref = hotellist
                db.session.commit()
                msg = "Room Info Updated Successfully..!"
            else:
                dbroom = Room(type=type, charge=charge, status=status, qty=qty)
                hotellist = []
                for hotel in hotelids:
                    hotellist.append(Hotel.query.filter_by(id=hotel).first())
                dbroom.rhotelref.extend(hotellist)
                db.session.add(dbroom)
                db.session.commit()
                msg = "Room Info Created Successfully...!"

        return render_template('dashboard.html',
                               resp='addroom',
                               msg=msg,
                               user=session['userinfo'],
                               hotellist=Hotel.query.all(),
                               hotel=Hotel.dummy_hotel(),
                               acclist=remaining_accounts(),
                               room=Room.dummy_room(),
                               roomlist=Room.query.all(),
                               menu=Menu.dummy_menu(),
                               menulist=Menu.query.all(),
                               account=Account.dummy_account(),
                               acclist2=Account.query.all())
    return render_template('login.html', resp='')
Пример #9
0
def save_or_update_menu():
    if 'userinfo' in session:
        msg  = ''
        if request.method == 'POST':
            menuid = int(request.form['menuid'])
            menuname = request.form['menuname']
            menuprice = request.form['menuprice']
            menuhotels = request.form.getlist('menuhotels')
            dbmenu = Menu.query.filter_by(id=menuid).first()
            if dbmenu:
                # dbmenu.id = menuid
                dbmenu.type = menuid
                dbmenu.name = menuname
                dbmenu.price = menuprice
                if menuhotels:
                    hotellist = []
                    for hotel in menuhotels:
                        hotellist.append(Hotel.query.filter_by(id=hotel).first())
                    # print(dbmenu.href)
                    dbmenu.href = hotellist
                db.session.commit()
                msg = "Menu Updated Successfully..!"
            else:
                dbmenu = Menu(name=menuname,price=menuprice)
                hotellist = []
                if menuhotels:
                    for hotel in menuhotels:
                        hotellist.append(Hotel.query.filter_by(id=hotel).first())
                    dbmenu.href.extend(hotellist)
                db.session.add(dbmenu)
                db.session.commit()
                msg = "Menu Created Successfully...!"

        return render_template('dashboard.html', resp='addmenu', msg=msg, user=session['userinfo'],
                               hotellist=Hotel.query.all(),
                               hotel=Hotel.dummy_hotel(),
                               acclist=remaining_accounts(), room=Room.dummy_room(),
                               roomlist=Room.query.all(), menu=Menu.dummy_menu(),
                               menulist=Menu.query.all(), account=Account.dummy_account(),
                               acclist2=Account.query.all())
    return render_template('login.html', resp='')