34 lines
881 B
MySQL
34 lines
881 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_printSticker`(
|
||
|
vSelf INT,
|
||
|
vLabelCount INT
|
||
|
)
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Prints a yellow label from a collection or a ticket
|
||
|
*
|
||
|
* @param vSelf collection or ticket
|
||
|
* @param vLabelCount number of times the collection has been printed
|
||
|
*/
|
||
|
DECLARE vPrintArgs JSON DEFAULT JSON_OBJECT('collectionOrTicketFk', vSelf);
|
||
|
|
||
|
IF vLabelCount IS NULL THEN
|
||
|
INSERT INTO ticketTrolley
|
||
|
SELECT ticketFk, 1
|
||
|
FROM ticketCollection
|
||
|
WHERE collectionFk = vSelf
|
||
|
ON DUPLICATE KEY UPDATE labelCount = labelCount + 1;
|
||
|
ELSE
|
||
|
SET vPrintArgs = JSON_MERGE_PATCH(vPrintArgs, JSON_OBJECT('labelCount', vLabelCount));
|
||
|
END IF;
|
||
|
|
||
|
CALL report_print(
|
||
|
'LabelCollection',
|
||
|
(SELECT o.labelerFk FROM operator o WHERE o.workerFk = account.myUser_getId()),
|
||
|
account.myUser_getId(),
|
||
|
vPrintArgs,
|
||
|
'high'
|
||
|
);
|
||
|
END$$
|
||
|
DELIMITER ;
|