element table
This commit is contained in:
parent
599f22a25d
commit
bb4f78961f
|
@ -20,7 +20,7 @@ BEGIN
|
|||
*/
|
||||
|
||||
CALL vn.mail_insert(
|
||||
'pako@verdnatura.es',
|
||||
'floranet@verdnatura.es',
|
||||
vEmail,
|
||||
'Contact request',
|
||||
CONCAT('Phone: ',vPhone, ' Message: ', vMessage)
|
||||
|
|
|
@ -1,23 +1,87 @@
|
|||
DROP PROCEDURE IF EXISTS floranet.order_confirm;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
|
||||
CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT)
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT)
|
||||
READS SQL DATA
|
||||
|
||||
BEGIN
|
||||
/** Update order.isPaid field.
|
||||
/** Update order.isPaid field, and makes the ticket
|
||||
*
|
||||
* @param vCatalogueFk floranet.catalogue.id
|
||||
*
|
||||
* @returns floranet.order.isPaid
|
||||
*/
|
||||
DECLARE vNewTicketFk INT;
|
||||
DECLARE vZoneFk INT;
|
||||
|
||||
UPDATE `order`
|
||||
SET isPaid = TRUE,
|
||||
payed = NOW()
|
||||
WHERE catalogueFk = vCatalogueFk;
|
||||
|
||||
SELECT zoneFk
|
||||
INTO vZoneFk
|
||||
FROM (
|
||||
SELECT zoneFk, COUNT(*) totalCount
|
||||
FROM vn.ticket t
|
||||
JOIN catalogue c ON c.id = vCatalogueFk
|
||||
WHERE t.shipped > util.VN_CURDATE() - INTERVAL 1 YEAR
|
||||
AND t.addressFk = c.addressFk
|
||||
GROUP BY zoneFk
|
||||
ORDER BY totalCount DESC
|
||||
LIMIT 10000000000000000000
|
||||
) sub
|
||||
LIMIT 1;
|
||||
|
||||
INSERT INTO ticket (
|
||||
clientFk,
|
||||
shipped,
|
||||
addressFk,
|
||||
agencyModeFk,
|
||||
nickname,
|
||||
warehouseFk,
|
||||
routeFk,
|
||||
companyFk,
|
||||
landed,
|
||||
zoneFk
|
||||
)
|
||||
SELECT a.clientFk,
|
||||
c.dated - INTERVAL 1 DAY,
|
||||
c.addressFk,
|
||||
a.agencyModeFk,
|
||||
a.nickname,
|
||||
ag.warehouseFk,
|
||||
NULL,
|
||||
co.id,
|
||||
c.dated,
|
||||
vZoneFk
|
||||
FROM vn.address a
|
||||
JOIN vn.agencyMode am ON am.id = a.agencyModeFk
|
||||
JOIN vn.agency ag ON ag.id = am.agencyFk
|
||||
JOIN catalogue c ON c.addressFk = a.id
|
||||
JOIN vn.company co ON co.code = 'VNL'
|
||||
WHERE c.id = vCatalogueFk;
|
||||
|
||||
SET vNewTicketFk = LAST_INSERT_ID();
|
||||
|
||||
INSERT INTO vn.sale(
|
||||
ticketFk,
|
||||
itemFk,
|
||||
concept,
|
||||
price,
|
||||
quantity)
|
||||
SELECT
|
||||
vNewTicketFk,
|
||||
c.itemFk,
|
||||
CONCAT('Entrega: ',c.name),
|
||||
- c.price,
|
||||
1
|
||||
FROM catalogue c
|
||||
JOIN addressPostCode apc
|
||||
ON apc.addressFk = c.addressFk
|
||||
AND apc.dayOfWeek = dayOfWeek(vDated)
|
||||
WHERE c.id = vCatalogueFk;
|
||||
|
||||
SELECT isPaid
|
||||
FROM `order`
|
||||
WHERE catalogueFk = vCatalogueFk;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
-- Place your SQL code here
|
||||
|
||||
ALTER TABLE floranet.catalogue ADD addressFk int(11) NOT NULL;
|
||||
ALTER TABLE floranet.catalogue ADD CONSTRAINT catalogue_address_FK FOREIGN KEY (addressFk) REFERENCES vn.address(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
@ -0,0 +1,6 @@
|
|||
ALTER TABLE floranet.builder DROP FOREIGN KEY builder_FK_1;
|
||||
ALTER TABLE floranet.`element` DROP PRIMARY KEY;
|
||||
ALTER TABLE floranet.`element` ADD id INT NOT NULL;
|
||||
ALTER TABLE floranet.`element` ADD CONSTRAINT element_pk PRIMARY KEY (id);
|
||||
ALTER TABLE floranet.builder ADD CONSTRAINT builder_element_FK FOREIGN KEY (elementFk) REFERENCES floranet.`element`(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
Loading…
Reference in New Issue