Exemple #1
0
    def open_table(self, data):
        if isinstance(data, DataTableItem):
            table_item = None
            for item in self.li_table_items:
                if item.table_id == data.table_id:
                    table_item = item

            table_item.waiter = data.waiter
            table_item.customer_num = int(data.customer_num)
            table_item.deposit = data.deposit
            table_item.memo = data.memo
            if CONFIG.useTemp:
                table_item.table_status = 1
                table_item.order_num = time.strftime('B%Y%m%d') + str(self.order_seq)
                self.order_seq += 1
            else:
                result = HttpService.get_instance().open_table(data.table_id, data.customer_num,
                                                               CtrlFrontLogin.get_instance().get_user(),
                                                               CtrlFrontLogin.get_instance().get_password())
                if result is not None:
                    table_item.table_status = 1
                    table_item.order_id = result
                    table_item.order_num = str(result)

            table_order_tmp = {table_item.table_id: table_item.order_num}
            self.di_table_order.update(table_order_tmp)

        EvtManager.dispatch_event(EnumEvent.EVT_FRONT_PAGE_REFRESH)
Exemple #2
0
 def initialize(self):
     # Add event listener
     EvtManager.add_listener(self, EnumEvent.EVT_LOGIN, self.on_evt_login)
     
     self.GetParent().SetTitle(u"登陆")
     x, y = CtrlHomePage.get_instance().get_screen_size()
     self.SetSize(wx.Size(x, y))
Exemple #3
0
    def change_table(self, src_table_num, dst_table_num):
        src_order_num = None
        if int(src_table_num) in self.di_table_order:
            src_order_num = self.di_table_order[int(src_table_num)]

        src_order_id = None
        table_item = CtrlTableInfo.get_instance().get_table_item(src_table_num)
        if table_item is not None:
            src_order_id = table_item.order_id

        result = HttpService.get_instance().change_table(src_table_num, dst_table_num, src_order_id)
        if result is not None:
            for item in self.li_table_items:
                if item.table_num == src_table_num:
                    item.table_num = dst_table_num
                elif item.table_num == dst_table_num:
                    item.table_num = src_table_num

            if src_order_num is not None:
                self.di_table_order[int(dst_table_num)] = src_order_num
                del self.di_table_order[int(src_table_num)]

            self.li_table_items.sort(lambda x, y: cmp(int(x.table_num), int(y.table_num)))

            EvtManager.dispatch_event(EnumEvent.EVT_FRONT_PAGE_REFRESH)
Exemple #4
0
    def minus_dishes(self):
        cur_order_item = self.di_order_item[self.cur_order_num]
        if self.cur_dishes_key in cur_order_item.di_order_dishes_items:
            if cur_order_item.di_order_dishes_items[self.cur_dishes_key].dishes_count <= 1:
                del cur_order_item.di_order_dishes_items[self.cur_dishes_key]
                self.cur_dishes_key = None
            else:
                cur_order_item.di_order_dishes_items[self.cur_dishes_key].dishes_count -= 1

        order_id = 0
        table_num = CtrlTableInfo.get_instance().get_selected_item_id()
        if table_num is not None:
            table_item = CtrlTableInfo.get_instance().get_table_item(table_num)
            order_id = table_item.order_id

        if self.cur_dishes_key in cur_order_item.di_place_dishes_items:
            dishes_item = cur_order_item.di_place_dishes_items[self.cur_dishes_key]
            if len(dishes_item.li_dishes_log_id) > 0:
                HttpService.get_instance().del_dishes(order_id, dishes_item.li_dishes_log_id[0],
                                                      dishes_item.dishes_code, 1, "")
                del dishes_item.li_dishes_log_id[0]

            if cur_order_item.di_place_dishes_items[self.cur_dishes_key].dishes_count <= 1:
                del cur_order_item.di_place_dishes_items[self.cur_dishes_key]
                self.cur_dishes_key = None
            else:
                cur_order_item.di_place_dishes_items[self.cur_dishes_key].dishes_retreat_count += 1
                cur_order_item.di_place_dishes_items[self.cur_dishes_key].dishes_count -= 1

            EvtManager.dispatch_event(EnumEvent.EVT_ORDER_DISHES_ITEMS_REFRESH)
Exemple #5
0
    def add_items(li_data):
        for data in li_data:
            if isinstance(data, DataTable):
                bat_add_items('TableInfo', data)

        bat_add_commit()
        EvtManager.dispatch_event(EnumEvent.EVT_DINING_ROOM_REFRESH)
Exemple #6
0
 def close_table(self, table_num):
     if CONFIG.useTemp:
         pass
     else:
         result = HttpService.get_instance().close_table(table_num)
         if result:
             for item in self.li_table_items:
                 if item.table_id == table_num:
                     item.table_status = 0
             EvtManager.dispatch_event(EnumEvent.EVT_FRONT_PAGE_REFRESH)
Exemple #7
0
    def login(self, user, password):
        try:
            if user == self.user and password == self.password:
                self.check_result = True
            elif get_password_by_user_name(user) == password:
                self.user = user
                self.password = password
                self.check_result = True
        except:
            self.check_result = False

        EvtManager.dispatch_event(EnumEvent.EVT_LOGIN)
Exemple #8
0
    def SetValue(self, value, item, col):
        node = self.ItemToObject(item)
        if isinstance(node, DataSpec):
            if col == 0:
                node.code = value
            elif col == 1:
                node.name = value
            elif col == 2:
                node.price = value

        from framework.core import EvtManager
        from app.enum_event import EnumEvent

        EvtManager.dispatch_event(EnumEvent.EVT_DEFAULT_DISHES_SPEC_REFRESH)
Exemple #9
0
    def plus_dishes(self):
        cur_order_item = self.di_order_item[self.cur_order_num]
        if self.cur_dishes_key in cur_order_item.di_order_dishes_items:
            cur_order_item.di_order_dishes_items[self.cur_dishes_key].dishes_count += 1

        if self.cur_dishes_key in cur_order_item.di_place_dishes_items:
            table_num = CtrlTableInfo.get_instance().get_selected_item_id()
            if table_num is not None:
                table_item = CtrlTableInfo.get_instance().get_table_item(table_num)
                if table_item is not None:
                    self.add_dishes_in_place_order(table_item.table_id, table_item.order_id,
                                                   cur_order_item.di_place_dishes_items[self.cur_dishes_key])
                    cur_order_item.di_place_dishes_items[self.cur_dishes_key].dishes_count += 1

        EvtManager.dispatch_event(EnumEvent.EVT_ORDER_DISHES_ITEMS_REFRESH)
Exemple #10
0
    def query_billboard(self, time_from, time_to, category_id):
        self.time_from = time_from
        self.time_to = time_to
        self.days = (time_to - time_from).days + 1
        del self.li_billboard[0:len(self.li_billboard)]
        result = get_billboard_info(time_from, time_to, category_id)
        if len(result) > 0:
            for key, info in result.items():
                average = info.dishes_count
                if self.days is not None and self.days > 0:
                    average = round(float(info.dishes_count) / self.days, 2)
                item = DataBillboardInfo(0, 0, info.dishes_name, info.brevity_code, info.category, info.unit,
                                         info.dishes_count, average, info.total_money, info.retreat_count,
                                         info.retreat_money)
                self.li_billboard.append(item)

            self.li_billboard.sort(lambda x, y: cmp(int(x.sale_count), int(y.sale_count)), reverse=True)
        EvtManager.dispatch_event(EnumEvent.EVT_BILLBOARD_INFO_REFRESH)
Exemple #11
0
    def query_business(self, date_from, time_from, date_to, time_to):
        self.consume_price = 0
        self.real_price = 0
        self.consumer_num = 0
        self.bill_total = 0
        self.cash_total = 0
        self.coupon_total = 0
        self.membership_total = 0
        self.pos_total = 0
        self.group_total = 0
        self.credit_total = 0
        self.boss_sign_total = 0
        self.date_from = date_from
        self.time_from = time_from
        self.date_to = date_to
        self.time_to = time_to
        del self.li_business[0:len(self.li_business)]
        result = get_business_info(date_from, time_from, date_to, time_to)
        if len(result) > 0:
            for key, info in result.items():
                free_price = info.price - info.real_price if info.real_price is not None else 0
                average_price = round(info.price / info.consumer, 2)
                self.consume_price = self.consume_price + info.price
                self.real_price = self.real_price + info.real_price
                self.consumer_num = self.consumer_num + info.consumer
                self.bill_total = self.bill_total + info.bill_num
                self.cash_total = self.cash_total + info.cash
                self.coupon_total = self.coupon_total + info.coupon
                self.membership_total = self.membership_total + info.membership
                self.pos_total = self.pos_total + info.pos
                self.group_total = self.group_total + info.group
                self.credit_total = self.credit_total + info.credit
                self.boss_sign_total = self.boss_sign_total + info.boss_sign
                item = DataBusinessInfo(0, 0, info.table_num, info.consumer, info.price, free_price, info.real_price,
                                        info.bill_num, average_price, info.cash, info.coupon, info.membership,
                                        info.pos, info.group, info.credit, info.boss_sign, info.checkout_time)
                self.li_business.append(item)
            #self.li_business.sort(lambda x, y: cmp(int(x.consumer_num), int(y.consumer_num)))
            self.li_business.sort(lambda x, y: cmp(str(x.consume_time.strftime("%Y-%m-%d")),
                                                   str(y.consume_time.strftime("%Y-%m-%d"))))

        EvtManager.dispatch_event(EnumEvent.EVT_BUSINESS_INFO_REFRESH)
Exemple #12
0
    def query_sales(self, date_from, time_from, date_to, time_to):
        self.consume_price = 0
        self.real_price = 0
        self.consumer_num = 0
        self.bill_total = 0
        self.cash_total = 0
        self.coupon_total = 0
        self.membership_total = 0
        self.pos_total = 0
        self.group_total = 0
        self.credit_total = 0
        self.boss_sign_total = 0
        self.date_from = date_from
        self.time_from = time_from
        self.date_to = date_to
        self.time_to = time_to
        del self.li_sales[0:len(self.li_sales)]
        result = get_sales_info(date_from, time_from, date_to, time_to)
        if len(result) > 0:
            for info in result:
                free_price = info.price - info.real_price if info.real_price is not None else 0
                self.consume_price = self.consume_price + info.price
                if info.real_price is not None:
                    self.real_price = self.real_price + info.real_price
                self.consumer_num = self.consumer_num + info.consumer
                self.bill_total = self.bill_total + info.bill_num
                self.cash_total = self.cash_total + info.cash
                self.coupon_total = self.coupon_total + info.coupon
                self.membership_total = self.membership_total + info.membership
                self.pos_total = self.pos_total + info.pos
                self.group_total = self.group_total + info.group
                self.credit_total = self.credit_total + info.credit
                self.boss_sign_total = self.boss_sign_total + info.boss_sign
                item = DataSalesInfo(0, 0, info.table_num, info.consumer, info.price, free_price, info.real_price,
                                     info.bill_num, info.cash, info.coupon, info.membership, info.pos,
                                     info.group, info.credit, info.boss_sign, info.checkout_time)
                self.li_sales.append(item)

            self.li_sales.sort(lambda x, y: cmp(str(x.consume_time.strftime("%Y-%m-%d %H:%M:%S")),
                                                str(y.consume_time.strftime("%Y-%m-%d %H:%M:%S"))))
        EvtManager.dispatch_event(EnumEvent.EVT_SALES_INFO_REFRESH)
Exemple #13
0
    def delete_dishes(self, del_reason=""):
        cur_order_item = self.di_order_item[self.cur_order_num]
        if self.cur_dishes_key in cur_order_item.di_order_dishes_items:
            del cur_order_item.di_order_dishes_items[self.cur_dishes_key]

        order_id = 0
        table_num = CtrlTableInfo.get_instance().get_selected_item_id()
        if table_num is not None:
            table_item = CtrlTableInfo.get_instance().get_table_item(table_num)
            order_id = table_item.order_id

        if self.cur_dishes_key in cur_order_item.di_place_dishes_items:
            dishes_item = cur_order_item.di_place_dishes_items[self.cur_dishes_key]
            for dishes_log_id in dishes_item.li_dishes_log_id:
                HttpService.get_instance().del_dishes(order_id, dishes_log_id, dishes_item.dishes_code, 1, del_reason)
                cur_order_item.di_place_dishes_items[self.cur_dishes_key].dishes_retreat_count += 1
            del cur_order_item.di_place_dishes_items[self.cur_dishes_key]

            self.cur_dishes_key = None

        EvtManager.dispatch_event(EnumEvent.EVT_ORDER_DISHES_ITEMS_REFRESH)
Exemple #14
0
    def order_dishes(self, dishes_code, spec_id, style_id, str_demand):
        cur_order_item = self.di_order_item[self.cur_order_num]
        dishes_key = str(dishes_code) + str(spec_id["id"]) + (str(style_id["id"]) if style_id is not None else "0")
        if dishes_key not in cur_order_item.di_order_dishes_items:
            item = DataOrderDishesItem()
            item.dishes_code = dishes_code
            item.dishes_count = 1
            item.dishes_spec = spec_id
            item.dishes_style = style_id
            item.dishes_demand = str_demand
            order_dishes_item_tmp = {dishes_key: item}
            cur_order_item.di_order_dishes_items.update(order_dishes_item_tmp)

            self.cur_dishes_key = dishes_key
        else:
            item = cur_order_item.di_order_dishes_items[dishes_key]
            item.dishes_code = dishes_code
            item.dishes_count = 1
            item.dishes_spec = spec_id
            item.dishes_style = style_id
            item.dishes_demand = str_demand

        EvtManager.dispatch_event(EnumEvent.EVT_ORDER_DISHES_ITEMS_REFRESH)
Exemple #15
0
 def update_item(data):
     if isinstance(data, DataDishes):
         update_item('DishInfo', data)
         EvtManager.dispatch_event(EnumEvent.EVT_DISHES_PUBLISH_REFRESH)
Exemple #16
0
 def update_checkout_info(self):
     EvtManager.dispatch_event(EnumEvent.EVT_CHECKOUT_INFO_REFRESH)
Exemple #17
0
 def change_table_status(self, table_num, status):
     for item in self.li_table_items:
         if item.table_id == table_num:
             item.table_status = status
     EvtManager.dispatch_event(EnumEvent.EVT_FRONT_PAGE_REFRESH)
Exemple #18
0
 def update_item(data):
     if isinstance(data, DataPrinterScheme):
         update_item('PrintSchemeInfo', data)
         EvtManager.dispatch_event(EnumEvent.EVT_PRINTER_SCHEME_REFRESH)
Exemple #19
0
 def refresh_table_items(self):
     del self.li_table_items[0: len(self.li_table_items)]
     EvtManager.dispatch_event(EnumEvent.EVT_FRONT_PAGE_REFRESH)
Exemple #20
0
 def update_item(data, group_list):
     if isinstance(data, DataEmployee):
         update_user_info(data, group_list)
         EvtManager.dispatch_event(EnumEvent.EVT_EMPLOYEE_REFRESH)
Exemple #21
0
                for (key, item) in cur_order_item.di_order_dishes_items.items():
                    if key in cur_order_item.di_place_dishes_items:
                        cur_order_item.di_place_dishes_items[key].dishes_count += item.dishes_count
                    else:
                        cur_place_item_tmp = {key: item}
                        cur_order_item.di_place_dishes_items.update(cur_place_item_tmp)
                cur_order_item.di_order_dishes_items.clear()

                for info in result:
                    dishes_key = str(info["code"]) + str(info["spec"]) + str(info["style"])
                    if dishes_key in cur_order_item.di_place_dishes_items:
                        cur_order_item.di_place_dishes_items[dishes_key].li_dishes_log_id.append(info["logDishId"])

            CtrlTableInfo.get_instance().change_table_status(table_id, 2)

            EvtManager.dispatch_event(EnumEvent.EVT_ORDER_DISHES_ITEMS_REFRESH)

    def get_add_dishes_item(self, item):
        ordered_item = DataOrderedDishesItem()
        dishes_item = CtrlDishesInfo.get_instance().get_dishes_item(str(item.dishes_code))
        ordered_item.dishes_code = dishes_item.dishes_code
        ordered_item.dishes_spec_id = item.dishes_spec['id']
        if item.dishes_style is not None:
            ordered_item.dishes_style_id = item.dishes_style['id'] if len(item.dishes_style) > 0 \
                else 0
        ordered_item.dishes_name = dishes_item.dishes_name
        ordered_item.dishes_spec = item.dishes_spec['vch_name']
        ordered_item.dishes_unit = dishes_item.dishes_unit
        ordered_item.dishes_count = item.dishes_count
        ordered_item.dishes_retreat_count = item.dishes_retreat_count
        ordered_item.dishes_spec_discount = item.dishes_spec_discount
Exemple #22
0
 def add_item(self, data, perm_list):
     if isinstance(data, DataUserRole):
         add_role_info(data, perm_list)
         self.data_len += 1
         EvtManager.dispatch_event(EnumEvent.EVT_PERMISSION_REFRESH)
Exemple #23
0
 def delete_item(data):
     if isinstance(data, DataUserRole):
         delete_item('RoleInfo', data)
         EvtManager.dispatch_event(EnumEvent.EVT_PERMISSION_REFRESH)
Exemple #24
0
 def update_item(data):
     if isinstance(data, DataTable):
         update_item('TableInfo', data)
         EvtManager.dispatch_event(EnumEvent.EVT_DINING_ROOM_REFRESH)
Exemple #25
0
 def delete_item(data):
     if isinstance(data, DataEmployee):
         delete_item('EmployeeInfo', data)
         EvtManager.dispatch_event(EnumEvent.EVT_EMPLOYEE_REFRESH)
Exemple #26
0
    def mod_dishes(self, count):
        cur_order_item = self.di_order_item[self.cur_order_num]
        if self.cur_dishes_key in cur_order_item.di_order_dishes_items and count > 0:
            cur_order_item.di_order_dishes_items[self.cur_dishes_key].dishes_count = count

            EvtManager.dispatch_event(EnumEvent.EVT_ORDER_DISHES_ITEMS_REFRESH)
Exemple #27
0
 def update_print_scheme(data):
     if isinstance(data, DataDishes):
         update_print_scheme(data)
         EvtManager.dispatch_event(EnumEvent.EVT_DISHES_PUBLISH_REFRESH)
Exemple #28
0
 def un_initialize(self):
     # Remove event listener
     EvtManager.remove_listener(self, EnumEvent.EVT_LOGIN, self.on_evt_login)
Exemple #29
0
 def update_item(data, perm_list):
     if isinstance(data, DataUserRole):
         update_role_info(data, perm_list)
         EvtManager.dispatch_event(EnumEvent.EVT_PERMISSION_REFRESH)