Beispiel #1
0
 def submit_user(self, widget):
     username = self.username.get_text().strip()
     user = SbDUser()
     rData = user.new([
         self.name.get_text().strip(), username,
         self.pin.get_text().strip(), self.level,
         self.phone.get_text().strip(),
         self.email.get_text().strip(),
         self.birthday.get_text().strip()
     ])
     if rData['rStatus'] == 11:
         return UiDialog("Entrada inválida",
                         "Por favor preencha os campos corretamente.")
     elif rData['rStatus'] == 9:
         return UiDialog("Erro!", "Username já cadastrado.")
     elif rData['rStatus'] == 0:
         self.destroy()
         return UiDialog("Erro ao enviar dados",
                         "Erro ao inserir informações no banco de dados.")
     else:
         self.destroy()
         data = user.get_id_by_username(username)
         if data['rStatus'] == 1:
             win = UiNewAddress(data['data'])
             win.show_all()
Beispiel #2
0
    def next_step(self, widget, data):
        name = self.name.get_text().strip()
        if name:
            if len(name) > 120:
                return UiDialog(
                    "Entrada inválida",
                    "Você excedeu o limite de 120 caracteres no nome do produto."
                )
            if len(name) <= 6:
                return UiDialog(
                    "Entrada inválida",
                    "Nome de produto muito curto, utilize um nome maior.")
        if not name:
            return UiDialog("Entrada inválida",
                            "Forneça um nome para o seu produto.")

        description = self.text.get_text(self.text.get_start_iter(),
                                         self.text.get_end_iter(),
                                         True).strip()
        ingre = self.text2.get_text(self.text2.get_start_iter(),
                                    self.text2.get_end_iter(), True).strip()
        if data['stage'] < 2:
            data['stage'] = 2
        data['data']['name'] = name
        data['data']['description'] = description
        data['data']['ingre'] = ingre

        win = UiNextS3(data)
        win.show_all()
        return self.destroy()
Beispiel #3
0
    def next_step(self, widget, data):
        price = self.price.get_text().strip()
        price = price.replace(',', '.')
        if not self.simple_remove_letters(price).isnumeric():
            return UiDialog("Entrada inválida",
                            "Por favor forneça um valor válido.")
        costPrice = self.costPrice.get_text().strip()
        costPrice = costPrice.replace(',', '.')
        if not self.simple_remove_letters(costPrice).isnumeric():
            return UiDialog("Entrada inválida",
                            "Por favor forneça um valor válido.")

        stock = self.stock.get_text().strip()
        if not stock:
            stock = 0

        if data['stage'] < 3:
            data['stage'] = 3
        data['data']['price'] = price
        data['data']['costPrice'] = costPrice
        data['data']['stock'] = stock

        win = UiNextS4(data)
        win.show_all()
        return self.destroy()
Beispiel #4
0
    def update(self, widget, idProduct):
        unity = self.unity.get_active_id()
        if unity == "0":
            return UiDialog("Entrada inválida",
                            "Por favor preencha todos os campos.")
        amount = self.qUnity.get_text().strip()
        amount = amount.replace(",", ".")
        if not amount:
            amount = 0
        category = self.category.get_active_id()
        if category == "0":
            return UiDialog("Entrada inválida",
                            "Por favor preencha todos os campos.")
        people = self.people.get_text().strip()
        if not people:
            people = 0
        cvirtual = self.cvirtual.get_active()
        delivery = self.delivery.get_active()
        special = self.special.get_active()
        printer = self.printer.get_active()
        self.destroy()

        submit = SbUpdateProduct()
        submit.set_product_id(idProduct)
        if not submit.update_technical_information([
                category, cvirtual, special, delivery, unity, amount, people,
                printer
        ]):
            return UiDialog(
                "Erro ao enviar dados!",
                "Não foi possível enviar as informações para a base de dados.")
Beispiel #5
0
 def submit_address(self, widget, userId):
     house = self.house.get_text().strip()
     if len(house) == 0:
         house = "SN"
     if len(self.street.get_text().strip()) == 0:
         return UiDialog("Entrada inválida",
                         "Por favor preencha os campos corretamente.")
     if len(self.bairro.get_text().strip()) == 0:
         return UiDialog("Entrada inválida",
                         "Por favor preencha os campos corretamente.")
     if len(self.city.get_text().strip()) == 0:
         return UiDialog("Entrada inválida",
                         "Por favor preencha os campos corretamente.")
     insert = SbDUser(userId)
     result = insert.insert_address([
         self.cep.get_text().strip(), house,
         self.street.get_text().strip(),
         self.complement.get_text().strip(),
         self.bairro.get_text().strip(),
         self.city.get_text().strip(),
         self.state.get_text().strip(), 'Brasil'
     ])
     self.destroy()
     if not result:
         return UiDialog(
             "Erro ao enviar",
             "Erro ao inserir as informações no banco de dados.")
Beispiel #6
0
    def update(self, widget, idProduct):
        name = self.name.get_text().strip()
        if name:
            if len(name) > 120:
                return UiDialog(
                    "Entrada inválida",
                    "Você excedeu o limite de 120 caracteres no nome do produto."
                )
            if len(name) <= 6:
                return UiDialog(
                    "Entrada inválida",
                    "Nome de produto muito curto, utilize um nome maior.")
        if not name:
            return UiDialog("Entrada inválida",
                            "Forneça um nome para o seu produto.")

        description = self.text.get_text(self.text.get_start_iter(),
                                         self.text.get_end_iter(),
                                         True).strip()
        ingre = self.text2.get_text(self.text2.get_start_iter(),
                                    self.text2.get_end_iter(), True).strip()

        submit = SbUpdateProduct()
        submit.set_product_id(idProduct)
        if not submit.update_info([name, description, ingre]):
            return UiDialog(
                "Erro ao enviar dados!",
                "Não foi possível enviar as informações para a base de dados.")
        return self.destroy()
Beispiel #7
0
 def submit_category(self, widget):
     name = self.name.get_text().strip()
     if not name:
         return UiDialog("Entrada inválida",
                         "Por favor preencha o campo corretamente.")
     self.destroy()
     submit = SbCategory()
     if not submit.insert_category(name):
         return UiDialog("Erro ao enviar dados",
                         "Erro ao inserir informações no banco de dados.")
Beispiel #8
0
 def update_name(self, widget, userId):
     name = self.name.get_text().strip()
     if not name:
         return UiDialog("Entrada inválida!",
                         "Por favor preencha os campos corretamente.")
     submit = SbDUser(userId)
     self.destroy()
     if not submit.change_name(name):
         return UiDialog("Erro ao enviar dados",
                         "Erro ao inserir informações no banco de dados.")
Beispiel #9
0
 def update_pin(self, widget, clientId):
     pin = self.newPin.get_text()
     if len(str(pin)) < 4 or len(str(pin)) > 4:
         return UiDialog("Entrada inválida",
                         "Por favor preencha os campos corretamente.")
     self.destroy()
     submit = SbDClient(clientId)
     if not submit.update_pin(pin):
         return UiDialog("Erro ao enviar dados",
                         "Erro ao inserir informações no banco de dados.")
Beispiel #10
0
 def update_pin(self, widget, userId):
     pin = self.pin.get_text().strip()
     if not pin or len(str(pin)) < 4 or len(str(pin)) > 4:
         return UiDialog("Entrada inválida",
                         "Por favor preencha os campos corretamente.")
     if not pin.isdigit():
         return UiDialog("Entrada inválida",
                         "Por favor preencha os campos corretamente.")
     submit = SbDUser(userId)
     self.destroy()
     if not submit.change_pin(pin):
         return UiDialog("Erro!", "Erro ao enviar dados.")
Beispiel #11
0
 def update(self, widget, idProduct):
     code = self.code.get_text().strip()
     if code:
         if SbNewProduct().check_product_barcode(code):
             return UiDialog(
                 "Conflito com dados existentes",
                 "Um produto com este código de barras já exister. Não é possível adicionar."
             )
     submit = SbUpdateProduct()
     submit.set_product_id(idProduct)
     if not submit.update_barcode(code):
         return UiDialog(
             "Erro ao enviar dados!",
             "Não foi possível enviar as informações para a base de dados.")
     return self.destroy()
Beispiel #12
0
 def update_number(self, widget, clientId):
     submit = SbClient(clientId)
     result = submit.change_phone_number(self.number.get_text())
     if result['rStatus'] == 11:
         return UiDialog("Entrada inválida",
                         "Por favor preencha os campos corretamente.")
     elif result['rStatus'] == 9:
         return UiDialog(
             "Erro!",
             "Não é possível atulizar, o número já está cadastrado.")
     elif result['rStatus'] == 0:
         return UiDialog("Erro ao enviar dados",
                         "Erro ao inserir informações no banco de dados.")
     else:
         return self.destroy()
Beispiel #13
0
 def update_name(self, widget, clientId):
     name = self.name.get_text()
     submit = SbClient(clientId)
     self.destroy()
     if not submit.change_name(name):
         return UiDialog("Erro ao enviar dados",
                         "Erro ao inserir informações no banco de dados.")
Beispiel #14
0
    def __init__(self, data):
        Gtk.Window.__init__(self,
                            title="Alterar nível de permissão",
                            window_position="center")
        self.set_resizable(False)

        check = SbSession()
        if check.check_level(True) != 3:
            UiDialog(
                'Erro de permissão!',
                'Somente usuários com o nível 3 podem alterar permissões.')
            return self.destroy()

        grid = Gtk.Grid(margin=40)
        grid.set_row_spacing(10)
        grid.set_column_spacing(10)
        self.add(grid)

        # Título
        label = Gtk.Label(margin_bottom=30, halign="start")
        label.set_markup(
            "<span size='20000'>Alterar nível de permissão</span>")
        grid.attach(label, 1, 1, 1, 1)

        # Nível de permisão
        label = Gtk.Label(halign="start")
        label.set_markup("Nível de permisão:<span color='red'>*</span>")
        grid.attach(label, 1, 2, 1, 1)

        box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        grid.attach(box, 1, 3, 1, 1)

        self.level = data[1]
        radiobutton1 = Gtk.RadioButton(label="Nível 1")
        radiobutton1.connect("toggled", self.on_radio_button_toggled)
        box.pack_start(radiobutton1, True, True, 0)
        radiobutton2 = Gtk.RadioButton(label="Nível 2", group=radiobutton1)
        radiobutton2.connect("toggled", self.on_radio_button_toggled)
        box.pack_start(radiobutton2, True, True, 0)
        radiobutton3 = Gtk.RadioButton(label="Nível 3", group=radiobutton1)
        radiobutton3.connect("toggled", self.on_radio_button_toggled)
        box.pack_start(radiobutton3, True, True, 0)

        if self.level == 1:
            radiobutton1.set_active(True)
        elif self.level == 2:
            radiobutton2.set_active(True)
        else:
            radiobutton3.set_active(True)

        # Separator
        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL,
                                  margin_top=10,
                                  margin_bottom=10)
        grid.attach(separator, 1, 4, 1, 1)

        button = Gtk.Button(height_request=40)
        button.set_label("Atualizar")
        button.connect("clicked", self.submit, data[0])
        grid.attach(button, 1, 5, 1, 1)
Beispiel #15
0
 def update(self, widget, userId):
     submit = SbDUser(userId)
     if not submit.change_contacts(
         [self.number.get_text(),
          self.email.get_text()]):
         return UiDialog("Entrada inválida",
                         "Por favor preencha os campos corretamente.")
     return self.destroy()
Beispiel #16
0
 def next_step(self, widget, data):
     unity = self.unity.get_active_id()
     if unity == "0":
         return UiDialog("Entrada inválida",
                         "Por favor preencha todos os campos.")
     amount = self.qUnity.get_text().strip()
     amount = amount.replace(",", ".")
     if not amount:
         amount = 0
     category = self.category.get_active_id()
     if category == "0":
         return UiDialog("Entrada inválida",
                         "Por favor preencha todos os campos.")
     people = self.people.get_text().strip()
     if not people:
         people = 0
     cvirtual = self.cvirtual.get_active()
     delivery = self.delivery.get_active()
     special = self.special.get_active()
     printer = self.printer.get_active()
     self.destroy()
     # Enviar informações
     submit = SbNewProduct()
     result = submit.insert_meta_product([
         category, cvirtual, special, delivery, unity, amount, people,
         printer
     ])
     if result[0]:
         if not submit.insert_product([
                 data['data']['code'], data['data']['name'],
                 data['data']['description'], data['data']['ingre'],
                 data['data']['price'], data['data']['costPrice'],
                 data['data']['stock']
         ]):
             submit.delete_meta_product()
             return UiDialog(
                 "Erro ao enviar dados",
                 "Erro ao enviar dados. Por favor, tente novamente.")
         win = UiDiscount([submit.get_product_id()])
         win.show_all()
     else:
         return UiDialog(
             "Erro ao enviar dados",
             "Erro ao enviar dados. Por favor, tente novamente.")
Beispiel #17
0
 def submit_client(self, widget):
     phone = self.phone.get_text().strip()
     client = SbDClient()
     rData = client.new(self.name.get_text(), phone, self.pin.get_text(),
                        self.birthday.get_text())
     if rData['rStatus'] == 11:
         return UiDialog("Entrada inválida",
                         "Por favor preencha os campos corretamente.")
     elif rData['rStatus'] == 9:
         return UiDialog("Erro!", "Cliente já cadastrado.")
     elif rData['rStatus'] == 0:
         self.destroy()
         return UiDialog("Erro ao enviar dados",
                         "Erro ao inserir informações no banco de dados.")
     else:
         self.destroy()
         data = client.get_customer_id_by_phone(phone)
         if data['rStatus'] == 1:
             win = UiNewAddress(data['data'])
             win.show_all()
Beispiel #18
0
 def on_button1_clicked(self, widget):
     self.spinner.start()
     username = self.username.get_text().strip()
     pin = self.pin.get_text().strip()
     if not username:
         self.spinner.stop()
         return UiDialog('Atenção', 'Dados de entrada inválidos.')
     if not pin:
         self.spinner.stop()
         return UiDialog('Atenção', 'Dados de entrada inválidos.')
     login = SbLogin(username, pin)
     if login.get_status()['rStatus'] == '1':
         print("Conectou-se com o usuário: {}".format(username))
         self.spinner.stop()
         win2 = UiBox()
         win2.connect("delete-event", Gtk.main_quit)
         win2.show_all()
         win.destroy()
         self.save_last_user(username)
     elif login.get_status()['rStatus'] == '10':
         self.spinner.stop()
         return UiDialog('Atenção', 'Este usuário está desativado.')
     elif login.get_status()['rStatus'] == '4':
         self.spinner.stop()
         return UiDialog('Atenção', 'Usuário ou senha incorreto.')
     elif login.get_status()['rStatus'] == '3':
         self.spinner.stop()
         return UiDialog('Atenção', 'Usuário não encontrado.')
     else:
         self.spinner.stop()
         return UiDialog('Atenção', 'Erro desconhecido.')
Beispiel #19
0
    def __init__(self, update=False, categoryId=None, name=None):
        Gtk.Window.__init__(self, window_position="center")
        self.set_resizable(False)

        userLevel = SbSession()
        if userLevel.check_level() != 3:
            UiDialog(
                "Erro de permissão",
                "Este usuário não possui permissão para acessar as informações."
            )
            return self.destroy()

        grid = Gtk.Grid(margin=40)
        grid.set_row_spacing(10)
        grid.set_column_spacing(10)
        self.add(grid)

        # Título
        if update:
            label = Gtk.Label(margin_bottom=30)
            label.set_markup("<span size='20000'>Atualizar categoria</span>")
            self.set_title("Atualizar categoria")
        else:
            label = Gtk.Label(margin_bottom=30)
            label.set_markup(
                "<span size='20000'>Adicionar nova categoria</span>")
            self.set_title("Adicionar nova categoria")
        grid.attach(label, 1, 1, 2, 1)

        # Nome
        label = Gtk.Label(label="Nome da categoria:")
        self.name = Gtk.Entry(width_request=350)
        grid.attach(label, 1, 2, 2, 1)
        grid.attach(self.name, 1, 3, 2, 1)

        # Enviar
        button = Gtk.Button(height_request=40)
        if update:
            button.set_label("Atualizar")
            button.connect("clicked", self.update_category, categoryId)
            self.name.connect("activate", self.update_category, categoryId)
            self.name.set_text(name)
        else:
            button.set_label("Enviar")
            self.name.connect("activate", self.submit_category)
            button.connect("clicked", self.submit_category)
        grid.attach(button, 1, 4, 1, 1)

        # Cancelar
        button = Gtk.Button(label="Fechar")
        button.connect("clicked", self.destroy_window)
        grid.attach(button, 2, 4, 1, 1)
Beispiel #20
0
    def update(self, widget, idProduct):
        price = self.price.get_text().strip()
        price = price.replace(',', '.')
        if not self.simple_remove_letters(price).isnumeric():
            return UiDialog("Entrada inválida!",
                            "Por favor forneça um valor válido.")
        costPrice = self.costPrice.get_text().strip()
        costPrice = costPrice.replace(',', '.')
        if not self.simple_remove_letters(costPrice).isnumeric():
            return UiDialog("Entrada inválida!",
                            "Por favor forneça um valor válido.")

        stock = self.stock.get_text().strip()
        if not stock:
            stock = 0

        submit = SbUpdateProduct()
        submit.set_product_id(idProduct)
        if not submit.update_price_stock([price, costPrice, stock]):
            return UiDialog(
                "Erro ao enviar dados!",
                "Não foi possível enviar as informações para a base de dados.")
        return self.destroy()
Beispiel #21
0
    def update(self, widget, tableId):
        newId = self.tableId.get_text().strip()
        if not newId.isnumeric():
            return UiDialog("Entrada inválida!",
                            "Por favor, insira um número de mesa válido.")

        price = self.price.get_text().strip()
        price = price.replace(",", ".")
        if not self.simple_remove_letters(price).isnumeric():
            return UiDialog("Entrada inválida!",
                            "Por favor, forneça um valor válido.")
        quant = self.capacity.get_text().strip()
        if not quant.isnumeric():
            return UiDialog("Entrada inválida!",
                            "Por favor, forneça um valor válido.")

        result = SbNewTable(tableId).update_table([newId, price, quant])
        if result['rStatus'] == 4:
            return UiDialog("Conflito!",
                            "Já existe um mesa cadastrada com esse número.")
        if result['rStatus'] == 0:
            return UiDialog("Erro ao enviar!",
                            "Não foi possível enviar as informações.")
        return self.destroy()
Beispiel #22
0
    def __init__(self, data):
        Gtk.Window.__init__(self,
                            title="Alterar informações de contato",
                            window_position="center")
        self.set_resizable(False)

        session = SbSession()
        info = session.get_info()
        if info['user']['username'] != data[1]:
            if info['user']['level'] != 3:
                UiDialog(
                    'Erro de permissão!',
                    'Somente usuários com o nível 3 podem alterar informações de outros usuários.'
                )
                return self.destroy()

        grid = Gtk.Grid(margin=40)
        grid.set_row_spacing(10)
        grid.set_column_spacing(10)
        self.add(grid)

        # Título
        label = Gtk.Label(margin_bottom=30)
        label.set_markup(
            "<span size='20000'>Alterar informações de contato</span>")
        grid.attach(label, 1, 1, 1, 1)

        # Telefone
        label = Gtk.Label(label="Número:")
        self.number = Gtk.Entry(max_length=20, width_request=200)
        self.number.set_text(data[2])
        self.number.connect("activate", self.update, data[0])
        grid.attach(label, 1, 2, 1, 1)
        grid.attach(self.number, 1, 3, 1, 1)

        # E-mail
        label = Gtk.Label(label="E-mail:")
        self.email = Gtk.Entry(max_length=200, width_request=200)
        self.email.set_text(data[3])
        self.email.connect("activate", self.update, data[0])
        grid.attach(label, 1, 4, 1, 1)
        grid.attach(self.email, 1, 5, 1, 1)

        # Enviar
        button = Gtk.Button(label="Atualizar", height_request=40)
        button.connect("clicked", self.update, data[0])
        grid.attach(button, 1, 6, 1, 1)
Beispiel #23
0
 def next_step(self, widget):
     code = self.code.get_text().strip()
     data = {'stage': 1, 'data': {'code': code}}
     if code:
         if SbNewProduct().check_product_barcode(code):
             return UiDialog(
                 "Conflito com dados existentes",
                 "Um produto com este código de barras já exister. Não é possível adicionar."
             )
         else:
             win = UiNextS2(data)
             win.show_all()
             return self.destroy()
     else:
         win = UiNextS2(data)
         win.show_all()
         return self.destroy()
Beispiel #24
0
    def __init__(self, data):
        Gtk.Window.__init__(self,
                            title="Alterar PIN",
                            window_position="center")
        self.set_resizable(False)

        session = SbSession()
        info = session.get_info()
        if info['user']['username'] != data[1]:
            if info['user']['level'] != 3:
                UiDialog(
                    'Erro de permissão!',
                    'Somente usuários com o nível 3 podem alterar senhas de outros usuários.'
                )
                return self.destroy()

        grid = Gtk.Grid(margin=40)
        grid.set_row_spacing(10)
        grid.set_column_spacing(10)
        self.add(grid)

        # Título
        label = Gtk.Label(margin_bottom=30, halign="start")
        label.set_markup("<span size='20000'>Alterar PIN</span>")
        grid.attach(label, 1, 1, 1, 1)

        # Nova senha
        label = Gtk.Label(halign="start")
        label.set_label("Novo PIN: (4 números)")
        self.pin = Gtk.Entry(max_length=4)
        self.pin.set_input_purpose(Gtk.InputPurpose.NUMBER)
        self.pin.connect("activate", self.update_pin, data[0])
        grid.attach(label, 1, 2, 1, 1)
        grid.attach(self.pin, 1, 3, 1, 1)

        # Separator
        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL,
                                  margin_top=10,
                                  margin_bottom=10)
        grid.attach(separator, 1, 8, 1, 1)

        # Enviar
        button = Gtk.Button(label="Atualizar", height_request=40)
        button.connect("clicked", self.update_pin, data[0])
        grid.attach(button, 1, 9, 1, 1)
Beispiel #25
0
 def submit_update(self, widget):
     data = [
         self.name.get_text().strip(),
         self.cnpj.get_text().strip(),
         self.street.get_text().strip(),
         self.number.get_text().strip(),
         self.cep.get_text().strip(),
         self.district.get_text().strip(),
         self.city.get_text().strip(),
         self.state.get_text().strip(),
         self.nation.get_text().strip(),
         self.phone.get_text().strip()
     ]
     submit = SbStoreInfo()
     if not submit.set_store_info(data):
         return UiDialog("Erro!", "Erro ao enviar dados.")
     else:
         return self.destroy()
Beispiel #26
0
    def submit(self, widget, idProduct):
        submit = SbUpdateProduct()
        submit.set_product_id(idProduct)

        # Envio sem desconto.
        typeFree = self.typeFree.get_active_id()
        if typeFree == "0":
            if not submit.update_discount({'free': '0'}):
                return UiDialog(
                    "Erro ao enviar dados!",
                    "Não foi possível enviar as informações para a base de dados."
                )
            return self.destroy()
        else:
            # Envio com desconto.
            value = self.value.get_text().strip()
            value = value.replace(",", ".")
            if not self.simple_remove_letters(value).isnumeric():
                return UiDialog("Entrada inválida!",
                                "Por favor, forneça um valor válido.")
            if value == '0':
                return UiDialog("Entrada inválida!",
                                "Por favor, forneça um valor válido.")
            quant = self.quant.get_text().strip()
            if not quant.isnumeric():
                return UiDialog("Entrada inválida!",
                                "Por favor, forneça um valor inteiro válido.")
            if quant == '0':
                return UiDialog("Entrada inválida!",
                                "Por favor, forneça um valor válido.")
            if not submit.update_discount({
                    'free': value,
                    'type': typeFree,
                    'quant': quant
            }):
                return UiDialog(
                    "Erro ao enviar dados!",
                    "Não foi possível enviar as informações para a base de dados."
                )
            return self.destroy()
Beispiel #27
0
    def __init__(self, data=None, update=False):
        Gtk.Window.__init__(self, window_position="center")
        self.set_resizable(False)
        userLevel = SbSession()
        if userLevel.check_level() < 2:
            UiDialog(
                "Erro de permissão",
                "Este usuário não possui permissão para acessar as informações."
            )
            return self.destroy()

        grid = Gtk.Grid(margin=30)
        grid.set_row_spacing(10)
        grid.set_column_spacing(10)
        self.add(grid)

        # Título
        label = Gtk.Label(margin_bottom=30)
        if not update:
            label.set_markup("<span size='20000'>Adicionar mesa</span>")
            self.set_title("Adicionar mesa")
        else:
            label.set_markup("<span size='20000'>Atualizar mesa</span>")
            self.set_title("Atualizar mesa")
        grid.attach(label, 1, 1, 1, 1)

        # Número da mesa
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Número da mesa:</span><span color='red'>*</span>"
        )
        self.tableId = Gtk.Entry()
        grid.attach(label, 1, 2, 1, 1)
        grid.attach(self.tableId, 1, 3, 1, 1)

        # Preço
        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>Preço:</span>")
        self.price = Gtk.Entry()
        self.price.set_text("0")
        grid.attach(label, 1, 4, 1, 1)
        grid.attach(self.price, 1, 5, 1, 1)

        # Capacidade
        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>Capacidade:</span> (pessoas)")
        self.capacity = Gtk.Entry(max_length=6)
        self.capacity.set_text("4")
        grid.attach(label, 1, 6, 1, 1)
        grid.attach(self.capacity, 1, 7, 1, 1)

        # Separator
        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL,
                                  margin_top=10,
                                  margin_bottom=10)
        grid.attach(separator, 1, 8, 1, 1)

        # Enviar
        button = Gtk.Button(height_request=40)
        if not update:
            button.set_label("Enviar")
            button.connect("clicked", self.submit)
        else:
            button.set_label("Atualizar")
            button.connect("clicked", self.update, data[0])
            self.tableId.set_text(str(data[0]))
            self.price.set_text(str(data[1]))
            self.capacity.set_text(str(data[2]))
        grid.attach(button, 1, 9, 1, 1)
Beispiel #28
0
    def __init__(self, data=None, update=False):
        Gtk.Window.__init__(self, window_position="center")
        self.set_resizable(False)
        userLevel = SbSession()
        if userLevel.check_level() < 2:
            UiDialog(
                "Erro de permissão",
                "Este usuário não possui permissão para acessar as informações."
            )
            return self.destroy()

        grid = Gtk.Grid(margin=40)
        grid.set_row_spacing(10)
        grid.set_column_spacing(10)
        self.add(grid)

        # Título
        label = Gtk.Label(margin_bottom=20, halign="start")
        self.set_title("Descontos")
        label.set_markup("<span size='21000'>Descontos</span>")
        grid.attach(label, 1, 1, 2, 1)

        # Desconto por volume
        self.typeFree = Gtk.ComboBoxText()
        listItems = [("0", "Sem desconto"),
                     ("percent", "Desconto por volume em porcentagem (%)"),
                     ("money", "Desconto por volume em dinheiro (R$)"),
                     ("unity", "Desconto por volume em volume (Unidades)")]
        for item in listItems:
            self.typeFree.append(item[0], item[1])
        self.typeFree.set_active_id("0")

        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>Tipo de desconto:</span>")
        grid.attach(label, 1, 2, 1, 1)
        grid.attach(self.typeFree, 1, 3, 1, 1)

        button = Gtk.Button("Como funciona?")
        button.connect("clicked", self.on_popover_clicked)
        grid.attach(button, 1, 5, 1, 1)

        self.popover = Gtk.Popover()
        self.popover.set_position(Gtk.PositionType.RIGHT)
        self.popover.set_relative_to(button)

        box = Gtk.Box()
        box.set_spacing(5)
        box.set_orientation(Gtk.Orientation.VERTICAL)
        self.popover.add(box)

        label = Gtk.Label(margin=10)
        label.set_markup(
            """<span color='#c6262e' font='bold'>Ex. (%):</span> a cada 4 unidades ou mais\ro cliente ganha 10% de desconto. 
<span color='#c6262e' font='bold'>Ex. (dinheiro):</span> a cada 4 unidades ou mais\ro cliente ganha 10 reais de desconto.
<span color='#c6262e' font='bold'>Ex. (unidade):</span> a cada 4 unidades ou mais\ro cliente ganha 1 unidade de desconto."""
        )
        box.add(label)

        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Valor do desconto:</span> <span color='#c6262e'>(somente números)</span>"
        )
        self.value = Gtk.Entry(max_length=10)
        self.value.set_input_purpose(Gtk.InputPurpose.NUMBER)
        self.value.set_text("0")

        grid.attach(label, 2, 2, 1, 1)
        grid.attach(self.value, 2, 3, 1, 1)

        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>Quantidade do produto:</span>")
        self.quant = Gtk.Entry(max_length=10)
        self.quant.set_input_purpose(Gtk.InputPurpose.NUMBER)
        self.quant.set_text("0")

        grid.attach(label, 2, 4, 1, 1)
        grid.attach(self.quant, 2, 5, 1, 1)

        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL,
                                  margin_top=10,
                                  margin_bottom=10)
        grid.attach(separator, 1, 9, 2, 1)

        button = Gtk.Button(height_request=40)
        button.set_label("Salvar")
        button.connect("clicked", self.submit, data[0])
        grid.attach(button, 1, 10, 1, 1)

        button = Gtk.Button(height_request=40)
        button.set_label("Fechar")
        button.connect("clicked", self.destroy_window)
        grid.attach(button, 2, 10, 2, 1)

        if update:
            self.set_data(data[1])
Beispiel #29
0
    def __init__(self, data=None, update=False):
        Gtk.Window.__init__(self, window_position="center")
        self.set_resizable(False)
        userLevel = SbSession()
        if userLevel.check_level() < 2:
            UiDialog(
                "Erro de permissão",
                "Este usuário não possui permissão para acessar as informações."
            )
            return self.destroy()

        grid = Gtk.Grid(margin=40)
        grid.set_row_spacing(10)
        grid.set_column_spacing(10)
        self.add(grid)

        # Título
        label = Gtk.Label(margin_bottom=20, halign="start")
        if not update:
            self.set_title("4ª Etapa - Novo produto")
            label.set_markup(
                "<span size='21000'>Informações e Configurações</span>")
        else:
            self.set_title("Atualizar produto")
            label.set_markup(
                "<span size='21000'>Atualizar informações e configurações</span>"
            )
        grid.attach(label, 1, 1, 3, 1)

        # Tipo
        liststore = Gtk.ListStore(str)
        for item in ["Escolher", "Líquido", "Peso", "Tamanho"]:
            liststore.append([item])

        self.typeUnity = Gtk.ComboBox(width_request=150)
        self.typeUnity.set_model(liststore)
        self.typeUnity.set_active(0)
        self.typeUnity.connect("changed", self.on_event_01)

        cellrenderertext = Gtk.CellRendererText()
        self.typeUnity.pack_start(cellrenderertext, True)
        self.typeUnity.add_attribute(cellrenderertext, "text", 0)

        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Tipo de produto:</span><span color='red'>*</span>"
        )
        grid.attach(label, 1, 2, 1, 1)
        grid.attach(self.typeUnity, 1, 3, 1, 1)

        # Unidade
        self.unity = Gtk.ComboBoxText()
        listItems = [("0", "Escolher"), ("L", "Litros (L)"),
                     ("Ml", "Mililitros (Ml)"), ("Kg", "Quilogramas (Kg)"),
                     ("g", "Gramas (g)"), ("P", "Pequeno (P)"),
                     ("M", "Médio (M)"), ("G", "Grande (G)")]
        for item in listItems:
            self.unity.append(item[0], item[1])
        self.unity.set_active_id("0")

        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Unidade:</span><span color='red'>*</span>")
        grid.attach(label, 1, 4, 1, 1)
        grid.attach(self.unity, 1, 5, 1, 1)

        # Seperator
        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
        grid.attach(separator, 1, 6, 1, 1)

        # Quantidade
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Peso/Volume:</span><span color='red'>*</span>")
        self.qUnity = Gtk.Entry()
        grid.attach(label, 1, 7, 1, 1)
        grid.attach(self.qUnity, 1, 8, 1, 1)

        # Pessoas servidas
        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>Pessoas servidas:</span>")
        self.people = Gtk.Entry(max_length=6)
        grid.attach(label, 1, 9, 1, 1)
        grid.attach(self.people, 1, 10, 1, 1)

        # Seperator
        separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL,
                                  margin_left=15,
                                  margin_right=15)
        grid.attach(separator, 2, 2, 1, 9)

        # Label info
        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>Configurações:</span>")
        grid.attach(label, 3, 2, 1, 1)

        # Cardápio virtual
        self.cvirtual = Gtk.CheckButton()
        self.cvirtual.set_label("Cardápio Virtual")
        self.cvirtual.set_active(True)
        grid.attach(self.cvirtual, 3, 3, 1, 1)

        # Delivery
        self.delivery = Gtk.CheckButton()
        self.delivery.set_label("Disponível para Delivery")
        self.delivery.set_active(False)
        grid.attach(self.delivery, 3, 4, 1, 1)

        # Pedido especial
        self.special = Gtk.CheckButton()
        self.special.set_label("Pedido Especial")
        self.special.set_active(False)
        grid.attach(self.special, 3, 5, 1, 1)

        # Imprimir pedidos
        self.printer = Gtk.CheckButton()
        self.printer.set_label("Imprimir pedidos")
        self.printer.set_active(False)
        grid.attach(self.printer, 3, 6, 1, 1)

        # Seperator
        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
        grid.attach(separator, 3, 7, 1, 1)

        # Categoria
        rData = SbCategory().get_categories()
        self.category = Gtk.ComboBoxText(width_request=200)
        self.category.append("0", "Escolher")
        if rData['rStatus'] == 1:
            for item in rData['data']:
                self.category.append(str(item[0]), item[1])

        self.category.set_active_id("0")
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Categoria:</span><span color='red'>*</span>")
        grid.attach(label, 3, 8, 1, 1)
        grid.attach(self.category, 3, 9, 1, 1)

        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL,
                                  margin_top=10,
                                  margin_bottom=10)
        grid.attach(separator, 1, 11, 3, 1)

        label = Gtk.Label()
        label.set_markup(
            "<span font='bold'>Pedido Especial:</span> autoriza ao cliente, solicitar a remoção de ingredientes."
        )
        grid.attach(label, 1, 12, 3, 1)

        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL,
                                  margin_top=10,
                                  margin_bottom=10)
        grid.attach(separator, 1, 13, 3, 1)

        button = Gtk.Button(height_request=40)
        if not update:
            button.set_label("Salvar")
            button.connect("clicked", self.next_step, data)
            back = Gtk.Button(height_request=40, label="Voltar")
            back.connect("clicked", self.come_back, data)
            grid.attach(back, 2, 14, 1, 1)
        else:
            button.set_label("Atualizar")
            button.connect("clicked", self.update, data[0])
            self.set_data(data)
        grid.attach(button, 3, 14, 1, 1)

        if not update:
            separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL,
                                      margin_top=10,
                                      margin_bottom=10)
            grid.attach(separator, 1, 15, 3, 1)

            label = Gtk.Label()
            label.set_markup(
                "<span color='#c6262e' font='bold'>Depois desta estapa não é possível voltar. O produto será salvo.</span>"
            )
            grid.attach(label, 1, 16, 3, 1)
Beispiel #30
0
    def __init__(self, data=None, update=False):
        Gtk.Window.__init__(self, window_position="center")
        self.set_resizable(False)
        userLevel = SbSession()
        if userLevel.check_level() < 2:
            UiDialog(
                "Erro de permissão",
                "Este usuário não possui permissão para acessar as informações."
            )
            return self.destroy()

        grid = Gtk.Grid(margin=40)
        grid.set_row_spacing(10)
        grid.set_column_spacing(10)
        self.add(grid)

        # Título
        label = Gtk.Label(margin_bottom=20, halign="start")
        if not update:
            self.set_title("3ª Etapa - Novo produto")
            label.set_markup("<span size='21000'>Preço e Estoque</span>")
        else:
            self.set_title("Atualizar produto")
            label.set_markup(
                "<span size='21000'>Atualizar preço e estoque</span>")
        grid.attach(label, 1, 1, 2, 1)

        # Preços
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Preço de venda:</span><span color='red'>*</span>"
        )
        self.price = Gtk.Entry(max_length=10)
        self.price.set_input_purpose(Gtk.InputPurpose.NUMBER)

        grid.attach(label, 1, 2, 1, 1)
        grid.attach(self.price, 1, 3, 1, 1)

        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>Preço de custo:</span>")
        self.costPrice = Gtk.Entry(max_length=10)
        self.costPrice.set_input_purpose(Gtk.InputPurpose.NUMBER)
        self.costPrice.set_text("0")

        grid.attach(label, 2, 2, 1, 1)
        grid.attach(self.costPrice, 2, 3, 1, 1)

        # Seperator
        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
        grid.attach(separator, 1, 4, 2, 1)

        # Estoque
        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>Estoque:</span>")
        self.stock = Gtk.Entry(max_length=10)
        self.stock.set_text("0")
        grid.attach(label, 1, 5, 1, 1)
        grid.attach(self.stock, 1, 6, 1, 1)

        label = Gtk.Label(margin_top=10)
        label.set_markup(
            "<span color='#c6262e' font='bold'>Atenção:</span> o produto que não\rpossue estoque definido, deve\rser deixado em branco ou (0)."
        )
        grid.attach(label, 2, 5, 1, 2)

        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL,
                                  margin_top=10,
                                  margin_bottom=10)
        grid.attach(separator, 1, 8, 2, 1)

        button = Gtk.Button(height_request=40)
        if not update:
            button.set_label("Próximo")
            button.connect("clicked", self.next_step, data)
            back = Gtk.Button(height_request=40, label="Voltar")
            back.connect("clicked", self.come_back, data)
            grid.attach(back, 1, 9, 1, 1)
            if data['stage'] >= 3:
                self.set_data(data)
        else:
            button.set_label("Atualizar")
            button.connect("clicked", self.update, data[0])
            self.set_data(data, True)
        grid.attach(button, 2, 9, 1, 1)