DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_printLabel`(vSelf INT)
BEGIN
/**
 * Calls the report_print procedure and passes it 
 * the necessary parameters for printing.
 *
 * @param vSelf expeditioPallet id.
 */
	DECLARE vPrinterFk INT;
	DECLARE vUserFk INT DEFAULT account.myUser_getId();
	
	SELECT o.labelerFk INTO vPrinterFk
		FROM operator o
		WHERE o.workerFk = vUserFk;

	CALL vn.report_print(
		'LabelPalletExpedition',
		vPrinterFk,
		account.myUser_getId(),
		JSON_OBJECT('palletFk', vSelf, 'userFk', vUserFk),
		'high'
	);

	UPDATE vn.expeditionPallet
		SET isPrint = TRUE
		WHERE id = vSelf;
END$$
DELIMITER ;