Beispiel #1
0
    def options(self):
        print('-' * 36)
        print("You have 1 options, enter the number corresponding to it:")
        print("Create a service fulfillment (1)")
        print("Enter 'exit' to logout")
        print('-' * 36)

        self.choice = input('Enter an option: ')

        if self.choice == '1':
            print('Agreements available for fulfillment:')
            displayQuery(self.controller, self.getAvailableAgreements())

            service_no = input('Enter service_no to fulfill: ')
            account_no = self.getAccountFromAgreement(service_no)
            print("List of Available Drivers: ")
            displayQuery(self.controller, self.getDrivers())
            driver = input('Enter driver\'s id to fulfill task: ')

            # determine if driver owns a truck
            truck = self.getTruckDriver(driver)
            if not truck:
                print('List of available trucks: ')
                displayQuery(self.controller, self.getPublicTrucks())
                truck = input('Enter truck_id for driver to use: ')

            # find a container to be picked up at the location
            pick_up = self.getContainerToPickUp(service_no)

            # drop off a container that is available
            print("List of available containers: ")
            displayQuery(self.controller,
                         self.getAvailabeContainers(service_no))

            drop_off = input('Enter cid for drop off: ')
            if not self.isAvailableContainer(service_no, drop_off):
                print('container is not available for drop off!')
                return

            date = input('Enter date for fulfillment (YYYY-MM-DD): ')

            self.controller.cursor.execute(
                "INSERT INTO service_fulfillments VALUES(?, ?, ?, ?, ?, ?, ?);",
                (
                    date,
                    account_no,
                    service_no,
                    truck,
                    driver,
                    drop_off,
                    pick_up,
                ))

            self.controller.connection.commit()
            self.controller.cursor.execute(
                "SELECT * FROM service_fulfillments ORDER BY service_no DESC")
            displayQuery(self.controller, self.controller.cursor.fetchall())
Beispiel #2
0
def loginPrompt(controller):
    attempts = 0
    controller.cursor.execute("SELECT user_id, role, login FROM users")
    displayQuery(controller, controller.cursor.fetchall())
    while (attempts < 3):
        username = input('Enter Username: '******'Enter Password: '******'Login Unsuccessful ({}) attempts left'.format(3 - attempts))
Beispiel #3
0
 def options(self):
     print('-' * 36)
     print("You have 1 options, enter the number corresponding to it:")
     print("Find driver tours(1)")
     print("Enter 'exit' to logout")
     print('-' * 36)
     self.choice = input('Enter an option: ')
     if self.choice == '1':
         start = input(
             'What is the starting date of the tours you want to assess in the format: YYYY-MM-DD: '
         )
         end = input(
             'What is the ending date of the tours you want to assess YYYY-MM-DD: '
         )
         displayQuery(self.controller, self.getTours(start, end))
Beispiel #4
0
def admin(db):
    db.cursor.execute("SELECT role, login FROM users")
    displayQuery(db, db.cursor.fetchall())
    # try logging in
    session = canLogin(db, 'owner', 'password')
    assert session

    assert session.role == 'admin'
    assert session.addUser('user1', 'pass1', '12', 'supervisor')
    assert not session.addUser('user1', 'pass1', '13', 'driver')
    assert not session.addUser('user1', 'pass1', '14', 'account manager')

    assert session.deleteUser('user1')

    print("Test case for admin passed!")
def main():
    # create a controller to test.db
    db_directory = os.path.join(os.path.dirname(__file__), 'data/')
    ctrl_db = Controller(db_directory, 'waste_management.db')

    user_id = generateID()
    role = input('Enter user\'s role: ')
    login = input('Enter username: '******'Enter password: ')

    createNewUser(ctrl_db, user_id, role, login, password)

    ctrl_db.cursor.execute("SELECT user_id, role, login FROM users")
    displayQuery(ctrl_db, ctrl_db.cursor.fetchall())

    ctrl_db.connection.close()
Beispiel #6
0
 def options(self):
     print('-' * 36)
     displayQuery(self.controller, self.showUsers())
     print("There are 2 options, enter the number corresponding to it:")
     print("Add login credentials for a personnel (1)")
     print("Delete login credentials for a personnel (2)")
     print("Enter 'exit' to logout")
     print('-' * 36)
     self.choice = input("Please enter an option: ")
     if self.choice == '1':
         username = input('Enter a username for user: '******'Enter a password for user: '******'Enter the users pid: ')
         role = input('Enter the users role: ')
         self.addUser(username, password, pid, role)
     elif self.choice == '2':
         username = input('Enter a username for user: ')
         self.deleteUser(username)
Beispiel #7
0
    def options(self):
        print('-' * 36)
        print("You have 4 options, enter the number corresponding to it:")
        print("Add a master account under a manager (1)")
        print("Create summary report of customer (2)")
        print("Create summary report of manager (3)")
        print("Enter 'exit' to logout")
        print('-' * 36)

        self.choice = input("Please enter an option: ")
        if self.choice == '1':
            displayQuery(self.controller, self.getSupervisedManagers())
            mgr_id = input('Enter supervising manager id: ')
            name = input('Enter customer name: ')
            contact = input('Enter customer contact info: ')
            customer_type = input('Enter customer type: ')
            start = input('Enter start date (YYYY-MM-DD): ')
            end = input('Enter end date (YYYY-MM-DD): ')
            self.addMasterAccount(mgr_id, name, contact, customer_type, start,
                                  end)
        elif self.choice == '2':
            displayQuery(self.controller, self.getSupervisedAccounts())
            account_no = input('Enter account number: ')
            displayRow(self.controller, self.getSummaryReport(account_no))
        elif self.choice == '3':
            displayQuery(self.controller, self.getManagerSummaryReport())
Beispiel #8
0
    def options(self):
        print('-' * 36)
        print("You have 4 options, enter the number corresponding to it:")
        print("Get master account information (1)")
        print("Create new master account (2)")
        print("Create new service agreement (3)")
        print("Create summary report for customer (4)")
        print("Enter 'exit' to logout")
        print('-' * 36)

        self.choice = input("Please enter an option: ")
        if self.choice == '1':
            displayQuery(self.controller, self.getManagedAccounts())
            account_no = input('Enter a account_no: ')
            # display info first, then their service agreements
            displayRow(self.controller, self.getMasterAccount(account_no))
            print()
            displayQuery(self.controller,
                         self.getServiceAgreements(account_no))
        elif self.choice == '2':
            name = input('Enter customer name: ')
            contact = input('Enter customer contact info: ')
            customer_type = input('Enter customer type: ')

            if (customer_type not in self.custoemr_types):
                print("customer type not valid!")
                return

            start = input('Enter start date (YYYY-MM-DD): ')
            end = input('Enter end date (YYYY-MM-DD): ')
            self.addMasterAccount(name, contact, customer_type, start, end)
            print('New master account made for {}!'.format(name))
        elif self.choice == '3':
            account_no = input('Enter account number: ')
            location = input('Enter service location: ')
            waste_type = input('Enter waste type: ')
            schedule = input('Enter schedule memo: ')
            contact = input('Enter contact info: ')
            cost = input('Enter internal costs: ')
            price = input('Enter price: ')
            self.createServiceAgreement(account_no, location, waste_type,
                                        schedule, contact, cost, price)
        elif self.choice == '4':
            displayQuery(self.controller, self.getManagedAccounts())
            account_no = input('Enter account number: ')
            displayRow(self.controller, self.getSummaryReport(account_no))