示例#1
0
def main():

	ipop.cls()

	username = sys.argv[1]

	screen = "_________________________________________________________________\n" + "|\t\t\t\t\t\t\t\t|\n" + "|\tThis page lists all the cancellations done\t\t|\n" + "|\tfrom this account.\t\t\t\t\t|\n" + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"

	print (screen)

	data = mdb.get_user_activity(username, 'cancellations')
	if data == None or data == '':
		print ("No cancellation data available in this account.")
		p = input("Press any key to go to main menu...")
		exit1(username)
	else:
		lines = data.split('\n')
		m = []
		for line in lines:
			m.append(tuple(line.split('_')))

		h = ['Ticket no.', 'Cancelled on', 'Bus ID', 'Source', 'Destination', 'Journey date', 'Seat no.', 'Amount']

		ipop.print_table((h, m))

		p = input("\nPress any key to go to main menu...")
		exit1(username)
def disp_tt(un, ttlist):

    bus_id = ipop.getUserData([str, int], "||\tEnter bus ID or !q to cancel: ",
                              "Wrong data")

    if bus_id == 'R':
        return -1
    elif bus_id == None:
        return 0
    for (i, b) in ttlist:
        if bus_id == i:
            bus_id = b
            break

    tt = mdb.bus_timetable(bus_id, un)

    if tt == []:
        print("Bus with this ID does not exist.")
        return 1
    else:
        h = ['Bus stop', 'Time']
        c = tt
        tup = (h, c)
        print("\nTime table for: " + bus_id)
        ipop.print_table(tup)
        return 1
示例#3
0
def main():

    ipop.cls()
    username = sys.argv[1]
    name = mdb.getNameFromUsername(username)

    fdate = ''
    tdate = ''

    screen = "_________________________________________________________________\n" + "|\t\t\t\t\t\t\t\t|\n" + "|\tHello administrator,\t\t\t\t\t\t\t|\n" + "|\t" + name + "\n" + "|\t\t\t\t\t\t\t\t|\n" + "|\tPlease select the appropriate option:\t\t\t|\n" + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"

    print(screen)
    print("||\t1. Print entire table")
    print("||\t2. Print revenue between two dates")
    print("||")

    ip = ipop.getUserData([int], "||\tEnter option: ", "Wrong data entered!",
                          True, ["x in [1,2]"], True)
    print()

    if ip != None:
        ipop.cls()
        if ip == 1:
            h, c, t = mdb.getRevenue()
            ipop.print_table((h, c))
            print('\nTotal revenue: ' + str(t))
            p = input("\nPress any key to go to main menu....")
            exit1(username)
        elif ip == 2:
            while True:

                print("||\tEnter a 'from' date (DD/MM/YYYY): ")
                fdate = reqdate()
                if fdate == '':
                    exit1(username)
                    break

                print("||\tEnter a 'to' date (DD/MM/YYYY): ")
                tdate = reqdate()
                if tdate == '':
                    exit1(username)
                    break

                if calc.compareDates(fdate, tdate):
                    h, c, t = mdb.getRevenue(fdate, tdate)
                    ipop.print_table((h, c))
                    print('\nTotal revenue: ' + str(t))
                    p = input("\nPress any key to go to main menu....")
                    exit1(username)
                    break
                else:
                    print(
                        "The 'from' date is later than 'to' date.\nEnter 1 to re-enter the dates !q to quit"
                    )
                    p = ipop.getUserData([int, str], "", "")
                    if p == 1: continue
                    else: break
示例#4
0
def main():

	ipop.cls()
	username = sys.argv[1]
	name = mdb.getNameFromUsername(username)

	screen = "_________________________________________________________________\n" + "|\t\t\t\t\t\t\t\t|\n" + "|\tHello administrator,\t\t\t\t\t|\n" + "|\t" + name + "\n" + "|\t\t\t\t\t\t\t\t|\n" + "|\tSee report on reservation/cancellation\t\t\t|\n" + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"

	print(screen)

	fdate = ''
	tdate = ''
	cat = 0
	t = ''
	

	while True:
		print("\tCatagories:\n\t1. Sort according to bus IDs\n\t2. According to route IDs\n\t3. According to actual routes\n")
		cat = ipop.getUserData([int], "||\tEnter category: ", "Wrong data entered!", True, ["x in [1,2,3]"], True)
		if cat == None:
			exit1(username)
			break

		print("||\tEnter a 'from' date (DD/MM/YYYY): ")
		fdate = reqdate()
		if fdate == '':
			exit1(username)
			break

		print("||\tEnter a 'to' date (DD/MM/YYYY): ")
		tdate = reqdate()
		if tdate == '':
			exit1(username)
			break
		
		print("\tType:\n\tr. See reservations\n\tc. See cancellations\n")
		t = ipop.getUserData([str], "||\tEnter type: ", "Wrong data entered!", True, ["x in ['r', 'c']"], True)
		if t == None:
			exit1(username)
			break

		print()
		h, c, t = mdb.order_rc_by_catagories(cat, fdate, tdate, t)
		ipop.print_table((h,c))
		print("\nTotal count: " + str(t) + '\n')

		c = ipop.getUserData([int, str], "||\tEnter 1 for re-search, !q to cancel: ", "Wrong data entered!")
		if c != 1:
			exit1(username)
			break
def main():

    ipop.cls()

    username = ''

    try:
        username = sys.argv[1]
        if mdb.checkUsernamePresence(username) == False: username = ''
    except:
        pass

    screen = "_________________________________________________________________\n" + "|\t\t\t\t\t\t\t\t|\n" + "|\tEnter bus ID to see time-table\t\t\t\t|\n" + "|\tExample: S1, V10, AC5, SL2 etc...\t\t\t|\n" + "|\t\t\t\t\t\t\t\t|\n" + "|\tDon't know bus id? Enter R to see buses between stops.\t|\n" + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"

    print(screen)

    ttlist = []

    if username != '':
        try:
            storedtt = mdb.get_user_activity(username, 'time_tables')
            if storedtt != '':
                storedtt = storedtt.split('\n')
                ttlist = list(enumerate(storedtt, start=1))
                print("||\tYour previous searches:\n")
                h = ['Choice', 'Bus ID']
                tup = (h, ttlist)
                ipop.print_table(tup)
                print("||\tYou can enter these choices in place of bus ID.\n")
        except:
            pass

    while True:
        r = disp_tt(username, ttlist)
        if r == 0:
            exit1(username)
            break
        elif r == -1:
            buses_bet_stops(username)
            break
        else:
            ch = ipop.getUserData(
                [int, str],
                "||\tEnter 1 for another search or !q for main menu.\n\t",
                "Wrong data.")
            if ch == 1: continue
            else:
                exit1(username)
                break
示例#6
0
def disp_seats():

	source = ipop.getUserData([str], "||\tEnter source of journey:\n||\t", "Wrong data")
	if source == None:
		return 0

	destination = ipop.getUserData([str], "||\tEnter destination of journey:\n||\t", "Wrong data")
	if destination == None:
		return 0

	
	while True:
		date = ipop.getUserData([str], "||\tEnter date of journey: (as DD/MM/YYYY format):\n||\t", "Wrong data")
		if date == None:
			return 0
		else:
			if calc.isValidTransactionDate(date):
				break
			else: print("Invalid date or wrong date format given.")

	buses = mdb.buses_between_stops(source, destination)
	if buses != []:
		bus_details = []
		for b in buses:
			n_seats = len(mdb.availableSeats(b, source, destination, date))
			bus_details.append((b, n_seats))
		bh = ['Bus ID', 'Seats available']
		print ("\nFollowing buses are available:")
		ipop.print_table((bh, bus_details))
		print()

	bus_id = ipop.getUserData([str], "||\tEnter bus ID:\n||\t", "Wrong data")
	if bus_id == None:
		return 0

	buses = mdb.buses_between_stops(source, destination)
	if bus_id not in buses:
		print ("This journey does not exist!!")
		return 1
	
	seats = mdb.availableSeats(bus_id, source, destination, date)
	if seats == []: print ("No more seats are available in this bus for the given date!")
	else:
		print("||\tAvailable seats are:")
		print(seats)
		return 1
示例#7
0
def main():

    ipop.cls()

    username = ''

    try:
        username = sys.argv[1]
        if mdb.checkUsernamePresence(username) == False: username = ''
    except:
        pass

    screen = "_________________________________________________________________\n" + "|\t\t\t\t\t\t\t\t|\n" + "|\tEnter source and destination to get avilable buses\t|\n" + "|\tExample: Howrah to Asansol etc...\t\t\t|\n" + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"

    print(screen)

    bbslist = []

    if username != '':
        try:
            storedbbs = mdb.get_user_activity(username, 'buses_between_stops')
            if storedbbs != '':
                storedbbs = storedbbs.split('\n')
                bbslist = list(enumerate(storedbbs, start=1))
                print("||\tYour previous searches:\n")
                h = ['Choice', 'Buses between stops']
                tup = (h, bbslist)
                ipop.print_table(tup)
                print("||\tYou can enter these choices in starting field.\n")
        except:
            pass

    while True:
        r = disp_bbs(username, bbslist)
        if r == 0:
            exit1(username)
            break
        else:
            ch = ipop.getUserData(
                [int, str],
                "||\tEnter 1 for another search or !q for main menu.\n\t",
                "Wrong data.")
            if ch == 1: continue
            else:
                exit1(username)
                break
示例#8
0
def disp_bbs(un, bbslist):

    buses = []
    source = ''
    destination = ''
    chflag = 0

    source = ipop.getUserData([
        str, int
    ], "||\tEnter source or previous search option (if available)\n||\tor !q to cancel: ",
                              "Wrong data")

    if source == None:
        return 0
    for (i, d) in bbslist:
        if source == i:
            source = d.split('_')[0]
            destination = d.split('_')[1]
            chflag = 1
            break

    if chflag == 0:
        destination = ipop.getUserData(
            [str, int], "||\tEnter destination of journey or !q to cancel: ",
            "Wrong data")
        if destination == None:
            return 0

    buses = mdb.buses_between_stops(source, destination, un)
    if buses == []:
        print("This route does not exist.")
        return 1
    else:
        l = []
        print('\nFollowing buses are available:')
        print('From ' + source + ' to ' + destination)
        for b in buses:
            l.append(
                (b, mdb.getBusType(b), mdb.getTime(b, source, destination),
                 mdb.getFare(b, source, destination)))
        h = ['Bus ID', 'Bus type', 'Journey time', 'Journey fare']
        ipop.print_table((h, l))
        return 1
示例#9
0
def adminDisplayTable(ch):

	if ch == 1:
		r1, table_name = create_reservation_table(0)
		headers, data = get_table(table_name)
	elif ch == 2:
		r1, table_name = create_cancellation_table(0)
		headers, data = get_table(table_name)
	elif ch == 3:
		r1, table_name = create_route_table(0)
		headers, data = get_table(table_name)
	elif ch == 4:
		r1, table_name = create_fare_chart(0)
		headers, data = get_table(table_name)
	elif ch == 5:
		r1, table_name = create_bus_table(0)
		headers, data = get_table(table_name)

	ipop.print_table((headers, data))
示例#10
0
def main():

    ipop.cls()

    username = sys.argv[1]

    screen = "_________________________________________________________________\n" + "|\t\t\t\t\t\t\t\t|\n" + "|\tThis page lists all your payment methods.\t\t|\n" + "|\tYou can add or delete some of them\t|\n" + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"

    print(screen)

    data = mdb.get_user_detail(username, 'payments')
    if data == None or data == '':
        print("No payment methods available in this account.")
    else:
        lines = data.split('\n')
        m = list(enumerate(lines, start=1))

        h = ['Option', 'Payment method']

        ipop.print_table((h, m))
def main():

    ipop.cls()

    username = sys.argv[1]

    screen = "_________________________________________________________________\n" + "|\t\t\t\t\t\t\t\t|\n" + "|\tWelcome to seat reservation.\t\t\t\t|\n" + "|\tYou will be guided through the reservation process.\t|\n" + "|\tPlease enter the relevant information as asked.\t\t|\n" + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"

    print(screen)

    print(
        "\nOn entering the start and end of your journey\nwe will automatically list the available buses for you to choose.\nYou can quit the process anytime by entering !q\n"
    )

    routeFlag = False
    dateFlag = False
    seatFlag = False
    seatReserveFlag = False

    source = ''
    destination = ''
    bus_id = ''
    date = ''
    n = 0
    seats = []
    bookedSeats = []
    fare = 0
    amount = 0

    ts = '00:00'
    te = '00:00'

    tickets = []

    while True:
        date = ipop.getUserData(
            [str], "||\tEnter date of journey: (as DD/MM/YYYY format):\n||\t",
            "Wrong data")
        if date == None:
            return 0
        else:
            if calc.isValidTransactionDate(date):
                dateFlag = True
                break
            else:
                print("Invalid date or wrong date format given.")

    while dateFlag:

        source = ipop.getUserData([str], "||\tEnter source:\n||\t",
                                  "Wrong data")
        if source == None:
            exit1(username)
            break
        destination = ipop.getUserData([str], "||\tEnter destination:\n||\t",
                                       "Wrong data")
        if destination == None:
            exit1(username)
            break
        buses = mdb.buses_between_stops(source, destination)
        if buses == []:
            print(
                "Sorry, this route does not exist. Press 1 to re-enter start and destination, !q to cancel and go to main menu."
            )
            p = ipop.getUserData([str, int], "", "Wrong data")
            if p == 1: continue
            else:
                exit1(username)
                break
        else:
            bus_details = []
            for b in buses:
                bus_type = mdb.getBusType(b)
                bus_fare = mdb.getFare(b, source, destination)
                n_seats = len(mdb.availableSeats(b, source, destination, date))
                bus_details.append((b, bus_type, bus_fare, n_seats))
            bh = ['Bus ID', 'Type', 'Fare', 'Seats available']
            print("\nFollowing buses are available:")
            ipop.print_table((bh, bus_details))
            print()
            bus_id = ipop.getUserData([str], "||\tEnter bus id:\n||\t",
                                      "Choose among the available buses.",
                                      True, ['x in ' + str(buses)], True)
            if bus_id == None:
                exit1(username)
            else:
                routeFlag = True
            break

    if routeFlag:
        print("Almost there....")
        while True:
            n = ipop.getUserData(
                [int], "||\tEnter number of seats to be reserved:\n||\t",
                "Wrong data")
            if n == None:
                exit1(username)
            else:
                seats = mdb.availableSeats(bus_id, source, destination, date)
                if n > len(seats):
                    print(
                        "The requested number of seats is currently not available in "
                        + bus_id + " on " + date)
                    p = ipop.getUserData([
                        int, str
                    ], "||\tEnter 1 to decrease number of seats or !q to cancel:\n||\t",
                                         "Wrong data")
                    if p == 1: continue
                    else:
                        exit1(username)
                        break
                else:
                    seatFlag = True
                    break

    if seatFlag:
        p = ipop.getUserData([
            str
        ], "||\tEnter S to manually select seats or any other key for automatic selection:\n||\t",
                             "Wrong data")
        if p == None:
            exit1(username)
        elif p == 'S' or p == 's':
            print("||\tAvailable seats are:")
            print(seats)
            print("||\tEnter seat numbers for " + str(n) + " reservations")
            for i in range(n):
                s = ipop.getUserData([int], "", "Wrong data", True,
                                     ['x in ' + str(seats)], True)
                if s == None:
                    exit1(username)
                bookedSeats.append(s)
        else:
            for i in range(n):
                s = seats[i]
                bookedSeats.append(s)
        seatReserveFlag = True
        print("||\tBooked seats are: " + str(bookedSeats) + '\n')

    if seatReserveFlag:
        fare = mdb.getFare(bus_id, source, destination)
        amount = n * fare
        print("||\tAll set! Total Fare = " + str(n) + " * " + str(fare) +
              " = " + str(amount))
        print("||\tPress any key to book. !q to cancel")
        p = input()
        if p == None:
            exit1(username)
        else:
            for bs in bookedSeats:
                tickets.append(
                    mdb.add_reservation(bus_id, username, source, destination,
                                        date, bs, fare) + '\t' + str(bs))

            timetable = mdb.bus_timetable(bus_id)
            for place, time in timetable:
                if source == place: ts = time
                if destination == place: te = time

            ticket_print(username, tickets, bus_id,
                         mdb.getRouteFromBusID(bus_id), source, destination,
                         date, n, amount, ts, te)
示例#12
0
def main():

    ipop.cls()
    username = sys.argv[1]
    name = mdb.getNameFromUsername(username)

    screen = "_________________________________________________________________\n" + "|\t\t\t\t\t\t\t\t|\n" + "|\tHello administrator,\t\t\t\t\t|\n" + "|\t" + name + "\n" + "|\t\t\t\t\t\t\t\t|\n" + "|\tSee report on reservation/cancellation\t\t\t|\n" + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"

    print(screen)

    bid = ''
    rid = ''
    source = ''
    destination = ''
    t = ''

    print(
        "\tEnter ATLEAST bus ID, or route ID or source or destination or their combination.\n"
    )

    while True:
        bid = input("||\tEnter bus ID (leave blank to include all buses): ")
        if bid == '!q':
            exit1(username)
            break
        elif bid == '':
            rid = input(
                "||\tEnter route ID (leave blank to include all routes): ")
            if rid == '!q':
                exit1(username)
                break

        source = input(
            "||\tEnter source (leave blank to include all sources): ")
        if source == '!q':
            exit1(username)
            break

        destination = input(
            "||\tEnter destination (leave blank to include all destinations): "
        )
        if destination == '!q':
            exit1(username)
            break

        t = input("||\tEnter 'r' for reservation or 'c' for cancellation: ")
        if t == '!q':
            exit1(username)
            break

        print()
        h, c = mdb.order_rc_by_month(t, rid, bid, source, destination)
        if c == []:
            print("\nData unavailable.")
        else:
            ipop.print_table((h, c))

        print()
        c = ipop.getUserData([int, str],
                             "||\tEnter 1 for re-search, !q to cancel: ",
                             "Wrong data entered!")
        if c != 1:
            exit1(username)
            break