2024-09-24 13:43:33 +00:00
|
|
|
DELIMITER $$
|
2024-10-03 14:50:31 +00:00
|
|
|
|
2024-09-24 13:43:33 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`(
|
|
|
|
vBusinessFk INT
|
|
|
|
)
|
|
|
|
BEGIN
|
2024-10-03 14:50:31 +00:00
|
|
|
/**
|
|
|
|
* Elimina la entrada de la cola anterior y luego inserta la nueva para un trabajador.
|
|
|
|
*
|
|
|
|
* @param vBusinessFk ID del negocio
|
|
|
|
*/
|
2024-09-24 13:43:33 +00:00
|
|
|
DECLARE vNewQueue VARCHAR(10);
|
|
|
|
DECLARE vExtension VARCHAR(10);
|
2024-10-04 14:48:38 +00:00
|
|
|
DECLARE exit handler FOR SQLEXCEPTION
|
|
|
|
|
|
|
|
SELECT d.pbxQueue, s.extension
|
|
|
|
INTO vNewQueue, vExtension
|
2024-09-24 13:43:33 +00:00
|
|
|
FROM business b
|
|
|
|
JOIN department d ON d.id = b.departmentFk
|
2024-10-03 14:50:31 +00:00
|
|
|
JOIN pbx.sip s ON s.user_id = b.workerFk
|
|
|
|
WHERE b.id = vBusinessFk;
|
|
|
|
|
|
|
|
DELETE FROM pbx.queueMember
|
|
|
|
WHERE extension = vExtension COLLATE utf8_general_ci;
|
2024-09-24 13:43:33 +00:00
|
|
|
|
2024-10-03 14:50:31 +00:00
|
|
|
INSERT IGNORE INTO pbx.queueMember (queue, extension)
|
|
|
|
VALUES (vNewQueue, vExtension);
|
2024-09-24 13:43:33 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|