Fix: Product Category, Product, and Product Permutation save and filter.
This commit is contained in:
Binary file not shown.
@@ -500,19 +500,20 @@ class Parameters_Product(Get_Many_Parameters_Base):
|
||||
# av.val_instance(form, 'form', 'Parameters_Product.from_form', Filters_Product_Permutation)
|
||||
has_category_filter = not (form.id_category.data == '0' or form.id_category.data == '' or form.id_category.data is None)
|
||||
has_product_filter = not (form.id_product.data == '0' or form.id_product.data == '' or form.id_product.data is None)
|
||||
get_permutations_stock_below_min = av.input_bool(form.is_out_of_stock.data, "is_out_of_stock", "Parameters_Product.from_form")
|
||||
Helper_App.console_log(f'form question: {type(form.is_out_of_stock)}\nbool interpretted: {get_permutations_stock_below_min}\ntype form: {type(form)}')
|
||||
get_permutations_stock_below_min = av.input_bool(form.is_out_of_stock.data, "is_out_of_stock", "Parameters_Product.from_form_filters_product_permutation")
|
||||
get_inactive = not av.input_bool(form.active.data, "active", "Parameters_Product.from_form_filters_product_permutation")
|
||||
Helper_App.console_log(f'form question: {type(form.is_out_of_stock)}\nbool interpretted: {get_permutations_stock_below_min}\nform question: {type(form.active)}\nget_inactive:{get_inactive}\ntype form: {type(form)}')
|
||||
return Parameters_Product(
|
||||
get_all_product_category = not has_category_filter,
|
||||
get_inactive_product_category = False,
|
||||
get_inactive_product_category = get_inactive,
|
||||
# get_first_product_category_only = False,
|
||||
ids_product_category = form.id_category.data if form.id_category.data is not None else '',
|
||||
get_all_product = not has_product_filter,
|
||||
get_inactive_product = False,
|
||||
get_inactive_product = get_inactive,
|
||||
# get_first_product_only = False,
|
||||
ids_product = form.id_product.data if form.id_product.data is not None else '',
|
||||
get_all_permutation = not get_permutations_stock_below_min,
|
||||
get_inactive_permutation = False,
|
||||
get_inactive_permutation = get_inactive,
|
||||
# get_first_permutation_only = False,
|
||||
ids_permutation = '',
|
||||
get_all_image = False,
|
||||
|
||||
Binary file not shown.
@@ -33,7 +33,8 @@ routes_store_product_permutation = Blueprint('routes_store_product_permutation',
|
||||
@routes_store_product_permutation.route(Model_View_Store_Product_Permutation.HASH_PAGE_STORE_PRODUCT_PERMUTATIONS, methods=['GET'])
|
||||
def permutations():
|
||||
Helper_App.console_log('permutations')
|
||||
data = Helper_App.get_request_data(request)
|
||||
data = request.args
|
||||
# Helper_App.console_log(f'data={data}\nrequest.args={request.args}\nrequest.form={request.form}\nrequest.data={request.data}\nrequest.values={request.values}\nrequest.headers={request.headers}')
|
||||
try:
|
||||
form_filters = Filters_Product_Permutation.from_json(data)
|
||||
except Exception as e:
|
||||
|
||||
Binary file not shown.
@@ -29,6 +29,7 @@ class Filters_Product_Permutation(Form_Base):
|
||||
id_category = SelectField('Category', validators=[Optional()], choices=[('', 'All')], default='')
|
||||
id_product = SelectField('Product', validators=[Optional()], choices=[('', 'All')], default='')
|
||||
is_out_of_stock = BooleanField('Out of stock only?')
|
||||
active = BooleanField('Active only?', default=True)
|
||||
quantity_min = FloatField('Min stock')
|
||||
quantity_max = FloatField('Max stock')
|
||||
# submit = SubmitField('Submit')
|
||||
@@ -49,6 +50,7 @@ class Filters_Product_Permutation(Form_Base):
|
||||
id_category={self.id_category.data},
|
||||
id_product={self.id_product.data},
|
||||
is_out_of_stock={self.is_out_of_stock.data},
|
||||
active={self.active.data},
|
||||
quantity_min={self.quantity_min.data},
|
||||
quantity_max={self.quantity_max.data})
|
||||
'''
|
||||
@@ -60,6 +62,7 @@ class Filters_Product_Permutation(Form_Base):
|
||||
form.id_product.choices = [(json[Store_Base.ATTR_ID_PRODUCT], json[Store_Base.ATTR_ID_PRODUCT])]
|
||||
form.id_product.data = json[Store_Base.ATTR_ID_PRODUCT]
|
||||
form.is_out_of_stock.data = av.input_bool(json[Store_Base.FLAG_IS_OUT_OF_STOCK], Store_Base.FLAG_IS_OUT_OF_STOCK, f'{cls.__name__}.from_json')
|
||||
form.active.data = av.input_bool(json[Store_Base.FLAG_ACTIVE], Store_Base.FLAG_ACTIVE, f'{cls.__name__}.from_json')
|
||||
form.quantity_min.data = json[Store_Base.FLAG_QUANTITY_MIN]
|
||||
form.quantity_max.data = json[Store_Base.FLAG_QUANTITY_MAX]
|
||||
return form
|
||||
@@ -65,10 +65,9 @@ BEGIN
|
||||
|
||||
-- Clear previous proc results
|
||||
DROP TABLE IF EXISTS tmp_Calc_User;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Calc_User;
|
||||
DROP TABLE IF EXISTS tmp_User_Calc_User;
|
||||
DROP TABLE IF EXISTS tmp_Product_Calc_User;
|
||||
DROP TABLE IF EXISTS tmp_Product_p_Shop_User_Eval_Temp;
|
||||
-- DROP TABLE IF EXISTS tmp_Split;
|
||||
DROP TABLE IF EXISTS tmp_Split;
|
||||
|
||||
-- Permanent Table
|
||||
CREATE TEMPORARY TABLE tmp_Calc_User (
|
||||
@@ -92,7 +91,14 @@ BEGIN
|
||||
-- guid BINARY(36) NOT NULL,
|
||||
-- rank_product INT NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TEMPORARY TABLE tmp_User_Calc_User (
|
||||
id_user INT NOT NULL
|
||||
, is_super_user BIT NOT NULL
|
||||
-- , id_access_level INT
|
||||
, priority_access_level 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,
|
||||
@@ -131,122 +137,314 @@ BEGIN
|
||||
;
|
||||
END IF;
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF v_has_filter_access_level THEN
|
||||
CALL partsltd_prod.p_split(a_guid, a_ids_access_level, ',', a_debug);
|
||||
|
||||
INSERT INTO tmp_Split (
|
||||
substring
|
||||
, as_int
|
||||
# Access levels
|
||||
IF v_has_filter_access_level THEN
|
||||
CALL partsltd_prod.p_split(a_guid, a_ids_access_level, ',', a_debug);
|
||||
|
||||
INSERT INTO tmp_Split (
|
||||
substring
|
||||
, as_int
|
||||
)
|
||||
SELECT
|
||||
substring
|
||||
, CONVERT(substring, DECIMAL(10,0)) -- AS as_int
|
||||
FROM Split_Temp
|
||||
WHERE 1=1
|
||||
AND GUID = a_guid
|
||||
AND NOT ISNULL(substring)
|
||||
AND substring != ''
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_clear_split_temp( a_guid );
|
||||
|
||||
# Invalid IDs
|
||||
IF EXISTS (
|
||||
SELECT t_S.substring
|
||||
FROM tmp_Split t_S
|
||||
LEFT JOIN partsltd_prod.Shop_Access_Level AL ON t_S.as_int = AL.id_access_level
|
||||
WHERE
|
||||
ISNULL(t_S.as_int)
|
||||
OR ISNULL(AL.id_access_level)
|
||||
OR AL.active = 0
|
||||
) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
-- guid,
|
||||
id_type,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
SELECT
|
||||
substring
|
||||
, CONVERT(substring, DECIMAL(10,0)) -- AS as_int
|
||||
FROM Split_Temp
|
||||
WHERE 1=1
|
||||
AND GUID = a_guid
|
||||
AND NOT ISNULL(substring)
|
||||
AND substring != ''
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_clear_split_temp( a_guid );
|
||||
|
||||
# Invalid IDs
|
||||
IF EXISTS (
|
||||
SELECT t_S.substring
|
||||
FROM tmp_Split t_S
|
||||
LEFT JOIN partsltd_prod.Shop_Access_Level AL ON t_S.as_int = AL.id_access_level
|
||||
WHERE
|
||||
ISNULL(t_S.as_int)
|
||||
OR ISNULL(AL.id_access_level)
|
||||
OR AL.active = 0
|
||||
) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
-- guid,
|
||||
id_type,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
SELECT
|
||||
-- a_guid,
|
||||
v_id_type_error_bad_data,
|
||||
v_code_type_error_bad_data,
|
||||
CONCAT('Invalid or inactive access level IDs: ', GROUP_CONCAT(t_S.substring SEPARATOR ', '))
|
||||
FROM tmp_Split t_S
|
||||
LEFT JOIN partsltd_prod.Shop_Access_Level AL ON t_S.as_int = AL.id_access_level
|
||||
WHERE
|
||||
ISNULL(t_S.as_int)
|
||||
OR ISNULL(AL.id_access_level)
|
||||
OR AL.active = 0
|
||||
;
|
||||
SELECT
|
||||
-- a_guid,
|
||||
v_id_type_error_bad_data,
|
||||
v_code_type_error_bad_data,
|
||||
CONCAT('Invalid or inactive access level IDs: ', GROUP_CONCAT(t_S.substring SEPARATOR ', '))
|
||||
FROM tmp_Split t_S
|
||||
LEFT JOIN partsltd_prod.Shop_Access_Level AL ON t_S.as_int = AL.id_access_level
|
||||
WHERE
|
||||
ISNULL(t_S.as_int)
|
||||
OR ISNULL(AL.id_access_level)
|
||||
OR AL.active = 0
|
||||
;
|
||||
ELSE
|
||||
IF v_has_filter_access_level THEN
|
||||
SET v_id_access_level := (
|
||||
SELECT AL.id_access_level
|
||||
FROM tmp_Split t_S
|
||||
INNER JOIN partsltd_prod.Shop_Access_Level AL
|
||||
ON t_S.as_int = AL.id_access_level
|
||||
AND AL.active
|
||||
ORDER BY AL.priority ASC
|
||||
LIMIT 1
|
||||
);
|
||||
ELSE
|
||||
SET v_id_access_level = v_id_access_level_view;
|
||||
END IF;
|
||||
SET v_priority_access_level := (SELECT priority FROM partsltd_prod.Shop_Access_Level WHERE id_access_level = v_id_access_level LIMIT 1);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF v_has_filter_access_level THEN
|
||||
SET v_id_access_level := (
|
||||
SELECT AL.id_access_level
|
||||
FROM tmp_Split t_S
|
||||
INNER JOIN partsltd_prod.Shop_Access_Level AL
|
||||
ON t_S.as_int = AL.id_access_level
|
||||
AND AL.active
|
||||
ORDER BY AL.priority ASC
|
||||
LIMIT 1
|
||||
);
|
||||
ELSE
|
||||
SET v_id_access_level = v_id_access_level_view;
|
||||
END IF;
|
||||
SET v_priority_access_level := (SELECT priority FROM partsltd_prod.Shop_Access_Level WHERE id_access_level = v_id_access_level LIMIT 1);
|
||||
END IF;
|
||||
|
||||
DELETE FROM tmp_Split;
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF v_has_filter_product = 1 THEN
|
||||
CALL partsltd_prod.p_split(a_guid, a_ids_product, ',', a_debug);
|
||||
|
||||
INSERT INTO tmp_Split (
|
||||
substring
|
||||
, as_int
|
||||
-- Permission IDs
|
||||
IF v_has_filter_permission THEN
|
||||
CALL partsltd_prod.p_split(a_guid, a_ids_permission, ',', a_debug);
|
||||
|
||||
INSERT INTO tmp_Split (
|
||||
substring
|
||||
, as_int
|
||||
)
|
||||
SELECT
|
||||
substring
|
||||
, CONVERT(substring, DECIMAL(10,0)) AS as_int
|
||||
FROM Split_Temp
|
||||
WHERE 1=1
|
||||
AND GUID = a_guid
|
||||
AND NOT ISNULL(substring)
|
||||
AND substring != ''
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_clear_split_temp( a_guid );
|
||||
|
||||
# Invalid or inactive
|
||||
IF EXISTS (SELECT PERM.id_permission FROM tmp_Split t_S LEFT JOIN partsltd_prod.Shop_Permission PERM ON t_S.as_int = PERM.id_permission WHERE ISNULL(t_S.as_int) OR ISNULL(PERM.id_permission) OR PERM.active = 0) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
-- guid,
|
||||
id_type,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
SELECT
|
||||
substring
|
||||
, CONVERT(substring, DECIMAL(10,0)) AS as_int
|
||||
FROM Split_Temp
|
||||
WHERE 1=1
|
||||
AND GUID = a_guid
|
||||
AND NOT ISNULL(substring)
|
||||
AND substring != ''
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_clear_split_temp( a_guid );
|
||||
|
||||
# Invalid product IDs
|
||||
IF EXISTS (SELECT * FROM tmp_Split t_S LEFT JOIN partsltd_prod.Shop_Product P ON t_S.as_int = P.id_product WHERE ISNULL(t_S.as_int) OR ISNULL(P.id_product) OR P.active = 0) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
-- guid,
|
||||
id_type,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
SELECT
|
||||
-- a_guid,
|
||||
v_id_type_error_bad_data,
|
||||
v_code_type_error_bad_data,
|
||||
CONCAT('Invalid or inactive product IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL'))
|
||||
FROM tmp_Split t_S
|
||||
LEFT JOIN partsltd_prod.Shop_Product P ON t_S.as_int = P.id_product
|
||||
WHERE
|
||||
ISNULL(t_S.as_int)
|
||||
OR ISNULL(P.id_product)
|
||||
OR P.active = 0
|
||||
;
|
||||
END IF;
|
||||
SELECT
|
||||
-- a_guid,
|
||||
v_id_type_error_bad_data,
|
||||
v_code_type_error_bad_data,
|
||||
CONCAT('Invalid or inactive permission IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL'))
|
||||
FROM tmp_Split t_S
|
||||
LEFT JOIN partsltd_prod.Shop_Permission PERM ON t_S.as_int = PERM.id_permission
|
||||
WHERE
|
||||
ISNULL(t_S.as_int)
|
||||
OR ISNULL(PERM.id_permission)
|
||||
OR PERM.active = 0
|
||||
;
|
||||
ELSE
|
||||
SET v_id_permission_required := (
|
||||
SELECT PERM.id_permission
|
||||
FROM partsltd_prod.Shop_Permission PERM
|
||||
INNER JOIN partsltd_prod.Shop_Access_Level AL ON PERM.id_access_level_required = AL.id_access_level
|
||||
ORDER BY AL.priority ASC
|
||||
LIMIT 1
|
||||
);
|
||||
END IF;
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF (v_has_filter_product = 1 AND EXISTS (SELECT * FROM tmp_Split)) THEN
|
||||
DELETE FROM tmp_Split;
|
||||
|
||||
# Users
|
||||
CALL partsltd_prod.p_split(a_guid, a_ids_user, ',', a_debug);
|
||||
|
||||
INSERT INTO tmp_Split (
|
||||
substring
|
||||
, as_int
|
||||
)
|
||||
SELECT
|
||||
substring
|
||||
, CONVERT(substring, DECIMAL(10,0)) AS as_int
|
||||
FROM Split_Temp
|
||||
WHERE 1=1
|
||||
AND GUID = a_guid
|
||||
AND NOT ISNULL(substring)
|
||||
AND substring != ''
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_clear_split_temp( a_guid );
|
||||
|
||||
# Invalid or inactive
|
||||
IF EXISTS (SELECT U.id_user FROM tmp_Split t_S LEFT JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user WHERE ISNULL(t_S.as_int) OR ISNULL(U.id_user) OR (a_get_inactive_user = 0 AND U.active = 0)) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
-- guid,
|
||||
id_type,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
SELECT
|
||||
-- a_guid,
|
||||
v_id_type_error_bad_data,
|
||||
v_code_type_error_bad_data,
|
||||
CONCAT('Invalid or inactive user IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL'))
|
||||
FROM tmp_Split t_S
|
||||
LEFT JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user
|
||||
WHERE
|
||||
ISNULL(t_S.as_int)
|
||||
OR ISNULL(U.id_user)
|
||||
OR (
|
||||
a_get_inactive_user = 0
|
||||
AND U.active = 0
|
||||
)
|
||||
;
|
||||
ELSE
|
||||
/*
|
||||
SET a_ids_user = (
|
||||
SELECT U.id_user
|
||||
FROM tmp_Split t_S
|
||||
INNER JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user
|
||||
);
|
||||
SET v_has_filter_user = ISNULL(a_ids_user);
|
||||
*/
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Split) THEN
|
||||
INSERT INTO tmp_Split (substring, as_int)
|
||||
VALUES ( '', NULL );
|
||||
END IF;
|
||||
|
||||
IF a_debug = 1 THEN
|
||||
SELECT *
|
||||
FROM tmp_Split;
|
||||
END IF;
|
||||
|
||||
INSERT INTO tmp_User_Calc_User (
|
||||
id_user
|
||||
-- , id_access_level
|
||||
, is_super_user
|
||||
, priority_access_level
|
||||
)
|
||||
SELECT
|
||||
U.id_user
|
||||
, U.is_super_user
|
||||
-- , IFNULL(AL_U.id_access_level, v_id_access_level_view) AS id_access_level
|
||||
, IFNULL(MIN(AL_U.priority), v_priority_access_level_view) AS priority_access_level
|
||||
FROM tmp_Split t_S
|
||||
INNER JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user
|
||||
LEFT JOIN partsltd_prod.Shop_User_Role_Link URL
|
||||
ON U.id_user = URL.id_user
|
||||
AND URL.active
|
||||
LEFT JOIN partsltd_prod.Shop_Role_Permission_Link RPL
|
||||
ON URL.id_role = RPL.id_role
|
||||
AND RPL.active
|
||||
LEFT JOIN partsltd_prod.Shop_Access_Level AL_U
|
||||
ON RPL.id_access_level = AL_U.id_access_level
|
||||
AND AL_U.active
|
||||
GROUP BY U.id_user
|
||||
;
|
||||
|
||||
INSERT INTO tmp_Calc_User (
|
||||
id_user
|
||||
, id_permission_required
|
||||
, priority_access_level_required
|
||||
, id_product
|
||||
, is_super_user
|
||||
, priority_access_level_user
|
||||
)
|
||||
SELECT
|
||||
t_UCU.id_user
|
||||
, v_id_permission_required
|
||||
, v_priority_access_level AS priority_access_level_required
|
||||
, NULL
|
||||
, t_UCU.priority_access_level AS priority_access_level_user
|
||||
, t_UCU.is_super_user AS is_super_user
|
||||
FROM tmp_User_Calc_User t_UCU
|
||||
;
|
||||
|
||||
/*
|
||||
INSERT INTO tmp_Calc_User (
|
||||
id_user
|
||||
, id_permission_required
|
||||
, priority_access_level_required
|
||||
-- , id_product
|
||||
, priority_access_level_user
|
||||
, is_super_user
|
||||
)
|
||||
SELECT
|
||||
U.id_user
|
||||
, v_id_permission_required
|
||||
, v_priority_access_level AS priority_access_level_required
|
||||
-- , t_P.id_product
|
||||
, CASE WHEN MIN(IFNULL(AL_U.priority, 0)) = 0 THEN v_priority_access_level_view ELSE MIN(IFNULL(AL_U.priority, 0)) END AS priority_access_level_user
|
||||
, IFNULL(U.is_super_user, 0) AS is_super_user
|
||||
FROM tmp_Split t_S
|
||||
LEFT JOIN partsltd_prod.Shop_User U
|
||||
ON t_S.as_int = U.id_user
|
||||
AND U.active
|
||||
LEFT JOIN partsltd_prod.Shop_User_Role_Link URL
|
||||
ON U.id_user = URL.id_user
|
||||
AND URL.active
|
||||
LEFT JOIN partsltd_prod.Shop_Role_Permission_Link RPL
|
||||
ON URL.id_role = RPL.id_role
|
||||
AND RPL.active
|
||||
LEFT JOIN partsltd_prod.Shop_Access_Level AL_U
|
||||
ON RPL.id_access_level = AL_U.id_access_level
|
||||
AND AL_U.active
|
||||
*
|
||||
CROSS JOIN tmp_Product_Calc_User t_P
|
||||
LEFT JOIN partsltd_prod.Shop_Access_Level AL_P
|
||||
ON t_P.id_access_level_required = AL_P.id_access_level
|
||||
AND AL_P.active
|
||||
*
|
||||
GROUP BY t_S.as_int, U.id_user
|
||||
;
|
||||
*/
|
||||
|
||||
# SET v_has_filter_user = EXISTS ( SELECT * FROM tmp_User_Calc_User LIMIT 1 );
|
||||
END IF;
|
||||
DELETE FROM tmp_Split;
|
||||
|
||||
# Products
|
||||
IF v_has_filter_product = 1 THEN
|
||||
CALL partsltd_prod.p_split(a_guid, a_ids_product, ',', a_debug);
|
||||
|
||||
INSERT INTO tmp_Split (
|
||||
substring
|
||||
, as_int
|
||||
)
|
||||
SELECT
|
||||
substring
|
||||
, CONVERT(substring, DECIMAL(10,0)) AS as_int
|
||||
FROM Split_Temp
|
||||
WHERE 1=1
|
||||
AND GUID = a_guid
|
||||
AND NOT ISNULL(substring)
|
||||
AND substring != ''
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_clear_split_temp( a_guid );
|
||||
|
||||
# Invalid product IDs
|
||||
IF EXISTS (SELECT * FROM tmp_Split t_S LEFT JOIN partsltd_prod.Shop_Product P ON t_S.as_int = P.id_product WHERE ISNULL(t_S.as_int) OR ISNULL(P.id_product)) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
-- guid,
|
||||
id_type,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
SELECT
|
||||
-- a_guid,
|
||||
v_id_type_error_bad_data,
|
||||
v_code_type_error_bad_data,
|
||||
CONCAT('Invalid Product IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL'))
|
||||
FROM tmp_Split t_S
|
||||
LEFT JOIN partsltd_prod.Shop_Product P ON t_S.as_int = P.id_product
|
||||
WHERE
|
||||
ISNULL(t_S.as_int)
|
||||
OR ISNULL(P.id_product)
|
||||
OR P.active = 0
|
||||
;
|
||||
END IF;
|
||||
IF (EXISTS (SELECT * FROM tmp_Split)) THEN
|
||||
INSERT INTO tmp_Product_Calc_User (
|
||||
id_product,
|
||||
-- id_permutation,
|
||||
@@ -294,177 +492,35 @@ BEGIN
|
||||
);
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
DELETE FROM tmp_Split;
|
||||
|
||||
-- Permission IDs
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
IF v_has_filter_permission THEN
|
||||
CALL partsltd_prod.p_split(a_guid, a_ids_permission, ',', a_debug);
|
||||
|
||||
INSERT INTO tmp_Split (
|
||||
substring
|
||||
, as_int
|
||||
)
|
||||
SELECT
|
||||
substring
|
||||
, CONVERT(substring, DECIMAL(10,0)) AS as_int
|
||||
FROM Split_Temp
|
||||
WHERE 1=1
|
||||
AND GUID = a_guid
|
||||
AND NOT ISNULL(substring)
|
||||
AND substring != ''
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_clear_split_temp( a_guid );
|
||||
|
||||
# Invalid or inactive
|
||||
IF EXISTS (SELECT PERM.id_permission FROM tmp_Split t_S LEFT JOIN partsltd_prod.Shop_Permission PERM ON t_S.as_int = PERM.id_permission WHERE ISNULL(t_S.as_int) OR ISNULL(PERM.id_permission) OR PERM.active = 0) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
-- guid,
|
||||
id_type,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
SELECT
|
||||
-- a_guid,
|
||||
v_id_type_error_bad_data,
|
||||
v_code_type_error_bad_data,
|
||||
CONCAT('Invalid or inactive permission IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL'))
|
||||
FROM tmp_Split t_S
|
||||
LEFT JOIN partsltd_prod.Shop_Permission PERM ON t_S.as_int = PERM.id_permission
|
||||
WHERE
|
||||
ISNULL(t_S.as_int)
|
||||
OR ISNULL(PERM.id_permission)
|
||||
OR PERM.active = 0
|
||||
;
|
||||
ELSE
|
||||
SET v_id_permission_required := (
|
||||
SELECT PERM.id_permission
|
||||
FROM partsltd_prod.Shop_Permission PERM
|
||||
INNER JOIN partsltd_prod.Shop_Access_Level AL ON PERM.id_access_level_required = AL.id_access_level
|
||||
ORDER BY AL.priority ASC
|
||||
LIMIT 1
|
||||
);
|
||||
END IF;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
DELETE FROM tmp_Split;
|
||||
|
||||
IF a_debug = 1 THEN
|
||||
SELECT * FROM tmp_Product_Calc_User;
|
||||
END IF;
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
-- Invalid user ID
|
||||
CALL partsltd_prod.p_split(a_guid, a_ids_user, ',', a_debug);
|
||||
|
||||
INSERT INTO tmp_Split (
|
||||
substring
|
||||
, as_int
|
||||
)
|
||||
SELECT
|
||||
substring
|
||||
, CONVERT(substring, DECIMAL(10,0)) AS as_int
|
||||
FROM Split_Temp
|
||||
WHERE 1=1
|
||||
AND GUID = a_guid
|
||||
AND NOT ISNULL(substring)
|
||||
AND substring != ''
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_clear_split_temp( a_guid );
|
||||
|
||||
# Invalid or inactive
|
||||
IF EXISTS (SELECT U.id_user FROM tmp_Split t_S LEFT JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user WHERE ISNULL(t_S.as_int) OR ISNULL(U.id_user) OR U.active = 0) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
-- guid,
|
||||
id_type,
|
||||
code,
|
||||
msg
|
||||
)
|
||||
SELECT
|
||||
-- a_guid,
|
||||
v_id_type_error_bad_data,
|
||||
v_code_type_error_bad_data,
|
||||
CONCAT('Invalid or inactive user IDs: ', IFNULL(GROUP_CONCAT(t_S.substring SEPARATOR ', '), 'NULL'))
|
||||
FROM tmp_Split t_S
|
||||
LEFT JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user
|
||||
WHERE
|
||||
ISNULL(t_S.as_int)
|
||||
OR ISNULL(U.id_user)
|
||||
OR U.active = 0
|
||||
;
|
||||
ELSE
|
||||
/*
|
||||
SET a_ids_user = (
|
||||
SELECT U.id_user
|
||||
FROM tmp_Split t_S
|
||||
INNER JOIN partsltd_prod.Shop_User U ON t_S.as_int = U.id_user
|
||||
);
|
||||
SET v_has_filter_user = ISNULL(a_ids_user);
|
||||
*/
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Split) THEN
|
||||
INSERT INTO tmp_Split (substring, as_int)
|
||||
VALUES ( '', NULL );
|
||||
END IF;
|
||||
|
||||
IF a_debug = 1 THEN
|
||||
SELECT *
|
||||
FROM tmp_Split;
|
||||
END IF;
|
||||
|
||||
INSERT INTO tmp_Calc_User (
|
||||
id_user
|
||||
, id_permission_required
|
||||
, priority_access_level_required
|
||||
, id_product
|
||||
, priority_access_level_user
|
||||
, is_super_user
|
||||
)
|
||||
SELECT
|
||||
U.id_user
|
||||
, v_id_permission_required
|
||||
, CASE WHEN v_priority_access_level < AL_P.priority THEN v_priority_access_level ELSE AL_P.priority END AS priority_access_level_required
|
||||
, t_P.id_product
|
||||
, CASE WHEN MIN(IFNULL(AL_U.priority, 0)) = 0 THEN v_priority_access_level_view ELSE MIN(IFNULL(AL_U.priority, 0)) END AS priority_access_level_user
|
||||
, IFNULL(U.is_super_user, 0) AS is_super_user
|
||||
FROM tmp_Split t_S
|
||||
LEFT JOIN partsltd_prod.Shop_User U
|
||||
ON t_S.as_int = U.id_user
|
||||
AND U.active
|
||||
LEFT JOIN partsltd_prod.Shop_User_Role_Link URL
|
||||
ON U.id_user = URL.id_user
|
||||
AND URL.active
|
||||
LEFT JOIN partsltd_prod.Shop_Role_Permission_Link RPL
|
||||
ON URL.id_role = RPL.id_role
|
||||
AND RPL.active
|
||||
LEFT JOIN partsltd_prod.Shop_Access_Level AL_U
|
||||
ON RPL.id_access_level = AL_U.id_access_level
|
||||
AND AL_U.active
|
||||
CROSS JOIN tmp_Product_Calc_User t_P
|
||||
LEFT JOIN partsltd_prod.Shop_Access_Level AL_P
|
||||
ON t_P.id_access_level_required = AL_P.id_access_level
|
||||
AND AL_P.active
|
||||
GROUP BY t_S.as_int, U.id_user, t_P.id_product, AL_P.priority
|
||||
;
|
||||
|
||||
SET v_has_filter_user = EXISTS ( SELECT * FROM tmp_Calc_User LIMIT 1 );
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
DELETE FROM tmp_Split;
|
||||
INSERT INTO tmp_Calc_User (
|
||||
id_user
|
||||
, id_permission_required
|
||||
, priority_access_level_required
|
||||
, id_product
|
||||
, is_super_user
|
||||
, priority_access_level_user
|
||||
)
|
||||
SELECT
|
||||
t_U.id_user
|
||||
, v_id_permission_required
|
||||
, CASE WHEN AL.priority < v_priority_access_level THEN AL.priority ELSE v_priority_access_level END AS priority_access_level_required
|
||||
, t_P.id_product
|
||||
, t_U.priority_access_level AS priority_access_level_user
|
||||
, t_U.is_super_user AS is_super_user
|
||||
FROM tmp_User_Calc_User t_U
|
||||
CROSS JOIN tmp_Product_Calc_User t_P
|
||||
LEFT JOIN partsltd_prod.Shop_Access_Level AL ON t_P.id_access_level_required = AL.id_access_level
|
||||
;
|
||||
|
||||
-- Calculated fields
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
UPDATE tmp_Calc_User t_U
|
||||
SET
|
||||
t_U.can_view = t_U.is_super_user = 1 OR (t_U.priority_access_level_user <= v_priority_access_level_view AND t_U.priority_access_level_user <= t_U.priority_access_level_required)
|
||||
, t_U.can_edit = t_U.is_super_user = 1 OR (t_U.priority_access_level_user <= v_priority_access_level_edit AND t_U.priority_access_level_user <= t_U.priority_access_level_required)
|
||||
, t_U.can_admin = t_U.is_super_user = 1 OR (t_U.priority_access_level_user <= v_priority_access_level_admin AND t_U.priority_access_level_user <= t_U.priority_access_level_required)
|
||||
;
|
||||
END IF;
|
||||
UPDATE tmp_Calc_User t_CU
|
||||
SET
|
||||
t_CU.can_view = t_CU.is_super_user = 1 OR (t_CU.priority_access_level_user <= v_priority_access_level_view AND t_CU.priority_access_level_user <= t_CU.priority_access_level_required)
|
||||
, t_CU.can_edit = t_CU.is_super_user = 1 OR (t_CU.priority_access_level_user <= v_priority_access_level_edit AND t_CU.priority_access_level_user <= t_CU.priority_access_level_required)
|
||||
, t_CU.can_admin = t_CU.is_super_user = 1 OR (t_CU.priority_access_level_user <= v_priority_access_level_admin AND t_CU.priority_access_level_user <= t_CU.priority_access_level_required)
|
||||
;
|
||||
|
||||
-- Export data to staging table
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error) THEN
|
||||
@@ -500,6 +556,7 @@ BEGIN
|
||||
IF a_debug = 1 THEN
|
||||
SELECT * FROM tmp_Msg_Error;
|
||||
SELECT * FROM tmp_Calc_User;
|
||||
SELECT * FROM tmp_User_Calc_User;
|
||||
SELECT * FROM tmp_Product_Calc_User;
|
||||
SELECT * FROM partsltd_prod.Shop_Calc_User_Temp WHERE GUID = a_guid;
|
||||
CALL partsltd_prod.p_shop_clear_calc_user ( a_guid, a_debug );
|
||||
@@ -507,10 +564,11 @@ BEGIN
|
||||
|
||||
-- Clean up
|
||||
DROP TABLE IF EXISTS tmp_Calc_User;
|
||||
DROP TABLE IF EXISTS tmp_Shop_Calc_User;
|
||||
DROP TABLE IF EXISTS tmp_User_Calc_User;
|
||||
DROP TABLE IF EXISTS tmp_Product_Calc_User;
|
||||
DROP TABLE IF EXISTS tmp_Product_p_Shop_User_Eval_Temp;
|
||||
-- DROP TABLE IF EXISTS tmp_Split;
|
||||
# Don't destroy common tables in nested Stored Procedures!
|
||||
-- DROP TABLE IF EXISTS tmp_Split;
|
||||
DELETE FROM tmp_Split;
|
||||
|
||||
IF a_debug = 1 THEN
|
||||
CALL partsltd_prod.p_debug_timing_reporting( v_time_start );
|
||||
@@ -518,19 +576,20 @@ BEGIN
|
||||
END //
|
||||
DELIMITER ;;
|
||||
|
||||
/*
|
||||
/*
|
||||
|
||||
CALL partsltd_prod.p_shop_calc_user (
|
||||
'chips '
|
||||
, NULL
|
||||
, 1
|
||||
, 0
|
||||
, '2'
|
||||
, '1'
|
||||
, '1,2,3,4,5'
|
||||
, 0
|
||||
);
|
||||
|
||||
|
||||
SELECT * FROM partsltd_prod.Shop_Calc_User_Temp WHERE GUID = 'chips ';
|
||||
DELETE FROM partsltd_prod.Shop_Calc_User_Temp WHERE GUID = 'chips ';
|
||||
|
||||
|
||||
-- SELECT * FROM partsltd_prod.Shop_Calc_User_Temp;
|
||||
SELECT * FROM partsltd_prod.Shop_Calc_User_Temp WHERE GUID = 'chips ';
|
||||
|
||||
@@ -126,7 +126,7 @@ BEGIN
|
||||
SELECT
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following category(s) do not have a code: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg
|
||||
, CONCAT('The following Product Category(s) do not have a code: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Category t_C
|
||||
WHERE ISNULL(t_C.code)
|
||||
;
|
||||
@@ -141,7 +141,7 @@ BEGIN
|
||||
SELECT
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following category(s) do not have a name: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg
|
||||
, CONCAT('The following Product Category(s) do not have a name: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Category t_C
|
||||
WHERE ISNULL(t_C.name)
|
||||
;
|
||||
@@ -156,7 +156,7 @@ BEGIN
|
||||
SELECT
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, CONCAT('The following category(s) do not have a display order: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg
|
||||
, CONCAT('The following Product Category(s) do not have a display order: ', GROUP_CONCAT(t_C.name_error SEPARATOR ', ')) AS msg
|
||||
FROM tmp_Category t_C
|
||||
WHERE ISNULL(t_C.display_order)
|
||||
;
|
||||
@@ -165,7 +165,7 @@ BEGIN
|
||||
-- Permissions
|
||||
SET v_ids_product_permission := (
|
||||
SELECT GROUP_CONCAT(P.id_product SEPARATOR ',')
|
||||
FROM Shop_Product P
|
||||
FROM partsltd_prod.Shop_Product P
|
||||
INNER JOIN tmp_Category t_C
|
||||
ON P.id_category = t_C.id_category
|
||||
AND t_C.is_new = 0
|
||||
@@ -185,7 +185,7 @@ BEGIN
|
||||
;
|
||||
END IF;
|
||||
|
||||
CALL p_shop_calc_user(
|
||||
CALL partsltd_prod.p_shop_calc_user(
|
||||
a_guid
|
||||
, a_id_user
|
||||
, FALSE -- a_get_inactive_user
|
||||
@@ -196,8 +196,8 @@ BEGIN
|
||||
);
|
||||
|
||||
UPDATE tmp_Category t_C
|
||||
INNER JOIN Shop_Product P ON t_C.id_category = P.id_product
|
||||
INNER JOIN Shop_Calc_User_Temp UE_T
|
||||
INNER JOIN partsltd_prod.Shop_Product P ON t_C.id_category = P.id_product
|
||||
INNER JOIN partsltd_prod.Shop_Calc_User_Temp UE_T
|
||||
ON P.id_product = UE_T.id_product
|
||||
AND UE_T.GUID = a_guid
|
||||
SET
|
||||
@@ -205,8 +205,43 @@ BEGIN
|
||||
, t_C.can_edit = UE_T.can_edit
|
||||
, t_C.can_admin = UE_T.can_admin
|
||||
;
|
||||
|
||||
IF EXISTS (SELECT * FROM tmp_Category WHERE IFNULL(can_edit, 0) = 0 AND is_new = 0 LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
v_id_type_error_no_permission
|
||||
, v_code_type_error_no_permission
|
||||
, CONCAT('You do not have permission to edit the following Product Catogory(s): ', IFNULL(GROUP_CONCAT(IFNULL(t_C.name_error, 'NULL') SEPARATOR ', '), 'NULL'))
|
||||
FROM tmp_Category t_C
|
||||
WHERE
|
||||
IFNULL(can_edit, 0) = 0
|
||||
AND is_new = 0
|
||||
;
|
||||
END IF;
|
||||
|
||||
IF EXISTS (SELECT * FROM partsltd_prod.Shop_Calc_User_Temp WHERE ISNULL(id_product) AND GUID = a_guid AND can_edit = 0 LIMIT 1) THEN
|
||||
DELETE t_ME
|
||||
FROM tmp_Msg_Error t_ME
|
||||
WHERE t_ME.id_type <> v_id_type_error_no_permission
|
||||
;
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
VALUES (
|
||||
v_id_type_error_no_permission
|
||||
, v_code_type_error_no_permission
|
||||
, 'You do not have permission to edit Product Catogories.'
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
|
||||
CALL p_shop_clear_calc_user(
|
||||
CALL partsltd_prod.p_shop_clear_calc_user(
|
||||
a_guid
|
||||
, 0 -- a_debug
|
||||
);
|
||||
|
||||
@@ -216,60 +216,90 @@ BEGIN
|
||||
|
||||
|
||||
-- Permissions
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN -- (SELECT * FROM tmp_Product WHERE is_new = 0 LIMIT 1) THEN
|
||||
SET v_ids_product_permission := (SELECT GROUP_CONCAT(id_product SEPARATOR ',') FROM tmp_Product WHERE is_new = 0);
|
||||
IF NOT ISNULL(v_ids_product_permission) THEN
|
||||
SET v_id_permission_product = (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
|
||||
|
||||
CALL partsltd_prod.p_shop_calc_user(
|
||||
a_guid
|
||||
, a_id_user
|
||||
, FALSE -- get_inactive_users
|
||||
, v_id_permission_product
|
||||
, v_id_access_level_edit
|
||||
, v_ids_product_permission
|
||||
, 0 -- debug
|
||||
);
|
||||
|
||||
UPDATE tmp_Product t_P
|
||||
INNER JOIN Shop_Calc_User_Temp UE_T
|
||||
ON t_P.id_product = UE_T.id_product
|
||||
AND UE_T.GUID = a_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
|
||||
;
|
||||
|
||||
CALL partsltd_prod.p_shop_clear_calc_user(
|
||||
a_guid
|
||||
, 0 -- debug
|
||||
);
|
||||
END IF;
|
||||
SET v_ids_product_permission := (SELECT GROUP_CONCAT(id_product SEPARATOR ',') FROM tmp_Product WHERE is_new = 0);
|
||||
|
||||
SET v_id_permission_product = (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
|
||||
|
||||
CALL partsltd_prod.p_shop_calc_user(
|
||||
a_guid
|
||||
, a_id_user
|
||||
, FALSE -- get_inactive_users
|
||||
, v_id_permission_product
|
||||
, v_id_access_level_edit
|
||||
, v_ids_product_permission
|
||||
, 0 -- debug
|
||||
);
|
||||
|
||||
UPDATE tmp_Product t_P
|
||||
INNER JOIN partsltd_prod.Shop_Calc_User_Temp UE_T
|
||||
ON t_P.id_product = UE_T.id_product
|
||||
AND UE_T.GUID = a_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
|
||||
;
|
||||
|
||||
IF EXISTS (SELECT * FROM tmp_Product WHERE IFNULL(can_edit, 0) = 0 AND is_new = 0 LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
SELECT
|
||||
v_id_type_error_no_permission
|
||||
, v_code_type_error_no_permission
|
||||
, CONCAT('You do not have permission to edit the following Product(s): ', IFNULL(GROUP_CONCAT(IFNULL(t_P.name_error, 'NULL') SEPARATOR ', '), 'NULL'))
|
||||
FROM tmp_Product t_P
|
||||
WHERE
|
||||
IFNULL(can_edit, 0) = 0
|
||||
AND is_new = 0
|
||||
;
|
||||
END IF;
|
||||
|
||||
IF EXISTS (SELECT * FROM partsltd_prod.Shop_Calc_User_Temp WHERE ISNULL(id_product) AND GUID = a_guid AND can_edit = 0) THEN
|
||||
DELETE t_ME
|
||||
FROM tmp_Msg_Error t_ME
|
||||
WHERE t_ME.id_type <> v_id_type_error_no_permission
|
||||
;
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
VALUES (
|
||||
v_id_type_error_no_permission
|
||||
, v_code_type_error_no_permission
|
||||
, 'You do not have permission to edit Products'
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
|
||||
CALL partsltd_prod.p_shop_clear_calc_user(
|
||||
a_guid
|
||||
, 0 -- debug
|
||||
);
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN
|
||||
START TRANSACTION;
|
||||
IF NOT ISNULL(v_ids_product_permission) THEN
|
||||
INSERT INTO partsltd_prod.Shop_Product_Change_Set ( comment )
|
||||
VALUES ( a_comment )
|
||||
;
|
||||
|
||||
SET v_id_change_set := LAST_INSERT_ID();
|
||||
|
||||
UPDATE partsltd_prod.Shop_Product P
|
||||
INNER JOIN tmp_Product t_P ON P.id_product = t_P.id_product
|
||||
SET
|
||||
P.id_category = t_P.id_category
|
||||
, P.name = t_P.name
|
||||
, P.has_variations = t_P.has_variations
|
||||
, P.id_access_level_required = t_P.id_access_level_required
|
||||
, P.display_order = t_P.display_order
|
||||
, P.active = t_P.active
|
||||
, P.id_change_set = v_id_change_set
|
||||
;
|
||||
END IF;
|
||||
|
||||
INSERT INTO partsltd_prod.Shop_Product_Change_Set ( comment )
|
||||
VALUES ( a_comment )
|
||||
;
|
||||
|
||||
SET v_id_change_set := LAST_INSERT_ID();
|
||||
|
||||
UPDATE partsltd_prod.Shop_Product P
|
||||
INNER JOIN tmp_Product t_P ON P.id_product = t_P.id_product
|
||||
SET
|
||||
P.id_category = t_P.id_category
|
||||
, P.name = t_P.name
|
||||
, P.has_variations = t_P.has_variations
|
||||
, P.id_access_level_required = t_P.id_access_level_required
|
||||
, P.display_order = t_P.display_order
|
||||
, P.active = t_P.active
|
||||
, P.id_change_set = v_id_change_set
|
||||
;
|
||||
|
||||
INSERT INTO partsltd_prod.Shop_Product (
|
||||
id_category
|
||||
@@ -297,7 +327,7 @@ BEGIN
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
DELETE FROM partsltd_prod.Shop_Product_Category_Temp
|
||||
DELETE FROM partsltd_prod.Shop_Product_Temp
|
||||
WHERE GUID = a_guid;
|
||||
|
||||
COMMIT;
|
||||
|
||||
@@ -440,11 +440,6 @@ BEGIN
|
||||
LEFT JOIN Shop_Product P ON t_PP.id_product = P.id_product
|
||||
;
|
||||
END IF;
|
||||
|
||||
CALL p_shop_clear_calc_user(
|
||||
a_guid
|
||||
, 0 -- a_debug
|
||||
);
|
||||
|
||||
IF EXISTS (SELECT * FROM tmp_Permutation t_P WHERE ISNULL(t_P.can_edit) LIMIT 1) THEN
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
@@ -461,13 +456,36 @@ BEGIN
|
||||
ISNULL(t_P.can_edit)
|
||||
;
|
||||
END IF;
|
||||
|
||||
IF EXISTS (SELECT * FROM partsltd_prod.Shop_User_Eval_Temp WHERE ISNULL(id_product) AND GUID = a_guid AND can_edit = 0) THEN
|
||||
DELETE FROM tmp_Msg_Error
|
||||
WHERE id_type <> v_id_type_error_no_permission
|
||||
;
|
||||
|
||||
IF a_debug = 1 THEN
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Product_Permutation_Variation_Link_Temp
|
||||
WHERE GUID = a_guid
|
||||
;
|
||||
END IF;
|
||||
INSERT INTO tmp_Msg_Error (
|
||||
id_type
|
||||
, code
|
||||
, msg
|
||||
)
|
||||
VALUES (
|
||||
v_id_type_error_bad_data
|
||||
, v_code_type_error_bad_data
|
||||
, 'You do not have permission to edit Product Permutations'
|
||||
)
|
||||
;
|
||||
END IF;
|
||||
|
||||
CALL p_shop_clear_calc_user(
|
||||
a_guid
|
||||
, 0 -- a_debug
|
||||
);
|
||||
|
||||
IF a_debug = 1 THEN
|
||||
SELECT *
|
||||
FROM partsltd_prod.Shop_Product_Permutation_Variation_Link_Temp
|
||||
WHERE GUID = a_guid
|
||||
;
|
||||
END IF;
|
||||
|
||||
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN
|
||||
START TRANSACTION;
|
||||
|
||||
@@ -40,6 +40,15 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_COLUMN }}">
|
||||
<div class="{{ model.FLAG_CONTAINER_INPUT }} {{ model.FLAG_ROW }} {{ model.FLAG_FILTER }}">
|
||||
{{ model.form_filters.active.label }}
|
||||
{{ model.form_filters.active() }}
|
||||
{% for error in model.form_filters.active.errors %}
|
||||
<p class="error">{{ error }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="{{ model.FLAG_CONTAINER }} {{ model.FLAG_COLUMN }}">
|
||||
<div class="{{ model.FLAG_CONTAINER_INPUT }} {{ model.FLAG_ROW }} {{ model.FLAG_FILTER }}">
|
||||
{{ model.form_filters.quantity_min.label }}
|
||||
|
||||
Reference in New Issue
Block a user