salix/db/routines/vn/procedures/ticket_printLabelPrevious.sql

34 lines
868 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_printLabelPrevious`(vTicketFk INT)
BEGIN
/**
* Calls the report_print procedure and passes it
* the necessary parameters for printing.
*
* @param vTicketFk id ticket to print.
*/
DECLARE vPrinterFk INT;
DECLARE vSaleGroup INT;
DECLARE vUserFk INT DEFAULT account.myUser_getId();
SELECT sg.id, o.labelerFk INTO vSaleGroup, vPrinterFk
FROM saleGroup sg
JOIN sector sc ON sc.id = sg.sectorFk
JOIN saleGroupDetail sgd ON sg.id = sgd.saleGroupFk
JOIN sale s ON sgd.saleFk = s.id
JOIN ticket t ON s.ticketFk = t.id
JOIN operator o ON o.workerFk = vUserFk
WHERE sc.id = o.sectorFk
AND t.id = vTicketFk
LIMIT 1;
CALL report_print(
'LabelPrevia',
vPrinterFk,
vUserFk,
JSON_OBJECT('id', vSaleGroup, 'userFk', vUserFk),
'high'
);
END$$
DELIMITER ;