예제 #1
0
class Bills:
    def __init__(self):
        self.bills = []
        if sqlite_mode == False:
            self.idcreator = IDcreator()

    def new(self):
        if sqlite_mode:
            bill = Bill(0)
            self.bills.append(bill)
            Reader_Writer.write_bill(bill)
            return bill
        else:
            bill = Bill(self.idcreator.getid())
            self.bills.append(bill)
            return bill

    def add(self, bill):
        self.bills.append(bill)

    def load(self, id, total, date, payment_method, eet, is_sale):
        bill = Bill(id)
        bill.total = total
        bill.date = date
        bill.payment_method = payment_method
        bill.eet = eet
        bill.is_sale = is_sale
        self.bills.append(bill)
        return bill

    def delete(self, search_term):
        b = self.find_bill(search_term)
        if (b == None):
            return
        index = self.bills.index(b)
        if sqlite_mode:
            Reader_Writer.delete_bill(b)
        del self.bills[index]

    def find_bill(self, search_term):
        for b in self.bills:
            if (b.id == int(search_term)):
                return b
        print("Bill not found")
        return None

    def __setitem__(self, number, data):
        self.bills[number] = data

    def __getitem__(self, number):
        return self.bills[number]

    def clear(self):
        self.bills.clear()

    def print(self):
        for b in self.bills:
            b.print()
예제 #2
0
class Users:
    def __init__(self):
        self.users = []
        if sqlite_mode == False:
            self.idcreator = IDcreator()

    def new(self, name, real_name, password, phone, email, is_employee,
            is_manager):
        if sqlite_mode:
            self.users.append(
                User(0, name, real_name, password, phone, email, is_employee,
                     is_manager))
        else:
            self.users.append(
                User(self.idcreator.getid(), name, real_name, password, phone,
                     email, is_employee, is_manager))

    def load(self, id, name, real_name, password, phone, email, is_employee,
             is_manager):
        self.users.append(
            User(int(id), name, real_name, password, phone, email,
                 bool(is_employee), bool(is_manager)))

    def add(self, user):
        self.users.append(user)

    def auth(self, username, password):
        for user in self.users:
            if (username == user.name):
                if (password == user.password):
                    return user
        return None

    def find_user(self, search_term):
        for u in self.users:
            if (u.id == search_term or u.name == search_term
                    or u.email == search_term):
                return u
        print("Item not found")
        return None

    def remove(self, search_term):
        u = self.find_user(search_term)
        if u is None:
            return
        index = self.users.index(u)
        del self.users[index]

    def __setitem__(self, number, data):
        self.users[number] = data

    def __getitem__(self, number):
        return self.users[number]

    def clear(self):
        self.users.clear()
예제 #3
0
 def __init__(self):
     self.stock = []
     if sqlite_mode == False:
         self.idcreator = IDcreator()
예제 #4
0
class Stock:
    def __init__(self):
        self.stock = []
        if sqlite_mode == False:
            self.idcreator = IDcreator()

    def load(self, id, name, code, price, dph, count, mincount, weight,
             is_age_restricted):
        self.stock.append(
            Item(int(id), name, code, float(price), int(dph), int(count),
                 int(mincount), float(weight), bool(is_age_restricted)))

    def add(self, item):
        self.stock.append(item)

    def new(self, name, code, price, dph, count, mincount, weight,
            is_age_restricted):
        if sqlite_mode:
            item = Item(0, name, code, price, dph, count, mincount, weight,
                        is_age_restricted)
            self.stock.append(item)
            Reader_Writer.write_item(item)
            return item
        else:
            item = Item(self.idcreator.getid(), name, code, price, dph, count,
                        mincount, weight, is_age_restricted)
            self.stock.append(item)
            return item

    def delete(self, search_term):
        i = self.find_item(search_term)
        if i is None:
            return
        if sqlite_mode:
            Reader_Writer.delete_item(i)
        index = self.stock.index(i)
        del self.stock[index]

    def __setitem__(self, number, data):
        self.stock[number] = data

    def __getitem__(self, number):
        return self.stock[number]

    def transform(self):
        return self.__dict__

    def find_item(self, search_term):
        for i in self.stock:
            if (i.id == search_term or i.name == search_term
                    or i.code == search_term):
                return i
        print("Item not found")
        return None

    def clear(self):
        self.stock.clear()

    def print_under_minimum(self):
        for i in self.stock:
            if (i.count <= i.mincount):
                print("[{}] {} {}".format(i.id, i.name, i.count))

    def print(self):
        print("[id]nazev, kod, cena(dph), pocet, minpocet, vaha, vekomez")
        for i in self.stock:
            i.print()
예제 #5
0
 def __init__(self):
     self.orders = []
     if sqlite_mode == False:
         self.idcreator = IDcreator()
예제 #6
0
class Orders:
    def __init__(self):
        self.orders = []
        if sqlite_mode == False:
            self.idcreator = IDcreator()

    def new(self, user):
        if sqlite_mode:
            order = Order(0, user)
            self.orders.append(order)
            Reader_Writer.write_order(order)
            return order
        else:
            order = Order(self.idcreator.getid(), user)
            self.orders.append(order)
            return order

    def add(self, order):
        self.orders.append(order)

    def load(self, id, user, total, total_weight, date, payment_method,
             shipping_method, address, status):
        order = Order(id, user)
        order.items = []
        order.total = total
        order.total_weight = total_weight
        order.date = date
        order.payment_method = payment_method
        order.shipping_method = shipping_method
        order.address = address
        order.status = status
        self.orders.append(order)
        return order

    def delete(self, search_term):
        o = self.find_order(search_term)
        if (o == None):
            return
        index = self.orders.index(o)
        if sqlite_mode:
            Reader_Writer.delete_order(o)
        del self.orders[index]

    def find_order(self, search_term):
        for o in self.orders:
            if (o.id == int(search_term)):
                return o
        print("Order not found")
        return None

    def __setitem__(self, number, data):
        self.orders[number] = data

    def __getitem__(self, number):
        return self.orders[number]

    def clear(self):
        self.orders.clear()

    def print(self):
        for o in self.orders:
            o.print()