Example #1
0
 def __init__(self):
     self.__order_repo = OrderRepository()
     self.__order_list = self.__order_repo.get_order_list()
     self.__car_service = CarService()
     self.__customer_service = CustomerService()
     self.__car = None
     self.__change_service = ChangeService()
Example #2
0
class CustomerView(MethodView):
    def __init__(self):
        super().__init__()
        self.customer = None
        self.customerService = CustomerService()

    def get(self):
        return jsonify(self.customerService.get_customers())

    def post(self):
        if request.json.get('request') is None:
            raise Exception('you have to specify the request')
        if request.json['request'] == 'login':
            return self.login(request.json.get('user'))
        elif request.json['request'] == 'signup':
            if request.json.get('user') is None:
                raise Exception('give us the user')
            return jsonify(
                self.customerService.add_customer(request.json.get('user')))
        elif request.json['request'] == 'reset_password':
            return self.reset_password(request.json.get('password'))
        elif request.json['request'] == 'logout':
            return self.logout(request.json.get('code'))

    def login(self, data):
        print(data)
        self.customer = self.customerService.get_specific_customer(data)
        if self.customer is None:
            raise Exception('customer not found check if the user exists')
        else:
            return jsonify({
                'refresh':
                create_access_token(self.customer['email'], fresh=True),
                'access':
                create_refresh_token(self.customer),
            })

    def reset_password(self, data):
        try:
            self.customer.password = data
            self.customer.save()
            return jsonify({'password changed': True})
        except Exception as exception:
            raise exception

    def logout(self):
        try:
            logout_user()
            return jsonify({"logout": True})
        except Exception as exception:
            return jsonify({"exception": 'exception'}), 400
Example #3
0
 def __init__(self):
     self._car_repo_sedan = CarRepository("Sedan")
     self._car_repo_minibus = CarRepository("Minibus")
     self._car_repo_seven_seat_suv = CarRepository("seven_seat_suv")
     self._car_repo_five_seat_suv = CarRepository("five_seat_suv")
     self._car_repo_small_car = CarRepository("small_car")
     self._all_cars_list = self.make_all_cars_list()
     self._customer_service = CustomerService()
     self._order_repo = OrderRepository()
     self.__change_service = ChangeService()
Example #4
0
 def __init__(self):
     self.__cars = CarService()
     self.__customer = CustomerService()
     self.__ordercar = OrderCar()
     self.__printrepo = PrintRepo()
Example #5
0
class StaffUI():
    def __init__(self):
        self.__cars = CarService()
        self.__customer = CustomerService()
        self.__ordercar = OrderCar()
        self.__printrepo = PrintRepo()

    def main_menu(self):
        """Prentar út "main menu" og biður um val, skilar notanda á réttann stað"""
        choice1 = "1. Pantanir"
        choice2 = "2. Viðskiptavinir"
        choice3 = "3. Bílar"
        choice4 = "4. Verðlisti"
        choice5 = "5. Panta bíl"
        choice6 = "6. Skila bíl"
        choice7 = "7. Skrá út bíl"
        choice8 = "8. Hætta"

        print("\n\t{:^10}".format("Bílaleiga ehf"))
        print(
            "\n\t{:<30}\n\t{:<10}\n\t{:<10}\n\t{:<10}\n\t{:<10}\n\t{:<10}\n\t{:<10}\n\t{:<10}"
            .format(choice1, choice2, choice3, choice4, choice5, choice6,
                    choice7, choice8))

        choice = input("\n\tValmöguleiki: ")

        if choice == '1':
            self.print_order_menu()

        elif choice == '2':
            self.print_clients_menu()

        elif choice == '3':
            self.print_car_menu()

        elif choice == '4':
            self.print_price_list()

        elif choice == '5':
            self.print_order_car_menu()

        elif choice == "6":
            self.return_car()

        elif choice == '7':
            self.rent_car()

        elif choice == '8':
            print("\tLoka forriti...")
            return
        else:
            print("\n\tVitlaust val, vinsamlegast veldu aftur!")
            self.main_menu()

    def return_car(self):
        """prentar út lista yfir upptekna bíla og biður um bílnúmer á bíl
        sem skil á og skráir hann sem skilaðann"""
        self.__cars.print_taken()
        car_plate = input(
            "\n\tBílnúmer bíls sem skila á('q' til að hætta við): ").upper()
        if car_plate == "Q":
            return self.main_menu()
        result = self.__cars.return_car(car_plate)
        if result == 0:
            print("\n\tBíll er ekki á skrá, vinsamlegast reyndu aftur")
            self.return_car()
        elif result == 3:
            print("\n\tBílnúmer ekki rétt slegið inn")
            self.return_car()
        return self.main_menu()

    def rent_car(self):
        """prentar út lista yfir lausa bíla og biður um bílnúmer á bíl
        sem leigja á og skráir hann sem uppteknann"""
        self.__cars.print_available()
        car_plate = input(
            "\n\tBílnúmer bíls sem leigja á('q' til að hætta við): ").upper()
        if car_plate == "Q":
            return self.main_menu()
        result = self.__cars.rent_car(car_plate)
        if result == 0:
            print("\n\tBíll er ekki á skrá, vinsamlegast reyndu aftur")
            self.rent_car()
        elif result == 3:
            print("\n\tBílnúmer ekki rétt slegið inn")
            self.rent_car()
        return self.main_menu()

    def print_order_menu(self):
        """Prentar út valmöguleika fyrir pantanir og biður um val og leiðir notenda á rétta staði"""
        choice1 = "1. Skrá nýja pöntun"
        choice2 = "2. Leita af pöntun"
        choice3 = "3. Pöntunarlisti"
        choice4 = "4. Til baka"

        print("\n\t{:^10}".format("Pantanir"))
        print("\n\t{:<30}\n\t{:<10}\n\t{:<10}\n\t{:<10}".format(
            choice1, choice2, choice3, choice4))

        choice = input("\n\tValmöguleiki: ")

        if choice == '1':
            self.print_order_car_menu()
        elif choice == '2':
            #biður um input frá notenda um vegabréfsnúmer og skilar lista yfir allar pantanir á því númeri
            passport = input("\n\tVegabréfsnúmer: ").upper()
            nr_list = self.search_for_order(passport)
            if nr_list == []:
                print("\tEngin pöntun fannst á þessu vegabréfsnúmeri!")
                self.print_order_menu()
            else:
                self.customer_order_menu(nr_list)
        elif choice == '3':
            #prentar út lista yfir allar pantanir
            self.__ordercar.print_list_of_orders()
            self.print_order_menu()
        elif choice == '4':
            self.main_menu()
        else:
            print("Vitlaust val, vinsamlegast veldu aftur")
            self.print_order_menu()

    def search_for_order(self, passport):
        """Fall sem tekur inn vegabréfsnúmer og prentar töflu af öllum pöntunum á því númeri"""
        #sækja lista af listum af þeim pöntunum sem eru á þessu númeri
        list_of_orders = self.__ordercar.search_for_orders(passport)
        if list_of_orders == 0:
            print("\n\tEkki rétt Vegabréfsnúmer! \n\treyndu aftur\n")
            return self.main_menu()
        #prenta út listann í format töflu formi
        print("\n\t{:<10}\t{:^10}\t{:^10}\t{:^10}\t{:^10}\t{:^10}".format(
            "nr.", "Vegabréfa N.", "Afhendingard.", "Skilad.", "Heildarverð",
            "Flokkur"))
        print(" " * 8 + "-" * 88)
        nr_list = []
        for lst in list_of_orders:
            nr = lst[0]
            nr_list.append(nr)
            passport = lst[1]
            day1 = lst[2]
            day2 = lst[3]
            price = lst[4]
            type_of_car = lst[5]
            insurance = lst[6]
            fullprice = int(price) + int(insurance)
            fullprice = "{:,}".format(fullprice)
            print("\n\t{:<10}\t{:^10}\t{:^10}\t{:^10}\t{:^10}\t{:^10}".format(
                nr, passport, day1, day2, fullprice, type_of_car))
        return nr_list

    def print_clients_menu(self):
        """fall sem prentar út valmöguleika í viðskiptavina menu og skilar notanda á rétta staði"""
        choice1 = "1. Fletta upp Viðskiptavin"
        choice2 = "2. Skrá nýjan viðskiptavin"
        choice3 = "3. Listi af Viðskiptavinum"
        choice4 = "4. Til baka"

        print("\n\t{:^10}".format("Viðskiptavinir"))
        print("\n\t{:<30}\n\t{:<10}\n\t{:<10}\n\t{:<10}".format(
            choice1, choice2, choice3, choice4))
        choice = input("\n\tValmöguleiki: ")

        if choice == '1':
            #sendir notenda í viðeigandi fall
            self.search_customer()

        elif choice == "2":
            #sendir notenda í viðeigandi fall
            self.add_new_customer()

        elif choice == '3':
            #sendir notenda í viðeigandi fall
            self.__customer.print_customer_list()

            #valmöguleiki til þess að fara til baka eftir að listi hefur verið prentaður
            print("\n\t1. Til baka")
            choice = input("\n\tValmöguleiki: ")
            if choice == "1":
                self.print_clients_menu()
            else:
                self.print_clients_menu()

        elif choice == '4':
            self.main_menu()
        else:
            print("\n\tVitlaust val, vinsamlegast veldu aftur!")
            self.print_clients_menu()

    def add_new_customer(self):
        """fall sem tekur inn upplýsingar frá notanda um nýjann viðskiptavin
        og sem síðan sendir upplýsingarnar áfram til að verða skráðar í textaskrána customer.txt"""
        #Input frá notenda um kúnnan
        first_name = input("\n\tFornafn(og millinafn): ").strip()
        last_name = input("\tEftirnafn: ").strip()
        passport = input("\tVegabréfsnúmer: ").upper().strip()
        kredit = input("\tKreditkortanúmer(engin bandstrik): ").strip()
        #upplýsingar sendar í models klasann customer
        new_customer = Customer(first_name, last_name, passport, kredit)
        #kallað í add_customer fallið í customerservice
        customer = self.__customer.add_customer(new_customer)
        #hér er kannað hvað fallið skilar, og þá er farið yfir hvort allt var rétt innslegið
        if customer == 1:
            print("\n\tEkki rétt Vegabréfsnúmer! \n\treyndu aftur\n")
            self.print_clients_menu()
            return
        elif customer == 2:
            print("\n\tEkki rétt kreditkortanúmer! \n\treyndu aftur\n")
            self.print_clients_menu()
            return
        elif customer == 3:
            print("\n\tViðskiptavinur hefur verið skráður!\n")
            self.main_menu()

    def search_customer(self):
        """fall sem prentar út viðskiptavin út frá vegabréfsnúmeri og 
        gefur notenda valmöguleiga um aðgerðir tengdar þeim viðskiptavin"""
        choice1 = "1. Skoða pantanir"
        choice2 = "2. Breyta upplýsingum"
        choice3 = "3. Afskrá viðskiptavin"
        choice4 = "4. Til baka"

        line = "-" * 80
        #beðið um vegabréfsnúmer frá notenda
        passport = input("\n\tVegabréfsnúmer: ").upper()
        #fall sem skilar upplýsingum um þennan ákveðna notenda
        customer, passport, kredit = self.__customer.find_customer(passport)
        if customer == 0:
            print("\n\tEngin viðskiptavinur er skráður á þetta númer!!")
            self.print_clients_menu()
            return
        if customer == 1:
            print(
                "\n\tEkki rétt skráð inn! \n\tVegabréfsnúmer á að vera 8 letur á lengd"
            )
            self.print_clients_menu()
            return

        print("")
        print("\t{:<27}{:^27}{:^27}".format("Nafn", "Vegabréfsnúmer",
                                            "Kreditkortanúmer"))
        print("\t" + line)
        print("\t{:<27} {:^27} {:^27}".format(customer, passport, kredit))

        print("\n\t{:<30}\n\t{:<10}\n\t{:<10}\n\t{:<10}".format(
            choice1, choice2, choice3, choice4))
        choice = input("\n\tValmöguleiki: ")

        if choice == '1':
            #finnur allar pantanir sem þessi ákveðni viðskiptavinur á og sendir í viðeigandi fall
            nr_list = self.search_for_order(passport)
            self.customer_order_menu(nr_list)
        elif choice == '2':
            #Fall til að breyta uppls. um viðskiptavin, byrjar a því að eyða honum og biður svo notenda um
            #að skrá nýjar upplýsingar um notenda

            #eyðir notenda
            self.__customer.delete_customer(passport)
            print("\n\tVinsamlegast skráðu inn nýjar upplýsingar!\n")
            #skráir hann upp á nýtt
            self.add_new_customer()
        elif choice == '3':
            #Sendir uppls. í fall sem eyðir viðskiptavin
            self.__customer.delete_customer(passport)
            print("\n\tViðskiptavin hefur verið eytt úr kerfinu!")
            self.print_clients_menu()
        elif choice == '4':
            self.print_clients_menu()

    def customer_order_menu(self, nr_list):
        """fall sem prentar út valmöguleika fyrir pantanir ákveðins viðskiptavins"""
        choice1 = "1. Breyta pöntun"
        choice2 = "2. Eyða pöntun"
        choice3 = "3. Prenta pöntunarstaðfestingu"
        choice4 = "4. Til baka"

        print("\n\t{:<30}\n\t{:<10}\n\t{:<10}\n\t{:<10}".format(
            choice1, choice2, choice3, choice4))
        choice = input("\n\tValmöguleiki: ")

        if choice == "1":
            #biður um pöntun sem notandi breyta og eyðir henni og biður notenda um uppfærðar uppls.
            number = input("\n\tHvaða pöntun viltu breyta?: ")
            if number.isdigit():
                number = int(number)
                result = self.__ordercar.delete_order(number)
                if result == 1:
                    print("\n\tPöntunarnúmer er ekki til")
                    return self.customer_order_menu(nr_list)
            else:
                print("\n\tVitlaust val, vinsamlegast veldu aftur!")
                self.customer_order_menu(nr_list)

            print("\n\tskráðu pöntun með nýjum upplýsingum!")
            self.print_order_car_menu()
        elif choice == "2":
            #biður um pöntunarnúmer frá notenda og eyðir þeirri ákveðnu pöntun
            number = input("\n\tHvaða pöntun viltu eyða?: ")
            if number.isdigit():
                number = int(number)
                result = self.__ordercar.delete_order(number)
                if result == 1:
                    print("\n\tPöntunarnúmer er ekki til")
                    return self.customer_order_menu(nr_list)
                print("\n\tPöntun hefur verið eytt!")
                self.main_menu()
            else:
                print("\n\tVitlaust val, vinsamlegast veldu aftur!")
                self.customer_order_menu(nr_list)
        elif choice == "3":
            #skrifar pöntunarstaðfestingu og prentar á skjáinn
            self.print_order_confirmation()
        elif choice == "4":
            self.print_order_menu()
        else:
            print("\n\tVitlaust val, vinsamlegast veldu aftur!")
            self.customer_order_menu(nr_list)

    def print_order_confirmation(self):
        '''Prentar út upplýsingar um pöntun út frá pöntunarnúmeri'''
        #biður um pöntunarnúmer sem notandi vill fá staðfestingu á
        number = input("\n\tPöntunarnúmer: ")
        if number.isdigit():
            number = int(number)
            #sækir pöntunarlista notenda
            order_list = self.__ordercar.get_order(number)
            if order_list == []:
                print("\n\tPöntun ekki á lista!")
                self.print_order_confirmation()
            passport = order_list[0]
            day1 = order_list[1]
            day2 = order_list[2]
            price = order_list[3]
            car_type = order_list[4]
            insurance = order_list[5]
            full_price = int(insurance) + int(price)
            full_price = "{:,}".format(full_price)
            #sækir upplýsingar um viðskiptavin
            customer, passport, kredit = self.__customer.find_customer(
                passport)
            self.__customer.write_to_file(customer, passport, kredit, day1,
                                          day2, price, car_type)

            print("\n{:^64}".format("Pöntunarstaðfesting"))
            print(
                "\n========================================================================"
            )
            print("\n\t{:<10}\t{:^10}\t{:^10}".format("Nafn", "Vegabr.Nr.",
                                                      "Kredit Nr."))
            print(
                "\n------------------------------------------------------------------------"
            )
            print("\n\t{:<10}\t{:^10}\t{:^10}".format(customer, passport,
                                                      kredit))
            print(
                "\n------------------------------------------------------------------------"
            )
            print("\n\t{:<10}\t{:^10}\t{:^10}\t{:^10}".format(
                "Frá", "Til", "Verð", "Flokkur"))
            print(
                "\n------------------------------------------------------------------------"
            )
            print("\n\t{:<10}\t{:^10}\t{:^10}\t{:^10}".format(
                day1, day2, full_price, car_type))
            print(
                "\n========================================================================"
            )
            print("\n\t{:<30}".format("1. Til baka"))
            choice = input("\n\tValmöguleiki: ")

            if choice == "1":
                self.main_menu()
            else:
                print("\n\tVitlaust val, vinsamlegast veldu aftur!")
                self.main_menu()
        else:
            print("\n\tVitlaust val, vinsamlegast veldu aftur!")
            self.print_order_confirmation()

    def print_car_menu(self):
        """Prentar út valmynd fyrir bíla og biður um input frá notenda um hvað hann vill gera"""
        choice1 = "1. Listi yfir Bílaflota"
        choice2 = "2. Bílar í Útleigu"
        choice3 = "3. Lausir Bílar"
        choice4 = "4. Fletta upp Bíl"
        choice5 = "5. Skrá nýjan bíl"
        choice6 = "6. Til baka"
        print("\n\t{:^10}".format("Bílaleiga ehf"))
        print("\n\t{:<30}\n\t{:<10}\n\t{:<10}\n\t{:<10}\n\t{:<10}\n\t{:<10}".
              format(choice1, choice2, choice3, choice4, choice5, choice6))

        choice = input("\n\tValmöguleiki: ")

        if choice == '1':
            self.__cars.print_cars()
            self.print_car_menu()
        elif choice == '2':
            self.__cars.print_taken()
            self.print_car_menu()
        elif choice == '3':
            self.__cars.print_available()
            self.print_car_menu()
        elif choice == '4':
            self.search_car()
        elif choice == '5':
            self.add_new_car()
        elif choice == '6':
            self.main_menu()
        else:
            print("\n\tVitlaust val, vinsamlegast veldu aftur!")
            self.print_car_menu()

    def search_car(self):
        """Leitar af ákveðinni bifreið út frá bílnúmeri og prentar upplýsingar á skjáinn"""
        line = "-" * 72
        car_plate = input("\n\tNúmer bifreiðar: ").upper()
        car_model, car_year, car_plate, car_miles, car_color, car_fuel_type, car_status, car_catagory = self.__cars.find_cars(
            car_plate)

        if car_model == 0:
            print("\n\tEnginn bíll er skráður með þetta númer!")
            self.print_car_menu()
            return
        if car_model == 1:
            print(
                "\n\tEkki rétt skráð inn! \n\tBílnúmer á að vera 5 letur á lengd"
            )
            self.print_car_menu()
            return
        print("")
        print("\n\t{:>4}{:>15}{:>8}{:>9}{:>7}{:>10}{:>6}{:>9}".format(
            "Tegund", "Árgerð", "Númer", "Keyrsla", "Litur", "Eldsneyti",
            "Staða", "Flokkur"))
        print("\t" + line)
        print("\t{:<10}\t{:^}\t{:^}\t{:^}\t{:^}\t{:^}\t{:^}\t{:^}".format(
            car_model.capitalize(), car_year, car_plate, car_miles,
            car_color.capitalize(), car_fuel_type, car_status, car_catagory))

        #Prentar út valmyndi fyrir þennan ákvðna bíl
        choice1 = "1. Afskrá bíl"
        choice2 = "2. Setja á lista yfir lausar bifreiðar"
        choice3 = "3. Skrá í útleigu"
        choice4 = "4. Til baka"

        print("\n\t{:<30}\n\t{:<10}\n\t{:<10}\n\t{:<10}".format(
            choice1, choice2, choice3, choice4))
        choice = input("\n\tValmöguleiki: ")
        if choice == "1":
            self.__cars.delete_cars(car_plate)
            print("\n\tBíl hefur verið eytt úr kerfinu!")
            self.print_car_menu()
        elif choice == "2":
            self.__cars.return_car(car_plate)
            self.print_car_menu()
        elif choice == "3":
            self.__cars.rent_car(car_plate)
            self.print_car_menu()
        elif choice == "4":
            self.main_menu()

    def print_price_list(self):
        """Fallið prentar út verðlista fyrir bílaleigubíla"""
        insurance = "Aukatrygging 30.000 kr."
        choice1 = "Smábílar"
        price1 = "10.000 kr."
        choice2 = "Fólksbílar"
        price2 = "15.000 kr."
        choice3 = "Jeppar"
        price3 = "20.000 kr."
        choice4 = "Húsbílar"
        price4 = "25.000 kr."
        over100 = "Athugið dagverð miðast við 100 ekna km á dag að meðaltali yfir \n leigutíma. Gjald fyrir akstur umfram 100 km miðast við 1% \n af dagverði fyrir hvern kílómetra umfram 100km."
        print("\n{:^64}".format("Verðlisti"))
        print(
            "\n================================================================"
        )
        print("\n\t{:<10}\t{:^10}\t{:^10}".format("Flokkur", "Daggjald",
                                                  "Trygging"))
        print(
            "\n----------------------------------------------------------------"
        )
        print("\n\t{:<10}\t{:^10}\t{:^10}".format(choice1, price1, insurance))
        print(
            "\n----------------------------------------------------------------"
        )
        print("\n\t{:<10}\t{:^10}\t{:^10}".format(choice2, price2, insurance))
        print(
            "\n----------------------------------------------------------------"
        )
        print("\n\t{:<10}\t{:^10}\t{:^10}".format(choice3, price3, insurance))
        print(
            "\n----------------------------------------------------------------"
        )
        print("\n\t{:<10}\t{:^10}\t{:^10}".format(choice4, price4, insurance))
        print(
            "\n----------------------------------------------------------------"
        )
        print("\n{}".format(over100))
        print(
            "\n================================================================"
        )
        print("\n\t{:<30}".format("1. Til baka"))
        choice = input("\n\tValmöguleiki: ")

        if choice == "1":
            self.main_menu()
        else:
            print("\n\tVitlaust val, vinsamlegast veldu aftur!")
            self.print_price_list()

    def print_order_car_menu(self):
        """Prentar út pöntunarskjá fyrir pöntun"""

        passport = input("\n\tVegabréfsnúmer: ").upper()
        #sækir find customer fallið og skila gildum sem notuð eru til að geyma gögn
        customer, passport, kredit = self.__customer.find_customer(passport)

        if customer == 0:
            print("\n\tEngin viðskiptavinur er skráður á þetta númer!\n")
            print("\t1. Nýskrá viðskiptavin")
            print("\t2. Slá inn nýtt vegabréfsnúmer")
            choice = input("\n\tValmöguleiki: ")
            if choice == "1":
                self.add_new_customer()
            elif choice == "2":
                self.print_order_car_menu()
            else:
                self.print_order_car_menu()

        if customer == 1:
            print(
                "\n\tEkki rétt skráð inn! \n\tVegabréfsnúmer á að vera 8 letur á lengd"
            )
            self.print_order_menu()
            return
        fullprice, today, someday, carchoice, extraprice = self.__ordercar.order_price(
        )
        if today == 0:
            self.print_order_car_menu()
        print("\n\t\tHeildarverð: {:,}".format(fullprice + extraprice))
        new_order = Order(passport, today, someday, fullprice, carchoice,
                          extraprice)
        fullprice = int(fullprice)
        if fullprice < 10000:
            print("\n\tDagsetning skrifuð vitlaus inn: ")
            self.print_order_car_menu()
        else:
            self.__ordercar.get_car_order(new_order)
            print("\n\tPöntun hefur verið skráð!")

        self.__printrepo.send_email(customer, today, someday)
        self.main_menu()

    def add_new_car(self):
        ''' búa til user interface þar sem notandinn getur skráð inn nýjan bíl '''
        ''' ef bílnúmer er skráð inn vitlaust þarf að láta notandann vita '''
        model = input("\n\ttegund bíls: ").strip().capitalize()
        year = input("\tÁrgerð(YYYY): ").strip()
        plate = input("\tBílnúmer: ").strip().upper()
        miles = input("\tKeyrsla bíls (í km): ").strip()
        color = input("\tLitur bíls: ").strip().capitalize()
        fuel_type = input("\tEldsneytis tegund(Bensín eða Dísel): ").strip()
        print("\n\t1. Smábíll\n\t2. Fólksbíll\n\t3. Jeppi\n\t4. Húsbíll")
        category = input("\tflokkur: ").strip()
        status = True
        new_car = Car(model, year, plate, miles, color, fuel_type, category,
                      status)
        decision = self.__cars.add_car(new_car)
        if decision == 2:
            print("\n\tBíl hefur verið bætt á skrá")
            self.print_car_menu()
        elif decision == 1:
            print("\n\tVitlaust skráð inn bílnúmer")
            self.print_car_menu()

    #def print_doc(self, filename):
        """fall sem prentar út í prentara textaskrá sem sett er inn"""
        """ATH virkar en vantar module win32 í tölvuna svo við commentuðum þetta út"""
Example #6
0
 def __init__(self):
     self.__CustomerService = CustomerService()
Example #7
0
class Customer_UI:

    def __init__(self):
        self.__CustomerService = CustomerService()

    def customer_Menu(self):
        def print_Choices():
            ''' Prints out everything you can do with customers in the system '''
            print('{:<40}{:>40}'.format('The Car Rental', 'F To Go To Frontpage'))
            print('-'*80)
            print("{:^80}".format('CUSTOMERS'))
            print('-'*80)
            print('Press 1 To Sign Up New Customer ')
            print('Press 2 To Delete Customer')
            print('Press 3 To Look Up Customer')
            print('Press 4 To Change Information About A Customer')
            print('Press F To Go To Frontpage\n')

        # Press 1 To Sign Up New Customer
        def action1():
            print("-"*80)
            print("New customer:")
            SSN_input = input('Enter The SSN Of The Person You Want To Sign Up: ')
            SSN = self.__CustomerService.check_SSN(SSN_input)
            # isFound iterates through the file and if there is a match, it will let you know that the customer already exists
            isfound = self.__CustomerService.check_Costumer(SSN)
            if isfound:
                print('\nCustomer Already Exists!')
            else:
                name = input('Enter A Name: ')
                phonenumber_input = input('Enter A Phone Number: ')
                phonenumber = self.__CustomerService.check_Phonenumber(
                    phonenumber_input)
                email = input('Enter An Email: ')
                new_Costumer = Customer(SSN, name, phonenumber, email)
                self.__CustomerService.add_customer(new_Costumer)
                print('\nCustomer Signed!')

        # Press 2 To Delete Customer
        def action2():
            print("-"*80)
            SSN_input = input(
                'Enter The SSN Of The Person You Want To Delete: ')
            SSN = self.__CustomerService.check_SSN(SSN_input)
            # isFound iterates through the file and if there is not match it will allow the user to try again or quit
            isFound = self.__CustomerService.check_Costumer(SSN)
            if isFound:
                self.__CustomerService.delete_customer(SSN)
                print('\nCustomer Deleted!')
            while not isFound:
                again = input("\nCostumer Not Found! (1 = Try Again, 2 = Quit) ")
                if again == '1':
                    SSN_input = input('\nEnter The SSN Of The Person You Want To Delete: ')
                    SSN = self.__CustomerService.check_SSN(SSN_input)
                    isFound = self.__CustomerService.check_Costumer(
                        SSN)
                    if isFound:
                        self.__CustomerService.delete_customer(SSN)
                        print('\nCustomer Deleted!')
                else:
                    print('\nQuitting..')
                    break

        #Press 3 To Look Up Customer
        def action3():
            print("-"*80)
            SSN_input = input('Enter The SSN Of The Person You Want To Look Up: ')
            SSN = self.__CustomerService.check_SSN(SSN_input)
            # isFound iterates through the file and if there is not match it will allow the user to try again or quit
            isFound = self.__CustomerService.check_Costumer(SSN)
            if isFound:
                print()
                print()
                self.__CustomerService.look_up_customer(SSN)
            while not isFound:
                again = input("Costumer Not Found! (1 = Try Again, 2 = Quit) ")
                if again == '1':
                    SSN_input = input('\nEnter The SSN Of The Person You Want To Look Up: ')
                    SSN = self.__CustomerService.check_SSN(SSN_input)
                    isFound = self.__CustomerService.check_Costumer(SSN)
                    if isFound:
                        print()
                        print()
                        self.__CustomerService.look_up_customer(SSN)
                else:
                    print('\nQuitting..')

        # Press 4 To Change Information About A Customer
        def action4():
            print("-"*80)
            SSN_input = input('Enter The SSN Of The Person You Want To Change: ')
            SSN = self.__CustomerService.check_SSN(SSN_input)
            # isFound iterates through the file and if there is not match it will allow the user to try again
            isFound = self.__CustomerService.check_Costumer(SSN)
            print()
            print()
            self.__CustomerService.look_up_customer(SSN)
            while not isFound:
                print("Costumer Not Found! Please Try Again")
                SSN_input = input('\nEnter The SSN Of The Person You Want To Change: ')
                SSN = self.__CustomerService.check_SSN(SSN_input)
                isFound = self.__CustomerService.check_Costumer(SSN)
                print()
                print()
                self.__CustomerService.look_up_customer(SSN)
            print('\npress 1 to Change The SSN')
            print('Press 2 to Change The Name')
            print('Press 3 to Change The Phone Number')
            print('Press 4 to Change The Email\n')
            choice_input = input('Enter Choice: ')
            choice = self.__CustomerService.check_Choice(choice_input)
            changes = input('Enter New Info: ')
            if choice == '1':
                changes = self.__CustomerService.check_SSN(changes)
            elif choice == '3':
                changes = self.__CustomerService.check_Phonenumber(changes)
            self.__CustomerService.Change_Information(SSN, choice, changes)
            print('\nCustomer Info Changed!')

        def main():
            print_Choices()
            action = ""
            while action not in ["1", "2", "3", "4", "F"]:
                action = input('Choose Command: ').lower()
                # Press 1 to Sign Up New Customer
                if action == '1':
                    action1()
                # Press 2 to Delete Customer
                elif action == '2':
                    action2()
                # Press 3 to Look Up Customer
                elif action == '3':
                    action3()
                # Press 4 to Change Information About A Customer
                elif action == '4':
                    action4()
                # Press F to Go To Frontpage
                elif action == 'f':
                    break
                else:
                    print("Invalid Input, Try Again!\n")

        main()
Example #8
0
 def __init__(self):
     self.__Vehicle_service = VehicleService()
     self.__Customer_service = CustomerService()
     self.__Ord_service = OrdService()
     self.__System_MaintenanceService = System_MaintenanceService()
Example #9
0
class SalesmanUi:
    def __init__(self):
        self.__Vehicle_service = VehicleService()
        self.__Customer_service = CustomerService()
        self.__Ord_service = OrdService()
        self.__System_MaintenanceService = System_MaintenanceService()

    def main_menu(self):
        update_progress(-1)
        time.sleep(.4)
        update_progress(1)
        time.sleep(.3)
        cls('')
        time.sleep(.2)
        action = ""
        while (action != "h"):
            print(
                "╔════════════════════════════════════════════════════════════════════════════════════╗"
            )
            print(
                "║                                                          ",
                "%d" % now.day + "/" + "%d" % now.month + "/" +
                "%d" % now.year + " | " + now.strftime("%H:%M:%S"), "    ║")
            print(
                "║--------------------------------------Aðgerðir:-------------------------------------║"
            )
            print(
                "║1. Leigja út bíl (skrá pöntun)                                                      ║"
            )
            print(
                "║2. Skila bíl í lok leigutíma                                                        ║"
            )
            print(
                "║--------------------------------------Skýrslur:-------------------------------------║"
            )
            print(
                "║4. Flétta upp pöntun                                                                ║"
            )
            print(
                "║6. Birta yfirlit yfir viðskiptamenn                                                 ║"
            )
            print(
                "║7. Birta lista yfir lausa bíla                                                      ║"
            )
            print(
                "║8. Birta lista yfir lausa bíla eftir flokkum                                        ║"
            )
            print(
                "║9. Birta lista yfir  bíla í útleigu                                                 ║"
            )
            print(
                "║                                                                                    ║"
            )
            print(
                "║                                                                                    ║"
            )
            print(
                "║                                                                                    ║"
            )
            print(
                "║                                                                                    ║"
            )
            print(
                "╠════════════════════════════════════════════════════════════════════════════════════╣"
            )
            print(
                "║--------------------------------Uppsetning / viðhald :------------------------------║"
            )
            print(
                "║90. Stofna notanda að kerfinu                                                       ║"
            )
            print(
                "║91. Stofna viðskiptamann                                                            ║"
            )
            print(
                "║92. Stofna bíl                                                                      ║"
            )
            print(
                "╠════════════════════════════════════════════════════════════════════════════════════╣"
            )
            print(
                "║                                                                                    ║"
            )
            print(
                "║                                                                                    ║"
            )
            print(
                "║Sláðu inn 'h' til að hætta                                                          ║"
            )
            print(
                "╚════════════════════════════════════════════════════════════════════════════════════╝"
            )
            action = input("Veldu valmöguleika: ").lower()
            if action == "1":
                d = {}
                cls('start')  # now, to clear the screen
                d["ORDER_ID"] = input("Sláðu inn pöntunarnúmer: ")
                d["CUSTOMER_ID"] = input("Nr viðskiptamanns: ")
                d["LICENCE_PLATE_NUMBER"] = input("Bílnúmer: ")
                d["CAR_LOCATION"] = input("Staðsetning bíls í upphafi ")
                d["ORDER_DATE"] = input("Pöntun dags: ")

                d["START_DATE"] = input("Start date: ")
                """
                ret_loc = input('Skilastaðsetning bíls: ')
                ret_date = input("Skiladags bíls: ")
                pay_meth = input("Greiðslumáti: ")
                card_no  = input("  Kortanúmer (ef við á): ")
                ins_bas = input("Grunntrygging: ")
                ins_xtra = input("Aukatrygging: ")
                com_ = input("Athugasemdir: ") """

                #new_o = Ord(order_n,customer_n,license_plate_n,start_loc,order_d,start_d,ret_loc,ret_date,pay_meth,card_no,ins_bas,ins_xtra,com_)
                new_o = Ord(d)
                self.__Ord_service.add_Ord(new_o)

                cls('end')
            elif action == "6":
                cls('')
                customer = self.__Customer_service.get_Customer()
                print(customer)
                cls('end')
            elif action == "7":
                cls('')  # now, to clear the screen
                vehicles = self.__Vehicle_service.get_Available_Vehicles()

                #for row in vehicles:
                #   print(row)
                cls('end')
            elif action == "8":
                cls('')  # now, to clear the screen
                vec_class = input(
                    'Hvaða flokk viltu skoða?  (ath: sýna hér lista yfir mögulega flokka...) '
                )

                vehicles = self.__Vehicle_service.get_Available_Vehicles_by_Class(
                    vec_class)  # does this work?

                cls('end')
            elif action == "9":
                cls('')  # now, to clear the screen
                vehicles = self.__Vehicle_service.get_Occupied_Vehicles()
                cls('end')
            elif action == "89":
                cls('')
                newuser = input("Sláðu inn notendanafn: ")
                pwd = input("Sláðu inn lykilorð: ")
                ssn = input("Sláðu inn kennitölu: ")
                name = input('Fullt nafn: ')
                addr = input('Heimilisfang: ')
                phone = input("Símanúmer: ")
                e_mail = input("Tölvupóstfang: ")
                active = 'YES'
                comments = input('Athugasemd: ')
                new_employee = System_Maintenance(newuser, pwd, ssn, name,
                                                  addr, phone, e_mail, active,
                                                  comments)
                self.__System_MaintenanceService.add_System_Maintenance(
                    new_employee)
                cls('end')

#new_veh = Vehicle(license_plate, manuf,subt,v_class, prod_year,curr_loc,return_loc,return_date,com) #0D, simply represents that this car isn't rented out (yet)
#                self.__Vehicle_service.add_Vehicle(new_veh)

            elif action == "90":
                cls('')
                newuser = input("Sláðu inn notendanafn ")
                pwd = input("Sláðu inn lykilorð ")
                """ file = open("./data/access.txt","a+")
                file.write(newuser)
                file.write(" ")
                file.write(pwd)
                file.write("\n")
                file.close() """

                cls('end')
            elif action == "91":
                cls('')
                name = input("Nafn: ")
                kennitala = input("Kennitala: ")
                phone = input("Símanúmer: ")
                new_Customer = Customer(name, kennitala, phone)
                self.__Customer_service.add_Customer(new_Customer)
                cls('end')
            elif action == '92':
                cls('')
                license_plate = input("Bílnúmer: ")
                manuf = input("Framleiðandi: ")
                subt = input("Undirtegund (týpa) ")
                v_class = input("Flokkur: ")
                prod_year = input("Árgerð: ")
                curr_loc = input("Staðsetning: ")
                return_loc = ''  #doesn't apply to cars - until they are rented out
                return_date = '0D'
                com = input("Athugasemdir: ")

                #self, license_plate, manufacturer, subtype, vec_class, production_year,current_location,return_location,'',comments
                new_veh = Vehicle(
                    license_plate, manuf, subt, v_class, prod_year, curr_loc,
                    return_loc, return_date, com
                )  #0D, simply represents that this car isn't rented out (yet)
                self.__Vehicle_service.add_Vehicle(new_veh)

                cls('end')
            elif action == 'h':
                time.sleep(.2)
                print('Bíðið - kerfi slekkur á sér og gengur frá')
                # update_progress() : Displays or updates a console progress bar
                ## Accepts a float between 0 and 1. Any int will be converted to a float.
                ## A value under 0 represents a 'halt'.
                ## A value at 1 or bigger represents 100%
                update_progress(-1)
                time.sleep(.3)
                update_progress(1)
                time.sleep(.2)
                print('Sjáumst aftur!')
                time.sleep(.2)
                cls("")
            else:
                cls('')
                print('Óleyfilegt gildi slegið inn, reyndu aftur.')
 def __init__(self):
     self.__OrderService = OrderService()
     self.__CarService = CarService()
     self.__CustomerService = CustomerService()
Example #11
0
class OrderService:

    def __init__(self):
        self.__order_repo = OrderRepository()
        self.__order_list = self.__order_repo.get_order_list()
        self.__car_service = CarService()
        self.__customer_service = CustomerService()
        self.__car = None
        self.__change_service = ChangeService()
        #self.__order_num = 1

    def make_date(self, a_date):
        """tekur inn dagsetningu og breytir henni í date() tilvik"""
        day, month, year = a_date.split(".")
        return date(int(year), int(month), int(day))

    def make_order_info(self, prompt, customer_known):
        """Býr til tóma pöntun og sendir pöntunina í gegnum ferlið að búa til allar upplýsingar um hana"""
        price_repo = PriceRepository()
        new_order = Order()
        for step in range(1, 5):
            if customer_known and (step == 1):
                new_order.set_customer(customer_known)
            else:
                choice = new_order.change_info(str(step), self.__car_service, self.__customer_service, prompt, price_repo)
                if choice == "t":
                    return "t"
                elif choice == "h":
                    return "h"
        price_repo = PriceRepository()
        price = calc_price(new_order, price_repo)
        new_order.set_price(price)
        print_header(prompt)
        print(new_order)
        print("="*70)
        continue_q = input("\nEr allt rétt? (j/n) ").lower()
        if continue_q != "j":
            self.change_order_info(new_order, prompt)
        print_header(prompt)
        payment_complete = take_payment(new_order.get_order_price())
        if type(payment_complete) == str:
            return "h"
        print_header(prompt)
        print("Pöntun skráð.")
        sleep(2.5)
        self.__order_repo.add_order(new_order)
        return new_order
        
    def change_order_info(self, order, prompt):
        """Sér um ferlið að uppfæra upplýsingar um pöntun. 
        Þ.e.a.s tekur order og spyr hverju þú villt breyta, sendir þig svo á viðeigandi skref í order.change_info
        síðan uppfærir það repoið og vistar breytingarnar"""
        correct = False
        while not correct:
            print_header(prompt)
            print(order)
            print("="*70)
            print("\nHverju villtu breyta:\n1.  Kennitölu á pöntun\n2.  Bíl og dagsetningu\n3.  Tryggingu\n4.  Kortanúmeri\n5.  Klára Skráningu")
            legal_choice = False
            while not legal_choice:
                choice = input()
                try:
                    if int(choice) in range(1,6):
                        legal_choice = True
                    else:
                        print("Ekki valmöguleiki, veldu aftur")
                except:
                    print("Ekki valmöguleiki, veldu aftur")
            if choice == "5":
                correct = True
            order.change_info(choice, self.__car_service, self.__customer_service, prompt, PriceRepository())
        self.__order_repo.update_order_list()

    def get_order_by_name(self, name):
        """Finnur pöntun eftir leitarkilyrðinu name, leitar eftir pöntunarnúmeri, skilar pöntun ef hún finnst annars None"""
        for order in self.__order_repo.get_order_list():
            order_num = self.get_order_num_from_name(order.get_order_name())
            try:
                name_num = self.get_order_num_from_name(name)
            except:
                name_num = name
            if order_num == name_num:
                return order
        return None

    def get_order_num_from_name(self, name):
        """tekur inn númer og pöntun og skilar bara númerinu"""
        name_list = name.split()
        num = name_list[1]
        return num

    def get_order_by_ssn(self, ssn):
        """Tekur við kennitölu og skilar lista af öllum pöntunum sem eru á þessari kennitölu"""
        customer = self.__customer_service.check_ssn(ssn)
        orders = []
        for order in self.__order_repo.get_order_list():
            if order.get_customer() == customer:
                orders.append(order)
        return orders
        
    def order_delete(self, order):
        """Tekur við pöntun, eyðir því úr pöntunarlistanum og uppfærir pöntunarskjalið í samræmi við nýja listann"""
        self.__order_list.remove(order)
        self.__order_repo.update_order_list()

    def complete_orders(self, prompt):
        """ Þetta fall finnur hvaða pantanir eru með skiladag í dag eða liðinn skiladag og prentar þær út.
            Notandi getur svo valið hvaða pöntun hann vill klára. Þegar sú pöntun hefur verið valinn þá reiknast
            út hvað aukakostnað þarf að greiða (ef viðskiptavinur keyrði meira en 150 km á dag) sem viðskiptavinur
            þarf að greiða. Þegar borgað hefur verið allan aukakostnað þá breytist skráningin á pöntuninni og hún
            hefur þar með verið kláruð. """
        finished_completing_orders = False
        while not finished_completing_orders:
            print_header(prompt)
            order_list = self.__order_repo.get_order_list()
            order_to_complete_list = []
            for order in order_list:
                if order.get_order_complete() != True and order.get_last_day() == date.today():
                    order_to_complete_list.append(order)
            if order_to_complete_list == []:
                print("Enga pöntun þarf að klára í dag.")
                sleep(2)
                finished_completing_orders = True
            else:
                for order in order_to_complete_list:
                    print(order)
                    print()
                order_to_change = input("Hvaða pöntun viltu klára? ")
                if order_to_change == "t" or order_to_change == "h":
                    return order_to_change
                if len(order_to_change.split()) == 2:
                    order_to_change = order_to_change.split()[1]
                for order in order_to_complete_list:
                    if order_to_change == order.get_order_name().split()[1]:
                        order_to_complete = order
                        break
                    order_to_complete = False
                # ss það finnst engin pöntun með þessu nafni
                if not order_to_complete:
                    choice = error_handle("Pöntun", order_to_change)
                    if choice == "t" or choice == "h":
                        return choice
                    print_header(prompt)
                else:
                    car = order_to_complete.get_car()
                    order_price = int(order_to_complete.get_order_price())
                    new_milage_boolean = False
                    while not new_milage_boolean:
                        try:
                            new_milage = input("Hvað er bíllinn núna keyrður? ").lower()
                            if new_milage == "t" or new_milage == "h":
                                return new_milage
                            milage_difference = int(new_milage) - car.get_milage()
                            if 0 < milage_difference:
                                new_milage_boolean = True
                            else:
                                print("Villa: Bíllinn getur ekki verið minna keyrður eftir leigu.")
                        except:
                            print("Villa: Bíllinn getur ekki verið minna keyrður eftir leigu.")
                    day_price = order_price // len(order_to_complete.get_date_list())
                    final_payment = int(milage_difference // 150 * 0.02 * day_price)
                    print_header(prompt)
                    if final_payment > 0:
                        payment_complete = take_payment(final_payment)
                    else:
                        payment_complete = True
                    if type(payment_complete) == str:
                        return "h"
                    self.__car_service.update_car_list(car)
                    order_to_complete.set_car(car)
                    order_to_complete.set_complete(True)
                    self.__order_repo.update_order_list()
                    car.set_milage(new_milage)
                    print_header(prompt)
                    print("Pöntun er nú kláruð")
                    choice = input("1.  Velja aðra pöntun til að klára\nt.  Tilbaka\nh.  Heim\n")
                    if choice == "t" or choice == "h":
                        finished_completing_orders = True
Example #12
0
 def __init__(self):
     super().__init__()
     self.customer = None
     self.customerService = CustomerService()
Example #13
0
class CustomerUI:
    def __init__(self):
        self.__customer_service = CustomerService()
        # self.customer_menu()

    def customer_menu(self):
        """ Hér er hægt að framkvæma tvær aðgerðir sem koma viðskiptavinum við.
            1. Leita að viðskiptavin, hér tekur CustomerService klasinn við kennitölu, athugar hvort það sé til viðskiptavinur
               í kerfinu með þessa kennitölu og skilar viðeigandi viðskiptavin. Þegar viðskiptavinur hefur verið valinn er hann
               sentur í view_customer fallið.
            2. Skrá nýjan viðskiptavin, sjá customer_register í CustomerService klasanum. """
        done = False
        while not done:
            prompt = "Heimasíða / Viðskiptavinir"
            print_header(prompt)
            action = input(
                "1.  Leita að viðskiptavin\n2.  Skrá nýjan viðskiptavin\nh.  Heim\n"
            )
            if action == "1":
                exit_info = ""
                prompt += " / Leita að viðskiptavin"
                while exit_info == "":
                    print_header(prompt)
                    ssn = input("Kennitala: ").lower()
                    if ssn == "h":
                        done = True
                        break
                    elif ssn == "t":
                        break
                    customer = self.__customer_service.check_ssn(ssn)
                    if customer:
                        exit_info, done = self.view_customer(customer)
                    else:
                        choice = input(
                            'Kennitalan: "{}" fannst ekki í kerfinu.\n1.  Reyna aftur\nt.  Tilbaka\nh.  Heim\n'
                            .format(ssn))
                        if choice == "t":
                            break
                        elif choice == "h":
                            done = True
                            break
            elif action == "2":
                prompt += " / Skrá nýjan viðskiptavin"
                print_header(prompt)
                new_customer = self.__customer_service.customer_register()
                if type(new_customer) == Customer:
                    exit_info, done = self.view_customer(new_customer)
                elif new_customer == "h":
                    done = True

            else:
                done = True

    def view_customer(self, customer):
        """ Hér er hægt að framkvæma fjórar aðgerðir fyrir viðskiptavin.
            1. Sjá pantanir, hér er hægt að sjá allar pantanir sem þessi viðskiptavinur hefur skráð á sig.
            2. Breyta skráningu, hér er hægt að breyta skráningu viðskiptavinar með hjálp customer_update_info fallinu í CustomerService
               klasanum.
            3. Afskrá viðskiptavin, hér er viðskiptavinurinn tekinn út úr kerfinu og allar þær pantanir sem eru ókláraðar eyðast úr
               kerfinu líka.
            4. Skrá pöntun á viðskiptavin, hér er hoppað beint inn í make_order_info fallið í OrderService klasanum og 
               viðskiptavinurinn líka svo það þurfi ekki að velja hann aftur."""
        loop = True
        while loop:
            prompt = "Heimasíða / Viðskiptavinir / Skoða viðskiptavin"
            print_header(prompt)
            print(customer)
            print('=' * 70)
            choice = input(
                "\n1.  Sjá pantanir\n2.  Breyta skráningu\n3.  Afskrá viðskiptavin\n4.  Skrá pöntun á viðskiptavin\nt.  Tilbaka\nh.  Heim\n"
            ).lower()
            if choice == "1":
                prompt += " / Sjá pantanir"
                print_header(prompt)
                customer_orders = self.__customer_service.customer_get_history(
                    customer)
                if customer_orders:
                    for order in customer_orders:
                        print(order)
                        print()
                    input('Ýttu á "Enter" til að halda áfram: ')
                else:
                    print("Þessi viðskiptavinur hefur enga notkunarsögu.")
                    sleep(2)
            elif choice == "2":
                prompt += " / Breyta skráningu"
                print_header(prompt)
                self.__customer_service.customer_update_info(customer)
            elif choice == "3":
                prompt += " / Afskrá viðskiptavin"
                print_header(prompt)
                choice = input("Ertu viss?(j/n): ")
                if choice == "j":
                    self.__customer_service.customer_delete(customer)
                    return "Tilbaka", False
            elif choice == "4":
                prompt += " / Skrá pöntun á viðskiptavin"
                print_header(prompt)
                self.__order_service = OrderService()
                new_order = self.__order_service.make_order_info(
                    prompt, customer)
                if type(new_order) == Order:
                    self.__order_ui = OrderUI()
                    self.__order_ui.view_order(new_order)
                else:
                    if new_order == "h":
                        return "Heim", True

                self.__customer_service.update_order_repo()
            elif choice == "t":
                return "Tilbaka", False
            else:
                return "Heim", True
class Put_In_Order_UI:
    def __init__(self):
        self.__OrderService = OrderService()
        self.__CarService = CarService()
        self.__CustomerService = CustomerService()

    def Put_In_Order_Menu(self):
        def print_Choices():
            print('\nPress 1 To Put In Order')
            print('Press 2 To Put In A Future Order\n')

        def new_Or_Old():
            '''Is the Customer new or has he rented from us before'''
            print("-" * 80)
            new_Or_Old = input(
                'Has The Customer Rented From Us Before? (Y = Yes, N = No) '
            ).lower()
            while new_Or_Old != 'y' or 'n':
                if new_Or_Old == 'y':
                    print()
                    break
                elif new_Or_Old == 'n':
                    print("\nSigning A New Customer:")
                    print("-" * 80)
                    SSN_input = input(
                        'Enter The SSN Of The Person Who Is Putting In An Order: '
                    )
                    SSN = self.__CustomerService.check_SSN(SSN_input)
                    # isFound iterates through the file and if there is not match it will allow the user to try again
                    isfound = self.__CustomerService.check_Costumer(SSN)
                    if isfound:
                        print('\nCustomer Already Exists!'
                              )  #we dont need to sign him up
                    else:
                        name = input('Enter A Name: ')
                        phonenumber_input = input('Enter A Phone Number: ')
                        phonenumber = self.__CustomerService.check_Phonenumber(
                            phonenumber_input)
                        email = input('Enter An Email: ')
                        new_Costumer = Customer(SSN, name, phonenumber, email)
                        self.__CustomerService.add_customer(new_Costumer)
                        print("\nCostumer Signed!\n\n")
                        break
                else:
                    print('Invalid Input, Try Again!')
                    new_Or_Old = input(
                        'Has The Customer Rented A Car From Us Before? (Y = Yes, N = No) '
                    ).lower()

        def available_Categories():
            print("-" * 80)
            loop = True
            while loop:
                print(
                    '\nWhat Kind Of Car Do You Want? (M = Mini car, S = Station car, J = Jeep'
                )
                car_choice = input('Choose A Category: ').lower()
                if car_choice == 'm':
                    print("-" * 80)
                    car_choice = 'Mini Car'
                    print('\nThese Mini Cars Are Available:\n')
                    self.__OrderService.pick_a_category(car_choice)
                    loop = False
                elif car_choice == 's':
                    print("-" * 80)
                    car_choice = 'Station Car'
                    print('\nThese Station Cars Are Available:\n')
                    self.__OrderService.pick_a_category(car_choice)
                    loop = False
                elif car_choice == 'j':
                    print("-" * 80)
                    car_choice = 'Jeep'
                    print('\nThese Jeeps Are Available:\n')
                    self.__OrderService.pick_a_category(car_choice)
                    loop = False
                else:
                    print('Invalid Input, Try Again!\n')
            print("-" * 80)

        def rent_Dates():
            rent_year = int(input('\nEnter Rent Year: '))
            car_rent_year = self.__OrderService.check_year(rent_year)
            rent_month = int(input('Enter Rent Month: '))
            car_rent_month = self.__OrderService.check_month(rent_month)
            rent_day = int(input('Enter Rent Day: '))
            car_rent_day = self.__OrderService.check_days(rent_day)
            return_year = int(input('\nEnter Return Year: '))
            car_return_year = self.__OrderService.check_year(return_year)
            return_month = int(input('Enter Return Month: '))
            car_return_month = self.__OrderService.check_month(return_month)
            return_day = int(input('Enter Return Day: '))
            car_return_day = self.__OrderService.check_days(return_day)
            return car_rent_year, car_rent_month, car_rent_day, car_return_year, car_return_month, car_return_day

        def credit_Card():
            cardholder = input("\nEnter The Cardholder's Name: ")
            card = input('Enter Your Card Number: ')
            while len(card) != 16:
                print('Invalid Input, Try Again! (only 16 digits)\n')
                card = input('Enter Your Card Number: ')
            exp_date = input('Enter The Expiration Date: (mm-yy) ')
            sec_num = input('Enter The Security Number: ')
            print('\nPayment Completed!')

        # Press 1 To Put In Order
        def action1():
            today = datetime.today().date()
            print('\nToday: {:}'.format(today))
            print('Are There Any Orders You have To Activate Today?\n')
            self.__OrderService.print_out_future_orders(
            )  # Print Out All The Future Orders
            available_Categories()
            SSN_input = input(
                'Enter The SSN Of The Person Who Is Putting In An Order: ')
            SSN = self.__CustomerService.check_SSN(SSN_input)
            self.__OrderService.remove_from_future_orders(SSN)
            licence_Plate = input(
                '\nEnter The Licence Plate Of The Car: ').upper()
            isFound = self.__OrderService.check_Car(licence_Plate)
            while not isFound:
                print("Car Not Found, Please Try Again!")
                licence_Plate = input(
                    'Enter The Licence Plate Of The Car: ').upper()
                isFound = self.__OrderService.check_Car(licence_Plate)
            car_rent_year, car_rent_month, car_rent_day, car_return_year, car_return_month, car_return_day = rent_Dates(
            )
            loop = True
            while loop:
                if car_return_day == car_rent_day and car_return_month == car_rent_month:
                    print(
                        "\nSorry You Can't Rent For Only One Day! Please Try Again\n"
                    )
                    car_return_month = int(input('Enter Return Month: '))
                    car_return_month = self.__OrderService.check_month(
                        car_return_month)
                    car_return_day = int(input('Enter Return Day: '))
                    car_return_day = self.__OrderService.check_days(
                        car_return_day)
                else:
                    loop = False
            extra_insurance = input(
                '\nDo You Want Extra Insurance: (Y = Yes, N = No) ').lower()
            if extra_insurance == 'y':
                print('\nWe Need Your Credit Card Number Please\n')
                credit_card = input('Enter Your Credit Card Number: ')
                while len(credit_card) != 16:
                    print('Invalid Input, Try Again! (only 16 digits)\n')
                    credit_card = input('Enter Your Credit Card Number: ')
            while extra_insurance not in ['y', 'n']:
                print('Invalid Input, Try Again!')
                extra_insurance = input(
                    '\nDo You Want Extra Insurance: (Y = Yes, N = No) ').lower(
                    )
            payment = input(
                '\nAre You Paying With A Card Or Cash: (1 = Card, 2 = Cash): ')
            if payment == '1':
                credit_Card()
            if payment == '2':
                print('Payment Completed!')
            self.__OrderService.put_in_an_order(SSN, licence_Plate,
                                                car_rent_year, car_rent_month,
                                                car_rent_day, car_return_year,
                                                car_return_month,
                                                car_return_day,
                                                extra_insurance)
            print('\nOrder Added!')

        # Press 2 To Put In A Future Order
        def action2():
            print("-" * 80)
            SSN_input = input('Enter The SSN: ')
            SSN = self.__CustomerService.check_SSN(SSN_input)
            Name = input('Enter Name: ')
            category_inp = input(
                'Enter The Category (M = Mini Car, S = Station Car, J = Jeep): '
            ).lower()
            Category = self.__CarService.check_Category(
                category_inp)  #Check if the category is valid
            car_rent_year, car_rent_month, car_rent_day, car_return_year, car_return_month, car_return_day = rent_Dates(
            )
            loop = True
            while loop:
                if car_return_day == car_rent_day and car_return_month == car_rent_month:
                    print(
                        "\nSorry You Can't Rent For Only One Day! Please Try Again\n"
                    )
                    car_return_month = int(input('Enter Return Month: '))
                    car_return_month = self.__OrderService.check_month(
                        car_return_month)
                    car_return_day = int(input('Enter Return Day: '))
                    car_return_day = self.__OrderService.check_days(
                        car_return_day)
                else:
                    loop = False
            extra_insurance = input(
                'Do You Want Extra Insurance: (Y = Yes, N = No) ').lower()
            while extra_insurance not in ['y', 'n']:
                print('Invalid Input, Try Again!')
                extra_insurance = input(
                    '\nDo You Want Extra Insurance: (Y = Yes, N = No) ').lower(
                    )
            self.__OrderService.put_in_future_order(
                SSN, Name, Category, car_rent_year, car_rent_month,
                car_rent_day, car_return_year, car_return_month,
                car_return_day, extra_insurance)
            print("\nOrder Added!")

        def main():
            new_Or_Old()
            print_Choices()
            action = ""
            while action not in ["1", "2"]:
                action = input('Choose Command: ').lower()
                # Press 1 to Put In Order
                if action == '1':
                    action1()
                # Press 2 to Put In Future Order
                elif action == '2':
                    action2()
                else:
                    print('\nInvalid Input, Try Again!\n')

        main()
Example #15
0
class SalesmanUI:
    def __init__(self):
        self.__car_service = CarService()
        self.__customer_service = CustomerService()

    def add_car(self):
        brand = input("Car Brand: ")
        model = input("Car Model: ")
        category = input("Car Category: ")
        taxti = input("Car rate: ")
        new_car = Car(brand, model, category, taxti)
        self.__car_service.add_car(new_car)

    def add_customer(self):
        name = input("Customer name: ")
        ssn = input("Customer snn: ")
        phone = input("Phone: ")
        email = input("Email: ")
        address = input("Address: ")
        cardInfo = input("Card info: ")
        return Customer(name, ssn, phone, email, address, cardInfo)

    def main_menu(self):

        action = " "
        while (action != "q"):
            print("Main menu:")
            # Add or remove a car to database # Add and remove and edit customer functions inside here.
            print("1: Car menu")
            # Here you can get all information about bookings. (Create new order, extend order, return car, remove/unorder car)
            print("2: Customer menu")
            print("3: Bookings menu")
            print("4: Search")
            print("Press q to quit")

            action = input("Choose an option: ").lower()

            if action == "1":
                self.car_menu()

            elif action == "2":
                self.customer_menu()

            elif action == "q":
                exit()

            else:
                print("Invalid option!")

    def car_menu(self):
        action = " "
        while action != "b":
            print("Car menu: ")
            print("1: Add car")
            print("2: Remove car")
            print("3: Car history")
            print("4: Available cars")
            print("5: Unavailable cars")
            print("Enter 'b' to go back.")
            action = input("Choose an option: ").lower()

            if action == "1":
                self.add_car()

            elif action == "4":
                self.__car_service.available_cars()

            elif action == "b":
                self.main_menu()

            elif action == "q":
                exit()

    def customer_menu(self):
        action = " "
        while action != "b":
            print("Customer menu: ")
            print("1: Add customer")
            print("2: Remove customer")

            action = input("Choose an option: ")

            if action == "1":
                new_customer = self.add_customer()
                self.__customer_service.add_customer(new_customer)
            elif action == "b":
                self.main_menu()
            elif action == "q":
                exit()
Example #16
0
 def __init__(self):
     self.__car_service = CarService()
     self.__customer_service = CustomerService()
Example #17
0
class Order_UI:

    def __init__(self):
        self.__OrderService = OrderService()
        self.__CarService = CarService()
        self.__Customer = CustomerOptions()
        self.__CustomerService = CustomerService()

    def Order_Menu(self):
        def print_Choices():
            ''' Prints out everything you can do with orders in the system '''
            print('{:<40}{:>40}'.format('The Car Rental', 'F To Go to Frontpage'))
            print('-'*80)
            print("{:^80}".format('ORDERS'))
            print('-'*80)
            print('Press 1 to Put In Order')
            print('Press 2 to Cancel Order')
            print('Press 3 to Look Up Order')
            print('Press 4 to Change Order')
            print('Press 5 to Return Car')
            print('Press F to Go To Frontpage\n')

        # Press 2 to Cancel Order
        def action2():
            print("-"*80)
            SSN_input = input('Enter The SSN Of The Person Who Put In The Order: ')
            SSN = self.__CustomerService.check_SSN(SSN_input)
            print()
            # isFound iterates through the file and if there is not match it will allow the user to try again or quit
            isFound = self.__OrderService.check_Order(SSN)
            if isFound:
                self.__OrderService.cancel_Order(SSN)
                print('Order Canceled!')
            while not isFound:
                again = input("Order Not Found! (1 = Try Again, 2 = to Quit)")
                if again == '1':
                    SSN_input = input('\nEnter The SSN Of The Person Who Put In Order: ')
                    SSN = self.__CustomerService.check_SSN(SSN_input)
                    print()
                    isFound = self.__CustomerService.check_Costumer(SSN)
                    if isFound:
                        self.__OrderService.cancel_Order(SSN)
                        print('Order Canceled!')
                else:
                    print('Quitting..')
                    break

        # Press 3 to Look Up Order
        def action3():
            print("-"*80)
            SSN_input = input('Enter The SSN Of The Person Who Put In The Order: ')
            SSN = self.__CustomerService.check_SSN(SSN_input)
            print()
            # isFound iterates through the file and if there is not match it will allow the user to try again or quit
            isFound = self.__OrderService.check_Order(SSN)
            if isFound:
                print()
                self.__OrderService.look_up_order(SSN)
            while not isFound:
                again = input("Order Not Found! (1 = Try Again, 2 = to Quit) ")
                if again == '1':
                    SSN_input = input('Enter The SSN Of The Person Who Put In Order: ')
                    SSN = self.__CustomerService.check_SSN(SSN_input)
                    isFound = self.__CustomerService.check_Costumer(SSN)
                    if isFound:
                        print()
                        self.__OrderService.look_up_order(SSN)
                else:
                    print('Quitting..')
                    break

        # Press 4 to Change Order
        def action4():
            print("-"*80)
            SSN_input = input('Enter The SSN Of The Person Who Put In The Order: ')
            SSN = self.__CustomerService.check_SSN(SSN_input)
            # isFound iterates through the file and if there is not match it will allow the user to try again
            isFound = self.__CustomerService.check_Costumer(SSN)
            while not isFound:
                print("\nOrder Not Found! Please Try Again\n")
                SSN_input = input('Enter The SSN Of The Person Who Put In The Order: ')
                SSN = self.__CustomerService.check_SSN(SSN_input)
                isFound = self.__CustomerService.check_Costumer(SSN)
            print()
            self.__OrderService.look_up_order(SSN)
            print('\n\nPress 1 To Change Rent Date')
            print('Press 2 To Change Return Date')
            print('Press 3 To Change Extra Insurance (Y = Yes, N = No)\n')
            choice = input('Enter Choice: ')
            while choice not in ['1', '2', '3']:
                print('Invalid Input, Try Again!\n')
                choice = input('Enter Choice: ')
            if choice == '1' or choice == '2':
                print('Put In The Date In The Format yyyy-mm-dd\n')
            changes = input('Enter New Info: ').lower()
            self.__OrderService.change_Order(SSN, choice, changes)
            print('\nOrder Changed!')

        # Press 5 to Return Car
        def action5():
            print("-"*80)
            print('Return Car: \n')
            self.__OrderService.print_orders()
            plate = input('\nEnter The Licence Plate Of The Car You Want To Return: ')
            plate = plate.upper()
            self.__OrderService.return_car(plate)
            print('\nCar Returned!')

        def main():
            print_Choices()
            action = ""
            while action not in ["1", "2", "3", "4", "5", "F"]:
                action = input('Choose Command: ').lower()
                if action == '1':
                    # Press 1 to Put in order
                    ui = Put_In_Order_UI()
                    ui.Put_In_Order_Menu()
                # Press 2 to Cancel Order
                elif action == '2':
                    action2()
                # Press 3 to Look Up Order
                elif action == '3':
                    action3()
                # Press 4 to Change Order
                elif action == '4':
                    action4()
                # Press 5 to Return Car'
                elif action == '5':
                    action5()
                # Press F to Go To Frontpage
                elif action == 'f':
                    break
                else:
                    print("Invalid Input, Try Again!")

        main()