Fix: Product Category save + filter debugging.

This commit is contained in:
2024-11-18 14:02:23 +00:00
parent 3f47af3b02
commit fd4dae0f8f
36 changed files with 47125 additions and 331 deletions

21301
static/MySQL/0000_combine.sql Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -100,7 +100,7 @@ BEGIN
, is_new
)
SELECT
IFNULL(PC_T.id_category, PC.id_category) AS id_category
PC_T.id_category AS id_category
, IFNULL(PC_T.code, PC.code) AS code
, IFNULL(PC_T.name, PC.code) AS name
, IFNULL(PC_T.description, PC.description) AS description
@@ -109,8 +109,8 @@ BEGIN
, IFNULL(PC_T.display_order, PC.display_order) AS display_order
, IFNULL(PC_T.name, IFNULL(PC.name, IFNULL(PC_T.code, IFNULL(PC.code, IFNULL(PC_T.id_category, '(No Product Category)'))))) AS name_error
, CASE WHEN IFNULL(PC_T.id_category, 0) < 1 THEN 1 ELSE 0 END AS is_new
FROM Shop_Product_Category_Temp PC_T
LEFT JOIN Shop_Product_Category PC ON PC_T.id_category = PC.id_category
FROM partsltd_prod.Shop_Product_Category_Temp PC_T
LEFT JOIN partsltd_prod.Shop_Product_Category PC ON PC_T.id_category = PC.id_category
WHERE PC_T.guid = a_guid
;
@@ -163,59 +163,79 @@ BEGIN
END IF;
-- 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(P.id_product SEPARATOR ',')
FROM Shop_Product P
INNER JOIN tmp_Category t_C
ON P.id_category = t_C.id_category
AND t_C.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 p_shop_calc_user(a_guid, a_id_user, FALSE, v_id_permission_product, v_id_access_level_edit, v_ids_product_permission);
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
ON P.id_product = UE_T.id_product
AND UE_T.GUID = a_guid
SET
t_C.can_view = UE_T.can_view
, t_C.can_edit = UE_T.can_edit
, t_C.can_admin = UE_T.can_admin
;
CALL p_shop_clear_calc_user(a_guid);
END IF;
SET v_ids_product_permission := (
SELECT GROUP_CONCAT(P.id_product SEPARATOR ',')
FROM Shop_Product P
INNER JOIN tmp_Category t_C
ON P.id_category = t_C.id_category
AND t_C.is_new = 0
WHERE P.active = 1
);
SET v_id_permission_product = (SELECT id_permission FROM Shop_Permission WHERE code = 'STORE_PRODUCT' LIMIT 1);
IF a_debug = 1 THEN
SELECT
a_guid
, a_id_user
, FALSE -- a_get_inactive_user
, v_id_permission_product
, v_id_access_level_edit
, v_ids_product_permission
, 0 -- a_debug
;
END IF;
CALL p_shop_calc_user(
a_guid
, a_id_user
, FALSE -- a_get_inactive_user
, v_id_permission_product
, v_id_access_level_edit
, v_ids_product_permission
, 0 -- a_debug
);
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
ON P.id_product = UE_T.id_product
AND UE_T.GUID = a_guid
SET
t_C.can_view = UE_T.can_view
, t_C.can_edit = UE_T.can_edit
, t_C.can_admin = UE_T.can_admin
;
CALL p_shop_clear_calc_user(
a_guid
, 0 -- a_debug
);
IF NOT EXISTS (SELECT * FROM tmp_Msg_Error LIMIT 1) THEN
START TRANSACTION;
INSERT INTO partsltd_prod.Shop_Product_Change_Set ( comment )
VALUES ( a_comment )
;
IF NOT ISNULL(v_ids_product_permission) THEN
INSERT INTO Shop_Product_Change_Set ( comment )
VALUES ( a_comment )
;
SET v_id_change_set := LAST_INSERT_ID();
UPDATE Shop_Product_Category PC
INNER JOIN tmp_Category t_C ON PC.id_category = t_C.id_category
SET
PC.id_category = t_C.id_category
, PC.code = t_C.code
, PC.name = t_C.name
, PC.description = t_C.description
, PC.id_access_level_required = t_C.id_access_level_required
, PC.active = t_C.active
, PC.display_order = t_C.display_order
, PC.id_change_set = v_id_change_set
;
END IF;
SET v_id_change_set := LAST_INSERT_ID();
INSERT INTO Shop_Product_Category (
UPDATE partsltd_prod.Shop_Product_Category PC
INNER JOIN tmp_Category t_C
ON PC.id_category = t_C.id_category
AND t_C.is_new = 0
SET
PC.id_category = t_C.id_category
, PC.code = t_C.code
, PC.name = t_C.name
, PC.description = t_C.description
, PC.id_access_level_required = t_C.id_access_level_required
, PC.active = t_C.active
, PC.display_order = t_C.display_order
, PC.id_change_set = v_id_change_set
;
INSERT INTO partsltd_prod.Shop_Product_Category (
code
, name
, description
@@ -236,15 +256,20 @@ BEGIN
, a_id_user AS created_by
, v_time_start AS created_on
FROM tmp_Category t_C
WHERE is_new = 1
AND active = 1
WHERE
t_C.is_new = 1
AND t_C.active = 1
;
DELETE FROM Shop_Product_Category_Temp
WHERE GUID = a_guid;
COMMIT;
END IF;
START TRANSACTION;
DELETE FROM partsltd_prod.Shop_Product_Category_Temp
WHERE GUID = a_guid;
COMMIT;
# Errors
SELECT *
@@ -253,10 +278,10 @@ BEGIN
;
IF a_debug = 1 THEN
SELECT * from tmp_Catgory;
SELECT * from tmp_Category;
END IF;
DROP TEMPORARY TABLE tmp_Catgory;
DROP TEMPORARY TABLE tmp_Category;
DROP TEMPORARY TABLE tmp_Msg_Error;
IF a_debug = 1 THEN
@@ -265,3 +290,27 @@ BEGIN
END //
DELIMITER ;;
/*
select
*
-- COUNT(*)
-- delete
from partsltd_prod.Shop_Product_Category_Temp
;
CALL partsltd_prod.p_shop_save_product_category (
'nipples'
, (SELECT GUID FROM partsltd_prod.Shop_Product_Category_Temp ORDER BY id_temp DESC LIMIT 1)
, 1
, 1
);
select
*
-- COUNT(*)
-- delete
from partsltd_prod.Shop_Product_Category_Temp
;
*/

View File

@@ -291,11 +291,16 @@ BEGIN
FROM tmp_Product t_P
WHERE is_new = 1
;
DELETE FROM partsltd_prod.Shop_Product_Category_Temp
WHERE GUID = a_guid;
COMMIT;
END IF;
START TRANSACTION;
DELETE FROM partsltd_prod.Shop_Product_Category_Temp
WHERE GUID = a_guid;
COMMIT;
SELECT *
FROM tmp_Msg_Error t_ME

View File

@@ -604,8 +604,11 @@ BEGIN
, PPVL.active = t_PPVL.active
, PPVL.id_change_set = v_id_change_set
;
END IF;
COMMIT;
END IF;
START TRANSACTION;
DELETE FROM Shop_Product_Permutation_Temp
WHERE GUID = a_guid

View File

@@ -511,18 +511,22 @@ BEGIN
, V.id_change_set = v_id_change_set
;
DELETE VT_T
FROM partsltd_prod.Shop_Variation_Type_Temp VT_T
WHERE VT_T.GUID = a_guid
;
DELETE V_T
FROM partsltd_prod.Shop_Variation_Temp V_T
WHERE V_T.GUID = a_guid
;
COMMIT;
END IF;
START TRANSACTION;
DELETE VT_T
FROM partsltd_prod.Shop_Variation_Type_Temp VT_T
WHERE VT_T.GUID = a_guid
;
DELETE V_T
FROM partsltd_prod.Shop_Variation_Temp V_T
WHERE V_T.GUID = a_guid
;
COMMIT;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME

View File

@@ -590,12 +590,16 @@ BEGIN
AND active = 1
;
DELETE FROM partsltd_prod.Shop_Stock_Item_Temp
WHERE GUID = a_guid;
COMMIT;
END IF;
START TRANSACTION;
DELETE FROM partsltd_prod.Shop_Stock_Item_Temp
WHERE GUID = a_guid;
COMMIT;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME

View File

@@ -247,13 +247,17 @@ BEGIN
, U.active = t_U.active
, U.id_change_set = v_id_change_set
;
DELETE FROM Shop_User_Temp
WHERE GUID = a_guid;
COMMIT;
END IF;
START TRANSACTION;
DELETE FROM Shop_User_Temp
WHERE GUID = a_guid;
COMMIT;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME

View File

@@ -558,6 +558,13 @@ BEGIN
COMMIT;
END IF;
START TRANSACTION;
DELETE FROM partsltd_prod.Shop_Supplier_Temp
WHERE GUID = a_guid;
DELETE FROM partsltd_prod.Shop_Supplier_Address_Temp
WHERE GUID = a_guid;
COMMIT;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME

View File

@@ -755,19 +755,23 @@ BEGIN
, SPOPL.cost_unit_local_VAT_incl = t_SPOPL.cost_unit_local_VAT_incl
, SPOPL.id_change_set = v_id_change_set
;
DELETE SPO_T
FROM Shop_Supplier_Purchase_Order_Temp SPO_T
WHERE SPO_T.GUID = a_guid
;
DELETE SPOPL_T
FROM Shop_Supplier_Purchase_Order_Product_Link_Temp SPOPL_T
WHERE SPOPL_T.GUID = a_guid
;
COMMIT;
END IF;
START TRANSACTION;
DELETE SPO_T
FROM Shop_Supplier_Purchase_Order_Temp SPO_T
WHERE SPO_T.GUID = a_guid
;
DELETE SPOPL_T
FROM Shop_Supplier_Purchase_Order_Product_Link_Temp SPOPL_T
WHERE SPOPL_T.GUID = a_guid
;
COMMIT;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME

View File

@@ -920,19 +920,23 @@ BEGIN
, MPOPL.price_unit_local_VAT_incl = t_MPOPL.price_unit_local_VAT_incl
, MPOPL.id_change_set = v_id_change_set
;
DELETE MPO_T
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Temp MPO_T
WHERE MPO_T.GUID = a_guid
;
DELETE MPOPL_T
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Temp MPOPL_T
WHERE MPOPL_T.GUID = a_guid
;
COMMIT;
END IF;
START TRANSACTION;
DELETE MPO_T
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Temp MPO_T
WHERE MPO_T.GUID = a_guid
;
DELETE MPOPL_T
FROM partsltd_prod.Shop_Manufacturing_Purchase_Order_Product_Link_Temp MPOPL_T
WHERE MPOPL_T.GUID = a_guid
;
COMMIT;
# Errors
SELECT *
FROM tmp_Msg_Error t_ME

221
static/MySQL/temp.txt Normal file
View File

@@ -0,0 +1,221 @@
0001_destroy.sql
1000_tbl_Shop_Product_Change_Set.sql
1000_tbl_Split_Temp.sql
1001_tbl_Shop_User_Change_Set.sql
1001_tbl_Split_Key_Value_Pair_Csv_Temp.sql
1002_tbl_Shop_Sales_And_Purchasing_Change_Set.sql
1003_tbl_Shop_Access_Level.sql
1004_tbl_Shop_Access_Level_Audit.sql
1005_tbl_Msg_Error_Type.sql
1010_tbl_File_Type.sql
1011_tbl_File_Type_Audit.sql
1012_tbl_Shop_General.sql
1013_tbl_Shop_General_Audit.sql
1014_tbl_Shop_Image_Type.sql
1015_tbl_Shop_Image_Type_Audit.sql
1100_tbl_Shop_Region.sql
1101_tbl_Shop_Region_Audit.sql
1102_tbl_Shop_Region_Temp.sql
1103_tbl_Shop_Region_Branch.sql
1104_tbl_Shop_Region_Branch_Audit.sql
1105_tbl_Shop_Region_Branch_Temp.sql
1106_tbl_Shop_Address.sql
1106_tbl_Shop_Plant.sql
1107_tbl_Shop_Address_Audit.sql
1107_tbl_Shop_Plant_Audit.sql
1108_tbl_Shop_Plant_Temp.sql
1109_tbl_Shop_Storage_Location.sql
1110_tbl_Shop_Storage_Location_Audit.sql
1111_tbl_Shop_Storage_Location_Temp.sql
1112_tbl_Shop_Storage_Location_Branch.sql
1113_tbl_Shop_Storage_Location_Branch_Audit.sql
1114_tbl_Shop_Storage_Location_Branch_Temp.sql
1115_tbl_Shop_Currency.sql
1116_tbl_Shop_Currency_Audit.sql
1117_tbl_Shop_Currency_Temp.sql
1118_tbl_Shop_Tax_Or_Surcharge.sql
1119_tbl_Shop_Tax_Or_Surcharge_Audit.sql
1120_tbl_Shop_Tax_Or_Surcharge_Temp.sql
1121_tbl_Shop_Unit_Measurement.sql
1122_tbl_Shop_Unit_Measurement_Audit.sql
1124_tbl_Shop_Unit_Measurement_Conversion.sql
1125_tbl_Shop_Unit_Measurement_Conversion_Audit.sql
1200_tbl_Shop_Product_Category.sql
1201_tbl_Shop_Product_Category_Audit.sql
1202_tbl_Shop_Product_Category_Temp.sql
1203_tbl_Shop_Product.sql
1204_tbl_Shop_Product_Audit.sql
1205_tbl_Shop_Product_Temp.sql
1206_tbl_Shop_Product_Permutation.sql
1207_tbl_Shop_Product_Permutation_Audit.sql
1208_tbl_Shop_Product_Permutation_Temp.sql
1209_tbl_Shop_Variation_Type.sql
1210_tbl_Shop_Variation_Type_Audit.sql
1211_tbl_Shop_Variation_Type_Temp.sql
1212_tbl_Shop_Variation.sql
1213_tbl_Shop_Variation_Audit.sql
1214_tbl_Shop_Variation_Temp.sql
1215_tbl_Shop_Product_Permutation_Variation_Link.sql
1216_tbl_Shop_Product_Permutation_Variation_Link_Audit.sql
1217_tbl_Shop_Product_Permutation_Variation_Link_Temp.sql
1218_tbl_Shop_Stock_Item.sql
1219_tbl_Shop_Stock_Item_Audit.sql
1220_tbl_Shop_Stock_Item_Temp.sql
1221_tbl_Shop_Product_Price.sql
1222_tbl_Shop_Product_Price_Audit.sql
1223_tbl_Shop_Product_Price_Temp.sql
1224_tbl_Shop_Product_Image.sql
1225_tbl_Shop_Product_Image_Audit.sql
1227_tbl_Shop_Delivery_Option.sql
1228_tbl_Shop_Delivery_Option_Audit.sql
1230_tbl_Shop_Product_Permutation_Delivery_Option_Link.sql
1231_tbl_Shop_Product_Permutation_Delivery_Option_Link_Audit.sql
1233_tbl_Shop_Discount.sql
1234_tbl_Shop_Discount_Audit.sql
1236_tbl_Shop_Discount_Region_Currency_Link.sql
1237_tbl_Shop_Discount_Region_Currency_Link_Audit.sql
1300_tbl_Shop_Permission_Group.sql
1301_tbl_Shop_Permission_Group_Audit.sql
1303_tbl_Shop_Permission.sql
1304_tbl_Shop_Permission_Audit.sql
1306_tbl_Shop_Role.sql
1307_tbl_Shop_Role_Audit.sql
1309_tbl_Shop_Role_Permission_Link.sql
1310_tbl_Shop_Role_Permission_Link_Audit.sql
1312_tbl_Shop_User.sql
1313_tbl_Shop_User_Audit.sql
1315_tbl_Shop_User_Role_Link.sql
1316_tbl_Shop_User_Role_Link_Audit.sql
1318_tbl_Shop_User_Address.sql
1319_tbl_Shop_User_Address_Audit.sql
1321_tbl_Shop_User_Basket.sql
1322_tbl_Shop_User_Basket_Audit.sql
1397_tbl_Shop_Order_Status.sql
1398_tbl_Shop_Order_Status_Audit.sql
1400_tbl_Shop_Supplier.sql
1401_tbl_Shop_Supplier_Audit.sql
1402_tbl_Shop_Supplier_Temp.sql
1403_tbl_Shop_Supplier_Address.sql
1404_tbl_Shop_Supplier_Address_Audit.sql
1405_tbl_Shop_Supplier_Address_Temp.sql
1409_tbl_Shop_Supplier_Purchase_Order.sql
1410_tbl_Shop_Supplier_Purchase_Order_Audit.sql
1411_tbl_Shop_Supplier_Purchase_Order_Temp.sql
1412_tbl_Shop_Supplier_Purchase_Order_Product_Link.sql
1413_tbl_Shop_Supplier_Purchase_Order_Product_Link_Audit.sql
1414_tbl_Shop_Supplier_Purchase_Order_Product_Link_Temp.sql
1415_tbl_Shop_Manufacturing_Purchase_Order.sql
1416_tbl_Shop_Manufacturing_Purchase_Order_Audit.sql
1417_tbl_Shop_Manufacturing_Purchase_Order_Temp.sql
1418_tbl_Shop_Manufacturing_Purchase_Order_Product_Link.sql
1419_tbl_Shop_Manufacturing_Purchase_Order_Product_Link_Audit.sql
1420_tbl_Shop_Manufacturing_Purchase_Order_Product_Link_Temp.sql
1421_tbl_Shop_Customer.sql
1422_tbl_Shop_Customer_Audit.sql
1424_tbl_Shop_Customer_Sales_Order.sql
1425_tbl_Shop_Customer_Sales_Order_Audit.sql
1427_tbl_Shop_Customer_Sales_Order_Product_Link.sql
1428_tbl_Shop_Customer_Sales_Order_Product_Link_Audit.sql
1429_tbl_Shop_Customer_Sales_Order_Product_Link_Temp.sql
1500_tbl_Shop_Calc_User_Temp.sql
3000_tri_Shop_Access_Level.sql
3000_tri_Shop_Product_Change_Set.sql
3001_tri_Shop_User_Change_Set.sql
3002_tri_Shop_Sales_And_Purchasing_Change_Set.sql
3010_tri_File_Type.sql
3011_tri_File_Type_Audit.sql
3012_tri_Shop_General.sql
3014_tri_Shop_Image_Type.sql
3100_tri_Shop_Region.sql
3103_tri_Shop_Region_Branch.sql
3106_tri_Shop_Address.sql
3109_tri_Shop_Storage_Location.sql
3115_tri_Shop_Currency.sql
3118_tri_Shop_Tax_Or_Surcharge.sql
3200_tri_Shop_Category.sql
3203_tri_Shop_Product.sql
3206_tri_Shop_Product_Permutation.sql
3209_tri_Shop_Variation_Type.sql
3212_tri_Shop_Variation.sql
3215_tri_Shop_Product_Permutation_Variation_Link.sql
3218_tri_Shop_Stock_Item.sql
3221_tri_Shop_Product_Price.sql
3224_tri_Shop_Product_Image.sql
3227_tri_Shop_Delivery_Option.sql
3230_tri_Shop_Product_Permutation_Delivery_Option_Link.sql
3233_tri_Shop_Discount.sql
3236_tri_Shop_Discount_Region_Currency_Link.sql
3300_tri_Shop_Permission_Group.sql
3303_tri_Shop_Permission.sql
3306_tri_Shop_Role.sql
3309_tri_Shop_Role_Permission_Link.sql
3312_tri_Shop_User.sql
3315_tri_Shop_User_Role_Link.sql
3318_tri_Shop_User_Address.sql
3321_tri_Shop_User_Basket.sql
3324_tri_Shop_User_Order_Status.sql
3400_tri_Shop_Supplier.sql
3403_tri_Shop_Supplier_Address.sql
3403_tri_Shop_Unit_Measurement.sql
3406_tri_Shop_Unit_Of_Measurement_Conversion.sql
3409_tri_Shop_Supplier_Purchase_Order.sql
3412_tri_Shop_Supplier_Purchase_Order_Product_Link.sql
3415_tri_Shop_Manufacturing_Purchase_Order.sql
3418_tri_Shop_Manufacturing_Purchase_Order_Product_Link.sql
3421_tri_Shop_Customer.sql
3424_tri_Shop_Customer_Sales_Order.sql
3427_tri_Shop_Customer_Sales_Order_Product_Link.sql
6000_p_debug_timing_reporting.sql
6000_p_split.sql
6001_p_clear_split_temp.sql
6001_p_validate_guid.sql
6003_p_split_key_value_pair_csv.sql
6004_p_clear_split_key_value_pair_csv_temp.sql
6206_fn_shop_get_product_permutation_name.sql
6210_fn_shop_get_id_product_permutation_from_variation_csv_list.sql
6211_fn_shop_get_product_variations_from_id_csv_list.sql
6500_p_shop_calc_user.sql
6501_p_shop_clear_calc_user.sql
7003_p_shop_get_many_access_level.sql
7101_p_shop_get_many_region.sql
7106_p_shop_get_many_plant.sql
7109_p_shop_get_many_storage_location.sql
7116_p_shop_get_many_currency.sql
7122_p_shop_get_many_unit_measurement.sql
7200_p_shop_save_product_category.sql
7200_p_shop_save_product_category_test.sql
7202_p_shop_clear_calc_product_permutation.sql
7203_p_shop_save_product.sql
7203_p_shop_save_product_test.sql
7204_p_shop_calc_product_permutation.sql
7204_p_shop_get_many_product.sql
7205_p_shop_get_many_stripe_product_new.sql
7206_p_shop_save_product_permutation.sql
7206_p_shop_save_product_permutation_test.sql
7210_p_shop_get_many_product_variation.sql
7212_p_shop_save_product_variation.sql
7212_p_shop_save_product_variation_test.sql
7219_p_shop_get_many_stock_item.sql
7220_p_shop_save_stock_item.sql
7220_p_shop_save_stock_item_test.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
7321_p_shop_save_user_basket.sql
7400_p_shop_save_supplier.sql
7400_p_shop_save_supplier_temp.sql
7401_p_shop_get_many_supplier.sql
7403_p_shop_save_supplier_purchase_order.sql
7403_p_shop_save_supplier_purchase_order_test.sql
7404_p_shop_get_many_supplier_purchase_order.sql
7415_p_shop_save_manufacturing_purchase_order.sql
7415_p_shop_save_Manufacturing_purchase_order_test.sql
7416_p_shop_get_many_manufacturing_purchase_order.sql
7421_p_shop_save_customer.sql
7422_p_shop_get_many_customer.sql
7424_p_shop_save_customer_sales_order.sql
7425_p_shop_get_many_customer_sales_order.sql
9000_populate.sql
9001_view.sql
9010_anal.sql