26 lines
769 B
SQL
26 lines
769 B
SQL
DROP TRIGGER IF EXISTS `vn`.`ticket_afterUpdate`;
|
|
|
|
DELIMITER $$
|
|
USE `vn`$$
|
|
CREATE DEFINER=`root`@`%` TRIGGER `ticket_afterUpdate`
|
|
AFTER UPDATE ON `ticket`
|
|
FOR EACH ROW
|
|
BEGIN
|
|
IF !(NEW.id <=> OLD.id)
|
|
OR !(NEW.warehouseFk <=> OLD.warehouseFk)
|
|
OR !(NEW.shipped <=> OLD.shipped) THEN
|
|
CALL stock.log_add('ticket', NEW.id, OLD.id);
|
|
END IF;
|
|
|
|
IF NEW.clientFk = 2067 AND !(NEW.clientFk <=> OLD.clientFk) THEN
|
|
-- Fallo que se insertan no se sabe como tickets en este cliente
|
|
INSERT INTO vn.mail SET
|
|
`sender` = 'jgallego@verdnatura.es',
|
|
`replyTo` = 'jgallego@verdnatura.es',
|
|
`subject` = 'Modificado ticket al cliente 2067',
|
|
`body` = CONCAT(account.myUserGetName(), ' ha modificado el ticket ',
|
|
NEW.id);
|
|
END IF;
|
|
END$$
|
|
DELIMITER ;
|