2024-05-13 07:54:27 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_setProblemFreeze`(
|
2024-05-13 07:54:27 +00:00
|
|
|
vClientFk INT
|
|
|
|
)
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Update the problem of tickets whose client is frozen or unfrozen
|
|
|
|
*
|
|
|
|
* @param vClientFk Id Cliente, if NULL all clients
|
|
|
|
*/
|
|
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
2024-06-27 11:01:42 +00:00
|
|
|
(INDEX(ticketFk, isProblemCalcNeeded))
|
2024-05-13 07:54:27 +00:00
|
|
|
ENGINE = MEMORY
|
2024-06-27 11:01:42 +00:00
|
|
|
SELECT t.id ticketFk,
|
|
|
|
FALSE hasProblem,
|
|
|
|
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
2024-05-13 07:54:27 +00:00
|
|
|
FROM ticket t
|
2024-06-05 08:11:04 +00:00
|
|
|
WHERE t.shipped >= util.VN_CURDATE()
|
2024-05-13 07:54:27 +00:00
|
|
|
AND (vClientFk IS NULL OR t.clientFk = vClientFk);
|
|
|
|
|
|
|
|
UPDATE tmp.ticket t
|
|
|
|
JOIN ticket ti ON ti.id = t.ticketFk
|
|
|
|
JOIN client c ON c.id = ti.clientFk
|
|
|
|
SET t.hasProblem = TRUE
|
|
|
|
WHERE c.isFreezed;
|
2024-06-27 11:01:42 +00:00
|
|
|
|
2024-05-22 12:50:45 +00:00
|
|
|
CALL ticket_setProblem('isFreezed');
|
2024-05-13 07:54:27 +00:00
|
|
|
|
|
|
|
DROP TEMPORARY TABLE tmp.ticket;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|