8093-devToTest_2442_3 #3100

Merged
alexm merged 284 commits from 8093-devToTest_2442_3 into test 2024-10-15 06:51:43 +00:00
1 changed files with 15 additions and 21 deletions
Showing only changes of commit 3638e9abb6 - Show all commits

View File

@ -1,36 +1,30 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`(
vBusinessFk INT
)
BEGIN
/**
* Replace the queue of a worker with the queue of the new department.
*
* @param vBusinessFk business id
*/
/**
* Elimina la entrada de la cola anterior y luego inserta la nueva para un trabajador.
*
* @param vBusinessFk ID del negocio
*/
DECLARE vNewQueue VARCHAR(10);
DECLARE vExtension VARCHAR(10);
DECLARE vPrevQueue VARCHAR(10);
SELECT d.pbxQueue, s.extension, qm.queue INTO vNewQueue, vExtension, vPrevQueue
SELECT d.pbxQueue, s.extension, qm.queue
INTO vNewQueue, vExtension, vPrevQueue
FROM business b
JOIN department d ON d.id = b.departmentFk
JOIN pbx.sip s ON s.user_id = b.workerFk
JOIN pbx.sip s ON s.user_id = b.workerFk
LEFT JOIN pbx.queueMember qm ON qm.extension = s.extension
WHERE b.id = vBusinessFk;
WHERE b.id = vBusinessFk;
IF vNewQueue IS NULL THEN
DELETE FROM pbx.queueMember
WHERE extension = vExtension COLLATE utf8_general_ci;
ELSE
IF vPrevQueue IS NULL THEN
INSERT INTO pbx.queueMember (queue, extension)
VALUES (vNewQueue, vExtension);
ELSE
UPDATE pbx.queueMember
SET queue = vNewQueue
WHERE extension = vExtension COLLATE utf8_general_ci;
END IF;
END IF;
DELETE FROM pbx.queueMember
WHERE extension = vExtension COLLATE utf8_general_ci;
INSERT IGNORE INTO pbx.queueMember (queue, extension)
VALUES (vNewQueue, vExtension);
END$$
DELIMITER ;