Пример #1
0
class SbTables():
    def __init__(self, tableId=None):
        self.conn = DBSysbar().conn()
        self.cursor = self.conn.cursor()
        self.tableId = tableId

    def set_table_id(self, tableId):
        self.tableId = tableId

    def get_table_id(self):
        return self.tableId

    def get_tables_list(self):
        self.cursor.execute(
            "SELECT ID_table, table_price, busy_table, table_capacity FROM sb_tables"
        )
        result = self.cursor.fetchall()
        if not result:
            return {'rStatus': 0}
        return {'rStatus': 1, 'data': result}

    def search_table(self, tableId):
        self.cursor.execute(
            "SELECT ID_table FROM sb_tables WHERE ID_table={}".format(tableId))
        result = self.cursor.fetchone()
        if not result:
            return False
        return True
Пример #2
0
class SbBNUProduct():

    def __init__(self):
        self.conn = DBSysbar().conn(False)
        self.cursor = self.conn.cursor()
    
    def get_product_id(self):
        return self.idProduct

    def set_product_id(self, idProduct):
        self.idProduct = idProduct
    
    def check_product_barcode(self, barcode):
        self.cursor.execute("SELECT ID_product FROM sb_product WHERE barcode='{}' LIMIT 1".format(barcode))
        result = self.cursor.fetchone()
        if not result:
            return False
        return True
    
    def check_product_id(self):
        self.cursor.execute("SELECT ID_product FROM sb_meta_product WHERE ID_product='{}' LIMIT 1".format(self.idProduct))
        result = self.cursor.fetchone()
        if not result:
            return False
        return True
Пример #3
0
class SbCategory():
    def __init__(self, categoryId=None):
        self.conn = DBSysbar().conn()
        self.cursor = self.conn.cursor()
        self.categoryId = categoryId

    def set_category_id(self, categoryId):
        self.categoryId = categoryId

    def get_categories(self):
        self.cursor.execute(
            "SELECT ID_category, category FROM sb_list_categories")
        result = self.cursor.fetchall()
        if not result:
            return {'rStatus': 0}
        return {'rStatus': 1, 'data': result}

    def insert_category(self, name):
        try:
            self.cursor.execute(
                """INSERT INTO sb_list_categories (category, register) 
            VALUES (?, ?)""", (name, datetime.now()))
            self.conn.commit()
            return True
        except:
            return False

    def update_category(self, name):
        print(self.categoryId)
        try:
            self.cursor.execute(
                """UPDATE sb_list_categories SET category = ?, register = ? WHERE ID_category = ?""",
                (name, datetime.now(), self.categoryId))
            self.conn.commit()
            return True
        except:
            return False
Пример #4
0
class SbOrders():
    def __init__(self, orderId=None):
        self.conn = DBSysbar().conn()
        self.cursor = self.conn.cursor()
        self.orderId = orderId

    def set_order_id(self, orderId):
        self.orderId = orderId

    def get_order_id(self):
        return self.orderId

    def get_orders_list(self):
        self.cursor.execute(
            "SELECT sb_orders.ID_order, sb_orders.ID_comanda, sb_comandas.ID_table, sb_client.client_name, sb_product.ID_product, sb_product.product_name, sb_meta_product.printer, sb_orders.amount, sb_orders.comment, sb_orders.register FROM sb_orders INNER JOIN sb_comandas ON sb_orders.ID_comanda=sb_comandas.ID_comanda INNER JOIN sb_client ON sb_comandas.ID_client=sb_client.ID_client INNER JOIN sb_product ON sb_orders.ID_product=sb_product.ID_product INNER JOIN sb_meta_product ON sb_product.ID_product=sb_meta_product.ID_product WHERE order_status=1"
        )
        result = self.cursor.fetchall()
        if not result:
            return {'rStatus': 0}

        items = {'rStatus': 1, 'data': {}}

        for x in result:
            if x[1] in items['data']:
                if x[6] == 1:
                    items['data'][x[1]]['printer'].append({
                        'ID_order': x[0],
                        'ID_product': x[4],
                        'name': x[5],
                        'amount': x[7],
                        'comment': x[8],
                        'register': x[9]
                    })
                else:
                    items['data'][x[1]]['items'].append({
                        'ID_order': x[0],
                        'ID_product': x[4],
                        'name': x[5],
                        'amount': x[7],
                        'comment': x[8],
                        'register': x[9]
                    })
            else:
                items['data'][x[1]] = {
                    'ID_comanda': x[1],
                    'ID_table': x[2],
                    'client_name': x[3],
                    'printer': [],
                    'items': []
                }
                if x[6] == 1:
                    items['data'][x[1]]['printer'].append({
                        'ID_order': x[0],
                        'ID_product': x[4],
                        'name': x[5],
                        'amount': x[7],
                        'comment': x[8],
                        'register': x[9]
                    })
                else:
                    items['data'][x[1]]['items'].append({
                        'ID_order': x[0],
                        'ID_product': x[4],
                        'name': x[5],
                        'amount': x[7],
                        'comment': x[8],
                        'register': x[9]
                    })
        return items

    def get_order_info(self):
        self.cursor.execute(
            "SELECT sb_orders.ID_order, sb_orders.ID_comanda, sb_comandas.ID_table, sb_client.ID_client, sb_client.client_name, sb_product.ID_product, sb_product.product_name, sb_orders.price, sb_orders.amount, sb_orders.discount, sb_orders.shared, sb_orders.comment, sb_orders.order_status, sb_orders.register FROM sb_orders INNER JOIN sb_comandas ON sb_orders.ID_comanda=sb_comandas.ID_comanda INNER JOIN sb_client ON sb_comandas.ID_client=sb_client.ID_client INNER JOIN sb_product ON sb_orders.ID_product=sb_product.ID_product INNER JOIN sb_meta_product ON sb_product.ID_product=sb_meta_product.ID_product WHERE ID_order={} LIMIT 1"
            .format(self.orderId))
        result = self.cursor.fetchone()
        if not result:
            return {'rStatus': 0}

        return {
            'rStatus': 1,
            'data': {
                'ID_comanda': result[1],
                'ID_table': result[2],
                'ID_client': result[3],
                'client_name': result[4],
                'item': {
                    'ID_order': result[0],
                    'ID_product': result[5],
                    'name': result[6],
                    'price': result[7],
                    'amount': result[8],
                    'discount': result[9],
                    'shared': result[10],
                    'comment': result[11],
                    'order_status': result[12],
                    'register': result[13]
                }
            }
        }