7863-devToTest_2434 #2852
|
@ -17,35 +17,33 @@ BEGIN
|
||||||
DECLARE vYear INT;
|
DECLARE vYear INT;
|
||||||
DECLARE vSalesPersonFK INT;
|
DECLARE vSalesPersonFK INT;
|
||||||
DECLARE vItemPicker INT;
|
DECLARE vItemPicker INT;
|
||||||
DECLARE vTicketfailed INT;
|
DECLARE vEmail VARCHAR(150);
|
||||||
|
DECLARE vIsDuplicateMail BOOL;
|
||||||
|
DECLARE vSubject VARCHAR(150);
|
||||||
|
DECLARE vMessage TEXT;
|
||||||
|
|
||||||
DECLARE rsTicket CURSOR FOR
|
DECLARE vTickets CURSOR FOR
|
||||||
SELECT tt.ticketFk,
|
SELECT tt.ticketFk,
|
||||||
t.clientFk,
|
t.clientFk,
|
||||||
t.warehouseFk,
|
t.warehouseFk,
|
||||||
t.companyFk,
|
t.companyFk,
|
||||||
t.addressFk,
|
t.addressFk,
|
||||||
tt.agencyModeFk,
|
tt.agencyModeFk,
|
||||||
ti.dated
|
ti.dated
|
||||||
FROM ticketWeekly tt
|
FROM ticketWeekly tt
|
||||||
JOIN ticket t ON tt.ticketFk = t.id
|
JOIN ticket t ON tt.ticketFk = t.id
|
||||||
JOIN tmp.time ti
|
JOIN tmp.time ti
|
||||||
WHERE WEEKDAY(ti.dated) = tt.weekDay;
|
WHERE WEEKDAY(ti.dated) = tt.weekDay;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
|
||||||
|
|
||||||
CALL `util`.`time_generate`(vDateFrom,vDateTo);
|
CALL `util`.`time_generate`(vDateFrom, vDateTo);
|
||||||
|
|
||||||
OPEN rsTicket;
|
OPEN vTickets;
|
||||||
myLoop: LOOP
|
l: LOOP
|
||||||
BEGIN
|
|
||||||
DECLARE vSalesPersonEmail VARCHAR(150);
|
|
||||||
DECLARE vIsDuplicateMail BOOL;
|
|
||||||
DECLARE vSubject VARCHAR(150);
|
|
||||||
DECLARE vMessage TEXT;
|
|
||||||
|
|
||||||
SET vIsDone = FALSE;
|
SET vIsDone = FALSE;
|
||||||
FETCH rsTicket INTO
|
FETCH vTickets INTO
|
||||||
vTicketFk,
|
vTicketFk,
|
||||||
vClientFk,
|
vClientFk,
|
||||||
vWarehouseFk,
|
vWarehouseFk,
|
||||||
|
@ -55,10 +53,10 @@ BEGIN
|
||||||
vShipment;
|
vShipment;
|
||||||
|
|
||||||
IF vIsDone THEN
|
IF vIsDone THEN
|
||||||
LEAVE myLoop;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- busca si el ticket ya ha sido clonado
|
-- Busca si el ticket ya ha sido clonado
|
||||||
IF EXISTS (SELECT TRUE FROM ticket tOrig
|
IF EXISTS (SELECT TRUE FROM ticket tOrig
|
||||||
JOIN sale saleOrig ON tOrig.id = saleOrig.ticketFk
|
JOIN sale saleOrig ON tOrig.id = saleOrig.ticketFk
|
||||||
JOIN saleCloned sc ON sc.saleOriginalFk = saleOrig.id
|
JOIN saleCloned sc ON sc.saleOriginalFk = saleOrig.id
|
||||||
|
@ -68,7 +66,7 @@ BEGIN
|
||||||
AND tClon.isDeleted = FALSE
|
AND tClon.isDeleted = FALSE
|
||||||
AND DATE(tClon.shipped) = vShipment)
|
AND DATE(tClon.shipped) = vShipment)
|
||||||
THEN
|
THEN
|
||||||
ITERATE myLoop;
|
ITERATE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF vAgencyModeFk IS NULL THEN
|
IF vAgencyModeFk IS NULL THEN
|
||||||
|
@ -184,9 +182,9 @@ BEGIN
|
||||||
ON DUPLICATE KEY UPDATE description =
|
ON DUPLICATE KEY UPDATE description =
|
||||||
CONCAT(ticketObservation.description,VALUES(description),' ');
|
CONCAT(ticketObservation.description,VALUES(description),' ');
|
||||||
|
|
||||||
IF (vLanding IS NULL) THEN
|
IF vLanding IS NULL THEN
|
||||||
|
|
||||||
SELECT IFNULL(d.notificationEmail,e.email) INTO vSalesPersonEmail
|
SELECT IFNULL(d.notificationEmail, e.email) INTO vEmail
|
||||||
FROM client c
|
FROM client c
|
||||||
JOIN worker w ON w.id = c.salesPersonFk
|
JOIN worker w ON w.id = c.salesPersonFk
|
||||||
JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk
|
JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk
|
||||||
|
@ -203,21 +201,21 @@ BEGIN
|
||||||
|
|
||||||
SELECT COUNT(*) INTO vIsDuplicateMail
|
SELECT COUNT(*) INTO vIsDuplicateMail
|
||||||
FROM mail
|
FROM mail
|
||||||
WHERE receiver = vSalesPersonEmail
|
WHERE receiver = vEmail
|
||||||
AND subject = vSubject;
|
AND subject = vSubject;
|
||||||
|
|
||||||
IF NOT vIsDuplicateMail THEN
|
IF NOT vIsDuplicateMail THEN
|
||||||
CALL mail_insert(vSalesPersonEmail, NULL, vSubject, vMessage);
|
CALL mail_insert(vEmail, NULL, vSubject, vMessage);
|
||||||
END IF;
|
END IF;
|
||||||
CALL ticket_setState(vNewTicket, 'FIXING');
|
CALL ticket_setState(vNewTicket, 'FIXING');
|
||||||
ELSE
|
ELSE
|
||||||
CALL ticketCalculateClon(vNewTicket, vTicketFk);
|
CALL ticketCalculateClon(vNewTicket, vTicketFk);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
END;
|
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE rsTicket;
|
CLOSE vTickets;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tmp.time, tmp.zoneGetLanded;
|
DROP TEMPORARY TABLE IF EXISTS
|
||||||
|
tmp.time,
|
||||||
|
tmp.zoneGetLanded;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
Loading…
Reference in New Issue