vn2008 structure update for credit employee

This commit is contained in:
Carlos Jimenez 2018-01-05 08:59:30 +01:00
parent b3ddeaf4a7
commit b3eac25e8a
1 changed files with 7 additions and 24 deletions

View File

@ -906,31 +906,14 @@ BEGIN
CALL pbx.phoneIsValid (NEW.fax); CALL pbx.phoneIsValid (NEW.fax);
END IF; END IF;
-- Actualiza el crédito -- Actualiza el crédito
SELECT Id_Trabajador INTO vEmployee
FROM Trabajadores WHERE user_id = account.userGetId();
IF vEmployee IS NULL THEN
SET vEmployee = 20;
END IF;
IF !(NEW.Credito <=> OLD.Credito) AND IFNULL(NEW.Credito, 0) >= 0 IF !(NEW.Credito <=> OLD.Credito) AND IFNULL(NEW.Credito, 0) >= 0
THEN THEN
INSERT INTO credit SET INSERT INTO credit SET
Id_Cliente = NEW.Id_Cliente, Id_Cliente = NEW.Id_Cliente,
amount = NEW.Credito, amount = NEW.Credito,
Id_Trabajador = vEmployee; Id_Trabajador = account.userGetId();
END IF;
-- Avisar al comercial si ha llegado la documentación sepa/core
IF NEW.sepavnl AND !OLD.sepavnl THEN
SET vText = 'Sepa de VNL';
END IF;
IF NEW.corevnl AND !OLD.corevnl THEN
SET vText = 'Core de VNL';
END IF; END IF;
IF vText IS NOT NULL IF vText IS NOT NULL