
DROP procedure IF EXISTS `hedera`.`order_calcCatalogFull`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `hedera`.`order_calcCatalogFull`(vSelf INT)
BEGIN
/**
 * Gets the availability and prices for the given items
 * using the order parameters.
 *
 * @param vSelf The order id
 * @table tmp.item(itemFk)
 * @return tmp.ticketCalculateItem
 * @return tmp.ticketComponentPrice
 * @return tmp.ticketLot
 */
	DECLARE vDate DATE;
	DECLARE vAddress INT;
	DECLARE vAgencyMode INT;

	SELECT date_send, address_id, agency_id
		INTO vDate, vAddress, vAgencyMode
		FROM `order`
		WHERE id = vSelf;

	CALL vn.ticketCalculate(vDate, vAddress, vAgencyMode);

	IF account.myUserGetName() = 'visitor'
	THEN
		DROP TEMPORARY TABLE tmp.ticketComponent;
		UPDATE tmp.ticketCalculateItem SET price = NULL;
	END IF;
END$$
DELIMITER ;
