refactor: refs #6495 Requested changes
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Guillermo Bonet 2024-03-05 08:55:40 +01:00
parent 216f6f1db3
commit 619ac4e053
3 changed files with 43 additions and 30 deletions

View File

@ -1,9 +1,9 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_sendMailPurchases`( CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_mailSales`(
vSelf INT, vSelf INT,
vDated DATE vDated DATE
) )
BEGIN proc: BEGIN
/** /**
* Envia un correo electrónico con un resumen de los pedidos * Envia un correo electrónico con un resumen de los pedidos
* preparados para un cliente. * preparados para un cliente.
@ -43,14 +43,19 @@ BEGIN
SET vDated = IFNULL(vDated, util.yesterday()); SET vDated = IFNULL(vDated, util.yesterday());
OPEN vTickets;
FETCH vTickets INTO vTicketFk, vAlias, vAmount, vStreet, vCity;
SET vString = CONCAT('<p><font face="verdana" >', SET vString = CONCAT('<p><font face="verdana" >',
'<h2> Relación de envíos.</h2>', '<h2> Relación de envíos.</h2>',
'<h3><font color="green">Dia: ', vDated, '</font></h3>'); '<h3><font color="green">Dia: ', vDated, '</font></h3>');
WHILE NOT vDone DO OPEN vTickets;
l: LOOP
SET vDone = FALSE;
FETCH vTickets INTO vTicketFk, vAlias, vAmount, vStreet, vCity;
IF vDone THEN
LEAVE l;
END IF;
SET vString = CONCAT(vString, '<br><br>', SET vString = CONCAT(vString, '<br><br>',
'<table> '<table>
<tr> <tr>
@ -63,8 +68,11 @@ BEGIN
</table>', </table>',
' ', vAlias, '<br>', ' ', vAlias, '<br>',
' ', vStreet, '(', vCity, ')'); ' ', vStreet, '(', vCity, ')');
FETCH vTickets INTO vTicketFk, vAlias, vAmount, vStreet, vCity; END LOOP;
END WHILE;
IF vTicketFk IS NULL THEN
LEAVE proc;
END IF;
SET vString = CONCAT( SET vString = CONCAT(
vString, vString,
@ -75,17 +83,19 @@ BEGIN
'<br><h3> Muchas gracias por su confianza</h3>', '<br><h3> Muchas gracias por su confianza</h3>',
'</font></p>'); '</font></p>');
-- Envío del email SELECT email INTO vMailTo
SELECT CONCAT(email,', pako@verdnatura.es') INTO vMailTo
FROM client FROM client
WHERE id = vSelf WHERE id = vSelf
AND email <> ''; AND email <> '';
-- Envío del email
IF vMailTo IS NOT NULL THEN
CALL mail_insert( CALL mail_insert(
IFNULL(vMailTo, 'pako.natek@gmail.com'), vMailTo,
'pako@verdnatura.es', NULL,
'Resumen de pedidos preparados', 'Resumen de pedidos preparados',
vString vString
); );
END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,5 +1,5 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_sendMailPurchasesLauncher`() CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_mailSalesLauncher`()
BEGIN BEGIN
/** /**
* Lanza el envío de correos electrónicos con el resumen de pedidos * Lanza el envío de correos electrónicos con el resumen de pedidos
@ -17,11 +17,14 @@ BEGIN
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
OPEN vClients; OPEN vClients;
l: LOOP
SET vDone = FALSE;
FETCH vClients INTO vClientFk; FETCH vClients INTO vClientFk;
WHILE NOT vDone DO IF vDone THEN
CALL client_sendMailPurchases(util.yesterday(), vClientFk); LEAVE l;
FETCH vClients INTO vClientFk; END IF;
END WHILE; CALL client_mailSales(vClientFk, util.yesterday());
END LOOP;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,4 +1,4 @@
UPDATE IGNORE bs.nightTask UPDATE IGNORE bs.nightTask
SET `procedure` = 'client_sendMailPurchasesLauncher', SET `procedure` = 'client_mailSalesLauncher',
`schema` = 'vn' `schema` = 'vn'
WHERE `procedure` = 'emailYesterdayPurchasesLauncher'; WHERE `procedure` = 'emailYesterdayPurchasesLauncher';