1.started removal of CDNs.\n 2. Improved modular structure for all parts of project including database.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,7 @@ DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Discount;
|
||||
DROP TABLE IF EXISTS tmp_Discount;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Currency_Region_Link;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Currency_Link;
|
||||
DROP TABLE IF EXISTS tmp_User_Role_Link;
|
||||
@@ -151,6 +152,8 @@ DROP TABLE IF EXISTS Shop_Recurrence_Interval;
|
||||
DROP TABLE IF EXISTS Shop_Product_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Product;
|
||||
|
||||
DROP TABLE IF EXISTS Shop_Product_Category_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Product_Category;
|
||||
DROP TABLE IF EXISTS Shop_Category_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Category;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ CREATE TABLE IF NOT EXISTS Shop_Currency (
|
||||
id_currency INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
code VARCHAR(50) NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
symbol VARCHAR(1) NOT NULL,
|
||||
symbol VARCHAR(50) NOT NULL,
|
||||
factor_from_GBP FLOAT NOT NULL,
|
||||
active BIT NOT NULL DEFAULT 1,
|
||||
display_order INT NOT NULL,
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
# Categories
|
||||
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Category';
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Category';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Category (
|
||||
CREATE TABLE IF NOT EXISTS Shop_Product_Category (
|
||||
id_category INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(255),
|
||||
@@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS Shop_Category (
|
||||
created_on TIMESTAMP,
|
||||
created_by VARCHAR(100),
|
||||
id_change_set INT,
|
||||
CONSTRAINT FK_Shop_Category_id_change_set
|
||||
CONSTRAINT FK_Shop_Product_Category_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
|
||||
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Category_Audit';
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Category_Audit';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Category_Audit (
|
||||
CREATE TABLE IF NOT EXISTS Shop_Product_Category_Audit (
|
||||
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_Shop_Category_Audit_id_category
|
||||
CONSTRAINT FK_Shop_Product_Category_Audit_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category)
|
||||
REFERENCES Shop_Product_Category(id_category)
|
||||
ON UPDATE RESTRICT,
|
||||
name_field VARCHAR(50),
|
||||
value_prev VARCHAR(500),
|
||||
value_new VARCHAR(500),
|
||||
id_change_set INT NOT NULL,
|
||||
CONSTRAINT FK_Shop_Category_Audit_id_change_set
|
||||
CONSTRAINT FK_Shop_Product_Category_Audit_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product (
|
||||
# ratio_discount_overall FLOAT NOT NULL DEFAULT 0,
|
||||
CONSTRAINT FK_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category)
|
||||
REFERENCES Shop_Product_Category(id_category)
|
||||
ON UPDATE RESTRICT,
|
||||
latency_manuf INT,
|
||||
quantity_min FLOAT,
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
|
||||
|
||||
DROP TRIGGER IF EXISTS before_insert_Shop_Category;
|
||||
DROP TRIGGER IF EXISTS before_update_Shop_Category;
|
||||
DROP TRIGGER IF EXISTS before_insert_Shop_Product_Category;
|
||||
DROP TRIGGER IF EXISTS before_update_Shop_Product_Category;
|
||||
|
||||
DELIMITER //
|
||||
CREATE TRIGGER before_insert_Shop_Category
|
||||
BEFORE INSERT ON Shop_Category
|
||||
CREATE TRIGGER before_insert_Shop_Product_Category
|
||||
BEFORE INSERT ON Shop_Product_Category
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.created_on = NOW();
|
||||
@@ -17,8 +17,8 @@ END //
|
||||
DELIMITER ;
|
||||
|
||||
DELIMITER //
|
||||
CREATE TRIGGER before_update_Shop_Category
|
||||
BEFORE UPDATE ON Shop_Category
|
||||
CREATE TRIGGER before_update_Shop_Product_Category
|
||||
BEFORE UPDATE ON Shop_Product_Category
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF OLD.id_change_set <=> NEW.id_change_set THEN
|
||||
@@ -26,7 +26,7 @@ BEGIN
|
||||
SET MESSAGE_TEXT = 'New change Set ID must be provided.';
|
||||
END IF;
|
||||
|
||||
INSERT INTO Shop_Category_Audit (
|
||||
INSERT INTO Shop_Product_Category_Audit (
|
||||
id_category,
|
||||
name_field,
|
||||
value_prev,
|
||||
|
||||
@@ -325,7 +325,7 @@ BEGIN
|
||||
RANK() OVER (ORDER BY C.display_order, P.display_order) AS rank_product
|
||||
FROM Split_Temp ST
|
||||
INNER JOIN Shop_Product P ON ST.substring = P.id_product # Shop_Product_Permutation PP
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Access_Level AL
|
||||
ON P.id_access_level_required = AL.id_access_level
|
||||
AND AL.active
|
||||
|
||||
@@ -5,39 +5,20 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_product;
|
||||
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE p_shop_get_many_product (
|
||||
IN a_id_user INT,
|
||||
IN a_get_all_category BIT,
|
||||
IN a_get_inactive_category BIT,
|
||||
IN a_get_first_category_only BIT,
|
||||
IN a_ids_category VARCHAR(500),
|
||||
IN a_get_all_product BIT,
|
||||
IN a_get_inactive_product BIT,
|
||||
IN a_get_first_product_only BIT,
|
||||
IN a_ids_product VARCHAR(500),
|
||||
IN a_get_all_product_permutation BIT,
|
||||
IN a_get_inactive_permutation BIT,
|
||||
IN a_get_first_permutation_only BIT,
|
||||
IN a_ids_permutation VARCHAR(4000),
|
||||
IN a_get_all_image BIT,
|
||||
IN a_get_inactive_image BIT,
|
||||
IN a_get_first_image_only BIT,
|
||||
IN a_ids_image VARCHAR(4000),
|
||||
IN a_get_all_delivery_region BIT,
|
||||
IN a_get_inactive_delivery_region BIT,
|
||||
IN a_get_first_delivery_region_only BIT,
|
||||
IN a_ids_delivery_region VARCHAR(4000),
|
||||
IN a_get_all_currency BIT,
|
||||
IN a_get_inactive_currency BIT,
|
||||
IN a_get_first_currency_only BIT,
|
||||
IN a_ids_currency VARCHAR(4000),
|
||||
IN a_get_all_discount BIT,
|
||||
IN a_get_inactive_discount BIT,
|
||||
IN a_ids_discount VARCHAR(4000),
|
||||
/*
|
||||
IN a_quantity_stock_min FLOAT,
|
||||
IN a_quantity_stock_min FLOAT,
|
||||
*/
|
||||
IN a_get_products_quantity_stock_below_min BIT
|
||||
IN a_id_user INT
|
||||
, IN a_get_all_category BIT
|
||||
, IN a_get_inactive_category BIT
|
||||
, IN a_ids_category VARCHAR(500)
|
||||
, IN a_get_all_product BIT
|
||||
, IN a_get_inactive_product BIT
|
||||
, IN a_ids_product VARCHAR(500)
|
||||
, IN a_get_all_product_permutation BIT
|
||||
, IN a_get_inactive_permutation BIT
|
||||
, IN a_ids_permutation VARCHAR(4000)
|
||||
, IN a_get_all_image BIT
|
||||
, IN a_get_inactive_image BIT
|
||||
, IN a_ids_image VARCHAR(4000)
|
||||
, IN a_get_products_quantity_stock_below_min BIT
|
||||
)
|
||||
BEGIN
|
||||
-- Argument redeclaration
|
||||
@@ -46,9 +27,6 @@ BEGIN
|
||||
DECLARE v_has_filter_product BIT;
|
||||
DECLARE v_has_filter_permutation BIT;
|
||||
DECLARE v_has_filter_image BIT;
|
||||
DECLARE v_has_filter_delivery_region BIT;
|
||||
DECLARE v_has_filter_currency BIT;
|
||||
DECLARE v_has_filter_discount BIT;
|
||||
DECLARE v_guid BINARY(36);
|
||||
# DECLARE v_id_user VARCHAR(100);
|
||||
DECLARE v_ids_permutation_unavailable VARCHAR(4000);
|
||||
@@ -67,86 +45,17 @@ BEGIN
|
||||
SET a_id_user := TRIM(IFNULL(a_id_user, ''));
|
||||
SET a_get_all_category := IFNULL(a_get_all_category, 0);
|
||||
SET a_get_inactive_category := IFNULL(a_get_inactive_category, 0);
|
||||
IF a_ids_category IS NULL THEN
|
||||
SET a_ids_category = '';
|
||||
ELSE
|
||||
SET a_ids_category = REPLACE(TRIM(a_ids_category), '|', ',');
|
||||
END IF;
|
||||
IF a_ids_product IS NULL THEN
|
||||
SET a_ids_product = '';
|
||||
ELSE
|
||||
SET a_ids_product = REPLACE(TRIM(a_ids_product), '|', ',');
|
||||
END IF;
|
||||
IF a_get_inactive_product IS NULL THEN
|
||||
SET a_get_inactive_product = 0;
|
||||
END IF;
|
||||
IF a_get_first_product_only IS NULL THEN
|
||||
SET a_get_first_product_only = 1;
|
||||
END IF;
|
||||
IF a_get_all_product IS NULL THEN
|
||||
SET a_get_all_product = 0;
|
||||
END IF;
|
||||
IF a_ids_permutation IS NULL THEN
|
||||
SET a_ids_permutation = '';
|
||||
ELSE
|
||||
SET a_ids_permutation = REPLACE(TRIM(a_ids_permutation), '|', ',');
|
||||
END IF;
|
||||
IF a_get_inactive_permutation IS NULL THEN
|
||||
SET a_get_inactive_permutation = 0;
|
||||
END IF;
|
||||
IF a_get_all_image IS NULL THEN
|
||||
SET a_get_all_image = 1;
|
||||
END IF;
|
||||
IF a_ids_image IS NULL THEN
|
||||
SET a_ids_image = '';
|
||||
ELSE
|
||||
SET a_ids_image = REPLACE(TRIM(a_ids_image), '|', ',');
|
||||
END IF;
|
||||
IF a_get_inactive_image IS NULL THEN
|
||||
SET a_get_inactive_image = 0;
|
||||
END IF;
|
||||
IF a_get_first_image_only IS NULL THEN
|
||||
SET a_get_first_image_only = 0;
|
||||
END IF;
|
||||
IF a_get_inactive_image IS NULL THEN
|
||||
SET a_get_inactive_image = 0;
|
||||
END IF;
|
||||
IF a_get_all_delivery_region IS NULL THEN
|
||||
SET a_get_all_delivery_region = 1;
|
||||
END IF;
|
||||
IF a_ids_delivery_region IS NULL THEN
|
||||
SET a_ids_delivery_region = '';
|
||||
ELSE
|
||||
SET a_ids_delivery_region = REPLACE(TRIM(a_ids_delivery_region), '|', ',');
|
||||
END IF;
|
||||
IF a_get_inactive_delivery_region IS NULL THEN
|
||||
SET a_get_inactive_delivery_region = 0;
|
||||
END IF;
|
||||
IF a_get_all_currency IS NULL THEN
|
||||
SET a_get_all_currency = 1;
|
||||
END IF;
|
||||
IF a_ids_currency IS NULL THEN
|
||||
SET a_ids_currency = '';
|
||||
ELSE
|
||||
SET a_ids_currency = REPLACE(TRIM(a_ids_currency), '|', ',');
|
||||
END IF;
|
||||
IF a_get_inactive_currency IS NULL THEN
|
||||
SET a_get_inactive_currency = 0;
|
||||
END IF;
|
||||
IF a_get_all_discount IS NULL THEN
|
||||
SET a_get_all_discount = 1;
|
||||
END IF;
|
||||
IF a_ids_discount IS NULL THEN
|
||||
SET a_ids_discount = '';
|
||||
ELSE
|
||||
SET a_ids_discount = REPLACE(TRIM(a_ids_discount), '|', ',');
|
||||
END IF;
|
||||
IF a_get_inactive_discount IS NULL THEN
|
||||
SET a_get_inactive_discount = 0;
|
||||
END IF;
|
||||
IF a_get_products_quantity_stock_below_min IS NULL THEN
|
||||
SET a_get_products_quantity_stock_below_min := 0;
|
||||
END IF;
|
||||
SET a_ids_category := TRIM(IFNULL(a_ids_category, ''));
|
||||
SET a_get_all_product := IFNULL(a_get_all_product, 0);
|
||||
SET a_get_inactive_product := IFNULL(a_get_inactive_product, 0);
|
||||
SET a_ids_product := TRIM(IFNULL(a_ids_product, ''));
|
||||
SET a_get_all_product_permutation := IFNULL(a_get_all_product_permutation, 0);
|
||||
SET a_get_inactive_permutation := IFNULL(a_get_inactive_permutation, 0);
|
||||
SET a_ids_permutation := TRIM(IFNULL(a_ids_permutation, ''));
|
||||
SET a_get_all_image := IFNULL(a_get_all_image, 0);
|
||||
SET a_get_inactive_image := IFNULL(a_get_inactive_image, 0);
|
||||
SET a_ids_image := TRIM(IFNULL(a_ids_image, ''));
|
||||
SET a_get_products_quantity_stock_below_min := IFNULL(a_get_products_quantity_stock_below_min, 0);
|
||||
|
||||
/*
|
||||
SELECT a_id_user, a_get_all_category, a_ids_category, a_get_inactive_category, a_get_all_product,
|
||||
@@ -158,23 +67,11 @@ BEGIN
|
||||
*/
|
||||
|
||||
-- Temporary tables
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Discount;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Currency;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Delivery_Region;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product_2;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product_Copy;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Shop_Category (
|
||||
id_category INT NOT NULL,
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL,
|
||||
can_view BIT,
|
||||
can_edit BIT,
|
||||
can_admin BIT
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Shop_Product (
|
||||
id_category INT NOT NULL,
|
||||
@@ -209,40 +106,13 @@ BEGIN
|
||||
can_admin BIT
|
||||
);
|
||||
|
||||
/*
|
||||
CREATE TEMPORARY TABLE tmp_Shop_Variation (
|
||||
id_variation INT NOT NULL,
|
||||
id_product INT NOT NULL,
|
||||
display_order INT NOT NULL
|
||||
);
|
||||
*/
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Shop_Image (
|
||||
id_image INT NOT NULL,
|
||||
id_product INT NOT NULL,
|
||||
-- id_product INT NOT NULL,
|
||||
id_permutation INT NULL,
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL,
|
||||
rank_in_product_permutation INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Delivery_Region (
|
||||
id_region INT NOT NULL,
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL,
|
||||
requires_delivery_option BIT NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Currency (
|
||||
id_currency INT NOT NULL,
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Discount (
|
||||
id_discount INT NOT NULL,
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL
|
||||
-- rank_in_product_permutation INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
|
||||
@@ -259,9 +129,6 @@ BEGIN
|
||||
SET v_has_filter_product = CASE WHEN a_ids_product = '' THEN 0 ELSE 1 END;
|
||||
SET v_has_filter_permutation = CASE WHEN a_ids_permutation = '' THEN 0 ELSE 1 END;
|
||||
SET v_has_filter_image = CASE WHEN a_ids_image = '' THEN 0 ELSE 1 END;
|
||||
SET v_has_filter_delivery_region = CASE WHEN a_ids_delivery_region = '' THEN 0 ELSE 1 END;
|
||||
SET v_has_filter_currency = CASE WHEN a_ids_currency = '' THEN 0 ELSE 1 END;
|
||||
SET v_has_filter_discount = CASE WHEN a_ids_discount = '' THEN 0 ELSE 1 END;
|
||||
|
||||
-- select v_has_filter_product, v_has_filter_permutation;
|
||||
|
||||
@@ -326,7 +193,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
# permutations
|
||||
@@ -377,50 +244,16 @@ BEGIN
|
||||
)
|
||||
;
|
||||
|
||||
-- select * from tmp_Shop_Product;
|
||||
|
||||
IF a_get_first_product_only = 1 THEN
|
||||
DELETE -- t_P
|
||||
FROM tmp_Shop_Product t_P
|
||||
WHERE t_P.rank_permutation > 1
|
||||
;
|
||||
END IF;
|
||||
|
||||
INSERT INTO tmp_Shop_Category (
|
||||
id_category,
|
||||
active,
|
||||
display_order
|
||||
)
|
||||
SELECT DISTINCT C.id_category,
|
||||
C.active,
|
||||
C.display_order
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Category C
|
||||
ON t_P.id_category = C.id_category
|
||||
ORDER BY C.display_order
|
||||
;
|
||||
|
||||
/*
|
||||
INSERT INTO tmp_Shop_Variation (
|
||||
id_variation, id_product # , display_order
|
||||
)
|
||||
SELECT P.id_variation, P.id_product # , P.display_order
|
||||
FROM Shop_Variation V
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON V.id_product = t_P.id_product
|
||||
WHERE V.active;
|
||||
*/
|
||||
|
||||
# Product Images
|
||||
CREATE TEMPORARY TABLE tmp_Shop_Product_2 SELECT * FROM tmp_Shop_Product;
|
||||
-- CREATE TEMPORARY TABLE tmp_Shop_Product_Copy SELECT * FROM tmp_Shop_Product;
|
||||
|
||||
INSERT INTO tmp_Shop_Image (
|
||||
id_product,
|
||||
id_permutation,
|
||||
id_image,
|
||||
active,
|
||||
display_order,
|
||||
rank_in_product_permutation
|
||||
-- id_product
|
||||
id_permutation
|
||||
, id_image
|
||||
, active
|
||||
, display_order
|
||||
-- , rank_in_product_permutation
|
||||
)
|
||||
/*
|
||||
WITH CTE_Product AS (
|
||||
@@ -433,305 +266,50 @@ BEGIN
|
||||
)
|
||||
*/
|
||||
SELECT
|
||||
IPP.id_product,
|
||||
IPP.id_permutation,
|
||||
IPP.id_image,
|
||||
IPP.active,
|
||||
ROW_NUMBER() OVER (ORDER BY IPP.display_order_product_temp, IPP.display_order_image),
|
||||
RANK() OVER (PARTITION BY IPP.id_product, IPP.id_permutation ORDER BY IPP.display_order_product_temp, IPP.display_order_image)
|
||||
-- IPP.id_product
|
||||
I.id_permutation
|
||||
, I.id_image
|
||||
, I.active
|
||||
, I.display_order
|
||||
-- , RANK() OVER (PARTITION BY IPP.id_product, IPP.id_permutation ORDER BY IPP.display_order_product_temp, IPP.display_order_image)
|
||||
FROM Shop_Product_Image I
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON I.id_permutation = t_P.id_permutation
|
||||
AND NOT t_P.product_has_variations
|
||||
/*
|
||||
FROM (
|
||||
SELECT
|
||||
t_P.id_product,
|
||||
I.id_permutation,
|
||||
I.id_image,
|
||||
I.active,
|
||||
I.display_order AS display_order_image,
|
||||
t_P.rank_permutation AS display_order_product_temp
|
||||
-- t_P.id_product
|
||||
I.id_permutation
|
||||
, I.id_image
|
||||
, I.active
|
||||
, I.display_order AS display_order_image
|
||||
-- , t_P.rank_permutation AS display_order_product_temp
|
||||
FROM Shop_Product_Image I
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON I.id_permutation = t_P.id_permutation
|
||||
AND NOT t_P.product_has_variations
|
||||
|
||||
UNION
|
||||
SELECT
|
||||
t_P2.id_product,
|
||||
I.id_permutation,
|
||||
I.id_image,
|
||||
I.active,
|
||||
I.display_order AS display_order_image,
|
||||
t_P2.rank_permutation AS display_order_product_temp
|
||||
-- t_P2_Copy.id_product
|
||||
I.id_permutation
|
||||
, I.id_image
|
||||
, I.active
|
||||
, I.display_order AS display_order_image
|
||||
-- , t_P2.rank_permutation AS display_order_product_temp
|
||||
FROM Shop_Product_Image I
|
||||
INNER JOIN tmp_Shop_Product_2 t_P2
|
||||
ON I.id_permutation = t_P2.id_permutation
|
||||
AND t_P2.product_has_variations
|
||||
) IPP
|
||||
WHERE (a_get_all_image OR a_get_first_image_only OR FIND_IN_SET(id_image, a_ids_image) > 0)
|
||||
AND (a_get_inactive_image OR IPP.active)
|
||||
INNER JOIN tmp_Shop_Product_Copy t_P_Copy
|
||||
ON I.id_permutation = t_P_Copy.id_permutation
|
||||
AND t_P_Copy.product_has_variations
|
||||
) IPP
|
||||
*/
|
||||
WHERE (a_get_all_image OR FIND_IN_SET(id_image, a_ids_image) > 0)
|
||||
AND (a_get_inactive_image OR I.active)
|
||||
;
|
||||
|
||||
IF a_get_first_image_only THEN
|
||||
DELETE FROM tmp_Shop_Image
|
||||
WHERE rank_in_product_permutation > 1
|
||||
;
|
||||
END IF;
|
||||
|
||||
/*
|
||||
select @@version;
|
||||
IF v_has_filter_image THEN
|
||||
DELETE FROM tmp_Shop_Product
|
||||
WHERE id_product NOT IN (SELECT DISTINCT id_product FROM tmp_Shop_Image);
|
||||
DELETE FROM tmp_Shop_Category
|
||||
WHERE id_category NOT IN (SELECT DISTINCT id_category FROM tmp_Shop_Product);
|
||||
END IF;
|
||||
*/
|
||||
|
||||
# Delivery Regions
|
||||
INSERT INTO tmp_Delivery_Region (
|
||||
id_region,
|
||||
active,
|
||||
display_order,
|
||||
requires_delivery_option
|
||||
)
|
||||
WITH RECURSIVE Recursive_CTE_Delivery_Region AS (
|
||||
SELECT
|
||||
DR.id_region AS id_region_parent,
|
||||
NULL AS id_region_child,
|
||||
CASE WHEN FIND_IN_SET(DR.id_region, a_ids_delivery_region) > 0 THEN 1 ELSE 0 END AS requires_delivery_option
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
INNER JOIN Shop_Currency C ON PCRL.id_currency = C.id_currency
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON PCRL.id_product <=> t_P.id_product
|
||||
AND PCRL.id_permutation <=> t_P.id_permutation
|
||||
INNER JOIN Shop_Region DR ON PCRL.id_region_purchase = DR.id_region
|
||||
WHERE
|
||||
(
|
||||
a_get_all_delivery_region
|
||||
OR FIND_IN_SET(DR.id_region, a_ids_delivery_region) > 0
|
||||
)
|
||||
AND (
|
||||
a_get_inactive_delivery_region
|
||||
OR DR.active = 1
|
||||
)
|
||||
UNION
|
||||
SELECT
|
||||
DRB.id_region_parent,
|
||||
DRB.id_region_child,
|
||||
0 AS requires_delivery_option
|
||||
FROM Shop_Region_Branch DRB
|
||||
INNER JOIN Recursive_CTE_Delivery_Region r_DR
|
||||
ON DRB.id_region_parent = r_DR.id_region_child
|
||||
AND (
|
||||
a_get_inactive_delivery_region
|
||||
OR DRB.active = 1
|
||||
)
|
||||
)
|
||||
SELECT
|
||||
DR.id_region,
|
||||
DR.active,
|
||||
DR.display_order,
|
||||
requires_delivery_option
|
||||
FROM Shop_Region DR
|
||||
INNER JOIN Recursive_CTE_Delivery_Region r_DR
|
||||
ON DR.id_region = r_DR.id_region_parent
|
||||
OR DR.id_region = r_DR.id_region_child
|
||||
;
|
||||
/*
|
||||
select * from tmp_delivery_region;
|
||||
SELECT *
|
||||
FROM tmp_Shop_Product t_P
|
||||
WHERE
|
||||
/*(
|
||||
a_get_all_category
|
||||
OR a_get_all_product
|
||||
OR a_get_all_product_permutation
|
||||
)*
|
||||
FIND_IN_SET(t_P.id_category, a_ids_category) > 0
|
||||
OR FIND_IN_SET(t_P.id_product, a_ids_product) > 0
|
||||
OR FIND_IN_SET(t_P.id_permutation, a_ids_permutation) > 0
|
||||
;
|
||||
*/
|
||||
|
||||
IF v_has_filter_delivery_region THEN
|
||||
SET v_ids_permutation_unavailable = (
|
||||
SELECT GROUP_CONCAT(t_P.id_permutation SEPARATOR ', ')
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM tmp_Shop_Product t_P
|
||||
WHERE
|
||||
/*(
|
||||
a_get_all_category
|
||||
OR a_get_all_produc
|
||||
OR a_get_all_product_permutation
|
||||
)*/
|
||||
FIND_IN_SET(t_P.id_category, a_ids_category) > 0
|
||||
OR FIND_IN_SET(t_P.id_product, a_ids_product) > 0
|
||||
OR FIND_IN_SET(t_P.id_permutation, a_ids_permutation) > 0
|
||||
) t_P
|
||||
LEFT JOIN (
|
||||
SELECT *
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
WHERE
|
||||
(
|
||||
a_get_all_delivery_region
|
||||
OR FIND_IN_SET(PCRL.id_region_purchase, a_ids_delivery_region) > 0
|
||||
)
|
||||
) PCRL
|
||||
ON t_P.id_product <=> PCRL.id_product
|
||||
AND t_P.id_permutation <=> PCRL.id_permutation
|
||||
LEFT JOIN tmp_Delivery_Region t_DR
|
||||
ON PCRL.id_region_purchase = t_DR.id_region
|
||||
AND t_DR.requires_delivery_option = 1
|
||||
WHERE
|
||||
ISNULL(t_DR.id_region)
|
||||
);
|
||||
IF NOT ISNULL(v_ids_permutation_unavailable) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid,
|
||||
id_type,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
VALUES (
|
||||
v_guid,
|
||||
(SELECT id_type FROM Shop_Msg_Error_Type WHERE code = 'PRODUCT_AVAILABILITY' LIMIT 1),
|
||||
'PRODUCT_AVAILABILITY',
|
||||
CONCAT('Error: The following permutation IDs are not available in this region: ', IFNULL(v_ids_permutation_unavailable, 'NULL'))
|
||||
);
|
||||
END IF;
|
||||
/*
|
||||
DELETE FROM tmp_Shop_Product t_P
|
||||
WHERE t_P.id_permutation NOT IN (
|
||||
SELECT
|
||||
id_permutation
|
||||
FROM Shop_Product_Currency_Region_Link PCL
|
||||
INNER JOIN tmp_Delivery_Region t_DR
|
||||
ON PCRL.id_region_purchase = t_DR.id_region
|
||||
);
|
||||
*/
|
||||
END IF;
|
||||
|
||||
-- select * from tmp_Shop_Product;
|
||||
|
||||
# Currencies
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE guid = v_guid) THEN
|
||||
INSERT INTO tmp_Currency (
|
||||
id_currency,
|
||||
active,
|
||||
display_order
|
||||
)
|
||||
SELECT
|
||||
C.id_currency,
|
||||
C.active,
|
||||
C.display_order
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
INNER JOIN Shop_Currency C ON PCRL.id_currency = C.id_currency
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON PCRL.id_product <=> t_P.id_product
|
||||
AND PCRL.id_permutation <=> t_P.id_permutation
|
||||
INNER JOIN tmp_Delivery_Region t_DR ON PCRL.id_region_purchase = t_DR.id_region
|
||||
WHERE
|
||||
(
|
||||
a_get_all_currency
|
||||
OR FIND_IN_SET(C.id_currency, a_ids_currency) > 0
|
||||
)
|
||||
AND (
|
||||
a_get_inactive_currency
|
||||
OR (
|
||||
C.active
|
||||
AND PCRL.active
|
||||
)
|
||||
)
|
||||
;
|
||||
|
||||
-- select * from tmp_Currency;
|
||||
|
||||
IF v_has_filter_currency THEN
|
||||
SET v_ids_permutation_unavailable = (
|
||||
SELECT GROUP_CONCAT(t_P.id_permutation SEPARATOR ', ')
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM tmp_Shop_Product t_P
|
||||
WHERE
|
||||
/*(
|
||||
a_get_all_category
|
||||
OR a_get_all_product
|
||||
OR a_get_all_product_permutation
|
||||
)*/
|
||||
FIND_IN_SET(t_P.id_category, a_ids_category) > 0
|
||||
OR FIND_IN_SET(t_P.id_product, a_ids_product) > 0
|
||||
OR FIND_IN_SET(t_P.id_permutation, a_ids_permutation) > 0
|
||||
) t_P
|
||||
INNER JOIN (
|
||||
SELECT *
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
WHERE
|
||||
(
|
||||
a_get_all_currency
|
||||
OR FIND_IN_SET(PCRL.id_currency, a_ids_currency) > 0
|
||||
)
|
||||
) PCRL
|
||||
ON t_P.id_permutation = PCRL.id_permutation
|
||||
LEFT JOIN tmp_Currency t_C
|
||||
ON PCRL.id_currency = t_C.id_currency
|
||||
WHERE ISNULL(t_C.id_currency)
|
||||
);
|
||||
IF NOT ISNULL(v_ids_permutation_unavailable) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid,
|
||||
id_type,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
VALUES (
|
||||
v_guid,
|
||||
(SELECT id_type FROM Shop_Msg_Error_Type WHERE code = 'PRODUCT_AVAILABILITY' LIMIT 1),
|
||||
'PRODUCT_AVAILABILITY',
|
||||
CONCAT('Error: The following permutation IDs are not available in this currency: ', IFNULL(v_ids_permutation_unavailable, 'NULL'))
|
||||
);
|
||||
END IF;
|
||||
/*
|
||||
DELETE FROM tmp_Shop_Product t_P
|
||||
WHERE t_P.id_permutation NOT IN (
|
||||
SELECT
|
||||
id_permutation
|
||||
FROM Shop_Product_Currency_Region_Link PCL
|
||||
INNER JOIN tmp_Currency t_C
|
||||
ON PCRL.id_currency = t_C.id_currency
|
||||
);
|
||||
*/
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
# Discounts
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE guid = v_guid) THEN
|
||||
INSERT INTO tmp_Discount (
|
||||
id_discount,
|
||||
active,
|
||||
display_order
|
||||
)
|
||||
SELECT
|
||||
D.id_discount,
|
||||
D.active,
|
||||
D.display_order
|
||||
FROM Shop_Discount D
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON D.id_product = t_P.id_product
|
||||
AND D.id_permutation <=> t_P.id_permutation
|
||||
WHERE
|
||||
(
|
||||
a_get_all_discount
|
||||
OR FIND_IN_SET(D.id_discount, a_ids_discount) > 0
|
||||
)
|
||||
AND (
|
||||
a_get_inactive_discount
|
||||
OR D.active
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
# select 'pre-permission results';
|
||||
# select * from tmp_Shop_Product;
|
||||
|
||||
-- Permissions
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Category LIMIT 1) THEN
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Product LIMIT 1) THEN
|
||||
# SET v_id_user := (SELECT id_user FROM Shop_User WHERE name = CURRENT_USER());
|
||||
SET v_id_permission_product := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
|
||||
SET v_ids_product_permission := (SELECT GROUP_CONCAT(id_product SEPARATOR ',') FROM tmp_Shop_Product WHERE NOT ISNULL(id_product));
|
||||
@@ -793,16 +371,14 @@ BEGIN
|
||||
|
||||
# Categories
|
||||
SELECT
|
||||
DISTINCT t_C.id_category,
|
||||
C.name,
|
||||
C.description,
|
||||
C.display_order
|
||||
FROM tmp_Shop_Category t_C
|
||||
INNER JOIN Shop_Category C
|
||||
ON t_C.id_category = C.id_category
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON t_C.id_category = t_P.id_category
|
||||
ORDER BY C.display_order
|
||||
DISTINCT t_P.id_category,
|
||||
PC.name,
|
||||
PC.description,
|
||||
PC.display_order
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Product_Category PC
|
||||
ON t_P.id_category = PC.id_category
|
||||
ORDER BY PC.display_order
|
||||
;
|
||||
|
||||
# Products
|
||||
@@ -845,15 +421,20 @@ BEGIN
|
||||
|
||||
# Variations
|
||||
SELECT
|
||||
V.id_variation,
|
||||
t_P.id_product,
|
||||
t_P.id_permutation,
|
||||
t_P.id_category,
|
||||
VT.code AS code_variation_type,
|
||||
VT.name AS name_variation_type,
|
||||
V.code AS code_variation,
|
||||
V.name AS name_variation,
|
||||
RANK() OVER (ORDER BY t_P.rank_permutation, PPVL.display_order) AS display_order
|
||||
V.id_variation
|
||||
, V.code AS code_variation
|
||||
, V.name AS name_variation
|
||||
, V.active AS active_variation
|
||||
, V.display_order
|
||||
, V.id_type
|
||||
, VT.code AS code_variation_type
|
||||
, VT.name AS name_variation_type
|
||||
, VT.name_plural AS name_plural_variation_type
|
||||
, VT.active AS active_variation_type
|
||||
, VT.display_order
|
||||
, t_P.id_product
|
||||
, t_P.id_permutation
|
||||
, t_P.id_category
|
||||
FROM Shop_Variation V
|
||||
INNER JOIN Shop_Variation_Type VT ON V.id_type = VT.id_type
|
||||
INNER JOIN Shop_Product_Permutation_Variation_Link PPVL ON V.id_variation = PPVL.id_variation
|
||||
@@ -882,57 +463,10 @@ BEGIN
|
||||
select * from tmp_shop_product;
|
||||
*/
|
||||
|
||||
# Product Price
|
||||
SELECT
|
||||
PCRL.id_link AS id_price,
|
||||
t_P.id_permutation,
|
||||
t_P.id_product,
|
||||
t_P.id_category,
|
||||
t_C.id_currency,
|
||||
C.code AS code_currency,
|
||||
C.name AS name_currency,
|
||||
C.symbol AS symbol_currency,
|
||||
t_DR.id_region,
|
||||
PCRL.price_local_VAT_incl,
|
||||
PCRL.price_local_VAT_excl,
|
||||
ROW_NUMBER() OVER(ORDER BY t_P.rank_permutation, C.display_order) AS display_order
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON PCRL.id_product <=> t_P.id_product
|
||||
AND PCRL.id_permutation <=> t_P.id_permutation
|
||||
-- INNER JOIN Shop_Product P ON PCRL.id_product = P.id_product
|
||||
INNER JOIN tmp_Currency t_C ON PCRL.id_currency = t_C.id_currency
|
||||
INNER JOIN Shop_Currency C ON t_C.id_currency = C.id_currency
|
||||
INNER JOIN tmp_Delivery_Region t_DR ON PCRL.id_region_purchase = t_DR.id_region
|
||||
WHERE (
|
||||
a_get_inactive_product
|
||||
AND a_get_inactive_permutation
|
||||
AND a_get_inactive_currency
|
||||
AND a_get_inactive_delivery_region
|
||||
OR PCRL.active
|
||||
)
|
||||
ORDER BY t_P.rank_permutation
|
||||
;
|
||||
|
||||
/*
|
||||
# Currency
|
||||
SELECT
|
||||
DISTINCT C.id_currency,
|
||||
C.code,
|
||||
C.name,
|
||||
C.factor_from_GBP,
|
||||
t_C.display_order
|
||||
FROM Shop_Currency C
|
||||
INNER JOIN tmp_Currency t_C ON C.id_currency = t_C.id_currency
|
||||
GROUP BY C.id_currency, t_C.display_order
|
||||
ORDER BY t_C.display_order
|
||||
;
|
||||
*/
|
||||
|
||||
# Images
|
||||
SELECT
|
||||
t_I.id_image,
|
||||
t_I.id_product,
|
||||
t_P.id_product,
|
||||
t_I.id_permutation,
|
||||
t_P.id_category,
|
||||
I.url,
|
||||
@@ -947,105 +481,6 @@ BEGIN
|
||||
ORDER BY t_P.rank_permutation, I.display_order
|
||||
;
|
||||
|
||||
# Delivery options
|
||||
SELECT
|
||||
_DO.id_option,
|
||||
PDOL.id_product,
|
||||
PDOL.id_permutation,
|
||||
t_P.id_category,
|
||||
_DO.code,
|
||||
_DO.name,
|
||||
_DO.latency_delivery_min,
|
||||
_DO.latency_delivery_max,
|
||||
_DO.quantity_min,
|
||||
_DO.quantity_max,
|
||||
GROUP_CONCAT(DR.code SEPARATOR ',') AS codes_region,
|
||||
GROUP_CONCAT(DR.name SEPARATOR ',') AS names_region,
|
||||
PDOL.price_local,
|
||||
PDOL.display_order
|
||||
FROM Shop_Delivery_Option _DO
|
||||
INNER JOIN Shop_Product_Delivery_Option_Link PDOL
|
||||
ON _DO.id_option = PDOL.id_delivery_option
|
||||
AND (
|
||||
a_get_inactive_delivery_region
|
||||
OR PDOL.active
|
||||
)
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON PDOL.id_product = t_P.id_product
|
||||
AND PDOL.id_permutation <=> t_P.id_permutation
|
||||
INNER JOIN tmp_Delivery_Region t_DR ON PDOL.id_region = t_DR.id_region
|
||||
INNER JOIN Shop_Region DR ON t_DR.id_region = DR.id_region
|
||||
WHERE (
|
||||
a_get_inactive_delivery_region
|
||||
OR _DO.active
|
||||
)
|
||||
GROUP BY t_P.id_category, t_P.id_product, PDOL.id_permutation, t_P.rank_permutation, DR.id_region, _DO.id_option, PDOL.id_link
|
||||
ORDER BY t_P.rank_permutation, PDOL.display_order
|
||||
;
|
||||
|
||||
# Discounts
|
||||
SELECT
|
||||
D.id_discount,
|
||||
P.id_category,
|
||||
D.id_product,
|
||||
D.id_permutation,
|
||||
DR.id_region,
|
||||
C.id_currency,
|
||||
D.code AS code_discount,
|
||||
D.name AS name_discount,
|
||||
D.multiplier,
|
||||
D.subtractor,
|
||||
D.apply_multiplier_first,
|
||||
D.quantity_min,
|
||||
D.quantity_max,
|
||||
D.date_start,
|
||||
D.date_end,
|
||||
GROUP_CONCAT(DR.code) AS codes_region,
|
||||
GROUP_CONCAT(DR.name) AS names_region,
|
||||
GROUP_CONCAT(C.code) AS codes_currency,
|
||||
GROUP_CONCAT(C.name) AS names_currency,
|
||||
ROW_NUMBER() OVER(ORDER BY D.display_order) AS display_order
|
||||
FROM tmp_Discount t_D
|
||||
INNER JOIN Shop_Discount D ON t_D.id_discount = D.id_discount
|
||||
INNER JOIN Shop_Product P ON D.id_product = P.id_product
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON D.id_product = t_P.id_product
|
||||
-- AND D.id_permutation <=> t_P.id_permutation
|
||||
INNER JOIN Shop_Discount_Region_Currency_Link DRCL
|
||||
ON D.id_discount = DRCL.id_discount
|
||||
INNER JOIN tmp_Delivery_Region t_DR ON DRCL.id_region = t_DR.id_region
|
||||
INNER JOIN Shop_Region DR ON t_DR.id_region = DR.id_region
|
||||
INNER JOIN tmp_Currency t_C ON DRCL.id_currency = t_C.id_currency
|
||||
INNER JOIN Shop_Currency C ON t_C.id_currency = C.id_currency
|
||||
GROUP BY D.id_discount, DR.id_region, C.id_currency
|
||||
ORDER BY D.display_order, DR.display_order, C.display_order
|
||||
;
|
||||
|
||||
/*
|
||||
# Delivery Regions
|
||||
SELECT
|
||||
t_DR.id_region,
|
||||
t_P.id_category,
|
||||
t_P.id_product,
|
||||
t_P.id_permutation,
|
||||
DR.code,
|
||||
DR.name
|
||||
FROM tmp_Delivery_Region t_DR
|
||||
INNER JOIN Shop_Delivery_Region DR ON t_DR.id_region = DR.id_region
|
||||
INNER JOIN Shop_Product_Region_Currency_Link PDRL
|
||||
ON DR.id_region = PDRL.id_region
|
||||
AND (
|
||||
a_get_inactive_delivery_region
|
||||
OR PDRL.active
|
||||
)
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON PDRL.id_product = t_P.id_product
|
||||
AND PDRL.id_permutation <=> t_P.id_permutation
|
||||
INNER JOIN tmp_Currency t_C ON PDRL.id_currency = t_C.id_currency
|
||||
ORDER BY t_DR.display_order
|
||||
;
|
||||
*/
|
||||
|
||||
# Errors
|
||||
SELECT
|
||||
t_ME.display_order,
|
||||
@@ -1081,54 +516,34 @@ BEGIN
|
||||
# select * from tmp_Shop_Product;
|
||||
|
||||
-- Clean up
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Discount;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Currency;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Delivery_Region;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Product;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product_2;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product_Copy;
|
||||
|
||||
END //
|
||||
DELIMITER ;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
CALL partsltd_prod.p_shop_get_many_product (
|
||||
1, #'auth0|6582b95c895d09a70ba10fef', # a_id_user
|
||||
1, # a_get_all_category
|
||||
1, # a_get_inactive_category
|
||||
0, # a_get_first_category_only
|
||||
'', # a_ids_category
|
||||
1, # a_get_all_product
|
||||
0, # a_get_inactive_product
|
||||
0, # a_get_first_product_only
|
||||
'', # a_ids_product
|
||||
1, # a_get_all_product_permutation
|
||||
0, # a_get_inactive_permutation
|
||||
0, # a_get_first_permutation_only
|
||||
'', # a_ids_permutation
|
||||
1, # a_get_all_image
|
||||
0, # a_get_inactive_image
|
||||
0, # a_get_first_image_only
|
||||
'', # a_ids_image
|
||||
1, # a_get_all_delivery_region
|
||||
0, # a_get_inactive_delivery_region
|
||||
0, # a_get_first_delivery_region_only
|
||||
'', # a_ids_delivery_region
|
||||
1, # a_get_all_currency
|
||||
0, # a_get_inactive_currency
|
||||
0, # a_get_first_currency_only
|
||||
'', # a_ids_currency
|
||||
1, # a_get_all_discount
|
||||
0, # a_get_inactive_discount
|
||||
'', # a_ids_discount
|
||||
1 # a_get_products_quantity_stock_below_minimum
|
||||
1 #'auth0|6582b95c895d09a70ba10fef', # a_id_user
|
||||
, 1 # a_get_all_category
|
||||
, 1 # a_get_inactive_category
|
||||
, '' # a_ids_category
|
||||
, 1 # a_get_all_product
|
||||
, 0 # a_get_inactive_product
|
||||
, '' # a_ids_product
|
||||
, 1 # a_get_all_product_permutation
|
||||
, 0 # a_get_inactive_permutation
|
||||
, '' # a_ids_permutation
|
||||
, 1 # a_get_all_image
|
||||
, 0 # a_get_inactive_image
|
||||
, '' # a_ids_image
|
||||
, 1 # a_get_products_quantity_stock_below_minimum
|
||||
);
|
||||
|
||||
/*
|
||||
select * FROM Shop_User_Eval_Temp;
|
||||
|
||||
select * from Shop_Product_Permutation;
|
||||
|
||||
@@ -154,6 +154,14 @@ BEGIN
|
||||
a_get_inactive_variation
|
||||
OR V.active = 1
|
||||
)
|
||||
AND (
|
||||
a_get_all_variation_type
|
||||
OR FIND_IN_SET(V.id_type, a_ids_variation_type)
|
||||
)
|
||||
AND (
|
||||
a_get_inactive_variation_type
|
||||
OR VT.active = 1
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
|
||||
@@ -161,10 +169,35 @@ BEGIN
|
||||
|
||||
IF a_get_first_variation_only THEN
|
||||
DELETE t_V
|
||||
FROM tmp_Shop_Variation t_V
|
||||
FROM tmp_Variation t_V
|
||||
WHERE t_V.rank_variation > 1
|
||||
;
|
||||
END IF;
|
||||
|
||||
INSERT INTO tmp_Variation_Type (
|
||||
id_type
|
||||
, active
|
||||
, rank_type
|
||||
)
|
||||
SELECT
|
||||
DISTINCT t_V.id_type
|
||||
, VT.active
|
||||
, RANK() OVER(ORDER BY t_V.id_type) AS rank_type
|
||||
FROM tmp_Variation t_V
|
||||
INNER JOIN Shop_Variation_Type VT ON t_V.id_type = VT.id_type
|
||||
;
|
||||
|
||||
IF a_get_first_variation_type_only THEN
|
||||
DELETE t_V
|
||||
FROM tmp_Variation t_V
|
||||
INNER JOIN tmp_Variation_Type t_VT ON t_V.id_variation = t_VT.id_variation
|
||||
WHERE t_VT.rank_type > 1
|
||||
;
|
||||
DELETE t_VT
|
||||
FROM tmp_Variation_Type t_VT
|
||||
WHERE t_VT.rank_type > 1
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
@@ -193,6 +226,8 @@ BEGIN
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
|
||||
CALL p_clear_shop_user_eval_temp(v_guid);
|
||||
END IF;
|
||||
|
||||
IF EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN
|
||||
@@ -201,6 +236,7 @@ BEGIN
|
||||
END IF;
|
||||
|
||||
-- Returns
|
||||
/*
|
||||
# Variation Types
|
||||
SELECT
|
||||
t_VT.id_type
|
||||
@@ -211,15 +247,26 @@ BEGIN
|
||||
FROM tmp_Variation_Type t_VT
|
||||
INNER JOIN Shop_Variation_Type VT ON t_VT.id_type = VT.id_type
|
||||
;
|
||||
*/
|
||||
|
||||
# Variations
|
||||
SELECT
|
||||
t_V.id_variation
|
||||
, V.code
|
||||
, V.name
|
||||
, V.active
|
||||
, V.code AS code_variation
|
||||
, V.name AS name_variation
|
||||
, V.active AS active_variation
|
||||
, V.display_order
|
||||
, t_V.id_type
|
||||
, VT.code AS code_variation_type
|
||||
, VT.name AS name_variation_type
|
||||
, VT.name_plural AS name_plural_variation_type
|
||||
, VT.active AS active_variation_type
|
||||
, VT.display_order
|
||||
FROM tmp_Variation t_V
|
||||
INNER JOIN Shop_Variation V ON t_V.id_variation = V.id_variation
|
||||
INNER JOIN tmp_Variation_Type t_VT ON V.id_type = t_VT.id_type
|
||||
INNER JOIN Shop_Variation_Type VT ON t_VT.id_type = VT.id_type
|
||||
ORDER BY VT.display_order, V.display_order
|
||||
;
|
||||
|
||||
# Errors
|
||||
@@ -239,6 +286,7 @@ END //
|
||||
DELIMITER ;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
CALL p_shop_get_many_product_variation (
|
||||
1, # 'auth0|6582b95c895d09a70ba10fef', # a_id_user
|
||||
@@ -252,7 +300,6 @@ CALL p_shop_get_many_product_variation (
|
||||
'' # a_ids_variation
|
||||
);
|
||||
|
||||
/*
|
||||
select * from shop_variation;
|
||||
select * from shop_variation_type;
|
||||
*/
|
||||
|
||||
@@ -123,7 +123,7 @@ BEGIN
|
||||
/*
|
||||
, CONSTRAINT FK_tmp_Category_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category)
|
||||
REFERENCES Shop_Product_Category(id_category)
|
||||
/
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL,
|
||||
@@ -139,7 +139,7 @@ BEGIN
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
*/
|
||||
id_product INT NOT NULL
|
||||
/*
|
||||
@@ -214,7 +214,7 @@ BEGIN
|
||||
/*
|
||||
CONSTRAINT FK_tmp_Stock_Item_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
*/
|
||||
, date_purchased TIMESTAMP NOT NULL
|
||||
, date_received TIMESTAMP NULL
|
||||
@@ -367,7 +367,7 @@ BEGIN
|
||||
FROM Shop_Stock_Item SI
|
||||
INNER JOIN Shop_Product_Permutation PP ON SI.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
WHERE
|
||||
# stock items
|
||||
(
|
||||
@@ -812,6 +812,7 @@ END //
|
||||
DELIMITER ;
|
||||
|
||||
/*
|
||||
|
||||
CALL p_shop_get_many_stock_item (
|
||||
0, # a_id_user
|
||||
1, # a_get_all_category
|
||||
@@ -852,6 +853,7 @@ CALL p_shop_get_many_stock_item (
|
||||
);
|
||||
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS tmp_Msg_Error;
|
||||
|
||||
select * from shop_image;
|
||||
|
||||
@@ -0,0 +1,827 @@
|
||||
-- USE partsltd_prod;
|
||||
|
||||
-- Clear previous proc
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_product_price_and_discount_and_delivery_region;
|
||||
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE p_shop_get_many_product_price_and_discount_and_delivery_region (
|
||||
IN a_id_user INT,
|
||||
IN a_get_all_product_permutation BIT,
|
||||
IN a_get_inactive_permutation BIT,
|
||||
IN a_ids_permutation VARCHAR(4000),
|
||||
IN a_get_all_delivery_region BIT,
|
||||
IN a_get_inactive_delivery_region BIT,
|
||||
IN a_ids_delivery_region VARCHAR(4000),
|
||||
IN a_get_all_currency BIT,
|
||||
IN a_get_inactive_currency BIT,
|
||||
IN a_ids_currency VARCHAR(4000),
|
||||
IN a_get_all_discount BIT,
|
||||
IN a_get_inactive_discount BIT,
|
||||
IN a_ids_discount VARCHAR(4000)
|
||||
)
|
||||
BEGIN
|
||||
-- Argument redeclaration
|
||||
-- Variable declaration
|
||||
DECLARE v_has_filter_category BIT;
|
||||
DECLARE v_has_filter_product BIT;
|
||||
DECLARE v_has_filter_permutation BIT;
|
||||
DECLARE v_has_filter_image BIT;
|
||||
DECLARE v_has_filter_delivery_region BIT;
|
||||
DECLARE v_has_filter_currency BIT;
|
||||
DECLARE v_has_filter_discount BIT;
|
||||
DECLARE v_guid BINARY(36);
|
||||
# DECLARE v_id_user VARCHAR(100);
|
||||
DECLARE v_ids_permutation_unavailable VARCHAR(4000);
|
||||
DECLARE v_id_permission_product INT;
|
||||
DECLARE v_ids_product_permission VARCHAR(4000);
|
||||
-- DECLARE v_ids_permutation_permission VARCHAR(4000);
|
||||
DECLARE v_id_access_level_view INT;
|
||||
-- DECLARE v_now TIMESTAMP;
|
||||
DECLARE v_id_minimum INT;
|
||||
|
||||
SET v_guid := UUID();
|
||||
SET v_id_access_level_view := (SELECT id_access_level FROM Shop_Access_Level WHERE code = 'VIEW');
|
||||
|
||||
|
||||
-- Argument validation + default values
|
||||
SET a_id_user := TRIM(IFNULL(a_id_user, ''));
|
||||
SET a_get_all_product_permutation := TRIM(IFNULL(a_get_all_product_permutation, 1));
|
||||
SET a_get_inactive_permutation := TRIM(IFNULL(a_get_inactive_permutation, 0));
|
||||
SET a_ids_permutation := TRIM(IFNULL(a_ids_permutation, ''));
|
||||
SET a_get_all_delivery_region := TRIM(IFNULL(a_get_all_delivery_region, 1));
|
||||
SET a_get_inactive_delivery_region := TRIM(IFNULL(a_get_inactive_delivery_region, 0));
|
||||
SET a_ids_delivery_region := TRIM(IFNULL(a_ids_delivery_region, ''));
|
||||
SET a_get_all_currency := TRIM(IFNULL(a_get_all_currency, 1));
|
||||
SET a_get_inactive_currency := TRIM(IFNULL(a_get_inactive_currency, 0));
|
||||
SET a_ids_currency := TRIM(IFNULL(a_ids_currency, ''));
|
||||
SET a_get_all_discount := TRIM(IFNULL(a_get_all_discount, 1));
|
||||
SET a_get_inactive_discount := TRIM(IFNULL(a_get_inactive_discount, 0));
|
||||
SET a_ids_discount := TRIM(IFNULL(a_ids_discount, ''));
|
||||
|
||||
-- Temporary tables
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Discount;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Currency;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Delivery_Region;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product_2;
|
||||
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Shop_Product_Permutation (
|
||||
id_permutation INT NULL,
|
||||
active_permutation BIT NULL,
|
||||
display_order_permutation INT NULL,
|
||||
can_view BIT,
|
||||
can_edit BIT,
|
||||
can_admin BIT
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Delivery_Region (
|
||||
id_region INT NOT NULL,
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL,
|
||||
requires_delivery_option BIT NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Currency (
|
||||
id_currency INT NOT NULL,
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Discount (
|
||||
id_discount INT NOT NULL,
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE IF NOT EXISTS tmp_Msg_Error (
|
||||
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
guid BINARY(36) NOT NULL,
|
||||
id_type INT NOT NULL,
|
||||
code VARCHAR(50) NOT NULL,
|
||||
msg VARCHAR(4000) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
-- Parse filters
|
||||
SET v_has_filter_permutation = CASE WHEN a_ids_permutation = '' THEN 0 ELSE 1 END;
|
||||
SET v_has_filter_delivery_region = CASE WHEN a_ids_delivery_region = '' THEN 0 ELSE 1 END;
|
||||
SET v_has_filter_currency = CASE WHEN a_ids_currency = '' THEN 0 ELSE 1 END;
|
||||
SET v_has_filter_discount = CASE WHEN a_ids_discount = '' THEN 0 ELSE 1 END;
|
||||
|
||||
-- select v_has_filter_product, v_has_filter_permutation;
|
||||
|
||||
INSERT INTO tmp_Shop_Product (
|
||||
id_permutation,
|
||||
active_permutation,
|
||||
display_order_permutation
|
||||
)
|
||||
SELECT
|
||||
PP.id_permutation,
|
||||
PP.active AS active_permutation,
|
||||
PP.display_order AS display_order_permutation
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
# permutations
|
||||
(
|
||||
a_get_all_product_permutation
|
||||
OR (
|
||||
v_has_filter_permutation
|
||||
AND FIND_IN_SET(PP.id_permutation, a_ids_permutation) > 0
|
||||
)
|
||||
OR (
|
||||
a_get_products_quantity_stock_below_min = 1
|
||||
AND PP.quantity_stock < PP.quantity_min
|
||||
)
|
||||
)
|
||||
AND (
|
||||
a_get_inactive_permutation
|
||||
OR PP.active
|
||||
)
|
||||
;
|
||||
|
||||
# Delivery Regions
|
||||
INSERT INTO tmp_Delivery_Region (
|
||||
id_region,
|
||||
active,
|
||||
display_order,
|
||||
requires_delivery_option
|
||||
)
|
||||
WITH RECURSIVE Recursive_CTE_Delivery_Region AS (
|
||||
SELECT
|
||||
DR.id_region AS id_region_parent,
|
||||
NULL AS id_region_child,
|
||||
CASE WHEN FIND_IN_SET(DR.id_region, a_ids_delivery_region) > 0 THEN 1 ELSE 0 END AS requires_delivery_option
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
INNER JOIN Shop_Currency C ON PCRL.id_currency = C.id_currency
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON PCRL.id_product <=> t_P.id_product
|
||||
AND PCRL.id_permutation <=> t_P.id_permutation
|
||||
INNER JOIN Shop_Region DR ON PCRL.id_region_purchase = DR.id_region
|
||||
WHERE
|
||||
(
|
||||
a_get_all_delivery_region
|
||||
OR FIND_IN_SET(DR.id_region, a_ids_delivery_region) > 0
|
||||
)
|
||||
AND (
|
||||
a_get_inactive_delivery_region
|
||||
OR DR.active = 1
|
||||
)
|
||||
UNION
|
||||
SELECT
|
||||
DRB.id_region_parent,
|
||||
DRB.id_region_child,
|
||||
0 AS requires_delivery_option
|
||||
FROM Shop_Region_Branch DRB
|
||||
INNER JOIN Recursive_CTE_Delivery_Region r_DR
|
||||
ON DRB.id_region_parent = r_DR.id_region_child
|
||||
AND (
|
||||
a_get_inactive_delivery_region
|
||||
OR DRB.active = 1
|
||||
)
|
||||
)
|
||||
SELECT
|
||||
DR.id_region,
|
||||
DR.active,
|
||||
DR.display_order,
|
||||
requires_delivery_option
|
||||
FROM Shop_Region DR
|
||||
INNER JOIN Recursive_CTE_Delivery_Region r_DR
|
||||
ON DR.id_region = r_DR.id_region_parent
|
||||
OR DR.id_region = r_DR.id_region_child
|
||||
;
|
||||
/*
|
||||
select * from tmp_delivery_region;
|
||||
SELECT *
|
||||
FROM tmp_Shop_Product t_P
|
||||
WHERE
|
||||
/*(
|
||||
a_get_all_category
|
||||
OR a_get_all_product
|
||||
OR a_get_all_product_permutation
|
||||
)*
|
||||
FIND_IN_SET(t_P.id_category, a_ids_category) > 0
|
||||
OR FIND_IN_SET(t_P.id_product, a_ids_product) > 0
|
||||
OR FIND_IN_SET(t_P.id_permutation, a_ids_permutation) > 0
|
||||
;
|
||||
*/
|
||||
|
||||
IF v_has_filter_delivery_region THEN
|
||||
SET v_ids_permutation_unavailable = (
|
||||
SELECT GROUP_CONCAT(t_P.id_permutation SEPARATOR ', ')
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM tmp_Shop_Product t_P
|
||||
WHERE
|
||||
/*(
|
||||
a_get_all_category
|
||||
OR a_get_all_produc
|
||||
OR a_get_all_product_permutation
|
||||
)*/
|
||||
FIND_IN_SET(t_P.id_category, a_ids_category) > 0
|
||||
OR FIND_IN_SET(t_P.id_product, a_ids_product) > 0
|
||||
OR FIND_IN_SET(t_P.id_permutation, a_ids_permutation) > 0
|
||||
) t_P
|
||||
LEFT JOIN (
|
||||
SELECT *
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
WHERE
|
||||
(
|
||||
a_get_all_delivery_region
|
||||
OR FIND_IN_SET(PCRL.id_region_purchase, a_ids_delivery_region) > 0
|
||||
)
|
||||
) PCRL
|
||||
ON t_P.id_product <=> PCRL.id_product
|
||||
AND t_P.id_permutation <=> PCRL.id_permutation
|
||||
LEFT JOIN tmp_Delivery_Region t_DR
|
||||
ON PCRL.id_region_purchase = t_DR.id_region
|
||||
AND t_DR.requires_delivery_option = 1
|
||||
WHERE
|
||||
ISNULL(t_DR.id_region)
|
||||
);
|
||||
IF NOT ISNULL(v_ids_permutation_unavailable) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid,
|
||||
id_type,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
VALUES (
|
||||
v_guid,
|
||||
(SELECT id_type FROM Shop_Msg_Error_Type WHERE code = 'PRODUCT_AVAILABILITY' LIMIT 1),
|
||||
'PRODUCT_AVAILABILITY',
|
||||
CONCAT('Error: The following permutation IDs are not available in this region: ', IFNULL(v_ids_permutation_unavailable, 'NULL'))
|
||||
);
|
||||
END IF;
|
||||
/*
|
||||
DELETE FROM tmp_Shop_Product t_P
|
||||
WHERE t_P.id_permutation NOT IN (
|
||||
SELECT
|
||||
id_permutation
|
||||
FROM Shop_Product_Currency_Region_Link PCL
|
||||
INNER JOIN tmp_Delivery_Region t_DR
|
||||
ON PCRL.id_region_purchase = t_DR.id_region
|
||||
);
|
||||
*/
|
||||
END IF;
|
||||
|
||||
-- select * from tmp_Shop_Product;
|
||||
|
||||
# Currencies
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE guid = v_guid) THEN
|
||||
INSERT INTO tmp_Currency (
|
||||
id_currency,
|
||||
active,
|
||||
display_order
|
||||
)
|
||||
SELECT
|
||||
C.id_currency,
|
||||
C.active,
|
||||
C.display_order
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
INNER JOIN Shop_Currency C ON PCRL.id_currency = C.id_currency
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON PCRL.id_product <=> t_P.id_product
|
||||
AND PCRL.id_permutation <=> t_P.id_permutation
|
||||
INNER JOIN tmp_Delivery_Region t_DR ON PCRL.id_region_purchase = t_DR.id_region
|
||||
WHERE
|
||||
(
|
||||
a_get_all_currency
|
||||
OR FIND_IN_SET(C.id_currency, a_ids_currency) > 0
|
||||
)
|
||||
AND (
|
||||
a_get_inactive_currency
|
||||
OR (
|
||||
C.active
|
||||
AND PCRL.active
|
||||
)
|
||||
)
|
||||
;
|
||||
|
||||
-- select * from tmp_Currency;
|
||||
|
||||
IF v_has_filter_currency THEN
|
||||
SET v_ids_permutation_unavailable = (
|
||||
SELECT GROUP_CONCAT(t_P.id_permutation SEPARATOR ', ')
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM tmp_Shop_Product t_P
|
||||
WHERE
|
||||
/*(
|
||||
a_get_all_category
|
||||
OR a_get_all_product
|
||||
OR a_get_all_product_permutation
|
||||
)*/
|
||||
FIND_IN_SET(t_P.id_category, a_ids_category) > 0
|
||||
OR FIND_IN_SET(t_P.id_product, a_ids_product) > 0
|
||||
OR FIND_IN_SET(t_P.id_permutation, a_ids_permutation) > 0
|
||||
) t_P
|
||||
INNER JOIN (
|
||||
SELECT *
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
WHERE
|
||||
(
|
||||
a_get_all_currency
|
||||
OR FIND_IN_SET(PCRL.id_currency, a_ids_currency) > 0
|
||||
)
|
||||
) PCRL
|
||||
ON t_P.id_permutation = PCRL.id_permutation
|
||||
LEFT JOIN tmp_Currency t_C
|
||||
ON PCRL.id_currency = t_C.id_currency
|
||||
WHERE ISNULL(t_C.id_currency)
|
||||
);
|
||||
IF NOT ISNULL(v_ids_permutation_unavailable) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid,
|
||||
id_type,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
VALUES (
|
||||
v_guid,
|
||||
(SELECT id_type FROM Shop_Msg_Error_Type WHERE code = 'PRODUCT_AVAILABILITY' LIMIT 1),
|
||||
'PRODUCT_AVAILABILITY',
|
||||
CONCAT('Error: The following permutation IDs are not available in this currency: ', IFNULL(v_ids_permutation_unavailable, 'NULL'))
|
||||
);
|
||||
END IF;
|
||||
/*
|
||||
DELETE FROM tmp_Shop_Product t_P
|
||||
WHERE t_P.id_permutation NOT IN (
|
||||
SELECT
|
||||
id_permutation
|
||||
FROM Shop_Product_Currency_Region_Link PCL
|
||||
INNER JOIN tmp_Currency t_C
|
||||
ON PCRL.id_currency = t_C.id_currency
|
||||
);
|
||||
*/
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
# Discounts
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE guid = v_guid) THEN
|
||||
INSERT INTO tmp_Discount (
|
||||
id_discount,
|
||||
active,
|
||||
display_order
|
||||
)
|
||||
SELECT
|
||||
D.id_discount,
|
||||
D.active,
|
||||
D.display_order
|
||||
FROM Shop_Discount D
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON D.id_product = t_P.id_product
|
||||
AND D.id_permutation <=> t_P.id_permutation
|
||||
WHERE
|
||||
(
|
||||
a_get_all_discount
|
||||
OR FIND_IN_SET(D.id_discount, a_ids_discount) > 0
|
||||
)
|
||||
AND (
|
||||
a_get_inactive_discount
|
||||
OR D.active
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
# select 'pre-permission results';
|
||||
# select * from tmp_Shop_Product;
|
||||
|
||||
-- Permissions
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Product_Category LIMIT 1) THEN
|
||||
# SET v_id_user := (SELECT id_user FROM Shop_User WHERE name = CURRENT_USER());
|
||||
SET v_id_permission_product := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
|
||||
SET v_ids_product_permission := (SELECT GROUP_CONCAT(id_product SEPARATOR ',') FROM tmp_Shop_Product WHERE NOT ISNULL(id_product));
|
||||
-- SET v_ids_permutation_permission := (SELECT GROUP_CONCAT(id_permutation SEPARATOR ',') FROM tmp_Shop_Product WHERE NOT ISNULL(id_permutation));
|
||||
|
||||
-- SELECT v_guid, a_id_user, false, v_id_permission_product, v_id_access_level_view, v_ids_product_permission;
|
||||
-- select * from Shop_User_Eval_Temp;
|
||||
|
||||
CALL p_shop_user_eval(v_guid, a_id_user, false, v_id_permission_product, v_id_access_level_view, v_ids_product_permission);
|
||||
|
||||
-- select * from Shop_User_Eval_Temp;
|
||||
|
||||
UPDATE tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_User_Eval_Temp UE_T
|
||||
ON t_P.id_product = UE_T.id_product
|
||||
AND UE_T.GUID = v_guid
|
||||
SET t_P.can_view = UE_T.can_view,
|
||||
t_P.can_edit = UE_T.can_edit,
|
||||
t_P.can_admin = UE_T.can_admin
|
||||
;
|
||||
-- select * from Shop_User_Eval_Temp;
|
||||
-- select * from tmp_Shop_Product;
|
||||
|
||||
DELETE -- t_P
|
||||
FROM tmp_Shop_Product t_P
|
||||
WHERE
|
||||
FIND_IN_SET(t_P.id_product, (SELECT GROUP_CONCAT(UET.id_product SEPARATOR ',') FROM Shop_User_Eval_Temp UET)) = 0 # id_product NOT LIKE CONCAT('%', (SELECT GROUP_CONCAT(id_product SEPARATOR '|') FROM Shop_User_Eval_Temp), '%');
|
||||
OR (
|
||||
ISNULL(t_P.can_view)
|
||||
AND (
|
||||
NOT v_has_filter_category
|
||||
OR FIND_IN_SET(t_P.id_category, a_ids_category) = 0
|
||||
)
|
||||
AND (
|
||||
NOT v_has_filter_product
|
||||
OR FIND_IN_SET(t_P.id_product, a_ids_product) = 0
|
||||
)
|
||||
AND (
|
||||
NOT v_has_filter_permutation
|
||||
OR FIND_IN_SET(t_P.id_permutation, a_ids_permutation) = 0
|
||||
)
|
||||
)
|
||||
;
|
||||
|
||||
CALL p_clear_shop_user_eval_temp(v_guid);
|
||||
# DROP TABLE IF EXISTS Shop_User_Eval_Temp;
|
||||
/*
|
||||
DELETE FROM Shop_User_Eval_Temp UE_T
|
||||
WHERE UE_T.GUID = v_guid
|
||||
;
|
||||
*/
|
||||
END IF;
|
||||
|
||||
|
||||
-- select * from tmp_Shop_Product;
|
||||
|
||||
-- Returns
|
||||
-- SET v_now := NOW();
|
||||
|
||||
# Categories
|
||||
SELECT
|
||||
DISTINCT t_C.id_category,
|
||||
C.name,
|
||||
C.description,
|
||||
C.display_order
|
||||
FROM tmp_Shop_Product_Category t_C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON t_C.id_category = C.id_category
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON t_C.id_category = t_P.id_category
|
||||
ORDER BY C.display_order
|
||||
;
|
||||
|
||||
# Products
|
||||
SELECT
|
||||
t_P.id_product,
|
||||
t_P.id_permutation,
|
||||
t_P.name,
|
||||
t_P.description,
|
||||
P.has_variations,
|
||||
P.id_category,
|
||||
PP.cost_local,
|
||||
PP.id_currency_cost,
|
||||
CURRENCY.code AS code_currency_cost,
|
||||
CURRENCY.symbol AS symbol_currency_cost,
|
||||
PP.profit_local_min,
|
||||
t_P.latency_manufacture,
|
||||
t_P.quantity_min,
|
||||
t_P.quantity_max,
|
||||
t_P.quantity_step,
|
||||
t_P.quantity_stock,
|
||||
t_P.id_stripe_product,
|
||||
t_P.is_subscription,
|
||||
UM.name_singular AS name_recurrence_interval,
|
||||
UM.name_plural AS name_plural_recurrence_interval,
|
||||
PP.count_interval_recurrence,
|
||||
t_P.display_order_category,
|
||||
t_P.display_order_product,
|
||||
t_P.display_order_permutation,
|
||||
IFNULL(t_P.can_view, 0) AS can_view,
|
||||
IFNULL(t_P.can_edit, 0) AS can_edit,
|
||||
IFNULL(t_P.can_admin, 0) AS can_admin
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Product P ON t_P.id_product = P.id_product
|
||||
INNER JOIN Shop_Product_Permutation PP ON t_P.id_permutation = PP.id_permutation
|
||||
-- LEFT JOIN Shop_Recurrence_Interval RI ON t_P.id_interval_recurrence = RI.id_interval
|
||||
LEFT JOIN Shop_Unit_Measurement UM ON PP.id_interval_recurrence = UM.id_unit_measurement
|
||||
INNER JOIN Shop_Currency CURRENCY ON PP.id_currency_cost = CURRENCY.id_currency
|
||||
ORDER BY t_P.rank_permutation
|
||||
;
|
||||
|
||||
# Variations
|
||||
SELECT
|
||||
V.id_variation
|
||||
, V.code AS code_variation
|
||||
, V.name AS name_variation
|
||||
, V.active AS active_variation
|
||||
, V.display_order
|
||||
, V.id_type
|
||||
, VT.code AS code_variation_type
|
||||
, VT.name AS name_variation_type
|
||||
, VT.name_plural AS name_plural_variation_type
|
||||
, VT.active AS active_variation_type
|
||||
, VT.display_order
|
||||
, t_P.id_product
|
||||
, t_P.id_permutation
|
||||
, t_P.id_category
|
||||
FROM Shop_Variation V
|
||||
INNER JOIN Shop_Variation_Type VT ON V.id_type = VT.id_type
|
||||
INNER JOIN Shop_Product_Permutation_Variation_Link PPVL ON V.id_variation = PPVL.id_variation
|
||||
INNER JOIN tmp_Shop_Product t_P ON PPVL.id_permutation <=> t_P.id_permutation
|
||||
WHERE V.active
|
||||
AND PPVL.active
|
||||
;
|
||||
|
||||
/*
|
||||
# Permutation variations output
|
||||
SELECT t_P.id_permutation,
|
||||
t_P.id_product,
|
||||
t_P.id_category,
|
||||
id_variation
|
||||
FROM Shop_Product_Permutation_Variation_Link PPVL
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON t_P.id_permutation = PPVL.id_permutation
|
||||
ORDER BY t_P.display_order
|
||||
;
|
||||
*/
|
||||
-- select * from Shop_Product_Currency_Region_Link;
|
||||
-- select * from shop_currency;
|
||||
/*
|
||||
select * from tmp_Currency;
|
||||
select * from tmp_delivery_region;
|
||||
select * from tmp_shop_product;
|
||||
*/
|
||||
|
||||
# Product Price
|
||||
SELECT
|
||||
PCRL.id_link AS id_price,
|
||||
t_P.id_permutation,
|
||||
t_P.id_product,
|
||||
t_P.id_category,
|
||||
t_C.id_currency,
|
||||
C.code AS code_currency,
|
||||
C.name AS name_currency,
|
||||
C.symbol AS symbol_currency,
|
||||
t_DR.id_region,
|
||||
PCRL.price_local_VAT_incl,
|
||||
PCRL.price_local_VAT_excl,
|
||||
ROW_NUMBER() OVER(ORDER BY t_P.rank_permutation, C.display_order) AS display_order
|
||||
FROM Shop_Product_Currency_Region_Link PCRL
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON PCRL.id_product <=> t_P.id_product
|
||||
AND PCRL.id_permutation <=> t_P.id_permutation
|
||||
-- INNER JOIN Shop_Product P ON PCRL.id_product = P.id_product
|
||||
INNER JOIN tmp_Currency t_C ON PCRL.id_currency = t_C.id_currency
|
||||
INNER JOIN Shop_Currency C ON t_C.id_currency = C.id_currency
|
||||
INNER JOIN tmp_Delivery_Region t_DR ON PCRL.id_region_purchase = t_DR.id_region
|
||||
WHERE (
|
||||
a_get_inactive_product
|
||||
AND a_get_inactive_permutation
|
||||
AND a_get_inactive_currency
|
||||
AND a_get_inactive_delivery_region
|
||||
OR PCRL.active
|
||||
)
|
||||
ORDER BY t_P.rank_permutation
|
||||
;
|
||||
|
||||
/*
|
||||
# Currency
|
||||
SELECT
|
||||
DISTINCT C.id_currency,
|
||||
C.code,
|
||||
C.name,
|
||||
C.factor_from_GBP,
|
||||
t_C.display_order
|
||||
FROM Shop_Currency C
|
||||
INNER JOIN tmp_Currency t_C ON C.id_currency = t_C.id_currency
|
||||
GROUP BY C.id_currency, t_C.display_order
|
||||
ORDER BY t_C.display_order
|
||||
;
|
||||
*/
|
||||
|
||||
# Images
|
||||
SELECT
|
||||
t_I.id_image,
|
||||
t_I.id_product,
|
||||
t_I.id_permutation,
|
||||
t_P.id_category,
|
||||
I.url,
|
||||
I.active,
|
||||
I.display_order
|
||||
FROM tmp_Shop_Image t_I
|
||||
INNER JOIN Shop_Product_Image I
|
||||
ON t_I.id_image = I.id_image
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON t_I.id_product = t_P.id_product
|
||||
AND t_I.id_permutation <=> t_P.id_permutation
|
||||
ORDER BY t_P.rank_permutation, I.display_order
|
||||
;
|
||||
|
||||
# Delivery options
|
||||
SELECT
|
||||
_DO.id_option,
|
||||
PDOL.id_product,
|
||||
PDOL.id_permutation,
|
||||
t_P.id_category,
|
||||
_DO.code,
|
||||
_DO.name,
|
||||
_DO.latency_delivery_min,
|
||||
_DO.latency_delivery_max,
|
||||
_DO.quantity_min,
|
||||
_DO.quantity_max,
|
||||
GROUP_CONCAT(DR.code SEPARATOR ',') AS codes_region,
|
||||
GROUP_CONCAT(DR.name SEPARATOR ',') AS names_region,
|
||||
PDOL.price_local,
|
||||
PDOL.display_order
|
||||
FROM Shop_Delivery_Option _DO
|
||||
INNER JOIN Shop_Product_Delivery_Option_Link PDOL
|
||||
ON _DO.id_option = PDOL.id_delivery_option
|
||||
AND (
|
||||
a_get_inactive_delivery_region
|
||||
OR PDOL.active
|
||||
)
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON PDOL.id_product = t_P.id_product
|
||||
AND PDOL.id_permutation <=> t_P.id_permutation
|
||||
INNER JOIN tmp_Delivery_Region t_DR ON PDOL.id_region = t_DR.id_region
|
||||
INNER JOIN Shop_Region DR ON t_DR.id_region = DR.id_region
|
||||
WHERE (
|
||||
a_get_inactive_delivery_region
|
||||
OR _DO.active
|
||||
)
|
||||
GROUP BY t_P.id_category, t_P.id_product, PDOL.id_permutation, t_P.rank_permutation, DR.id_region, _DO.id_option, PDOL.id_link
|
||||
ORDER BY t_P.rank_permutation, PDOL.display_order
|
||||
;
|
||||
|
||||
# Discounts
|
||||
SELECT
|
||||
D.id_discount,
|
||||
P.id_category,
|
||||
D.id_product,
|
||||
D.id_permutation,
|
||||
DR.id_region,
|
||||
C.id_currency,
|
||||
D.code AS code_discount,
|
||||
D.name AS name_discount,
|
||||
D.multiplier,
|
||||
D.subtractor,
|
||||
D.apply_multiplier_first,
|
||||
D.quantity_min,
|
||||
D.quantity_max,
|
||||
D.date_start,
|
||||
D.date_end,
|
||||
GROUP_CONCAT(DR.code) AS codes_region,
|
||||
GROUP_CONCAT(DR.name) AS names_region,
|
||||
GROUP_CONCAT(C.code) AS codes_currency,
|
||||
GROUP_CONCAT(C.name) AS names_currency,
|
||||
ROW_NUMBER() OVER(ORDER BY D.display_order) AS display_order
|
||||
FROM tmp_Discount t_D
|
||||
INNER JOIN Shop_Discount D ON t_D.id_discount = D.id_discount
|
||||
INNER JOIN Shop_Product P ON D.id_product = P.id_product
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON D.id_product = t_P.id_product
|
||||
-- AND D.id_permutation <=> t_P.id_permutation
|
||||
INNER JOIN Shop_Discount_Region_Currency_Link DRCL
|
||||
ON D.id_discount = DRCL.id_discount
|
||||
INNER JOIN tmp_Delivery_Region t_DR ON DRCL.id_region = t_DR.id_region
|
||||
INNER JOIN Shop_Region DR ON t_DR.id_region = DR.id_region
|
||||
INNER JOIN tmp_Currency t_C ON DRCL.id_currency = t_C.id_currency
|
||||
INNER JOIN Shop_Currency C ON t_C.id_currency = C.id_currency
|
||||
GROUP BY D.id_discount, DR.id_region, C.id_currency
|
||||
ORDER BY D.display_order, DR.display_order, C.display_order
|
||||
;
|
||||
|
||||
/*
|
||||
# Delivery Regions
|
||||
SELECT
|
||||
t_DR.id_region,
|
||||
t_P.id_category,
|
||||
t_P.id_product,
|
||||
t_P.id_permutation,
|
||||
DR.code,
|
||||
DR.name
|
||||
FROM tmp_Delivery_Region t_DR
|
||||
INNER JOIN Shop_Delivery_Region DR ON t_DR.id_region = DR.id_region
|
||||
INNER JOIN Shop_Product_Region_Currency_Link PDRL
|
||||
ON DR.id_region = PDRL.id_region
|
||||
AND (
|
||||
a_get_inactive_delivery_region
|
||||
OR PDRL.active
|
||||
)
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON PDRL.id_product = t_P.id_product
|
||||
AND PDRL.id_permutation <=> t_P.id_permutation
|
||||
INNER JOIN tmp_Currency t_C ON PDRL.id_currency = t_C.id_currency
|
||||
ORDER BY t_DR.display_order
|
||||
;
|
||||
*/
|
||||
|
||||
# Errors
|
||||
SELECT
|
||||
t_ME.display_order,
|
||||
t_ME.guid,
|
||||
t_ME.id_type,
|
||||
t_ME.msg,
|
||||
MET.code,
|
||||
MET.name,
|
||||
MET.description
|
||||
FROM tmp_Msg_Error t_ME
|
||||
INNER JOIN Shop_Msg_Error_Type MET
|
||||
ON t_ME.id_type = MET.id_type
|
||||
WHERE guid = v_guid
|
||||
;
|
||||
|
||||
/*
|
||||
# Return arguments for test
|
||||
SELECT
|
||||
a_ids_category,
|
||||
a_get_inactive_category,
|
||||
a_ids_product,
|
||||
a_get_inactive_product,
|
||||
a_get_first_product_only,
|
||||
a_get_all_product,
|
||||
a_ids_image,
|
||||
a_get_inactive_image,
|
||||
a_get_first_image_only,
|
||||
a_get_all_image
|
||||
;
|
||||
*/
|
||||
|
||||
# select 'other outputs';
|
||||
# select * from tmp_Shop_Product;
|
||||
|
||||
-- Clean up
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Discount;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Currency;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Delivery_Region;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Product;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product_2;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
|
||||
END //
|
||||
DELIMITER ;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
CALL partsltd_prod.p_shop_get_many_product (
|
||||
1, #'auth0|6582b95c895d09a70ba10fef', # a_id_user
|
||||
1, # a_get_all_category
|
||||
1, # a_get_inactive_category
|
||||
0, # a_get_first_category_only
|
||||
'', # a_ids_category
|
||||
1, # a_get_all_product
|
||||
0, # a_get_inactive_product
|
||||
0, # a_get_first_product_only
|
||||
'', # a_ids_product
|
||||
1, # a_get_all_product_permutation
|
||||
0, # a_get_inactive_permutation
|
||||
0, # a_get_first_permutation_only
|
||||
'', # a_ids_permutation
|
||||
1, # a_get_all_image
|
||||
0, # a_get_inactive_image
|
||||
0, # a_get_first_image_only
|
||||
'', # a_ids_image
|
||||
1, # a_get_all_delivery_region
|
||||
0, # a_get_inactive_delivery_region
|
||||
0, # a_get_first_delivery_region_only
|
||||
'', # a_ids_delivery_region
|
||||
1, # a_get_all_currency
|
||||
0, # a_get_inactive_currency
|
||||
0, # a_get_first_currency_only
|
||||
'', # a_ids_currency
|
||||
1, # a_get_all_discount
|
||||
0, # a_get_inactive_discount
|
||||
'', # a_ids_discount
|
||||
1 # a_get_products_quantity_stock_below_minimum
|
||||
);
|
||||
|
||||
select * FROM Shop_User_Eval_Temp;
|
||||
|
||||
select * from Shop_Product_Permutation;
|
||||
select * from shop_product_change_set;
|
||||
insert into shop_product_change_set ( comment ) values ('set stock quantities below minimum for testing');
|
||||
update shop_product_permutation
|
||||
set quantity_stock = 0,
|
||||
id_change_set = (select id_change_set from shop_product_change_set order by id_change_set desc limit 1)
|
||||
where id_permutation < 5
|
||||
|
||||
DROP TABLE IF EXISTS tmp_Msg_Error;
|
||||
|
||||
select * from shop_image;
|
||||
select * from shop_product;
|
||||
select * from TMP_MSG_ERROR;
|
||||
DROP TABLE TMP_MSG_ERROR;
|
||||
|
||||
insert into shop_product_change_set (comment)
|
||||
values ('set product not subscription - test bool output to python');
|
||||
update shop_product
|
||||
set is_subscription = 0,
|
||||
id_change_set = (select id_change_set from shop_product_change_set order by id_change_set desc limit 1)
|
||||
where id_product = 1
|
||||
|
||||
select * FROM Shop_User_Eval_Temp;
|
||||
select distinct guid
|
||||
-- DELETE
|
||||
FROM Shop_User_Eval_Temp;
|
||||
*/
|
||||
@@ -149,12 +149,6 @@ BEGIN
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
|
||||
/*
|
||||
DELETE FROM Shop_User_Eval_Temp
|
||||
WHERE GUID = v_guid;
|
||||
*/
|
||||
CALL p_clear_shop_user_eval_temp(v_guid);
|
||||
END IF;
|
||||
|
||||
|
||||
@@ -236,6 +230,12 @@ BEGIN
|
||||
-- Clean up
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_User;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Msg_Error;
|
||||
|
||||
/*
|
||||
DELETE FROM Shop_User_Eval_Temp
|
||||
WHERE GUID = v_guid;
|
||||
*/
|
||||
CALL p_clear_shop_user_eval_temp(v_guid);
|
||||
END //
|
||||
DELIMITER ;
|
||||
|
||||
@@ -253,4 +253,18 @@ CALL p_get_many_user (
|
||||
);
|
||||
select * from shop_user_eval_temp;
|
||||
delete from shop_user_eval_temp;
|
||||
|
||||
SELECT *
|
||||
FROM SHOP_USER;
|
||||
|
||||
CALL p_get_many_user(
|
||||
NULL -- :a_id_user,
|
||||
, 'auth0|6582b95c895d09a70ba10fef' -- :a_id_user_auth0,
|
||||
, 1 -- :a_get_all_user,
|
||||
, 0 -- :a_get_inactive_user,
|
||||
, 0 -- :a_get_first_user_only,
|
||||
, NULL -- :a_ids_user,
|
||||
, 'auth0|6582b95c895d09a70ba10fef' -- :a_ids_user_auth0
|
||||
);
|
||||
|
||||
*/
|
||||
|
||||
@@ -112,7 +112,7 @@ BEGIN
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Basket_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Basket_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -302,7 +302,7 @@ BEGIN
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
AND C.active
|
||||
WHERE UB.id_user = a_id_user
|
||||
@@ -451,7 +451,7 @@ BEGIN
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
AND C.active
|
||||
-- RIGHT JOIN tmp_Shop_Basket t_UB ON ISNULL(t_UB.id_product)
|
||||
@@ -462,7 +462,7 @@ BEGIN
|
||||
IF EXISTS(
|
||||
SELECT *
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
INNER JOIN tmp_Shop_Basket t_B
|
||||
ON P.id_product = t_B.id_product
|
||||
@@ -498,7 +498,7 @@ BEGIN
|
||||
FROM Shop_Product_Permutation PP
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
(
|
||||
@@ -713,7 +713,7 @@ BEGIN
|
||||
ON t_UB.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Currency_Link PCL
|
||||
ON PP.id_permutation = PCL.id_permutation
|
||||
|
||||
@@ -173,7 +173,7 @@ BEGIN
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -293,7 +293,7 @@ BEGIN
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE guid = v_guid LIMIT 1) THEN
|
||||
CALL p_split(a_ids_category, ',');
|
||||
|
||||
IF EXISTS (SELECT * FROM Split_Temp TS LEFT JOIN Shop_Category C ON TS.substring = C.id_category WHERE ISNULL(C.id_category)) THEN
|
||||
IF EXISTS (SELECT * FROM Split_Temp TS LEFT JOIN Shop_Product_Category C ON TS.substring = C.id_category WHERE ISNULL(C.id_category)) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid,
|
||||
id_type,
|
||||
@@ -306,7 +306,7 @@ BEGIN
|
||||
v_code_error_data,
|
||||
CONCAT('Invalid category IDs: ', IFNULL(GROUP_CONCAT(TS.substring SEPARATOR ', ') ,'NULL'))
|
||||
FROM Split_Temp TS
|
||||
LEFT JOIN Shop_Category C ON TS.substring = C.id_category
|
||||
LEFT JOIN Shop_Product_Category C ON TS.substring = C.id_category
|
||||
WHERE ISNULL(C.id_category)
|
||||
;
|
||||
END IF;
|
||||
@@ -434,7 +434,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
# permutations
|
||||
@@ -512,7 +512,7 @@ BEGIN
|
||||
INNER JOIN Shop_Supplier S ON SPO.id_supplier_ordered = S.id_supplier
|
||||
INNER JOIN Shop_Product_Permutation PP ON SPOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
LEFT JOIN tmp_Shop_Product t_P ON SPOPL.id_permutation = t_P.id_permutation
|
||||
LEFT JOIN tmp_Shop_Supplier t_S ON SPO.id_supplier_ordered = t_S.id_supplier
|
||||
WHERE
|
||||
@@ -675,7 +675,7 @@ BEGIN
|
||||
INNER JOIN tmp_Shop_Supplier_Purchase_Order t_SPO ON SPOPL.id_order = t_SPO.id_order
|
||||
INNER JOIN Shop_Product_Permutation PP ON SPOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
ORDER BY SPOPL.id_order, C.display_order, P.display_order, PP.display_order
|
||||
;
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ BEGIN
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -213,7 +213,7 @@ BEGIN
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE guid = v_guid LIMIT 1) THEN
|
||||
CALL p_split(a_ids_category, ',');
|
||||
|
||||
IF EXISTS (SELECT * FROM Split_Temp TS LEFT JOIN Shop_Category C ON TS.substring = C.id_category WHERE ISNULL(C.id_category)) THEN
|
||||
IF EXISTS (SELECT * FROM Split_Temp TS LEFT JOIN Shop_Product_Category C ON TS.substring = C.id_category WHERE ISNULL(C.id_category)) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid,
|
||||
id_type,
|
||||
@@ -226,7 +226,7 @@ BEGIN
|
||||
v_code_error_data,
|
||||
CONCAT('Invalid category IDs: ', IFNULL(GROUP_CONCAT(TS.substring SEPARATOR ', ') ,'NULL'))
|
||||
FROM Split_Temp TS
|
||||
LEFT JOIN Shop_Category C ON TS.substring = C.id_category
|
||||
LEFT JOIN Shop_Product_Category C ON TS.substring = C.id_category
|
||||
WHERE ISNULL(C.id_category)
|
||||
;
|
||||
END IF;
|
||||
@@ -354,7 +354,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
# permutations
|
||||
@@ -431,7 +431,7 @@ BEGIN
|
||||
INNER JOIN Shop_manufacturing_Purchase_Order_Product_Link MPOPL ON MPO.id_order = MPOPL.id_order
|
||||
INNER JOIN Shop_Product_Permutation PP ON MPOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
LEFT JOIN tmp_Shop_Product t_P ON MPOPL.id_permutation = t_P.id_permutation
|
||||
WHERE
|
||||
# order
|
||||
@@ -571,7 +571,7 @@ BEGIN
|
||||
INNER JOIN tmp_Shop_Manufacturing_Purchase_Order t_MPO ON MPOPL.id_order = t_MPO.id_order
|
||||
INNER JOIN Shop_Product_Permutation PP ON MPOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
ORDER BY MPOPL.id_order, C.display_order, P.display_order, PP.display_order
|
||||
;
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ BEGIN
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -303,7 +303,7 @@ BEGIN
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE guid = v_guid LIMIT 1) THEN
|
||||
CALL p_split(a_ids_category, ',');
|
||||
|
||||
IF EXISTS (SELECT * FROM Split_Temp TS LEFT JOIN Shop_Category C ON TS.substring = C.id_category WHERE ISNULL(C.id_category)) THEN
|
||||
IF EXISTS (SELECT * FROM Split_Temp TS LEFT JOIN Shop_Product_Category C ON TS.substring = C.id_category WHERE ISNULL(C.id_category)) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid,
|
||||
id_type,
|
||||
@@ -316,7 +316,7 @@ BEGIN
|
||||
v_code_error_data,
|
||||
CONCAT('Invalid category IDs: ', IFNULL(GROUP_CONCAT(TS.substring SEPARATOR ', ') ,'NULL'))
|
||||
FROM Split_Temp TS
|
||||
LEFT JOIN Shop_Category C ON TS.substring = C.id_category
|
||||
LEFT JOIN Shop_Product_Category C ON TS.substring = C.id_category
|
||||
WHERE ISNULL(C.id_category)
|
||||
;
|
||||
END IF;
|
||||
@@ -444,7 +444,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
# permutations
|
||||
@@ -522,7 +522,7 @@ BEGIN
|
||||
INNER JOIN Shop_Customer S ON CSO.id_customer = S.id_customer
|
||||
INNER JOIN Shop_Product_Permutation PP ON CSOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
LEFT JOIN tmp_Shop_Product t_P ON CSOPL.id_permutation = t_P.id_permutation
|
||||
LEFT JOIN tmp_Shop_Customer t_S ON CSO.id_customer = t_S.id_customer
|
||||
WHERE
|
||||
@@ -686,7 +686,7 @@ BEGIN
|
||||
INNER JOIN tmp_Shop_Customer_Sales_Order t_CSO ON CSOPL.id_order = t_CSO.id_order
|
||||
INNER JOIN Shop_Product_Permutation PP ON CSOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
ORDER BY CSOPL.id_order, C.display_order, P.display_order, PP.display_order
|
||||
;
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ VALUES
|
||||
|
||||
|
||||
# Categories
|
||||
INSERT INTO Shop_Category (
|
||||
INSERT INTO Shop_Product_Category (
|
||||
display_order,
|
||||
code,
|
||||
name,
|
||||
|
||||
@@ -74,8 +74,8 @@ SELECT * FROM Shop_Recurrence_Interval_Audit;
|
||||
|
||||
|
||||
# Categories
|
||||
SELECT * FROM Shop_Category;
|
||||
SELECT * FROM Shop_Category_Audit;
|
||||
SELECT * FROM Shop_Product_Category;
|
||||
SELECT * FROM Shop_Product_Category_Audit;
|
||||
|
||||
# Products
|
||||
SELECT * FROM Shop_Product;
|
||||
|
||||
@@ -39,8 +39,8 @@ DROP TABLE IF EXISTS Shop_Product;
|
||||
DROP TABLE IF EXISTS Shop_Recurrence_Interval_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Recurrence_Interval;
|
||||
|
||||
DROP TABLE IF EXISTS Shop_Category_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Category;
|
||||
DROP TABLE IF EXISTS Shop_Product_Category_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Product_Category;
|
||||
|
||||
DROP TABLE IF EXISTS Shop_General_Audit;
|
||||
DROP TABLE IF EXISTS Shop_General;
|
||||
@@ -247,7 +247,7 @@ SELECT * FROM Shop_General_Audit;
|
||||
|
||||
|
||||
# Categories
|
||||
CREATE TABLE Shop_Category (
|
||||
CREATE TABLE Shop_Product_Category (
|
||||
id_category INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(255),
|
||||
@@ -257,14 +257,14 @@ CREATE TABLE Shop_Category (
|
||||
created_on TIMESTAMP,
|
||||
created_by VARCHAR(100),
|
||||
id_change_set INT,
|
||||
CONSTRAINT FK_Shop_Category_id_change_set
|
||||
CONSTRAINT FK_Shop_Product_Category_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
|
||||
DELIMITER //
|
||||
CREATE TRIGGER before_insert_Shop_Category
|
||||
BEFORE INSERT ON Shop_Category
|
||||
CREATE TRIGGER before_insert_Shop_Product_Category
|
||||
BEFORE INSERT ON Shop_Product_Category
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.created_on = NOW();
|
||||
@@ -272,28 +272,28 @@ BEGIN
|
||||
END //
|
||||
DELIMITER ;
|
||||
|
||||
CREATE TABLE Shop_Category_Audit (
|
||||
CREATE TABLE Shop_Product_Category_Audit (
|
||||
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_Shop_Category_Audit_id_category
|
||||
CONSTRAINT FK_Shop_Product_Category_Audit_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category)
|
||||
REFERENCES Shop_Product_Category(id_category)
|
||||
ON UPDATE RESTRICT,
|
||||
name_field VARCHAR(50),
|
||||
value_prev VARCHAR(500),
|
||||
value_new VARCHAR(500),
|
||||
id_change_set INT NOT NULL,
|
||||
CONSTRAINT FK_Shop_Category_Audit_id_change_set
|
||||
CONSTRAINT FK_Shop_Product_Category_Audit_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
|
||||
DELIMITER //
|
||||
CREATE TRIGGER before_update_Shop_Category
|
||||
BEFORE UPDATE ON Shop_Category
|
||||
CREATE TRIGGER before_update_Shop_Product_Category
|
||||
BEFORE UPDATE ON Shop_Product_Category
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO Shop_Category_Audit (
|
||||
INSERT INTO Shop_Product_Category_Audit (
|
||||
id_category,
|
||||
name_field,
|
||||
value_prev,
|
||||
@@ -323,7 +323,7 @@ BEGIN
|
||||
END //
|
||||
DELIMITER ;
|
||||
|
||||
INSERT INTO Shop_Category (
|
||||
INSERT INTO Shop_Product_Category (
|
||||
display_order,
|
||||
code,
|
||||
name,
|
||||
@@ -336,8 +336,8 @@ VALUES (
|
||||
'Not category allocated products'
|
||||
);
|
||||
|
||||
SELECT * FROM Shop_Category;
|
||||
SELECT * FROM Shop_Category_Audit;
|
||||
SELECT * FROM Shop_Product_Category;
|
||||
SELECT * FROM Shop_Product_Category_Audit;
|
||||
|
||||
|
||||
|
||||
@@ -431,7 +431,7 @@ CREATE TABLE Shop_Product (
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category)
|
||||
REFERENCES Shop_Product_Category(id_category)
|
||||
ON UPDATE RESTRICT,
|
||||
latency_manuf INT NOT NULL DEFAULT 14,
|
||||
quantity_min FLOAT NOT NULL DEFAULT 1,
|
||||
|
||||
@@ -26,7 +26,7 @@ DROP PROCEDURE IF EXISTS p_shop_get_many_role_permission;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
*/
|
||||
|
||||
DELIMITER //
|
||||
@@ -123,7 +123,7 @@ BEGIN
|
||||
|
||||
|
||||
-- Clean up
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
END //
|
||||
|
||||
@@ -79,7 +79,7 @@ BEGIN
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
display_order INT,
|
||||
can_view BIT,
|
||||
can_edit BIT,
|
||||
@@ -288,7 +288,7 @@ BEGIN
|
||||
C.description,
|
||||
C.display_order
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON t_P.id_category = C.id_category
|
||||
ORDER BY C.display_order
|
||||
;
|
||||
|
||||
@@ -476,8 +476,8 @@ CREATE TABLE `shop_category` (
|
||||
`created_by` varchar(100) DEFAULT NULL,
|
||||
`id_change_set` int DEFAULT NULL,
|
||||
PRIMARY KEY (`id_category`),
|
||||
KEY `FK_Shop_Category_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Category_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`)
|
||||
KEY `FK_Shop_Product_Category_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Product_Category_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
@@ -499,7 +499,7 @@ UNLOCK TABLES;
|
||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
DELIMITER ;;
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `before_insert_Shop_Category` BEFORE INSERT ON `shop_category` FOR EACH ROW BEGIN
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `before_insert_Shop_Product_Category` BEFORE INSERT ON `shop_category` FOR EACH ROW BEGIN
|
||||
SET NEW.created_on = NOW();
|
||||
SET NEW.created_by = CURRENT_USER();
|
||||
END */;;
|
||||
@@ -517,13 +517,13 @@ DELIMITER ;
|
||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
DELIMITER ;;
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `before_update_Shop_Category` BEFORE UPDATE ON `shop_category` FOR EACH ROW BEGIN
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `before_update_Shop_Product_Category` BEFORE UPDATE ON `shop_category` FOR EACH ROW BEGIN
|
||||
IF OLD.id_change_set <=> NEW.id_change_set THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'New change Set ID must be provided.';
|
||||
END IF;
|
||||
|
||||
INSERT INTO Shop_Category_Audit (
|
||||
INSERT INTO Shop_Product_Category_Audit (
|
||||
id_category,
|
||||
name_field,
|
||||
value_prev,
|
||||
@@ -572,10 +572,10 @@ CREATE TABLE `shop_category_audit` (
|
||||
`value_new` varchar(500) DEFAULT NULL,
|
||||
`id_change_set` int NOT NULL,
|
||||
PRIMARY KEY (`id_audit`),
|
||||
KEY `FK_Shop_Category_Audit_id_category` (`id_category`),
|
||||
KEY `FK_Shop_Category_Audit_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Category_Audit_id_category` FOREIGN KEY (`id_category`) REFERENCES `shop_category` (`id_category`) ON UPDATE RESTRICT,
|
||||
CONSTRAINT `FK_Shop_Category_Audit_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`)
|
||||
KEY `FK_Shop_Product_Category_Audit_id_category` (`id_category`),
|
||||
KEY `FK_Shop_Product_Category_Audit_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Product_Category_Audit_id_category` FOREIGN KEY (`id_category`) REFERENCES `shop_category` (`id_category`) ON UPDATE RESTRICT,
|
||||
CONSTRAINT `FK_Shop_Product_Category_Audit_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
@@ -5202,7 +5202,7 @@ BEGIN
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Basket_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Basket_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -5392,7 +5392,7 @@ BEGIN
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
AND C.active
|
||||
WHERE UB.id_user = a_id_user
|
||||
@@ -5541,7 +5541,7 @@ BEGIN
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
AND C.active
|
||||
-- RIGHT JOIN tmp_Shop_Basket t_UB ON ISNULL(t_UB.id_product)
|
||||
@@ -5552,7 +5552,7 @@ BEGIN
|
||||
IF EXISTS(
|
||||
SELECT *
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
INNER JOIN tmp_Shop_Basket t_B
|
||||
ON P.id_product = t_B.id_product
|
||||
@@ -5588,7 +5588,7 @@ BEGIN
|
||||
FROM Shop_Product_Permutation PP
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
(
|
||||
@@ -5803,7 +5803,7 @@ BEGIN
|
||||
ON t_UB.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Currency_Link PCL
|
||||
ON PP.id_permutation = PCL.id_permutation
|
||||
@@ -6069,13 +6069,13 @@ BEGIN
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
|
||||
CREATE TABLE tmp_Shop_Category (
|
||||
CREATE TABLE tmp_Shop_Product_Category (
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Category_id_category
|
||||
CONSTRAINT FK_tmp_Shop_Product_Category_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL,
|
||||
can_view BIT,
|
||||
@@ -6087,7 +6087,7 @@ BEGIN
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -6267,7 +6267,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
# permutations
|
||||
@@ -6304,7 +6304,7 @@ BEGIN
|
||||
;
|
||||
END IF;
|
||||
|
||||
INSERT INTO tmp_Shop_Category (
|
||||
INSERT INTO tmp_Shop_Product_Category (
|
||||
id_category,
|
||||
active,
|
||||
display_order
|
||||
@@ -6313,7 +6313,7 @@ BEGIN
|
||||
C.active,
|
||||
C.display_order
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON t_P.id_category = C.id_category
|
||||
ORDER BY C.display_order
|
||||
;
|
||||
@@ -6381,7 +6381,7 @@ BEGIN
|
||||
IF v_has_filter_image THEN
|
||||
DELETE FROM tmp_Shop_Product
|
||||
WHERE id_product NOT IN (SELECT DISTINCT id_product FROM tmp_Shop_Image);
|
||||
DELETE FROM tmp_Shop_Category
|
||||
DELETE FROM tmp_Shop_Product_Category
|
||||
WHERE id_category NOT IN (SELECT DISTINCT id_category FROM tmp_Shop_Product);
|
||||
END IF;
|
||||
*/
|
||||
@@ -6629,7 +6629,7 @@ BEGIN
|
||||
# select * from tmp_Shop_Product;
|
||||
|
||||
-- Permissions
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Category LIMIT 1) THEN
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Product_Category LIMIT 1) THEN
|
||||
# SET v_id_user := (SELECT id_user FROM Shop_User WHERE name = CURRENT_USER());
|
||||
SET v_id_permission_product := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
|
||||
-- SET v_ids_product_permission := (SELECT GROUP_CONCAT(id_product SEPARATOR ',') FROM tmp_Shop_Product);
|
||||
@@ -6689,8 +6689,8 @@ BEGIN
|
||||
C.name,
|
||||
C.description,
|
||||
C.display_order
|
||||
FROM tmp_Shop_Category t_C
|
||||
INNER JOIN Shop_Category C
|
||||
FROM tmp_Shop_Product_Category t_C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON t_C.id_category = C.id_category
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON t_C.id_category = t_P.id_category
|
||||
@@ -6974,7 +6974,7 @@ BEGIN
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
END ;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
|
||||
@@ -476,8 +476,8 @@ CREATE TABLE `shop_category` (
|
||||
`created_by` varchar(100) DEFAULT NULL,
|
||||
`id_change_set` int DEFAULT NULL,
|
||||
PRIMARY KEY (`id_category`),
|
||||
KEY `FK_Shop_Category_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Category_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`)
|
||||
KEY `FK_Shop_Product_Category_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Product_Category_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
@@ -499,7 +499,7 @@ UNLOCK TABLES;
|
||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
DELIMITER ;;
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `before_insert_Shop_Category` BEFORE INSERT ON `shop_category` FOR EACH ROW BEGIN
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `before_insert_Shop_Product_Category` BEFORE INSERT ON `shop_category` FOR EACH ROW BEGIN
|
||||
SET NEW.created_on = NOW();
|
||||
SET NEW.created_by = CURRENT_USER();
|
||||
END */;;
|
||||
@@ -517,13 +517,13 @@ DELIMITER ;
|
||||
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
|
||||
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
|
||||
DELIMITER ;;
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `before_update_Shop_Category` BEFORE UPDATE ON `shop_category` FOR EACH ROW BEGIN
|
||||
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `before_update_Shop_Product_Category` BEFORE UPDATE ON `shop_category` FOR EACH ROW BEGIN
|
||||
IF OLD.id_change_set <=> NEW.id_change_set THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = 'New change Set ID must be provided.';
|
||||
END IF;
|
||||
|
||||
INSERT INTO Shop_Category_Audit (
|
||||
INSERT INTO Shop_Product_Category_Audit (
|
||||
id_category,
|
||||
name_field,
|
||||
value_prev,
|
||||
@@ -572,10 +572,10 @@ CREATE TABLE `shop_category_audit` (
|
||||
`value_new` varchar(500) DEFAULT NULL,
|
||||
`id_change_set` int NOT NULL,
|
||||
PRIMARY KEY (`id_audit`),
|
||||
KEY `FK_Shop_Category_Audit_id_category` (`id_category`),
|
||||
KEY `FK_Shop_Category_Audit_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Category_Audit_id_category` FOREIGN KEY (`id_category`) REFERENCES `shop_category` (`id_category`) ON UPDATE RESTRICT,
|
||||
CONSTRAINT `FK_Shop_Category_Audit_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`)
|
||||
KEY `FK_Shop_Product_Category_Audit_id_category` (`id_category`),
|
||||
KEY `FK_Shop_Product_Category_Audit_id_change_set` (`id_change_set`),
|
||||
CONSTRAINT `FK_Shop_Product_Category_Audit_id_category` FOREIGN KEY (`id_category`) REFERENCES `shop_category` (`id_category`) ON UPDATE RESTRICT,
|
||||
CONSTRAINT `FK_Shop_Product_Category_Audit_id_change_set` FOREIGN KEY (`id_change_set`) REFERENCES `shop_product_change_set` (`id_change_set`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
@@ -5202,7 +5202,7 @@ BEGIN
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Basket_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Basket_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -5392,7 +5392,7 @@ BEGIN
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
AND C.active
|
||||
WHERE UB.id_user = a_id_user
|
||||
@@ -5541,7 +5541,7 @@ BEGIN
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
AND C.active
|
||||
-- RIGHT JOIN tmp_Shop_Basket t_UB ON ISNULL(t_UB.id_product)
|
||||
@@ -5552,7 +5552,7 @@ BEGIN
|
||||
IF EXISTS(
|
||||
SELECT *
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
INNER JOIN tmp_Shop_Basket t_B
|
||||
ON P.id_product = t_B.id_product
|
||||
@@ -5588,7 +5588,7 @@ BEGIN
|
||||
FROM Shop_Product_Permutation PP
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
(
|
||||
@@ -5803,7 +5803,7 @@ BEGIN
|
||||
ON t_UB.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Currency_Link PCL
|
||||
ON PP.id_permutation = PCL.id_permutation
|
||||
@@ -6069,13 +6069,13 @@ BEGIN
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
|
||||
CREATE TABLE tmp_Shop_Category (
|
||||
CREATE TABLE tmp_Shop_Product_Category (
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Category_id_category
|
||||
CONSTRAINT FK_tmp_Shop_Product_Category_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
active BIT NOT NULL,
|
||||
display_order INT NOT NULL,
|
||||
can_view BIT,
|
||||
@@ -6087,7 +6087,7 @@ BEGIN
|
||||
id_category INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -6267,7 +6267,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
# permutations
|
||||
@@ -6304,7 +6304,7 @@ BEGIN
|
||||
;
|
||||
END IF;
|
||||
|
||||
INSERT INTO tmp_Shop_Category (
|
||||
INSERT INTO tmp_Shop_Product_Category (
|
||||
id_category,
|
||||
active,
|
||||
display_order
|
||||
@@ -6313,7 +6313,7 @@ BEGIN
|
||||
C.active,
|
||||
C.display_order
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON t_P.id_category = C.id_category
|
||||
ORDER BY C.display_order
|
||||
;
|
||||
@@ -6381,7 +6381,7 @@ BEGIN
|
||||
IF v_has_filter_image THEN
|
||||
DELETE FROM tmp_Shop_Product
|
||||
WHERE id_product NOT IN (SELECT DISTINCT id_product FROM tmp_Shop_Image);
|
||||
DELETE FROM tmp_Shop_Category
|
||||
DELETE FROM tmp_Shop_Product_Category
|
||||
WHERE id_category NOT IN (SELECT DISTINCT id_category FROM tmp_Shop_Product);
|
||||
END IF;
|
||||
*/
|
||||
@@ -6629,7 +6629,7 @@ BEGIN
|
||||
# select * from tmp_Shop_Product;
|
||||
|
||||
-- Permissions
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Category LIMIT 1) THEN
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Product_Category LIMIT 1) THEN
|
||||
# SET v_id_user := (SELECT id_user FROM Shop_User WHERE name = CURRENT_USER());
|
||||
SET v_id_permission_product := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
|
||||
-- SET v_ids_product_permission := (SELECT GROUP_CONCAT(id_product SEPARATOR ',') FROM tmp_Shop_Product);
|
||||
@@ -6689,8 +6689,8 @@ BEGIN
|
||||
C.name,
|
||||
C.description,
|
||||
C.display_order
|
||||
FROM tmp_Shop_Category t_C
|
||||
INNER JOIN Shop_Category C
|
||||
FROM tmp_Shop_Product_Category t_C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON t_C.id_category = C.id_category
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON t_C.id_category = t_P.id_category
|
||||
@@ -6974,7 +6974,7 @@ BEGIN
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
END ;;
|
||||
DELIMITER ;
|
||||
/*!50003 SET sql_mode = @saved_sql_mode */ ;
|
||||
|
||||
@@ -151,14 +151,18 @@
|
||||
3424_tri_Shop_Customer_Sales_Order.sql
|
||||
3427_tri_Shop_Customer_Sales_Order_Product_Link.sql
|
||||
6000_p_split.sql
|
||||
6001_p_clear_split_temp.sql
|
||||
6500_p_shop_user_eval.sql
|
||||
6501_p_clear_shop_user_eval_temp.sql
|
||||
7101_p_shop_get_many_region.sql
|
||||
7116_p_shop_get_many_currency.sql
|
||||
7203_p_shop_save_product.sql
|
||||
7204_p_shop_get_many_product.sql
|
||||
7205_p_shop_get_many_stripe_product_new.sql
|
||||
7206_p_shop_save_permutation.sql
|
||||
7210_p_shop_get_many_product_variation.sql
|
||||
7219_p_shop_get_many_stock_item.sql
|
||||
7221_p_get_many_shop_product_price_and_discount_and_delivery_option.sql
|
||||
7223_p_shop_get_many_stripe_price_new.sql
|
||||
7312_p_shop_save_user.sql
|
||||
7313_p_get_many_user.sql
|
||||
|
||||
@@ -17,7 +17,7 @@ DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Discount;
|
||||
DROP TABLE IF EXISTS tmp_Discount;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Currency_Region_Link;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Currency_Link;
|
||||
DROP TABLE IF EXISTS tmp_User_Role_Link;
|
||||
@@ -160,8 +160,8 @@ DROP TABLE IF EXISTS Shop_Region;
|
||||
DROP TABLE IF EXISTS Shop_Recurrence_Interval_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Recurrence_Interval;
|
||||
|
||||
DROP TABLE IF EXISTS Shop_Category_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Category;
|
||||
DROP TABLE IF EXISTS Shop_Product_Category_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Product_Category;
|
||||
|
||||
DROP TABLE IF EXISTS Shop_General_Audit;
|
||||
DROP TABLE IF EXISTS Shop_General;
|
||||
@@ -460,9 +460,9 @@ CREATE TABLE IF NOT EXISTS Shop_General_Audit (
|
||||
|
||||
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Category';
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Category';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Category (
|
||||
CREATE TABLE IF NOT EXISTS Shop_Product_Category (
|
||||
id_category INTEGER NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(255),
|
||||
@@ -472,7 +472,7 @@ CREATE TABLE IF NOT EXISTS Shop_Category (
|
||||
created_on TIMESTAMP,
|
||||
created_by VARCHAR(100),
|
||||
id_change_set INTEGER,
|
||||
CONSTRAINT FK_Shop_Category_id_change_set
|
||||
CONSTRAINT FK_Shop_Product_Category_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
@@ -481,20 +481,20 @@ CREATE TABLE IF NOT EXISTS Shop_Category (
|
||||
|
||||
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Category_Audit';
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Category_Audit';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Category_Audit (
|
||||
CREATE TABLE IF NOT EXISTS Shop_Product_Category_Audit (
|
||||
id_audit INTEGER NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
id_category INTEGER NOT NULL,
|
||||
CONSTRAINT FK_Shop_Category_Audit_id_category
|
||||
CONSTRAINT FK_Shop_Product_Category_Audit_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category)
|
||||
REFERENCES Shop_Product_Category(id_category)
|
||||
ON UPDATE RESTRICT,
|
||||
name_field VARCHAR(50),
|
||||
value_prev VARCHAR(4000),
|
||||
value_new VARCHAR(4000),
|
||||
id_change_set INTEGER NOT NULL,
|
||||
CONSTRAINT FK_Shop_Category_Audit_id_change_set
|
||||
CONSTRAINT FK_Shop_Product_Category_Audit_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
@@ -752,7 +752,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product (
|
||||
-- ratio_discount_overall REAL NOT NULL DEFAULT 0,
|
||||
CONSTRAINT FK_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category)
|
||||
REFERENCES Shop_Product_Category(id_category)
|
||||
ON UPDATE RESTRICT,
|
||||
latency_manuf INTEGER,
|
||||
quantity_min REAL,
|
||||
@@ -2751,7 +2751,7 @@ FOR EACH ROW
|
||||
EXECUTE FUNCTION before_update_Shop_General();
|
||||
-- Shop Category
|
||||
|
||||
CREATE OR REPLACE FUNCTION before_insert_Shop_Category()
|
||||
CREATE OR REPLACE FUNCTION before_insert_Shop_Product_Category()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW.created_on = CURRENT_TIMESTAMP;
|
||||
@@ -2761,13 +2761,13 @@ BEGIN
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE TRIGGER tri_before_insert_Shop_Category
|
||||
BEFORE INSERT ON Shop_Category
|
||||
CREATE OR REPLACE TRIGGER tri_before_insert_Shop_Product_Category
|
||||
BEFORE INSERT ON Shop_Product_Category
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION before_insert_Shop_Category();
|
||||
EXECUTE FUNCTION before_insert_Shop_Product_Category();
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION before_update_Shop_Category()
|
||||
CREATE OR REPLACE FUNCTION before_update_Shop_Product_Category()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
IF OLD.id_change_set IS NOT DISTINCT FROM NEW.id_change_set THEN
|
||||
@@ -2775,7 +2775,7 @@ BEGIN
|
||||
USING ERRCODE = '45000';
|
||||
END IF;
|
||||
|
||||
INSERT INTO Shop_Category_Audit (
|
||||
INSERT INTO Shop_Product_Category_Audit (
|
||||
id_category,
|
||||
name_field,
|
||||
value_prev,
|
||||
@@ -2807,10 +2807,10 @@ BEGIN
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE TRIGGER tri_before_update_Shop_Category
|
||||
BEFORE UPDATE ON Shop_Category
|
||||
CREATE OR REPLACE TRIGGER tri_before_update_Shop_Product_Category
|
||||
BEFORE UPDATE ON Shop_Product_Category
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION before_update_Shop_Category();
|
||||
EXECUTE FUNCTION before_update_Shop_Product_Category();
|
||||
|
||||
-- Shop Recurrence Interval
|
||||
|
||||
@@ -5988,7 +5988,7 @@ BEGIN
|
||||
v_guid,
|
||||
RANK() OVER (ORDER BY C.display_order, P.display_order) AS rank_product
|
||||
FROM Shop_Product P -- ON ST.substring = P.id_product -- Shop_Product_Permutation PP
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Access_Level AL
|
||||
ON P.id_access_level_required = AL.id_access_level
|
||||
AND AL.active
|
||||
@@ -8826,7 +8826,7 @@ BEGIN
|
||||
id_category INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Basket_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Basket_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -9016,7 +9016,7 @@ BEGIN
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
AND C.active
|
||||
WHERE UB.id_user = a_id_user
|
||||
@@ -9165,7 +9165,7 @@ BEGIN
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
AND C.active
|
||||
-- RIGHT JOIN tmp_Shop_Basket t_UB ON ISNULL(t_UB.id_product)
|
||||
@@ -9176,7 +9176,7 @@ BEGIN
|
||||
IF EXISTS(
|
||||
SELECT *
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
INNER JOIN tmp_Shop_Basket t_B
|
||||
ON P.id_product = t_B.id_product
|
||||
@@ -9212,7 +9212,7 @@ BEGIN
|
||||
FROM Shop_Product_Permutation PP
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
(
|
||||
@@ -9427,7 +9427,7 @@ BEGIN
|
||||
ON t_UB.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Currency_Link PCL
|
||||
ON PP.id_permutation = PCL.id_permutation
|
||||
@@ -9689,7 +9689,7 @@ BEGIN
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
*/
|
||||
DROP TABLE IF EXISTS tmp_Discount;
|
||||
DROP TABLE IF EXISTS tmp_Currency;
|
||||
@@ -9697,14 +9697,14 @@ BEGIN
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Shop_Category (
|
||||
CREATE TEMPORARY TABLE tmp_Shop_Product_Category (
|
||||
id_category INTEGER NOT NULL,
|
||||
/*
|
||||
CONSTRAINT FK_tmp_Shop_Category_id_category
|
||||
CONSTRAINT FK_tmp_Shop_Product_Category_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
*/
|
||||
active BOOLEAN NOT NULL,
|
||||
display_order INTEGER NOT NULL,
|
||||
@@ -9718,7 +9718,7 @@ BEGIN
|
||||
/*
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
*/
|
||||
id_product INTEGER NOT NULL,
|
||||
/*
|
||||
@@ -9918,7 +9918,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
-- permutations
|
||||
@@ -9980,7 +9980,7 @@ BEGIN
|
||||
END IF;
|
||||
|
||||
|
||||
INSERT INTO tmp_Shop_Category (
|
||||
INSERT INTO tmp_Shop_Product_Category (
|
||||
id_category,
|
||||
active,
|
||||
display_order
|
||||
@@ -9989,7 +9989,7 @@ BEGIN
|
||||
C.active,
|
||||
C.display_order
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON t_P.id_category = C.id_category
|
||||
ORDER BY C.display_order
|
||||
;
|
||||
@@ -10063,7 +10063,7 @@ BEGIN
|
||||
IF v_has_filter_image THEN
|
||||
DELETE FROM tmp_Shop_Product
|
||||
WHERE id_product NOT IN (SELECT DISTINCT id_product FROM tmp_Shop_Image);
|
||||
DELETE FROM tmp_Shop_Category
|
||||
DELETE FROM tmp_Shop_Product_Category
|
||||
WHERE id_category NOT IN (SELECT DISTINCT id_category FROM tmp_Shop_Product);
|
||||
END IF;
|
||||
*/
|
||||
@@ -10331,7 +10331,7 @@ BEGIN
|
||||
-- select * from tmp_Shop_Product;
|
||||
|
||||
-- Permissions
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Category LIMIT 1) THEN
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Product_Category LIMIT 1) THEN
|
||||
-- v_id_user := (SELECT id_user FROM Shop_User WHERE name = CURRENT_USER);
|
||||
v_id_permission_product := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
|
||||
v_ids_product_permission := (SELECT STRING_AGG(id_product, ',') FROM tmp_Shop_Product WHERE NOT ISNULL(id_product));
|
||||
@@ -10389,8 +10389,8 @@ BEGIN
|
||||
C.name,
|
||||
C.description,
|
||||
C.display_order
|
||||
FROM tmp_Shop_Category t_C
|
||||
INNER JOIN Shop_Category C
|
||||
FROM tmp_Shop_Product_Category t_C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON t_C.id_category = C.id_category
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON t_C.id_category = t_P.id_category
|
||||
@@ -10707,14 +10707,14 @@ BEGIN
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
DROP TABLE IF EXISTS tmp_Discount;
|
||||
DROP TABLE IF EXISTS tmp_Currency;
|
||||
DROP TABLE IF EXISTS tmp_Delivery_Region;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
*/
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
@@ -12139,7 +12139,7 @@ BEGIN
|
||||
id_category INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -12246,13 +12246,13 @@ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM UNNEST(v_ids_category) AS Category_Id
|
||||
LEFT JOIN Shop_Category C ON Category_Id = C.id_category
|
||||
LEFT JOIN Shop_Product_Category C ON Category_Id = C.id_category
|
||||
WHERE ISNULL(C.id_category)
|
||||
) THEN
|
||||
RAISE EXCEPTION 'Invalid category IDs: %', (
|
||||
SELECT STRING_AGG(Category_Id, ', ')
|
||||
FROM UNNEST(v_ids_category) AS Category_Id
|
||||
LEFT JOIN Shop_Category C ON Category_Id = C.id_category
|
||||
LEFT JOIN Shop_Product_Category C ON Category_Id = C.id_category
|
||||
WHERE ISNULL(C.id_category)
|
||||
)
|
||||
USING ERRCODE = '22000'
|
||||
@@ -12364,7 +12364,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
-- permutations
|
||||
@@ -12435,7 +12435,7 @@ BEGIN
|
||||
INNER JOIN Shop_Supplier S ON SPO.id_supplier_ordered = S.id_supplier
|
||||
INNER JOIN Shop_Product_Permutation PP ON SPOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
LEFT JOIN tmp_Shop_Product t_P ON SPOPL.id_permutation = t_P.id_permutation
|
||||
LEFT JOIN tmp_Shop_Supplier t_S ON SPO.id_supplier_ordered = t_S.id_supplier
|
||||
WHERE
|
||||
@@ -12591,7 +12591,7 @@ BEGIN
|
||||
INNER JOIN tmp_Shop_Supplier_Purchase_Order t_SPO ON SPOPL.id_order = t_SPO.id_order
|
||||
INNER JOIN Shop_Product_Permutation PP ON SPOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
ORDER BY SPOPL.id_order, C.display_order, P.display_order, PP.display_order
|
||||
;
|
||||
RETURN NEXT result_order_product_links;
|
||||
@@ -12825,7 +12825,7 @@ BEGIN
|
||||
id_category INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -12886,13 +12886,13 @@ BEGIN
|
||||
IF v_has_filter_category = TRUE AND EXISTS (
|
||||
SELECT *
|
||||
FROM UNNEST(v_ids_category) AS Category_Id
|
||||
LEFT JOIN Shop_Category C ON Category_Id = C.id_category
|
||||
LEFT JOIN Shop_Product_Category C ON Category_Id = C.id_category
|
||||
WHERE ISNULL(C.id_category)
|
||||
) THEN
|
||||
RAISE EXCEPTION 'Invalid category IDs: %', (
|
||||
SELECT COALESCE(STRING_AGG(Category_Id, ', ') ,'NULL')
|
||||
FROM UNNEST(v_ids_category) AS Category_Id
|
||||
LEFT JOIN Shop_Category C ON Category_Id = C.id_category
|
||||
LEFT JOIN Shop_Product_Category C ON Category_Id = C.id_category
|
||||
WHERE ISNULL(C.id_category)
|
||||
)
|
||||
USING ERRCODE = '22000'
|
||||
@@ -12999,7 +12999,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
-- permutations
|
||||
@@ -13070,7 +13070,7 @@ BEGIN
|
||||
INNER JOIN Shop_manufacturing_Purchase_Order_Product_Link MPOPL ON MPO.id_order = MPOPL.id_order
|
||||
INNER JOIN Shop_Product_Permutation PP ON MPOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
LEFT JOIN tmp_Shop_Product t_P ON MPOPL.id_permutation = t_P.id_permutation
|
||||
WHERE
|
||||
-- order
|
||||
@@ -13200,7 +13200,7 @@ BEGIN
|
||||
INNER JOIN tmp_Shop_Manufacturing_Purchase_Order t_MPO ON MPOPL.id_order = t_MPO.id_order
|
||||
INNER JOIN Shop_Product_Permutation PP ON MPOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
ORDER BY MPOPL.id_order, C.display_order, P.display_order, PP.display_order
|
||||
;
|
||||
RETURN NEXT result_order_product_links;
|
||||
@@ -13707,7 +13707,7 @@ BEGIN
|
||||
id_category INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -13819,14 +13819,14 @@ BEGIN
|
||||
IF v_has_filter_category = TRUE AND EXISTS (
|
||||
SELECT STRING_AGG(Category_Id, ', ')
|
||||
FROM UNNEST(v_ids_category) AS Category_Id
|
||||
LEFT JOIN Shop_Category C ON Category_Id = C.id_customer
|
||||
LEFT JOIN Shop_Product_Category C ON Category_Id = C.id_customer
|
||||
WHERE ISNULL(C.id_customer)
|
||||
LIMIT 1
|
||||
) THEN
|
||||
RAISE EXCEPTION 'Invalid category IDs: %', (
|
||||
SELECT STRING_AGG(Category_Id, ', ')
|
||||
FROM UNNEST(v_ids_category) AS Category_Id
|
||||
LEFT JOIN Shop_Category C ON Category_Id = C.id_customer
|
||||
LEFT JOIN Shop_Product_Category C ON Category_Id = C.id_customer
|
||||
WHERE ISNULL(C.id_customer)
|
||||
)
|
||||
USING ERRCODE = '22000'
|
||||
@@ -13933,7 +13933,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
-- permutations
|
||||
@@ -14005,7 +14005,7 @@ BEGIN
|
||||
INNER JOIN Shop_Customer S ON CSO.id_customer = S.id_customer
|
||||
INNER JOIN Shop_Product_Permutation PP ON CSOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
LEFT JOIN tmp_Shop_Product t_P ON CSOPL.id_permutation = t_P.id_permutation
|
||||
LEFT JOIN tmp_Shop_Customer t_S ON CSO.id_customer = t_S.id_customer
|
||||
WHERE
|
||||
@@ -14162,7 +14162,7 @@ BEGIN
|
||||
INNER JOIN tmp_Shop_Customer_Sales_Order t_CSO ON CSOPL.id_order = t_CSO.id_order
|
||||
INNER JOIN Shop_Product_Permutation PP ON CSOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
ORDER BY CSOPL.id_order, C.display_order, P.display_order, PP.display_order
|
||||
;
|
||||
RETURN NEXT result_order_product_links;
|
||||
@@ -14332,7 +14332,7 @@ VALUES (
|
||||
);
|
||||
|
||||
-- Categories
|
||||
INSERT INTO Shop_Category (
|
||||
INSERT INTO Shop_Product_Category (
|
||||
display_order,
|
||||
code,
|
||||
name,
|
||||
@@ -14952,8 +14952,8 @@ SELECT * FROM Shop_General;
|
||||
SELECT * FROM Shop_General_Audit;
|
||||
|
||||
-- Categories
|
||||
SELECT * FROM Shop_Category;
|
||||
SELECT * FROM Shop_Category_Audit;
|
||||
SELECT * FROM Shop_Product_Category;
|
||||
SELECT * FROM Shop_Product_Category_Audit;
|
||||
|
||||
-- Recurrence Interval
|
||||
SELECT * FROM Shop_Recurrence_Interval;
|
||||
|
||||
@@ -17,7 +17,7 @@ DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Discount;
|
||||
DROP TABLE IF EXISTS tmp_Discount;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Currency_Region_Link;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Currency_Link;
|
||||
DROP TABLE IF EXISTS tmp_User_Role_Link;
|
||||
@@ -160,8 +160,8 @@ DROP TABLE IF EXISTS Shop_Region;
|
||||
DROP TABLE IF EXISTS Shop_Recurrence_Interval_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Recurrence_Interval;
|
||||
|
||||
DROP TABLE IF EXISTS Shop_Category_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Category;
|
||||
DROP TABLE IF EXISTS Shop_Product_Category_Audit;
|
||||
DROP TABLE IF EXISTS Shop_Product_Category;
|
||||
|
||||
DROP TABLE IF EXISTS Shop_General_Audit;
|
||||
DROP TABLE IF EXISTS Shop_General;
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Category';
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Category';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Category (
|
||||
CREATE TABLE IF NOT EXISTS Shop_Product_Category (
|
||||
id_category INTEGER NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(255),
|
||||
@@ -15,7 +15,7 @@ CREATE TABLE IF NOT EXISTS Shop_Category (
|
||||
created_on TIMESTAMP,
|
||||
created_by VARCHAR(100),
|
||||
id_change_set INTEGER,
|
||||
CONSTRAINT FK_Shop_Category_id_change_set
|
||||
CONSTRAINT FK_Shop_Product_Category_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
|
||||
@@ -3,20 +3,20 @@
|
||||
|
||||
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Category_Audit';
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Product_Category_Audit';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Category_Audit (
|
||||
CREATE TABLE IF NOT EXISTS Shop_Product_Category_Audit (
|
||||
id_audit INTEGER NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
|
||||
id_category INTEGER NOT NULL,
|
||||
CONSTRAINT FK_Shop_Category_Audit_id_category
|
||||
CONSTRAINT FK_Shop_Product_Category_Audit_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category)
|
||||
REFERENCES Shop_Product_Category(id_category)
|
||||
ON UPDATE RESTRICT,
|
||||
name_field VARCHAR(50),
|
||||
value_prev VARCHAR(4000),
|
||||
value_new VARCHAR(4000),
|
||||
id_change_set INTEGER NOT NULL,
|
||||
CONSTRAINT FK_Shop_Category_Audit_id_change_set
|
||||
CONSTRAINT FK_Shop_Product_Category_Audit_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS Shop_Product (
|
||||
-- ratio_discount_overall REAL NOT NULL DEFAULT 0,
|
||||
CONSTRAINT FK_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category)
|
||||
REFERENCES Shop_Product_Category(id_category)
|
||||
ON UPDATE RESTRICT,
|
||||
latency_manuf INTEGER,
|
||||
quantity_min REAL,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
-- Shop Category
|
||||
|
||||
CREATE OR REPLACE FUNCTION before_insert_Shop_Category()
|
||||
CREATE OR REPLACE FUNCTION before_insert_Shop_Product_Category()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW.created_on = CURRENT_TIMESTAMP;
|
||||
@@ -11,13 +11,13 @@ BEGIN
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE TRIGGER tri_before_insert_Shop_Category
|
||||
BEFORE INSERT ON Shop_Category
|
||||
CREATE OR REPLACE TRIGGER tri_before_insert_Shop_Product_Category
|
||||
BEFORE INSERT ON Shop_Product_Category
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION before_insert_Shop_Category();
|
||||
EXECUTE FUNCTION before_insert_Shop_Product_Category();
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION before_update_Shop_Category()
|
||||
CREATE OR REPLACE FUNCTION before_update_Shop_Product_Category()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
IF OLD.id_change_set IS NOT DISTINCT FROM NEW.id_change_set THEN
|
||||
@@ -25,7 +25,7 @@ BEGIN
|
||||
USING ERRCODE = '45000';
|
||||
END IF;
|
||||
|
||||
INSERT INTO Shop_Category_Audit (
|
||||
INSERT INTO Shop_Product_Category_Audit (
|
||||
id_category,
|
||||
name_field,
|
||||
value_prev,
|
||||
@@ -57,7 +57,7 @@ BEGIN
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE TRIGGER tri_before_update_Shop_Category
|
||||
BEFORE UPDATE ON Shop_Category
|
||||
CREATE OR REPLACE TRIGGER tri_before_update_Shop_Product_Category
|
||||
BEFORE UPDATE ON Shop_Product_Category
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION before_update_Shop_Category();
|
||||
EXECUTE FUNCTION before_update_Shop_Product_Category();
|
||||
|
||||
@@ -52,7 +52,7 @@ BEGIN
|
||||
|
||||
|
||||
-- Temporary tables
|
||||
CREATE TABLE tmp_Shop_Category (
|
||||
CREATE TABLE tmp_Shop_Product_Category (
|
||||
id_category INTEGER NOT NULL,
|
||||
active BOOLEAN NOT NULL,
|
||||
display_order INTEGER NOT NULL,
|
||||
@@ -102,11 +102,11 @@ BEGIN
|
||||
SET v_has_filter_category = CASE WHEN a_ids_category = '' THEN FALSE ELSE TRUE END;
|
||||
SET v_has_filter_product = CASE WHEN a_ids_product = '' THEN FALSE ELSE TRUE END;
|
||||
|
||||
INSERT INTO tmp_Shop_Category (
|
||||
INSERT INTO tmp_Shop_Product_Category (
|
||||
id_category, active, display_order
|
||||
)
|
||||
SELECT C.id_category, C.active, C.display_order
|
||||
FROM Shop_Category C
|
||||
FROM Shop_Product_Category C
|
||||
WHERE (NOT v_has_filter_category OR C.id_category LIKE '%' || a_ids_category || '%')
|
||||
AND (a_get_inactive_categories OR C.active);
|
||||
|
||||
@@ -115,7 +115,7 @@ BEGIN
|
||||
)
|
||||
SELECT P.id_category, P.id_product, P.active, P.display_order
|
||||
FROM Shop_Product P
|
||||
INNER JOIN tmp_Shop_Category tC
|
||||
INNER JOIN tmp_Shop_Product_Category tC
|
||||
ON P.id_category = tC.id_category
|
||||
WHERE (a_get_all_products OR P.id_product LIKE '%' || a_ids_product || '%')
|
||||
AND (a_get_inactive_products OR P.active);
|
||||
@@ -126,7 +126,7 @@ BEGIN
|
||||
END IF;
|
||||
|
||||
IF v_has_filter_product THEN
|
||||
DELETE FROM tmp_Shop_Category
|
||||
DELETE FROM tmp_Shop_Product_Category
|
||||
WHERE id_category NOT IN (SELECT DISTINCT id_category FROM tmp_Shop_Product);
|
||||
END IF;
|
||||
|
||||
@@ -157,13 +157,13 @@ BEGIN
|
||||
IF v_has_filter_image THEN
|
||||
DELETE FROM tmp_Shop_Product
|
||||
WHERE id_product NOT IN (SELECT DISTINCT id_product FROM tmp_Shop_Image);
|
||||
DELETE FROM tmp_Shop_Category
|
||||
DELETE FROM tmp_Shop_Product_Category
|
||||
WHERE id_category NOT IN (SELECT DISTINCT id_category FROM tmp_Shop_Product);
|
||||
END IF;
|
||||
|
||||
|
||||
-- Permissions
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Category LIMIT 1) THEN
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Product_Category LIMIT 1) THEN
|
||||
SET v_guid_permission = gen_random_uuid();
|
||||
SET v_id_user = CURRENT_USER;
|
||||
SET v_id_permission_product = (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
|
||||
@@ -195,8 +195,8 @@ BEGIN
|
||||
tC.can_edit,
|
||||
tC.can_admin
|
||||
)
|
||||
FROM tmp_Shop_Category tC
|
||||
INNER JOIN Shop_Category C
|
||||
FROM tmp_Shop_Product_Category tC
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON tC.id_category = C.id_category
|
||||
;
|
||||
|
||||
|
||||
@@ -466,7 +466,7 @@ BEGIN
|
||||
v_guid,
|
||||
RANK() OVER (ORDER BY C.display_order, P.display_order) AS rank_product
|
||||
FROM Shop_Product P -- ON ST.substring = P.id_product -- Shop_Product_Permutation PP
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Access_Level AL
|
||||
ON P.id_access_level_required = AL.id_access_level
|
||||
AND AL.active
|
||||
|
||||
@@ -113,7 +113,7 @@ BEGIN
|
||||
id_category INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Basket_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Basket_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -303,7 +303,7 @@ BEGIN
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
AND C.active
|
||||
WHERE UB.id_user = a_id_user
|
||||
@@ -452,7 +452,7 @@ BEGIN
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
AND P.active
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
AND C.active
|
||||
-- RIGHT JOIN tmp_Shop_Basket t_UB ON ISNULL(t_UB.id_product)
|
||||
@@ -463,7 +463,7 @@ BEGIN
|
||||
IF EXISTS(
|
||||
SELECT *
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
INNER JOIN tmp_Shop_Basket t_B
|
||||
ON P.id_product = t_B.id_product
|
||||
@@ -499,7 +499,7 @@ BEGIN
|
||||
FROM Shop_Product_Permutation PP
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
(
|
||||
@@ -714,7 +714,7 @@ BEGIN
|
||||
ON t_UB.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P
|
||||
ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Currency_Link PCL
|
||||
ON PP.id_permutation = PCL.id_permutation
|
||||
|
||||
@@ -143,7 +143,7 @@ BEGIN
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
*/
|
||||
DROP TABLE IF EXISTS tmp_Discount;
|
||||
DROP TABLE IF EXISTS tmp_Currency;
|
||||
@@ -151,14 +151,14 @@ BEGIN
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_Shop_Category (
|
||||
CREATE TEMPORARY TABLE tmp_Shop_Product_Category (
|
||||
id_category INTEGER NOT NULL,
|
||||
/*
|
||||
CONSTRAINT FK_tmp_Shop_Category_id_category
|
||||
CONSTRAINT FK_tmp_Shop_Product_Category_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
*/
|
||||
active BOOLEAN NOT NULL,
|
||||
display_order INTEGER NOT NULL,
|
||||
@@ -172,7 +172,7 @@ BEGIN
|
||||
/*
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
*/
|
||||
id_product INTEGER NOT NULL,
|
||||
/*
|
||||
@@ -372,7 +372,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
-- permutations
|
||||
@@ -434,7 +434,7 @@ BEGIN
|
||||
END IF;
|
||||
|
||||
|
||||
INSERT INTO tmp_Shop_Category (
|
||||
INSERT INTO tmp_Shop_Product_Category (
|
||||
id_category,
|
||||
active,
|
||||
display_order
|
||||
@@ -443,7 +443,7 @@ BEGIN
|
||||
C.active,
|
||||
C.display_order
|
||||
FROM tmp_Shop_Product t_P
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON t_P.id_category = C.id_category
|
||||
ORDER BY C.display_order
|
||||
;
|
||||
@@ -517,7 +517,7 @@ BEGIN
|
||||
IF v_has_filter_image THEN
|
||||
DELETE FROM tmp_Shop_Product
|
||||
WHERE id_product NOT IN (SELECT DISTINCT id_product FROM tmp_Shop_Image);
|
||||
DELETE FROM tmp_Shop_Category
|
||||
DELETE FROM tmp_Shop_Product_Category
|
||||
WHERE id_category NOT IN (SELECT DISTINCT id_category FROM tmp_Shop_Product);
|
||||
END IF;
|
||||
*/
|
||||
@@ -785,7 +785,7 @@ BEGIN
|
||||
-- select * from tmp_Shop_Product;
|
||||
|
||||
-- Permissions
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Category LIMIT 1) THEN
|
||||
IF EXISTS (SELECT * FROM tmp_Shop_Product_Category LIMIT 1) THEN
|
||||
-- v_id_user := (SELECT id_user FROM Shop_User WHERE name = CURRENT_USER);
|
||||
v_id_permission_product := (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
|
||||
v_ids_product_permission := (SELECT STRING_AGG(id_product, ',') FROM tmp_Shop_Product WHERE NOT ISNULL(id_product));
|
||||
@@ -843,8 +843,8 @@ BEGIN
|
||||
C.name,
|
||||
C.description,
|
||||
C.display_order
|
||||
FROM tmp_Shop_Category t_C
|
||||
INNER JOIN Shop_Category C
|
||||
FROM tmp_Shop_Product_Category t_C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON t_C.id_category = C.id_category
|
||||
INNER JOIN tmp_Shop_Product t_P
|
||||
ON t_C.id_category = t_P.id_category
|
||||
@@ -1161,14 +1161,14 @@ BEGIN
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
DROP TABLE IF EXISTS tmp_Discount;
|
||||
DROP TABLE IF EXISTS tmp_Currency;
|
||||
DROP TABLE IF EXISTS tmp_Delivery_Region;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
*/
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Variation;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
|
||||
CREATE OR REPLACE PROCEDURE p_shop_get_many_role_permission (
|
||||
a_ids_role VARCHAR(4000),
|
||||
@@ -84,7 +84,7 @@ BEGIN
|
||||
|
||||
|
||||
-- Clean up
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
END;
|
||||
|
||||
@@ -146,7 +146,7 @@ BEGIN
|
||||
id_category INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -253,13 +253,13 @@ BEGIN
|
||||
IF EXISTS (
|
||||
SELECT *
|
||||
FROM UNNEST(v_ids_category) AS Category_Id
|
||||
LEFT JOIN Shop_Category C ON Category_Id = C.id_category
|
||||
LEFT JOIN Shop_Product_Category C ON Category_Id = C.id_category
|
||||
WHERE ISNULL(C.id_category)
|
||||
) THEN
|
||||
RAISE EXCEPTION 'Invalid category IDs: %', (
|
||||
SELECT STRING_AGG(Category_Id, ', ')
|
||||
FROM UNNEST(v_ids_category) AS Category_Id
|
||||
LEFT JOIN Shop_Category C ON Category_Id = C.id_category
|
||||
LEFT JOIN Shop_Product_Category C ON Category_Id = C.id_category
|
||||
WHERE ISNULL(C.id_category)
|
||||
)
|
||||
USING ERRCODE = '22000'
|
||||
@@ -371,7 +371,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
-- permutations
|
||||
@@ -442,7 +442,7 @@ BEGIN
|
||||
INNER JOIN Shop_Supplier S ON SPO.id_supplier_ordered = S.id_supplier
|
||||
INNER JOIN Shop_Product_Permutation PP ON SPOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
LEFT JOIN tmp_Shop_Product t_P ON SPOPL.id_permutation = t_P.id_permutation
|
||||
LEFT JOIN tmp_Shop_Supplier t_S ON SPO.id_supplier_ordered = t_S.id_supplier
|
||||
WHERE
|
||||
@@ -598,7 +598,7 @@ BEGIN
|
||||
INNER JOIN tmp_Shop_Supplier_Purchase_Order t_SPO ON SPOPL.id_order = t_SPO.id_order
|
||||
INNER JOIN Shop_Product_Permutation PP ON SPOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
ORDER BY SPOPL.id_order, C.display_order, P.display_order, PP.display_order
|
||||
;
|
||||
RETURN NEXT result_order_product_links;
|
||||
|
||||
@@ -123,7 +123,7 @@ BEGIN
|
||||
id_category INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -184,13 +184,13 @@ BEGIN
|
||||
IF v_has_filter_category = TRUE AND EXISTS (
|
||||
SELECT *
|
||||
FROM UNNEST(v_ids_category) AS Category_Id
|
||||
LEFT JOIN Shop_Category C ON Category_Id = C.id_category
|
||||
LEFT JOIN Shop_Product_Category C ON Category_Id = C.id_category
|
||||
WHERE ISNULL(C.id_category)
|
||||
) THEN
|
||||
RAISE EXCEPTION 'Invalid category IDs: %', (
|
||||
SELECT COALESCE(STRING_AGG(Category_Id, ', ') ,'NULL')
|
||||
FROM UNNEST(v_ids_category) AS Category_Id
|
||||
LEFT JOIN Shop_Category C ON Category_Id = C.id_category
|
||||
LEFT JOIN Shop_Product_Category C ON Category_Id = C.id_category
|
||||
WHERE ISNULL(C.id_category)
|
||||
)
|
||||
USING ERRCODE = '22000'
|
||||
@@ -297,7 +297,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
-- permutations
|
||||
@@ -368,7 +368,7 @@ BEGIN
|
||||
INNER JOIN Shop_manufacturing_Purchase_Order_Product_Link MPOPL ON MPO.id_order = MPOPL.id_order
|
||||
INNER JOIN Shop_Product_Permutation PP ON MPOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
LEFT JOIN tmp_Shop_Product t_P ON MPOPL.id_permutation = t_P.id_permutation
|
||||
WHERE
|
||||
-- order
|
||||
@@ -498,7 +498,7 @@ BEGIN
|
||||
INNER JOIN tmp_Shop_Manufacturing_Purchase_Order t_MPO ON MPOPL.id_order = t_MPO.id_order
|
||||
INNER JOIN Shop_Product_Permutation PP ON MPOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
ORDER BY MPOPL.id_order, C.display_order, P.display_order, PP.display_order
|
||||
;
|
||||
RETURN NEXT result_order_product_links;
|
||||
|
||||
@@ -155,7 +155,7 @@ BEGIN
|
||||
id_category INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_category
|
||||
FOREIGN KEY (id_category)
|
||||
REFERENCES Shop_Category(id_category),
|
||||
REFERENCES Shop_Product_Category(id_category),
|
||||
id_product INTEGER NOT NULL,
|
||||
CONSTRAINT FK_tmp_Shop_Product_id_product
|
||||
FOREIGN KEY (id_product)
|
||||
@@ -267,14 +267,14 @@ BEGIN
|
||||
IF v_has_filter_category = TRUE AND EXISTS (
|
||||
SELECT STRING_AGG(Category_Id, ', ')
|
||||
FROM UNNEST(v_ids_category) AS Category_Id
|
||||
LEFT JOIN Shop_Category C ON Category_Id = C.id_customer
|
||||
LEFT JOIN Shop_Product_Category C ON Category_Id = C.id_customer
|
||||
WHERE ISNULL(C.id_customer)
|
||||
LIMIT 1
|
||||
) THEN
|
||||
RAISE EXCEPTION 'Invalid category IDs: %', (
|
||||
SELECT STRING_AGG(Category_Id, ', ')
|
||||
FROM UNNEST(v_ids_category) AS Category_Id
|
||||
LEFT JOIN Shop_Category C ON Category_Id = C.id_customer
|
||||
LEFT JOIN Shop_Product_Category C ON Category_Id = C.id_customer
|
||||
WHERE ISNULL(C.id_customer)
|
||||
)
|
||||
USING ERRCODE = '22000'
|
||||
@@ -381,7 +381,7 @@ BEGIN
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Product_Permutation PP
|
||||
ON P.id_product = PP.id_product
|
||||
INNER JOIN Shop_Category C
|
||||
INNER JOIN Shop_Product_Category C
|
||||
ON P.id_category = C.id_category
|
||||
WHERE
|
||||
-- permutations
|
||||
@@ -453,7 +453,7 @@ BEGIN
|
||||
INNER JOIN Shop_Customer S ON CSO.id_customer = S.id_customer
|
||||
INNER JOIN Shop_Product_Permutation PP ON CSOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
LEFT JOIN tmp_Shop_Product t_P ON CSOPL.id_permutation = t_P.id_permutation
|
||||
LEFT JOIN tmp_Shop_Customer t_S ON CSO.id_customer = t_S.id_customer
|
||||
WHERE
|
||||
@@ -610,7 +610,7 @@ BEGIN
|
||||
INNER JOIN tmp_Shop_Customer_Sales_Order t_CSO ON CSOPL.id_order = t_CSO.id_order
|
||||
INNER JOIN Shop_Product_Permutation PP ON CSOPL.id_permutation = PP.id_permutation
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Category C ON P.id_category = C.id_category
|
||||
INNER JOIN Shop_Product_Category C ON P.id_category = C.id_category
|
||||
ORDER BY CSOPL.id_order, C.display_order, P.display_order, PP.display_order
|
||||
;
|
||||
RETURN NEXT result_order_product_links;
|
||||
|
||||
@@ -62,7 +62,7 @@ VALUES (
|
||||
);
|
||||
|
||||
-- Categories
|
||||
INSERT INTO Shop_Category (
|
||||
INSERT INTO Shop_Product_Category (
|
||||
display_order,
|
||||
code,
|
||||
name,
|
||||
|
||||
@@ -27,8 +27,8 @@ SELECT * FROM Shop_General;
|
||||
SELECT * FROM Shop_General_Audit;
|
||||
|
||||
-- Categories
|
||||
SELECT * FROM Shop_Category;
|
||||
SELECT * FROM Shop_Category_Audit;
|
||||
SELECT * FROM Shop_Product_Category;
|
||||
SELECT * FROM Shop_Product_Category_Audit;
|
||||
|
||||
-- Recurrence Interval
|
||||
SELECT * FROM Shop_Recurrence_Interval;
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
103_tbl_File_Type_Audit.sql
|
||||
104_tbl_Shop_General.sql
|
||||
105_tbl_Shop_General_Audit.sql
|
||||
106_tbl_Shop_Category.sql
|
||||
107_tbl_Shop_Category_Audit.sql
|
||||
106_tbl_Shop_Product_Category.sql
|
||||
107_tbl_Shop_Product_Category_Audit.sql
|
||||
108_tbl_Shop_Recurrence_Interval.sql
|
||||
109_tbl_Shop_Recurrence_Interval_Audit.sql
|
||||
110.0_tbl_Shop_Region.sql
|
||||
@@ -93,7 +93,7 @@
|
||||
302_tri_File_Type.sql
|
||||
303_tri_File_Type_Audit.sql
|
||||
304_tri_Shop_General.sql
|
||||
306_tri_Shop_Category.sql
|
||||
306_tri_Shop_Product_Category.sql
|
||||
308_tri_Shop_Recurrence_Interval.sql
|
||||
310.0_tri_Shop_Region.sql
|
||||
310.2_tri_Shop_Region_Branch.sql
|
||||
|
||||
0
static/css/components/card.css
Normal file
0
static/css/components/card.css
Normal file
0
static/css/components/dialog.css
Normal file
0
static/css/components/dialog.css
Normal file
0
static/css/components/form.css
Normal file
0
static/css/components/form.css
Normal file
0
static/css/components/modal.css
Normal file
0
static/css/components/modal.css
Normal file
0
static/css/components/navigation.css
Normal file
0
static/css/components/navigation.css
Normal file
0
static/css/components/overlay.css
Normal file
0
static/css/components/overlay.css
Normal file
0
static/css/layouts/footer.css
Normal file
0
static/css/layouts/footer.css
Normal file
0
static/css/layouts/header.css
Normal file
0
static/css/layouts/header.css
Normal file
0
static/css/lib/reset.css
Normal file
0
static/css/lib/reset.css
Normal file
0
static/css/lib/typography.css
Normal file
0
static/css/lib/typography.css
Normal file
0
static/css/lib/utils.css
Normal file
0
static/css/lib/utils.css
Normal file
0
static/css/lib/variables.css
Normal file
0
static/css/lib/variables.css
Normal file
@@ -1,3 +1,55 @@
|
||||
|
||||
/* Base styles */
|
||||
@import 'lib/reset.css';
|
||||
@import 'lib/typography.css';
|
||||
@import 'lib/variables.css';
|
||||
@import 'lib/utils.css';
|
||||
|
||||
/* Layout styles */
|
||||
@import 'layouts/header.css';
|
||||
@import 'layouts/footer.css';
|
||||
|
||||
/* Component styles */
|
||||
@import 'components/button.css';
|
||||
@import 'components/card.css';
|
||||
@import 'components/dialog.css';
|
||||
@import 'components/form.css';
|
||||
@import 'components/modal.css';
|
||||
@import 'components/navigation.css';
|
||||
@import 'components/overlay.css';
|
||||
|
||||
/* Section styles */
|
||||
@import 'sections/store.css';
|
||||
|
||||
/* Page-specific styles *
|
||||
@import 'pages/page_admin.css';
|
||||
@import 'pages/page_contact.css';
|
||||
@import 'pages/page_home.css';
|
||||
@import 'pages/page_license.css';
|
||||
@import 'pages/page_services.css';
|
||||
@import 'pages/page_store_home.css';
|
||||
@import 'pages/page_store_product_permutations.css';
|
||||
@import 'pages/page_store_stock_items.css';
|
||||
*/
|
||||
|
||||
/* Theme styles *
|
||||
@import 'themes/light.css';
|
||||
/* Uncomment the line below to enable dark theme */
|
||||
/* @import 'themes/dark.css'; */
|
||||
|
||||
/* Custom styles */
|
||||
/* Add any custom styles or overrides here */
|
||||
|
||||
body {
|
||||
/* Example of using a CSS variable defined in variables.css */
|
||||
background-color: var(--background-color);
|
||||
color: var(--text-color);
|
||||
font-family: var(--font-family-base);
|
||||
}
|
||||
|
||||
/* You can add more global styles here */
|
||||
|
||||
|
||||
:root {
|
||||
/* Declare global variables */
|
||||
--c_purple: #5B29FF;
|
||||
@@ -429,16 +481,19 @@ button, .button-submit, input[type="submit"] {
|
||||
color: var(--c_purple_dark);
|
||||
border-color: var(--c_purple_dark);
|
||||
}
|
||||
.button-contact {
|
||||
button.navContactUs {
|
||||
border: 4px solid var(--c_purple_dark);
|
||||
background-color: var(--c_purple_pastel);
|
||||
color: var(--c_purple_dark) !important;
|
||||
border-radius: 2vh;
|
||||
width: 180px !important;
|
||||
}
|
||||
.button-contact:hover {
|
||||
button:hover, input[type="submit"]:hover, #overlayHamburger .row *:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
#buttonHamburger:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.delete {
|
||||
text-decoration: underline;
|
||||
@@ -468,6 +523,11 @@ button, .button-submit, input[type="submit"] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
#overlayHamburger {
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
max-height: 80%;
|
||||
}
|
||||
.hamburger {
|
||||
border: 2px solid var(--c_purple_dark);
|
||||
border-radius: 4px;
|
||||
@@ -491,7 +551,7 @@ button, .button-submit, input[type="submit"] {
|
||||
color: var(--c_purple_dark);
|
||||
font-weight: bold;
|
||||
font-size: 18px;
|
||||
height: 18px;
|
||||
/* height: 18px; */
|
||||
}
|
||||
.hamburger > :hover {
|
||||
background-color: var(--c_purple_light);
|
||||
7
static/css/pages/page_admin_home.css
Normal file
7
static/css/pages/page_admin_home.css
Normal file
@@ -0,0 +1,7 @@
|
||||
#pageBody > .card:first-of-type {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.container.row {
|
||||
width: auto;
|
||||
}
|
||||
0
static/css/pages/page_store_home.css
Normal file
0
static/css/pages/page_store_home.css
Normal file
@@ -1,86 +0,0 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
padding: 10px;
|
||||
display: block;
|
||||
background-color: grey;
|
||||
}
|
||||
|
||||
.banner {
|
||||
background-color: black;
|
||||
color: white;
|
||||
width: 100%;
|
||||
position: fixed;
|
||||
padding-top: 5vh;
|
||||
padding-bottom: 10vh;
|
||||
}
|
||||
|
||||
.banner.top {
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.banner.bottom {
|
||||
background-color: black;
|
||||
color: white;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.row:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.column {
|
||||
float: left;
|
||||
padding: 5vw;
|
||||
}
|
||||
|
||||
.column.side {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.column.middle {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.midbod {
|
||||
background-color: white;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.panel {
|
||||
float: left;
|
||||
}
|
||||
|
||||
img {
|
||||
height: 100px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.panel.labelcontainer {
|
||||
background-color: black;
|
||||
color: white;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.label.bodytext {
|
||||
background-color: black;
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-style: normal;
|
||||
font-size: 12;
|
||||
}
|
||||
|
||||
.label.title {
|
||||
font-style: bold;
|
||||
font-size: 18;
|
||||
}
|
||||
45
static/css/themes/dark.css
Normal file
45
static/css/themes/dark.css
Normal file
@@ -0,0 +1,45 @@
|
||||
:root {
|
||||
--background-color: #121212;
|
||||
--text-color: #e0e0e0;
|
||||
--primary-color: #bb86fc;
|
||||
--secondary-color: #03dac6;
|
||||
--success-color: #00c853;
|
||||
--danger-color: #cf6679;
|
||||
--warning-color: #ffab00;
|
||||
--info-color: #2196f3;
|
||||
--light-color: #2c2c2c;
|
||||
--dark-color: #1f1f1f;
|
||||
--border-color: #333333;
|
||||
--shadow-color: rgba(255, 255, 255, 0.1);
|
||||
|
||||
/* Header */
|
||||
--header-bg: #1f1f1f;
|
||||
--header-text: #e0e0e0;
|
||||
|
||||
/* Footer */
|
||||
--footer-bg: #1f1f1f;
|
||||
--footer-text: #a0a0a0;
|
||||
|
||||
/* Navigation */
|
||||
--nav-bg: #1f1f1f;
|
||||
--nav-text: #e0e0e0;
|
||||
--nav-hover-bg: #2c2c2c;
|
||||
--nav-hover-text: #bb86fc;
|
||||
|
||||
/* Buttons */
|
||||
--btn-primary-bg: #bb86fc;
|
||||
--btn-primary-text: #121212;
|
||||
--btn-secondary-bg: #03dac6;
|
||||
--btn-secondary-text: #121212;
|
||||
|
||||
/* Forms */
|
||||
--input-bg: #2c2c2c;
|
||||
--input-border: #454545;
|
||||
--input-text: #e0e0e0;
|
||||
--input-focus-border: #bb86fc;
|
||||
|
||||
/* Cards */
|
||||
--card-bg: #1f1f1f;
|
||||
--card-border: #333333;
|
||||
--card-shadow: 0 0.125rem 0.25rem rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
45
static/css/themes/light.css
Normal file
45
static/css/themes/light.css
Normal file
@@ -0,0 +1,45 @@
|
||||
:root {
|
||||
--background-color: #ffffff;
|
||||
--text-color: #333333;
|
||||
--primary-color: #007bff;
|
||||
--secondary-color: #6c757d;
|
||||
--success-color: #28a745;
|
||||
--danger-color: #dc3545;
|
||||
--warning-color: #ffc107;
|
||||
--info-color: #17a2b8;
|
||||
--light-color: #f8f9fa;
|
||||
--dark-color: #343a40;
|
||||
--border-color: #dee2e6;
|
||||
--shadow-color: rgba(0, 0, 0, 0.1);
|
||||
|
||||
/* Header */
|
||||
--header-bg: #f8f9fa;
|
||||
--header-text: #333333;
|
||||
|
||||
/* Footer */
|
||||
--footer-bg: #f8f9fa;
|
||||
--footer-text: #6c757d;
|
||||
|
||||
/* Navigation */
|
||||
--nav-bg: #ffffff;
|
||||
--nav-text: #333333;
|
||||
--nav-hover-bg: #f1f3f5;
|
||||
--nav-hover-text: #007bff;
|
||||
|
||||
/* Buttons */
|
||||
--btn-primary-bg: #007bff;
|
||||
--btn-primary-text: #ffffff;
|
||||
--btn-secondary-bg: #6c757d;
|
||||
--btn-secondary-text: #ffffff;
|
||||
|
||||
/* Forms */
|
||||
--input-bg: #ffffff;
|
||||
--input-border: #ced4da;
|
||||
--input-text: #495057;
|
||||
--input-focus-border: #80bdff;
|
||||
|
||||
/* Cards */
|
||||
--card-bg: #ffffff;
|
||||
--card-border: #dee2e6;
|
||||
--card-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
|
||||
}
|
||||
88
static/docs/example abstract base class.py
Normal file
88
static/docs/example abstract base class.py
Normal file
@@ -0,0 +1,88 @@
|
||||
from abc import abstractmethod
|
||||
import types
|
||||
|
||||
class AbstractBaseClass:
|
||||
def __init_subclass__(cls, **kwargs):
|
||||
super().__init_subclass__(**kwargs)
|
||||
for name, value in vars(AbstractBaseClass).items():
|
||||
if getattr(value, "__isabstractmethod__", False):
|
||||
if name not in cls.__dict__:
|
||||
raise TypeError(f"Can't instantiate class {cls.__name__} "
|
||||
f"without implementation of abstract method {name}")
|
||||
subclass_value = cls.__dict__[name]
|
||||
if (isinstance(value, (staticmethod, classmethod)) and
|
||||
not isinstance(subclass_value, type(value))):
|
||||
raise TypeError(f"Abstract {type(value).__name__} {name} in {cls.__name__} "
|
||||
f"must be implemented as a {type(value).__name__}")
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
if cls is AbstractBaseClass:
|
||||
raise TypeError("Can't instantiate abstract class AbstractBaseClass directly")
|
||||
return super().__new__(cls)
|
||||
|
||||
@abstractmethod
|
||||
def instance_method(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
@abstractmethod
|
||||
def class_method(cls):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
@abstractmethod
|
||||
def static_method():
|
||||
pass
|
||||
|
||||
class ConcreteClass(AbstractBaseClass):
|
||||
def instance_method(self):
|
||||
return "Implemented instance method"
|
||||
|
||||
@classmethod
|
||||
def class_method(cls):
|
||||
return "Implemented class method"
|
||||
|
||||
@staticmethod
|
||||
def static_method():
|
||||
return "Implemented static method"
|
||||
|
||||
class IncompleteClass(AbstractBaseClass):
|
||||
def instance_method(self):
|
||||
return "Only implemented instance method"
|
||||
# class_method and static_method are not implemented
|
||||
|
||||
class IncorrectImplementationClass(AbstractBaseClass):
|
||||
def instance_method(self):
|
||||
return "Implemented instance method"
|
||||
|
||||
@classmethod
|
||||
def class_method(cls):
|
||||
return "Implemented class method"
|
||||
|
||||
def static_method(self): # This should be a static method, not an instance method
|
||||
return "Incorrectly implemented static method"
|
||||
|
||||
# Usage
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
concrete = ConcreteClass()
|
||||
print(concrete.instance_method())
|
||||
print(ConcreteClass.class_method())
|
||||
print(ConcreteClass.static_method())
|
||||
except TypeError as e:
|
||||
print(f"Error with ConcreteClass: {e}")
|
||||
|
||||
try:
|
||||
IncompleteClass()
|
||||
except TypeError as e:
|
||||
print(f"Error with IncompleteClass: {e}")
|
||||
|
||||
try:
|
||||
IncorrectImplementationClass()
|
||||
except TypeError as e:
|
||||
print(f"Error with IncorrectImplementationClass: {e}")
|
||||
|
||||
try:
|
||||
AbstractBaseClass()
|
||||
except TypeError as e:
|
||||
print(f"Error with AbstractBaseClass: {e}")
|
||||
109
static/js/DEPRECATED/routing.js
Normal file
109
static/js/DEPRECATED/routing.js
Normal file
@@ -0,0 +1,109 @@
|
||||
|
||||
function mapHashToController(hash) {
|
||||
if (hash == null) return mapHashToController(hashPageHome);
|
||||
|
||||
url = _pathHost; // + '/';
|
||||
console.log("url: " + url + "\nhash: " + hash);
|
||||
return url + hash;
|
||||
|
||||
switch (hash) {
|
||||
case hashPageErrorNoPermission:
|
||||
url += 'error';
|
||||
break;
|
||||
case hashPageStoreHome:
|
||||
url += 'store/home';
|
||||
break;
|
||||
case hashPageStoreProduct:
|
||||
url += 'store/product';
|
||||
break;
|
||||
case hashStoreBasketLoad:
|
||||
url += 'store/basket_load';
|
||||
break;
|
||||
case hashStoreBasketAdd:
|
||||
url += 'store/product';
|
||||
break;
|
||||
default:
|
||||
url += '';
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
/*
|
||||
function goToPage(pageHash, parameters) {
|
||||
window.location.href = "{{ url_for(" + pageHash + (parameters == '' ? '' : ',' + parameters) + ") }}"; // getPageRoute(pageHash, parameters);
|
||||
}
|
||||
*/
|
||||
function goToPage(pageHash, parametersJSON) {
|
||||
// window.location.href = "{{ url_for(" + pageHash + (parameters == '' ? '' : ',' + parameters) + ") }}"; // getPageRoute(pageHash, parameters);
|
||||
// ajaxJSONData(pageHash, mapHashToController(pageHash), parameters, null, false);
|
||||
url = mapHashToController(pageHash);
|
||||
|
||||
|
||||
if (!isEmpty(parametersJSON)) {
|
||||
url += '%3F'; // '?';
|
||||
let firstParameter = true;
|
||||
for (var p in parametersJSON) {
|
||||
// url += p + '=' + parametersJSON[p];
|
||||
if (!firstParameter) {
|
||||
url += '&';
|
||||
} else {
|
||||
firstParameter = false;
|
||||
}
|
||||
url += parametersJSON[p];
|
||||
}
|
||||
}
|
||||
|
||||
leavePage();
|
||||
|
||||
window.location.href = url;
|
||||
// ajaxJSONData(pageHash, url, parametersJSON, loadPageBody, false);
|
||||
}
|
||||
function leavePage() {}
|
||||
|
||||
function goToUrl(parameterisedUrl) {
|
||||
|
||||
leavePage();
|
||||
|
||||
window.location.href = parameterisedUrl;
|
||||
}
|
||||
|
||||
function htmlEncode(value) {
|
||||
return document.createElement('<div/>').text(value).innerHTML;
|
||||
}
|
||||
|
||||
var _domParser = null;
|
||||
function htmlDecode(value) {
|
||||
if (_domParser == null) _domParser = DOMParser(); // https://www.w3docs.com/snippets/javascript/how-to-html-encode-a-string.html
|
||||
return _domParser.parseFromString(value, 'text/html').documentElement.textContent;
|
||||
}
|
||||
|
||||
function convertForm2JSON(elemForm) {
|
||||
|
||||
formData = {}
|
||||
|
||||
formDataTmp = elemForm.serializeArray();
|
||||
|
||||
$.each(formDataTmp, function(index, field) {
|
||||
formData[field.name] = field.value;
|
||||
/*
|
||||
console.log('field name: ' + field.name);
|
||||
console.log('field value: ' + field.value);
|
||||
console.log('field currentval: ' + getElementCurrentValue(field));
|
||||
*/
|
||||
});
|
||||
|
||||
return formData;
|
||||
}
|
||||
|
||||
function loadPageBody(response) {
|
||||
|
||||
let pageBody = document.querySelectorAll(idPageBody);
|
||||
|
||||
console.log('ajax:');
|
||||
console.log(response.data);
|
||||
|
||||
pageBody.innerHTML = response.data['html_block'];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
var _loading = true;
|
||||
|
||||
function hookupPageAccessibilityStatement() {
|
||||
_loading = false;
|
||||
}
|
||||
69
static/js/api.js
Normal file
69
static/js/api.js
Normal file
@@ -0,0 +1,69 @@
|
||||
import DOM from './dom.js';
|
||||
|
||||
// Module for API calls
|
||||
export default class API {
|
||||
|
||||
static getCsrfToken() {
|
||||
// return document.querySelectorAll('meta[name=' + nameCSRFToken + ']').attr('content');
|
||||
return document.querySelector(idCSRFToken).getAttribute('content');
|
||||
}
|
||||
|
||||
static async request(hashEndpoint, method = 'GET', data = null) {
|
||||
const url = mapHashToController(hashEndpoint);
|
||||
const options = {
|
||||
method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': API.getCsrfToken()
|
||||
}
|
||||
};
|
||||
|
||||
if (data) { //} && (method === 'POST' || method === 'PUT' || method === 'PATCH')) {
|
||||
options.body = JSON.stringify(data);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(url, options);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('API request failed:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// specific api calls
|
||||
/* Example:
|
||||
getUsers: () => request('/users'),
|
||||
getUserById: (id) => request(`/users/${id}`),
|
||||
createUser: (userData) => request('/users', 'POST', userData),
|
||||
updateUser: (id, userData) => request(`/users/${id}`, 'PUT', userData),
|
||||
deleteUser: (id) => request(`/users/${id}`, 'DELETE'),
|
||||
*/
|
||||
static async loginUser() {
|
||||
let callback = {};
|
||||
callback[keyCallback] = DOM.getHashPageCurrent();
|
||||
return await API.request(hashPageUserLogin, 'POST', callback);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
const api = new API();
|
||||
export default api;
|
||||
|
||||
Example of using the API
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
initializeApp();
|
||||
setupEventListeners();
|
||||
initializeComponents();
|
||||
|
||||
// Example of using the API
|
||||
API.getData('/some-endpoint')
|
||||
.then(data => console.log('Data received:', data))
|
||||
.catch(error => console.error('Error:', error));
|
||||
});
|
||||
*/
|
||||
68
static/js/app.js
Normal file
68
static/js/app.js
Normal file
@@ -0,0 +1,68 @@
|
||||
|
||||
// Main entry point for the application
|
||||
'use strict';
|
||||
|
||||
// import API from './api.js';
|
||||
import DOM from './dom.js';
|
||||
import Router from './router.js';
|
||||
|
||||
|
||||
class App {
|
||||
constructor() {
|
||||
this.dom = new DOM();
|
||||
this.router = new Router();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
console.log('Initializing application...');
|
||||
this.setupEventListeners();
|
||||
this.start();
|
||||
}
|
||||
|
||||
setupEventListeners() {
|
||||
// Global event listeners
|
||||
// document.addEventListener('click', this.handleGlobalClick.bind(this));
|
||||
// Add more global event listeners as needed
|
||||
}
|
||||
|
||||
handleGlobalClick(event) {
|
||||
// Handle global click events
|
||||
console.log('Global click:', event.target);
|
||||
}
|
||||
|
||||
start() {
|
||||
console.log('Starting application...');
|
||||
// Additional startup logic
|
||||
this.initPageCurrent();
|
||||
}
|
||||
|
||||
initPageCurrent() {
|
||||
console.log("initPageCurrent");
|
||||
_pageCurrent = Router.getPageCurrent();
|
||||
_pageCurrent.initialize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Application instance
|
||||
const app = new App();
|
||||
|
||||
// DOM ready handler
|
||||
function domReady(fn) {
|
||||
if (document.readyState !== 'loading') {
|
||||
fn();
|
||||
} else {
|
||||
document.addEventListener('DOMContentLoaded', fn);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize and start the app when DOM is ready
|
||||
domReady(() => {
|
||||
app.initialize();
|
||||
});
|
||||
|
||||
// Expose app to window for debugging (optional)
|
||||
window.app = app;
|
||||
|
||||
// Export app if using modules
|
||||
export default app;
|
||||
@@ -1,82 +1,4 @@
|
||||
|
||||
/* Page elements */
|
||||
function displayOverlay(message, show, force) {
|
||||
|
||||
if (show) {
|
||||
_overlayLoadingCount += 1;
|
||||
}
|
||||
else if (force) {
|
||||
_overlayLoadingCount = 0;
|
||||
}
|
||||
else {
|
||||
_overlayLoadingCount -= 1;
|
||||
if (_overlayLoadingCount < 0) _overlayLoadingCount = 0;
|
||||
}
|
||||
|
||||
var loadingImg = $(idImageLoading);
|
||||
var overlay = $(loadingImg.closest("div.overlay"));
|
||||
|
||||
if (_overlayLoadingCount == 0) {
|
||||
|
||||
// Prevent short glimpse of prev. content before switch to new content
|
||||
// caused by data load but not fully rendered
|
||||
setTimeout(function() {
|
||||
overlay.fadeOut();
|
||||
}, 100);
|
||||
}
|
||||
else if (show && _overlayLoadingCount == 1) {
|
||||
// only show once
|
||||
loadingImg.html(message);
|
||||
overlay.show();
|
||||
}
|
||||
}
|
||||
|
||||
function setBackgroundToLoading(elId, isLoading) {
|
||||
|
||||
if (isEmpty(el)) {
|
||||
|
||||
var elObj = $(elId);
|
||||
|
||||
if (isLoading) {
|
||||
|
||||
setTimeout(function() {
|
||||
elObj.html("");
|
||||
elObj.css({
|
||||
"background-image": "url(" + urlImgLoading + ")",
|
||||
"background-position": "center",
|
||||
"background-repeat": "no-repeat"
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
else {
|
||||
elObj.css("background-image", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function allowClick() {
|
||||
return !$("body").hasClass(_dataLoadingFlag);
|
||||
}
|
||||
|
||||
function imageExists(url, callback) {
|
||||
|
||||
var img = new Image();
|
||||
|
||||
img.onload = function() { callback(true); };
|
||||
img.onerror = function() { callback(false); };
|
||||
img.src = url;
|
||||
}
|
||||
|
||||
function validateImageUrl(id, img) {
|
||||
imageExists(img, function(exists) {
|
||||
if (exists) {
|
||||
$("#" + id).css({ "background-image": "url(" + url + ")", "background-size": "35px 35px"})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Date picker inputs
|
||||
/*
|
||||
@@ -88,7 +10,7 @@ function hookupInputDatePickers(dateInputs, notFuture, notPast, parent, addClear
|
||||
|
||||
for (let i = 0; i < dateInputs.length; i++) {
|
||||
|
||||
currentInput = $(dateInputs[i]);
|
||||
currentInput = document.querySelectorAll(dateInputs[i]);
|
||||
currentDateString = currentInput.val();
|
||||
currentDate = (!isEmpty(currentDateString)) ? convertDDMMYYYYString2Date(currentDateString, false) : null;
|
||||
exceptionsArray = (currentDate != null) ? [currentDate] : null;
|
||||
@@ -101,9 +23,9 @@ function hookupInputDatePickers(dateInputs, notFuture, notPast, parent, addClear
|
||||
// which will clear the whole value to ensure we either have a whole
|
||||
// date string or none
|
||||
|
||||
parent.on("keydown", isDatePickerSelector, function(event) {
|
||||
parent.addEventListener("keydown", isDatePickerSelector, function(event) {
|
||||
if (event.keyCode == 46 | event.keyCode == 8) { // delete or backspace
|
||||
$(this).val('');
|
||||
this.val('');
|
||||
}
|
||||
else {
|
||||
event.preventDefault();
|
||||
@@ -128,8 +50,8 @@ function hookupInputDatePickers(dateInputs, notFuture, notPast, parent, addClear
|
||||
"clears": {
|
||||
name: "Clear Date",
|
||||
icon: "delete",
|
||||
disabled: function(key, opt) { return isEmpty($(opt.$trigger)); }, // if it's already empty, don't do anything
|
||||
callback: function(itemKey, opt, rootMenu, originalEvent) { var input = $(opt.$trigger); input.val(''); input.trigger('change'); }
|
||||
disabled: function(key, opt) { return isEmpty(document.querySelectorAll(opt.$trigger)); }, // if it's already empty, don't do anything
|
||||
callback: function(itemKey, opt, rootMenu, originalEvent) { var input = document.querySelectorAll(opt.$trigger); input.val(''); input.trigger('change'); }
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -172,7 +94,7 @@ function turnInputIntoDatePicker(input, notFuture, notPast, exceptionValueArray)
|
||||
});
|
||||
|
||||
// prevent datepicker from appearing on right click
|
||||
input.on('contextmenu', function() { $(this).datepicker('hide'); });
|
||||
input.addEventListener('contextmenu', function() { this.datepicker('hide'); });
|
||||
|
||||
// Disable autocomplete suggestions appearing when clicking on input
|
||||
input.attr('autocomplete', 'off');
|
||||
@@ -257,21 +179,3 @@ function convertDate2DDMMYYYYString(date) {
|
||||
return 'Formatting error';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Data tables
|
||||
function getDataTableCellByNode(table, elRow, indexColumn) {
|
||||
// normal jQuery selector won't pick up hidden columns
|
||||
return $(table.DataTable().cells(elRow, indexColumn, null).nodes());
|
||||
}
|
||||
|
||||
function outputTableElementDateInput(table, elRow, indexColumn, value) {
|
||||
|
||||
let currentCell = getDataTableCellByNode(table, elRow, indexColumn);
|
||||
|
||||
let dateTxt = '';
|
||||
|
||||
if (!isEmpty(value)) {
|
||||
if (typeof value === 'string') value = convertJSONDateString2Date(value);
|
||||
}
|
||||
}
|
||||
16
static/js/components/select.js
Normal file
16
static/js/components/select.js
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
function handleSelectCollapse(elementSelect) {
|
||||
let optionSelected = document.querySelectorAll(elementSelect).querySelector('option:selected');
|
||||
optionSelected.text(optionSelected.attr(attrTextCollapsed));
|
||||
console.log('collapsed: ', optionSelected.text());
|
||||
optionSelected.classList.remove(flagExpanded);
|
||||
optionSelected.classList.add(flagCollapsed);
|
||||
}
|
||||
function handleSelectExpand(elementSelect) {
|
||||
let optionSelected = document.querySelectorAll(elementSelect).querySelector('option:selected');
|
||||
optionSelected.text(optionSelected.attr(attrTextExpanded));
|
||||
console.log('expanded: ', optionSelected.text());
|
||||
optionSelected.classList.remove(flagCollapsed);
|
||||
optionSelected.classList.add(flagExpanded);
|
||||
}
|
||||
18
static/js/components/table.js
Normal file
18
static/js/components/table.js
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
// Data tables
|
||||
function getDataTableCellByNode(table, elRow, indexColumn) {
|
||||
// normal jQuery selector won't pick up hidden columns
|
||||
return document.querySelectorAll(table.DataTable().cells(elRow, indexColumn, null).nodes());
|
||||
}
|
||||
|
||||
function outputTableElementDateInput(table, elRow, indexColumn, value) {
|
||||
|
||||
let currentCell = getDataTableCellByNode(table, elRow, indexColumn);
|
||||
|
||||
let dateTxt = '';
|
||||
|
||||
if (!isEmpty(value)) {
|
||||
if (typeof value === 'string') value = convertJSONDateString2Date(value);
|
||||
}
|
||||
}
|
||||
41
static/js/components/textarea.js
Normal file
41
static/js/components/textarea.js
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
function removeBlankTextAreaLines(textarea) {
|
||||
textarea.val(textarea.val.replace(/(?:(?:\r\n|\r|\n)\s*){2}/gm, ''));
|
||||
}
|
||||
|
||||
function fitTextAreasToContent(parent) {
|
||||
var textareas = parent.querySelector('textarea');
|
||||
|
||||
if (!isEmpty(textareas)) {
|
||||
for (var t = 0; t < textareas.length; t++) {
|
||||
fitTextAreaToContent(document.querySelectorAll(textareas[t]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fitTextAreaToContent(textarea) {
|
||||
// Trim new text
|
||||
var txtNew = textarea.val().trim();
|
||||
textarea.val(txtNew);
|
||||
|
||||
var elTextarea = textarea[0];
|
||||
|
||||
// Clear style height and set rows = 1
|
||||
elTextarea.style.removeProperty('height');
|
||||
textarea.attr('rows', 1);
|
||||
|
||||
const paddingTop = parseCSSPropertyToFloat(textarea, 'padding-top');
|
||||
const paddingBottom= parseCSSPropertyToFloat(textarea, 'padding-bottom');
|
||||
const borderTop = parseCSSPropertyToFloat(textarea, 'border-top');
|
||||
const borderBottom = parseCSSPropertyToFloat(textarea, 'border-bottom');
|
||||
let heightDelta = paddingTop + paddingBottom + borderTop + borderBottom;
|
||||
let heightNew = elTextarea.scrollHeight + heightDelta;
|
||||
|
||||
// If new height is less than 1 linem default to single line height
|
||||
const heightSingleLine = parseCSSPropertyToFloat(textarea, 'line-height') + heightDelta;
|
||||
if (heightNew < heightSingleLine) heightNew = heightSingleLine;
|
||||
|
||||
elTextarea.style.height = heightNew + 'px';
|
||||
}
|
||||
|
||||
|
||||
13
static/js/components/video.js
Normal file
13
static/js/components/video.js
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
function videoPlay(elemVideo) {
|
||||
if (!_loading) { // elemVideo.paused &&
|
||||
elemVideo.play();
|
||||
if (_verbose) { console.log("Playing video element: " + elemVideo.name)};
|
||||
}
|
||||
}
|
||||
|
||||
function videoPause(elemVideo) {
|
||||
elemVideo.pause();
|
||||
if (_verbose) { console.log("Pausing video element: " + elemVideo.name)};
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
var _loading = true;
|
||||
|
||||
function hookupPageContact() {
|
||||
_loading = false;
|
||||
}
|
||||
|
||||
function stylePageContact() {
|
||||
let elementEmail = $(idEmail);
|
||||
let elementName = $(idName);
|
||||
let elementMessage = $(idMessage);
|
||||
|
||||
elementEmail.css({
|
||||
width: "50%"
|
||||
});
|
||||
elementName.css({
|
||||
width: "40%"
|
||||
});
|
||||
elementMessage.css({
|
||||
width: "66%"
|
||||
});
|
||||
}
|
||||
33
static/js/dom.js
Normal file
33
static/js/dom.js
Normal file
@@ -0,0 +1,33 @@
|
||||
// Module for DOM manipulation
|
||||
export default class DOM {
|
||||
static updateElement(id, data) {
|
||||
const element = document.getElementById(id);
|
||||
if (element) {
|
||||
element.textContent = data;
|
||||
}
|
||||
}
|
||||
|
||||
// Add more DOM manipulation methods as needed
|
||||
|
||||
static convertForm2JSON(elementForm) {
|
||||
formData = {}
|
||||
formDataTmp = elementForm.serializeArray();
|
||||
formDataTmp.forEach((value, key) => {
|
||||
formData[key] = value;
|
||||
/*
|
||||
console.log('key: ' + key);
|
||||
console.log('value: ' + value);
|
||||
*/
|
||||
});
|
||||
return formData;
|
||||
}
|
||||
|
||||
static loadPageBody(contentNew) {
|
||||
let pageBody = document.querySelector(idPageBody);
|
||||
pageBody.innerHTML = contentNew;
|
||||
}
|
||||
|
||||
static getHashPageCurrent() {
|
||||
return document.body.dataset.page;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
var _loading = true;
|
||||
|
||||
function hookupPageHome() {
|
||||
// hookupVideos();
|
||||
|
||||
hookupButtonsContactUs();
|
||||
|
||||
_loading = false;
|
||||
}
|
||||
142
static/js/lib/common.js
Normal file
142
static/js/lib/common.js
Normal file
@@ -0,0 +1,142 @@
|
||||
|
||||
function getElementCurrentValue(element) {
|
||||
let returnVal = '';
|
||||
|
||||
if (!isEmpty(element)) {
|
||||
|
||||
if (element.type === "checkbox") {
|
||||
returnVal = element.checked;
|
||||
}
|
||||
/*
|
||||
else if (element.classList.contains(flagIsDatePicker)) {
|
||||
returnVal = getDatePickerDate(element, adjust4DayLightSavings);
|
||||
}
|
||||
*/
|
||||
else if (element.tagName === 'INPUT' || element.tagName === 'textarea' || element.tagName === 'select') {
|
||||
returnVal = element.value;
|
||||
}
|
||||
else {
|
||||
returnVal = element.textContent;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEmpty(returnVal)) returnVal = '';
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
function parseCSSPropertyToFloat(element, propertyName) {
|
||||
var propertyText = element.css(propertyName);
|
||||
|
||||
if (!isEmpty(propertyText)) {
|
||||
|
||||
propertyText = propertyText.replace('px', '');
|
||||
|
||||
if (!isValidNumber(propertyText, true)) return parseFloat(propertyText);
|
||||
}
|
||||
|
||||
return 0.00;
|
||||
}
|
||||
|
||||
function scrollToElement(parent, element) {
|
||||
// REQUIRED: parent has scroll-bar
|
||||
parent.scrollTop(parent.scrollTop() + (element.offset().top - parent.offset().top));
|
||||
}
|
||||
|
||||
function isElementInContainer(container, element) {
|
||||
|
||||
if (typeof jQuery === 'function') {
|
||||
if (container instanceof jQuery) container = container[0];
|
||||
if (element instanceof jQuery) element = element[0];
|
||||
}
|
||||
|
||||
var containerBounds = container.getBoundingClientRect();
|
||||
var elementBounds = element.getBoundingClientRect();
|
||||
|
||||
return (
|
||||
containerBounds.top <= elementBounds.top &&
|
||||
containerBounds.left <= elementBounds.left &&
|
||||
((elementBounds.top + elementBounds.height) <= (containerBounds.top + containerBounds.height)) &&
|
||||
((elementBounds.left + elementBounds.width) <= (containerBounds.left + containerBounds.width))
|
||||
);
|
||||
}
|
||||
|
||||
function getRowFromElement(element) {
|
||||
return document.querySelectorAll(element).closest('tr');
|
||||
}
|
||||
|
||||
function getCellFromElement(element) {
|
||||
return document.querySelectorAll(element).closest('td');
|
||||
}
|
||||
|
||||
function alertError(errorType, errorText) {
|
||||
alert(errorType + '\n' + errorText);
|
||||
}
|
||||
|
||||
function setPageToLoading(isLoading) {
|
||||
|
||||
if (isLoading) {
|
||||
document.querySelectorAll(document.body).classList.add(_dataLoadingFlag);
|
||||
}
|
||||
else {
|
||||
document.querySelectorAll(document.body).classList.remove(_dataLoadingFlag);
|
||||
}
|
||||
}
|
||||
|
||||
function setBackgroundToLoading(elId, isLoading) {
|
||||
|
||||
if (isEmpty(el)) {
|
||||
|
||||
var elObj = document.querySelectorAll(elId);
|
||||
|
||||
if (isLoading) {
|
||||
|
||||
setTimeout(function() {
|
||||
elObj.innerHTML = "";
|
||||
elObj.css({
|
||||
"background-image": "url(" + urlImgLoading + ")",
|
||||
"background-position": "center",
|
||||
"background-repeat": "no-repeat"
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
else {
|
||||
elObj.css("background-image", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function allowClick() {
|
||||
return !document.querySelectorAll("body").classList.contains(_dataLoadingFlag);
|
||||
}
|
||||
|
||||
function displayOverlay(message, show, force) {
|
||||
|
||||
if (show) {
|
||||
_overlayLoadingCount += 1;
|
||||
}
|
||||
else if (force) {
|
||||
_overlayLoadingCount = 0;
|
||||
}
|
||||
else {
|
||||
_overlayLoadingCount -= 1;
|
||||
if (_overlayLoadingCount < 0) _overlayLoadingCount = 0;
|
||||
}
|
||||
|
||||
var loadingImg = document.querySelectorAll(idImageLoading);
|
||||
var overlay = document.querySelectorAll(loadingImg.closest("div.overlay"));
|
||||
|
||||
if (_overlayLoadingCount == 0) {
|
||||
|
||||
// Prevent short glimpse of prev. content before switch to new content
|
||||
// caused by data load but not fully rendered
|
||||
setTimeout(function() {
|
||||
overlay.fadeOut();
|
||||
}, 100);
|
||||
}
|
||||
else if (show && _overlayLoadingCount == 1) {
|
||||
// only show once
|
||||
loadingImg.innerHTML = message;
|
||||
overlay.style.display = "";
|
||||
}
|
||||
}
|
||||
7
static/js/lib/constants.js
Normal file
7
static/js/lib/constants.js
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
const _dataLoadingFlag = 'data-loading'
|
||||
var _domParser = null;
|
||||
// var hashPageCurrent; // moved to layout
|
||||
const keyPublicStripe = 'pk_test_51OGrxlL7BuLKjoMpfpfw7bSmZZK1MhqMoQ5VhW2jUj7YtoEejO4vqnxKPiqTHHuh9U4qqkywbPCSI9TpFKtr4SYH007KHMWs68';
|
||||
var _pageCurrent = null;
|
||||
var _verbose = true;
|
||||
9
static/js/lib/events.js
Normal file
9
static/js/lib/events.js
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
function initialiseEventHandler(selectorElement, classInitialised, eventHandler) {
|
||||
document.querySelectorAll(selectorElement).forEach(function(element) {
|
||||
if (!element.classList.contains(classInitialised)) {
|
||||
element.classList.add(classInitialised);
|
||||
eventHandler(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
0
static/js/lib/extras.js
Normal file
0
static/js/lib/extras.js
Normal file
3
static/js/lib/init.js
Normal file
3
static/js/lib/init.js
Normal file
@@ -0,0 +1,3 @@
|
||||
// Shared JS file names: routing, main, shared, localStorage, appDialogs
|
||||
|
||||
|
||||
59
static/js/lib/local_storage.js
Normal file
59
static/js/lib/local_storage.js
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
// Local storage
|
||||
/*
|
||||
function getPageLocalStorage(pageHash) {
|
||||
|
||||
let ls;
|
||||
try {
|
||||
ls = JSON.parse(localStorage.getItem(pageHash));
|
||||
} catch {
|
||||
|
||||
}
|
||||
|
||||
if (isEmpty(ls)) return {}
|
||||
|
||||
return ls;
|
||||
}
|
||||
function getPageLocalStorageCurrent() {
|
||||
|
||||
return JSON.parse(localStorage.getItem(hashPageCurrent));
|
||||
}
|
||||
|
||||
function setPageLocalStorage(pageHash, newLS) {
|
||||
|
||||
localStorage.setItem(pageHash, JSON.stringify(newLS));
|
||||
}
|
||||
|
||||
function clearPageLocalStorage(pageHash) {
|
||||
localStorage.removeItem(pageHash);
|
||||
}
|
||||
|
||||
function setupPageLocalStorage(pageHash) {
|
||||
|
||||
let ls = getPageLocalStorage(pageHash);
|
||||
|
||||
if (isEmpty(ls)) ls = {};
|
||||
|
||||
setPageLocalStorage(pageHash, ls);
|
||||
}
|
||||
*/
|
||||
|
||||
function getLocalStorage(key) {
|
||||
return JSON.parse(localStorage.getItem(key));
|
||||
}
|
||||
|
||||
function setLocalStorage(key, newLS) {
|
||||
localStorage.setItem(key, JSON.stringify(newLS));
|
||||
}
|
||||
|
||||
/*
|
||||
function setupPageLocalStorageNext(pageHashNext) {
|
||||
let lsOld = getPageLocalStorage(hashPageCurrent);
|
||||
hashPageCurrent = pageHashNext;
|
||||
clearPageLocalStorage(hashPageCurrent);
|
||||
setupPageLocalStorage(hashPageCurrent);
|
||||
let lsNew = getPageLocalStorage(hashPageCurrent);
|
||||
lsNew[keyBasket] = (keyBasket in lsOld) ? lsOld[keyBasket] : {'items': []};
|
||||
setPageLocalStorage(hashPageCurrent, lsNew);
|
||||
}
|
||||
*/
|
||||
10
static/js/lib/utils.js
Normal file
10
static/js/lib/utils.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// Utility functions
|
||||
/*
|
||||
function $(selector) {
|
||||
return document.querySelector(selector);
|
||||
}
|
||||
|
||||
function $$(selector) {
|
||||
return document.querySelectorAll(selector);
|
||||
}
|
||||
*/
|
||||
146
static/js/lib/validation.js
Normal file
146
static/js/lib/validation.js
Normal file
@@ -0,0 +1,146 @@
|
||||
|
||||
// Argument validation
|
||||
/*
|
||||
function isNullOrWhitespace(v) {
|
||||
let txt = JSON.stringify(v).replace('/\s\g', '');
|
||||
return (txt == '' || 'null');
|
||||
}
|
||||
*/
|
||||
|
||||
function isEmpty(object) {
|
||||
|
||||
let isEmpty = true;
|
||||
|
||||
if (object !== null && object !== "null" && object !== undefined && object !== "undefined") {
|
||||
|
||||
if (object.length == undefined) {
|
||||
isEmpty = false; // object exists but isn't a collection
|
||||
}
|
||||
else if (typeof object === "function") {
|
||||
isEmpty = false; // object is function reference
|
||||
}
|
||||
else { // string or collection
|
||||
|
||||
let isString = (typeof object == "string");
|
||||
|
||||
if (isString) object = object.trim();
|
||||
|
||||
if (object.length > 0) {
|
||||
|
||||
if (isString) {
|
||||
isEmpty = false; // String greater than length 0
|
||||
}
|
||||
else {
|
||||
|
||||
if (typeof object[0] != "string") {
|
||||
isEmpty = false;
|
||||
}
|
||||
else {
|
||||
for(let i = 0; i < object.length; i++) {
|
||||
if (object[i] != "") {
|
||||
isEmpty = false;
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
function isValidNumber(value, positiveOnly) {
|
||||
return !isEmpty(value) && !isNaN(value) && (!positiveOnly || parseFloat(value) > 0);
|
||||
}
|
||||
|
||||
function getDataContentType(params) {
|
||||
|
||||
var data = null;
|
||||
var contentType = '';
|
||||
|
||||
if (!isEmpty(params)) {
|
||||
|
||||
if (typeof params === "string") {
|
||||
data = params;
|
||||
contentType = "application/x-www-form-urlencoded; charset=UTF-8";
|
||||
}
|
||||
else {
|
||||
data = JSON.stringify(params);
|
||||
contentType = "application/json; charset=UTF-8";
|
||||
}
|
||||
}
|
||||
|
||||
return { Data: data, ContentType: contentType };
|
||||
}
|
||||
|
||||
function arrayContainsItem(array, itemValue) {
|
||||
|
||||
var hasItem = false;
|
||||
|
||||
if (!isEmpty(array) && !isEmpty(itemValue)) {
|
||||
|
||||
var isJQueryElementArray = array[0] instanceof jQuery;
|
||||
|
||||
if (isJQueryElementArray) {
|
||||
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
|
||||
if (document.querySelectorAll(array[i]).is(itemValue)) {
|
||||
hasItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
var isDate = array[0] instanceof Date;
|
||||
|
||||
if (isDate) {
|
||||
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
|
||||
if (array[i].getTime() === itemValue.getTime()) {
|
||||
hasItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
|
||||
if (array[i] == itemValue) {
|
||||
hasItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hasItem;
|
||||
}
|
||||
|
||||
function dictHasKey(d, k) {
|
||||
return (k in d);
|
||||
}
|
||||
|
||||
function imageExists(url, callback) {
|
||||
|
||||
var img = new Image();
|
||||
|
||||
img.onload = function() { callback(true); };
|
||||
img.onerror = function() { callback(false); };
|
||||
img.src = url;
|
||||
}
|
||||
|
||||
function validateImageUrl(id, img) {
|
||||
imageExists(img, function(exists) {
|
||||
if (exists) {
|
||||
document.querySelectorAll("#" + id).css({ "background-image": "url(" + url + ")", "background-size": "35px 35px"})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
var _loading = true;
|
||||
|
||||
function hookupPageLicense() {
|
||||
_loading = false;
|
||||
}
|
||||
17
static/js/pages/page_accessibility_statement.js
Normal file
17
static/js/pages/page_accessibility_statement.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { PageBase } from "./page_base.js";
|
||||
|
||||
export class PageAccessibilityStatement extends PageBase {
|
||||
static hash = hashPageAccessibilityStatement;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
}
|
||||
|
||||
leave() {
|
||||
super.leave();
|
||||
}
|
||||
}
|
||||
46
static/js/pages/page_admin_home.js
Normal file
46
static/js/pages/page_admin_home.js
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
import { PageBase } from "./page_base.js";
|
||||
import { router } from "../router.js";
|
||||
|
||||
export class PageAdminHome extends PageBase {
|
||||
static hash = hashPageAdminHome;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
this.hookupAdminStore();
|
||||
}
|
||||
|
||||
hookupAdminStore() {
|
||||
this.hookupButtonNavStoreProductCategories();
|
||||
this.hookupButtonNavStoreProducts();
|
||||
this.hookupButtonNavStoreProductPermutations();
|
||||
this.hookupButtonNavStoreProductPrices();
|
||||
this.hookupButtonNavStoreStockItems();
|
||||
this.hookupButtonNavStoreProductVariations();
|
||||
|
||||
this.hookupButtonNavAdminStoreStripeProducts();
|
||||
this.hookupButtonNavAdminStoreStripePrices();
|
||||
}
|
||||
hookupButtonNavAdminStoreStripeProducts() {
|
||||
initialiseEventHandler('.' + flagNavAdminStoreStripeProducts, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
router.navigateToHash(hashPageAdminStoreStripeProducts);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavAdminStoreStripePrices() {
|
||||
initialiseEventHandler('.' + flagNavAdminStoreStripePrices, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
router.navigateToHash(hashPageAdminStoreStripePrices);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
leave() {
|
||||
super.leave();
|
||||
}
|
||||
}
|
||||
244
static/js/pages/page_base.js
Normal file
244
static/js/pages/page_base.js
Normal file
@@ -0,0 +1,244 @@
|
||||
import API from "../api.js";
|
||||
import { router } from "../router.js";
|
||||
|
||||
export class PageBase {
|
||||
constructor() {
|
||||
this.title = titlePageCurrent;
|
||||
// this.hash = hashPageCurrent;
|
||||
if (this.constructor === PageBase) {
|
||||
throw new Error("Cannot instantiate abstract class");
|
||||
}
|
||||
|
||||
if (!this.constructor.hash) {
|
||||
throw new Error(`Class ${this.constructor.name} must have a static hash attribute.`);
|
||||
}
|
||||
}
|
||||
|
||||
initialize() {
|
||||
throw new Error("Method 'init()' must be implemented.");
|
||||
}
|
||||
|
||||
sharedInitialize() {
|
||||
this.logInitialisation();
|
||||
this.hookupCommonElements();
|
||||
}
|
||||
|
||||
logInitialisation() {
|
||||
console.log('Initializing ' + this.title + ' page');
|
||||
}
|
||||
|
||||
hookupCommonElements() {
|
||||
// hookupVideos();
|
||||
this.hookupNavigation();
|
||||
this.hookupImagesLogo();
|
||||
}
|
||||
|
||||
hookupNavigation() {
|
||||
/* Can be removed: */
|
||||
console.log("hooking up navigation");
|
||||
let overlayHamburger = document.querySelector(idOverlayHamburger);
|
||||
let hamburgerOptions = overlayHamburger.querySelectorAll('div.' + flagRow);
|
||||
let countOptions = hamburgerOptions.length;
|
||||
console.log('count nav options: ', countOptions);
|
||||
// overlayHamburger.css('height', (countOptions * 27) + 'px');
|
||||
/* end of can be removed */
|
||||
|
||||
initialiseEventHandler(idButtonHamburger, flagInitialised, function(buttonToggleOverlayNavigation) {
|
||||
buttonToggleOverlayNavigation.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
let overlayHamburger = document.querySelector(idOverlayHamburger);
|
||||
if (overlayHamburger.classList.contains(flagCollapsed)) {
|
||||
overlayHamburger.classList.remove(flagCollapsed);
|
||||
overlayHamburger.classList.add(flagExpanded);
|
||||
} else {
|
||||
overlayHamburger.classList.remove(flagExpanded);
|
||||
overlayHamburger.classList.add(flagCollapsed);
|
||||
}
|
||||
// overlayHamburger.classList.add(flagInitialised);
|
||||
});
|
||||
});
|
||||
|
||||
this.hookupButtonNavHome();
|
||||
this.hookupButtonNavServices();
|
||||
this.hookupButtonNavContact();
|
||||
this.hookupButtonNavUserAccount();
|
||||
this.hookupButtonNavUserLogout();
|
||||
this.hookupButtonNavUserLogin();
|
||||
this.hookupButtonNavStoreHome();
|
||||
this.hookupButtonNavStoreProductPermutations();
|
||||
this.hookupButtonNavStoreStockItems();
|
||||
this.hookupButtonNavAdminHome();
|
||||
}
|
||||
hookupButtonNavHome() {
|
||||
initialiseEventHandler('.' + flagNavHome, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageHome);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavServices() {
|
||||
initialiseEventHandler('.' + flagNavServices, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
console.log('going to services page');
|
||||
router.navigateToHash(hashPageServices);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavContact() {
|
||||
initialiseEventHandler('.' + flagNavContact, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageContact);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavUserAccount() {
|
||||
initialiseEventHandler('.' + flagNavUserAccount, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageUserAccount);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavUserLogout() {
|
||||
initialiseEventHandler('.' + flagNavUserLogout, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageUserLogout);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavUserLogin() {
|
||||
initialiseEventHandler('.' + flagNavUserLogin, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
// router.navigateToHash(hashPageUserLogin);
|
||||
/*
|
||||
let dataRequest = {};
|
||||
dataRequest[keyCallback] = hashPageCurrent;
|
||||
console.log('sending data to user login controller: ');
|
||||
console.log(dataRequest);
|
||||
*/
|
||||
API.loginUser()
|
||||
.then(function(response) {
|
||||
if (response.Success) {
|
||||
window.app.router.navigateToUrl(response[keyCallback], null, false);
|
||||
} else {
|
||||
alertError("Error", response.Message);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreHome() {
|
||||
initialiseEventHandler('.' + flagNavStoreHome, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreHome);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreProductCategories() {
|
||||
initialiseEventHandler('.' + flagNavStoreProductCategories, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreProductCategories);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreProducts() {
|
||||
initialiseEventHandler('.' + flagNavStoreProducts, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreProducts);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreProductPermutations() {
|
||||
initialiseEventHandler('.' + flagNavStoreProductPermutations, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreProductPermutations);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreProductPrices() {
|
||||
initialiseEventHandler('.' + flagNavStoreProductPrices, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreProductPrices);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreProductVariations() {
|
||||
initialiseEventHandler('.' + flagNavStoreProductVariations, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreProductVariations);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreStockItems() {
|
||||
initialiseEventHandler('.' + flagNavStoreStockItems, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreStockItems);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavAdminHome() {
|
||||
initialiseEventHandler('.' + flagNavAdminHome, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageAdminHome);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
hookupImagesLogo() {
|
||||
let selectorImagesLogo = "img." + flagImageLogo;
|
||||
initialiseEventHandler(selectorImagesLogo, flagInitialised, function(imageLogo) {
|
||||
imageLogo.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageHome);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
hookupOverlayFromId(idOverlay) {
|
||||
initialiseEventHandler(idOverlay, flagInitialised, function(overlay) {
|
||||
overlay.querySelector('button.' + flagClose).addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
overlay.css('display', 'none');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
hookupButtonsContactUs() {
|
||||
let selectorButtonsContactUs = "." + flagNavContact;
|
||||
initialiseEventHandler(selectorButtonsContactUs, flagInitialised, function(buttonContactUs) {
|
||||
buttonContactUs.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageContact);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
hookupVideos() {
|
||||
initialiseEventHandler('video', flagInitialised, function(video) {
|
||||
video.addEventListener("mouseover", videoPlay(video));
|
||||
video.addEventListener("mouseout", videoPause(video));
|
||||
});
|
||||
}
|
||||
|
||||
leave() {
|
||||
console.log('Leaving ' + this.title + ' page');
|
||||
_pageCurrent = null;
|
||||
if (this.constructor === PageBase) {
|
||||
throw new Error("Must implement leave() method.");
|
||||
}
|
||||
}
|
||||
}
|
||||
14
static/js/pages/page_contact.js
Normal file
14
static/js/pages/page_contact.js
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
import { PageBase } from "./page_base.js";
|
||||
|
||||
export class PageContact extends PageBase {
|
||||
static hash = hashPageContact;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
}
|
||||
}
|
||||
19
static/js/pages/page_home.js
Normal file
19
static/js/pages/page_home.js
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
import { PageBase } from "./page_base.js";
|
||||
|
||||
export class PageHome extends PageBase {
|
||||
static hash = hashPageHome;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
this.hookupButtonsContactUs();
|
||||
}
|
||||
|
||||
leave() {
|
||||
super.leave();
|
||||
}
|
||||
}
|
||||
18
static/js/pages/page_license.js
Normal file
18
static/js/pages/page_license.js
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
import { PageBase } from "./page_base.js";
|
||||
|
||||
export class PageLicense extends PageBase {
|
||||
static hash = hashPageLicense;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
}
|
||||
|
||||
leave() {
|
||||
super.leave();
|
||||
}
|
||||
}
|
||||
19
static/js/pages/page_services.js
Normal file
19
static/js/pages/page_services.js
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
import { PageBase } from "./page_base.js";
|
||||
|
||||
export class PageServices extends PageBase {
|
||||
static hash = hashPageServices;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
}
|
||||
|
||||
leave() {
|
||||
super.leave();
|
||||
}
|
||||
}
|
||||
|
||||
382
static/js/pages/page_store_base.js
Normal file
382
static/js/pages/page_store_base.js
Normal file
@@ -0,0 +1,382 @@
|
||||
|
||||
import { PageBase } from "./page_base.js";
|
||||
|
||||
export class PageStoreHome extends PageBase {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
sharedInitialize() {
|
||||
super.sharedInitialize();
|
||||
this.hookupFiltersStore();
|
||||
this.hookupStoreHome();
|
||||
}
|
||||
|
||||
|
||||
hookupStore() {
|
||||
console.log('hookup store start');
|
||||
console.log(_pathHost);
|
||||
hookupLocalStorageStore();
|
||||
hookupBasket();
|
||||
hookupBtnsAdd2Basket();
|
||||
}
|
||||
|
||||
hookupBasket() {
|
||||
|
||||
// const containerBasket = document.querySelectorAll(idContainerBasket);
|
||||
toggleShowBtnCheckout(); // containerBasket
|
||||
hookupBtnCheckout();
|
||||
hookupBtnsPlusMinus();
|
||||
hookupBasketAddInputs();
|
||||
hookupBasketEditInputs();
|
||||
hookupBtnsDelete();
|
||||
}
|
||||
|
||||
hookupLocalStorageStore() {
|
||||
|
||||
// setupPageLocalStorage(hashPageCurrent);
|
||||
// let lsPage = getPageLocalStorage(hashPageCurrent);
|
||||
// let d = {}
|
||||
// d[keyBasket] = getLocalStorage(keyBasket); // (keyBasket in lsPage) ? lsPage[keyBasket] : {'items': []};
|
||||
// console.log('d:'); console.log(d);
|
||||
let basket;
|
||||
let createNewBasket = true;
|
||||
if (true) { // !isUserLoggedIn) {
|
||||
try {
|
||||
basket = getLocalStorage(keyBasket);
|
||||
console.log('basket found: '); console.log(basket);
|
||||
createNewBasket = isEmpty(basket);
|
||||
}
|
||||
catch {
|
||||
|
||||
}
|
||||
// lsPage[keyBasket] = ajaxJSONData(keyBasket, hashStoreBasketLoad, d, loadBasket, false);
|
||||
}
|
||||
else {
|
||||
// store basket from server in localStorage
|
||||
|
||||
}
|
||||
if (createNewBasket) {
|
||||
basket = {};
|
||||
basket[keyItems] = [];
|
||||
basket[keyIsIncludedVAT] = true;
|
||||
basket[keyIdCurrency] = 1;
|
||||
basket[keyIdRegionDelivery] = 1;
|
||||
setLocalStorage(keyBasket, basket);
|
||||
console.log("new local basket created");
|
||||
}
|
||||
let ajaxData = {}
|
||||
ajaxData[keyBasket] = basket;
|
||||
// console.log("hookupLocalStorageStore\nhashStoreBasketLoad: " + hashStoreBasketLoad + "\n");
|
||||
// ajaxData[keyIsIncludedVAT] = getLocalStorage(keyIsIncludedVAT);
|
||||
console.log('ajax:' + ajaxData);
|
||||
ajaxJSONData(keyBasket, mapHashToController(hashStoreBasketLoad), ajaxData, loadBasket, false);
|
||||
}
|
||||
|
||||
/*
|
||||
setupPageLocalStorageNextStore(pageHashNext) {
|
||||
let lsOld = getPageLocalStorage(hashPageCurrent);
|
||||
hashPageCurrent = pageHashNext;
|
||||
clearPageLocalStorage(hashPageCurrent);
|
||||
setupPageLocalStorage(hashPageCurrent);
|
||||
let lsNew = getPageLocalStorage(hashPageCurrent);
|
||||
lsNew[keyBasket] = (keyBasket in lsOld) ? lsOld[keyBasket] : {'items': []};
|
||||
setPageLocalStorage(hashPageCurrent, lsNew);
|
||||
}
|
||||
|
||||
goToPageStore(pageHash, parameters_dict) {
|
||||
|
||||
let lsOld = getPageLocalStorage(pageHashCurrent);
|
||||
pageHashCurrent = pageHash;
|
||||
clearPageLocalStorage(pageHashCurrent);
|
||||
setupPageLocalStorage(pageHashCurrent);
|
||||
let lsNew = getPageLocalStorage(pageHashCurrent);
|
||||
lsNew[keyBasket] = (keyBasket in lsOld) ? lsOld[keyBasket] : {'items': []};
|
||||
setPageLocalStorage(pageHashCurrent, lsNew);
|
||||
|
||||
goToPage(pageHash, parameters_dict);
|
||||
}
|
||||
*/
|
||||
|
||||
toggleShowBtnCheckout() { // containerBasket
|
||||
|
||||
console.log("toggling checkout button");
|
||||
|
||||
const btnCheckout = document.querySelectorAll(idBtnCheckout);
|
||||
const labelBasketEmpty = document.querySelectorAll(idLabelBasketEmpty);
|
||||
|
||||
// let lsPage = getPageLocalStorage(hashPageCurrent);
|
||||
// let basket = lsPage[keyBasket]['items'];
|
||||
// let products = containerBasket.filter('');
|
||||
let basket = getLocalStorage(keyBasket);
|
||||
|
||||
if (basket['items'].length == 0) {
|
||||
btnCheckout.style.display = "none";
|
||||
labelBasketEmpty.style.display = "";
|
||||
} else {
|
||||
btnCheckout.style.display = "";
|
||||
labelBasketEmpty.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
getBasket() {
|
||||
|
||||
lsShared = getPageLocalStorage(keyShared);
|
||||
|
||||
return lsShared[keyBasket];
|
||||
}
|
||||
*/
|
||||
|
||||
hookupBtnsAdd2Basket() {
|
||||
|
||||
// let product, btn, lsPage;
|
||||
// [' + attrIdProduct + '=' + elBtn.attr(attrIdProduct) + ']
|
||||
document.querySelectorAll('form[' + attrFormType + '="' + typeFormBasketAdd +'"]').each(function() {
|
||||
|
||||
var form = this;
|
||||
|
||||
initialiseEventHandler(form, flagInitialised, function() {
|
||||
// form = document.querySelectorAll(form);
|
||||
form.submit(function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// lsShared = getPageLocalStorage(keyShared);
|
||||
console.log("adding to basket for product ID: ", form.attr(attrIdProduct));
|
||||
|
||||
ajaxData = {};
|
||||
ajaxData[keyIdProduct] = form.attr(attrIdProduct);
|
||||
ajaxData[keyIdPermutation] = form.attr(attrIdPermutation);
|
||||
basket = getLocalStorage(keyBasket);
|
||||
ajaxData[keyBasket] = basket; // lsShared[keyBasket];
|
||||
console.log("basket before add: ", basket);
|
||||
ajaxData[keyForm] = convertForm2JSON(form); // formData; // form.serialize();
|
||||
console.log("ajax data:"); console.log(ajaxData);
|
||||
ajaxJSONData('add2Basket', mapHashToController(hashStoreBasketAdd), ajaxData, loadBasket, false); // { product_id: form.attr(attrIdProduct), basket_local: lsPage[keyBasket] , }
|
||||
});
|
||||
console.log("basket add method added for product ID: ", form.attr(attrIdProduct));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
hookupBtnCheckout() {
|
||||
|
||||
console.log("hooking up checkout button");
|
||||
|
||||
const btnCheckout = document.querySelectorAll(idBtnCheckout);
|
||||
// let lsPage = getPageLocalStorage(hashPageCurrent);
|
||||
initialiseEventHandler(btnCheckout, flagInitialised, function() {
|
||||
btnCheckout.addEventListener("click", function() {
|
||||
/*
|
||||
//setupPageLocalStorageNext(hashPageStoreBasket);
|
||||
let basket = getLocalStorage(keyBasket);
|
||||
// goToPage(hashPageStoreBasket);
|
||||
let ajaxData = {};
|
||||
ajaxData[keyBasket] = basket;
|
||||
|
||||
ajaxJSONData('checkout', mapHashToController(hashPageStoreBasket), ajaxData, null, false);
|
||||
*/
|
||||
goToPage(hashPageStoreBasket);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
loadBasket(response) {
|
||||
|
||||
let basketContainer = document.querySelectorAll(idBasketContainer);
|
||||
// let lsPage = getPageLocalStorage(hashPageCurrent);
|
||||
// let lsShared = getPageLocalStorage(keyShared);
|
||||
|
||||
console.log('ajax:'); console.log(response.data);
|
||||
|
||||
let basket = response.data[keyBasket]; // JSON.parse(response.data[keyBasket]);
|
||||
// setPageLocalStorage(keyShared, lsShared);
|
||||
setLocalStorage(keyBasket, basket);
|
||||
items = basket['items'];
|
||||
// console.log('old basket:'); console.log(basketContainer.innerHTML);
|
||||
// console.log('setting basket:'); console.log(response.data['html_block']);
|
||||
basketContainer.innerHTML = response.data['html_block'];
|
||||
|
||||
/*
|
||||
if (items.length > 0) {
|
||||
let basketItem;
|
||||
for (let indexItemBasket = 0; indexItemBasket < items.length; indexItemBasket++) {
|
||||
basketItem = items[indexItemBasket];
|
||||
if (basketItem[keyQuantity] > 1) {
|
||||
elInput = basketContainer.querySelector('form[' + attrFormType + '=' + typeFormBasketEdit + ']').querySelector('input[type="number"]');
|
||||
// todo : what is missing?
|
||||
elInput.val(basketItem[keyQuantity]);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
hookupBasket();
|
||||
}
|
||||
|
||||
getFormProductSelector(typeForm, elementInForm) {
|
||||
idPermutation = elementInForm.attr(attrIdPermutation);
|
||||
console.log('idPermutation: ', idPermutation);
|
||||
hasPermutation = !isEmpty(idPermutation);
|
||||
console.log('has permutation: ', hasPermutation);
|
||||
selectorIdPermutation = hasPermutation ? '[' + attrIdPermutation + '=' + idPermutation + ']' : '';
|
||||
return 'form[' + attrFormType + '="' + typeForm + '"][' + attrIdProduct + '=' + elementInForm.attr(attrIdProduct) + ']' + selectorIdPermutation;
|
||||
}
|
||||
|
||||
hookupBtnsPlusMinus() {
|
||||
|
||||
// let elBtn, elInput, newVal, product;
|
||||
const minVal = 1;
|
||||
// Basket Add
|
||||
// Increment
|
||||
document.querySelectorAll('div.btn-increment[' + attrFormType + '=' + typeFormBasketAdd + ']').each(function() {
|
||||
let elBtn = this;
|
||||
initialiseEventHandler(elBtn, flagInitialised, function(){
|
||||
elBtn.addEventListener("click", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
let elInput = document.querySelectorAll(getFormProductSelector(typeFormBasketAdd, elBtn)).querySelector('input[type="number"]');
|
||||
// console.log('input selector ='); console.log('form[' + attrFormType + '=' + elBtn.attr(attrFormType) + '][' + attrIdProduct + '=' + elBtn.attr(attrIdProduct) + ']');
|
||||
let newVal = parseInt(getElementCurrentValue(elInput));
|
||||
if (isNaN(newVal)) newVal = minVal;
|
||||
newVal += 1;
|
||||
elInput.val(newVal);
|
||||
});
|
||||
});
|
||||
});
|
||||
// Decrement
|
||||
document.querySelectorAll('div.btn-decrement[' + attrFormType + '=' + typeFormBasketAdd + ']').each(function() {
|
||||
let elBtn = this;
|
||||
initialiseEventHandler(elBtn, flagInitialised, function(){
|
||||
elBtn.addEventListener("click", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
// let product = document.querySelectorAll('.card.subcard[' + attrIdProduct +'=' + elBtn.attr(attrIdProduct) + ']');
|
||||
let elInput= document.querySelectorAll(getFormProductSelector(typeFormBasketAdd, elBtn)).querySelector('input[type="number"]');
|
||||
let newVal = parseInt(getElementCurrentValue(elInput));
|
||||
if (isNaN(newVal)) newVal = minVal;
|
||||
newVal = Math.max(minVal, newVal - 1);
|
||||
elInput.val(newVal);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Basket Edit
|
||||
// Increment
|
||||
document.querySelectorAll('div.btn-increment[' + attrFormType + '=' + typeFormBasketEdit + ']').each(function() {
|
||||
let elBtn = this;
|
||||
initialiseEventHandler(elBtn, flagInitialised, function(){
|
||||
elBtn.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
// basketItem = document.querySelectorAll('.card.subcard[' + attrIdProduct +'=' + elBtn.attr(attrIdProduct) + ']');
|
||||
let elInput = document.querySelectorAll(getFormProductSelector(typeFormBasketEdit, elBtn)).querySelector('input[type="number"]');
|
||||
// console.log('input selector ='); console.log('form[' + attrFormType + '=' + elBtn.attr(attrFormType) + '][' + attrIdProduct + '=' + elBtn.attr(attrIdProduct) + ']');
|
||||
let newVal = parseInt(getElementCurrentValue(elInput));
|
||||
if (isNaN(newVal)) newVal = minVal;
|
||||
newVal += 1;
|
||||
elInput.val(newVal);
|
||||
elInput.trigger("change");
|
||||
});
|
||||
});
|
||||
});
|
||||
// Decrement
|
||||
document.querySelectorAll('div.btn-decrement[' + attrFormType + '=' + typeFormBasketEdit + ']').each(function() {
|
||||
let elBtn = this;
|
||||
initialiseEventHandler(elBtn, flagInitialised, function(){
|
||||
elBtn.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
let elInput= document.querySelectorAll(getFormProductSelector(typeFormBasketEdit, elBtn)).querySelector('input[type="number"]');
|
||||
let newVal = parseInt(getElementCurrentValue(elInput));
|
||||
if (isNaN(newVal)) newVal = minVal;
|
||||
newVal = Math.max(minVal, newVal - 1);
|
||||
elInput.val(newVal);
|
||||
elInput.trigger("change");
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
hookupBasketAddInputs() {
|
||||
|
||||
document.querySelectorAll('form[' + attrFormType + '=' + typeFormBasketAdd + ']').each(function() {
|
||||
let elForm = this;
|
||||
let elInput = elForm.querySelector('input[type="number"]');
|
||||
initialiseEventHandler(elInput, flagInitialised, function(){
|
||||
elInput.addEventListener("change", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
});
|
||||
elInput.addEventListener("click", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
hookupBasketEditInputs() {
|
||||
|
||||
// let elBtn, elInput, newVal, product;
|
||||
const minVal = 1;
|
||||
// Basket Edit
|
||||
// Increment
|
||||
document.querySelectorAll('form[' + attrFormType + '=' + typeFormBasketEdit + ']').each(function() {
|
||||
let elForm = this;
|
||||
let elInput = elForm.querySelector('input[type="number"]');
|
||||
initialiseEventHandler(elInput, flagInitialised, function(){
|
||||
elInput.addEventListener("change", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
// let lsPage = getPageLocalStorageCurrent();
|
||||
d = {};
|
||||
d[keyBasket]= getLocalStorage(keyBasket); // lsPage[keyBasket]; // JSON.parse(lsPage[keyBasket]);
|
||||
d[keyIdProduct] = elForm.attr(attrIdProduct); // lsPage[keyIdProduct];
|
||||
d[keyIdPermutation] = elForm.attr(attrIdPermutation);
|
||||
// d[keyQuantity] = lsPage[keyQuantity];
|
||||
d[keyForm] = convertForm2JSON(elForm);
|
||||
d[keyForm][keyQuantity] = elInput.val();
|
||||
console.log('sending data to basket edit controller: '); console.log(d);
|
||||
ajaxJSONData('basket update', mapHashToController(hashStoreBasketEdit), d, loadBasket, false);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
hookupBtnsDelete() {
|
||||
|
||||
console.log('hooking up basket item delete buttons');
|
||||
// let elForm, elDelete;
|
||||
// const minVal = 1;
|
||||
// Basket Add
|
||||
// Increment
|
||||
document.querySelectorAll('form[' + attrFormType + '=' + typeFormBasketEdit + ']').each(function() {
|
||||
let elForm = this;
|
||||
let elDelete = elForm.querySelector('a.' + flagBasketItemDelete);
|
||||
initialiseEventHandler(elDelete, flagInitialised, function(){
|
||||
elDelete.addEventListener("click", function(event) {
|
||||
event.stopPropagation();
|
||||
ajaxData = {};
|
||||
ajaxData[keyBasket]= getLocalStorage(keyBasket);
|
||||
ajaxData[keyIdProduct] = elForm.attr(attrIdProduct);
|
||||
ajaxData[keyIdPermutation] = elForm.attr(attrIdPermutation);
|
||||
console.log('sending data to basket delete controller: '); console.log(ajaxData);
|
||||
ajaxJSONData('basket update', mapHashToController(hashStoreBasketDelete), ajaxData, loadBasket, false);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getCurrencySelected() {
|
||||
let elementSelectorCurrency = document.querySelectorAll(idSelectorCurrency);
|
||||
let selectedCurrency = elementSelectorCurrency.val();
|
||||
console.log("selected currency: ", selectedCurrency);
|
||||
return selectedCurrency;
|
||||
}
|
||||
|
||||
addMetadataBasketToJSON(jsonData) {
|
||||
jsonData[keyIdCurrency] = getLocalStorage(keyIdCurrency);
|
||||
jsonData[keyIdRegionDelivery] = getLocalStorage(keyIdRegionDelivery);
|
||||
jsonData[keyIsIncludedVAT] = getLocalStorage(keyIsIncludedVAT);
|
||||
return jsonData;
|
||||
}
|
||||
}
|
||||
191
static/js/pages/page_store_basket.js
Normal file
191
static/js/pages/page_store_basket.js
Normal file
@@ -0,0 +1,191 @@
|
||||
import { PageBase } from "./page_base.js";
|
||||
|
||||
export class PageStoreBasket extends PageBase {
|
||||
static hash = hashPageStoreBasket;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
this.hookupStoreCardsInfo();
|
||||
this.hookupOverlaysStoreBasketInfo();
|
||||
this.hookupBtnCheckoutSession();
|
||||
}
|
||||
|
||||
|
||||
hookupStoreCardsInfo() {
|
||||
|
||||
document.querySelectorAll(idContainerInfoDelivery).addEventListener("click", function(event) {
|
||||
console.log("delivery modal display method");
|
||||
document.querySelectorAll(idOverlayInfoDelivery).css('display', 'block');
|
||||
});
|
||||
|
||||
document.querySelectorAll(idContainerInfoBilling).addEventListener("click", function(event) {
|
||||
console.log("billing modal display method");
|
||||
document.querySelectorAll(idOverlayInfoBilling).css('display', 'block');
|
||||
});
|
||||
}
|
||||
|
||||
hookupOverlaysStoreBasketInfo() {
|
||||
|
||||
let elOverlay, elForm;
|
||||
|
||||
// Delivery
|
||||
elOverlay = document.querySelectorAll(idOverlayInfoDelivery);
|
||||
elForm = elOverlay.querySelector('form');
|
||||
|
||||
hookupOverlay(elOverlay);
|
||||
initialiseEventHandler(elForm, flagInitialised, function() {
|
||||
elForm.submit(function(event) {
|
||||
elForm = document.querySelectorAll(elForm);
|
||||
event.preventDefault();
|
||||
console.log("delivery submit method");
|
||||
|
||||
ajaxData = {};
|
||||
ajaxData[keyInfoType] = keyInfoDelivery;
|
||||
ajaxData = convertFormBilling2JSON(ajaxData, idOverlayInfoDelivery);
|
||||
|
||||
ajaxJSONData('info delivery', mapHashToController(hashStoreBasketInfo), ajaxData, loadInfoAddress, false);
|
||||
// document.querySelectorAll(idOverlayInfoDelivery).css('display', 'none');
|
||||
});
|
||||
});
|
||||
|
||||
// Billing
|
||||
elOverlay = document.querySelectorAll(idOverlayInfoBilling);
|
||||
elForm = elOverlay.querySelector('form');
|
||||
|
||||
hookupOverlay(elOverlay);
|
||||
initialiseEventHandler(elForm, flagInitialised, function() {
|
||||
elForm.submit(function(event) {
|
||||
event.preventDefault();
|
||||
console.log("billing submit method");
|
||||
|
||||
ajaxData = {};
|
||||
ajaxData[keyInfoType] = keyInfoBilling;
|
||||
ajaxData = convertFormBilling2JSON(ajaxData, idOverlayInfoBilling); // formData; // form.serialize();
|
||||
|
||||
ajaxJSONData('info billing', mapHashToController(hashStoreBasketInfo), ajaxData, loadInfoAddress, false);
|
||||
// document.querySelectorAll(idOverlayInfoBilling).css('display', 'none');
|
||||
});
|
||||
});
|
||||
let keys = [keyNameFull, keyPhoneNumber, keyPostcode, keyAddress1, keyCity, keyCounty];
|
||||
for (var k in keys) {
|
||||
elForm.querySelector('#' + keys[k]).removeAttr('required');
|
||||
}
|
||||
}
|
||||
|
||||
loadInfoAddress(response) {
|
||||
|
||||
console.log('ajax:'); console.log(response.data);
|
||||
let infoType = response.data[keyInfoType];
|
||||
let infoAddress = response.data[infoType];
|
||||
setLocalStorage(infoType, infoAddress);
|
||||
|
||||
// update webpage elements in background
|
||||
if (infoType == keyInfoBilling) {
|
||||
|
||||
let container = document.querySelectorAll(idContainerInfoBilling);
|
||||
if (infoAddress[keyInfoIdentical]) {
|
||||
container.querySelector('div').innerHTML = "Same as delivery address";
|
||||
} else {
|
||||
container.querySelector('div').innerHTML = "<strong>" + infoAddress[keyNameFull] + '</strong> at <strong>' + infoAddress[keyPostcode] + "</strong>";
|
||||
}
|
||||
|
||||
document.querySelectorAll(idOverlayInfoBilling).css('display', 'none');
|
||||
|
||||
document.querySelectorAll(idOverlayInfoBilling).querySelector('form').classList.add(flagSubmitted);
|
||||
} else {
|
||||
|
||||
let container = document.querySelectorAll(idContainerInfoDelivery);
|
||||
container.querySelector('div').innerHTML = "<strong>" + infoAddress[keyNameFull] + '</strong> at <strong>' + infoAddress[keyPostcode] + "</strong>";
|
||||
|
||||
document.querySelectorAll(idOverlayInfoDelivery).css('display', 'none');
|
||||
|
||||
document.querySelectorAll(idOverlayInfoDelivery).querySelector('form').classList.add(flagSubmitted);
|
||||
}
|
||||
}
|
||||
|
||||
convertFormBilling2JSON(ajaxData, idOverlayInfo) {
|
||||
|
||||
let elOverlay, elForm, elOverlayDelivery, elFormDelivery;
|
||||
|
||||
elOverlay = document.querySelectorAll(idOverlayInfo);
|
||||
elForm = elOverlay.querySelector('form');
|
||||
elOverlay = document.querySelectorAll(idOverlayInfoDelivery);
|
||||
elForm = elOverlay.querySelector('form');
|
||||
|
||||
console.log('converting billing form to json\nform ID: ' + elForm.id);
|
||||
ajaxData[keyForm] = convertForm2JSON(elForm); // formData; // form.serialize();
|
||||
let keys = [keyNameFull, keyPhoneNumber, keyPostcode, keyAddress1, keyAddress2, keyCity, keyCounty];
|
||||
console.log('ajaxData:');
|
||||
console.log(ajaxData);
|
||||
ajaxData[keyForm][keyInfoIdentical] = getElementCurrentValue(elForm.querySelector('#' + keyInfoIdentical));
|
||||
for (var k in keys) {
|
||||
if (idOverlayInfo == idOverlayInfoBilling && ajaxData[keyForm][keyInfoIdentical]) {
|
||||
ajaxData[keyForm][keys[k]] = getElementCurrentValue(elFormDelivery.querySelector('#' + keys[k]));
|
||||
} else {
|
||||
ajaxData[keyForm][keys[k]] = getElementCurrentValue(elForm.querySelector('#' + keys[k]));
|
||||
}
|
||||
}
|
||||
console.log('ajaxData:');
|
||||
console.log(ajaxData);
|
||||
return ajaxData;
|
||||
}
|
||||
|
||||
hookupBtnCheckoutSession() {
|
||||
let btnCheckout = document.querySelectorAll(idBtnCheckout);
|
||||
btnCheckout.classList.remove(flagInitialised);
|
||||
initialiseEventHandler(idBtnCheckout, flagInitialised, function() {
|
||||
|
||||
btnCheckout.removeEventListener("click");
|
||||
btnCheckout.addEventListener("click", function(event) {
|
||||
|
||||
|
||||
//setupPageLocalStorageNext(hashPageStoreBasket);
|
||||
let basket = getLocalStorage(keyBasket);
|
||||
// goToPage(hashPageStoreBasket);
|
||||
let ajaxData = {};
|
||||
ajaxData[keyBasket] = basket;
|
||||
ajaxData = convertFormBilling2JSON(ajaxData, idOverlayInfoDelivery);
|
||||
ajaxData = convertFormBilling2JSON(ajaxData, idOverlayInfoBilling);
|
||||
ajaxData[key_code_currency] = getCurrencySelected();
|
||||
// ajaxData[keyIsSubscription] = false; // only checkout one-time payment items for now
|
||||
|
||||
ajaxJSONData('checkout session', mapHashToController(hashPageStoreCheckout), ajaxData, handleResponseCheckout, false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
handleResponseCheckout(response) {
|
||||
// let tmpData = {};
|
||||
// tmpData[keyIdCheckout] = response.data[keyIdCheckout]
|
||||
// goToPage(hashPageStoreCheckoutSession, tmpData);
|
||||
window.location.href = response.data[keyUrlCheckout]
|
||||
}
|
||||
|
||||
hookupBtnFormBillingCopy() {
|
||||
|
||||
// let elBtn = document.querySelectorAll(idBtnFormBillingCopy);
|
||||
|
||||
initialiseEventHandler(idBtnFormBillingCopy, flagInitialised, function() {
|
||||
document.querySelectorAll(idBtnFormBillingCopy).addEventListener("click", function (event) {
|
||||
|
||||
let keys = [keyNameFull, keyPhoneNumber, keyPostcode, keyAddress1, keyAddress2, keyCity, keyCounty];
|
||||
|
||||
let elFormBilling = document.querySelectorAll(idOverlayInfoBilling).querySelector('form');
|
||||
let elFormDelivery = document.querySelectorAll(idOverlayInfoDelivery).querySelector('form');
|
||||
|
||||
for (var k in keys) {
|
||||
elFormBilling.querySelector('#' + keys[k]).value = getElementCurrentValue(elFormDelivery.querySelector('#' + keys[k]));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
leave() {
|
||||
super.leave();
|
||||
}
|
||||
}
|
||||
174
static/js/pages/page_store_home.js
Normal file
174
static/js/pages/page_store_home.js
Normal file
@@ -0,0 +1,174 @@
|
||||
|
||||
import { PageBase } from "./page_base.js";
|
||||
|
||||
export class PageStoreHome extends PageBase {
|
||||
static hash = hashPageStoreHome;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
this.hookupFiltersStore();
|
||||
this.hookupStoreHome();
|
||||
}
|
||||
|
||||
|
||||
hookupFiltersStore() {
|
||||
hookupFilterCurrency();
|
||||
hookupFilterDeliveryRegion();
|
||||
hookupFilterIsIncludedVAT();
|
||||
}
|
||||
|
||||
hookupFilterCurrency() {
|
||||
/*
|
||||
let elForm = document.querySelectorAll(idFormCurrency);
|
||||
let elSelector = document.querySelectorAll(elForm.querySelector('select')[0]);
|
||||
initialiseEventHandler(elSelector, flagInitialised, function(){
|
||||
elForm = document.querySelectorAll(idFormCurrency);
|
||||
elSelector.addEventListener("change", function(event) {
|
||||
ajaxData = {};
|
||||
ajaxData[keyForm] = convertForm2JSON(elForm);
|
||||
console.log('sending data to currency selector controller: '); console.log(ajaxData);
|
||||
ajaxJSONData('select currency', mapHashToController(hashStoreSelectCurrency), ajaxData, function() { window.location.reload() }, false);
|
||||
|
||||
let optionSelected = elSelector.options[elSelector.selectedIndex]
|
||||
let textSelected = optionSelected.attr(attrDataShort)
|
||||
|
||||
});
|
||||
});
|
||||
console.log("form currency initialised")
|
||||
*/
|
||||
|
||||
let dropdownCurrency = document.querySelectorAll(idCurrency)[0];
|
||||
// dropdownCurrency.options.map(function(option) {
|
||||
let option, indexHyphen, textOption;
|
||||
for (let indexOption = 0; indexOption < dropdownCurrency.options.length; indexOption++) {
|
||||
option = document.querySelectorAll(dropdownCurrency.options[indexOption]);
|
||||
textOption = option.text();
|
||||
indexHyphen = textOption.indexOf('-');
|
||||
option.attr(attrTextExpanded, textOption);
|
||||
option.attr(attrTextCollapsed, textOption.substring(0, indexHyphen - 1));
|
||||
option.classList.add(flagCollapsed);
|
||||
}
|
||||
handleSelectCollapse(dropdownCurrency);
|
||||
initialiseEventHandler(dropdownCurrency, flagInitialised, function() {
|
||||
dropdownCurrency = document.querySelectorAll(dropdownCurrency);
|
||||
dropdownCurrency.addEventListener("focus", function() {
|
||||
handleSelectExpand(dropdownCurrency);
|
||||
});
|
||||
dropdownCurrency.addEventListener("blur", function() {
|
||||
handleSelectCollapse(dropdownCurrency);
|
||||
});
|
||||
dropdownCurrency.addEventListener("change", function() {
|
||||
let selectedCurrency = dropdownCurrency.val();
|
||||
console.log("selected currency: ", selectedCurrency);
|
||||
let basket = getLocalStorage(keyBasket);
|
||||
basket[keyIdCurrency] = selectedCurrency;
|
||||
// setLocalStorage(keyIdCurrency, selectedCurrency);
|
||||
setLocalStorage(keyBasket, basket);
|
||||
let ajaxData = {};
|
||||
ajaxData[keyBasket] = basket;
|
||||
ajaxJSONData('update currency', mapHashToController(hashPageCurrent), ajaxData, loadPageBody, false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
hookupFilterDeliveryRegion() {
|
||||
/*
|
||||
let elForm = document.querySelectorAll(idFormDeliveryRegion);
|
||||
let elSelector = document.querySelectorAll(elForm.querySelector('select')[0]);
|
||||
initialiseEventHandler(elSelector, flagInitialised, function(){
|
||||
elForm = document.querySelectorAll(idFormDeliveryRegion);
|
||||
elSelector.addEventListener("change", function(event) {
|
||||
ajaxData = {};
|
||||
ajaxData[keyForm] = convertForm2JSON(elForm);
|
||||
console.log('sending data to delivery region selector controller: '); console.log(ajaxData);
|
||||
ajaxJSONData('select delivery region', mapHashToController(hashStoreSelectDeliveryRegion), ajaxData, function() { window.location.reload() }, false);
|
||||
});
|
||||
console.log("form delivery region initialised")
|
||||
});
|
||||
*/
|
||||
|
||||
let dropdownRegion = document.querySelectorAll(idRegionDelivery)[0];
|
||||
|
||||
let option, indexHyphen, textOption;
|
||||
for (let indexOption = 0; indexOption < dropdownRegion.options.length; indexOption++) {
|
||||
option = document.querySelectorAll(dropdownRegion.options[indexOption]);
|
||||
textOption = option.text();
|
||||
indexHyphen = textOption.indexOf('-');
|
||||
option.attr(attrTextExpanded, textOption);
|
||||
option.attr(attrTextCollapsed, textOption.substring(0, indexHyphen - 1));
|
||||
option.classList.add(flagCollapsed);
|
||||
}
|
||||
|
||||
handleSelectCollapse(dropdownRegion);
|
||||
|
||||
initialiseEventHandler(dropdownRegion, flagInitialised, function() {
|
||||
dropdownRegion = document.querySelectorAll(dropdownRegion);
|
||||
dropdownRegion.addEventListener("focus", function() {
|
||||
console.log("dropdown region focused");
|
||||
handleSelectExpand(dropdownRegion);
|
||||
});
|
||||
dropdownRegion.addEventListener("blur", function() {
|
||||
console.log("dropdown region blurred");
|
||||
handleSelectCollapse(dropdownRegion);
|
||||
});
|
||||
dropdownRegion.addEventListener("change", function() {
|
||||
handleSelectCollapse(dropdownRegion);
|
||||
let selectedRegion = dropdownRegion.val();
|
||||
console.log("selected region: ", selectedRegion);
|
||||
let basket = getLocalStorage(keyBasket);
|
||||
basket[keyIdRegionDelivery] = selectedRegion;
|
||||
// setLocalStorage(keyIdRegionDelivery, selectedRegion);
|
||||
setLocalStorage(keyBasket, basket);
|
||||
let ajaxData = {};
|
||||
ajaxData[keyIdRegionDelivery] = selectedRegion;
|
||||
ajaxJSONData('update region', mapHashToController(hashStoreSetRegion), ajaxData, null, false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
hookupFilterIsIncludedVAT() {
|
||||
let elForm = document.querySelectorAll(idFormIsIncludedVAT);
|
||||
let elSelector = document.querySelectorAll(elForm.querySelector('input[type="checkbox"]')[0]);
|
||||
initialiseEventHandler(elSelector, flagInitialised, function(){
|
||||
elForm = document.querySelectorAll(idFormIsIncludedVAT);
|
||||
elSelector.addEventListener("change", function(event) {
|
||||
ajaxData = {};
|
||||
ajaxData[keyForm] = convertForm2JSON(elForm);
|
||||
console.log('sending data to include VAT controller: '); console.log(ajaxData);
|
||||
ajaxJSONData('set include VAT', mapHashToController(hashStoreSetIsIncludedVAT), ajaxData, function() { window.location.reload() }, false);
|
||||
});
|
||||
console.log("form is included VAT initialised")
|
||||
});
|
||||
}
|
||||
|
||||
hookupStoreCardsProduct() {
|
||||
|
||||
let d; // , lsShared;
|
||||
let selectorCardProduct = '.card.subcard';
|
||||
initialiseEventHandler(selectorCardProduct, flagInitialised, function(cardProduct) {
|
||||
console.log("initialising product card: ", cardProduct);
|
||||
cardProduct.addEventListener("click", function(event) {
|
||||
// d = { keyIdProduct: product.attr(attrIdProduct) }
|
||||
var elemClicked = event.target;
|
||||
if (elemClicked.id != 'submit') { // disable for submit buttons
|
||||
console.log("product click: " + cardProduct.attr(attrIdProduct));
|
||||
console.log("permutation click: " + cardProduct.attr(attrIdPermutation));
|
||||
var d = {}
|
||||
d[keyIdProduct] = cardProduct.attr(attrIdProduct)
|
||||
d[keyIdPermutation] = cardProduct.attr(attrIdPermutation)
|
||||
// send quantity requested
|
||||
goToPage(hashPageStoreProduct, d);
|
||||
}
|
||||
});
|
||||
console.log("click method added for product ID: " + cardProduct.attr(attrIdProduct) + ', permutation ID: ', cardProduct.attr(attrIdPermutation));
|
||||
});
|
||||
}
|
||||
|
||||
leave() {
|
||||
super.leave();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user