Exemplo n.º 1
0
 def log_in(self):
     messagebox.showinfo("#byle_na_4.5", 'RUDY KRUL')
     username = self.username_input.get()
     password = self.password_input.get()
     if not username or not password:
         messagebox.showinfo('Error', 'Wprowadź dane logowania.')
         return
     login_data = api.get('DaneLogowania', filters={
         'login': username,
         'haslo': password
     })
     if not login_data:
         messagebox.showinfo('Error', 'Podano błędne dane logowania!')
         return
     klient = api.get('Klient', filters={
         'dane_logowania.login': username
     })
     if klient:
         self.controller.set_user(klient[0])
         self.controller.show_frame(KlientPage)
         return
     pracownik = api.get('Pracownik', filters={
         'dane_logowania.login': username
     })
     if pracownik:
         self.controller.set_user(pracownik[0])
         self.controller.show_frame(PracownikPage)
         return
Exemplo n.º 2
0
    def __init__(self, parent, controller):
        super().__init__(parent, controller)
        self.label = tk.Label(self)
        self.label.pack(pady=10, padx=10)

        self.descriptions_get = []
        self.descriptions_get = api.get(
            'OpisApartamentu',
            fields={
                "IdApartamentu": ['id'],
                "OpisApartamentu": ['verbose_name']
            }
        )

        self.elements = []
        for i in range(len(self.descriptions_get)):
            self.elements.append(self.descriptions_get[i]['verbose_name'])

        self.descr_label = tk.Label(self)
        self.opis = tk.StringVar(self)
        self.descr_list = tk.OptionMenu(self, self.opis, *self.elements)
        self.status_label = tk.Label(self)
        self.status = tk.StringVar(self)
        self.status_list = tk.OptionMenu(self, self.status, "Wolny", "Zajęty")

        self.add_button = tk.Button(self, text="Dodaj nowy apartament", command=self.add_ap)
        self.return_button = tk.Button(self, text="Wróć do strony pracownika", command=self.tohome)
Exemplo n.º 3
0
    def tkraise(self, *args, **kwargs):
        self.label.config(text=f"Zmiana danych osobowych:")
        self.password_label.config(text="Hasło:")
        self.password_label2.config(text="Powtórz hasło:")
        self.name_label.config(text="Imię:")
        self.lastname_label.config(text="Nazwisko:")
        self.email_label.config(text="Adres email:")
        self.money_label.config(text="Wynagrodzenie miesięczne:")
        self.address_label.config(text="Adres zamieszkania:")

        self.dane = api.get('Pracownik',
                            filters={'id': self.controller.user_data['id']},
                            include=['dane_logowania'])

        self.password_input.delete(0, tk.END)
        self.password_input.insert(0, self.dane[0]['dane_logowania']['haslo'])
        self.password_input2.delete(0, tk.END)
        self.password_input2.insert(0, self.dane[0]['dane_logowania']['haslo'])
        self.name_input.delete(0, tk.END)
        self.name_input.insert(0, self.dane[0]['imie'])
        self.lastname_input.delete(0, tk.END)
        self.lastname_input.insert(0, self.dane[0]['nazwisko'])
        self.email_input.delete(0, tk.END)
        self.email_input.insert(0, self.dane[0]['dane_logowania']['email'])
        self.money_input.delete(0, tk.END)
        self.money_input.insert(0, self.dane[0]['wyplata'])
        self.address_input.delete(0, tk.END)
        self.address_input.insert(0, self.dane[0]['adres'])
        super().tkraise()
Exemplo n.º 4
0
    def __init__(self, parent, controller):
        super().__init__(parent, controller)
        self.label = tk.Label(self)
        self.label.pack(pady=10, padx=10)

        self.type_get = []
        self.type_get = api.get('RodzajSprzetu',
                                fields={
                                    "IdTypu": ['id'],
                                    "NazwaTypu": ['nazwa']
                                })

        self.type_elements = []
        for i in range(len(self.type_get)):
            self.type_elements.append(self.type_get[i]['nazwa'])

        self.type_label = tk.Label(self)
        self.opis = tk.StringVar(self)
        self.type_list = tk.OptionMenu(self, self.opis, *self.type_elements)

        self.mark_get = []
        self.mark_get = api.get('Producent',
                                fields={
                                    "IdProducenta": ['id'],
                                    "NazwaProducenta": ['nazwa']
                                })

        self.mark_elements = []
        for i in range(len(self.mark_get)):
            self.mark_elements.append(self.mark_get[i]['nazwa'])

        self.mark_label = tk.Label(self)
        self.opis1 = tk.StringVar(self)
        self.location_list = tk.OptionMenu(self, self.opis1,
                                           *self.mark_elements)

        self.price_label = tk.Label(self)
        self.price_input = tk.Entry(self)

        self.add_button = tk.Button(self,
                                    text="Dodaj opis",
                                    command=self.add_desc)
        self.return_button = tk.Button(self,
                                       text="Wróć do strony głównej",
                                       command=self.tohome)
Exemplo n.º 5
0
    def filter_res(self):
        # messagebox.showinfo('Info', 'Tego jeszcze nie ma ;)')

        nazwisko = self.filter_res_input.get()
        if not nazwisko:
            messagebox.showinfo('Info', 'Nie wpisano kryterium!')
            return

        klient_id = api.get('Klient',
                            fields={"KlientId": ['id']},
                            filters={'nazwisko': nazwisko})

        if not klient_id:
            messagebox.showinfo('Info', 'Nie znalezino takiego klienta!')
            return

        # messagebox.showinfo('Info', f'Klient id: {klient_id[0]["id"]}')

        self.reservation_list.delete(0, tk.END)

        self.reservations_get = []
        self.reservations_get = api.get(
            'RezerwacjaSprzetu',
            fields={
                "Idrezerwacji": ['id'],
                "Nazwarezerwacji": ['verbose_name']
            },
            filters={'klient.id': klient_id[0]["id"]})

        self.elements.clear()
        for i in range(len(self.reservations_get)):
            self.elements.append(self.reservations_get[i]['verbose_name'])

        for item in self.elements:
            self.reservation_list.insert(tk.END, item)

        self.reservation_list.activate(0)
        self.reservation_list.selection_set(0, 0)
Exemplo n.º 6
0
    def tkraise(self, *args, **kwargs):
        self.label.config(text="Zwrot sprzętu")
        self.res_label.config(text="Wybierz rezerwację:")
        self.filter_res_label.config(text="Wprowadź nazwisko rezerwującego:")
        self.filter_res_input.delete(0, tk.END)

        # self.filter_res_input.insert(0, "Baggins")

        self.reservation_list.delete(0, tk.END)

        self.reservations_get = []
        self.reservations_get = api.get(
            'RezerwacjaSprzetu',
            fields={
                "Idrezerwacji": ['id'],
                "Nazwarezerwacji": ['verbose_name']
            },
            include={'sprzet': {
                "IdSprzetu": ['id']
            }})

        self.elements = [
            reservation['verbose_name']
            for reservation in self.reservations_get
        ]

        for item in self.elements:
            self.reservation_list.insert(tk.END, item)

        self.reservation_list.activate(0)
        self.reservation_list.selection_set(0, 0)

        self.res_label.pack()
        self.reservation_list.pack()
        self.filter_res_label.pack()
        self.filter_res_input.pack()
        self.filter_res_button.pack()
        self.return_item_button.pack()
        self.return_button.pack()
        super().tkraise()
Exemplo n.º 7
0
    def tkraise(self, *args, **kwargs):
        self.label.config(text="Rezerwacja apartamentu")
        self.start_date_label.config(text="Data rozpoczęcia rezerwacji:")
        self.end_date_label.config(text="Data zakończenia rezerwacji:")

        self.apartment_list.delete(0, tk.END)

        self.apps_get = []
        self.apps_get = api.get('Apartament',
                                fields={
                                    "IdApartamentu": ['id'],
                                    "NazwaApartamentu": ['verbose_name']
                                },
                                filters={'zajety': False})

        self.elements = []
        for i in range(len(self.apps_get)):
            self.elements.append(self.apps_get[i]['verbose_name'])

        for item in self.elements:
            self.apartment_list.insert(tk.END, item)

        self.apartment_list.activate(0)
        self.apartment_list.selection_set(0, 0)
        self.start_date_input.delete(0, tk.END)
        self.start_date_input.insert(0, "yyyy-mm-dd")
        self.end_date_input.delete(0, tk.END)
        self.end_date_input.insert(0, "yyyy-mm-dd")

        self.start_date_label.pack()
        self.start_date_input.pack()
        self.end_date_label.pack()
        self.end_date_input.pack()
        self.apartment_list.pack()
        self.reserve_apartment_button.pack()
        self.return_button.pack()
        super().tkraise()
Exemplo n.º 8
0
    def register(self):
        username = self.username_input.get()
        password1 = self.password_input.get()
        password2 = self.password_input2.get()
        name = self.name_input.get()
        lastname = self.lastname_input.get()
        email = self.email_input.get()
        card = self.card_input.get()
        address = self.address_input.get()

        self.register_button.config(bg='deep sky blue')

        if not username or (not password1 and not password2):
            messagebox.showinfo('Error', 'Podaj login i hasło!')
            self.register_button.config(bg='ghost white')
            return
        if password1 != password2:
            messagebox.showinfo('Error', 'Podano dwa różne hasła!')
            self.register_button.config(bg='ghost white')
            return
        if not name or not lastname:
            messagebox.showinfo(
                'Error', 'Potrzebujemy Twoich danych osobowych!\n'
                'Podaj imię i nazwisko.')
            self.register_button.config(bg='ghost white')
            return
        if not email or not address or not card:
            messagebox.showinfo(
                'Error', 'Ptrzebujemy Twoich danych kontaktowych!\n'
                'Podaj swój adres email, adres zamieszkania i numer karty.')
            self.register_button.config(bg='ghost white')
            return

        login_data = api.get('DaneLogowania', filters={'login': username})

        if login_data:
            messagebox.showinfo('Error', 'Ten login jest zajęty! Wymyśl inny.')
            self.register_button.config(bg='ghost white')
            return

        if not (len(card) == 19) or not (card[4] == ' ') or not (
                card[9] == ' ') or not (card[14] == ' '):
            messagebox.showinfo('Error', 'Podano nieprawidłowy numer karty!')
            return

        try:
            dane_logowania = api.create('DaneLogowania',
                                        attributes={
                                            "login": username,
                                            "email": email,
                                            "haslo": password1
                                        })
        except Exception:
            messagebox.showinfo('Error',
                                'Taki adres email nie ma prawa istnieć!.')
            self.register_button.config(bg='ghost white')
            return

        try:
            klient = api.create('Klient',
                                attributes={
                                    "imie": name,
                                    "nazwisko": lastname,
                                    "adres": address,
                                    "numer_karty": card
                                },
                                relationships={
                                    'dane_logowania': {
                                        'type': 'DaneLogowania',
                                        'id': username
                                    }
                                })
        except Exception:
            messagebox.showinfo(
                'Error', 'Nie udało się utworzyć konta!\n'
                'Sprawdź, czy wszystkie wartości są\n'
                'prawidłowo wprowadzone.')
            return

        klient = api.get('Klient', filters={'dane_logowania.login': username})
        self.register_button.config(bg='ghost white')
        messagebox.showinfo('Dodano', f'Dodano klienta: {(username)}')
        self.controller.set_user(klient[0])
        self.controller.show_frame(KlientPage)
Exemplo n.º 9
0
    def return_item(self):
        res_id = self.reservation_list.get(tk.ACTIVE)
        item_id = 0
        # nazwisko = self.filter_res_input.get()

        for item in range(len(self.elements)):
            if self.elements[item] == res_id:
                res_id = self.reservations_get[item]['id']
                item_id = self.reservations_get[item]['sprzet']['id']
        if not res_id:
            messagebox.showinfo('Error', 'Wybierz rezerwację!')
            return

        # messagebox.showinfo('Error', f'Dane:\n'
        #                              f'Rezka: {res_id}\n'
        #                              f'Item: {item_id}\n')

        self.dane = api.get('Sprzet',
                            fields={
                                "ItemId": 'id',
                                "CzyZajety": 'zajety'
                            },
                            filters={'id': item_id},
                            include={'opis'})

        # messagebox.showinfo('Error', f'Dotyczy sprzętu: {self.dane}')

        try:
            api.update('Sprzet',
                       attributes={"zajety": False},
                       relationships={
                           'opis': {
                               'type': 'OpisSprzetu',
                               'id': self.dane[0]['opis']['id']
                           }
                       },
                       _id=item_id)
        except Exception:
            messagebox.showinfo(
                'Error', 'Nie można ustawić sprzętu na wolny!\n'
                'Sprawdź czy wszystkie dane zostały\n'
                'prawidłowo wprowadzone.')
            return

        try:
            api.delete('RezerwacjaSprzetu', _id=res_id)
        except Exception:
            messagebox.showinfo(
                'Error', 'Nie można usunąć wybranej rezerwacji!\n'
                'Sprawdź, czy wszystkie dane zostały podane prawidłowo.')
            try:
                api.update('Sprzet',
                           attributes={"zajety": True},
                           relationships={
                               'opis': {
                                   'type': 'OpisSprzetu',
                                   'id': self.dane[0]['opis']['id']
                               }
                           },
                           _id=item_id)
            except Exception:
                messagebox.showinfo(
                    'Error', 'Nie można ustawić sprzętu na wolny!\n'
                    'Sprawdź czy wszystkie dane zostały\n'
                    'prawidłowo wprowadzone.')
                return
            return

        messagebox.showinfo('Info', f'Udało się zwrócić sprzęt.')
Exemplo n.º 10
0
                        "adres": "pl. Jana Pawla",
                        "numer_karty": "0000 0000 0000 0001"
                    },
                    relationships={
                        'dane_logowania': {
                            'type': 'DaneLogowania',
                            'id': 'JanPawel'
                        }
                    })

api.update('Klient',
           attributes={
               "imie": klient['imie'],
               "nazwisko": "inne nazwisko",
               "adres": klient['adres'],
               "numer_karty": klient['numer_karty']
           },
           relationships={
               'dane_logowania': {
                   'type': 'DaneLogowania',
                   'id': klient['dane_logowania']['id']
               }
           },
           _id=klient['id'])

klient_z_danymi_logowania = api.get('Klient',
                                    filters={'id': klient['id']},
                                    include=['dane_logowania'])
api.delete('Klient', _id=klient['id'])
api.delete('DaneLogowania', _id=dane_logowania['id'])
Exemplo n.º 11
0
    def reserve_apartment(self):
        apartment = self.apartment_list.get(tk.ACTIVE)
        new_id = self.controller.user_data["id"]
        start_date = self.start_date_input.get()
        end_date = self.end_date_input.get()

        for item in range(len(self.elements)):
            if self.elements[item] == apartment:
                apartment = self.apps_get[item]['id']
        if not apartment or not start_date or not end_date:
            messagebox.showinfo('Error', 'Wybierz apartament i podaj daty!')

        self.dane = api.get('Apartament',
                            filters={'id': apartment},
                            include=['opis'])

        try:
            reservation = api.create('RezerwacjeApartamentow',
                                     attributes={
                                         "data_wynajecia": start_date,
                                         "data_wymeldowania": end_date
                                     },
                                     relationships={
                                         'klient': {
                                             'type': 'Klient',
                                             'id':
                                             self.controller.user_data['id']
                                         },
                                         'apartament': {
                                             'type': 'Apartament',
                                             'id': apartment
                                         }
                                     })
        except Exception:
            messagebox.showinfo(
                'Error', 'Nie można utworzyć rezerwacji apartamentu! '
                'Sprawdź czy wszystkie dane (np. daty) zostały '
                'prawidłowo wprowadzone.')
            return

        try:

            api.update('Apartament',
                       attributes={"zajety": True},
                       relationships={
                           'opis': {
                               'type': 'OpisApartamentu',
                               'id': self.dane[0]['opis']['id']
                           }
                       },
                       _id=apartment)
        except Exception:
            api.delete('RezerwacjeApartamentow', _id=reservation['id'])
            messagebox.showinfo(
                'Error', 'Nie można ustawić apartamentu na zajęty! '
                'Sprawdź czy wszystkie dane (np. daty) zostały '
                'prawidłowo wprowadzone.')
            return

        messagebox.showinfo(
            'Error',
            f'Dodano nową rezerwację od: {reservation["data_wynajecia"]}\n'
            f'Ustawiono apartament na zajęty.')
Exemplo n.º 12
0
    def register(self):
        password1 = self.password_input.get()
        password2 = self.password_input2.get()
        name = self.name_input.get()
        lastname = self.lastname_input.get()
        email = self.email_input.get()
        money = self.money_input.get()
        address = self.address_input.get()

        if not password1 and not password2:
            messagebox.showinfo('Error', 'Podaj hasło!')
            return
        if password1 != password2:
            messagebox.showinfo('Error', 'Podano dwa różne hasła!')
            return
        if not name or not lastname:
            messagebox.showinfo(
                'Error', 'Potrzebujemy Twoich danych osobowych!\n'
                'Podaj imię i nazwisko.')
            return
        if not email or not address or not money:
            messagebox.showinfo(
                'Error', 'Ptrzebujemy Twoich danych kontaktowych!\n'
                'Podaj swój adres email, adres zamieszkania i numer karty.')
            return

        if password1 == self.dane[0]['dane_logowania']['haslo'] and (
                name
                == self.dane[0]['imie']) and (lastname
                                              == self.dane[0]['nazwisko']):
            if (email == self.dane[0]['dane_logowania']['email']) and (
                    money
                    == self.dane[0]['wyplata']) and (address
                                                     == self.dane[0]['adres']):
                messagebox.showinfo('Error', 'Nie wprowadzono żadnych zmian! ')
                return

        try:
            api.update('DaneLogowania',
                       attributes={
                           "login": self.dane[0]['dane_logowania']['login'],
                           "email": email,
                           "haslo": password1
                       },
                       _id=self.dane[0]['dane_logowania']['login'])
        except Exception:
            messagebox.showinfo('Error',
                                'Taki adres email nie ma prawa istnieć!.')
            return

        try:
            api.update('Pracownik',
                       attributes={
                           "imie": name,
                           "nazwisko": lastname,
                           "adres": address,
                           "wyplata": money
                       },
                       relationships={
                           'dane_logowania': {
                               'type': 'DaneLogowania',
                               'id': self.dane[0]['dane_logowania']['login']
                           }
                       },
                       _id=self.dane[0]['id'])
        except Exception:
            messagebox.showinfo(
                'Error', 'Nie udało sie zmienić danych!\n'
                'Sprawdź, czy wszystkie dane są wpisane prawodłowo.')
            return

        pracownik = api.get('Pracownik',
                            filters={
                                'dane_logowania.login':
                                self.dane[0]['dane_logowania']['login']
                            })
        messagebox.showinfo('Zmieniono',
                            f'Zmieniono dane pracownika: {(name)}')
        self.controller.set_user(pracownik[0])
        self.controller.show_frame(frames.PracownikPage)
Exemplo n.º 13
0
    def return_item(self):
        res_id = self.reservation_list.get(tk.ACTIVE)
        app_id = 0

        for appart in range(len(self.elements)):
            if self.elements[appart] == res_id:
                res_id = self.reservations_get[appart]['id']
                app_id = self.reservations_get[appart]['apartament']['id']
        if not res_id:
            messagebox.showinfo('Error', 'Wybierz rezerwację!')
            return

        # messagebox.showinfo('Error', f'Dane:\n'
        #                              f'Rezka: {res_id}\n'
        #                              f'Apek: {app_id}\n')

        self.dane = api.get('Apartament',
                            fields={
                                "ItemId": 'id',
                                "CzyZajety": 'zajety'
                            },
                            filters={'id': app_id},
                            include={'opis'})

        # messagebox.showinfo('Error', f'Dotyczy apu: {self.dane}')

        try:
            api.update('Apartament',
                       attributes={"zajety": False},
                       relationships={
                           'opis': {
                               'type': 'OpisApartamentu',
                               'id': self.dane[0]['opis']['id']
                           }
                       },
                       _id=app_id)
        except Exception:
            messagebox.showinfo(
                'Error', 'Nie ustawiono apartamentu na wolny!\n'
                'Sprawdź czy wszystkie dane zostały\n'
                'prawidłowo wprowadzone.')
            return

        try:
            api.delete('RezerwacjeApartamentow', _id=res_id)
        except Exception:
            messagebox.showinfo(
                'Error', 'Nie można usunąć wybranej rezerwacji!\n'
                'Sprawdź, czy wszystkie dane zostały podane prawidłowo.')
            try:
                api.update('Apartament',
                           attributes={"zajety": True},
                           relationships={
                               'opis': {
                                   'type': 'OpisApartamentu',
                                   'id': self.dane[0]['opis']['id']
                               }
                           },
                           _id=app_id)
            except Exception:
                messagebox.showinfo(
                    'Error', 'Nie ustawiono apartamentu na wolny!\n'
                    'Sprawdź czy wszystkie dane zostały\n'
                    'prawidłowo wprowadzone.')
                return
            return

        messagebox.showinfo('Info', f'Udało się wymeldować gości.')