コード例 #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']
        if custname and custadr and custcont and custmail and 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:
                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('login.html', resp=msg)
        msg = "Invalid Credential"

    return render_template('customer_register.html',
                           cust=Customer.dummy_cust(),
                           acclist=remaining_accounts(),
                           resp=msg)
コード例 #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 save_or_update_rooms():
    if 'userinfo' in session:
        #if user:
        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.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(id=rid,
                              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='')
コード例 #5
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.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(id=menuid, 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='')
コード例 #6
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='')
コード例 #7
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='')
コード例 #8
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='')