2020-04-19 17:54:08 +02:00
|
|
|
import os
|
|
|
|
from PyQt5.QtCore import Qt
|
2020-12-27 20:06:21 +01:00
|
|
|
from PyQt5.QtWidgets import (
|
|
|
|
QWidget, QGridLayout, QHBoxLayout, QStackedWidget, QVBoxLayout, QFrame
|
|
|
|
)
|
2020-04-19 17:54:08 +02:00
|
|
|
|
2020-12-24 15:07:38 +01:00
|
|
|
from app.commons.image import Image
|
2020-07-27 06:17:17 +02:00
|
|
|
from .commons.custom_button import CustomButton
|
2020-06-12 04:36:27 +02:00
|
|
|
from .tools import get_icon
|
2020-12-24 15:07:38 +01:00
|
|
|
from .constants import FILE_BANNER
|
2020-04-19 17:54:08 +02:00
|
|
|
|
2021-03-19 21:54:41 +01:00
|
|
|
__all__ = ['ButtonsFunction', 'ButtonsStacked', 'StartButtons']
|
2020-04-19 17:54:08 +02:00
|
|
|
|
2020-12-27 20:06:21 +01:00
|
|
|
DIR_SHARE = os.path.abspath(os.path.normpath(
|
|
|
|
os.path.join(__file__, '..', '..', 'share'))
|
|
|
|
)
|
2020-04-19 17:54:08 +02:00
|
|
|
|
|
|
|
|
2020-12-24 15:07:38 +01:00
|
|
|
class StartButtons(QVBoxLayout):
|
2020-04-19 17:54:08 +02:00
|
|
|
|
2020-12-23 18:24:47 +01:00
|
|
|
def __init__(self, parent):
|
|
|
|
super(StartButtons, self).__init__()
|
2020-12-24 15:07:38 +01:00
|
|
|
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)
|
2020-12-27 17:30:02 +01:00
|
|
|
grid.setHorizontalSpacing(2)
|
|
|
|
grid.setVerticalSpacing(2)
|
2020-12-24 15:07:38 +01:00
|
|
|
grid.rowStretch(1)
|
|
|
|
grid.parent = parent
|
2021-01-05 13:17:06 +01:00
|
|
|
columns = 4
|
2021-01-11 05:41:41 +01:00
|
|
|
rows = 3
|
2020-12-23 18:24:47 +01:00
|
|
|
|
|
|
|
values = [
|
2021-01-10 03:25:24 +01:00
|
|
|
['button_start_take_away', 'PARA LLEVAR', 'action_start_take_away', 'take_away'],
|
|
|
|
['button_start_delivery', 'DOMICILIO', 'action_start_delivery', 'delivery'],
|
2020-12-23 18:24:47 +01:00
|
|
|
]
|
2021-01-05 13:17:06 +01:00
|
|
|
|
|
|
|
if parent.enviroment == 'restaurant':
|
|
|
|
values.extend([
|
2021-01-11 03:24:26 +01:00
|
|
|
['button_start_table', 'A LA MESA', 'action_start_table', 'table'],
|
2021-03-19 21:54:41 +01:00
|
|
|
['button_start_catering', 'CATERING', 'action_start_catering', 'catering'],
|
2021-01-05 13:17:06 +01:00
|
|
|
])
|
2021-01-10 18:02:30 +01:00
|
|
|
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(
|
2021-01-11 03:24:26 +01:00
|
|
|
['button_tables', 'VER MESAS', 'action_tables', 'tables']
|
2021-01-10 18:02:30 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
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'],
|
2021-03-20 18:22:28 +01:00
|
|
|
['button_historic_sales', 'HISTORIAL', 'action_historic_sales', 'sales_history'],
|
2021-01-10 18:02:30 +01:00
|
|
|
])
|
2020-12-23 18:24:47 +01:00
|
|
|
|
2021-01-11 05:41:41 +01:00
|
|
|
values.append(
|
|
|
|
['button_help', 'AYUDA', 'action_help', 'help'],
|
|
|
|
)
|
|
|
|
|
2020-12-23 18:24:47 +01:00
|
|
|
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],
|
2020-12-31 17:02:27 +01:00
|
|
|
name_style='toolbar'
|
2020-12-23 18:24:47 +01:00
|
|
|
)
|
2020-12-24 15:07:38 +01:00
|
|
|
grid.addWidget(button, *position)
|
2020-04-19 17:54:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ButtonsFunction(QGridLayout):
|
|
|
|
|
2020-12-21 21:50:52 +01:00
|
|
|
def __init__(self, parent, values=[]):
|
2020-04-19 17:54:08 +02:00
|
|
|
super(ButtonsFunction, self).__init__()
|
|
|
|
|
|
|
|
rows = 4
|
|
|
|
columns = 3
|
2020-12-27 17:30:02 +01:00
|
|
|
self.setHorizontalSpacing(2)
|
|
|
|
self.setVerticalSpacing(2)
|
2020-09-03 06:00:57 +02:00
|
|
|
self.parent = parent
|
|
|
|
self.set_values(values)
|
2020-12-16 22:42:39 +01:00
|
|
|
if self.parent.enviroment == 'restaurant':
|
2020-12-21 21:50:52 +01:00
|
|
|
rows = 3
|
|
|
|
columns = 5
|
2020-12-09 21:05:09 +01:00
|
|
|
name_style = 'toolbar'
|
2020-09-03 06:00:57 +02:00
|
|
|
|
|
|
|
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],
|
2020-12-06 01:37:57 +01:00
|
|
|
size=parent.screen_size,
|
2020-09-03 06:00:57 +02:00
|
|
|
icon=get_icon(name_icon),
|
2020-09-18 19:06:26 +02:00
|
|
|
title=value[1],
|
2020-09-03 06:00:57 +02:00
|
|
|
method=value[2],
|
2020-09-18 19:06:26 +02:00
|
|
|
name_style=name_style
|
2020-09-03 06:00:57 +02:00
|
|
|
)
|
|
|
|
self.addWidget(button, *position)
|
2021-01-11 05:41:41 +01:00
|
|
|
last_row = position[0]
|
|
|
|
self.setRowStretch(last_row + 1, 1)
|
2020-04-19 17:54:08 +02:00
|
|
|
|
2020-09-03 06:00:57 +02:00
|
|
|
def set_values(self, values):
|
|
|
|
if values:
|
|
|
|
self.values = values
|
|
|
|
return
|
2020-04-19 17:54:08 +02:00
|
|
|
self.values = [
|
2021-01-10 03:25:24 +01:00
|
|
|
['button_search_product', 'PRODUCTOS', 'action_search_product'],
|
2020-04-19 17:54:08 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
self.values.extend([
|
2021-01-10 03:25:24 +01:00
|
|
|
['button_party', 'CLIENTE', 'action_party'],
|
|
|
|
['button_cancel', 'CANCELAR', 'action_cancel'],
|
2021-01-11 03:24:26 +01:00
|
|
|
['button_search_sale', 'BUSCAR ORDEN', 'action_search_sale'],
|
2021-01-10 03:25:24 +01:00
|
|
|
['button_print_sale', 'IMPRIMIR', 'action_print_sale'],
|
|
|
|
['button_delivery_party', 'DOMICILIARIO', 'action_delivery_party'],
|
|
|
|
['button_position', 'POSICION', 'action_position'],
|
2021-01-19 15:57:15 +01:00
|
|
|
['button_print_order', 'ENVIAR ORDEN', 'action_send_order'],
|
2021-02-24 05:02:35 +01:00
|
|
|
['button_channel', 'CANALES', 'action_source'],
|
2022-06-14 17:57:50 +02:00
|
|
|
['button_advance', 'ANTICIPO', 'action_add_advance'],
|
2020-04-19 17:54:08 +02:00
|
|
|
])
|
|
|
|
|
2020-09-03 06:00:57 +02:00
|
|
|
if self.parent.enviroment == 'restaurant':
|
2021-01-05 02:32:31 +01:00
|
|
|
rest_options = [
|
2021-01-11 03:24:26 +01:00
|
|
|
['button_delivery', 'AGREGAR DOMICILIO', 'action_delivery'],
|
2021-01-10 03:25:24 +01:00
|
|
|
['button_comment', 'NOTA', 'action_comment'],
|
2021-01-11 03:24:26 +01:00
|
|
|
['button_tip', 'AGREGAR PROPINA', 'action_tip'],
|
2021-01-10 03:25:24 +01:00
|
|
|
['button_tables', 'MESAS', 'action_tables'],
|
|
|
|
['button_consumer', 'CONSUMIDOR', 'action_consumer'],
|
2021-03-01 03:24:52 +01:00
|
|
|
['button_split_sale', 'DIVIDIR CUENTA', 'action_split_sale'],
|
2021-01-05 02:32:31 +01:00
|
|
|
]
|
|
|
|
self.values.extend(rest_options)
|
2021-04-12 18:29:53 +02:00
|
|
|
else:
|
|
|
|
self.values.extend([['button_product_info', 'INFO. PRODUCTO', 'action_info_product']])
|
2020-04-19 17:54:08 +02:00
|
|
|
|
|
|
|
|
2021-01-28 21:49:07 +01:00
|
|
|
class ButtonsStacked(QWidget):
|
2020-04-19 17:54:08 +02:00
|
|
|
|
|
|
|
def __init__(self, parent):
|
|
|
|
super(ButtonsStacked, self).__init__()
|
|
|
|
self.stacked = QStackedWidget()
|
2020-12-06 01:37:57 +01:00
|
|
|
_size = 100
|
2021-02-03 05:39:19 +01:00
|
|
|
hbox = QHBoxLayout()
|
2020-12-06 01:37:57 +01:00
|
|
|
if parent.screen_size == 'small':
|
2020-12-27 01:50:38 +01:00
|
|
|
_size = 70
|
2020-12-06 01:37:57 +01:00
|
|
|
self.stacked.setMaximumHeight(_size)
|
2020-04-19 17:54:08 +02:00
|
|
|
|
|
|
|
self.button_accept = CustomButton(
|
|
|
|
id='button_accept',
|
|
|
|
parent=parent,
|
|
|
|
icon=get_icon('accept'),
|
2021-01-10 03:25:24 +01:00
|
|
|
title='FINALIZAR',
|
2020-04-19 17:54:08 +02:00
|
|
|
name_style='toolbar',
|
|
|
|
method='button_accept_pressed'
|
|
|
|
)
|
2021-02-03 05:39:19 +01:00
|
|
|
self.button_checkout = CustomButton(
|
|
|
|
id='button_checkout',
|
2020-04-19 17:54:08 +02:00
|
|
|
parent=parent,
|
|
|
|
icon=get_icon('cash'),
|
2021-01-25 23:46:49 +01:00
|
|
|
title='FACTURAR',
|
2020-04-19 17:54:08 +02:00
|
|
|
name_style='toolbar',
|
2021-02-03 05:39:19 +01:00
|
|
|
method='button_checkout_pressed'
|
2020-04-19 17:54:08 +02:00
|
|
|
)
|
2021-02-03 05:39:19 +01:00
|
|
|
self.button_payment_method = CustomButton(
|
2020-12-27 20:06:21 +01:00
|
|
|
id='button_payment',
|
|
|
|
parent=parent,
|
2021-01-10 03:25:24 +01:00
|
|
|
title='MEDIO DE PAGO',
|
2020-12-27 20:06:21 +01:00
|
|
|
icon=get_icon('money'),
|
|
|
|
name_style='toolbar',
|
|
|
|
method='button_payment_pressed'
|
|
|
|
)
|
2020-04-19 17:54:08 +02:00
|
|
|
|
2021-02-03 05:39:19 +01:00
|
|
|
self.button_payment_term = CustomButton(
|
|
|
|
id='button_payment_term',
|
|
|
|
parent=parent,
|
|
|
|
title='PLAZO DE PAGO',
|
|
|
|
icon=get_icon('terminal_journal'),
|
|
|
|
name_style='toolbar',
|
|
|
|
method='action_payment_term'
|
|
|
|
)
|
|
|
|
|
2020-07-22 06:26:51 +02:00
|
|
|
if parent.type_pos_user != 'order':
|
2020-04-19 17:54:08 +02:00
|
|
|
self.stacked.addWidget(self.button_accept)
|
2021-02-03 05:39:19 +01:00
|
|
|
self.stacked.addWidget(self.button_checkout)
|
|
|
|
self.stacked.addWidget(self.button_payment_method)
|
|
|
|
|
|
|
|
hbox.addWidget(self.stacked, 0)
|
|
|
|
if parent.type_pos_user in ('cashier', 'frontend_admin'):
|
|
|
|
hbox.addWidget(self.button_payment_term, 0)
|
2020-04-19 17:54:08 +02:00
|
|
|
|
2021-01-28 21:49:07 +01:00
|
|
|
if parent.type_pos_user == 'cashier' and parent.enviroment == 'retail':
|
2020-04-19 17:54:08 +02:00
|
|
|
self.button_to_draft = CustomButton(
|
|
|
|
id='button_to_draft',
|
|
|
|
parent=parent,
|
2021-01-10 03:25:24 +01:00
|
|
|
title='VOLVER A BORRADOR',
|
2020-04-19 17:54:08 +02:00
|
|
|
icon=get_icon('draft'),
|
|
|
|
name_style='toolbar',
|
|
|
|
method='button_to_draft_pressed'
|
|
|
|
)
|
2022-10-28 00:58:20 +02:00
|
|
|
# hbox.addWidget(self.button_to_draft, 0)
|
2020-04-19 17:54:08 +02:00
|
|
|
|
2021-01-28 21:49:07 +01:00
|
|
|
if parent.type_pos_user == 'order' or parent.type_pos_user == 'salesman' and parent.enviroment == 'retail':
|
2020-04-19 17:54:08 +02:00
|
|
|
self.button_send_order = CustomButton(
|
|
|
|
id='button_send_to_pay',
|
|
|
|
icon=get_icon('draft'),
|
|
|
|
parent=parent,
|
2021-01-10 03:25:24 +01:00
|
|
|
title='IR A PAGAR',
|
2020-04-19 17:54:08 +02:00
|
|
|
method='button_send_to_pay_pressed',
|
|
|
|
name_style='toolbar'
|
|
|
|
)
|
2021-02-03 05:39:19 +01:00
|
|
|
hbox.addWidget(self.button_send_order, 0)
|
|
|
|
self.setLayout(hbox)
|
2020-04-19 17:54:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
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
|