feat: refs #7207 allocate new queue on dept change
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2024-09-24 10:15:01 +02:00
parent 6ff76fd74b
commit c6a3004d12
2 changed files with 22 additions and 6 deletions

View File

@ -3982,12 +3982,15 @@ INSERT INTO pbx.queueMultiConfig
maxLen = 0,
ringInUse = 0;
INSERT IGNORE INTO pbx.queue
SET description = 'X-men',
name = '1000',
config = 1;
INSERT INTO pbx.queue (description, name, config)
VALUES ('X-men', '1000', 1),
('Avengers', '2000', 1);
INSERT IGNORE INTO pbx.queueMember
SET queue = '1000',
extension = '1010';
UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA";
UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";

View File

@ -3,10 +3,23 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`business_afterUpdate`
AFTER UPDATE ON `business`
FOR EACH ROW
BEGIN
DECLARE vnIsActive INT;
DECLARE vnExtension VARCHAR(10);
DECLARE vnQueue VARCHAR(10);
CALL worker_updateBusiness(NEW.workerFk);
IF NOT (OLD.workerFk <=> NEW.workerFk) THEN
CALL worker_updateBusiness(OLD.workerFk);
END IF;
SELECT COUNT(*) INTO vnIsActive FROM vn.worker WHERE businessFk = NEW.id;
IF(vnIsActive) THEN
SELECT extension INTO vnExtension FROM pbx.sip WHERE user_id = NEW.workerFk COLLATE utf8mb3_general_ci;
SELECT pbxQueue INTO vnQueue FROM vn.department WHERE id = NEW.departmentFk COLLATE utf8mb3_general_ci;
UPDATE pbx.queueMember SET queue = vnQueue WHERE extension = vnExtension;
END IF;
END$$
DELIMITER ;