def rate(): global log rate = dbc.seetable("rate") rate_ = pd.DataFrame(rate, columns=['Item', 'Rate per day']) print(rate_) opt = input(bcolors.OKGREEN + "Do you want to change rates (admin only)? (y/n)" + bcolors.ENDC).lower() if opt == 'y': if adm == True: print(bcolors.OKCYAN + '''Which rate do you want to change? 1. Charge of 'n' bed per day 2. Charge of AC/TV/Wifi per day''' + bcolors.ENDC) opt2 = int(input(bcolors.OKGREEN + "Enter (1/2): " + bcolors.ENDC)) if opt2 == 1: nbed = int( input( bcolors.OKGREEN + "Enter the number of beds (1/2/3) of which you wish to change rates: " + bcolors.ENDC)) item = "item='" + str(nbed) + " bed'" crate = dbc.get("rate", "rpd", item)[0][0] print("Current rate is Rs." + str(crate)) nrate = int(input("Enter the new rate (Rs.): ")) uptr = "rpd=" + str(nrate) dbc.update('rate', uptr, item) print("The new is set to Rs." + str(nrate)) if opt2 == 2: print(bcolors.OKCYAN + '''Please select one of the options: 1. TV, 2. AC, 3. Wifi''' + bcolors.ENDC) opt3 = int( input(bcolors.OKGREEN + "Enter (1/2/3: " + bcolors.ENDC)) items = ['tv', 'ac', 'wifi'] item = "item='" + items[(opt3) - 1] + "'" crate = dbc.get("rate", "rpd", item)[0][0] print("Current rate is Rs." + str(crate)) nrate = int( input(bcolors.OKGREEN + "Enter the new rate (Rs.): " + bcolors.ENDC)) uptr = "rpd=" + str(nrate) dbc.update('rate', uptr, item) print(bcolors.OKCYAN + "The new is set to Rs." + str(nrate) + bcolors.ENDC) else: print(bcolors.WARNING + "You need admin priviledge to change the rates" + bcolors.ENDC) opt = input(bcolors.OKGREEN + "Do you want to login as admin? (y/n)" + bcolors.ENDC).lower() if opt == 'y': log = False login()
def set_mood(user, like_percentage): if like_percentage > 100: like_percentage = 100 elif like_percentage < 0: like_percentage = 0 user_result = db_connect.select('users', where_expression='telegram_id = ' + user.id.__str__()) # bei Fehlschlagen der Datenbankanfrage würde False zurückgeliefert werden if user_result is not False: # zurückgeliefertes Array enthält einen Wert if len(user_result) > 0: # like_percentage (und andere User-Attribute) aktualisieren db_connect.update('users', ['like_percentage', 'first_name', 'last_name', 'username'], [like_percentage, user.first_name, user.last_name, user.username], 'telegram_id=' + user.id.__str__()) # zurückgeliefertes Array enthält keinen Wert else: # neuen User hinzufügen db_connect.insert('users', ['telegram_id', 'like_percentage', 'first_name', 'last_name', 'username'], [user.id, like_percentage, user.first_name, user.last_name, user.username])
def increment_vote(word): result = db_connect.select('aggronymes', 'votes', 'word = "' + word + '"') if result is not False: if len(result) > 0: votes = result[0][0] if votes < 3: # hochzählen votes += 1 result = db_connect.update('aggronymes', ['votes'], [votes], 'word = "' + word + '"') if result is not False: return True return False return False return False return False
def guest(): dbc.create( 'guest_t2', "'fname', 'lname', 'phone', 'email', 'address', 'adults', 'child', 'stay', 'room_no', 'wifi'" ) # personal info fname = input(bcolors.OKGREEN + "First Name: " + bcolors.ENDC) lname = input(bcolors.OKGREEN + "Last Name: " + bcolors.ENDC) # contact while True: phone = input(bcolors.OKGREEN + "Phone Number: " + bcolors.ENDC) if (phone.isnumeric()) and (8 < len(phone) < 13) and (" " not in phone): break else: print(bcolors.FAIL + "Invalid phone number" + bcolors.ENDC) while True: email = input(bcolors.OKGREEN + "Email: " + bcolors.ENDC) if "@" in email: a = email.partition("@") if len(a[0]) != 0 and len( a[2]) != 0 and "@" not in a[0] and "@" not in a[2]: break else: print(bcolors.FAIL + "Invalid email" + bcolors.ENDC) else: print(bcolors.FAIL + "Invalid email" + bcolors.ENDC) while True: address = input(bcolors.OKGREEN + "Guest's Address: " + bcolors.ENDC) if address.isalnum() and len(address) != 0: break else: print(bcolors.FAIL + "Invalid" + bcolors.ENDC) # reservation info while True: adults = input(bcolors.OKGREEN + "Number of Adults: " + bcolors.ENDC) if int(adults) >= 0 and adults.isnumeric(): break else: print(bcolors.FAIL + "Invalid number" + bcolors.ENDC) while True: child = input(bcolors.OKGREEN + "Number of Children: " + bcolors.ENDC) if int(child) >= 0 and child.isnumeric(): break else: print(bcolors.FAIL + "Invalid number" + bcolors.ENDC) while True: stay = input(bcolors.OKGREEN + "Number of Days of stay: " + bcolors.ENDC) if int(stay) >= 0 and stay.isnumeric(): break else: print(bcolors.FAIL + "Invalid number" + bcolors.ENDC) wifi = input(bcolors.OKGREEN + "Wifi access required (y/n): " + bcolors.ENDC).upper() # room room_no = input(bcolors.OKGREEN + "Enter the room number to reserve: " + bcolors.ENDC) #insert guest details in database data = "'" + fname + "', '" + lname + "', " + phone + ", '" + email + "', '" + address + "', " + adults + ", " + child + ", " + stay + ", " + room_no + ", '" + wifi + "'" dbc.insert("guest_t2", data) #update room status upd_cond = "room_no=" + room_no dbc.update("rooms", "status='R'", upd_cond) #confirmation for room allotment chosen = [ ["First name", fname], ["Last name", lname], ["Phone no", phone], ["Email ID", email], ["Address", address], ["No. of Adults", adults], ["No. of children", child], ["No. of days", stay], ["Room Number", room_no], ] print(bcolors.BOLD + "\n\n*********** ROOM ALLOTMENT ************\n\n" + bcolors.ENDC) print(tabulate(chosen, tablefmt="fancy_grid")) con_trans = input(bcolors.OKGREEN + "Do you want to confirm reservation ? [y/n]" + bcolors.ENDC) if con_trans in ["y", "Y", "Yes", "YES"]: print(bcolors.OKCYAN + "\n\nReservation Successful\n\n" + bcolors.ENDC) y_n = input(bcolors.OKGREEN + "\nDo you want to book another room ? [y/n]\n" + bcolors.ENDC) if y_n in ["n", "N", "No"]: print(bcolors.OKCYAN + "Thank you" + bcolors.ENDC) global flag flag = False
def check_out(): roomno = input(bcolors.OKGREEN + "Enter the room number to check out: " + bcolors.ENDC) stay = int(input(bcolors.OKGREEN + "Days stayed?: " + bcolors.ENDC)) dat = "fname, lname, phone, room_no, wifi" _filter = "room_no=" + roomno roominf = dbc.get("guest_t2", dat, _filter) roominf_ = pd.DataFrame( roominf, columns=['First Name', 'Last Name', 'Phone', 'Room No', 'Wifi']) print(roominf_) fname = roominf[0][0] lname = roominf[0][1] phone = roominf[0][2] wifi = roominf[0][4] dat2 = "beds, ac, tv" facility = dbc.get("rooms", dat2, _filter) beds = facility[0][0] ac = facility[0][1] tv = facility[0][2] #generating bill item1 = "'" + str(beds) + " bed" + "'" _filter3 = "item=" + item1 r_1 = dbc.get("rate", "rpd", _filter3)[0][0] if ac == "Y": item2 = "'ac'" _filter4 = "item=" + item2 r_2 = dbc.get("rate", "rpd", _filter4)[0][0] else: r_2 = 0 if tv == "Y": item3 = "'tv'" _filter5 = "item=" + item3 r_3 = dbc.get("rate", "rpd", _filter5)[0][0] else: r_3 = 0 if wifi == "Y": item4 = "'ac'" _filter6 = "item=" + item4 r_4 = dbc.get("rate", "rpd", _filter6)[0][0] else: r_4 = 0 total = (r_1 + r_2 + r_3 + r_4) * stay inv = [ ["First name", fname], ["Last name", lname], ["Phone no", phone], ["No. of days", stay], ["Room per day", "Rs." + str(r_1)], ["TV per day", "Rs." + str(r_3)], ["AC per day", "Rs." + str(r_2)], ["Wifi per day", "Rs." + str(r_4)], ["Total ", "Rs." + str(total)], ["Room Number", roomno], ] co = input(bcolors.WARNING + "Do you want to check out? (y/n)" + bcolors.ENDC) if co.lower() == "y": #Print BILL print(bcolors.BOLD + "\n\n*********** INVOICE ************\n\n" + bcolors.ENDC) print(tabulate(inv, tablefmt="fancy_grid")) con_trans = input(bcolors.OKGREEN + "Do you want to confirm transaction ? [y/n]" + bcolors.ENDC) if con_trans in ["y", "Y", "Yes", "YES"]: print(bcolors.OKCYAN + "\n\nTransaction Successful\n\n" + bcolors.ENDC) y_n = input(bcolors.OKGREEN + "\nDo you want to book another room ? [y/n]\n" + bcolors.ENDC) if y_n in ["n", "N", "No"]: print(bcolors.OKCYAN + "Thank you" + bcolors.ENDC) global flag flag = False cond = "room_no=" + roomno dbc.delt("guest_t2", cond) upd_cond = "room_no=" + roomno dbc.update("rooms", "status='NR'", upd_cond) elif co.lower() == "n": interf()
def guest(): dbc.create( 'guest_t2', "'fname', 'lname', 'phone', 'email', 'address', 'adults', 'child', 'stay', 'room_no'" ) check_room() # personal info fname = input("First Name: ") lname = input("Last Name: ") # contact while True: phone = input("Phone Number: ") if (phone.isnumeric()) and (8 < len(phone) < 12) and ( " " not in phone) and (phone.startswith("09") or phone.startswith("07") or phone.startswith("91")): #if all( [phone.isnumeric(), 8<len(phone.strip())<=12, phone.startswith( ("09","07" ,"91") ) ] ) : break else: print("Invalid phone number") while True: email = input("Email: ") if "@" in email: a = email.partition("@") if len(a[0]) != 0 and len( a[2]) != 0 and "@" not in a[0] and "@" not in a[2]: break else: print("Invalid email") else: print("Invalid email") address = input("Guest's Address: ") # reservation info adults = input("Number of Adults: ") child = input("Number of Children: ") stay = input("Number of Days of stay: ") # room room_no = input("Enter the room number to reserve: ") upd_cond = "room_no=" + room_no dbc.update("rooms", "status='R'", upd_cond) chosen = [ ["First name", fname], ["Last name", lname], ["Phone no", phone], ["Email ID", email], ["Address", address], ["No. of Adults", adults], ["No. of children", child], ["No. of days", stay], ["Room Number", room_no], ] print("\n\n*********** Invoice ************\n\n") print(tabulate(chosen, tablefmt="fancy_grid")) con_trans = input("Do you want to confirm transaction ? [y/n]") if con_trans in ["y", "Y", "Yes", "YES"]: print("\n\nTransaction Successful\n\n") y_n = input("\nDo you want to book another room ? [y/n]\n") if y_n in ["n", "N", "No"]: print("Thank you") global flag flag = False