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`.`workerDisable`(vUserId int)
|
2024-01-15 11:31:03 +00:00
|
|
|
mainLabel:BEGIN
|
|
|
|
|
|
|
|
IF (SELECT COUNT(*) FROM workerDisableExcluded WHERE workerFk = vUserId AND (dated > util.VN_CURDATE() OR dated IS NULL)) > 0 THEN
|
|
|
|
LEAVE mainLabel;
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
DELETE cp FROM clientProtected cp
|
|
|
|
JOIN client c ON c.id = cp.clientFk
|
|
|
|
WHERE c.salesPersonFk = vUserId;
|
|
|
|
|
|
|
|
DELETE FROM account.account
|
|
|
|
WHERE id = vUserId;
|
|
|
|
|
|
|
|
UPDATE account.user
|
|
|
|
SET role = 2
|
|
|
|
WHERE id = vUserId;
|
|
|
|
|
|
|
|
DELETE FROM pbx.sip
|
|
|
|
WHERE user_id = vUserId;
|
|
|
|
|
|
|
|
UPDATE `client` c
|
|
|
|
JOIN payMethod p ON p.name = 'CONTADO'
|
|
|
|
SET c.credit = 0, c.payMethodFk = p.id, hasCoreVnl = FALSE
|
|
|
|
WHERE c.id = vUserId;
|
|
|
|
|
|
|
|
UPDATE `client` c
|
|
|
|
SET c.salesPersonFk = null
|
|
|
|
WHERE c.salesPersonFk = vUserId;
|
2024-04-29 14:05:36 +00:00
|
|
|
|
|
|
|
UPDATE locker l
|
|
|
|
SET l.workerFk = NULL
|
|
|
|
WHERE l.workerFk = vUserId;
|
2024-01-15 11:31:03 +00:00
|
|
|
END$$
|
|
|
|
DELIMITER ;
|