2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`worker_updateBusiness`(vSelf INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Activates an account and configures its email settings.
|
|
|
|
*
|
|
|
|
* @param vSelf account id.
|
|
|
|
*/
|
|
|
|
DECLARE vOldBusinessFk INT;
|
|
|
|
DECLARE vNewBusinessFk INT;
|
|
|
|
|
|
|
|
SELECT businessFk INTO vOldBusinessFk FROM worker WHERE id = vSelf;
|
|
|
|
|
|
|
|
SELECT id INTO vNewBusinessFk
|
|
|
|
FROM business
|
|
|
|
WHERE workerFk = vSelf
|
|
|
|
AND util.VN_CURDATE() BETWEEN started AND IFNULL(ended, util.VN_CURDATE())
|
|
|
|
LIMIT 1;
|
|
|
|
|
|
|
|
UPDATE worker
|
|
|
|
SET businessFk = vNewBusinessFk
|
|
|
|
WHERE id = vSelf;
|
|
|
|
|
2024-09-24 13:43:33 +00:00
|
|
|
CALL queueMember_updateQueue(vNewBusinessFk);
|
|
|
|
|
2024-01-15 11:31:03 +00:00
|
|
|
IF vOldBusinessFk IS NULL THEN
|
|
|
|
CALL account.account_enable(vSelf);
|
2024-02-13 12:19:26 +00:00
|
|
|
|
|
|
|
UPDATE client c
|
|
|
|
JOIN payMethod pm ON pm.code = 'bankDraft'
|
|
|
|
SET c.payMethodFk = pm.id
|
|
|
|
WHERE c.id = vSelf
|
|
|
|
AND c.iban;
|
2024-01-15 11:31:03 +00:00
|
|
|
END IF;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|