UX Improvements for Home page and Accessibility Statement page
This commit is contained in:
20
static/MySQL/deprecated/108_tbl_Shop_Recurrence_Interval.sql
Normal file
20
static/MySQL/deprecated/108_tbl_Shop_Recurrence_Interval.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
# Recurrence Interval
|
||||
|
||||
USE PARTSLTD_PROD;
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Recurrence_Interval';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval (
|
||||
id_interval INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
code VARCHAR(50),
|
||||
name VARCHAR(255),
|
||||
name_plural VARCHAR(256),
|
||||
active BIT NOT NULL DEFAULT 1,
|
||||
created_on DATETIME,
|
||||
created_by VARCHAR(100),
|
||||
id_change_set INT,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
# Recurrence Interval Audits
|
||||
|
||||
USE PARTSLTD_PROD;
|
||||
|
||||
SELECT CONCAT('WARNING: Table ', TABLE_NAME, ' already exists.') AS msg_warning FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Shop_Recurrence_Interval_Audit';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS Shop_Recurrence_Interval_Audit (
|
||||
id_audit INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
id_interval INT NOT NULL,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_Audit_id_interval
|
||||
FOREIGN KEY (id_interval)
|
||||
REFERENCES Shop_Recurrence_Interval(id_interval)
|
||||
ON UPDATE RESTRICT,
|
||||
name_field VARCHAR(50),
|
||||
value_prev VARCHAR(256),
|
||||
value_new VARCHAR(256),
|
||||
id_change_set INT NOT NULL,
|
||||
CONSTRAINT FK_Shop_Recurrence_Interval_Audit_id_change_set
|
||||
FOREIGN KEY (id_change_set)
|
||||
REFERENCES Shop_Product_Change_Set(id_change_set)
|
||||
);
|
||||
56
static/MySQL/deprecated/308_tri_Shop_Recurrence_Interval.sql
Normal file
56
static/MySQL/deprecated/308_tri_Shop_Recurrence_Interval.sql
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
# Shop Recurrence Interval
|
||||
|
||||
USE PARTSLTD_PROD;
|
||||
|
||||
|
||||
DROP TRIGGER IF EXISTS before_insert_Shop_Recurrence_Interval;
|
||||
DROP TRIGGER IF EXISTS before_update_Shop_Recurrence_Interval;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
CREATE TRIGGER before_insert_Shop_Recurrence_Interval
|
||||
BEFORE INSERT ON Shop_Recurrence_Interval
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.created_on = NOW();
|
||||
SET NEW.created_by = CURRENT_USER();
|
||||
END //
|
||||
DELIMITER ;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
CREATE TRIGGER before_update_Shop_Recurrence_Interval
|
||||
BEFORE UPDATE ON Shop_Recurrence_Interval
|
||||
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_Recurrence_Interval_Audit (
|
||||
id_interval,
|
||||
name_field,
|
||||
value_prev,
|
||||
value_new,
|
||||
id_change_set
|
||||
)
|
||||
# Changed code
|
||||
SELECT NEW.id_interval, 'code', OLD.code, NEW.code, NEW.id_change_set
|
||||
WHERE NOT OLD.code <=> NEW.code
|
||||
UNION
|
||||
# Changed name
|
||||
SELECT NEW.id_interval, 'name', OLD.name, NEW.name, NEW.id_change_set
|
||||
WHERE NOT OLD.name <=> NEW.name
|
||||
UNION
|
||||
# Changed name_plural
|
||||
SELECT NEW.id_interval, 'name_plural', OLD.name_plural, NEW.name_plural, NEW.id_change_set
|
||||
WHERE NOT OLD.name_plural <=> NEW.name_plural
|
||||
UNION
|
||||
# Changed name
|
||||
SELECT NEW.id_interval, 'active', OLD.active, NEW.active, NEW.id_change_set
|
||||
WHERE NOT OLD.active <=> NEW.active
|
||||
;
|
||||
END //
|
||||
DELIMITER ;
|
||||
93
static/MySQL/deprecated/322_tri_Shop_Price.sql
Normal file
93
static/MySQL/deprecated/322_tri_Shop_Price.sql
Normal file
@@ -0,0 +1,93 @@
|
||||
|
||||
# Shop Product Currency Region Link
|
||||
|
||||
USE PARTSLTD_PROD;
|
||||
|
||||
DROP TRIGGER IF EXISTS before_insert_Shop_Product_Currency_Region_Link;
|
||||
DROP TRIGGER IF EXISTS before_update_Shop_Product_Currency_Region_Link;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
CREATE TRIGGER before_insert_Shop_Product_Currency_Region_Link
|
||||
BEFORE INSERT ON Shop_Product_Currency_Region_Link
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.created_on <=> NULL THEN
|
||||
SET NEW.created_on = NOW();
|
||||
END IF;
|
||||
IF NEW.created_by <=> NULL THEN
|
||||
SET NEW.created_by = CURRENT_USER();
|
||||
END IF;
|
||||
/*
|
||||
SET NEW.price_local = (
|
||||
SELECT PP.price_GBP_full * C.factor_from_GBP
|
||||
FROM Shop_Product_Permutation PP
|
||||
INNER JOIN Shop_Product P ON PP.id_product = P.id_product
|
||||
INNER JOIN Shop_Currency C ON NEW.id_currency = C.id_currency
|
||||
WHERE NEW.id_product = P.id_product
|
||||
LIMIT 1
|
||||
);
|
||||
*/
|
||||
END //
|
||||
DELIMITER ;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
CREATE TRIGGER before_update_Shop_Product_Currency_Region_Link
|
||||
BEFORE UPDATE ON Shop_Product_Currency_Region_Link
|
||||
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;
|
||||
|
||||
/*
|
||||
SET NEW.price_local = (
|
||||
SELECT P.price_GBP_full * C.factor_from_GBP
|
||||
FROM Shop_Product P
|
||||
INNER JOIN Shop_Currency C ON NEW.id_currency = C.id_currency
|
||||
WHERE NEW.id_product = P.id_product
|
||||
LIMIT 1
|
||||
);
|
||||
*/
|
||||
|
||||
INSERT INTO Shop_Product_Currency_Region_Link_Audit (
|
||||
id_link,
|
||||
name_field,
|
||||
value_prev,
|
||||
value_new,
|
||||
id_change_set
|
||||
)
|
||||
/*
|
||||
# Changed id_product
|
||||
SELECT NEW.id_link, 'id_product', CONVERT(OLD.id_product, CHAR), CONVERT(NEW.id_product, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_product <=> NEW.id_product
|
||||
UNION
|
||||
# Changed id_currency
|
||||
SELECT NEW.id_link, 'id_currency', CONVERT(OLD.id_currency, CHAR), CONVERT(NEW.id_currency, CHAR), NEW.id_change_set
|
||||
WHERE NOT OLD.id_currency <=> NEW.id_currency
|
||||
UNION
|
||||
# Changed price_local
|
||||
SELECT NEW.id_link, 'price_local', OLD.price_local, NEW.price_local, NEW.id_change_set
|
||||
WHERE NOT OLD.price_local <=> NEW.price_local
|
||||
UNION
|
||||
*/
|
||||
# Changed price_local_VAT_incl
|
||||
SELECT NEW.id_link, 'price_local_VAT_incl', OLD.price_local_VAT_incl, NEW.price_local_VAT_incl, NEW.id_change_set
|
||||
WHERE NOT OLD.price_local_VAT_incl <=> NEW.price_local_VAT_incl
|
||||
UNION
|
||||
# Changed price_local_VAT_excl
|
||||
SELECT NEW.id_link, 'price_local_VAT_excl', OLD.price_local_VAT_excl, NEW.price_local_VAT_excl, NEW.id_change_set
|
||||
WHERE NOT OLD.price_local_VAT_excl <=> NEW.price_local_VAT_excl
|
||||
UNION
|
||||
# Changed id_stripe_price
|
||||
SELECT NEW.id_link, 'id_stripe_price', OLD.id_stripe_price, NEW.id_stripe_price, NEW.id_change_set
|
||||
WHERE NOT OLD.id_stripe_price <=> NEW.id_stripe_price
|
||||
UNION
|
||||
# Changed active
|
||||
SELECT NEW.id_link, 'active', CONVERT(CONVERT(OLD.active, SIGNED), CHAR), CONVERT(CONVERT(NEW.active, SIGNED), CHAR), NEW.id_change_set
|
||||
WHERE NOT (OLD.active <=> NEW.active)
|
||||
;
|
||||
END //
|
||||
DELIMITER ;
|
||||
131
static/MySQL/deprecated/7000_p_shop_get_many_role_permission.sql
Normal file
131
static/MySQL/deprecated/7000_p_shop_get_many_role_permission.sql
Normal file
@@ -0,0 +1,131 @@
|
||||
|
||||
USE PARTSLTD_PROD;
|
||||
|
||||
/*
|
||||
THIS STRUCTURE DOES NOT WORK WITH MYSQL ??
|
||||
|
||||
CALL p_shop_get_many_role_permission (
|
||||
'',
|
||||
0,
|
||||
'',
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'',
|
||||
0,
|
||||
0,
|
||||
1
|
||||
)
|
||||
|
||||
*/
|
||||
|
||||
|
||||
-- Clear previous proc
|
||||
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;
|
||||
*/
|
||||
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE p_shop_get_many_role_permission (
|
||||
a_ids_role NVARCHAR(500),
|
||||
a_get_inactive_roles BIT
|
||||
)
|
||||
BEGIN
|
||||
-- Variable declaration
|
||||
DECLARE v_has_filter_role BIT;
|
||||
DECLARE v_priority_view INT;
|
||||
DECLARE v_priority_edit INT;
|
||||
DECLARE v_priority_admin INT;
|
||||
/*
|
||||
DECLARE v_ids_product_permission VARCHAR(500);
|
||||
DECLARE v_now DATETIME;
|
||||
*/
|
||||
|
||||
-- Parse arguments + get default values
|
||||
IF a_ids_role IS NULL THEN
|
||||
SET a_ids_role = '';
|
||||
ELSE
|
||||
SET a_ids_role = TRIM(a_ids_role);
|
||||
END IF;
|
||||
IF a_get_inactive_roles IS NULL THEN
|
||||
SET a_get_inactive_roles = 0;
|
||||
END IF;
|
||||
|
||||
|
||||
-- Temporary tables
|
||||
CREATE TABLE tmp_Permission (
|
||||
id_role INT NOT NULL,
|
||||
CONSTRAINT FK_tmp_User_Permission_id_role
|
||||
FOREIGN KEY (id_role)
|
||||
REFERENCES Shop_Role(id_role),
|
||||
id_permission INT,
|
||||
CONSTRAINT FK_tmp_User_Permission_id_permission
|
||||
FOREIGN KEY (id_permission)
|
||||
REFERENCES Shop_Permission(id_permission),
|
||||
id_access_level INT,
|
||||
CONSTRAINT FK_tmp_User_Permission_id_access_level
|
||||
FOREIGN KEY (id_user)
|
||||
REFERENCES Shop_Access_Level(id_user),
|
||||
can_view BIT,
|
||||
can_edit BIT,
|
||||
can_admin BIT
|
||||
);
|
||||
|
||||
|
||||
-- Parse filters
|
||||
SET a_ids_role = REPLACE(a_ids_role, ',', '|');
|
||||
SET v_has_filter_role = CASE WHEN a_ids_role = '' THEN 0 ELSE 1 END;
|
||||
|
||||
INSERT INTO tmp_User_Permission (
|
||||
id_role,
|
||||
id_permission,
|
||||
id_access_level,
|
||||
can_view,
|
||||
can_edit,
|
||||
can_admin
|
||||
)
|
||||
SELECT U.id_user,
|
||||
U.is_super_user,
|
||||
U.is_super_user,
|
||||
U.is_super_user,
|
||||
U.is_super_user
|
||||
FROM Shop_Role R
|
||||
INNER JOIN Shop_Role_Permission_Link RPL
|
||||
ON R.id_role = RPL.id_role
|
||||
AND RPL.active
|
||||
INNER JOIN Shop_Permission PERM
|
||||
ON RPL.id_permission = PERM.id_permission
|
||||
AND PERM.active
|
||||
INNER JOIN Shop_Permission_Group PG
|
||||
ON PERM.id_permission_group = PG.id_group
|
||||
AND PG.active
|
||||
LEFT JOIN Shop_Access_Level AL
|
||||
ON RPL.id_access_level = AL.id_access_level
|
||||
AND AL.active
|
||||
WHERE
|
||||
R.id_role LIKE CONCAT('%', a_ids_role, '%')
|
||||
AND (
|
||||
PERM.required_access_level = 0
|
||||
OR AL.priority >= PERM.required_access_level
|
||||
)
|
||||
;
|
||||
|
||||
UPDATE tmp_User_Permission t_UP
|
||||
INNER JOIN Shop_Access_Level AL
|
||||
ON AL.code = 'ADMIN'
|
||||
SET t_UP.id_access_level = AL.id_access_level
|
||||
WHERE t_UP.is_super_user
|
||||
;
|
||||
|
||||
|
||||
-- Clean up
|
||||
DROP TABLE IF EXISTS tmp_Shop_Category;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Product;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Image;
|
||||
END //
|
||||
DELIMITER ;
|
||||
|
||||
285
static/MySQL/deprecated/7000_p_shop_get_many_user_order.sql
Normal file
285
static/MySQL/deprecated/7000_p_shop_get_many_user_order.sql
Normal file
@@ -0,0 +1,285 @@
|
||||
|
||||
USE PARTSLTD_PROD;
|
||||
|
||||
/*
|
||||
|
||||
CALL p_shop_get_many_user_order (
|
||||
'',
|
||||
'',
|
||||
1,
|
||||
''
|
||||
)
|
||||
|
||||
*/
|
||||
|
||||
|
||||
-- Clear previous proc
|
||||
DROP PROCEDURE IF EXISTS p_shop_get_many_user_order;
|
||||
|
||||
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE p_shop_get_many_user_order (
|
||||
IN a_id_user VARCHAR(200),
|
||||
IN a_ids_order VARCHAR(4000),
|
||||
IN a_n_order_max INT,
|
||||
IN a_id_checkout_session VARCHAR(200)
|
||||
)
|
||||
BEGIN
|
||||
-- Argument redeclaration
|
||||
-- Variable declaration
|
||||
DECLARE v_has_filter_user BIT;
|
||||
DECLARE v_has_filter_order BIT;
|
||||
DECLARE v_has_filter_session BIT;
|
||||
DECLARE v_code_error_data VARCHAR(200);
|
||||
DECLARE v_code_error_permission VARCHAR(200);
|
||||
DECLARE v_guid VARCHAR(36);
|
||||
|
||||
SET v_code_error_data := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 1);
|
||||
SET v_code_error_permission := (SELECT code FROM Shop_Msg_Error_Type WHERE id_type = 2);
|
||||
SET v_guid = UUID();
|
||||
|
||||
-- Argument validation + default values
|
||||
IF a_id_user IS NULL THEN
|
||||
SET a_id_user = '';
|
||||
ELSE
|
||||
SET a_id_user = TRIM(a_id_user);
|
||||
END IF;
|
||||
IF a_ids_order IS NULL THEN
|
||||
SET a_ids_order = '';
|
||||
ELSE
|
||||
SET a_ids_order = TRIM(a_ids_order);
|
||||
END IF;
|
||||
IF a_n_order_max IS NULL THEN
|
||||
SET a_n_order_max = 1;
|
||||
END IF;
|
||||
IF a_id_checkout_session IS NULL THEN
|
||||
SET a_id_checkout_session = '';
|
||||
ELSE
|
||||
SET a_id_checkout_session = TRIM(a_id_checkout_session);
|
||||
END IF;
|
||||
|
||||
|
||||
|
||||
-- Temporary tables
|
||||
DROP TABLE IF EXISTS tmp_Shop_User;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Order;
|
||||
|
||||
CREATE TABLE tmp_Shop_User(
|
||||
id_user VARCHAR(200) NOT NULL PRIMARY KEY,
|
||||
CONSTRAINT FK_tmp_Shop_User_id_user
|
||||
FOREIGN KEY (id_user)
|
||||
REFERENCES Shop_User(id_user),
|
||||
active BIT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE tmp_Shop_Order (
|
||||
id_order INT NOT NULL PRIMARY KEY,
|
||||
CONSTRAINT FK_tmp_Shop_Order_id_order
|
||||
FOREIGN KEY (id_order)
|
||||
REFERENCES Shop_User_Order(id_order),
|
||||
active BIT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS tmp_Msg_Error (
|
||||
display_order INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
guid VARCHAR(36) NOT NULL,
|
||||
# id_type INT NOT NULL,
|
||||
# CONSTRAINT FK_tmp_Msg_Error_id_type FOREIGN KEY (id_type)
|
||||
# REFERENCES Shop_Msg_Error_Type (id_type),
|
||||
code VARCHAR(50),
|
||||
msg VARCHAR(4000) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
-- Parse filters
|
||||
SET v_has_filter_user = CASE WHEN a_id_user = '' THEN 0 ELSE 1 END;
|
||||
SET a_ids_order = REPLACE(a_ids_order, '|', ',');
|
||||
SET v_has_filter_order = CASE WHEN a_ids_order = '' THEN 0 ELSE 1 END;
|
||||
SET v_has_filter_session = CASE WHEN a_id_checkout_session = '' THEN 0 ELSE 1 END;
|
||||
|
||||
-- User
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN
|
||||
IF v_has_filter_user THEN
|
||||
INSERT INTO tmp_Shop_User (
|
||||
id_user,
|
||||
active
|
||||
)
|
||||
SELECT id_user,
|
||||
active
|
||||
FROM Shop_User
|
||||
WHERE id_user LIKE CONCAT('%', a_id_user, '%')
|
||||
AND active
|
||||
LIMIT 1
|
||||
;
|
||||
|
||||
SET v_has_filter_user = EXISTS (SELECT id_user FROM tmp_Shop_User LIMIT 1);
|
||||
SET a_id_user := (SELECT id_user FROM tmp_Shop_User LIMIT 1);
|
||||
END IF;
|
||||
END IF;
|
||||
IF NOT v_has_filter_user THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
VALUES (
|
||||
v_guid,
|
||||
v_code_error_data,
|
||||
'User ID not valid.'
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
|
||||
-- Permissions
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE guid = v_guid LIMIT 1) THEN
|
||||
CALL p_shop_user_eval (
|
||||
v_guid, # a_guid
|
||||
a_id_user, # a_id_user
|
||||
0, # a_get_inactive_users
|
||||
CONVERT((SELECT id_permission FROM Shop_Permission WHERE 'STORE_USER' = code), CHAR), # a_ids_permission
|
||||
(SELECT id_access_level FROM Shop_Access_Level WHERE code = 'VIEW' AND active), # a_ids_access_level
|
||||
'', # a_ids_product
|
||||
'' # a_ids_permutation
|
||||
);
|
||||
|
||||
IF NOT (SELECT can_edit FROM Shop_User_Eval_Temp WHERE guid = v_guid) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
VALUES (
|
||||
v_guid,
|
||||
v_code_error_permission,
|
||||
'User ID does not have permission to access orders.'
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
|
||||
DELETE FROM Shop_User_Eval_Temp
|
||||
WHERE guid = v_guid
|
||||
;
|
||||
END IF;
|
||||
|
||||
-- Invalid Orders
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE guid = v_guid LIMIT 1) THEN
|
||||
# Invalid Order IDs
|
||||
IF EXISTS (SELECT * FROM Shop_User_Order WHERE NOT (id_user = a_id_user) AND v_has_filter_order AND FIND_IN_SET(id_order, a_ids_order) > 0) THEN # id_order LIKE CONCAT('%', a_ids_order, '%') LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
VALUES (
|
||||
v_guid,
|
||||
v_code_error_data,
|
||||
CONCAT('You do not have access to the following order IDs: ', (SELECT GROUP_CONCAT(id_order SEPARATOR ', ') FROM Shop_User_Order WHERE NOT (id_user = a_id_user) AND FIND_IN_SET(id_order, a_ids_order) > 0)) # id_order LIKE CONCAT('%', a_ids_order, '%'))) # AND v_has_filter_order # filtered by parent condition
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
# Invalid Checkout Session IDs
|
||||
IF EXISTS (SELECT * FROM Shop_User_Order WHERE NOT (id_user = a_id_user) AND v_has_filter_session AND id_checkout_session = a_id_checkout_session) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
guid,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
VALUES (
|
||||
v_guid,
|
||||
v_code_error_data,
|
||||
CONCAT('You do not have access to the following checkout session IDs: ', (SELECT GROUP_CONCAT(id_order SEPARATOR ', ') FROM Shop_User_Order WHERE NOT (id_user = a_id_user) AND id_checkout_session = a_id_checkout_session)) # AND v_has_filter_order # filtered by parent condition
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
-- Valid Orders
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error WHERE guid = v_guid LIMIT 1) THEN
|
||||
|
||||
INSERT INTO tmp_Shop_Order (
|
||||
id_order,
|
||||
active
|
||||
)
|
||||
SELECT UO.id_order,
|
||||
UO.active
|
||||
FROM Shop_User_Order UO
|
||||
INNER JOIN tmp_Shop_User t_U
|
||||
ON UO.id_user = t_U.id_user
|
||||
AND t_U.active
|
||||
WHERE ((NOT v_has_filter_order OR FIND_IN_SET(UO.id_order, a_ids_order) > 0) # UO.id_order LIKE CONCAT('%', a_ids_order, '%'))
|
||||
OR (NOT v_has_filter_session OR UO.id_checkout_session = a_id_checkout_session))
|
||||
AND UO.active
|
||||
;
|
||||
END IF;
|
||||
|
||||
|
||||
|
||||
-- Returns
|
||||
/*
|
||||
SELECT *
|
||||
FROM tmp_Shop_User
|
||||
;
|
||||
*/
|
||||
|
||||
SELECT t_O.id_order,
|
||||
UOPL.id_product,
|
||||
UOPL.id_permutation,
|
||||
UOPL.quantity
|
||||
FROM tmp_Shop_Order t_O
|
||||
INNER JOIN Shop_User_Order UO
|
||||
ON t_O.id_order = UO.id_order
|
||||
INNER JOIN Shop_User_Order_Product_Link UOPL
|
||||
ON UO.id_order = UOPL.id_order
|
||||
WHERE t_O.active
|
||||
;
|
||||
|
||||
|
||||
# Errors
|
||||
SELECT *
|
||||
FROM tmp_Msg_Error
|
||||
WHERE guid = v_guid
|
||||
;
|
||||
|
||||
|
||||
/*
|
||||
# Return arguments for test
|
||||
SELECT
|
||||
a_id_user,
|
||||
a_ids_order,
|
||||
a_n_order_max,
|
||||
a_id_checkout_session
|
||||
;
|
||||
*/
|
||||
|
||||
-- Clean up
|
||||
DROP TABLE IF EXISTS tmp_Shop_User;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Order;
|
||||
END //
|
||||
DELIMITER ;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
CALL p_shop_get_many_user_order (
|
||||
'auth0|6582b95c895d09a70ba10fef',
|
||||
'1',
|
||||
0,
|
||||
''
|
||||
);
|
||||
|
||||
CALL p_shop_get_many_user_order (
|
||||
'',
|
||||
'1',
|
||||
0,
|
||||
''
|
||||
);
|
||||
|
||||
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;
|
||||
select * from shop_User_oRDER;
|
||||
*/
|
||||
Reference in New Issue
Block a user