Exemple #1
0
    def __init__(self):
        Gtk.Window.__init__(self, title="Backup", window_position="center")
        self.set_resizable(False)

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

        userLevel = SbSession()
        if userLevel.check_level() != 3:
            label = Gtk.Label(halign="center")
            label.set_label(
                "Este usuário não possui permissão para essa função.")
            grid.attach(label, 1, 1, 1, 1)
        else:
            # Título
            label = Gtk.Label(margin_bottom=30, halign="center")
            label.set_markup(
                "<span size='20000'>Fazer backup da base de dados?</span>")
            grid.attach(label, 1, 1, 2, 1)

            button = Gtk.Button(label="Não", height_request=40)
            button.connect("clicked", self.destroy_window)
            grid.attach(button, 1, 2, 1, 1)

            button = Gtk.Button(label="Sim", height_request=40)
            button.connect("clicked", self.create)
            grid.attach(button, 2, 2, 1, 1)
Exemple #2
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)
Exemple #3
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)
Exemple #4
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)
Exemple #5
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)
Exemple #6
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)
Exemple #7
0
    def __init__(self):
        Gtk.Window.__init__(self,
                            title="Informações do estabelecimento",
                            window_position="center")
        self.set_resizable(False)

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

        # Título
        label = Gtk.Label(margin_bottom=20, halign="start")
        label.set_markup(
            "<span size='20000'>Informações do Estabelecimento</span>")
        grid.attach(label, 1, 1, 1, 1)

        # Nome da empresa
        label = Gtk.Label(halign="start")
        label.set_label("Nome da empresa:")
        self.name = Gtk.Entry(width_request=300)
        grid.attach(label, 1, 2, 1, 1)
        grid.attach(self.name, 1, 3, 1, 1)

        # CNPJ
        label = Gtk.Label(halign="start")
        label.set_label("CNPJ:")
        self.cnpj = Gtk.Entry()
        grid.attach(label, 2, 2, 1, 1)
        grid.attach(self.cnpj, 2, 3, 1, 1)

        # Telefone
        label = Gtk.Label(halign="start")
        label.set_label("Telefone:")
        self.phone = Gtk.Entry()
        grid.attach(label, 3, 2, 1, 1)
        grid.attach(self.phone, 3, 3, 1, 1)

        # Logradouro
        label = Gtk.Label(halign="start")
        label.set_label("Logradouro:")
        self.street = Gtk.Entry()
        grid.attach(label, 1, 4, 1, 1)
        grid.attach(self.street, 1, 5, 1, 1)

        # Número do local
        label = Gtk.Label(halign="start")
        label.set_label("Número do local:")
        self.number = Gtk.Entry()
        grid.attach(label, 2, 4, 1, 1)
        grid.attach(self.number, 2, 5, 1, 1)

        # CEP
        label = Gtk.Label(halign="start")
        label.set_label("CEP:")
        self.cep = Gtk.Entry()
        grid.attach(label, 3, 4, 1, 1)
        grid.attach(self.cep, 3, 5, 1, 1)

        # Bairro/Distrito
        label = Gtk.Label(halign="start")
        label.set_label("Bairro:")
        self.district = Gtk.Entry()
        grid.attach(label, 1, 6, 1, 1)
        grid.attach(self.district, 1, 7, 1, 1)

        # Cidade
        label = Gtk.Label(halign="start")
        label.set_label("Cidade:")
        self.city = Gtk.Entry()
        grid.attach(label, 2, 6, 1, 1)
        grid.attach(self.city, 2, 7, 1, 1)

        # País/Nação
        label = Gtk.Label(halign="start")
        label.set_label("País/Nação:")
        self.nation = Gtk.Entry()
        # self.nation.set_editable(False)
        grid.attach(label, 3, 6, 1, 1)
        grid.attach(self.nation, 3, 7, 1, 1)

        # Estado/Região
        label = Gtk.Label(halign="start")
        label.set_label("Estado/Região:")
        self.state = Gtk.Entry()
        grid.attach(label, 1, 8, 1, 1)
        grid.attach(self.state, 1, 9, 1, 1)

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

        # Data config
        config = SbStoreInfo()
        data = config.get_store_info()
        if data['rStatus'] == 1:
            self.set_data(data['data'])

        # Enviar
        userLevel = SbSession()
        if userLevel.check_level() == 3:
            button = Gtk.Button(height_request=40)
            button.set_label("Enviar/Atualizar")
            button.connect("clicked", self.submit_update)
            grid.attach(button, 1, 11, 3, 1)
        else:
            label = Gtk.Label(halign="center", margin_top=10, margin_bottom=10)
            label.set_label(
                "Este usuário não possui permissão para atualizar essas informações."
            )
            grid.attach(label, 1, 11, 3, 1)
Exemple #8
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])
Exemple #9
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)
Exemple #10
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)
Exemple #11
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)
        if not update:
            self.set_title("1ª Etapa - Novo produto")
            label.set_markup(
                "<span size='21000'>Deseja adicionar código de barras?</span>")
        else:
            self.set_title("Atualizar código de barras")
            label.set_markup(
                "<span size='21000'>Atualizar o código de barras</span>")
        grid.attach(label, 1, 1, 2, 1)

        label = Gtk.Label()
        label.set_markup("<span font='bold'>Código de barras:</span>")
        grid.attach(label, 1, 2, 2, 1)
        self.code = Gtk.Entry(max_length=20)
        if not update:
            self.code.connect("activate", self.next_step)
        else:
            self.code.connect("activate", self.update, data[0])
        grid.attach(self.code, 1, 3, 2, 1)

        label = Gtk.Label()
        label.set_markup(
            "<span color='#c6262e' font='bold'>Adicionar o código de barras é opcional.</span>"
        )
        grid.attach(label, 1, 4, 2, 1)

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

        button = Gtk.Button(height_request=40)
        if not update:
            button.set_label("Próximo")
            button.connect("clicked", self.next_step)
            # Define as informações
            if data:
                if data['stage'] == 1:
                    self.code.set_text(data['data']['code'])
        else:
            self.code.set_text(str(data[1]))
            button.set_label("Atualizar")
            button.connect("clicked", self.update, data[0])
        grid.attach(button, 1, 6, 1, 1)

        button = Gtk.Button(label="Fechar")
        button.connect("clicked", self.destroy_window)
        grid.attach(button, 2, 6, 1, 1)
Exemple #12
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("2ª Etapa - Novo produto")
            label.set_markup(
                "<span size='21000'>Descrição e Ingredientes</span>")
        else:
            self.set_title("Atualizar descrição e ingredientes")
            label.set_markup(
                "<span size='21000'>Atualizar descrição e ingredientes</span>")
        grid.attach(label, 1, 1, 2, 1)

        # Nome do produto
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Nome do produto:</span><span color='red'>*</span>"
        )
        self.name = Gtk.Entry(max_length=120)
        grid.attach(label, 1, 2, 2, 1)
        grid.attach(self.name, 1, 3, 2, 1)

        label = Gtk.Label(margin_top=10)
        label.set_markup(
            "<span color='#c6262e' font='bold'>Nomes curtos e intuitivos chamão mais à atenção.</span>"
        )
        grid.attach(label, 1, 4, 2, 1)

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

        # Descrição
        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>Descrição:</span>")

        scrolledwindow = Gtk.ScrolledWindow(width_request=400,
                                            height_request=50)

        description = Gtk.TextView(width_request=400, height_request=50)
        self.text = description.get_buffer()

        scrolledwindow.add(description)
        grid.attach(label, 1, 6, 2, 1)
        grid.attach(scrolledwindow, 1, 7, 2, 8)

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

        # Ingredientes
        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>Ingredientes:</span>")

        scrolledwindow = Gtk.ScrolledWindow(width_request=400,
                                            height_request=30)

        ingre = Gtk.TextView(width_request=400, height_request=30)
        self.text2 = ingre.get_buffer()

        scrolledwindow.add(ingre)
        grid.attach(label, 1, 16, 2, 1)
        grid.attach(scrolledwindow, 1, 17, 2, 8)

        label = Gtk.Label(margin_top=10)
        label.set_markup(
            "<span color='#c6262e' font='bold'>Sempre separe os ingredientes por uma vírgula. (Ex.: tomate, milho)</span>"
        )
        grid.attach(label, 1, 25, 2, 1)

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

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

        grid.attach(button, 2, 27, 1, 1)
Exemple #13
0
    def __init__(self, userId):
        Gtk.Window.__init__(self, title="Endereço", window_position="center")
        self.set_resizable(False)

        session = SbSession()
        if session.check_level() != 3:
            UiDialog(
                'Erro de permissão!',
                'Somente usuários com o nível 3 podem inserir e/ou alterar endereços.'
            )
            return self.destroy()

        grid = Gtk.Grid(margin=20)
        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'>Endereço</span>")
        grid.attach(label, 1, 1, 1, 1)

        # CEP
        label = Gtk.Label(halign="start")
        label.set_label("CEP:")
        self.cep = Gtk.Entry(max_length=10)
        self.cep.set_input_purpose(Gtk.InputPurpose.NUMBER)
        grid.attach(label, 1, 2, 1, 1)
        grid.attach(self.cep, 1, 3, 1, 1)

        # Rua
        label = Gtk.Label(halign="start")
        label.set_markup("Logradouro<span color='red'>*</span>:")
        self.street = Gtk.Entry(max_length=120)
        grid.attach(label, 1, 4, 1, 1)
        grid.attach(self.street, 1, 5, 3, 1)

        # Complemento
        label = Gtk.Label(halign="start")
        label.set_label("Complemento:")
        self.complement = Gtk.Entry(width_request=300)
        grid.attach(label, 1, 6, 1, 1)
        grid.attach(self.complement, 1, 7, 2, 1)

        # Número da casa
        label = Gtk.Label(halign="start")
        label.set_label("Número da casa:")
        self.house = Gtk.Entry(max_length=5)
        self.house.set_input_purpose(Gtk.InputPurpose.NUMBER)
        grid.attach(label, 3, 6, 1, 1)
        grid.attach(self.house, 3, 7, 1, 1)

        # Bairro
        label = Gtk.Label(halign="start")
        label.set_markup("Bairro/Distrito<span color='red'>*</span>:")
        self.bairro = Gtk.Entry(max_length=120)
        grid.attach(label, 1, 8, 1, 1)
        grid.attach(self.bairro, 1, 9, 2, 1)

        # Cidade
        label = Gtk.Label(halign="start")
        label.set_markup("Cidade<span color='red'>*</span>:")
        self.city = Gtk.Entry(max_length=120)
        grid.attach(label, 3, 8, 1, 1)
        grid.attach(self.city, 3, 9, 1, 1)

        # Estado
        label = Gtk.Label(halign="start")
        label.set_label("Estado:")

        liststore = Gtk.ListStore(str)

        listStates = [
            "Acre", "Alagoas", "Amapá", "Amazonas", "Bahia", "Ceará",
            "Distrito Federal", "Espírito Santo", "Goiás", "Maranhão",
            "Mato Grosso", "Mato Grosso do Sul", "Minas Gerais", "Pará",
            "Paraíba", "Paraná", "Pernambuco", "Piauí", "Rio de Janeiro",
            "Rio Grande do Norte", "Rio Grande do Sul", "Rondônia", "Roraima",
            "Santa Catarina", "São Paulo", "Sergipe", "Tocantins"
        ]
        for item in listStates:
            liststore.append([item])

        entrycompletion = Gtk.EntryCompletion()
        entrycompletion.set_model(liststore)
        entrycompletion.set_text_column(0)
        entrycompletion.set_inline_completion(True)

        self.state = Gtk.Entry(max_length=120)
        self.state.set_completion(entrycompletion)
        self.state.set_text("Espírito Santo")
        grid.attach(label, 1, 10, 1, 1)
        grid.attach(self.state, 1, 11, 1, 1)

        # Separator
        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL,
                                  margin_top=20,
                                  margin_bottom=20)
        grid.attach(separator, 1, 12, 3, 1)

        # Enviar
        submit = Gtk.Button(label="Enviar", height_request=40)
        submit.connect("clicked", self.submit_address, userId)
        grid.attach(submit, 1, 13, 2, 1)

        # Cancelar
        button = Gtk.Button(label="Fechar", height_request=40)
        button.connect("clicked", self.destroy_window)
        grid.attach(button, 3, 13, 1, 1)
Exemple #14
0
    def __init__(self):
        Gtk.Window.__init__(self,
                            title="Cadastro de usuário",
                            window_position="center")
        self.set_resizable(False)

        session = SbSession()
        if session.check_level() != 3:
            UiDialog(
                'Erro de permissão!',
                'Somente usuários com o nível 3 podem criar novos usuários.')
            return self.destroy()

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

        # Título
        label = Gtk.Label(margin_bottom=20, halign="start")
        label.set_markup("<span size='20000'>Cadastro de usuário</span>")
        grid.attach(label, 1, 1, 1, 1)

        # Nome
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Nome completo:</span><span color='red'>*</span>"
        )
        self.name = Gtk.Entry(max_length=120)
        grid.attach(label, 1, 2, 2, 1)
        grid.attach(self.name, 1, 3, 2, 1)

        # Username
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Username:</span><span color='red'>*</span>")
        self.username = Gtk.Entry(max_length=120)
        self.username.set_input_purpose(Gtk.InputPurpose.NUMBER)
        grid.attach(label, 3, 2, 1, 1)
        grid.attach(self.username, 3, 3, 1, 1)

        # PIN
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>PIN:</span><span color='red'>*</span> (4 números)"
        )
        self.pin = Gtk.Entry(max_length=4)
        grid.attach(label, 3, 4, 1, 1)
        grid.attach(self.pin, 3, 5, 1, 1)

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

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

        self.level = 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)

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

        # E-mail
        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>E-mail:</span>")
        self.email = Gtk.Entry(max_length=200)
        self.email.set_input_purpose(Gtk.InputPurpose.EMAIL)
        grid.attach(label, 1, 7, 1, 1)
        grid.attach(self.email, 1, 8, 1, 1)

        # Telefone
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Telefone:</span><span color='red'>*</span>")
        self.phone = Gtk.Entry(max_length=20)
        self.phone.set_input_purpose(Gtk.InputPurpose.PHONE)
        grid.attach(label, 2, 7, 1, 1)
        grid.attach(self.phone, 2, 8, 1, 1)

        # Aniversário
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Aniversário:</span><span color='red'>*</span>")
        self.birthday = Gtk.Entry(max_length=10)
        grid.attach(label, 3, 7, 1, 1)
        grid.attach(self.birthday, 3, 8, 1, 1)

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

        # Enviar
        submit = Gtk.Button(label="Próximo", height_request=40)
        submit.connect("clicked", self.submit_user)
        grid.attach(submit, 1, 10, 3, 1)
Exemple #15
0
    def __init__(self):
        Gtk.Window.__init__(self,
                            title="Caixa - SysBar",
                            window_position="center",
                            icon_name="applications-utilities")
        self.maximize()
        # Gtk.Window.fullscreen(self)
        # self.set_default_size(900, 400)

        self.connect("destroy", self.logout_system)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                      spacing=6,
                      margin=0)
        self.add(box)

        # Menu de ferramentas
        subBox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                         spacing=0,
                         margin=0)
        box.pack_start(subBox, True, True, 0)

        pix = Pixbuf.new_from_file_at_size("icon/gksu.svg", 60, 60)
        img = Gtk.Image()
        img.set_from_pixbuf(pix)
        button = Gtk.Button(margin=4)
        button.set_image(img)
        button.set_focus_on_click(False)
        button.connect("clicked", self.show_new_customer)

        subBox.pack_start(button, True, True, 0)

        pix = Pixbuf.new_from_file_at_size("icon/winefile.svg", 60, 60)
        img = Gtk.Image()
        img.set_from_pixbuf(pix)
        button = Gtk.Button(margin=4)
        button.add(img)
        button.set_focus_on_click(False)
        button.connect("clicked", self.show_customer_list)

        subBox.pack_start(button, True, True, 0)

        pix = Pixbuf.new_from_file_at_size("icon/fbreader.svg", 60, 60)
        img = Gtk.Image()
        img.set_from_pixbuf(pix)
        button = Gtk.Button(margin=4)
        button.add(img)
        button.set_focus_on_click(False)
        button.connect("clicked", self.show_tables_list)

        subBox.pack_start(button, True, True, 0)

        pix = Pixbuf.new_from_file_at_size("icon/preferences-desktop.png", 60,
                                           60)
        img = Gtk.Image()
        img.set_from_pixbuf(pix)
        button = Gtk.Button(margin=4)
        button.add(img)
        button.set_focus_on_click(False)
        button.connect("clicked", self.show_ui_admin)

        subBox.pack_start(button, True, True, 0)

        pix = Pixbuf.new_from_file_at_size("icon/hwinfo.svg", 60, 60)
        img = Gtk.Image()
        img.set_from_pixbuf(pix)
        button = Gtk.Button(margin=4)
        button.add(img)
        button.set_focus_on_click(False)
        wAbout = AboutSystem()
        button.connect("clicked", wAbout.about_dialog)

        subBox.pack_start(button, True, True, 0)

        pix = Pixbuf.new_from_file_at_size("icon/gshutdown.svg", 60, 60)
        img = Gtk.Image()
        img.set_from_pixbuf(pix)
        button = Gtk.Button(margin=4)
        button.add(img)
        button.set_focus_on_click(False)
        button.connect("clicked", self.dialog_logout)

        subBox.pack_start(button, True, True, 0)

        # GRID
        grid = Gtk.Grid()
        grid.set_column_homogeneous(True)
        box.pack_start(grid, True, True, 0)

        # Pedido do cliente
        label = Gtk.Label(margin_left=20,
                          margin_right=20,
                          margin_top=30,
                          margin_bottom=10,
                          halign="center",
                          valign="end")
        label.set_markup("<span size=\"40000\">NÚMERO DO CLIENTE:</span>")
        grid.attach(label, 1, 1, 1, 1)

        listPhone = Gtk.ListStore(str)
        customers = SbClient()
        data = customers.get_customer_list()
        if data['rStatus'] == 1:
            for client in data['data']:
                listPhone.append([client[1]])

        entrycompletion = Gtk.EntryCompletion()
        entrycompletion.set_model(listPhone)
        entrycompletion.set_text_column(0)
        entrycompletion.set_inline_completion(False)

        self.idClient = Gtk.Entry(margin_left=20,
                                  margin_right=20,
                                  max_length=12,
                                  input_purpose="phone",
                                  width_request=400,
                                  halign="center",
                                  valign="start")
        self.idClient.set_completion(entrycompletion)
        self.idClient.grab_focus_without_selecting()
        self.idClient.modify_font(Pango.FontDescription('32'))
        # self.entry1.modify_font(Pango.FontDescription('Sans Serif 24'))
        # self.idClient.connect("activate", self.on_event1)
        # Valor predefinido no campo.
        # self.idClient.set_text("27996135732")
        grid.attach(self.idClient, 1, 2, 1, 1)

        gridBt = Gtk.Grid(halign="center", margin_top=5, margin_bottom=5)
        # gridBt.set_row_homogeneous(False)
        # gridBt.set_column_homogeneous(False)
        bt01 = Gtk.Button(label="7",
                          margin=5,
                          width_request=70,
                          height_request=60)
        bt01.connect("clicked", self.on_event_button)
        gridBt.attach(bt01, 1, 1, 1, 1)

        bt01 = Gtk.Button(label="8",
                          margin=5,
                          width_request=70,
                          height_request=60)
        bt01.connect("clicked", self.on_event_button)
        gridBt.attach(bt01, 2, 1, 1, 1)

        bt01 = Gtk.Button(label="9",
                          margin=5,
                          width_request=70,
                          height_request=60)
        bt01.connect("clicked", self.on_event_button)
        gridBt.attach(bt01, 3, 1, 1, 1)

        bt01 = Gtk.Button(label="4",
                          margin=5,
                          width_request=70,
                          height_request=60)
        bt01.connect("clicked", self.on_event_button)
        gridBt.attach(bt01, 1, 2, 1, 1)

        bt01 = Gtk.Button(label="5",
                          margin=5,
                          width_request=70,
                          height_request=60)
        bt01.connect("clicked", self.on_event_button)
        gridBt.attach(bt01, 2, 2, 1, 1)

        bt01 = Gtk.Button(label="6",
                          margin=5,
                          width_request=70,
                          height_request=60)
        bt01.connect("clicked", self.on_event_button)
        gridBt.attach(bt01, 3, 2, 1, 1)

        bt01 = Gtk.Button(label="1",
                          margin=5,
                          width_request=70,
                          height_request=60)
        bt01.connect("clicked", self.on_event_button)
        gridBt.attach(bt01, 1, 3, 1, 1)

        bt01 = Gtk.Button(label="2",
                          margin=5,
                          width_request=70,
                          height_request=60)
        bt01.connect("clicked", self.on_event_button)
        gridBt.attach(bt01, 2, 3, 1, 1)

        bt01 = Gtk.Button(label="3",
                          margin=5,
                          width_request=70,
                          height_request=60)
        bt01.connect("clicked", self.on_event_button)
        gridBt.attach(bt01, 3, 3, 1, 1)

        bt01 = Gtk.Button(label="0",
                          margin=5,
                          width_request=70,
                          height_request=60)
        bt01.connect("clicked", self.on_event_button)
        gridBt.attach(bt01, 4, 1, 1, 2)

        bt01 = Gtk.Button(label="<",
                          margin=5,
                          width_request=70,
                          height_request=60)
        bt01.connect("clicked", self.on_event_back)
        gridBt.attach(bt01, 4, 3, 1, 1)

        accelgroup = Gtk.AccelGroup()
        self.add_accel_group(accelgroup)
        button = Gtk.Button(label="FECHAR CONTA",
                            margin_top=10,
                            margin_left=5,
                            height_request=60)
        button.add_accelerator("clicked", accelgroup,
                               Gdk.keyval_from_name("f"),
                               Gdk.ModifierType.CONTROL_MASK,
                               Gtk.AccelFlags.VISIBLE)
        button.connect("clicked", self.on_event1)
        button.set_focus_on_click(False)
        # button.modify_bg(Gtk.StateType.NORMAL,Gdk.color_parse("#FD0000"))
        gridBt.attach(button, 1, 4, 2, 1)

        accelgroup = Gtk.AccelGroup()
        self.add_accel_group(accelgroup)
        button = Gtk.Button(label="INFORMAÇÕES",
                            margin_top=10,
                            margin_left=10,
                            margin_right=5,
                            height_request=60)
        button.add_accelerator("clicked", accelgroup,
                               Gdk.keyval_from_name("i"),
                               Gdk.ModifierType.CONTROL_MASK,
                               Gtk.AccelFlags.VISIBLE)
        button.connect("clicked", self.show_customer_info)
        button.set_focus_on_click(False)
        # button.modify_bg(Gtk.StateType.NORMAL,Gdk.color_parse("#FFC90B"))
        gridBt.attach(button, 3, 4, 2, 1)

        grid.attach(gridBt, 1, 3, 1, 1)

        # Nova compra
        accelgroup = Gtk.AccelGroup()
        self.add_accel_group(accelgroup)
        button = Gtk.Button(label="NOVA COMPRA",
                            width_request=310,
                            height_request=60,
                            halign="center")
        button.add_accelerator("clicked", accelgroup,
                               Gdk.keyval_from_name("n"),
                               Gdk.ModifierType.CONTROL_MASK,
                               Gtk.AccelFlags.VISIBLE)
        button.connect("clicked", self.on_event1)
        button.set_focus_on_click(False)
        # button.modify_bg(Gtk.StateType.NORMAL,Gdk.color_parse("#0080DB"))
        grid.attach(button, 1, 4, 1, 1)

        # Lista
        # ID ORDER - ID COMANDA - ID TABLE - NAME CUSTOMER - NAME PRODUCT - AMOUNT PRODUCT - COMMENT - REGISTER ORDER
        self.liststore = Gtk.ListStore(int, int, int, str, str, int, str, str)
        treeview = Gtk.TreeView()
        treeview.set_model(self.liststore)
        treeview.set_search_column(2)
        treeview.set_vexpand(True)
        treeview.set_hexpand(True)
        treeview.connect("row-activated", self.show_order)

        scrolledwindow = Gtk.ScrolledWindow()
        scrolledwindow.add(treeview)
        grid.attach(scrolledwindow, 2, 1, 1, 4)

        cellrenderertext = Gtk.CellRendererText()

        # treeviewcolumn = Gtk.TreeViewColumn("ID ORDEM")
        # treeviewcolumn.set_spacing(10)
        # treeviewcolumn.set_resizable(True)
        # treeviewcolumn.pack_start(cellrenderertext, False)
        # treeviewcolumn.add_attribute(cellrenderertext, "text", 0)
        # treeview.append_column(treeviewcolumn)

        # treeviewcolumn = Gtk.TreeViewColumn("ID COMANDA")
        # treeviewcolumn.set_spacing(10)
        # treeviewcolumn.set_resizable(True)
        # treeviewcolumn.pack_start(cellrenderertext, False)
        # treeviewcolumn.add_attribute(cellrenderertext, "text", 1)
        # treeview.append_column(treeviewcolumn)

        treeviewcolumn = Gtk.TreeViewColumn("N. MESA")
        treeviewcolumn.set_spacing(10)
        treeviewcolumn.set_resizable(True)
        treeviewcolumn.pack_start(cellrenderertext, False)
        treeviewcolumn.add_attribute(cellrenderertext, "text", 2)
        treeview.append_column(treeviewcolumn)

        treeviewcolumn = Gtk.TreeViewColumn("NOME DO PRODUTO")
        treeviewcolumn.set_spacing(10)
        treeviewcolumn.set_resizable(True)
        treeviewcolumn.pack_start(cellrenderertext, False)
        treeviewcolumn.add_attribute(cellrenderertext, "text", 4)
        treeview.append_column(treeviewcolumn)

        treeviewcolumn = Gtk.TreeViewColumn("QUANTIDADE")
        treeviewcolumn.set_spacing(10)
        treeviewcolumn.set_resizable(True)
        treeviewcolumn.pack_start(cellrenderertext, False)
        treeviewcolumn.add_attribute(cellrenderertext, "text", 5)
        treeview.append_column(treeviewcolumn)

        treeviewcolumn = Gtk.TreeViewColumn("COMENTÁRIO")
        treeviewcolumn.set_spacing(10)
        treeviewcolumn.set_resizable(True)
        treeviewcolumn.pack_start(cellrenderertext, False)
        treeviewcolumn.add_attribute(cellrenderertext, "text", 6)
        treeview.append_column(treeviewcolumn)

        treeviewcolumn = Gtk.TreeViewColumn("NOME DO CLIETE")
        treeviewcolumn.set_spacing(10)
        treeviewcolumn.set_resizable(True)
        treeviewcolumn.pack_start(cellrenderertext, False)
        treeviewcolumn.add_attribute(cellrenderertext, "text", 3)
        treeview.append_column(treeviewcolumn)

        treeviewcolumn = Gtk.TreeViewColumn("DATA DO PEDIDO")
        treeviewcolumn.set_spacing(10)
        treeviewcolumn.set_resizable(True)
        treeviewcolumn.pack_start(cellrenderertext, False)
        treeviewcolumn.add_attribute(cellrenderertext, "text", 7)
        treeview.append_column(treeviewcolumn)

        # Informações da sessão
        data = SbSession()
        session = data.get_info()
        label = Gtk.Label("Usuário: {} | Username: {} | Nível: {}".format(
            session['user']['name'], session['user']['username'],
            session['user']['level']),
                          halign="center",
                          valign="end",
                          margin_bottom=10)
        box.pack_start(label, True, True, 0)

        # Copyright
        # label = Gtk.Label("© COPYRIGHT 2018 SysBar", ypad=18, halign="center", valign="end")
        # box.pack_start(label, True, True, 0)
        thread = threading.Thread(target=self.start_update)
        thread.daemon = True
        thread.start()
Exemple #16
0
    def __init__(self, idProduct):
        Gtk.Window.__init__(self,
                            title="Informações do produto - SysBar",
                            window_position="center")
        self.set_resizable(False)

        data = SbProducts(idProduct).get_product_info()
        if data['rStatus'] == 0:
            UiDialog("Não encontrado!", "Não encontramos o produto.")
            return self.destroy()

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

        # Lado esquerdo
        # Título
        label = Gtk.Label(margin_bottom=30, halign="start")
        label.set_markup("<span size='20000'>Informações do produto</span>")
        grid.attach(label, 1, 1, 5, 1)

        # Nome do produto
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Nome:</span> <span color='blue'>{}</span>".
            format(data['data']['name']))
        grid.attach(label, 1, 2, 2, 1)

        separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
        grid.attach(separator, 1, 3, 2, 1)

        # Descrição
        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>Descrição:</span>")

        scrolledwindow = Gtk.ScrolledWindow(width_request=200,
                                            height_request=50)

        description = Gtk.TextView(width_request=200, height_request=50)
        description.set_editable(False)
        description.set_cursor_visible(False)
        text = description.get_buffer()
        if data['data']['description']:
            text.set_text(str(data['data']['description']))

        scrolledwindow.add(description)
        grid.attach(label, 1, 4, 2, 1)
        grid.attach(scrolledwindow, 1, 5, 2, 5)

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

        # Ingredientes
        label = Gtk.Label(halign="start")
        label.set_markup("<span font='bold'>Ingredientes:</span>")

        scrolledwindow = Gtk.ScrolledWindow(width_request=200,
                                            height_request=50)

        ingre = Gtk.TextView(width_request=200, height_request=50)
        ingre.set_editable(False)
        ingre.set_cursor_visible(False)
        text2 = ingre.get_buffer()
        if data['data']['ingre']:
            text2.set_text(str(data['data']['ingre']))

        scrolledwindow.add(ingre)
        grid.attach(label, 1, 11, 2, 1)
        grid.attach(scrolledwindow, 1, 12, 2, 4)

        # Meio
        separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
        grid.attach(separator, 3, 2, 1, 14)

        # Lado direito
        # ID do produto
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>ID do produto:</span> <span color='blue'>{}</span>"
            .format(data['data']['id']))
        grid.attach(label, 4, 2, 2, 1)

        # Código de barras
        label = Gtk.Label(halign="start")
        if not data['data']['barcode']:
            label.set_markup(
                "<span font='bold'>Código de Barras:</span> <span color='red'>Não informado.</span>"
            )
        else:
            label.set_markup(
                "<span font='bold'>Código de Barras:</span> <span color='blue'>{}</span>"
                .format(data['data']['barcode']))
        grid.attach(label, 4, 3, 2, 1)

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

        # Unidade
        label = Gtk.Label(halign="start")
        if data['data']['unity'] in ['P', 'M', 'G']:
            if data['data']['unity'] == 'P':
                label.set_markup(
                    "<span font='bold'>Tamanho:</span> <span color='blue'>Pequeno (P)</span>"
                )
            elif data['data']['unity'] == 'M':
                label.set_markup(
                    "<span font='bold'>Tamanho:</span> <span color='blue'>Médio (M)</span>"
                )
            else:
                label.set_markup(
                    "<span font='bold'>Tamanho:</span> <span color='blue'>Grande (G)</span>"
                )
        elif data['data']['unity'] in ['Kg', 'g']:
            label.set_markup(
                "<span font='bold'>Peso:</span> <span color='blue'>{} {}</span>"
                .format(data['data']['amount'], data['data']['unity']))
        else:
            label.set_markup(
                "<span font='bold'>Volume:</span> <span color='blue'>{} {}</span>"
                .format(data['data']['amount'], data['data']['unity']))
        grid.attach(label, 4, 5, 2, 1)

        # Pessoas servidas
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Pessoas servidas:</span> <span color='blue'>{}</span>"
            .format(data['data']['peopleServed']))
        grid.attach(label, 4, 6, 2, 1)

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

        # Estoque
        label = Gtk.Label(halign="start")
        if data['data']['statusStock'] == 1:
            label.set_markup(
                "<span font='bold'>Estoque:</span> <span color='blue'>{} unidades</span>"
                .format(data['data']['stock']))
        else:
            label.set_markup(
                "<span font='bold'>Estoque:</span> <span color='blue'>ilimitado</span>"
            )
        grid.attach(label, 4, 8, 2, 1)

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

        # Preço de venda
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Preço de Venda:</span> <span color='blue'>R$ {}</span>"
            .format(str(data['data']['price']).replace(".", ",")))
        grid.attach(label, 4, 10, 2, 1)

        # Preço de custo
        button = Gtk.Button(label="Mostrar preço de custo", halign="start")
        button.connect("clicked", self.show_cust_price)
        grid.attach(button, 4, 11, 2, 1)

        self.popover = Gtk.Popover()
        self.popover.set_position(Gtk.PositionType.TOP)
        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)
        if SbSession().check_level() >= 2:
            label.set_markup(
                "<span font='bold'>Preço de custo:</span> <span color='blue'>R$ {}</span>"
                .format(str(data['data']['custPrice']).replace(".", ",")))
        else:
            label.set_markup(
                "<span color='red'>Você não tem permissão para ver o preço de custo.</span>"
            )
        box.add(label)

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

        # Desconto
        label = Gtk.Label(halign="start")
        free = json.loads(data['data']['discount'])
        if free['free'] == '0':
            label.set_markup(
                "<span font='bold'>Desconto:</span> <span color='red'>Desativado</span>"
            )
        else:
            if free['type'] == "percent":
                label.set_markup(
                    "<span font='bold'>Desconto:</span> <span color='blue'>A partir de {} produto(s) o cliente ganha {}% de desconto.</span>"
                    .format(free['quant'], free['free']))
            elif free['type'] == "money":
                label.set_markup(
                    "<span font='bold'>Desconto:</span> <span color='blue'>A partir de {} produto(s) o cliente ganha R$ {} de desconto.</span>"
                    .format(free['quant'],
                            str(free['free']).replace(".", ",")))
            else:
                label.set_markup(
                    "<span font='bold'>Desconto:</span> <span color='blue'>A partir de {} produto(s) o cliente ganha {} unidade(s) de desconto.</span>"
                    .format(free['quant'], free['free']))
        grid.attach(label, 4, 13, 2, 1)

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

        # Categoria
        label = Gtk.Label(halign="start")
        label.set_markup(
            "<span font='bold'>Categoria:</span> <span color='blue'>{}</span>".
            format(data['data']['category']))
        grid.attach(label, 4, 15, 2, 1)

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

        button = Gtk.Button(label="Alterar nome e descrições",
                            height_request=40)
        button.connect("clicked", self.update_name, [
            data['data']['id'], data['data']['name'],
            data['data']['description'], data['data']['ingre']
        ])
        grid.attach(button, 1, 17, 1, 1)

        button = Gtk.Button(label="Alterar código de barras",
                            height_request=40)
        button.connect("clicked", self.update_barcode,
                       [data['data']['id'], data['data']['barcode']])
        grid.attach(button, 2, 17, 1, 1)

        button = Gtk.Button(label="Alterar preço/estoque", height_request=40)
        button.connect("clicked", self.update_price, [
            data['data']['id'], data['data']['price'],
            data['data']['custPrice'], data['data']['stock']
        ])
        grid.attach(button, 4, 17, 1, 1)

        button = Gtk.Button(label="Alterar desconto", height_request=40)
        button.connect("clicked", self.update_discount,
                       [data['data']['id'], free])
        grid.attach(button, 5, 17, 1, 1)

        button = Gtk.Button(label="Alterar informações tecnicas",
                            height_request=40)
        button.connect("clicked", self.update_technical_information, [
            data['data']['id'], data['data']['unity'], data['data']['amount'],
            data['data']['peopleServed'], data['data']['virtualMenu'],
            data['data']['delivery'], data['data']['specialRequest'],
            data['data']['printer'], data['data']['idCategory']
        ])
        grid.attach(button, 4, 18, 2, 1)

        button = Gtk.Button(label="Atualizar", height_request=40)
        button.connect("clicked", self.show_info_product, idProduct)
        grid.attach(button, 4, 19, 1, 1)

        button = Gtk.Button(label="Fechar", height_request=40)
        button.connect("clicked", self.destroy_window)
        grid.attach(button, 5, 19, 1, 1)

        label = Gtk.Label()
        label.set_markup("<span font='bold'>Registrado em:</span> {}".format(
            data['data']['register'][:-7]))
        grid.attach(label, 1, 18, 2, 1)

        label = Gtk.Label()
        if not data['data']['lastChange']:
            label.set_markup(
                "<span font='bold'>Última alteração:</span> nunca sofreu alteração."
            )
        else:
            label.set_markup(
                "<span font='bold'>Última alteração:</span> {}".format(
                    data['data']['lastChange'][:-7]))
        grid.attach(label, 1, 19, 2, 1)