2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`ticket_setNextState`(
|
2024-07-08 11:17:29 +00:00
|
|
|
vSelf INT
|
|
|
|
)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
2024-07-08 11:17:29 +00:00
|
|
|
* Cambia el estado del ticket al siguiente estado según la tabla state.
|
2024-01-15 11:31:03 +00:00
|
|
|
*
|
2024-07-08 11:17:29 +00:00
|
|
|
* @param vSelf Id ticket
|
2024-01-15 11:31:03 +00:00
|
|
|
*/
|
|
|
|
DECLARE vStateFk INT;
|
|
|
|
DECLARE vNewStateFk INT;
|
|
|
|
|
2024-07-08 11:17:29 +00:00
|
|
|
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
|
|
|
BEGIN
|
|
|
|
RESIGNAL;
|
|
|
|
END;
|
|
|
|
|
2024-01-15 11:31:03 +00:00
|
|
|
SELECT stateFk INTO vStateFk
|
|
|
|
FROM ticketState
|
|
|
|
WHERE ticketFk = vSelf;
|
|
|
|
|
|
|
|
SELECT nextStateFk INTO vNewStateFk
|
|
|
|
FROM state
|
|
|
|
WHERE id = vStateFk;
|
|
|
|
|
2024-07-08 11:17:29 +00:00
|
|
|
IF vNewStateFk IS NULL THEN
|
|
|
|
CALL util.throw('The ticket not have next state');
|
|
|
|
END IF;
|
|
|
|
|
2024-01-15 11:31:03 +00:00
|
|
|
INSERT INTO ticketTracking(stateFk, ticketFk, userFk)
|
|
|
|
VALUES (vNewStateFk, vSelf, account.myUser_getId());
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|