mirror of
https://bitbucket.org/presik/presik_pos.git
synced 2023-12-14 06:03:00 +01:00
257 lines
8.7 KiB
Python
257 lines
8.7 KiB
Python
import os
|
|
from PyQt5.QtCore import Qt
|
|
from PyQt5.QtWidgets import (
|
|
QWidget, QGridLayout, QHBoxLayout, QStackedWidget, QVBoxLayout, QFrame
|
|
)
|
|
|
|
from app.commons.image import Image
|
|
from .commons.custom_button import CustomButton
|
|
from .tools import get_icon
|
|
from .constants import FILE_BANNER
|
|
|
|
__all__ = ['ButtonsFunction', 'ButtonsStacked', 'ButtonsNumber']
|
|
|
|
DIR_SHARE = os.path.abspath(os.path.normpath(
|
|
os.path.join(__file__, '..', '..', 'share'))
|
|
)
|
|
|
|
|
|
class StartButtons(QVBoxLayout):
|
|
|
|
def __init__(self, parent):
|
|
super(StartButtons, self).__init__()
|
|
grid = QGridLayout()
|
|
frame = QFrame()
|
|
pixmap_pos = Image(self, 'pixmap_pos', FILE_BANNER)
|
|
self.addWidget(pixmap_pos, 0)
|
|
self.addLayout(grid, 0)
|
|
self.addWidget(frame, 1)
|
|
grid.setHorizontalSpacing(2)
|
|
grid.setVerticalSpacing(2)
|
|
grid.rowStretch(1)
|
|
grid.parent = parent
|
|
columns = 4
|
|
rows = 3
|
|
|
|
values = [
|
|
['button_start_take_away', 'PARA LLEVAR', 'action_start_take_away', 'take_away'],
|
|
['button_start_delivery', 'DOMICILIO', 'action_start_delivery', 'delivery'],
|
|
]
|
|
|
|
if parent.enviroment == 'restaurant':
|
|
values.extend([
|
|
['button_start_table', 'A LA MESA', 'action_start_table', 'table'],
|
|
])
|
|
values.extend([
|
|
['button_start_search_order', 'BUSCAR ORDEN', 'action_search_sale', 'search_sale'],
|
|
['button_print_sale', 'IMPRIMIR', 'action_print_sale', 'print_sale'],
|
|
])
|
|
|
|
if parent.enviroment == 'restaurant':
|
|
values.append(
|
|
['button_tables', 'VER MESAS', 'action_tables', 'tables']
|
|
)
|
|
|
|
if parent.type_pos_user in ('cashier', 'frontend', 'frontend_admin'):
|
|
values.extend([
|
|
['button_control_panel', 'PANEL DE CONTROL', 'action_control_panel', 'settings'],
|
|
['button_reports', 'REPORTES', 'action_reports', 'reports'],
|
|
])
|
|
|
|
values.append(
|
|
['button_help', 'AYUDA', 'action_help', 'help'],
|
|
)
|
|
|
|
positions = [(i, j) for i in range(rows) for j in range(columns)]
|
|
for position, value in zip(positions, values):
|
|
button = CustomButton(
|
|
parent,
|
|
id=value[0],
|
|
size=parent.screen_size,
|
|
icon=get_icon(value[3]),
|
|
title=value[1],
|
|
method=value[2],
|
|
name_style='toolbar'
|
|
)
|
|
grid.addWidget(button, *position)
|
|
|
|
|
|
class ButtonsFunction(QGridLayout):
|
|
|
|
def __init__(self, parent, values=[]):
|
|
super(ButtonsFunction, self).__init__()
|
|
|
|
rows = 4
|
|
columns = 3
|
|
self.setHorizontalSpacing(2)
|
|
self.setVerticalSpacing(2)
|
|
self.parent = parent
|
|
self.set_values(values)
|
|
if self.parent.enviroment == 'restaurant':
|
|
rows = 3
|
|
columns = 5
|
|
name_style = 'toolbar'
|
|
|
|
positions = [(i, j) for i in range(rows) for j in range(columns)]
|
|
for position, value in zip(positions, self.values):
|
|
name_icon = value[0][7:]
|
|
button = CustomButton(
|
|
parent,
|
|
id=value[0],
|
|
size=parent.screen_size,
|
|
icon=get_icon(name_icon),
|
|
title=value[1],
|
|
method=value[2],
|
|
name_style=name_style
|
|
)
|
|
self.addWidget(button, *position)
|
|
last_row = position[0]
|
|
self.setRowStretch(last_row + 1, 1)
|
|
|
|
def set_values(self, values):
|
|
if values:
|
|
self.values = values
|
|
return
|
|
self.values = [
|
|
['button_search_product', 'PRODUCTOS', 'action_search_product'],
|
|
]
|
|
|
|
self.values.extend([
|
|
['button_party', 'CLIENTE', 'action_party'],
|
|
['button_cancel', 'CANCELAR', 'action_cancel'],
|
|
['button_search_sale', 'BUSCAR ORDEN', 'action_search_sale'],
|
|
['button_print_sale', 'IMPRIMIR', 'action_print_sale'],
|
|
['button_delivery_party', 'DOMICILIARIO', 'action_delivery_party'],
|
|
['button_position', 'POSICION', 'action_position'],
|
|
['button_print_order', 'ENVIAR ORDEN', 'action_send_order'],
|
|
])
|
|
|
|
if self.parent.type_pos_user in ('cashier', 'frontend_admin'):
|
|
self.values.append([
|
|
'button_payment_term', 'PLAZO DE PAGO', 'action_payment_term']
|
|
)
|
|
|
|
if self.parent.enviroment == 'restaurant':
|
|
rest_options = [
|
|
['button_delivery', 'AGREGAR DOMICILIO', 'action_delivery'],
|
|
['button_comment', 'NOTA', 'action_comment'],
|
|
['button_tip', 'AGREGAR PROPINA', 'action_tip'],
|
|
['button_tables', 'MESAS', 'action_tables'],
|
|
['button_consumer', 'CONSUMIDOR', 'action_consumer'],
|
|
# ['button_reservations', 'RESERVACIONES', 'action_reservations'],
|
|
]
|
|
self.values.extend(rest_options)
|
|
# if self.parent.type_pos_user in ('cashier', 'frontend_admin'):
|
|
# self.values.append(
|
|
# ['button_global_discount', 'DESCUENTO GLOBAL', 'action_global_discount'],
|
|
# )
|
|
|
|
if self.parent._web_channel:
|
|
self.values.append([
|
|
'button_channel', 'CANALES', 'action_channel'
|
|
])
|
|
|
|
|
|
class ButtonsStacked(QWidget):
|
|
|
|
def __init__(self, parent):
|
|
super(ButtonsStacked, self).__init__()
|
|
self.stacked = QStackedWidget()
|
|
_size = 100
|
|
vbox = QHBoxLayout()
|
|
if parent.screen_size == 'small':
|
|
_size = 70
|
|
self.stacked.setMaximumHeight(_size)
|
|
|
|
self.button_accept = CustomButton(
|
|
id='button_accept',
|
|
parent=parent,
|
|
icon=get_icon('accept'),
|
|
title='FINALIZAR',
|
|
name_style='toolbar',
|
|
method='button_accept_pressed'
|
|
)
|
|
self.button_cash = CustomButton(
|
|
id='button_cash',
|
|
parent=parent,
|
|
icon=get_icon('cash'),
|
|
title='FACTURAR',
|
|
name_style='toolbar',
|
|
method='button_cash_pressed'
|
|
)
|
|
self.button_payment = CustomButton(
|
|
id='button_payment',
|
|
parent=parent,
|
|
title='MEDIO DE PAGO',
|
|
icon=get_icon('money'),
|
|
name_style='toolbar',
|
|
method='button_payment_pressed'
|
|
)
|
|
|
|
if parent.type_pos_user != 'order':
|
|
self.stacked.addWidget(self.button_accept)
|
|
self.stacked.addWidget(self.button_cash)
|
|
self.stacked.addWidget(self.button_payment)
|
|
vbox.addWidget(self.stacked, 0)
|
|
|
|
if parent.type_pos_user == 'cashier' and parent.enviroment == 'retail':
|
|
self.button_to_draft = CustomButton(
|
|
id='button_to_draft',
|
|
parent=parent,
|
|
title='VOLVER A BORRADOR',
|
|
icon=get_icon('draft'),
|
|
name_style='toolbar',
|
|
method='button_to_draft_pressed'
|
|
)
|
|
vbox.addWidget(self.button_to_draft, 0)
|
|
|
|
# self.button_payment.setMaximumHeight(_size)
|
|
# self.addWidget(self.button_payment, 0)
|
|
# else:
|
|
# self.button_plus = CustomButton(
|
|
# id='button_plus',
|
|
# parent=parent,
|
|
# icon=get_icon('plus'),
|
|
# method='button_plus_pressed',
|
|
# name_style='toolbar',
|
|
# )
|
|
# self.addWidget(self.button_plus, 0)
|
|
|
|
if parent.type_pos_user == 'order' or parent.type_pos_user == 'salesman' and parent.enviroment == 'retail':
|
|
self.button_send_order = CustomButton(
|
|
id='button_send_to_pay',
|
|
icon=get_icon('draft'),
|
|
parent=parent,
|
|
title='IR A PAGAR',
|
|
method='button_send_to_pay_pressed',
|
|
name_style='toolbar'
|
|
)
|
|
vbox.addWidget(self.button_send_order, 0)
|
|
self.setLayout(vbox)
|
|
|
|
|
|
class ButtonsNumber(QGridLayout):
|
|
|
|
def __init__(self, parent):
|
|
# Numpad for Numbers
|
|
super(ButtonsNumber, self).__init__()
|
|
self.setHorizontalSpacing(1)
|
|
self.setVerticalSpacing(1)
|
|
|
|
|
|
class Buttonpad(QWidget):
|
|
|
|
def __init__(self, parent):
|
|
super(Buttonpad, self).__init__()
|
|
self._text = ''
|
|
self._keyStates = {}
|
|
self.set_keys()
|
|
|
|
def set_keys(self):
|
|
q = Qt
|
|
self.keys_numbers = list(range(q.Key_0, q.Key_9 + 1))
|
|
self.keys_alpha = list(range(q.Key_A, q.Key_Z + 1))
|
|
self.keys_special = [
|
|
q.Key_Asterisk, q.Key_Comma, q.Key_Period,
|
|
q.Key_Minus, q.Key_Slash]
|
|
self.show_keys = self.keys_numbers + self.keys_alpha + self.keys_special
|